Re imageviewer issue
<p>The images from json are displayed in grid view as expected but when i click them only 2 images can be swiped through image viewer. I dont need to upload the images as in photoshare demo I just have to display all images in a gridview and then show them in imageviewer when clicked. I am having hard time to accomplish this. Below is the what I have done so far. </p>

<p><strong>ImageGallery form</strong></p>

<pre><code>@Override
protected void beforeImgGallery(Form f) {
    int iter = 0;
    GridLayout gr = new GridLayout(1, 2);
    Container grid = new Container(gr);
    GridLayout gr = new GridLayout(1, 2);
    grid.setScrollableY(true);
    grid.addComponent(new InfiniteProgress());
    f.addComponent(grid);
    createPictureCommand(grid);
}
</code></pre>

<p><strong>connectionRequest</strong> - here i dont need to update the image in server:</p>

<pre><code>private static boolean animating;
private Vector&lt;Map&lt;String, Object&gt;&gt; responsesgallery;
String[] galleryPhotoUrlCopy = new String[100];
int galleryIndex;

private void createPictureCommand(final Container grid) {
    ConnectionRequest mp = new ConnectionRequest() {
        private long key;

        @Override
        protected void readResponse(InputStream input) throws IOException {
            JSONParser p = new JSONParser();
            results = p.parse(new InputStreamReader(input));
            responsesgallery = (Vector&lt;Map&lt;String, Object&gt;&gt;) results.get("data");
            for (int i = 0; i &lt; responsesgallery.size(); i++) {
                Hashtable hm = (Hashtable) responsesgallery.get(i);
                String galleryImgId = (String) hm.get("news_id");

                String galleryPhotoUrl = (String) hm.get("photo");
                galleryPhotoUrlCopy[i] = galleryPhotoUrl;
                galleryIndex = i;
                key = (long) i;
                long[] img = {key};
                //problem lies in here
                imageList = new ImageList(img);

                final Button btn = createImageButton(key, grid, i, galleryPhotoUrl);
                imageList.addImageId(key);
                grid.addComponent(i, btn);
            }
        }

        @Override
        protected void postResponse() {
        }
    };
    mp.setUrl(SERVER_URL);
    NetworkManager.getInstance().addToQueueAndWait(mp);
}

Command createBackCommand(final Container viewerParent, final Container grid) {
    return new Command("Back") {
        @Override
        public void actionPerformed(ActionEvent evt) {
            viewerParent.getParent().replace(viewerParent, grid, CommonTransitions.createSlide(CommonTransitions.SLIDE_HORIZONTAL, true, 300));
            Form frm = Display.getInstance().getCurrent();
            frm.removeAllCommands();
            frm.setBackCommand(null);
        }
    };
}
</code></pre>

<p><strong>imagelist class</strong></p>

<pre><code>public static final String SERVER_URL = "http://capitaleyedevelopment.com/~admin/traffic/api/news/getLatestNews";
private static String THUMB_URL_PREFIX = SERVER_URL + "image?";

class ImageList implements ListModel&lt;Image&gt; {

    private int selection;
    private long[] imageIds;
    private EncodedImage[] images;
    private EventDispatcher listeners = new EventDispatcher();

    public void addImageId(long id) {
        long[] n = new long[imageIds.length + 1];
        EncodedImage[] nImages = new EncodedImage[n.length];
        System.arraycopy(imageIds, 0, n, 0, imageIds.length);
        System.arraycopy(images, 0, nImages, 0, images.length);
        n[imageIds.length] = id;
        imageIds = n;
        images = nImages;
        listeners.fireDataChangeEvent(-1, DataChangedListener.ADDED);
    }

    public long getSelectedImageId() {
        return imageIds[selection];
    }

    public ImageList(long[] images) {
        this.imageIds = images;
        this.images = new EncodedImage[images.length];
    }

    public Image getItemAt(int index) {
        System.out.println("index " + index);
        System.out.println("images[index] " + images[index]);
        if (images[index] == null) {
            images[index] = placeholder;
            Util.downloadUrlToStorageInBackground(galleryPhotoUrlCopy[index], "FullImage_" + imageIds[index], new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    try {
                        images[index] = EncodedImage.create(Storage.getInstance().createInputStream("FullImage_" + imageIds[index]));
                        listeners.fireDataChangeEvent(index, DataChangedListener.CHANGED);
                        System.out.println("bibek check in ");
                    } catch (IOException err) {
                        err.printStackTrace();
                    }
                }
            });
        }
        //            index = 3;
        return images[index];
    }

    public int getSize() {
        return imageIds.length;
    }

    public int getSelectedIndex() {
        return selection;
    }

    public void setSelectedIndex(int index) {
        WebServiceProxy.getPhotoLikesAsync(imageIds[selection], new Callback&lt;Integer&gt;() {
            public void onSucess(Integer value) {
                if (likeCount != null) {
                }
            }

            public void onError(Object sender, Throwable err, int errorCode, String errorMessage) {
            }
        });
        selection = index;
    }

    public void addDataChangedListener(DataChangedListener l) {
        listeners.addListener(l);
    }

    public void removeDataChangedListener(DataChangedListener l) {
        listeners.removeListener(l);
    }

    public void addSelectionListener(SelectionListener l) {
    }

    public void removeSelectionListener(SelectionListener l) {
    }

    public void addItem(Image item) {
    }

    public void removeItem(int index) {
    }
}
</code></pre>