Skip to content

Commit 7dfe07b

Browse files
AriesHoo@126.comAriesHoo@126.com
authored andcommitted
优化: 优化FastManager初始化init逻辑,FastLib自动初始化
优化: 将eventbus、bga-swipebacklayout、UIWidget:tab-layout 使用compileOnly开发者根据需要导入
1 parent 5c47663 commit 7dfe07b

File tree

13 files changed

+185
-70
lines changed

13 files changed

+185
-70
lines changed

README.md

Lines changed: 52 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ Demo中使用到的网络请求api来源于[豆瓣API V2](https://developers.dou
4747

4848
## 重大更新日志 其它版本参看[Release](https://github.com/AriesHoo/FastLib/releases)
4949

50+
* 2.3.1
51+
52+
* 优化: 优化FastManager初始化init逻辑,FastLib自动初始化
53+
* 优化: 将eventbus、bga-swipebacklayout、UIWidget:tab-layout 使用compileOnly开发者根据需要导入
54+
5055
* 2.2.13
5156

5257
* 新增: 下拉刷新接口IFastRefreshView及标题栏IFastTitleBarView
@@ -112,6 +117,10 @@ Demo中使用到的网络请求api来源于[豆瓣API V2](https://developers.dou
112117

113118
## 录屏预览
114119

120+
![](https://github.com/AriesHoo/FastLib/blob/dev/screenshot/fold.gif)
121+
122+
**折叠屏效果一览
123+
115124
![](https://github.com/AriesHoo/FastLib/blob/dev/screenshot/FastRefresh.gif)
116125

117126
**快速实现页面下拉刷新-全局控制及局部个性化**-参考WebActivity、FastRefreshActivity、MineFragment
@@ -158,7 +167,7 @@ allprojects {
158167

159168
```
160169
dependencies {
161-
implementation 'com.github.AriesHoo:FastLib:2.3.0'
170+
implementation 'com.github.AriesHoo:FastLib:2.3.1'
162171
}
163172
```
164173

@@ -177,7 +186,7 @@ dependencies {
177186
<dependency>
178187
<groupId>com.github.AriesHoo</groupId>
179188
<artifactId>FastLib</artifactId>
180-
<version>2.3.0</version>
189+
<version>2.3.1</version>
181190
</dependency>
182191
```
183192

@@ -191,49 +200,53 @@ implementation project(':fastLib')
191200

192201
```
193202
compileSdkVersion = 28
194-
buildToolsVersion = "28.0.3"
195-
minSdkVersion = 21
203+
minSdkVersion = 16
204+
minLibSdkVersion = 15
196205
targetSdkVersion = 28
197206
supportVersion = "1.0.0"
207+
widgetVersion = "3.2.24"
198208
```
199209

200210
```
201211
dependencies {
202-
compileOnly 'com.google.android.material:material:'.concat(supportVersion)
203-
compileOnly 'androidx.appcompat:appcompat:'.concat(supportVersion)
204-
compileOnly 'androidx.recyclerview:recyclerview:'.concat(supportVersion)
205-
//万能适配器
206-
compileOnly 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.45-androidx'
207-
//webView库
208-
compileOnly 'com.just.agentweb:agentweb:4.0.2'
209-
//下拉刷新库
210-
compileOnly 'com.scwang.smartrefresh:SmartRefreshLayout:1.0.5.1'
211-
//图片加载
212-
compileOnly 'com.github.bumptech.glide:glide:4.8.0'
213-
//常用UI控件(TitleBarView、RadiusView等)
214-
api 'com.github.AriesHoo.UIWidget:widget-core:3.2.9'
215-
//日志打印
216-
api 'com.orhanobut:logger:2.2.0'
217-
//注解
218-
api 'com.jakewharton:butterknife:10.1.0'
219-
//retrofit+rxjava 网络请求及数据解析相关
220-
api "io.reactivex.rxjava2:rxjava:2.2.6"
221-
api 'io.reactivex.rxjava2:rxandroid:2.1.1'
222-
api 'com.squareup.retrofit2:retrofit:2.5.0'
223-
api 'com.squareup.retrofit2:converter-gson:2.5.0'
224-
api 'com.squareup.retrofit2:adapter-rxjava2:2.5.0'
225-
api 'com.squareup.okhttp3:logging-interceptor:3.13.1'
226-
api 'com.google.code.gson:gson:2.8.5'
227-
//处理rxjava内存泄漏-生命周期绑定
228-
api 'com.trello.rxlifecycle3:rxlifecycle-components:3.0.0'
229-
//滑动返回Activity
230-
api 'cn.bingoogolapple:bga-swipebacklayout:1.2.0@aar'
231-
//快速Tab库
232-
api 'com.github.AriesHoo:TabLayout:1.0.2'
233-
//页面事件交互
234-
api 'org.simple:androideventbus:1.0.5.1'
235-
//多状态视图切换
236-
api 'com.github.Bakumon:StatusLayoutManager:1.0.4'
212+
compileOnly "com.google.android.material:material:$rootProject.supportVersion"
213+
// compileOnly 'androidx.appcompat:appcompat:'.concat(supportVersion)
214+
compileOnly "androidx.recyclerview:recyclerview:$rootProject.supportVersion"
215+
//万能适配器
216+
compileOnly 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.49-androidx'
217+
//webView库
218+
compileOnly 'com.just.agentweb:agentweb:4.1.2'
219+
//下拉刷新库
220+
compileOnly 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0-andx-14'
221+
//图片加载
222+
compileOnly 'com.github.bumptech.glide:glide:4.8.0'
223+
//常用UI控件(TitleBarView、RadiusView等)
224+
api "com.github.AriesHoo.UIWidget:widget-core:$rootProject.widgetVersion"
225+
//快速Tab库
226+
compileOnly "com.github.AriesHoo.UIWidget:tab-layout:$rootProject.widgetVersion"
227+
//日志打印
228+
api 'com.orhanobut:logger:2.2.0'
229+
//注解
230+
api 'com.jakewharton:butterknife:10.1.0'
231+
//retrofit+rxjava 网络请求及数据解析相关
232+
api "io.reactivex.rxjava2:rxjava:2.2.6"
233+
api 'io.reactivex.rxjava2:rxandroid:2.1.1'
234+
api 'com.squareup.retrofit2:retrofit:2.6.1'
235+
api 'com.squareup.retrofit2:converter-gson:2.6.1'
236+
api 'com.squareup.retrofit2:adapter-rxjava2:2.6.1'
237+
//3.12.x是支持Android 4.4的
238+
api 'com.squareup.okhttp3:logging-interceptor:3.12.2'
239+
api 'com.google.code.gson:gson:2.8.5'
240+
//处理rxjava内存泄漏-生命周期绑定
241+
api 'com.trello.rxlifecycle3:rxlifecycle-components:3.0.0'
242+
//滑动返回Activity
243+
compileOnly 'cn.bingoogolapple:bga-swipebacklayout:1.2.0@aar'
244+
//页面事件交互-androideventbus-停止维护
245+
compileOnly 'org.simple:androideventbus:1.0.5.1'
246+
//页面事件交互-eventbus
247+
compileOnly 'org.greenrobot:eventbus:3.1.1'
248+
//多状态视图切换
249+
api 'com.github.Bakumon:StatusLayoutManager:1.0.4'
237250
}
238251
```
239252

apk/sample.apk

-412 Bytes
Binary file not shown.

apk/update

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"versionCode": 244,
3-
"versionName": "2.3.0",
2+
"versionCode": 245,
3+
"versionName": "2.3.1",
44
"url": "https://raw.githubusercontent.com/AriesHoo/FastLib/dev/apk/sample.apk",
55
"force": false,
66
"size": "3.74M",
7-
"message": "1、升级部分三方库增强稳定性\n2、修改部分BUG"
7+
"message": "1、去掉部分非必须三方库导入由使用者决定是否导入\n2、优化FastManager初始化逻辑"
88
}

app/build.gradle

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ android {
7777
dependencies {
7878
implementation fileTree(include: ['*.jar'], dir: 'libs')
7979
implementation project(':library')
80-
// implementation 'com.github.AriesHoo:FastLib:2.3.0'
80+
// implementation 'com.github.AriesHoo:FastLib:2.3.1'
8181
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.3'
8282
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.3'
8383
testImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.3'
@@ -88,6 +88,12 @@ dependencies {
8888
implementation 'androidx.recyclerview:recyclerview:'.concat(supportVersion)
8989
//快速Tab库-继承FastMainActivity使用
9090
implementation "com.github.AriesHoo.UIWidget:tab-layout:$rootProject.widgetVersion"
91+
//滑动返回Activity-鉴于现在全面屏比较多不推荐使用该库
92+
implementation 'cn.bingoogolapple:bga-swipebacklayout:1.2.0@aar'
93+
//页面事件交互-androideventbus-停止维护-按需导入
94+
// implementation 'org.simple:androideventbus:1.0.5.1'
95+
//页面事件交互-eventbus-按需导入
96+
// compileOnly 'org.greenrobot:eventbus:3.1.1'
9197
//万能适配器--一般都需要吧
9298
implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.49-androidx'
9399
//webView库 继承FastWebActivity需要,不需要内置WebView可以不implementation
@@ -121,4 +127,6 @@ dependencies {
121127
implementation 'com.pgyersdk:sdk:3.0.5'
122128
//保活组件
123129
// implementation 'com.fanjun:keeplive:1.1.18'
130+
//滑动返回Activity-类全面屏手势效果
131+
implementation 'com.github.ParfoisMeng:SlideBack:1.0.7'
124132
}

app/src/main/java/com/aries/library/fast/demo/App.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import com.aries.library.fast.demo.impl.ActivityControlImpl;
1919
import com.aries.library.fast.demo.impl.AppImpl;
2020
import com.aries.library.fast.demo.impl.HttpRequestControlImpl;
21+
import com.aries.library.fast.demo.impl.SwipeBackControlImpl;
2122
import com.aries.library.fast.demo.module.WebViewActivity;
2223
import com.aries.library.fast.demo.module.main.MainActivity;
2324
import com.aries.library.fast.demo.util.NotificationUtil;
@@ -84,7 +85,7 @@ public void onCreate() {
8485
//设置全局TitleBarView相关配置
8586
.setTitleBarViewControl(impl)
8687
//设置Activity滑动返回控制-默认开启滑动返回功能不需要设置透明主题
87-
// .setSwipeBackControl(new SwipeBackControlImpl())
88+
.setSwipeBackControl(new SwipeBackControlImpl())
8889
//设置Activity/Fragment相关配置(横竖屏+背景+虚拟导航栏+状态栏+生命周期)
8990
.setActivityFragmentControl(activityControl)
9091
//设置BasisActivity 子类按键监听

app/src/main/java/com/aries/library/fast/demo/impl/ActivityControlImpl.java

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import com.aries.library.fast.demo.R;
3131
import com.aries.library.fast.demo.module.SplashActivity;
3232
import com.aries.library.fast.demo.module.main.MainActivity;
33+
import com.aries.library.fast.demo.module.main.sample.SwipeBackActivity;
3334
import com.aries.library.fast.demo.module.main.sample.TestStatusActivity;
3435
import com.aries.library.fast.i.ActivityDispatchEventControl;
3536
import com.aries.library.fast.i.ActivityFragmentControl;
@@ -51,6 +52,8 @@
5152
import com.didichuxing.doraemonkit.ui.base.BaseActivity;
5253
import com.luck.picture.lib.PictureBaseActivity;
5354
import com.luck.picture.lib.PicturePreviewActivity;
55+
import com.parfoismeng.slidebacklib.SlideBack;
56+
import com.parfoismeng.slidebacklib.callback.SlideBackCallBack;
5457
import com.umeng.analytics.MobclickAgent;
5558

5659
import java.util.List;
@@ -209,7 +212,9 @@ private boolean isLeak(Activity activity) {
209212
public boolean setNavigationBar(Activity activity, NavigationViewHelper helper, View bottomView) {
210213
//其它默认属性请参考FastLifecycleCallbacks
211214
helper.setLogEnable(BuildConfig.DEBUG)
212-
.setPlusNavigationViewEnable(true, !isPlusView(activity), true)
215+
.setPlusNavigationViewEnable(true)
216+
//此处为配合BGASwipeBackHelper滑动返回效果-如不使用BGASwipeBackHelper推荐使用上面的方法
217+
.setPlusNavigationViewEnable(true, true, true)
213218
.setNavigationBarLightMode(NavigationBarUtil.isSupportNavigationBarFontChange() && isPlusView(activity))
214219
.setOnKeyboardVisibilityChangedListener(getOnKeyboardVisibilityChangedListener(activity))
215220
.setBottomView(PicturePreviewActivity.class.isAssignableFrom(activity.getClass()) ?
@@ -292,6 +297,21 @@ public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
292297
//阻止系统截屏功能
293298
//activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
294299
setActivityOrientation(activity);
300+
Activity previous = FastStackUtil.getInstance().getPrevious();
301+
if (previous != null && previous instanceof SwipeBackActivity) {
302+
return;
303+
}
304+
//设置类全面屏手势滑动返回
305+
SlideBack.with(activity)
306+
.haveScroll(true)
307+
.edgeMode(SlideBack.EDGE_BOTH)
308+
.callBack(new SlideBackCallBack() {
309+
@Override
310+
public void onSlideBack() {
311+
activity.onBackPressed();
312+
}
313+
})
314+
.register();
295315
}
296316

297317
@Override
@@ -331,8 +351,18 @@ public void onActivityPaused(Activity activity) {
331351
public void onActivityStopped(Activity activity) {
332352
//统一于滑动返回动画
333353
if (activity.isFinishing()) {
334-
// activity.overridePendingTransition(0, R.anim.bga_sbl_activity_swipeback_exit);
354+
activity.overridePendingTransition(0, R.anim.fast_activity_swipeback_exit);
355+
}
356+
}
357+
358+
@Override
359+
public void onActivityDestroyed(Activity activity) {
360+
super.onActivityDestroyed(activity);
361+
Activity previous = FastStackUtil.getInstance().getPrevious();
362+
if (previous != null && previous instanceof SwipeBackActivity) {
363+
return;
335364
}
365+
SlideBack.unregister(activity);
336366
}
337367
};
338368
}
@@ -394,16 +424,6 @@ private void setStatusBarActivity(Activity activity) {
394424
imageView.setPadding(SizeUtil.dp2px(15), SizeUtil.dp2px(4), SizeUtil.dp2px(4), SizeUtil.dp2px(4));
395425
}
396426
}
397-
// RxJavaManager.getInstance().setTimer(100)
398-
// .subscribe(new FastObserver<Long>() {
399-
// @Override
400-
// public void _onNext(Long entity) {
401-
// if (isLeak(activity)) {
402-
// return;
403-
// }
404-
// StatusBarUtil.setStatusBarLightMode(activity);
405-
// }
406-
// });
407427
}
408428

409429
/**
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package com.aries.library.fast.demo.impl;
2+
3+
import android.app.Activity;
4+
5+
import com.aries.library.fast.demo.R;
6+
import com.aries.library.fast.demo.module.main.sample.SwipeBackActivity;
7+
import com.aries.library.fast.i.SwipeBackControl;
8+
import com.aries.library.fast.util.FastStackUtil;
9+
10+
import cn.bingoogolapple.swipebacklayout.BGASwipeBackHelper;
11+
import cn.bingoogolapple.swipebacklayout.BGASwipeBackLayout;
12+
13+
/**
14+
* @Author: AriesHoo on 2018/12/4 18:00
15+
* @E-Mail: AriesHoo@126.com
16+
* @Function: 滑动返回处理-鉴于现在全面屏比较多不推荐使用该库;推荐使用使用类全面屏手势滑动返回库
17+
* 可参考{@link ActivityControlImpl#getActivityLifecycleCallbacks()}
18+
* @Description:
19+
*/
20+
public class SwipeBackControlImpl implements SwipeBackControl {
21+
22+
/**
23+
* 设置当前Activity是否支持滑动返回(用于控制是否添加一层{@link BGASwipeBackLayout})
24+
* 返回为true {@link #setSwipeBack(Activity, BGASwipeBackHelper)}才有设置的意义
25+
*
26+
* @param activity
27+
* @return
28+
*/
29+
@Override
30+
public boolean isSwipeBackEnable(Activity activity) {
31+
Activity previous = FastStackUtil.getInstance().getPrevious();
32+
return previous != null && previous instanceof SwipeBackActivity;
33+
}
34+
35+
/**
36+
* 设置Activity 全局滑动属性--包括三方库
37+
*
38+
* @param activity
39+
* @param swipeBackHelper BGASwipeBackHelper 控制详见{@link com.aries.library.fast.FastManager}
40+
*/
41+
@Override
42+
public void setSwipeBack(Activity activity, BGASwipeBackHelper swipeBackHelper) {
43+
//以下为默认设置
44+
//需设置activity window背景为透明避免滑动过程中漏出背景也可减少背景层级降低过度绘制
45+
activity.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
46+
swipeBackHelper.setSwipeBackEnable(true)
47+
.setShadowResId(R.drawable.bga_sbl_shadow);
48+
}
49+
50+
@Override
51+
public void onSwipeBackLayoutSlide(Activity activity, float slideOffset) {
52+
53+
}
54+
55+
@Override
56+
public void onSwipeBackLayoutCancel(Activity activity) {
57+
58+
}
59+
60+
@Override
61+
public void onSwipeBackLayoutExecuted(Activity activity) {
62+
63+
}
64+
}
Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<LinearLayout
3-
xmlns:android="http://schemas.android.com/apk/res/android"
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
43
android:id="@+id/lLayout_containerSwipeBack"
54
android:layout_width="match_parent"
65
android:layout_height="match_parent"
76
android:orientation="vertical"
87
android:overScrollMode="never">
98

10-
<include layout="@layout/fast_layout_title_bar"/>
9+
<include layout="@layout/fast_layout_title_bar" />
10+
11+
<TextView
12+
android:id="@+id/tv_tipFastView"
13+
android:layout_width="match_parent"
14+
android:layout_height="wrap_content"
15+
android:lineSpacingExtra="12dp"
16+
android:padding="10dp"
17+
android:text="@string/swipe_back_tip"
18+
android:textColor="@color/colorTitleText"
19+
android:textSize="16dp" />
1120

1221
<com.aries.ui.view.radius.RadiusTextView
1322
android:id="@+id/rtv_swipe"
1423
style="@style/RadiusTextStyle"
15-
android:text="@string/swipe_back_style"/>
24+
android:text="@string/swipe_back_style" />
1625

1726
</LinearLayout>

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ ext{
3232
targetSdkVersion = 28
3333
supportVersion = "1.0.0"
3434
widgetVersion = "3.2.24"
35-
versionCode = 244
36-
versionName = "2.3.0"
35+
versionCode = 245
36+
versionName = "2.3.1"
3737
}

0 commit comments

Comments
 (0)