Files
MoGoEagleEye/app/src/main/java/com/mogo/launcher/MogoApplication.java
2022-09-22 10:20:12 +08:00

76 lines
2.6 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package com.mogo.launcher;
import com.mogo.eagle.core.function.main.MainMoGoApplication;
import android.content.Context;
import androidx.annotation.NonNull;
import com.mogo.eagle.core.utilcode.mogo.logger.LogLevel;
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
import com.mogo.launcher.crash.CrashSystem;
import com.mogo.thread.ext.core.ThreadManager;
import com.mogo.thread.ext.core.config.ThreadConfig;
import java.util.concurrent.ThreadPoolExecutor;
/**
* @author congtaowang
* @since 2019-12-18
* <p>
* Launcher application
*/
public class MogoApplication extends MainMoGoApplication {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
ThreadConfig.Builder builder = new ThreadConfig.Builder().listener(new ThreadConfig.TaskExecuteListener() {
@Override
public boolean isEnabled() {
return true; // 如果返回true会有后续的回调如果返回false, 不会有后续的回调
}
@Override
public void onExecutorBefore(@NonNull Runnable runnable, @NonNull ThreadConfig.TaskType type) {
//每个任务执行前回调
// if (type == ThreadConfig.TaskType.HandlerThread) {
//
//
// }
}
@Override
public void onExecutorAfter(@NonNull Runnable runnable, @NonNull ThreadConfig.TaskType type) {
//每个任务执行后回调
}
/**
* @param core 线程池的核心数
* @param max 线程池的最大线程数
* @param active 线程池正在活跃的任务数
* @param completed 线程池已完成的任务数
*/
@Override
public void onExecutorStateChanged(@NonNull ThreadPoolExecutor pool, int core, int max, int active, long completed) {
//线程池在执行过程,状态变化回调
//Log.d("POOL", "core:" + core + ";max:" + max + ";active:" + active + ";completed:" + completed);
}
});
builder.loggable(false);
ThreadManager.INSTANCE.init(builder);
}
@Override
protected void initCrashConfig() {
CrashSystem crashSystem = CrashSystem.getInstance(this);
crashSystem.init();
//设置debug模式日志不上传
crashSystem.setDebug(BuildConfig.DEBUG);
}
@Override
protected void initLogConfig() {
super.initLogConfig();
Logger.init(BuildConfig.DEBUG ? LogLevel.DEBUG : LogLevel.OFF);
}
}