com.bumptech.glide.request.target.ImageViewTarget Java Examples
The following examples show how to use
com.bumptech.glide.request.target.ImageViewTarget.
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: ImageAdapter.java From MeiZiNews with MIT License | 6 votes |
@Override protected void convert(final BaseAdapterHelper helper, T item, int position) { final RadioImageView story_img = (RadioImageView) helper.getView(R.id.story_img); TextView story_title = helper.getTextView(R.id.story_item_title); story_title.setText(item.getStory_title()); Glide.with(helper.itemView.getContext()) .load(item.getImgUrl()) // //设置占位图或者加载错误图: // .placeholder(R.drawable.ic_sun_smile) // .error(R.drawable.ic_cloud_sad) .diskCacheStrategy(DiskCacheStrategy.ALL) .into(new ImageViewTarget<GlideDrawable>(story_img) { @Override protected void setResource(GlideDrawable resource) { story_img.setOriginalSize(resource.getIntrinsicWidth(), resource.getIntrinsicHeight()); story_img.setImageDrawable(resource); } }); helper.itemView.setTag(position); }
Example #2
Source File: VerFullLiveUI.java From likequanmintv with Apache License 2.0 | 6 votes |
private void initData() { if (mPlayBean!=null){ livePlayerPresenterImpl.enterRoom(mPlayBean.uid); } Glide.with(this) .load(mPlayBean.love_cover) .into(new ImageViewTarget<GlideDrawable>(bgImg) { @Override protected void setResource(GlideDrawable resource) { bgImg.setImageDrawable(resource); Blurry.with(VerFullLiveUI.this) .animate() .radius(10) .sampling(8) .capture(bgImg) .into(bgImg); } }); }
Example #3
Source File: PersonFragment.java From Melophile with Apache License 2.0 | 6 votes |
@Override public void showAvatar(String avatarUrl) { this.avatarUrl = avatarUrl; Glide.with(getContext()) .load(avatarUrl) .asBitmap() .priority(Priority.IMMEDIATE) .into(new ImageViewTarget<Bitmap>(avatar) { @Override protected void setResource(Bitmap resource) { avatar.setImageBitmap(resource); avatar.post(() -> { media.post(() -> { View blank = adapter.getBlank(); ViewGroup.LayoutParams params = blank.getLayoutParams(); params.height = followers.getTop() + followers.getHeight() + 2 * getResources().getDimensionPixelOffset(R.dimen.spacing_large); blank.setLayoutParams(params); }); media.setVisibility(View.INVISIBLE); getActivity().supportStartPostponedEnterTransition(); presenter.start(id); }); } }); }
Example #4
Source File: AlbumAdapter.java From Melophile with Apache License 2.0 | 6 votes |
@Override public View instantiateItem(ViewGroup container, int position) { View view = inflater.inflate(R.layout.adapter_album, container, false); ImageView image = ButterKnife.findById(view, R.id.image); Glide.with(container.getContext()) .load(albums.get(position).getArtworkUrl()) .asBitmap() .priority(Priority.IMMEDIATE) .diskCacheStrategy(DiskCacheStrategy.RESULT) .into(new ImageViewTarget<Bitmap>(image) { @Override protected void setResource(Bitmap resource) { image.setImageBitmap(resource); if (position == current && !isLoaded) { isLoaded = true; if (callback != null) { callback.onTransitionImageLoaded(image, resource); } } } }); container.addView(view); return view; }
Example #5
Source File: TrackFragment.java From Melophile with Apache License 2.0 | 6 votes |
public void showArt(String artUrl) { if (!TextUtils.equals(lastArtUrl, artUrl)) { lastArtUrl = artUrl; Glide.with(getContext()) .load(artUrl) .asBitmap() .priority(Priority.IMMEDIATE) .into(new ImageViewTarget<Bitmap>(smallImage) { @Override protected void setResource(Bitmap resource) { smallImage.setImageBitmap(resource); smallImage.post(() -> { Blurry.with(getContext()) .async(bitmap -> { background.setImageDrawable(bitmap); getActivity().supportStartPostponedEnterTransition(); }) .from(resource) .into(background); }); } }); } }
Example #6
Source File: PlaylistFragment.java From Melophile with Apache License 2.0 | 6 votes |
@Override public void showPlaylistArt(String artUrl) { if (!loaded) { loaded = true; Glide.with(getContext()) .load(artUrl) .asBitmap() .priority(Priority.IMMEDIATE) .into(new ImageViewTarget<Bitmap>(playlistArt) { @Override protected void setResource(Bitmap resource) { final int imageHeight = playlistArt.getHeight(); playlistArt.setImageBitmap(resource); parent.setStaticOffset(imageHeight); parent.setOffset(imageHeight); toggle.setStaticOffset(imageHeight - toggle.getHeight() / 2); toggle.setOffset(imageHeight - toggle.getHeight() / 2); toggle.setMinOffset(ViewCompat.getMinimumHeight(playlistArt) - toggle.getHeight() / 2); tracks.addOnScrollListener(listener); tracks.setOnFlingListener(flingListener); new Palette.Builder(resource).generate(PlaylistFragment.this::applyPalette); getActivity().supportStartPostponedEnterTransition(); } }); } }
Example #7
Source File: GlideImageLoader.java From GalleryFinal with Apache License 2.0 | 5 votes |
@Override public void displayImage(Activity activity, String path, final GFImageView imageView, Drawable defaultDrawable, int width, int height) { Glide.with(activity) .load("file://" + path) .placeholder(defaultDrawable) .error(defaultDrawable) .override(width, height) .diskCacheStrategy(DiskCacheStrategy.NONE) //不缓存到SD卡 .skipMemoryCache(true) //.centerCrop() .into(new ImageViewTarget<GlideDrawable>(imageView) { @Override protected void setResource(GlideDrawable resource) { imageView.setImageDrawable(resource); } @Override public void setRequest(Request request) { imageView.setTag(R.id.adapter_item_tag_key,request); } @Override public Request getRequest() { return (Request) imageView.getTag(R.id.adapter_item_tag_key); } }); }
Example #8
Source File: SvgSoftwareLayerSetter.java From PowerFileExplorer with GNU General Public License v3.0 | 5 votes |
@Override public boolean onException(Exception e, T model, Target<PictureDrawable> target, boolean isFirstResource) { ImageView view = ((ImageViewTarget<?>) target).getView(); if (Build.VERSION_CODES.HONEYCOMB <= Build.VERSION.SDK_INT) { view.setLayerType(ImageView.LAYER_TYPE_NONE, null); } return false; }
Example #9
Source File: SvgSoftwareLayerSetter.java From incubator-taverna-mobile with Apache License 2.0 | 5 votes |
@Override public boolean onResourceReady(PictureDrawable resource, T model , Target<PictureDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) { ImageView view = ((ImageViewTarget<?>) target).getView(); if (Build.VERSION_CODES.HONEYCOMB <= Build.VERSION.SDK_INT) { view.setLayerType(ImageView.LAYER_TYPE_SOFTWARE, null); } return false; }
Example #10
Source File: SvgSoftwareLayerSetter.java From incubator-taverna-mobile with Apache License 2.0 | 5 votes |
@Override public boolean onException(Exception e, T model, Target<PictureDrawable> target, boolean isFirstResource) { ImageView view = ((ImageViewTarget<?>) target).getView(); if (Build.VERSION_CODES.HONEYCOMB <= Build.VERSION.SDK_INT) { view.setLayerType(ImageView.LAYER_TYPE_NONE, null); } return false; }
Example #11
Source File: LoyalUtil.java From LoyalNativeSlider with MIT License | 5 votes |
public static void hybridImplementation(String u, final ImageView target, Context context, final Runnable callback) { if (u.contains(".gif")) { Glide.with(context).asGif().load(u) .apply(getOpt()) .into(new ImageViewTarget<GifDrawable>(target) { @Override protected void setResource(GifDrawable resource) { target.setImageDrawable(resource); callback.run(); } }); } else { picassoImplementation(u, target, context, callback); } }
Example #12
Source File: XmTvClassificationAdapter.java From MeiZiNews with MIT License | 5 votes |
@Override protected void convert(BaseAdapterHelper helper, final Items item, int position) { final RadioImageView story_img = (RadioImageView) helper.getView(R.id.story_img); TextView story_title = helper.getTextView(R.id.story_item_title); story_title.setText(item.getName()); Glide.with(helper.itemView.getContext()) .load(item.getPictures().getImg()) .diskCacheStrategy(DiskCacheStrategy.ALL) .into(new ImageViewTarget<GlideDrawable>(story_img) { @Override protected void setResource(GlideDrawable resource) { story_img.setOriginalSize(resource.getIntrinsicWidth(), resource.getIntrinsicHeight()); story_img.setImageDrawable(resource); } }); helper.itemView.setTag(position); helper.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.putExtra("title", item.getName()); intent.setClass(context, M3u8VideoActivity.class); intent.putExtra("type", VideoApi.TYPE_XM); intent.putExtra("roomid", item.getId()); context.startActivity(intent); } }); }
Example #13
Source File: GlideEngine.java From PictureSelector with Apache License 2.0 | 5 votes |
/** * 加载网络图片适配长图方案 * # 注意:此方法只有加载网络图片才会回调 * * @param context * @param url * @param imageView * @param longImageView * @ 已废弃 */ @Override public void loadImage(@NonNull Context context, @NonNull String url, @NonNull ImageView imageView, SubsamplingScaleImageView longImageView) { Glide.with(context) .asBitmap() .load(url) .into(new ImageViewTarget<Bitmap>(imageView) { @Override protected void setResource(@Nullable Bitmap resource) { if (resource != null) { boolean eqLongImage = MediaUtils.isLongImg(resource.getWidth(), resource.getHeight()); longImageView.setVisibility(eqLongImage ? View.VISIBLE : View.GONE); imageView.setVisibility(eqLongImage ? View.GONE : View.VISIBLE); if (eqLongImage) { // 加载长图 longImageView.setQuickScaleEnabled(true); longImageView.setZoomEnabled(true); longImageView.setPanEnabled(true); longImageView.setDoubleTapZoomDuration(100); longImageView.setMinimumScaleType(SubsamplingScaleImageView.SCALE_TYPE_CENTER_CROP); longImageView.setDoubleTapZoomDpi(SubsamplingScaleImageView.ZOOM_FOCUS_CENTER); longImageView.setImage(ImageSource.bitmap(resource), new ImageViewState(0, new PointF(0, 0), 0)); } else { // 普通图片 imageView.setImageBitmap(resource); } } } }); }
Example #14
Source File: GlideEngine.java From react-native-syan-image-picker with MIT License | 5 votes |
/** * 加载网络图片适配长图方案 * # 注意:此方法只有加载网络图片才会回调 * * @param context * @param url * @param imageView * @param longImageView * @ 已废弃 */ @Override public void loadImage(@NonNull Context context, @NonNull String url, @NonNull ImageView imageView, SubsamplingScaleImageView longImageView) { Glide.with(context) .asBitmap() .load(url) .into(new ImageViewTarget<Bitmap>(imageView) { @Override protected void setResource(@Nullable Bitmap resource) { if (resource != null) { boolean eqLongImage = MediaUtils.isLongImg(resource.getWidth(), resource.getHeight()); longImageView.setVisibility(eqLongImage ? View.VISIBLE : View.GONE); imageView.setVisibility(eqLongImage ? View.GONE : View.VISIBLE); if (eqLongImage) { // 加载长图 longImageView.setQuickScaleEnabled(true); longImageView.setZoomEnabled(true); longImageView.setPanEnabled(true); longImageView.setDoubleTapZoomDuration(100); longImageView.setMinimumScaleType(SubsamplingScaleImageView.SCALE_TYPE_CENTER_CROP); longImageView.setDoubleTapZoomDpi(SubsamplingScaleImageView.ZOOM_FOCUS_CENTER); longImageView.setImage(ImageSource.bitmap(resource), new ImageViewState(0, new PointF(0, 0), 0)); } else { // 普通图片 imageView.setImageBitmap(resource); } } } }); }
Example #15
Source File: SvgSoftwareLayerSetter.java From GlideToVectorYou with Apache License 2.0 | 5 votes |
@Override public boolean onResourceReady(PictureDrawable resource, Object model, Target<PictureDrawable> target, DataSource dataSource, boolean isFirstResource) { ImageView view = ((ImageViewTarget<?>) target).getView(); view.setLayerType(ImageView.LAYER_TYPE_SOFTWARE, null); if (customListener != null) { customListener.onResourceReady(); } return false; }
Example #16
Source File: SvgSoftwareLayerSetter.java From GlideToVectorYou with Apache License 2.0 | 5 votes |
@Override public boolean onLoadFailed(GlideException e, Object model, Target<PictureDrawable> target, boolean isFirstResource) { ImageView view = ((ImageViewTarget<?>) target).getView(); view.setLayerType(ImageView.LAYER_TYPE_NONE, null); if (customListener != null) { customListener.onLoadFailed(); } return false; }
Example #17
Source File: SvgSoftwareLayerSetter.java From PowerFileExplorer with GNU General Public License v3.0 | 5 votes |
@Override public boolean onResourceReady(PictureDrawable resource, T model, Target<PictureDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) { ImageView view = ((ImageViewTarget<?>) target).getView(); if (Build.VERSION_CODES.HONEYCOMB <= Build.VERSION.SDK_INT) { view.setLayerType(ImageView.LAYER_TYPE_SOFTWARE, null); } return false; }
Example #18
Source File: LoginActivity.java From android-login with MIT License | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); ButterKnife.bind(this); final AnimatedViewPager pager = ButterKnife.findById(this, R.id.pager); final ImageView background = ButterKnife.findById(this, R.id.scrolling_background); int[] screenSize = screenSize(); for (ImageView element : sharedElements) { @ColorRes int color = element.getId() != R.id.logo ? R.color.white_transparent : R.color.color_logo_log_in; DrawableCompat.setTint(element.getDrawable(), ContextCompat.getColor(this, color)); } //load a very big image and resize it, so it fits our needs Glide.with(this) .load(R.drawable.busy) .asBitmap() .override(screenSize[0] * 2, screenSize[1]) .diskCacheStrategy(DiskCacheStrategy.RESULT) .into(new ImageViewTarget<Bitmap>(background) { @Override protected void setResource(Bitmap resource) { background.setImageBitmap(resource); background.post(() -> { //we need to scroll to the very left edge of the image //fire the scale animation background.scrollTo(-background.getWidth() / 2, 0); ObjectAnimator xAnimator = ObjectAnimator.ofFloat(background, View.SCALE_X, 4f, background.getScaleX()); ObjectAnimator yAnimator = ObjectAnimator.ofFloat(background, View.SCALE_Y, 4f, background.getScaleY()); AnimatorSet set = new AnimatorSet(); set.playTogether(xAnimator, yAnimator); set.setDuration(getResources().getInteger(R.integer.duration)); set.start(); }); pager.post(() -> { AuthAdapter adapter = new AuthAdapter(getSupportFragmentManager(), pager, background, sharedElements); pager.setAdapter(adapter); }); } }); }
Example #19
Source File: GlideEngine.java From PictureSelector with Apache License 2.0 | 4 votes |
/** * 加载网络图片适配长图方案 * # 注意:此方法只有加载网络图片才会回调 * * @param context * @param url * @param imageView * @param longImageView * @param callback 网络图片加载回调监听 {link after version 2.5.1 Please use the #OnImageCompleteCallback#} */ @Override public void loadImage(@NonNull Context context, @NonNull String url, @NonNull ImageView imageView, SubsamplingScaleImageView longImageView, OnImageCompleteCallback callback) { Glide.with(context) .asBitmap() .load(url) .into(new ImageViewTarget<Bitmap>(imageView) { @Override public void onLoadStarted(@Nullable Drawable placeholder) { super.onLoadStarted(placeholder); if (callback != null) { callback.onShowLoading(); } } @Override public void onLoadFailed(@Nullable Drawable errorDrawable) { super.onLoadFailed(errorDrawable); if (callback != null) { callback.onHideLoading(); } } @Override protected void setResource(@Nullable Bitmap resource) { if (callback != null) { callback.onHideLoading(); } if (resource != null) { boolean eqLongImage = MediaUtils.isLongImg(resource.getWidth(), resource.getHeight()); longImageView.setVisibility(eqLongImage ? View.VISIBLE : View.GONE); imageView.setVisibility(eqLongImage ? View.GONE : View.VISIBLE); if (eqLongImage) { // 加载长图 longImageView.setQuickScaleEnabled(true); longImageView.setZoomEnabled(true); longImageView.setPanEnabled(true); longImageView.setDoubleTapZoomDuration(100); longImageView.setMinimumScaleType(SubsamplingScaleImageView.SCALE_TYPE_CENTER_CROP); longImageView.setDoubleTapZoomDpi(SubsamplingScaleImageView.ZOOM_FOCUS_CENTER); longImageView.setImage(ImageSource.bitmap(resource), new ImageViewState(0, new PointF(0, 0), 0)); } else { // 普通图片 imageView.setImageBitmap(resource); } } } }); }
Example #20
Source File: GlideEngine.java From react-native-syan-image-picker with MIT License | 4 votes |
/** * 加载网络图片适配长图方案 * # 注意:此方法只有加载网络图片才会回调 * * @param context * @param url * @param imageView * @param longImageView * @param callback 网络图片加载回调监听 {link after version 2.5.1 Please use the #OnImageCompleteCallback#} */ @Override public void loadImage(@NonNull Context context, @NonNull String url, @NonNull ImageView imageView, SubsamplingScaleImageView longImageView, OnImageCompleteCallback callback) { Glide.with(context) .asBitmap() .load(url) .into(new ImageViewTarget<Bitmap>(imageView) { @Override public void onLoadStarted(@Nullable Drawable placeholder) { super.onLoadStarted(placeholder); if (callback != null) { callback.onShowLoading(); } } @Override public void onLoadFailed(@Nullable Drawable errorDrawable) { super.onLoadFailed(errorDrawable); if (callback != null) { callback.onHideLoading(); } } @Override protected void setResource(@Nullable Bitmap resource) { if (callback != null) { callback.onHideLoading(); } if (resource != null) { boolean eqLongImage = MediaUtils.isLongImg(resource.getWidth(), resource.getHeight()); longImageView.setVisibility(eqLongImage ? View.VISIBLE : View.GONE); imageView.setVisibility(eqLongImage ? View.GONE : View.VISIBLE); if (eqLongImage) { // 加载长图 longImageView.setQuickScaleEnabled(true); longImageView.setZoomEnabled(true); longImageView.setPanEnabled(true); longImageView.setDoubleTapZoomDuration(100); longImageView.setMinimumScaleType(SubsamplingScaleImageView.SCALE_TYPE_CENTER_CROP); longImageView.setDoubleTapZoomDpi(SubsamplingScaleImageView.ZOOM_FOCUS_CENTER); longImageView.setImage(ImageSource.bitmap(resource), new ImageViewState(0, new PointF(0, 0), 0)); } else { // 普通图片 imageView.setImageBitmap(resource); } } } }); }