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

Commit 552bc61a authored by Amith Yamasani's avatar Amith Yamasani
Browse files

Remove pending message when fragment is paused.

Bug: 5422788

Converted the runnable to a message and removed any pending messages in onPause.

Change-Id: I048413ae2abd69a359b1fa2c648d98df3c3ae343
parent 3f28ff1a
Loading
Loading
Loading
Loading
+21 −7
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.content.Intent;
import android.inputmethodservice.KeyboardView;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.preference.PreferenceActivity;
import android.text.Editable;
import android.text.InputType;
@@ -44,7 +45,6 @@ import android.widget.Button;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;


public class ChooseLockPassword extends PreferenceActivity {
    public static final String PASSWORD_MIN_KEY = "lockscreen.password_min";
    public static final String PASSWORD_MAX_KEY = "lockscreen.password_max";
@@ -98,10 +98,19 @@ public class ChooseLockPassword extends PreferenceActivity {
        private boolean mIsAlphaMode;
        private Button mCancelButton;
        private Button mNextButton;
        private static Handler mHandler = new Handler();
        private static final int CONFIRM_EXISTING_REQUEST = 58;
        static final int RESULT_FINISHED = RESULT_FIRST_USER;
        private static final long ERROR_MESSAGE_TIMEOUT = 3000;
        private static final int MSG_SHOW_ERROR = 1;

        private Handler mHandler = new Handler() {
            @Override
            public void handleMessage(Message msg) {
                if (msg.what == MSG_SHOW_ERROR) {
                    updateStage((Stage) msg.obj);
                }
            }
        };

        /**
         * Keep track internally of where the user is in choosing a pattern.
@@ -234,6 +243,13 @@ public class ChooseLockPassword extends PreferenceActivity {
            mKeyboardView.requestFocus();
        }

        @Override
        public void onPause() {
            mHandler.removeMessages(MSG_SHOW_ERROR);

            super.onPause();
        }

        @Override
        public void onSaveInstanceState(Bundle outState) {
            super.onSaveInstanceState(outState);
@@ -399,11 +415,9 @@ public class ChooseLockPassword extends PreferenceActivity {

        private void showError(String msg, final Stage next) {
            mHeaderText.setText(msg);
            mHandler.postDelayed(new Runnable() {
                public void run() {
                    updateStage(next);
                }
            }, ERROR_MESSAGE_TIMEOUT);
            Message mesg = mHandler.obtainMessage(MSG_SHOW_ERROR, next);
            mHandler.removeMessages(MSG_SHOW_ERROR);
            mHandler.sendMessageDelayed(mesg, ERROR_MESSAGE_TIMEOUT);
        }

        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {