mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-08 05:24:39 +01:00
add invalidateOptionsMenuIf(), for working with action bar in a
safe-before-sdk-11 way
This commit is contained in:
parent
f4881dd00e
commit
4abc9623f9
1 changed files with 25 additions and 0 deletions
|
@ -72,6 +72,24 @@ public class Utils {
|
||||||
private static Boolean s_hasSmallScreen = null;
|
private static Boolean s_hasSmallScreen = null;
|
||||||
private static Random s_random = new Random();
|
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() {}
|
private Utils() {}
|
||||||
|
|
||||||
public static int nextRandomInt()
|
public static int nextRandomInt()
|
||||||
|
@ -358,6 +376,13 @@ public class Utils {
|
||||||
item.setEnabled( enabled );
|
item.setEnabled( enabled );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void invalidateOptionsMenuIf( Activity activity )
|
||||||
|
{
|
||||||
|
if ( null != s_safeInval ) {
|
||||||
|
s_safeInval.doInval( activity );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean hasSmallScreen( Context context )
|
public static boolean hasSmallScreen( Context context )
|
||||||
{
|
{
|
||||||
if ( null == s_hasSmallScreen ) {
|
if ( null == s_hasSmallScreen ) {
|
||||||
|
|
Loading…
Reference in a new issue