use of com.quran.labs.androidquran.data.VerseRange in project quran_android by quran.
the class BaseTranslationPresenterTest method testCombineAyahDataOneVerseNoArabic.
@Test
public void testCombineAyahDataOneVerseNoArabic() {
VerseRange verseRange = new VerseRange(1, 1, 1, 1, 1);
List<QuranText> arabic = Collections.emptyList();
List<QuranAyahInfo> info = presenter.combineAyahData(verseRange, arabic, Collections.singletonList(Collections.singletonList(new QuranText(1, 1, "translation"))));
assertThat(info).hasSize(1);
QuranAyahInfo first = info.get(0);
assertThat(first.sura).isEqualTo(1);
assertThat(first.ayah).isEqualTo(1);
assertThat(first.texts).hasSize(1);
assertThat(first.arabicText).isNull();
assertThat(first.texts.get(0)).isEqualTo("translation");
}
use of com.quran.labs.androidquran.data.VerseRange in project quran_android by quran.
the class BaseTranslationPresenterTest method testCombineAyahDataOneVerse.
@Test
public void testCombineAyahDataOneVerse() {
VerseRange verseRange = new VerseRange(1, 1, 1, 1, 1);
List<QuranText> arabic = Collections.singletonList(new QuranText(1, 1, "first ayah"));
List<QuranAyahInfo> info = presenter.combineAyahData(verseRange, arabic, Collections.singletonList(Collections.singletonList(new QuranText(1, 1, "translation"))));
assertThat(info).hasSize(1);
QuranAyahInfo first = info.get(0);
assertThat(first.sura).isEqualTo(1);
assertThat(first.ayah).isEqualTo(1);
assertThat(first.texts).hasSize(1);
assertThat(first.arabicText).isEqualTo("first ayah");
assertThat(first.texts.get(0)).isEqualTo("translation");
}
use of com.quran.labs.androidquran.data.VerseRange in project quran_android by quran.
the class BaseTranslationPresenterTest method testCombineAyahDataOneVerseEmpty.
@Test
public void testCombineAyahDataOneVerseEmpty() {
VerseRange verseRange = new VerseRange(1, 1, 1, 1, 1);
List<QuranText> arabic = Collections.emptyList();
List<QuranAyahInfo> info = presenter.combineAyahData(verseRange, arabic, Collections.emptyList());
assertThat(info).hasSize(0);
}
use of com.quran.labs.androidquran.data.VerseRange 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.data.VerseRange in project quran_android by quran.
the class BaseTranslationPresenterTest method testEnsureProperTranslations.
@Test
public void testEnsureProperTranslations() {
VerseRange verseRange = new VerseRange(1, 1, 1, 2, 2);
List<QuranText> text = new ArrayList<>();
text.add(new QuranText(1, 1, "bismillah"));
text = presenter.ensureProperTranslations(verseRange, text);
assertThat(text).hasSize(2);
QuranText first = text.get(0);
assertThat(first.sura).isEqualTo(1);
assertThat(first.ayah).isEqualTo(1);
assertThat(first.text).isEqualTo("bismillah");
QuranText second = text.get(1);
assertThat(second.sura).isEqualTo(1);
assertThat(second.ayah).isEqualTo(2);
assertThat(second.text).isEmpty();
}
Aggregations