Skip to content

Commit bb4d307

Browse files
committed
add TwoButton Dialog
1 parent 1d34d5e commit bb4d307

File tree

1 file changed

+31
-12
lines changed

1 file changed

+31
-12
lines changed

scdisplayutils/src/main/java/com/stevechulsdev/scdisplayutils/ScDisplayUtils.kt

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ object ScDisplayUtils {
3434
if(largeCircle) {
3535
mProgressBar = ProgressBar(activity.applicationContext, null, android.R.attr.progressBarStyleLarge).apply {
3636
isIndeterminate = true
37-
setBackgroundColor(ContextCompat.getColor(activity, android.R.color.transparent))
3837
visibility = View.VISIBLE
3938

4039
try {
@@ -49,9 +48,8 @@ object ScDisplayUtils {
4948
}
5049
}
5150
else {
52-
mProgressBar = ProgressBar(activity.applicationContext, null, android.R.attr.progressBarStyleInverse).apply {
51+
mProgressBar = ProgressBar(activity.applicationContext, null, android.R.attr.progressBarStyle).apply {
5352
isIndeterminate = true
54-
setBackgroundColor(ContextCompat.getColor(activity, android.R.color.transparent))
5553
visibility = View.VISIBLE
5654

5755
try {
@@ -74,7 +72,7 @@ object ScDisplayUtils {
7472
rl!!.gravity = Gravity.CENTER
7573
rl!!.addView(mProgressBar)
7674
rl!!.isClickable = true
77-
// rl!!.setBackgroundColor(Color.parseColor("#80000000"))
75+
rl!!.setBackgroundColor(Color.parseColor("#80000000"))
7876

7977
layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT)
8078

@@ -85,15 +83,15 @@ object ScDisplayUtils {
8583
* Hide ProgressBar
8684
*/
8785
fun hideProgressBar() {
88-
// mProgressBar?.let { it.apply {
89-
// if(visibility == View.VISIBLE) visibility = View.GONE
90-
// } }
86+
mProgressBar?.let { it.apply {
87+
if(visibility == View.VISIBLE) visibility = View.GONE
88+
} }
9189

92-
// parent?.let { viewGroup ->
93-
// rl?.let {
94-
// viewGroup.removeView(it)
95-
// }
96-
// }
90+
parent?.let { viewGroup ->
91+
rl?.let {
92+
viewGroup.removeView(it)
93+
}
94+
}
9795

9896
mProgressBar = null
9997
rl = null
@@ -130,7 +128,28 @@ object ScDisplayUtils {
130128
}.show()
131129
}
132130

131+
fun showDialog(context: Context, dialogTitle: String, dialogMsg: String, dialogTwoButtonClickListener: DialogTwoButtonClickListener? = null, firstButtonText: String = "확인", secondButtonText: String = "취소", dismissOutSideTouch: Boolean = false) {
132+
context.alert(dialogMsg, dialogTitle) {
133+
isCancelable = dismissOutSideTouch
134+
positiveButton(firstButtonText) {
135+
dialogTwoButtonClickListener?.let {
136+
it.onClickConfirm()
137+
}
138+
}
139+
negativeButton(secondButtonText) {
140+
dialogTwoButtonClickListener?.let {
141+
it.onCLickCancel()
142+
}
143+
}
144+
}.show()
145+
}
146+
133147
interface DialogOneButtonClickListener {
134148
fun onClick()
135149
}
150+
151+
interface DialogTwoButtonClickListener {
152+
fun onClickConfirm()
153+
fun onCLickCancel()
154+
}
136155
}

0 commit comments

Comments
 (0)