use of com.quran.labs.androidquran.ui.helpers.QuranRow in project quran_android by quran.
the class BookmarkPresenter method getRowsSortedByTags.
private List<QuranRow> getRowsSortedByTags(List<Tag> tags, List<Bookmark> bookmarks) {
List<QuranRow> rows = new ArrayList<>();
// sort by tags, alphabetical
Map<Long, List<Bookmark>> tagsMapping = generateTagsMapping(tags, bookmarks);
for (int i = 0, tagsSize = tags.size(); i < tagsSize; i++) {
Tag tag = tags.get(i);
rows.add(quranRowFactory.fromTag(tag));
List<Bookmark> tagBookmarks = tagsMapping.get(tag.getId());
for (int j = 0, tagBookmarksSize = tagBookmarks.size(); j < tagBookmarksSize; j++) {
rows.add(quranRowFactory.fromBookmark(appContext, tagBookmarks.get(j), tag.getId()));
}
}
// add untagged bookmarks
List<Bookmark> untagged = tagsMapping.get(BOOKMARKS_WITHOUT_TAGS_ID);
if (untagged.size() > 0) {
rows.add(quranRowFactory.fromNotTaggedHeader(appContext));
for (int i = 0, untaggedSize = untagged.size(); i < untaggedSize; i++) {
rows.add(quranRowFactory.fromBookmark(appContext, untagged.get(i)));
}
}
return rows;
}
use of com.quran.labs.androidquran.ui.helpers.QuranRow in project quran_android by quran.
the class BookmarkPresenter method getContextualOperationsForItems.
public boolean[] getContextualOperationsForItems(List<QuranRow> rows) {
boolean[] result = new boolean[3];
int headers = 0;
int bookmarks = 0;
for (int i = 0, rowsSize = rows.size(); i < rowsSize; i++) {
QuranRow row = rows.get(i);
if (row.isBookmarkHeader()) {
headers++;
} else if (row.isBookmark()) {
bookmarks++;
}
}
result[0] = headers == 1 && bookmarks == 0;
result[1] = (headers + bookmarks) > 0;
result[2] = headers == 0 && bookmarks > 0;
return result;
}
use of com.quran.labs.androidquran.ui.helpers.QuranRow in project quran_android by quran.
the class JuzListFragment method getJuz2List.
private QuranRow[] getJuz2List() {
Activity activity = getActivity();
Resources res = getResources();
String[] quarters = res.getStringArray(R.array.quarter_prefix_array);
QuranRow[] elements = new QuranRow[JUZ2_COUNT * (8 + 1)];
int ctr = 0;
for (int i = 0; i < (8 * JUZ2_COUNT); i++) {
int[] pos = quranInfo.getQuarterByIndex(i);
int page = quranInfo.getPageFromSuraAyah(pos[0], pos[1]);
if (i % 8 == 0) {
int juz = 1 + (i / 8);
final String juzTitle = activity.getString(R.string.juz2_description, QuranUtils.getLocalizedNumber(activity, juz));
final QuranRow.Builder builder = new QuranRow.Builder().withType(QuranRow.HEADER).withText(juzTitle).withPage(quranInfo.getStartingPageForJuz(juz));
elements[ctr++] = builder.build();
}
final String metadata = getString(R.string.sura_ayah_notification_str, quranInfo.getSuraName(activity, pos[0], false), pos[1]);
final QuranRow.Builder builder = new QuranRow.Builder().withText(quarters[i]).withMetadata(metadata).withPage(page).withJuzType(sEntryTypes[i % 4]);
if (i % 4 == 0) {
final String overlayText = QuranUtils.getLocalizedNumber(activity, 1 + (i / 4));
builder.withJuzOverlayText(overlayText);
}
elements[ctr++] = builder.build();
}
return elements;
}
use of com.quran.labs.androidquran.ui.helpers.QuranRow in project quran_android by quran.
the class SuraListFragment method getSuraList.
private QuranRow[] getSuraList() {
int next;
int pos = 0;
int sura = 1;
QuranRow[] elements = new QuranRow[SURAS_COUNT + JUZ2_COUNT];
Activity activity = getActivity();
boolean wantPrefix = activity.getResources().getBoolean(R.bool.show_surat_prefix);
boolean wantTranslation = activity.getResources().getBoolean(R.bool.show_sura_names_translation);
for (int juz = 1; juz <= JUZ2_COUNT; juz++) {
final String headerTitle = activity.getString(R.string.juz2_description, QuranUtils.getLocalizedNumber(activity, juz));
final QuranRow.Builder headerBuilder = new QuranRow.Builder().withType(QuranRow.HEADER).withText(headerTitle).withPage(quranInfo.getStartingPageForJuz(juz));
elements[pos++] = headerBuilder.build();
next = (juz == JUZ2_COUNT) ? numberOfPages + 1 : quranInfo.getStartingPageForJuz(juz + 1);
while ((sura <= SURAS_COUNT) && (quranInfo.getPageNumberForSura(sura) < next)) {
final QuranRow.Builder builder = new QuranRow.Builder().withText(quranInfo.getSuraName(activity, sura, wantPrefix, wantTranslation)).withMetadata(quranInfo.getSuraListMetaString(activity, sura)).withSura(sura).withPage(quranInfo.getPageNumberForSura(sura));
elements[pos++] = builder.build();
sura++;
}
}
return elements;
}
Aggregations