From a175a5b7ea3682cb58cca7f9726d0b8171cd549d Mon Sep 17 00:00:00 2001 From: Jeff Brown Date: Wed, 15 Feb 2012 19:18:31 -0800 Subject: Encapsulate the ViewRootImpl's handler. This change makes it much easier to make sense of the messages that get posted to the ViewRootImpl's handler by encapsulating their point of dispatch within the ViewRootImpl itself. As part of this change, the View.AttachInfo now carries a reference to the ViewRootImpl itself, which simplifies some code that used to try to find the ViewRootImpl by getting the root view's parent. In principle, it might have been nice to hide the ViewRootImpl from the View hierarchy but in practice the two were coupled in many ways. Change-Id: I51ebccdf5f8c8c505cd6f17cdf594174d041dc54 --- core/java/android/widget/TextView.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'core/java/android/widget/TextView.java') diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 7db8a1e..ffe54e9 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -3807,21 +3807,21 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } } - Handler h = getHandler(); - if (h != null) { + ViewRootImpl viewRootImpl = getViewRootImpl(); + if (viewRootImpl != null) { long eventTime = SystemClock.uptimeMillis(); - h.sendMessage(h.obtainMessage(ViewRootImpl.DISPATCH_KEY_FROM_IME, + viewRootImpl.dispatchKeyFromIme( new KeyEvent(eventTime, eventTime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER, 0, 0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE - | KeyEvent.FLAG_EDITOR_ACTION))); - h.sendMessage(h.obtainMessage(ViewRootImpl.DISPATCH_KEY_FROM_IME, + | KeyEvent.FLAG_EDITOR_ACTION)); + viewRootImpl.dispatchKeyFromIme( new KeyEvent(SystemClock.uptimeMillis(), eventTime, KeyEvent.ACTION_UP, KeyEvent.KEYCODE_ENTER, 0, 0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE - | KeyEvent.FLAG_EDITOR_ACTION))); + | KeyEvent.FLAG_EDITOR_ACTION)); } } -- cgit v1.1