public void initWith(AddRequest item) { AVUser avUser = item.getFromUser(); if (avUser != null) { User user = UserBeanCacheHelper.AvUserToUser(avUser,new User()); nickTv.setText(user.getNick()); Glide.with(mAppCtx).load(user.getAvatar()).placeholder(R.drawable.default_avatar).into(iconIv); infoTv.setText(mAppCtx.getText(R.string.preIntroduce)+user.getNick()); int status = item.getStatus(); if (status == AddRequest.STATUS_WAIT) { acceptBtn.setSelected(false); acceptBtn.setText(R.string.accept); } else if (status == AddRequest.STATUS_DONE) { acceptBtn.setSelected(true); acceptBtn.setText(R.string.accepted); } } }
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHoder viewHoder; if(convertView ==null){ convertView = View.inflate(context, R.layout.net_video_item,null); viewHoder = new ViewHoder(); viewHoder.iv_icon = (ImageView) convertView.findViewById(R.id.net_video_img); viewHoder.tv_name = (TextView) convertView.findViewById(R.id.net_video_name); viewHoder.tv_desc = (TextView) convertView.findViewById(R.id.net_video_desc); convertView.setTag(viewHoder); }else{ viewHoder = (ViewHoder) convertView.getTag(); } SearchBean.ItemData mediaItem = mediaItems.get(position); viewHoder.tv_name.setText(mediaItem.getItemTitle()); viewHoder.tv_desc.setText(mediaItem.getKeywords()); Glide.with(context).load(mediaItem.getItemImage().getImgUrl1()) .diskCacheStrategy(DiskCacheStrategy.ALL) .placeholder(R.drawable.video_default) .error(R.drawable.video_default) .into(viewHoder.iv_icon); return convertView; }
private void updateAvatar(AVIMConversation conversation,ImageView avatarView) { if(null != conversation) { if(!conversation.isTransient() && conversation.getMembers().size() <= 2) { ConversationUtils.getConversationPeerIcon(conversation, new AVCallback<String>() { protected void internalDone0(String s, AVException e) { if(null != e) { NLog.e(TagUtil.makeTag(getClass()),"updateAvatar failed :",e); } if(!TextUtils.isEmpty(s)) { Glide.with(HiTalkApplication.mAppContext).load(s).placeholder(R.drawable.default_avatar).into(avatarView); } else { avatarView.setImageResource(R.drawable.default_avatar); } } }); } else { avatarView.setImageResource(R.drawable.default_group_icon); } } }
@Override public void onBindViewHolder(ClickableViewHolder holder, int position) { if (holder instanceof ItemViewHolder) { ItemViewHolder itemViewHolder = (ItemViewHolder) holder; AllareasRankInfo.RankBean.ListBean listBean = allRanks.get(position); itemViewHolder.mVideoTitle.setText(listBean.getTitle()); itemViewHolder.mVideoPlayNum.setText(String.valueOf(listBean.getPlay())); itemViewHolder.mVideoReviewCount.setText(String.valueOf(listBean.getVideo_review())); itemViewHolder.mUserName.setText(listBean.getAuthor()); itemViewHolder.mSortNum.setText(String.valueOf(position + 1)); setSortNumTextSize(itemViewHolder, position); Glide.with(getContext()) .load(listBean.getPic()) .centerCrop() .diskCacheStrategy(DiskCacheStrategy.ALL) .placeholder(R.drawable.bili_default_image_tv) .dontAnimate() .into(itemViewHolder.mVideoImg); } super.onBindViewHolder(holder, position); }
@Override public Object instantiateItem(ViewGroup container, int position) { // TODO Auto-generated method stub View view = null; view= inflater.inflate(R.layout.main_viewpager_popular, null); ImageView img= (ImageView)view.findViewById(R.id.img_viewpager_childimage); TextView maintext = (TextView)view.findViewById(R.id.text_viewpager_main); TextView subtext = (TextView)view.findViewById(R.id.text_viewpager_sub); Log.d("position", position+""); maintext.setText(mDataset.get(position).getTitle()); subtext.setText(mDataset.get(position).getEng_title()); Log.d("image url", mDataset.get(position).getImage()); if(mDataset.get(position).getImage() == "NoImage"){ Glide.with(mContext).load(R.drawable.noimage).into(img); } else { String imgUrl = mDataset.get(position).getImage().substring(1, mDataset.get(position).getImage().length() - 1); Log.d("image url2", imgUrl); Glide.with(mContext).load(imgUrl).into(img); } container.addView(view); return view; }
private void updateMetadata(final Movie movie) { final MediaMetadata.Builder metadataBuilder = new MediaMetadata.Builder(); String title = movie.getTitle().replace("_", " -"); metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_TITLE, title); metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_SUBTITLE, movie.getDescription()); metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_ICON_URI, movie.getCardImageUrl()); // And at minimum the title and artist for legacy support metadataBuilder.putString(MediaMetadata.METADATA_KEY_TITLE, title); metadataBuilder.putString(MediaMetadata.METADATA_KEY_ARTIST, movie.getStudio()); Glide.with(this) .load(Uri.parse(movie.getCardImageUrl())) .asBitmap() .into(new SimpleTarget<Bitmap>(500, 500) { @Override public void onResourceReady(Bitmap bitmap, GlideAnimation anim) { metadataBuilder.putBitmap(MediaMetadata.METADATA_KEY_ART, bitmap); mSession.setMetadata(metadataBuilder.build()); } }); }
private void setImageOrSensitive(String url, ImageView imageView, boolean sensitiveContent) { if (!sensitiveContent) { Glide .with(parentCtx) .load(url) .crossFade() .into(imageView); } else { imageView.setImageDrawable(new ColorDrawable(Color.GRAY)); } imageView.setVisibility(View.VISIBLE); }
private static Bitmap generateImageThumbnail(Context context, MasterSecret masterSecret, Uri uri) throws BitmapDecodingException { try { int maxSize = context.getResources().getDimensionPixelSize(R.dimen.media_bubble_height); return Glide.with(context) .load(new DecryptableUri(masterSecret, uri)) .asBitmap() .centerCrop() .into(maxSize, maxSize) .get(); } catch (InterruptedException | ExecutionException e) { Log.w(TAG, e); throw new BitmapDecodingException(e); } }
@SuppressLint("SetTextI18n") @Override public void onBindViewHolder(ClickableViewHolder holder, int position) { if (holder instanceof ItemViewHolder) { ItemViewHolder itemViewHolder = (ItemViewHolder) holder; BangumiDetailsRecommendInfo.ResultBean.ListBean listBean = bangumiRecommends.get(position); Glide.with(getContext()) .load(listBean.getCover()) .centerCrop() .diskCacheStrategy(DiskCacheStrategy.ALL) .placeholder(R.drawable.bili_default_image_tv) .dontAnimate() .into(itemViewHolder.mImage); itemViewHolder.mTitle.setText(listBean.getTitle()); itemViewHolder.mFollow.setText( NumberUtil.converString(Integer.valueOf(listBean.getFollow())) + "人追番"); } super.onBindViewHolder(holder, position); }
private void renderData(ProductDetailsViewState.DataState state) { TransitionManager.beginDelayedTransition(rootView); errorView.setVisibility(View.GONE); loadingView.setVisibility(View.GONE); detailsView.setVisibility(View.VISIBLE); isProductInshoppingCart = state.getDetail().isInShoppingCart(); product = state.getDetail().getProduct(); price.setText("Price: $" + String.format(Locale.US, "%.2f", product.getPrice())); description.setText(product.getDescription()); toolbar.setTitle(product.getName()); collapsingToolbarLayout.setTitle(product.getName()); if (isProductInshoppingCart) { fab.setImageResource(R.drawable.ic_in_shopping_cart); } else { fab.setImageResource(R.drawable.ic_add_shopping_cart); } Glide.with(this) .load(DependencyInjection.BASE_IMAGE_URL + product.getImage()) .centerCrop() .into(backdrop); }
/** * 高斯背景图和一般图片 */ private void setPicture() { Glide.with(this) .load(IMAGE_URL_LARGE) .override((int) CommonUtils.getDimens(R.dimen.movie_detail_width), (int) CommonUtils.getDimens(R.dimen.movie_detail_height)) .into(binding.include.ivOnePhoto); // "14":模糊度;"3":图片缩放3倍后再进行模糊 Glide.with(this) .load(IMAGE_URL_MEDIUM) .error(R.drawable.stackblur_default) .placeholder(R.drawable.stackblur_default) .crossFade(500) .bitmapTransform(new BlurTransformation(this, 14, 3)) .into(binding.include.imgItemBg); }
@Override public void onBindViewHolder(StepHolder holder, int position) { holder.mStep = mStepList.get(position); holder.mBinding.cvStepItemHolder.setSelected(mSelectedPosition == position); if(holder.mStep.getVideoURL()!=null && !holder.mStep.getVideoURL().matches("")) { Glide.with(holder.itemView.getContext()) .load(holder.mStep.getThumbnailURL()) .placeholder(R.drawable.ic_videocam_black_24dp) .error(R.drawable.ic_videocam_black_24dp) .dontAnimate() .into(holder.mBinding.ivStepItemVideoThumb); } else { holder.mBinding.ivStepItemVideoThumb.setImageResource(R.drawable.ic_videocam_off_black_24dp); } if(holder.mStep.getId() == 0) holder.mBinding.tvStepListStepNumber.setText(" "); else holder.mBinding.tvStepListStepNumber.setText(String.valueOf(holder.mStep.getId()) + ": "); holder.mBinding.tvStepListStepShortDesc.setText(holder.mStep.getShortDescription()); }
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { Contentlist contentlist= list.get(position); // 随机高度, 模拟瀑布效果. if (mHeights.size() <= position) { mHeights.add((int) (100 + Math.random() * 300)); } ViewGroup.LayoutParams lp = ((ViewHolder) holder).imageView.getLayoutParams(); lp.height = mHeights.get(position); ((ViewHolder) holder).imageView.setLayoutParams(lp); Glide.with(UIcollector.getContext()) .load(contentlist.getList().get(0).getMiddle()) .override(300, 400) .into(((ViewHolder) holder).imageView); ((ViewHolder) holder).imageView.setOnClickListener(view -> { if (null != onItemClickListener) { onItemClickListener.onItemClickListener(((ViewHolder) holder).imageView, position); } }); }
@Override public void onBindViewHolder(ViewHolder holder,int position){ //得到当前项DiseaseInfo实例 DiseaseInfo disease= myDiseaseInfoList.get(position); //得到时间 holder.time.setText(disease.getInfoTime()); //得到疾病名称 holder.name.setText(disease.getDiseaseKind().getDiseaseName()); //得到疾病位置,精确到个位 int longitude=(int)disease.getLongitude(); int latitude=(int)disease.getLatitude(); String longitudeStr=String.valueOf(longitude); String latitudeStr=String.valueOf(latitude); holder.location.setText("("+longitudeStr+","+latitudeStr+")"); //得到疾病图片 Bitmap bm=PictureClass.StringToBitmap(disease.getPicture()); ByteArrayOutputStream baos=new ByteArrayOutputStream(); bm.compress(Bitmap.CompressFormat.JPEG,100,baos); byte[] buff=baos.toByteArray(); Glide.with(mContext).load(buff).into(holder.disease_pic); }
@Override public void onBindViewHolder(ClickableViewHolder holder, int position) { if (holder instanceof ItemViewHolder) { ItemViewHolder itemViewHolder = (ItemViewHolder) holder; ActivityCenterInfo.ListBean listBean = activityCenters.get(position); Glide.with(getContext()) .load(listBean.getCover()) .centerCrop() .diskCacheStrategy(DiskCacheStrategy.ALL) .placeholder(R.drawable.bili_default_image_tv) .dontAnimate() .into(itemViewHolder.mImage); itemViewHolder.mTitle.setText(listBean.getTitle()); if (listBean.getState() == 1) { itemViewHolder.mState.setImageResource(R.drawable.ic_badge_end); } else { itemViewHolder.mState.setImageResource(R.drawable.ic_badge_going); } } super.onBindViewHolder(holder, position); }
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { CommentViewHolder viewHolder = (CommentViewHolder) holder; if(position<10){ switch(position%3){ case 0: viewHolder.tvComment.setText("comment1"); break; case 1: viewHolder.tvComment.setText("comment2"); break; case 2: viewHolder.tvComment.setText("comment3"); break; } }else{ viewHolder.tvComment.setText(mCommentString);//更新评论字符串 } Glide.with(mContext) .load(R.drawable.ic_launcher) .centerCrop() .into(viewHolder.ivUserAvatar); }
private void displayImage() { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; // 对图片进行设置 但不形成示例,不耗费内存 BitmapFactory.decodeFile(mImageFile.getPath(), options); int imageRequestWidth = getRequestImeWidth(); int imageRequestHeight = getRequestImeHeight(options); Logger.d("width " + imageRequestWidth + " height:" + imageRequestHeight); Logger.d("bitmap1 width " + options.outWidth + " height:" + options.outHeight); Glide.with(mView.getActivity()) .load(mImageFile) .asBitmap() .override(imageRequestWidth, imageRequestHeight) // 设置大小 .fitCenter() // 不按照比例 .into(new SimpleTarget<Bitmap>() { @Override public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) { //根据Bitmap对象创建ImageSpan对象 Logger.d("bitmap width:" + resource.getWidth() + " height:" + resource.getHeight()); mView.insertImage(mImageName, resource); } }); }
@Override public void onBindItemViewHolder(RecyclerView.ViewHolder holder, int position) { ItemViewHolder itemViewHolder = (ItemViewHolder) holder; BangumiAppIndexInfo.ResultBean.SerializingBean serializingBean = mSerials.get(position); Glide.with(mContext) .load(serializingBean.getCover()) .centerCrop() .diskCacheStrategy(DiskCacheStrategy.ALL) .placeholder(R.drawable.bili_default_image_tv) .dontAnimate() .into(itemViewHolder.mImage); itemViewHolder.mTitle.setText(serializingBean.getTitle()); itemViewHolder.mPlay.setText(NumberUtil.converString(serializingBean.getWatching_count()) + "人在看"); itemViewHolder.mUpdate.setText("更新至第" + serializingBean.getNewest_ep_index() + "话"); itemViewHolder.mCardView.setOnClickListener(v -> BangumiDetailsActivity.launch((Activity) mContext, serializingBean.getSeason_id())); }
@Override protected void convert(final BaseViewHolder helper, FakeWeather.FakeForecastHourly item) { int width = SizeUtils.getScreenWidth(mContext) / 5; RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) helper.itemView.getLayoutParams(); params.width = width; helper.itemView.setLayoutParams(params); helper.setText(R.id.tv_hourly_temp, item.getTemp() + "°"); helper.setText(R.id.tv_hourly_time, item.getTime()); final ImageView imageView = helper.getView(R.id.iv_hourly_weather); WeatherUtil.getInstance().getWeatherDict(item.getCode()).observeOn(AndroidSchedulers.mainThread()).subscribe(new SimpleSubscriber<WeatherBean>() { @Override public void onNext(WeatherBean weatherBean) { Glide.with(mContext).load(weatherBean.getIcon()).diskCacheStrategy(DiskCacheStrategy.ALL).into(imageView); } }); }
@Override public void onBindItemViewHolder(RecyclerView.ViewHolder holder, int position) { ItemViewHolder itemViewHolder = (ItemViewHolder) holder; RegionDetailsInfo.DataBean.NewBean newBean = newsVideos.get(position); Glide.with(mContext) .load(newBean.getCover()) .centerCrop() .diskCacheStrategy(DiskCacheStrategy.ALL) .placeholder(R.drawable.bili_default_image_tv) .dontAnimate() .into(itemViewHolder.mVideoPic); itemViewHolder.mTitle.setText(newBean.getTitle()); itemViewHolder.mUpName.setText(newBean.getName()); itemViewHolder.mPlay.setText(String.valueOf(newBean.getPlay())); itemViewHolder.mReview.setText(String.valueOf(newBean.getDanmaku())); itemViewHolder.mItemView.setOnClickListener( v -> VideoDetailsActivity.launch((Activity) mContext, Integer.valueOf(newBean.getParam()), newBean.getCover())); }
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if(holder instanceof ViewHolder){ Horoscope horoscope = mHoroList.get(position); ViewHolder horoVH=(ViewHolder)holder; horoVH.enName.setText(horoscope.geteNname()); horoVH.cnName.setText(horoscope.getcNname()); Glide.with(mContext).load(horoscope.getImageId()).into(horoVH.horoImage); }else if(holder instanceof AlbumViewHolder){ AlbumViewHolder AlbumVH=(AlbumViewHolder)holder; LinearLayoutManager manager=new LinearLayoutManager(mContext); manager.setOrientation(LinearLayoutManager.HORIZONTAL); AlbumVH.horizon.setLayoutManager(manager); AlbumAdapter albumAdapter= new AlbumAdapter(albumList); AlbumVH.horizon.setAdapter(albumAdapter); } }
@Override public void loadThumbnail(Context context, int resize, Drawable placeholder, ImageView imageView, Uri uri) { Glide.with(context) .load(uri) .asBitmap() // some .jpeg files are actually gif .placeholder(placeholder) .override(resize, resize) .centerCrop() .into(imageView); }
/** * Helper constructor that accepts an {@link android.support.v4.app.Fragment}. */ public RecyclerViewPreloader(Fragment fragment, PreloadModelProvider<T> preloadModelProvider, PreloadSizeProvider<T> preloadDimensionProvider, int maxPreload) { this(Glide.with(fragment), preloadModelProvider, preloadDimensionProvider, maxPreload); }
@BindingAdapter({"roundImageUrl"}) public static void loadRoundImg(ImageView v, String url) { v.setColorFilter(v.getContext().getResources().getColor(SpUtil.isNight() ? R.color.CoverColor : R.color.colorWhite), PorterDuff.Mode.MULTIPLY); Glide.with(v.getContext()) .load(getFuckUrl(url)) .diskCacheStrategy(DiskCacheStrategy.ALL) .transform(new GlideCircleTransform(v.getContext())) .error(R.mipmap.ic_launcher) .into(v); }
/** * 异步加载图片 * * @param view the view * @param resIds 图片资源ID */ static void asyncLoadDrawable(CompositionAvatarView view, int... resIds) { int length = Math.min(resIds.length, CompositionAvatarView.MAX_DRAWABLE_COUNT); for (int i = 0; i < length; i++) { // 图片布局的顺序是按添加的顺序以顺时针方向布局的,所以可以添加点位图以固定图片的显示顺序 view.addDrawable(DRAWABLE_IDS[i], new ColorDrawable(0xffdddddd)); Glide.with(view.getContext()) .fromResource() .load(resIds[i]) // .placeholder(new ColorDrawable(0xffdddddd)) // 由于异步,这里并不能保证显示的顺序 .into(new CompositionAvatarViewTarget(view, DRAWABLE_IDS[i])); } }
@Override protected void convert(BaseViewHolder viewHolder, Movie item) { viewHolder.setText(R.id.lmi_title, item.filmName) .setText(R.id.lmi_actor, item.actors) .setText(R.id.lmi_grade, item.grade) .setText(R.id.lmi_describe, item.shortinfo); Glide.with(mContext).load(item.picaddr).into((ImageView) viewHolder.getView(R.id.lmi_avatar)); }
@Override public void registerComponents(Context context, Glide glide) { glide.register(DecryptableUri.class, InputStream.class, new DecryptableStreamUriLoader.Factory()); glide.register(ContactPhotoUri.class, InputStream.class, new ContactPhotoUriLoader.Factory()); glide.register(AttachmentModel.class, InputStream.class, new AttachmentStreamUriLoader.Factory()); glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory()); }
@Override public Drawable getDrawable(@NonNull String url) { final UrlDrawable urlDrawable = new UrlDrawable(); if (container != null && container.get() != null) { Context context = container.get().getContext(); final GenericRequestBuilder load = Glide.with(context) .load(url) .dontAnimate(); final GlideDrawableTarget target = new GlideDrawableTarget(urlDrawable, container, width); load.into(target); cachedTargets.add(target); } return urlDrawable; }
/** * set user avatar * @param username */ public static void setUserAvatar(Context context, String username, ImageView imageView){ EaseUser user = getUserInfo(username); if(user != null && user.getAvatar() != null){ try { int avatarResId = Integer.parseInt(user.getAvatar()); Glide.with(context).load(avatarResId).into(imageView); } catch (Exception e) { //use default avatar Glide.with(context).load(user.getAvatar()).diskCacheStrategy(DiskCacheStrategy.ALL).placeholder(R.drawable.ease_default_avatar).into(imageView); } }else{ Glide.with(context).load(R.drawable.ease_default_avatar).into(imageView); } }
@Override public void onLowMemory() { if (BuildConfig.DEBUG) { T_.show("请注意, 内存过低!"); } Glide.get(this).clearMemory(); //Fresco.shutDown(); // if (Fresco.hasBeenInitialized()) { // Fresco.getImagePipeline().clearMemoryCaches(); // } super.onLowMemory(); }
private void setupDetailsOverviewRow() { final DetailsOverviewRow row = new DetailsOverviewRow(mSelectedVideo); Glide.with(this) .load(mSelectedVideo.cardImageUrl) .asBitmap() .dontAnimate() .error(R.drawable.default_background) .into(new SimpleTarget<Bitmap>() { @Override public void onResourceReady(final Bitmap resource, GlideAnimation glideAnimation) { row.setImageBitmap(getActivity(), resource); startEntranceTransition(); } }); SparseArrayObjectAdapter adapter = new SparseArrayObjectAdapter(); adapter.set(ACTION_WATCH_TRAILER, new Action(ACTION_WATCH_TRAILER, getResources() .getString(R.string.watch_trailer_1), getResources().getString(R.string.watch_trailer_2))); adapter.set(ACTION_RENT, new Action(ACTION_RENT, getResources().getString(R.string.rent_1), getResources().getString(R.string.rent_2))); adapter.set(ACTION_BUY, new Action(ACTION_BUY, getResources().getString(R.string.buy_1), getResources().getString(R.string.buy_2))); row.setActionsAdapter(adapter); mAdapter.add(row); }
@BindingAdapter(value = {"imageUrl", "placeHolder", "error"}, requireAll = false) /** * 不支持mipmap下的图片 */ public static void loadImage(ImageView imageView, String url, Drawable holderDrawable, Drawable errorDrawable) { Glide.with(imageView.getContext()) .load(url) .apply(GlideRequestOption.getRequestOptions().placeholder(holderDrawable) .error(errorDrawable)) .into(imageView); }
@SuppressLint("SetTextI18n") @Override public void onBindViewHolder(ClickableViewHolder holder, int position) { if (holder instanceof ItemViewHolder) { ItemViewHolder itemViewHolder = (ItemViewHolder) holder; AttentionDynamicInfo.DataBean.FeedsBean feedsBean = dynamics.get(position); Glide.with(getContext()) .load(feedsBean.getAddition().getPic()) .centerCrop() .diskCacheStrategy(DiskCacheStrategy.ALL) .placeholder(R.drawable.bili_default_image_tv) .dontAnimate() .into(itemViewHolder.mImage); Glide.with(getContext()) .load(feedsBean.getSource().getAvatar()) .centerCrop() .diskCacheStrategy(DiskCacheStrategy.ALL) .placeholder(R.drawable.ico_user_default) .dontAnimate() .into(itemViewHolder.mAvatar); itemViewHolder.mName.setText(feedsBean.getSource().getUname()); itemViewHolder.mTitle.setText(feedsBean.getAddition().getTitle()); itemViewHolder.mPlay.setText(NumberUtil.converString(feedsBean.getAddition().getPlay())); itemViewHolder.mReview.setText( NumberUtil.converString(feedsBean.getAddition().getVideo_review())); itemViewHolder.mUpdateTime.setText( WeekDayUtil.formatDate(feedsBean.getAddition().getCreate())); } super.onBindViewHolder(holder, position); }
private void setCover(@Nullable String url) { if (url != null) { Glide.with(getContext()) .load(url) .asBitmap() .placeholder(R.drawable.placeholder) .centerCrop() .error(R.drawable.placeholder) .into(mImageView); } else { mImageView.setImageResource(R.drawable.placeholder); } }
/** * 重载方法 加载展示圆形图片 * @param round 调用方传布尔值即视为要加载圆形图片 */ public void displayImage(Context context, String uri, ImageView view , int defaultIcon, boolean round) { Glide.with(context) .load(uri) .diskCacheStrategy(mDiskCacheStrategy) .transform(new GlideCircleTransform(context)) .placeholder(defaultIcon) .error(defaultIcon) .into(view); }
@Override public View getGroupView(final int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { final View group = inflater.inflate(R.layout.item_top_rank_group, null); ImageView ivCover = (ImageView) group.findViewById(R.id.ivRankCover); if (!TextUtils.isEmpty(groupArray.get(groupPosition).cover)) { Glide.with(mContext).load(Constant.IMG_BASE_URL + groupArray.get(groupPosition).cover).placeholder(R.drawable.avatar_default) .transform(new GlideCircleTransform(mContext)).into(ivCover); group.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (listener != null) { listener.onItemClick(group, groupPosition, groupArray.get(groupPosition)); } } }); } else { ivCover.setImageResource(R.drawable.ic_rank_collapse); } TextView tvName = (TextView) group.findViewById(R.id.tvRankGroupName); tvName.setText(groupArray.get(groupPosition).title); ImageView ivArrow = (ImageView) group.findViewById(R.id.ivRankArrow); if (childArray.get(groupPosition).size() > 0) { if (isExpanded) { ivArrow.setImageResource(R.drawable.rank_arrow_up); } else { ivArrow.setImageResource(R.drawable.rank_arrow_down); } } else { ivArrow.setVisibility(View.GONE); } return group; }
@Override protected File doInBackground(String... params) { String url = params[0]; try { return Glide .with(context) .downloadOnly() .load(url) .submit(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL) .get(); } catch (Exception ex) { return null; } }
public static void requestImgFromBytes(Context context, byte[] bytes, ImageView view) { Glide.with(context) .load(bytes) .placeholder(R.color.grey_300) .error(R.color.red_300) .into(view); }
@Override public void onBindViewHolder(CharacterSmall model) { Glide.with(mContext).load(model.getImage_url_lge()) .diskCacheStrategy(DiskCacheStrategy.ALL) .centerCrop() .into(model_image); name.setText(String.format(Locale.getDefault(), "%s %s", model.getName_first(), model.getName_last())); if(model.getRole() != null) role.setText(model.getRole()); }