类com.bumptech.glide.request.target.GlideDrawableImageViewTarget源码实例Demo

下面列出了怎么用com.bumptech.glide.request.target.GlideDrawableImageViewTarget的API类实例代码及写法,或者点击链接到github查看源代码。

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);
                        }
                    })
            ;
        }
 
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);
                }
            })
    ;
}
 
源代码3 项目: YiZhi   文件: ImageBrowseActivity.java
/**
 * 加载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);
                }
            });
}
 
源代码4 项目: AndroidModulePattern   文件: ImageUtils.java
/**
 * 显示加载进度
 *
 * @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);
        }
    });
}
 
源代码5 项目: tribbble   文件: ArchiveItemView.java
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() {}
      });
}
 
源代码6 项目: Anecdote   文件: ImageViewHolder.java
/**
 * 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;
        }
    });
}
 
源代码7 项目: glide-support   文件: DetailFragment.java
@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);
				}
			});
}
 
源代码8 项目: glide-support   文件: ListFragment.java
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);
				}
			});
}
 
源代码9 项目: glide-support   文件: TestFragment_Single.java
@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)))
	;
}
 
源代码10 项目: Silence   文件: ZoomingImageView.java
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();
         }
       });
}
 
源代码11 项目: androidtestdebug   文件: AddNoteFragment.java
@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.
                }
            });
}
 
源代码12 项目: androidtestdebug   文件: NoteDetailFragment.java
@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.
                }
            });
}
 
源代码13 项目: androidtestdebug   文件: AddNoteFragment.java
@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.
                }
            });
}
 
源代码14 项目: androidtestdebug   文件: NoteDetailFragment.java
@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.
                }
            });
}
 
源代码15 项目: YiZhi   文件: ImageBrowseActivity.java
/**
 * 加载静态图片
 */
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);
                }
            });
}
 
源代码16 项目: tenor-android-core   文件: GlideLoader.java
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);
                }
            });
}
 
源代码17 项目: glide-support   文件: TestFragment_List.java
@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)))
			;
		}
	});
}
 
源代码18 项目: glide-support   文件: TestFragment.java
@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);
				}
			});
}
 
源代码19 项目: glide-support   文件: TestFragment.java
@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)))
	;
}
 
源代码20 项目: glide-support   文件: TestFragment.java
@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)))
	;
}
 
源代码21 项目: glide-support   文件: QuickFragment.java
@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)))
	;
}
 
源代码22 项目: glide-support   文件: TestFragment_Pre380.java
@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));
				}
			});
}
 
源代码23 项目: FileManager   文件: PictureDetailFragment.java
@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();
                }
            });
}
 
 类所在包
 类方法
 同包方法