mirror of
https://github.com/fankes/MIUINativeNotifyIcon.git
synced 2025-09-05 10:15:31 +08:00
Fix Activity destroy non-null unregister bug
This commit is contained in:
@@ -43,13 +43,13 @@ class NotifyIconRuleUpdateActivity : Activity() {
|
||||
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_NAVIGATION)
|
||||
/** 注册 */
|
||||
SystemUITool.register(context = this)
|
||||
/** 检测运行状态 */
|
||||
if (BaseActivity.isMainThreadRunning) {
|
||||
finish()
|
||||
return
|
||||
}
|
||||
/** 注册 */
|
||||
SystemUITool.register(context = this)
|
||||
/** 拉取云端数据 */
|
||||
IconRuleManagerTool.sync(appContext) {
|
||||
/** 刷新系统界面 */
|
||||
|
@@ -47,7 +47,7 @@ object SystemUITool {
|
||||
* 注册广播
|
||||
* @param context 实例
|
||||
*/
|
||||
fun register(context: Context) {
|
||||
fun register(context: Context) = runInSafe {
|
||||
/** 注册广播检查模块激活状态 */
|
||||
context.registerReceiver(moduleHandlerReceiver, IntentFilter().apply { addAction(Const.ACTION_MODULE_HANDLER_RECEIVER) })
|
||||
/** 注册广播通知系统界面改变 */
|
||||
@@ -58,7 +58,7 @@ object SystemUITool {
|
||||
* 取消注册广播
|
||||
* @param context 实例
|
||||
*/
|
||||
fun unregister(context: Context) {
|
||||
fun unregister(context: Context) = runInSafe {
|
||||
context.unregisterReceiver(moduleHandlerReceiver)
|
||||
context.unregisterReceiver(remindHandlerReceiver)
|
||||
}
|
||||
|
Reference in New Issue
Block a user