/** * Equivalent to calling {@link #asDrawable()} and then {@link RequestBuilder#load(byte[])}. * * @return A new request builder for loading a {@link Drawable} using the given model. */ @NonNull @CheckResult @Override public RequestBuilder<Drawable> load(@Nullable byte[] model) { return asDrawable().load(model); }
/** * Equivalent to calling {@link #asDrawable()} and then {@link RequestBuilder#load(Drawable)}. * * @return A new request builder for loading a {@link Drawable} using the given model. */ @NonNull @CheckResult @Override public RequestBuilder<Drawable> load(@Nullable Drawable drawable) { return asDrawable().load(drawable); }
/** * Equivalent to calling {@link #asDrawable()} and then {@link RequestBuilder#load(Uri)}. * * @return A new request builder for loading a {@link Drawable} using the given model. */ @NonNull @CheckResult @Override public RequestBuilder<Drawable> load(@Nullable Uri uri) { return asDrawable().load(uri); }
/** * Equivalent to calling {@link #asDrawable()} and then {@link RequestBuilder#load(File)}. * * @return A new request builder for loading a {@link Drawable} using the given model. */ @NonNull @CheckResult @Override public RequestBuilder<Drawable> load(@Nullable File file) { return asDrawable().load(file); }
/** * Equivalent to calling {@link #asDrawable()} and then {@link RequestBuilder#load(URL)}. * * @return A new request builder for loading a {@link Drawable} using the given model. */ @SuppressWarnings("deprecation") @CheckResult @Override @Deprecated public RequestBuilder<Drawable> load(@Nullable URL url) { return asDrawable().load(url); }
/** * Equivalent to calling {@link #asDrawable()} and then {@link RequestBuilder#load(Bitmap)}. * * @return A new request builder for loading a {@link Drawable} using the given model. */ @NonNull @CheckResult @Override public RequestBuilder<Drawable> load(@Nullable Bitmap bitmap) { return asDrawable().load(bitmap); }
/** * Equivalent to calling {@link #asDrawable()} and then {@link RequestBuilder#load(String)}. * * @return A new request builder for loading a {@link Drawable} using the given model. */ @NonNull @CheckResult @Override public RequestBuilder<Drawable> load(@Nullable String string) { return asDrawable().load(string); }
/** * A helper method equivalent to calling {@link #asDrawable()} and then {@link * RequestBuilder#load(Object)} with the given model. * * @return A new request builder for loading a {@link Drawable} using the given model. */ @NonNull @CheckResult @Override public RequestBuilder<Drawable> load(@Nullable Object model) { return asDrawable().load(model); }
/** * Equivalent to calling {@link #asDrawable()} and then {@link RequestBuilder#load(Integer)}. * * @return A new request builder for loading a {@link Drawable} using the given model. */ @SuppressWarnings("deprecation") @NonNull @CheckResult @Override public RequestBuilder<Drawable> load(@RawRes @DrawableRes @Nullable Integer resourceId) { return asDrawable().load(resourceId); }
@Override protected void onAttachedToWindow() { super.onAttachedToWindow(); Glide.with(getContext()).asDrawable().load(android.R.drawable.ic_menu_rotate).into(this); } }
@Test public void requestBuilder_intoImageView_withSameByteArrayAndMemoryCacheEnabled_loadsFromMemory() throws IOException { final byte[] canonicalBytes = getCanonicalBytes(); concurrency.loadOnMainThread( Glide.with(context) .asDrawable() .load(canonicalBytes) .apply(skipMemoryCacheOf(false)), imageView); Glide.with(context).clear(imageView); concurrency.loadOnMainThread( Glide.with(context) .asDrawable() .load(canonicalBytes) .listener(requestListener) .apply(skipMemoryCacheOf(false)), imageView); verify(requestListener).onResourceReady( anyDrawable(), any(), anyDrawableTarget(), eq(DataSource.MEMORY_CACHE), anyBoolean()); }
/** * A helper method equivalent to calling {@link #asDrawable()} and then {@link * RequestBuilder#load(Object)} with the given model. * * @return A new request builder for loading a {@link Drawable} using the given model. */ public RequestBuilder<Drawable> load(@Nullable Object model) { return asDrawable().load(model); }
public static void showImage(@NonNull Context context,@NonNull String url, @NonNull ImageView imageView){ RequestOptions requestOptions = new RequestOptions().centerCrop(); Glide.with(context).asDrawable().load(url).into(imageView); } public static void showImage(@NonNull Context context,@NonNull String url, @NonNull ImageView imageView,@DrawableRes int errorRes,@DrawableRes int placeholderRes){
public static void showImage(@NonNull Context context, @DrawableRes int drawableRes, @NonNull ImageView imageView){ RequestOptions requestOptions = new RequestOptions().centerCrop(); Glide.with(context).asDrawable().load(drawableRes).apply(requestOptions).into(imageView); } }
public static void showImage(@NonNull Context context,@NonNull String url, @NonNull ImageView imageView,@DrawableRes int errorRes,@DrawableRes int placeholderRes){ RequestOptions requestOptions = new RequestOptions().centerCrop().error(errorRes).placeholder(placeholderRes); Glide.with(context).asDrawable().load(url).apply(requestOptions).into(imageView); } public static void showImage(@NonNull Context context, @NonNull File file, @NonNull ImageView imageView, @DrawableRes int errorRes, @DrawableRes int placeholderRes){
public static void showImage(@NonNull Context context, @NonNull File file, @NonNull ImageView imageView, @DrawableRes int errorRes, @DrawableRes int placeholderRes){ RequestOptions requestOptions = new RequestOptions().centerCrop().error(errorRes).placeholder(placeholderRes); Glide.with(context).asDrawable().load(file).apply(requestOptions).into(imageView); } public static void showImage(@NonNull Context context, @DrawableRes int drawableRes, @NonNull ImageView imageView){
@Override public void loadThumbnail(Context context, int resize, Drawable placeholder, ImageView imageView, Uri uri) { /* Glide.with(context) .load(uri) .asBitmap() // some .jpeg files are actually gif .placeholder(placeholder) .override(resize, resize) .centerCrop() .into(imageView);*/ RequestOptions requestOptions = new RequestOptions().centerCrop(); Glide.with(context).asDrawable().load(uri).apply(requestOptions).into(imageView); }
@Override public void loadImage(Context context, int resizeX, int resizeY, ImageView imageView, Uri uri) { /* Glide.with(context) .load(uri) .override(resizeX, resizeY) .priority(Priority.HIGH) .fitCenter() .into(imageView);*/ RequestOptions requestOptions = new RequestOptions().override(resizeX,resizeY).fitCenter().priority(Priority.HIGH); Glide.with(context).asDrawable().load(uri).apply(requestOptions).into(imageView); }
@Override public void loadGifThumbnail(Context context, int resize, Drawable placeholder, ImageView imageView, Uri uri) { RequestOptions requestOptions = new RequestOptions().override(resize,resize).centerCrop().error(placeholder).placeholder(placeholder); Glide.with(context).asDrawable().load(uri).apply(requestOptions).into(imageView); /*Glide.with(context) .load(uri) .asBitmap() .placeholder(placeholder) .override(resize, resize) .centerCrop() .into(imageView);*/ }
public LaunchPoint(Context context, String appTitle, String iconUrl, Intent launchIntent, int launchColor, InstallingLaunchPointListener listener) { clear(context); this.mAppTitle = appTitle; this.mLaunchColor = launchColor; if (launchIntent != null) { this.mLaunchIntent = launchIntent.addFlags(270532608); if (this.mLaunchIntent.getComponent() != null) { this.mComponentName = this.mLaunchIntent.getComponent().flattenToString(); this.mPackageName = this.mLaunchIntent.getComponent().getPackageName(); } } Resources resources = context.getResources(); this.mLaunchColor = ResourcesCompat.getColor(resources, R.color.app_launch_ripple_default_color, null); this.mPackageInstallTime = Util.getInstallTimeForPackage(context, this.mPackageName); this.mListener = listener; this.mIsInitialInstall = true; if (!TextUtils.isEmpty(iconUrl)) { int maxIconSize = resources.getDimensionPixelSize(R.dimen.banner_icon_size); Glide.with(context).asDrawable().apply(RequestOptions.skipMemoryCacheOf(true)).apply(RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.NONE)).load(iconUrl).into(new SimpleTarget<Drawable>(maxIconSize, maxIconSize) { public void onResourceReady(Drawable drawable, Transition<? super Drawable> transition) { InstallingLaunchPointListener launchPointListener = LaunchPoint.this.mListener; if (drawable != null && launchPointListener != null) { LaunchPoint.this.mIconDrawable = drawable; launchPointListener.onInstallingLaunchPointChanged(LaunchPoint.this); } } }); } }