use of com.odysee.app.tasks.claim.ResolveTask in project odysee-android by OdyseeTeam.
the class FileViewFragment method resolveUrl.
private void resolveUrl(String url) {
// resolving = true;
Helper.setViewVisibility(layoutDisplayArea, View.INVISIBLE);
Helper.setViewVisibility(layoutLoadingState, View.VISIBLE);
Helper.setViewVisibility(layoutNothingAtLocation, View.GONE);
ResolveTask task = new ResolveTask(url, Lbry.API_CONNECTION_STRING, layoutResolving, new ClaimListResultHandler() {
@Override
public void onSuccess(List<Claim> claims) {
if (!claims.isEmpty() && !Helper.isNullOrEmpty(claims.get(0).getClaimId())) {
fileClaim = claims.get(0);
if (Claim.TYPE_REPOST.equalsIgnoreCase(fileClaim.getValueType())) {
fileClaim = fileClaim.getRepostedClaim();
// cache the reposted claim too for subsequent loads
Lbry.addClaimToCache(fileClaim);
if (fileClaim.getName().startsWith("@")) {
// this is a reposted channel, so finish this activity and launch the channel url
Context context = getContext();
if (context instanceof MainActivity) {
MainActivity activity = (MainActivity) context;
activity.getSupportFragmentManager().popBackStack();
activity.openChannelUrl(!Helper.isNullOrEmpty(fileClaim.getShortUrl()) ? fileClaim.getShortUrl() : fileClaim.getPermanentUrl());
}
return;
}
} else {
Lbry.addClaimToCache(fileClaim);
}
if (Claim.TYPE_COLLECTION.equalsIgnoreCase(fileClaim.getValueType()) && fileClaim.getClaimIds() != null && fileClaim.getClaimIds().size() > 0) {
collectionClaimItem = null;
}
Helper.saveUrlHistory(url, fileClaim.getTitle(), UrlSuggestion.TYPE_FILE);
// do not save collections to view history
if (!Claim.TYPE_COLLECTION.equalsIgnoreCase(fileClaim.getType())) {
// also save view history
Helper.saveViewHistory(url, fileClaim);
}
checkAndResetNowPlayingClaim();
if (Helper.isClaimBlocked(fileClaim)) {
renderClaimBlocked();
} else {
loadFile();
checkAndLoadRelatedContent();
checkAndLoadComments();
renderClaim();
}
} else {
// render nothing at location
renderNothingAtLocation();
}
}
@Override
public void onError(Exception error) {
// resolving = false;
}
});
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
use of com.odysee.app.tasks.claim.ResolveTask in project odysee-android by OdyseeTeam.
the class ChannelFragment method resolveUrl.
private void resolveUrl() {
Helper.setViewVisibility(layoutDisplayArea, View.INVISIBLE);
Helper.setViewVisibility(layoutLoadingState, View.VISIBLE);
ResolveTask task = new ResolveTask(currentUrl, Lbry.API_CONNECTION_STRING, layoutResolving, new ClaimListResultHandler() {
@Override
public void onSuccess(List<Claim> claims) {
if (claims.size() > 0 && !Helper.isNullOrEmpty(claims.get(0).getClaimId())) {
claim = claims.get(0);
if (!Helper.isNullOrEmpty(currentUrl)) {
Helper.saveUrlHistory(currentUrl, claim.getTitle(), UrlSuggestion.TYPE_CHANNEL);
}
renderClaim();
checkOwnChannel();
} else {
renderNothingAtLocation();
}
}
@Override
public void onError(Exception error) {
renderNothingAtLocation();
}
});
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
use of com.odysee.app.tasks.claim.ResolveTask in project odysee-android by OdyseeTeam.
the class FollowingFragment method fetchAndResolveChannelList.
private void fetchAndResolveChannelList() {
buildChannelIdsAndUrls();
if (!channelIds.isEmpty()) {
ResolveTask resolveSubscribedTask = new ResolveTask(channelUrls, Lbry.API_CONNECTION_STRING, channelListLoading, new ClaimListResultHandler() {
@Override
public void onSuccess(List<Claim> claims) {
updateChannelFilterListAdapter(claims, true);
Lbryio.cacheResolvedSubscriptions = claims;
}
@Override
public void onError(Exception error) {
handler.postDelayed(FollowingFragment.this::fetchAndResolveChannelList, 5_000);
}
});
resolveSubscribedTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
fetchClaimSearchContent();
}
}
use of com.odysee.app.tasks.claim.ResolveTask in project odysee-android by OdyseeTeam.
the class LibraryFragment method resolveMissingChannelNames.
private void resolveMissingChannelNames(List<String> urls) {
if (urls.size() > 0) {
ResolveTask task = new ResolveTask(urls, Lbry.API_CONNECTION_STRING, null, new ClaimListResultHandler() {
@Override
public void onSuccess(List<Claim> claims) {
boolean updated = false;
for (Claim claim : claims) {
if (claim.getClaimId() == null) {
continue;
}
if (contentListAdapter != null) {
contentListAdapter.updateSigningChannelForClaim(claim);
updated = true;
}
}
if (updated) {
contentListAdapter.notifyDataSetChanged();
}
}
@Override
public void onError(Exception error) {
}
});
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
use of com.odysee.app.tasks.claim.ResolveTask in project odysee-android by OdyseeTeam.
the class FileViewFragment method resolveCommentPosters.
private void resolveCommentPosters() {
if (commentListAdapter != null) {
long st = System.currentTimeMillis();
List<String> urlsToResolve = new ArrayList<>(commentListAdapter.getClaimUrlsToResolve());
if (urlsToResolve.size() > 0) {
ResolveTask task = new ResolveTask(urlsToResolve, Lbry.API_CONNECTION_STRING, null, new ClaimListResultHandler() {
@Override
public void onSuccess(List<Claim> claims) {
if (commentListAdapter != null) {
for (Claim claim : claims) {
if (claim.getClaimId() != null) {
commentListAdapter.updatePosterForComment(claim.getClaimId(), claim);
}
}
// filter for blocked comments
commentListAdapter.filterBlockedChannels(Lbryio.blockedChannels);
commentListAdapter.notifyDataSetChanged();
}
}
@Override
public void onError(Exception error) {
// pass
}
});
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
}
Aggregations