Search in sources :

Example 1 with PagerActivity

use of com.quran.labs.androidquran.ui.PagerActivity in project quran_android by quran.

the class AyahActionFragment method onResume.

@Override
public void onResume() {
    super.onResume();
    if (justCreated) {
        justCreated = false;
        PagerActivity activity = (PagerActivity) getActivity();
        if (activity != null) {
            start = activity.getSelectionStart();
            end = activity.getSelectionEnd();
            refreshView();
        }
    }
}
Also used : PagerActivity(com.quran.labs.androidquran.ui.PagerActivity)

Example 2 with PagerActivity

use of com.quran.labs.androidquran.ui.PagerActivity 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)

Example 3 with PagerActivity

use of com.quran.labs.androidquran.ui.PagerActivity in project quran_android by quran.

the class TabletFragment method onAttach.

@Override
public void onAttach(Context context) {
    super.onAttach(context);
    pageNumber = getArguments().getInt(FIRST_PAGE_EXTRA);
    mode = getArguments().getInt(MODE_EXTRA, Mode.ARABIC);
    ((PagerActivity) getActivity()).getPagerActivityComponent().quranPageComponentBuilder().withQuranPageModule(new QuranPageModule(pageNumber - 1, pageNumber)).build().inject(this);
}
Also used : QuranPageModule(com.quran.labs.androidquran.module.fragment.QuranPageModule) PagerActivity(com.quran.labs.androidquran.ui.PagerActivity)

Example 4 with PagerActivity

use of com.quran.labs.androidquran.ui.PagerActivity in project quran_android by quran.

the class TabletFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = getActivity();
    mainView = new TabletView(context);
    if (mode == Mode.ARABIC) {
        mainView.init(TabletView.QURAN_PAGE, TabletView.QURAN_PAGE);
        leftImageView = ((QuranImagePageLayout) mainView.getLeftPage()).getImageView();
        rightImageView = ((QuranImagePageLayout) mainView.getRightPage()).getImageView();
        mainView.setPageController(this, pageNumber, pageNumber - 1);
    } else if (mode == Mode.TRANSLATION) {
        mainView.init(TabletView.TRANSLATION_PAGE, TabletView.TRANSLATION_PAGE);
        leftTranslation = ((QuranTranslationPageLayout) mainView.getLeftPage()).getTranslationView();
        rightTranslation = ((QuranTranslationPageLayout) mainView.getRightPage()).getTranslationView();
        PagerActivity pagerActivity = (PagerActivity) context;
        leftTranslation.setTranslationClickedListener(v -> pagerActivity.toggleActionBar());
        rightTranslation.setTranslationClickedListener(v -> pagerActivity.toggleActionBar());
        leftTranslation.setOnTranslationActionListener(this);
        rightTranslation.setOnTranslationActionListener(this);
        mainView.setPageController(null, pageNumber, pageNumber - 1);
    }
    return mainView;
}
Also used : Context(android.content.Context) Context(android.content.Context) Bundle(android.os.Bundle) AyahBounds(com.quran.labs.androidquran.common.AyahBounds) PageController(com.quran.labs.androidquran.ui.util.PageController) ImageView(android.widget.ImageView) StringRes(android.support.annotation.StringRes) NonNull(android.support.annotation.NonNull) TranslationPresenter(com.quran.labs.androidquran.presenter.translation.TranslationPresenter) Inject(javax.inject.Inject) EventType(com.quran.labs.androidquran.ui.helpers.AyahSelectedListener.EventType) QuranAyahInfo(com.quran.labs.androidquran.common.QuranAyahInfo) OnTranslationActionListener(com.quran.labs.androidquran.ui.translation.OnTranslationActionListener) AyahSelectedListener(com.quran.labs.androidquran.ui.helpers.AyahSelectedListener) QuranTranslationPageLayout(com.quran.labs.androidquran.widgets.QuranTranslationPageLayout) MotionEvent(android.view.MotionEvent) HighlightingImageView(com.quran.labs.androidquran.widgets.HighlightingImageView) Map(java.util.Map) View(android.view.View) AyahTranslationTrackerItem(com.quran.labs.androidquran.presenter.quran.ayahtracker.AyahTranslationTrackerItem) PagerActivity(com.quran.labs.androidquran.ui.PagerActivity) QuranPageScreen(com.quran.labs.androidquran.presenter.quran.QuranPageScreen) QuranSettings(com.quran.labs.androidquran.util.QuranSettings) AyahTrackerItem(com.quran.labs.androidquran.presenter.quran.ayahtracker.AyahTrackerItem) TabletView(com.quran.labs.androidquran.widgets.TabletView) AyahTrackerPresenter(com.quran.labs.androidquran.presenter.quran.ayahtracker.AyahTrackerPresenter) RectF(android.graphics.RectF) Bookmark(com.quran.labs.androidquran.dao.Bookmark) QuranPagePresenter(com.quran.labs.androidquran.presenter.quran.QuranPagePresenter) LayoutInflater(android.view.LayoutInflater) TranslationView(com.quran.labs.androidquran.ui.translation.TranslationView) AyahImageTrackerItem(com.quran.labs.androidquran.presenter.quran.ayahtracker.AyahImageTrackerItem) Fragment(android.support.v4.app.Fragment) QuranPageModule(com.quran.labs.androidquran.module.fragment.QuranPageModule) BitmapDrawable(android.graphics.drawable.BitmapDrawable) QuranImagePageLayout(com.quran.labs.androidquran.widgets.QuranImagePageLayout) QuranScreenInfo(com.quran.labs.androidquran.util.QuranScreenInfo) Lazy(dagger.Lazy) ViewGroup(android.view.ViewGroup) Timber(timber.log.Timber) QuranPage(com.quran.labs.androidquran.ui.helpers.QuranPage) AyahTracker(com.quran.labs.androidquran.ui.helpers.AyahTracker) List(java.util.List) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Bitmap(android.graphics.Bitmap) QuranInfo(com.quran.labs.androidquran.data.QuranInfo) Nullable(android.support.annotation.Nullable) Activity(android.app.Activity) QuranTranslationPageLayout(com.quran.labs.androidquran.widgets.QuranTranslationPageLayout) TabletView(com.quran.labs.androidquran.widgets.TabletView) PagerActivity(com.quran.labs.androidquran.ui.PagerActivity)

