Commit 6824b0f8 authored by jyx's avatar jyx

代码优化

parent 80bdeaf4
......@@ -36,6 +36,7 @@ import com.mints.flowbox.manager.wifi.WifiDataManager;
import com.mints.flowbox.net.LoanService;
import com.mints.flowbox.ui.activitys.keepalive.TriggerActivity;
import com.mints.flowbox.utils.ForegroundOrBackground;
import com.mints.flowbox.utils.LogUtil;
import com.mints.flowbox.utils.SystemUtils;
import com.mints.flowbox.utils.keepalive.ScreenLockerUtils;
import com.module.legacy.oreo.RegisterJobUtils;
......@@ -215,9 +216,10 @@ public class MintsApplication extends BaseApp {
@Override
public void onScreenOff() {
// if (!ScreenLockerUtils.INSTANCE.canShowScreenLocker(mContext)) {
// return;
// }
if (!ScreenLockerUtils.INSTANCE.canShowScreenLocker(mContext)) {
return;
}
if (WifiDataManager.INSTANCE.getLockOn()) {
OutAppRouter.INSTANCE.showScreenActivity();
}
......@@ -257,7 +259,6 @@ public class MintsApplication extends BaseApp {
// });
// 监听电话状态
PhoneWatch.getInstance(this).begin(new PhoneWatch.PhoneStateListener() {
@Override
public void onIdle(String phoneNum, int time) {
......
......@@ -131,6 +131,10 @@ public class AlarmManager implements WeakHandler.IHandler {
* 展示定时页面
*/
private void showTimingActivity() {
if (ForegroundOrBackground.isForeground2() || ScreenLockerUtils.INSTANCE.canShowScreenLocker(MintsApplication.getContext())) {
return;
}
if (currentType > 5) {
currentType = 0;
}
......@@ -139,7 +143,7 @@ public class AlarmManager implements WeakHandler.IHandler {
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION);
intent.putExtra(TransparentActivity.TIMING_TYPE, currentType++);
if (PhoneBrandUtils.isLockScreenProtected()) {
IntentUtils.startActivity(ForegroundOrBackground.getMain_activity(), intent);
IntentUtils.startActivity(intent);
} else {
IntentUtils.startActivity2(intent);
}
......
......@@ -44,7 +44,7 @@ object OutAppRouter {
intent.putExtra(ApkActivity.APK_PKG_NAME, pkgName)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_NO_ANIMATION
if (PhoneBrandUtils.isLockScreenProtected()) {
IntentUtils.startActivity(ForegroundOrBackground.getMain_activity(), intent)
IntentUtils.startActivity(intent)
} else {
IntentUtils.startActivity2(intent)
}
......@@ -64,12 +64,12 @@ object OutAppRouter {
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_NO_ANIMATION
if (PhoneBrandUtils.isHuaweiHonor()) {
IntentUtils.startActivity(ForegroundOrBackground.getMain_activity(), intent)
IntentUtils.startActivity(intent)
return
}
if (PhoneBrandUtils.isLockScreenProtected()) {
IntentUtils.startActivity(ForegroundOrBackground.getMain_activity(), intent)
IntentUtils.startActivity(intent)
} else {
IntentUtils.startActivity2(intent)
}
......@@ -122,7 +122,7 @@ object OutAppRouter {
intent.putExtra(TriggerActivity.CALL_PHONE_NUM, phone)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_NO_ANIMATION
if (PhoneBrandUtils.isLockScreenProtected()) {
IntentUtils.startActivity(ForegroundOrBackground.getMain_activity(), intent)
IntentUtils.startActivity(intent)
} else {
IntentUtils.startActivity2(intent)
}
......@@ -156,7 +156,7 @@ object OutAppRouter {
intent.putExtra(TriggerActivity.TRIGGER_TYPE, realType)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_NO_ANIMATION
if (PhoneBrandUtils.isLockScreenProtected()) {
IntentUtils.startActivity(ForegroundOrBackground.getMain_activity(), intent)
IntentUtils.startActivity(intent)
} else {
IntentUtils.startActivity2(intent)
}
......
......@@ -6,7 +6,6 @@ import android.content.Context
import android.graphics.Color
import android.os.Build
import android.os.Bundle
import android.util.Log
import android.view.View
import android.view.WindowManager
import android.view.animation.Animation
......@@ -24,12 +23,12 @@ import com.mints.flowbox.ui.adapter.clean.CleanExpandAdapter
import com.mints.flowbox.ui.adapter.clean.ExpandInfo
import com.mints.flowbox.ui.adapter.clean.ExpandInfo.ChildInfo
import com.mints.flowbox.ui.widgets.seekbar.BubbleUtils
import com.mints.flowbox.utils.CleanRDataUtil
import com.mints.flowbox.utils.FileUtils
import com.mints.flowbox.utils.SpanUtils
import kotlinx.android.synthetic.main.activity_clean.*
import kotlinx.android.synthetic.main.header_layout.*
import kotlinx.android.synthetic.main.view_title.*
import java.lang.Exception
import java.util.*
/**
......@@ -491,12 +490,16 @@ class CleanActivity : BaseActivity(), View.OnClickListener {
/** 清理内存 */
private fun cleaningOperation(ctx: Context, list: List<ChildInfo>) {
try {
val am = ctx.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
for (childInfo in list) {
if (childInfo.getName() != Constant.MINTS_PKG_NAME) {
if (childInfo.pkgName != Constant.MINTS_PKG_NAME) {
am.killBackgroundProcesses(childInfo.pkgName)
}
}
} catch (e: Exception) {
e.printStackTrace()
}
}
}
......@@ -64,10 +64,15 @@ public class ForegroundOrBackground implements Application.ActivityLifecycleCall
}
public static Activity getMain_activity() {
try {
if (main_activity.get() == null) {
return app_activity.get();
}
return main_activity.get();
} catch (NullPointerException e) {
e.printStackTrace();
return null;
}
}
@Override
......
......@@ -27,10 +27,12 @@ public class IntentUtils {
public static final String TAG = "IntentUtils";
public static void startActivity2(Intent intent) {
if (PhoneBrandUtils.isHuaweiHonor()){
startActivity(ForegroundOrBackground.getMain_activity(),intent);
if (PhoneBrandUtils.isHuaweiHonor()) {
if (ForegroundOrBackground.getMain_activity() != null) {
startActivity(intent);
return;
}
}
try {
ActivityManagerProxy.INSTANCE.bringToFront(new BringToFrontListener() {
@Override
......@@ -47,14 +49,15 @@ public class IntentUtils {
}
}
public static void startActivity(Activity activity, Intent intent) {
try {
public static void startActivity(Intent intent) {
if (ForegroundOrBackground.getMain_activity() != null) {
Activity activity = ForegroundOrBackground.getMain_activity();
moveToFront(activity);
activity.startActivity(intent);
activity.moveTaskToBack(true);
} catch (Exception e) {
e.printStackTrace();
return;
}
startActivity2(intent);
}
public static Boolean isRunningForeground(Activity activity) {
......
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