com.bumptech.glide.request.target.GlideDrawableImageViewTarget Java Examples

The following examples show how to use com.bumptech.glide.request.target.GlideDrawableImageViewTarget. 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: receiverpictureactivity.java    From Secure-Photo-Viewer with MIT License 6 votes vote down vote up
private void pictureSetFile(final TouchImageView imageset, Uri urinormal) {
    imageset.setMaxZoom(30);

    Glide.with(this)
            .load(urinormal)
            .override(2000, 2000)
            //.override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
            .into(new GlideDrawableImageViewTarget(imageset) {
                @Override
                public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> animation) {
                    super.onResourceReady(resource, animation);
                    imageset.setZoom(1);
                }
            })
    ;
}
 
Example #2
Source File: NoteDetailFragment.java    From androidtestdebug with MIT License 6 votes vote down vote up
@Override
public void showImage(String imageUrl) {
    // The image is loaded in a different thread so in order to UI-test this, an idling resource
    // is used to specify when the app is idle.
    EspressoIdlingResource.increment(); // App is busy until further notice.

    mDetailImage.setVisibility(View.VISIBLE);

    // This app uses Glide for image loading
    Glide.with(this)
            .load(imageUrl)
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .centerCrop()
            .into(new GlideDrawableImageViewTarget(mDetailImage) {
                @Override
                public void onResourceReady(GlideDrawable resource,
                                            GlideAnimation<? super GlideDrawable> animation) {
                    super.onResourceReady(resource, animation);
                    EspressoIdlingResource.decrement(); // App is idle.
                }
            });
}
 
Example #3
Source File: AddNoteFragment.java    From androidtestdebug with MIT License 6 votes vote down vote up
@Override
public void showImagePreview(@NonNull String imageUrl) {
    checkState(!TextUtils.isEmpty(imageUrl), "imageUrl cannot be null or empty!");
    mImageThumbnail.setVisibility(View.VISIBLE);

    // The image is loaded in a different thread so in order to UI-test this, an idling resource
    // is used to specify when the app is idle.
    EspressoIdlingResource.increment(); // App is busy until further notice.

    // This app uses Glide for image loading
    Glide.with(this)
            .load(imageUrl)
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .centerCrop()
            .into(new GlideDrawableImageViewTarget(mImageThumbnail) {
                @Override
                public void onResourceReady(GlideDrawable resource,
                                            GlideAnimation<? super GlideDrawable> animation) {
                    super.onResourceReady(resource, animation);
                    EspressoIdlingResource.decrement(); // Set app as idle.
                }
            });
}
 
Example #4
Source File: NoteDetailFragment.java    From androidtestdebug with MIT License 6 votes vote down vote up
@Override
public void showImage(String imageUrl) {
    // The image is loaded in a different thread so in order to UI-test this, an idling resource
    // is used to specify when the app is idle.
    EspressoIdlingResource.increment(); // App is busy until further notice.

    mDetailImage.setVisibility(View.VISIBLE);

    // This app uses Glide for image loading
    Glide.with(this)
            .load(imageUrl)
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .centerCrop()
            .into(new GlideDrawableImageViewTarget(mDetailImage) {
                @Override
                public void onResourceReady(GlideDrawable resource,
                                            GlideAnimation<? super GlideDrawable> animation) {
                    super.onResourceReady(resource, animation);
                    EspressoIdlingResource.decrement(); // App is idle.
                }
            });
}
 
Example #5
Source File: AddNoteFragment.java    From androidtestdebug with MIT License 6 votes vote down vote up
@Override
public void showImagePreview(@NonNull String imageUrl) {
    checkState(!TextUtils.isEmpty(imageUrl), "imageUrl cannot be null or empty!");
    mImageThumbnail.setVisibility(View.VISIBLE);

    // The image is loaded in a different thread so in order to UI-test this, an idling resource
    // is used to specify when the app is idle.
    EspressoIdlingResource.increment(); // App is busy until further notice.

    // This app uses Glide for image loading
    Glide.with(this)
            .load(imageUrl)
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .centerCrop()
            .into(new GlideDrawableImageViewTarget(mImageThumbnail) {
                @Override
                public void onResourceReady(GlideDrawable resource,
                                            GlideAnimation<? super GlideDrawable> animation) {
                    super.onResourceReady(resource, animation);
                    EspressoIdlingResource.decrement(); // Set app as idle.
                }
            });
}
 
