MainActivity: Fix ActionBar after rotation
Signed-off-by: Samuel Holland <samuel@sholland.org>
This commit is contained in:
		
							parent
							
								
									2206dfc432
								
							
						
					
					
						commit
						2543f28274
					
				| @ -53,14 +53,9 @@ public class MainActivity extends BaseActivity { | |||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|         state = nextState; |         state = nextState; | ||||||
|         if (state.layer > 1) { |         if (state.layer <= State.LIST.layer) | ||||||
|             if (getActionBar() != null) |  | ||||||
|                 getActionBar().setDisplayHomeAsUpEnabled(true); |  | ||||||
|         } else { |  | ||||||
|             if (getActionBar() != null) |  | ||||||
|                 getActionBar().setDisplayHomeAsUpEnabled(false); |  | ||||||
|             setSelectedTunnel(null); |             setSelectedTunnel(null); | ||||||
|         } |         updateActionBar(); | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -82,6 +77,7 @@ public class MainActivity extends BaseActivity { | |||||||
|                 initialState = State.valueOf(getIntent().getStringExtra(KEY_STATE)); |                 initialState = State.valueOf(getIntent().getStringExtra(KEY_STATE)); | ||||||
|             moveToState(initialState); |             moveToState(initialState); | ||||||
|         } |         } | ||||||
|  |         updateActionBar(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
| @ -124,6 +120,11 @@ public class MainActivity extends BaseActivity { | |||||||
|         moveToState(newTunnel != null ? State.DETAIL : State.LIST); |         moveToState(newTunnel != null ? State.DETAIL : State.LIST); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     private void updateActionBar() { | ||||||
|  |         if (getActionBar() != null) | ||||||
|  |             getActionBar().setDisplayHomeAsUpEnabled(state.layer > State.LIST.layer); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     private enum State { |     private enum State { | ||||||
|         EMPTY(null, 0), |         EMPTY(null, 0), | ||||||
|         LIST(TunnelListFragment.class, 1), |         LIST(TunnelListFragment.class, 1), | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user