Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4d891e7d authored by Dmitri Plotnikov's avatar Dmitri Plotnikov
Browse files

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
parent 5a08b50e
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -46584,6 +46584,21 @@
<parameter name="cursor" type="android.database.Cursor">
</parameter>
</method>
<method name="registerContentObserver"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="cursor" type="android.database.Cursor">
</parameter>
<parameter name="observer" type="android.database.ContentObserver">
</parameter>
</method>
<method name="setProjection"
 return="void"
 abstract="false"
+11 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.content;

import android.database.ContentObserver;
import android.database.Cursor;
import android.net.Uri;

@@ -37,14 +38,22 @@ public class CursorLoader extends AsyncTaskLoader<Cursor> {
    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) {