Search in sources :

Example 6 with AyahBounds

use of com.quran.labs.androidquran.common.AyahBounds in project quran_android by quran.

the class AyahInfoDatabaseHandler method getVersesBoundsForPage.

@NonNull
public Map<String, List<AyahBounds>> getVersesBoundsForPage(int page) {
    Map<String, List<AyahBounds>> result = new HashMap<>();
    Cursor cursor = null;
    try {
        cursor = getVersesBoundsCursorForPage(page);
        while (cursor.moveToNext()) {
            int sura = cursor.getInt(2);
            int ayah = cursor.getInt(3);
            String key = sura + ":" + ayah;
            List<AyahBounds> bounds = result.get(key);
            if (bounds == null) {
                bounds = new ArrayList<>();
            }
            AyahBounds last = null;
            if (bounds.size() > 0) {
                last = bounds.get(bounds.size() - 1);
            }
            AyahBounds bound = new AyahBounds(cursor.getInt(1), cursor.getInt(4), cursor.getInt(5), cursor.getInt(6), cursor.getInt(7), cursor.getInt(8));
            if (last != null && last.getLine() == bound.getLine()) {
                last.engulf(bound);
            } else {
                bounds.add(bound);
            }
            result.put(key, bounds);
        }
    } finally {
        DatabaseUtils.closeCursor(cursor);
    }
    return result;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) Cursor(android.database.Cursor) AyahBounds(com.quran.labs.androidquran.common.AyahBounds) NonNull(android.support.annotation.NonNull)

Aggregations

AyahBounds (com.quran.labs.androidquran.common.AyahBounds)6 RectF (android.graphics.RectF)4 ArrayList (java.util.ArrayList)3 List (java.util.List)2 Cursor (android.database.Cursor)1 Matrix (android.graphics.Matrix)1 Paint (android.graphics.Paint)1 Drawable (android.graphics.drawable.Drawable)1 NonNull (android.support.annotation.NonNull)1 AttributeSet (android.util.AttributeSet)1 SparseArray (android.util.SparseArray)1 HighlightType (com.quran.labs.androidquran.ui.helpers.HighlightType)1 AyahToolBar (com.quran.labs.androidquran.widgets.AyahToolBar)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1 SortedMap (java.util.SortedMap)1 TreeMap (java.util.TreeMap)1