diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2017-10-02 12:45:10 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2017-10-02 14:50:09 -0700 |
commit | 326403e958344751539cefec62ecbc6d28abd2ce (patch) | |
tree | f85bf31497e8addcc28542990d897cb234b5fb0d /src/com/android/launcher3/ExtendedEditText.java | |
parent | ec21a599f4cf68c74a2f7aad6797c0ba6d7409ad (diff) | |
download | packages_apps_Trebuchet-326403e958344751539cefec62ecbc6d28abd2ce.tar.gz packages_apps_Trebuchet-326403e958344751539cefec62ecbc6d28abd2ce.tar.bz2 packages_apps_Trebuchet-326403e958344751539cefec62ecbc6d28abd2ce.zip |
Moving some calls off the UI thread
This saves ~5ms in onNewIntent
Bug: 67305604
Change-Id: Ic97727b1c526e50bd3c8a1d8f511e1d7fd5e05e7
Diffstat (limited to 'src/com/android/launcher3/ExtendedEditText.java')
-rw-r--r-- | src/com/android/launcher3/ExtendedEditText.java | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/com/android/launcher3/ExtendedEditText.java b/src/com/android/launcher3/ExtendedEditText.java index 596aa8f7b..403c8b8ba 100644 --- a/src/com/android/launcher3/ExtendedEditText.java +++ b/src/com/android/launcher3/ExtendedEditText.java @@ -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()); + } } |