diff options
author | 2018-01-14 16:30:59 -0800 | |
---|---|---|
committer | 2018-01-14 16:30:59 -0800 | |
commit | 623e94b857f2bc2a5cbb1a24cf4bcc5ec9c70c9f (patch) | |
tree | 3a44a1b9382c5ae0a39fbf695f94d4cf145d6b56 | |
parent | 31a260f144348cf7da0ce6f34b6b286eecacb8de (diff) |
Use lambda when appropriate
This is a safe refactoring that should have no behavior change in
terms of semantics and performance characteristics.
Test: make -j checkbuild
Change-Id: I30b40c483e490ff42c1c707233ca5cc7b67da28f
-rw-r--r-- | core/java/android/inputmethodservice/InputMethodService.java | 53 | ||||
-rw-r--r-- | core/java/android/view/inputmethod/InputMethodManager.java | 7 |
2 files changed, 24 insertions, 36 deletions
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java index 9e5f5cb887c9..02d6f3e85fe3 100644 --- a/core/java/android/inputmethodservice/InputMethodService.java +++ b/core/java/android/inputmethodservice/InputMethodService.java @@ -340,42 +340,35 @@ public class InputMethodService extends AbstractInputMethodService { final Insets mTmpInsets = new Insets(); final int[] mTmpLocation = new int[2]; - final ViewTreeObserver.OnComputeInternalInsetsListener mInsetsComputer = - new ViewTreeObserver.OnComputeInternalInsetsListener() { - public void onComputeInternalInsets(ViewTreeObserver.InternalInsetsInfo info) { - if (isExtractViewShown()) { - // In true fullscreen mode, we just say the window isn't covering - // any content so we don't impact whatever is behind. - View decor = getWindow().getWindow().getDecorView(); - info.contentInsets.top = info.visibleInsets.top - = decor.getHeight(); - info.touchableRegion.setEmpty(); - info.setTouchableInsets(ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME); - } else { - onComputeInsets(mTmpInsets); - info.contentInsets.top = mTmpInsets.contentTopInsets; - info.visibleInsets.top = mTmpInsets.visibleTopInsets; - info.touchableRegion.set(mTmpInsets.touchableRegion); - info.setTouchableInsets(mTmpInsets.touchableInsets); - } + final ViewTreeObserver.OnComputeInternalInsetsListener mInsetsComputer = info -> { + if (isExtractViewShown()) { + // In true fullscreen mode, we just say the window isn't covering + // any content so we don't impact whatever is behind. + View decor = getWindow().getWindow().getDecorView(); + info.contentInsets.top = info.visibleInsets.top = decor.getHeight(); + info.touchableRegion.setEmpty(); + info.setTouchableInsets(ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME); + } else { + onComputeInsets(mTmpInsets); + info.contentInsets.top = mTmpInsets.contentTopInsets; + info.visibleInsets.top = mTmpInsets.visibleTopInsets; + info.touchableRegion.set(mTmpInsets.touchableRegion); + info.setTouchableInsets(mTmpInsets.touchableInsets); } }; - final View.OnClickListener mActionClickListener = new View.OnClickListener() { - public void onClick(View v) { - final EditorInfo ei = getCurrentInputEditorInfo(); - final InputConnection ic = getCurrentInputConnection(); - if (ei != null && ic != null) { - if (ei.actionId != 0) { - ic.performEditorAction(ei.actionId); - } else if ((ei.imeOptions&EditorInfo.IME_MASK_ACTION) - != EditorInfo.IME_ACTION_NONE) { - ic.performEditorAction(ei.imeOptions&EditorInfo.IME_MASK_ACTION); - } + final View.OnClickListener mActionClickListener = v -> { + final EditorInfo ei = getCurrentInputEditorInfo(); + final InputConnection ic = getCurrentInputConnection(); + if (ei != null && ic != null) { + if (ei.actionId != 0) { + ic.performEditorAction(ei.actionId); + } else if ((ei.imeOptions & EditorInfo.IME_MASK_ACTION) != EditorInfo.IME_ACTION_NONE) { + ic.performEditorAction(ei.imeOptions & EditorInfo.IME_MASK_ACTION); } } }; - + /** * Concrete implementation of * {@link AbstractInputMethodService.AbstractInputMethodImpl} that provides diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java index 358625b4e13a..1e291209a373 100644 --- a/core/java/android/view/inputmethod/InputMethodManager.java +++ b/core/java/android/view/inputmethod/InputMethodManager.java @@ -1258,12 +1258,7 @@ public final class InputMethodManager { // The view is running on a different thread than our own, so // we need to reschedule our work for over there. if (DEBUG) Log.v(TAG, "Starting input: reschedule to view thread"); - vh.post(new Runnable() { - @Override - public void run() { - startInputInner(startInputReason, null, 0, 0, 0); - } - }); + vh.post(() -> startInputInner(startInputReason, null, 0, 0, 0)); return false; } |