Skip to content

Commit 6aca118

Browse files
committed
Add custom title support for theme dialog
1 parent af6d5a1 commit 6aca118

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed

dynamic-support/src/main/java/com/pranavpandey/android/dynamic/support/theme/dialog/DynamicThemeDialog.java

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ public class DynamicThemeDialog<T extends DynamicAppTheme, V> extends DynamicDia
8787
*/
8888
private @Theme.Action int mThemeAction;
8989

90+
/**
91+
* Custom title for the dialog.
92+
*/
93+
private CharSequence mTitle;
94+
9095
/**
9196
* Optional message for the dialog.
9297
*/
@@ -394,7 +399,11 @@ public void onShow(DialogInterface dialog) {
394399
break;
395400
}
396401

402+
if (mTitle != null) {
403+
dialogBuilder.setTitle(mTitle);
404+
}
397405
Dynamic.set(mMessageView, mMessage);
406+
398407
return dialogBuilder.setView(view);
399408
}
400409

@@ -480,16 +489,39 @@ private void updatePositiveButton(@Nullable CharSequence charSequence) {
480489
}
481490

482491
/**
483-
* Get the message used by this dialog.
492+
* Get the custom title used by this dialog.
493+
*
494+
* @return The custom title used by this dialog.
495+
*/
496+
public @Nullable CharSequence getTitle() {
497+
return mTitle;
498+
}
499+
500+
/**
501+
* Set the custom title for this dialog.
502+
*
503+
* @param title The title to be set.
504+
*
505+
* @return The {@link DynamicThemeDialog} object to allow for chaining of calls to
506+
* set methods.
507+
*/
508+
public @NonNull DynamicThemeDialog<T, V> setTitle(@Nullable CharSequence title) {
509+
this.mTitle = title;
510+
511+
return this;
512+
}
513+
514+
/**
515+
* Get the optional message used by this dialog.
484516
*
485-
* @return The message used by this dialog.
517+
* @return The optional message used by this dialog.
486518
*/
487519
public @Nullable CharSequence getMessage() {
488520
return mMessage;
489521
}
490522

491523
/**
492-
* Get the optional message for this dialog.
524+
* Set the optional message for this dialog.
493525
*
494526
* @param message The message to be set.
495527
*

0 commit comments

Comments
 (0)