Search in sources :

Example 1 with TranslationHeader

use of com.quran.labs.androidquran.dao.translation.TranslationHeader in project quran_android by quran.

the class TranslationManagerActivity method generateListItems.

private void generateListItems() {
    if (allItems == null) {
        return;
    }
    List<TranslationItem> downloaded = new ArrayList<>();
    List<TranslationItem> notDownloaded = new ArrayList<>();
    for (int i = 0, mAllItemsSize = allItems.size(); i < mAllItemsSize; i++) {
        TranslationItem item = allItems.get(i);
        if (item.exists()) {
            downloaded.add(item);
        } else {
            notDownloaded.add(item);
        }
    }
    List<TranslationRowData> result = new ArrayList<>();
    if (downloaded.size() > 0) {
        TranslationHeader hdr = new TranslationHeader(getString(R.string.downloaded_translations));
        result.add(hdr);
        boolean needsUpgrade = false;
        for (TranslationItem item : downloaded) {
            result.add(item);
            needsUpgrade = needsUpgrade || item.needsUpgrade();
        }
        if (!needsUpgrade) {
            quranSettings.setHaveUpdatedTranslations(false);
        }
    }
    result.add(new TranslationHeader(getString(R.string.available_translations)));
    result.addAll(notDownloaded);
    adapter.setTranslations(result);
    adapter.notifyDataSetChanged();
}
Also used : TranslationItem(com.quran.labs.androidquran.dao.translation.TranslationItem) TranslationHeader(com.quran.labs.androidquran.dao.translation.TranslationHeader) ArrayList(java.util.ArrayList) TranslationRowData(com.quran.labs.androidquran.dao.translation.TranslationRowData)

Aggregations

TranslationHeader (com.quran.labs.androidquran.dao.translation.TranslationHeader)1 TranslationItem (com.quran.labs.androidquran.dao.translation.TranslationItem)1 TranslationRowData (com.quran.labs.androidquran.dao.translation.TranslationRowData)1 ArrayList (java.util.ArrayList)1