Android Open Source - gridView Download Image Task






From Project

Back to project page gridView.

License

The source code is released under:

Apache License

If you think the Android project gridView listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.datayumyum.pos;
//  w  w w . j a v  a 2s. c  o  m
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.util.Log;
import android.widget.ImageButton;

import java.io.InputStream;

public class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
    private static final String TAG = "com.datayumyum.pos.DownloadImageTask";
    private ImageButton imageButton;
    private String url;

    public DownloadImageTask(ImageButton imageButton) {
        this.imageButton = imageButton;
    }

    protected Bitmap doInBackground(String... urls) {
        url = urls[0];
        Bitmap bitmap = null;
        try {
            InputStream in = new java.net.URL(url).openStream();
            bitmap = BitmapFactory.decodeStream(in);
        } catch (Exception e) {
            Log.e(TAG, e.getMessage());
        }
        return bitmap;
    }

    protected void onPostExecute(Bitmap result) {
        imageButton.setImageBitmap(result);
        Log.i(TAG, "loaded " + url);
    }
}




Java Source Code List

com.datayumyum.pos.CategoryAdapter.java
com.datayumyum.pos.DownloadImageTask.java
com.datayumyum.pos.GridViewActivity.java
com.datayumyum.pos.ItemButton.java
com.datayumyum.pos.ItemRepository.java
com.datayumyum.pos.Item.java
com.datayumyum.pos.SwipeDismissListViewTouchListener.java
com.datayumyum.pos.SwipeDismissTouchListener.java
com.datayumyum.pos.SwipeListener.java