Example usage for android.widget ImageView postInvalidate

List of usage examples for android.widget ImageView postInvalidate

Introduction

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

Prototype

public void postInvalidate() 

Source Link

Document

Cause an invalidate to happen on a subsequent cycle through the event loop.

Usage

From source file:com.oasis.sdk.activity.OasisSdkPayEpinActivity.java

private void initImage(List<String> imgUrls) {
    if (imgUrls == null || imgUrls.size() <= 0)
        return;/* ww  w  .  j av  a  2  s  .  c o  m*/

    int size = imgUrls.size();
    if (size > 4)// 4
        size = 4;
    Rect r = new Rect();
    et_code.getGlobalVisibleRect(r);

    int width = r.right - r.left;
    int singWidth = width / size;

    int imgWidth = DisplayUtil.dip2px(70, BaseUtils.getDensity());
    int imgHeight = DisplayUtil.dip2px(30, BaseUtils.getDensity());

    double l = singWidth / (double) imgWidth;
    if (l <= 1) {
        imgWidth = singWidth;
    } else {
        l = Math.round(l * 100) * 0.01d;// ?2??

        imgWidth *= l;
        imgHeight *= l;
    }

    for (int i = 0; i < size; i++) {
        // ? 105*45
        final ImageView img = new ImageView(this.getApplicationContext());
        img.setLayoutParams(new LayoutParams(imgWidth, imgHeight));
        img.setImageResource(BaseUtils.getResourceValue("drawable", "oasisgames_sdk_payway_mob_epin"));
        ImageRequest iq = new ImageRequest(imgUrls.get(i), new Response.Listener<Bitmap>() {

            @Override
            public void onResponse(final Bitmap arg0) {
                if (arg0 == null)
                    return;
                img.setImageBitmap(arg0);
                img.postInvalidate();
            }
        }, imgWidth, // ???
                imgHeight, Config.ARGB_8888, new Response.ErrorListener() {

                    @Override
                    public void onErrorResponse(VolleyError arg0) {

                        setWaitScreen(false);
                    }

                });
        iq.setRetryPolicy(new DefaultRetryPolicy(60000, 2, 1));
        ApplicationContextManager.getInstance().getVolleyRequestQueue().add(iq);

        ll_images.addView(img);
    }
    if (ll_images.getChildCount() > 0) {
        ll_images.setVisibility(View.VISIBLE);
    }
}