| | |
| | | } |
| | | } |
| | | |
| | | fun showAlertDialog2( |
| | | context: Context?, |
| | | content: String, |
| | | pStr: String? = null, |
| | | nStr: String? = null, |
| | | onConfirmed: (dialog: Dialog) -> Unit = { it.dismiss() }, |
| | | onCanceled: (dialog: Dialog) -> Unit = { it.dismiss() } |
| | | ): Dialog? { |
| | | val view = LayoutInflater.from(context).inflate(R.layout.dialog_alert_2, null) |
| | | return context?.let { |
| | | Dialog(it).apply { |
| | | setCancelable(false) |
| | | setCanceledOnTouchOutside(false) |
| | | setContentView(view) |
| | | view.findViewById<TextView>(R.id.tv_dialog_content).text = content |
| | | view.findViewById<TextView>(R.id.tv_positive).let {t -> |
| | | pStr?.let { p -> t.text = p } |
| | | t.setOnClickListener { onConfirmed(this) } |
| | | } |
| | | view.findViewById<TextView>(R.id.tv_neutral).let {t -> |
| | | nStr?.let { n -> t.text = n } |
| | | t.setOnClickListener { onCanceled(this) } |
| | | } |
| | | window?.attributes?.apply { |
| | | gravity = Gravity.CENTER |
| | | width = (ScreenUtils.getScreenWidth(context) * 0.8).toInt() |
| | | windowAnimations = R.style.dialog_anim_style |
| | | } |
| | | window?.setBackgroundDrawableResource(android.R.color.transparent) |
| | | window?.setGravity(Gravity.CENTER) |
| | | show() |
| | | } |
| | | } |
| | | } |
| | | |
| | | fun showBottomDialog( |
| | | activity: Activity?, |
| | | anchorView: View, |