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