2025-09-24 17:19:02 +08:00
|
|
|
|
package com.jdf.myyuliao;
|
2025-09-22 18:56:13 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
|
import android.os.Handler;
|
|
|
|
|
|
import android.os.PersistableBundle;
|
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.android.arouter.launcher.ARouter;
|
2025-09-24 17:19:02 +08:00
|
|
|
|
import com.jdf.myyuliao.databinding.ActivityLaunchPageBinding;
|
2025-09-22 18:56:13 +08:00
|
|
|
|
import com.xscm.modulelogin.activity.ImproveInfoActivity;
|
|
|
|
|
|
import com.xscm.moduleutil.activity.BaseAppCompatActivity;
|
2025-10-10 09:10:42 +08:00
|
|
|
|
import com.xscm.moduleutil.activity.WebViewActivity;
|
2025-09-22 18:56:13 +08:00
|
|
|
|
import com.xscm.moduleutil.base.AppStateListener;
|
|
|
|
|
|
import com.xscm.moduleutil.base.AppStateManager;
|
|
|
|
|
|
import com.xscm.moduleutil.base.CommonAppContext;
|
|
|
|
|
|
import com.xscm.moduleutil.dialog.PolicyDialog;
|
|
|
|
|
|
import com.xscm.moduleutil.utils.ARouteConstants;
|
|
|
|
|
|
import com.xscm.moduleutil.utils.SpUtil;
|
|
|
|
|
|
|
|
|
|
|
|
public class LaunchPageActivity extends BaseAppCompatActivity<ActivityLaunchPageBinding> {
|
|
|
|
|
|
private Handler handler;
|
|
|
|
|
|
private PolicyDialog policyDialog;
|
|
|
|
|
|
private AppStateListener appStateListener;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void onCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) {
|
|
|
|
|
|
super.onCreate(savedInstanceState, persistentState);
|
|
|
|
|
|
|
|
|
|
|
|
// 获取Application实例并设置监听器
|
|
|
|
|
|
CommonAppContext app = (CommonAppContext) getApplication();
|
|
|
|
|
|
appStateListener = AppStateManager.getInstance();
|
|
|
|
|
|
app.setAppStateListener(appStateListener);
|
|
|
|
|
|
|
|
|
|
|
|
if (!isTaskRoot()) {
|
|
|
|
|
|
|
|
|
|
|
|
if (SpUtil.getUnderagePassword() != null && !SpUtil.getUnderagePassword().isEmpty()) {
|
2025-10-10 09:10:42 +08:00
|
|
|
|
// ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url() + "/web/index.html#/pages/feedback/teenage?id=" + SpUtil.getToken())
|
|
|
|
|
|
// .withString("type", "1").navigation();//type==1:青少年模式
|
|
|
|
|
|
|
|
|
|
|
|
Intent intent = new Intent(this, WebViewActivity.class);
|
|
|
|
|
|
intent.putExtra("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url() + "/web/index.html#/pages/feedback/teenage?id=" + SpUtil.getToken());
|
|
|
|
|
|
intent.putExtra("title", "1");
|
|
|
|
|
|
startActivity(intent);
|
2025-09-22 18:56:13 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
// 如果没有设置青少年模式,应该导航到首页
|
|
|
|
|
|
try {
|
|
|
|
|
|
ARouter.getInstance().build(ARouteConstants.ME).navigation();
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
Log.e("LaunchPageActivity", "导航到首页失败", e);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
finish();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
// if (shouldRestoreRoom()) {
|
|
|
|
|
|
// ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("form", "首页").withString("roomId", CommonAppContext.getInstance().playId).navigation();
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private boolean shouldRestoreRoom() {
|
|
|
|
|
|
// 检查是否应该恢复房间:
|
|
|
|
|
|
// 1. 应用有正在播放的房间
|
|
|
|
|
|
// 2. 应用应该显示房间
|
|
|
|
|
|
// 3. 应用是从后台恢复的(通过检查 CommonAppContext 状态)
|
|
|
|
|
|
return CommonAppContext.getInstance().isPlaying
|
|
|
|
|
|
&& CommonAppContext.getInstance().isShow;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void initData() {
|
|
|
|
|
|
handler = new Handler();
|
|
|
|
|
|
// 定义一个Runnable
|
|
|
|
|
|
Runnable runnable = new Runnable() {
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void run() {
|
|
|
|
|
|
initLogin();
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
if (SpUtil.isAgreePolicy()) {
|
|
|
|
|
|
initLogin();
|
|
|
|
|
|
// //延迟1.5秒执行
|
|
|
|
|
|
// handler.postDelayed(runnable, 2500);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
policyDialog = new PolicyDialog(this);
|
|
|
|
|
|
policyDialog.setCancelable(false);
|
|
|
|
|
|
policyDialog.setCanceledOnTouchOutside(false);
|
|
|
|
|
|
policyDialog.setPolicyClickListener(new PolicyDialog.PolicyClickListener() {
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void policyAgree() {
|
|
|
|
|
|
SpUtil.completeAgreePolicy();
|
|
|
|
|
|
// CommonAppContext.getInstance().initialization();
|
|
|
|
|
|
initLogin();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void policyExit() {
|
|
|
|
|
|
finish();
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
policyDialog.show();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void onDestroy() {
|
|
|
|
|
|
// 如果 PolicyDialog 仍在显示,则 dismiss 它
|
|
|
|
|
|
if (policyDialog != null && policyDialog.isShowing()) {
|
|
|
|
|
|
policyDialog.dismiss();
|
|
|
|
|
|
policyDialog = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 移除所有待处理的回调以防止内存泄漏
|
|
|
|
|
|
if (handler != null) {
|
|
|
|
|
|
handler.removeCallbacksAndMessages(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
super.onDestroy();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void initView() {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void initLogin() {
|
|
|
|
|
|
// 在启动新 Activity 前先关闭对话框
|
|
|
|
|
|
if (policyDialog != null && policyDialog.isShowing()) {
|
|
|
|
|
|
policyDialog.dismiss();
|
|
|
|
|
|
policyDialog = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
startActivity(new Intent(this, PasswordLoginActivity.class));
|
|
|
|
|
|
finish();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected int getLayoutId() {
|
|
|
|
|
|
return R.layout.activity_launch_page;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
if (!isTaskRoot()) {
|
|
|
|
|
|
finish();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|