com.bumptech.glide.Glide Java Examples
The following examples show how to use
com.bumptech.glide.Glide.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BookListDetailActivity.java From NovelReader with MIT License | 6 votes |
@Override public void onBindView(View view) { if (detailUnbinder == null){ detailUnbinder = ButterKnife.bind(this,view); } //如果没有值就直接返回 if (detailBean == null){ return; } //标题 tvTitle.setText(detailBean.getTitle()); //描述 tvDesc.setText(detailBean.getDesc()); //头像 Glide.with(App.getContext()) .load(Constant.IMG_BASE_URL+detailBean.getAuthor().getAvatar()) .placeholder(R.drawable.ic_loadding) .error(R.drawable.ic_load_error) .transform(new CircleTransform(App.getContext())) .into(ivPortrait); //作者 tvAuthor.setText(detailBean.getAuthor().getNickname()); }
Example #2
Source File: MovieDetailAdapter.java From YiZhi with Apache License 2.0 | 6 votes |
@Override protected void convert(BaseViewHolder helper, PersonBean item) { helper.setText(R.id.tv_person_name, item.getName()); helper.setText(R.id.tv_person_type, item.getType()); try { //避免空指针异常 if (StringUtils.isEmpty(item.getAvatars().getLarge())) return; Glide.with(mContext).load(item.getAvatars().getLarge()).crossFade().into((ImageView) helper.getView(R.id.iv_avatar_photo)); } catch (Exception e) { e.printStackTrace(); } }
Example #3
Source File: ImageLoaderKit.java From NIM_Android_UIKit with MIT License | 6 votes |
/** * 如果图片是上传到云信服务器,并且用户开启了文件安全功能,那么这里可能是短链,需要先换成源链才能下载。 * 如果没有使用云信存储或没开启文件安全,那么不用这样做 */ private void loadAvatarBitmapToCache(final String url) { if (TextUtils.isEmpty(url)) { return; } /* * 若使用网易云信云存储,这里可以设置下载图片的压缩尺寸,生成下载URL * 如果图片来源是非网易云信云存储,请不要使用NosThumbImageUtil */ NIMClient.getService(NosService.class).getOriginUlrFromShortUrl(url).setCallback( new RequestCallbackWrapper<String>() { @Override public void onResult(int code, String result, Throwable exception) { if (TextUtils.isEmpty(result)) { result = url; } final int imageSize = HeadImageView.DEFAULT_AVATAR_THUMB_SIZE; Glide.with(context).load(result).submit(imageSize, imageSize); } }); }
Example #4
Source File: CustomViewHolder3.java From Banner with Apache License 2.0 | 6 votes |
@SuppressLint("InflateParams") @Override public View createView(Context context, int position, CustomData data) { View view = LayoutInflater.from(context).inflate(R.layout.banner_item2, null); TextView position1 = view.findViewById(R.id.position); LinearLayout ll = view.findViewById(R.id.ll_group); ImageView image1 = view.findViewById(R.id.image1); ImageView image2 = view.findViewById(R.id.image2); position1.setText(String.valueOf(position)); if (data.isMovie()) { ll.setVisibility(View.GONE); image2.setVisibility(View.VISIBLE); Glide.with(context).load(R.mipmap.b1).into(image1); Glide.with(context).load(R.mipmap.movie).into(image2); } else { ll.setVisibility(View.VISIBLE); image2.setVisibility(View.GONE); Glide.with(context).load(data.getUrl()).into(image1); Glide.with(context).load(R.mipmap.b1).into(image2); } return view; }
Example #5
Source File: MeiziAdapter.java From Gank.io with GNU General Public License v3.0 | 6 votes |
@Override public void onBindViewHolder(MeiziHolder holder, int position) { final Meizi meizi = list.get(position); holder.card.setTag(meizi); int red = (int) (Math.random() * 255); int green = (int) (Math.random() * 255); int blue = (int) (Math.random() * 255); holder.ivMeizi.setBackgroundColor(Color.argb(204, red, green, blue)); Glide.with(context) .load(meizi.url) .crossFade() .into(holder.ivMeizi); holder.tvWho.setText(meizi.who); holder.tvDesc.setText(meizi.desc); holder.tvTime.setText(DateUtil.toDateTimeStr(meizi.publishedAt)); showItemAnimation(holder, position); }
Example #6
Source File: TextListData.java From Pasta-for-Spotify with Apache License 2.0 | 6 votes |
@Override public void bindView(ViewHolder holder) { if (title != null) { holder.title.setVisibility(View.VISIBLE); holder.title.setText(title); } else holder.title.setVisibility(View.GONE); if (subtitle != null) { holder.subtitle.setVisibility(View.VISIBLE); holder.subtitle.setText(subtitle); } else holder.subtitle.setVisibility(View.GONE); if (image != null) { holder.image.setVisibility(View.VISIBLE); holder.image.setImageDrawable(new ColorDrawable(Color.parseColor("#bdbdbd"))); Glide.with(holder.image.getContext()).load(image).thumbnail(0.2f).into(holder.image); } else holder.image.setVisibility(View.GONE); if (primary != null) holder.itemView.setClickable(true); else holder.itemView.setClickable(false); }
Example #7
Source File: HomeActivity.java From DragFooterView with Apache License 2.0 | 6 votes |
private void setupHorizontalScrollView() { LinearLayout linearLayout = (LinearLayout) findViewById(R.id.linear_layout); for (int i = 10; i < 20; i++) { ImageView imageView = new ImageView(this); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(dp2px(120), ViewGroup.LayoutParams.MATCH_PARENT); params.leftMargin = 0; params.rightMargin = dp2px(5); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setLayoutParams(params); linearLayout.addView(imageView); Glide.with(this).load(Constants.urls[i]).into(imageView); } DragContainer dragContainer = (DragContainer) findViewById(R.id.drag_scroll_view); BaseFooterDrawer drawer = new ArrowPathFooterDrawer.Builder(this, 0xff444444).setPathColor(0xffffffff).build(); dragContainer.setFooterDrawer(drawer); dragContainer.setDragListener(this); }
Example #8
Source File: BillAdapter.java From DMusic with Apache License 2.0 | 6 votes |
@Override public void convert(int position, CommonHolder holder, final BillModel item) { holder.setViewVisibility(musics[0], View.GONE); holder.setViewVisibility(musics[1], View.GONE); holder.setViewVisibility(musics[2], View.GONE); if (item.content != null && item.content.size() > 0) { for (int i = 0; i < item.content.size() && i < 3; i++) { holder.setViewVisibility(musics[i], View.VISIBLE); holder.setText(musics[i], (i + 1) + ". " + item.content.get(i).title + " - " + item.content.get(i).author); } } Glide.with(mContext) .load(item.pic_s192) .apply(new RequestOptions().dontAnimate()) .into((ImageView) holder.getView(R.id.iv_cover)); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DetailActivity.openActivity(mContext, DetailActivity.TYPE_BILL, "" + item.type, "" + item.name); } }); }
Example #9
Source File: ImageUtils.java From SendBird-Android with MIT License | 6 votes |
/** * Displays an GIF image from a URL in an ImageView. */ public static void displayGifImageFromUrl(Context context, String url, ImageView imageView, String thumbnailUrl, Drawable placeholderDrawable) { RequestOptions myOptions = new RequestOptions() .dontAnimate() .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC) .placeholder(placeholderDrawable); if (thumbnailUrl != null) { Glide.with(context) .asGif() .load(url) .apply(myOptions) .thumbnail(Glide.with(context).asGif().load(thumbnailUrl)) .into(imageView); } else { Glide.with(context) .asGif() .load(url) .apply(myOptions) .into(imageView); } }
Example #10
Source File: SuggestedAppViewHolder.java From aptoide-client with GNU General Public License v2.0 | 6 votes |
public void populateView(Displayable displayable) { if (displayable instanceof SuggestedAppDisplayable) { itemView.setVisibility(View.VISIBLE); SuggestedAppDisplayable suggestedAppDisplayable = (SuggestedAppDisplayable) displayable; DecimalFormat df = new DecimalFormat("0.00"); labelTextView.setText(suggestedAppDisplayable.getLabel()); sizeTextView.setText(df.format(suggestedAppDisplayable.getSize()) + " MB"); descriptionTextView.setText(suggestedAppDisplayable.getDescription()); store.setText(suggestedAppDisplayable.getStore()); Glide.with(itemView.getContext()).load(suggestedAppDisplayable.getIconPath()).into(iconImageView); itemView.setOnClickListener(generateOnClickListener(suggestedAppDisplayable)); } }
Example #11
Source File: BitmapTransformation.java From AcgClub with MIT License | 6 votes |
@Override public final Resource<Bitmap> transform(Context context, Resource<Bitmap> resource, int outWidth, int outHeight) { if (!Util.isValidDimensions(outWidth, outHeight)) { throw new IllegalArgumentException( "Cannot apply transformation on width: " + outWidth + " or height: " + outHeight + " less than or equal to zero and not Target.SIZE_ORIGINAL"); } BitmapPool bitmapPool = Glide.get(context).getBitmapPool(); Bitmap toTransform = resource.get(); int targetWidth = outWidth == Target.SIZE_ORIGINAL ? toTransform.getWidth() : outWidth; int targetHeight = outHeight == Target.SIZE_ORIGINAL ? toTransform.getHeight() : outHeight; Bitmap transformed = transform(context.getApplicationContext(), bitmapPool, toTransform, targetWidth, targetHeight); final Resource<Bitmap> result; if (toTransform.equals(transformed)) { result = resource; } else { result = BitmapResource.obtain(transformed, bitmapPool); } return result; }
Example #12
Source File: GlideRoundedImageView.java From SlyceMessaging with MIT License | 6 votes |
private void loadImageUrl() { // If the view has been laid out (has width/height), and hasn't been loaded yet, attempt to load it if (mViewHasLaidOut && !mHasStartedImageLoad && !TextUtils.isEmpty(mSourceImageUrl)) { if (mSourceImageUrl != null) { Glide .with(getContext()) .load(mSourceImageUrl) .centerCrop() .error(R.drawable.shape_rounded_rectangle_gray) .placeholder(R.drawable.shape_rounded_rectangle_gray) .into(this); } else { setImageResource(R.drawable.shape_rounded_rectangle_gray); } } }
Example #13
Source File: TVShowBriefsSmallAdapter.java From PopCorn with Apache License 2.0 | 6 votes |
@Override public void onBindViewHolder(TVShowViewHolder holder, int position) { Glide.with(mContext.getApplicationContext()).load(Constants.IMAGE_LOADING_BASE_URL_342 + mTVShows.get(position).getPosterPath()) .asBitmap() .centerCrop() .diskCacheStrategy(DiskCacheStrategy.ALL) .into(holder.tvShowPosterImageView); if (mTVShows.get(position).getName() != null) holder.tvShowTitleTextView.setText(mTVShows.get(position).getName()); else holder.tvShowTitleTextView.setText(""); if (Favourite.isTVShowFav(mContext, mTVShows.get(position).getId())) { holder.tvShowFavImageButton.setImageResource(R.mipmap.ic_favorite_black_18dp); holder.tvShowFavImageButton.setEnabled(false); } else { holder.tvShowFavImageButton.setImageResource(R.mipmap.ic_favorite_border_black_18dp); holder.tvShowFavImageButton.setEnabled(true); } }
Example #14
Source File: PictureView.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void setInitialValue(String value) { if (!isEmpty(value)) { Glide.with(image).clear(image); clearButton.setVisibility(View.VISIBLE); File file = new File(value); if (file.exists()) { currentValue = value; setTextSelected(getContext().getString(R.string.image_selected)); image.setVisibility(View.VISIBLE); Glide.with(image) .load(file) .apply(new RequestOptions().centerCrop()) .apply(RequestOptions.skipMemoryCacheOf(true)) .apply(RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.NONE)) .skipMemoryCache(true) .into(image); } } else clearButton.setVisibility(View.GONE); }
Example #15
Source File: RobotImageView.java From NIM_Android_UIKit with MIT License | 6 votes |
@Override public void onBindContentView() { String url = content; if (element != null) { url = element.getUrl(); } if (TextUtils.isEmpty(url)) { return; } Glide.with(getContext()) .asBitmap() .load(url) .apply(new RequestOptions() .centerCrop() .placeholder(R.drawable.nim_message_item_round_bg)) .into(thumbnail); }
Example #16
Source File: RecieverAdapter.java From SnapchatClone with MIT License | 6 votes |
@Override public void onBindViewHolder(@NonNull final RecieverViewHolders rcViewHolders, int i) { rcViewHolders.username.setText(usersList.get(i).getUsername()); String imageUrl = usersList.get(i).getProfileImageUrl(); if (imageUrl.equals("default")) { rcViewHolders.profileImage.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.profile)); } else { Glide.with(context).load(imageUrl).into(rcViewHolders.profileImage); } rcViewHolders.receiveCheck.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { boolean receiveState = !usersList.get(rcViewHolders.getLayoutPosition()).getReceive(); usersList.get(rcViewHolders.getLayoutPosition()).setReceive(receiveState); } }); }
Example #17
Source File: ThemeDetailsEditorsAdapter.java From LeisureRead with Apache License 2.0 | 6 votes |
@Override public void onBindViewHolder(ClickableViewHolder holder, int position) { if (holder instanceof ItemViewHolder) { ItemViewHolder itemViewHolder = (ItemViewHolder) holder; ThemeDetailsInfo.EditorsBean editorsBean = mDataSources.get(position); Glide.with(getContext()) .load(editorsBean.getAvatar()) .centerCrop() .dontAnimate() .placeholder(R.drawable.account_avatar) .into(itemViewHolder.mPic); } super.onBindViewHolder(holder, position); }
Example #18
Source File: LockScreenActivity.java From RetroMusicPlayer with GNU General Public License v3.0 | 6 votes |
private void loadSong() { SongGlideRequest.Builder.from(Glide.with(this), MusicPlayerRemote.getCurrentSong()) .checkIgnoreMediaStore(this) .generatePalette(this).build() .into(new RetroMusicColoredTarget(image) { @Override public void onLoadCleared(Drawable placeholder) { super.onLoadCleared(placeholder); // mPlayerPlaybackControlsFragment.setDark(getDefaultFooterColor()); } @Override public void onColorReady(int color) { mPlayerPlaybackControlsFragment.setDark((color)); if (PreferenceUtil.getInstance(LockScreenActivity.this).getAdaptiveColor()) changeColor(color); else { changeColor(ThemeStore.accentColor(LockScreenActivity.this)); } } }); }
Example #19
Source File: TopicHeader.java From pybbsMD with Apache License 2.0 | 6 votes |
public void updateViews(@Nullable Topic topic, boolean isCollect, int replyCount) { this.topic = topic; this.isCollect = isCollect; if (topic != null) { layoutContent.setVisibility(View.VISIBLE); iconGood.setVisibility(topic.isGood() ? View.VISIBLE : View.GONE); tvTitle.setText(topic.getTitle()); Glide.with(activity).load(topic.getAvatar()).placeholder(R.drawable.image_placeholder).dontAnimate().into(imgAvatar); ctvTab.setText(topic.isTop() ? R.string.tab_top : topic.getTab().getNameId()); ctvTab.setChecked(topic.isTop()); tvLoginName.setText(topic.getAuthor()); tvCreateTime.setText(FormatUtils.getRelativeTimeSpanString(topic.getInTime()) + "创建"); tvVisitCount.setText(topic.getView() + "次浏览"); btnFavorite.setImageResource(isCollect ? R.drawable.ic_favorite_theme_24dp : R.drawable.ic_favorite_outline_grey600_24dp); // 这里直接使用WebView,有性能问题 webContent.loadRenderedContent(topic.getContentHtml()); updateReplyCount(replyCount); } else { layoutContent.setVisibility(View.GONE); iconGood.setVisibility(View.GONE); } }
Example #20
Source File: BaseHttp.java From MousePaint with MIT License | 5 votes |
protected void baseDisplayImage(T t,ImageView imageView,String imgUrl,int placeholderId,int errorId) { if(t instanceof Activity) { Glide.with((Activity) t).load(imgUrl).placeholder(placeholderId).error(errorId).into(imageView); }else if(t instanceof Fragment) { Glide.with((Fragment) t).load(imgUrl).placeholder(placeholderId).error(errorId).into(imageView); }else if(t instanceof Context) { Glide.with((Context) t).load(imgUrl).placeholder(placeholderId).error(errorId).into(imageView); }else { throw new RuntimeException("the t must be context or activity or fragment"); } }
Example #21
Source File: BenihImageView.java From CodePolitan with Apache License 2.0 | 5 votes |
public void setImageUrl(String url, int errorResourceId) { imageUrl = url; Glide.with(getContext()) .load(url) .error(errorResourceId) .into(this); }
Example #22
Source File: ImageBrowserActivity.java From MultiType-FilePicker with Apache License 2.0 | 5 votes |
@Override public Object instantiateItem(ViewGroup container, int position) { PhotoView view = new PhotoView(ImageBrowserActivity.this); view.enable(); view.setScaleType(ImageView.ScaleType.CENTER_INSIDE); Glide.with(ImageBrowserActivity.this) .load(mList.get(position).getPath()) .transition(withCrossFade()) .into(view); container.addView(view); return view; }
Example #23
Source File: GlideEngine.java From Matisse with Apache License 2.0 | 5 votes |
@Override public void loadGifImage(Context context, int resizeX, int resizeY, ImageView imageView, Uri uri) { Glide.with(context) .asGif() .load(uri) .apply(new RequestOptions() .override(resizeX, resizeY) .priority(Priority.HIGH) .fitCenter()) .into(imageView); }
Example #24
Source File: GlideUtils.java From RecyclerViewAdapter with Apache License 2.0 | 5 votes |
public static void loadImageByGlide(Context context, String url, ImageView mImageView, int width, int height) { Glide.with(context) .load(url) .override(width, height) .dontAnimate() // .placeholder(R.drawable.default_pic) .diskCacheStrategy(DiskCacheStrategy.ALL) .into(mImageView); }
Example #25
Source File: GanhuoAdapter.java From scallop with MIT License | 5 votes |
@Override public void bind(final GanHuo ganhuo, int position) { title.setText(ganhuo.getDesc().trim()); who.setText(ganhuo.getWho()); pubDate.setText(StringUtils.getRelativeTime(ganhuo.getPublishedAt())); List<String> imageUrlList = ganhuo.getImages(); if (imageUrlList != null && imageUrlList.size() > 0) { image.setVisibility(View.VISIBLE); Glide.with(itemView.getContext()) .load(imageUrlList.get(0)).apply(RequestOptions.centerCropTransform()) .into(image); } else { image.setVisibility(View.GONE); } itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(itemView.getContext(), WebViewActivity.class); intent.putExtra("URL", ganhuo.getUrl()); intent.putExtra("TITLE", ganhuo.getDesc()); itemView.getContext().startActivity( intent, ActivityOptionsCompat.makeClipRevealAnimation( itemView, 0, 0, itemView.getWidth(), itemView.getHeight()).toBundle() ); } }); }
Example #26
Source File: RecyclerViewPreloader.java From FastAndroid with Apache License 2.0 | 5 votes |
/** * Helper constructor that accepts an {@link Fragment}. */ public RecyclerViewPreloader(Fragment fragment, PreloadModelProvider<T> preloadModelProvider, PreloadSizeProvider<T> preloadDimensionProvider, int maxPreload) { this(Glide.with(fragment), preloadModelProvider, preloadDimensionProvider, maxPreload); }
Example #27
Source File: XmlyAlbumAdapter.java From AssistantBySDK with Apache License 2.0 | 5 votes |
@Override public void onBindViewHolder(BaseAlbumAdapter.AlbumHolder holder, int position) { Album album = mDatas.get(position); Glide.with(mContext).load(album.getCoverUrlMiddle()).into(holder.mIvAlbum); holder.mTvAlbumTitle.setText(album.getAlbumTitle()); LastUpTrack lastUptrack = album.getLastUptrack(); holder.mTvLastTrack.setText(new StringBuilder().append("更新至").append(TimeUtils.formatDate(new Date(lastUptrack.getCreatedAt()))).append(" ").append(lastUptrack.getTrackTitle()).toString()); holder.mTvPlayCount.setText(StringUtils.formPlayCount(album.getPlayCount()) + "次播放"); holder.mTvTrackCount.setText(album.getIncludeTrackCount() + "集"); }
Example #28
Source File: PicassoUtils.java From BigApp_Discuz_Android with Apache License 2.0 | 5 votes |
public static void display(Context context, ImageView imageView, String url) { if (url == null || TextUtils.isEmpty(url)) return; Glide.with(context) .load(url) // .networkPolicy(NetworkPolicy.NO_CACHE) // .memoryPolicy(MemoryPolicy.NO_CACHE) .error(R.drawable.no_picture) .centerCrop() .fitCenter() .into(imageView); }
Example #29
Source File: QBMessagesAdapter.java From ChatMessagesAdapter-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * displayAvatarImage must be implemented in derived class */ @Override public void displayAvatarImage(String url, ImageView imageView) { Glide.with(context) .load(url) .placeholder(R.drawable.placeholder_user) .dontAnimate() .into(imageView); }
Example #30
Source File: AppDetailActivity.java From Bailan with Apache License 2.0 | 5 votes |
private void setDetailHead(AppDetailBean bean) { Glide.with(UIUtils.getContext()).load(bean.getIcoUrl()).into(detail_app_icon); detail_app_name.setText(bean.getName()); detail_app_download_count.setText(bean.getIntro()); /*原生Api RatingBar 用于设置星星评级 setRating设置星星的个数 参数为float*/ detail_app_stars.setRating(Float.parseFloat(bean.getStars())); }