AppCompatDelegate - fix cast exception

View#getParent can return a ViewParent and not
necessarily a View. Check that the action mode view
is an instance of View (besides checking for null)
before casting it to a View.

Test: create a custom dialog with TextView as message,
open it and select text multiple times. Observe no crash.

Bug: 31500890
Change-Id: Ie2fcd7de6730b5521086401b2be621fd0a64e593
diff --git a/v7/appcompat/src/android/support/v7/app/AppCompatDelegateImplV9.java b/v7/appcompat/src/android/support/v7/app/AppCompatDelegateImplV9.java
index a203252..9491922 100644
--- a/v7/appcompat/src/android/support/v7/app/AppCompatDelegateImplV9.java
+++ b/v7/appcompat/src/android/support/v7/app/AppCompatDelegateImplV9.java
@@ -832,7 +832,7 @@
                                 mActionModeView.setVisibility(View.VISIBLE);
                                 mActionModeView.sendAccessibilityEvent(
                                         AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
-                                if (mActionModeView.getParent() != null) {
+                                if (mActionModeView.getParent() instanceof View) {
                                     ViewCompat.requestApplyInsets((View) mActionModeView.getParent());
                                 }
                             }
@@ -849,7 +849,7 @@
                         mActionModeView.setVisibility(View.VISIBLE);
                         mActionModeView.sendAccessibilityEvent(
                                 AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
-                        if (mActionModeView.getParent() != null) {
+                        if (mActionModeView.getParent() instanceof View) {
                             ViewCompat.requestApplyInsets((View) mActionModeView.getParent());
                         }
                     }