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

Commit 45ee872f authored by Makoto Onuki's avatar Makoto Onuki
Browse files

Don't send view notification before showing quick contact

Instead, do this in the second load.  This directly affects the quick contact
startup time.

Bug 6529921

Change-Id: Ief7bda9bd32cb4be0c86c4b79efb35da812721dc
parent ef4458a0
Loading
Loading
Loading
Loading
+13 −6
Original line number Diff line number Diff line
@@ -84,22 +84,25 @@ public class ContactLoader extends AsyncTaskLoader<ContactLoader.Result> {
    private boolean mLoadGroupMetaData;
    private boolean mLoadStreamItems;
    private boolean mLoadInvitableAccountTypes;
    private boolean mPostViewNotification;
    private Result mContact;
    private ForceLoadContentObserver mObserver;
    private final Set<Long> mNotifiedRawContactIds = Sets.newHashSet();

    public ContactLoader(Context context, Uri lookupUri) {
        this(context, lookupUri, false, false, false);
    public ContactLoader(Context context, Uri lookupUri, boolean postViewNotification) {
        this(context, lookupUri, false, false, false, postViewNotification);
    }

    public ContactLoader(Context context, Uri lookupUri, boolean loadGroupMetaData,
            boolean loadStreamItems, boolean loadInvitableAccountTypes) {
            boolean loadStreamItems, boolean loadInvitableAccountTypes,
            boolean postViewNotification) {
        super(context);
        mLookupUri = lookupUri;
        mRequestedUri = lookupUri;
        mLoadGroupMetaData = loadGroupMetaData;
        mLoadStreamItems = loadStreamItems;
        mLoadInvitableAccountTypes = loadInvitableAccountTypes;
        mPostViewNotification = postViewNotification;
    }

    /**
@@ -1236,9 +1239,11 @@ public class ContactLoader extends AsyncTaskLoader<ContactLoader.Result> {
                        mLookupUri, true, mObserver);
            }

            if (mPostViewNotification) {
                // inform the source of the data that this contact is being looked at
                postViewNotificationToSyncAdapter();
            }
        }

        super.deliverResult(mContact);
    }
@@ -1301,11 +1306,13 @@ public class ContactLoader extends AsyncTaskLoader<ContactLoader.Result> {
     */
    public void upgradeToFullContact() {
        // Everything requested already? Nothing to do, so let's bail out
        if (mLoadGroupMetaData && mLoadInvitableAccountTypes && mLoadStreamItems) return;
        if (mLoadGroupMetaData && mLoadInvitableAccountTypes && mLoadStreamItems
                && mPostViewNotification) return;

        mLoadGroupMetaData = true;
        mLoadInvitableAccountTypes = true;
        mLoadStreamItems = true;
        mPostViewNotification = true;

        // Cache the current result, so that we only load the "missing" parts of the contact.
        cacheResult();
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ public class ViewNotificationService extends Service {

        // We simply need to start a Loader here. When its done, it will send out the
        // View-Notification automatically.
        final ContactLoader contactLoader = new ContactLoader(this, intent.getData());
        final ContactLoader contactLoader = new ContactLoader(this, intent.getData(), true);
        contactLoader.registerListener(0, new OnLoadCompleteListener<ContactLoader.Result>() {
            @Override
            public void onLoadComplete(Loader<Result> loader, Result data) {
+1 −1
Original line number Diff line number Diff line
@@ -149,7 +149,7 @@ public class AttachPhotoActivity extends ContactsActivity {
    // although this is convenient, it isn't quite as robust as using LoaderManager... for
    // instance, the loader doesn't persist across Activity restarts.
    private void loadContact(Uri contactUri, final Listener listener) {
        final ContactLoader loader = new ContactLoader(this, contactUri);
        final ContactLoader loader = new ContactLoader(this, contactUri, true);
        loader.registerListener(0, new OnLoadCompleteListener<ContactLoader.Result>() {
            @Override
            public void onLoadComplete(
+2 −1
Original line number Diff line number Diff line
@@ -185,7 +185,8 @@ public class ContactLoaderFragment extends Fragment implements FragmentKeyListen
        public Loader<ContactLoader.Result> onCreateLoader(int id, Bundle args) {
            Uri lookupUri = args.getParcelable(LOADER_ARG_CONTACT_URI);
            return new ContactLoader(mContext, lookupUri, true /* loadGroupMetaData */,
                    true /* loadStreamItems */, true /* load invitable account types */);
                    true /* loadStreamItems */, true /* load invitable account types */,
                    true /* postViewNotification */);
        }

        @Override
+1 −1
Original line number Diff line number Diff line
@@ -1667,7 +1667,7 @@ public class ContactEditorFragment extends Fragment implements
        @Override
        public Loader<ContactLoader.Result> onCreateLoader(int id, Bundle args) {
            mLoaderStartTime = SystemClock.elapsedRealtime();
            return new ContactLoader(mContext, mLookupUri);
            return new ContactLoader(mContext, mLookupUri, true);
        }

        @Override
Loading