孩子们这次真修了
修复从后台进入前台且Activity被系统回收时导致的书籍未加载和NPE问题
This commit is contained in:
@@ -253,7 +253,7 @@ class ReadBookActivity : BaseReadBookActivity(),
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
if (AppConfig.sharedElementEnterTransitionEnable && savedInstanceState == null) {
|
||||
if (AppConfig.sharedElementEnterTransitionEnable) {
|
||||
|
||||
val transform = MaterialContainerTransform().apply {
|
||||
addTarget(binding.rootView)
|
||||
@@ -280,8 +280,7 @@ class ReadBookActivity : BaseReadBookActivity(),
|
||||
override fun onTransitionResume(transition: Transition) {}
|
||||
})
|
||||
}
|
||||
} else {
|
||||
loadBook()
|
||||
|
||||
}
|
||||
window.sharedElementReturnTransition =
|
||||
MaterialSharedAxis(MaterialSharedAxis.X, true).apply {
|
||||
@@ -289,6 +288,10 @@ class ReadBookActivity : BaseReadBookActivity(),
|
||||
}
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
if (savedInstanceState != null && AppConfig.delayBookLoadEnable) {
|
||||
loadBook()
|
||||
}
|
||||
|
||||
if (AppConfig.sharedElementEnterTransitionEnable)
|
||||
binding.rootView.transitionName = intent.getStringExtra("transitionName")
|
||||
|
||||
@@ -325,6 +328,13 @@ class ReadBookActivity : BaseReadBookActivity(),
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPostCreate(savedInstanceState: Bundle?) {
|
||||
super.onPostCreate(savedInstanceState)
|
||||
if (!AppConfig.delayBookLoadEnable || !AppConfig.sharedElementEnterTransitionEnable) {
|
||||
loadBook()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onNewIntent(intent: Intent) {
|
||||
super.onNewIntent(intent)
|
||||
viewModel.initData(intent)
|
||||
@@ -440,7 +450,7 @@ class ReadBookActivity : BaseReadBookActivity(),
|
||||
lifecycleScope.launch(Dispatchers.Default) {
|
||||
viewModel.initReadBookConfig(intent)
|
||||
viewModel.initData(intent)
|
||||
withContext(Dispatchers.Main) {
|
||||
withContext(Main) {
|
||||
binding.readView.initAfterTransition()
|
||||
justInitData = true
|
||||
}
|
||||
|
||||
@@ -236,9 +236,10 @@ class ReadView(context: Context, attrs: AttributeSet) :
|
||||
removeCallbacks(longPressRunnable)
|
||||
if (!pressDown) return true
|
||||
pressDown = false
|
||||
if (!pageDelegate!!.isMoved && !isMove) {
|
||||
if (pageDelegate?.isMoved == false && !isMove) {
|
||||
if (!longPressed && !pressOnTextSelected) {
|
||||
if (!curPage.onClick(startX, startY)) {
|
||||
val handled = curPage.onClick(startX, startY)
|
||||
if (!handled) {
|
||||
onSingleTapUp()
|
||||
}
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user