use of com.odysee.app.tasks.claim.ClaimListResultHandler in project odysee-android by OdyseeTeam.
the class InvitesFragment method fetchChannels.
private void fetchChannels() {
if (Lbry.ownChannels != null && Lbry.ownChannels.size() > 0) {
updateChannelList(Lbry.ownChannels);
return;
}
fetchingChannels = true;
disableChannelSpinner();
ClaimListTask task = new ClaimListTask(Claim.TYPE_CHANNEL, progressLoadingChannels, new ClaimListResultHandler() {
@Override
public void onSuccess(List<Claim> claims) {
Lbry.ownChannels = new ArrayList<>(claims);
updateChannelList(Lbry.ownChannels);
if (Lbry.ownChannels == null || Lbry.ownChannels.size() == 0) {
fetchDefaultInviteLink();
}
enableChannelSpinner();
fetchingChannels = false;
}
@Override
public void onError(Exception error) {
fetchDefaultInviteLink();
enableChannelSpinner();
fetchingChannels = false;
}
});
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
use of com.odysee.app.tasks.claim.ClaimListResultHandler in project odysee-android by OdyseeTeam.
the class MainActivity method fetchOwnClaims.
public void fetchOwnClaims() {
ClaimListTask task = new ClaimListTask(Arrays.asList(Claim.TYPE_STREAM, Claim.TYPE_REPOST), null, new ClaimListResultHandler() {
@Override
public void onSuccess(List<Claim> claims) {
Lbry.ownClaims = Helper.filterDeletedClaims(new ArrayList<>(claims));
for (FetchClaimsListener listener : fetchClaimsListeners) {
listener.onClaimsFetched(claims);
}
}
@Override
public void onError(Exception error) {
}
});
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
use of com.odysee.app.tasks.claim.ClaimListResultHandler 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.ClaimListResultHandler 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.ClaimListResultHandler 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();
}
}
Aggregations