1
1
package com .aries .library .fast .demo ;
2
2
3
+ import android .app .Application ;
3
4
import android .content .Context ;
5
+ import android .graphics .Color ;
6
+ import android .os .Build ;
4
7
import android .support .annotation .NonNull ;
5
8
6
- import com .aries .library .fast .FastApplication ;
7
9
import com .aries .library .fast .FastConfig ;
8
10
import com .aries .library .fast .demo .helper .RefreshHeaderHelper ;
11
+ import com .aries .library .fast .entity .FastQuitConfigEntity ;
9
12
import com .aries .library .fast .entity .FastTitleConfigEntity ;
13
+ import com .aries .library .fast .i .LoadMoreFoot ;
10
14
import com .aries .library .fast .manager .LoggerManager ;
11
15
import com .aries .library .fast .retrofit .FastRetrofit ;
12
16
import com .aries .library .fast .util .SizeUtil ;
13
17
import com .aries .library .fast .util .ToastUtil ;
14
- import com .chad .library .adapter .base .animation .ScaleInAnimation ;
18
+ import com .aries .library .fast .widget .FastLoadMoreView ;
19
+ import com .chad .library .adapter .base .BaseQuickAdapter ;
20
+ import com .chad .library .adapter .base .loadmore .LoadMoreView ;
21
+ import com .scwang .smartrefresh .header .DeliveryHeader ;
15
22
import com .scwang .smartrefresh .layout .api .DefaultRefreshHeaderCreater ;
16
23
import com .scwang .smartrefresh .layout .api .RefreshHeader ;
17
24
import com .scwang .smartrefresh .layout .api .RefreshLayout ;
20
27
/**
21
28
* Created: AriesHoo on 2017/7/20 14:11
22
29
* Function: 基础配置Application
23
- * Desc: 是否继承根据情况而定--滑动返回设置请查看 {@link FastApplication}
30
+ * Desc:
24
31
*/
25
- public class App extends FastApplication {
32
+ public class App extends Application {
33
+
26
34
private static Context mContext ;
27
35
private String TAG = "FastLib" ;
28
36
private static int imageHeight = 0 ;
@@ -53,34 +61,93 @@ public void onCreate() {
53
61
//增加一个Header配置注意FastMultiUrl.BASE_URL_NAME_HEADER是必须后面"test"作为标记
54
62
// FastMultiUrl里增加的拦截器才找得到对应的BaseUrl
55
63
56
-
64
+ //主页返回键是否退回桌面--程序后台
65
+ boolean isBackTask = false ;
57
66
//全局配置参数
58
- //推荐先获取library里默认TitleBarView配置再按需修改的模式 FastTitleConfigEntity
67
+ //推荐先获取library里默认标题栏TitleBarView配置再按需修改的模式 FastTitleConfigEntity
59
68
FastTitleConfigEntity titleConfig = FastConfig .getInstance (mContext ).getTitleConfig ();
69
+ //推荐先获取library里默认主页面点击返回键配置FastQuitConfigEntity配置再按需修改的模式 FastQuitConfigEntity
70
+ FastQuitConfigEntity quitConfig = FastConfig .getInstance (mContext ).getQuitConfig ();
71
+ //推荐先获取library里默认主页面Tab参数配置FastTabConfigEntity配置再按需修改的模式 FastTabConfigEntity
60
72
FastConfig .getInstance (mContext )
61
- // 其它属性请查看getInstance默认设置
73
+ // 设置全局TitleBarView- 其它属性请查看getInstance默认设置
62
74
.setTitleConfig (titleConfig
63
75
//设置TitleBarView 所有TextView颜色
64
76
.setTitleTextColor (mContext .getResources ().getColor (R .color .colorTitleText ))
65
77
//设置TitleBarView背景资源
66
78
.setTitleBackgroundResource (R .color .colorTitleBackground )
67
79
//设置是否状态栏浅色模式(深色状态栏文字及图标)
68
80
.setLightStatusBarEnable (true )
81
+ .setDividerHeight (Build .VERSION .SDK_INT < Build .VERSION_CODES .LOLLIPOP ? SizeUtil .dp2px (0.5f ) : 0 )
69
82
//设置TitleBarView海拔高度
70
83
.setTitleElevation (mContext .getResources ().getDimension (R .dimen .dp_elevation )))
84
+ //设置Activity 点击返回键提示退出程序或返回桌面相关参数
85
+ .setQuitConfig (quitConfig
86
+ //设置是否退回桌面否则直接退出程序
87
+ .setBackToTaskEnable (isBackTask )
88
+ //设置退回桌面是否有一次提示setBackToTaskEnable(true)才有意义
89
+ .setBackToTaskDelayEnable (isBackTask )
90
+ .setQuitDelay (2000 )
91
+ .setQuitMessage (isBackTask ? mContext .getString (R .string .fast_back_home ) : mContext .getString (R .string .fast_quit_app ))
92
+ .setSnackBarBackgroundColor (Color .argb (220 , 0 , 0 , 0 ))
93
+ .setSnackBarEnable (false )
94
+ .setSnackBarMessageColor (Color .WHITE ))
71
95
//设置Glide背景色
72
96
.setPlaceholderColor (mContext .getResources ().getColor (R .color .colorPlaceholder ))
73
97
//设置Glide圆角背景弧度
74
98
.setPlaceholderRoundRadius (mContext .getResources ().getDimension (R .dimen .dp_placeholder_radius ))
99
+ //设置Activity是否支持滑动返回-添加透明主题参考Demo样式;
100
+ .setSwipeBackEnable (true , this )
101
+ //设置Activity横竖屏模式
102
+ // .setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)
75
103
.setContentViewBackgroundResource (R .color .colorBackground )//设置Activity或Fragment根布局背景资源
76
- .setSwipeBackEnable (true )//设置Activity是否支持滑动返回--注意设置透明主题参考demo
77
- .setAdapterAnimationEnable (true ) //是否设置Adapter加载动画
78
- .setDefaultAdapterAnimation (new ScaleInAnimation ())//设置全局Adapter加载动画--设置该方法内部同步调用setAdapterAnimationEnable(true)
104
+ //设置Adapter加载更多视图--默认设置了FastLoadMoreView
105
+ .setDefaultLoadMoreView (new LoadMoreFoot () {
106
+ @ Override
107
+ public LoadMoreView createDefaultLoadMoreView (BaseQuickAdapter adapter ) {
108
+ if (adapter != null ) {
109
+ //设置动画是否一直开启
110
+ adapter .isFirstOnly (false );
111
+ adapter .openLoadAnimation (BaseQuickAdapter .SCALEIN );
112
+ }
113
+ //方式一:设置FastLoadMoreView--以下为FastConfig里默认配置
114
+ return new FastLoadMoreView .Builder ()
115
+ .setLoadTextColor (mContext .getResources ().getColor (R .color .colorLoadMoreText ))
116
+ .setLoadTextSize (mContext .getResources ().getDimensionPixelSize (R .dimen .dp_load_more_text_size ))
117
+ .setLoadingProgressColor (mContext .getResources ().getColor (R .color .colorLoadMoreProgress ))
118
+ .setLoadingText (mContext .getText (R .string .fast_load_more_loading ))
119
+ .setLoadFailText (mContext .getText (R .string .fast_load_more_load_failed ))
120
+ .setLoadEndText (mContext .getText (R .string .fast_load_more_load_end ))
121
+ // //设置Loading 颜色-5.0以上有效
122
+ // .setLoadingProgressColor(Color.MAGENTA)
123
+ // //设置Loading drawable--会是Loading颜色失效
124
+ // .setLoadingProgressDrawable(mContext.getResources().getDrawable(R.drawable.dialog_loading_wei_bo))
125
+ // //设置全局TextView颜色
126
+ // .setLoadTextColor(Color.MAGENTA)
127
+ // //设置全局TextView文字字号
128
+ // .setLoadTextSize(SizeUtil.dp2px(14))
129
+ // .setLoadingText("努力加载中...")
130
+ // .setLoadingTextColor(Color.GREEN)
131
+ // .setLoadingTextSize(SizeUtil.dp2px(14))
132
+ // .setLoadEndText("我是有底线的")
133
+ // .setLoadEndTextColor(Color.GREEN)
134
+ // .setLoadEndTextSize(SizeUtil.dp2px(14))
135
+ // .setLoadFailText("哇哦!出错了")
136
+ // .setLoadFailTextColor(Color.RED)
137
+ // .setLoadFailTextSize(SizeUtil.dp2px(14))
138
+ .build ();
139
+ //方式二:使用adapter自带--其实我默认设置的和这个基本一致只是提供了相应设置方法
140
+ // return new SimpleLoadMoreView();
141
+ //方式三:参考SimpleLoadMoreView或FastLoadMoreView完全自定义自己的LoadMoreView
142
+ // return MyLoadMoreView();
143
+ }
144
+ })
79
145
.setDefaultRefreshHeader (new DefaultRefreshHeaderCreater () {//设置SmartRefreshLayout刷新头-自定加载使用BaseRecyclerViewAdapterHelper
80
146
@ NonNull
81
147
@ Override
82
148
public RefreshHeader createRefreshHeader (Context context , RefreshLayout layout ) {
83
149
layout .setEnableHeaderTranslationContent (false );
150
+ layout .setRefreshHeader (new DeliveryHeader (mContext ));
84
151
return RefreshHeaderHelper .getInstance ().getRefreshHeader (mContext );
85
152
}
86
153
});
@@ -96,6 +163,10 @@ public static int getImageHeight() {
96
163
return imageHeight ;
97
164
}
98
165
166
+ public static boolean isSupportElevation () {
167
+ return Build .VERSION .SDK_INT >= Build .VERSION_CODES .LOLLIPOP ;
168
+ }
169
+
99
170
public static Context getContext () {
100
171
return mContext ;
101
172
}
0 commit comments