From a524d531e49b8c1c818c7db183914b45f97a7aee 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') 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