2012-04-03 11:58:01 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
package org.mozilla.gecko;
|
|
|
|
|
|
|
|
import android.app.Application;
|
|
|
|
|
2012-07-27 17:53:54 -07:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
2012-07-17 17:54:54 -07:00
|
|
|
public class GeckoApplication extends Application {
|
|
|
|
|
2012-09-27 07:52:59 -07:00
|
|
|
private boolean mInited;
|
2012-09-14 08:19:40 -07:00
|
|
|
private boolean mInBackground;
|
2012-04-03 11:58:01 -07:00
|
|
|
|
2012-10-31 22:10:59 -07:00
|
|
|
private LightweightTheme mLightweightTheme;
|
|
|
|
|
2012-09-27 07:52:59 -07:00
|
|
|
protected void initialize() {
|
|
|
|
if (mInited)
|
|
|
|
return;
|
|
|
|
|
2012-07-06 22:38:05 -07:00
|
|
|
// workaround for http://code.google.com/p/android/issues/detail?id=20915
|
|
|
|
try {
|
|
|
|
Class.forName("android.os.AsyncTask");
|
|
|
|
} catch (ClassNotFoundException e) {}
|
|
|
|
|
2012-10-31 22:10:59 -07:00
|
|
|
mLightweightTheme = new LightweightTheme(this);
|
|
|
|
|
2012-09-14 08:19:40 -07:00
|
|
|
GeckoConnectivityReceiver.getInstance().init(getApplicationContext());
|
|
|
|
GeckoBatteryManager.getInstance().init(getApplicationContext());
|
|
|
|
GeckoBatteryManager.getInstance().start();
|
|
|
|
GeckoNetworkManager.getInstance().init(getApplicationContext());
|
2012-09-19 12:21:19 -07:00
|
|
|
MemoryMonitor.getInstance().init(getApplicationContext());
|
2012-09-27 07:52:59 -07:00
|
|
|
mInited = true;
|
2012-04-03 11:58:01 -07:00
|
|
|
}
|
|
|
|
|
2012-09-14 08:19:40 -07:00
|
|
|
protected void onActivityPause(GeckoActivity activity) {
|
2012-05-08 16:40:12 -07:00
|
|
|
mInBackground = true;
|
|
|
|
|
2012-09-14 08:19:40 -07:00
|
|
|
GeckoAppShell.sendEventToGecko(GeckoEvent.createPauseEvent(true));
|
|
|
|
GeckoConnectivityReceiver.getInstance().stop();
|
|
|
|
GeckoNetworkManager.getInstance().stop();
|
2012-04-03 11:58:01 -07:00
|
|
|
}
|
|
|
|
|
2012-09-14 08:19:40 -07:00
|
|
|
protected void onActivityResume(GeckoActivity activity) {
|
|
|
|
if (GeckoApp.checkLaunchState(GeckoApp.LaunchState.GeckoRunning))
|
|
|
|
GeckoAppShell.sendEventToGecko(GeckoEvent.createResumeEvent(true));
|
|
|
|
GeckoConnectivityReceiver.getInstance().start();
|
|
|
|
GeckoNetworkManager.getInstance().start();
|
2012-05-08 16:40:12 -07:00
|
|
|
|
|
|
|
mInBackground = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isApplicationInBackground() {
|
|
|
|
return mInBackground;
|
2012-04-03 11:58:01 -07:00
|
|
|
}
|
2012-10-31 22:10:59 -07:00
|
|
|
|
|
|
|
public LightweightTheme getLightweightTheme() {
|
|
|
|
return mLightweightTheme;
|
|
|
|
}
|
2012-04-03 11:58:01 -07:00
|
|
|
}
|