diff --git a/module_common/src/main/java/com/gh/gamecenter/common/base/activity/BaseActivity.java b/module_common/src/main/java/com/gh/gamecenter/common/base/activity/BaseActivity.java index 9c993acd22..8ac66a7f12 100644 --- a/module_common/src/main/java/com/gh/gamecenter/common/base/activity/BaseActivity.java +++ b/module_common/src/main/java/com/gh/gamecenter/common/base/activity/BaseActivity.java @@ -196,8 +196,8 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy startPageTime = System.currentTimeMillis(); if (BuildConfig.IS_DARK_MODE_ON - && !DarkModeUtils.INSTANCE.isFollowSystemDarkModeFromSp() - && mIsDarkModeOn != DarkModeUtils.INSTANCE.isDarkModeOn(this)) { + && !DarkModeUtils.INSTANCE.isFollowSystemDarkModeFromSp() + && mIsDarkModeOn != DarkModeUtils.INSTANCE.isDarkModeOn(this)) { onDarkModeChanged(); } } @@ -280,7 +280,7 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy if (PackageFlavorHelper.IS_TEST_FLAVOR) { RelativeLayout screenRootView = new RelativeLayout(this); screenRootView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); - + LinearLayout ll = new LinearLayout(this); TextView tv = new TextView(this); String envText = "正式环境"; @@ -303,21 +303,21 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy ll.setRotation(45); ll.addView(tv); ll.setPadding(0, (width - height) / 2, 0, (width - height) / 2); - + if (BuildConfig.DEBUG) { tv.setOnLongClickListener(v -> { IEntranceUtilsProvider entranceUtilsProvider = (IEntranceUtilsProvider) ARouter.getInstance() - .build(RouteConsts.provider.entranceUtils) - .navigation(); + .build(RouteConsts.provider.entranceUtils) + .navigation(); entranceUtilsProvider.saveShortcut(this.getClass().getName(), getIntent().getExtras()); return true; }); } - + screenRootView.addView(view); screenRootView.addView(ll); screenRootView.addView(getDarkModeIndicatorView()); - + RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) ll.getLayoutParams(); lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); view.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); @@ -538,7 +538,7 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy @Override public Pair getBusinessId() { - return new Pair("", ""); + return new Pair<>("", ""); } @Override @@ -562,13 +562,13 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { getWindow().getDecorView().setBackgroundColor(ContextCompat.getColor(this, R.color.background)); - getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.background)); + getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.background_white)); } } } protected boolean isAutoResetViewBackgroundEnabled() { - return false; + return true; } /** @@ -577,7 +577,7 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy * @param view 父 view */ protected void updateStaticViewBackground(View view) { - BaseActivity.updateStaticView(view, new ArrayList<>()); + updateStaticView(view, new ArrayList<>()); } public static void updateStaticView(View view, List blackList) { @@ -608,11 +608,7 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy if (backgroundString != null) { if (backgroundString.startsWith("#")) return; - int backgroundId = Integer.parseInt( - backgroundString - .replace("@", "") - .replace("?", "") - ); + int backgroundId = getIntFromString(backgroundString); if (backgroundId != 0) { try { @@ -632,11 +628,7 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy if (textColorString != null && view instanceof TextView) { if (textColorString.startsWith("#")) return; - int textColorId = Integer.parseInt( - textColorString - .replace("@", "") - .replace("?", "") - ); + int textColorId = getIntFromString(textColorString); if (textColorId != 0) { try { @@ -645,17 +637,12 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy } catch (Exception e) { e.printStackTrace(); } - } } if (textColorHintString != null && view instanceof EditText) { if (textColorHintString.startsWith("#")) return; - int textColorHintId = Integer.parseInt( - textColorHintString - .replace("@", "") - .replace("?", "") - ); + int textColorHintId = getIntFromString(textColorHintString); if (textColorHintId != 0) { try { @@ -669,11 +656,7 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy if (view instanceof ImageView && srcString != null) { if (srcString.startsWith("#")) return; - int srcId = Integer.parseInt( - srcString - .replace("@", "") - .replace("?", "") - ); + int srcId = getIntFromString(srcString); if (srcId != 0) { ((ImageView) view).setImageResource(srcId); } @@ -686,44 +669,28 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy Drawable drawableBottom = null; if (drawableLeftString != null) { if (drawableLeftString.startsWith("#")) return; - int drawableLeftId = Integer.parseInt( - drawableLeftString - .replace("@", "") - .replace("?", "") - ); + int drawableLeftId = getIntFromString(drawableLeftString); if (drawableLeftId != 0) { drawableLeft = ExtensionsKt.toDrawable(drawableLeftId, context); } } if (drawableTopString != null) { if (drawableTopString.startsWith("#")) return; - int drawableTopId = Integer.parseInt( - drawableTopString - .replace("@", "") - .replace("?", "") - ); + int drawableTopId = getIntFromString(drawableTopString); if (drawableTopId != 0) { drawableTop = ExtensionsKt.toDrawable(drawableTopId, context); } } if (drawableRightString != null) { if (drawableRightString.startsWith("#")) return; - int drawableRightId = Integer.parseInt( - drawableRightString - .replace("@", "") - .replace("?", "") - ); + int drawableRightId = getIntFromString(drawableRightString); if (drawableRightId != 0) { drawableRight = ExtensionsKt.toDrawable(drawableRightId, context); } } if (drawableBottomString != null) { if (drawableBottomString.startsWith("#")) return; - int drawableBottomId = Integer.parseInt( - drawableBottomString - .replace("@", "") - .replace("?", "") - ); + int drawableBottomId = getIntFromString(drawableBottomString); if (drawableBottomId != 0) { drawableBottom = ExtensionsKt.toDrawable(drawableBottomId, context); } @@ -733,4 +700,8 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy } } } + + private static int getIntFromString(String rawString) { + return Integer.parseInt(rawString.replace("@", "").replace("?", "")); + } }