Example usage for android.widget ImageView getContext

List of usage examples for android.widget ImageView getContext

Introduction

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

Prototype

@ViewDebug.CapturedViewProperty
public final Context getContext() 

Source Link

Document

Returns the context the view is running in, through which it can access the current theme, resources, etc.

Usage

From source file:com.myapps.upesse.upes_spefest.ui.utils.GlideUtil.java

public static void loadProfileIcon(String url, ImageView imageView) {
    Context context = imageView.getContext();
    if (context != null || (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)) {
        Glide.with(context).load(url).placeholder(R.drawable.ic_person_outline_black).dontAnimate().fitCenter()
                .into(imageView);/*  w w w.  j a va 2  s . com*/
    }
}

From source file:com.myapps.upesse.upes_spefest.ui.utils.GlideUtil.java

public static void loadImage(String url, ImageView imageView) {
    Context context = imageView.getContext();
    if (context != null || (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)) {
        assert context != null;
        ColorDrawable cd = new ColorDrawable(ContextCompat.getColor(context, R.color.blue_grey_500));

        Glide.with(context).load(url).placeholder(cd).crossFade().centerCrop().into(imageView);
    }//from w  w  w. j  av a  2s. com
}

From source file:com.fa.mastodon.util.ThemeUtils.java

public static void setImageViewTint(ImageView view, @AttrRes int attribute) {
    view.setColorFilter(getColor(view.getContext(), attribute), PorterDuff.Mode.SRC_IN);
}

From source file:com.keylesspalace.tusky.ThemeUtils.java

static void setImageViewTint(ImageView view, @AttrRes int attribute) {
    view.setColorFilter(getColor(view.getContext(), attribute), PorterDuff.Mode.SRC_IN);
}

From source file:Main.java

private static boolean loadAssetImage(ImageView view, String filename) {

    InputStream input = null;/*from  w w w.  j ava  2s.c  o m*/
    try {
        input = view.getContext().getAssets().open(filename);
        Bitmap icon = BitmapFactory.decodeStream(input);
        view.setImageBitmap(icon);
        input.close();
        return true;
    } catch (Exception error) {
    } finally {
        silentClose(input);
    }
    return false;
}

From source file:com.myapps.upesse.upes_spefest.ui.utils.GlideUtil.java

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public static void loadImage(String url, ImageView mPhotoView, final ProgressBar mProgress) {
    Context context = mPhotoView.getContext();
    if (context != null || (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)) {
        assert context != null;
        ColorDrawable cd = new ColorDrawable(ContextCompat.getColor(context, R.color.blue_grey_500));

        mProgress.setEnabled(true);//  ww  w .  j a  va2 s  .  c  o  m
        Glide.with(context).load(url).listener(new RequestListener<String, GlideDrawable>() {
            @Override
            public boolean onException(Exception e, String model, Target<GlideDrawable> target,
                    boolean isFirstResource) {
                mProgress.setVisibility(View.GONE);
                return false;
            }

            @Override
            public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target,
                    boolean isFromMemoryCache, boolean isFirstResource) {
                mProgress.setVisibility(View.GONE);
                return false;
            }
        }).placeholder(cd).crossFade().centerCrop().into(mPhotoView);
    }
}

From source file:Main.java

private static void loadAssetImage(ImageView view, String filename, int defaultIconId) {

    InputStream input = null;//from   ww  w  . j a v  a 2  s  . c om
    try {
        input = view.getContext().getAssets().open(filename);
        Bitmap icon = BitmapFactory.decodeStream(input);
        view.setImageBitmap(icon);
        input.close();
    } catch (Exception error) {
        view.setImageResource(defaultIconId);
    } finally {
        silentClose(input);
    }
}

From source file:nl.sebastiaanschool.contact.app.gui.GrabBag.java

/**
 * Apply a vector drawable to an image view.
 * @param imageView the imageView./*  w ww. j  a v  a  2s  .c om*/
 * @param resId the drawable resource.
 */
public static void applyVectorImage(ImageView imageView, @DrawableRes int resId) {
    imageView.setImageDrawable(loadVectorDrawable(imageView.getContext(), resId));
}

From source file:com.rayman.v2ex.viewmodel.BindingAdapter.java

@android.databinding.BindingAdapter(value = "android:src")
public static void loadImageByUrl(ImageView imageView, String url) {
    if (StringUtil.isEmpty(url))
        return;//  ww w  .j  a  va  2  s  .  c  om
    Picasso.with(imageView.getContext()).load(getFormatImageUrl(url)).placeholder(R.mipmap.ic_launcher)
            .into(imageView);
}

From source file:org.goseumdochi.android.leash.EfficientAnimation.java

public static void animate(int resourceId, final ImageView imageView, final int duration) {
    loadRaw(resourceId, imageView.getContext(), new OnDrawableLoadedListener() {
        @Override//w w  w  .j a va  2s.c  o  m
        public void onDrawableLoaded(List<EaFrame> frames) {
            animate(frames, imageView, 0, true, duration);
        }
    });
}