1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package com.miya.fastcashier.ui.dialog
import android.app.Dialog
import android.content.Context
import android.view.Gravity
import android.view.WindowManager
import android.widget.ImageView
import android.widget.TextView
import com.fastcashier.lib_common.util.StringPriceFormatUtils
import com.fastcashier.lib_common.util.clickWithTrigger
import com.miya.fastcashier.R
import com.sdy.miya.moblie.component.pay.platform.bean.PayServiceResponse
/**
* 退款信息弹窗
*/
class RefundInfoDialog(context: Context) : Dialog(context) {
private lateinit var ivClose: ImageView
private lateinit var tvRefund: TextView
private lateinit var tvPrice: TextView
private lateinit var payServiceResponse: PayServiceResponse
init {
initWindow()
initConfig()
initView()
}
private fun initConfig() {
setCancelable(false)
}
private fun initView() {
setContentView(R.layout.dialog_refund_info)
ivClose = findViewById(R.id.ivClose)
ivClose.clickWithTrigger {
dismiss()
}
tvRefund = findViewById(R.id.tvRefund)
tvPrice = findViewById(R.id.tvPrice)
}
fun setData(payServiceResponse: PayServiceResponse, action: (PayServiceResponse) -> Unit) {
this.payServiceResponse = payServiceResponse
tvPrice.text =
"¥${StringPriceFormatUtils.transStringPriceToDecimalString(payServiceResponse.tradPrice)}"
tvRefund.clickWithTrigger {
action.invoke(payServiceResponse)
}
}
private fun initWindow() {
val win = this.window
win!!.decorView.setPadding(0, 0, 0, 0)
val lp = win.attributes
lp.width = WindowManager.LayoutParams.MATCH_PARENT
lp.height = WindowManager.LayoutParams.WRAP_CONTENT
lp.gravity = Gravity.BOTTOM
lp.windowAnimations = R.style.BottomInAndOutStyle
win.attributes = lp
win.setBackgroundDrawableResource(R.color.transparent)
}
}