提交 63703ee7 编写于 作者: 杜庆泉's avatar 杜庆泉

waiting view 增加 topPageView参数

上级 1bd91505
......@@ -57,17 +57,19 @@ export class WaitingView{
private loadingHeight = 0
private LoadingIcon: string = ""
private mBitmap: Bitmap | null = null;
private mpopWindow?: PopupWindow = null
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"}
constructor(context?: Activity, style: UTSJSONObject) {
constructor(context?: Activity, style: UTSJSONObject,view:View) {
this.context = context;
this.style = style.toJSONObject() as JSONObject
this.screenWidth = context?.getResources()?.getDisplayMetrics()!.widthPixels
......@@ -79,7 +81,8 @@ export class WaitingView{
this.textView = this.waitingView.findViewById<TextView>(R.id.dcloud_tv_loading)
this.seaparatorView = this.waitingView.findViewById<View>(R.id.dcloud_view_seaparator)
this.mImageView = this.waitingView.findViewById<ImageView>(R.id.dcloud_iv_loading)
this.hostView = view
this.textView.setMaxLines(2)
this.handlerArguments()
......@@ -92,7 +95,7 @@ export class WaitingView{
this.currentHandler = new Handler(Looper.getMainLooper())
this.initView()
this.makeBitmap()
}
handlerArguments() {
......@@ -133,7 +136,7 @@ export class WaitingView{
this.textView.setGravity(Gravity.CENTER)
this.textView.setText(this.title)
this.textView.setTextSize(0, (16 * this.density).toFloat())
if(this.title.length < 1){
// 没有文本需要展示
this.textView.setVisibility(View.GONE)
......@@ -166,8 +169,8 @@ export class WaitingView{
}
return this.context!.dispatchTouchEvent(ev)
}
showWaiting() {
if(this.context != null && !this.context!.isFinishing()){
let width = -2;
......@@ -179,7 +182,7 @@ export class WaitingView{
}
let mpop = new PopupWindow(this.waitingView, width.toInt(), height.toInt(), this.mask)
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.setOnDismissListener(new WaitingDismissListener())
mpop.setTouchInterceptor(new TouchInterceptorListener(this.mask))
......@@ -315,4 +318,4 @@ class TouchInterceptorListener implements View.OnTouchListener {
override onTouch(v: View, event: MotionEvent): boolean {
return this.interceptor
}
}
\ No newline at end of file
}
......@@ -31,7 +31,7 @@ let toastType : string | null = null
export function showToastImpl(style : ShowToastOptions) {
makeToast(style, 'toast', 'showToast')
}
export function hideToastImpl() {
......@@ -108,33 +108,33 @@ function makeLoading(style : ShowLoadingOptions, type : string, errMsg : string)
options["width"] = "140"
options["height"] = "112"
// #ifndef UNI-APP-X
/**
* uni-app
*/
const alert = new WaitingView(UTSAndroid.getTopPageActivity(), options)
const alert = new WaitingView(UTSAndroid.getTopPageActivity(), options,UTSAndroid.getTopPageView())
toast = alert
alert?.showWaiting();
UTSAndroid.onAppActivityDestroy(function(){
toast?.close()
toast = null
})
// #endif
// #ifdef UNI-APP-X
/**
* uni-app x
* 需要特殊处理生命周期
* 需要特殊处理生命周期
*/
const pages = getCurrentPages();
if (pages.length > 0) {
const page = pages[pages.length - 1].vm!
const instance = page.$
if (page.$isReady) {
const alert = new WaitingView(UTSAndroid.getTopPageActivity(), options)
const alert = new WaitingView(UTSAndroid.getTopPageActivity(), options,UTSAndroid.getTopPageView())
toast = alert
alert?.showWaiting();
} else {
......@@ -142,24 +142,24 @@ function makeLoading(style : ShowLoadingOptions, type : string, errMsg : string)
onReady(() => {
if(onReadyToast.containsKey(page)){
options = onReadyToast.get(page) as UTSJSONObject;
const alert = new WaitingView(UTSAndroid.getTopPageActivity(), options)
const alert = new WaitingView(UTSAndroid.getTopPageActivity(), options,UTSAndroid.getTopPageView())
toast = alert
alert?.showWaiting();
onReadyToast.remove(page)
}
}, instance)
}
onUnload(() => {
toast?.close()
toast = null
}, instance)
}
// #endif
const res : ShowLoadingSuccess = {
}
style.success?.(res)
......@@ -178,7 +178,7 @@ function makeToast(style : ShowToastOptions, type : string, errMsg : string) {
style.complete?.(res)
} else {
toastType = type
if (["top", "center", "bottom"].indexOf(style.position) >= 0) {
androidToast = Toast.makeText(UTSAndroid.getAppContext(), style.title, Toast.LENGTH_SHORT);
......@@ -200,7 +200,7 @@ function makeToast(style : ShowToastOptions, type : string, errMsg : string) {
androidToast!.show()
const res : ShowToastSuccess = {
}
style.success?.(res)
style.complete?.(res)
} else {
......@@ -240,8 +240,8 @@ function makeToast(style : ShowToastOptions, type : string, errMsg : string) {
}
}
// #ifndef UNI-APP-X
/**
* uni-app
......@@ -249,17 +249,17 @@ function makeToast(style : ShowToastOptions, type : string, errMsg : string) {
const alert = new WaitingView(UTSAndroid.getTopPageActivity(), options)
toast = alert
alert?.showWaiting();
UTSAndroid.onAppActivityDestroy(function(){
toast?.close()
toast = null
})
// #endif
// #ifdef UNI-APP-X
/**
* uni-app x
* 需要特殊处理生命周期
* 需要特殊处理生命周期
*/
const pages = getCurrentPages();
if (pages.length > 0) {
......@@ -274,24 +274,24 @@ function makeToast(style : ShowToastOptions, type : string, errMsg : string) {
onReady(() => {
if(onReadyToast.containsKey(page)){
options = onReadyToast.get(page) as UTSJSONObject;
const alert = new WaitingView(UTSAndroid.getTopPageActivity(), options)
toast = alert
alert?.showWaiting();
onReadyToast.remove(page)
}
}, instance)
}
onUnload(() => {
toast?.close()
toast = null
}, instance)
}
// #endif
let duration : number | null = style.duration
if (duration == null || duration <= 0) {
duration = 1500
......@@ -301,10 +301,10 @@ function makeToast(style : ShowToastOptions, type : string, errMsg : string) {
toast?.close()
}, duration)
}
const res : ShowToastSuccess = {
}
style.success?.(res)
style.complete?.(res)
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册