Moving some calls off the UI thread

This saves ~5ms in onNewIntent

Bug: 67305604
Change-Id: Ic97727b1c526e50bd3c8a1d8f511e1d7fd5e05e7
This commit is contained in:
Sunny Goyal
2017-10-02 12:45:10 -07:00
parent ec21a599f4
commit 326403e958
6 changed files with 105 additions and 39 deletions

View File

@@ -16,12 +16,16 @@
package com.android.launcher3;
import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.DragEvent;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import com.android.launcher3.util.UiThreadHelper;
/**
* The edit text that reports back when the back key has been pressed.
@@ -102,8 +106,7 @@ public class ExtendedEditText extends EditText {
}
public void dispatchBackKey() {
((InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE))
.hideSoftInputFromWindow(getWindowToken(), 0);
UiThreadHelper.hideKeyboardAsync(getContext(), getWindowToken());
if (mBackKeyListener != null) {
mBackKeyListener.onBackKey();
}
@@ -121,4 +124,17 @@ public class ExtendedEditText extends EditText {
public boolean isSuggestionsEnabled() {
return !mForceDisableSuggestions && super.isSuggestionsEnabled();
}
public void reset() {
if (!TextUtils.isEmpty(getText())) {
setText("");
}
if (isFocused()) {
View nextFocus = focusSearch(View.FOCUS_DOWN);
if (nextFocus != null) {
nextFocus.requestFocus();
}
}
UiThreadHelper.hideKeyboardAsync(getContext(), getWindowToken());
}
}