diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java index 22a569bc4..9a04d9de9 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java @@ -72,6 +72,24 @@ public class Utils { private static Boolean s_hasSmallScreen = null; private static Random s_random = new Random(); + private static interface SafeInvalOptionsMenu { + public void doInval( Activity activity ); + } + + private static class SafeInvalOptionsMenuImpl + implements SafeInvalOptionsMenu { + public void doInval( Activity activity ) { + activity.invalidateOptionsMenu(); + } + } + private static SafeInvalOptionsMenu s_safeInval = null; + static { + int sdkVersion = Integer.valueOf( android.os.Build.VERSION.SDK ); + if ( 11 <= sdkVersion ) { + s_safeInval = new SafeInvalOptionsMenuImpl(); + } + } + private Utils() {} public static int nextRandomInt() @@ -358,6 +376,13 @@ public class Utils { item.setEnabled( enabled ); } + public static void invalidateOptionsMenuIf( Activity activity ) + { + if ( null != s_safeInval ) { + s_safeInval.doInval( activity ); + } + } + public static boolean hasSmallScreen( Context context ) { if ( null == s_hasSmallScreen ) {