初始化开发工具库与全局上下文 应用启动时必须调用,传入 Activity、Application 等 Context 均可。 @param context Context
(final Context context)
| 82 | * @param context {@link Context} |
| 83 | */ |
| 84 | public static void init(final Context context) { |
| 85 | if (context == null) return; |
| 86 | |
| 87 | // 初始化全局 Context |
| 88 | initContext(context); |
| 89 | // 初始化全局 Application |
| 90 | initApplication(context); |
| 91 | // 注册 Activity 生命周期监听 |
| 92 | getLifecycleAssist().registerActivityLifecycleCallbacks(); |
| 93 | |
| 94 | // ================= |
| 95 | // = 初始化工具类相关 = |
| 96 | // ================= |
| 97 | |
| 98 | // 初始化 Record |
| 99 | FileRecordUtils.setRecordInsert(new AppRecordInsert(false)); |
| 100 | |
| 101 | // ============ |
| 102 | // = Java Log = |
| 103 | // ============ |
| 104 | |
| 105 | // 设置 Java 模块日志信息在 logcat 输出 |
| 106 | JCLogUtils.setPrint((logType, tag, message) -> { |
| 107 | switch (logType) { |
| 108 | case JCLogUtils.INFO: |
| 109 | LogPrintUtils.iTag(tag, message); |
| 110 | break; |
| 111 | case JCLogUtils.ERROR: |
| 112 | LogPrintUtils.eTag(tag, message); |
| 113 | break; |
| 114 | case JCLogUtils.DEBUG: |
| 115 | default: |
| 116 | LogPrintUtils.dTag(tag, message); |
| 117 | break; |
| 118 | } |
| 119 | }); |
| 120 | } |
| 121 | |
| 122 | /** |
| 123 | * 初始化全局 Context |
no test coverage detected