@Override protected Rect doInBackground(Void... params) { if (mAyahInfoDatabaseHandler == null) { return null; } return mAyahInfoDatabaseHandler.getPageBounds(mPageNumber); }
@Override protected Map<String, List<AyahBounds>> doInBackground(Void... params) { if (mAyahInfoDatabaseHandler == null) { return null; } Cursor cursor; try { cursor = mAyahInfoDatabaseHandler.getVersesBoundsForPage(mPageNumber); } catch (Exception e) { // happens when the glyphs table doesn't exist somehow return null; } if (cursor == null || !cursor.moveToFirst()) { return null; } Map<String, List<AyahBounds>> map = new HashMap<String, List<AyahBounds>>(); do { int sura = cursor.getInt(2); int ayah = cursor.getInt(3); String key = sura + ":" + ayah; List<AyahBounds> bounds = map.get(key); if (bounds == null) { bounds = new ArrayList<AyahBounds>(); } 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); } map.put(key, bounds); } while (cursor.moveToNext()); cursor.close(); return map; }