Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev
This commit is contained in:
@ -5,18 +5,28 @@ import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.gh.common.util.GsonUtils;
|
||||
import com.gh.common.util.PackageHelper;
|
||||
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.NewsEntity;
|
||||
import com.gh.gamecenter.entity.SettingsEntity;
|
||||
import com.gh.gamecenter.eventbus.EBReuse;
|
||||
import com.gh.gamecenter.retrofit.Response;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
import com.halo.assistant.HaloApp;
|
||||
import com.lightgame.utils.Utils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
public class Config {
|
||||
|
||||
@ -168,7 +178,7 @@ public class Config {
|
||||
public static void setSettings(SettingsEntity settingsEntity) {
|
||||
getPreferences().edit().putString(SETTINGS_KEY, GsonUtils.toJson(settingsEntity)).apply();
|
||||
mSettingsEntity = settingsEntity;
|
||||
|
||||
|
||||
// 更新 FIX_ARTICLE_KEY 状态
|
||||
mSettingsEntity.showArticleEntrance();
|
||||
|
||||
@ -235,4 +245,29 @@ public class Config {
|
||||
editor.putBoolean(Config.FIX_PLUGIN_KEY, true);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void getGhzsSettings() {
|
||||
String channel = HaloApp.getInstance().getChannel();
|
||||
RetrofitManager.getInstance(HaloApp.getInstance().getApplication())
|
||||
.getApi().getSettings(PackageUtils.getVersionName(), channel)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Response<SettingsEntity>() {
|
||||
@Override
|
||||
public void onResponse(SettingsEntity response) {
|
||||
Config.setSettings(response);
|
||||
|
||||
// 意见反馈
|
||||
SharedPreferences.Editor edit = getPreferences().edit();
|
||||
edit.putString(SuggestionActivity.SUGGESTION_HINT_TYPE,
|
||||
GsonUtils.toJson(response.getSuggestion()));
|
||||
edit.apply();
|
||||
|
||||
if (!getPreferences().getBoolean(Config.FIX_DOWNLOAD_KEY, false) && Config.isShow()) {
|
||||
getPreferences().edit().putBoolean(Config.FIX_DOWNLOAD_KEY, true).apply();
|
||||
}
|
||||
EventBus.getDefault().post(new EBReuse("Refresh"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,6 +25,9 @@ import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.ViewModelProviders;
|
||||
|
||||
import com.gh.base.AppUncaughtHandler;
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.base.fragment.BaseFragment_ViewPager;
|
||||
@ -47,7 +50,6 @@ import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.DirectUtils;
|
||||
import com.gh.common.util.DownloadNotificationHelper;
|
||||
import com.gh.common.util.EntranceUtils;
|
||||
import com.gh.common.util.GsonUtils;
|
||||
import com.gh.common.util.LogUtils;
|
||||
import com.gh.common.util.LunchType;
|
||||
import com.gh.common.util.MtaHelper;
|
||||
@ -68,7 +70,6 @@ import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.entity.InnerMetaInfoEntity;
|
||||
import com.gh.gamecenter.entity.NotificationHint;
|
||||
import com.gh.gamecenter.entity.NotificationUgc;
|
||||
import com.gh.gamecenter.entity.SettingsEntity;
|
||||
import com.gh.gamecenter.entity.SimpleGameEntity;
|
||||
import com.gh.gamecenter.eventbus.EBDownloadStatus;
|
||||
import com.gh.gamecenter.eventbus.EBNetworkState;
|
||||
@ -129,8 +130,6 @@ import java.util.UUID;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.ViewModelProviders;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.MediaType;
|
||||
@ -382,7 +381,7 @@ public class MainActivity extends BaseActivity {
|
||||
// 上传数据
|
||||
DataCollectionManager.getInstance(getApplicationContext()).upload();
|
||||
// 获取默认配置
|
||||
getGhzsSettings();
|
||||
Config.getGhzsSettings();
|
||||
// 检查助手更新
|
||||
UpdateManager.getInstance(this).checkUpdate(true, null);
|
||||
// 初始化PlatformUtils
|
||||
@ -687,32 +686,6 @@ public class MainActivity extends BaseActivity {
|
||||
EventBus.getDefault().post(new EBReuse(CommunityFragment.EB_RETRY_PAGE));
|
||||
}
|
||||
|
||||
private void getGhzsSettings() {
|
||||
String channel = HaloApp.getInstance().getChannel();
|
||||
RetrofitManager.getInstance(this)
|
||||
.getApi().getSettings(PackageUtils.getVersionName(), channel)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Response<SettingsEntity>() {
|
||||
@Override
|
||||
public void onResponse(SettingsEntity response) {
|
||||
Config.setSettings(response);
|
||||
|
||||
// 意见反馈
|
||||
SharedPreferences.Editor edit = mSp.edit();
|
||||
edit.putString(SuggestionActivity.SUGGESTION_HINT_TYPE,
|
||||
GsonUtils.toJson(response.getSuggestion()));
|
||||
edit.apply();
|
||||
|
||||
if (!mSp.getBoolean(Config.FIX_DOWNLOAD_KEY, false) && Config.isShow()) {
|
||||
mSp.edit().putBoolean(Config.FIX_DOWNLOAD_KEY, true).apply();
|
||||
}
|
||||
|
||||
EventBus.getDefault().post(new EBReuse("Refresh"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void checkRetryDownload() {
|
||||
DownloadManager.getInstance(this).checkRetryDownload();
|
||||
}
|
||||
@ -897,7 +870,7 @@ public class MainActivity extends BaseActivity {
|
||||
if (busNetworkState.isNetworkConnected()) {
|
||||
checkRetryDownload();
|
||||
if (Config.getSettings() == null) {
|
||||
getGhzsSettings();
|
||||
Config.getGhzsSettings();
|
||||
}
|
||||
|
||||
mPackageViewModel.checkData();
|
||||
|
||||
@ -22,6 +22,7 @@ import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.g00fy2.versioncompare.Version;
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.DeviceTokenUtils;
|
||||
import com.gh.common.util.DeviceUtils;
|
||||
@ -135,6 +136,7 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
HaloApp.getInstance().getMainExecutor().execute(() -> {
|
||||
Config.getGhzsSettings();
|
||||
|
||||
UsageStatsHelper.checkAndPostUsageStats();
|
||||
GameRepositoryHelper.getGameRepository(this);
|
||||
|
||||
@ -2,36 +2,21 @@ package com.gh.gamecenter.home
|
||||
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.text.SpannableStringBuilder
|
||||
import android.text.Spanned
|
||||
import android.text.style.RelativeSizeSpan
|
||||
import android.view.View
|
||||
import com.gh.base.BaseRecyclerViewHolder
|
||||
import com.gh.common.util.DisplayUtils
|
||||
import com.gh.common.util.RandomUtils
|
||||
import com.gh.common.util.toColor
|
||||
import com.gh.common.view.RoundStrokeBackgroundColorSpan
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.databinding.HomeGameItemBinding
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.halo.assistant.HaloApp
|
||||
|
||||
class HomeGameItemViewHolder(val binding: HomeGameItemBinding) : BaseRecyclerViewHolder<Any>(binding.root) {
|
||||
|
||||
fun bindGame(game: GameEntity) {
|
||||
binding.data = game
|
||||
|
||||
val firstTag = if (game.tagStyle.isNotEmpty()) " " + game.tagStyle[0].name + " " else ""
|
||||
val gameBrief = SpannableStringBuilder(firstTag + " " + game.brief)
|
||||
if (firstTag.isNotEmpty()) {
|
||||
val tagSpan = RoundStrokeBackgroundColorSpan(
|
||||
R.color.text_979A9F.toColor(),
|
||||
R.color.text_666666.toColor(),
|
||||
DisplayUtils.dip2px(1F),
|
||||
DisplayUtils.sp2px(HaloApp.getInstance().application, 9F))
|
||||
gameBrief.setSpan(RelativeSizeSpan(0.8f), 0, firstTag.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
gameBrief.setSpan(tagSpan, 0, firstTag.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
}
|
||||
binding.includeGame.gameTags.text = gameBrief
|
||||
binding.gameBrief.text = game.brief
|
||||
binding.gameTags.visibility = if (game.tagStyle.isNotEmpty()) {
|
||||
binding.gameTags.text = game.tagStyle[0].name
|
||||
View.VISIBLE
|
||||
} else View.GONE
|
||||
|
||||
val hierarchy = binding.gameImage.hierarchy
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user