[Android] Static map to easily pass data between components

Geoffrey Métais git at videolan.org
Thu Jan 28 13:03:40 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Jan 28 12:45:08 2016 +0100| [b9fb216df17e519ffa3eded9840c5cfe468d3f8d] | committer: Geoffrey Métais

Static map to easily pass data between components

> https://code.videolan.org/videolan/vlc-android/commit/b9fb216df17e519ffa3eded9840c5cfe468d3f8d
---

 vlc-android/src/org/videolan/vlc/VLCApplication.java | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/vlc-android/src/org/videolan/vlc/VLCApplication.java b/vlc-android/src/org/videolan/vlc/VLCApplication.java
index c9cc4cd..96272d0 100644
--- a/vlc-android/src/org/videolan/vlc/VLCApplication.java
+++ b/vlc-android/src/org/videolan/vlc/VLCApplication.java
@@ -25,6 +25,7 @@ import android.content.SharedPreferences;
 import android.content.res.Configuration;
 import android.content.res.Resources;
 import android.preference.PreferenceManager;
+import android.support.v4.util.SimpleArrayMap;
 import android.util.Log;
 
 import org.videolan.vlc.gui.helpers.AudioUtil;
@@ -50,6 +51,8 @@ public class VLCApplication extends Application {
     private static boolean sTV;
     private static SharedPreferences mSettings;
 
+    private static SimpleArrayMap<String, Object> sDataMap = new SimpleArrayMap<>();
+
     /* Up to 2 threads maximum, inactive threads are killed after 2 seconds */
     private ThreadPoolExecutor mThreadPool = new ThreadPoolExecutor(0, 2, 2, TimeUnit.SECONDS,
                                                                     new LinkedBlockingQueue<Runnable>());
@@ -136,4 +139,12 @@ public class VLCApplication extends Application {
     public static boolean removeTask(Runnable runnable) {
         return instance.mThreadPool.remove(runnable);
     }
+
+    public static void storeData(String key, Object data) {
+        sDataMap.put(key, data);
+    }
+
+    public static Object getData(String key) {
+        return sDataMap.remove(key);
+    }
 }



More information about the Android mailing list