Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.octo.android.robospice.spicelist;
 
 
This android.widget.ListView is optimized to display some content that contains image loaded from the network via RoboSpice. It uses a com.octo.android.robospice.spicelist.simple.SpiceArrayAdapter to hold data and create/update views. It can be instanciated programmatically or via XML. Basically, it will load images only when scrolling is stopped.

Author(s):
sni
public class SpiceListView extends ListView {
    // ----------------------------
    // --- CONSTRUCTORS
    // ----------------------------
    public SpiceListView(Context contextAttributeSet attrsint defStyle) {
        super(contextattrsdefStyle);
        initialize();
    }
    public SpiceListView(Context contextAttributeSet attrs) {
        super(contextattrs);
        initialize();
    }
    public SpiceListView(Context context) {
        super(context);
        initialize();
    }
    // ----------------------------
    // --- PUBLIC API
    // ----------------------------
    @Deprecated
    @Override
    public void setOnScrollListener(OnScrollListener l) {
        throw new RuntimeException("OnScrollListener is already used internally by a SpliceListView.");
    }
    @Override
    public void setAdapter(ListAdapter adapter) {
        if (!(adapter instanceof BaseSpiceArrayAdapter)) {
            throw new IllegalArgumentException("SpiceLists only support SpiceArrayAdapters.");
        }
        super.setAdapter(adapter);
    }
    @Override
    public BaseSpiceArrayAdapter<?> getAdapter() {
        return (BaseSpiceArrayAdapter<?>) super.getAdapter();
    }
    // ----------------------------
    // --- PRIVATE API
    // ----------------------------
    private void initialize() {
        super.setOnScrollListener(new SpiceListScrollListener());
    }
    // ----------------------------
    // --- INNER CLASS API
    // ----------------------------
    private final class SpiceListScrollListener implements OnScrollListener {
        @Override
        public void onScrollStateChanged(AbsListView viewint scrollState) {
            if (getAdapter() != null) {
                getAdapter().setNetworkFetchingAllowed(scrollState == );
            }
        }
        @Override
        public void onScroll(AbsListView viewint firstVisibleItemint visibleItemCountint totalItemCount) {
        }
    }
New to GrepCode? Check out our FAQ X