From 3afebb1e3887df53b411dcf07b42d35764241d12 Mon Sep 17 00:00:00 2001 From: yangfei Date: Thu, 4 Jan 2024 14:35:50 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=8E=B7=E5=8F=9632=E4=BD=8D=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=92=8C=E6=8F=92=E4=BB=B6=E7=9A=84=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gh/common/constant/Config.java | 34 ++++++++++++++ .../java/com/gh/gamecenter/MainActivity.java | 4 ++ .../com/gh/gamecenter/entity/VNewSetting.kt | 45 +++++++++++++++++++ .../retrofit/service/VApiService.kt | 3 ++ .../gamecenter/common/constant/Constants.java | 4 ++ 5 files changed, 90 insertions(+) create mode 100644 app/src/main/java/com/gh/gamecenter/entity/VNewSetting.kt diff --git a/app/src/main/java/com/gh/common/constant/Config.java b/app/src/main/java/com/gh/common/constant/Config.java index b5fa944512..7f7bdbbc11 100644 --- a/app/src/main/java/com/gh/common/constant/Config.java +++ b/app/src/main/java/com/gh/common/constant/Config.java @@ -25,6 +25,7 @@ import com.gh.gamecenter.core.utils.UrlFilterUtils; import com.gh.gamecenter.entity.GameGuidePopupEntity; import com.gh.gamecenter.entity.NewApiSettingsEntity; import com.gh.gamecenter.entity.NewSettingsEntity; +import com.gh.gamecenter.entity.VNewSetting; import com.gh.gamecenter.entity.VSetting; import com.gh.gamecenter.feature.entity.NewsEntity; import com.gh.gamecenter.feature.entity.SettingsEntity; @@ -73,6 +74,7 @@ public class Config { private static NewApiSettingsEntity.NightMode mNightModeSetting; private static SimulatorEntity mNewSimulatorEntity; private static VSetting mVSetting; + private static VNewSetting mVNewSetting; private static GameGuidePopupEntity mGameGuidePopupEntity; private static SharedPreferences mDefaultSharedPreferences; @@ -306,6 +308,20 @@ public class Config { return mVSetting; } + public static VNewSetting getVNewSettingEntity() { + if (mVNewSetting == null) { + try { + String json = SPUtils.getString(Constants.SP_V_NEW_SETTINGS); + if (!TextUtils.isEmpty(json)) { + mVNewSetting = GsonUtils.fromJson(json, VNewSetting.class); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + return mVNewSetting; + } + /** * 请求网络数据,尝试刷新畅玩相关配置 */ @@ -326,6 +342,23 @@ public class Config { }); } + @SuppressLint("CheckResult") + public static void getNewSetting() { + RetrofitManager.getInstance() + .getVApi().getNewSettings(BuildConfig.VERSION_NAME, Build.VERSION.SDK_INT) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new BiResponse() { + @Override + public void onSuccess(VNewSetting data) { + // TODO: test + data.getVa().getArch32().setUrl("https://dev-app-static.796697.com/va/apk/2024/01/04/com.gh.gamecenter.addon_2.0.0-debug_20000_0.0.10_1704335165.apk"); + mVNewSetting = data; + SPUtils.setString(Constants.SP_V_NEW_SETTINGS, GsonUtils.toJson(data)); + } + }); + } + @Nullable public static GameGuidePopupEntity getGameGuidePopupEntity() { return mGameGuidePopupEntity; @@ -404,6 +437,7 @@ public class Config { }); refreshVSettingEntity(); + getNewSetting(); RetrofitManager.getInstance() .getApi().getGameGuidePopup(Build.MANUFACTURER, Build.VERSION.RELEASE, Build.MODEL, channel, BuildConfig.VERSION_NAME) diff --git a/app/src/main/java/com/gh/gamecenter/MainActivity.java b/app/src/main/java/com/gh/gamecenter/MainActivity.java index af83789103..351bc24c3b 100644 --- a/app/src/main/java/com/gh/gamecenter/MainActivity.java +++ b/app/src/main/java/com/gh/gamecenter/MainActivity.java @@ -304,6 +304,8 @@ public class MainActivity extends BaseActivity { Config.getGhzsSettings(); } else if (Config.getVSettingEntity() == null) { Config.refreshVSettingEntity(); + } else if (Config.getVNewSettingEntity() == null) { + Config.getNewSetting(); } // 耗时操作 @@ -948,6 +950,8 @@ public class MainActivity extends BaseActivity { Config.getGhzsSettings(); } else if (Config.getVSettingEntity() == null) { Config.refreshVSettingEntity(); + } else if (Config.getVNewSettingEntity() == null) { + Config.getNewSetting(); } mPackageViewModel.checkData(); diff --git a/app/src/main/java/com/gh/gamecenter/entity/VNewSetting.kt b/app/src/main/java/com/gh/gamecenter/entity/VNewSetting.kt new file mode 100644 index 0000000000..52d9909863 --- /dev/null +++ b/app/src/main/java/com/gh/gamecenter/entity/VNewSetting.kt @@ -0,0 +1,45 @@ +package com.gh.gamecenter.entity + +import com.google.gson.annotations.SerializedName + +class VNewSetting { + + @SerializedName("va") + var va: Va? = null + + @SerializedName("va_plugin") + var vaPlugin: VaPlugin? = null + + class Va( + @SerializedName("32-bit") + val arch32: VaArch? = null, + ) + + class VaArch( + val size: String, + @SerializedName("package") + val packageName: String, + @SerializedName("version") + val versionName: String, + @SerializedName("version_code") + val versionCode: Int, + // TODO: test change to val + var url: String + ) + + data class VaPlugin( + @SerializedName("_id") + val id: String, + @SerializedName("version") + val versionName: String, + @SerializedName("version_code") + val versionCode: Int, + @SerializedName("update_log") + var updateLog: String?, + @SerializedName("url_32") + val url32: String, + @SerializedName("url64") + val url64: String, + ) + +} \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/retrofit/service/VApiService.kt b/app/src/main/java/com/gh/gamecenter/retrofit/service/VApiService.kt index 29f6998d4c..be899fec04 100644 --- a/app/src/main/java/com/gh/gamecenter/retrofit/service/VApiService.kt +++ b/app/src/main/java/com/gh/gamecenter/retrofit/service/VApiService.kt @@ -1,6 +1,7 @@ package com.gh.gamecenter.retrofit.service import com.gh.gamecenter.entity.AppEntity +import com.gh.gamecenter.entity.VNewSetting import com.gh.gamecenter.entity.VSetting import io.reactivex.Single import retrofit2.http.GET @@ -24,4 +25,6 @@ interface VApiService { @GET("setting") fun getSettings(@Query("version") version: String?, @Query("android") androidSdkVersion: Int): Single + @GET("new/setting") + fun getNewSettings(@Query("version") version: String?, @Query("android") androidSdkVersion: Int): Single } \ No newline at end of file diff --git a/module_common/src/main/java/com/gh/gamecenter/common/constant/Constants.java b/module_common/src/main/java/com/gh/gamecenter/common/constant/Constants.java index d92772120b..34ba352d49 100644 --- a/module_common/src/main/java/com/gh/gamecenter/common/constant/Constants.java +++ b/module_common/src/main/java/com/gh/gamecenter/common/constant/Constants.java @@ -222,6 +222,10 @@ public class Constants { // 畅玩组件的配置 public static final String SP_V_SETTINGS = "v_settings"; + // 畅玩,插件的配置 + + public static final String SP_V_NEW_SETTINGS = "v_new_settings"; + // 头像挂件ID public static final String SP_CHOOSE_AVATAR_ID = "choose_avatar_id";