Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions app/src/main/java/com/dozingcatsoftware/bouncy/BouncyActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,8 @@ public void doStartGame(View view) {
// synchronized because that can deadlock the FieldDriver thread.
// All of this concurrency is badly in need of refactoring.
synchronized (field) {
restoreMenuHeight();

buttonPanel.setVisibility(View.GONE);
highScorePanel.setVisibility(View.GONE);
resetFieldForCurrentLevel();
Expand Down Expand Up @@ -674,6 +676,8 @@ else if (!state.isGameInProgress()) {
}

void switchToTable(int tableNum) {
shrinkMenuToTableSelectionSize();

this.currentLevel = tableNum;
synchronized (field) {
resetFieldForCurrentLevel();
Expand All @@ -690,6 +694,28 @@ public void doSwitchTable(View view) {
doNextTable(view);
}


private int menuHeight;
private int tableSelectionHeight;

private void shrinkMenuToTableSelectionSize() {
// There must be a better place to obtain this information
if (menuHeight == 0) {
menuHeight = buttonPanel.getHeight();
tableSelectionHeight = previousTableButton.getHeight();
}

buttonPanel.getLayoutParams().height = tableSelectionHeight;
buttonPanel.setLayoutParams(buttonPanel.getLayoutParams());
}

private void restoreMenuHeight() {
if (menuHeight != 0) {
buttonPanel.getLayoutParams().height = menuHeight;
buttonPanel.setLayoutParams(buttonPanel.getLayoutParams());
}
}

public void doNextTable(View view) {
int nextTableNum = (currentLevel == numberOfLevels) ? 1 : currentLevel + 1;
switchToTable(nextTableNum);
Expand Down