Java Code Examples for android.database.Cursor.unregisterDataSetObserver()

The following are Jave code examples for showing how to use unregisterDataSetObserver() of the android.database.Cursor class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: ActivityDiary   File: DetailRecyclerViewAdapter.java   Source Code and License Vote up 6 votes
public Cursor swapCursor(Cursor newCursor) {
    if (newCursor == mCursor) {
        return null;
    }
    final Cursor oldCursor = mCursor;
    if (oldCursor != null && mDataObserver != null) {
        oldCursor.unregisterDataSetObserver(mDataObserver);
    }
    mCursor = newCursor;
    if (mCursor != null) {
        if (mDataObserver != null) {
            mCursor.registerDataSetObserver(mDataObserver);
        }
        uriRowIdx = mCursor.getColumnIndex(ActivityDiaryContract.DiaryImage.URI);
        idRowIdx = mCursor.getColumnIndex(ActivityDiaryContract.DiaryImage._ID);
        notifyDataSetChanged();
    } else {
        uriRowIdx = -1;
        idRowIdx = -1;
        notifyDataSetChanged();
    }
    return oldCursor;
}
 
Example 2
Project: ActivityDiary   File: HistoryRecyclerViewAdapter.java   Source Code and License Vote up 6 votes
public Cursor swapCursor(Cursor newCursor) {
    if (newCursor == mCursor) {
        return null;
    }
    final Cursor oldCursor = mCursor;
    if (oldCursor != null && mDataObserver != null) {
        oldCursor.unregisterDataSetObserver(mDataObserver);
    }
    mCursor = newCursor;
    if (mCursor != null) {
        if (mDataObserver != null) {
            mCursor.registerDataSetObserver(mDataObserver);
        }
        setRowIndex();
        notifyDataSetChanged();
    } else {
        idRowIdx = -1;
        notifyDataSetChanged();
    }
    return oldCursor;
}
 
Example 3
Project: multiselect   File: CursorRVAdpater.java   Source Code and License Vote up 6 votes
/**
 * Swap in a new Cursor, returning the old Cursor.  Unlike
 * {@link #changeCursor(Cursor)}, the returned old Cursor is <em>not</em>
 * closed.
 */
public Cursor swapCursor(Cursor newCursor) {
    if (newCursor == myCursor) {
        return null;
    }
    final Cursor oldCursor = myCursor;
    if (oldCursor != null && mDataSetObserver != null) {
        oldCursor.unregisterDataSetObserver(mDataSetObserver);
    }
    myCursor = newCursor;
    if (myCursor != null) {
        if (mDataSetObserver != null) {
            myCursor.registerDataSetObserver(mDataSetObserver);
        }
        mYRowIdCol = newCursor.getColumnIndexOrThrow("_id");
        isValidData = true;
        notifyDataSetChanged();
    } else {
        mYRowIdCol = -1;
        isValidData = false;
        notifyDataSetChanged();
        //There is no notifyDataSetInvalidated() method in RecyclerView.Adapter
    }
    return oldCursor;
}
 
Example 4
Project: PeSanKita-android   File: CursorRecyclerViewAdapter.java   Source Code and License Vote up 6 votes
public Cursor swapCursor(Cursor newCursor) {
  if (newCursor == cursor) {
    return null;
  }

  final Cursor oldCursor = cursor;
  if (oldCursor != null) {
    oldCursor.unregisterDataSetObserver(observer);
  }

  cursor = newCursor;
  if (cursor != null) {
    cursor.registerDataSetObserver(observer);
  }

  valid = cursor != null;
  notifyDataSetChanged();
  return oldCursor;
}
 
Example 5
Project: easyfilemanager   File: CursorRecyclerViewAdapter.java   Source Code and License Vote up 6 votes
/**
 * Swap in a new Cursor, returning the old Cursor.  Unlike
 * {@link #changeCursor(Cursor)}, the returned old Cursor is <em>not</em>
 * closed.
 */
public Cursor swapCursor(Cursor newCursor) {
    if (newCursor == mCursor) {
        return null;
    }
    final Cursor oldCursor = mCursor;
    if (oldCursor != null && mDataSetObserver != null) {
        oldCursor.unregisterDataSetObserver(mDataSetObserver);
    }
    mCursor = newCursor;
    if (mCursor != null) {
        if (mDataSetObserver != null) {
            mCursor.registerDataSetObserver(mDataSetObserver);
        }
        mRowIdColumn = newCursor.getColumnIndex(DocumentsContract.Document.COLUMN_DOCUMENT_ID);
        mDataValid = true;
        notifyDataSetChanged();
    } else {
        mRowIdColumn = -1;
        mDataValid = false;
        notifyDataSetChanged();
        //There is no notifyDataSetInvalidated() method in RecyclerView.Adapter
    }
    return oldCursor;
}
 
