Index: samples/android_sample/jni/dart_host.h |
=================================================================== |
--- samples/android_sample/jni/dart_host.h (revision 0) |
+++ samples/android_sample/jni/dart_host.h (revision 0) |
@@ -0,0 +1,59 @@ |
+#ifndef DART_HOST_H |
+#define DART_HOST_H |
+ |
+#include <android_native_app_glue.h> |
+#include "include/dart_api.h" |
+#include "bin/dartutils.h" |
+#include "activity_handler.h" |
+#include "input_service.h" |
+#include "timer.h" |
+#include "graphics.h" |
+#include "context.h" |
+#include "vm_glue.h" |
+ |
+// Currently the life cycle management is very crude. We conservatively |
+// shutdown the main isolate when we lose focus and create a new one when |
+// we resume. This needs to be improved later when we understand this better, |
+// and we need some hooks to tell the Dart script to save/restore state |
+// (and an API that will support that). |
+ |
+class DartHost : public ActivityHandler { |
+ public: |
+ DartHost(Context* pContext); |
+ virtual ~DartHost(); |
+ |
+ protected: |
+ int32_t onActivate(); |
+ void onDeactivate(); |
+ int32_t onStep(); |
+ |
+ void onStart(); |
+ void onResume(); |
+ void onPause(); |
+ void onStop(); |
+ void onDestroy(); |
+ |
+ void onSaveState(void** pData, int32_t pSize); |
+ void onConfigurationChanged(); |
+ void onLowMemory(); |
+ void onCreateWindow(); |
+ void onDestroyWindow(); |
+ void onGainedFocus(); |
+ void onLostFocus(); |
+ |
+ private: |
+ |
+ void clear(); |
+ int32_t activate(); |
+ void deactivate(); |
+ |
+ ANativeWindow_Buffer mWindowBuffer; |
+ InputHandler *mInputHandler; |
+ Timer* mTimer; |
+ Graphics *mGraphics; |
+ VMGlue *mVmGlue; |
+ bool mActive; |
+}; |
+ |
+#endif |
+ |