Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-api
提交
63703ee7
U
uni-api
项目概览
DCloud
/
uni-api
通知
679
Star
23
Fork
12
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
3
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-api
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
3
Issue
3
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
63703ee7
编写于
12月 02, 2024
作者:
杜庆泉
1
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
waiting view 增加 topPageView参数
上级
1bd91505
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
44 addition
and
41 deletion
+44
-41
uni_modules/uni-prompt/utssdk/app-android/WaitingView.uts
uni_modules/uni-prompt/utssdk/app-android/WaitingView.uts
+16
-13
uni_modules/uni-prompt/utssdk/app-android/showToast.uts
uni_modules/uni-prompt/utssdk/app-android/showToast.uts
+28
-28
未找到文件。
uni_modules/uni-prompt/utssdk/app-android/WaitingView.uts
浏览文件 @
63703ee7
...
@@ -57,17 +57,19 @@ export class WaitingView{
...
@@ -57,17 +57,19 @@ export class WaitingView{
private loadingHeight = 0
private loadingHeight = 0
private LoadingIcon: string = ""
private LoadingIcon: string = ""
private mBitmap: Bitmap | null = null;
private mBitmap: Bitmap | null = null;
private mpopWindow?: PopupWindow = null
private mpopWindow?: PopupWindow = null
private currentHandler: Handler
private currentHandler: Handler
private hostView:View | null = null
//{"back":"transmit","height":"112px","loading":{"display":"block","height":"55px","icon":"__uniapperror.png","jSONArray":false},"padding":"10px","size":"16px","width":"140px"}
//{"back":"transmit","height":"112px","loading":{"display":"block","height":"55px","icon":"__uniapperror.png","jSONArray":false},"padding":"10px","size":"16px","width":"140px"}
constructor(context?: Activity, style: UTSJSONObject) {
constructor(context?: Activity, style: UTSJSONObject
,view:View
) {
this.context = context;
this.context = context;
this.style = style.toJSONObject() as JSONObject
this.style = style.toJSONObject() as JSONObject
this.screenWidth = context?.getResources()?.getDisplayMetrics()!.widthPixels
this.screenWidth = context?.getResources()?.getDisplayMetrics()!.widthPixels
...
@@ -79,7 +81,8 @@ export class WaitingView{
...
@@ -79,7 +81,8 @@ export class WaitingView{
this.textView = this.waitingView.findViewById<TextView>(R.id.dcloud_tv_loading)
this.textView = this.waitingView.findViewById<TextView>(R.id.dcloud_tv_loading)
this.seaparatorView = this.waitingView.findViewById<View>(R.id.dcloud_view_seaparator)
this.seaparatorView = this.waitingView.findViewById<View>(R.id.dcloud_view_seaparator)
this.mImageView = this.waitingView.findViewById<ImageView>(R.id.dcloud_iv_loading)
this.mImageView = this.waitingView.findViewById<ImageView>(R.id.dcloud_iv_loading)
this.hostView = view
this.textView.setMaxLines(2)
this.textView.setMaxLines(2)
this.handlerArguments()
this.handlerArguments()
...
@@ -92,7 +95,7 @@ export class WaitingView{
...
@@ -92,7 +95,7 @@ export class WaitingView{
this.currentHandler = new Handler(Looper.getMainLooper())
this.currentHandler = new Handler(Looper.getMainLooper())
this.initView()
this.initView()
this.makeBitmap()
this.makeBitmap()
}
}
handlerArguments() {
handlerArguments() {
...
@@ -133,7 +136,7 @@ export class WaitingView{
...
@@ -133,7 +136,7 @@ export class WaitingView{
this.textView.setGravity(Gravity.CENTER)
this.textView.setGravity(Gravity.CENTER)
this.textView.setText(this.title)
this.textView.setText(this.title)
this.textView.setTextSize(0, (16 * this.density).toFloat())
this.textView.setTextSize(0, (16 * this.density).toFloat())
if(this.title.length < 1){
if(this.title.length < 1){
// 没有文本需要展示
// 没有文本需要展示
this.textView.setVisibility(View.GONE)
this.textView.setVisibility(View.GONE)
...
@@ -166,8 +169,8 @@ export class WaitingView{
...
@@ -166,8 +169,8 @@ export class WaitingView{
}
}
return this.context!.dispatchTouchEvent(ev)
return this.context!.dispatchTouchEvent(ev)
}
}
showWaiting() {
showWaiting() {
if(this.context != null && !this.context!.isFinishing()){
if(this.context != null && !this.context!.isFinishing()){
let width = -2;
let width = -2;
...
@@ -179,7 +182,7 @@ export class WaitingView{
...
@@ -179,7 +182,7 @@ export class WaitingView{
}
}
let mpop = new PopupWindow(this.waitingView, width.toInt(), height.toInt(), this.mask)
let mpop = new PopupWindow(this.waitingView, width.toInt(), height.toInt(), this.mask)
this.mpopWindow = mpop
this.mpopWindow = mpop
mpop.showAtLocation(
(this.context?.findViewById<ViewGroup>(android.R.id.content))?.getChildAt(0)
, Gravity.CENTER, 0, 0)
mpop.showAtLocation(
hostView
, Gravity.CENTER, 0, 0)
mpop.setOutsideTouchable(true)
mpop.setOutsideTouchable(true)
mpop.setOnDismissListener(new WaitingDismissListener())
mpop.setOnDismissListener(new WaitingDismissListener())
mpop.setTouchInterceptor(new TouchInterceptorListener(this.mask))
mpop.setTouchInterceptor(new TouchInterceptorListener(this.mask))
...
@@ -315,4 +318,4 @@ class TouchInterceptorListener implements View.OnTouchListener {
...
@@ -315,4 +318,4 @@ class TouchInterceptorListener implements View.OnTouchListener {
override onTouch(v: View, event: MotionEvent): boolean {
override onTouch(v: View, event: MotionEvent): boolean {
return this.interceptor
return this.interceptor
}
}
}
}
\ No newline at end of file
uni_modules/uni-prompt/utssdk/app-android/showToast.uts
浏览文件 @
63703ee7
...
@@ -31,7 +31,7 @@ let toastType : string | null = null
...
@@ -31,7 +31,7 @@ let toastType : string | null = null
export function showToastImpl(style : ShowToastOptions) {
export function showToastImpl(style : ShowToastOptions) {
makeToast(style, 'toast', 'showToast')
makeToast(style, 'toast', 'showToast')
}
}
export function hideToastImpl() {
export function hideToastImpl() {
...
@@ -108,33 +108,33 @@ function makeLoading(style : ShowLoadingOptions, type : string, errMsg : string)
...
@@ -108,33 +108,33 @@ function makeLoading(style : ShowLoadingOptions, type : string, errMsg : string)
options["width"] = "140"
options["width"] = "140"
options["height"] = "112"
options["height"] = "112"
// #ifndef UNI-APP-X
// #ifndef UNI-APP-X
/**
/**
* uni-app
* uni-app
*/
*/
const alert = new WaitingView(UTSAndroid.getTopPageActivity(), options)
const alert = new WaitingView(UTSAndroid.getTopPageActivity(), options
,UTSAndroid.getTopPageView()
)
toast = alert
toast = alert
alert?.showWaiting();
alert?.showWaiting();
UTSAndroid.onAppActivityDestroy(function(){
UTSAndroid.onAppActivityDestroy(function(){
toast?.close()
toast?.close()
toast = null
toast = null
})
})
// #endif
// #endif
// #ifdef UNI-APP-X
// #ifdef UNI-APP-X
/**
/**
* uni-app x
* uni-app x
* 需要特殊处理生命周期
* 需要特殊处理生命周期
*/
*/
const pages = getCurrentPages();
const pages = getCurrentPages();
if (pages.length > 0) {
if (pages.length > 0) {
const page = pages[pages.length - 1].vm!
const page = pages[pages.length - 1].vm!
const instance = page.$
const instance = page.$
if (page.$isReady) {
if (page.$isReady) {
const alert = new WaitingView(UTSAndroid.getTopPageActivity(), options)
const alert = new WaitingView(UTSAndroid.getTopPageActivity(), options
,UTSAndroid.getTopPageView()
)
toast = alert
toast = alert
alert?.showWaiting();
alert?.showWaiting();
} else {
} else {
...
@@ -142,24 +142,24 @@ function makeLoading(style : ShowLoadingOptions, type : string, errMsg : string)
...
@@ -142,24 +142,24 @@ function makeLoading(style : ShowLoadingOptions, type : string, errMsg : string)
onReady(() => {
onReady(() => {
if(onReadyToast.containsKey(page)){
if(onReadyToast.containsKey(page)){
options = onReadyToast.get(page) as UTSJSONObject;
options = onReadyToast.get(page) as UTSJSONObject;
const alert = new WaitingView(UTSAndroid.getTopPageActivity(), options)
const alert = new WaitingView(UTSAndroid.getTopPageActivity(), options
,UTSAndroid.getTopPageView()
)
toast = alert
toast = alert
alert?.showWaiting();
alert?.showWaiting();
onReadyToast.remove(page)
onReadyToast.remove(page)
}
}
}, instance)
}, instance)
}
}
onUnload(() => {
onUnload(() => {
toast?.close()
toast?.close()
toast = null
toast = null
}, instance)
}, instance)
}
}
// #endif
// #endif
const res : ShowLoadingSuccess = {
const res : ShowLoadingSuccess = {
}
}
style.success?.(res)
style.success?.(res)
...
@@ -178,7 +178,7 @@ function makeToast(style : ShowToastOptions, type : string, errMsg : string) {
...
@@ -178,7 +178,7 @@ function makeToast(style : ShowToastOptions, type : string, errMsg : string) {
style.complete?.(res)
style.complete?.(res)
} else {
} else {
toastType = type
toastType = type
if (["top", "center", "bottom"].indexOf(style.position) >= 0) {
if (["top", "center", "bottom"].indexOf(style.position) >= 0) {
androidToast = Toast.makeText(UTSAndroid.getAppContext(), style.title, Toast.LENGTH_SHORT);
androidToast = Toast.makeText(UTSAndroid.getAppContext(), style.title, Toast.LENGTH_SHORT);
...
@@ -200,7 +200,7 @@ function makeToast(style : ShowToastOptions, type : string, errMsg : string) {
...
@@ -200,7 +200,7 @@ function makeToast(style : ShowToastOptions, type : string, errMsg : string) {
androidToast!.show()
androidToast!.show()
const res : ShowToastSuccess = {
const res : ShowToastSuccess = {
}
}
style.success?.(res)
style.success?.(res)
style.complete?.(res)
style.complete?.(res)
} else {
} else {
...
@@ -240,8 +240,8 @@ function makeToast(style : ShowToastOptions, type : string, errMsg : string) {
...
@@ -240,8 +240,8 @@ function makeToast(style : ShowToastOptions, type : string, errMsg : string) {
}
}
}
}
// #ifndef UNI-APP-X
// #ifndef UNI-APP-X
/**
/**
* uni-app
* uni-app
...
@@ -249,17 +249,17 @@ function makeToast(style : ShowToastOptions, type : string, errMsg : string) {
...
@@ -249,17 +249,17 @@ function makeToast(style : ShowToastOptions, type : string, errMsg : string) {
const alert = new WaitingView(UTSAndroid.getTopPageActivity(), options)
const alert = new WaitingView(UTSAndroid.getTopPageActivity(), options)
toast = alert
toast = alert
alert?.showWaiting();
alert?.showWaiting();
UTSAndroid.onAppActivityDestroy(function(){
UTSAndroid.onAppActivityDestroy(function(){
toast?.close()
toast?.close()
toast = null
toast = null
})
})
// #endif
// #endif
// #ifdef UNI-APP-X
// #ifdef UNI-APP-X
/**
/**
* uni-app x
* uni-app x
* 需要特殊处理生命周期
* 需要特殊处理生命周期
*/
*/
const pages = getCurrentPages();
const pages = getCurrentPages();
if (pages.length > 0) {
if (pages.length > 0) {
...
@@ -274,24 +274,24 @@ function makeToast(style : ShowToastOptions, type : string, errMsg : string) {
...
@@ -274,24 +274,24 @@ function makeToast(style : ShowToastOptions, type : string, errMsg : string) {
onReady(() => {
onReady(() => {
if(onReadyToast.containsKey(page)){
if(onReadyToast.containsKey(page)){
options = onReadyToast.get(page) as UTSJSONObject;
options = onReadyToast.get(page) as UTSJSONObject;
const alert = new WaitingView(UTSAndroid.getTopPageActivity(), options)
const alert = new WaitingView(UTSAndroid.getTopPageActivity(), options)
toast = alert
toast = alert
alert?.showWaiting();
alert?.showWaiting();
onReadyToast.remove(page)
onReadyToast.remove(page)
}
}
}, instance)
}, instance)
}
}
onUnload(() => {
onUnload(() => {
toast?.close()
toast?.close()
toast = null
toast = null
}, instance)
}, instance)
}
}
// #endif
// #endif
let duration : number | null = style.duration
let duration : number | null = style.duration
if (duration == null || duration <= 0) {
if (duration == null || duration <= 0) {
duration = 1500
duration = 1500
...
@@ -301,10 +301,10 @@ function makeToast(style : ShowToastOptions, type : string, errMsg : string) {
...
@@ -301,10 +301,10 @@ function makeToast(style : ShowToastOptions, type : string, errMsg : string) {
toast?.close()
toast?.close()
}, duration)
}, duration)
}
}
const res : ShowToastSuccess = {
const res : ShowToastSuccess = {
}
}
style.success?.(res)
style.success?.(res)
style.complete?.(res)
style.complete?.(res)
}
}
...
...
杜庆泉
@shili8889
mentioned in commit
80ed21d2
·
12月 02, 2024
mentioned in commit
80ed21d2
mentioned in commit 80ed21d2dabfcbf6c1a4c84dfa32794ede7b508b
开关提交列表
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录