Example #6
Source File: ZoomingImageView.java    From Silence with GNU General Public License v3.0 6 votes vote down vote up
private void setImageViewUri(MasterSecret masterSecret, Uri uri) {
  subsamplingImageView.setVisibility(View.GONE);
  imageView.setVisibility(View.VISIBLE);

  Glide.with(getContext())
       .load(new DecryptableUri(masterSecret, uri))
       .diskCacheStrategy(DiskCacheStrategy.NONE)
       .dontTransform()
       .dontAnimate()
       .into(new GlideDrawableImageViewTarget(imageView) {
         @Override protected void setResource(GlideDrawable resource) {
           super.setResource(resource);
           imageViewAttacher.update();
         }
       });
}
 
Example #7
Source File: TestFragment_Single.java    From glide-support with The Unlicense 6 votes vote down vote up
@Override protected void load(final Context context) throws Exception {
	String url = "http://www.kizoa.com/img/e8nZC.gif";
	Drawable drawable = ContextCompat.getDrawable(getContext(), R.drawable.github_1261_nine_to_five);
	if (drawable instanceof Animatable) {
		((Animatable)drawable).stop();
		((Animatable)drawable).start();
	}
	Glide
			.with(this)
			.load(url)
			.placeholder(drawable)
			.crossFade(3000)
			.skipMemoryCache(true) // make sure the image is reloaded so the placeholder has a chance
			.diskCacheStrategy(DiskCacheStrategy.SOURCE)
			.bitmapTransform(DelayTransformation.<Bitmap>create(2000)) // debug lengthen decode to see placeholder
			.listener(new LoggingListener<String, GlideDrawable>())
			.into(new LoggingTarget<>(new GlideDrawableImageViewTarget(imageView)))
	;
}
 
Example #8
Source File: ListFragment.java    From glide-support with The Unlicense 6 votes vote down vote up
private void bind(final ListItem model) {
	bound = model;
	Glide
			.with(itemView.getContext())
			.load(model.getLowUrl())
			.diskCacheStrategy(DiskCacheStrategy.SOURCE)
			.listener(new LoggingListener<String, GlideDrawable>())
			.into(new GlideDrawableImageViewTarget(image) {
				@Override public void onLoadFailed(Exception e, Drawable errorDrawable) {
					Glide
							.with(itemView.getContext())
							.load(model.getThumbUrl())
							.error(R.drawable.glide_error)
							.listener(new LoggingListener<String, GlideDrawable>())
							.into(image);
				}
			});
}
 
Example #9
Source File: DetailFragment.java    From glide-support with The Unlicense 6 votes vote down vote up
@Override public void onActivityCreated(@Nullable Bundle savedInstanceState) {
	super.onActivityCreated(savedInstanceState);
	final ListItem model = (ListItem)getArguments().getSerializable("model");
	Glide
			.with(this)
			.using(new NetworkDisablingLoader<String>()) // TODO disables network for debug
			.load(model.getStandardUrl())
			.listener(new LoggingListener<String, GlideDrawable>())
			.into(new GlideDrawableImageViewTarget(imageView) {
				@Override public void onLoadFailed(Exception e, Drawable errorDrawable) {
					Glide
							.with(DetailFragment.this)
							.using(new NetworkDisablingLoader<String>()) // TODO disables network for debug
							.load(model.getLowUrl())
							.diskCacheStrategy(DiskCacheStrategy.SOURCE)
							.error(R.drawable.glide_error)
							.listener(new LoggingListener<String, GlideDrawable>())
							.into(imageView);
				}
			});
}
 
Example #10
Source File: ImageViewHolder.java    From Anecdote with Apache License 2.0 6 votes vote down vote up
/**
 * Load the image in the view
 */
