diff options
author | Samuel Holland <samuel@sholland.org> | 2018-01-06 04:30:34 -0600 |
---|---|---|
committer | Samuel Holland <samuel@sholland.org> | 2018-01-06 05:18:34 -0600 |
commit | 9d0a5943a31aa6a02548940357e3365f42ddc030 (patch) | |
tree | 054669713af43da487fd6b8a37efacba24780936 /app/src/main/java/com | |
parent | 6f8f35b3fe306ade222c9e96615d830c10348466 (diff) |
MainActivity: Fix ActionBar after rotation
Signed-off-by: Samuel Holland <samuel@sholland.org>
Diffstat (limited to 'app/src/main/java/com')
-rw-r--r-- | app/src/main/java/com/wireguard/android/activity/MainActivity.java | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/app/src/main/java/com/wireguard/android/activity/MainActivity.java b/app/src/main/java/com/wireguard/android/activity/MainActivity.java index e13438d9..a905156c 100644 --- a/app/src/main/java/com/wireguard/android/activity/MainActivity.java +++ b/app/src/main/java/com/wireguard/android/activity/MainActivity.java @@ -53,14 +53,9 @@ public class MainActivity extends BaseActivity { return true; } state = nextState; - if (state.layer > 1) { - if (getActionBar() != null) - getActionBar().setDisplayHomeAsUpEnabled(true); - } else { - if (getActionBar() != null) - getActionBar().setDisplayHomeAsUpEnabled(false); + if (state.layer <= State.LIST.layer) setSelectedTunnel(null); - } + updateActionBar(); return true; } @@ -82,6 +77,7 @@ public class MainActivity extends BaseActivity { initialState = State.valueOf(getIntent().getStringExtra(KEY_STATE)); moveToState(initialState); } + updateActionBar(); } @Override @@ -124,6 +120,11 @@ public class MainActivity extends BaseActivity { moveToState(newTunnel != null ? State.DETAIL : State.LIST); } + private void updateActionBar() { + if (getActionBar() != null) + getActionBar().setDisplayHomeAsUpEnabled(state.layer > State.LIST.layer); + } + private enum State { EMPTY(null, 0), LIST(TunnelListFragment.class, 1), |