Java Code Examples for android.widget.ImageView#getResources()
The following examples show how to use
android.widget.ImageView#getResources() .
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: GifViewUtils.java From android-gif-drawable-eclipse-sample with MIT License | 6 votes |
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) @SuppressWarnings("deprecation") static boolean setResource(ImageView view, boolean isSrc, int resId) { Resources res = view.getResources(); if (res != null) { try { GifDrawable d = new GifDrawable(res, resId); if (isSrc) { view.setImageDrawable(d); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { view.setBackground(d); } else { view.setBackgroundDrawable(d); } return true; } catch (IOException | Resources.NotFoundException ignored) { //ignored } } return false; }
Example 2
Source File: AsyncImageDownloadTask.java From HomeGenie-Android with GNU General Public License v3.0 | 6 votes |
private void setImage(ImageView imageView, Bitmap bitmap) { if (animate) { Resources resources = imageView.getResources(); BitmapDrawable drawable = new BitmapDrawable(resources, bitmap); Drawable currentDrawable = imageView.getDrawable(); if (currentDrawable != null) { Drawable[] arrayDrawable = new Drawable[2]; arrayDrawable[0] = currentDrawable; arrayDrawable[1] = drawable; final TransitionDrawable transitionDrawable = new TransitionDrawable(arrayDrawable); transitionDrawable.setCrossFadeEnabled(true); imageView.setImageDrawable(transitionDrawable); transitionDrawable.startTransition(150); } else { imageView.setImageDrawable(drawable); } } else { imageView.setImageBitmap(bitmap); } }
Example 3
Source File: GifViewUtils.java From sketch with Apache License 2.0 | 6 votes |
@SuppressWarnings("deprecation") static boolean setResource(ImageView view, boolean isSrc, int resId) { Resources res = view.getResources(); if (res != null) { try { final String resourceTypeName = res.getResourceTypeName(resId); if (!SUPPORTED_RESOURCE_TYPE_NAMES.contains(resourceTypeName)) { return false; } GifDrawable d = new GifDrawable(res, resId); if (isSrc) { view.setImageDrawable(d); } else { view.setBackground(d); } return true; } catch (IOException | Resources.NotFoundException ignored) { //ignored } } return false; }
Example 4
Source File: ImageProvider.java From mobile-manager-tool with MIT License | 5 votes |
private void setLoadedBitmap(ImageView imageView, Bitmap bitmap, String tag) { if (!tag.equals(imageView.getTag())) return; final TransitionDrawable transition = new TransitionDrawable(new Drawable[]{ new ColorDrawable(android.R.color.transparent), new BitmapDrawable(imageView.getResources(), bitmap) }); imageView.setImageDrawable(transition); final int duration = imageView.getResources().getInteger(R.integer.image_fade_in_duration); transition.startTransition(duration); }
Example 5
Source File: ViewUtil.java From BaseProject with Apache License 2.0 | 4 votes |
public static void imageViewRounded(ImageView iv, int imageResId, int roundedRadius) { Resources res = iv.getResources(); RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(res, BitmapFactory.decodeResource(res, imageResId)); roundedBitmapDrawable.setCornerRadius(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, roundedRadius, res.getDisplayMetrics())); iv.setImageDrawable(roundedBitmapDrawable); }
Example 6
Source File: LoaderDrawable.java From box-android-browse-sdk with Apache License 2.0 | 4 votes |
public static LoaderDrawable create(BoxRequestsFile.DownloadRepresentation request, final BoxItem boxItem, ImageView imageView, Bitmap placeHolder, final ImageReadyListener imageReadyListener) { return new LoaderDrawable(ThumbnailTask.create(request, boxItem, imageView, imageReadyListener),imageView.getResources(), placeHolder); }
Example 7
Source File: CrossbowImage.java From CrossBow with Apache License 2.0 | 4 votes |
@VisibleForTesting void setBitmap(Bitmap bitmap, boolean fromCache) { ImageView imageView = this.imageView.get(); if (bitmap != null && imageView != null) { Resources resources = imageView.getResources(); BitmapDrawable bitmapDrawable = new BitmapDrawable(resources, bitmap); ScaleTypeDrawable bitmapScale = new ScaleTypeDrawable(bitmapDrawable, this.scaleType, this.debug && fromCache); if (this.fade != DEFAULT && !fromCache) { //Do a fade with an animation drawable if (defaultDrawable != null) { ScaleTypeDrawable defaultScale = new ScaleTypeDrawable(defaultDrawable, this.preScaleType); Drawable[] layers = new Drawable[2]; layers[0] = defaultScale; layers[1] = bitmapScale; TransitionDrawable animationDrawable = new TransitionDrawable(layers); imageView.setImageDrawable(animationDrawable); animationDrawable.setCrossFadeEnabled(true); animationDrawable.startTransition(this.fade); } else { AlphaAnimation alphaAnimation = new AlphaAnimation(0,1); alphaAnimation.setDuration(this.fade); imageView.setImageDrawable(bitmapScale); imageView.startAnimation(alphaAnimation); } } else { //just set the bitmap imageView.setImageDrawable(bitmapScale); } if (this.listener != null) { this.listener.onLoad(true, fromCache, bitmap, imageView); } } }
Example 8
Source File: LoaderDrawable.java From box-android-browse-sdk with Apache License 2.0 | 2 votes |
/** * Creates a LoaderDrawable that is responsible for loading a thumbnail into the provided image view * * @param request the request * @param boxItem the box item * @param imageView the image view * @param placeHolder the place holder * @param imageReadyListener the image ready listener * @return loader drawable */ public static LoaderDrawable create(BoxRequestsFile.DownloadThumbnail request, final BoxItem boxItem, ImageView imageView, Bitmap placeHolder, final ImageReadyListener imageReadyListener) { return new LoaderDrawable(ThumbnailTask.create(request, boxItem, imageView, imageReadyListener),imageView.getResources(), placeHolder); }