private void loadImage(){
    if(TextUtils.isEmpty(mImageUrl)){
        return;
    }

    GlideDrawableImageViewTarget imageViewTarget = new GlideDrawableImageViewTarget(mImageView);

    Glide.with(mImageView.getContext())
            .load(mImageUrl)
            .listener(this)
            .error(R.drawable.ic_error_white_24dp)
            .into(imageViewTarget);

    mImageView.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View view) {
            MediaContextDialog.openDialog(mImageView.getContext(), mWebsiteName, mCurrentAnecdote, mImageUrl, mImageView);
            return true;
        }
    });
}
 
Example #11
Source File: ArchiveItemView.java    From tribbble with Apache License 2.0 6 votes vote down vote up
public void bind(Shot shot, @DrawableRes int placeholderId) {
  mGifLabel.setVisibility(shot.isAnimated() ? VISIBLE : INVISIBLE);
  Glide.with(getContext())
      .load(shot.getImages().getHighResImage())
      .placeholder(placeholderId)
      .diskCacheStrategy(DiskCacheStrategy.SOURCE)
      .into(new GlideDrawableImageViewTarget(mShotImageView) {
        @Override public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> animation) {
          super.onResourceReady(resource, animation);
          resource.stop();
        }

        @Override public void onStart() {}

        @Override public void onStop() {}
      });
}
 
Example #12
Source File: ImageUtils.java    From AndroidModulePattern with Apache License 2.0 6 votes vote down vote up
/**
 * 显示加载进度
 *
 * @param path       图片地址
 * @param mImageView 图片控件
 * @param loadView   加载view
 */
public static void loadImageWithProgress(String path, final ImageView mImageView, final View loadView, int errorRes) {
    Glide.with(mImageView.getContext()).load(path).error(errorRes).into(new GlideDrawableImageViewTarget(mImageView) {
        @Override
        public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> animation) {
            super.onResourceReady(resource, animation);
            loadView.setVisibility(View.GONE);
        }

        @Override
        public void onLoadFailed(Exception e, Drawable errorDrawable) {
            super.onLoadFailed(e, errorDrawable);
            loadView.setVisibility(View.GONE);
        }
    });
}
 
Example #13
Source File: ImageBrowseActivity.java    From YiZhi with Apache License 2.0 6 votes vote down vote up
/**
 * 加载gif
 */
private void loadGif() {
    Glide.with(ImageBrowseActivity.this)
            .load(mImageUrl)
            .fitCenter()
            .diskCacheStrategy(DiskCacheStrategy.SOURCE)
            .into(new GlideDrawableImageViewTarget(pvPic) {
                @Override
                public void onResourceReady(GlideDrawable resource, GlideAnimation<?
                        super GlideDrawable> animation) {
                    super.onResourceReady(resource, animation);
                    //在这里添加一些图片加载完成的操作
                    pbPicBrowse.setVisibility(View.GONE);
                }
            });
}
 
Example #14
Source File: receiverpictureactivity.java    From Secure-Photo-Viewer with MIT License 6 votes vote down vote up
private void pictureSet(final TouchImageView imageset, Uri urinormal) {

            imageset.setMaxZoom(30);

            Glide.with(this)
                    .load(urinormal)
                    .override(2000, 2000)
                    //.override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
                    .into(new GlideDrawableImageViewTarget(imageset) {
                        @Override
                        public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> animation) {
                            super.onResourceReady(resource, animation);
                            imageset.setZoom(1);
                        }
                    })
            ;
        }
 