Example 6
Project: mdb-android-application   File: CursorRecyclerViewAdapter.java   Source Code and License Vote up 6 votes
/**
 * Swap in a new Cursor, returning the old Cursor.  Unlike
 * {@link #changeCursor(Cursor)}, the returned old Cursor is <em>not</em>
 * closed.
 */
public Cursor swapCursor(Cursor newCursor) {
    if (newCursor == mCursor) {
        return null;
    }
    final Cursor oldCursor = mCursor;
    if (oldCursor != null && mDataSetObserver != null) {
        oldCursor.unregisterDataSetObserver(mDataSetObserver);
    }
    mCursor = newCursor;
    if (mCursor != null) {
        if (mDataSetObserver != null) {
            mCursor.registerDataSetObserver(mDataSetObserver);
        }
        mRowIdColumn = newCursor.getColumnIndexOrThrow("_id");
        mDataValid = true;
        notifyDataSetChanged();
    } else {
        mRowIdColumn = -1;
        mDataValid = false;
        notifyDataSetChanged();
        //There is no notifyDataSetInvalidated() method in RecyclerView.Adapter
    }
    return oldCursor;
}
 
Example 7
Project: FuelUp   File: RecyclerViewCursorAdapter.java   Source Code and License Vote up 6 votes
public void swapCursor(Cursor newCursor)
{
    if(newCursor == mCursor){
        return;
    }
    Cursor oldCursor = mCursor;
    if(oldCursor != null){
        if(mDataSetObserver != null){
            oldCursor.unregisterDataSetObserver(mDataSetObserver);
        }
    }
    mCursor = newCursor;
    if(newCursor != null){
        if(mDataSetObserver != null){
            newCursor.registerDataSetObserver(mDataSetObserver);
        }
        mRowIDColumn = newCursor.getColumnIndexOrThrow("_id");
        mDataValid = true;
        notifyDataSetChanged();
    }
    else{
        mRowIDColumn = -1;
        mDataValid = false;
        notifyDataSetChanged();
    }
}
 
Example 8
Project: IslamicLibraryAndroid   File: TableOfContentRecyclerViewAdapter.java   Source Code and License Vote up 6 votes
/**
 * Swap in a new Cursor, returning the old Cursor.  Unlike
 * {@link #changeCursor(Cursor)}, the returned old Cursor is <em>not</em>
 * closed.
 */
public Cursor swapCursor(Cursor newCursor) {
    if (newCursor == mCursor) {
        return null;
    }
    final Cursor oldCursor = mCursor;
    if (oldCursor != null && mDataSetObserver != null) {
        oldCursor.unregisterDataSetObserver(mDataSetObserver);
    }
    mCursor = newCursor;
    if (mCursor != null) {
        if (mDataSetObserver != null) {
            mCursor.registerDataSetObserver(mDataSetObserver);
        }
        mDataValid = true;
        notifyDataSetChanged();
    } else {
        mRowIdColumn = -1;
        mDataValid = false;
        notifyDataSetChanged();
        //There is no notifyDataSetInvalidated() method in RecyclerView.Adapter
    }
    return oldCursor;
}
 
Example 9
Project: IslamicLibraryAndroid   File: AuthorRecyclerViewAdapter.java   Source Code and License Vote up 6 votes
/**
 * Swap in a new Cursor, returning the old Cursor.  Unlike
 * {@link #changeCursor(Cursor)}, the returned old Cursor is <em>not</em>
 * closed.
 */
public Cursor swapCursor(Cursor newCursor) {
    if (newCursor == mCursor) {
        return null;
    }
    final Cursor oldCursor = mCursor;
    if (oldCursor != null && mDataSetObserver != null) {
        oldCursor.unregisterDataSetObserver(mDataSetObserver);
    }
    mCursor = newCursor;
    if (mCursor != null) {
        if (mDataSetObserver != null) {
            mCursor.registerDataSetObserver(mDataSetObserver);
        }
        itemCount = newCursor.getCount();
        notifyDataSetChanged();
    } else {
        mRowIdColumn = -1;
        notifyDataSetChanged();
        //There is no notifyDataSetInvalidated() method in RecyclerView.Adapter
    }
    return oldCursor;
}
 
