Search in sources :

Example 1 with CircleCrop

use of com.bumptech.glide.load.resource.bitmap.CircleCrop in project talk-android by nextcloud.

the class SettingsController method loadAvatarImage.

private void loadAvatarImage() {
    String avatarId;
    if (!TextUtils.isEmpty(userEntity.getUserId())) {
        avatarId = userEntity.getUserId();
    } else {
        avatarId = userEntity.getUsername();
    }
    GlideUrl glideUrl = new GlideUrl(ApiUtils.getUrlForAvatarWithName(userEntity.getBaseUrl(), avatarId, true), new LazyHeaders.Builder().setHeader("Accept", "image/*").setHeader("User-Agent", ApiUtils.getUserAgent()).build());
    GlideApp.with(NextcloudTalkApplication.getSharedApplication().getApplicationContext()).load(glideUrl).centerInside().apply(RequestOptions.bitmapTransform(new CircleCrop())).into(avatarImageView);
}
Also used : CircleCrop(com.bumptech.glide.load.resource.bitmap.CircleCrop) GlideUrl(com.bumptech.glide.load.model.GlideUrl)

Example 2 with CircleCrop

use of com.bumptech.glide.load.resource.bitmap.CircleCrop in project talk-android by nextcloud.

the class AdvancedUserItem method bindViewHolder.

@Override
public void bindViewHolder(FlexibleAdapter adapter, UserItemViewHolder holder, int position, List payloads) {
    if (adapter.hasFilter()) {
        FlexibleUtils.highlightText(holder.contactDisplayName, participant.getName(), String.valueOf(adapter.getFilter(String.class)));
    } else {
        holder.contactDisplayName.setText(participant.getName());
    }
    holder.serverUrl.setText(userEntity.getBaseUrl());
    if (userEntity.getBaseUrl().startsWith("http://") || userEntity.getBaseUrl().startsWith("https://")) {
        holder.avatarImageView.setVisibility(View.VISIBLE);
        GlideUrl glideUrl = new GlideUrl(ApiUtils.getUrlForAvatarWithName(userEntity.getBaseUrl(), participant.getUserId(), false), new LazyHeaders.Builder().setHeader("Accept", "image/*").setHeader("User-Agent", ApiUtils.getUserAgent()).build());
        int avatarSize = Math.round(NextcloudTalkApplication.getSharedApplication().getResources().getDimension(R.dimen.avatar_size));
        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);
        RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) holder.linearLayout.getLayoutParams();
        layoutParams.setMarginStart((int) NextcloudTalkApplication.getSharedApplication().getApplicationContext().getResources().getDimension(R.dimen.activity_horizontal_margin));
        layoutParams.addRule(RelativeLayout.ALIGN_PARENT_START);
        holder.linearLayout.setLayoutParams(layoutParams);
    }
}
Also used : CircleCrop(com.bumptech.glide.load.resource.bitmap.CircleCrop) RelativeLayout(android.widget.RelativeLayout) GlideUrl(com.bumptech.glide.load.model.GlideUrl)

Example 3 with CircleCrop

use of com.bumptech.glide.load.resource.bitmap.CircleCrop 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)

Example 4 with CircleCrop

use of com.bumptech.glide.load.resource.bitmap.CircleCrop in project glide by bumptech.

the class RequestOptionsTest method testApplyMultiTransform.

@Test
@SuppressWarnings({ "unchecked", "varargs" })
public void testApplyMultiTransform() {
    options.transforms(new CircleCrop(), new CenterCrop());
    assertThat(options.isTransformationRequired()).isTrue();
    assertThat(options.getTransformations()).containsKey(Bitmap.class);
    assertThat(options.getTransformations().get(Bitmap.class)).isInstanceOf(MultiTransformation.class);
}
Also used : CircleCrop(com.bumptech.glide.load.resource.bitmap.CircleCrop) CenterCrop(com.bumptech.glide.load.resource.bitmap.CenterCrop) Test(org.junit.Test)

Example 5 with CircleCrop

use of com.bumptech.glide.load.resource.bitmap.CircleCrop in project talk-android by nextcloud.

the class UserItem method bindViewHolder.

@Override
public void bindViewHolder(FlexibleAdapter adapter, UserItemViewHolder holder, int position, List payloads) {
    flipView = holder.avatarFlipView;
    flipView.flipSilently(adapter.isSelected(position));
    if (adapter.hasFilter()) {
        FlexibleUtils.highlightText(holder.contactDisplayName, participant.getName(), String.valueOf(adapter.getFilter(String.class)));
    } else {
        holder.contactDisplayName.setText(participant.getName());
    }
    GlideUrl glideUrl = new GlideUrl(ApiUtils.getUrlForAvatarWithName(userEntity.getBaseUrl(), participant.getUserId(), false), new LazyHeaders.Builder().setHeader("Accept", "image/*").setHeader("User-Agent", ApiUtils.getUserAgent()).build());
    int avatarSize = Math.round(NextcloudTalkApplication.getSharedApplication().getResources().getDimension(R.dimen.avatar_size));
    GlideApp.with(NextcloudTalkApplication.getSharedApplication().getApplicationContext()).asBitmap().diskCacheStrategy(DiskCacheStrategy.NONE).load(glideUrl).centerInside().override(avatarSize, avatarSize).apply(RequestOptions.bitmapTransform(new CircleCrop())).into(holder.avatarFlipView.getFrontImageView());
}
Also used : CircleCrop(com.bumptech.glide.load.resource.bitmap.CircleCrop) GlideUrl(com.bumptech.glide.load.model.GlideUrl)

Aggregations

CircleCrop (com.bumptech.glide.load.resource.bitmap.CircleCrop)5 GlideUrl (com.bumptech.glide.load.model.GlideUrl)4 RelativeLayout (android.widget.RelativeLayout)1 CenterCrop (com.bumptech.glide.load.resource.bitmap.CenterCrop)1 MoreMenuClickEvent (com.nextcloud.talk.events.MoreMenuClickEvent)1 Test (org.junit.Test)1