use of com.quran.labs.androidquran.common.QuranAyahInfo 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.common.QuranAyahInfo 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.common.QuranAyahInfo 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.common.QuranAyahInfo in project quran_android by quran.
the class BaseTranslationPresenter method combineAyahData.
@NonNull
List<QuranAyahInfo> combineAyahData(@NonNull VerseRange verseRange, @NonNull List<QuranText> arabic, @NonNull List<List<QuranText>> texts) {
final int arabicSize = arabic.size();
final int translationCount = texts.size();
List<QuranAyahInfo> result = new ArrayList<>();
if (translationCount > 0) {
final int verses = arabicSize == 0 ? verseRange.versesInRange : arabicSize;
for (int i = 0; i < verses; i++) {
QuranText element = arabicSize == 0 ? null : arabic.get(i);
final List<String> ayahTranslations = new ArrayList<>();
for (int j = 0; j < translationCount; j++) {
QuranText item = texts.get(j).size() > i ? texts.get(j).get(i) : null;
if (item != null) {
ayahTranslations.add(texts.get(j).get(i).text);
element = item;
} else {
// this keeps the translations aligned with their translators
// even when a particular translator doesn't load.
ayahTranslations.add("");
}
}
if (element != null) {
String arabicText = arabicSize == 0 ? null : arabic.get(i).text;
result.add(new QuranAyahInfo(element.sura, element.ayah, arabicText, ayahTranslations, quranInfo.getAyahId(element.sura, element.ayah)));
}
}
} else if (arabicSize > 0) {
for (int i = 0; i < arabicSize; i++) {
QuranText arabicItem = arabic.get(i);
result.add(new QuranAyahInfo(arabicItem.sura, arabicItem.ayah, arabicItem.text, Collections.emptyList(), quranInfo.getAyahId(arabicItem.sura, arabicItem.ayah)));
}
}
return result;
}
use of com.quran.labs.androidquran.common.QuranAyahInfo in project quran_android by quran.
the class TranslationPresenter method getPage.
private int getPage(List<QuranAyahInfo> result) {
final int page;
if (pages.length == 1) {
page = pages[0];
} else {
QuranAyahInfo ayahInfo = result.get(0);
page = quranInfo.getPageFromSuraAyah(ayahInfo.sura, ayahInfo.ayah);
}
return page;
}
Aggregations