Skip to content

Commit

Permalink
Properly refresh partial-page translation view
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedre committed Oct 14, 2017
1 parent 18b6c44 commit 2780eaf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,10 @@ public String[] getTranslationNames() {
return translationItems;
}

public Set<String> getActiveTranslations() {
return activeTranslations;
}

@Override
public void onAddTagSelected() {
FragmentManager fm = getSupportFragmentManager();
Expand Down Expand Up @@ -1310,8 +1314,6 @@ private void requestTranslationsList() {
.subscribeWith(new DisposableSingleObserver<List<LocalTranslation>>() {
@Override
public void onSuccess(List<LocalTranslation> translationList) {
int before = activeTranslations == null ? 0 : activeTranslations.size();

int items = translationList.size();
String[] titles = new String[items];
for (int i = 0; i < items; i++) {
Expand Down Expand Up @@ -1345,9 +1347,7 @@ public void onSuccess(List<LocalTranslation> translationList) {
updateActionBarSpinner();
}

if (before != currentActiveTranslations.size()) {
refreshPages();
}
refreshPages();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.quran.labs.androidquran.widgets.QuranSpinner;

import java.util.List;
import java.util.Set;

import javax.inject.Inject;

Expand Down Expand Up @@ -118,11 +119,16 @@ public void refreshView() {
}

if (translationAdapter == null) {
Set<String> 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();
Expand Down

0 comments on commit 2780eaf

Please sign in to comment.