Fix Activity destroy non-null unregister bug

This commit is contained in:
2022-05-09 00:56:26 +08:00
parent 826805c552
commit 02f8852ab0
2 changed files with 4 additions and 4 deletions

View File

@@ -43,13 +43,13 @@ class NotifyIconRuleUpdateActivity : Activity() {
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_STABLE View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
window?.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS) window?.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
window?.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION) window?.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION)
/** 注册 */
SystemUITool.register(context = this)
/** 检测运行状态 */ /** 检测运行状态 */
if (BaseActivity.isMainThreadRunning) { if (BaseActivity.isMainThreadRunning) {
finish() finish()
return return
} }
/** 注册 */
SystemUITool.register(context = this)
/** 拉取云端数据 */ /** 拉取云端数据 */
IconRuleManagerTool.sync(appContext) { IconRuleManagerTool.sync(appContext) {
/** 刷新系统界面 */ /** 刷新系统界面 */

View File

@@ -47,7 +47,7 @@ object SystemUITool {
* 注册广播 * 注册广播
* @param context 实例 * @param context 实例
*/ */
fun register(context: Context) { fun register(context: Context) = runInSafe {
/** 注册广播检查模块激活状态 */ /** 注册广播检查模块激活状态 */
context.registerReceiver(moduleHandlerReceiver, IntentFilter().apply { addAction(Const.ACTION_MODULE_HANDLER_RECEIVER) }) context.registerReceiver(moduleHandlerReceiver, IntentFilter().apply { addAction(Const.ACTION_MODULE_HANDLER_RECEIVER) })
/** 注册广播通知系统界面改变 */ /** 注册广播通知系统界面改变 */
@@ -58,7 +58,7 @@ object SystemUITool {
* 取消注册广播 * 取消注册广播
* @param context 实例 * @param context 实例
*/ */
fun unregister(context: Context) { fun unregister(context: Context) = runInSafe {
context.unregisterReceiver(moduleHandlerReceiver) context.unregisterReceiver(moduleHandlerReceiver)
context.unregisterReceiver(remindHandlerReceiver) context.unregisterReceiver(remindHandlerReceiver)
} }