Example 10
Project: FireFiles   File: CursorRecyclerViewAdapter.java   Source Code and License Vote up 6 votes
/**
 * Swap in a new Cursor, returning the old Cursor.  Unlike
 * {@link #changeCursor(Cursor)}, the returned old Cursor is <em>not</em>
 * closed.
 */
public Cursor swapCursor(Cursor newCursor) {
    if (newCursor == mCursor) {
        return null;
    }
    final Cursor oldCursor = mCursor;
    if (oldCursor != null && mDataSetObserver != null) {
        oldCursor.unregisterDataSetObserver(mDataSetObserver);
    }
    mCursor = newCursor;
    if (mCursor != null) {
        if (mDataSetObserver != null) {
            mCursor.registerDataSetObserver(mDataSetObserver);
        }
        mRowIdColumn = newCursor.getColumnIndex(DocumentsContract.Document.COLUMN_DOCUMENT_ID);
        mDataValid = true;
        notifyDataSetChanged();
    } else {
        mRowIdColumn = -1;
        mDataValid = false;
        notifyDataSetChanged();
        //There is no notifyDataSetInvalidated() method in RecyclerView.Adapter
    }
    return oldCursor;
}
 
Example 11
Project: simple-share-android   File: CursorRecyclerViewAdapter.java   Source Code and License Vote up 6 votes
/**
 * Swap in a new Cursor, returning the old Cursor.  Unlike
 * {@link #changeCursor(Cursor)}, the returned old Cursor is <em>not</em>
 * closed.
 */
public Cursor swapCursor(Cursor newCursor) {
    if (newCursor == mCursor) {
        return null;
    }
    final Cursor oldCursor = mCursor;
    if (oldCursor != null && mDataSetObserver != null) {
        oldCursor.unregisterDataSetObserver(mDataSetObserver);
    }
    mCursor = newCursor;
    if (mCursor != null) {
        if (mDataSetObserver != null) {
            mCursor.registerDataSetObserver(mDataSetObserver);
        }
        mRowIdColumn = newCursor.getColumnIndex(DocumentsContract.Document.COLUMN_DOCUMENT_ID);
        mDataValid = true;
        notifyDataSetChanged();
    } else {
        mRowIdColumn = -1;
        mDataValid = false;
        notifyDataSetChanged();
        //There is no notifyDataSetInvalidated() method in RecyclerView.Adapter
    }
    return oldCursor;
}
 
Example 12
Project: Cable-Android   File: CursorRecyclerViewAdapter.java   Source Code and License Vote up 6 votes
public Cursor swapCursor(Cursor newCursor) {
  if (newCursor == cursor) {
    return null;
  }

  final Cursor oldCursor = cursor;
  if (oldCursor != null) {
    oldCursor.unregisterDataSetObserver(observer);
  }

  cursor = newCursor;
  if (cursor != null) {
    cursor.registerDataSetObserver(observer);
  }

  valid = cursor != null;
  notifyDataSetChanged();
  return oldCursor;
}
 
Example 13
Project: SuperSelector   File: RecyclerViewCursorAdapter.java   Source Code and License Vote up 5 votes
/**
     * Swap in a new Cursor, returning the old Cursor.  Unlike
     * {@link #changeCursor(Cursor)}, the returned old Cursor is <em>not</em>
     * closed.
     *
     * @param newCursor The new cursor to be used.
     * @return Returns the previously set Cursor, or null if there wasa not one.
     * If the given new Cursor is the same instance is the previously set
     * Cursor, null is also returned.
     */
    public Cursor swapCursor(Cursor newCursor) {
        if (newCursor == mCursor) {
            return null;
        }
        Cursor oldCursor = mCursor;
        if (oldCursor != null) {
            if (mChangeObserver != null) oldCursor.unregisterContentObserver(mChangeObserver);
            if (mDataSetObserver != null) oldCursor.unregisterDataSetObserver(mDataSetObserver);
        }
        mCursor = newCursor;
        if (newCursor != null) {
            if (mChangeObserver != null) newCursor.registerContentObserver(mChangeObserver);
            if (mDataSetObserver != null) newCursor.registerDataSetObserver(mDataSetObserver);
            mRowIDColumn = newCursor.getColumnIndexOrThrow("_id");
            mDataValid = true;
            // notify the observers about the new cursor
            notifyDataSetChanged();
        } else {
            mRowIDColumn = -1;
            mDataValid = false;
            // notify the observers about the lack of a data set
            notifyDataSetChanged();
//            notifyDataSetInvalidated();
        }
        return oldCursor;
    }
 
