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

Commit

Permalink
Correctly calculate number of selected tickets
Browse files Browse the repository at this point in the history
  • Loading branch information
kordianbruck committed Apr 10, 2019
1 parent 8aee0f9 commit ee5406d
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,21 @@ private int getTotalPrice() {
return sum;
}

private int getTotalTickets() {
if (currentTicketAmounts == null) {
Utils.log("currentTicketAmounts not initialized");
return 0;
}
int sum = 0;
for (int i = 0; i < ticketTypes.size(); i++) {
Integer count = currentTicketAmounts[i];
if (count != null && count > 0) {
sum += count;
}
}
return sum;
}

private void showError(int title, int message) {
AlertDialog dialog = new AlertDialog.Builder(this)
.setTitle(title)
Expand Down Expand Up @@ -185,7 +200,7 @@ private Integer[] getTicketTypeIds() {
}

private boolean zeroTicketsSelected() {
return getTotalPrice() == 0;
return getTotalTickets() == 0;
}

private void reserveTicket() {
Expand Down

0 comments on commit ee5406d

Please sign in to comment.