package au.com.codeka.warworlds.client;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.Toolbar;

import com.google.common.base.Preconditions;

import au.com.codeka.warworlds.client.activity.BaseFragmentActivity;
import au.com.codeka.warworlds.client.ctrl.DebugView;
import au.com.codeka.warworlds.client.opengl.RenderSurfaceView;
import au.com.codeka.warworlds.client.game.starfield.StarfieldManager;
import au.com.codeka.warworlds.client.util.GameSettings;
import au.com.codeka.warworlds.client.game.welcome.CreateEmpireFragment;
import au.com.codeka.warworlds.client.game.welcome.WarmWelcomeFragment;
import au.com.codeka.warworlds.client.game.welcome.WelcomeFragment;
import au.com.codeka.warworlds.common.Log;

import static com.google.common.base.Preconditions.checkNotNull;

public class MainActivity extends BaseFragmentActivity {
  private static final Log log = new Log("MainActivity");

  // Will be non-null between of onCreate/onDestroy.
  @Nullable private StarfieldManager starfieldManager;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    createFragmentTransitionManager(R.id.fragment_container);

    setSupportActionBar(findViewById(R.id.toolbar));
    checkNotNull(getSupportActionBar()).hide();

    RenderSurfaceView renderSurfaceView = checkNotNull(findViewById(R.id.render_surface));
    renderSurfaceView.setRenderer();
    starfieldManager = new StarfieldManager(renderSurfaceView);
    starfieldManager.create();

    DebugView debugView = checkNotNull(findViewById(R.id.debug_view));
    debugView.setFrameCounter(renderSurfaceView.getFrameCounter());

    if (savedInstanceState == null) {
      if (!GameSettings.i.getBoolean(GameSettings.Key.WARM_WELCOME_SEEN)) {
        getFragmentTransitionManager().replaceFragment(WarmWelcomeFragment.class);
      } else if (GameSettings.i.getString(GameSettings.Key.COOKIE).isEmpty()) {
        getFragmentTransitionManager().replaceFragment(CreateEmpireFragment.class);
      } else {
        getFragmentTransitionManager().replaceFragment(WelcomeFragment.class);
      }
    }
  }

  @NonNull
  public StarfieldManager getStarfieldManager() {
    return checkNotNull(starfieldManager);
  }

  @Override
  public void onDestroy() {
    super.onDestroy();

    starfieldManager.destroy();
    starfieldManager = null;
  }
}

@@ -34,16 +34,48 @@
 lient;%0A%0A
+import android.content.Context;%0A
 import a
@@ -838,16 +838,34 @@
 mon.Log;
+%0Aimport flow.Flow;
 %0A%0Aimport
@@ -1149,16 +1149,196 @@
 nager;%0A%0A
+  @Override%0A  protected void attachBaseContext(Context baseContext) %7B%0A    baseContext = Flow.configure(baseContext, this).install();%0A    super.attachBaseContext(baseContext);%0A  %7D%0A%0A
   @Overr

Configure Flow.