Universal Image Loader - Add new image from data or Uri
<p>I'm using Universal Image Loader in my app for show images saved in a DDBB, I get URIs using JSON and then I create the array. All works fine, but I need to add new images. I added a button in the layout to launch camera, then I get the new picture and save it in DDBB fine. Just, I need to "say" to Pager that I added a new picture, without refresh the instance. How can I do that guys?</p>

<p>Thanks!</p>

<p><strong>ImagePagerAdapter</strong>:</p>

<pre><code>private class ImagePagerAdapter extends PagerAdapter {

    private String[] images;
    private LayoutInflater inflater;

    ImagePagerAdapter(String[] images) {
        this.images = images;
        inflater = getLayoutInflater();
    }

    @Override
    public void destroyItem(View container, int position, Object object) {
        ((ViewPager) container).removeView((View) object);
    }

    @Override
    public void finishUpdate(View container) {
    }

    @Override
    public int getCount() {
        return images.length;
    }

    @Override
    public Object instantiateItem(View view, int position) {
        final View imageLayout = inflater.inflate(
                R.layout.item_pager_image, null);
        final ImageView imageView = (ImageView) imageLayout
                .findViewById(R.id.image);
        final ProgressBar spinner = (ProgressBar) imageLayout
                .findViewById(R.id.loading);

        imageLoader.displayImage(images[position], imageView, options,
                new ImageLoadingListener() {
                    @Override
                    public void onLoadingStarted() {
                        spinner.setVisibility(View.VISIBLE);
                    }

                    @Override
                    public void onLoadingFailed(FailReason failReason) {
                        String message = null;
                        switch (failReason) {
                        case IO_ERROR:
                            message = "Input/Output error";
                            break;
                        case OUT_OF_MEMORY:
                            message = "Out Of Memory error";
                            break;
                        case UNKNOWN:
                            message = "Unknown error";
                            break;
                        }
                        Toast.makeText(SingleMenuItemActivity.this, message,
                                Toast.LENGTH_SHORT).show();

                        spinner.setVisibility(View.GONE);
                        imageView
                                .setImageResource(android.R.drawable.ic_delete);
                    }

                    @Override
                    public void onLoadingComplete(Bitmap loadedImage) {
                        spinner.setVisibility(View.GONE);
                        Animation anim = AnimationUtils.loadAnimation(
                                SingleMenuItemActivity.this, R.anim.fade_in);
                        imageView.setAnimation(anim);
                        anim.start();
                    }

                    @Override
                    public void onLoadingCancelled() {
                        // Do nothing
                    }
                });

        ((ViewPager) view).addView(imageLayout, 0);
        return imageLayout;
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view.equals(object);
    }

    @Override
    public void restoreState(Parcelable state, ClassLoader loader) {
    }

    @Override
    public Parcelable saveState() {
        return null;
    }

    @Override
    public void startUpdate(View container) {
    }
}
</code></pre>

<p><strong>onActivityResult</strong>: (Camera)</p>

<pre><code>protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) {
        if (resultCode == RESULT_OK) {
            addImage(data);
        } else if (resultCode == RESULT_CANCELED) {
            Toast.makeText(this, "Acción cancelada", Toast.LENGTH_LONG).show();
        } else {
            Toast.makeText(this, "Ha ocurrido un error al obtener la imagen", Toast.LENGTH_LONG).show();
        }
    }
}
</code></pre>

<p><strong>addImage</strong>:</p>

<pre><code>protected void addImage(Intent data) {
    [Add image to DDBB]

    if(entity1 != null&amp;&amp;(response.getStatusLine().getStatusCode()==201||response.getStatusLine().getStatusCode()==200))
    {
        Here I need to do something to add new image to Pager
    }
    else
    {
        Toast.makeText(this, "Ha ocurrido un error al cargar la foto", Toast.LENGTH_LONG).show();
    }
}
</code></pre>
