From e2ab2210cdda2d598c213f07dbc1d1199499ffd3 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Sun, 6 May 2018 03:02:22 +0530 Subject: 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 --- app/src/main/java/com/wireguard/android/activity/MainActivity.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'app/src/main/java/com') 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 9494dd22..21bec130 100644 --- a/app/src/main/java/com/wireguard/android/activity/MainActivity.java +++ b/app/src/main/java/com/wireguard/android/activity/MainActivity.java @@ -35,11 +35,11 @@ public class MainActivity extends BaseActivity { private State state = State.EMPTY; private boolean moveToState(final State nextState) { + if (state == nextState) + return false; final FragmentManager fragmentManager = getSupportFragmentManager(); Log.i(TAG, "Moving from " + state.name() + " to " + nextState.name()); - if (nextState == state) { - return false; - } else if (nextState.layer > state.layer + 1) { + if (nextState.layer > state.layer + 1) { moveToState(State.ofLayer(state.layer + 1)); moveToState(nextState); return true; -- cgit v1.2.3