基本完成使用浏览器下载功能,埋点细节待补充 https://git.ghzs.com/pm/halo-app-issues/-/issues/1132

This commit is contained in:
juntao
2021-03-03 18:30:14 +08:00
parent 4f6969a70a
commit 68ee926897
15 changed files with 226 additions and 215 deletions

View File

@ -2,6 +2,7 @@ package com.gh.common.constant;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import android.preference.PreferenceManager;
import android.text.TextUtils;
@ -11,9 +12,11 @@ import com.gh.common.util.PackageUtils;
import com.gh.common.util.SPUtils;
import com.gh.gamecenter.BuildConfig;
import com.gh.gamecenter.SuggestionActivity;
import com.gh.gamecenter.entity.NewSettingsEntity;
import com.gh.gamecenter.entity.NewsEntity;
import com.gh.gamecenter.entity.SettingsEntity;
import com.gh.gamecenter.eventbus.EBReuse;
import com.gh.gamecenter.retrofit.BiResponse;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
import com.halo.assistant.HaloApp;
@ -61,6 +64,7 @@ public class Config {
private static String SETTINGS_KEY = "settingsKey";
private static SettingsEntity mSettingsEntity;
private static NewSettingsEntity mNewSettingsEntity;
public static final String FIX_DOWNLOAD_KEY = "isFixDownload";
public static final String FIX_PLUGIN_KEY = "isFixPlugin";
@ -203,6 +207,21 @@ public class Config {
return mSettingsEntity;
}
@Nullable
public static NewSettingsEntity getNewSettingsEntity() {
if (mNewSettingsEntity == null) {
try {
String json = SPUtils.getString(Constants.SP_NEW_SETTINGS);
if (!TextUtils.isEmpty(json)) {
mNewSettingsEntity = GsonUtils.fromJson(json, NewSettingsEntity.class);
}
} catch (Exception e) {
e.printStackTrace();
}
}
return mNewSettingsEntity;
}
private static boolean isExistDownloadFilter() {
if (getSettings() == null || getSettings().getDownload() == null || getSettings().getDownload().size() == 0) {
return false;
@ -278,5 +297,17 @@ public class Config {
EventBus.getDefault().post(new EBReuse("Refresh"));
}
});
RetrofitManager.getInstance(HaloApp.getInstance().getApplication())
.getApi().getNewSettings(Build.MANUFACTURER, Build.MODEL, channel)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new BiResponse<NewSettingsEntity>() {
@Override
public void onSuccess(NewSettingsEntity data) {
mNewSettingsEntity = data;
SPUtils.setString(Constants.SP_NEW_SETTINGS, data.toString());
}
});
}
}