Example 5 with PagerActivity

use of com.quran.labs.androidquran.ui.PagerActivity in project quran_android by quran.

the class AyahPlaybackFragment method apply.

private void apply() {
    final Context context = getActivity();
    if (context instanceof PagerActivity) {
        final SuraAyah start = new SuraAyah(startSuraSpinner.getSelectedItemPosition() + 1, startAyahSpinner.getSelectedItemPosition() + 1);
        final SuraAyah ending = new SuraAyah(endingSuraSpinner.getSelectedItemPosition() + 1, endingAyahSpinner.getSelectedItemPosition() + 1);
        // force the correct order
        final SuraAyah currentStart;
        final SuraAyah currentEnding;
        if (ending.after(start)) {
            currentStart = start;
            currentEnding = ending;
        } else {
            currentStart = ending;
            currentEnding = start;
        }
        final int page = quranInfo.getPageFromSuraAyah(currentStart.sura, currentStart.ayah);
        final int verseRepeat = positionToRepeat(repeatVerseSpinner.getSelectedItemPosition());
        final int rangeRepeat = positionToRepeat(repeatRangeSpinner.getSelectedItemPosition());
        final boolean enforceRange = restrictToRange.isChecked();
        boolean updatedRange = false;
        final PagerActivity pagerActivity = (PagerActivity) context;
        if (!currentStart.equals(decidedStart) || !currentEnding.equals(decidedEnd)) {
            // different range or not playing, so make a new request
            updatedRange = true;
            if (this.start != null) {
                final SuraAyah starting = decidedStart == null ? this.start : decidedStart;
                final int origPage = quranInfo.getPageFromSuraAyah(starting.sura, starting.ayah);
                if (page != origPage) {
                    pagerActivity.highlightAyah(currentStart.sura, currentStart.ayah, HighlightType.AUDIO);
                }
            }
            pagerActivity.playFromAyah(currentStart, currentEnding, page, verseRepeat, rangeRepeat, enforceRange, true);
        } else if (shouldEnforce != enforceRange || rangeRepeatCount != rangeRepeat || verseRepeatCount != verseRepeat) {
            // can just update repeat settings
            if (!pagerActivity.updatePlayOptions(rangeRepeat, verseRepeat, enforceRange)) {
                // audio stopped in the process, let's start it
                pagerActivity.playFromAyah(currentStart, currentEnding, page, verseRepeat, rangeRepeat, enforceRange, true);
            }
        }
        pagerActivity.endAyahMode();
        if (updatedRange) {
            pagerActivity.toggleActionBarVisibility(true);
        }
    }
}
Also used : Context(android.content.Context) SuraAyah(com.quran.labs.androidquran.data.SuraAyah) PagerActivity(com.quran.labs.androidquran.ui.PagerActivity)

Aggregations

PagerActivity (com.quran.labs.androidquran.ui.PagerActivity)12 Activity (android.app.Activity)5 Context (android.content.Context)5 QuranPageModule (com.quran.labs.androidquran.module.fragment.QuranPageModule)4 Bundle (android.os.Bundle)2 NonNull (android.support.annotation.NonNull)2 LayoutInflater (android.view.LayoutInflater)2 View (android.view.View)2 ViewGroup (android.view.ViewGroup)2 QuranAyahInfo (com.quran.labs.androidquran.common.QuranAyahInfo)2 QuranInfo (com.quran.labs.androidquran.data.QuranInfo)2 SuraAyah (com.quran.labs.androidquran.data.SuraAyah)2 QuranSettings (com.quran.labs.androidquran.util.QuranSettings)2 List (java.util.List)2 Inject (javax.inject.Inject)2 Bitmap (android.graphics.Bitmap)1 RectF (android.graphics.RectF)1 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 Nullable (android.support.annotation.Nullable)1 StringRes (android.support.annotation.StringRes)1