use of com.odysee.app.tasks.claim.ResolveTask in project odysee-android by OdyseeTeam.
the class MainActivity method resolveUrlSuggestions.
private void resolveUrlSuggestions(List<String> urls) {
ResolveTask task = new ResolveTask(urls, Lbry.API_CONNECTION_STRING, null, new ClaimListResultHandler() {
@Override
public void onSuccess(List<Claim> claims) {
if (findViewById(R.id.url_suggestions_container).getVisibility() == View.VISIBLE) {
for (int i = 0; i < claims.size(); i++) {
// build a simple url from the claim for matching
Claim claim = claims.get(i);
Claim actualClaim = claim;
boolean isRepost = false;
if (Claim.TYPE_REPOST.equalsIgnoreCase(claim.getValueType())) {
actualClaim = claim.getRepostedClaim();
isRepost = true;
}
if (Helper.isNullOrEmpty(claim.getName())) {
continue;
}
LbryUri simpleUrl = new LbryUri();
if (actualClaim.getName().startsWith("@") && !isRepost) {
// channel
simpleUrl.setChannelName(actualClaim.getName());
} else {
simpleUrl.setStreamName(claim.getName());
}
urlSuggestionListAdapter.setClaimForUrl(simpleUrl, actualClaim);
}
urlSuggestionListAdapter.notifyDataSetChanged();
}
}
@Override
public void onError(Exception error) {
}
});
task.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
}
use of com.odysee.app.tasks.claim.ResolveTask in project odysee-android by OdyseeTeam.
the class MainActivity method resolveCommentAuthors.
private void resolveCommentAuthors(List<String> urls) {
if (urls != null && !urls.isEmpty()) {
ResolveTask task = new ResolveTask(urls, Lbry.API_CONNECTION_STRING, null, new ClaimListResultHandler() {
@Override
public void onSuccess(List<Claim> claims) {
if (notificationListAdapter != null) {
notificationListAdapter.updateAuthorClaims(claims);
}
}
@Override
public void onError(Exception error) {
// pass
}
});
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
use of com.odysee.app.tasks.claim.ResolveTask 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.ResolveTask 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);
}
Aggregations