Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
Hello UTS
提交
1c6d2c2c
H
Hello UTS
项目概览
DCloud
/
Hello UTS
通知
1595
Star
27
Fork
9
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
2
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
Hello UTS
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
2
Issue
2
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
1c6d2c2c
编写于
11月 25, 2022
作者:
杜庆泉
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
android uts-alert 对齐ios
上级
caa6a2b1
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
101 addition
and
71 deletion
+101
-71
pages/advance/advance.vue
pages/advance/advance.vue
+0
-3
uni_modules/uts-advance/utssdk/app-android/index.uts
uni_modules/uts-advance/utssdk/app-android/index.uts
+0
-63
uni_modules/uts-alert/package.json
uni_modules/uts-alert/package.json
+1
-1
uni_modules/uts-alert/utssdk/app-android/index.uts
uni_modules/uts-alert/utssdk/app-android/index.uts
+100
-4
未找到文件。
pages/advance/advance.vue
浏览文件 @
1c6d2c2c
...
...
@@ -40,9 +40,7 @@
<uni-list-item
@
tap=
"testLifecyle"
title=
"activity生命周期监听"
:clickable=
"true"
link
/>
<uni-list-item
@
tap=
"testAssetLoad"
title=
"播放asset音频(需自定义基座)"
:clickable=
"true"
link
/>
<uni-list-item
@
tap=
"gotoDecorView"
title=
"操作DecorView"
:clickable=
"true"
link
/>
<uni-list-item
@
tap=
"testInputDialog"
title=
"同步获取用户输入"
:clickable=
"true"
/>
<uni-list-item
@
tap=
"testMetaRead"
title=
"读取meta配置"
:clickable=
"true"
/>
</uni-list>
...
...
@@ -58,7 +56,6 @@
doIntervalTask
,
clearIntervalTask
,
playAssetAudio
,
getUserInput
,
getMetaConfig
}
from
"
../../uni_modules/uts-advance
"
;
...
...
uni_modules/uts-advance/utssdk/app-android/index.uts
浏览文件 @
1c6d2c2c
...
...
@@ -141,69 +141,6 @@ export function removeViewToDecorView() {
UTSAndroid.getUniActivity()!.runOnUiThread(uiRunable)
}
/**
* 用户输入对话框监听器
*/
class DialogListener extends DialogInterface.OnClickListener{
inputET:EditText
callback:UTSCallback
constructor(et:EditText,cb:UTSCallback){
super();
this.callback = cb;
this.inputET = et;
}
override onClick(_dialog:DialogInterface,_arg1:Int ):void {
//数据获取
let input = this.inputET.getText().toString()
this.callback(input);
Toast.makeText(UTSAndroid.getUniActivity(),input,
Toast.LENGTH_LONG).show();
}
}
/**
* Dialog ui任务封装
*/
class DialogUIRunnable extends Runnable {
callback:UTSCallback
constructor(success:UTSCallback){
super();
this.callback = success
}
override run():void {
let et = new EditText(UTSAndroid.getUniActivity());
et.setText("127.0.0.1");
new AlertDialog.Builder(UTSAndroid.getUniActivity()).setTitle("请输入IP地址")
.setIcon(android.R.drawable.ic_dialog_info).setView(et)
.setPositiveButton("确定", new DialogListener(et,this.callback))
.setNegativeButton("取消", null).show();
}
};
/**
* 通过对话框同步获取用户输入
*/
export function getUserInput(success: (res: string) => void) {
let uiRunable = new DialogUIRunnable(success);
UTSAndroid.getUniActivity()!.runOnUiThread(uiRunable)
}
/**
...
...
uni_modules/uts-alert/package.json
浏览文件 @
1c6d2c2c
...
...
@@ -8,7 +8,7 @@
],
"repository"
:
""
,
"engines"
:
{
"HBuilderX"
:
"^3.6.
8
"
"HBuilderX"
:
"^3.6.
11
"
},
"dcloudext"
:
{
"type"
:
"uts"
,
...
...
uni_modules/uts-alert/utssdk/app-android/index.uts
浏览文件 @
1c6d2c2c
@Suppress("unuse")
import {
UTSAndroid
} from "io.dcloud.uts";
import Toast from 'android.widget.Toast';
import AlertDialog from 'android.app.AlertDialog';
import DialogInterface from 'android.content.DialogInterface';
import EditText from 'android.widget.EditText';
export function showAlert(_title: string|null, _message: string|null, _result: (index: Number) => void) {
// todo
let uiRunable = new DialogUIRunnable(null,_title!,_message!,"",false);
UTSAndroid.getUniActivity()!.runOnUiThread(uiRunable)
}
@Suppress("unuse")
export function showPrompt(_title: string|null,_message: string|null,_placeholder: string|null, _result: (content: string)=>void) {
// todo
export function showPrompt(_title: string|null,_message: string|null,_placeholder: string|null, success: (content: string)=>void) {
let uiRunable = new DialogUIRunnable(success,_title!,_message!,_placeholder!,true);
UTSAndroid.getUniActivity()!.runOnUiThread(uiRunable)
}
/**
* 用户输入对话框监听器
*/
class DialogListener extends DialogInterface.OnClickListener{
inputET:EditText
callback:UTSCallback
constructor(et:EditText,cb:UTSCallback){
super();
this.callback = cb;
this.inputET = et;
}
override onClick(_dialog:DialogInterface,_arg1:Int ):void {
//数据获取
let input = this.inputET.getText().toString()
this.callback(input);
Toast.makeText(UTSAndroid.getUniActivity(),input,
Toast.LENGTH_LONG).show();
}
}
/**
* Dialog ui任务封装
*/
class DialogUIRunnable extends Runnable {
callback:UTSCallback|null = null
title: string
message: string
placeholder: string
needInput:boolean
constructor(success?:UTSCallback,title: string,message: string,placeholder: string,needInput:boolean){
super();
if(success != null){
this.callback = success
}
this.title = title
this.message = message
this.placeholder = placeholder
this.needInput = needInput
}
override run():void {
if(this.needInput){
let et = new EditText(UTSAndroid.getUniActivity());
et.setText(this.placeholder);
new AlertDialog.Builder(UTSAndroid.getUniActivity())
.setTitle(this.title)
.setMessage(this.message)
.setIcon(android.R.drawable.ic_dialog_info).setView(et)
.setPositiveButton("确定", new DialogListener(et,this.callback!))
.setNegativeButton("取消", null).show();
}else{
new AlertDialog.Builder(UTSAndroid.getUniActivity())
.setTitle(this.title)
.setMessage(this.message)
.setIcon(android.R.drawable.ic_dialog_info)
.setNegativeButton("取消", null).show();
}
}
};
/**
* 通过对话框同步获取用户输入
*/
export function getUserInput(success: (res: string) => void) {
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录