From 2780eafd99de4c0f3c2a3f6beee14d10ed9af906 Mon Sep 17 00:00:00 2001 From: Ahmed El-Helw Date: Sat, 14 Oct 2017 20:23:49 +0400 Subject: [PATCH] Properly refresh partial-page translation view --- .../com/quran/labs/androidquran/ui/PagerActivity.java | 10 +++++----- .../ui/fragment/AyahTranslationFragment.java | 8 +++++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/quran/labs/androidquran/ui/PagerActivity.java b/app/src/main/java/com/quran/labs/androidquran/ui/PagerActivity.java index b724cf1f65..51526762e2 100644 --- a/app/src/main/java/com/quran/labs/androidquran/ui/PagerActivity.java +++ b/app/src/main/java/com/quran/labs/androidquran/ui/PagerActivity.java @@ -1054,6 +1054,10 @@ public String[] getTranslationNames() { return translationItems; } + public Set getActiveTranslations() { + return activeTranslations; + } + @Override public void onAddTagSelected() { FragmentManager fm = getSupportFragmentManager(); @@ -1310,8 +1314,6 @@ private void requestTranslationsList() { .subscribeWith(new DisposableSingleObserver>() { @Override public void onSuccess(List translationList) { - int before = activeTranslations == null ? 0 : activeTranslations.size(); - int items = translationList.size(); String[] titles = new String[items]; for (int i = 0; i < items; i++) { @@ -1345,9 +1347,7 @@ public void onSuccess(List translationList) { updateActionBarSpinner(); } - if (before != currentActiveTranslations.size()) { - refreshPages(); - } + refreshPages(); } @Override diff --git a/app/src/main/java/com/quran/labs/androidquran/ui/fragment/AyahTranslationFragment.java b/app/src/main/java/com/quran/labs/androidquran/ui/fragment/AyahTranslationFragment.java index b4fa4fd4f5..efce42ca7e 100644 --- a/app/src/main/java/com/quran/labs/androidquran/ui/fragment/AyahTranslationFragment.java +++ b/app/src/main/java/com/quran/labs/androidquran/ui/fragment/AyahTranslationFragment.java @@ -22,6 +22,7 @@ import com.quran.labs.androidquran.widgets.QuranSpinner; import java.util.List; +import java.util.Set; import javax.inject.Inject; @@ -118,11 +119,16 @@ public void refreshView() { } if (translationAdapter == null) { + Set activeTranslations = pagerActivity.getActiveTranslations(); + if (activeTranslations == null) { + activeTranslations = quranSettings.getActiveTranslations(); + } + translationAdapter = new TranslationsSpinnerAdapter(activity, R.layout.translation_ab_spinner_item, pagerActivity.getTranslationNames(), translations, - quranSettings.getActiveTranslations(), + activeTranslations, selectedItems -> { quranSettings.setActiveTranslations(selectedItems); refreshView();