diff --git a/app/src/main/java/com/dozingcatsoftware/bouncy/BouncyActivity.java b/app/src/main/java/com/dozingcatsoftware/bouncy/BouncyActivity.java index c572692..085752c 100644 --- a/app/src/main/java/com/dozingcatsoftware/bouncy/BouncyActivity.java +++ b/app/src/main/java/com/dozingcatsoftware/bouncy/BouncyActivity.java @@ -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(); @@ -674,6 +676,8 @@ else if (!state.isGameInProgress()) { } void switchToTable(int tableNum) { + shrinkMenuToTableSelectionSize(); + this.currentLevel = tableNum; synchronized (field) { resetFieldForCurrentLevel(); @@ -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);