Example 14
Project: letv   File: CursorAdapter.java   Source Code and License Vote up 5 votes
public Cursor swapCursor(Cursor newCursor) {
    if (newCursor == this.mCursor) {
        return null;
    }
    Cursor oldCursor = this.mCursor;
    if (oldCursor != null) {
        if (this.mChangeObserver != null) {
            oldCursor.unregisterContentObserver(this.mChangeObserver);
        }
        if (this.mDataSetObserver != null) {
            oldCursor.unregisterDataSetObserver(this.mDataSetObserver);
        }
    }
    this.mCursor = newCursor;
    if (newCursor != null) {
        if (this.mChangeObserver != null) {
            newCursor.registerContentObserver(this.mChangeObserver);
        }
        if (this.mDataSetObserver != null) {
            newCursor.registerDataSetObserver(this.mDataSetObserver);
        }
        this.mRowIDColumn = newCursor.getColumnIndexOrThrow("_id");
        this.mDataValid = true;
        notifyDataSetChanged();
        return oldCursor;
    }
    this.mRowIDColumn = -1;
    this.mDataValid = false;
    notifyDataSetInvalidated();
    return oldCursor;
}
 
Example 15
Project: letv   File: CursorAdapter.java   Source Code and License Vote up 5 votes
public Cursor swapCursor(Cursor newCursor) {
    if (newCursor == this.mCursor) {
        return null;
    }
    Cursor oldCursor = this.mCursor;
    if (oldCursor != null) {
        if (this.mChangeObserver != null) {
            oldCursor.unregisterContentObserver(this.mChangeObserver);
        }
        if (this.mDataSetObserver != null) {
            oldCursor.unregisterDataSetObserver(this.mDataSetObserver);
        }
    }
    this.mCursor = newCursor;
    if (newCursor != null) {
        if (this.mChangeObserver != null) {
            newCursor.registerContentObserver(this.mChangeObserver);
        }
        if (this.mDataSetObserver != null) {
            newCursor.registerDataSetObserver(this.mDataSetObserver);
        }
        this.mRowIDColumn = newCursor.getColumnIndexOrThrow("_id");
        this.mDataValid = true;
        notifyDataSetChanged();
        return oldCursor;
    }
    this.mRowIDColumn = -1;
    this.mDataValid = false;
    notifyDataSetInvalidated();
    return oldCursor;
}
 
Example 16
Project: IslamicLibraryAndroid   File: BookListRecyclerViewAdapter.java   Source Code and License Vote up 5 votes
/**
 * Swap in a new Cursor, returning the old Cursor.  Unlike
 * {@link #changeCursor(Cursor)}, the returned old Cursor is <em>not</em>
 * closed.
 */
public Cursor swapCursor(Cursor newCursor) {
    if (newCursor == mCursor) {
        return null;
    }
    final Cursor oldCursor = mCursor;
    if (oldCursor != null && mDataSetObserver != null) {
        oldCursor.unregisterDataSetObserver(mDataSetObserver);
    }
    mCursor = newCursor;
    if (mCursor != null) {
        if (mDataSetObserver != null) {
            mCursor.registerDataSetObserver(mDataSetObserver);

        }
        itemCount = newCursor.getCount();
        //   mRowIdColumn = newCursor.getColumnIndexOrThrow("_id");
        mDataValid = true;
        notifyDataSetChanged();
    } else {
        mRowIdColumn = -1;
        mDataValid = false;
        notifyDataSetChanged();
        //There is no notifyDataSetInvalidated() method in RecyclerView.Adapter
    }
    return oldCursor;
}
 
