use of com.quran.labs.androidquran.common.QuranText in project quran_android by quran.
the class ShareUtil method getShareText.
private String getShareText(Activity activity, List<QuranText> verses) {
final int size = verses.size();
StringBuilder sb = new StringBuilder("(");
for (int i = 0; i < size; i++) {
sb.append(verses.get(i).text);
if (i + 1 < size) {
sb.append(" * ");
}
}
// append ) and a new line after last ayah
sb.append(")\n");
// append [ before sura label
sb.append("[");
final QuranText firstAyah = verses.get(0);
sb.append(quranInfo.getSuraName(activity, firstAyah.sura, true));
sb.append(" ");
sb.append(firstAyah.ayah);
if (size > 1) {
final QuranText lastAyah = verses.get(size - 1);
sb.append(" - ");
if (firstAyah.sura != lastAyah.sura) {
sb.append(quranInfo.getSuraName(activity, lastAyah.sura, true));
sb.append(" ");
}
sb.append(lastAyah.ayah);
}
// close sura label and append two new lines
sb.append("]\n\n");
sb.append(activity.getString(R.string.via_string));
return sb.toString();
}
use of com.quran.labs.androidquran.common.QuranText 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();
}
use of com.quran.labs.androidquran.common.QuranText in project quran_android by quran.
the class BaseTranslationPresenterTest method testCombineAyahDataArabicEmptyTranslations.
@Test
public void testCombineAyahDataArabicEmptyTranslations() {
VerseRange verseRange = new VerseRange(1, 1, 1, 2, 2);
List<QuranText> arabic = Arrays.asList(new QuranText(1, 1, "first ayah"), new QuranText(1, 2, "second ayah"));
List<QuranAyahInfo> info = presenter.combineAyahData(verseRange, arabic, new ArrayList<>());
assertThat(info).hasSize(2);
assertThat(info.get(0).sura).isEqualTo(1);
assertThat(info.get(0).ayah).isEqualTo(1);
assertThat(info.get(0).texts).hasSize(0);
assertThat(info.get(0).arabicText).isEqualTo("first ayah");
assertThat(info.get(1).sura).isEqualTo(1);
assertThat(info.get(1).ayah).isEqualTo(2);
assertThat(info.get(1).texts).hasSize(0);
assertThat(info.get(1).arabicText).isEqualTo("second ayah");
}
use of com.quran.labs.androidquran.common.QuranText in project quran_android by quran.
the class DatabaseHandler method getVerses.
public List<QuranText> getVerses(VerseRange verses, @TextType int textType) {
Cursor cursor = null;
List<QuranText> results = new ArrayList<>();
try {
String table = textType == TextType.ARABIC ? ARABIC_TEXT_TABLE : VERSE_TABLE;
cursor = getVersesInternal(verses, table);
while (cursor != null && cursor.moveToNext()) {
int sura = cursor.getInt(1);
int ayah = cursor.getInt(2);
String text = cursor.getString(3);
results.add(new QuranText(sura, ayah, text));
}
} finally {
DatabaseUtils.closeCursor(cursor);
}
return results;
}
Aggregations