Skip to content

Commit 91ee5c6

Browse files
committed
Dismiss dialog on button click
1 parent aa12525 commit 91ee5c6

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ publish {
3636
userOrg = 'buffer'
3737
groupId = 'org.buffer.android'
3838
artifactId = 'android-components'
39-
publishVersion = '0.11'
39+
publishVersion = '0.12'
4040
desc = 'An Android library for frequently used UI components'
4141
website = 'https://github.com/bufferapp/android-components'
4242
}

app/src/main/java/org/buffer/android/components/DialogFactory.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ object DialogFactory {
3838
neutralListener: View.OnClickListener? = null
3939
): AlertDialog {
4040
val view = LayoutInflater.from(context).inflate(R.layout.dialog_whats_new, null)
41+
val alert = AlertDialog.Builder(context).setView(view).create()
4142

4243
title?.let {
4344
view.titleText.text = context.getString(title)
@@ -67,6 +68,7 @@ object DialogFactory {
6768
view.positiveButton.text = context.getString(positive)
6869
view.positiveButton.setOnClickListener {
6970
positiveListener?.onClick(view.positiveButton)
71+
alert.dismiss()
7072
}
7173
} ?: run {
7274
view.positiveButton.visibility = View.GONE
@@ -76,12 +78,13 @@ object DialogFactory {
7678
view.neutralButton.text = context.getString(neutral)
7779
view.neutralButton.setOnClickListener {
7880
neutralListener?.onClick(view.neutralButton)
81+
alert.dismiss()
7982
}
8083
} ?: run {
8184
view.neutralButton.visibility = View.GONE
8285
}
8386

84-
return AlertDialog.Builder(context).setView(view).create()
87+
return alert
8588
}
8689

8790
fun createSimpleYesNoDialog(

0 commit comments

Comments
 (0)