From 7cf6ae2516bd6b233b219dcd957dda9e5b9318f4 Mon Sep 17 00:00:00 2001 From: shutao Date: Tue, 30 Jul 2024 15:07:34 +0800 Subject: [PATCH] update uts-get-native-view/utssdk/app-android/index.uts --- .../utssdk/app-android/index.uts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/uni_modules/uts-get-native-view/utssdk/app-android/index.uts b/uni_modules/uts-get-native-view/utssdk/app-android/index.uts index e502bdb9..5f8ddbac 100644 --- a/uni_modules/uts-get-native-view/utssdk/app-android/index.uts +++ b/uni_modules/uts-get-native-view/utssdk/app-android/index.uts @@ -1,7 +1,6 @@ import { CanWebViewGoBack, CanWebViewGoForward, HasNativeView, CheckWebViewNativeView, CheckInputNativeView, CheckTextareaNativeView, CheckViewNativeView} from "../interface"; import WebView from 'android.webkit.WebView'; -import View from "android.view.View" -import EditText from "android.widget.EditText" +import AppCompatEditText from "androidx.appcompat.widget.AppCompatEditText" import ViewGroup from "android.view.ViewGroup" export const canWebViewGoBack : CanWebViewGoBack = function (elementId : string) : boolean { @@ -15,28 +14,29 @@ export const canWebViewGoForward : CanWebViewGoForward = function (elementId : s } export const hasNativeView : HasNativeView = function (elementId : string) : boolean { - const view = uni.getElementById(elementId)?.getAndroidView(); + const view = uni.getElementById(elementId)?.getAndroidView(); return view != null; } export const checkWebViewNativeView: CheckWebViewNativeView = function (elementId : string) : boolean { //通过getElementById不设置泛型,取值view类型 再通过instanceof校验WebView const element = uni.getElementById(elementId) - if(element != null && element.getAndroidView()! instanceof WebView) { + const view = element?.getAndroidView() + if(view != null && view instanceof WebView) { return true } return false; } export const checkInputNativeView: CheckInputNativeView = function (elementId : string) : boolean { - //通过getAndroidView设置泛型直接获取EditText 如果获取失败则返回null - const view = uni.getElementById(elementId)?.getAndroidView(); + //通过getAndroidView设置泛型直接获取AppCompatEditText 如果获取失败则返回null + const view = uni.getElementById(elementId)?.getAndroidView(); return view != null; } export const checkTextareaNativeView: CheckViewNativeView = function (elementId : string) : boolean { - //通过getAndroidView设置泛型直接获取EditText 如果获取失败则返回null - const view = uni.getElementById(elementId)?.getAndroidView(); + //通过getAndroidView设置泛型直接获取AppCompatEditText 如果获取失败则返回null + const view = uni.getElementById(elementId)?.getAndroidView(); return view != null; } -- GitLab