33
33
import com .aries .library .fast .manager .LoggerManager ;
34
34
import com .aries .library .fast .retrofit .FastLoadingObserver ;
35
35
import com .aries .library .fast .retrofit .FastObserver ;
36
+ import com .aries .library .fast .util .FastStackUtil ;
36
37
import com .aries .library .fast .util .FastUtil ;
37
38
import com .aries .library .fast .util .SizeUtil ;
38
39
import com .aries .library .fast .widget .FastLoadDialog ;
57
58
* E-Mail: AriesHoo@126.com
58
59
* Function: 全局参数配置--可在Application处设置Library全局属性
59
60
* Description:
61
+ * 1、2018-2-24 18:55:26新增setSwipeBackEnable 全局控制Activity堆栈及滑动返回
60
62
*/
61
63
public class FastConfig {
62
64
63
65
private static volatile FastConfig sInstance ;
64
66
private static Context mContext ;
67
+ private Application mApplication ;
65
68
66
69
public static FastConfig getInstance (@ Nullable Context context ) {
67
70
if (sInstance == null ) {
@@ -78,7 +81,6 @@ private FastConfig(@Nullable Context context) {
78
81
if (context == null ) {
79
82
throw new NullPointerException (FastConstant .EXCEPTION_FAST_CONFIG_CONTEXT_NOT_NULL );
80
83
}
81
- LoggerManager .i ("FastConfig" ,mContext +"" );
82
84
if (context != null ) {
83
85
this .mContext = context .getApplicationContext ();
84
86
if (FastUtil .isClassExist ("com.aries.ui.view.title.TitleBarView" )) {
@@ -140,6 +142,9 @@ public IMultiStatusView createMultiStatusView() {
140
142
}
141
143
});
142
144
}
145
+ if (mContext instanceof Application ) {
146
+ setSwipeBackEnable (false , (Application ) mContext );
147
+ }
143
148
setQuitConfig (new FastQuitConfigEntity ()
144
149
.setQuitDelay (2000 )
145
150
.setQuitMessage (getText (R .string .fast_quit_app ))
@@ -302,15 +307,49 @@ public boolean isSwipeBackEnable() {
302
307
* @return
303
308
*/
304
309
public FastConfig setSwipeBackEnable (boolean swipeBackEnable , Application application ) {
305
- if (application == null ) {
306
- throw new NullPointerException (FastConstant .EXCEPTION_SWIPE_BACK_APPLICATION_NOT_NULL );
307
- }
308
310
mIsSwipeBackEnable = swipeBackEnable ;
309
- if (application != null &&
310
- FastUtil .isClassExist ("cn.bingoogolapple.swipebacklayout.BGASwipeBackManager" )) {
311
+ if (application != null && mApplication == null && FastUtil .isClassExist ("cn.bingoogolapple.swipebacklayout.BGASwipeBackManager" )) {
311
312
BGASwipeBackManager .getInstance ().init (application );//初始化滑动返回关闭Activity功能
312
313
// 导航栏处理--不设置会预留一块导航栏高度的空白
313
314
BGASwipeBackManager .ignoreNavigationBarModels (Arrays .asList (Build .MODEL ));
315
+ mApplication = application ;
316
+ mApplication .registerActivityLifecycleCallbacks (new Application .ActivityLifecycleCallbacks () {
317
+ @ Override
318
+ public void onActivityCreated (Activity activity , Bundle savedInstanceState ) {
319
+ FastStackUtil .getInstance ().push (activity );
320
+ }
321
+
322
+ @ Override
323
+ public void onActivityStarted (Activity activity ) {
324
+
325
+ }
326
+
327
+ @ Override
328
+ public void onActivityResumed (Activity activity ) {
329
+
330
+ }
331
+
332
+ @ Override
333
+ public void onActivityPaused (Activity activity ) {
334
+
335
+ }
336
+
337
+ @ Override
338
+ public void onActivityStopped (Activity activity ) {
339
+
340
+ }
341
+
342
+ @ Override
343
+ public void onActivitySaveInstanceState (Activity activity , Bundle outState ) {
344
+
345
+ }
346
+
347
+ @ Override
348
+ public void onActivityDestroyed (Activity activity ) {
349
+ FastStackUtil .getInstance ().pop (activity , false );
350
+ }
351
+ });
352
+
314
353
}
315
354
return sInstance ;
316
355
}
0 commit comments