Search in sources :

Example 6 with QuranRow

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;
}
Also used : Bookmark(com.quran.labs.androidquran.dao.Bookmark) QuranRow(com.quran.labs.androidquran.ui.helpers.QuranRow) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Tag(com.quran.labs.androidquran.dao.Tag) SuppressLint(android.annotation.SuppressLint)

Example 7 with QuranRow

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;
}
Also used : QuranRow(com.quran.labs.androidquran.ui.helpers.QuranRow) SuppressLint(android.annotation.SuppressLint)

Example 8 with QuranRow

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;
}
Also used : QuranRow(com.quran.labs.androidquran.ui.helpers.QuranRow) QuranActivity(com.quran.labs.androidquran.ui.QuranActivity) Activity(android.app.Activity) Resources(android.content.res.Resources)

Example 9 with QuranRow

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;
}
Also used : QuranRow(com.quran.labs.androidquran.ui.helpers.QuranRow) QuranActivity(com.quran.labs.androidquran.ui.QuranActivity) Activity(android.app.Activity)

Aggregations

QuranRow (com.quran.labs.androidquran.ui.helpers.QuranRow)9 SuppressLint (android.annotation.SuppressLint)5 Bookmark (com.quran.labs.androidquran.dao.Bookmark)3 Tag (com.quran.labs.androidquran.dao.Tag)3 ArrayList (java.util.ArrayList)3 Activity (android.app.Activity)2 QuranActivity (com.quran.labs.androidquran.ui.QuranActivity)2 Context (android.content.Context)1 Resources (android.content.res.Resources)1 Nullable (android.support.annotation.Nullable)1 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 RecentPage (com.quran.labs.androidquran.dao.RecentPage)1 BookmarkResult (com.quran.labs.androidquran.model.bookmark.BookmarkResult)1 QuranListAdapter (com.quran.labs.androidquran.ui.helpers.QuranListAdapter)1 List (java.util.List)1