From 039624f439aeed007e689250c5916224b9f0a911 Mon Sep 17 00:00:00 2001 From: Brayan Oliveira <69634269+BrayanDSO@users.noreply.github.com> Date: Tue, 2 Jan 2024 21:15:33 -0300 Subject: [PATCH] refactor: remove displayCard --- .../java/com/ichi2/anki/previewer/PreviewerFragment.kt | 4 +--- .../java/com/ichi2/anki/previewer/PreviewerViewModel.kt | 7 ------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/previewer/PreviewerFragment.kt b/AnkiDroid/src/main/java/com/ichi2/anki/previewer/PreviewerFragment.kt index bbeb816dd949..ee286a0591ab 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/previewer/PreviewerFragment.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/previewer/PreviewerFragment.kt @@ -192,9 +192,7 @@ class PreviewerFragment : Fragment(), Toolbar.OnMenuItemClickListener { override fun onStartTrackingTouch(slider: Slider) {} override fun onStopTrackingTouch(slider: Slider) { - viewModel.launchCatching { - displayCard(value.toInt() - 1) - } + viewModel.currentIndex.tryEmit(slider.value.toInt() - 1) } } ) diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/previewer/PreviewerViewModel.kt b/AnkiDroid/src/main/java/com/ichi2/anki/previewer/PreviewerViewModel.kt index b006efc05044..8b551ebe1760 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/previewer/PreviewerViewModel.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/previewer/PreviewerViewModel.kt @@ -158,13 +158,6 @@ class PreviewerViewModel(private val selectedCardIds: LongArray, firstIndex: Int return addPlayButtons(withCol { media.escapeMediaFilenames(text) }) } - suspend fun displayCard(index: Int) { - if (index !in 0..selectedCardIds.lastIndex) { - return - } - currentIndex.emit(index) - } - fun showPreviousCard() { currentIndex.update { it - 1 } }