Code example for SimpleCursorAdapter

Methods: notifyDataSetChanged, notifyDataSetInvalidated, swapCursor

0
    } 
 
    private void setIndeterminateLoading(boolean isLoading) {
        if (isLoading != mShowIndeterminate) {
            mShowIndeterminate = isLoading;
            notifyDataSetInvalidated();
            notifyDataSetChanged();
        } 
    } 
 
    @Override 
    public int getCount() { 
        if (mShowIndeterminate) {
            return 1; 
        } else { 
            return super.getCount(); 
        } 
    } 
 
    @Override 
    public View getView(int position, View convertView, ViewGroup parent) {
        final boolean convertViewIsProgressBar = convertView != null
                && convertView.getId() == R.id.progress;
 
        if (mShowIndeterminate) {
            if (convertViewIsProgressBar) {
                return convertView;
            } 
 
            if (mIndeterminate == null) {
                mIndeterminate = LayoutInflater.from(mContext).inflate(R.layout.list_loading,
                        parent, false);
            } 
 
            return mIndeterminate;
 
        } else { 
            // ensure that we don't reuse the indeterminate progress bar as a 
            // real view 
            if (convertViewIsProgressBar) {
                convertView = null;
            } 
            return super.getView(position, convertView, parent);
        } 
    } 
 
    @Override 
    public Cursor swapCursor(Cursor c) {
        setIndeterminateLoading(c == null || isNotShowingExpectedCount(c));
        return super.swapCursor(c);
    } 
 
    @Override 
    public void changeCursor(Cursor cursor) {
        super.changeCursor(cursor);