Code example for SparseIntArray

Methods: clear

0
     * Count of groups in the list. 
     */ 
    private int mGroupCount;
 
 
    private SparseIntArray mPositionCache = new SparseIntArray();
 
 
    /** 
     * A reusable temporary instance of PositionMetadata 
     */ 
    private PositionMetadata mPositionMetadata = new PositionMetadata();
 
    protected ContentObserver mChangeObserver = new ContentObserver(new Handler()) {
 
        @Override 
        public boolean deliverSelfNotifications() { 
            return true; 
        } 
 
        @Override 
        public void onChange(boolean selfChange) { 
            onContentChanged(); 
        } 
    }; 
 
    protected DataSetObserver mDataSetObserver = new DataSetObserver() {
 
        @Override 
        public void onChanged() { 
            notifyDataSetChanged(); 
        } 
 
        @Override 
        public void onInvalidated() { 
            notifyDataSetInvalidated(); 
        } 
    }; 
 
    public ShenduGroupingListAdapter(Context context) {
        mContext = context;
        resetCache(); 
    } 
 
    /** 
     * Finds all groups of adjacent items in the cursor and calls {@link #addGroup} for 
     * each of them. 
     */ 
    protected abstract void addGroups(Cursor cursor);
 
 
 
    protected abstract View newGroupView(Context context, ViewGroup parent);
    protected abstract void bindGroupView(View view, Context context, Cursor cursor);
 
 
 
    /** 
     * Cache should be reset whenever the cursor changes or groups are expanded or collapsed. 
     */ 
    private void resetCache() { 
        mCount = -1;
        mPositionMetadata.listPosition = -1;
        mPositionCache.clear();
    } 
 
    protected void onContentChanged() { 
    }