MainActivity: Nip out as early as possible when moving to same fragment
Save the useless logging and fragment manager object creation. Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
332c35747e
commit
e2ab2210cd
@ -35,11 +35,11 @@ public class MainActivity extends BaseActivity {
|
|||||||
private State state = State.EMPTY;
|
private State state = State.EMPTY;
|
||||||
|
|
||||||
private boolean moveToState(final State nextState) {
|
private boolean moveToState(final State nextState) {
|
||||||
|
if (state == nextState)
|
||||||
|
return false;
|
||||||
final FragmentManager fragmentManager = getSupportFragmentManager();
|
final FragmentManager fragmentManager = getSupportFragmentManager();
|
||||||
Log.i(TAG, "Moving from " + state.name() + " to " + nextState.name());
|
Log.i(TAG, "Moving from " + state.name() + " to " + nextState.name());
|
||||||
if (nextState == state) {
|
if (nextState.layer > state.layer + 1) {
|
||||||
return false;
|
|
||||||
} else if (nextState.layer > state.layer + 1) {
|
|
||||||
moveToState(State.ofLayer(state.layer + 1));
|
moveToState(State.ofLayer(state.layer + 1));
|
||||||
moveToState(nextState);
|
moveToState(nextState);
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user