Search in sources :

Example 1 with QariItem

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

the class PagerActivity method playFromAyah.

public void playFromAyah(SuraAyah start, SuraAyah end, int page, int verseRepeat, int rangeRepeat, boolean enforceRange, boolean force) {
    if (force) {
        shouldOverridePlaying = true;
    }
    QariItem item = audioStatusBar.getAudioInfo();
    lastAudioDownloadRequest = getAudioDownloadRequest(start, end, page, item, verseRepeat, rangeRepeat, enforceRange);
    if (quranSettings.shouldStream() && lastAudioDownloadRequest != null && !audioUtils.haveAllFiles(lastAudioDownloadRequest)) {
        playStreaming(start, end, page, item, verseRepeat, rangeRepeat, enforceRange);
    } else {
        playAudioRequest(lastAudioDownloadRequest);
    }
}
Also used : QariItem(com.quran.labs.androidquran.common.QariItem)

Example 2 with QariItem

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

the class AudioUtils method getGaplessDatabaseUrl.

public String getGaplessDatabaseUrl(DownloadAudioRequest request) {
    if (!request.isGapless()) {
        return null;
    }
    QariItem item = request.getQariItem();
    String dbname = item.getDatabaseName() + ZIP_EXTENSION;
    return quranFileUtils.getGaplessDatabaseRootUrl() + "/" + dbname;
}
Also used : QariItem(com.quran.labs.androidquran.common.QariItem)

Example 3 with QariItem

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

the class AudioManagerUtils method shuyookhDownloadObservable.

@NonNull
public static Single<List<QariDownloadInfo>> shuyookhDownloadObservable(QuranInfo quranInfo, String basePath, List<QariItem> qariItems) {
    return Observable.fromIterable(qariItems).flatMap(new Function<QariItem, ObservableSource<QariDownloadInfo>>() {

        @Override
        public ObservableSource<QariDownloadInfo> apply(QariItem item) throws Exception {
            QariDownloadInfo cached = sCache.get(item);
            if (cached != null) {
                return Observable.just(cached);
            }
            File baseFile = new File(basePath, item.getPath());
            return !baseFile.exists() ? Observable.just(new QariDownloadInfo(item)) : item.isGapless() ? getGaplessSheikhObservable(baseFile, item).toObservable() : getGappedSheikhObservable(quranInfo, baseFile, item).toObservable();
        }
    }).doOnNext(qariDownloadInfo -> sCache.put(qariDownloadInfo.qariItem, qariDownloadInfo)).toList().subscribeOn(Schedulers.io());
}
Also used : Function(io.reactivex.functions.Function) QariItem(com.quran.labs.androidquran.common.QariItem) File(java.io.File) NonNull(android.support.annotation.NonNull)

Example 4 with QariItem

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

the class AudioUtils method getQariList.

/**
 * Get a list of QariItem representing the qaris to show
 *
 * This method takes into account qaris that exist both in gapped and gapless, and, in those
 * cases, hides the gapped version if it contains no files.
 *
 * @param context the current context
 * @return a list of QariItem representing the qaris to show.
 */
public List<QariItem> getQariList(@NonNull Context context) {
    final Resources resources = context.getResources();
    final String[] shuyookh = resources.getStringArray(R.array.quran_readers_name);
    final String[] paths = resources.getStringArray(R.array.quran_readers_path);
    final String[] urls = resources.getStringArray(R.array.quran_readers_urls);
    final String[] databases = resources.getStringArray(R.array.quran_readers_db_name);
    final int[] hasGaplessEquivalent = resources.getIntArray(R.array.quran_readers_have_gapless_equivalents);
    List<QariItem> items = new ArrayList<>(shuyookh.length);
    for (int i = 0; i < shuyookh.length; i++) {
        if (hasGaplessEquivalent[i] == 0 || haveAnyFiles(context, paths[i])) {
            items.add(new QariItem(i, shuyookh[i], urls[i], paths[i], databases[i]));
        }
    }
    Collections.sort(items, (lhs, rhs) -> {
        boolean lhsGapless = lhs.isGapless();
        boolean rhsGapless = rhs.isGapless();
        if (lhsGapless != rhsGapless) {
            return lhsGapless ? -1 : 1;
        }
        return lhs.getName().compareTo(rhs.getName());
    });
    return items;
}
Also used : QariItem(com.quran.labs.androidquran.common.QariItem) ArrayList(java.util.ArrayList) Resources(android.content.res.Resources)

Aggregations

QariItem (com.quran.labs.androidquran.common.QariItem)4 Resources (android.content.res.Resources)1 NonNull (android.support.annotation.NonNull)1 Function (io.reactivex.functions.Function)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1