Example #15
Source File: TestFragment_List.java    From glide-support with The Unlicense 5 votes vote down vote up
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
	super.onViewCreated(view, savedInstanceState);
	listView.setLayoutManager(new GridLayoutManager(null, 2));
	String[] urls = new String[40];
	Arrays.fill(urls, "http://www.kizoa.com/img/e8nZC.gif");
	listView.setAdapter(new SimpleUrlAdapter(Glide.with(this), Arrays.asList(urls)) {
		@Override protected void load(Context context, RequestManager glide, String url, ImageView imageView)
				throws Exception {
			Drawable drawable = ContextCompat.getDrawable(getContext(), R.drawable.github_1261_nine_to_five);
			if (drawable instanceof Animatable) {
				((Animatable)drawable).stop(); // required in case the drawable was reused
				((Animatable)drawable).start(); // required to start the animation
			}
			glide
					.load(url)
					.placeholder(drawable)
					.crossFade(3000)
					.skipMemoryCache(true) // debug: make sure the image is reloaded so the placeholder has a chance
					.diskCacheStrategy(DiskCacheStrategy.SOURCE)
					// debug: lengthen loading to see placeholder
					.bitmapTransform(DelayTransformation.<Bitmap>create(2000))
					.listener(new LoggingListener<String, GlideDrawable>())
					.into(new LoggingTarget<>(new GlideDrawableImageViewTarget(imageView)))
			;
		}
	});
}
 
Example #16
Source File: TestFragment.java    From glide-support with The Unlicense 5 votes vote down vote up
@Override protected void load(Context context) throws Exception {
	String url =
			"https://capfor.files.wordpress.com/2012/07/beautiful-forest-beautiful-day-forests-grass-green-light-nature-sunshine-trees.jpg";
	imageView.setBackgroundColor(Color.RED);
	Glide
			.with(getContext())
			.load(url)
			.skipMemoryCache(true)
			.centerCrop()
			.thumbnail(Glide
					.with(getContext())
					.load(url)
					.skipMemoryCache(true)
					.centerCrop()
					.sizeMultiplier(.1f)
					.crossFade(0) // dontAnimate doesn't work here, see GRB.buildRequestRecursive
			)
			.placeholder(new ColorDrawable(Color.BLUE))
			.crossFade(5000)
			.into(new GlideDrawableImageViewTarget(imageView) {
				@Override public void setDrawable(Drawable drawable) {
					if (drawable instanceof TransitionDrawable) {
						//((TransitionDrawable)drawable).setCrossFadeEnabled(false);
					}
					super.setDrawable(drawable);
				}
			});
}
 
Example #17
Source File: TestFragment.java    From glide-support with The Unlicense 5 votes vote down vote up
@Override protected void load1(Context context, ImageView imageView) throws Exception {
	Glide
			.with(this)
			// default timeout is 2.5 seconds (com.bumptech.glide.load.data.HttpUrlFetcher)
			.load("https://httpbin.org/delay/12") // force a timeout: 2.5 < 12
			.signature(new StringSignature("load1")) // distinguish from other load to make sure loader is picked up
			.placeholder(R.drawable.glide_placeholder)
			.error(R.drawable.glide_error)
			.listener(new LoggingListener<String, GlideDrawable>("load1"))
			.into(new LoggingTarget<>("load1", Log.VERBOSE, new GlideDrawableImageViewTarget(imageView)))
	;
}
 
Example #18
Source File: TestFragment.java    From glide-support with The Unlicense 5 votes vote down vote up
@Override protected void load2(Context context, ImageView imageView) throws Exception {
	Glide
			.with(this)
			.using(new StreamModelLoaderWrapper<>(new OkHttpUrlLoader(longTimeoutClient)))
			.load(new GlideUrl("https://httpbin.org/delay/12")) // timeout increased: 15 > 10, so it'll pass
			.signature(new StringSignature("load2")) // distinguish from other load to make sure loader is picked up
			.placeholder(R.drawable.glide_placeholder)
			// since the test URL returns a JSON stream, the load will fail,
			// let's still add an error to see that the load fails slower than the other,
			// meaning the image was actually tried to be decoded
			.error(R.drawable.glide_error)
			.listener(new LoggingListener<GlideUrl, GlideDrawable>("load2"))
			.into(new LoggingTarget<>("load2", Log.VERBOSE, new GlideDrawableImageViewTarget(imageView)))
	;
}
 
