use of com.quran.labs.androidquran.ui.util.TranslationsSpinnerAdapter in project quran_android by quran.
the class PagerActivity method updateActionBarSpinner.
private void updateActionBarSpinner() {
if (translationItems == null || translationItems.length == 0) {
int page = getCurrentPage();
updateActionBarTitle(page);
return;
}
if (translationsSpinnerAdapter == null) {
translationsSpinnerAdapter = new TranslationsSpinnerAdapter(this, R.layout.translation_ab_spinner_item, translationItems, translations, activeTranslations == null ? quranSettings.getActiveTranslations() : activeTranslations, translationItemChangedListener) {
@NonNull
@Override
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
int type = super.getItemViewType(position);
convertView = super.getView(position, convertView, parent);
if (type == 0) {
SpinnerHolder holder = (SpinnerHolder) convertView.getTag();
int page = getCurrentPage();
String sura = quranInfo.getSuraNameFromPage(PagerActivity.this, page, true);
holder.title.setText(sura);
String desc = quranInfo.getPageSubtitle(PagerActivity.this, page);
holder.subtitle.setText(desc);
holder.subtitle.setVisibility(View.VISIBLE);
}
return convertView;
}
};
translationsSpinner.setAdapter(translationsSpinnerAdapter);
}
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayShowTitleEnabled(false);
translationsSpinner.setVisibility(View.VISIBLE);
}
}
use of com.quran.labs.androidquran.ui.util.TranslationsSpinnerAdapter in project quran_android by quran.
the class AyahTranslationFragment method refreshView.
@Override
public void refreshView() {
if (start == null || end == null) {
return;
}
final Activity activity = getActivity();
if (activity instanceof PagerActivity) {
PagerActivity pagerActivity = (PagerActivity) activity;
if (translations == null || translations.size() == 0) {
translations = pagerActivity.getTranslations();
}
if (translations == null || translations.size() == 0) {
progressBar.setVisibility(View.GONE);
emptyState.setVisibility(View.VISIBLE);
translationControls.setVisibility(View.GONE);
return;
}
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, activeTranslations, selectedItems -> {
quranSettings.setActiveTranslations(selectedItems);
refreshView();
});
translator.setAdapter(translationAdapter);
}
if (start.equals(end)) {
translationControls.setVisibility(View.VISIBLE);
} else {
translationControls.setVisibility(View.GONE);
}
final int verses = 1 + Math.abs(quranInfo.getAyahId(start.sura, start.ayah) - quranInfo.getAyahId(end.sura, end.ayah));
VerseRange verseRange = new VerseRange(start.sura, start.ayah, end.sura, end.ayah, verses);
translationPresenter.refresh(verseRange);
}
}
Aggregations