Passing ArrayList<Bitmap> into another class and convert to Bitmap[]
===

I fetch the image URL from my PHP and MySQL database. Everything here is fine, because the `Log.d` shows the result with a valid image URL.


    if (success == 1) {
        JSONArray comments = json.getJSONArray("photos");
        for (int i = 0; i < comments.length(); i++) {
            JSONObject m = comments.getJSONObject(i);
            final String filename = m.getString("filename");
            final String extension = m.getString("extension");
            String upload_at = m.getString("upload_at");
            String uid = m.getString("uid");
            
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    Bitmap mThumbIds = fetchImage(filepath_min
                    + filename + "." + extension);
		    Log.d("Photo URL", filepath_min + filename + "." + extension);
                    List<Bitmap> l = Arrays.asList(mThumbIds);
                    photoList = new ArrayList<Bitmap>(l);
                }
            });
        }
    }
    
    // Instance of ImageAdapter Class
    mHandler.postDelayed((new Runnable() {
        public void run() {
            imgGrid.setAdapter(new ImageAdapter(
            PhotoViewerActivity.this, photoList));
        }
    }), 1000);

<br>

Below this for fetch an image from the given URL and return as Bitmap.
Nothing problem here, just for reference want to show that the return is Bitmap.


    public Bitmap fetchImage(String urlstr) {
        try {
            URL url;
            url = new URL(urlstr);
            
            HttpURLConnection c = (HttpURLConnection) url.openConnection();
            c.setDoInput(true);
            c.connect();
            InputStream is = c.getInputStream();
            Bitmap img;
            img = BitmapFactory.decodeStream(is);
            return img;
            } catch (MalformedURLException e) {
            Log.d("RemoteImageHandler", "fetchImage passed invalid URL: "
            + urlstr);
            } catch (IOException e) {
            Log.d("RemoteImageHandler", "fetchImage IO exception: " + e);
        }
        return null;
    }


<br>

This is my ImageAdapter for viewing image in GridView.


    public class ImageAdapter extends BaseAdapter {
        private Context mContext;
        List<Bitmap> list = new ArrayList<Bitmap> l;
        
        public ImageAdapter(Context c, ArrayList<Bitmap> l) {
            mContext = c;
            list = l;
        }
        
        public Bitmap[] mThumbIds = list.toArray(new Bitmap[list.size()]);
        
        @Override
        public int getCount() {
            return mThumbIds.length;
        }
        
        @Override
        public Object getItem(int position) {
            return mThumbIds[position];
        }
        
        @Override
        public long getItemId(int position) {
            return 0;
        }
        
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            ImageView imageView = new ImageView(mContext);
            imageView.setImageBitmap(mThumbIds[position]);
            imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
            imageView.setLayoutParams(new GridView.LayoutParams(130, 130));
            return imageView;
        }
        
    }

<br>


Here is my problem. None image shown on the activity.
When I try hardcoded URL with fetch array in Bitmap[] mThumbIds, its was success.

    Bitmap[] mThumbIds = { fetchImage("http://...jpg"),
                           fetchImage("http://...jpg") }

I don't know what's wrong. I've tried `Bitmap[] mThumbIds = list.toArray(new Bitmap[list.size()]);` to convert ArrayList to Array.
<br>