Search in sources :

Example 1 with QuranPage

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

the class PagerActivity method unHighlightAyahs.

private void unHighlightAyahs(HighlightType type) {
    if (HighlightType.AUDIO.equals(type)) {
        lastPlayingSura = null;
        lastPlayingAyah = null;
    }
    int position = viewPager.getCurrentItem();
    Fragment f = pagerAdapter.getFragmentIfExists(position);
    if (f instanceof QuranPage && f.isVisible()) {
        ((QuranPage) f).getAyahTracker().unHighlightAyahs(type);
    }
}
Also used : QuranPage(com.quran.labs.androidquran.ui.helpers.QuranPage) TabletFragment(com.quran.labs.androidquran.ui.fragment.TabletFragment) Fragment(android.support.v4.app.Fragment) AyahActionFragment(com.quran.labs.androidquran.ui.fragment.AyahActionFragment) TranslationFragment(com.quran.labs.androidquran.ui.fragment.TranslationFragment) JumpFragment(com.quran.labs.androidquran.ui.fragment.JumpFragment)

Example 2 with QuranPage

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

the class PagerActivity method refreshQuranPages.

private void refreshQuranPages() {
    int pos = viewPager.getCurrentItem();
    int start = (pos == 0) ? pos : pos - 1;
    int end = (pos == pagerAdapter.getCount() - 1) ? pos : pos + 1;
    for (int i = start; i <= end; i++) {
        Fragment f = pagerAdapter.getFragmentIfExists(i);
        if (f instanceof QuranPage) {
            ((QuranPage) f).updateView();
        }
    }
}
Also used : QuranPage(com.quran.labs.androidquran.ui.helpers.QuranPage) TabletFragment(com.quran.labs.androidquran.ui.fragment.TabletFragment) Fragment(android.support.v4.app.Fragment) AyahActionFragment(com.quran.labs.androidquran.ui.fragment.AyahActionFragment) TranslationFragment(com.quran.labs.androidquran.ui.fragment.TranslationFragment) JumpFragment(com.quran.labs.androidquran.ui.fragment.JumpFragment)

Example 3 with QuranPage

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

the class PagerActivity method showAyahModeRangeHighlights.

private void showAyahModeRangeHighlights() {
    // Determine the start and end of the selection
    final int startPage = quranInfo.getPageFromSuraAyah(start.sura, start.ayah);
    final int endingPage = quranInfo.getPageFromSuraAyah(end.sura, end.ayah);
    int minPage = Math.min(startPage, endingPage);
    int maxPage = Math.max(startPage, endingPage);
    SuraAyah start = SuraAyah.min(this.start, end);
    SuraAyah end = SuraAyah.max(this.start, this.end);
    // Iterate from beginning to end
    for (int i = minPage; i <= maxPage; i++) {
        QuranPage fragment = pagerAdapter.getFragmentIfExistsForPage(i);
        if (fragment != null) {
            Set<String> ayahKeys = quranInfo.getAyahKeysOnPage(i, start, end);
            fragment.getAyahTracker().highlightAyat(i, ayahKeys, HighlightType.SELECTION);
        }
    }
}
Also used : SuraAyah(com.quran.labs.androidquran.data.SuraAyah) QuranPage(com.quran.labs.androidquran.ui.helpers.QuranPage)

Example 4 with QuranPage

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

the class PagerActivity method highlightAyah.

private void highlightAyah(int sura, int ayah, boolean force, HighlightType type) {
    Timber.d("highlightAyah() - %s:%s", sura, ayah);
    int page = quranInfo.getPageFromSuraAyah(sura, ayah);
    if (page < Constants.PAGES_FIRST || numberOfPages < page) {
        return;
    }
    int position = quranInfo.getPosFromPage(page, isDualPages);
    if (position != viewPager.getCurrentItem() && force) {
        unHighlightAyahs(type);
        viewPager.setCurrentItem(position);
    }
    Fragment f = pagerAdapter.getFragmentIfExists(position);
    if (f instanceof QuranPage && f.isAdded()) {
        ((QuranPage) f).getAyahTracker().highlightAyah(sura, ayah, type, true);
    }
}
Also used : QuranPage(com.quran.labs.androidquran.ui.helpers.QuranPage) TabletFragment(com.quran.labs.androidquran.ui.fragment.TabletFragment) Fragment(android.support.v4.app.Fragment) AyahActionFragment(com.quran.labs.androidquran.ui.fragment.AyahActionFragment) TranslationFragment(com.quran.labs.androidquran.ui.fragment.TranslationFragment) JumpFragment(com.quran.labs.androidquran.ui.fragment.JumpFragment)

Example 5 with QuranPage

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

the class PagerActivity method clearAyahModeHighlights.

private void clearAyahModeHighlights() {
    if (isInAyahMode) {
        final int startPage = quranInfo.getPageFromSuraAyah(start.sura, start.ayah);
        final int endingPage = quranInfo.getPageFromSuraAyah(end.sura, end.ayah);
        for (int i = startPage; i <= endingPage; i++) {
            QuranPage fragment = pagerAdapter.getFragmentIfExistsForPage(i);
            if (fragment != null) {
                fragment.getAyahTracker().unHighlightAyahs(HighlightType.SELECTION);
            }
        }
    }
}
Also used : QuranPage(com.quran.labs.androidquran.ui.helpers.QuranPage)

Aggregations

QuranPage (com.quran.labs.androidquran.ui.helpers.QuranPage)7 Fragment (android.support.v4.app.Fragment)5 AyahActionFragment (com.quran.labs.androidquran.ui.fragment.AyahActionFragment)5 JumpFragment (com.quran.labs.androidquran.ui.fragment.JumpFragment)5 TabletFragment (com.quran.labs.androidquran.ui.fragment.TabletFragment)5 TranslationFragment (com.quran.labs.androidquran.ui.fragment.TranslationFragment)5 SuraAyah (com.quran.labs.androidquran.data.SuraAyah)1