diff --git a/app/src/main/java/com/huanchengfly/tieba/post/fragments/MainForumListFragment.kt b/app/src/main/java/com/huanchengfly/tieba/post/fragments/MainForumListFragment.kt index ce961f8b..7ebe90f9 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/fragments/MainForumListFragment.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/fragments/MainForumListFragment.kt @@ -208,22 +208,28 @@ class MainForumListFragment : BaseFragment(), Refreshable, Toolbar.OnMenuItemCli } val workInfoLiveData = WorkManager.getInstance(attachContext).getWorkInfoByIdLiveData(id) - workInfoLiveData.observe(viewLifecycleOwner) { - if (it == null) { - workInfoLiveData.removeObservers(viewLifecycleOwner) - return@observe - } - if (it.progress.getBoolean(DATA_SUCCESS, false)) { - workInfoLiveData.removeObservers(viewLifecycleOwner) - } - if (DateTimeUtils.isToday( - it.progress.getLong( - DATA_TIMESTAMP, - System.currentTimeMillis() - ) - ) && it.progress.hasKeyWithValueOfType(DATA_SUCCESS) - ) { - okSignProgressData = it.progress + if (view != null) { + runCatching { + workInfoLiveData.observe(viewLifecycleOwner) { + runCatching { + if (it == null) { + workInfoLiveData.removeObservers(viewLifecycleOwner) + return@observe + } + if (it.progress.getBoolean(DATA_SUCCESS, false)) { + workInfoLiveData.removeObservers(viewLifecycleOwner) + } + } + if (DateTimeUtils.isToday( + it.progress.getLong( + DATA_TIMESTAMP, + System.currentTimeMillis() + ) + ) && it.progress.hasKeyWithValueOfType(DATA_SUCCESS) + ) { + okSignProgressData = it.progress + } + } } } } else {