diff --git a/examples/src/main/java/org/hitogo/examples/MainActivity.java b/examples/src/main/java/org/hitogo/examples/MainActivity.java index 54dec10..1c02205 100644 --- a/examples/src/main/java/org/hitogo/examples/MainActivity.java +++ b/examples/src/main/java/org/hitogo/examples/MainActivity.java @@ -27,9 +27,10 @@ protected void onCreate(Bundle savedInstanceState) { //sourceTest(); //showFirstView(); //showPrioAlerts(); - showPrioAlerts2(); + //showPrioAlerts2(); //testImage(); //testButtonImage(); + dialogTestThreeButtons(); // DialogAlerts support up to three buttons //testToast(); testSnackbar(); @@ -442,6 +443,53 @@ public void onClick(@NonNull Alert alert, Object parameter) { .show(); } + private void dialogTestThreeButtons() { + TextButton button1 = Hitogo.with(this) + .asTextButton() + .setButtonListener(new ButtonListener() { + @Override + public void onClick(@NonNull Alert alert, Object parameter) { + showPopup(); + } + }) + .addText("Button 1") + .build(); + + TextButton button2 = Hitogo.with(this) + .asTextButton() + .setButtonListener(new ButtonListener() { + @Override + public void onClick(@NonNull Alert alert, Object parameter) { + showPopup(); + } + }) + .addText("Button 2") + .build(); + + TextButton button3 = Hitogo.with(this) + .asTextButton() + .setButtonListener(new ButtonListener() { + @Override + public void onClick(@NonNull Alert alert, Object parameter) { + showPopup(); + } + }) + .addText("Button 3") + .build(); + + Hitogo.with(this) + .asDialogAlert() + .setTitle(R.id.title, "Test Dialog") + .addText(R.id.text, "Long message...") + .setState(AlertState.DANGER) + .addButton(button1) + .addButton(button2) + .addButton(button3) + .asDismissible() + .setTag("Test Dialog 2 Buttons") + .show(); + } + private void showSecondView() { ViewButton button = Hitogo.with(this) .asViewButton() diff --git a/library/src/main/java/org/hitogo/alert/dialog/DialogAlertImpl.java b/library/src/main/java/org/hitogo/alert/dialog/DialogAlertImpl.java old mode 100644 new mode 100755 index 8ad0c7f..2bda6a5 --- a/library/src/main/java/org/hitogo/alert/dialog/DialogAlertImpl.java +++ b/library/src/main/java/org/hitogo/alert/dialog/DialogAlertImpl.java @@ -288,14 +288,14 @@ public void onClick(DialogInterface dialog, int id) { }); break; default: + if (getController().provideIsDebugState()) { + throw new InvalidParameterException("Dialog only supports up to three different " + + "builder buttons (primary, secondary and neutral)!"); + } break; } - dialogButtonCount++; - if (getController().provideIsDebugState() && dialogButtonCount >= MAX_BUILDER_BUTTON_AMOUNT) { - throw new InvalidParameterException("Dialog only supports up to three different " + - "builder buttons (primary, secondary and neutral)!"); - } + dialogButtonCount++; } else if (getController().provideIsDebugState()) { throw new InvalidParameterException("Empty button text cannot be added to the dialog."); }