[Android] Avoid using app context from static call
Geoffrey Métais
git at videolan.org
Fri Mar 9 11:44:01 CET 2018
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Mar 9 10:51:40 2018 +0100| [5924da80144392d92a80863943115471af54c739] | committer: Geoffrey Métais
Avoid using app context from static call
> https://code.videolan.org/videolan/vlc-android/commit/5924da80144392d92a80863943115471af54c739
---
vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.java | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.java b/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.java
index ad013e3e7..26d76d61b 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.java
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.java
@@ -223,14 +223,13 @@ public class UiTools {
}
public static void setKeyboardVisibility(final View v, final boolean show) {
- final InputMethodManager inputMethodManager = (InputMethodManager) VLCApplication.getAppContext().getSystemService(Activity.INPUT_METHOD_SERVICE);
+ if (v == null) return;
+ final InputMethodManager inputMethodManager = (InputMethodManager) v.getContext().getApplicationContext().getSystemService(Activity.INPUT_METHOD_SERVICE);
sHandler.post(new Runnable() {
@Override
public void run() {
- if (show)
- inputMethodManager.showSoftInput(v, InputMethodManager.SHOW_FORCED);
- else
- inputMethodManager.hideSoftInputFromWindow(v.getWindowToken(), 0);
+ if (show) inputMethodManager.showSoftInput(v, InputMethodManager.SHOW_FORCED);
+ else inputMethodManager.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
});
}
More information about the Android
mailing list