From d6f5b7af5bb18afd97653e687943d87299de1cac Mon Sep 17 00:00:00 2001 From: shutao Date: Fri, 16 Aug 2024 16:50:20 +0800 Subject: [PATCH] =?UTF-8?q?uni-native-button/utssdk/app-android/index.uts?= =?UTF-8?q?=20uni-time-picker/utssdk/app-android/index.uts=20=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uni-native-button/utssdk/app-android/index.uts | 8 ++++---- .../uni-time-picker/utssdk/app-android/index.uts | 13 ++++++------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/uni_modules/uni-native-button/utssdk/app-android/index.uts b/uni_modules/uni-native-button/utssdk/app-android/index.uts index 449b7c17..88d1ba62 100644 --- a/uni_modules/uni-native-button/utssdk/app-android/index.uts +++ b/uni_modules/uni-native-button/utssdk/app-android/index.uts @@ -5,13 +5,13 @@ export class NativeButton { constructor(element : UniNativeViewElement) { this.$element = element; - bindView(); + this.bindView(); } button : Button | null = null; bindView() { //通过UniElement.getAndroidActivity()获取android平台activity 用于创建view的上下文 - this.button = new Button($element.getAndroidActivity()!); //构建原生view + this.button = new Button(this.$element.getAndroidActivity()!); //构建原生view //限制原生Button 文案描述不自动大写 this.button?.setAllCaps(false) //监听原生Button点击事件 @@ -20,10 +20,10 @@ export class NativeButton { //构建自定义UniNativeViewEvent返回对象 const event = new UniNativeViewEvent("customClick", detail) //响应分发原生Button的点击事件 - $element.dispatchEvent(event) + this.$element.dispatchEvent(event) }) //UniNativeViewEvent 绑定 安卓原生view - $element.bindAndroidView(button!); + this.$element.bindAndroidView(button!); } updateText(text: string) { diff --git a/uni_modules/uni-time-picker/utssdk/app-android/index.uts b/uni_modules/uni-time-picker/utssdk/app-android/index.uts index 4fdd2f7b..6b4d9e9f 100644 --- a/uni_modules/uni-time-picker/utssdk/app-android/index.uts +++ b/uni_modules/uni-time-picker/utssdk/app-android/index.uts @@ -1,24 +1,23 @@ import { TimePicker } from "android.widget" -import { View } from "android.view" export class NativeTimePicker { $element : UniNativeViewElement; constructor(element : UniNativeViewElement, hour: number, minute: number) { this.$element = element; - bindView(hour, minute); + this.bindView(hour, minute); } picker : TimePicker | null = null; bindView(hour: number, minute: number) { - this.picker = new TimePicker($element.getAndroidActivity()!); //构建原生view - $element.bindAndroidView(picker!); - setHour(hour) - setMinute(minute) + this.picker = new TimePicker(this.$element.getAndroidActivity()!); //构建原生view + this.$element.bindAndroidView(this.picker!); + this.setHour(hour) + this.setMinute(minute) this.picker?.setOnTimeChangedListener((_, hourOfDay, minute) => { const detail = {"hour": hourOfDay, "minute": minute} const event = new UniNativeViewEvent("timechanged", detail) - $element.dispatchEvent(event) + this.$element.dispatchEvent(event) }) } -- GitLab