fix: 修复主页闪退

This commit is contained in:
HuanCheng65 2022-09-02 17:10:02 +08:00
parent 89d6497831
commit f21e66fab6
No known key found for this signature in database
GPG Key ID: E9031EF91A805148
1 changed files with 22 additions and 16 deletions

View File

@ -208,22 +208,28 @@ class MainForumListFragment : BaseFragment(), Refreshable, Toolbar.OnMenuItemCli
} }
val workInfoLiveData = val workInfoLiveData =
WorkManager.getInstance(attachContext).getWorkInfoByIdLiveData(id) WorkManager.getInstance(attachContext).getWorkInfoByIdLiveData(id)
workInfoLiveData.observe(viewLifecycleOwner) { if (view != null) {
if (it == null) { runCatching {
workInfoLiveData.removeObservers(viewLifecycleOwner) workInfoLiveData.observe(viewLifecycleOwner) {
return@observe runCatching {
} if (it == null) {
if (it.progress.getBoolean(DATA_SUCCESS, false)) { workInfoLiveData.removeObservers(viewLifecycleOwner)
workInfoLiveData.removeObservers(viewLifecycleOwner) return@observe
} }
if (DateTimeUtils.isToday( if (it.progress.getBoolean(DATA_SUCCESS, false)) {
it.progress.getLong( workInfoLiveData.removeObservers(viewLifecycleOwner)
DATA_TIMESTAMP, }
System.currentTimeMillis() }
) if (DateTimeUtils.isToday(
) && it.progress.hasKeyWithValueOfType<Boolean>(DATA_SUCCESS) it.progress.getLong(
) { DATA_TIMESTAMP,
okSignProgressData = it.progress System.currentTimeMillis()
)
) && it.progress.hasKeyWithValueOfType<Boolean>(DATA_SUCCESS)
) {
okSignProgressData = it.progress
}
}
} }
} }
} else { } else {