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;
}
Aggregations