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
This commit is contained in:
@@ -27,6 +27,7 @@ import android.content.Intent;
|
|||||||
import android.inputmethodservice.KeyboardView;
|
import android.inputmethodservice.KeyboardView;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
import android.preference.PreferenceActivity;
|
import android.preference.PreferenceActivity;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
@@ -44,7 +45,6 @@ import android.widget.Button;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.TextView.OnEditorActionListener;
|
import android.widget.TextView.OnEditorActionListener;
|
||||||
|
|
||||||
|
|
||||||
public class ChooseLockPassword extends PreferenceActivity {
|
public class ChooseLockPassword extends PreferenceActivity {
|
||||||
public static final String PASSWORD_MIN_KEY = "lockscreen.password_min";
|
public static final String PASSWORD_MIN_KEY = "lockscreen.password_min";
|
||||||
public static final String PASSWORD_MAX_KEY = "lockscreen.password_max";
|
public static final String PASSWORD_MAX_KEY = "lockscreen.password_max";
|
||||||
@@ -98,10 +98,19 @@ public class ChooseLockPassword extends PreferenceActivity {
|
|||||||
private boolean mIsAlphaMode;
|
private boolean mIsAlphaMode;
|
||||||
private Button mCancelButton;
|
private Button mCancelButton;
|
||||||
private Button mNextButton;
|
private Button mNextButton;
|
||||||
private static Handler mHandler = new Handler();
|
|
||||||
private static final int CONFIRM_EXISTING_REQUEST = 58;
|
private static final int CONFIRM_EXISTING_REQUEST = 58;
|
||||||
static final int RESULT_FINISHED = RESULT_FIRST_USER;
|
static final int RESULT_FINISHED = RESULT_FIRST_USER;
|
||||||
private static final long ERROR_MESSAGE_TIMEOUT = 3000;
|
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.
|
* Keep track internally of where the user is in choosing a pattern.
|
||||||
@@ -234,6 +243,13 @@ public class ChooseLockPassword extends PreferenceActivity {
|
|||||||
mKeyboardView.requestFocus();
|
mKeyboardView.requestFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
mHandler.removeMessages(MSG_SHOW_ERROR);
|
||||||
|
|
||||||
|
super.onPause();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSaveInstanceState(Bundle outState) {
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
@@ -399,11 +415,9 @@ public class ChooseLockPassword extends PreferenceActivity {
|
|||||||
|
|
||||||
private void showError(String msg, final Stage next) {
|
private void showError(String msg, final Stage next) {
|
||||||
mHeaderText.setText(msg);
|
mHeaderText.setText(msg);
|
||||||
mHandler.postDelayed(new Runnable() {
|
Message mesg = mHandler.obtainMessage(MSG_SHOW_ERROR, next);
|
||||||
public void run() {
|
mHandler.removeMessages(MSG_SHOW_ERROR);
|
||||||
updateStage(next);
|
mHandler.sendMessageDelayed(mesg, ERROR_MESSAGE_TIMEOUT);
|
||||||
}
|
|
||||||
}, ERROR_MESSAGE_TIMEOUT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
|
Reference in New Issue
Block a user