diff options
author | Mihai Preda <preda@google.com> | 2010-03-09 12:27:45 +0100 |
---|---|---|
committer | Mihai Preda <preda@google.com> | 2010-03-09 12:27:45 +0100 |
commit | cf3ca321fa8cc1f5427454c5e2501b7978bb3711 (patch) | |
tree | 7b0100c46ce52c45f52cb56bba2c8b431dba621a /src/com/android/calculator2/Calculator.java | |
parent | b9a127c80fcbabe76af689a2fb98509940fa1f86 (diff) | |
download | android_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.java | 18 |
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 |