use of com.odysee.app.model.Claim in project odysee-android by OdyseeTeam.
the class ClaimListAdapter method addItems.
public void addItems(List<Claim> claims) {
final int initialCount = items.size();
for (Claim claim : claims) {
if (claim != null) {
boolean c = items.stream().anyMatch(p -> p.getClaimId() != null && p.getClaimId().equalsIgnoreCase(claim.getClaimId()));
if (!c) {
items.add(claim);
}
}
}
notifyItemRangeInserted(initialCount, items.size() - initialCount);
notFoundClaimUrlMap.clear();
notFoundClaimIdMap.clear();
}
use of com.odysee.app.model.Claim in project odysee-android by OdyseeTeam.
the class ClaimListAdapter method filterBlockedChannels.
public void filterBlockedChannels(List<LbryUri> blockedChannels) {
if (blockedChannels.size() == 0) {
return;
}
List<String> blockedChannelClaimIds = new ArrayList<>();
for (LbryUri uri : blockedChannels) {
blockedChannelClaimIds.add(uri.getClaimId());
}
for (Claim claim : items) {
if (claim.getSigningChannel() != null && blockedChannelClaimIds.contains(claim.getSigningChannel().getClaimId())) {
int position = items.indexOf(claim);
items.remove(claim);
notifyItemRemoved(position);
}
}
}
use of com.odysee.app.model.Claim in project odysee-android by OdyseeTeam.
the class CommentListAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
Comment comment = items.get(position);
switchViewReplies(comment, (TextView) holder.viewReplies);
ViewGroup.LayoutParams lp = holder.itemView.getLayoutParams();
if (collapsed || (comment.getParentId() != null && !childsToBeShown.contains(comment.getParentId()))) {
holder.itemView.setVisibility(View.GONE);
lp.height = 0;
lp.width = 0;
holder.itemView.setLayoutParams(lp);
} else {
if (comment.getParentId() == null || (comment.getParentId() != null && childsToBeShown.contains(comment.getParentId()))) {
lp.height = ViewGroup.LayoutParams.WRAP_CONTENT;
lp.width = ViewGroup.LayoutParams.MATCH_PARENT;
holder.itemView.setLayoutParams(lp);
holder.itemView.setVisibility(View.VISIBLE);
}
}
holder.comment = comment;
holder.blockChannelView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Claim channel = comment.getPoster();
if (channel != null) {
if (context instanceof MainActivity) {
((MainActivity) context).handleBlockChannel(channel);
}
}
}
});
if (CommentAction.areAnyActionsAvailable(comment, claim)) {
holder.moreOptionsView.setVisibility(collapsed ? View.INVISIBLE : View.VISIBLE);
holder.moreOptionsView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
view.showContextMenu();
}
});
} else {
holder.moreOptionsView.setVisibility(View.INVISIBLE);
holder.moreOptionsView.setOnClickListener(null);
}
holder.channelName.setText(comment.getChannelName());
holder.commentTimeView.setText(DateUtils.getRelativeTimeSpanString((comment.getTimestamp() * 1000), System.currentTimeMillis(), 0, DateUtils.FORMAT_ABBREV_RELATIVE));
holder.commentText.setText(comment.getText());
Reactions commentReactions = comment.getReactions();
if (commentReactions != null) {
int countTextColor;
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) {
countTextColor = context.getResources().getColor(R.color.foreground, null);
} else {
countTextColor = context.getResources().getColor(R.color.foreground);
}
String likesAmount = String.valueOf(commentReactions.getOthersLikes());
String dislikesAmount = String.valueOf(commentReactions.getOthersDislikes());
if (commentReactions.isLiked()) {
int fireActive;
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) {
fireActive = context.getResources().getColor(R.color.fireActive, null);
} else {
fireActive = context.getResources().getColor(R.color.fireActive);
}
holder.likesCount.setText(String.valueOf(Integer.parseInt(likesAmount) + 1));
holder.likesCount.setTextColor(fireActive);
for (Drawable d : holder.likesCount.getCompoundDrawablesRelative()) {
if (d != null) {
d.setColorFilter(new PorterDuffColorFilter(ContextCompat.getColor(holder.likesCount.getContext(), R.color.fireActive), PorterDuff.Mode.SRC_IN));
}
}
} else {
holder.likesCount.setText(likesAmount);
holder.likesCount.setTextColor(countTextColor);
for (Drawable d : holder.likesCount.getCompoundDrawablesRelative()) {
if (d != null) {
d.setColorFilter(new PorterDuffColorFilter(ContextCompat.getColor(holder.likesCount.getContext(), R.color.foreground), PorterDuff.Mode.SRC_IN));
}
}
}
if (commentReactions.isDisliked()) {
int slimeActive;
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) {
slimeActive = context.getResources().getColor(R.color.slimeActive, null);
} else {
slimeActive = context.getResources().getColor(R.color.slimeActive);
}
holder.dislikesCount.setText(String.valueOf(Integer.parseInt(dislikesAmount) + 1));
holder.dislikesCount.setTextColor(slimeActive);
for (Drawable d : holder.dislikesCount.getCompoundDrawablesRelative()) {
if (d != null) {
d.setColorFilter(new PorterDuffColorFilter(ContextCompat.getColor(holder.dislikesCount.getContext(), R.color.slimeActive), PorterDuff.Mode.SRC_IN));
}
}
} else {
holder.dislikesCount.setText(dislikesAmount);
holder.dislikesCount.setTextColor(countTextColor);
for (Drawable d : holder.dislikesCount.getCompoundDrawablesRelative()) {
if (d != null) {
d.setColorFilter(new PorterDuffColorFilter(ContextCompat.getColor(holder.dislikesCount.getContext(), R.color.foreground), PorterDuff.Mode.SRC_IN));
}
}
}
}
holder.likesCount.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AccountManager am = AccountManager.get(context);
Account odyseeAccount = Helper.getOdyseeAccount(am.getAccounts());
if (odyseeAccount != null && comment.getClaimId() != null && commentListListener != null) {
commentListListener.onCommentReactClicked(comment, true);
}
}
});
holder.dislikesCount.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AccountManager am = AccountManager.get(context);
Account odyseeAccount = Helper.getOdyseeAccount(am.getAccounts());
if (odyseeAccount != null && comment.getClaimId() != null && commentListListener != null) {
commentListListener.onCommentReactClicked(comment, false);
}
}
});
boolean hasThumbnail = comment.getPoster() != null && !Helper.isNullOrEmpty(comment.getPoster().getThumbnailUrl());
holder.thumbnailView.setVisibility(hasThumbnail ? View.VISIBLE : View.INVISIBLE);
holder.noThumbnailView.setVisibility(!hasThumbnail ? View.VISIBLE : View.INVISIBLE);
int bgColor = Helper.generateRandomColorForValue(comment.getChannelId());
Helper.setIconViewBackgroundColor(holder.noThumbnailView, bgColor, false, context);
if (hasThumbnail) {
Glide.with(context.getApplicationContext()).asBitmap().load(comment.getPoster().getThumbnailUrl(holder.thumbnailView.getLayoutParams().width, holder.thumbnailView.getLayoutParams().height, 85)).apply(RequestOptions.circleCropTransform()).into(holder.thumbnailView);
}
holder.alphaView.setText(comment.getChannelName() != null ? comment.getChannelName().substring(1, 2).toUpperCase() : null);
holder.channelName.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (listener != null && comment.getPoster() != null) {
listener.onClaimClicked(comment.getPoster(), position);
}
}
});
holder.replyLink.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (commentListListener != null) {
commentListListener.onReplyClicked(comment);
}
}
});
if (position != (items.size() - 1)) {
String pId = items.get(position + 1).getParentId();
if (pId != null && pId.equalsIgnoreCase(comment.getId())) {
holder.viewReplies.setVisibility(View.VISIBLE);
holder.viewReplies.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
switchRepliesVisibility(comment.getId());
switchViewReplies(comment, (TextView) holder.viewReplies);
}
});
} else {
holder.viewReplies.setVisibility(View.GONE);
}
} else {
holder.viewReplies.setVisibility(View.GONE);
}
}
use of com.odysee.app.model.Claim in project odysee-android by OdyseeTeam.
the class SuggestedChannelGridAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(SuggestedChannelGridAdapter.ViewHolder vh, int position) {
Claim claim = items.get(position);
ViewGroup.LayoutParams lp = vh.thumbnailView.getLayoutParams();
String thumbnailUrl = claim.getThumbnailUrl(lp.width, lp.height, 85);
int bgColor = Helper.generateRandomColorForValue(claim.getClaimId());
Helper.setIconViewBackgroundColor(vh.noThumbnailView, bgColor, false, context);
vh.noThumbnailView.setVisibility(Helper.isNullOrEmpty(thumbnailUrl) ? View.INVISIBLE : View.VISIBLE);
vh.alphaView.setText(claim.getName().substring(1, 2));
if (!Helper.isNullOrEmpty(thumbnailUrl)) {
vh.thumbnailView.setVisibility(View.VISIBLE);
Glide.with(context.getApplicationContext()).load(thumbnailUrl).apply(RequestOptions.circleCropTransform()).into(vh.thumbnailView);
} else {
vh.thumbnailView.setVisibility(View.GONE);
}
vh.titleView.setText(Helper.isNullOrEmpty(claim.getTitle()) ? claim.getName() : claim.getTitle());
String firstTag = claim.getFirstTag();
vh.tagView.setVisibility(Helper.isNullOrEmpty(firstTag) ? View.INVISIBLE : View.VISIBLE);
vh.tagView.setBackgroundResource(R.drawable.bg_tag);
vh.tagView.setText(firstTag);
vh.itemView.setSelected(isClaimSelected(claim));
vh.itemView.setOnClickListener(view -> {
if (selectedItems.contains(claim)) {
selectedItems.remove(claim);
if (listener != null) {
listener.onChannelItemDeselected(claim);
}
} else {
selectedItems.add(claim);
if (listener != null) {
listener.onChannelItemSelected(claim);
}
}
notifyDataSetChanged();
});
}
use of com.odysee.app.model.Claim in project odysee-android by OdyseeTeam.
the class InlineChannelSpinnerAdapter method createView.
private View createView(int position, View convertView, ViewGroup parent) {
View view = inflater.inflate(layoutResourceId, parent, false);
Context context = getContext();
Claim channel = getItem(position);
String name = channel.getName();
if (channel.isPlaceholder()) {
name = context.getString(R.string.create_a_channel);
} else if (channel.isPlaceholderAnonymous()) {
name = context.getString(R.string.anonymous);
}
TextView label = view.findViewById(R.id.channel_item_name);
label.setText(name);
return view;
}
Aggregations