Commit 89692725 authored by jyx's avatar jyx

代码优化

parent b087bc27
This diff is collapsed.
......@@ -6,6 +6,8 @@ import android.content.ComponentName;
import android.content.Context;
import android.text.TextUtils;
import com.duben.miniplaylet.utils.LogUtil;
import java.util.List;
import java.util.Stack;
......@@ -83,6 +85,21 @@ public class ActivityPageManager {
return null;
}
/**
* 是否包含指定类名的Activity
*
* @param clazz Activity.class
*/
public boolean containActivity(Class<?> clazz) {
for (Activity activity : mActivityStack) {
LogUtil.d("AAAAAAAA" + activity.getClass().getSimpleName());
if (activity.getClass().equals(clazz)) {
return true;
}
}
return false;
}
/**
* 结束当前Activity (堆栈中最后一个添加的)
*/
......@@ -178,4 +195,5 @@ public class ActivityPageManager {
}
return false;
}
}
\ No newline at end of file
package com.duben.miniplaylet.ui.activitys
import android.annotation.SuppressLint
import android.content.Intent
import android.os.Bundle
import android.view.KeyEvent
import android.view.View
......@@ -10,6 +11,7 @@ import com.duben.miniplaylet.ad.splash.SplashManager
import com.duben.miniplaylet.common.Constant
import com.duben.miniplaylet.common.Constant.PRIVACY_URL
import com.duben.miniplaylet.common.Constant.REGISTER_URL
import com.duben.miniplaylet.manager.ActivityPageManager
import com.duben.miniplaylet.manager.TrackManager
import com.duben.miniplaylet.ui.activitys.base.BaseActivity
import com.duben.miniplaylet.ui.widgets.CycleProgress
......@@ -41,7 +43,9 @@ class SplashActivity : BaseActivity() {
}
override fun initViewsAndEvents() {
if (!isTaskRoot) {
//点击Home键后再点击App图标,会回到原来的界面。今天重新打包后,但是在Debug模式下,一切正常,
// 但是把打完包的apk(Release)安装在其他手机上时,回到桌面后点击图标会重新打开启动页
finish()
......@@ -49,6 +53,13 @@ class SplashActivity : BaseActivity() {
}
mProgressBar = findViewById(R.id.progressBar)
// showPowerDialog()
}
override fun onResume() {
LogUtil.d("AAAAAAAAA isTaskRoot")
super.onResume()
isAdSuc = false
showPowerDialog()
}
......@@ -105,7 +116,8 @@ class SplashActivity : BaseActivity() {
mProgressBar!!.setCompleteNoAnim()
}
// 跳转广告
readyGoThenKill(SplashAdActivity::class.java)
// readyGoThenKill(SplashAdActivity::class.java)
readyGo(SplashAdActivity::class.java)
}
}
}
......@@ -140,7 +152,14 @@ class SplashActivity : BaseActivity() {
* 跳转到主页面
*/
private fun goToMainActivity() {
readyGoThenKill(MainActivity::class.java)
// readyGoThenKill(MainActivity::class.java)
if (ActivityPageManager.getInstance().containActivity(MainActivity::class.java)) {
LogUtil.d("AAAAAAAAAAAAAAA")
finish()
} else {
LogUtil.d("BBBBBBBBBBBB")
readyGo(MainActivity::class.java)
}
}
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
......
......@@ -8,6 +8,7 @@ import com.duben.miniplaylet.R
import com.duben.miniplaylet.ad.AdStatusListener
import com.duben.miniplaylet.ad.splash.SplashManager
import com.duben.miniplaylet.common.Constant
import com.duben.miniplaylet.manager.ActivityPageManager
import com.duben.miniplaylet.manager.LocalVedioManager
import com.duben.miniplaylet.manager.UserManager
import com.duben.miniplaylet.ui.activitys.base.BaseActivity
......@@ -95,7 +96,14 @@ class SplashAdActivity : BaseActivity() {
* 跳转到主页面
*/
private fun goToMainActivity() {
readyGoThenKill(MainActivity::class.java)
// readyGoThenKill(MainActivity::class.java)
if (ActivityPageManager.getInstance().containActivity(MainActivity::class.java)) {
LogUtil.d("AAAAAAAAAAAAAAA")
finish()
} else {
LogUtil.d("BBBBBBBBBBBB")
readyGo(MainActivity::class.java)
}
}
/**
......
......@@ -107,7 +107,7 @@ public class ForegroundOrBackground implements Application.ActivityLifecycleCall
AppConfig.alipayBackFalg = false;
}
} else {
activity.startActivity(new Intent(activity, SplashBackActivity.class));
// activity.startActivity(new Intent(activity, SplashBackActivity.class));
}
// }
}
......@@ -150,6 +150,8 @@ public class ForegroundOrBackground implements Application.ActivityLifecycleCall
e.printStackTrace();
}
LogUtil.d("AAAAAAAA remove --> " + activity.getClass());
ActivityPageManager.getInstance().removeActivity(activity);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment