package com.nilhcem.frcndict.core;

import android.app.Dialog;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;

import com.nilhcem.frcndict.R;
import com.nilhcem.frcndict.about.AboutDialog;

// classes which extends from this will have an option menu
public class AbstractMenuActivity extends AbstractDictActivity {
	private Dialog mAboutDialog = null;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		if (savedInstanceState != null) {
			if (savedInstanceState.getBoolean("about-displayed", false)) {
				getAboutDialog().show();
			}
		}
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.main_menu, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		if (item.getItemId() == R.id.main_menu_about) {
			getAboutDialog().show();
			return true;
		} else {
			return super.onOptionsItemSelected(item);
		}
	}

	@Override
	protected void onSaveInstanceState(Bundle outState) {
		super.onSaveInstanceState(outState);

		if (mAboutDialog != null && mAboutDialog.isShowing()) {
			outState.putBoolean("about-displayed", true);
			mAboutDialog.dismiss();
		}
	}

	// lazy get
	private Dialog getAboutDialog() {
		if (mAboutDialog == null) {
			mAboutDialog = new AboutDialog(this, R.style.sAboutDialog);
		}
		return mAboutDialog;
	}
}

@@ -624,19 +624,22 @@
 ) %7B%0A%09%09%09%09
-get
+create
 AboutDia
@@ -952,19 +952,22 @@
 t) %7B%0A%09%09%09
-get
+create
 AboutDia
@@ -1312,21 +1312,8 @@
 %09%7D%0A%0A
-%09// lazy get%0A
 %09pri
@@ -1324,19 +1324,22 @@
  Dialog 
-get
+create
 AboutDia
@@ -1350,39 +1350,8 @@
 ) %7B%0A
-%09%09if (mAboutDialog == null) %7B%0A%09
 %09%09mA
@@ -1408,20 +1408,16 @@
 ialog);%0A
-%09%09%7D%0A
 %09%09return

Fix glitch in about dialog.