Loading core/java/android/widget/ToastPresenter.java +13 −4 Original line number Diff line number Diff line Loading @@ -91,7 +91,6 @@ public class ToastPresenter { private final WeakReference<Context> mContext; private final Resources mResources; private final WeakReference<WindowManager> mWindowManager; private final IAccessibilityManager mAccessibilityManagerService; private final INotificationManager mNotificationManager; private final String mPackageName; Loading @@ -104,7 +103,6 @@ public class ToastPresenter { INotificationManager notificationManager, String packageName) { mContext = new WeakReference<>(context); mResources = context.getResources(); mWindowManager = new WeakReference<>(context.getSystemService(WindowManager.class)); mNotificationManager = notificationManager; mPackageName = packageName; mContextPackageName = context.getPackageName(); Loading Loading @@ -274,7 +272,7 @@ public class ToastPresenter { public void hide(@Nullable ITransientNotificationCallback callback) { checkState(mView != null, "No toast to hide."); final WindowManager windowManager = mWindowManager.get(); final WindowManager windowManager = getWindowManager(mView); if (mView.getParent() != null && windowManager != null) { windowManager.removeViewImmediate(mView); } Loading @@ -295,6 +293,17 @@ public class ToastPresenter { mToken = null; } private WindowManager getWindowManager(View view) { Context context = mContext.get(); if (context == null && view != null) { context = view.getContext(); } if (context != null) { return context.getSystemService(WindowManager.class); } return null; } /** * Sends {@link AccessibilityEvent#TYPE_NOTIFICATION_STATE_CHANGED} event if accessibility is * enabled. Loading Loading @@ -331,7 +340,7 @@ public class ToastPresenter { } private void addToastView() { final WindowManager windowManager = mWindowManager.get(); final WindowManager windowManager = getWindowManager(mView); if (windowManager == null) { return; } Loading Loading
core/java/android/widget/ToastPresenter.java +13 −4 Original line number Diff line number Diff line Loading @@ -91,7 +91,6 @@ public class ToastPresenter { private final WeakReference<Context> mContext; private final Resources mResources; private final WeakReference<WindowManager> mWindowManager; private final IAccessibilityManager mAccessibilityManagerService; private final INotificationManager mNotificationManager; private final String mPackageName; Loading @@ -104,7 +103,6 @@ public class ToastPresenter { INotificationManager notificationManager, String packageName) { mContext = new WeakReference<>(context); mResources = context.getResources(); mWindowManager = new WeakReference<>(context.getSystemService(WindowManager.class)); mNotificationManager = notificationManager; mPackageName = packageName; mContextPackageName = context.getPackageName(); Loading Loading @@ -274,7 +272,7 @@ public class ToastPresenter { public void hide(@Nullable ITransientNotificationCallback callback) { checkState(mView != null, "No toast to hide."); final WindowManager windowManager = mWindowManager.get(); final WindowManager windowManager = getWindowManager(mView); if (mView.getParent() != null && windowManager != null) { windowManager.removeViewImmediate(mView); } Loading @@ -295,6 +293,17 @@ public class ToastPresenter { mToken = null; } private WindowManager getWindowManager(View view) { Context context = mContext.get(); if (context == null && view != null) { context = view.getContext(); } if (context != null) { return context.getSystemService(WindowManager.class); } return null; } /** * Sends {@link AccessibilityEvent#TYPE_NOTIFICATION_STATE_CHANGED} event if accessibility is * enabled. Loading Loading @@ -331,7 +340,7 @@ public class ToastPresenter { } private void addToastView() { final WindowManager windowManager = mWindowManager.get(); final WindowManager windowManager = getWindowManager(mView); if (windowManager == null) { return; } Loading