public void displayImage(final String uri, final ImageView imageView, int defaultIcon, final DisplayListener listener) { GenericRequestBuilder req = Glide.with(imageView.getContext().getApplicationContext()).load(uri).asBitmap().diskCacheStrategy(mDiskCacheStrategy); if (defaultIcon > 0) { req.placeholder(defaultIcon); } req.into(new BitmapImageViewTarget(imageView) { @Override public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) { super.onResourceReady(resource, glideAnimation); if (listener != null) { listener.onLoadCompleted(uri, imageView, resource); } } @Override public void onLoadFailed(Exception e, Drawable errorDrawable) { super.onLoadFailed(e, errorDrawable); if (listener != null) { listener.onLoadFailed(uri, imageView); } } }); }
public static void loadRound(final Context context, String url, final ImageView iv) { Glide.with(context)// .load(url)// .asBitmap()// .placeholder(R.drawable.company_logo)// .centerCrop()// .into(new BitmapImageViewTarget(iv) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(context.getResources(), resource); circularBitmapDrawable.setCircular(true); iv.setImageDrawable(circularBitmapDrawable); } }); }
/** * Handle a google signIn * @param result - the result of the signin attempt */ private void handleSignInResult(GoogleSignInResult result) { Log.d(TAG, "handleSignInResult:" + result.isSuccess()); final ImageView accountImageView = findViewById(R.id.account_picture); if (result.isSuccess()) { // Signed in successfully, show authenticated UI. GoogleSignInAccount acct = result.getSignInAccount(); if (acct != null) { Glide.with(this).load(acct.getPhotoUrl()).asBitmap().centerCrop().into(new BitmapImageViewTarget(accountImageView) { /** * Set a glide image * @param resource - the image to set */ @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), resource); circularBitmapDrawable.setCircular(true); accountImageView.setImageDrawable(circularBitmapDrawable); } }); } } }
public void loadRoundImage(final Context context, String imgPath, final ImageView imageView, int placeholderResId, int failedResId) { if (context == null) { return; } Context appContext = context.getApplicationContext(); Glide.with(appContext). load(imgPath) .asBitmap() .placeholder(placeholderResId) .error(failedResId) .centerCrop() .into(new BitmapImageViewTarget(imageView) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(context.getResources(), resource); circularBitmapDrawable.setCircular(true); imageView.setImageDrawable(circularBitmapDrawable); } }); }
/***** * MVP View methods implementation *****/ @Override public void showAvatar(String avatarUrl) { if (avatarUrl.contains("gif")) { Glide.with(this).load(avatarUrl).asGif().into(avatar); } else { Glide.with(this).load(avatarUrl).asBitmap().centerCrop().into(new BitmapImageViewTarget(avatar) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), resource); circularBitmapDrawable.setCircular(true); avatar.setImageDrawable(circularBitmapDrawable); } }); } }
/** * Crops image into a circle that fits within the ImageView. */ public static void displayRoundImageFromUrl(final Context context, final String url, final ImageView imageView) { Glide.with(context) .load(url) .asBitmap() .centerCrop() .dontAnimate() .into(new BitmapImageViewTarget(imageView) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(context.getResources(), resource); circularBitmapDrawable.setCircular(true); imageView.setImageDrawable(circularBitmapDrawable); } }); }
@Override public void onBindViewHolder(final AnchorHotViewHolder holder, final int position) { ComMember member = mData.get(position); if (StringUtils.isNotEmpty(member.getImageUrl())){ Glide.with(mContext).load(member.getImageUrl()).asBitmap().centerCrop().into(new BitmapImageViewTarget(holder.pic) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(mContext.getResources(), resource); circularBitmapDrawable.setCircular(true); holder.pic.setImageDrawable(circularBitmapDrawable); } }); } }
public void setCircleInfo(CircleInfo info) { mTvCircleName.setText(info.getCircleName()); mTvTitle.setText(info.getCircleName()); mTvCircleNum.setText(info.getNum() + "人"); mTvIntroduce.setText(info.getAnnouncement()); String path = info.getLogoUrl(); if (!path.contains("http://")) { path = BuildConfig.QiniuBase + path; } Glide.with(this.getActivity()).load(path).asBitmap().error(R.mipmap.icon_default_pic).centerCrop().into(new BitmapImageViewTarget(mImgTop) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(getActivity().getResources(), resource); circularBitmapDrawable.setCircular(true); mImgTop.setImageDrawable(circularBitmapDrawable); } }); }
public void setData(CircleInfo info) { Glide.with(this.getActivity()).load(info.getLogoUrl()).asBitmap().centerCrop().into(new BitmapImageViewTarget(mImgPic) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(getActivity().getResources(), resource); circularBitmapDrawable.setCircular(true); mImgPic.setImageDrawable(circularBitmapDrawable); } }); mTvName.setText(info.getCircleName()); mEdtAnnouncement.setText(info.getAnnouncement()); // mTvType.setText(); }
@Override public void onBindViewHolder(final AnchorHotViewHolder holder, final int position) { ProjectComments comments = mData.get(position); if (comments != null) { ComMember member = comments.getCommentUser(); if (null != member && StringUtils.isNotEmpty(member.getName())) { holder.tvName.setText(member.getName()); } if (StringUtils.isNotEmpty(member.getImageUrl())){ Glide.with(mContext).load(member.getImageUrl()).asBitmap().centerCrop().into(new BitmapImageViewTarget(holder.pic) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(mContext.getResources(), resource); circularBitmapDrawable.setCircular(true); holder.pic.setImageDrawable(circularBitmapDrawable); } }); } } holder.tvContent.setText(comments.getComment()); holder.tvTime.setText(TimeUtil.getDateToString(comments.getCreateTime())); }
public void setUserInfo(ComMember member) { if (member.getImageUrl() != null) { Glide.with(this.getActivity()).load(member.getImageUrl()).asBitmap().centerCrop().into(new BitmapImageViewTarget(imgPic) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(getActivity().getResources(), resource); circularBitmapDrawable.setCircular(true); imgPic.setImageDrawable(circularBitmapDrawable); } }); } if (member.getName() != null) tvName.setText(member.getName()); tv_center_shareholder.setVisibility(member.getShareholder() == 0 ? View.GONE : View.VISIBLE); tv_center_investor.setVisibility(member.getInvestor() == 0 ? View.GONE : View.VISIBLE); if (StringUtils.isNotEmpty(member.getCompany())) tv_center_company.setText(member.getCompany()); if (StringUtils.isNotEmpty(member.getPosition())) tv_center_position.setText(member.getPosition()); }
public void setData(ReciveRedPacket info,String name ,String tip) { tv_money.setText(info.getMoney()+""); String path = info.getImgUrl(); if (!path.contains("http://")){ path = BuildConfig.QiniuBase + path; } Glide.with(this.getActivity()).load(path).asBitmap().centerCrop().into(new BitmapImageViewTarget(img_icon) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(getActivity().getResources(), resource); circularBitmapDrawable.setCircular(true); img_icon.setImageDrawable(circularBitmapDrawable); } }); tv_name.setText(name+"的红包"); // EMTextMessageBody txtBody = (EMTextMessageBody) message.getBody(); // Spannable span = EaseSmileUtils.getSmiledText(this.getActivity(), txtBody.getMessage()); // 设置内容 tv_tip.setText(tip); }
/** * 将url编程圆形的加载在 ImageView中 */ public static void requestCircleImg(final Context context, String url, final ImageView imageView) { Glide.with(context) .load(url) .asBitmap() .centerCrop() .into(new BitmapImageViewTarget(imageView) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(context.getResources(), resource); circularBitmapDrawable.setCircular(true); imageView.setImageDrawable(circularBitmapDrawable); } }); }
public void setRightMessage(Context context, String name, String message, String time, String avatar) { layoutright.setVisibility(View.VISIBLE); layoutLeft.setVisibility(View.GONE); txtNameRight.setVisibility(View.GONE); txtNameRight.setText(name); txtMessageRight.setText(message); txtTimeRight.setText(time); Glide.with(context) .load(avatar) .asBitmap().centerCrop() .placeholder(R.mipmap.ic_nfkita_round) .into(new BitmapImageViewTarget(imgAvatar) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable rounded = RoundedBitmapDrawableFactory.create(context.getResources(), resource); rounded.setCircular(true); imgAvatar.setImageDrawable(rounded); } }); }
private void loadData() { String avatar = CacheManager.grabString("avatar"); String name = CacheManager.grabString("name"); String email = CacheManager.grabString("email"); Glide.with(getContext()) .load(avatar) .asBitmap().centerCrop() .placeholder(R.mipmap.ic_nfkita_round) .into(new BitmapImageViewTarget(imgAvatar) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable rounded = RoundedBitmapDrawableFactory.create(getContext().getResources(), resource); rounded.setCircular(true); imgAvatar.setImageDrawable(rounded); } }); txtFullName.setText(name); txtEmail.setText(email); }
private void loadProfilePic() { Glide.with(mContext).load(mSharedPreferences.getString(PROFILE_PIC_URL, "")) .asBitmap() .fitCenter() .diskCacheStrategy(DiskCacheStrategy.ALL) .error(R.drawable.default_avatar) .into(new BitmapImageViewTarget(profileImg) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(mContext.getResources(), resource); circularBitmapDrawable.setCircular(true); profileImg.setImageDrawable(circularBitmapDrawable); } }); }
private void setImage(final UserItemViewHolder holder, User user) { Glide.with(mContext) .load(USER_IMAGES_URL + user.getImage()) .asBitmap() .placeholder(R.drawable.person_placeholder) .diskCacheStrategy(DiskCacheStrategy.ALL) .centerCrop() .into(new BitmapImageViewTarget(holder.userImage) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(mContext.getResources(), resource); circularBitmapDrawable.setCircular(true); holder.userImage.setImageDrawable(circularBitmapDrawable); } }); }
private RxImageLoader(Builder builder) { this.imageView = builder.imageView; this.uri = builder.uri; this.target = new BitmapImageViewTarget(imageView) { @Override public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) { super.onResourceReady(resource, glideAnimation); onSuccess(); } @Override public void onLoadFailed(Exception e, Drawable errorDrawable) { super.onLoadFailed(e, errorDrawable); onError(); } }; }
@Override public void bindCursor(Cursor cursor) { name.setText(cursor.getString(cursor.getColumnIndex(PlaceContract.PlaceEntry.COLUMN_NAME))); id.setText(cursor.getString(cursor.getColumnIndex(PlaceContract.PlaceEntry.COLUMN_PLACE_ID))); photo.setText(cursor.getString(cursor.getColumnIndex(PlaceContract.PlaceEntry.COLUMN_PHOTO))); vicinity.setText(cursor.getString(cursor.getColumnIndex(PlaceContract.PlaceEntry.COLUMN_VICINITY))); Glide.with(icon.getContext()) .load(Config.getPlacePhotoUrl("80", cursor.getString(cursor.getColumnIndex(PlaceContract.PlaceEntry.COLUMN_PHOTO)), Config.API_KEY)) .asBitmap().centerCrop().into(new BitmapImageViewTarget(icon) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(mContext.getResources(), resource); circularBitmapDrawable.setCircular(true); icon.setImageDrawable(circularBitmapDrawable); } }); // Log.e("Photo" , Config.getPlacePhotoUrl("80", cursor.getString(cursor.getColumnIndex(PlaceContract.PlaceEntry.COLUMN_PHOTO)), Config.API_KEY)); }
/** 与Glide高耦合的设置图片 */ public ViewHolder setImageCircle(@IdRes final int viewId, @DrawableRes int resId){ final ImageView imageView = getView(viewId); Glide.with(mContext) .load(resId) .asBitmap() .into(new BitmapImageViewTarget(imageView) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(mContext.getResources(), resource); circularBitmapDrawable.setCircular(true); imageView.setImageDrawable(circularBitmapDrawable); } }); return this; }
@Override public void onBindViewHolder(ViewHolder holder, int position) { GankBean gankBean = mData.get(position); BitmapRequestBuilder<String, Bitmap> requestBuilder = Glide.with(mContext) .load(gankBean.url) .asBitmap() .diskCacheStrategy(DiskCacheStrategy.SOURCE) .transform(new GlideRoundTransform(mContext, 4)) .animate(R.anim.image_alpha_in) .error(R.color.accent); requestBuilder.into(new BitmapImageViewTarget(holder.ivGirlImg){ @Override protected void setResource(Bitmap resource) { holder.ivGirlImg.setOriginalSize(resource.getWidth(), resource.getHeight()); holder.ivGirlImg.setImageBitmap(resource); } }); }
@Override public View getView(int position, View convertView, ViewGroup container) { if (convertView == null) { convertView = LayoutInflater.from(getActivity()).inflate(R.layout.list_item_ride, container, false); } final Ride ride = (Ride) getItem(position); ((TextView) convertView.findViewById(R.id.ride_date)).setText(ride.date); ((TextView) convertView.findViewById(R.id.ride_time)).setText(ride.time); final ImageView img = (ImageView) convertView.findViewById(R.id.thumbnail); Glide.with(getActivity()).load(imageResIds[position % 5]).asBitmap().fitCenter().into(new BitmapImageViewTarget(img) { // Glide.with(getActivity()).load(item.photoId).asBitmap().fitCenter().into(new BitmapImageViewTarget(img) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(getActivity().getResources(), resource); circularBitmapDrawable.setCircular(true); img.setImageDrawable(circularBitmapDrawable); } }); return convertView; }
@BindingAdapter(value = {"imageUrl", "circle"}, requireAll = false) public static void loadImage(ImageView view, String url, Boolean circle) { if (circle == null || !circle) { Glide.with(view.getContext()).load(url).into(view); } else { Glide.with(view.getContext()).load(url).asBitmap().centerCrop().into(new BitmapImageViewTarget(view) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(view.getResources(), resource); circularBitmapDrawable.setCircular(true); view.setImageDrawable(circularBitmapDrawable); } }); } }
private void setUserInfo() { Glide.with(this) .load(mUserInfo.avatarUrl) .asBitmap() .placeholder(R.drawable.ic_slide_menu_avatar_no_login) .into(new BitmapImageViewTarget(mUserInfoAvatar) { @Override protected void setResource(Bitmap resource) { mUserInfoAvatar.setImageDrawable(RoundedBitmapDrawableFactory .create(GitHubUserActivity.this.getResources(), resource)); } }); mUsername.setText(mUserInfo.name); }
@Override public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) { if (holder instanceof BookCommentHolder) { List<HotReview.Reviews> reviews = mHotView.getReviews(); Glide.with(UIUtils.getContext()) .load(EBookUtils.getImageUrl(reviews.get(position).getAuthor().getAvatar())) .asBitmap() .centerCrop() .into(new BitmapImageViewTarget(((BookCommentHolder) holder).iv_avatar) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(UIUtils.getContext().getResources(), resource); circularBitmapDrawable.setCircular(true); ((BookCommentHolder) holder).iv_avatar.setImageDrawable(circularBitmapDrawable); } }); ((BookCommentHolder) holder).tv_user_name.setText(reviews.get(position).getAuthor().getNickname()); ((BookCommentHolder) holder).ratingBar_hots.setRating((float) reviews.get(position).getRating()); ((BookCommentHolder) holder).tv_comment_content.setText(reviews.get(position).getContent()); ((BookCommentHolder) holder).tv_favorite_num.setText(reviews.get(position).getLikeCount() + ""); ((BookCommentHolder) holder).tv_update_time.setText(reviews.get(position).getUpdated().split("T")[0]); } }
@Override public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) { if (holder instanceof BookCommentHolder) { List<BookReviewResponse> reviews = reviewsListResponse.getReviews(); Glide.with(UIUtils.getContext()) .load(reviews.get(position).getAuthor().getAvatar()) .asBitmap() .centerCrop() .into(new BitmapImageViewTarget(((BookCommentHolder) holder).iv_avatar) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(UIUtils.getContext().getResources(), resource); circularBitmapDrawable.setCircular(true); ((BookCommentHolder) holder).iv_avatar.setImageDrawable(circularBitmapDrawable); } }); ((BookCommentHolder) holder).tv_user_name.setText(reviews.get(position).getAuthor().getName()); if (reviews.get(position).getRating() != null) { ((BookCommentHolder) holder).ratingBar_hots.setRating(Float.valueOf(reviews.get(position).getRating().getValue())); } ((BookCommentHolder) holder).tv_comment_content.setText(reviews.get(position).getSummary()); ((BookCommentHolder) holder).tv_favorite_num.setText(reviews.get(position).getVotes() + ""); ((BookCommentHolder) holder).tv_update_time.setText(reviews.get(position).getUpdated().split(" ")[0]); } }
private void fillProfile(Profile value) { Glide.with(this) .load(value.getPicture()) .asBitmap() .centerCrop() .into(new BitmapImageViewTarget(imageView) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), resource); circularBitmapDrawable.setCircular(true); imageView.setImageDrawable(circularBitmapDrawable); } }); result.setText(value.getName()); }
@Override public void showProfile(User user) { Glide.with(getContext()).load(user.getAvatarUrl()) .asBitmap() .centerCrop() .into(new BitmapImageViewTarget(avatar) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(getContext().getResources(), resource); circularBitmapDrawable.setCircular(true); avatar.setImageDrawable(circularBitmapDrawable); } }); name.setText(user.getName()); username.setText(user.getUsername()); shotCount.setText(String.valueOf(user.getShotsCount())); followerCount.setText(String.valueOf(user.getFollowersCount())); likesCount.setText(String.valueOf(user.getLikesReceivedCount())); bio.setText(Html.fromHtml("Co-founder & designer of <a href=\\\"https://dribbble.com/dribbble\\\">@Dribbble</a>. Principal of SimpleBits. Aspiring clawhammer banjoist.")); }
public void bind(Comment comment) { Glide.with(itemView.getContext()).load(comment.getUser().getAvatarUrl()) .asBitmap() .centerCrop() .into(new BitmapImageViewTarget(avatar) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(itemView.getContext().getResources(), resource); circularBitmapDrawable.setCircular(true); avatar.setImageDrawable(circularBitmapDrawable); } }); name.setText(comment.getUser().getName()); content.setText(comment.getBody()); LinkUtils.setTextWithLinks(content, comment.getBody()); time.setText(DateUtils.parse(comment.getCreatedAt())); }
@Override void bindItem(Context context, final Gank gank, final int position) { mTvTime.setText(DateUtil.toDate(gank.publishedAt)); Glide.with(context) .load(gank.url) .asBitmap() .into(new BitmapImageViewTarget(mImageView){ @Override public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) { super.onResourceReady(resource, glideAnimation); mBkTime.setVisibility(View.VISIBLE); } }); mTvTime.setText(DateUtil.toDate(gank.publishedAt)); mImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mIClickItem.onClickGankItemGirl(gank, mImageView, mTvTime); } }); }
@Override public View getView(int position, View convertView, ViewGroup container) { if (convertView == null) { convertView = LayoutInflater.from(getActivity()).inflate(R.layout.list_item_article, container, false); } final DummyContent.DummyItem item = (DummyContent.DummyItem) getItem(position); ((TextView) convertView.findViewById(R.id.article_title)).setText(item.title); ((TextView) convertView.findViewById(R.id.article_subtitle)).setText(item.author); final ImageView img = (ImageView) convertView.findViewById(R.id.thumbnail); Glide.with(getActivity()).load(item.photoId).asBitmap().fitCenter().into(new BitmapImageViewTarget(img) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(getActivity().getResources(), resource); circularBitmapDrawable.setCircular(true); img.setImageDrawable(circularBitmapDrawable); } }); return convertView; }
@Override protected void onFinishInflate() { super.onFinishInflate(); ButterKnife.bind(this, this); Glide.with(ivProfileDummy.getContext()).load(R.drawable.dummy_profile).asBitmap().centerCrop().into(new BitmapImageViewTarget(ivProfileDummy) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(ivProfile.getResources(), resource); circularBitmapDrawable.setCircular(true); ivProfileDummy.setImageDrawable(circularBitmapDrawable); } }); EventBus eventBus = EventBus.getDefault(); if (!eventBus.isRegistered(this)) { eventBus.register(this); } if (UserModel.getInstance().isUserLogin()) { UserVO loginUser = UserModel.getInstance().getLoginUser(); displayLoginUserInfo(loginUser); } }
public static void loadRoundImage(final Context context, String url, final ImageView imgView) { Glide.with(context).load(url).asBitmap().centerCrop().into(new BitmapImageViewTarget(imgView) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(context.getResources(), resource); circularBitmapDrawable.setCircular(true); imgView.setImageDrawable(circularBitmapDrawable); } }); }
public static void loadRoundImage(final Context context, int resId, final ImageView imgView) { Glide.with(context).load(resId).asBitmap().centerCrop().into(new BitmapImageViewTarget(imgView) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(context.getResources(), resource); circularBitmapDrawable.setCircular(true); imgView.setImageDrawable(circularBitmapDrawable); } }); }
@Override public void onBindViewHolder(LeaderBoardViewHolder holder, int position) { LeaderBoardActivity.LeaderBoardUserModel user=users.get(position); holder.username.setText(user.getName().toString()); holder.score.setText("Score: "+Integer.toString(user.getSets().getScore())); Glide.with(context).load(user.getPhoto()).into(holder.photo); final ImageView imageView=holder.photo; Glide.with(context).load(user.getPhoto()).asBitmap().centerCrop().into(new BitmapImageViewTarget(imageView) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(context.getResources(), resource); circularBitmapDrawable.setCircular(true); imageView.setImageDrawable(circularBitmapDrawable); } }); Integer prsnlscore = user.getSets().getScore(); if(prsnlscore>=800) holder.useraward.setImageResource(R.drawable.trophy_gold); else if(prsnlscore>=600) holder.useraward.setImageResource(R.drawable.trophy_silver); else if(prsnlscore>=450) holder.useraward.setImageResource(R.drawable.trophy_bronze); else if(prsnlscore>=300) holder.useraward.setImageResource(R.drawable.trophy_goldbadge); else if(prsnlscore>=150) holder.useraward.setImageResource(R.drawable.trophy_silverbadge); else if(prsnlscore>0) holder.useraward.setImageResource(R.drawable.trophy_bronzebadge); else if(prsnlscore==0) holder.useraward.setImageResource(R.drawable.trophy_participation); holder.sets.setText("Sets: "+Integer.toString(user.getSets().getSets())); }
public void loadImageRounded(String imageUrl, final ImageView imageView) { Glide.with(this).load(imageUrl).asBitmap().centerCrop().into(new BitmapImageViewTarget(imageView) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), resource); circularBitmapDrawable.setCircular(true); imageView.setImageDrawable(circularBitmapDrawable); } }); }
@Override public void showDefaultAvatar() { Glide.with(this).load(R.drawable.default_avatar).asBitmap().centerCrop().into(new BitmapImageViewTarget(avatar) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), resource); circularBitmapDrawable.setCircular(true); avatar.setImageDrawable(circularBitmapDrawable); } }); }
public static void loadRoundedImage(final Context context, final ImageView imageView, String imageUrl, int placeHolderRes) { Glide.with(context) .load(imageUrl) .asBitmap() .placeholder(placeHolderRes).centerCrop().into(new BitmapImageViewTarget(imageView) { @Override protected void setResource(Bitmap resource) { final RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(context.getResources(), resource); circularBitmapDrawable.setCircular(true); imageView.setImageDrawable(circularBitmapDrawable); } }); }