use of com.odysee.app.tasks.file.GetFileTask in project odysee-android by OdyseeTeam.
the class FileViewFragment method fileGet.
private void fileGet(boolean save) {
if (getFileTask != null && getFileTask.getStatus() != AsyncTask.Status.FINISHED) {
return;
}
Claim actualClaim = collectionClaimItem != null ? collectionClaimItem : fileClaim;
getFileTask = new GetFileTask(actualClaim.getPermanentUrl(), save, null, new GetFileTask.GetFileHandler() {
@Override
public void beforeStart() {
}
@Override
public void onSuccess(LbryFile file, boolean saveFile) {
// queue the download
if (actualClaim != null) {
if (actualClaim.isFree()) {
// paid is handled differently
Bundle bundle = new Bundle();
bundle.putString("uri", currentUrl);
bundle.putString("paid", "false");
LbryAnalytics.logEvent(LbryAnalytics.EVENT_PURCHASE_URI, bundle);
}
if (!actualClaim.isPlayable()) {
logFileView(actualClaim.getPermanentUrl(), 0);
}
actualClaim.setFile(file);
playOrViewMedia();
}
}
@Override
public void onError(Exception error, boolean saveFile) {
try {
showError(getString(R.string.unable_to_view_url, currentUrl));
if (saveFile) {
onDownloadAborted();
}
restoreMainActionButton();
} catch (IllegalStateException ex) {
// pass
}
}
});
getFileTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Aggregations