|
|
@@ -11,7 +11,6 @@ import androidx.appcompat.widget.SearchView
|
|
|
import androidx.core.app.ActivityOptionsCompat
|
|
|
import androidx.core.view.ViewCompat
|
|
|
import androidx.core.view.WindowInsetsCompat
|
|
|
-import androidx.core.view.doOnPreDraw
|
|
|
import androidx.core.view.isGone
|
|
|
import androidx.lifecycle.Lifecycle
|
|
|
import androidx.lifecycle.lifecycleScope
|
|
|
@@ -52,7 +51,6 @@ import io.legado.app.utils.showDialogFragment
|
|
|
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
|
|
import kotlinx.coroutines.Dispatchers
|
|
|
import kotlinx.coroutines.Job
|
|
|
-import kotlinx.coroutines.delay
|
|
|
import kotlinx.coroutines.flow.catch
|
|
|
import kotlinx.coroutines.flow.conflate
|
|
|
import kotlinx.coroutines.flow.flowOn
|
|
|
@@ -120,10 +118,6 @@ class BookshelfFragment2() : BaseBookshelfFragment(R.layout.fragment_bookshelf2)
|
|
|
|
|
|
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
|
|
|
setSupportToolbar(binding.topBar)
|
|
|
- postponeEnterTransition()
|
|
|
- view.doOnPreDraw {
|
|
|
- startPostponedEnterTransition()
|
|
|
- }
|
|
|
initRecyclerView()
|
|
|
initBookGroupData()
|
|
|
initAllBooksData()
|
|
|
@@ -305,11 +299,10 @@ class BookshelfFragment2() : BaseBookshelfFragment(R.layout.fragment_bookshelf2)
|
|
|
).catch {
|
|
|
AppLog.put("书架更新出错", it)
|
|
|
}.conflate().flowOn(Dispatchers.Default).collect { list ->
|
|
|
- if (view == null) return@collect
|
|
|
- binding.emptyView.isGone = list.isNotEmpty()
|
|
|
- binding.refreshLayout.isEnabled = enableRefresh && list.isNotEmpty()
|
|
|
+ books = list
|
|
|
booksAdapter.updateItems()
|
|
|
- delay(500)
|
|
|
+ binding.emptyView.isGone = getItemCount() > 0
|
|
|
+ binding.refreshLayout.isEnabled = enableRefresh && getItemCount() > 0
|
|
|
}
|
|
|
}
|
|
|
}
|