Merge: contrib/header_static: a cog in the toolchains to generate Objcwrapper
[nit.git] / examples / calculator / src / calculator.nit
index 2cc50ec..6ed8be7 100644 (file)
@@ -24,6 +24,7 @@ app_name "app.nit Calc."
 end
 
 import app::ui
+import app::data_store
 import android::aware
 
 import calculator_logic
@@ -92,4 +93,21 @@ class CalculatorWindow
                        display.text = context.display_text
                end
        end
+
+       redef fun on_save_state
+       do
+               app.data_store["context"] = context
+               super
+       end
+
+       redef fun on_restore_state
+       do
+               super
+
+               var context = app.data_store["context"]
+               if not context isa CalculatorContext then return
+
+               self.context = context
+               display.text = context.display_text
+       end
 end