214 When exit button is pressed all resources are released.

This commit is contained in:
Victor Shcherb 2011-05-04 00:05:12 +02:00
parent 2339b2334e
commit 1b4025ab4a
4 changed files with 19 additions and 3 deletions

View file

@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.osmand.plus" android:installLocation="auto" android:versionName="0.6.2" android:versionCode="31">
<application android:icon="@drawable/icon" android:label="@string/app_name"
android:debuggable="false" android:name=".activities.OsmandApplication" android:description="@string/app_description">
android:debuggable="true" android:name=".activities.OsmandApplication" android:description="@string/app_description">
<activity android:name=".activities.MainMenuActivity"
android:label="@string/app_name">
<intent-filter>

View file

@ -174,6 +174,7 @@ public class MainMenuActivity extends Activity {
closeButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
((OsmandApplication) getApplication()).closeApplication();
finish();
}
});

View file

@ -196,7 +196,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
settings = OsmandSettings.getPrefs(this);
// for voice navigation
setVolumeControlStream(AudioManager.STREAM_MUSIC);
requestWindowFeature(Window.FEATURE_NO_TITLE);
requestWindowFeature(Window.FEATURE_NO_TITLE);
// Full screen is not used here
// getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);

View file

@ -47,6 +47,7 @@ public class OsmandApplication extends Application {
private Handler uiHandler;
private DayNightHelper daynightHelper;
private NavigationService navigationService;
private boolean applicationInitializing = false;
public void onCreate(){
@ -87,6 +88,8 @@ public class OsmandApplication extends Application {
}
public ProgressDialog checkApplicationIsBeingInitialized(Context uiContext){
// start application if it was previously closed
startApplication();
synchronized (OsmandApplication.this) {
if(startDialog != null){
progressDlg = ProgressDialog.show(uiContext, getString(R.string.loading_data), getString(R.string.reading_indexes), true);
@ -170,8 +173,20 @@ public class OsmandApplication extends Application {
public void setNavigationService(NavigationService navigationService) {
this.navigationService = navigationService;
}
public synchronized void closeApplication(){
if(applicationInitializing){
manager.close();
}
applicationInitializing = false;
}
public void startApplication() {
public synchronized void startApplication() {
if(applicationInitializing){
return;
}
applicationInitializing = true;
startDialog = new ProgressDialogImplementation(this, null, false);
startDialog.setRunnable("Initializing app", new Runnable() { //$NON-NLS-1$