use of com.odysee.app.model.Claim 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.model.Claim in project odysee-android by OdyseeTeam.
the class MainActivity method fetchOwnChannels.
public void fetchOwnChannels() {
ClaimListTask task = new ClaimListTask(Claim.TYPE_CHANNEL, null, Lbryio.AUTH_TOKEN, new ClaimListResultHandler() {
@Override
public void onSuccess(List<Claim> claims) {
Lbry.ownChannels = Helper.filterDeletedClaims(new ArrayList<>(claims));
for (FetchChannelsListener listener : fetchChannelsListeners) {
listener.onChannelsFetched(claims);
}
}
@Override
public void onError(Exception error) {
Log.e("FetchingChannels", "onError: ".concat(error.getLocalizedMessage()));
}
});
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
use of com.odysee.app.model.Claim 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.model.Claim in project odysee-android by OdyseeTeam.
the class ChannelFilterListAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(ChannelFilterListAdapter.ViewHolder vh, int position) {
Claim claim = items.get(position);
vh.alphaView.setVisibility(claim.isPlaceholder() ? View.GONE : View.VISIBLE);
vh.titleView.setVisibility(claim.isPlaceholder() ? View.INVISIBLE : View.VISIBLE);
vh.allView.setVisibility(claim.isPlaceholder() ? View.VISIBLE : View.GONE);
vh.titleView.setText(Helper.isNullOrEmpty(claim.getTitle()) ? claim.getName() : claim.getTitle());
String thumbnailUrl = claim.getThumbnailUrl(vh.thumbnailView.getLayoutParams().width, vh.thumbnailView.getLayoutParams().height, 85);
if (!Helper.isNullOrEmpty(thumbnailUrl) && context != null) {
Glide.with(context.getApplicationContext()).load(thumbnailUrl).apply(RequestOptions.circleCropTransform()).into(vh.thumbnailView);
}
vh.alphaContainer.setVisibility(claim.isPlaceholder() || Helper.isNullOrEmpty(thumbnailUrl) ? View.VISIBLE : View.GONE);
vh.thumbnailView.setVisibility(claim.isPlaceholder() || Helper.isNullOrEmpty(thumbnailUrl) ? View.GONE : View.VISIBLE);
vh.alphaView.setText(claim.isPlaceholder() ? null : claim.getName() != null ? claim.getName().substring(1, 2).toUpperCase() : "");
int bgColor = Helper.generateRandomColorForValue(claim.getClaimId());
Helper.setIconViewBackgroundColor(vh.alphaContainer, bgColor, claim.isPlaceholder(), context);
vh.itemView.setSelected(isClaimSelected(claim));
vh.itemView.setOnClickListener(view -> {
if (claim.isPlaceholder()) {
selectedItem = null;
if (listener != null) {
listener.onChannelSelectionCleared();
}
} else if (!claim.equals(selectedItem)) {
selectedItem = claim;
if (listener != null) {
listener.onChannelItemSelected(claim);
}
}
notifyDataSetChanged();
});
}
use of com.odysee.app.model.Claim in project odysee-android by OdyseeTeam.
the class ClaimListAdapter method updateFileForClaimByIdOrUrl.
public void updateFileForClaimByIdOrUrl(LbryFile file, String claimId, String url, boolean skipNotFound) {
if (!skipNotFound) {
if (notFoundClaimIdMap.containsKey(claimId) && notFoundClaimUrlMap.containsKey(url)) {
return;
}
}
if (quickClaimIdMap.containsKey(claimId)) {
quickClaimIdMap.get(claimId).setFile(file);
notifyDataSetChanged();
return;
}
if (quickClaimUrlMap.containsKey(claimId)) {
quickClaimUrlMap.get(claimId).setFile(file);
notifyDataSetChanged();
return;
}
boolean claimFound = false;
for (int i = 0; i < items.size(); i++) {
Claim claim = items.get(i);
if (claimId.equalsIgnoreCase(claim.getClaimId()) || url.equalsIgnoreCase(claim.getPermanentUrl())) {
quickClaimIdMap.put(claimId, claim);
quickClaimUrlMap.put(url, claim);
claim.setFile(file);
notifyDataSetChanged();
claimFound = true;
break;
}
}
if (!claimFound) {
notFoundClaimIdMap.put(claimId, true);
notFoundClaimUrlMap.put(url, true);
}
}
Aggregations