// Path: src/com/nitindhar/kampr/util/ImageUtils.java
// public class ImageUtils {
// 
//     public static Bitmap getBitmapFromByteArray(byte[] imageData) {
//         return BitmapFactory.decodeByteArray(imageData, 0, imageData.length);
//     }
// 
//     public static byte[] getByteArrayFromBitmap(Bitmap imageData) {
//         ByteArrayOutputStream stream = new ByteArrayOutputStream();
//         imageData.compress(Bitmap.CompressFormat.JPEG, 100, stream);
//         return stream.toByteArray();
//     }
// 
//     public static Bitmap fetchUserIcon(Context context, String url, int defaultDrawableId) {
//         try {
//             InputStream is = (InputStream) new URL(url).getContent();
//             return getBitmapFromStream(is, context, defaultDrawableId);
//         } catch (MalformedURLException e) {
//             throw new RuntimeException("Error: malformed URI", e);
//         } catch (IOException e) {
//             throw new RuntimeException("Error: could not read from stream", e);
//         }
//     }
// 
//     public static Bitmap getBitmapFromStream(InputStream is, Context context, int drawableId) {
//         Bitmap bmp = BitmapFactory.decodeStream(is);
//         if(bmp == null) {
//             return BitmapFactory.decodeResource(context.getResources(), drawableId);
//         }
//         else {
//             return bmp;
//         }
//     }
// 
//     public static Bitmap fetchImageBitmap(String uri) {
//         Bitmap imageData = null;
//         try {
//             InputStream is = (InputStream) new URL(uri).getContent();
//             imageData = BitmapFactory.decodeStream(is);
//         } catch (MalformedURLException e) {
//             throw new RuntimeException("Error processing url", e);
//         } catch (IOException e) {
//             throw new RuntimeException("Error fetching data from stream", e);
//         }
//         return imageData;
//     }
// 
// }


import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.widget.ImageView;
import com.nitindhar.forrst.model.Post;
import com.nitindhar.kampr.util.ImageUtils;
package com.nitindhar.kampr.async;



public class SnapTask extends AsyncTask<Post, Integer, Bitmap> {

    private final ImageView postOriginal;

    public SnapTask(ImageView postOriginal) {
        this.postOriginal = postOriginal;
    }

    @Override
    protected Bitmap doInBackground(Post... posts) {
// Path: src/com/nitindhar/kampr/util/ImageUtils.java
// public class ImageUtils {
// 
//     public static Bitmap getBitmapFromByteArray(byte[] imageData) {
//         return BitmapFactory.decodeByteArray(imageData, 0, imageData.length);
//     }
// 
//     public static byte[] getByteArrayFromBitmap(Bitmap imageData) {
//         ByteArrayOutputStream stream = new ByteArrayOutputStream();
//         imageData.compress(Bitmap.CompressFormat.JPEG, 100, stream);
//         return stream.toByteArray();
//     }
// 
//     public static Bitmap fetchUserIcon(Context context, String url, int defaultDrawableId) {
//         try {
//             InputStream is = (InputStream) new URL(url).getContent();
//             return getBitmapFromStream(is, context, defaultDrawableId);
//         } catch (MalformedURLException e) {
//             throw new RuntimeException("Error: malformed URI", e);
//         } catch (IOException e) {
//             throw new RuntimeException("Error: could not read from stream", e);
//         }
//     }
// 
//     public static Bitmap getBitmapFromStream(InputStream is, Context context, int drawableId) {
//         Bitmap bmp = BitmapFactory.decodeStream(is);
//         if(bmp == null) {
//             return BitmapFactory.decodeResource(context.getResources(), drawableId);
//         }
//         else {
//             return bmp;
//         }
//     }
// 
//     public static Bitmap fetchImageBitmap(String uri) {
//         Bitmap imageData = null;
//         try {
//             InputStream is = (InputStream) new URL(uri).getContent();
//             imageData = BitmapFactory.decodeStream(is);
//         } catch (MalformedURLException e) {
//             throw new RuntimeException("Error processing url", e);
//         } catch (IOException e) {
//             throw new RuntimeException("Error fetching data from stream", e);
//         }
//         return imageData;
//     }
// 
// }


// Path: src/com/nitindhar/kampr/async/SnapTask.java
import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.widget.ImageView;
import com.nitindhar.forrst.model.Post;
import com.nitindhar.kampr.util.ImageUtils;

package com.nitindhar.kampr.async;



public class SnapTask extends AsyncTask<Post, Integer, Bitmap> {

    private final ImageView postOriginal;

    public SnapTask(ImageView postOriginal) {
        this.postOriginal = postOriginal;
    }

    @Override
    protected Bitmap doInBackground(Post... posts) {
        Bitmap snapBitmap = ImageUtils.fetchImageBitmap(posts[0].getSnap().getOriginalUrl());