Compare commits
172 Commits
v5.8.0-510
...
feature-is
| Author | SHA1 | Date | |
|---|---|---|---|
| 8a7d588206 | |||
| 42ae45c743 | |||
| 3246dd0d70 | |||
| 06ac1fd8b0 | |||
| 81da40d786 | |||
| 9eb919b3cf | |||
| b4cbff3d6a | |||
| c7dfac8f46 | |||
| 08af4a99f8 | |||
| f3a358eb2d | |||
| 6abac72ee7 | |||
| b027c57a7c | |||
| 84b876394d | |||
| 3fb031c329 | |||
| e46afac397 | |||
| fdf2c80667 | |||
| d12a1037a2 | |||
| 056400d4d1 | |||
| 26cbdeaf2d | |||
| 6a5f7f8284 | |||
| f272e486f8 | |||
| 7b0514c055 | |||
| 909e7f33a8 | |||
| 677511b119 | |||
| 26a2605cd7 | |||
| b02f650a34 | |||
| e1d82e7fbd | |||
| 4263f53315 | |||
| f235959372 | |||
| 7bc6655b99 | |||
| 7ecc227df5 | |||
| 3046d33f91 | |||
| a32829fd0d | |||
| 4819bf3ddf | |||
| c2e02d356d | |||
| dafaeef184 | |||
| a9917c9201 | |||
| c0b61822c0 | |||
| a16a16cbdf | |||
| 0decb62237 | |||
| cdedea5002 | |||
| 88c4ebe5a0 | |||
| 10cbcdd768 | |||
| 7afbfb30a2 | |||
| 090a567887 | |||
| e55faee9fe | |||
| 362e34be8a | |||
| bf1e5586b0 | |||
| bad10158bd | |||
| 5cc58e2182 | |||
| fd836137a5 | |||
| b122e460cc | |||
| 3b29fcbef7 | |||
| 9f60a2ba86 | |||
| 8df7b3d9ee | |||
| e2040f9a2d | |||
| e39cd494b5 | |||
| f70b721441 | |||
| 877acf54f4 | |||
| a31d7a06f7 | |||
| f52937830b | |||
| b5202cc931 | |||
| dd2bfbc53f | |||
| d2f3cdadf6 | |||
| 73a88f9099 | |||
| a86c957872 | |||
| 45588a2580 | |||
| 3b55269319 | |||
| 01966a87ec | |||
| b4a8e5c68d | |||
| aeb7842299 | |||
| e0bcf947bf | |||
| 30bf685962 | |||
| 1e6fa023dc | |||
| b5920fc409 | |||
| 16ceb7115e | |||
| 279ed66270 | |||
| 9bfa8a33c8 | |||
| 99bd4da08a | |||
| 4824814981 | |||
| 10237d2fde | |||
| c1b236080e | |||
| 83d16a16b8 | |||
| 52ccffb97a | |||
| 9ed9e22df4 | |||
| 5aa29782cc | |||
| 82fcde1245 | |||
| eab945acfc | |||
| 8ed57cbfb8 | |||
| d3ed6d750b | |||
| bb4878eab4 | |||
| 53d8444c85 | |||
| 7db009a3cd | |||
| 4932fc2d7b | |||
| ca55ac02b7 | |||
| c535ffb2e0 | |||
| 9c6eb22d9d | |||
| 9ec6ec0281 | |||
| 327441e62b | |||
| ae3f07a3ee | |||
| f967e1f283 | |||
| ba1308c568 | |||
| 3144e3b007 | |||
| ec1c5713ad | |||
| 15adc93340 | |||
| c9b27f6ebe | |||
| cff7f7d2e2 | |||
| cb5d0c4840 | |||
| dea6abe399 | |||
| 20c792d4fa | |||
| b8cbd5a0fb | |||
| 0a34f23e62 | |||
| 7413b4e4ac | |||
| d2025c32c9 | |||
| 5c5dd35409 | |||
| b509e9046e | |||
| 46e99434c9 | |||
| b6ff94aed3 | |||
| 25e0bd19bc | |||
| fe5b398fad | |||
| 417ed1401e | |||
| 48698f06cd | |||
| b70a7eaf8b | |||
| ad86d7bbcc | |||
| a2eb550099 | |||
| e736855a4a | |||
| 0b49f531ac | |||
| c36f4d9abf | |||
| db72b0a5c9 | |||
| b19d21fc39 | |||
| 2d172d70ad | |||
| cc434771c0 | |||
| f5a9502261 | |||
| c48d970b0a | |||
| 9a53c7a84e | |||
| ce17ae2d2b | |||
| d97f65e9b3 | |||
| 9f1f3a2d66 | |||
| 4c9609ba52 | |||
| edc326ff3c | |||
| 819beb779c | |||
| de31dcaf0b | |||
| 587c217b7c | |||
| b03e86f903 | |||
| ea80942937 | |||
| 06153cbf58 | |||
| 0b94f777a2 | |||
| ed80533198 | |||
| 4b5c741ff9 | |||
| 0e9f267117 | |||
| 02bb977cc0 | |||
| c4a89b9302 | |||
| edcb4a949e | |||
| a5c113e527 | |||
| 048bdbc367 | |||
| 1e287f56e2 | |||
| 2aacab80a6 | |||
| a052f981c5 | |||
| 021886c3cb | |||
| a406127cda | |||
| f761715ebd | |||
| 9303f534d9 | |||
| 0ef0ed7c50 | |||
| 220fd340ce | |||
| d0ad110d9e | |||
| 006f71def7 | |||
| 047dc9a7ae | |||
| 01eb074df1 | |||
| f6473b0e5e | |||
| e244797e7d | |||
| 89f8aebefe | |||
| 52eca3b1ab |
@ -44,6 +44,7 @@ android {
|
||||
|
||||
defaultConfig {
|
||||
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
multiDexEnabled true
|
||||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
@ -88,8 +89,10 @@ android {
|
||||
|
||||
/**
|
||||
* Build Time 供区分 jenkins 打包时间用
|
||||
* IS_NIGHT_MODE_ON 供区分夜间模式功能是否启用
|
||||
*/
|
||||
buildConfigField "long", "BUILD_TIME", "0"
|
||||
buildConfigField "boolean", "IS_NIGHT_MODE_ON", "true"
|
||||
}
|
||||
|
||||
// gradle 2.2以上默认同时启用v1和v2(优先用于Android N)
|
||||
@ -134,7 +137,7 @@ android {
|
||||
variantFilter { variant ->
|
||||
def names = variant.flavors*.name
|
||||
def isDebugType = variant.buildType.name == "debug"
|
||||
if ((names.contains("tea") || name.contains("gdt")) && isDebugType) {
|
||||
if ((names.contains("tea")) && isDebugType) {
|
||||
setIgnore(true)
|
||||
}
|
||||
}
|
||||
@ -151,9 +154,6 @@ android {
|
||||
tea {
|
||||
java.srcDirs = ['src/main/java', 'src/tea/java']
|
||||
}
|
||||
gdt {
|
||||
java.srcDirs = ['src/main/java', 'src/gdt/java']
|
||||
}
|
||||
}
|
||||
|
||||
productFlavors {
|
||||
@ -182,13 +182,6 @@ android {
|
||||
|
||||
manifestPlaceholders.put("APPLOG_SCHEME", "rangersapplog.byAx6uYt".toLowerCase())
|
||||
}
|
||||
|
||||
gdt {
|
||||
dimension "env"
|
||||
|
||||
buildConfigField "String", "DEV_API_HOST", "\"${API_HOST}\""
|
||||
buildConfigField "String", "NEW_DEV_API_HOST", "\"${NEW_API_HOST}\""
|
||||
}
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
@ -206,7 +199,6 @@ repositories {
|
||||
dependencies {
|
||||
|
||||
implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
|
||||
gdtImplementation fileTree(include: ['*.jar', '*.aar'], dir: 'src/gdt/libs')
|
||||
|
||||
testImplementation 'junit:junit:4.12'
|
||||
|
||||
@ -603,4 +595,4 @@ project.afterEvaluate {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -220,10 +220,6 @@
|
||||
-keepattributes Signature
|
||||
-keepattributes Annotation
|
||||
|
||||
### 广点通
|
||||
-dontwarn com.qq.gdt.action.**
|
||||
-keep class com.qq.gdt.action.** {*;}
|
||||
|
||||
### AndroidX
|
||||
-keep class androidx.core.app.CoreComponentFactory { *; }
|
||||
|
||||
@ -267,5 +263,4 @@
|
||||
-keep class com.ut.**{*;}
|
||||
-keep class com.ta.**{*;}
|
||||
|
||||
-keep class com.gh.gamecenter.GdtHelper { *; }
|
||||
-keep class com.gh.gamecenter.TeaHelper { *; }
|
||||
@ -94,10 +94,6 @@
|
||||
@androidx.annotation.Keep *;
|
||||
}
|
||||
|
||||
### 广点通
|
||||
-dontwarn com.qq.gdt.action.**
|
||||
-keep class com.qq.gdt.action.* {*;}
|
||||
|
||||
### 阿里云上传
|
||||
-keep class com.alibaba.sdk.android.oss.* { *; }
|
||||
-dontwarn okio.**
|
||||
@ -124,8 +120,7 @@
|
||||
-keep class com.ut.*{*;}
|
||||
-keep class com.ta.*{*;}
|
||||
|
||||
### GDT & TEA
|
||||
-keep class com.gh.gamecenter.GdtHelper { *; }
|
||||
### TEA
|
||||
-keep class com.gh.gamecenter.TeaHelper { *; }
|
||||
|
||||
### 阿里云日志
|
||||
|
||||
@ -1,77 +0,0 @@
|
||||
package com.gh.gamecenter
|
||||
|
||||
import android.app.Application
|
||||
import android.text.TextUtils
|
||||
import android.util.Log
|
||||
import com.gh.common.util.ToastUtils
|
||||
import com.lightgame.utils.Utils
|
||||
import com.qq.gdt.action.GDTAction
|
||||
import org.json.JSONObject
|
||||
|
||||
/**
|
||||
* 广点通辅助类 [https://gitlab.ghzhushou.com/pm/halo-app-issues/issues/403]
|
||||
*
|
||||
* 更换帐号 [https://gitlab.ghzs.com/pm/yunying/issues/893]
|
||||
*/
|
||||
object GdtHelper {
|
||||
|
||||
const val NETWORK_TYPE = "NETWORK_TYPE"
|
||||
const val PAGE_TYPE = "PAGE_TYPE"
|
||||
const val CONTENT_TYPE = "CONTENT_TYPE"
|
||||
const val CONTENT_ID = "CONTENT_ID"
|
||||
const val KEYWORD = "KEYWORD"
|
||||
const val GAME_ID = "GAME_ID"
|
||||
const val SCORE = "SCORE"
|
||||
const val PLATFORM = "PLATFORM"
|
||||
|
||||
@JvmStatic
|
||||
fun init(application: Application, channel: String) {
|
||||
if (shouldUseGdtHelper()) {
|
||||
if (channel == "GH_728") {
|
||||
GDTAction.init(application, "1111012969", "9d3d9da5b0948a317c03d08f14d445dc")
|
||||
} else if (channel == "GH_729") {
|
||||
GDTAction.init(application, "1111013063", "f53dabf458a356b101d99fc4069eb7f1")
|
||||
} else if (channel == "GH_765") {
|
||||
GDTAction.init(application, "1111327925", "588d503f0990f98f9b2394fbb795c570")
|
||||
} else {
|
||||
GDTAction.init(application, "1110680399", "f5ddaafbf520d7d7385499232a408d0a")
|
||||
}
|
||||
}
|
||||
Utils.log("init GdtHelper")
|
||||
}
|
||||
|
||||
// fun logAction(type: String) {
|
||||
// if (shouldUseGdtHelper()) {
|
||||
// GDTAction.logAction(type)
|
||||
// Utils.log("GDT", type)
|
||||
// }
|
||||
// }
|
||||
@JvmStatic
|
||||
fun logAction(type: String, vararg kv: String?) {
|
||||
try {
|
||||
val actionParam = JSONObject()
|
||||
for (i in kv.indices) {
|
||||
if (i % 2 != 0) {
|
||||
val key = kv[i - 1]
|
||||
val value = kv[i]
|
||||
if (!TextUtils.isEmpty(key) && !TextUtils.isEmpty(value)) {
|
||||
actionParam.put(key, value)
|
||||
}
|
||||
}
|
||||
}
|
||||
Utils.log("GDT", "$type + [${kv.joinToString(" , ")}]")
|
||||
GDTAction.logAction(type, actionParam)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
// TODO 确认开启的渠道条件
|
||||
private fun shouldUseGdtHelper(): Boolean {
|
||||
return true
|
||||
//
|
||||
// val channel = HaloApp.getInstance().channel
|
||||
// return !(TextUtils.isEmpty(channel) || channel.contains("GDT".toLowerCase(Locale.CHINA)))
|
||||
}
|
||||
|
||||
}
|
||||
Binary file not shown.
@ -165,7 +165,8 @@
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.WebActivity" />
|
||||
android:name="com.gh.gamecenter.WebActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.SingletonWebActivity"
|
||||
@ -731,6 +732,10 @@
|
||||
android:name="com.gh.gamecenter.toolbox.ToolBoxBlockActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.qa.subject.CommunitySubjectActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="${applicationId}.wxapi.WXEntryActivity"
|
||||
android:exported="true"
|
||||
@ -754,6 +759,12 @@
|
||||
android:resource="@xml/provider_paths" />
|
||||
</provider>
|
||||
|
||||
<provider
|
||||
android:name="com.gh.gamecenter.provider.GhContentProvider"
|
||||
android:authorities="${applicationId}.provider"
|
||||
android:enabled="true"
|
||||
android:exported="true"/>
|
||||
|
||||
<provider
|
||||
android:name="androidx.startup.InitializationProvider"
|
||||
android:authorities="${applicationId}.androidx-startup"
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -280,12 +280,8 @@ RE.replaceAllDfImage = function(imgRuleFlag, gifRuleFlag) {
|
||||
i--;
|
||||
} else {
|
||||
if(img.src.indexOf(".gif") > 0) {
|
||||
if(gifRuleFlag.indexOf(",default") > 0) {
|
||||
img.style.cssText = "max-width: 100%; display:block; margin:8px auto; height: auto;"
|
||||
img.src = img.src.split("?")[0] + gifRuleFlag
|
||||
}
|
||||
img.src = img.src.split("?")[0] + gifRuleFlag
|
||||
} else {
|
||||
img.style.cssText = "max-width: 100%; display:block; margin:8px auto; height: auto;"
|
||||
img.src = img.src.split("?")[0] + imgRuleFlag
|
||||
}
|
||||
}
|
||||
@ -301,7 +297,7 @@ RE.hideShowBigPic = function() {
|
||||
var img = imgs[i];
|
||||
var imageClassName = img.className;
|
||||
if (imageClassName == "image-link" || img.className == "poster") continue;
|
||||
if(img.src.indexOf(",thumbnail") > 0 && img.src.indexOf(".gif") == -1) {
|
||||
if (img.src.indexOf(".gif") == -1) {
|
||||
j++;
|
||||
}
|
||||
}
|
||||
@ -327,7 +323,6 @@ RE.replaceDfImageByUrl = function(imgUrl, imgRuleFlag, gifRuleFlag) {
|
||||
var imageClassName = img.className;
|
||||
if (imageClassName == "image-link" || img.className == "poster") continue;
|
||||
if (img.src.indexOf(imgUrl) != -1) {
|
||||
img.style.cssText = "max-width: 100%; display:block; margin:8px auto; height: auto;"
|
||||
if(img.src.indexOf(".gif") > 0) {
|
||||
img.src = img.src.split("?")[0] + gifRuleFlag
|
||||
} else {
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
package com.gh.base;
|
||||
|
||||
import static com.gh.common.util.EntranceUtils.KEY_ENTRANCE;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
@ -14,6 +17,7 @@ import android.text.TextUtils;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.LinearLayout;
|
||||
@ -21,7 +25,9 @@ import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.view.LayoutInflaterCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
|
||||
@ -33,10 +39,11 @@ import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.EntranceUtils;
|
||||
import com.gh.common.util.EnvHelper;
|
||||
import com.gh.common.util.PackageFlavorHelper;
|
||||
import com.gh.common.util.ExtensionsKt;
|
||||
import com.gh.common.util.MtaHelper;
|
||||
import com.gh.common.util.NetworkUtils;
|
||||
import com.gh.common.util.NightModeUtils;
|
||||
import com.gh.common.util.PackageFlavorHelper;
|
||||
import com.gh.common.util.PackageInstaller;
|
||||
import com.gh.common.util.QuickLoginHelper;
|
||||
import com.gh.common.util.RunningUtils;
|
||||
@ -66,10 +73,8 @@ import java.util.List;
|
||||
import kotlin.Pair;
|
||||
import pub.devrel.easypermissions.EasyPermissions;
|
||||
|
||||
import static com.gh.common.util.EntranceUtils.KEY_ENTRANCE;
|
||||
|
||||
/**
|
||||
* 只提供基础的服务(EventBus/ButterKnife/Share/GlobalDialog/Permissions)
|
||||
* 只提供基础的服务(EventBus/Share/GlobalDialog/Permissions)
|
||||
* <p>
|
||||
* 需要工具栏的页面请继承{@link ToolBarActivity}
|
||||
*/
|
||||
@ -82,12 +87,14 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy
|
||||
public final static String PLUGGABLE = "plugin";
|
||||
public final static String SIGNATURE_CONFLICT = "signature_conflict";
|
||||
public final static int ID_ROOT_INDICATOR = 999;
|
||||
public final static int ID_NIGHT_INDICATOR = 998;
|
||||
public final int MAX_BUNDLE_SIZE = 300;
|
||||
|
||||
@NonNull
|
||||
protected String mEntrance;
|
||||
|
||||
private boolean mIsExistLogoutDialog;
|
||||
protected boolean mNightMode;
|
||||
public long startPageTime = 0;
|
||||
|
||||
protected final Handler mBaseHandler = new BaseHandler(this);
|
||||
@ -127,6 +134,10 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
if (PackageFlavorHelper.IS_TEST_FLAVOR && isAutoResetViewBackgroundEnabled()) {
|
||||
LayoutInflaterCompat.setFactory2(getLayoutInflater(), new CustomLayoutInflaterFactory(this));
|
||||
}
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if (useEventBus()) EventBus.getDefault().register(this);
|
||||
@ -159,12 +170,20 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mNightMode = NightModeUtils.INSTANCE.isNightMode(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
startPageTime = System.currentTimeMillis();
|
||||
|
||||
if (BuildConfig.IS_NIGHT_MODE_ON
|
||||
&& !NightModeUtils.INSTANCE.getSystemMode()
|
||||
&& mNightMode != NightModeUtils.INSTANCE.isNightMode(this)) {
|
||||
onNightModeChange();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@ -255,6 +274,9 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy
|
||||
|
||||
screenRootView.addView(view);
|
||||
screenRootView.addView(ll);
|
||||
if (BuildConfig.IS_NIGHT_MODE_ON) {
|
||||
screenRootView.addView(getNightModeIndicatorView());
|
||||
}
|
||||
|
||||
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) ll.getLayoutParams();
|
||||
lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
|
||||
@ -262,6 +284,80 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy
|
||||
return screenRootView;
|
||||
}
|
||||
|
||||
private View getNightModeIndicatorView() {
|
||||
LinearLayout ll = new LinearLayout(this);
|
||||
TextView tv = new TextView(this);
|
||||
String envText = NightModeUtils.INSTANCE.isNightMode(this) ? "夜间模式" : "日间模式";
|
||||
tv.setBackground(ContextCompat.getDrawable(this, R.color.theme));
|
||||
tv.setText(envText);
|
||||
tv.setGravity(Gravity.CENTER);
|
||||
tv.setTextColor(Color.WHITE);
|
||||
tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13);
|
||||
tv.measure(0, 0);
|
||||
tv.setAlpha(NightModeUtils.INSTANCE.isNightMode(this) ? 0.8F : 0.15F);
|
||||
tv.setId(ID_NIGHT_INDICATOR);
|
||||
int height = tv.getMeasuredHeight();
|
||||
int width = tv.getMeasuredWidth();
|
||||
tv.setPadding(DisplayUtils.dip2px(20), 0, DisplayUtils.dip2px(20), 0);
|
||||
ll.setTranslationX(DisplayUtils.dip2px(-20));
|
||||
ll.setRotation(-45);
|
||||
ll.addView(tv);
|
||||
ll.setPadding(0, (width - height) / 2, 0, (width - height) / 2);
|
||||
|
||||
if (PackageFlavorHelper.IS_TEST_FLAVOR) {
|
||||
tv.setOnClickListener(v -> {
|
||||
//切换深色模式
|
||||
String mode;
|
||||
String positive;
|
||||
String negative;
|
||||
if (NightModeUtils.INSTANCE.getSystemMode()) {
|
||||
mode = "跟随系统模式";
|
||||
positive = "普通模式";
|
||||
negative = "深色模式";
|
||||
} else if (NightModeUtils.INSTANCE.getNightMode()) {
|
||||
mode = "深色模式";
|
||||
positive = "跟随系统模式";
|
||||
negative = "普通模式";
|
||||
} else {
|
||||
mode = "普通模式";
|
||||
positive = "跟随系统模式";
|
||||
negative = "深色模式";
|
||||
}
|
||||
DialogHelper.showCenterDialog(this, "选择模式", "当前为 " + mode, positive, negative, () -> {
|
||||
if (NightModeUtils.INSTANCE.getSystemMode()) {
|
||||
NightModeUtils.INSTANCE.setNightMode(false);
|
||||
NightModeUtils.INSTANCE.setSystemMode(false);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_NO);
|
||||
}
|
||||
} else {
|
||||
NightModeUtils.INSTANCE.setSystemMode(true);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
|
||||
}
|
||||
}
|
||||
NightModeUtils.INSTANCE.initNightMode();
|
||||
}, () -> {
|
||||
if (NightModeUtils.INSTANCE.getSystemMode()) {
|
||||
NightModeUtils.INSTANCE.setNightMode(true);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_YES);
|
||||
}
|
||||
} else {
|
||||
boolean nightMode = NightModeUtils.INSTANCE.getNightMode();
|
||||
NightModeUtils.INSTANCE.setNightMode(!NightModeUtils.INSTANCE.getNightMode());
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
getDelegate().setLocalNightMode(nightMode ? AppCompatDelegate.MODE_NIGHT_NO : AppCompatDelegate.MODE_NIGHT_YES);
|
||||
}
|
||||
}
|
||||
NightModeUtils.INSTANCE.setSystemMode(false);
|
||||
NightModeUtils.INSTANCE.initNightMode();
|
||||
});
|
||||
});
|
||||
}
|
||||
return ll;
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onEventMainThread(final EBShowDialog showDialog) {
|
||||
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED)
|
||||
@ -292,7 +388,8 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy
|
||||
DialogHelper.showCenterDialog(this, "你的账号已在另外一台设备登录"
|
||||
, StringUtils.buildString("(", model, ")")
|
||||
, "知道了", "重新登录"
|
||||
, () -> {}
|
||||
, () -> {
|
||||
}
|
||||
, () -> {
|
||||
if (SPUtils.getBoolean(Constants.SP_HAS_GET_PHONE_INFO) || NetworkUtils.isOpenMobileData(BaseActivity.this)) {
|
||||
QuickLoginHelper.startLogin(BaseActivity.this, "你的账号已在另外一台设备登录多设备-重新登录");
|
||||
@ -445,4 +542,88 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy
|
||||
public Pair<String, String> getBusinessId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(@NonNull Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
onNightModeChange();
|
||||
}
|
||||
|
||||
protected void onNightModeChange() {
|
||||
if (BuildConfig.IS_NIGHT_MODE_ON) {
|
||||
mNightMode = NightModeUtils.INSTANCE.isNightMode(this);
|
||||
TextView tv = findViewById(ID_NIGHT_INDICATOR);
|
||||
if (tv != null) {
|
||||
tv.setText(NightModeUtils.INSTANCE.isNightMode(this) ? "夜间模式" : "日间模式");
|
||||
tv.setAlpha(NightModeUtils.INSTANCE.isNightMode(this) ? 0.8F : 0.15F);
|
||||
}
|
||||
if (isAutoResetViewBackgroundEnabled()) {
|
||||
updateStaticViewBackground(getWindow().getDecorView());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isAutoResetViewBackgroundEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动重置部分 view 的背景颜色/资源
|
||||
*
|
||||
* @param view 父 view
|
||||
*/
|
||||
private void updateStaticViewBackground(View view) {
|
||||
if (view instanceof ViewGroup) {
|
||||
for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
|
||||
View child = ((ViewGroup) view).getChildAt(i);
|
||||
updateStaticViewBackground(child);
|
||||
}
|
||||
}
|
||||
|
||||
String backgroundString = (String) view.getTag(CustomLayoutInflaterFactory.TAG_BACKGROUND_ID);
|
||||
String textColorString = (String) view.getTag(CustomLayoutInflaterFactory.TAG_TEXT_COLOR_ID);
|
||||
if (backgroundString != null) {
|
||||
if (backgroundString.startsWith("#")) return;
|
||||
int backgroundId = Integer.parseInt(
|
||||
backgroundString
|
||||
.replace("@", "")
|
||||
.replace("?", "")
|
||||
);
|
||||
|
||||
if (backgroundId != 0) {
|
||||
try {
|
||||
TypedValue value = new TypedValue();
|
||||
getResources().getValue(backgroundId, value, true);
|
||||
|
||||
if (value.type >= TypedValue.TYPE_FIRST_COLOR_INT && value.type <= TypedValue.TYPE_LAST_COLOR_INT) {
|
||||
view.setBackgroundColor(ExtensionsKt.toColor(backgroundId, this));
|
||||
} else {
|
||||
view.setBackground(ExtensionsKt.toDrawable(backgroundId, this));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (textColorString != null && view instanceof TextView) {
|
||||
if (textColorString.startsWith("#")) return;
|
||||
int textColorId = Integer.parseInt(
|
||||
textColorString
|
||||
.replace("@", "")
|
||||
.replace("?", "")
|
||||
);
|
||||
|
||||
if (textColorId != 0) {
|
||||
try {
|
||||
final ColorStateList colorStateList = ContextCompat.getColorStateList(this, textColorId);
|
||||
((TextView) view).setTextColor(colorStateList);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -15,6 +15,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
@ -98,7 +99,7 @@ public abstract class BaseActivity_TabLayout extends ToolBarActivity implements
|
||||
String tabTitle = tab.getText() != null ? tab.getText().toString() : "";
|
||||
View tabView = provideTabView(i, tabTitle);
|
||||
if (tabView == null)
|
||||
tabView = BaseFragment_TabLayout.createDefaultTabCustomView(tabTitle);
|
||||
tabView = BaseFragment_TabLayout.createDefaultTabCustomView(this, tabTitle);
|
||||
tab.setCustomView(tabView);
|
||||
}
|
||||
|
||||
@ -133,4 +134,22 @@ public abstract class BaseActivity_TabLayout extends ToolBarActivity implements
|
||||
public void onPageScrollStateChanged(int state) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNightModeChange() {
|
||||
super.onNightModeChange();
|
||||
View container = findViewById(R.id.activity_tab_container);
|
||||
if (container != null) {
|
||||
container.setBackgroundColor(ContextCompat.getColor(this, R.color.background_white));
|
||||
for (int i = 0; i < mTabLayout.getTabCount(); i++) {
|
||||
TabLayout.Tab tab = mTabLayout.getTabAt(i);
|
||||
if (tab != null) {
|
||||
BaseFragment_TabLayout.updateTabStyle(tab, tab.isSelected());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mDividerLineView != null) {
|
||||
mDividerLineView.setBackgroundColor(ContextCompat.getColor(this, R.color.divider));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
53
app/src/main/java/com/gh/base/CustomLayoutInflaterFactory.kt
Normal file
53
app/src/main/java/com/gh/base/CustomLayoutInflaterFactory.kt
Normal file
@ -0,0 +1,53 @@
|
||||
package com.gh.base
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.gh.gamecenter.R
|
||||
|
||||
class CustomLayoutInflaterFactory(
|
||||
private val mAppCompatActivity: AppCompatActivity
|
||||
) : LayoutInflater.Factory2 {
|
||||
|
||||
override fun onCreateView(
|
||||
parent: View?,
|
||||
name: String,
|
||||
context: Context,
|
||||
attrs: AttributeSet
|
||||
): View? {
|
||||
|
||||
val view: View?
|
||||
|
||||
try {
|
||||
view = mAppCompatActivity.delegate.createView(parent, name, context, attrs)
|
||||
?: mAppCompatActivity.onCreateView(parent, name, context, attrs)
|
||||
?: mAppCompatActivity.layoutInflater.createView(name, null, attrs)
|
||||
} catch (e: Exception) {
|
||||
return null
|
||||
}
|
||||
|
||||
val n = attrs.attributeCount
|
||||
for (i in 0 until n) {
|
||||
val attributeName = attrs.getAttributeName(i).toString()
|
||||
if (attributeName.contains("background")) {
|
||||
view?.setTag(TAG_BACKGROUND_ID, attrs.getAttributeValue(i))
|
||||
} else if (attributeName.contains("textColor")) {
|
||||
view?.setTag(TAG_TEXT_COLOR_ID, attrs.getAttributeValue(i))
|
||||
}
|
||||
}
|
||||
|
||||
return view
|
||||
}
|
||||
|
||||
override fun onCreateView(name: String, context: Context, attrs: AttributeSet): View? {
|
||||
return mAppCompatActivity.onCreateView(name, context, attrs)
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TAG_BACKGROUND_ID = R.string.background_id
|
||||
const val TAG_TEXT_COLOR_ID = R.string.text_color_id
|
||||
}
|
||||
|
||||
}
|
||||
@ -13,6 +13,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
@ -21,6 +22,7 @@ import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.appcompat.widget.ActionMenuView;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProviders;
|
||||
|
||||
@ -310,4 +312,25 @@ public abstract class ToolBarActivity extends BaseActivity implements ToolbarCon
|
||||
mToolbarContainer.setVisibility(isHide ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNightModeChange() {
|
||||
super.onNightModeChange();
|
||||
if (mToolbar != null) {
|
||||
mToolbar.setBackgroundColor(ContextCompat.getColor(this, R.color.background_white));
|
||||
}
|
||||
if (mBackBtn != null) {
|
||||
if (mBackBtn instanceof ImageView) {
|
||||
((ImageView) mBackBtn).setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_bar_back));
|
||||
} else if (mBackBtn instanceof TextView) {
|
||||
((TextView) mBackBtn).setTextColor(ContextCompat.getColor(this, R.color.text_subtitle));
|
||||
}
|
||||
}
|
||||
if (mTitleTv != null) {
|
||||
mTitleTv.setTextColor(ContextCompat.getColor(this, R.color.text_black));
|
||||
}
|
||||
if (showDownloadMenu() && getMenuItem(R.id.menu_download) != null) {
|
||||
((ImageView) getMenuItem(R.id.menu_download).getActionView().findViewById(R.id.menu_download_iv)).setImageDrawable(ContextCompat.getDrawable(this, R.drawable.toolbar_download));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
package com.gh.base.fragment;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.view.KeyEvent;
|
||||
|
||||
import com.gh.common.util.ClickUtils;
|
||||
import com.gh.common.util.NightModeUtils;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.lightgame.utils.RuntimeUtils;
|
||||
import com.lightgame.utils.Utils;
|
||||
@ -28,6 +30,14 @@ import androidx.lifecycle.Lifecycle;
|
||||
|
||||
public class BaseDialogFragment extends DialogFragment {
|
||||
|
||||
protected boolean mNightMode;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mNightMode = NightModeUtils.INSTANCE.isNightMode(requireContext());
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
@ -95,6 +105,16 @@ public class BaseDialogFragment extends DialogFragment {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(@NonNull Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
onNightModeChange();
|
||||
}
|
||||
|
||||
protected void onNightModeChange() {
|
||||
mNightMode = NightModeUtils.INSTANCE.isNightMode(requireContext());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.gh.base.fragment;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
@ -8,6 +9,7 @@ import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.LayoutRes;
|
||||
import androidx.annotation.NonNull;
|
||||
@ -23,6 +25,7 @@ import com.gh.common.constant.Constants;
|
||||
import com.gh.common.syncpage.ISyncAdapterHandler;
|
||||
import com.gh.common.syncpage.SyncDataEntity;
|
||||
import com.gh.common.syncpage.SyncPageRepository;
|
||||
import com.gh.common.util.NightModeUtils;
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.eventbus.EBMiPush;
|
||||
@ -58,6 +61,8 @@ public abstract class BaseFragment<T> extends Fragment implements OnRequestCallB
|
||||
|
||||
protected boolean isEverPause;
|
||||
|
||||
protected boolean mNightMode;
|
||||
|
||||
@NonNull
|
||||
protected String mEntrance = "";
|
||||
|
||||
@ -158,6 +163,12 @@ public abstract class BaseFragment<T> extends Fragment implements OnRequestCallB
|
||||
if (addSyncPageObserver()) {
|
||||
initSyncPageObserver();
|
||||
}
|
||||
|
||||
if (BuildConfig.IS_NIGHT_MODE_ON) {
|
||||
mNightMode = NightModeUtils.INSTANCE.isNightMode(requireContext());
|
||||
} else {
|
||||
mNightMode = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void initSyncPageObserver() {
|
||||
@ -230,6 +241,12 @@ public abstract class BaseFragment<T> extends Fragment implements OnRequestCallB
|
||||
super.onResume();
|
||||
isEverPause = false;
|
||||
startPageTime = System.currentTimeMillis();
|
||||
|
||||
if (BuildConfig.IS_NIGHT_MODE_ON
|
||||
&& !NightModeUtils.INSTANCE.getSystemMode()
|
||||
&& mNightMode != NightModeUtils.INSTANCE.isNightMode(requireContext())) {
|
||||
onNightModeChange();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -315,7 +332,9 @@ public abstract class BaseFragment<T> extends Fragment implements OnRequestCallB
|
||||
|
||||
// 为 fragment 附加 bundle (setArgument())
|
||||
public BaseFragment with(Bundle bundle) {
|
||||
this.setArguments(bundle);
|
||||
if (!isStateSaved()) {
|
||||
this.setArguments(bundle);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -331,4 +350,16 @@ public abstract class BaseFragment<T> extends Fragment implements OnRequestCallB
|
||||
protected boolean addSyncPageObserver() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(@NonNull Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
if (BuildConfig.IS_NIGHT_MODE_ON) {
|
||||
onNightModeChange();
|
||||
}
|
||||
}
|
||||
|
||||
protected void onNightModeChange() {
|
||||
mNightMode = NightModeUtils.INSTANCE.isNightMode(requireContext());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.gh.base.fragment;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
@ -8,6 +9,12 @@ import android.view.View;
|
||||
import android.widget.CheckedTextView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.gh.base.adapter.FragmentAdapter;
|
||||
import com.gh.common.view.TabIndicatorView;
|
||||
import com.gh.gamecenter.R;
|
||||
@ -20,11 +27,6 @@ import com.lightgame.view.NoScrollableViewPager;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
/**
|
||||
* Created by khy on 15/03/18.
|
||||
*/
|
||||
@ -119,7 +121,7 @@ public abstract class BaseFragment_TabLayout extends NormalFragment implements V
|
||||
if (tab == null) continue;
|
||||
String tabTitle = tab.getText() != null ? tab.getText().toString() : "";
|
||||
View tabView = provideTabView(i, tabTitle);
|
||||
if (tabView == null) tabView = createDefaultTabCustomView(tabTitle);
|
||||
if (tabView == null) tabView = createDefaultTabCustomView(requireContext(), tabTitle);
|
||||
tab.setCustomView(tabView);
|
||||
}
|
||||
|
||||
@ -152,7 +154,7 @@ public abstract class BaseFragment_TabLayout extends NormalFragment implements V
|
||||
});
|
||||
}
|
||||
|
||||
private static void updateTabStyle(TabLayout.Tab tab, boolean isChecked) {
|
||||
public static void updateTabStyle(TabLayout.Tab tab, boolean isChecked) {
|
||||
View tabView = tab.getCustomView();
|
||||
if (tabView == null) {
|
||||
Utils.log("TabLayout->Tab样式不是通用样式,请检查");
|
||||
@ -171,12 +173,13 @@ public abstract class BaseFragment_TabLayout extends NormalFragment implements V
|
||||
return;
|
||||
}
|
||||
tabTitle.setTypeface(isChecked ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);
|
||||
tabTitle.setTextColor(ContextCompat.getColorStateList(tabTitle.getContext(), R.color.text_tabbar_style));
|
||||
}
|
||||
|
||||
// 如果不设置View的话,无法动态设置字体样式
|
||||
@NonNull
|
||||
public static View createDefaultTabCustomView(String title) {
|
||||
View view = LayoutInflater.from(HaloApp.getInstance().getApplication().getBaseContext()).inflate(R.layout.tab_item, null);
|
||||
public static View createDefaultTabCustomView(Context context, String title) {
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.tab_item, null);
|
||||
View tabTitle = view.findViewById(R.id.tab_title);
|
||||
if (tabTitle instanceof CheckedTextView) {
|
||||
((CheckedTextView) tabTitle).setText(title);
|
||||
@ -198,4 +201,22 @@ public abstract class BaseFragment_TabLayout extends NormalFragment implements V
|
||||
public void onPageScrollStateChanged(int state) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNightModeChange() {
|
||||
super.onNightModeChange();
|
||||
View container = requireView().findViewById(R.id.fragment_tab_container);
|
||||
if (container != null) {
|
||||
container.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.background_white));
|
||||
for (int i = 0; i < mTabLayout.getTabCount(); i++) {
|
||||
TabLayout.Tab tab = mTabLayout.getTabAt(i);
|
||||
if (tab != null) {
|
||||
updateTabStyle(tab, tab.isSelected());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mDividerLineView != null) {
|
||||
mDividerLineView.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.divider));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package com.gh.base.fragment
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.viewpager.widget.PagerAdapter
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
@ -93,7 +94,7 @@ abstract class BaseLazyTabFragment : BaseLazyFragment(), ViewPager.OnPageChangeL
|
||||
val tab = mTabLayout.getTabAt(i) ?: continue
|
||||
val tabTitle = if (tab.text != null) tab.text.toString() else ""
|
||||
var tabView = provideTabView(i, tabTitle)
|
||||
if (tabView == null) tabView = BaseFragment_TabLayout.createDefaultTabCustomView(tabTitle)
|
||||
if (tabView == null) tabView = BaseFragment_TabLayout.createDefaultTabCustomView(requireContext(), tabTitle)
|
||||
tab.customView = tabView
|
||||
}
|
||||
BaseFragment_TabLayout.initTabStyle(mTabLayout, mCheckedIndex)
|
||||
@ -121,6 +122,20 @@ abstract class BaseLazyTabFragment : BaseLazyFragment(), ViewPager.OnPageChangeL
|
||||
|
||||
override fun onPageScrollStateChanged(state: Int) {}
|
||||
|
||||
override fun onNightModeChange() {
|
||||
super.onNightModeChange()
|
||||
val container = requireView().findViewById<View>(R.id.fragment_tab_container)
|
||||
if (container != null) {
|
||||
container.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.background_white))
|
||||
for (i in 0 until mTabLayout.tabCount) {
|
||||
val tab = mTabLayout.getTabAt(i)
|
||||
if (tab != null) {
|
||||
BaseFragment_TabLayout.updateTabStyle(tab, tab.isSelected)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val PAGE_INDEX = "PAGE_INDEX"
|
||||
}
|
||||
|
||||
@ -447,10 +447,4 @@ class DefaultJsApi(var context: Context) {
|
||||
var activityId: String = "",
|
||||
var platform: String = ""
|
||||
)
|
||||
|
||||
@Keep
|
||||
data class GameActivityTaskEvent(
|
||||
var gameId: String = "",
|
||||
var activityId: String = "",
|
||||
)
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ import java.nio.charset.Charset
|
||||
object DefaultUrlHandler {
|
||||
|
||||
@JvmStatic
|
||||
fun interceptUrl(context: Context, url: String, entrance: String) : Boolean {
|
||||
fun interceptUrl(context: Context, url: String, entrance: String): Boolean {
|
||||
return interceptUrl(context, url, entrance, false)
|
||||
}
|
||||
|
||||
@ -335,6 +335,7 @@ object DefaultUrlHandler {
|
||||
EntranceUtils.HOST_UPLOAD_VIDEO_NEW -> {
|
||||
val activityName = uri.getQueryParameter("activity_name") ?: ""
|
||||
val activityId = uri.getQueryParameter("activity_id") ?: ""
|
||||
val original = uri.getQueryParameter("original") ?: ""
|
||||
val forumName = uri.getQueryParameter("forum_name") ?: ""
|
||||
val forumId = uri.getQueryParameter("forum_id") ?: ""
|
||||
val forumIcon = uri.getQueryParameter("forum_icon") ?: ""
|
||||
@ -343,11 +344,16 @@ object DefaultUrlHandler {
|
||||
val gameName = uri.getQueryParameter("game_name") ?: ""
|
||||
val icon = uri.getQueryParameter("game_icon") ?: ""
|
||||
val iconSubscript = uri.getQueryParameter("game_icon_subscript") ?: ""
|
||||
val gameEntity = if (forumType == BbsType.OFFICIAL_BBS.value) {
|
||||
GameEntity(id = gameId, mName = gameName, mIcon = icon, mIconSubscript = iconSubscript)
|
||||
val gameEntity =
|
||||
if (forumType == BbsType.OFFICIAL_BBS.value && gameId.isNotEmpty() && gameName.isNotEmpty() && icon.isNotEmpty()) {
|
||||
GameEntity(id = gameId, mName = gameName, mIcon = icon, mIconSubscript = iconSubscript)
|
||||
} else null
|
||||
val activityLabelEntity = if (activityId.isNotEmpty() && activityName.isNotEmpty()) {
|
||||
ActivityLabelEntity(id = activityId, name = activityName, original = original.ifEmpty { "false" }.toBoolean())
|
||||
} else null
|
||||
val communityEntity = if (forumId.isNotEmpty() && forumName.isNotEmpty() && forumIcon.isNotEmpty()) {
|
||||
CommunityEntity(id = forumId, name = forumName, icon = forumIcon)
|
||||
} else null
|
||||
val activityLabelEntity = ActivityLabelEntity(id = activityId, name = activityName)
|
||||
val communityEntity = CommunityEntity(id = forumId, name = forumName, icon = forumIcon)
|
||||
|
||||
context.startActivity(
|
||||
VideoPublishActivity.getIntent(
|
||||
@ -356,7 +362,8 @@ object DefaultUrlHandler {
|
||||
gameEntity,
|
||||
activityLabelEntity,
|
||||
forumType,
|
||||
false,
|
||||
disableForumSelection = false,
|
||||
isFromCommunityActivity = true,
|
||||
entrance,
|
||||
""
|
||||
)
|
||||
|
||||
@ -49,6 +49,8 @@ public class Constants {
|
||||
// 最近显示的弹窗信息
|
||||
public static final String SP_LAST_OPENING_ID = "last_opening_dialog_id";
|
||||
public static final String SP_LAST_OPENING_TIME = "last_opening_dialog_time";
|
||||
|
||||
public static final String SP_LAST_ACCEPTED_PRIVACY_DIALOG_ID = "last_accepted_privacy_dialog_id";
|
||||
|
||||
// 游戏图标和图标角标
|
||||
public static final String RAW_GAME_ICON = "raw_game_icon";
|
||||
@ -245,6 +247,8 @@ public class Constants {
|
||||
public static final String SP_MY_GAME_GUIDE = "my_game_guide";
|
||||
//微信绑定配置信息
|
||||
public static final String SP_WECHAT_CONFIG = "wechat_config";
|
||||
//游戏库导航栏小红点提示
|
||||
public static final String SP_GAME_NAVIGATION = "game_navigation";
|
||||
|
||||
//手机号码匹配规则
|
||||
public static final String REGEX_MOBILE = "^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$";
|
||||
@ -415,4 +419,9 @@ public class Constants {
|
||||
public static final String DEFAULT_VIVO_BROWSER_HINT_URL = "https://static-web.ghzs.com/ghzs_help/help.html?content=618112ce04796e63e97643a4&from=ghzs";
|
||||
|
||||
public static final int FOLLOW_HINT_TRIGGER_HEIGHT = 10;
|
||||
|
||||
// 深色模式
|
||||
public static final String SP_NIGHT_MODE = "night_mode";
|
||||
// 跟随系统模式
|
||||
public static final String SP_SYSTEM_MODE = "system_mode";
|
||||
}
|
||||
|
||||
@ -580,6 +580,7 @@ public class BindingAdapters {
|
||||
case notfound:
|
||||
case uncertificated:
|
||||
case unqualified:
|
||||
case unavailable:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@ -87,7 +87,7 @@ class ApplyModeratorDialogFragment : BaseDialogFragment() {
|
||||
}
|
||||
}.show(
|
||||
activity.supportFragmentManager,
|
||||
PrivacyDialogFragment::class.java.simpleName
|
||||
ApplyModeratorDialogFragment::class.java.simpleName
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,6 +19,7 @@ import com.gh.common.util.PermissionHelper.INSTALL_PERMISSION_CODE
|
||||
import com.gh.common.xapk.XapkInstaller
|
||||
import com.gh.gamecenter.R
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import com.lightgame.utils.Utils
|
||||
import kotlin.random.Random
|
||||
|
||||
class InstallPermissionDialogFragment : BaseTrackableDialogFragment() {
|
||||
@ -26,7 +27,7 @@ class InstallPermissionDialogFragment : BaseTrackableDialogFragment() {
|
||||
lateinit var mView: View
|
||||
var isXapk = false
|
||||
var url: String = ""
|
||||
var mCallBack: (() -> Unit)? = null
|
||||
var mCallBack: ((isFromPermissionGrantedCallback: Boolean) -> Unit)? = null
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
mView = inflater.inflate(R.layout.dialog_install_permission, null, false)
|
||||
@ -56,7 +57,7 @@ class InstallPermissionDialogFragment : BaseTrackableDialogFragment() {
|
||||
closeTv.setOnClickListener {
|
||||
MtaHelper.onEvent(getEvent(), getKey(), "文案样式_点击以后再说")
|
||||
if (isXapk) {
|
||||
mCallBack?.invoke()
|
||||
mCallBack?.invoke(false)
|
||||
}
|
||||
dismiss()
|
||||
}
|
||||
@ -77,9 +78,11 @@ class InstallPermissionDialogFragment : BaseTrackableDialogFragment() {
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
if (resultCode == RESULT_OK && requestCode == INSTALL_PERMISSION_CODE) {
|
||||
SPUtils.setString(Constants.SP_XAPK_UNZIP_ACTIVITY, "")
|
||||
SPUtils.setString(Constants.SP_XAPK_URL, "")
|
||||
mCallBack?.invoke()
|
||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.R) {
|
||||
SPUtils.setString(Constants.SP_XAPK_UNZIP_ACTIVITY, "")
|
||||
SPUtils.setString(Constants.SP_XAPK_URL, "")
|
||||
}
|
||||
mCallBack?.invoke(true)
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
@ -90,27 +93,27 @@ class InstallPermissionDialogFragment : BaseTrackableDialogFragment() {
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun show(activity: AppCompatActivity, downloadEntity: DownloadEntity, callBack: (() -> Unit)?) {
|
||||
fun show(activity: AppCompatActivity, downloadEntity: DownloadEntity, callBack: ((isFromPermissionGrantedCallback: Boolean) -> Unit)?) {
|
||||
val isXapk = XapkInstaller.XAPK_EXTENSION_NAME == downloadEntity.path.getExtension()
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
||||
callBack?.invoke()
|
||||
callBack?.invoke(false)
|
||||
return
|
||||
}
|
||||
val haveInstallPermission = activity.packageManager.canRequestPackageInstalls()
|
||||
if (haveInstallPermission) {
|
||||
callBack?.invoke()
|
||||
callBack?.invoke(false)
|
||||
return
|
||||
}
|
||||
if (isXapk) {
|
||||
val xapkUnzipVersions = Config.getSettings()?.permissionPopupAppliedVersions?.xapkUnzip
|
||||
if (xapkUnzipVersions?.contains(Build.VERSION.SDK_INT.toString()) == false) {
|
||||
callBack?.invoke()
|
||||
callBack?.invoke(false)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
val installVersions = Config.getSettings()?.permissionPopupAppliedVersions?.install
|
||||
if (installVersions?.contains(Build.VERSION.SDK_INT.toString()) == false) {
|
||||
callBack?.invoke()
|
||||
callBack?.invoke(false)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,157 +0,0 @@
|
||||
package com.gh.common.dialog
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.DialogInterface
|
||||
import android.os.Bundle
|
||||
import android.text.SpannableStringBuilder
|
||||
import android.text.Spanned
|
||||
import android.text.TextPaint
|
||||
import android.text.method.ScrollingMovementMethod
|
||||
import android.text.style.ClickableSpan
|
||||
import android.view.*
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.FragmentTransaction
|
||||
import com.gh.base.fragment.BaseDialogFragment
|
||||
import com.gh.common.util.dip2px
|
||||
import com.gh.common.view.CustomLinkMovementMethod
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.WebActivity
|
||||
|
||||
class PrivacyDialogFragment : BaseDialogFragment() {
|
||||
|
||||
// private val mLocalPrivacyHtml = "file:///android_asset/privacy_policies.html"
|
||||
// private val mLocalRegulationHtml = "file:///android_asset/user_regulation.html"
|
||||
|
||||
var containerView: View? = null
|
||||
var mCallBack: ((isSuccess: Boolean) -> Unit)? = null
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
containerView = LayoutInflater.from(requireContext()).inflate(R.layout.dialog_privacy_protocol, null, false)
|
||||
return containerView
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
// val mWebViewPrivacy = containerView?.findViewById<WebView>(R.id.webView)
|
||||
// val mWebViewRegulation = containerView?.findViewById<WebView>(R.id.webView2)
|
||||
//
|
||||
// mWebViewPrivacy?.isHorizontalScrollBarEnabled = false
|
||||
// mWebViewRegulation?.isHorizontalScrollBarEnabled = false
|
||||
|
||||
val contentTv = containerView?.findViewById<TextView>(R.id.contentTv)
|
||||
val descTv = containerView?.findViewById<TextView>(R.id.descTv)
|
||||
contentTv?.movementMethod = ScrollingMovementMethod()
|
||||
|
||||
val skipText = SpannableStringBuilder("查看完整版的隐私政策和用户协议")
|
||||
skipText.setSpan(object : ClickableSpan() {
|
||||
override fun updateDrawState(ds: TextPaint) {
|
||||
super.updateDrawState(ds)
|
||||
ds.color = ContextCompat.getColor(requireContext(), R.color.theme_font)
|
||||
ds.isUnderlineText = false
|
||||
}
|
||||
|
||||
override fun onClick(widget: View) {
|
||||
val intent = WebActivity.getIntent(requireContext(), context!!.getString(R.string.privacy_policy_url), true)
|
||||
context?.startActivity(intent)
|
||||
}
|
||||
}, skipText.length - 9, skipText.length - 5, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
|
||||
skipText.setSpan(object : ClickableSpan() {
|
||||
override fun updateDrawState(ds: TextPaint) {
|
||||
super.updateDrawState(ds)
|
||||
ds.color = ContextCompat.getColor(requireContext(), R.color.theme_font)
|
||||
ds.isUnderlineText = false
|
||||
}
|
||||
|
||||
override fun onClick(widget: View) {
|
||||
val intent = WebActivity.getIntent(requireContext(), context!!.getString(R.string.disclaimer_url), true)
|
||||
context?.startActivity(intent)
|
||||
}
|
||||
}, skipText.length - 4, skipText.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
descTv?.movementMethod = CustomLinkMovementMethod()
|
||||
descTv?.text = skipText
|
||||
|
||||
// val mWebViewPrivacy = containerView?.findViewById<WebView>(R.id.webView)
|
||||
//
|
||||
// mWebViewPrivacy?.isHorizontalScrollBarEnabled = false
|
||||
//
|
||||
// val settingsArrayList = arrayListOf(mWebViewPrivacy?.settings, mWebViewRegulation?.settings)
|
||||
//
|
||||
// for (settings in settingsArrayList) {
|
||||
// settings?.javaScriptEnabled = true
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
// settings?.mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW
|
||||
// }
|
||||
// // 避免提示网页有害信息不能访问
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
// settings?.safeBrowsingEnabled = false
|
||||
// }
|
||||
//
|
||||
// // 适配大于屏幕宽度的页面
|
||||
// settings?.useWideViewPort = true
|
||||
// settings?.loadWithOverviewMode = true
|
||||
// settings?.domStorageEnabled = true
|
||||
//
|
||||
// // 自适应屏幕
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
// settings?.layoutAlgorithm = WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING
|
||||
// }
|
||||
// }
|
||||
|
||||
// mWebViewPrivacy?.webViewClient = client
|
||||
// mWebViewRegulation?.webViewClient = client
|
||||
|
||||
containerView?.findViewById<View>(R.id.refuseTv)?.setOnClickListener {
|
||||
mCallBack?.invoke(false)
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
containerView?.findViewById<View>(R.id.agreeTv)?.setOnClickListener {
|
||||
mCallBack?.invoke(true)
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val createDialog = super.onCreateDialog(savedInstanceState)
|
||||
createDialog.setCanceledOnTouchOutside(false)
|
||||
createDialog.setOnKeyListener(object : DialogInterface.OnKeyListener {
|
||||
override fun onKey(dialog: DialogInterface?, keyCode: Int, event: KeyEvent?): Boolean {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
})
|
||||
|
||||
val window = createDialog.window
|
||||
window?.setGravity(Gravity.CENTER)
|
||||
return createDialog
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
val width = requireContext().resources.displayMetrics.widthPixels - 60F.dip2px()
|
||||
val height = ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
dialog?.window?.setLayout(width, height)
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun show(activity: AppCompatActivity, callBack: ((isSuccess: Boolean) -> Unit)?) {
|
||||
var privacyDialogFragment = activity.supportFragmentManager.findFragmentByTag(PrivacyDialogFragment::class.java.simpleName) as? PrivacyDialogFragment
|
||||
if (privacyDialogFragment != null) {
|
||||
privacyDialogFragment.mCallBack = callBack
|
||||
val transaction: FragmentTransaction = activity.supportFragmentManager.beginTransaction()
|
||||
transaction.show(privacyDialogFragment)
|
||||
transaction.commit()
|
||||
} else {
|
||||
privacyDialogFragment = PrivacyDialogFragment().apply {
|
||||
mCallBack = callBack
|
||||
}
|
||||
privacyDialogFragment.show(activity.supportFragmentManager, PrivacyDialogFragment::class.java.simpleName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,190 @@
|
||||
package com.gh.common.dialog
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.DialogInterface
|
||||
import android.os.Bundle
|
||||
import android.text.SpannableStringBuilder
|
||||
import android.text.Spanned
|
||||
import android.text.TextPaint
|
||||
import android.text.method.ScrollingMovementMethod
|
||||
import android.text.style.ClickableSpan
|
||||
import android.view.*
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.fragment.app.FragmentTransaction
|
||||
import com.gh.base.fragment.BaseDialogFragment
|
||||
import com.gh.common.constant.Constants
|
||||
import com.gh.common.util.SPUtils
|
||||
import com.gh.common.util.dip2px
|
||||
import com.gh.common.util.fromHtml
|
||||
import com.gh.common.view.CustomLinkMovementMethod
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.WebActivity
|
||||
import com.gh.gamecenter.databinding.DialogPrivacyProtocolBinding
|
||||
import com.gh.gamecenter.entity.DialogEntity
|
||||
import com.lightgame.utils.AppManager
|
||||
import splitties.bundle.put
|
||||
|
||||
class PrivacyPolicyDialogFragment : BaseDialogFragment() {
|
||||
|
||||
private var mCallBack: ((isSuccess: Boolean) -> Unit)? = null
|
||||
private val mBinding by lazy { DialogPrivacyProtocolBinding.inflate(layoutInflater) }
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
return mBinding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
mBinding.contentTv.movementMethod = ScrollingMovementMethod()
|
||||
|
||||
val privacyPolicyEntity = arguments?.get(KEY_DATA) as? DialogEntity.PrivacyPolicyEntity
|
||||
if (privacyPolicyEntity == null) {
|
||||
showPreLaunchStyle()
|
||||
} else {
|
||||
showUpdatedStyle(privacyPolicyEntity)
|
||||
}
|
||||
}
|
||||
|
||||
private fun showUpdatedStyle(privacyPolicyEntity: DialogEntity.PrivacyPolicyEntity) {
|
||||
mBinding.titleIv.visibility = View.VISIBLE
|
||||
mBinding.privacyTitleTv.text = "光环助手《隐私协议》更新"
|
||||
mBinding.contentTv.text = privacyPolicyEntity.content.fromHtml()
|
||||
|
||||
val skipText = SpannableStringBuilder("查看隐私政策详情")
|
||||
skipText.setSpan(object : ClickableSpan() {
|
||||
override fun updateDrawState(ds: TextPaint) {
|
||||
super.updateDrawState(ds)
|
||||
ds.color = ContextCompat.getColor(requireContext(), R.color.theme_font)
|
||||
ds.isUnderlineText = false
|
||||
}
|
||||
|
||||
override fun onClick(widget: View) {
|
||||
val intent = WebActivity.getIntent(requireContext(), context!!.getString(R.string.privacy_policy_url), true)
|
||||
context?.startActivity(intent)
|
||||
}
|
||||
}, skipText.length - 6, skipText.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
mBinding.descTv.movementMethod = CustomLinkMovementMethod()
|
||||
mBinding.descTv.text = skipText
|
||||
|
||||
if (privacyPolicyEntity.alertType == "INFORM") {
|
||||
mBinding.refuseTv.visibility = View.GONE
|
||||
mBinding.agreeTv.text = "我知道了"
|
||||
mBinding.agreeTv.setOnClickListener {
|
||||
SPUtils.setString(Constants.SP_LAST_ACCEPTED_PRIVACY_DIALOG_ID, privacyPolicyEntity.id)
|
||||
mCallBack?.invoke(true)
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
} else {
|
||||
mBinding.refuseTv.text = "不同意退出"
|
||||
mBinding.agreeTv.text = "同意"
|
||||
mBinding.refuseTv.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
AppManager.getInstance().finishAllActivity()
|
||||
}
|
||||
mBinding.agreeTv.setOnClickListener {
|
||||
SPUtils.setString(Constants.SP_LAST_ACCEPTED_PRIVACY_DIALOG_ID, privacyPolicyEntity.id)
|
||||
mCallBack?.invoke(true)
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showPreLaunchStyle() {
|
||||
val skipText = SpannableStringBuilder("查看完整版的隐私政策和用户协议")
|
||||
|
||||
skipText.setSpan(object : ClickableSpan() {
|
||||
override fun updateDrawState(ds: TextPaint) {
|
||||
super.updateDrawState(ds)
|
||||
ds.color = ContextCompat.getColor(requireContext(), R.color.theme_font)
|
||||
ds.isUnderlineText = false
|
||||
}
|
||||
|
||||
override fun onClick(widget: View) {
|
||||
val intent = WebActivity.getIntent(requireContext(), context!!.getString(R.string.privacy_policy_url), true)
|
||||
context?.startActivity(intent)
|
||||
}
|
||||
}, skipText.length - 9, skipText.length - 5, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
|
||||
skipText.setSpan(object : ClickableSpan() {
|
||||
override fun updateDrawState(ds: TextPaint) {
|
||||
super.updateDrawState(ds)
|
||||
ds.color = ContextCompat.getColor(requireContext(), R.color.theme_font)
|
||||
ds.isUnderlineText = false
|
||||
}
|
||||
|
||||
override fun onClick(widget: View) {
|
||||
val intent = WebActivity.getIntent(requireContext(), context!!.getString(R.string.disclaimer_url), true)
|
||||
context?.startActivity(intent)
|
||||
}
|
||||
}, skipText.length - 4, skipText.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
mBinding.descTv.movementMethod = CustomLinkMovementMethod()
|
||||
mBinding.descTv.text = skipText
|
||||
|
||||
mBinding.refuseTv.setOnClickListener {
|
||||
mCallBack?.invoke(false)
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
mBinding.agreeTv.setOnClickListener {
|
||||
mCallBack?.invoke(true)
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val createDialog = super.onCreateDialog(savedInstanceState)
|
||||
createDialog.setCanceledOnTouchOutside(false)
|
||||
createDialog.setOnKeyListener(object : DialogInterface.OnKeyListener {
|
||||
override fun onKey(dialog: DialogInterface?, keyCode: Int, event: KeyEvent?): Boolean {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
})
|
||||
|
||||
val window = createDialog.window
|
||||
window?.setGravity(Gravity.CENTER)
|
||||
return createDialog
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
val width = requireContext().resources.displayMetrics.widthPixels - 60F.dip2px()
|
||||
val height = ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
dialog?.window?.setLayout(width, height)
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val KEY_DATA = "data"
|
||||
|
||||
@JvmStatic
|
||||
fun show(activity: FragmentActivity,
|
||||
privacyPolicyEntity: DialogEntity.PrivacyPolicyEntity? = null,
|
||||
callBack: ((isSuccess: Boolean) -> Unit)?) {
|
||||
var privacyDialogFragment = activity.supportFragmentManager.findFragmentByTag(PrivacyPolicyDialogFragment::class.java.simpleName) as? PrivacyPolicyDialogFragment
|
||||
if (privacyDialogFragment != null) {
|
||||
privacyDialogFragment.mCallBack = callBack
|
||||
val transaction: FragmentTransaction = activity.supportFragmentManager.beginTransaction()
|
||||
transaction.show(privacyDialogFragment)
|
||||
transaction.commit()
|
||||
} else {
|
||||
privacyDialogFragment = PrivacyPolicyDialogFragment().apply {
|
||||
mCallBack = callBack
|
||||
}
|
||||
}
|
||||
privacyDialogFragment.arguments = Bundle().apply {
|
||||
put(KEY_DATA, privacyPolicyEntity)
|
||||
}
|
||||
privacyDialogFragment.show(
|
||||
activity.supportFragmentManager,
|
||||
PrivacyPolicyDialogFragment::class.java.simpleName
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -12,6 +12,8 @@ data class ExposureEntity(
|
||||
val gameId: String? = "",
|
||||
@SerializedName("subject_id")
|
||||
val subjectId: String? = null, // 专题 id
|
||||
@SerializedName("carousel_id")
|
||||
val carouselId: String? = "", // 轮播图 id
|
||||
val gameName: String? = "",
|
||||
val gameVersion: String? = "",
|
||||
val sequence: Int? = 0,
|
||||
@ -43,6 +45,8 @@ data class ExposureEntity(
|
||||
var categoryId: String? = null,
|
||||
@SerializedName("category_v2_id")
|
||||
var categoryV2Id: String? = null,
|
||||
@SerializedName("navigation_id")
|
||||
var navigationId: String? = null,
|
||||
|
||||
// 专题详情的来源页面和来源 id
|
||||
@SerializedName("source_page")
|
||||
@ -69,6 +73,7 @@ data class ExposureEntity(
|
||||
BLOCK_ID -> blockId = id
|
||||
CATEGORY_ID -> categoryId = id
|
||||
CATEGORY_V2_ID -> categoryV2Id = id
|
||||
NAVIGATION_ID -> navigationId = id
|
||||
}
|
||||
|
||||
containerId = null
|
||||
@ -80,5 +85,6 @@ data class ExposureEntity(
|
||||
const val BLOCK_ID = "block_id"
|
||||
const val CATEGORY_ID = "category_id"
|
||||
const val CATEGORY_V2_ID = "category_v2_id"
|
||||
const val NAVIGATION_ID = "navigation_id"
|
||||
}
|
||||
}
|
||||
@ -16,7 +16,7 @@ import com.gh.gamecenter.room.converter.*
|
||||
import com.gh.gamecenter.room.dao.*
|
||||
import com.halo.assistant.HaloApp
|
||||
|
||||
@Database(entities = [AnswerEntity::class, ArticleEntity::class, NewsEntity::class, HistoryGameEntity::class, MyVideoEntity::class, GamesCollectionEntity::class], version = 10, exportSchema = false)
|
||||
@Database(entities = [AnswerEntity::class, ArticleEntity::class, NewsEntity::class, HistoryGameEntity::class, MyVideoEntity::class, GamesCollectionEntity::class], version = 11, exportSchema = false)
|
||||
@TypeConverters(CountConverter::class,
|
||||
CommunityConverter::class,
|
||||
TimeConverter::class,
|
||||
@ -32,7 +32,8 @@ import com.halo.assistant.HaloApp
|
||||
QuestionsConverter::class,
|
||||
MeConverter::class,
|
||||
SimpleGameListConverter::class,
|
||||
TagInfoListConverter::class)
|
||||
TagInfoListConverter::class,
|
||||
ActivityLabelListConverter::class)
|
||||
|
||||
abstract class HistoryDatabase : RoomDatabase() {
|
||||
|
||||
@ -113,6 +114,12 @@ abstract class HistoryDatabase : RoomDatabase() {
|
||||
}
|
||||
}
|
||||
|
||||
val MIGRATION_10_11: Migration = object : Migration(10, 11) {
|
||||
override fun migrate(database: SupportSQLiteDatabase) {
|
||||
database.execSQL("Alter TABLE GamesCollectionEntity add activityTags TEXT DEFAULT ''")
|
||||
}
|
||||
}
|
||||
|
||||
val instance by lazy {
|
||||
Room.databaseBuilder(HaloApp.getInstance().application, HistoryDatabase::class.java, "USER_TRACK_HISTORY_DATABASE")
|
||||
.addMigrations(MIGRATION_2_3)
|
||||
@ -123,6 +130,7 @@ abstract class HistoryDatabase : RoomDatabase() {
|
||||
.addMigrations(MIGRATION_7_8)
|
||||
.addMigrations(MIGRATION_8_9)
|
||||
.addMigrations(MIGRATION_9_10)
|
||||
.addMigrations(MIGRATION_10_11)
|
||||
.build()
|
||||
}
|
||||
}
|
||||
|
||||
@ -160,6 +160,7 @@ object HistoryHelper {
|
||||
|
||||
gamesCollectionEntity.id = gamesCollectionDetailEntity.id
|
||||
gamesCollectionEntity.tags = gamesCollectionDetailEntity.tags
|
||||
gamesCollectionEntity.activityTags = gamesCollectionDetailEntity.activityTags
|
||||
gamesCollectionDetailEntity.games?.take(3)?.map { it.toSimpleGame() }?.run {
|
||||
gamesCollectionEntity.games = ArrayList(this)
|
||||
}
|
||||
|
||||
@ -91,6 +91,9 @@ class SimulatorDownloadManager private constructor() {
|
||||
DownloadStatus.unqualified == downloadEntity.status -> {
|
||||
ToastUtils.showToast("未成年人暂不允许在此时间下载游戏")
|
||||
}
|
||||
DownloadStatus.unavailable == downloadEntity.status -> {
|
||||
ToastUtils.showToast("该游戏未接入防沉迷系统,暂不支持下载")
|
||||
}
|
||||
DownloadStatus.hijack == downloadEntity.status -> {
|
||||
ToastUtils.showToast("网络劫持,请稍后重试")
|
||||
}
|
||||
|
||||
@ -141,7 +141,7 @@ object CommentHelper {
|
||||
val context = view.context
|
||||
val dialogOptions = ArrayList<String>()
|
||||
|
||||
if (isShowTop && (articleId != null || questionId != null) && commentEntity.me?.isContentAuthor == true) {
|
||||
if (isShowTop && (articleId != null || questionId != null || videoId != null) && commentEntity.me?.isContentAuthor == true) {
|
||||
dialogOptions.add(if (commentEntity.isTop) "取消置顶" else "置顶")
|
||||
}
|
||||
if (questionId != null && commentEntity.me?.isContentAuthor == true) {
|
||||
@ -158,9 +158,8 @@ object CommentHelper {
|
||||
}
|
||||
if (questionId != null &&
|
||||
commentEntity.me?.isModerator == true &&
|
||||
(commentEntity.me?.moderatorPermissions?.highlightAnswer
|
||||
?: Permissions.GUEST) > Permissions.GUEST &&
|
||||
!commentEntity.choiceness) {
|
||||
(commentEntity.me?.moderatorPermissions?.highlightAnswer ?: Permissions.GUEST) > Permissions.GUEST && !commentEntity.choiceness
|
||||
) {
|
||||
dialogOptions.add("加精选")
|
||||
}
|
||||
if (questionId != null &&
|
||||
|
||||
@ -3,16 +3,23 @@ package com.gh.common.util;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.gh.common.AppExecutor;
|
||||
import com.gh.common.constant.Constants;
|
||||
import com.gh.common.exposure.meta.MetaUtil;
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.entity.IdCardEntity;
|
||||
import com.gh.gamecenter.entity.UserInfoEntity;
|
||||
import com.gh.gamecenter.provider.GhContentProvider;
|
||||
import com.gh.gamecenter.retrofit.BiResponse;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
import com.gh.gid.GidCallback;
|
||||
@ -24,7 +31,6 @@ import com.lightgame.utils.Utils;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import io.sentry.Sentry;
|
||||
import io.sentry.android.core.SentryAndroid;
|
||||
@ -42,11 +48,10 @@ public class DataUtils {
|
||||
* @param channel
|
||||
*/
|
||||
public static void init(final Application context, String channel) {
|
||||
|
||||
if (CommonDebug.IS_DEBUG) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// 初始化 Sentry 约占用 90ms,这里切换到子线程初始化
|
||||
AppExecutor.getIoExecutor().execute(() -> initSentry(context, channel));
|
||||
|
||||
@ -118,7 +123,7 @@ public class DataUtils {
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static void initSentry(Context context, String channel) {
|
||||
SentryAndroid.init(context, options -> {
|
||||
// Sentry 疯狂报 ANR (很大一部分还是莫名奇妙的 ANR)严重影响到其它闪退日志的收集
|
||||
@ -129,12 +134,12 @@ public class DataUtils {
|
||||
} else {
|
||||
options.setAnrEnabled(false);
|
||||
}
|
||||
|
||||
|
||||
options.setDebug(BuildConfig.DEBUG);
|
||||
options.setEnableSessionTracking(true);
|
||||
options.setEnvironment(BuildConfig.FLAVOR);
|
||||
options.setDsn("https://6b1caf0d17c1408e8680f3f73ff80bd0@sentry.shanqu.cc/22");
|
||||
|
||||
|
||||
options.setBeforeSend((event, hint) -> {
|
||||
if (BuildConfig.DEBUG) {
|
||||
return null;
|
||||
@ -143,7 +148,7 @@ public class DataUtils {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Sentry.configureScope(scope -> {
|
||||
if (BuildConfig.BUILD_TIME != 0L) {
|
||||
scope.setTag("alias", "内测版" + BuildConfig.VERSION_NAME);
|
||||
@ -203,6 +208,22 @@ public class DataUtils {
|
||||
@Override
|
||||
public void onSuccess(UserInfoEntity data) {
|
||||
SPUtils.setString(Constants.SP_DEVICE_CERTIFICATION_PREFIX + gid, GsonUtils.toJson(data));
|
||||
|
||||
ContentValues values = new ContentValues();
|
||||
IdCardEntity idCardEntity = data.getIdCard();
|
||||
|
||||
if (idCardEntity != null) {
|
||||
values.put(GhContentProvider.KEY_IS_CERTIFICATED, !TextUtils.isEmpty(data.getIdCard().getId())); // 是否认证
|
||||
values.put(GhContentProvider.KEY_IS_ADULT,
|
||||
data.getIdCard().getMinor() == null
|
||||
|| !data.getIdCard().getMinor()
|
||||
);
|
||||
} else {
|
||||
values.put(GhContentProvider.KEY_IS_CERTIFICATED, false);
|
||||
values.put(GhContentProvider.KEY_IS_ADULT, false);
|
||||
}
|
||||
|
||||
HaloApp.getInstance().getContentResolver().insert(Uri.parse("content://com.gh.gamecenter.provider/certification"), values);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -200,6 +200,7 @@ public class DetailDownloadUtils {
|
||||
case notfound:
|
||||
case uncertificated:
|
||||
case unqualified:
|
||||
case unavailable:
|
||||
detailInitDownload(viewHolder, false);
|
||||
break;
|
||||
default:
|
||||
|
||||
@ -846,7 +846,7 @@ public class DialogUtils {
|
||||
|
||||
LinearLayout container = new LinearLayout(context);
|
||||
container.setOrientation(LinearLayout.VERTICAL);
|
||||
container.setBackgroundColor(Color.WHITE);
|
||||
container.setBackgroundColor(ContextCompat.getColor(context, R.color.background_white));
|
||||
container.setPadding(0, DisplayUtils.dip2px(context, 12f), 0, DisplayUtils.dip2px(context, 12f));
|
||||
|
||||
for (String option : options) {
|
||||
|
||||
@ -19,6 +19,7 @@ import com.gh.common.constant.Constants
|
||||
import com.gh.common.exposure.ExposureEvent
|
||||
import com.gh.common.exposure.ExposureEvent.Companion.createEvent
|
||||
import com.gh.common.exposure.ExposureManager.log
|
||||
import com.gh.common.exposure.ExposureSource
|
||||
import com.gh.common.exposure.ExposureTraceUtils.appendTrace
|
||||
import com.gh.common.exposure.ExposureType
|
||||
import com.gh.common.util.EntranceUtils.*
|
||||
@ -51,6 +52,7 @@ import com.gh.gamecenter.personalhome.home.UserHistoryViewModel
|
||||
import com.gh.gamecenter.qa.answer.detail.SimpleAnswerDetailActivity
|
||||
import com.gh.gamecenter.qa.article.detail.ArticleDetailActivity
|
||||
import com.gh.gamecenter.qa.questions.newdetail.NewQuestionDetailActivity
|
||||
import com.gh.gamecenter.qa.subject.CommunitySubjectActivity
|
||||
import com.gh.gamecenter.qa.video.detail.ForumVideoDetailActivity
|
||||
import com.gh.gamecenter.retrofit.Response
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
@ -157,7 +159,7 @@ object DirectUtils {
|
||||
entrance: String,
|
||||
path: String,
|
||||
exposureEvent: ExposureEvent? = null,
|
||||
unknownCallback: (() -> Unit)?
|
||||
unknownCallback: (() -> Unit)?,
|
||||
) {
|
||||
when (linkEntity.type) {
|
||||
"article", "news", "文章" -> {
|
||||
@ -898,14 +900,14 @@ object DirectUtils {
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToCommunityColumn(context: Context, community: CommunityEntity?, subjectId: String, entrance: String?, path: String?) {
|
||||
// if (subjectId.isEmpty()) return
|
||||
// val bundle = Bundle()
|
||||
// bundle.putString(KEY_PATH, path)
|
||||
// bundle.putString(KEY_TO, CommunitySubjectActivity::class.java.name)
|
||||
// bundle.putString(KEY_ENTRANCE, BaseActivity.mergeEntranceAndPath(entrance, path))
|
||||
// bundle.putString(KEY_COLUMN_ID, subjectId)
|
||||
// bundle.putParcelable(KEY_COMMUNITY_DATA, community)
|
||||
// jumpActivity(context, bundle)
|
||||
if (subjectId.isEmpty()) return
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_PATH, path)
|
||||
bundle.putString(KEY_TO, CommunitySubjectActivity::class.java.name)
|
||||
bundle.putString(KEY_ENTRANCE, BaseActivity.mergeEntranceAndPath(entrance, path))
|
||||
bundle.putString(KEY_COLUMN_ID, subjectId)
|
||||
bundle.putParcelable(KEY_COMMUNITY_DATA, community)
|
||||
jumpActivity(context, bundle)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@ -1143,7 +1145,13 @@ object DirectUtils {
|
||||
* 跳转新分类
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directCatalog(context: Context, catalogId: String, catalogTitle: String, entrance: String? = null, path: String? = "") {
|
||||
fun directCatalog(
|
||||
context: Context,
|
||||
catalogId: String,
|
||||
catalogTitle: String,
|
||||
entrance: String? = null,
|
||||
path: String? = "",
|
||||
) {
|
||||
if (catalogId.isEmpty()) return
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_TO, CatalogActivity::class.java.name)
|
||||
@ -1157,7 +1165,13 @@ object DirectUtils {
|
||||
* 跳转新分类2.0
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directCategoryV2(context: Context, categoryId: String, categoryTitle: String, entrance: String? = null, path: String? = "") {
|
||||
fun directCategoryV2(
|
||||
context: Context,
|
||||
categoryId: String,
|
||||
categoryTitle: String,
|
||||
entrance: String? = null,
|
||||
path: String? = "",
|
||||
) {
|
||||
if (categoryId.isEmpty()) return
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_TO, CategoryV2Activity::class.java.name)
|
||||
|
||||
@ -18,13 +18,16 @@ import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.ColorRes;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.graphics.ColorUtils;
|
||||
|
||||
import com.halo.assistant.HaloApp;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
public class DisplayUtils {
|
||||
|
||||
/**
|
||||
@ -223,6 +226,27 @@ public class DisplayUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void setStatusBarColor(Activity activity, @ColorRes int colorRes) {
|
||||
Window window = activity.getWindow();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
int colorInt = ContextCompat.getColor(activity, colorRes);
|
||||
// 设置状态栏底色颜色
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
window.setStatusBarColor(colorInt);
|
||||
// 如果亮色,设置状态栏文字为黑色
|
||||
if (isLightColor(colorInt)) {
|
||||
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||
} else {
|
||||
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isLightColor(@ColorInt int color) {
|
||||
return ColorUtils.calculateLuminance(color) >= 0.5;
|
||||
}
|
||||
|
||||
|
||||
private static boolean isMiuiOs() {
|
||||
String property = getSystemProperty("ro.miui.ui.version.name", "");
|
||||
|
||||
@ -166,6 +166,7 @@ object DownloadItemUtils {
|
||||
hideDownloadBtnIfNoAvailableContent: Boolean = false,
|
||||
pluginLocation: PluginLocation? = PluginLocation.only_game
|
||||
) {
|
||||
downloadBtn.background = R.drawable.download_button_normal_style.toDrawable(context)
|
||||
// 控制是否显示下载按钮
|
||||
downloadBtn.goneIf(!Config.isShowDownload(gameEntity.id) || context.getString(R.string.app_name) == gameEntity.name)
|
||||
// 青少年模式显示查看
|
||||
|
||||
@ -112,6 +112,7 @@ object DownloadNotificationHelper {
|
||||
|| entity.status == DownloadStatus.cancel
|
||||
|| entity.status == DownloadStatus.hijack
|
||||
|| entity.status == DownloadStatus.unqualified
|
||||
|| entity.status == DownloadStatus.unavailable
|
||||
|| entity.status == DownloadStatus.uncertificated
|
||||
|| entity.status == DownloadStatus.notfound
|
||||
|| entity.status == DownloadStatus.overflow
|
||||
|
||||
@ -36,7 +36,6 @@ import okhttp3.MediaType
|
||||
import okhttp3.RequestBody
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.json.JSONObject
|
||||
import java.util.*
|
||||
|
||||
object DownloadObserver {
|
||||
|
||||
@ -109,6 +108,20 @@ object DownloadObserver {
|
||||
// 未成年
|
||||
RealNameHelper.showRealNameUnqualifiedDialog(downloadEntity)
|
||||
|
||||
// 删除任务
|
||||
downloadEntity.status = DownloadStatus.cancel
|
||||
downloadManager.cancel(downloadEntity.url)
|
||||
} else if (DownloadStatus.unavailable == downloadEntity.status) {
|
||||
// 未接入防沉迷系统
|
||||
val currentActivity = AppManager.getInstance().currentActivity() ?: return
|
||||
|
||||
DialogHelper.showDialog(
|
||||
context = currentActivity,
|
||||
title = "温馨提示",
|
||||
content = "该游戏未接入防沉迷系统,暂不支持下载",
|
||||
confirmText = "知道了",
|
||||
cancelText = "")
|
||||
|
||||
// 删除任务
|
||||
downloadEntity.status = DownloadStatus.cancel
|
||||
downloadManager.cancel(downloadEntity.url)
|
||||
|
||||
@ -47,6 +47,7 @@ public class EntranceUtils {
|
||||
public static final String KEY_GAMENAME = "gameName";
|
||||
public static final String KEY_PACKAGE_MD5 = "package_md5";
|
||||
public static final String HOST_ARTICLE = "article";
|
||||
public static final String HOST_INVOKE_ONLY = "invoke_only";
|
||||
public static final String HOST_UPLOAD_VIDEO = "upload_video";//上传视频
|
||||
public static final String HOST_UPLOAD_VIDEO_NEW = "upload_video_new"; // 上传视频新(AKA 发视频)
|
||||
public static final String HOST_VIDEO_SINGLE = "video_single";//指定视频-不能划动
|
||||
@ -264,6 +265,8 @@ public class EntranceUtils {
|
||||
public static final String KEY_GAME_COLLECTION_ID = "game_collection_id";//游戏单ID
|
||||
public static final String KEY_ASSIST_RES = "assist_res";
|
||||
public static final String KEY_LAST_SELECTED_POSITION = "last_selected_position";
|
||||
public static final String KEY_RECOMMEND_ID = "recommend_id";
|
||||
public static final String KEY_LAST_PAGE_DATA = "last_page_data";
|
||||
|
||||
public static void jumpActivity(Context context, Bundle bundle) {
|
||||
bundle.putBoolean(KEY_REQUIRE_REDIRECT, true);
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.animation.Animator
|
||||
import android.app.Activity
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
@ -20,11 +21,13 @@ import android.util.Log
|
||||
import android.util.TypedValue
|
||||
import android.view.*
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.webkit.WebView
|
||||
import android.widget.EditText
|
||||
import android.widget.PopupWindow
|
||||
import android.widget.SeekBar
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.ColorRes
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.text.HtmlCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
@ -34,6 +37,8 @@ import androidx.lifecycle.Observer
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import androidx.webkit.WebSettingsCompat
|
||||
import androidx.webkit.WebViewFeature
|
||||
import com.airbnb.lottie.LottieAnimationView
|
||||
import com.facebook.drawee.view.SimpleDraweeView
|
||||
import com.gh.common.DefaultUrlHandler
|
||||
@ -753,7 +758,7 @@ fun <T> Array<out T>.secondOrNull(): T? {
|
||||
fun ExpandTextView.setTextWithInterceptingInternalUrl(
|
||||
shrankText: CharSequence,
|
||||
expandedText: CharSequence,
|
||||
clickedCallback: (url: String)-> Unit
|
||||
clickedCallback: (url: String) -> Unit
|
||||
) {
|
||||
var shrankSsb = shrankText.interceptUrlSpanAndRoundImageSpan(clickedCallback)
|
||||
var expandedSsb = expandedText.interceptUrlSpanAndRoundImageSpan(clickedCallback)
|
||||
@ -881,10 +886,24 @@ fun Int.toColor(): Int {
|
||||
return ContextCompat.getColor(HaloApp.getInstance().application, this)
|
||||
}
|
||||
|
||||
/**
|
||||
* 只能传Activity的context,如果是Application的context会导致切换夜间模式变不了色
|
||||
*/
|
||||
fun Int.toColor(context: Context): Int {
|
||||
return ContextCompat.getColor(context, this)
|
||||
}
|
||||
|
||||
fun Int.toDrawable(): Drawable? {
|
||||
return ContextCompat.getDrawable(HaloApp.getInstance().application, this)
|
||||
}
|
||||
|
||||
/**
|
||||
* 只能传Activity的context,如果是Application的context会导致切换夜间模式变不了色
|
||||
*/
|
||||
fun Int.toDrawable(context: Context): Drawable? {
|
||||
return ContextCompat.getDrawable(context, this)
|
||||
}
|
||||
|
||||
fun Int.toResString(): String {
|
||||
return HaloApp.getInstance().application.resources.getString(this)
|
||||
}
|
||||
@ -1172,6 +1191,20 @@ fun View.getBitmapFromView(): Bitmap? {
|
||||
return bitmap
|
||||
}
|
||||
|
||||
fun View.setRootBackgroundColor(@ColorRes res: Int) {
|
||||
if (this.id == View.NO_ID) {
|
||||
this.id = R.id.root_container
|
||||
}
|
||||
this.setBackgroundColor(res.toColor(this.context))
|
||||
}
|
||||
|
||||
fun View.setRootBackgroundDrawable(@DrawableRes res: Int) {
|
||||
if (this.id == View.NO_ID) {
|
||||
this.id = R.id.root_container
|
||||
}
|
||||
this.background = res.toDrawable(this.context)
|
||||
}
|
||||
|
||||
fun String.hexStringToIntColor(): Int {
|
||||
val colorStr = if (this.length == 9) {
|
||||
"#${this.substring(3)}"
|
||||
@ -1194,4 +1227,25 @@ fun String.lengthOfEmojiHalf(): Int {
|
||||
fun String.emojiCount(): Int {
|
||||
val onlyText = EmojiUtils.removeEmoji(this)
|
||||
return (this.length - onlyText.length) / 2
|
||||
}
|
||||
|
||||
/**
|
||||
* WebView启用强制深色模式
|
||||
*/
|
||||
fun WebView.enableForceDark(nightMode: Boolean) {
|
||||
if (BuildConfig.IS_NIGHT_MODE_ON && WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) {
|
||||
WebSettingsCompat.setForceDark(settings, if (nightMode) WebSettingsCompat.FORCE_DARK_ON else WebSettingsCompat.FORCE_DARK_OFF)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 日夜间模式切换更新状态栏底色
|
||||
*/
|
||||
fun Activity.updateStatusBarColor(@ColorRes nightColor: Int, @ColorRes dayColor: Int) {
|
||||
if (BuildConfig.IS_NIGHT_MODE_ON) {
|
||||
DisplayUtils.setStatusBarColor(
|
||||
this,
|
||||
if (NightModeUtils.isNightMode(this)) nightColor else dayColor
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -51,15 +51,17 @@ object NewLogUtils {
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
fun logForumContentBrowser(contentId: String, contentType: String) {
|
||||
val requestBody = hashMapOf(
|
||||
Pair("content_id", contentId),
|
||||
Pair("content_type", contentType)
|
||||
).createRequestBody()
|
||||
fun logForumContentBrowser(contentId: String, contentType: String, recommendId: String) {
|
||||
val requestMap = hashMapOf<String, Any>()
|
||||
requestMap["content_id"] = contentId
|
||||
requestMap["content_type"] = contentType
|
||||
if (recommendId.isNotBlank()) {
|
||||
requestMap["recommend_id"] = recommendId
|
||||
}
|
||||
|
||||
RetrofitManager.getInstance()
|
||||
.api
|
||||
.postBrowses(requestBody)
|
||||
.postBrowses(requestMap.toRequestBody())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(EmptyResponse<ResponseBody>())
|
||||
}
|
||||
|
||||
61
app/src/main/java/com/gh/common/util/NightModeUtils.kt
Normal file
61
app/src/main/java/com/gh/common/util/NightModeUtils.kt
Normal file
@ -0,0 +1,61 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.Configuration
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import com.gh.common.constant.Constants
|
||||
import com.gh.gamecenter.BuildConfig
|
||||
|
||||
object NightModeUtils {
|
||||
/**
|
||||
* 当前系统是否是深色模式
|
||||
*/
|
||||
fun isNightMode(context: Context): Boolean {
|
||||
// 仅配置开启的包才提供夜间模式功能
|
||||
return if (BuildConfig.IS_NIGHT_MODE_ON) {
|
||||
val uiMode = context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
|
||||
uiMode == Configuration.UI_MODE_NIGHT_YES
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取是否跟随系统,默认true
|
||||
*/
|
||||
fun getSystemMode() = SPUtils.getBoolean(Constants.SP_SYSTEM_MODE, true)
|
||||
|
||||
fun setSystemMode(nightMode: Boolean) = SPUtils.setBoolean(Constants.SP_SYSTEM_MODE, nightMode)
|
||||
|
||||
/**
|
||||
* 获取是否设置深色模式,默认false
|
||||
*/
|
||||
fun getNightMode() = SPUtils.getBoolean(Constants.SP_NIGHT_MODE, false)
|
||||
|
||||
fun setNightMode(nightMode: Boolean) = SPUtils.setBoolean(Constants.SP_NIGHT_MODE, nightMode)
|
||||
|
||||
fun initNightMode() {
|
||||
initNightMode(getSystemMode(), getNightMode())
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化App深色模式
|
||||
*
|
||||
* @param systemMode 是否是跟随系统
|
||||
* @param nightMode 是否是深色模式
|
||||
*/
|
||||
fun initNightMode(systemMode: Boolean, nightMode: Boolean) {
|
||||
// 仅配置开启的包才提供夜间模式功能
|
||||
if (BuildConfig.IS_NIGHT_MODE_ON) {
|
||||
if (systemMode) {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
|
||||
} else {
|
||||
if (nightMode) {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
|
||||
} else {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -15,7 +15,7 @@ object OptionDialogHelper {
|
||||
val dialog = Dialog(context)
|
||||
val container = LinearLayout(context)
|
||||
container.orientation = LinearLayout.VERTICAL
|
||||
container.setBackgroundColor(Color.WHITE)
|
||||
container.setBackgroundColor(R.color.background_white.toColor(context))
|
||||
container.setPadding(0, DisplayUtils.dip2px(context, 12f), 0, DisplayUtils.dip2px(context, 12f))
|
||||
|
||||
for (type in typeList) {
|
||||
|
||||
@ -53,15 +53,23 @@ object PackageInstaller {
|
||||
// TODO 此处可能遇到 activity 是 WXEntryActivity
|
||||
// TODO 当 activity 全部出栈,但是应用还在下载游戏,下载完会唤不起安装!
|
||||
if (currentActivity is AppCompatActivity && !currentActivity.isFinishing) {
|
||||
InstallPermissionDialogFragment.show(currentActivity, downloadEntity) {
|
||||
InstallPermissionDialogFragment.show(currentActivity, downloadEntity) { isFromPermissionGrantedCallback ->
|
||||
// 取消状态栏下载完成的通知,若存在
|
||||
downloadEntity.meta[Constants.MARK_ALREADY_TRIGGERED_INSTALLATION] = "YES"
|
||||
DownloadNotificationHelper.addOrUpdateDownloadNotification(downloadEntity)
|
||||
|
||||
if (isXapk) {
|
||||
XapkInstaller.install(context, downloadEntity, showUnzipToast)
|
||||
if (isFromPermissionGrantedCallback && Build.VERSION.SDK_INT >= 31) {
|
||||
val pm = context.packageManager
|
||||
val intent = pm.getLaunchIntentForPackage(context.packageName)
|
||||
val mainIntent = Intent.makeRestartActivityTask(intent!!.component)
|
||||
context.startActivity(mainIntent)
|
||||
Runtime.getRuntime().exit(0)
|
||||
} else {
|
||||
install(context, downloadEntity.isPlugin, downloadEntity.path)
|
||||
if (isXapk) {
|
||||
XapkInstaller.install(context, downloadEntity, showUnzipToast)
|
||||
} else {
|
||||
install(context, downloadEntity.isPlugin, downloadEntity.path)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -151,6 +151,43 @@ public class PostCommentUtils {
|
||||
});
|
||||
}
|
||||
|
||||
public static void unLikeComment(
|
||||
String articleId,
|
||||
String articleCommunityId,
|
||||
String videoId,
|
||||
String questionId,
|
||||
final String commentId,
|
||||
final PostCommentListener listener) {
|
||||
Observable<ResponseBody> observable;
|
||||
|
||||
if (!TextUtils.isEmpty(questionId)) {
|
||||
observable = RetrofitManager.getInstance().getApi().postUnVoteQuestionComment(questionId, commentId);
|
||||
} else if (!TextUtils.isEmpty(articleCommunityId) && !TextUtils.isEmpty(articleId)) {
|
||||
observable = RetrofitManager.getInstance().getApi().postUnVoteArticleComment(articleCommunityId, articleId, commentId);
|
||||
} else {
|
||||
observable = RetrofitManager.getInstance().getApi().postUnVoteVideoComment(videoId, commentId);
|
||||
}
|
||||
observable
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Response<ResponseBody>() {
|
||||
@Override
|
||||
public void onResponse(ResponseBody response) {
|
||||
if (listener != null) {
|
||||
listener.postSuccess(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(HttpException e) {
|
||||
if (listener != null) {
|
||||
listener.postFailed(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public static void addCommentVote(final String commentId,
|
||||
final PostCommentListener listener) {
|
||||
RetrofitManager.getInstance().getApi()
|
||||
@ -260,10 +297,11 @@ public class PostCommentUtils {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void reportQuestionComment(final String questionId,
|
||||
final String commentId,
|
||||
final String reportData,
|
||||
final PostCommentListener listener) {
|
||||
final String commentId,
|
||||
final String reportData,
|
||||
final PostCommentListener listener) {
|
||||
RequestBody body = RequestBody.create(MediaType.parse("application/json"), reportData);
|
||||
RetrofitManager.getInstance().getApi()
|
||||
.postQuestionCommentReport(questionId, commentId, body)
|
||||
|
||||
@ -10,6 +10,7 @@ import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.PopupWindow
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.gh.common.util.toColor
|
||||
import com.gh.common.util.visibleIf
|
||||
@ -74,13 +75,23 @@ class CatalogFilterView @JvmOverloads constructor(context: Context, attrs: Attri
|
||||
mOnCatalogFilterSetupListener = onCatalogFilterSetupListener
|
||||
}
|
||||
|
||||
fun setRootBackgroundColor(@ColorInt color: Int) {
|
||||
findViewById<View>(R.id.config_controller).setBackgroundColor(color)
|
||||
}
|
||||
|
||||
fun setItemTextColor(@ColorInt color: Int) {
|
||||
mTypeTv.setTextColor(color)
|
||||
mCatalogTv.setTextColor(color)
|
||||
mSizeTv.setTextColor(color)
|
||||
}
|
||||
|
||||
private fun toggleHighlightedTextView(targetTextView: TextView, highlightIt: Boolean) {
|
||||
if (highlightIt) {
|
||||
targetTextView.background = ContextCompat.getDrawable(targetTextView.context, R.drawable.bg_tag_text)
|
||||
targetTextView.setTextColor(Color.WHITE)
|
||||
} else {
|
||||
targetTextView.background = null
|
||||
targetTextView.setTextColor(ContextCompat.getColor(targetTextView.context, R.color.text_757575))
|
||||
targetTextView.setTextColor(R.color.text_757575.toColor(context))
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,7 +101,7 @@ class CatalogFilterView @JvmOverloads constructor(context: Context, attrs: Attri
|
||||
drawableUp?.setBounds(0, 0, drawableUp.minimumWidth, drawableUp.minimumHeight)
|
||||
drawableDown?.setBounds(0, 0, drawableDown.minimumWidth, drawableDown.minimumHeight)
|
||||
|
||||
typeTv.setTextColor(R.color.theme_font.toColor())
|
||||
typeTv.setTextColor(R.color.theme_font.toColor(context))
|
||||
typeTv.setCompoundDrawables(null, null, drawableUp, null)
|
||||
|
||||
val inflater = LayoutInflater.from(typeTv.context)
|
||||
@ -134,7 +145,7 @@ class CatalogFilterView @JvmOverloads constructor(context: Context, attrs: Attri
|
||||
}
|
||||
|
||||
popupWindow.setOnDismissListener {
|
||||
typeTv.setTextColor(R.color.text_757575.toColor())
|
||||
typeTv.setTextColor(R.color.text_757575.toColor(context))
|
||||
typeTv.setCompoundDrawables(null, null, drawableDown, null)
|
||||
}
|
||||
|
||||
@ -150,7 +161,7 @@ class CatalogFilterView @JvmOverloads constructor(context: Context, attrs: Attri
|
||||
drawableUp?.setBounds(0, 0, drawableUp.minimumWidth, drawableUp.minimumHeight)
|
||||
drawableDown?.setBounds(0, 0, drawableDown.minimumWidth, drawableDown.minimumHeight)
|
||||
|
||||
catalogTv.setTextColor(R.color.theme_font.toColor())
|
||||
catalogTv.setTextColor(R.color.theme_font.toColor(context))
|
||||
catalogTv.setCompoundDrawables(null, null, drawableUp, null)
|
||||
|
||||
val inflater = LayoutInflater.from(catalogTv.context)
|
||||
@ -196,7 +207,7 @@ class CatalogFilterView @JvmOverloads constructor(context: Context, attrs: Attri
|
||||
}
|
||||
|
||||
popupWindow.setOnDismissListener {
|
||||
catalogTv.setTextColor(R.color.text_757575.toColor())
|
||||
catalogTv.setTextColor(R.color.text_757575.toColor(context))
|
||||
catalogTv.setCompoundDrawables(null, null, drawableDown, null)
|
||||
}
|
||||
|
||||
@ -212,7 +223,7 @@ class CatalogFilterView @JvmOverloads constructor(context: Context, attrs: Attri
|
||||
drawableUp?.setBounds(0, 0, drawableUp.minimumWidth, drawableUp.minimumHeight)
|
||||
drawableDown?.setBounds(0, 0, drawableDown.minimumWidth, drawableDown.minimumHeight)
|
||||
|
||||
sizeTv.setTextColor(R.color.theme_font.toColor())
|
||||
sizeTv.setTextColor(R.color.theme_font.toColor(context))
|
||||
sizeTv.setCompoundDrawables(null, null, drawableUp, null)
|
||||
|
||||
val inflater = LayoutInflater.from(sizeTv.context)
|
||||
@ -266,7 +277,7 @@ class CatalogFilterView @JvmOverloads constructor(context: Context, attrs: Attri
|
||||
}
|
||||
|
||||
popupWindow.setOnDismissListener {
|
||||
sizeTv.setTextColor(R.color.text_757575.toColor())
|
||||
sizeTv.setTextColor(R.color.text_757575.toColor(context))
|
||||
sizeTv.setCompoundDrawables(null, null, drawableDown, null)
|
||||
}
|
||||
|
||||
|
||||
@ -23,11 +23,13 @@ class ConfigFilterView @JvmOverloads constructor(
|
||||
) : ConstraintLayout(context, attrs, defStyleAttr) {
|
||||
|
||||
private var mSizeTv: TextView
|
||||
private var mPopupWindow: PopupWindow? = null
|
||||
|
||||
var newestTv: TextView
|
||||
var ratingTv: TextView //目前只在专题页面显示
|
||||
var recommendedTv: TextView
|
||||
var updateTv: TextView //更新
|
||||
var container: View
|
||||
|
||||
var sizeFilterArray: ArrayList<SubjectSettingEntity.Size>? = null
|
||||
|
||||
@ -42,6 +44,7 @@ class ConfigFilterView @JvmOverloads constructor(
|
||||
ratingTv = findViewById(R.id.rating_tv)
|
||||
updateTv = findViewById(R.id.updateTv)
|
||||
recommendedTv = findViewById(R.id.recommended_tv)
|
||||
container = findViewById(R.id.config_controller)
|
||||
|
||||
mSelectionTvList = arrayListOf(newestTv, ratingTv, updateTv, recommendedTv)
|
||||
|
||||
@ -77,6 +80,16 @@ class ConfigFilterView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
fun updateAllTextView(sortType: SortType) {
|
||||
when (sortType) {
|
||||
SortType.RECOMMENDED -> updateHighlightedTextView(recommendedTv)
|
||||
SortType.NEWEST -> updateHighlightedTextView(newestTv)
|
||||
SortType.RATING -> updateHighlightedTextView(ratingTv)
|
||||
SortType.UPDATE -> updateHighlightedTextView(updateTv)
|
||||
}
|
||||
mSizeTv.setTextColor(R.color.text_757575.toColor(context))
|
||||
}
|
||||
|
||||
fun setOnConfigSetupListener(onConfigFilterSetupListener: OnConfigFilterSetupListener) {
|
||||
mOnConfigFilterSetupListener = onConfigFilterSetupListener
|
||||
}
|
||||
@ -97,6 +110,13 @@ class ConfigFilterView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
fun updatePopupWindow() {
|
||||
if (mPopupWindow != null) {
|
||||
mPopupWindow?.dismiss()
|
||||
showSelectionPopupWindow(this, mSizeTv, mSizeTv.text.toString())
|
||||
}
|
||||
}
|
||||
|
||||
private fun showSelectionPopupWindow(containerView: View, sizeTv: TextView, sizeText: String) {
|
||||
val drawableUp = ContextCompat.getDrawable(sizeTv.context, R.drawable.ic_filter_arrow_up)
|
||||
val drawableDown =
|
||||
@ -104,7 +124,7 @@ class ConfigFilterView @JvmOverloads constructor(
|
||||
drawableUp?.setBounds(0, 0, drawableUp.minimumWidth, drawableUp.minimumHeight)
|
||||
drawableDown?.setBounds(0, 0, drawableDown.minimumWidth, drawableDown.minimumHeight)
|
||||
|
||||
sizeTv.setTextColor(R.color.theme_font.toColor())
|
||||
sizeTv.setTextColor(R.color.theme_font.toColor(sizeTv.context))
|
||||
sizeTv.setCompoundDrawables(null, null, drawableUp, null)
|
||||
|
||||
val inflater = LayoutInflater.from(sizeTv.context)
|
||||
@ -113,7 +133,7 @@ class ConfigFilterView @JvmOverloads constructor(
|
||||
layout,
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
)
|
||||
).apply { mPopupWindow = this }
|
||||
|
||||
val flexboxLayout = layout.findViewById<FlexboxLayout>(R.id.flexbox)
|
||||
val backgroundView = layout.findViewById<View>(R.id.background)
|
||||
@ -163,8 +183,9 @@ class ConfigFilterView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
popupWindow.setOnDismissListener {
|
||||
sizeTv.setTextColor(R.color.text_757575.toColor())
|
||||
sizeTv.setTextColor(R.color.text_757575.toColor(sizeTv.context))
|
||||
sizeTv.setCompoundDrawables(null, null, drawableDown, null)
|
||||
mPopupWindow = null
|
||||
}
|
||||
|
||||
popupWindow.isTouchable = true
|
||||
|
||||
@ -183,7 +183,7 @@ class FilterView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
||||
holder.binding.titleTv.setBackgroundResource(R.drawable.bg_tag_text)
|
||||
holder.binding.titleTv.setTextColor(R.color.white.toColor())
|
||||
} else {
|
||||
holder.binding.titleTv.setBackgroundColor(Color.WHITE)
|
||||
holder.binding.titleTv.setBackgroundColor(R.color.background_white.toColor(holder.binding.root.context))
|
||||
holder.binding.titleTv.setTextColor(R.color.text_777777.toColor())
|
||||
}
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@ import androidx.core.content.ContextCompat
|
||||
import com.gh.common.util.DisplayUtils
|
||||
import com.gh.common.util.dip2px
|
||||
import com.gh.common.util.sp2px
|
||||
import com.gh.common.util.toColor
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.entity.TagStyleEntity
|
||||
import kotlin.math.ceil
|
||||
@ -43,7 +44,7 @@ class FlexLinearLayout @JvmOverloads constructor(context: Context, attrs: Attrib
|
||||
mMargin = ta.getDimensionPixelSize(R.styleable.FlexLinearLayout_itemMargin, 4f.dip2px())
|
||||
mTextSize = ta.getDimension(R.styleable.FlexLinearLayout_itemTextSize, 10f.sp2px().toFloat())
|
||||
mLastItemWidth = ta.getDimensionPixelSize(R.styleable.FlexLinearLayout_lastItemWidth, 18f.dip2px())
|
||||
mStrokeWidth = ta.getDimensionPixelSize(R.styleable.FlexLinearLayout_strokeWidth, 1f.dip2px())
|
||||
mStrokeWidth = ta.getDimensionPixelSize(R.styleable.FlexLinearLayout_strokeWidth, 0.5f.dip2px())
|
||||
|
||||
ta.recycle()
|
||||
}
|
||||
@ -107,7 +108,7 @@ class FlexLinearLayout @JvmOverloads constructor(context: Context, attrs: Attrib
|
||||
includeFontPadding = false
|
||||
textSize = DisplayUtils.px2sp(context, mTextSize).toFloat()
|
||||
gravity = Gravity.CENTER
|
||||
setTextColor(Color.parseColor("#333333"))
|
||||
setTextColor(R.color.text_title.toColor(context))
|
||||
|
||||
val params = LayoutParams(LayoutParams.WRAP_CONTENT, mItemHeight)
|
||||
params.setMargins(0, 0, mMargin, 0)
|
||||
@ -125,7 +126,7 @@ class FlexLinearLayout @JvmOverloads constructor(context: Context, attrs: Attrib
|
||||
private fun createBackgroundDrawable(): GradientDrawable {
|
||||
val gradientDrawable = GradientDrawable()
|
||||
gradientDrawable.setColor(Color.TRANSPARENT)
|
||||
gradientDrawable.setStroke(mStrokeWidth, Color.parseColor("#C2C6CC"))
|
||||
gradientDrawable.setStroke(mStrokeWidth, Color.parseColor("#CCCCCC"))
|
||||
gradientDrawable.cornerRadius = DisplayUtils.dip2px(2f).toFloat()
|
||||
return gradientDrawable
|
||||
}
|
||||
|
||||
@ -12,6 +12,7 @@ import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.gh.common.util.DisplayUtils
|
||||
import com.gh.common.util.toColor
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.entity.TagStyleEntity
|
||||
import kotlin.math.ceil
|
||||
@ -80,7 +81,7 @@ class GameTagFlexLinearLayout @JvmOverloads constructor(context: Context, attrs:
|
||||
includeFontPadding = false
|
||||
textSize = mTextSize
|
||||
gravity = Gravity.CENTER
|
||||
setTextColor(Color.parseColor("#666666"))
|
||||
setTextColor(R.color.text_subtitle.toColor(context))
|
||||
|
||||
val params = LayoutParams(LayoutParams.WRAP_CONTENT, mItemHeight)
|
||||
params.setMargins(0, 0, mMargin, 0)
|
||||
|
||||
@ -237,6 +237,10 @@ class ImageContainerView : LinearLayout {
|
||||
} else {
|
||||
params.width = mDefaultWidth.toInt()
|
||||
params.height = mDefaultWidth.toInt()
|
||||
if (width > height) {
|
||||
val loadImageWidth = width * (mDefaultWidth.toInt() / height)
|
||||
binding.image.setTag(ImageUtils.TAG_TARGET_WIDTH, loadImageWidth.toInt())
|
||||
}
|
||||
ImageUtils.display(binding.image, url, false)
|
||||
}
|
||||
//长图
|
||||
|
||||
@ -24,7 +24,6 @@ import com.gh.common.util.GsonUtils;
|
||||
import com.gh.common.util.HtmlUtils;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
import com.gh.common.util.MtaHelper;
|
||||
import com.gh.common.util.NetworkUtils;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.util.RichEditorUtils;
|
||||
import com.gh.common.util.SPUtils;
|
||||
@ -62,8 +61,8 @@ import java.util.Locale;
|
||||
|
||||
public class RichEditor extends WebView {
|
||||
// 和 rich_editor.js 同步
|
||||
public static String IMAGE_FLAG_DEFAULT = ",default";
|
||||
public static String IMAGE_FLAG_THUMBNAIL = ",thumbnail";
|
||||
// public static String IMAGE_FLAG_DEFAULT = ",default";
|
||||
// public static String IMAGE_FLAG_THUMBNAIL = ",thumbnail";
|
||||
|
||||
private boolean mContentOwner;
|
||||
private boolean mInputEnabled;
|
||||
@ -132,7 +131,7 @@ public class RichEditor extends WebView {
|
||||
|
||||
int widthPixels = getResources().getDisplayMetrics().widthPixels - DisplayUtils.dip2px(40);
|
||||
mThumbnailImageWidth = widthPixels / 3;
|
||||
mDefaultImageWidth = widthPixels * 2;
|
||||
mDefaultImageWidth = widthPixels;
|
||||
}
|
||||
|
||||
@SuppressLint({"SetJavaScriptEnabled", "AddJavascriptInterface"})
|
||||
@ -251,13 +250,7 @@ public class RichEditor extends WebView {
|
||||
exec("javascript:RE.setHtmlByVideoStatus('" + URLEncoder.encode(contents, "UTF-8") + "');");
|
||||
|
||||
if (isLoadTbImage) {
|
||||
if (!NetworkUtils.isWifiOr4GConnected(getContext())) {
|
||||
exec("javascript:RE.replaceTbImage('" +
|
||||
ImageUtils.getLimitWidthRule(mThumbnailImageWidth) + IMAGE_FLAG_THUMBNAIL + "','" +
|
||||
ImageUtils.getWatermarkWidthGifRule(mThumbnailImageWidth) + IMAGE_FLAG_THUMBNAIL + "');");
|
||||
} else {
|
||||
replaceAllDfImageExcludeGif();
|
||||
}
|
||||
replaceAllDfImage();
|
||||
exec("javascript:RE.ImageClickListener()");
|
||||
}
|
||||
|
||||
@ -370,21 +363,21 @@ public class RichEditor extends WebView {
|
||||
|
||||
public void replaceAllDfImageExcludeGif() {
|
||||
exec("javascript:RE.replaceAllDfImage('" +
|
||||
ImageUtils.getLimitWidthRule(mDefaultImageWidth) + IMAGE_FLAG_DEFAULT + "','" +
|
||||
ImageUtils.getWatermarkWidthGifRule(mThumbnailImageWidth) + IMAGE_FLAG_THUMBNAIL + "')");
|
||||
ImageUtils.getLimitWidthRule(mDefaultImageWidth) + "','" +
|
||||
ImageUtils.getWatermarkWidthGifRule(mThumbnailImageWidth) + "')");
|
||||
}
|
||||
|
||||
|
||||
public void replaceAllDfImage() {
|
||||
exec("javascript:RE.replaceAllDfImage('" +
|
||||
ImageUtils.getLimitWidthRule(mDefaultImageWidth) + IMAGE_FLAG_DEFAULT + "','" +
|
||||
ImageUtils.getDefaultGifRule() + IMAGE_FLAG_DEFAULT + "')");
|
||||
ImageUtils.getLimitWidthRule(mDefaultImageWidth) + "','" +
|
||||
ImageUtils.getDefaultGifRule() + "')");
|
||||
}
|
||||
|
||||
public void replaceDfImageByUrl(String imgUrl) {
|
||||
exec("javascript:RE.replaceDfImageByUrl('" + imgUrl + "','" +
|
||||
ImageUtils.getLimitWidthRule(mDefaultImageWidth) + IMAGE_FLAG_DEFAULT + "','" +
|
||||
ImageUtils.getDefaultGifRule() + IMAGE_FLAG_DEFAULT + "');");
|
||||
ImageUtils.getLimitWidthRule(mDefaultImageWidth) + "','" +
|
||||
ImageUtils.getDefaultGifRule() + "');");
|
||||
}
|
||||
|
||||
public void loadCSS(String cssFile) {
|
||||
|
||||
215
app/src/main/java/com/gh/common/view/ScaleIndicatorView.kt
Normal file
215
app/src/main/java/com/gh/common/view/ScaleIndicatorView.kt
Normal file
@ -0,0 +1,215 @@
|
||||
package com.gh.common.view
|
||||
|
||||
import android.animation.ArgbEvaluator
|
||||
import android.content.Context
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Color
|
||||
import android.graphics.Paint
|
||||
import android.graphics.RectF
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import androidx.annotation.ColorInt
|
||||
import com.gh.common.util.dip2px
|
||||
import com.gh.gamecenter.R
|
||||
|
||||
class ScaleIndicatorView : View {
|
||||
|
||||
private var argbEvaluator: ArgbEvaluator? = null
|
||||
|
||||
private var mCurrentPosition = 0
|
||||
private var mSlideProgress = 0F
|
||||
var mPageSize = 0
|
||||
var mNormalSliderWidth = 0F
|
||||
var mCheckedSliderWidth = 0F
|
||||
var mSliderHeight = 0F
|
||||
var mSliderGap = 0F
|
||||
|
||||
@ColorInt
|
||||
var mNormalColor = 0
|
||||
|
||||
@ColorInt
|
||||
var mCheckedColor = 0
|
||||
|
||||
private var mRectF = RectF()
|
||||
private var mPaint = Paint()
|
||||
|
||||
private var maxWidth = 0F
|
||||
private var minWidth = 0F
|
||||
|
||||
private val isWidthEquals
|
||||
get() = mNormalSliderWidth == mCheckedSliderWidth
|
||||
|
||||
constructor(context: Context) : super(context, null) {
|
||||
initView(null)
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs, 0) {
|
||||
initView(attrs)
|
||||
}
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyleAttr
|
||||
) {
|
||||
initView(attrs)
|
||||
}
|
||||
|
||||
private fun initView(attrs: AttributeSet?) {
|
||||
if (attrs != null) {
|
||||
val ta = context.obtainStyledAttributes(attrs, R.styleable.ScaleIndicatorView)
|
||||
mNormalSliderWidth = ta.getDimensionPixelSize(R.styleable.ScaleIndicatorView_normalSliderWidth, 10F.dip2px()).toFloat()
|
||||
mCheckedSliderWidth = ta.getDimensionPixelSize(R.styleable.ScaleIndicatorView_checkedSliderWidth, 10F.dip2px()).toFloat()
|
||||
mSliderHeight = ta.getDimensionPixelSize(R.styleable.ScaleIndicatorView_normalSliderWidth, 10F.dip2px()).toFloat()
|
||||
mSliderGap = ta.getDimensionPixelSize(R.styleable.ScaleIndicatorView_normalSliderWidth, 10F.dip2px()).toFloat()
|
||||
mNormalColor = ta.getColor(R.styleable.ScaleIndicatorView_normalColor, Color.WHITE)
|
||||
mCheckedColor = ta.getColor(R.styleable.ScaleIndicatorView_checkedColor, Color.WHITE)
|
||||
}
|
||||
mPaint.isAntiAlias = true
|
||||
argbEvaluator = ArgbEvaluator()
|
||||
}
|
||||
|
||||
fun onPageScrolled(position: Int, positionOffset: Float) {
|
||||
if (mPageSize > 1) {
|
||||
scrollSlider(position, positionOffset)
|
||||
invalidate()
|
||||
}
|
||||
}
|
||||
|
||||
fun notifyDataChanged() {
|
||||
requestLayout()
|
||||
invalidate()
|
||||
}
|
||||
|
||||
private fun scrollSlider(
|
||||
position: Int,
|
||||
positionOffset: Float
|
||||
) {
|
||||
mCurrentPosition = position
|
||||
mSlideProgress = positionOffset
|
||||
}
|
||||
|
||||
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
|
||||
maxWidth = mNormalSliderWidth.coerceAtLeast(mCheckedSliderWidth)
|
||||
minWidth = mNormalSliderWidth.coerceAtMost(mCheckedSliderWidth)
|
||||
setMeasuredDimension(measureWidth(), measureHeight())
|
||||
}
|
||||
|
||||
private fun measureHeight() = mSliderHeight.toInt() + INDICATOR_PADDING
|
||||
|
||||
private fun measureWidth() =
|
||||
((mPageSize - 1) * mSliderGap + maxWidth + (mPageSize - 1) * minWidth).toInt() + INDICATOR_PADDING_ADDITION
|
||||
|
||||
override fun onDraw(canvas: Canvas?) {
|
||||
super.onDraw(canvas)
|
||||
if (mPageSize > 1) {
|
||||
if (isWidthEquals) {
|
||||
drawUncheckedSlider(canvas, mPageSize)
|
||||
} else {
|
||||
for (i in 0 until mPageSize) {
|
||||
drawScaleSlider(canvas, i)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun drawScaleSlider(
|
||||
canvas: Canvas?,
|
||||
i: Int
|
||||
) {
|
||||
when {
|
||||
i < mCurrentPosition -> {
|
||||
mPaint.color = mNormalColor
|
||||
val left: Float = if (mCurrentPosition == mPageSize - 1) {
|
||||
(i * mNormalSliderWidth + i * mSliderGap) + (mCheckedSliderWidth - mNormalSliderWidth) * mSlideProgress
|
||||
} else {
|
||||
(i * mNormalSliderWidth + i * mSliderGap)
|
||||
}
|
||||
mRectF.set(left, 0f, left + mNormalSliderWidth, mSliderHeight)
|
||||
canvas?.drawRoundRect(mRectF, mSliderHeight, mSliderHeight, mPaint)
|
||||
}
|
||||
i == mCurrentPosition -> {
|
||||
mPaint.color = mCheckedColor
|
||||
val slideProgress = mSlideProgress
|
||||
if (mCurrentPosition == mPageSize - 1) {
|
||||
val evaluate = argbEvaluator?.evaluate(
|
||||
slideProgress, mCheckedColor, mNormalColor
|
||||
)
|
||||
mPaint.color = (evaluate as Int)
|
||||
val right =
|
||||
(mPageSize - 1) * (mNormalSliderWidth + mSliderGap) + mCheckedSliderWidth
|
||||
val left =
|
||||
right - mCheckedSliderWidth + (mCheckedSliderWidth - mNormalSliderWidth) * (slideProgress)
|
||||
mRectF.set(left, 0f, right, mSliderHeight)
|
||||
canvas?.drawRoundRect(mRectF, mSliderHeight, mSliderHeight, mPaint)
|
||||
} else {
|
||||
if (slideProgress < 1) {
|
||||
val evaluate = argbEvaluator?.evaluate(
|
||||
slideProgress, mCheckedColor, mNormalColor
|
||||
)
|
||||
mPaint.color = (evaluate as Int)
|
||||
val left = i * mNormalSliderWidth + i * mSliderGap
|
||||
val right =
|
||||
left + mNormalSliderWidth + (mCheckedSliderWidth - mNormalSliderWidth) * (1 - slideProgress)
|
||||
mRectF.set(left, 0f, right, mSliderHeight)
|
||||
canvas?.drawRoundRect(mRectF, mSliderHeight, mSliderHeight, mPaint)
|
||||
}
|
||||
}
|
||||
|
||||
if (mCurrentPosition == mPageSize - 1) {
|
||||
if (slideProgress > 0) {
|
||||
val evaluate = argbEvaluator?.evaluate(
|
||||
1 - slideProgress, mCheckedColor, mNormalColor
|
||||
)
|
||||
mPaint.color = evaluate as Int
|
||||
val left = 0f
|
||||
val right =
|
||||
left + mNormalSliderWidth + (mCheckedSliderWidth - mNormalSliderWidth) * slideProgress
|
||||
|
||||
mRectF.set(left, 0f, right, mSliderHeight)
|
||||
canvas?.drawRoundRect(mRectF, mSliderHeight, mSliderHeight, mPaint)
|
||||
}
|
||||
} else {
|
||||
if (slideProgress > 0) {
|
||||
val evaluate = argbEvaluator?.evaluate(
|
||||
1 - slideProgress, mCheckedColor, mNormalColor
|
||||
)
|
||||
mPaint.color = evaluate as Int
|
||||
val right =
|
||||
i * mNormalSliderWidth + i * mSliderGap + mNormalSliderWidth + (mSliderGap + mCheckedSliderWidth)
|
||||
val left =
|
||||
right - (mNormalSliderWidth) - (mCheckedSliderWidth - mNormalSliderWidth) * (slideProgress)
|
||||
mRectF.set(left, 0f, right, mSliderHeight)
|
||||
canvas?.drawRoundRect(mRectF, mSliderHeight, mSliderHeight, mPaint)
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
if ((mCurrentPosition + 1 != i || mSlideProgress == 0f)) { // 避免多余绘制
|
||||
mPaint.color = mNormalColor
|
||||
val left = i * minWidth + i * mSliderGap + (mCheckedSliderWidth - minWidth)
|
||||
mRectF.set(left, 0f, left + minWidth, mSliderHeight)
|
||||
canvas?.drawRoundRect(mRectF, mSliderHeight, mSliderHeight, mPaint)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun drawUncheckedSlider(
|
||||
canvas: Canvas?,
|
||||
pageSize: Int
|
||||
) {
|
||||
for (i in 0 until pageSize) {
|
||||
mPaint.color = mNormalColor
|
||||
val left = i * maxWidth + i * +mSliderGap + (maxWidth - minWidth)
|
||||
mRectF.set(left, 0f, left + minWidth, mSliderHeight)
|
||||
canvas?.drawRoundRect(mRectF, mSliderHeight, mSliderHeight, mPaint)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val INDICATOR_PADDING_ADDITION = 6
|
||||
const val INDICATOR_PADDING = 3
|
||||
}
|
||||
}
|
||||
@ -32,6 +32,7 @@ class SegmentedFilterView : FrameLayout {
|
||||
private lateinit var mContainer: FrameLayout
|
||||
private lateinit var mRadioGroup: RadioGroup
|
||||
private lateinit var mIndicator: View
|
||||
private var mCallback: OnCheckedCallback? = null
|
||||
|
||||
private var mItemList = listOf<String>()
|
||||
|
||||
@ -51,6 +52,25 @@ class SegmentedFilterView : FrameLayout {
|
||||
initView(attrs)
|
||||
}
|
||||
|
||||
fun setTextColor(colorStateList: ColorStateList?) {
|
||||
if (::mRadioGroup.isInitialized) {
|
||||
for (i in 0 until mRadioGroup.childCount) {
|
||||
val radioBtn = mRadioGroup.getChildAt(i) as RadioButton
|
||||
radioBtn.setTextColor(colorStateList)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun setContainerBackground(drawable: Drawable?) {
|
||||
background = drawable
|
||||
}
|
||||
|
||||
fun setIndicatorBackground(drawable: Drawable?) {
|
||||
if (::mIndicator.isInitialized) {
|
||||
mIndicator.background = drawable
|
||||
}
|
||||
}
|
||||
|
||||
private fun initView(attrs: AttributeSet?) {
|
||||
if (attrs != null) {
|
||||
val ta = context.obtainStyledAttributes(attrs, R.styleable.SegmentedFilterView)
|
||||
@ -100,13 +120,47 @@ class SegmentedFilterView : FrameLayout {
|
||||
if (defaultCheckPosition in 0 until mRadioGroup.childCount) (mRadioGroup.getChildAt(defaultCheckPosition) as RadioButton).isChecked = true
|
||||
}
|
||||
|
||||
fun getItemList(): List<String> {
|
||||
return mItemList
|
||||
}
|
||||
|
||||
fun performClick(position: Int) {
|
||||
if (position in 0 until mRadioGroup.childCount) {
|
||||
val radioButton = mRadioGroup.getChildAt(position) as RadioButton
|
||||
radioButton.isChecked = true
|
||||
startIndicatorAnimation(radioButton.x)
|
||||
mCallback?.onItemCheck(position)
|
||||
}
|
||||
}
|
||||
|
||||
fun setChecked(position: Int) {
|
||||
if (position in 0 until mRadioGroup.childCount) {
|
||||
val radioButton = mRadioGroup.getChildAt(position) as RadioButton
|
||||
mIndicator.x = radioButton.x
|
||||
radioButton.isChecked = true
|
||||
}
|
||||
}
|
||||
|
||||
fun getCurrentPosition(): Int {
|
||||
var position = 0
|
||||
for (i in 0 until mRadioGroup.childCount) {
|
||||
val radioButton = mRadioGroup.getChildAt(i) as RadioButton
|
||||
if (radioButton.isChecked) {
|
||||
position = i
|
||||
break
|
||||
}
|
||||
}
|
||||
return position
|
||||
}
|
||||
|
||||
fun setOnCheckedCallback(callback: OnCheckedCallback) {
|
||||
mCallback = callback
|
||||
mRadioGroup.setOnCheckedChangeListener { _, checkId ->
|
||||
for (i in 0 until mRadioGroup.childCount) {
|
||||
val radioBtn = mRadioGroup.getChildAt(i)
|
||||
if (checkId == radioBtn.id) {
|
||||
if (checkId == radioBtn.id && radioBtn.x != mIndicator.x) {
|
||||
startIndicatorAnimation(radioBtn.x)
|
||||
callback.onItemCheck(i)
|
||||
mCallback?.onItemCheck(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package com.gh.common.view
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.text.*
|
||||
import android.text.InputFilter.LengthFilter
|
||||
@ -14,6 +15,7 @@ import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.EditText
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.gh.gamecenter.R
|
||||
import java.util.*
|
||||
@ -33,6 +35,7 @@ class VerifyEditText @JvmOverloads constructor(
|
||||
private var mEditText: EditText? = null
|
||||
private var drawableNormal: Drawable? = null
|
||||
private var drawableSelected: Drawable? = null
|
||||
private var textColor: Int
|
||||
private var mContext: Context? = null
|
||||
|
||||
|
||||
@ -58,6 +61,23 @@ class VerifyEditText @JvmOverloads constructor(
|
||||
if (drawable != null) textView.background = drawable
|
||||
}
|
||||
|
||||
fun setTextViewStyle(normal: Drawable?, selected: Drawable?, @ColorInt color: Int) {
|
||||
drawableNormal = normal
|
||||
drawableSelected = selected
|
||||
textColor = color
|
||||
var isFirst = true
|
||||
for (i in mTextViewList.indices) {
|
||||
val textView = mTextViewList[i]
|
||||
if (textView.text.isNullOrEmpty() && isFirst) {
|
||||
isFirst = false
|
||||
setTextViewBackground(textView, drawableSelected)
|
||||
} else {
|
||||
setTextViewBackground(textView, drawableNormal)
|
||||
}
|
||||
textView.setTextColor(textColor)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前输入的内容
|
||||
*
|
||||
@ -179,7 +199,7 @@ class VerifyEditText @JvmOverloads constructor(
|
||||
obtainStyledAttributes.getDrawable(R.styleable.verify_EditText_verify_background_normal)
|
||||
drawableSelected =
|
||||
obtainStyledAttributes.getDrawable(R.styleable.verify_EditText_verify_background_selected)
|
||||
val textColor = obtainStyledAttributes.getColor(
|
||||
textColor = obtainStyledAttributes.getColor(
|
||||
R.styleable.verify_EditText_verify_textColor,
|
||||
ContextCompat.getColor(context, R.color.black)
|
||||
)
|
||||
|
||||
@ -82,6 +82,8 @@ object DownloadDataHelper {
|
||||
"未实名"
|
||||
} else if (status == DownloadStatus.unqualified) {
|
||||
"未成年"
|
||||
} else if (status == DownloadStatus.unavailable) {
|
||||
"未接入防沉迷系统,暂不支持下载"
|
||||
} else if (status == DownloadStatus.redirected) {
|
||||
"重定向至最终地址"
|
||||
} else {
|
||||
|
||||
@ -5,7 +5,9 @@ import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.EntranceUtils;
|
||||
import com.gh.common.util.ExtensionsKt;
|
||||
import com.halo.assistant.fragment.AboutFragment;
|
||||
|
||||
/**
|
||||
@ -13,6 +15,12 @@ import com.halo.assistant.fragment.AboutFragment;
|
||||
*/
|
||||
public class AboutActivity extends NormalActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.black, R.color.white);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static Intent getIntent(Context context, boolean isUpdate) {
|
||||
Bundle bundle = new Bundle();
|
||||
@ -20,4 +28,14 @@ public class AboutActivity extends NormalActivity {
|
||||
return getTargetIntent(context, AboutActivity.class, AboutFragment.class, bundle);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAutoResetViewBackgroundEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNightModeChange() {
|
||||
super.onNightModeChange();
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.black, R.color.white);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,10 @@ package com.gh.gamecenter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.ExtensionsKt;
|
||||
import com.gh.gamecenter.info.ConcernFragment;
|
||||
|
||||
/**
|
||||
@ -11,7 +14,19 @@ import com.gh.gamecenter.info.ConcernFragment;
|
||||
|
||||
public class ConcernInfoActivity extends NormalActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.black, R.color.white);
|
||||
}
|
||||
|
||||
public static Intent getIntent(Context context) {
|
||||
return getTargetIntent(context, ConcernInfoActivity.class, ConcernFragment.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNightModeChange() {
|
||||
super.onNightModeChange();
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.black, R.color.white);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,7 +5,9 @@ import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.gh.base.fragment.BaseFragment_TabLayout;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.EntranceUtils;
|
||||
import com.gh.common.util.ExtensionsKt;
|
||||
import com.gh.gamecenter.download.DownloadFragment;
|
||||
|
||||
/**
|
||||
@ -20,6 +22,12 @@ public class DownloadManagerActivity extends NormalActivity {
|
||||
|
||||
public static final String TAG = "DownloadManagerActivity";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.black, R.color.white);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Intent provideNormalIntent() {
|
||||
return getTargetIntent(this, DownloadManagerActivity.class, DownloadFragment.class);
|
||||
@ -48,4 +56,10 @@ public class DownloadManagerActivity extends NormalActivity {
|
||||
bundle.putString(EntranceUtils.KEY_PACKAGENAME, packageName);
|
||||
return getTargetIntent(context, DownloadManagerActivity.class, DownloadFragment.class, bundle);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNightModeChange() {
|
||||
super.onNightModeChange();
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.black, R.color.white);
|
||||
}
|
||||
}
|
||||
@ -75,6 +75,8 @@ class GameDetailActivity : NormalActivity() {
|
||||
})
|
||||
}
|
||||
|
||||
override fun isAutoResetViewBackgroundEnabled(): Boolean = true
|
||||
|
||||
companion object {
|
||||
|
||||
@JvmStatic
|
||||
|
||||
@ -5,6 +5,8 @@ import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.gh.base.BaseActivity_TabLayout
|
||||
import com.gh.common.util.DisplayUtils
|
||||
import com.gh.common.util.updateStatusBarColor
|
||||
import com.gh.gamecenter.help.HelpContainerFragment
|
||||
import com.gh.gamecenter.suggest.SuggestSelectFragment
|
||||
import com.lightgame.utils.Util_System_Keyboard
|
||||
@ -38,6 +40,7 @@ class HelpAndFeedbackActivity : BaseActivity_TabLayout() {
|
||||
setNavigationTitle("帮助与反馈")
|
||||
val defaultPosition = intent.getIntExtra(PAGE_INDEX, HELP_ITEM)
|
||||
setCurrentItem(defaultPosition)
|
||||
updateStatusBarColor(R.color.black, R.color.white)
|
||||
}
|
||||
|
||||
override fun onPageSelected(position: Int) {
|
||||
@ -51,6 +54,11 @@ class HelpAndFeedbackActivity : BaseActivity_TabLayout() {
|
||||
mViewPager.currentItem = position
|
||||
}
|
||||
|
||||
override fun onNightModeChange() {
|
||||
super.onNightModeChange()
|
||||
updateStatusBarColor(R.color.black, R.color.white)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
const val HELP_ITEM = 0
|
||||
|
||||
@ -2,7 +2,10 @@ package com.gh.gamecenter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.ExtensionsKt;
|
||||
import com.gh.gamecenter.info.InfoWrapperFragment;
|
||||
|
||||
/**
|
||||
@ -10,7 +13,20 @@ import com.gh.gamecenter.info.InfoWrapperFragment;
|
||||
*/
|
||||
|
||||
public class InfoActivity extends NormalActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.black, R.color.white);
|
||||
}
|
||||
|
||||
public static Intent getIntent(Context context) {
|
||||
return getTargetIntent(context, InfoActivity.class, InfoWrapperFragment.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNightModeChange() {
|
||||
super.onNightModeChange();
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.black, R.color.white);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package com.gh.gamecenter;
|
||||
|
||||
import static com.gh.gamecenter.personal.PersonalFragment.LOGIN_TAG;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@ -12,6 +14,7 @@ import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
@ -24,6 +27,7 @@ import com.gh.common.util.ApkActiveUtils;
|
||||
import com.gh.common.util.CheckLoginUtils;
|
||||
import com.gh.common.util.DetailDownloadUtils;
|
||||
import com.gh.common.util.DeviceTokenUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.EntranceUtils;
|
||||
import com.gh.common.util.ExtensionsKt;
|
||||
import com.gh.common.util.LibaoUtils;
|
||||
@ -63,8 +67,6 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import retrofit2.HttpException;
|
||||
|
||||
import static com.gh.gamecenter.personal.PersonalFragment.LOGIN_TAG;
|
||||
|
||||
/**
|
||||
* Created by khy on 2016/12/13.
|
||||
*/
|
||||
@ -196,7 +198,7 @@ public class LibaoDetailActivity extends ToolBarActivity implements LibaoDetailA
|
||||
if (mLibaoEntity != null) {
|
||||
mLibaoEntity.setClickReceiveBtnIn(isClickReceiveBtnIn);
|
||||
}
|
||||
|
||||
DisplayUtils.setStatusBarColor(this, mNightMode ? android.R.color.black : R.color.white);
|
||||
mIsScroll = true;
|
||||
|
||||
mSkeleton = Skeleton.bind(mListSkeleton).shimmer(false).load(R.layout.activity_libaodetail_skeleton).show();
|
||||
@ -207,7 +209,7 @@ public class LibaoDetailActivity extends ToolBarActivity implements LibaoDetailA
|
||||
return mIsScroll;
|
||||
}
|
||||
});
|
||||
mLibaoDetailRv.addItemDecoration(new VerticalItemDecoration(this, 8, false));
|
||||
mLibaoDetailRv.addItemDecoration(getItemDecoration());
|
||||
mLibaoDetailRv.setAdapter(mAdapter);
|
||||
|
||||
mNoConnection.setOnClickListener(v -> {
|
||||
@ -235,6 +237,10 @@ public class LibaoDetailActivity extends ToolBarActivity implements LibaoDetailA
|
||||
|
||||
}
|
||||
|
||||
private RecyclerView.ItemDecoration getItemDecoration() {
|
||||
return new VerticalItemDecoration(this, 8, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
@ -549,4 +555,18 @@ public class LibaoDetailActivity extends ToolBarActivity implements LibaoDetailA
|
||||
getLibaoDigest(mLibaoEntity.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNightModeChange() {
|
||||
super.onNightModeChange();
|
||||
ExtensionsKt.setRootBackgroundColor(mContentView, R.color.background);
|
||||
mDetailBottom.setBackgroundColor(ContextCompat.getColor(this, R.color.background));
|
||||
mLibaoDetailRv.getRecycledViewPool().clear();
|
||||
mAdapter.notifyItemRangeChanged(0, mAdapter.getItemCount());
|
||||
if (mLibaoDetailRv.getItemDecorationCount() > 0) {
|
||||
mLibaoDetailRv.removeItemDecorationAt(0);
|
||||
mLibaoDetailRv.addItemDecoration(getItemDecoration());
|
||||
}
|
||||
DisplayUtils.setStatusBarColor(this, mNightMode ? android.R.color.black : R.color.white);
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,7 +106,6 @@ import com.gh.gamecenter.room.dao.SimulatorGameDao;
|
||||
import com.gh.gamecenter.suggest.SuggestSelectFragment;
|
||||
import com.gh.gamecenter.suggest.SuggestType;
|
||||
import com.google.android.exoplayer2.upstream.cache.Cache;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.halo.assistant.HaloApp;
|
||||
@ -295,11 +294,6 @@ public class MainActivity extends BaseActivity {
|
||||
checkDialog();
|
||||
}
|
||||
|
||||
// handler.postDelayed(() -> {
|
||||
// PushHelper.postPushClickAction(this.getApplicationContext(), null);
|
||||
// }, 2000);
|
||||
|
||||
|
||||
// 耗时操作
|
||||
AppExecutor.getIoExecutor().execute(() -> {
|
||||
// 上传数据
|
||||
@ -312,9 +306,6 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
// 初始化PlatformUtils
|
||||
PlatformUtils.getInstance(getApplicationContext());
|
||||
// // 友盟记录启动
|
||||
// PushAgent.getInstance(this).onAppStart();
|
||||
|
||||
HomePluggableHelper.activationFilterData();
|
||||
});
|
||||
|
||||
@ -336,6 +327,9 @@ public class MainActivity extends BaseActivity {
|
||||
postAttentionVideoRecord();
|
||||
deleteSimulatorGame();
|
||||
|
||||
// 检查是否需要触发 XAPK 安装
|
||||
AppExecutor.getUiExecutor().executeWithDelay(this::resumeXapkInstallIfNeeded, 150);
|
||||
|
||||
QuickLoginHelper.getPhoneInfo(this);
|
||||
WechatBindHelper.getWechatConfig(null);
|
||||
initWBSDK();
|
||||
@ -515,7 +509,7 @@ public class MainActivity extends BaseActivity {
|
||||
AppExecutor.getIoExecutor().execute(() -> {
|
||||
UpdateManager updateManager = UpdateManager.getInstance(this);
|
||||
updateManager.checkUpdate(true, null);
|
||||
updateManager.setDismissCallback(() -> mMainWrapperFragment.getWelcomeDialog());
|
||||
updateManager.setDismissCallback(mMainWrapperFragment::getDialog);
|
||||
});
|
||||
}
|
||||
|
||||
@ -1033,4 +1027,27 @@ public class MainActivity extends BaseActivity {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新触发 XAPK 安装流程
|
||||
* 因为 Android 12 起授予应用安装未知应用权限以后不触发进程重启,导致应用一直无法读写 android/data 目录
|
||||
* 所以这里再手动重启应用进程时再触发一回安装
|
||||
*/
|
||||
private void resumeXapkInstallIfNeeded() {
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R) {
|
||||
String xapkUrl = SPUtils.getString(Constants.SP_XAPK_URL);
|
||||
if (!TextUtils.isEmpty(xapkUrl)) {
|
||||
DownloadEntity downloadEntity = DownloadManager.getInstance().getDownloadEntityByUrl(xapkUrl);
|
||||
if (downloadEntity != null) {
|
||||
PackageInstaller.install(this, downloadEntity, false);
|
||||
}
|
||||
}
|
||||
SPUtils.setString(Constants.SP_XAPK_UNZIP_ACTIVITY, "");
|
||||
SPUtils.setString(Constants.SP_XAPK_URL, "");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAutoResetViewBackgroundEnabled() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,7 +4,9 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.EntranceUtils;
|
||||
import com.gh.common.util.ExtensionsKt;
|
||||
import com.gh.gamecenter.message.MessageFragment;
|
||||
|
||||
/**
|
||||
@ -13,10 +15,21 @@ import com.gh.gamecenter.message.MessageFragment;
|
||||
@Deprecated
|
||||
public class MessageActivity extends NormalActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.black, R.color.white);
|
||||
}
|
||||
|
||||
public static Intent getIntent(Context context, String entrance) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(EntranceUtils.KEY_ENTRANCE, entrance);
|
||||
return getTargetIntent(context, MessageActivity.class, MessageFragment.class, bundle);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNightModeChange() {
|
||||
super.onNightModeChange();
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.black, R.color.white);
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ public class MessageDetailActivity extends NormalActivity {
|
||||
ViewGroup.LayoutParams layoutParams = mShadowView.getLayoutParams();
|
||||
layoutParams.height = DisplayUtils.dip2px(50f) + DisplayUtils.getStatusBarHeight(getResources());
|
||||
mShadowView.setLayoutParams(layoutParams);
|
||||
DisplayUtils.setStatusBarColor(this, R.color.transparent, false);
|
||||
DisplayUtils.setStatusBarColor(this, R.color.transparent, !mNightMode);
|
||||
}
|
||||
|
||||
public View getShadowView() {
|
||||
@ -71,4 +71,9 @@ public class MessageDetailActivity extends NormalActivity {
|
||||
return getTargetIntent(context, MessageDetailActivity.class, MessageDetailFragment.class, intent.getExtras());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNightModeChange() {
|
||||
super.onNightModeChange();
|
||||
DisplayUtils.setStatusBarColor(this, R.color.transparent, !mNightMode);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,7 +4,9 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.EntranceUtils;
|
||||
import com.gh.common.util.ExtensionsKt;
|
||||
import com.gh.gamecenter.message.MessageNormalFragment;
|
||||
|
||||
/**
|
||||
@ -20,4 +22,16 @@ public class MessageInviteActivity extends NormalActivity {
|
||||
bundle.putString(EntranceUtils.KEY_OUTER_INFO, outerInfo);
|
||||
return getTargetIntent(context, MessageInviteActivity.class, MessageNormalFragment.class, bundle);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.black, R.color.white);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNightModeChange() {
|
||||
super.onNightModeChange();
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.black, R.color.white);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,7 +4,9 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.EntranceUtils;
|
||||
import com.gh.common.util.ExtensionsKt;
|
||||
import com.gh.gamecenter.message.KeFuFragment;
|
||||
|
||||
/**
|
||||
@ -23,4 +25,16 @@ public class MessageKeFuActivity extends NormalActivity {
|
||||
bundle.putString(EntranceUtils.KEY_ENTRANCE, entrance);
|
||||
return getTargetIntent(context, MessageKeFuActivity.class, KeFuFragment.class, bundle);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.black, R.color.white);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNightModeChange() {
|
||||
super.onNightModeChange();
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.black, R.color.white);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,7 +4,9 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.EntranceUtils;
|
||||
import com.gh.common.util.ExtensionsKt;
|
||||
import com.gh.gamecenter.message.MessageNormalFragment;
|
||||
|
||||
/**
|
||||
@ -20,4 +22,16 @@ public class MessageVoteActivity extends NormalActivity {
|
||||
bundle.putString(EntranceUtils.KEY_OUTER_INFO, outerInfo);
|
||||
return getTargetIntent(context, MessageVoteActivity.class, MessageNormalFragment.class, bundle);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.black, R.color.white);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNightModeChange() {
|
||||
super.onNightModeChange();
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.black, R.color.white);
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,6 +19,7 @@ import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.view.MotionEventCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
@ -64,6 +65,7 @@ import com.lightgame.utils.Utils;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@ -125,6 +127,8 @@ public class NewsDetailActivity extends ToolBarActivity implements OnClickListen
|
||||
|
||||
private ViewSkeletonScreen mViewSkeletonScreen;
|
||||
|
||||
private RecyclerView.ItemDecoration mItemDecoration;
|
||||
|
||||
private DataWatcher dataWatcher = new DataWatcher() {
|
||||
@Override
|
||||
public void onDataChanged(DownloadEntity downloadEntity) {
|
||||
@ -236,6 +240,7 @@ public class NewsDetailActivity extends ToolBarActivity implements OnClickListen
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.black, R.color.white);
|
||||
|
||||
mDetailRv = findViewById(R.id.news_detail_rv_show);
|
||||
mDetailBottomLl = findViewById(R.id.news_detail_ll_bottom);
|
||||
@ -254,7 +259,8 @@ public class NewsDetailActivity extends ToolBarActivity implements OnClickListen
|
||||
// init RecyclerView
|
||||
mDetailRv.setHasFixedSize(true);
|
||||
mDetailRv.setLayoutManager(new FixLinearLayoutManager(this));
|
||||
mDetailRv.addItemDecoration(new VerticalItemDecoration(this, 8, false));
|
||||
mItemDecoration = new VerticalItemDecoration(this, 8, false);
|
||||
mDetailRv.addItemDecoration(mItemDecoration);
|
||||
|
||||
mHideUselessInfo = getIntent().getBooleanExtra(EntranceUtils.KEY_HIDE_USELESS_INFO, false);
|
||||
|
||||
@ -353,10 +359,6 @@ public class NewsDetailActivity extends ToolBarActivity implements OnClickListen
|
||||
new CollectionUtils.OnCollectionListener() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
// GdtHelper.INSTANCE.logAction(ActionType.ADD_TO_WISHLIST,
|
||||
// GdtHelper.CONTENT_TYPE, "ARTICLE",
|
||||
// GdtHelper.CONTENT_ID, newsDetailEntity.getId());
|
||||
|
||||
newsDetailEntity.getMe().setArticleFavorite(false);
|
||||
mNewsCollection.setEnabled(true);
|
||||
mNewsCollection.setIcon(R.drawable.community_content_detail_collect_unselect);
|
||||
@ -664,10 +666,6 @@ public class NewsDetailActivity extends ToolBarActivity implements OnClickListen
|
||||
} else {
|
||||
mDetailBottomLl.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// GdtHelper.INSTANCE.logAction(ActionType.PAGE_VIEW,
|
||||
// GdtHelper.CONTENT_TYPE, "ARTICLE",
|
||||
// GdtHelper.CONTENT_ID, response.getId());
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -740,4 +738,23 @@ public class NewsDetailActivity extends ToolBarActivity implements OnClickListen
|
||||
protected boolean showDownloadMenu() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNightModeChange() {
|
||||
super.onNightModeChange();
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.black, R.color.white);
|
||||
mNewsShare.setIcon(R.drawable.icon_share_black);
|
||||
mNewsCollection.setIcon(R.drawable.community_content_detail_collect_unselect);
|
||||
mDetailRv.removeItemDecoration(mItemDecoration);
|
||||
mItemDecoration = new VerticalItemDecoration(this, 8, false);
|
||||
mDetailRv.addItemDecoration(mItemDecoration);
|
||||
if (mContentView != null) {
|
||||
mContentView.setBackgroundColor(ContextCompat.getColor(this, R.color.background));
|
||||
findViewById(R.id.commentContainer).setBackgroundColor(ContextCompat.getColor(this, R.color.background_white));
|
||||
((TextView) findViewById(R.id.commentTv)).setTextColor(ContextCompat.getColor(this, R.color.text_subtitle));
|
||||
}
|
||||
if (adapter != null) {
|
||||
adapter.notifyItemRangeChanged(0, adapter.getItemCount());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,6 +60,8 @@ open class SearchActivity : BaseActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
updateStatusBarColor(R.color.black, R.color.white)
|
||||
|
||||
searchEt = findViewById(R.id.searchEt)
|
||||
searchBtn = findViewById(R.id.searchBtn)
|
||||
deleteIv = findViewById(R.id.deleteIv)
|
||||
@ -89,15 +91,6 @@ open class SearchActivity : BaseActivity() {
|
||||
|
||||
initSearchBar()
|
||||
|
||||
// 子 Fragment 自己恢复状态
|
||||
// if (savedInstanceState != null) {
|
||||
// mDisplayType = DisplayType.fromInt(savedInstanceState.getInt(KEY_DISPLAY_TYPE, 0))
|
||||
// mSearchKey = savedInstanceState.getString(EntranceUtils.KEY_SEARCHKEY, null)
|
||||
// mSearchType = SearchType.fromString(savedInstanceState.getString(KEY_SEARCH_TYPE, null))
|
||||
// if (mDisplayType != DisplayType.DEFAULT && !TextUtils.isEmpty(mSearchKey)) {
|
||||
// search(mSearchType, mSearchKey)
|
||||
// }
|
||||
// } else
|
||||
if (!TextUtils.isEmpty(hint)) {
|
||||
searchEt.hint = hint
|
||||
if (searchImmediately) {
|
||||
@ -244,7 +237,6 @@ open class SearchActivity : BaseActivity() {
|
||||
search.gameId, search.gameName
|
||||
)
|
||||
"search" -> {
|
||||
// GdtHelper.logAction(ActionType.SEARCH, GdtHelper.KEYWORD, mSearchKey)
|
||||
DataCollectionUtils.uploadSearch(
|
||||
this, mSearchKey, mSearchType.value, "搜索页面",
|
||||
search.gameId, search.gameName
|
||||
@ -262,6 +254,14 @@ open class SearchActivity : BaseActivity() {
|
||||
return super.handleBackPressed()
|
||||
}
|
||||
|
||||
override fun onNightModeChange() {
|
||||
super.onNightModeChange()
|
||||
|
||||
updateStatusBarColor(R.color.black, R.color.white)
|
||||
}
|
||||
|
||||
override fun isAutoResetViewBackgroundEnabled() = true
|
||||
|
||||
companion object {
|
||||
const val KEY_SEARCH_TYPE = "search_type"
|
||||
private const val KEY_DISPLAY_TYPE = "display_type"
|
||||
@ -311,8 +311,4 @@ enum class DisplayType(var value: Int) {
|
||||
GAME_DIGEST(1),
|
||||
GAME_DETAIL(2),
|
||||
FORUM_OR_USER(3);
|
||||
|
||||
companion object {
|
||||
fun fromInt(typeInt: Int) = values().find { typeInt == it.value } ?: DEFAULT
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,20 +3,35 @@ package com.gh.gamecenter
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.gh.common.util.DisplayUtils
|
||||
import com.gh.common.util.EntranceUtils
|
||||
import com.gh.common.util.updateStatusBarColor
|
||||
import com.halo.assistant.fragment.SettingsFragment
|
||||
|
||||
class SettingActivity : NormalActivity() {
|
||||
companion object {
|
||||
fun getIntent(context: Context, isUpdate: Boolean, entrance: String): Intent {
|
||||
return getTargetIntent(
|
||||
context,
|
||||
SettingActivity::class.java,
|
||||
SettingsFragment::class.java, Bundle().apply {
|
||||
putString(EntranceUtils.KEY_ENTRANCE, entrance)
|
||||
putBoolean(EntranceUtils.KEY_VERSION_UPDATE, isUpdate)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
updateStatusBarColor(R.color.black, R.color.white)
|
||||
}
|
||||
|
||||
override fun isAutoResetViewBackgroundEnabled() = true
|
||||
|
||||
override fun onNightModeChange() {
|
||||
super.onNightModeChange()
|
||||
updateStatusBarColor(R.color.black, R.color.white)
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun getIntent(context: Context, isUpdate: Boolean, entrance: String): Intent {
|
||||
return getTargetIntent(
|
||||
context,
|
||||
SettingActivity::class.java,
|
||||
SettingsFragment::class.java, Bundle().apply {
|
||||
putString(EntranceUtils.KEY_ENTRANCE, entrance)
|
||||
putBoolean(EntranceUtils.KEY_VERSION_UPDATE, isUpdate)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -38,6 +38,7 @@ import static com.gh.common.util.EntranceUtils.HOST_DOWNLOAD;
|
||||
import static com.gh.common.util.EntranceUtils.HOST_GAME;
|
||||
import static com.gh.common.util.EntranceUtils.HOST_GAME_COLLECTION_DETAIL;
|
||||
import static com.gh.common.util.EntranceUtils.HOST_GAME_COLLECTION_SQUARE;
|
||||
import static com.gh.common.util.EntranceUtils.HOST_INVOKE_ONLY;
|
||||
import static com.gh.common.util.EntranceUtils.HOST_LIBAO;
|
||||
import static com.gh.common.util.EntranceUtils.HOST_QQ;
|
||||
import static com.gh.common.util.EntranceUtils.HOST_QQ_GROUP;
|
||||
@ -100,6 +101,9 @@ public class SkipActivity extends BaseActivity {
|
||||
if (host != null) {
|
||||
Intent intent;
|
||||
switch (host) {
|
||||
case HOST_INVOKE_ONLY:
|
||||
// 仅唤起光环助手,不进入光环页面。用于类似 ContentProvider 的用途
|
||||
break;
|
||||
case HOST_ARTICLE:
|
||||
DirectUtils.directToArticle(this, path, ENTRANCE_BROWSER);
|
||||
break;
|
||||
|
||||
@ -5,6 +5,7 @@ import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.TextUtils;
|
||||
@ -25,11 +26,10 @@ import com.gh.base.BaseActivity;
|
||||
import com.gh.common.AppExecutor;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.constant.Constants;
|
||||
import com.gh.common.dialog.PrivacyDialogFragment;
|
||||
import com.gh.common.dialog.PrivacyPolicyDialogFragment;
|
||||
import com.gh.common.tracker.TrackerLogger;
|
||||
import com.gh.common.util.AdHelper;
|
||||
import com.gh.common.util.DeviceTokenUtils;
|
||||
import com.gh.common.util.DeviceUtils;
|
||||
import com.gh.common.util.DialogHelper;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
@ -60,7 +60,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
@ -176,12 +175,14 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
launchMainActivity();
|
||||
}
|
||||
|
||||
SPUtils.setString(Constants.SP_XAPK_UNZIP_ACTIVITY, "");
|
||||
SPUtils.setString(Constants.SP_XAPK_URL, "");
|
||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.R) {
|
||||
SPUtils.setString(Constants.SP_XAPK_UNZIP_ACTIVITY, "");
|
||||
SPUtils.setString(Constants.SP_XAPK_URL, "");
|
||||
}
|
||||
}
|
||||
|
||||
private void showPrivacyDialog(ViewPager guideLayout) {
|
||||
PrivacyDialogFragment.show(this, (isSuccess) -> {
|
||||
PrivacyPolicyDialogFragment.show(this, null, (isSuccess) -> {
|
||||
if (isSuccess) {
|
||||
showPrivacyPolicy((shouldRequestPermission) -> {
|
||||
// Dialog dismiss 后的回调
|
||||
@ -386,8 +387,6 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
getAd();
|
||||
prefetchData();
|
||||
|
||||
uploadTeaAndGdtData();
|
||||
|
||||
Bundle bundle = getIntent().getExtras();
|
||||
Intent intent = new Intent(SplashScreenActivity.this, MainActivity.class);
|
||||
if (bundle != null) {
|
||||
@ -397,7 +396,7 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
overridePendingTransition(0, 0);
|
||||
startActivity(intent);
|
||||
|
||||
uploadTeaAndGdtData();
|
||||
uploadTeaData();
|
||||
|
||||
finish();
|
||||
}
|
||||
@ -407,7 +406,7 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
AdHelper.getStartUpAd();
|
||||
}
|
||||
|
||||
private void uploadTeaAndGdtData() {
|
||||
private void uploadTeaData() {
|
||||
if ("tea".equals(BuildConfig.FLAVOR)) {
|
||||
// 在可能获取了相关权限后才初始化SDK/发送激活数据
|
||||
// TeaHelper.init(getApplication(), HaloApp.getInstance().getChannel());
|
||||
@ -419,23 +418,6 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
// GdtHelper.INSTANCE.logAction(ActionType.START_APP, GdtHelper.NETWORK_TYPE, DeviceUtils.getNetwork(this));
|
||||
if ("gdt".equals(BuildConfig.FLAVOR)) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName("com.gh.gamecenter.GdtHelper");
|
||||
Field field = clazz.getDeclaredField("NETWORK_TYPE");
|
||||
String type = (String) field.get(null);
|
||||
Method method = clazz.getMethod("logAction", String.class, String[].class);
|
||||
|
||||
Class<?> actionTypeClazz = Class.forName("com.qq.gdt.action.ActionType");
|
||||
Field typeField = actionTypeClazz.getDeclaredField("START_APP");
|
||||
String actionType = (String) typeField.get(null);
|
||||
|
||||
method.invoke(null, actionType, new String[]{type, DeviceUtils.getNetwork(this)});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void prefetchData() {
|
||||
|
||||
@ -48,6 +48,7 @@ import com.gh.common.util.DialogHelper;
|
||||
import com.gh.common.util.DirectUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.EntranceUtils;
|
||||
import com.gh.common.util.ExtensionsKt;
|
||||
import com.gh.common.util.GsonUtils;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
import com.gh.common.util.MtaHelper;
|
||||
@ -61,6 +62,7 @@ import com.gh.common.util.ToastUtils;
|
||||
import com.gh.common.util.UploadImageUtils;
|
||||
import com.gh.common.util.UrlFilterUtils;
|
||||
import com.gh.common.view.FixLinearLayoutManager;
|
||||
import com.gh.gamecenter.databinding.ActivitySuggestBinding;
|
||||
import com.gh.gamecenter.entity.ErrorEntity;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.entity.InstallGameEntity;
|
||||
@ -325,7 +327,7 @@ public class SuggestionActivity extends ToolBarActivity implements OnRequestCall
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.black, R.color.white);
|
||||
initView();
|
||||
|
||||
Bundle extras = getIntent().getExtras();
|
||||
@ -1505,4 +1507,80 @@ public class SuggestionActivity extends ToolBarActivity implements OnRequestCall
|
||||
}
|
||||
return super.handleBackPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNightModeChange() {
|
||||
super.onNightModeChange();
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.black, R.color.white);
|
||||
ActivitySuggestBinding binding = ActivitySuggestBinding.bind(mContentView);
|
||||
binding.suggestScrollview.setBackgroundColor(ContextCompat.getColor(this, R.color.background));
|
||||
binding.divider1.setBackgroundColor(ContextCompat.getColor(this, R.color.cutting_line));
|
||||
binding.divider2.setBackgroundColor(ContextCompat.getColor(this, R.color.cutting_line));
|
||||
binding.divider3.setBackgroundColor(ContextCompat.getColor(this, R.color.background));
|
||||
binding.divider4.setBackgroundColor(ContextCompat.getColor(this, R.color.background));
|
||||
binding.divider5.setBackgroundColor(ContextCompat.getColor(this, R.color.background));
|
||||
binding.divider6.setBackgroundColor(ContextCompat.getColor(this, R.color.background));
|
||||
binding.divider7.setBackgroundColor(ContextCompat.getColor(this, R.color.background));
|
||||
binding.divider8.setBackgroundColor(ContextCompat.getColor(this, R.color.background));
|
||||
binding.divider9.setBackgroundColor(ContextCompat.getColor(this, R.color.background));
|
||||
binding.suggestGameContainer.setBackgroundColor(ContextCompat.getColor(this, R.color.background_white));
|
||||
binding.suggestGameSelect.setBackground(ContextCompat.getDrawable(this, R.drawable.border_suggest_bg));
|
||||
binding.suggestPlatformContainer.setBackgroundColor(ContextCompat.getColor(this, R.color.background_white));
|
||||
binding.suggestTypeContainer.setBackgroundColor(ContextCompat.getColor(this, R.color.background_white));
|
||||
binding.picContainer.setBackgroundColor(ContextCompat.getColor(this, R.color.background_white));
|
||||
binding.suggestLinkContainer.setBackgroundColor(ContextCompat.getColor(this, R.color.background_white));
|
||||
binding.contactMethodContainer.setBackgroundColor(ContextCompat.getColor(this, R.color.background_white));
|
||||
binding.suggestPostLl.setBackgroundColor(ContextCompat.getColor(this, R.color.background_white));
|
||||
binding.copyrightContainer.setBackgroundColor(ContextCompat.getColor(this, R.color.background_white));
|
||||
binding.suggestCrashTypeContainer.setBackgroundColor(ContextCompat.getColor(this, R.color.background_white));
|
||||
binding.explanationTv.setBackgroundColor(ContextCompat.getColor(this, R.color.background_white));
|
||||
binding.explanationEt.setBackgroundColor(ContextCompat.getColor(this, R.color.background_white));
|
||||
binding.suggestGameNameTitle.setTextColor(ContextCompat.getColor(this, R.color.text_black));
|
||||
binding.suggestPlatformTitle.setTextColor(ContextCompat.getColor(this, R.color.text_black));
|
||||
binding.suggestTypeName.setTextColor(ContextCompat.getColor(this, R.color.text_black));
|
||||
binding.suggestLinkTitle.setTextColor(ContextCompat.getColor(this, R.color.text_black));
|
||||
binding.suggestEmailName.setTextColor(ContextCompat.getColor(this, R.color.text_black));
|
||||
binding.suggestGameSelect.setTextColor(ContextCompat.getColor(this, R.color.hint));
|
||||
binding.suggestGameName.setTextColor(ContextCompat.getColor(this, R.color.title));
|
||||
binding.suggestPlatformEt.setTextColor(ContextCompat.getColor(this, R.color.content));
|
||||
binding.suggestPlatformEt.setHintTextColor(ContextCompat.getColor(this, R.color.content));
|
||||
binding.tvAd.setTextColor(ContextCompat.getColor(this, R.color.theme_font));
|
||||
binding.typeAccelerate.setTextColor(ContextCompat.getColor(this, R.color.content));
|
||||
binding.typeStandalone.setTextColor(ContextCompat.getColor(this, R.color.content));
|
||||
binding.typeMaterial.setTextColor(ContextCompat.getColor(this, R.color.content));
|
||||
binding.typeOther.setTextColor(ContextCompat.getColor(this, R.color.content));
|
||||
binding.typeOtherName.setTextColor(ContextCompat.getColor(this, R.color.content));
|
||||
binding.typeOtherName.setHintTextColor(ContextCompat.getColor(this, R.color.content));
|
||||
binding.typeOtherName.setBackground(ContextCompat.getDrawable(this, R.drawable.border_suggest_bg));
|
||||
binding.suggestCrashTypeName.setTextColor(ContextCompat.getColor(this, R.color.text_title));
|
||||
binding.suggestAppCrash.setTextColor(ContextCompat.getColor(this, R.color.text_title));
|
||||
binding.suggestGameCrash.setTextColor(ContextCompat.getColor(this, R.color.text_title));
|
||||
binding.suggestContentEt.setHintTextColor(ContextCompat.getColor(this, R.color.content));
|
||||
binding.suggestLinkEt.setTextColor(ContextCompat.getColor(this, R.color.content));
|
||||
binding.suggestLinkEt.setHintTextColor(ContextCompat.getColor(this, R.color.content));
|
||||
binding.suggestEmailEt.setTextColor(ContextCompat.getColor(this, R.color.content));
|
||||
binding.suggestEmailEt.setHintTextColor(ContextCompat.getColor(this, R.color.content));
|
||||
binding.suggestIdentityTv.setTextColor(ContextCompat.getColor(this, R.color.text_title));
|
||||
binding.credentialsCodeTv.setTextColor(ContextCompat.getColor(this, R.color.text_title));
|
||||
binding.credentialsCodeEt.setTextColor(ContextCompat.getColor(this, R.color.text_subtitle));
|
||||
binding.credentialsCodeEt.setHintTextColor(ContextCompat.getColor(this, R.color.text_body));
|
||||
binding.credentialsPhotoTv.setTextColor(ContextCompat.getColor(this, R.color.text_title));
|
||||
binding.appNameTv.setTextColor(ContextCompat.getColor(this, R.color.text_title));
|
||||
binding.appNameEt.setTextColor(ContextCompat.getColor(this, R.color.text_subtitle));
|
||||
binding.appNameEt.setHintTextColor(ContextCompat.getColor(this, R.color.text_body));
|
||||
binding.infringementAppScreenshotTv.setTextColor(ContextCompat.getColor(this, R.color.text_title));
|
||||
binding.infringementAppScreenshotTipTv.setTextColor(ContextCompat.getColor(this, R.color.text_subtitleDesc));
|
||||
binding.explanationTv.setTextColor(ContextCompat.getColor(this, R.color.text_title));
|
||||
binding.explanationEt.setTextColor(ContextCompat.getColor(this, R.color.text_subtitle));
|
||||
binding.explanationEt.setHintTextColor(ContextCompat.getColor(this, R.color.text_body));
|
||||
binding.contactMethodTv.setTextColor(ContextCompat.getColor(this, R.color.text_title));
|
||||
binding.contactMethodEt.setTextColor(ContextCompat.getColor(this, R.color.text_subtitle));
|
||||
binding.contactMethodEt.setHintTextColor(ContextCompat.getColor(this, R.color.text_body));
|
||||
binding.emailFeedbackTv.setTextColor(ContextCompat.getColor(this, R.color.text_subtitleDesc));
|
||||
binding.lookDetailDesTv.setTextColor(ContextCompat.getColor(this, R.color.theme_font));
|
||||
binding.suggestPersonalRb.setBackground(ContextCompat.getDrawable(this, R.drawable.game_upload_rg_button_selector));
|
||||
binding.suggestCompanyRb.setBackground(ContextCompat.getDrawable(this, R.drawable.game_upload_rg_button_selector));
|
||||
binding.suggestPersonalRb.setTextColor(ContextCompat.getColorStateList(this, R.color.game_upload_rg_button_selector));
|
||||
binding.suggestCompanyRb.setTextColor(ContextCompat.getColorStateList(this, R.color.game_upload_rg_button_selector));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package com.gh.gamecenter
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import com.gh.common.util.updateStatusBarColor
|
||||
import com.halo.assistant.fragment.user.UserInfoFragment
|
||||
|
||||
class UserInfoActivity : NormalActivity() {
|
||||
@ -14,4 +15,11 @@ class UserInfoActivity : NormalActivity() {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun isAutoResetViewBackgroundEnabled(): Boolean=true
|
||||
|
||||
override fun onNightModeChange() {
|
||||
super.onNightModeChange()
|
||||
updateStatusBarColor(R.color.black, R.color.white)
|
||||
}
|
||||
}
|
||||
@ -9,9 +9,7 @@ import android.text.TextUtils
|
||||
import android.view.KeyEvent
|
||||
import android.view.View
|
||||
import com.gh.common.constant.Constants
|
||||
import com.gh.common.util.EntranceUtils
|
||||
import com.gh.common.util.EnvHelper
|
||||
import com.gh.common.util.IntentUtils
|
||||
import com.gh.common.util.*
|
||||
import com.gh.gamecenter.entity.ConcernEntity
|
||||
import com.gh.gamecenter.entity.NewsEntity
|
||||
import com.gh.gamecenter.entity.ToolBoxEntity
|
||||
@ -30,9 +28,6 @@ open class WebActivity : NormalActivity() {
|
||||
if (mIsFullScreen) {
|
||||
setTheme(R.style.AppFullScreenTheme)
|
||||
}
|
||||
if (Build.VERSION.SDK_INT != Build.VERSION_CODES.O) {
|
||||
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||
}
|
||||
super.onCreate(savedInstanceState)
|
||||
if (mIsFullScreen) {
|
||||
hideToolbar(true)
|
||||
@ -40,6 +35,7 @@ open class WebActivity : NormalActivity() {
|
||||
} else {
|
||||
super.onCreate(savedInstanceState)
|
||||
}
|
||||
updateStatusBarColor(R.color.black, R.color.white)
|
||||
}
|
||||
|
||||
override fun provideNormalIntent(): Intent {
|
||||
@ -70,6 +66,11 @@ open class WebActivity : NormalActivity() {
|
||||
return super.onKeyDown(keyCode, event)
|
||||
}
|
||||
|
||||
override fun onNightModeChange() {
|
||||
super.onNightModeChange()
|
||||
updateStatusBarColor(R.color.black, R.color.white)
|
||||
}
|
||||
|
||||
companion object {
|
||||
// 获取带分享按钮页面
|
||||
@JvmStatic
|
||||
|
||||
@ -4,6 +4,8 @@ import android.content.Context;
|
||||
import android.text.Html;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.gh.common.util.LibaoUtils;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.viewholder.LiBaoCodeViewHolder;
|
||||
@ -35,6 +37,7 @@ public class LiBaoCodeAdapter extends BaseRecyclerAdapter<LiBaoCodeViewHolder> {
|
||||
@Override
|
||||
public void onBindViewHolder(LiBaoCodeViewHolder holder, int position) {
|
||||
final UserDataLibaoEntity userDataLibaoEntity = mUserDataLibaoList.get(position);
|
||||
holder.binding.libaoCodeTv.setTextColor(ContextCompat.getColor(mContext,R.color.text_subtitle));
|
||||
if ("ling".equals(userDataLibaoEntity.getType()) || "linged".equals(userDataLibaoEntity.getType())) {
|
||||
StringBuilder content = new StringBuilder();
|
||||
if (mUserDataLibaoList.size() > 1) {
|
||||
|
||||
@ -193,6 +193,7 @@ public class LibaoDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
}
|
||||
});
|
||||
|
||||
ExtensionsKt.setRootBackgroundColor( holder.binding.getRoot(),R.color.background_white);
|
||||
if (mLibaoEntity.getGame() != null) {
|
||||
holder.binding.libaodetailGameIcon.displayGameIcon(mLibaoEntity.getGame().getIcon(), mLibaoEntity.getGame().getIconSubscript());
|
||||
} else {
|
||||
|
||||
@ -33,7 +33,7 @@ public class CommentViewHolder extends BaseRecyclerViewHolder {
|
||||
public TextView badgeNameTv;
|
||||
public SimpleDraweeView quoteAuthorBadgeSdv;
|
||||
public View commentMore;
|
||||
public View commentReply;
|
||||
public TextView commentReply;
|
||||
@Nullable
|
||||
public View replyLine;
|
||||
|
||||
|
||||
@ -4,6 +4,8 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.gh.base.BaseRecyclerViewHolder
|
||||
import com.gh.common.util.dip2px
|
||||
import com.gh.common.util.toColor
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.databinding.GameHeadItemBinding
|
||||
import com.gh.gamecenter.entity.SubjectEntity
|
||||
|
||||
@ -56,5 +58,6 @@ class GameHeadViewHolder(var binding: GameHeadItemBinding) :
|
||||
} else {
|
||||
binding.headMore.visibility = View.VISIBLE
|
||||
}
|
||||
binding.headTitle.setTextColor(R.color.text_title.toColor(binding.root.context))
|
||||
}
|
||||
}
|
||||
|
||||
@ -177,6 +177,16 @@ class AmwayAdapter(
|
||||
fun bindComment(viewModel: AmwayViewModel, itemData: AmwayListItemData, blockPosition: Int, basicExposureSource: List<ExposureSource>) {
|
||||
val context = binding.root.context
|
||||
val amway = itemData.amwayCommentItem!!
|
||||
|
||||
binding.gameContainer.background = R.drawable.selector_f8f8f8.toDrawable(context)
|
||||
binding.commentContainer.background = R.drawable.selector_f8f8f8.toDrawable(context)
|
||||
binding.gameNameTv.setTextColor(R.color.title.toColor(context))
|
||||
binding.ratingTv.setTextColor(R.color.theme_font.toColor(context))
|
||||
binding.tagTv.setTextColor(R.color.text_subtitleDesc.toColor(context))
|
||||
binding.amwayContentTv.setTextColor(R.color.text_3a3a3a.toColor(context))
|
||||
binding.userNameTv.setTextColor(R.color.title.toColor(context))
|
||||
binding.likeCountTv.setTextColor(R.color.text_B3B3B3.toColor(context))
|
||||
|
||||
binding.gameNameTv.text = amway.game.name
|
||||
binding.ratingTv.text = amway.game.star.toString()
|
||||
binding.userNameTv.text = amway.comment.user.name
|
||||
|
||||
@ -47,8 +47,10 @@ class AmwayFragment : LazyListFragment<AmwayListItemData, AmwayViewModel>() {
|
||||
private var mAlternativeBinding: FragmentAmwayAlBinding? = null
|
||||
|
||||
private var mAdapter: AmwayAdapter? = null
|
||||
private var mItemDecoration: RecyclerView.ItemDecoration? = null
|
||||
|
||||
private var mUseAlternativeLayout = false
|
||||
private var mIsCollapsed = false
|
||||
|
||||
private val dataWatcher = object : DataWatcher() {
|
||||
override fun onDataChanged(downloadEntity: DownloadEntity) {
|
||||
@ -123,7 +125,7 @@ class AmwayFragment : LazyListFragment<AmwayListItemData, AmwayViewModel>() {
|
||||
return mViewModel
|
||||
}
|
||||
|
||||
override fun getItemDecoration() = VerticalItemDecoration(context, 12F, false)
|
||||
override fun getItemDecoration() = VerticalItemDecoration(context, 12F, false).apply { mItemDecoration = this }
|
||||
|
||||
override fun provideListAdapter(): ListAdapter<*> {
|
||||
if (mAdapter == null) {
|
||||
@ -155,10 +157,11 @@ class AmwayFragment : LazyListFragment<AmwayListItemData, AmwayViewModel>() {
|
||||
|
||||
collapsingToolbar.scrimVisibleHeightTrigger = collapsingTrigger
|
||||
collapsingToolbar.scrimShownAction = {
|
||||
DisplayUtils.setLightStatusBar(requireActivity(), it)
|
||||
mIsCollapsed = it
|
||||
DisplayUtils.setLightStatusBar(requireActivity(), !mNightMode && it)
|
||||
if (it) {
|
||||
titleTv.alpha = 1F
|
||||
titleTv.setTextColor(ContextCompat.getColor(requireContext(), R.color.black))
|
||||
titleTv.setTextColor(ContextCompat.getColor(requireContext(), R.color.text_black))
|
||||
toolbar.navigationIcon = ContextCompat.getDrawable(requireContext(), R.drawable.ic_bar_back)
|
||||
} else {
|
||||
titleTv.setTextColor(ContextCompat.getColor(requireContext(), R.color.white))
|
||||
@ -292,4 +295,35 @@ class AmwayFragment : LazyListFragment<AmwayListItemData, AmwayViewModel>() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun onScrollChanged() {
|
||||
if (parentFragment is HomeSearchToolWrapperFragment) {
|
||||
val scrollY = mAlternativeBinding?.listRv?.computeVerticalScrollOffset()
|
||||
if (scrollY != null) {
|
||||
mAlternativeBinding?.headerContainer?.translationY = -scrollY.toFloat()
|
||||
if (parentFragment is HomeSearchToolWrapperFragment && isSupportVisible) {
|
||||
(parentFragment as HomeSearchToolWrapperFragment).onScrollChanged(
|
||||
mAlternativeBinding?.headerContainer?.measuredHeight ?: 0,
|
||||
scrollY
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onNightModeChange() {
|
||||
super.onNightModeChange()
|
||||
mItemDecoration?.let { mListRv?.removeItemDecoration(it) }
|
||||
mListRv?.addItemDecoration(itemDecoration)
|
||||
mAdapter?.itemCount?.let { mAdapter?.notifyItemRangeChanged(0, it) }
|
||||
if (mUseAlternativeLayout) {
|
||||
mAlternativeBinding?.secondBackground?.background = R.drawable.amway_gradient_background.toDrawable(requireContext())
|
||||
mAlternativeBinding?.listRefresh?.setBackgroundColor(R.color.background.toColor(requireContext()))
|
||||
onScrollChanged()
|
||||
} else {
|
||||
mDefaultBinding?.appbar?.setBackgroundColor(R.color.background_white.toColor(requireContext()))
|
||||
mDefaultBinding?.collapsingToolbar?.setContentScrimColor(R.color.background_white.toColor(requireContext()))
|
||||
mDefaultBinding?.listRefresh?.setBackgroundColor(R.color.background.toColor(requireContext()))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6,6 +6,7 @@ import android.widget.LinearLayout;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProviders;
|
||||
import androidx.recyclerview.widget.DefaultItemAnimator;
|
||||
@ -55,13 +56,16 @@ public abstract class ListFragment<T, VM extends BaseListViewModel /* 该泛型
|
||||
@Nullable
|
||||
protected SkeletonScreen mSkeletonScreen;
|
||||
|
||||
protected RecyclerView.ItemDecoration mItemDecoration;
|
||||
|
||||
private int[] lastPositions;
|
||||
private int lastVisibleItemPosition;
|
||||
|
||||
protected abstract ListAdapter provideListAdapter();
|
||||
|
||||
protected RecyclerView.ItemDecoration getItemDecoration() {
|
||||
return new VerticalItemDecoration(getContext(), 8, true);
|
||||
mItemDecoration = new VerticalItemDecoration(getContext(), 8, true);
|
||||
return mItemDecoration;
|
||||
}
|
||||
|
||||
protected VM provideListViewModel() {
|
||||
@ -288,4 +292,18 @@ public abstract class ListFragment<T, VM extends BaseListViewModel /* 该泛型
|
||||
protected boolean shouldLoadMore() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNightModeChange() {
|
||||
super.onNightModeChange();
|
||||
mCachedView.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.background));
|
||||
if (provideListAdapter() != null) {
|
||||
mListRv.getRecycledViewPool().clear();
|
||||
provideListAdapter().notifyItemRangeChanged(0, provideListAdapter().getItemCount());
|
||||
if (mItemDecoration != null) {
|
||||
mListRv.removeItemDecoration(mItemDecoration);
|
||||
mListRv.addItemDecoration(getItemDecoration());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,14 +10,18 @@ import com.gh.common.exposure.ExposureEvent
|
||||
import com.gh.common.exposure.ExposureSource
|
||||
import com.gh.common.util.DirectUtils
|
||||
import com.gh.common.util.ImageUtils
|
||||
import com.gh.common.util.PageSwitchDataHelper
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.adapter.RecyclingPagerAdapter
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
|
||||
class BannerAdapter(private val mContext: Context,
|
||||
private val mCatalogViewModel: SpecialCatalogViewModel,
|
||||
private var mItemData: SpecialCatalogItemData,
|
||||
mExposureSource: List<ExposureSource>) : RecyclingPagerAdapter() {
|
||||
class BannerAdapter(
|
||||
private val mContext: Context,
|
||||
private val mCatalogViewModel: SpecialCatalogViewModel,
|
||||
private var mItemData: SpecialCatalogItemData,
|
||||
mExposureSource: List<ExposureSource>,
|
||||
private val mLastPageDataMap: HashMap<String, String>?
|
||||
) : RecyclingPagerAdapter() {
|
||||
|
||||
private var mBanners = mItemData.banner!!.data
|
||||
private var mIsInfiniteLoop = getDataSize() != 1
|
||||
@ -51,10 +55,18 @@ class BannerAdapter(private val mContext: Context,
|
||||
var exposureEvent: ExposureEvent? = null
|
||||
if ("game" == banner.link.type) {
|
||||
exposureEvent = ExposureEvent.createEvent(
|
||||
GameEntity(id = banner.link.link,
|
||||
name = banner.link.text)
|
||||
.apply { sequence = index },
|
||||
mExposureSourceList)
|
||||
GameEntity(
|
||||
id = banner.link.link,
|
||||
name = banner.link.text
|
||||
).apply { sequence = index },
|
||||
mExposureSourceList
|
||||
).apply {
|
||||
mLastPageDataMap?.let {
|
||||
payload.sourcePage = it[PageSwitchDataHelper.PAGE_BUSINESS_TYPE]
|
||||
payload.sourcePageId = it[PageSwitchDataHelper.PAGE_BUSINESS_ID]
|
||||
payload.sourcePageName = it[PageSwitchDataHelper.PAGE_BUSINESS_NAME]
|
||||
}
|
||||
}
|
||||
mItemData.exposureEventList?.add(exposureEvent)
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,9 @@ package com.gh.gamecenter.catalog
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.gh.common.util.DisplayUtils
|
||||
import com.gh.common.util.EntranceUtils
|
||||
import com.gh.common.util.updateStatusBarColor
|
||||
import com.gh.gamecenter.NormalActivity
|
||||
import com.gh.gamecenter.R
|
||||
|
||||
@ -12,6 +14,7 @@ class CatalogActivity : NormalActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setToolbarMenu(R.menu.menu_download)
|
||||
updateStatusBarColor(R.color.black, R.color.white)
|
||||
}
|
||||
|
||||
override fun showDownloadMenu(): Boolean {
|
||||
@ -22,6 +25,13 @@ class CatalogActivity : NormalActivity() {
|
||||
return getTargetIntent(this, CatalogActivity::class.java, CatalogFragment::class.java)
|
||||
}
|
||||
|
||||
override fun onNightModeChange() {
|
||||
super.onNightModeChange()
|
||||
updateStatusBarColor(R.color.black, R.color.white)
|
||||
}
|
||||
|
||||
override fun isAutoResetViewBackgroundEnabled() = true
|
||||
|
||||
companion object {
|
||||
fun getIntent(context: Context, catalogId: String, catalogTitle: String, entrance: String): Intent {
|
||||
val bundle = Bundle()
|
||||
|
||||
@ -31,12 +31,12 @@ class CatalogAdapter(
|
||||
recommendTag.goneIf(!catalogEntity.recommended)
|
||||
if (catalogEntity.name == mViewModel.selectedCatalogName) {
|
||||
selectedTag.visibility = View.VISIBLE
|
||||
catalogName.setTextColor(R.color.theme_font.toColor())
|
||||
root.setBackgroundColor(R.color.white.toColor())
|
||||
catalogName.setTextColor(R.color.theme_font.toColor(mContext))
|
||||
root.setBackgroundColor(R.color.background_white.toColor(mContext))
|
||||
} else {
|
||||
selectedTag.visibility = View.GONE
|
||||
catalogName.setTextColor(R.color.text_title.toColor())
|
||||
root.setBackgroundColor(R.color.background.toColor())
|
||||
catalogName.setTextColor(R.color.text_title.toColor(mContext))
|
||||
root.background = null
|
||||
}
|
||||
root.setOnClickListener {
|
||||
if (catalogEntity.name != mViewModel.selectedCatalogName) {
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package com.gh.gamecenter.catalog
|
||||
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.core.os.bundleOf
|
||||
@ -99,9 +98,9 @@ class CatalogFragment : LazyFragment() {
|
||||
// 嵌入在首页时特殊处理
|
||||
if (arguments?.getBoolean(EntranceUtils.KEY_IS_HOME) == true) {
|
||||
mBinding?.divider?.visibility = View.GONE
|
||||
mBinding?.root?.setBackgroundColor(Color.WHITE)
|
||||
mBinding?.root?.setBackgroundColor(R.color.background_white.toColor(requireContext()))
|
||||
mBinding?.root?.setPadding(0, 8F.dip2px(), 0, 0)
|
||||
mBinding?.rvCatalog?.setBackgroundColor(R.color.background.toColor())
|
||||
mBinding?.rvCatalog?.setBackgroundColor(R.color.background.toColor(requireContext()))
|
||||
}
|
||||
}
|
||||
|
||||
@ -193,4 +192,11 @@ class CatalogFragment : LazyFragment() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onNightModeChange() {
|
||||
super.onNightModeChange()
|
||||
mBinding?.rvCatalog?.adapter?.run {
|
||||
notifyItemRangeChanged(0, itemCount)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3,13 +3,32 @@ package com.gh.gamecenter.catalog
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.gh.common.util.DisplayUtils
|
||||
import com.gh.common.util.EntranceUtils
|
||||
import com.gh.common.util.updateStatusBarColor
|
||||
import com.gh.gamecenter.NormalActivity
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.entity.CatalogEntity
|
||||
|
||||
class NewCatalogListActivity : NormalActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setToolbarMenu(R.menu.menu_download)
|
||||
updateStatusBarColor(R.color.black, R.color.white)
|
||||
}
|
||||
|
||||
override fun showDownloadMenu(): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onNightModeChange() {
|
||||
super.onNightModeChange()
|
||||
updateStatusBarColor(R.color.black, R.color.white)
|
||||
}
|
||||
|
||||
override fun isAutoResetViewBackgroundEnabled() = true
|
||||
|
||||
companion object {
|
||||
fun getIntent(context: Context,
|
||||
primaryCatalogId: String, // 一级分类 id
|
||||
@ -28,13 +47,4 @@ class NewCatalogListActivity : NormalActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setToolbarMenu(R.menu.menu_download)
|
||||
}
|
||||
|
||||
override fun showDownloadMenu(): Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@ -6,10 +6,7 @@ import com.ethanhua.skeleton.Skeleton
|
||||
import com.gh.common.constant.Constants
|
||||
import com.gh.common.exposure.ExposureListener
|
||||
import com.gh.common.exposure.ExposureSource
|
||||
import com.gh.common.util.DialogUtils
|
||||
import com.gh.common.util.EntranceUtils
|
||||
import com.gh.common.util.observeNonNull
|
||||
import com.gh.common.util.viewModelProvider
|
||||
import com.gh.common.util.*
|
||||
import com.gh.common.view.CatalogFilterView
|
||||
import com.gh.common.xapk.XapkInstaller
|
||||
import com.gh.common.xapk.XapkUnzipStatus
|
||||
@ -43,7 +40,7 @@ class NewCatalogListFragment : ListFragment<GameEntity, NewCatalogListViewModel>
|
||||
}
|
||||
}
|
||||
|
||||
private lateinit var mBinding: FragmentCatalogListBinding
|
||||
private var mBinding: FragmentCatalogListBinding? = null
|
||||
private lateinit var mExposureListener: ExposureListener
|
||||
private lateinit var mViewModel: NewCatalogListViewModel
|
||||
|
||||
@ -95,7 +92,7 @@ class NewCatalogListFragment : ListFragment<GameEntity, NewCatalogListViewModel>
|
||||
mExposureListener = ExposureListener(this, mAdapter!!)
|
||||
mListRv.addOnScrollListener(mExposureListener)
|
||||
|
||||
mSkeletonScreen = Skeleton.bind(mBinding.listSkeleton)
|
||||
mSkeletonScreen = Skeleton.bind(mBinding?.listSkeleton)
|
||||
.shimmer(true)
|
||||
.angle(Constants.SHIMMER_ANGLE)
|
||||
.color(R.color.skeleton_shimmer_color)
|
||||
@ -124,7 +121,7 @@ class NewCatalogListFragment : ListFragment<GameEntity, NewCatalogListViewModel>
|
||||
}
|
||||
|
||||
private fun initFilterView() {
|
||||
mBinding.filterContainer.run {
|
||||
mBinding?.filterContainer?.run {
|
||||
visibility = View.VISIBLE
|
||||
setTypeList(mPrimeCatalog?.switch ?: CatalogEntity.CatalogSwitch())
|
||||
setCatalogList(mSubCatalogList, mInitCatalogName)
|
||||
@ -190,4 +187,12 @@ class NewCatalogListFragment : ListFragment<GameEntity, NewCatalogListViewModel>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onNightModeChange() {
|
||||
super.onNightModeChange()
|
||||
mBinding?.run {
|
||||
filterContainer.setRootBackgroundColor(R.color.background_white.toColor(requireContext()))
|
||||
filterContainer.setItemTextColor(R.color.text_subtitle.toColor(requireContext()))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -26,7 +26,8 @@ import com.gh.gamecenter.subject.SubjectActivity.Companion.startSubjectActivity
|
||||
|
||||
class SpecialCatalogAdapter(
|
||||
context: Context,
|
||||
private val mCatalogViewModel: SpecialCatalogViewModel
|
||||
private val mCatalogViewModel: SpecialCatalogViewModel,
|
||||
private val mLastPageDataMap: HashMap<String, String>? = null
|
||||
) : ListAdapter<SpecialCatalogItemData>(context), IExposable {
|
||||
|
||||
private val mExposureEventSparseArray: SparseArray<ExposureEvent> = SparseArray()
|
||||
@ -120,7 +121,7 @@ class SpecialCatalogAdapter(
|
||||
is CatalogBannerItemHolder -> {
|
||||
val itemData = mEntityList[position]!!
|
||||
isBannerSizeMoreThanOne = itemData.banner!!.data.size > 1
|
||||
holder.bindBanners(itemData)
|
||||
holder.bindBanners(itemData, mLastPageDataMap)
|
||||
}
|
||||
|
||||
is CatalogImageItemHolder -> {
|
||||
@ -142,7 +143,13 @@ class SpecialCatalogAdapter(
|
||||
},
|
||||
mCatalogViewModel.basicExposureSource,
|
||||
listOf(ExposureSource("精选页图片", ""))
|
||||
)
|
||||
).apply {
|
||||
mLastPageDataMap?.let {
|
||||
payload.sourcePage = it[PageSwitchDataHelper.PAGE_BUSINESS_TYPE]
|
||||
payload.sourcePageId = it[PageSwitchDataHelper.PAGE_BUSINESS_ID]
|
||||
payload.sourcePageName = it[PageSwitchDataHelper.PAGE_BUSINESS_NAME]
|
||||
}
|
||||
}
|
||||
mExposureEventSparseArray.append(position, exposureEvent)
|
||||
}
|
||||
root.setOnClickListener {
|
||||
@ -186,7 +193,13 @@ class SpecialCatalogAdapter(
|
||||
game,
|
||||
mCatalogViewModel.basicExposureSource,
|
||||
listOf(ExposureSource("精选页专题", subject.link.text ?: ""))
|
||||
)
|
||||
).apply {
|
||||
mLastPageDataMap?.let {
|
||||
payload.sourcePage = it[PageSwitchDataHelper.PAGE_BUSINESS_TYPE]
|
||||
payload.sourcePageId = it[PageSwitchDataHelper.PAGE_BUSINESS_ID]
|
||||
payload.sourcePageName = it[PageSwitchDataHelper.PAGE_BUSINESS_NAME]
|
||||
}
|
||||
}
|
||||
exposureList.add(exposureEvent)
|
||||
|
||||
game.exposureEvent = exposureEvent
|
||||
@ -234,7 +247,7 @@ class SpecialCatalogAdapter(
|
||||
inner class CatalogBannerItemHolder(val binding: CatalogBannerItemBinding) : BaseRecyclerViewHolder<Any>(binding.root) {
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
fun bindBanners(itemData: SpecialCatalogItemData) {
|
||||
fun bindBanners(itemData: SpecialCatalogItemData, lastPageDataMap: HashMap<String, String>?) {
|
||||
val banners = itemData.banner!!.data
|
||||
val pagerAdapter = binding.viewPager.adapter
|
||||
if (banners.isNotEmpty()
|
||||
@ -265,7 +278,13 @@ class SpecialCatalogAdapter(
|
||||
}
|
||||
|
||||
binding.viewPager.run {
|
||||
adapter = BannerAdapter(mContext, mCatalogViewModel, itemData, mCatalogViewModel.basicExposureSource)
|
||||
adapter = BannerAdapter(
|
||||
mContext,
|
||||
mCatalogViewModel,
|
||||
itemData,
|
||||
mCatalogViewModel.basicExposureSource,
|
||||
lastPageDataMap
|
||||
)
|
||||
if (banners.size > 1) {
|
||||
currentItem = banners.size * 10
|
||||
interval = 3000L
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package com.gh.gamecenter.catalog
|
||||
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import com.ethanhua.skeleton.Skeleton
|
||||
@ -18,8 +17,8 @@ class SpecialCatalogFragment : ListFragment<SpecialCatalogItemData, SpecialCatal
|
||||
private var mCatalogTitle = ""
|
||||
private var mIsCategoryV2 = false // 是否为新分类2.0
|
||||
private val mBinding by lazy { FragmentListBaseSkeletonBinding.inflate(layoutInflater) }
|
||||
|
||||
private var mAdapter: SpecialCatalogAdapter? = null
|
||||
private var mLastPageDataMap: HashMap<String, String>? = null
|
||||
|
||||
private lateinit var mExposureListener: ExposureListener
|
||||
|
||||
@ -34,7 +33,11 @@ class SpecialCatalogFragment : ListFragment<SpecialCatalogItemData, SpecialCatal
|
||||
mIsCategoryV2,
|
||||
arguments?.getParcelable(EntranceUtils.KEY_EXPOSURE_SOURCE)))
|
||||
|
||||
override fun provideListAdapter() = mAdapter ?: SpecialCatalogAdapter(requireContext(), mListViewModel).apply {
|
||||
override fun provideListAdapter() = mAdapter ?: SpecialCatalogAdapter(
|
||||
requireContext(),
|
||||
mListViewModel,
|
||||
mLastPageDataMap
|
||||
).apply {
|
||||
mAdapter = this
|
||||
mExposureListener = ExposureListener(this@SpecialCatalogFragment, this)
|
||||
}
|
||||
@ -47,6 +50,7 @@ class SpecialCatalogFragment : ListFragment<SpecialCatalogItemData, SpecialCatal
|
||||
mIsCategoryV2 = arguments?.getBoolean(EntranceUtils.KEY_IS_CATEGORY_V2) ?: false
|
||||
mCatalogId = arguments?.getString(EntranceUtils.KEY_CATALOG_ID) ?: ""
|
||||
mCatalogTitle = arguments?.getString(EntranceUtils.KEY_CATALOG_TITLE) ?: ""
|
||||
mLastPageDataMap = arguments?.getSerializable(EntranceUtils.KEY_LAST_PAGE_DATA) as? HashMap<String, String>
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
@ -69,7 +73,6 @@ class SpecialCatalogFragment : ListFragment<SpecialCatalogItemData, SpecialCatal
|
||||
.show()
|
||||
onLoadRefresh()
|
||||
|
||||
mListRv.setBackgroundColor(Color.WHITE)
|
||||
mListRv.addOnScrollListener(mExposureListener)
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,9 @@ import android.view.ViewGroup
|
||||
import com.gh.base.BaseRecyclerViewHolder
|
||||
import com.gh.common.util.dip2px
|
||||
import com.gh.common.util.toBinding
|
||||
import com.gh.common.util.toColor
|
||||
import com.gh.gamecenter.GameDetailActivity
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.databinding.CatalogSubjectGameItemBinding
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.lightgame.adapter.BaseRecyclerAdapter
|
||||
|
||||
@ -3,10 +3,8 @@ package com.gh.gamecenter.catalog
|
||||
import android.content.Context
|
||||
import android.view.ViewGroup
|
||||
import com.gh.base.BaseRecyclerViewHolder
|
||||
import com.gh.common.util.DialogHelper
|
||||
import com.gh.common.util.ImageUtils
|
||||
import com.gh.common.util.goneIf
|
||||
import com.gh.common.util.toBinding
|
||||
import com.gh.common.util.*
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.databinding.SubCatalogItemBinding
|
||||
import com.gh.gamecenter.entity.CatalogEntity
|
||||
import com.lightgame.adapter.BaseRecyclerAdapter
|
||||
|
||||
@ -5,8 +5,10 @@ import android.view.View
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.gh.common.util.EntranceUtils
|
||||
import com.gh.common.util.toColor
|
||||
import com.gh.common.util.viewModelProvider
|
||||
import com.gh.common.util.viewModelProviderFromParent
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.databinding.FragmentSubCatalogBinding
|
||||
import com.gh.gamecenter.entity.CatalogEntity
|
||||
import com.gh.gamecenter.normal.NormalFragment
|
||||
|
||||
@ -6,6 +6,7 @@ import androidx.lifecycle.ViewModelProviders
|
||||
import com.ethanhua.skeleton.Skeleton
|
||||
import com.gh.common.constant.Constants
|
||||
import com.gh.common.util.EntranceUtils
|
||||
import com.gh.common.util.toColor
|
||||
import com.gh.common.view.VerticalItemDecoration
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.baselist.LazyListFragment
|
||||
@ -67,7 +68,7 @@ class CategoryDirectoryFragment : LazyListFragment<CategoryEntity, CategoryDirec
|
||||
override fun getItemDecoration() = VerticalItemDecoration(context, 0F, false)
|
||||
|
||||
override fun onLoadRefresh() {
|
||||
mCachedView?.setBackgroundColor(Color.WHITE)
|
||||
mCachedView?.setBackgroundColor(R.color.background_white.toColor(requireContext()))
|
||||
super.onLoadRefresh()
|
||||
}
|
||||
|
||||
|
||||
@ -30,6 +30,7 @@ class CategoryV2Fragment : LazyFragment() {
|
||||
private var mEntity: SidebarsEntity? = null
|
||||
private var mSpecialCatalogFragment: SpecialCatalogFragment? = null
|
||||
private var mCategoryV2ListFragment: CategoryV2ListFragment? = null
|
||||
private var mLastPageDataMap: HashMap<String, String>? = null
|
||||
|
||||
private var mCategoryId: String = ""
|
||||
private var mCategoryTitle: String = ""
|
||||
@ -58,6 +59,7 @@ class CategoryV2Fragment : LazyFragment() {
|
||||
override fun onFragmentFirstVisible() {
|
||||
mCategoryId = arguments?.getString(EntranceUtils.KEY_CATEGORY_ID) ?: ""
|
||||
mCategoryTitle = arguments?.getString(EntranceUtils.KEY_CATEGORY_TITLE) ?: ""
|
||||
mLastPageDataMap = PageSwitchDataHelper.popLastPageData()
|
||||
mViewModel = viewModelProviderFromParent(CategoryV2ViewModel.Factory(mCategoryId, mCategoryTitle), mCategoryId)
|
||||
|
||||
// 除了这里以外,下面还有一个判断是否为首页 tab 栏的赋值
|
||||
@ -301,7 +303,8 @@ class CategoryV2Fragment : LazyFragment() {
|
||||
EntranceUtils.KEY_IS_CATEGORY_V2 to true,
|
||||
EntranceUtils.KEY_CATALOG_ID to id,
|
||||
EntranceUtils.KEY_CATALOG_TITLE to mCategoryTitle,
|
||||
EntranceUtils.KEY_EXPOSURE_SOURCE to arguments?.getParcelable(EntranceUtils.KEY_EXPOSURE_SOURCE)
|
||||
EntranceUtils.KEY_EXPOSURE_SOURCE to arguments?.getParcelable(EntranceUtils.KEY_EXPOSURE_SOURCE),
|
||||
EntranceUtils.KEY_LAST_PAGE_DATA to mLastPageDataMap
|
||||
)
|
||||
childFragmentManager
|
||||
.beginTransaction()
|
||||
@ -324,7 +327,8 @@ class CategoryV2Fragment : LazyFragment() {
|
||||
EntranceUtils.KEY_CATEGORY_ID to id,
|
||||
EntranceUtils.KEY_SUB_CATEGORY_ID to sidebars[selectedCategoryPosition].categoryId,
|
||||
EntranceUtils.KEY_CATEGORY_TITLE to mCategoryTitle,
|
||||
EntranceUtils.KEY_EXPOSURE_SOURCE to arguments?.getParcelable(EntranceUtils.KEY_EXPOSURE_SOURCE)
|
||||
EntranceUtils.KEY_EXPOSURE_SOURCE to arguments?.getParcelable(EntranceUtils.KEY_EXPOSURE_SOURCE),
|
||||
EntranceUtils.KEY_LAST_PAGE_DATA to mLastPageDataMap
|
||||
)
|
||||
childFragmentManager
|
||||
.beginTransaction()
|
||||
@ -352,7 +356,8 @@ class CategoryV2Fragment : LazyFragment() {
|
||||
EntranceUtils.KEY_CATEGORY_ID to id,
|
||||
EntranceUtils.KEY_SUB_CATEGORY_ID to sidebars[position].categoryId,
|
||||
EntranceUtils.KEY_CATALOG_TITLE to mCategoryTitle,
|
||||
EntranceUtils.KEY_EXPOSURE_SOURCE to arguments?.getParcelable(EntranceUtils.KEY_EXPOSURE_SOURCE)
|
||||
EntranceUtils.KEY_EXPOSURE_SOURCE to arguments?.getParcelable(EntranceUtils.KEY_EXPOSURE_SOURCE),
|
||||
EntranceUtils.KEY_LAST_PAGE_DATA to mLastPageDataMap
|
||||
)
|
||||
childFragmentManager
|
||||
.beginTransaction()
|
||||
@ -369,7 +374,8 @@ class CategoryV2Fragment : LazyFragment() {
|
||||
EntranceUtils.KEY_IS_CATEGORY_V2 to true,
|
||||
EntranceUtils.KEY_CATALOG_ID to id,
|
||||
EntranceUtils.KEY_CATALOG_TITLE to mCategoryTitle,
|
||||
EntranceUtils.KEY_EXPOSURE_SOURCE to arguments?.getParcelable(EntranceUtils.KEY_EXPOSURE_SOURCE)
|
||||
EntranceUtils.KEY_EXPOSURE_SOURCE to arguments?.getParcelable(EntranceUtils.KEY_EXPOSURE_SOURCE),
|
||||
EntranceUtils.KEY_LAST_PAGE_DATA to mLastPageDataMap
|
||||
)
|
||||
childFragmentManager
|
||||
.beginTransaction()
|
||||
@ -381,7 +387,8 @@ class CategoryV2Fragment : LazyFragment() {
|
||||
EntranceUtils.KEY_CATEGORY_ID to id,
|
||||
EntranceUtils.KEY_SUB_CATEGORY_ID to sidebars[position].categoryId,
|
||||
EntranceUtils.KEY_CATALOG_TITLE to mCategoryTitle,
|
||||
EntranceUtils.KEY_EXPOSURE_SOURCE to arguments?.getParcelable(EntranceUtils.KEY_EXPOSURE_SOURCE)
|
||||
EntranceUtils.KEY_EXPOSURE_SOURCE to arguments?.getParcelable(EntranceUtils.KEY_EXPOSURE_SOURCE),
|
||||
EntranceUtils.KEY_LAST_PAGE_DATA to mLastPageDataMap
|
||||
)
|
||||
}
|
||||
mCategoryV2ListFragment?.changeCategoryTab(sidebars[position].categoryId)
|
||||
@ -402,7 +409,8 @@ class CategoryV2Fragment : LazyFragment() {
|
||||
EntranceUtils.KEY_CATEGORY_ID to id,
|
||||
EntranceUtils.KEY_SUB_CATEGORY_ID to sidebars[position].categoryId,
|
||||
EntranceUtils.KEY_CATALOG_TITLE to mCategoryTitle,
|
||||
EntranceUtils.KEY_EXPOSURE_SOURCE to arguments?.getParcelable(EntranceUtils.KEY_EXPOSURE_SOURCE)
|
||||
EntranceUtils.KEY_EXPOSURE_SOURCE to arguments?.getParcelable(EntranceUtils.KEY_EXPOSURE_SOURCE),
|
||||
EntranceUtils.KEY_LAST_PAGE_DATA to mLastPageDataMap
|
||||
)
|
||||
}
|
||||
mCategoryV2ListFragment?.changeCategoryTab(sidebars[position].categoryId)
|
||||
|
||||
@ -24,10 +24,13 @@ import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.eventbus.EBDownloadStatus
|
||||
import com.lightgame.download.DownloadEntity
|
||||
|
||||
class CategoryV2ListAdapter(context: Context,
|
||||
private val mViewModel: CategoryV2ListViewModel,
|
||||
private val mCategoryViewModel: CategoryV2ViewModel,
|
||||
private val mEntrance: String?) : ListAdapter<GameEntity>(context), IExposable {
|
||||
class CategoryV2ListAdapter(
|
||||
context: Context,
|
||||
private val mViewModel: CategoryV2ListViewModel,
|
||||
private val mCategoryViewModel: CategoryV2ViewModel,
|
||||
private val mEntrance: String?,
|
||||
private var mLastPageDataMap: HashMap<String, String>? = null
|
||||
) : ListAdapter<GameEntity>(context), IExposable {
|
||||
|
||||
private val mExposureEventSparseArray: SparseArray<ExposureEvent> = SparseArray()
|
||||
|
||||
@ -107,7 +110,15 @@ class CategoryV2ListAdapter(context: Context,
|
||||
exposureSources.add(ExposureSource(selectedCategoryName))
|
||||
exposureSources.add(ExposureSource("二级分类详情", "$selectedSubCatalogName+$sortType+$sortSize"))
|
||||
|
||||
val event = ExposureEvent.createEvent(gameEntity, exposureSources, null, ExposureType.EXPOSURE)
|
||||
val event =
|
||||
ExposureEvent.createEvent(gameEntity, exposureSources, null, ExposureType.EXPOSURE)
|
||||
.apply {
|
||||
mLastPageDataMap?.let {
|
||||
payload.sourcePage = it[PageSwitchDataHelper.PAGE_BUSINESS_TYPE]
|
||||
payload.sourcePageId = it[PageSwitchDataHelper.PAGE_BUSINESS_ID]
|
||||
payload.sourcePageName = it[PageSwitchDataHelper.PAGE_BUSINESS_NAME]
|
||||
}
|
||||
}
|
||||
mExposureEventSparseArray.put(position, event)
|
||||
|
||||
holder.itemView.setOnClickListener {
|
||||
|
||||
@ -35,6 +35,7 @@ class CategoryV2ListFragment : ListFragment<GameEntity, CategoryV2ListViewModel>
|
||||
private var mSelectedViewList = ArrayList<View>()
|
||||
private var mBinding: FragmentCategoryListBinding? = null
|
||||
private var mCategoryViewModel: CategoryV2ViewModel? = null
|
||||
private var mLastPageDataMap: HashMap<String, String>? = null
|
||||
private val mDataWatcher = object : DataWatcher() {
|
||||
override fun onDataChanged(downloadEntity: DownloadEntity) {
|
||||
mAdapter?.notifyItemByDownload(downloadEntity)
|
||||
@ -56,11 +57,18 @@ class CategoryV2ListFragment : ListFragment<GameEntity, CategoryV2ListViewModel>
|
||||
arguments?.getParcelable(EntranceUtils.KEY_EXPOSURE_SOURCE)))
|
||||
|
||||
override fun provideListAdapter() = mAdapter
|
||||
?: CategoryV2ListAdapter(
|
||||
requireContext(),
|
||||
mListViewModel ?: provideListViewModel(),
|
||||
mCategoryViewModel ?: viewModelProviderFromParent(CategoryV2ViewModel.Factory(mCategoryId, mCategoryTitle), mCategoryId),
|
||||
mEntrance).apply { mAdapter = this }
|
||||
?: CategoryV2ListAdapter(
|
||||
requireContext(),
|
||||
mListViewModel ?: provideListViewModel(),
|
||||
mCategoryViewModel ?: viewModelProviderFromParent(
|
||||
CategoryV2ViewModel.Factory(
|
||||
mCategoryId,
|
||||
mCategoryTitle
|
||||
), mCategoryId
|
||||
),
|
||||
mEntrance,
|
||||
mLastPageDataMap
|
||||
).apply { mAdapter = this }
|
||||
|
||||
override fun getItemDecoration() = null
|
||||
|
||||
@ -68,6 +76,7 @@ class CategoryV2ListFragment : ListFragment<GameEntity, CategoryV2ListViewModel>
|
||||
mCategoryId = arguments?.getString(EntranceUtils.KEY_CATEGORY_ID) ?: ""
|
||||
mSubCategoryId = arguments?.getString(EntranceUtils.KEY_SUB_CATEGORY_ID) ?: ""
|
||||
mCategoryTitle = arguments?.getString(EntranceUtils.KEY_CATEGORY_TITLE) ?: ""
|
||||
mLastPageDataMap = arguments?.getSerializable(EntranceUtils.KEY_LAST_PAGE_DATA) as? HashMap<String, String>
|
||||
|
||||
mCategoryViewModel = viewModelProviderFromParent(CategoryV2ViewModel.Factory(mCategoryId, mCategoryTitle), mCategoryId)
|
||||
mEntrance = arguments?.getString(EntranceUtils.KEY_ENTRANCE) ?: Constants.ENTRANCE_UNKNOWN
|
||||
|
||||
@ -102,14 +102,17 @@ class GamesCollectionAdapter(
|
||||
ImageUtils.display(poster, itemEntity.cover)
|
||||
nameTv.text = itemEntity.title
|
||||
tagIv.goneIf(itemEntity.stamp.isEmpty())
|
||||
itemEntity.games?.let {
|
||||
gameOne.goneIf(it.size == 0)
|
||||
gameOne.displayGameIcon(it[0].toGameEntity())
|
||||
gameTwo.goneIf(it.size < 2)
|
||||
gameTwo.displayGameIcon(it[1].toGameEntity())
|
||||
gameThree.goneIf(it.size < 3)
|
||||
gameThree.displayGameIcon(it[2].toGameEntity())
|
||||
|
||||
val gameIconList = listOf(gameOne, gameTwo, gameThree)
|
||||
itemEntity.games?.take(3)?.forEachIndexed { index, game ->
|
||||
gameIconList[index].displayGameIcon(game.toGameEntity())
|
||||
}
|
||||
itemEntity.games?.size?.let {
|
||||
gameOne.goneIf(it == 0)
|
||||
gameTwo.goneIf(it < 2)
|
||||
gameThree.goneIf(it < 3)
|
||||
}
|
||||
|
||||
moreNumTv.goneIf((itemEntity.count?.game ?: 0) < 4)
|
||||
moreNumTv.text = "+ " + ((itemEntity.count?.game ?: 0) - 3)
|
||||
tagContainer.goneIf(itemEntity.count?.game != 0)
|
||||
@ -185,7 +188,6 @@ class GamesCollectionAdapter(
|
||||
}, extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true))
|
||||
}
|
||||
|
||||
val gameIconList = listOf(gameOne, gameTwo, gameThree)
|
||||
gameIconList.forEachIndexed { index, gameIcon ->
|
||||
gameIcon.setOnClickListener {
|
||||
GameDetailActivity.startGameDetailActivity(mContext, itemEntity.games?.safelyGetInRelease(index)?.id ?: "", "")
|
||||
@ -222,16 +224,9 @@ class GamesCollectionAdapter(
|
||||
debounceActionWithInterval(R.id.vote_count_container, 1000) {
|
||||
mViewModel.postVoteGameCollection(itemEntity.id, !voteIcon.isChecked) {
|
||||
if (!voteIcon.isChecked) {
|
||||
voteCount.setTextColor(R.color.theme_font.toColor())
|
||||
voteCount.setTextColor(R.color.text_white.toColor())
|
||||
voteIcon.isChecked = true
|
||||
voteIcon.visibility = View.INVISIBLE
|
||||
voteAnimation.visibility = View.VISIBLE
|
||||
voteAnimation.setAnimation("lottie/community_vote.json")
|
||||
voteAnimation.playAnimation()
|
||||
voteAnimation.doOnAnimationEnd {
|
||||
voteAnimation.visibility = View.GONE
|
||||
voteIcon.visibility = View.VISIBLE
|
||||
}
|
||||
voteIcon.visibility = View.VISIBLE
|
||||
|
||||
itemEntity.me?.isVoted = true
|
||||
itemEntity.count?.run {
|
||||
|
||||
@ -44,7 +44,11 @@ class GamesCollectionFragment : ListFragment<GamesCollectionEntity, GamesCollect
|
||||
super.onCreate(savedInstanceState)
|
||||
mListRv?.run {
|
||||
overScrollMode = View.OVER_SCROLL_NEVER
|
||||
if (!mIsInsertGameCollection && mType == TYPE_USER) setBackgroundColor(R.color.white.toColor())
|
||||
if (!mIsInsertGameCollection && mType == TYPE_USER) {
|
||||
setBackgroundColor(R.color.background_white.toColor(requireContext()))
|
||||
}else{
|
||||
setBackgroundColor(R.color.background.toColor(requireContext()))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -94,6 +98,17 @@ class GamesCollectionFragment : ListFragment<GamesCollectionEntity, GamesCollect
|
||||
mAdapter?.changeOption(option)
|
||||
}
|
||||
|
||||
override fun onNightModeChange() {
|
||||
super.onNightModeChange()
|
||||
mListRv?.run {
|
||||
if (!mIsInsertGameCollection && mType == TYPE_USER) {
|
||||
setBackgroundColor(R.color.background_white.toColor(requireContext()))
|
||||
} else {
|
||||
setBackgroundColor(R.color.background.toColor(requireContext()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TYPE_HISTORY = "history"
|
||||
const val TYPE_COLLECT = "collect"
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user