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

Commit 610a5555 authored by Bonian Chen's avatar Bonian Chen Committed by Automerger Merge Worker
Browse files

[Settings] Avoid from redraw UI when first time onResume am: 17ad56b3

Change-Id: I975397eb10ad3b4b0435dcfb71288425a15717e8
parents 09c4926e 17ad56b3
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings {
    private String mClickedPrefKey;

    private ActiveSubsciptionsListener mActiveSubsciptionsListener;
    private boolean mActiveSubsciptionsListenerStarting;
    private boolean mDropFirstSubscriptionChangeNotify;
    private int mActiveSubsciptionsListenerCount;

    public MobileNetworkSettings() {
@@ -207,20 +207,20 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings {
    public void onResume() {
        super.onResume();
        if (mActiveSubsciptionsListener == null) {
            mActiveSubsciptionsListenerStarting = true;
            mActiveSubsciptionsListener = new ActiveSubsciptionsListener(
                    getContext().getMainLooper(), getContext(), mSubId) {
                public void onChanged() {
                    onSubscriptionDetailChanged();
                }
            };
            mActiveSubsciptionsListenerStarting = false;
            mDropFirstSubscriptionChangeNotify = true;
        }
        mActiveSubsciptionsListener.start();
    }

    private void onSubscriptionDetailChanged() {
        if (mActiveSubsciptionsListenerStarting) {
        if (mDropFirstSubscriptionChangeNotify) {
            mDropFirstSubscriptionChangeNotify = false;
            Log.d(LOG_TAG, "Callback during onResume()");
            return;
        }
@@ -235,6 +235,14 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings {
        });
    }

    @Override
    public void onDestroy() {
        if (mActiveSubsciptionsListener != null) {
            mActiveSubsciptionsListener.stop();
        }
        super.onDestroy();
    }

    @VisibleForTesting
    void onRestoreInstance(Bundle icicle) {
        if (icicle != null) {