Search in sources :

Example 1 with TranslationsSpinnerAdapter

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);
    }
}
Also used : TranslationsSpinnerAdapter(com.quran.labs.androidquran.ui.util.TranslationsSpinnerAdapter) ViewGroup(android.view.ViewGroup) NonNull(android.support.annotation.NonNull) SearchView(android.support.v7.widget.SearchView) View(android.view.View) ActionBar(android.support.v7.app.ActionBar)

Example 2 with TranslationsSpinnerAdapter

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);
    }
}
Also used : Context(android.content.Context) Bundle(android.os.Bundle) ProgressBar(android.widget.ProgressBar) LayoutInflater(android.view.LayoutInflater) LocalTranslation(com.quran.labs.androidquran.common.LocalTranslation) QuranSpinner(com.quran.labs.androidquran.widgets.QuranSpinner) Set(java.util.Set) InlineTranslationPresenter(com.quran.labs.androidquran.presenter.translation.InlineTranslationPresenter) NonNull(android.support.annotation.NonNull) ViewGroup(android.view.ViewGroup) InlineTranslationView(com.quran.labs.androidquran.widgets.InlineTranslationView) Inject(javax.inject.Inject) VerseRange(com.quran.labs.androidquran.data.VerseRange) List(java.util.List) QuranAyahInfo(com.quran.labs.androidquran.common.QuranAyahInfo) TranslationsSpinnerAdapter(com.quran.labs.androidquran.ui.util.TranslationsSpinnerAdapter) QuranInfo(com.quran.labs.androidquran.data.QuranInfo) R(com.quran.labs.androidquran.R) View(android.view.View) Button(android.widget.Button) PagerActivity(com.quran.labs.androidquran.ui.PagerActivity) QuranSettings(com.quran.labs.androidquran.util.QuranSettings) Activity(android.app.Activity) VerseRange(com.quran.labs.androidquran.data.VerseRange) TranslationsSpinnerAdapter(com.quran.labs.androidquran.ui.util.TranslationsSpinnerAdapter) PagerActivity(com.quran.labs.androidquran.ui.PagerActivity) Activity(android.app.Activity) PagerActivity(com.quran.labs.androidquran.ui.PagerActivity)

Aggregations

NonNull (android.support.annotation.NonNull)2 View (android.view.View)2 ViewGroup (android.view.ViewGroup)2 TranslationsSpinnerAdapter (com.quran.labs.androidquran.ui.util.TranslationsSpinnerAdapter)2 Activity (android.app.Activity)1 Context (android.content.Context)1 Bundle (android.os.Bundle)1 ActionBar (android.support.v7.app.ActionBar)1 SearchView (android.support.v7.widget.SearchView)1 LayoutInflater (android.view.LayoutInflater)1 Button (android.widget.Button)1 ProgressBar (android.widget.ProgressBar)1 R (com.quran.labs.androidquran.R)1 LocalTranslation (com.quran.labs.androidquran.common.LocalTranslation)1 QuranAyahInfo (com.quran.labs.androidquran.common.QuranAyahInfo)1 QuranInfo (com.quran.labs.androidquran.data.QuranInfo)1 VerseRange (com.quran.labs.androidquran.data.VerseRange)1 InlineTranslationPresenter (com.quran.labs.androidquran.presenter.translation.InlineTranslationPresenter)1 PagerActivity (com.quran.labs.androidquran.ui.PagerActivity)1 QuranSettings (com.quran.labs.androidquran.util.QuranSettings)1