1. Introducing Channels - a new way to chat with other Android users!
    Dismiss Notice

imageview async loading


Last Updated:

  1. faisalloe

    faisalloe Member This Topic's Starter

    Joined:
    Jan 21, 2010
    Messages:
    17
    Likes Received:
    0
    I am using the following custom widget to async image loading from web...

    i am dispalying images in listview when i scrool down in speed it throws

    RejectedExecutionException exception

    any idea ?


    public class WebImage extends ImageView {

    private final static String TAG = SearchTitleResults.class.getSimpleName();

    public WebImage(Context context) {
    super(context);

    }

    public WebImage(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    // TODO Auto-generated constructor stub
    }

    public WebImage(Context context, AttributeSet attrs) {
    super(context, attrs);
    // TODO Auto-generated constructor stub
    }

    public synchronized void reset(){
    setImageResource(R.drawable.water2);
    }

    public synchronized void loadImage(String imageURL){
    class DownloadImageTask extends AsyncTask {
    String url = "";
    @Override
    protected Object doInBackground(Object... arg0) {
    url = arg0[0].toString();
    Log.v(TAG, "doInbackground: " + url);
    Bitmap bmp = WebServiceRequest.getInstance().getImageFromURL(url);
    return bmp;
    }
    @Override
    protected void onPostExecute(Object result) {
    super.onPostExecute(result);
    setImageBitmap((Bitmap)result);
    Log.v(TAG, "Post() -> " + url);
    }
    }
    new DownloadImageTask().execute(imageURL);
    }
    }
     

    Advertisement

Share This Page

Loading...