Expose the asset manager from Android::MainThread
authorMikko Rasa <tdb@tdb.fi>
Sun, 19 Oct 2014 17:23:02 +0000 (20:23 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 19 Oct 2014 17:23:02 +0000 (20:23 +0300)
AFAICT the asset manager is tied to the application and not the activity,
so this simple approach should be safe even if the activity gets destroyed
and recreated due to orientation change or whatever.

source/core/android/mainthread.cpp
source/core/android/mainthread.h

index 1e5fc1198072ef48cc84c48fead2436bcba3e39b..6a3f865bbc3ccf53d6142a321bf881547c6b1822 100644 (file)
@@ -10,6 +10,7 @@ namespace Msp {
 namespace Android {
 
 MainThread::MainThread(ANativeActivity *a):
+       asset_manager(a->assetManager),
        starting_up(true)
 {
        attach_to_activity(a);
index 68da6c4bc9133de65366f1a9ebe2bf72518e804b..efd0fe0e0af22e1c5c833e000b5fd10862f37546 100644 (file)
@@ -20,6 +20,7 @@ public:
 
 private:
        ANativeActivity *activity;
+       AAssetManager *asset_manager;
        bool starting_up;
        Mutex startup_mutex;
 
@@ -31,6 +32,8 @@ public:
        void wait_for_app_created();
        void resume_startup();
 
+       AAssetManager *get_asset_manager() const { return asset_manager; }
+
 private:
        virtual void main();