Example #19
Source File: QuickFragment.java    From glide-support with The Unlicense 5 votes vote down vote up
@Override protected void load(final Context context) throws Exception {
	String url = "http://i.imgur.com/1ALnB2s.gif";
	Glide
			.with(this)
			.load(url)
			.placeholder(R.drawable.glide_placeholder)
			.animate(android.R.anim.fade_in)
			.error(R.drawable.glide_error)
			.fallback(R.drawable.glide_fallback)
			.diskCacheStrategy(DiskCacheStrategy.SOURCE)
			.skipMemoryCache(true)
			.listener(new LoggingListener<String, GlideDrawable>())
			.into(new LoggingTarget<>(new GlideDrawableImageViewTarget(imageView)))
	;
}
 
Example #20
Source File: TestFragment_Pre380.java    From glide-support with The Unlicense 5 votes vote down vote up
@Override protected void load(Context context) throws Exception {
	Glide
			.with(context)
			.load(R.drawable.glide)
			.diskCacheStrategy(DiskCacheStrategy.NONE)
			.fitCenter()
			.placeholder(R.drawable.glide_placeholder)
			.crossFade(2000)
			.into(new GlideDrawableImageViewTarget(imageView) {
				@Override public void onResourceReady(GlideDrawable resource,
						GlideAnimation<? super GlideDrawable> animation) {
					super.onResourceReady(resource, new PaddingAnimation<>(animation));
				}
			});
}
 
Example #21
Source File: PictureDetailFragment.java    From FileManager with Apache License 2.0 5 votes vote down vote up
@Override
protected void initViews(View self, Bundle savedInstanceState) {
    Glide.with(App.getAppContext())
            .load("file://" + mImageUrl)
            .fitCenter()
            //禁止磁盘缓存
            .diskCacheStrategy(DiskCacheStrategy.NONE)
            //禁止内存缓存
            //.skipMemoryCache( true )
            //.placeholder(R.drawable.image_loading)
            .error(R.drawable.image_load_failure)
            .into(new GlideDrawableImageViewTarget(image) {
                @Override
                public void onLoadStarted(Drawable placeholder) {
                    super.onLoadStarted(placeholder);
                    memoryProgressbar.show();
                }

                @Override
                public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> animation) {
                    super.onResourceReady(resource, animation);
                    memoryProgressbar.hide();
                }

                @Override
                public void onLoadFailed(Exception e, Drawable errorDrawable) {
                    super.onLoadFailed(e, errorDrawable);
                    memoryProgressbar.hide();
                }
            });
}
 
Example #22
Source File: GlideLoader.java    From tenor-android-core with Apache License 2.0 5 votes vote down vote up
public static <T extends ImageView> void load(@NonNull final GenericRequestBuilder requestBuilder,
                                              @NonNull final GlideTaskParams<T> payload) {

    if (payload.isThumbnail()) {
        requestBuilder.thumbnail(payload.getThumbnailMultiplier());
    }

    requestBuilder.placeholder(payload.getPlaceholder())
            .into(new GlideDrawableImageViewTarget(payload.getTarget()) {
                @Override
                public void onLoadFailed(Exception e, Drawable errorDrawable) {
                    if (payload.getCurrentRetry() < payload.getMaxRetry()) {
                        payload.incrementCurrentRetry();
                        load(requestBuilder, payload);
                    } else {
                        super.onLoadFailed(e, errorDrawable);
                        payload.getListener().failure(payload.getTarget(), errorDrawable);
                    }
                }

                @Override
                public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> animation) {
                    super.onResourceReady(resource, animation);
                    payload.getListener().success(payload.getTarget(), resource);
                }
            });
}
 
Example #23
Source File: ImageBrowseActivity.java    From YiZhi with Apache License 2.0 5 votes vote down vote up
/**
 * 加载静态图片
 */
private void loadImage() {
    Glide.with(ImageBrowseActivity.this)
            .load(mImageUrl)
            .fitCenter()
            .crossFade()
            .into(new GlideDrawableImageViewTarget(pvPic) {
                @Override
                public void onResourceReady(GlideDrawable drawable, GlideAnimation anim) {
                    super.onResourceReady(drawable, anim);
                    //在这里添加一些图片加载完成的操作
                    pbPicBrowse.setVisibility(View.GONE);
                }
            });
}