Skip to content
This repository has been archived by the owner on Aug 10, 2022. It is now read-only.

Commit

Permalink
Merge pull request #8 from Henkoglobin/dialog_alert_bug
Browse files Browse the repository at this point in the history
Fixed a bug that prevents one from adding a third button to a DialogA…
  • Loading branch information
Mordag authored Oct 21, 2018
2 parents 7b656ce + 079db4f commit 5e77041
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 6 deletions.
50 changes: 49 additions & 1 deletion examples/src/main/java/org/hitogo/examples/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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()
Expand Down
10 changes: 5 additions & 5 deletions library/src/main/java/org/hitogo/alert/dialog/DialogAlertImpl.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
Expand Down

0 comments on commit 5e77041

Please sign in to comment.