com.bumptech.glide.load.resource.drawable.GlideDrawable Java Examples
The following examples show how to use
com.bumptech.glide.load.resource.drawable.GlideDrawable.
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: MainFragment.java From BuildingForAndroidTV with MIT License | 6 votes |
protected void updateBackground(String uri) { int width = mMetrics.widthPixels; int height = mMetrics.heightPixels; Glide.with(getActivity()) .load(uri) .centerCrop() .error(mDefaultBackground) .into(new SimpleTarget<GlideDrawable>(width, height) { @Override public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) { mBackgroundManager.setDrawable(resource); } }); mBackgroundTimer.cancel(); }
Example #2
Source File: TestFragment.java From glide-support with The Unlicense | 6 votes |
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); listView.setAdapter(new SimpleUrlAdapter(Glide.with(this), Arrays.asList( // original url, already url-encoded URL_BASE + "s%C3%BCt%C3%A9s+1146.jpg", // parse url-encoded url and toString encodes it again Uri.parse(URL_BASE + "s%C3%BCt%C3%A9s+1146.jpg").toString(), // raw url, nothing is escaped "sütés" Uri.decode(URL_BASE + "s%C3%BCt%C3%A9s+1146.jpg"), // illegally decoded url, utf-8 is not parsed properly URL_BASE + "sĂĽtĂ©s+1146.jpg" )) { @Override protected void load(Context context, RequestManager glide, String url, ImageView imageView) { glide.load(url).listener(new LoggingListener<String, GlideDrawable>()).into(imageView); } }); }
Example #3
Source File: MyApplication.java From PocketEOS-Android with GNU Lesser General Public License v3.0 | 6 votes |
public void showCirImage(String url, final ImageView image) { if (url == null || url.isEmpty() || "".equals(url)) { image.setImageResource(R.mipmap.defeat_person_img); return; } Glide.with(getApplicationContext()) .load(url) .error(R.mipmap.ic_launcher_round) .into(new SimpleTarget<GlideDrawable>() { // 加上这段代码 可以解决 @Override public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) { image.setImageDrawable(resource); //显示图片 } }); }
Example #4
Source File: ImageBrowseActivity.java From YiZhi with Apache License 2.0 | 6 votes |
/** * 加载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 #5
Source File: ImageUtils.java From AndroidModulePattern with Apache License 2.0 | 6 votes |
/** * 显示加载进度 * * @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 #6
Source File: FullHintActivity.java From hintcase with Apache License 2.0 | 6 votes |
@NonNull private ImageView getGifLoadedUsingGlide() { ImageView animatedImageView = new ImageView(getActivity()); animatedImageView.setMaxHeight(900); Glide.with(getActivity()) .load(R.drawable.animated_image) .diskCacheStrategy(DiskCacheStrategy.SOURCE) .thumbnail(Glide.with(getActivity()) .load(R.drawable.animated_image) .asBitmap() .transcode(new BitmapToGlideDrawableTranscoder(getActivity()), GlideDrawable.class) .diskCacheStrategy(DiskCacheStrategy.ALL) ) .into(animatedImageView); return animatedImageView; }
Example #7
Source File: AddNoteFragment.java From androidtestdebug with MIT License | 6 votes |
@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 #8
Source File: TestFragment_Single.java From glide-support with The Unlicense | 6 votes |
@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 #9
Source File: ZoomingImageView.java From Silence with GNU General Public License v3.0 | 6 votes |
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 #10
Source File: CustomImageView.java From Anecdote with Apache License 2.0 | 6 votes |
@Nullable public File saveImage(){ Drawable drawable = getDrawable(); Bitmap bitmap = null; if(drawable instanceof BitmapDrawable){ bitmap = ((BitmapDrawable) drawable).getBitmap(); } else if (drawable instanceof GlideDrawable){ bitmap = ((GlideBitmapDrawable)drawable.getCurrent()).getBitmap(); } File output = new ImageSaver(getContext()) .setExternal(true) .setDirectoryName(Configuration.DOWNLOAD_FOLDER) .setFileName(getContext().getString(R.string.app_name) + "-" + System.currentTimeMillis() + ".jpg") .save(bitmap); if(output != null){ return output; } return null; }
Example #11
Source File: MainFragment.java From TvAppRepo with Apache License 2.0 | 6 votes |
protected void updateBackground(String uri) { int width = mMetrics.widthPixels; int height = mMetrics.heightPixels; Glide.with(getActivity()) .load(uri) .centerCrop() .error(mDefaultBackground) .into(new SimpleTarget<GlideDrawable>(width, height) { @Override public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) { mBackgroundManager.setDrawable(resource); } }); mBackgroundTimer.cancel(); }
Example #12
Source File: DribbbleTarget.java From android-proguards with Apache License 2.0 | 5 votes |
@Override public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> animation) { super.onResourceReady(resource, animation); if (!autoplayGifs) { resource.stop(); } BadgedFourThreeImageView badgedImageView = (BadgedFourThreeImageView) getView(); if (resource instanceof GlideBitmapDrawable) { Palette.from(((GlideBitmapDrawable) resource).getBitmap()) .clearFilters() .generate(this); } else if (resource instanceof GifDrawable) { Bitmap image = ((GifDrawable) resource).getFirstFrame(); Palette.from(image).clearFilters().generate(this); // look at the corner to determine the gif badge color int cornerSize = (int) (56 * getView().getContext().getResources().getDisplayMetrics ().scaledDensity); Bitmap corner = Bitmap.createBitmap(image, image.getWidth() - cornerSize, image.getHeight() - cornerSize, cornerSize, cornerSize); boolean isDark = ColorUtils.isDark(corner); corner.recycle(); badgedImageView.setBadgeColor(ContextCompat.getColor(getView().getContext(), isDark ? R.color.gif_badge_dark_image : R.color.gif_badge_light_image)); } }
Example #13
Source File: UrlDrawable.java From diycode with Apache License 2.0 | 5 votes |
public void setDrawable(GlideDrawable drawable) { if (this.mDrawable != null) { this.mDrawable.setCallback(null); } drawable.setCallback(this); this.mDrawable = drawable; }
Example #14
Source File: GlideDrawableTarget.java From mvvm-template with GNU General Public License v3.0 | 5 votes |
@Override public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) { if (container != null && container.get() != null) { TextView textView = container.get(); float width; float height; if (resource.getIntrinsicWidth() >= this.width) { float downScale = (float) resource.getIntrinsicWidth() / this.width; width = (float) (resource.getIntrinsicWidth() / downScale / 1.3); height = (float) (resource.getIntrinsicHeight() / downScale / 1.3); } else { float multiplier = (float) this.width / resource.getIntrinsicWidth(); width = (float) resource.getIntrinsicWidth() * multiplier; height = (float) resource.getIntrinsicHeight() * multiplier; } Rect rect = new Rect(0, 0, Math.round(width), Math.round(height)); resource.setBounds(rect); urlDrawable.setBounds(rect); urlDrawable.setDrawable(resource); if (resource.isAnimated() && !PrefGetter.isGistDisabled()) { urlDrawable.setCallback((Drawable.Callback) textView.getTag(R.id.drawable_callback)); resource.setLoopCount(GlideDrawable.LOOP_FOREVER); resource.start(); } textView.setText(textView.getText()); textView.invalidate(); } }
Example #15
Source File: ViewerFragment.java From NewsMe with Apache License 2.0 | 5 votes |
private void loadFullImage() { Glide.with(this).load(mImage.url) .diskCacheStrategy(DiskCacheStrategy.SOURCE) .crossFade(0) .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL) .listener(new GlideRequestListenerAdapter<String, GlideDrawable>() { @Override protected void onSuccess(GlideDrawable resource) { sharedElement = getBinding().image; fadeInFullImage(); } }) .into(getBinding().image); }
Example #16
Source File: TestActivity.java From glide-support with The Unlicense | 5 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); ImageView imageView = new ImageView(this); imageView.setLayoutParams(new MarginLayoutParams(MATCH_PARENT, MATCH_PARENT)); setContentView(imageView); String url = String.format(Locale.ROOT, URL_TEMPLATE, -1); Glide .with(this) .load(url) .listener(new LoggingListener<String, GlideDrawable>()) .into(imageView); }
Example #17
Source File: ViewerFragment.java From mr-mantou-android with GNU General Public License v3.0 | 5 votes |
private void loadThumbnail() { Glide.with(this).load(thumbnail) .diskCacheStrategy(DiskCacheStrategy.SOURCE) .crossFade(0) .listener(new GlideRequestListenerAdapter<String, GlideDrawable>() { @Override protected void onComplete() { startPostponedEnterTransition(); } }) .into(binding.thumbnail); }
Example #18
Source File: TestFragment.java From glide-support with The Unlicense | 5 votes |
@Override protected void load(Context context) throws Exception { Glide .with(this) .load(R.drawable.glide) .animate(new ViewAnimationFactory<GlideDrawable>(context, android.R.anim.slide_in_left) { @Override public GlideAnimation<GlideDrawable> build( boolean isFromMemoryCache, boolean isFirstResource) { return super.build(false, isFirstResource); } }) .into(imageView); }
Example #19
Source File: MainActivity.java From RxPalette with Apache License 2.0 | 5 votes |
@Override public boolean onResourceReady( GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) { onBitmapReady(GlideBitmapDrawable.class.cast(resource).getBitmap()); return false; }
Example #20
Source File: TestFragment_Pre380.java From glide-support with The Unlicense | 5 votes |
@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: GlideLoader.java From tenor-android-core with Apache License 2.0 | 5 votes |
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 #22
Source File: ViewerFragment.java From GankMeizhi with Apache License 2.0 | 5 votes |
@Override public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) { maybeStartPostponedEnterTransition(); return true; }
Example #23
Source File: WorkflowDetailFragment.java From incubator-taverna-mobile with Apache License 2.0 | 5 votes |
@Override public void showWorkflowDetail(Workflow workflow) { this.mWorkflow = workflow; uploaderName.setText(workflow.getUploader().getContent()); date.setText(workflow.getUpdatedAt() .substring(0, workflow.getUpdatedAt().indexOf(' '))); type.setText(workflow.getType().getContent()); title.setText(workflow.getTitle()); description.loadData(workflow.getDescription(), "text/html", "utf-8"); Glide.with(getContext()) .load(workflow.getPreviewUri()) .diskCacheStrategy(DiskCacheStrategy.SOURCE) .placeholder(R.drawable.placeholder) .error(R.drawable.placeholder) .into(new SimpleTarget<GlideDrawable>() { @Override public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) { workflowImage.setImageDrawable(resource); } }); if (workflow.getLicenseType().getId() == null) { licenceId = ""; } else { licenceId = workflow.getLicenseType().getId(); } if (mWorkflow.getType().getContent().equals(getString(R.string.t2_workflow_type))) { fabRun.setVisibility(View.VISIBLE); } else { fabRun.setVisibility(View.GONE); } }
Example #24
Source File: ImageViewHolder.java From Anecdote with Apache License 2.0 | 5 votes |
/** * GLIDE LISTENER */ @Override public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) { if(mRetried < RETRY_COUNT && mImageUrl != null){ mRetried ++; Log.d(TAG, "Retry " + mImageUrl + " retried?" + mRetried); loadImage(); return true; } EventTracker.trackError("Image download: " + mImageUrl, e.toString()); return false; }
Example #25
Source File: QuickFragment.java From glide-support with The Unlicense | 5 votes |
@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 #26
Source File: TestFragment.java From glide-support with The Unlicense | 5 votes |
@Override protected void load(Context context) throws Exception { String url = // "https://cloud.githubusercontent.com/assets/3822339/14021484/b8814c80-f201-11e5-93b0-b50076381286.gif"; "https://cloud.githubusercontent.com/assets/2906988/14031433/1bfc4106-f20d-11e5-94c6-861bbf3f4991.gif"; Glide .with(context) .load(url) .diskCacheStrategy(DiskCacheStrategy.SOURCE) .listener(new LoggingListener<String, GlideDrawable>()) .into(imageView) ; }
Example #27
Source File: BaseWrappedViewHolder.java From TestChat with Apache License 2.0 | 5 votes |
public BaseWrappedViewHolder setImageBg(final int id, String url) { if (getView(id) instanceof ImageView) { Glide.with(itemView.getContext()).load(url).into(new SimpleTarget<GlideDrawable>() { @Override public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) { LogUtil.e("设置背景"); getView(id).setBackground(resource); } }); } return this; }
Example #28
Source File: MeiziDetailsFragment.java From MoeQuest with Apache License 2.0 | 5 votes |
@Override public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) { mImageView.setImageDrawable(resource); mPhotoViewAttacher = new PhotoViewAttacher(mImageView); mImageError.setVisibility(View.GONE); setPhotoViewAttacher(); return false; }
Example #29
Source File: AboutActivity.java From FakeWeather with Apache License 2.0 | 5 votes |
private void loadImage() { Glide.with(this).load(imageUrls[new Random().nextInt(5)]).into(new SimpleTarget<GlideDrawable>(imageSwitcher.getWidth(), imageSwitcher.getHeight()) { @Override public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) { imageSwitcher.setImageDrawable(resource); } }); }
Example #30
Source File: TestFragment.java From glide-support with The Unlicense | 5 votes |
@Override protected void load1(Context context, ImageView imageView) throws Exception { Glide .with(this) .load("http://facebook.github.io/stetho/static/logo.png") .diskCacheStrategy(NONE) .skipMemoryCache(true) .listener(new LoggingListener<String, GlideDrawable>()) .into(imageView) ; }