Example 17
Project: boohee_v5.6   File: CursorAdapter.java   Source Code and License Vote up 5 votes
public Cursor swapCursor(Cursor newCursor) {
    if (newCursor == this.mCursor) {
        return null;
    }
    Cursor oldCursor = this.mCursor;
    if (oldCursor != null) {
        if (this.mChangeObserver != null) {
            oldCursor.unregisterContentObserver(this.mChangeObserver);
        }
        if (this.mDataSetObserver != null) {
            oldCursor.unregisterDataSetObserver(this.mDataSetObserver);
        }
    }
    this.mCursor = newCursor;
    if (newCursor != null) {
        if (this.mChangeObserver != null) {
            newCursor.registerContentObserver(this.mChangeObserver);
        }
        if (this.mDataSetObserver != null) {
            newCursor.registerDataSetObserver(this.mDataSetObserver);
        }
        this.mRowIDColumn = newCursor.getColumnIndexOrThrow("_id");
        this.mDataValid = true;
        notifyDataSetChanged();
        return oldCursor;
    }
    this.mRowIDColumn = -1;
    this.mDataValid = false;
    notifyDataSetInvalidated();
    return oldCursor;
}
 
Example 18
Project: News24x7-news-from-every-part-of-the-world   File: CursorRecyclerViewAdapter.java   Source Code and License Vote up 5 votes
/**
 * Swap in a new Cursor, returning the old Cursor.  Unlike
 * {@link #changeCursor(Cursor)}, the returned old Cursor is <em>not</em>
 * closed.
 *
 * @param newCursor The new cursor to be used.
 * @return Returns the previously set Cursor, or null if there wasa not one.
 * If the given new Cursor is the same instance is the previously set
 * Cursor, null is also returned.
 */
public Cursor swapCursor(Cursor newCursor) {
    if (newCursor == mCursor) {
        return null;
    }
    Cursor oldCursor = mCursor;
    if (oldCursor != null) {
        if (mChangeObserver != null) oldCursor.unregisterContentObserver(mChangeObserver);
        if (mDataSetObserver != null) oldCursor.unregisterDataSetObserver(mDataSetObserver);
    }
    mCursor = newCursor;
    if (newCursor != null) {
        if (mChangeObserver != null) newCursor.registerContentObserver(mChangeObserver);
        if (mDataSetObserver != null) newCursor.registerDataSetObserver(mDataSetObserver);
        mRowIDColumn = newCursor.getColumnIndexOrThrow("_id");
        mDataValid = true;
        // notify the observers about the new cursor
        notifyDataSetChanged();
    } else {
        mRowIDColumn = -1;
        mDataValid = false;
        // notify the observers about the lack of a data set
        // notifyDataSetInvalidated();
        notifyItemRangeRemoved(0, oldCursor.getCount());
    }
    return oldCursor;
}
 
Example 19
Project: Ocr-android   File: BaseRecyclerCursorAdapter.java   Source Code and License Vote up 5 votes
/**
     * Swap in a new Cursor, returning the old Cursor.  Unlike
     * {@link #changeCursor(Cursor)}, the returned old Cursor is <em>not</em>
     * closed.
     *
     * @param newCursor The new cursor to be used.
     * @return Returns the previously set Cursor, or null if there wasa not one.
     * If the given new Cursor is the same instance is the previously set
     * Cursor, null is also returned.
     */
    public Cursor swapCursor(Cursor newCursor) {
        if (newCursor == mCursor) {
            return null;
        }
        Cursor oldCursor = mCursor;
        if (oldCursor != null) {
            if (mChangeObserver != null) {
                oldCursor.unregisterContentObserver(mChangeObserver);
            }
            if (mDataSetObserver != null) {
                oldCursor.unregisterDataSetObserver(mDataSetObserver);
            }
        }
        mCursor = newCursor;
        if (newCursor != null) {
            if (mChangeObserver != null) {
                newCursor.registerContentObserver(mChangeObserver);
            }
            if (mDataSetObserver != null) {
                newCursor.registerDataSetObserver(mDataSetObserver);
            }
            mRowIDColumn = newCursor.getColumnIndexOrThrow("_id");
            mDataValid = true;
            // notify the observers about the new cursor
            notifyDataSetChanged();
        } else {
            mRowIDColumn = -1;
            mDataValid = false;
            // notify the observers about the lack of a data set
            notifyDataSetChanged();
//            notifyDataSetInvalidated();
        }
        return oldCursor;
    }
 
Example 20
Project: q-mail   File: MergeCursor.java   Source Code and License Vote up 4 votes
@Override
public void unregisterDataSetObserver(DataSetObserver observer) {
    for (Cursor cursor : mCursors) {
        cursor.unregisterDataSetObserver(observer);
    }
}