From a1b85433ec7887bf1537fb77b056306b0e205868 Mon Sep 17 00:00:00 2001 From: Koitharu Date: Tue, 12 Sep 2023 13:05:39 +0300 Subject: [PATCH] Fix bookmarks crash #492 --- .../kotatsu/bookmarks/ui/BookmarksFragment.kt | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/bookmarks/ui/BookmarksFragment.kt b/app/src/main/kotlin/org/koitharu/kotatsu/bookmarks/ui/BookmarksFragment.kt index dbbe008b7..51cf7e009 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/bookmarks/ui/BookmarksFragment.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/bookmarks/ui/BookmarksFragment.kt @@ -14,7 +14,6 @@ import androidx.core.view.updatePadding import androidx.fragment.app.viewModels import androidx.recyclerview.widget.GridLayoutManager import coil.ImageLoader -import com.google.android.material.snackbar.Snackbar import dagger.hilt.android.AndroidEntryPoint import org.koitharu.kotatsu.R import org.koitharu.kotatsu.bookmarks.domain.Bookmark @@ -25,8 +24,7 @@ import org.koitharu.kotatsu.core.ui.BaseFragment import org.koitharu.kotatsu.core.ui.list.ListSelectionController import org.koitharu.kotatsu.core.ui.list.OnListItemClickListener import org.koitharu.kotatsu.core.ui.list.fastscroll.FastScroller -import org.koitharu.kotatsu.core.ui.util.ReversibleAction -import org.koitharu.kotatsu.core.ui.util.reverseAsync +import org.koitharu.kotatsu.core.ui.util.ReversibleActionObserver import org.koitharu.kotatsu.core.util.ext.observe import org.koitharu.kotatsu.core.util.ext.observeEvent import org.koitharu.kotatsu.databinding.FragmentListSimpleBinding @@ -38,7 +36,6 @@ import org.koitharu.kotatsu.list.ui.adapter.ListStateHolderListener import org.koitharu.kotatsu.list.ui.adapter.TypedListSpacingDecoration import org.koitharu.kotatsu.list.ui.model.ListHeader import org.koitharu.kotatsu.main.ui.owners.AppBarOwner -import org.koitharu.kotatsu.main.ui.owners.SnackbarOwner import org.koitharu.kotatsu.parsers.model.Manga import org.koitharu.kotatsu.reader.ui.ReaderActivity import javax.inject.Inject @@ -105,7 +102,7 @@ class BookmarksFragment : viewLifecycleOwner, SnackbarErrorObserver(binding.recyclerView, this) ) - viewModel.onActionDone.observeEvent(viewLifecycleOwner, ::onActionDone) + viewModel.onActionDone.observeEvent(viewLifecycleOwner, ReversibleActionObserver(binding.recyclerView)) } override fun onDestroyView() { @@ -184,17 +181,6 @@ class BookmarksFragment : } } - private fun onActionDone(action: ReversibleAction) { - val handle = action.handle - val length = if (handle == null) Snackbar.LENGTH_SHORT else Snackbar.LENGTH_LONG - val snackbar = - Snackbar.make((activity as SnackbarOwner).snackbarHost, action.stringResId, length) - if (handle != null) { - snackbar.setAction(R.string.undo) { handle.reverseAsync() } - } - snackbar.show() - } - private inner class SpanSizeLookup : GridLayoutManager.SpanSizeLookup(), Runnable { init {