diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/notice/NoticeCheckDialog.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/notice/NoticeCheckDialog.kt index 467e6c1e12..b97bed7717 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/notice/NoticeCheckDialog.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/notice/NoticeCheckDialog.kt @@ -7,9 +7,11 @@ import android.util.Log import android.view.View import android.widget.ImageView import android.widget.TextView +import androidx.lifecycle.LifecycleObserver import com.mogo.eagle.core.data.notice.NoticeNormalData import com.mogo.eagle.core.function.hmi.R import com.mogo.eagle.core.widget.media.video.NoticeSimpleVideoPlayer +import com.mogo.module.common.MogoApisHandler import com.mogo.module.common.dialog.BaseFloatDialog import com.mogo.service.IMogoServiceApis import com.mogo.service.statusmanager.IMogoStatusChangedListener @@ -25,7 +27,7 @@ import com.shuyu.gsyvideoplayer.listener.VideoAllCallBack * @brief 点击查看对话框 * @author lixiaopeng */ -class NoticeCheckDialog(context: Context) : BaseFloatDialog(context) { +class NoticeCheckDialog(context: Context) : BaseFloatDialog(context), LifecycleObserver{ private val TAG = "NoticeCheckDialog" private var pushCheckClose: ImageView? = null @@ -39,7 +41,7 @@ class NoticeCheckDialog(context: Context) : BaseFloatDialog(context) { private var mVideoUrl: String = "" private var playErrorImageView: ImageView? = null private var connectTextView: TextView? = null - private val mServiceApis: IMogoServiceApis? = null + private var mServiceApis: IMogoServiceApis? = null private val statusChangedListenerForCheckNotice = IMogoStatusChangedListener { descriptor, isTrue -> if (descriptor == StatusDescriptor.MAIN_PAGE_IS_BACKGROUND) { dismiss() @@ -49,6 +51,7 @@ class NoticeCheckDialog(context: Context) : BaseFloatDialog(context) { init { setContentView(R.layout.notice_dialog_check_with_accessory) setCanceledOnTouchOutside(true) + pushCheckClose = findViewById(R.id.module_push_dialog_close) pushCheckTitle = findViewById(R.id.module_push_dialog_acc_title) pushCheckContent = findViewById(R.id.module_push_dialog_bottom_title) @@ -88,11 +91,9 @@ class NoticeCheckDialog(context: Context) : BaseFloatDialog(context) { pushVideo!!.visibility = View.VISIBLE playVideo(mVideoUrl) } - mServiceApis?.statusManagerApi?.registerStatusChangedListener( - TAG, - StatusDescriptor.MAIN_PAGE_IS_BACKGROUND, - statusChangedListenerForCheckNotice - ) + + mServiceApis = MogoApisHandler.getInstance().apis + mServiceApis?.getStatusManagerApi()?.registerStatusChangedListener(TAG, StatusDescriptor.MAIN_PAGE_IS_BACKGROUND, statusChangedListenerForCheckNotice) }