From 4d891e7db56c823a7baefd94fd3fb4af8b485ea9 Mon Sep 17 00:00:00 2001 From: Dmitri Plotnikov Date: Wed, 22 Sep 2010 11:04:10 -0700 Subject: [PATCH] Making observer registration customizable. There is a need to skip registering the observer or register a different observer in cases when we have an extremely chatty content provider (think MediaStore). Change-Id: Iadfb8e0193736cb231762a147c2df1491ad22e0e --- api/current.xml | 15 +++++++++++++++ core/java/android/content/CursorLoader.java | 13 +++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/api/current.xml b/api/current.xml index 89e91cad37849..c43ebac2ff72a 100644 --- a/api/current.xml +++ b/api/current.xml @@ -46584,6 +46584,21 @@ + + + + + + { public Cursor loadInBackground() { Cursor cursor = getContext().getContentResolver().query(mUri, mProjection, mSelection, mSelectionArgs, mSortOrder); - // Ensure the cursor window is filled if (cursor != null) { + // Ensure the cursor window is filled cursor.getCount(); - cursor.registerContentObserver(mObserver); + registerContentObserver(cursor, mObserver); } return cursor; } + /** + * Registers an observer to get notifications from the content provider + * when the cursor needs to be refreshed. + */ + public void registerContentObserver(Cursor cursor, ContentObserver observer) { + cursor.registerContentObserver(mObserver); + } + /* Runs on the UI thread */ @Override public void deliverResult(Cursor cursor) {