summaryrefslogtreecommitdiffstats
path: root/src/com/android/calculator2/Calculator.java
diff options
context:
space:
mode:
authorMihai Preda <preda@google.com>2010-03-09 12:27:45 +0100
committerMihai Preda <preda@google.com>2010-03-09 12:27:45 +0100
commitcf3ca321fa8cc1f5427454c5e2501b7978bb3711 (patch)
tree7b0100c46ce52c45f52cb56bba2c8b431dba621a /src/com/android/calculator2/Calculator.java
parentb9a127c80fcbabe76af689a2fb98509940fa1f86 (diff)
downloadandroid_packages_apps_ExactCalculator-cf3ca321fa8cc1f5427454c5e2501b7978bb3711.tar.gz
android_packages_apps_ExactCalculator-cf3ca321fa8cc1f5427454c5e2501b7978bb3711.tar.bz2
android_packages_apps_ExactCalculator-cf3ca321fa8cc1f5427454c5e2501b7978bb3711.zip
Calculator: preserve basic/advanced panel on orientation change.
Bug 2154998. Change-Id: Ie40ebe485cdb0721a5394c4d19450fddf035134f
Diffstat (limited to 'src/com/android/calculator2/Calculator.java')
-rw-r--r--src/com/android/calculator2/Calculator.java18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/com/android/calculator2/Calculator.java b/src/com/android/calculator2/Calculator.java
index d5c5030..a871c00 100644
--- a/src/com/android/calculator2/Calculator.java
+++ b/src/com/android/calculator2/Calculator.java
@@ -50,10 +50,11 @@ public class Calculator extends Activity {
private static final String LOG_TAG = "Calculator";
private static final boolean DEBUG = false;
private static final boolean LOG_ENABLED = DEBUG ? Config.LOGD : Config.LOGV;
+ private static final String STATE_CURRENT_VIEW = "state-current-view";
@Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
+ public void onCreate(Bundle state) {
+ super.onCreate(state);
setContentView(R.layout.main);
@@ -65,14 +66,15 @@ public class Calculator extends Activity {
mLogic = new Logic(this, mHistory, mDisplay, (Button) findViewById(R.id.equal));
HistoryAdapter historyAdapter = new HistoryAdapter(this, mHistory, mLogic);
mHistory.setObserver(historyAdapter);
- View view;
+
mPanelSwitcher = (PanelSwitcher) findViewById(R.id.panelswitch);
-
+ mPanelSwitcher.setCurrentIndex(state==null ? 0 : state.getInt(STATE_CURRENT_VIEW, 0));
+
mListener.setHandler(mLogic, mPanelSwitcher);
mDisplay.setOnKeyListener(mListener);
-
+ View view;
if ((view = findViewById(R.id.del)) != null) {
// view.setOnClickListener(mListener);
view.setOnLongClickListener(mListener);
@@ -138,9 +140,9 @@ public class Calculator extends Activity {
}
@Override
- protected void onSaveInstanceState(Bundle icicle) {
- // as work-around for ClassCastException in TextView on restart
- // avoid calling superclass, to keep icicle empty
+ protected void onSaveInstanceState(Bundle state) {
+ super.onSaveInstanceState(state);
+ state.putInt(STATE_CURRENT_VIEW, mPanelSwitcher.getCurrentIndex());
}
@Override