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);
}
}
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();
}
}
}
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);
}
}
}
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);
}
}
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);
}
}
}
}
Aggregations