Skip to content

Commit f1f1713

Browse files
AriesHooAriesHoo
AriesHoo
authored and
AriesHoo
committed
修复:修改FastUtil startActivity 方法增加singletag设置方法setActivitySingleFlag(int)
1 parent 27931b0 commit f1f1713

File tree

7 files changed

+36
-23
lines changed

7 files changed

+36
-23
lines changed

apk/sample.apk

716 Bytes
Binary file not shown.

apk/update

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"versionCode": 235,
3-
"versionName": "2.2.10-beta25",
2+
"versionCode": 237,
3+
"versionName": "2.2.10-beta27",
44
"url": "https://raw.githubusercontent.com/AriesHoo/FastLib/master/apk/sample.apk",
55
"force": true,
66
"size": "3.77M",

app/src/main/java/com/aries/library/fast/demo/helper/TitleBarViewHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public TitleBarViewHelper setRecyclerView(RecyclerView recyclerView) {
7070
@Override
7171
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
7272
super.onScrolled(recyclerView, dx, dy);
73-
mScrollY += dy;
73+
mScrollY = recyclerView.computeVerticalScrollOffset();
7474
mAlpha = setChange(mScrollY);
7575
}
7676
});

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,7 @@ public int getContentLayout() {
8282
public void setTitleBar(TitleBarView titleBar) {
8383
titleBar.setBgColor(Color.WHITE)
8484
.setTitleMainTextColor(Color.WHITE)
85-
.setTitleMainText(R.string.mine)
86-
.setLeftTextDrawable(R.drawable.ic_setting)
87-
.setOnLeftTextClickListener(new View.OnClickListener() {
88-
@Override
89-
public void onClick(View v) {
90-
FastUtil.startActivity(mContext, SettingActivity.class);
91-
}
92-
});
85+
.setTitleMainText(R.string.mine);
9386
titleBar.getBackground().setAlpha(0);
9487
}
9588

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ ext{
3333
minSdkVersion = 21
3434
targetSdkVersion = 28
3535
supportVersion = "28.0.0"
36-
versionCode = 235
37-
versionName = "2.2.10-beta25"
36+
versionCode = 237
37+
versionName = "2.2.10-beta27"
3838
}

library/src/main/java/com/aries/library/fast/module/activity/FastWebActivity.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import android.graphics.Color;
66
import android.os.Bundle;
77
import android.support.annotation.ColorInt;
8+
import android.support.v4.content.ContextCompat;
89
import android.support.v7.app.AlertDialog;
910
import android.util.TypedValue;
1011
import android.view.KeyEvent;
@@ -107,17 +108,17 @@ public void onClick(View v) {
107108
}
108109
})
109110
.setRightTextDrawable(FastUtil.getTintDrawable(
110-
getResources().getDrawable(R.drawable.fast_ic_more),
111-
getResources().getColor(R.color.colorTitleText)))
111+
ContextCompat.getDrawable(mContext, R.drawable.fast_ic_more),
112+
ContextCompat.getColor(mContext, R.color.colorTitleText)))
112113
.setOnRightTextClickListener(new View.OnClickListener() {
113114
@Override
114115
public void onClick(View v) {
115116
showActionSheet();
116117
}
117118
})
118119
.addLeftAction(titleBar.new ImageAction(
119-
FastUtil.getTintDrawable(getResources().getDrawable(R.drawable.fast_ic_close),
120-
getResources().getColor(R.color.colorTitleText)), new View.OnClickListener() {
120+
FastUtil.getTintDrawable(ContextCompat.getDrawable(mContext, R.drawable.fast_ic_close),
121+
ContextCompat.getColor(mContext, R.color.colorTitleText)), new View.OnClickListener() {
121122
@Override
122123
public void onClick(View v) {
123124
showDialog();
@@ -222,27 +223,33 @@ public boolean onKeyDown(int keyCode, KeyEvent event) {
222223

223224
@Override
224225
public void onBackPressed() {
225-
if (mAgentWeb.back()) {
226+
if (mAgentWeb != null && mAgentWeb.back()) {
226227
return;
227228
}
228229
super.onBackPressed();
229230
}
230231

231232
@Override
232233
protected void onPause() {
233-
mAgentWeb.getWebLifeCycle().onPause();
234+
if (mAgentWeb != null) {
235+
mAgentWeb.getWebLifeCycle().onPause();
236+
}
234237
super.onPause();
235238
}
236239

237240
@Override
238241
protected void onResume() {
239-
mAgentWeb.getWebLifeCycle().onResume();
242+
if (mAgentWeb != null) {
243+
mAgentWeb.getWebLifeCycle().onResume();
244+
}
240245
super.onResume();
241246
}
242247

243248
@Override
244249
protected void onDestroy() {
245-
mAgentWeb.getWebLifeCycle().onDestroy();
250+
if (mAgentWeb != null) {
251+
mAgentWeb.getWebLifeCycle().onDestroy();
252+
}
246253
super.onDestroy();
247254
}
248255
}

library/src/main/java/com/aries/library/fast/util/FastUtil.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,12 @@
3131
* Description:
3232
* 1、将startActivity 参数Activity 改为Context
3333
* 2、2018-7-23 09:29:55 新增获取App 应用名称方法
34+
* 3、2019-2-15 11:28:53 修改startActivity 方法增加single tag设置方法{@link #setActivitySingleFlag(int)}
3435
*/
3536
public class FastUtil {
3637

38+
private static int ACTIVITY_SINGLE_FLAG = Intent.FLAG_ACTIVITY_SINGLE_TOP;
39+
3740
/**
3841
* 获取应用名称
3942
*
@@ -230,6 +233,17 @@ public static void jumpMarket(Context mContext, String packageName) {
230233
}
231234
}
232235

236+
/**
237+
* 设置Activity只启动一个Flag
238+
*
239+
* @param flag {@link Intent#FLAG_ACTIVITY_SINGLE_TOP}
240+
* {@link Intent#FLAG_ACTIVITY_NEW_TASK}
241+
* {@link Intent#FLAG_ACTIVITY_CLEAR_TOP}
242+
*/
243+
public static void setActivitySingleFlag(int flag) {
244+
ACTIVITY_SINGLE_FLAG = flag;
245+
}
246+
233247
/**
234248
* @param context
235249
* @param activity 跳转Activity
@@ -241,8 +255,7 @@ public static void startActivity(Context context, Class<? extends Activity> acti
241255
return;
242256
}
243257
Intent intent = new Intent(context, activity);
244-
intent.setFlags(isSingle ? Intent.FLAG_ACTIVITY_NEW_TASK
245-
| Intent.FLAG_ACTIVITY_CLEAR_TOP : Intent.FLAG_ACTIVITY_NEW_TASK);
258+
intent.setFlags(isSingle ? ACTIVITY_SINGLE_FLAG : Intent.FLAG_ACTIVITY_NEW_TASK);
246259
if (bundle != null) {
247260
intent.putExtras(bundle);
248261
}

0 commit comments

Comments
 (0)