Search in sources :

Example 1 with FileListTask

use of com.odysee.app.tasks.file.FileListTask in project odysee-android by OdyseeTeam.

the class FileViewFragment method tryOpenFileOrFileGet.

private void tryOpenFileOrFileGet() {
    Claim actualClaim = collectionClaimItem != null ? collectionClaimItem : fileClaim;
    if (actualClaim != null) {
        String claimId = actualClaim.getClaimId();
        FileListTask task = new FileListTask(claimId, null, new FileListTask.FileListResultHandler() {

            @Override
            public void onSuccess(List<LbryFile> files, boolean hasReachedEnd) {
                if (files.size() > 0) {
                    actualClaim.setFile(files.get(0));
                    handleMainActionForClaim();
                    checkIsFileComplete();
                } else {
                    checkStoragePermissionAndFileGet();
                }
            }

            @Override
            public void onError(Exception error) {
                checkStoragePermissionAndFileGet();
            }
        });
        task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    }
}
Also used : FileListTask(com.odysee.app.tasks.file.FileListTask) LbryFile(com.odysee.app.model.LbryFile) TrackSelectionOverride(com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride) Claim(com.odysee.app.model.Claim) LbryRequestException(com.odysee.app.exceptions.LbryRequestException) JSONException(org.json.JSONException) LbryUriException(com.odysee.app.exceptions.LbryUriException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) LbryResponseException(com.odysee.app.exceptions.LbryResponseException) LbryioRequestException(com.odysee.app.exceptions.LbryioRequestException) LbryioResponseException(com.odysee.app.exceptions.LbryioResponseException) ApiCallException(com.odysee.app.exceptions.ApiCallException)

Example 2 with FileListTask

use of com.odysee.app.tasks.file.FileListTask in project odysee-android by OdyseeTeam.

the class LibraryFragment method fetchDownloads.

private void fetchDownloads() {
    contentListLoading = true;
    Helper.setViewVisibility(linkStats, View.GONE);
    Helper.setViewVisibility(layoutListEmpty, View.GONE);
    FileListTask task = new FileListTask(currentPage, PAGE_SIZE, true, listLoading, new FileListTask.FileListResultHandler() {

        @Override
        public void onSuccess(List<LbryFile> files, boolean hasReachedEnd) {
            listReachedEnd = hasReachedEnd;
            List<LbryFile> filteredFiles = Helper.filterDownloads(files);
            List<Claim> claims = Helper.claimsFromFiles(filteredFiles);
            addFiles(filteredFiles);
            updateStats();
            checkStatsLink();
            if (contentListAdapter == null) {
                initContentListAdapter(claims);
            } else {
                contentListAdapter.addItems(claims);
            }
            if (contentListAdapter != null && contentList.getAdapter() == null) {
                contentList.setAdapter(contentListAdapter);
            }
            resolveMissingChannelNames(buildUrlsToResolve(claims));
            checkListEmpty();
            contentListLoading = false;
        }

        @Override
        public void onError(Exception error) {
            // pass
            checkStatsLink();
            checkListEmpty();
            contentListLoading = false;
        }
    });
    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Also used : FileListTask(com.odysee.app.tasks.file.FileListTask) LbryFile(com.odysee.app.model.LbryFile) List(java.util.List) ArrayList(java.util.ArrayList) JSONException(org.json.JSONException) ApiCallException(com.odysee.app.exceptions.ApiCallException)

Example 3 with FileListTask

use of com.odysee.app.tasks.file.FileListTask in project odysee-android by OdyseeTeam.

the class FileViewFragment method loadFile.

private void loadFile() {
    Claim actualClaim = collectionClaimItem != null ? collectionClaimItem : fileClaim;
    String claimId = actualClaim.getClaimId();
    FileListTask task = new FileListTask(claimId, null, new FileListTask.FileListResultHandler() {

        @Override
        public void onSuccess(List<LbryFile> files, boolean hasReachedEnd) {
            if (files.size() > 0) {
                actualClaim.setFile(files.get(0));
                checkIsFileComplete();
                if (!actualClaim.isPlayable() && !actualClaim.isViewable()) {
                    showUnsupportedView();
                }
            } else {
                if (!actualClaim.isPlayable() && !actualClaim.isViewable()) {
                    restoreMainActionButton();
                }
            }
        // initialFileLoadDone = true;
        }

        @Override
        public void onError(Exception error) {
        // initialFileLoadDone = true;
        }
    });
    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Also used : FileListTask(com.odysee.app.tasks.file.FileListTask) LbryFile(com.odysee.app.model.LbryFile) TrackSelectionOverride(com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride) Claim(com.odysee.app.model.Claim) LbryRequestException(com.odysee.app.exceptions.LbryRequestException) JSONException(org.json.JSONException) LbryUriException(com.odysee.app.exceptions.LbryUriException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) LbryResponseException(com.odysee.app.exceptions.LbryResponseException) LbryioRequestException(com.odysee.app.exceptions.LbryioRequestException) LbryioResponseException(com.odysee.app.exceptions.LbryioResponseException) ApiCallException(com.odysee.app.exceptions.ApiCallException)

Aggregations

ApiCallException (com.odysee.app.exceptions.ApiCallException)3 LbryFile (com.odysee.app.model.LbryFile)3 FileListTask (com.odysee.app.tasks.file.FileListTask)3 JSONException (org.json.JSONException)3 TrackSelectionOverride (com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride)2 LbryRequestException (com.odysee.app.exceptions.LbryRequestException)2 LbryResponseException (com.odysee.app.exceptions.LbryResponseException)2 LbryUriException (com.odysee.app.exceptions.LbryUriException)2 LbryioRequestException (com.odysee.app.exceptions.LbryioRequestException)2 LbryioResponseException (com.odysee.app.exceptions.LbryioResponseException)2 Claim (com.odysee.app.model.Claim)2 IOException (java.io.IOException)2 ExecutionException (java.util.concurrent.ExecutionException)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1