Skip to content

Commit 4da0959

Browse files
authored
Add neutral button support to yes no dialog function (#4)
* Add drawable support to text option adapter * Add neutral button support to yes/no dialog Revert changtes Revert changtes
1 parent bddeb0b commit 4da0959

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
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.19'
39+
publishVersion = '1.1'
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: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,23 @@ object DialogFactory {
9191
context: Context,
9292
title: String,
9393
message: String? = null,
94-
positive: String,
95-
negative: String,
94+
positive: String? = null,
95+
negative: String? = null,
96+
neutral: String? = null,
9697
positiveListener: DialogInterface.OnClickListener? = null,
97-
negativeListener: DialogInterface.OnClickListener? = null
98+
negativeListener: DialogInterface.OnClickListener? = null,
99+
neutralListener: DialogInterface.OnClickListener? = null
98100
): AlertDialog {
99-
val alertDialog = MaterialAlertDialogBuilder(context)
100-
.setTitle(title)
101-
.setPositiveButton(positive, positiveListener)
102-
.setNegativeButton(negative, negativeListener)
101+
val alertDialog = MaterialAlertDialogBuilder(context).setTitle(title)
102+
if (positive != null) {
103+
alertDialog.setPositiveButton(positive, positiveListener)
104+
}
105+
if (negative != null) {
106+
alertDialog.setNegativeButton(negative, negativeListener)
107+
}
108+
if (neutral != null) {
109+
alertDialog.setNeutralButton(neutral, neutralListener)
110+
}
103111
if (!message.isNullOrBlank()) {
104112
alertDialog.setMessage(message)
105113
}

0 commit comments

Comments
 (0)