use of com.odysee.app.model.LbryFile in project odysee-android by OdyseeTeam.
the class ChannelContentFragment method onDownloadAction.
public void onDownloadAction(String downloadAction, String uri, String outpoint, String fileInfoJson, double progress) {
if ("abort".equals(downloadAction)) {
if (contentListAdapter != null) {
contentListAdapter.clearFileForClaimOrUrl(outpoint, uri);
}
return;
}
try {
JSONObject fileInfo = new JSONObject(fileInfoJson);
LbryFile claimFile = LbryFile.fromJSONObject(fileInfo);
String claimId = claimFile.getClaimId();
if (contentListAdapter != null) {
contentListAdapter.updateFileForClaimByIdOrUrl(claimFile, claimId, uri);
}
} catch (JSONException ex) {
// invalid file info for download
}
}
use of com.odysee.app.model.LbryFile 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);
}
use of com.odysee.app.model.LbryFile 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);
}
use of com.odysee.app.model.LbryFile in project odysee-android by OdyseeTeam.
the class AllContentFragment method onDownloadAction.
public void onDownloadAction(String downloadAction, String uri, String outpoint, String fileInfoJson, double progress) {
if ("abort".equals(downloadAction)) {
if (contentListAdapter != null) {
contentListAdapter.clearFileForClaimOrUrl(outpoint, uri);
}
return;
}
try {
JSONObject fileInfo = new JSONObject(fileInfoJson);
LbryFile claimFile = LbryFile.fromJSONObject(fileInfo);
String claimId = claimFile.getClaimId();
if (contentListAdapter != null) {
contentListAdapter.updateFileForClaimByIdOrUrl(claimFile, claimId, uri);
}
} catch (JSONException ex) {
// invalid file info for download
}
}
use of com.odysee.app.model.LbryFile in project odysee-android by OdyseeTeam.
the class GetFileTask method doInBackground.
protected LbryFile doInBackground(Void... params) {
LbryFile file = null;
try {
Map<String, Object> options = new HashMap<>();
options.put("uri", uri);
options.put("save_file", saveFile);
JSONObject streamInfo = (JSONObject) Lbry.genericApiCall("get", options);
if (streamInfo.has("error")) {
throw new ApiCallException(Helper.getJSONString("error", "", streamInfo));
}
file = LbryFile.fromJSONObject(streamInfo);
} catch (ApiCallException ex) {
error = ex;
}
return file;
}
Aggregations