summaryrefslogtreecommitdiffstats
path: root/src/java/jogamp/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/jogamp/common')
-rw-r--r--src/java/jogamp/common/os/android/StaticContext.java27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/java/jogamp/common/os/android/StaticContext.java b/src/java/jogamp/common/os/android/StaticContext.java
index d7f134a..359e603 100644
--- a/src/java/jogamp/common/os/android/StaticContext.java
+++ b/src/java/jogamp/common/os/android/StaticContext.java
@@ -29,9 +29,11 @@ package jogamp.common.os.android;
import android.content.Context;
import android.util.Log;
+import android.view.ViewGroup;
public class StaticContext {
private static Context appContext = null;
+ private static ViewGroup contentViewGroup = null;
private static boolean DEBUG = false;
@@ -42,19 +44,32 @@ public class StaticContext {
* @throws RuntimeException if the context is already registered.
*/
public static final synchronized void init(Context appContext) {
+ init(appContext, null);
+ }
+
+ /**
+ * Register Android application context w/ a ViewGroup for static usage.
+ *
+ * @param appContext mandatory application Context
+ * @param contentViewGroup optional ViewGroup acting as the Window's ContentView, usually a FrameLayout instance.
+ * @throws RuntimeException if the context is already registered.
+ */
+ public static final synchronized void init(Context appContext, ViewGroup contentViewGroup) {
if(null != StaticContext.appContext) {
throw new RuntimeException("Context already set");
}
- if(DEBUG) { Log.d(MD.TAG, "init(appCtx "+appContext+")"); }
+ if(DEBUG) { Log.d(MD.TAG, "init(appCtx "+appContext+", viewGroup "+contentViewGroup+")"); }
StaticContext.appContext = appContext;
+ StaticContext.contentViewGroup = contentViewGroup;
}
/**
- * Unregister the Android application Context
+ * Unregister the Android application Context and ViewGroup
*/
public static final synchronized void clear() {
if(DEBUG) { Log.d(MD.TAG, "clear()"); }
appContext = null;
+ contentViewGroup = null;
}
/**
@@ -64,4 +79,12 @@ public class StaticContext {
public static final synchronized Context getContext() {
return appContext;
}
+
+ /**
+ * Return the registered Android ViewGroup acting as the Window's ContentView
+ * @return
+ */
+ public static final synchronized ViewGroup getContentViewGroup() {
+ return contentViewGroup;
+ }
}