Example usage for android.widget ImageView getResources

List of usage examples for android.widget ImageView getResources

Introduction

In this page you can find the example usage for android.widget ImageView getResources.

Prototype

public Resources getResources() 

Source Link

Document

Returns the resources associated with this view.

Usage

From source file:cn.bingoogolapple.scaffolding.util.DrawableUtil.java

public static void tintPressedIndicator(ImageView imageView, @DrawableRes int normalResId,
        @DrawableRes int pressedResId, @ColorRes int colorResId) {
    Drawable normal = imageView.getResources().getDrawable(normalResId);
    Drawable pressed = imageView.getResources().getDrawable(pressedResId);
    pressed = tintDrawable(imageView.getContext(), pressed, colorResId);
    imageView.setImageDrawable(getPressedSelectorDrawable(normal, pressed));
}

From source file:Main.java

public static void stripImageView(ImageView view) {
    if (view.getDrawable() instanceof BitmapDrawable) {
        ((BitmapDrawable) view.getDrawable()).getBitmap().recycle();
    }/*from  www  .ja  v  a  2  s. c  o  m*/
    view.getDrawable().setCallback(null);
    view.setImageDrawable(null);
    view.getResources().flushLayoutCache();
    view.destroyDrawingCache();
}

From source file:com.xebia.xsdnl.innorater.Crap.java

public static void showNearbyStateInImageView(ImageView iv, boolean enabled) {
    if (enabled) {
        iv.setImageResource(R.drawable.logo_nearby_color_48dp);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            iv.setImageTintList(null);//  w w  w . j  av  a 2s . c o  m
        }
    } else {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            iv.setImageResource(R.drawable.ic_nearby_white_48dp);
            iv.setImageTintList(iv.getResources().getColorStateList(R.color.primary_text_disabled_light));
        } else {
            Drawable raw = iv.getResources().getDrawable(R.drawable.ic_nearby_white_48dp);
            Drawable tintable = DrawableCompat.wrap(raw);
            DrawableCompat.setTint(tintable, iv.getResources().getColor(R.color.primary_text_disabled_light));
            iv.setImageDrawable(tintable);
        }
    }
}

From source file:uk.co.bubblebearapps.motionaiclient.view.customsetters.ImageViewSetters.java

@BindingAdapter("circleImageUrl")
public static void setCircularImageUrl(final ImageView imageView, String url) {
    if (Strings.isNullOrEmpty(url)) {
        imageView.setImageBitmap(null);// w  w  w .j  a  va  2  s .c  o m
    } else {
        Glide.with(imageView.getContext()).load(url).asBitmap().centerCrop()
                .into(new BitmapImageViewTarget(imageView) {
                    @Override
                    protected void setResource(Bitmap resource) {
                        RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory
                                .create(imageView.getResources(), resource);
                        roundedBitmapDrawable.setCircular(true);
                        imageView.setImageDrawable(roundedBitmapDrawable);
                    }
                });
    }
}

From source file:com.benefit.buy.library.http.query.callback.BitmapAjaxCallback.java

private static Drawable makeDrawable(ImageView iv, Bitmap bm, float ratio, float anchor) {
    BitmapDrawable bd = null;//from   w ww.  j a  v  a 2s .c  om
    if (ratio > 0) {
        bd = new RatioDrawable(iv.getResources(), bm, iv, ratio, anchor);
    } else {
        bd = new BitmapDrawable(iv.getResources(), bm);
    }
    return bd;
}

From source file:com.appbase.androidquery.callback.BitmapAjaxCallback.java

private static Drawable makeDrawable(ImageView iv, Bitmap bm, float ratio, float anchor) {

    BitmapDrawable bd = null;//www .  ja  va 2s.  co m

    if (ratio > 0) {
        bd = new RatioDrawable(iv.getResources(), bm, iv, ratio, anchor);
    } else {
        bd = new BitmapDrawable(iv.getResources(), bm);
    }

    return bd;

}

From source file:com.stasbar.knowyourself.stopwatch.StopwatchFragment.java

public void onUpdateFab(@NonNull ImageView fab) {
    if (getStopwatch().isRunning()) {
        fab.setImageResource(R.drawable.ic_pause_white_24dp);
        fab.setContentDescription(fab.getResources().getString(R.string.sw_pause_button));
    } else {//from w  ww.  j a  v  a2 s.  com
        fab.setImageResource(R.drawable.ic_start_white_24dp);
        fab.setContentDescription(fab.getResources().getString(R.string.sw_start_button));
    }
    fab.setVisibility(VISIBLE);
}

From source file:com.androidpi.bricks.gallery.lru.cache.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be set on the ImageView.
 *
 * @param imageView//from  ww  w . jav a2  s.c  o  m
 * @param drawable
 */
private void setImageDrawable(ImageView imageView, Drawable drawable) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final
        // drawable
        final TransitionDrawable td = new TransitionDrawable(new Drawable[] {
                new ColorDrawable(imageView.getResources().getColor(android.R.color.transparent)), drawable });
        // Set background to loading bitmap
        imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageDrawable(drawable);
    }
}

From source file:com.krava.vkmessenger.domain.image.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be
 * set on the ImageView./*w w  w .j  av  a2s  .co m*/
 *
 * @param imageView
 * @param drawable
 */
private void setImageDrawable(ImageView imageView, Drawable drawable) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td = new TransitionDrawable(new Drawable[] {
                new ColorDrawable(imageView.getResources().getColor(android.R.color.transparent)), drawable });
        // Set background to loading bitmap
        imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageDrawable(drawable);
    }
}

From source file:com.android.deskclock.stopwatch.StopwatchFragment.java

@Override
public void onUpdateFab(@NonNull ImageView fab) {
    if (getStopwatch().isRunning()) {
        fab.setImageResource(R.drawable.ic_pause_white_24dp);
        fab.setContentDescription(fab.getResources().getString(R.string.sw_pause_button));
    } else {/* w  ww .j  a v a 2  s.co  m*/
        fab.setImageResource(R.drawable.ic_start_white_24dp);
        fab.setContentDescription(fab.getResources().getString(R.string.sw_start_button));
    }
    fab.setVisibility(VISIBLE);
}