GeezerVison is showing github.com — 项目介绍排版 · StandOpen/SmartRefreshLayout@6bcb245
File treeExpand file treeCollapse file tree Open diff view settings java/com/scwang/refreshlayout/activity
refresh-header/src/main/java/com/scwang/smartrefresh/header java/com/scwang/smartrefresh/layout
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: app/src/main/java/com/scwang/refreshlayout/activity/style/ClassicsStyleActivity.java +16-1Lines changed: 16 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 18 | 18 | import com.scwang.refreshlayout.adapter.SmartViewHolder; | 19 | 19 | import com.scwang.refreshlayout.util.DynamicTimeFormat; | 20 | 20 | import com.scwang.smartrefresh.layout.api.RefreshLayout; | | 21 | +import com.scwang.smartrefresh.layout.constant.RefreshState; | 21 | 22 | import com.scwang.smartrefresh.layout.constant.SpinnerStyle; | 22 | 23 | import com.scwang.smartrefresh.layout.header.ClassicsHeader; | | 24 | +import com.scwang.smartrefresh.layout.listener.SimpleMultiPurposeListener; | 23 | 25 |
| 24 | 26 | import java.text.SimpleDateFormat; | 25 | 27 | import java.util.Arrays; | @@ -68,7 +70,6 @@ public void onClick(View v) { | 68 | 70 | }); | 69 | 71 |
| 70 | 72 | mRefreshLayout = (RefreshLayout)findViewById(R.id.smart); | 71 | | - mRefreshLayout.autoRefresh(); | 72 | 73 |
| 73 | 74 | int deta = new Random().nextInt(7 * 24 * 60 * 60 * 1000); | 74 | 75 | mClassicsHeader = (ClassicsHeader)mRefreshLayout.getRefreshHeader(); | @@ -93,6 +94,20 @@ protected void onBindViewHolder(SmartViewHolder holder, Item model, int position | 93 | 94 | }); | 94 | 95 | mRecyclerView = recyclerView; | 95 | 96 | } | | 97 | + | | 98 | + //触发上啦加载 | | 99 | + mRefreshLayout.autoLoadmore(); | | 100 | + //通过多功能监听接口实现 在第一次加载完成之后 自动刷新 | | 101 | + mRefreshLayout.setOnMultiPurposeListener(new SimpleMultiPurposeListener(){ | | 102 | + @Override | | 103 | + public void onStateChanged(RefreshState oldState, RefreshState state) { | | 104 | + if (oldState == RefreshState.LoadingFinish | | 105 | + && state == RefreshState.None) { | | 106 | + mRefreshLayout.autoRefresh(); | | 107 | + mRefreshLayout.setOnMultiPurposeListener(null);//保准只有第一次关联 | | 108 | + } | | 109 | + } | | 110 | + }); | 96 | 111 | } | 97 | 112 |
| 98 | 113 | @Override | |
Collapse file Copy file name to clipboardExpand all lines: app/src/main/java/com/scwang/refreshlayout/activity/style/FunGameBattleCityStyleActivity.java +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 25 | 25 | public class FunGameBattleCityStyleActivity extends AppCompatActivity implements AdapterView.OnItemClickListener { | 26 | 26 |
| 27 | 27 | private enum Item { | | 28 | + 默认主题("更改为橙色默认颜色"), | 28 | 29 | 橙色主题("更改为橙色主题颜色"), | 29 | 30 | 红色主题("更改为红色主题颜色"), | 30 | 31 | 绿色主题("更改为绿色主题颜色"), | @@ -75,6 +76,9 @@ protected void onBindViewHolder(SmartViewHolder holder, Item model, int position | 75 | 76 | @Override | 76 | 77 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | 77 | 78 | switch (Item.values()[position]) { | | 79 | + case 默认主题: | | 80 | + mRefreshLayout.setPrimaryColorsId(android.R.color.white, android.R.color.black); | | 81 | + break; | 78 | 82 | case 蓝色主题: | 79 | 83 | setThemeColor(R.color.colorPrimary, R.color.colorPrimaryDark); | 80 | 84 | break; | |
Collapse file Copy file name to clipboardExpand all lines: app/src/main/java/com/scwang/refreshlayout/activity/style/FunGameHitBlockStyleActivity.java +11Lines changed: 11 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 16 | 16 | import com.scwang.refreshlayout.adapter.BaseRecyclerAdapter; | 17 | 17 | import com.scwang.refreshlayout.adapter.SmartViewHolder; | 18 | 18 | import com.scwang.smartrefresh.layout.api.RefreshLayout; | | 19 | +import com.scwang.smartrefresh.layout.listener.OnRefreshListener; | 19 | 20 |
| 20 | 21 | import java.util.Arrays; | 21 | 22 |
| | 25 | 26 | public class FunGameHitBlockStyleActivity extends AppCompatActivity implements AdapterView.OnItemClickListener { | 26 | 27 |
| 27 | 28 | private enum Item { | | 29 | + 默认主题("更改为橙色默认颜色"), | 28 | 30 | 橙色主题("更改为橙色主题颜色"), | 29 | 31 | 红色主题("更改为红色主题颜色"), | 30 | 32 | 绿色主题("更改为绿色主题颜色"), | @@ -54,6 +56,12 @@ public void onClick(View v) { | 54 | 56 |
| 55 | 57 | mRefreshLayout = (RefreshLayout)findViewById(R.id.smart); | 56 | 58 | mRefreshLayout.autoRefresh(); | | 59 | + mRefreshLayout.setOnRefreshListener(new OnRefreshListener() { | | 60 | + @Override | | 61 | + public void onRefresh(RefreshLayout refreshlayout) { | | 62 | + refreshlayout.finishRefresh(4000); | | 63 | + } | | 64 | + }); | 57 | 65 |
| 58 | 66 | View view = findViewById(R.id.recycler); | 59 | 67 | if (view instanceof RecyclerView) { | @@ -75,6 +83,9 @@ protected void onBindViewHolder(SmartViewHolder holder, Item model, int position | 75 | 83 | @Override | 76 | 84 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | 77 | 85 | switch (Item.values()[position]) { | | 86 | + case 默认主题: | | 87 | + mRefreshLayout.setPrimaryColorsId(android.R.color.white, android.R.color.black); | | 88 | + break; | 78 | 89 | case 蓝色主题: | 79 | 90 | setThemeColor(R.color.colorPrimary, R.color.colorPrimaryDark); | 80 | 91 | break; | |
Collapse file Copy file name to clipboardExpand all lines: app/src/main/java/com/scwang/refreshlayout/activity/style/StoreHouseStyleActivity.java +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -93,6 +93,7 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id) | 93 | 93 |
| 94 | 94 | private void setThemeColor(int colorPrimary, int colorPrimaryDark) { | 95 | 95 | mToolbar.setBackgroundResource(colorPrimary); | | 96 | + ((View)mRefreshLayout).setBackgroundResource(colorPrimary); | 96 | 97 | mRefreshLayout.setPrimaryColorsId(colorPrimary, android.R.color.white); | 97 | 98 | if (Build.VERSION.SDK_INT >= 21) { | 98 | 99 | getWindow().setStatusBarColor(ContextCompat.getColor(this, colorPrimaryDark)); | |
Collapse file Copy file name to clipboardExpand all lines: app/src/main/java/com/scwang/refreshlayout/activity/using/AssignCodeUsingActivity.java +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -58,6 +58,7 @@ public void onStateChanged(RefreshState oldState, RefreshState state) { | 58 | 58 | } | 59 | 59 | } | 60 | 60 | }); | | 61 | + | 61 | 62 | } | 62 | 63 |
| 63 | 64 | } |
Collapse file Copy file name to clipboardExpand all lines: app/src/main/java/com/scwang/refreshlayout/activity/using/AssignDefaultUsingActivity.java +7-3Lines changed: 7 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 15 | 15 | import com.scwang.smartrefresh.layout.api.RefreshHeader; | 16 | 16 | import com.scwang.smartrefresh.layout.api.RefreshLayout; | 17 | 17 | import com.scwang.smartrefresh.layout.constant.RefreshState; | | 18 | +import com.scwang.smartrefresh.layout.constant.SpinnerStyle; | 18 | 19 | import com.scwang.smartrefresh.layout.footer.ClassicsFooter; | 19 | 20 | import com.scwang.smartrefresh.layout.header.ClassicsHeader; | 20 | 21 | import com.scwang.smartrefresh.layout.listener.SimpleMultiPurposeListener; | @@ -36,16 +37,19 @@ public AssignDefaultUsingActivity() { | 36 | 37 | @Override | 37 | 38 | public RefreshHeader createRefreshHeader(Context context, RefreshLayout layout) { | 38 | 39 | layout.setPrimaryColorsId(R.color.colorPrimary, android.R.color.white);//创建同时可以先设置主题颜色 | 39 | | - ((View) layout).setBackgroundResource(R.color.colorPrimary); | 40 | | - return new ClassicsHeader(context);//指定为经典Header,默认是 贝塞尔雷达Header | | 40 | + ((View) layout).setBackgroundResource(R.color.colorPrimary);//设置刷新布局的背景融合Header主题色 | | 41 | + return new ClassicsHeader(context).setSpinnerStyle(SpinnerStyle.FixedBehind);//指定为经典Header,默认是 贝塞尔雷达Header | 41 | 42 | } | 42 | 43 | }); | 43 | 44 | //设置全局的Footer构建器 | 44 | 45 | SmartRefreshLayout.setDefaultRefreshFooterCreater(new DefaultRefreshFooterCreater() { | 45 | 46 | @NonNull | 46 | 47 | @Override | 47 | 48 | public RefreshFooter createRefreshFooter(Context context, RefreshLayout layout) { | 48 | | - return new ClassicsFooter(context);//指定为经典Footer,默认是 BallPulseFooter | | 49 | + ClassicsFooter footer = new ClassicsFooter(context); | | 50 | + footer.setBackgroundResource(android.R.color.white); | | 51 | + footer.setSpinnerStyle(SpinnerStyle.Scale);//设置为拉伸模式 | | 52 | + return footer;//指定为经典Footer,默认是 BallPulseFooter | 49 | 53 | } | 50 | 54 | }); | 51 | 55 | } | |
Collapse file Copy file name to clipboardExpand all lines: app/src/main/res/layout/activity_style_classics.xml +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 30 | 30 | tools:listitem="@android:layout/simple_list_item_2"/> | 31 | 31 | <com.scwang.smartrefresh.layout.footer.ClassicsFooter | 32 | 32 | android:layout_width="match_parent" | 33 | | - android:layout_height="wrap_content"/> | | 33 | + android:layout_height="wrap_content" | | 34 | + app:srlClassicsSpinnerStyle="Scale" | | 35 | + android:background="@android:color/white"/> | 34 | 36 | </com.scwang.smartrefresh.layout.SmartRefreshLayout> | 35 | 37 |
| 36 | 38 | </LinearLayout> |
Collapse file Copy file name to clipboardExpand all lines: app/src/main/res/layout/activity_style_fungame_battlecity.xml +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 16 | 16 | android:id="@+id/smart" | 17 | 17 | android:layout_width="match_parent" | 18 | 18 | android:layout_height="match_parent" | 19 | | - app:srlEnableHeaderTranslationContent="true" | | 19 | + app:srlPrimaryColor="@color/colorPrimary" | | 20 | + app:srlAccentColor="@android:color/white" | 20 | 21 | app:srlEnableLoadmore="false"> | 21 | 22 | <com.scwang.smartrefresh.header.FunGameBattleCityHeader | 22 | 23 | android:layout_width="match_parent" | |
Collapse file Copy file name to clipboardExpand all lines: app/src/main/res/layout/activity_style_fungame_hitblock.xml +3-2Lines changed: 3 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 16 | 16 | android:id="@+id/smart" | 17 | 17 | android:layout_width="match_parent" | 18 | 18 | android:layout_height="match_parent" | 19 | | - app:srlEnableLoadmore="false" | 20 | | - app:srlEnableHeaderTranslationContent="true"> | | 19 | + app:srlPrimaryColor="@color/colorPrimary" | | 20 | + app:srlAccentColor="@android:color/white" | | 21 | + app:srlEnableLoadmore="false"> | 21 | 22 | <com.scwang.smartrefresh.header.FunGameHitBlockHeader | 22 | 23 | android:layout_width="match_parent" | 23 | 24 | android:layout_height="match_parent"/> | |
Collapse file Copy file name to clipboardExpand all lines: app/src/main/res/layout/activity_using_assign_xml.xml +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 35 | 35 | <com.scwang.smartrefresh.layout.footer.ClassicsFooter | 36 | 36 | android:layout_width="match_parent" | 37 | 37 | android:layout_height="wrap_content" | | 38 | + app:srlAccentColor="@android:color/white" | 38 | 39 | app:srlClassicsSpinnerStyle="FixedBehind"/> | 39 | 40 | <!--FixedBehind可以让Footer固定在内容的背后,下拉的时候效果同微信浏览器的效果--> | 40 | 41 | </com.scwang.smartrefresh.layout.SmartRefreshLayout> | |
|