use of com.odysee.app.tasks.claim.ClaimListResultHandler in project odysee-android by OdyseeTeam.
the class FirstRunActivity method checkChannelStep.
private void checkChannelStep() {
ClaimListTask task = new ClaimListTask(Claim.TYPE_CHANNEL, null, Lbryio.AUTH_TOKEN, new ClaimListResultHandler() {
@Override
public void onSuccess(List<Claim> claims) {
onRequestInProgress(false);
if (claims.size() == 0) {
// no channels, move to first run step: channel
checkEmailVerifiedRewardForChannelStep();
} else {
// this user already has a channel, move to the final step: rewards verification
proceedToRewardsStep();
}
}
@Override
public void onError(Exception error) {
checkEmailVerifiedRewardForChannelStep();
// onRequestCompleted(FIRST_RUN_STEP_CHANNEL);
}
});
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
use of com.odysee.app.tasks.claim.ClaimListResultHandler in project odysee-android by OdyseeTeam.
the class SearchFragment method resolveFeaturedItem.
private void resolveFeaturedItem(String vanityUrl) {
final ClaimCacheKey key = new ClaimCacheKey();
key.setUrl(vanityUrl);
if (Lbry.claimCache.containsKey(key)) {
Claim cachedClaim = Lbry.claimCache.get(key);
updateFeaturedItemFromResolvedClaim(cachedClaim);
return;
}
ResolveTask task = new ResolveTask(vanityUrl, Lbry.API_CONNECTION_STRING, null, new ClaimListResultHandler() {
@Override
public void onSuccess(List<Claim> claims) {
if (claims.size() > 0 && !Helper.isNullOrEmpty(claims.get(0).getClaimId())) {
Claim resolved = claims.get(0);
Lbry.claimCache.put(key, resolved);
updateFeaturedItemFromResolvedClaim(resolved);
}
}
@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 LibraryFragment method fetchOwnClaimsAndShowDownloads.
private void fetchOwnClaimsAndShowDownloads() {
if (Lbry.ownClaims != null && Lbry.ownClaims.size() > 0) {
initialOwnClaimsFetched = true;
fetchDownloads();
return;
}
linkStats.setVisibility(View.INVISIBLE);
ClaimListTask task = new ClaimListTask(Arrays.asList(Claim.TYPE_STREAM, Claim.TYPE_REPOST), listLoading, new ClaimListResultHandler() {
@Override
public void onSuccess(List<Claim> claims) {
Lbry.ownClaims = Helper.filterDeletedClaims(new ArrayList<>(claims));
initialOwnClaimsFetched = true;
if (currentFilter == FILTER_DOWNLOADS) {
fetchDownloads();
}
checkStatsLink();
}
@Override
public void onError(Exception error) {
initialOwnClaimsFetched = true;
checkStatsLink();
}
});
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
use of com.odysee.app.tasks.claim.ClaimListResultHandler in project odysee-android by OdyseeTeam.
the class PlaylistFragment method onPlaylistLoaded.
private void onPlaylistLoaded(OdyseeCollection collection) {
currentCollection = collection;
if (visibilityIcon != null) {
visibilityIcon.setImageResource(collection.getVisibility() == OdyseeCollection.VISIBILITY_PRIVATE ? R.drawable.ic_private : R.drawable.ic_public);
}
Helper.setViewText(textTitle, collection.getName());
Helper.setViewText(textVideoCount, getResources().getQuantityString(R.plurals.video_count, collection.getItems().size(), collection.getItems().size()));
// load the claims
ResolveTask task = new ResolveTask(collection.getItems(), Lbry.API_CONNECTION_STRING, playlistItemsLoading, new ClaimListResultHandler() {
@Override
public void onSuccess(List<Claim> claims) {
// reorder the claims based on the order in the playlist collection, TODO: find a more efficient way to do this
Map<String, Claim> playlistClaimMap = new LinkedHashMap<>();
List<String> claimIds = new ArrayList<>();
List<String> collectionItems = collection.getItems();
for (int i = 0; i < collectionItems.size(); i++) {
LbryUri url = LbryUri.tryParse(collectionItems.get(i));
if (url != null) {
claimIds.add(url.getClaimId());
}
}
for (String id : claimIds) {
for (Claim claim : claims) {
if (id.equalsIgnoreCase(claim.getClaimId())) {
playlistClaimMap.put(id, claim);
break;
}
}
}
collection.setClaims(new ArrayList<>(playlistClaimMap.values()));
adapter = new ClaimListAdapter(collection.getClaims(), ClaimListAdapter.STYLE_SMALL_LIST, getContext());
adapter.setListener(new ClaimListAdapter.ClaimListItemListener() {
@Override
public void onClaimClicked(Claim claim, int position) {
Context context = getContext();
if (context instanceof MainActivity) {
((MainActivity) context).openPrivatePlaylist(collection, claim, position);
}
}
});
if (playlistList != null) {
playlistList.setAdapter(adapter);
}
}
@Override
public void onError(Exception error) {
// pass
Context context = getContext();
if (context instanceof MainActivity) {
((MainActivity) context).showError(getString(R.string.could_not_load_playlist));
}
}
});
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
use of com.odysee.app.tasks.claim.ClaimListResultHandler in project odysee-android by OdyseeTeam.
the class PublishFormFragment 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);
enableChannelSpinner();
fetchingChannels = false;
}
@Override
public void onError(Exception error) {
enableChannelSpinner();
fetchingChannels = false;
}
});
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Aggregations