Search in sources :

Example 6 with RemoteImageView

use of com.github.ignition.core.widgets.RemoteImageView in project ignition by mttkay.

the class RemoteImageGalleryAdapter method getView.

// TODO: both convertView and ViewHolder are pointless at the moment, since there's a framework
// bug which causes views to not be cached in a Gallery widget:
// http://code.google.com/p/android/issues/detail?id=3376
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    String imageUrl = (String) getItem(position);
    ViewHolder viewHolder = null;
    RemoteImageView remoteImageView = null;
    if (convertView == null) {
        // create the image view
        remoteImageView = new RemoteImageView(context, null, progressDrawable, errorDrawable, false);
        FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
        lp.gravity = Gravity.CENTER;
        remoteImageView.setLayoutParams(lp);
        // create the container layout for the image view
        FrameLayout container = new FrameLayout(context);
        container.setLayoutParams(new Gallery.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
        container.addView(remoteImageView, 0);
        convertView = container;
        viewHolder = new ViewHolder();
        viewHolder.webImageView = remoteImageView;
        convertView.setTag(viewHolder);
    } else {
        viewHolder = (ViewHolder) convertView.getTag();
        remoteImageView = viewHolder.webImageView;
    }
    // calling reset is important to prevent old images from displaying in a recycled view.
    remoteImageView.reset();
    remoteImageView.setImageUrl(imageUrl);
    remoteImageView.loadImage();
    onGetView(position, remoteImageView, (ViewGroup) convertView, parent);
    return convertView;
}
Also used : LayoutParams(android.widget.Gallery.LayoutParams) RemoteImageView(com.github.ignition.core.widgets.RemoteImageView) FrameLayout(android.widget.FrameLayout) LayoutParams(android.widget.Gallery.LayoutParams) Gallery(android.widget.Gallery)

Aggregations

RemoteImageView (com.github.ignition.core.widgets.RemoteImageView)6 Test (org.junit.Test)3 Drawable (android.graphics.drawable.Drawable)2 Gallery (android.widget.Gallery)2 ViewGroup (android.view.ViewGroup)1 FrameLayout (android.widget.FrameLayout)1 LayoutParams (android.widget.Gallery.LayoutParams)1 RemoteImageGalleryAdapter (com.github.ignition.core.adapters.RemoteImageGalleryAdapter)1 TestShadowProgressBar (com.github.ignition.core.test.shadows.TestShadowProgressBar)1 RemoteImageLoader (com.github.ignition.support.images.remote.RemoteImageLoader)1