package com.spiddekauga.android;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.ViewGroup;

/**
 * Base class for Android Activities
 */
public abstract class AppActivity extends AppCompatActivity {
static private AppCompatActivity mActivity;

/**
 * Exit the application
 */
public static void exit() {
	if (mActivity != null) {
		Intent intent = new Intent(Intent.ACTION_MAIN);
		intent.addCategory(Intent.CATEGORY_HOME);
		intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		mActivity.startActivity(intent);
	}
}

/**
 * @return the context for this app
 */
public static AppCompatActivity getActivity() {
	return mActivity;
}

/**
 * Switch to the specified activity
 * @param activityClass the activity to switch to
 */
public static void switchTo(Class<? extends Activity> activityClass) {
	if (mActivity != null) {
		Intent intent = new Intent(mActivity, activityClass);
		mActivity.startActivity(intent);
	}
}

/**
 * Set the title of the action bar (if it exists)
 * @param title title of the action bar
 */
public static void setTitle(String title) {
	ActionBar actionBar = mActivity.getSupportActionBar();
	if (actionBar != null) {
		actionBar.setTitle(title);
	}
}

public static View getRootView() {
	View contentView = mActivity.findViewById(android.R.id.content);
	return ((ViewGroup) contentView).getChildAt(0);
}

@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	mActivity = this;
}

@Override
protected void onResume() {
	super.onResume();
	mActivity = this;
}
}

@@ -31,37 +31,8 @@
 d;%0A%0A
-import android.app.Activity;%0A
 impo
@@ -58,16 +58,16 @@
 Intent;%0A
+
 import a
@@ -381,16 +381,65 @@
 Activity
+ = null;%0Aprivate static boolean mFirstTime = true
 ;%0A%0A/**%0A 
@@ -956,16 +956,19 @@
 extends 
+App
 Activity
@@ -1621,16 +1621,16 @@
 State);%0A
-
 %09mActivi
@@ -1640,16 +1640,169 @@
 = this;%0A
+%0A%09if (mFirstTime) %7B%0A%09%09mFirstTime = false;%0A%09%09onFirstTime();%0A%09%7D%0A%7D%0A%0A/**%0A * Called first time the application is started%0A */%0Aprotected void onFirstTime() %7B%0A%0A
 %7D%0A%0A@Over

Add onFirstTime() for AppActivity