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: 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 #2
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 #3
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 #4
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 #5
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 #6
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 #7
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 #8
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 #9
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 #10
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 #11
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 #12
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 #13
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 #14
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 #15
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 #16
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 #17
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 #18
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 #19
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 #20
Source File: PlayBgDrawableController.java From Musicoco with Apache License 2.0 | 5 votes |
private void updateBackgroundDrawable(PlayBackgroundModeEnum bgMode, SongInfo info) { String path = null; if (info != null) { path = info.getAlbum_path(); } ImageView view = (ImageView) isBg.getCurrentView(); switch (bgMode) { case PICTUREWITHMASK: { final VignetteFilterTransformation vtf = new VignetteFilterTransformation( activity, new PointF(0.5f, 0.4f), new float[]{0.0f, 0.0f, 0.0f}, 0.1f, 0.75f ); Glide.with(activity) .load(StringUtils.isReal(path) ? path : R.drawable.default_album) .diskCacheStrategy(DiskCacheStrategy.RESULT) .bitmapTransform(vtf) .crossFade() .into(view); break; } case PICTUREWITHBLUR: default: { final BlurTransformation btf = new BlurTransformation(activity, 10, 10); Glide.with(activity) .load(StringUtils.isReal(path) ? path : R.drawable.default_album) .diskCacheStrategy(DiskCacheStrategy.RESULT) .bitmapTransform(btf) .crossFade() .into(view); break; } } }
Example #21
Source File: GalleryPagerFragment.java From DelegateAdapter with Apache License 2.0 | 5 votes |
private void loadPhoto(Photo photo) { if (photo != null && getUserVisibleHint() && isAdded() && !mScaleImageView.isImageLoaded()) { mPb.setVisibility(View.VISIBLE); Glide.with(this).asFile().load(photo.urls.full).into(new SimpleTarget<File>() { @Override public void onResourceReady(File resource, Transition<? super File> transition) { ImageSource source = ImageSource.uri(Uri.fromFile(resource)); mScaleImageView.setImage(source); } }); } }
Example #22
Source File: Glide4Engine.java From AndroidAnimationExercise with Apache License 2.0 | 5 votes |
@Override public void loadThumbnail(Context context, int resize, Drawable placeholder, ImageView imageView, Uri uri) { Glide.with(context) .asBitmap() // some .jpeg files are actually gif .load(uri) .apply(new RequestOptions() .override(resize, resize) .placeholder(placeholder) .centerCrop()) .into(imageView); }
Example #23
Source File: HomeFragment.java From ClassSchedule with Apache License 2.0 | 5 votes |
/** * 更新头像 */ @Override public void updateShowAvator(@NonNull String email) { if (!isActive()) { return; } String grAvatar = AppUtils.getGravatar(email); Glide.with(Objects.requireNonNull(getContext())) .load(grAvatar) .into(mCivAvator); }
Example #24
Source File: CategoriesAdapter.java From Loop with Apache License 2.0 | 5 votes |
private void setUpThumbnail(DynamicHeightImageView iv, Category category){ iv.setHeightRatio(1.0D/1.0D); String thumbnailUrl = category.getThumbnailUrl(); if(!TextUtils.isEmpty(thumbnailUrl)){ Glide.with(iv.getContext()) .load(thumbnailUrl) // .placeholder(R.drawable.ic_placeholder) // .error(R.drawable.ic_error) .into(iv); } }
Example #25
Source File: PIPActivity.java From DKVideoPlayer with Apache License 2.0 | 5 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_pip); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setTitle(R.string.str_pip_demo); actionBar.setDisplayHomeAsUpEnabled(true); } FrameLayout playerContainer = findViewById(R.id.player_container); mPIPManager = PIPManager.getInstance(); VideoView videoView = getVideoViewManager().get(Tag.PIP); StandardVideoController controller = new StandardVideoController(this); controller.addDefaultControlComponent(getString(R.string.str_pip), false); videoView.setVideoController(controller); if (mPIPManager.isStartFloatWindow()) { mPIPManager.stopFloatWindow(); controller.setPlayerState(videoView.getCurrentPlayerState()); controller.setPlayState(videoView.getCurrentPlayState()); } else { mPIPManager.setActClass(PIPActivity.class); ImageView thumb = controller.findViewById(R.id.thumb); Glide.with(this) .load("http://sh.people.com.cn/NMediaFile/2016/0112/LOCAL201601121344000138197365721.jpg") .placeholder(android.R.color.darker_gray) .into(thumb); videoView.setUrl(DataUtil.SAMPLE_URL); } playerContainer.addView(videoView); }
Example #26
Source File: GankListActivity.java From Gank-Veaer with GNU General Public License v3.0 | 5 votes |
public void bindViews(VFeed vFeed) { this.vFeed = vFeed; vDate = new VDate(vFeed.publishedAt); yearTv.append(vDate.YEAR + ""); monthTv.setText(vDate.getMonth()); dayTv.append(vDate.DAY + ""); descTv.setText(vFeed.desc); Glide.with(mActivity) .load(vFeed.url) .centerCrop() .into(pictureIV); }
Example #27
Source File: BenihImageView.java From CodePolitan with Apache License 2.0 | 5 votes |
public void setImageUrl(String url, int placeHolderDrawable, Drawable errorDrawable) { imageUrl = url; Glide.with(getContext()) .load(url) .placeholder(placeHolderDrawable) .error(errorDrawable) .into(this); }
Example #28
Source File: MusicAdapter.java From PlayWidget with MIT License | 5 votes |
@Override public void onBindViewHolder(MusicViewHolder holder, int position) { MusicItem item = getItem(position); holder.title.setText(getFilter().highlightFilteredSubstring(item.title())); holder.artist.setText(getFilter().highlightFilteredSubstring(item.artist())); holder.album.setText(getFilter().highlightFilteredSubstring(item.album())); holder.duration.setText(convertDuration(item.duration())); Glide.with(getContext()) .load(item.albumArtUri()) .asBitmap() .diskCacheStrategy(DiskCacheStrategy.ALL) .placeholder(R.drawable.ic_white_centered_bordered_song_note) .error(R.drawable.ic_white_centered_bordered_song_note) .into(holder.albumCover); }
Example #29
Source File: RequestFriendLocationDialogActivity.java From Social with Apache License 2.0 | 5 votes |
private void initView(){ tv_nickname = (TextView)this.findViewById(R.id.id_request_friend_location_dialog_activity_tv_nickname); tv_reason = (TextView)this.findViewById(R.id.id_request_friend_location_dialog_activity_tv_reason); tv_nickname.setText(SharedPreferenceUtil.getUserNickname(username)); btn_accept = (ButtonRectangle)this.findViewById(R.id.id_request_friend_location_dialog_activity_btn_accept); btn_reject = (ButtonRectangle)this.findViewById(R.id.id_request_friend_location_dialog_activity_btn_reject); btn_accept.setOnClickListener(this); btn_reject.setOnClickListener(this); iv_head = (ImageView)this.findViewById(R.id.id_request_friend_location_dialog_activity_iv_head); Glide.with(this).load( SharedPreferenceUtil.getUserHeadPath(username)).into(iv_head); iv_head.setOnClickListener(this); }
Example #30
Source File: GlideUtil.java From Android-IM with Apache License 2.0 | 5 votes |
/** * 加载圆角封面,默认4dp */ public static void loadCornerPicture(Context context, String imgUrl, ImageView imageView) { Glide.with(context) .load(imgUrl) .apply(new RequestOptions().error(R.drawable.icon_user)) .apply(RequestOptions.bitmapTransform(new MultiTransformation<Bitmap>(new CenterCrop(), new RoundedCornersTransformation(ConvertUtils.dp2px(4), 0)))) .into(imageView); }