am d9597642: am 512234f1: Merge "Close input session when the view is detached from the window." into mnc-dev

* commit 'd9597642ebbe4601568ad73ff20281c237e606fa':
  Close input session when the view is detached from the window.
This commit is contained in:
Yohei Yukawa
2015-06-01 17:07:48 +00:00
committed by Android Git Automerger
2 changed files with 21 additions and 0 deletions

View File

@@ -14506,6 +14506,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
onDetachedFromWindow();
onDetachedFromWindowInternal();
InputMethodManager imm = InputMethodManager.peekInstance();
if (imm != null) {
imm.onViewDetachedFromWindow(this);
}
ListenerInfo li = mListenerInfo;
final CopyOnWriteArrayList<OnAttachStateChangeListener> listeners =
li != null ? li.mOnAttachStateChangeListeners : null;

View File

@@ -1320,6 +1320,22 @@ public final class InputMethodManager {
}
}
/**
* Call this when a view is being detached from a {@link android.view.Window}.
* @hide
*/
public void onViewDetachedFromWindow(View view) {
synchronized (mH) {
if (DEBUG) Log.v(TAG, "onViewDetachedFromWindow: " + view
+ " mServedView=" + mServedView
+ " hasWindowFocus=" + view.hasWindowFocus());
if (mServedView == view && view.hasWindowFocus()) {
mNextServedView = null;
scheduleCheckFocusLocked(view);
}
}
}
static void scheduleCheckFocusLocked(View view) {
ViewRootImpl viewRootImpl = view.getViewRootImpl();
if (viewRootImpl != null) {