GeezerVison is showing github.com — 完成自主开发的DropboxHeader · StandOpen/SmartRefreshLayout@be1dad3
File treeExpand file treeCollapse file tree Open diff view settings java/com/scwang/refreshlayout
refresh-header/src/main/java/com/scwang/smartrefresh/header refresh-layout/src/main/java/com/scwang/smartrefresh/layout/internal/pathview
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: app/build.gradle +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -34,6 +34,7 @@ dependencies { | 34 | 34 | compile project(':refresh-header') | 35 | 35 | compile project(':refresh-layout') | 36 | 36 | compile 'com.android.support:appcompat-v7:25.3.1' | | 37 | + compile 'com.android.support:cardview-v7:25.3.1' | 37 | 38 | compile 'com.android.support:design:25.3.1' | 38 | 39 | compile 'com.android.support:support-v4:25.3.1' | 39 | 40 | compile 'com.android.support:support-vector-drawable:25.3.1' | |
Collapse file Copy file name to clipboardExpand all lines: app/src/main/AndroidManifest.xml +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 80 | 80 | android:name=".activity.style.DropboxStyleActivity" | 81 | 81 | android:label="@string/title_activity_style_dropbox" | 82 | 82 | android:screenOrientation="portrait" /> | | 83 | + <activity | | 84 | + android:name=".activity.style.DeliveryStyleActivity" | | 85 | + android:label="@string/title_activity_style_dropbox" | | 86 | + android:screenOrientation="portrait" /> | 83 | 87 | <activity | 84 | 88 | android:name=".activity.using.BasicUsingActivity" | 85 | 89 | android:label="@string/title_activity_using_basic" | |
Collapse file Copy file name to clipboard +69Lines changed: 69 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +package com.scwang.refreshlayout.activity.style; | | 2 | + | | 3 | +import android.os.Build; | | 4 | +import android.os.Bundle; | | 5 | +import android.support.v7.app.AppCompatActivity; | | 6 | +import android.support.v7.widget.DefaultItemAnimator; | | 7 | +import android.support.v7.widget.LinearLayoutManager; | | 8 | +import android.support.v7.widget.RecyclerView; | | 9 | +import android.support.v7.widget.Toolbar; | | 10 | +import android.view.View; | | 11 | +import android.view.Window; | | 12 | + | | 13 | +import com.scwang.refreshlayout.R; | | 14 | +import com.scwang.refreshlayout.adapter.BaseRecyclerAdapter; | | 15 | +import com.scwang.refreshlayout.adapter.SmartViewHolder; | | 16 | +import com.scwang.smartrefresh.layout.api.RefreshLayout; | | 17 | + | | 18 | +import static com.scwang.refreshlayout.R.layout.listitem_delivery; | | 19 | + | | 20 | +public class DeliveryStyleActivity extends AppCompatActivity { | | 21 | + | | 22 | + private Toolbar mToolbar; | | 23 | + private RefreshLayout mRefreshLayout; | | 24 | + private static boolean isFirstEnter = true; | | 25 | + | | 26 | + @Override | | 27 | + protected void onCreate(Bundle savedInstanceState) { | | 28 | + super.onCreate(savedInstanceState); | | 29 | + setContentView(R.layout.activity_style_delivery); | | 30 | + if (Build.VERSION.SDK_INT >= 21) { | | 31 | + getWindow().setStatusBarColor(0xfff0f0f0); | | 32 | + } | | 33 | + if (Build.VERSION.SDK_INT >= 23) { | | 34 | + Window window = getWindow(); | | 35 | + int systemUiVisibility = window.getDecorView().getSystemUiVisibility(); | | 36 | + systemUiVisibility |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; | | 37 | + window.getDecorView().setSystemUiVisibility(systemUiVisibility); | | 38 | + } | | 39 | + | | 40 | + mToolbar = (Toolbar)findViewById(R.id.toolbar); | | 41 | + mToolbar.setNavigationOnClickListener(new View.OnClickListener() { | | 42 | + @Override | | 43 | + public void onClick(View v) { | | 44 | + finish(); | | 45 | + } | | 46 | + }); | | 47 | + | | 48 | + mRefreshLayout = (RefreshLayout)findViewById(R.id.smart); | | 49 | + if (isFirstEnter) { | | 50 | + isFirstEnter = false; | | 51 | + mRefreshLayout.autoRefresh();//第一次进入触发自动刷新,演示效果 | | 52 | + } | | 53 | + | | 54 | + View view = findViewById(R.id.recycler); | | 55 | + if (view instanceof RecyclerView) { | | 56 | + RecyclerView recyclerView = (RecyclerView) view; | | 57 | + recyclerView.setLayoutManager(new LinearLayoutManager(this)); | | 58 | + recyclerView.setItemAnimator(new DefaultItemAnimator()); | | 59 | + recyclerView.setAdapter(new BaseRecyclerAdapter<Void>(listitem_delivery) { | | 60 | + public int getItemCount() { | | 61 | + return 30; | | 62 | + } | | 63 | + protected void onBindViewHolder(SmartViewHolder holder, Void model, int position) { | | 64 | + } | | 65 | + }); | | 66 | + } | | 67 | + } | | 68 | + | | 69 | +} |
Collapse file Copy file name to clipboardExpand all lines: app/src/main/java/com/scwang/refreshlayout/adapter/BaseRecyclerAdapter.java +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -56,7 +56,7 @@ public SmartViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | 56 | 56 |
| 57 | 57 | @Override | 58 | 58 | public void onBindViewHolder(SmartViewHolder holder, int position) { | 59 | | - onBindViewHolder(holder, mList.get(position), position); | | 59 | + onBindViewHolder(holder, position < mList.size() ? mList.get(position) : null, position); | 60 | 60 | } | 61 | 61 |
| 62 | 62 | protected abstract void onBindViewHolder(SmartViewHolder holder, T model, int position); | |
Collapse file Copy file name to clipboardExpand all lines: app/src/main/java/com/scwang/refreshlayout/adapter/SmartViewHolder.java +9Lines changed: 9 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | package com.scwang.refreshlayout.adapter; | 2 | 2 |
| 3 | 3 | import android.content.res.Resources; | | 4 | +import android.support.annotation.StringRes; | 4 | 5 | import android.support.v4.content.ContextCompat; | 5 | 6 | import android.support.v7.widget.RecyclerView; | 6 | 7 | import android.util.TypedValue; | @@ -53,6 +54,14 @@ public SmartViewHolder text(int id, CharSequence sequence) { | 53 | 54 | return this; | 54 | 55 | } | 55 | 56 |
| | 57 | + public SmartViewHolder text(int id,@StringRes int stringRes) { | | 58 | + View view = findViewById(id); | | 59 | + if (view instanceof TextView) { | | 60 | + ((TextView) view).setText(stringRes); | | 61 | + } | | 62 | + return this; | | 63 | + } | | 64 | + | 56 | 65 | public SmartViewHolder textColorId(int id, int colorId) { | 57 | 66 | View view = findViewById(id); | 58 | 67 | if (view instanceof TextView) { | |
Collapse file Copy file name to clipboardExpand all lines: app/src/main/java/com/scwang/refreshlayout/fragment/RefreshStylesFragment.java +20-17Lines changed: 20 additions & 17 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 6 | 6 | import android.content.Intent; | 7 | 7 | import android.os.Bundle; | 8 | 8 | import android.support.annotation.Nullable; | | 9 | +import android.support.annotation.StringRes; | 9 | 10 | import android.support.v4.app.Fragment; | 10 | 11 | import android.support.v7.widget.DefaultItemAnimator; | 11 | 12 | import android.support.v7.widget.DividerItemDecoration; | | 20 | 21 | import com.scwang.refreshlayout.activity.style.BezierStyleActivity; | 21 | 22 | import com.scwang.refreshlayout.activity.style.CircleStyleActivity; | 22 | 23 | import com.scwang.refreshlayout.activity.style.ClassicsStyleActivity; | | 24 | +import com.scwang.refreshlayout.activity.style.DeliveryStyleActivity; | 23 | 25 | import com.scwang.refreshlayout.activity.style.DropboxStyleActivity; | 24 | 26 | import com.scwang.refreshlayout.activity.style.FlyRefreshStyleActivity; | 25 | 27 | import com.scwang.refreshlayout.activity.style.FunGameBattleCityStyleActivity; | | 49 | 51 | public class RefreshStylesFragment extends Fragment implements AdapterView.OnItemClickListener { | 50 | 52 |
| 51 | 53 | private enum Item { | 52 | | - Dropbox("掉落盒子", DropboxStyleActivity.class), | 53 | | - FlyRefresh("纸飞机", FlyRefreshStyleActivity.class), | 54 | | - WaveSwipe("水波", WaveSwipStyleActivity.class), | 55 | | - WaterDrop("苹果水滴风格", WaterDropStyleActivity.class), | 56 | | - Material("官方主题", MaterialStyleActivity.class), | 57 | | - Phoenix("金色校园", PhoenixStyleActivity.class), | 58 | | - Taurus("冲上云霄", TaurusStyleActivity.class), | 59 | | - Bezier("贝塞尔雷达", BezierStyleActivity.class), | 60 | | - Circle("弹出圆圈", CircleStyleActivity.class), | 61 | | - FunGameHitBlock("游戏-打砖块", FunGameHitBlockStyleActivity.class), | 62 | | - FunGameBattleCity("游戏-战争城市", FunGameBattleCityStyleActivity.class), | 63 | | - StoreHouse("StoreHouse", StoreHouseStyleActivity.class), | 64 | | - Classics("经典风格", ClassicsStyleActivity.class), | | 54 | + Delivery(R.string.title_activity_style_delivery,DeliveryStyleActivity.class), | | 55 | + Dropbox(R.string.title_activity_style_dropbox, DropboxStyleActivity.class), | | 56 | + FlyRefresh(R.string.title_activity_style_flyrefresh, FlyRefreshStyleActivity.class), | | 57 | + WaveSwipe(R.string.title_activity_style_wave_swip, WaveSwipStyleActivity.class), | | 58 | + WaterDrop(R.string.title_activity_style_water_drop, WaterDropStyleActivity.class), | | 59 | + Material(R.string.title_activity_style_material, MaterialStyleActivity.class), | | 60 | + Phoenix(R.string.title_activity_style_phoenix, PhoenixStyleActivity.class), | | 61 | + Taurus(R.string.title_activity_style_taurus, TaurusStyleActivity.class), | | 62 | + Bezier(R.string.title_activity_style_bezier, BezierStyleActivity.class), | | 63 | + Circle(R.string.title_activity_style_circle, CircleStyleActivity.class), | | 64 | + FunGameHitBlock(R.string.title_activity_style_fungame_hitblock, FunGameHitBlockStyleActivity.class), | | 65 | + FunGameBattleCity(R.string.title_activity_style_fungame_battlecity, FunGameBattleCityStyleActivity.class), | | 66 | + StoreHouse(R.string.title_activity_style_storehouse, StoreHouseStyleActivity.class), | | 67 | + Classics(R.string.title_activity_style_classics, ClassicsStyleActivity.class), | 65 | 68 | ; | 66 | | - public String name; | | 69 | + public int nameId; | 67 | 70 | public Class<?> clazz; | 68 | | - Item(String name, Class<?> clazz) { | 69 | | - this.name = name; | | 71 | + Item(@StringRes int nameId, Class<?> clazz) { | | 72 | + this.nameId = nameId; | 70 | 73 | this.clazz = clazz; | 71 | 74 | } | 72 | 75 |
| @@ -91,7 +94,7 @@ public void onViewCreated(View root, @Nullable Bundle savedInstanceState) { | 91 | 94 | @Override | 92 | 95 | protected void onBindViewHolder(SmartViewHolder holder, Item model, int position) { | 93 | 96 | holder.text(android.R.id.text1, model.name()); | 94 | | - holder.text(android.R.id.text2, model.name); | | 97 | + holder.text(android.R.id.text2, model.nameId); | 95 | 98 | holder.textColorId(android.R.id.text2, R.color.colorTextAssistant); | 96 | 99 | } | 97 | 100 | }); | |
Collapse file Copy file name to clipboardExpand all lines: app/src/main/res/drawable/ic_airplane.xml -11Lines changed: 0 additions & 11 deletions Collapse file Copy file name to clipboard +9Lines changed: 9 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +<vector xmlns:android="http://schemas.android.com/apk/res/android" | | 2 | + android:width="24dp" | | 3 | + android:height="24dp" | | 4 | + android:viewportWidth="24.0" | | 5 | + android:viewportHeight="24.0"> | | 6 | + <path | | 7 | + android:fillColor="#bbb" | | 8 | + android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z"/> | | 9 | +</vector> |
Collapse file Copy file name to clipboardExpand all lines: app/src/main/res/drawable/ic_bga_refresh_loading12.xml -43Lines changed: 0 additions & 43 deletions
|