diff --git a/app/src/main/java/com/gh/gamecenter/MainActivity.java b/app/src/main/java/com/gh/gamecenter/MainActivity.java index b896b4d1a2..1abf13aeee 100644 --- a/app/src/main/java/com/gh/gamecenter/MainActivity.java +++ b/app/src/main/java/com/gh/gamecenter/MainActivity.java @@ -214,6 +214,7 @@ public class MainActivity extends BaseActivity { ActivationHelper.sendActivationInfo(); // 第一次打开App删除模拟器游戏记录(不包括更新版本) if (HaloApp.getInstance().isBrandNewInstall) { + getTeenagerMode(); SimulatorGameManager.deleteAllSimulatorGame(); } } @@ -330,6 +331,33 @@ public class MainActivity extends BaseActivity { initWBSDK(); } + @SuppressLint("CheckResult") + private void getTeenagerMode() { + RetrofitManager.getInstance(HaloApp.getInstance().getApplication()) + .getApi().getTeenagerMode(HaloApp.getInstance().getGid()) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new BiResponse() { + @Override + public void onSuccess(ResponseBody data) { + try { + boolean preStatus = SPUtils.getBoolean(Constants.SP_TEENAGER_MODE); + JSONObject object = new JSONObject(data.string()); + boolean curStatus = "open".equals(object.getString("status")); + SPUtils.setBoolean(Constants.SP_TEENAGER_MODE, curStatus); + if (preStatus != curStatus) { + Intent intent = getMainIntent(MainActivity.this); + intent.putExtra(SHOW_AD, true); + finish(); + startActivity(intent); + } + } catch (Throwable e) { + e.printStackTrace(); + } + } + }); + } + //上传关注视频浏览记录 @SuppressLint("CheckResult") private void postAttentionVideoRecord() { diff --git a/app/src/main/java/com/gh/gamecenter/SplashScreenActivity.java b/app/src/main/java/com/gh/gamecenter/SplashScreenActivity.java index 75ade42c29..986a34be6b 100644 --- a/app/src/main/java/com/gh/gamecenter/SplashScreenActivity.java +++ b/app/src/main/java/com/gh/gamecenter/SplashScreenActivity.java @@ -44,7 +44,6 @@ import com.gh.download.DownloadManager; import com.gh.gamecenter.entity.AuthDialogEntity; import com.gh.gamecenter.entity.DeviceDialogEntity; import com.gh.gamecenter.entity.PrivacyPolicyEntity; -import com.gh.gamecenter.eventbus.EBTeenagerModelStatus; import com.gh.gamecenter.manager.FilterManager; import com.gh.gamecenter.retrofit.BiResponse; import com.gh.gamecenter.retrofit.Response; @@ -378,7 +377,6 @@ public class SplashScreenActivity extends BaseActivity { private void prefetchData() { AppExecutor.getIoExecutor().execute(() -> { - if (HaloApp.getInstance().isBrandNewInstall) getTeenagerMode(); Config.getGhzsSettings(); deviceDialogSetting(); getFilterDetailTags(); @@ -411,30 +409,6 @@ public class SplashScreenActivity extends BaseActivity { }); } - @SuppressLint("CheckResult") - private void getTeenagerMode() { - RetrofitManager.getInstance(HaloApp.getInstance().getApplication()) - .getApi().getTeenagerMode(HaloApp.getInstance().getGid()) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(new BiResponse() { - @Override - public void onSuccess(ResponseBody data) { - try { - boolean preStatus = SPUtils.getBoolean(Constants.SP_TEENAGER_MODE); - JSONObject object = new JSONObject(data.string()); - boolean curStatus = "open".equals(object.getString("status")); - SPUtils.setBoolean(Constants.SP_TEENAGER_MODE, curStatus); - if (preStatus != curStatus) { - EventBus.getDefault().post(new EBTeenagerModelStatus()); - } - } catch (Throwable e) { - e.printStackTrace(); - } - } - }); - } - @AfterPermissionGranted(REQUEST_PERMISSION_TAG) private void checkAndRequestPermission() { if (EasyPermissions.hasPermissions(this, mPermissions)) { diff --git a/app/src/main/java/com/gh/gamecenter/eventbus/EBTeenagerModelStatus.java b/app/src/main/java/com/gh/gamecenter/eventbus/EBTeenagerModelStatus.java deleted file mode 100644 index 2b4e87f35e..0000000000 --- a/app/src/main/java/com/gh/gamecenter/eventbus/EBTeenagerModelStatus.java +++ /dev/null @@ -1,3 +0,0 @@ -package com.gh.gamecenter.eventbus; - -public class EBTeenagerModelStatus { } diff --git a/app/src/main/java/com/gh/gamecenter/fragment/SearchToolbarFragment.java b/app/src/main/java/com/gh/gamecenter/fragment/SearchToolbarFragment.java index a7bc460c20..b4affab4a5 100644 --- a/app/src/main/java/com/gh/gamecenter/fragment/SearchToolbarFragment.java +++ b/app/src/main/java/com/gh/gamecenter/fragment/SearchToolbarFragment.java @@ -43,9 +43,9 @@ import com.gh.gamecenter.energy.EnergyCenterActivity; import com.gh.gamecenter.entity.GameUpdateEntity; import com.gh.gamecenter.eventbus.EBDownloadStatus; import com.gh.gamecenter.eventbus.EBReuse; -import com.gh.gamecenter.eventbus.EBTeenagerModelStatus; import com.gh.gamecenter.message.MessageUnreadViewModel; import com.gh.gamecenter.packagehelper.PackageViewModel; +import com.gh.gamecenter.teenagermode.TeenagerModeActivity; import com.halo.assistant.HaloApp; import org.greenrobot.eventbus.Subscribe; @@ -262,6 +262,7 @@ public class SearchToolbarFragment extends BaseLazyFragment implements View.OnCl mSearchRightView.setVisibility(View.GONE); } + mTeenagerModelView.setOnClickListener(this); mSearchHintTv.setOnClickListener(this); mSignView.setOnClickListener(this); mSearchRightView.setOnClickListener(this); @@ -320,6 +321,7 @@ public class SearchToolbarFragment extends BaseLazyFragment implements View.OnCl startActivity(EnergyCenterActivity.Companion.getIntent(requireContext())); break; case R.id.actionbar_teenager_model: + startActivity(TeenagerModeActivity.getIntent(requireContext())); break; } } @@ -341,11 +343,6 @@ public class SearchToolbarFragment extends BaseLazyFragment implements View.OnCl setDownloadHint(mPackageViewModel.getFilterSameUpdateLiveData().getValue()); } - @Subscribe(threadMode = ThreadMode.MAIN) - public void onEventMainThread(EBTeenagerModelStatus status) { - initActionBar(mCachedView); - } - private void setDownloadHint(List updateList) { String count = DownloadManager.getInstance(requireContext()).getDownloadOrUpdateCount(updateList); if (count != null) {