recycleしすぎてた?
[ofnhwx.olib.git] / src / jp / gr / java_conf / ofnhwx / olib / compatibility / OCompatibility.java
bloba3194fb0d7e4994b255a7ea83070cb0838e6f1b3
1 package jp.gr.java_conf.ofnhwx.olib.compatibility;
3 import java.lang.reflect.Method;
5 import android.app.Activity;
6 import android.os.Build;
7 import android.util.Log;
9 /**
10 * 互換性を確保するための関数.
11 * @author yuta
13 public final class OCompatibility {
15 private static final String TAG = OCompatibility.class.getSimpleName();
17 private OCompatibility() {}
19 public static final class Version {
21 private Version() {}
23 public static final boolean isAndroid21() {
24 return Build.VERSION.SDK_INT > 4;
27 public static final boolean isAndroid30() {
28 return Build.VERSION.SDK_INT > 10;
31 public static final boolean isAndroid40() {
32 return Build.VERSION.SDK_INT > 13;
37 public static final class MenuItem {
39 private MenuItem() {}
41 public static final int SHOW_AS_ACTION_NEVER = 0;
42 public static final int SHOW_AS_ACTION_IF_ROOM = 1;
43 public static final int SHOW_AS_ACTION_ALWAYS = 2;
44 public static final int SHOW_AS_ACTION_WITH_TEXT = 4;
45 public static final int SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW = 8;
49 public static final void invalidateOptionsMenu(Activity activity) {
50 if (!Version.isAndroid30()) {
51 return;
53 try {
54 Method m = activity.getClass().getMethod("invalidateOptionsMenu");
55 m.invoke(activity);
56 } catch (Exception e) {
57 Log.e(TAG, "invalidateOptionsMenu", e);