feat: 重构首页弹窗显示逻辑
This commit is contained in:
@ -38,15 +38,13 @@ import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.content.res.AppCompatResources;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.lifecycle.ViewModelProviders;
|
||||
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.gh.ad.AdDelegateHelper;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.exposure.ExposureManager;
|
||||
import com.gh.common.filter.RegionSettingHelper;
|
||||
import com.gh.common.history.HistoryDatabase;
|
||||
import com.gh.common.history.HistoryHelper;
|
||||
@ -63,7 +61,6 @@ import com.gh.common.util.ErrorHelper;
|
||||
import com.gh.common.util.HomePluggableHelper;
|
||||
import com.gh.common.util.LogUtils;
|
||||
import com.gh.common.util.LunchType;
|
||||
import com.gh.common.util.NewFlatLogUtils;
|
||||
import com.gh.common.util.PackageInstaller;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.util.WechatBindHelper;
|
||||
@ -76,7 +73,6 @@ import com.gh.gamecenter.common.base.fragment.ToolbarFragment;
|
||||
import com.gh.gamecenter.common.constant.CommonConsts;
|
||||
import com.gh.gamecenter.common.constant.Constants;
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts;
|
||||
import com.gh.gamecenter.common.entity.LinkEntity;
|
||||
import com.gh.gamecenter.common.entity.NotificationUgc;
|
||||
import com.gh.gamecenter.common.entity.SuggestType;
|
||||
import com.gh.gamecenter.common.eventbus.EBNetworkState;
|
||||
@ -86,7 +82,6 @@ import com.gh.gamecenter.common.retrofit.BiResponse;
|
||||
import com.gh.gamecenter.common.retrofit.Response;
|
||||
import com.gh.gamecenter.common.utils.DialogHelper;
|
||||
import com.gh.gamecenter.common.utils.ExtensionsKt;
|
||||
import com.gh.gamecenter.common.utils.ImageUtils;
|
||||
import com.gh.gamecenter.common.utils.NotificationHelper;
|
||||
import com.gh.gamecenter.common.utils.ShareUtils;
|
||||
import com.gh.gamecenter.core.AppExecutor;
|
||||
@ -96,17 +91,14 @@ import com.gh.gamecenter.core.utils.GsonUtils;
|
||||
import com.gh.gamecenter.core.utils.MtaHelper;
|
||||
import com.gh.gamecenter.core.utils.SPUtils;
|
||||
import com.gh.gamecenter.core.utils.SentryHelper;
|
||||
import com.gh.gamecenter.core.utils.TimeUtils;
|
||||
import com.gh.gamecenter.core.utils.ToastUtils;
|
||||
import com.gh.gamecenter.core.utils.UrlFilterUtils;
|
||||
import com.gh.gamecenter.entity.StartupAdEntity;
|
||||
import com.gh.gamecenter.eventbus.EBSkip;
|
||||
import com.gh.gamecenter.feature.entity.GameEntity;
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent;
|
||||
import com.gh.gamecenter.feature.exposure.ExposureSource;
|
||||
import com.gh.gamecenter.feature.exposure.ExposureType;
|
||||
import com.gh.gamecenter.feature.utils.PlatformUtils;
|
||||
import com.gh.gamecenter.fragment.MainWrapperFragment;
|
||||
import com.gh.gamecenter.fragment.MainWrapperViewModel;
|
||||
import com.gh.gamecenter.home.skip.PackageSkipActivity;
|
||||
import com.gh.gamecenter.login.user.UserManager;
|
||||
import com.gh.gamecenter.login.utils.QuickLoginHelper;
|
||||
@ -171,6 +163,8 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
private PackageViewModel mPackageViewModel;
|
||||
|
||||
private MainWrapperViewModel mMainWrapperViewModel;
|
||||
|
||||
private MainWrapperFragment mMainWrapperFragment;
|
||||
|
||||
// 黄壮华 按连续按返回键两次才退出应用
|
||||
@ -187,6 +181,9 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
HaloApp.getInstance().isAlreadyUpAndRunning = true;
|
||||
|
||||
mMainWrapperViewModel = new ViewModelProvider(this, new MainWrapperViewModel.Factory(HaloApp.getInstance()))
|
||||
.get(MainWrapperViewModel.class);
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
setStatusBarColor(Color.TRANSPARENT);
|
||||
|
||||
@ -339,8 +336,15 @@ public class MainActivity extends BaseActivity {
|
||||
// 检查是否需要触发 XAPK 安装
|
||||
AppExecutor.getUiExecutor().executeWithDelay(this::resumeXapkInstallIfNeeded, 150);
|
||||
|
||||
mMainWrapperViewModel.requestAllDialogData();
|
||||
|
||||
// TODO 去掉一键登录?
|
||||
QuickLoginHelper.getPhoneInfo();
|
||||
|
||||
// TODO 搞清楚为什么这里要获取微信相关配置
|
||||
WechatBindHelper.getWechatConfig(null);
|
||||
|
||||
// TODO 根据用户是否安装微博来确定是否需要初始化微博 SDK
|
||||
initWBSDK();
|
||||
CertificationSwitchHelper.getCertificationSwitch();
|
||||
}
|
||||
@ -580,17 +584,10 @@ public class MainActivity extends BaseActivity {
|
||||
ExtensionsKt.removeFromParent(startSdkAdContainer);
|
||||
AdDelegateHelper.INSTANCE.cancelSplashAd(this);
|
||||
}
|
||||
checkDialog();
|
||||
}
|
||||
|
||||
private void checkDialog() {
|
||||
// 检查通知权限
|
||||
checkNotificationPermission();
|
||||
// 检查助手更新
|
||||
AppExecutor.getIoExecutor().execute(() -> {
|
||||
UpdateManager updateManager = UpdateManager.getInstance(this);
|
||||
updateManager.checkUpdate(true, null);
|
||||
updateManager.setDismissCallback(mMainWrapperFragment::getDialog);
|
||||
// 通知优先级高的弹窗可以显示了
|
||||
AppExecutor.getUiExecutor().execute(() -> {
|
||||
mMainWrapperFragment.showDialog();
|
||||
});
|
||||
}
|
||||
|
||||
@ -797,13 +794,6 @@ public class MainActivity extends BaseActivity {
|
||||
});
|
||||
}
|
||||
|
||||
private void checkNotificationPermission() {
|
||||
// 仅登录后再启动光环时请求一次权限
|
||||
if (UserManager.getInstance().isLoggedIn()) {
|
||||
NotificationHelper.showNotificationHintDialog(NotificationUgc.LOGIN, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0 && !mMainWrapperFragment.onHandleBackPressed()) {
|
||||
|
||||
Reference in New Issue
Block a user