提交 7cf6ae25 编写于 作者: shutao-dc's avatar shutao-dc

update uts-get-native-view/utssdk/app-android/index.uts

上级 28f396fe
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<View>();
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<EditText>();
//通过getAndroidView设置泛型直接获取AppCompatEditText 如果获取失败则返回null
const view = uni.getElementById(elementId)?.getAndroidView<AppCompatEditText>();
return view != null;
}
export const checkTextareaNativeView: CheckViewNativeView = function (elementId : string) : boolean {
//通过getAndroidView设置泛型直接获取EditText 如果获取失败则返回null
const view = uni.getElementById(elementId)?.getAndroidView<EditText>();
//通过getAndroidView设置泛型直接获取AppCompatEditText 如果获取失败则返回null
const view = uni.getElementById(elementId)?.getAndroidView<AppCompatEditText>();
return view != null;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册