From c4993f0e6dcb7b812635e1ef20671db4a487dfe3 Mon Sep 17 00:00:00 2001 From: Ahmed El-Helw Date: Sun, 10 Dec 2023 21:24:41 +0400 Subject: [PATCH] Avoid unnecessary reads of translations data --- .../presenter/translation/InlineTranslationPresenter.kt | 2 +- .../labs/androidquran/ui/fragment/AyahActionFragment.kt | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/quran/labs/androidquran/presenter/translation/InlineTranslationPresenter.kt b/app/src/main/java/com/quran/labs/androidquran/presenter/translation/InlineTranslationPresenter.kt index 678451d325..d084f71502 100644 --- a/app/src/main/java/com/quran/labs/androidquran/presenter/translation/InlineTranslationPresenter.kt +++ b/app/src/main/java/com/quran/labs/androidquran/presenter/translation/InlineTranslationPresenter.kt @@ -21,7 +21,7 @@ class InlineTranslationPresenter @Inject constructor( dbAdapter: TranslationsDBAdapter, translationUtil: TranslationUtil, private val quranSettings: QuranSettings, - private val translationListPresenter: TranslationListPresenter, + translationListPresenter: TranslationListPresenter, quranInfo: QuranInfo ) : BaseTranslationPresenter( translationModel, dbAdapter, translationUtil, quranInfo diff --git a/app/src/main/java/com/quran/labs/androidquran/ui/fragment/AyahActionFragment.kt b/app/src/main/java/com/quran/labs/androidquran/ui/fragment/AyahActionFragment.kt index 3f0287a9de..0b7f45314f 100644 --- a/app/src/main/java/com/quran/labs/androidquran/ui/fragment/AyahActionFragment.kt +++ b/app/src/main/java/com/quran/labs/androidquran/ui/fragment/AyahActionFragment.kt @@ -34,6 +34,7 @@ abstract class AyahActionFragment : Fragment() { scope = MainScope() readingEventPresenter.ayahSelectionFlow .combine(audioEventPresenter.audioPlaybackAyahFlow) { selectedAyah, playbackAyah -> + val (previousStart, previousEnd) = start to end if (selectedAyah !is AyahSelection.None) { start = selectedAyah.startSuraAyah() end = selectedAyah.endSuraAyah() @@ -41,7 +42,10 @@ abstract class AyahActionFragment : Fragment() { start = playbackAyah end = playbackAyah } - refreshView() + + if (previousStart != start || previousEnd != end) { + refreshView() + } } .launchIn(scope)