summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoradrianknight89 <adrianknight89@outlook.com>2016-10-24 16:28:58 -0500
committerRui Marinho <me@ruimarinho.net>2016-10-24 22:28:58 +0100
commit6196407f8924463e526bc96f6855560954d9d2e0 (patch)
tree7eaf587666153d6d5132027f4d9ea0e693d4e39f
parentad776f942b0d3ebe625ec3ad2ba928839ee6aeb9 (diff)
downloadxamarin-forms-6196407f8924463e526bc96f6855560954d9d2e0.tar.gz
xamarin-forms-6196407f8924463e526bc96f6855560954d9d2e0.tar.bz2
xamarin-forms-6196407f8924463e526bc96f6855560954d9d2e0.zip
[Android] Internal keyboard hide/show should handle null views (#418)
* Check for null input view before trying to hide keyboard * Adding null check to ShowKeyboard * change to throw an exception
-rw-r--r--Xamarin.Forms.Platform.Android/KeyboardManager.cs10
1 files changed, 7 insertions, 3 deletions
diff --git a/Xamarin.Forms.Platform.Android/KeyboardManager.cs b/Xamarin.Forms.Platform.Android/KeyboardManager.cs
index bfe65d13..eb89731b 100644
--- a/Xamarin.Forms.Platform.Android/KeyboardManager.cs
+++ b/Xamarin.Forms.Platform.Android/KeyboardManager.cs
@@ -14,14 +14,15 @@ namespace Xamarin.Forms.Platform.Android
if (Forms.Context == null)
throw new InvalidOperationException("Call Forms.Init() before HideKeyboard");
+ if (inputView == null)
+ throw new ArgumentNullException(nameof(inputView) + " must be set before the keyboard can be hidden.");
+
using (var inputMethodManager = (InputMethodManager)Forms.Context.GetSystemService(Context.InputMethodService))
{
- IBinder windowToken = null;
-
if (!overrideValidation && !(inputView is EditText || inputView is TextView || inputView is SearchView))
throw new ArgumentException("inputView should be of type EditText, SearchView, or TextView");
- windowToken = inputView.WindowToken;
+ IBinder windowToken = inputView.WindowToken;
if (windowToken != null)
inputMethodManager.HideSoftInputFromWindow(windowToken, HideSoftInputFlags.None);
}
@@ -32,6 +33,9 @@ namespace Xamarin.Forms.Platform.Android
if (Forms.Context == null)
throw new InvalidOperationException("Call Forms.Init() before ShowKeyboard");
+ if (inputView == null)
+ throw new ArgumentNullException(nameof(inputView) + " must be set before the keyboard can be shown.");
+
using (var inputMethodManager = (InputMethodManager)Forms.Context.GetSystemService(Context.InputMethodService))
{
if (inputView is EditText || inputView is TextView || inputView is SearchView)