Search in sources :

Example 1 with MoreMenuClickEvent

use of com.nextcloud.talk.events.MoreMenuClickEvent in project talk-android by nextcloud.

the class CallItem method bindViewHolder.

@Override
public void bindViewHolder(final FlexibleAdapter adapter, RoomItemViewHolder holder, int position, List payloads) {
    if (adapter.hasFilter()) {
        FlexibleUtils.highlightText(holder.roomDisplayName, room.getDisplayName(), String.valueOf(adapter.getFilter(String.class)));
    } else {
        holder.roomDisplayName.setText(room.getDisplayName());
    }
    if (room.getLastPing() == 0) {
        holder.roomLastPing.setText(R.string.nc_never);
    } else {
        holder.roomLastPing.setText(DateUtils.getRelativeTimeSpanString(room.getLastPing() * 1000L, System.currentTimeMillis(), 0, DateUtils.FORMAT_ABBREV_RELATIVE));
    }
    if (room.hasPassword) {
        holder.passwordProtectedImageView.setVisibility(View.VISIBLE);
    } else {
        holder.passwordProtectedImageView.setVisibility(View.GONE);
    }
    int avatarSize = Math.round(NextcloudTalkApplication.getSharedApplication().getResources().getDimension(R.dimen.avatar_size));
    switch(room.getType()) {
        case ROOM_TYPE_ONE_TO_ONE_CALL:
            holder.avatarImageView.setVisibility(View.VISIBLE);
            if (!TextUtils.isEmpty(room.getName())) {
                GlideUrl glideUrl = new GlideUrl(ApiUtils.getUrlForAvatarWithName(userEntity.getBaseUrl(), room.getName(), false), new LazyHeaders.Builder().setHeader("Accept", "image/*").setHeader("User-Agent", ApiUtils.getUserAgent()).build());
                GlideApp.with(NextcloudTalkApplication.getSharedApplication().getApplicationContext()).asBitmap().diskCacheStrategy(DiskCacheStrategy.NONE).load(glideUrl).centerInside().override(avatarSize, avatarSize).apply(RequestOptions.bitmapTransform(new CircleCrop())).into(holder.avatarImageView.getFrontImageView());
            } else {
                holder.avatarImageView.setVisibility(View.GONE);
            }
            break;
        case ROOM_GROUP_CALL:
            GlideApp.with(NextcloudTalkApplication.getSharedApplication().getApplicationContext()).asBitmap().diskCacheStrategy(DiskCacheStrategy.NONE).load(R.drawable.ic_group_white_24px).centerInside().override(avatarSize, avatarSize).apply(RequestOptions.bitmapTransform(new CircleCrop())).into(holder.avatarImageView.getFrontImageView());
            holder.avatarImageView.setVisibility(View.VISIBLE);
            break;
        case ROOM_PUBLIC_CALL:
            GlideApp.with(NextcloudTalkApplication.getSharedApplication().getApplicationContext()).asBitmap().diskCacheStrategy(DiskCacheStrategy.NONE).load(R.drawable.ic_link_white_24px).centerInside().override(avatarSize, avatarSize).apply(RequestOptions.bitmapTransform(new CircleCrop())).into(holder.avatarImageView.getFrontImageView());
            holder.avatarImageView.setVisibility(View.VISIBLE);
            break;
        default:
            holder.avatarImageView.setVisibility(View.GONE);
    }
    holder.moreMenuButton.setOnClickListener(view -> EventBus.getDefault().post(new MoreMenuClickEvent(room)));
}
Also used : CircleCrop(com.bumptech.glide.load.resource.bitmap.CircleCrop) MoreMenuClickEvent(com.nextcloud.talk.events.MoreMenuClickEvent) GlideUrl(com.bumptech.glide.load.model.GlideUrl)

Aggregations

GlideUrl (com.bumptech.glide.load.model.GlideUrl)1 CircleCrop (com.bumptech.glide.load.resource.bitmap.CircleCrop)1 MoreMenuClickEvent (com.nextcloud.talk.events.MoreMenuClickEvent)1