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

Commit ab36b285 authored by kaiyiz's avatar kaiyiz Committed by Roman Birg
Browse files

Contacts: Do not observer DB change in MemberListActivity when it paused

While import SIM contacts in background, switching among PeopleActivity,
MemberListActivity and Luncher could cause lots of DB operations and data
change notifications. As a result, the screen will be frozen or dark
during these operations.

Do not observer DB change in MemberListActivity when it paused, since it
will requery in onResume.

CRs-Fixed: 659023

Change-Id: I02866b262c86a9dab4ecda5b7138020b2d035d5c
parent 484cb732
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -127,6 +127,8 @@ public class MemberListActivity extends TabActivity implements OnItemClickListen

    private DeleteMembersThread mDeleteMembersTask;

    private boolean mPaused = false;

    private Handler mUpdateUiHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
@@ -278,6 +280,14 @@ public class MemberListActivity extends TabActivity implements OnItemClickListen
        }
    };

    @Override
    protected void onPause() {
        super.onPause();

        mPaused = true;
        mAdapter.changeCursor(null);
    }

    public void onDestroy() {
        super.onDestroy();
        getContentResolver().unregisterContentObserver(observer);
@@ -316,6 +326,7 @@ public class MemberListActivity extends TabActivity implements OnItemClickListen
    @Override
    protected void onResume() {
        super.onResume();
        mPaused = false;
        startQuery();
    }

@@ -349,6 +360,9 @@ public class MemberListActivity extends TabActivity implements OnItemClickListen

        @Override
        protected void onQueryComplete(int token, Object cookie, Cursor cursor) {
            if (mPaused) {
                return;
            }
            final MemberListActivity activity = mActivity.get();
            activity.mAdapter.changeCursor(cursor);
            updateDisplay(cursor == null || cursor.getCount() == 0);