Skip to content

Commit 8b5c027

Browse files
committed
1、全新优化NavigationViewHelper
2、修复滑动返回与tab冲突BUG 3、必须Application设置全局滑动返回是否开启setSwipeBackEnable(boolean, this)
1 parent 815d862 commit 8b5c027

File tree

11 files changed

+31
-46
lines changed

11 files changed

+31
-46
lines changed

apk/sample.apk

-260 Bytes
Binary file not shown.

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ android {
1515
minSdkVersion ext.minSdkVersion
1616
targetSdkVersion ext.targetSdkVersion
1717
versionCode 229
18-
versionName "2.2.9-beta2"
18+
versionName "2.2.9-beta3"
1919
multiDexEnabled true
2020
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
2121
buildConfigField "String", "BASE_URL", "\"https://api.douban.com/\""

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ public void onCreate() {
8282
//全局主页面返回键操作设置--推荐先获取library里默认主页面点击返回键配置FastQuitConfigEntity配置再按需修改的模式 FastQuitConfigEntity
8383
FastQuitConfigEntity quitConfig = FastConfig.getInstance(mContext).getQuitConfig();
8484
FastConfig.getInstance(mContext)
85+
//设置Activity是否支持滑动返回-添加透明主题参考Demo样式;
86+
//说明该配置必填--注意注意
87+
.setSwipeBackEnable(true, this)
8588
// 设置全局TitleBarView-其它属性请查看getInstance默认设置
8689
.setTitleConfig(titleConfig
8790
//设置TitleBarView 所有TextView颜色
@@ -108,8 +111,6 @@ public void onCreate() {
108111
.setPlaceholderColor(getResources().getColor(R.color.colorPlaceholder))
109112
//设置Glide圆角背景弧度
110113
.setPlaceholderRoundRadius(mContext.getResources().getDimension(R.dimen.dp_placeholder_radius))
111-
//设置Activity是否支持滑动返回-添加透明主题参考Demo样式;
112-
.setSwipeBackEnable(true, this)
113114
//设置Activity横竖屏模式
114115
.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)
115116
//设置Activity或Fragment根布局背景资源

app/src/main/java/com/aries/library/fast/demo/module/main/MainActivity.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ public boolean isSwipeEnable() {
3030
return false;
3131
}
3232

33-
@Override
34-
protected boolean isSwipeBackEnable() {
35-
return true;
36-
}
37-
3833
@Override
3934
public int getContentBackground() {
4035
return 0;

app/src/main/java/com/aries/library/fast/demo/module/main/sample/SwipeBackActivity.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ public static void start(Activity mActivity, String title) {
3232
FastUtil.startActivity(mActivity, SwipeBackActivity.class, bundle, false);
3333
}
3434

35+
@Override
36+
protected boolean isSwipeBackEnable() {
37+
return true;
38+
}
39+
3540
@Override
3641
public boolean isLightStatusBarEnable() {
3742
return false;

app/src/main/java/com/aries/library/fast/demo/module/main/sample/ali/ALiPayMainActivity.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ public class ALiPayMainActivity extends FastMainActivity {
2323
@BindView(R.id.tabLayout_commonFastLib) CommonTabLayout mTabLayout;
2424
String[] titles;
2525

26-
@Override
27-
protected boolean isSwipeBackEnable() {
28-
return true;
29-
}
30-
3126
@Override
3227
public List<FastTabEntity> getTabList() {
3328
ArrayList<FastTabEntity> list = new ArrayList<>();

app/src/main/java/com/aries/library/fast/demo/module/main/sample/news/NewsMainActivity.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ public boolean isSwipeEnable() {
2424
return false;
2525
}
2626

27-
@Override
28-
protected boolean isSwipeBackEnable() {
29-
return true;
30-
}
31-
3227
@Override
3328
public List<FastTabEntity> getTabList() {
3429
titles = getResources().getStringArray(R.array.arrays_tab_news);

library/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ android {
99
minSdkVersion 15
1010
targetSdkVersion 25
1111
versionCode 229
12-
versionName "2.2.9-beta2"
12+
versionName "2.2.9-beta3"
1313
}
1414
buildTypes {
1515
release {

library/src/main/java/com/aries/library/fast/FastConfig.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ public NavigationViewHelper createNavigationBarControl(Activity activity, View b
172172
});
173173
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
174174
setContentViewBackgroundResource(-1);
175-
setSwipeBackEnable(false, null);
176175
setPlaceholderColor(getColor(R.color.colorPlaceholder));
177176
setPlaceholderRoundRadius(mContext.getResources().getDimension(R.dimen.dp_placeholder_radius));
178177
}
@@ -297,11 +296,11 @@ public boolean isSwipeBackEnable() {
297296
* 最终调用{@link BasisActivity#initSwipeBack()}
298297
*
299298
* @param swipeBackEnable
300-
* @param application swipeBackEnable为true application必传
299+
* @param application application必传
301300
* @return
302301
*/
303302
public FastConfig setSwipeBackEnable(boolean swipeBackEnable, Application application) {
304-
if (swipeBackEnable && application == null) {
303+
if (application == null) {
305304
throw new NullPointerException(FastConstant.EXCEPTION_SWIPE_BACK_APPLICATION_NOT_NULL);
306305
}
307306
mIsSwipeBackEnable = swipeBackEnable;

library/src/main/java/com/aries/library/fast/basis/BasisActivity.java

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -140,29 +140,27 @@ private void initSwipeBack() {
140140
LoggerManager.e(TAG, "initSwipeBack:Please compile 'cn.bingoogolapple:bga-swipebacklayout:1.1.1@aar' in app main program");
141141
return;
142142
}
143-
if (isSwipeBackEnable()) {
144-
mSwipeBackHelper = new BGASwipeBackHelper(this, new BGASwipeBackHelper.Delegate() {
145-
@Override
146-
public boolean isSupportSwipeBack() {
147-
return true;
148-
}
143+
mSwipeBackHelper = new BGASwipeBackHelper(this, new BGASwipeBackHelper.Delegate() {
144+
@Override
145+
public boolean isSupportSwipeBack() {
146+
return true;
147+
}
149148

150-
@Override
151-
public void onSwipeBackLayoutSlide(float slideOffset) {
152-
}
149+
@Override
150+
public void onSwipeBackLayoutSlide(float slideOffset) {
151+
}
153152

154-
@Override
155-
public void onSwipeBackLayoutCancel() {
153+
@Override
154+
public void onSwipeBackLayoutCancel() {
156155

157-
}
156+
}
158157

159-
@Override
160-
public void onSwipeBackLayoutExecuted() {
161-
//滑动返回执行完毕,销毁当前 Activity
162-
mSwipeBackHelper.swipeBackward();
163-
}
164-
});
165-
}
158+
@Override
159+
public void onSwipeBackLayoutExecuted() {
160+
//滑动返回执行完毕,销毁当前 Activity
161+
mSwipeBackHelper.swipeBackward();
162+
}
163+
}).setSwipeBackEnable(isSwipeBackEnable());
166164
}
167165

168166
@Override

library/src/main/java/com/aries/library/fast/helper/NavigationViewHelper.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,9 @@ public void init() {
178178
&& ((!mPlusNavigationViewEnable && mTransEnable) || mPlusNavigationViewEnable)) {
179179
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
180180
window.getDecorView().setSystemUiVisibility(window.getDecorView().getSystemUiVisibility() |
181-
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
181+
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
182182
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
183-
window.setNavigationBarColor(Color.TRANSPARENT);
184-
if (mTransEnable && !mPlusNavigationViewEnable) {
185-
window.setNavigationBarColor(mNavigationViewColor);
186-
}
183+
window.setNavigationBarColor(!mPlusNavigationViewEnable ? mNavigationViewColor : Color.TRANSPARENT);
187184
}
188185
SPUtil.put(activity, activity.getClass().getSimpleName() + "0", mTransEnable);
189186
SPUtil.put(activity, activity.getClass().getSimpleName() + "1", mPlusNavigationViewEnable);

0 commit comments

Comments
 (0)