aboutsummaryrefslogtreecommitdiffstats
path: root/APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/view/MenuInflater.java
diff options
context:
space:
mode:
Diffstat (limited to 'APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/view/MenuInflater.java')
-rw-r--r--APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/view/MenuInflater.java41
1 files changed, 32 insertions, 9 deletions
diff --git a/APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/view/MenuInflater.java b/APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/view/MenuInflater.java
index 969459749..5a0f40859 100644
--- a/APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/view/MenuInflater.java
+++ b/APG/android-libs/ActionBarSherlock/src/com/actionbarsherlock/view/MenuInflater.java
@@ -67,6 +67,7 @@ public class MenuInflater {
private final Object[] mActionProviderConstructorArguments;
private Context mContext;
+ private Object mRealOwner;
/**
* Constructs a menu inflater.
@@ -75,6 +76,20 @@ public class MenuInflater {
*/
public MenuInflater(Context context) {
mContext = context;
+ mRealOwner = context;
+ mActionViewConstructorArguments = new Object[] {context};
+ mActionProviderConstructorArguments = mActionViewConstructorArguments;
+ }
+
+ /**
+ * Constructs a menu inflater.
+ *
+ * @see Activity#getMenuInflater()
+ * @hide
+ */
+ public MenuInflater(Context context, Object realOwner) {
+ mContext = context;
+ mRealOwner = realOwner;
mActionViewConstructorArguments = new Object[] {context};
mActionProviderConstructorArguments = mActionViewConstructorArguments;
}
@@ -192,12 +207,12 @@ public class MenuInflater {
implements MenuItem.OnMenuItemClickListener {
private static final Class<?>[] PARAM_TYPES = new Class[] { MenuItem.class };
- private Context mContext;
+ private Object mRealOwner;
private Method mMethod;
- public InflatedOnMenuItemClickListener(Context context, String methodName) {
- mContext = context;
- Class<?> c = context.getClass();
+ public InflatedOnMenuItemClickListener(Object realOwner, String methodName) {
+ mRealOwner = realOwner;
+ Class<?> c = realOwner.getClass();
try {
mMethod = c.getMethod(methodName, PARAM_TYPES);
} catch (Exception e) {
@@ -212,9 +227,9 @@ public class MenuInflater {
public boolean onMenuItemClick(MenuItem item) {
try {
if (mMethod.getReturnType() == Boolean.TYPE) {
- return (Boolean) mMethod.invoke(mContext, item);
+ return (Boolean) mMethod.invoke(mRealOwner, item);
} else {
- mMethod.invoke(mContext, item);
+ mMethod.invoke(mRealOwner, item);
return true;
}
} catch (Exception e) {
@@ -358,8 +373,16 @@ public class MenuInflater {
itemListenerMethodName = a.getString(R.styleable.SherlockMenuItem_android_onClick);
itemActionViewLayout = a.getResourceId(R.styleable.SherlockMenuItem_android_actionLayout, 0);
- itemActionViewClassName = a.getString(R.styleable.SherlockMenuItem_android_actionViewClass);
- itemActionProviderClassName = a.getString(R.styleable.SherlockMenuItem_android_actionProviderClass);
+
+ // itemActionViewClassName = a.getString(R.styleable.SherlockMenuItem_android_actionViewClass);
+ value = new TypedValue();
+ a.getValue(R.styleable.SherlockMenuItem_android_actionViewClass, value);
+ itemActionViewClassName = value.type == TypedValue.TYPE_STRING ? value.string.toString() : null;
+
+ // itemActionProviderClassName = a.getString(R.styleable.SherlockMenuItem_android_actionProviderClass);
+ value = new TypedValue();
+ a.getValue(R.styleable.SherlockMenuItem_android_actionProviderClass, value);
+ itemActionProviderClassName = value.type == TypedValue.TYPE_STRING ? value.string.toString() : null;
final boolean hasActionProvider = itemActionProviderClassName != null;
if (hasActionProvider && itemActionViewLayout == 0 && itemActionViewClassName == null) {
@@ -407,7 +430,7 @@ public class MenuInflater {
+ "be used within a restricted context");
}
item.setOnMenuItemClickListener(
- new InflatedOnMenuItemClickListener(mContext, itemListenerMethodName));
+ new InflatedOnMenuItemClickListener(mRealOwner, itemListenerMethodName));
}
if (itemCheckable >= 2) {