當前位置: 首頁>>代碼示例>>Java>>正文


Java Field.getInt方法代碼示例

本文整理匯總了Java中java.lang.reflect.Field.getInt方法的典型用法代碼示例。如果您正苦於以下問題:Java Field.getInt方法的具體用法?Java Field.getInt怎麽用?Java Field.getInt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.lang.reflect.Field的用法示例。


在下文中一共展示了Field.getInt方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getCodeName

import java.lang.reflect.Field; //導入方法依賴的package包/類
/**
 * Looks up and returns the name of the code give if there is a constant
 * field in EosEventConstants which starts with the given prefix
 *
 * @param prefix the field name prefix
 * @param code image format code
 *
 * @return the printable name of the given code
 */
private static String getCodeName(String prefix, int code) {
    Field[] fields = NikonEventConstants.class.getDeclaredFields();

    for (Field f: fields) {
        String name = f.getName();
        if (name.startsWith(prefix)) {
            try {
                if (f.getInt(null) == code) {
                    return name.substring(prefix.length());
                }
            } catch (Exception e) {
                //
                // Nothing to do
                //
            }
        }
    }
    return "Unknown";
}
 
開發者ID:iyundong,項目名稱:InstantUpload,代碼行數:29,代碼來源:NikonEventFormat.java

示例2: setMiuiStatusBarDarkMode

import java.lang.reflect.Field; //導入方法依賴的package包/類
private static boolean setMiuiStatusBarDarkMode(Activity activity, boolean darkmode) {
    Class<? extends Window> clazz = activity.getWindow().getClass();
    try {
        int darkModeFlag;
        Class<?> layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams");

        Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE");
        darkModeFlag = field.getInt(layoutParams);
        Method extraFlagField = clazz.getMethod("setExtraFlags", int.class, int.class);
        extraFlagField.invoke(activity.getWindow(), darkmode ? darkModeFlag : 0, darkModeFlag);
        return true;
    } catch (Exception ignored) {

    }

    return false;
}
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:18,代碼來源:StatusbarUtil.java

示例3: setMIUIStatusBarDarkMode

import java.lang.reflect.Field; //導入方法依賴的package包/類
/**
 * 設置小米黑色狀態欄字體
 */
@SuppressLint("PrivateApi")
private void setMIUIStatusBarDarkMode() {
    if (isMiUi) {
        Class<? extends Window> clazz = getWindow().getClass();
        try {
            int darkModeFlag;
            Class<?> layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams");
            Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE");
            darkModeFlag = field.getInt(layoutParams);
            Method extraFlagField = clazz.getMethod("setExtraFlags", int.class, int.class);
            extraFlagField.invoke(getWindow(), darkModeFlag, darkModeFlag);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
開發者ID:yhyonghao,項目名稱:CalendarView_master,代碼行數:20,代碼來源:BaseActivity.java

示例4: MIUISetStatusBarLightMode

import java.lang.reflect.Field; //導入方法依賴的package包/類
/**
 * 設置狀態欄字體圖標為深色,需要MIUIV6以上
 * @param window 需要設置的窗口
 * @param dark 是否把狀態欄字體及圖標顏色設置為深色
 * @return  boolean 成功執行返回true
 *
 */
public static boolean MIUISetStatusBarLightMode(Window window, boolean dark) {
    boolean result = false;
    if (window != null) {
        Class clazz = window.getClass();
        try {
            int darkModeFlag = 0;
            Class layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams");
            Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE");
            darkModeFlag = field.getInt(layoutParams);
            Method extraFlagField = clazz.getMethod("setExtraFlags", int.class, int.class);
            if(dark){
                extraFlagField.invoke(window,darkModeFlag,darkModeFlag);//狀態欄透明且黑色字體
            }else{
                extraFlagField.invoke(window, 0, darkModeFlag);//清除黑色字體
            }
            result=true;
        }catch (Exception e){

        }
    }
    return result;
}
 
開發者ID:zuoni1018,項目名稱:CoordinatorLayoutExample-master,代碼行數:30,代碼來源:StatusBarUtil.java

示例5: setStaticFinalField

import java.lang.reflect.Field; //導入方法依賴的package包/類
public static void setStaticFinalField(
        Field field, Object value)
        throws NoSuchFieldException, IllegalAccessException
{
    // 獲得 public 權限
    field.setAccessible(true);
    // 將modifiers域設為非final,這樣就可以修改了
    Field modifiersField =
            Field.class.getDeclaredField(MODIFIERS_FIELD);
    modifiersField.setAccessible(true);
    int modifiers = modifiersField.getInt(field);
    // 去掉 final 標誌位
    modifiers &= ~Modifier.FINAL;
    modifiersField.setInt(field, modifiers);
    FieldAccessor fa = reflection.newFieldAccessor(
            field, false
    );
    fa.set(null, value);
}
 
開發者ID:priester,項目名稱:hanlpStudy,代碼行數:20,代碼來源:ReflectionHelper.java

示例6: darkModeForFlyme4

import java.lang.reflect.Field; //導入方法依賴的package包/類
/**
 * 設置Flyme4+的darkMode,darkMode時候字體顏色及icon變黑
 * http://open-wiki.flyme.cn/index.php?title=Flyme%E7%B3%BB%E7%BB%9FAPI
 */
public static boolean darkModeForFlyme4(Window window, boolean dark) {
    boolean result = false;
    if (window != null) {
        try {
            WindowManager.LayoutParams e = window.getAttributes();
            Field darkFlag = WindowManager.LayoutParams.class.getDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON");
            Field meizuFlags = WindowManager.LayoutParams.class.getDeclaredField("meizuFlags");
            darkFlag.setAccessible(true);
            meizuFlags.setAccessible(true);
            int bit = darkFlag.getInt(null);
            int value = meizuFlags.getInt(e);
            if (dark) {
                value |= bit;
            } else {
                value &= ~bit;
            }

            meizuFlags.setInt(e, value);
            window.setAttributes(e);
            result = true;
        } catch (Exception var8) {
            Log.e("StatusBar", "darkIcon: failed");
        }
    }

    return result;
}
 
開發者ID:SiberiaDante,項目名稱:MultiScrollDemo,代碼行數:32,代碼來源:StatusBarUtil.java

示例7: setStatusBarLightMode

import java.lang.reflect.Field; //導入方法依賴的package包/類
/**
 * 設置狀態欄圖標為深色和魅族特定的文字風格
 * 可以用來判斷是否為Flyme用戶
 *
 * @param isFontColorDark 是否把狀態欄字體及圖標顏色設置為深色
 * @return boolean 成功執行返回true
 */
@Override
public boolean setStatusBarLightMode(Activity activity, boolean isFontColorDark) {
    Window window = activity.getWindow();
    boolean result = false;
    if (window != null) {
        try {
            WindowManager.LayoutParams lp = window.getAttributes();
            Field darkFlag = WindowManager.LayoutParams.class
                    .getDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON");
            Field meizuFlags = WindowManager.LayoutParams.class
                    .getDeclaredField("meizuFlags");
            darkFlag.setAccessible(true);
            meizuFlags.setAccessible(true);
            int bit = darkFlag.getInt(null);
            int value = meizuFlags.getInt(lp);
            if (isFontColorDark) {
                value |= bit;
            } else {
                value &= ~bit;
            }
            meizuFlags.setInt(lp, value);
            window.setAttributes(lp);
            result = true;
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return result;
}
 
開發者ID:tututututututu,項目名稱:BaseCore,代碼行數:37,代碼來源:FlymeHelper.java

示例8: getIntFieldIfExists

import java.lang.reflect.Field; //導入方法依賴的package包/類
public static int getIntFieldIfExists(Class<?> klass, String fieldName,
                                      Class<?> obj, int defaultVal) {
    try {
        Field f = klass.getDeclaredField(fieldName);
        return f.getInt(obj);
    } catch (Exception e) {
        return defaultVal;
    }
}
 
開發者ID:mayurkaul,項目名稱:medialibrary,代碼行數:10,代碼來源:ApiHelper.java

示例9: testUniqueIds

import java.lang.reflect.Field; //導入方法依賴的package包/類
/**
 * testUniqueIds
 */
public void testUniqueIds() throws Exception {
    Class<SysProcFragmentId> clazz = SysProcFragmentId.class;
    Map<Integer, String> ids = new HashMap<Integer, String>();
    for (Field f : clazz.getDeclaredFields()) {
       String f_name = f.getName(); 
       int id = f.getInt(null);
       assertTrue(f_name, id >= 0);
       
       assertFalse(String.format("Duplicate id %d for %s <-> %s", id, f_name, ids.get(id)),
                   ids.containsKey(id));
       ids.put(id, f_name);
    } // FOR
    assertFalse(ids.isEmpty());
}
 
開發者ID:s-store,項目名稱:sstore-soft,代碼行數:18,代碼來源:TestSysProcFragmentId.java

示例10: invokeEnvironmentSdcardMethod

import java.lang.reflect.Field; //導入方法依賴的package包/類
private static void invokeEnvironmentSdcardMethod(PathCallback callback)
        throws NoSuchMethodException, ClassNotFoundException, NoSuchFieldException, IllegalAccessException {
    Field sCurrentUserField = getCurrentUserField();
    AbstractWrapper wrapper = getInstalledWrapper(sCurrentUserField);
    if (wrapper != null) {
        // Update current wrapper
        wrapper.setCallback(callback);
        wrapper.setEnable(true);
    } else {
        // Install new wrapper
        Environment.UserEnvironment o = (Environment.UserEnvironment) sCurrentUserField
                .get(null);
        int user = 0;
        try {
            Field mUserIdField = o.getClass().getDeclaredField("mUserId");
            mUserIdField.setAccessible(true);
            user = mUserIdField.getInt(o);
        } catch (Exception e) {
            e.printStackTrace();
        }
        AbstractWrapper abstractWrapper = AbstractWrapper.getWrapper(o,
                callback, user);
        if (abstractWrapper == null) {
            Log.e(TAG, "Can not create wrapper, it looks like not support your ROM: " +
                    Build.VERSION.SDK_INT);
            return;
        }
        sCurrentUserField.set(null, abstractWrapper);
    }
}
 
開發者ID:Trumeet,項目名稱:RedirectStorage,代碼行數:31,代碼來源:RedirectStorage.java

示例11: check

import java.lang.reflect.Field; //導入方法依賴的package包/類
static void check(boolean showBeMissing) throws Exception {
    KeyTab kt = KeyTab.getInstance(NAME);
    if (kt.isMissing() != showBeMissing) {
        throw new Exception("isMissing is not " + showBeMissing);
    }
    Field f = KeyTab.class.getDeclaredField("kt_vno");
    f.setAccessible(true);
    if (f.getInt(kt) != KeyTabConstants.KRB5_KT_VNO) {
        throw new Exception("kt_vno is " + f.getInt(kt));
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:12,代碼來源:KtabZero.java

示例12: a

import java.lang.reflect.Field; //導入方法依賴的package包/類
private static int a(Object obj, String str) {
    try {
        Field declaredField = DisplayMetrics.class.getDeclaredField(str);
        declaredField.setAccessible(true);
        return declaredField.getInt(obj);
    } catch (Exception e) {
        e.printStackTrace();
        return -1;
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:11,代碼來源:bt.java

示例13: FlymeSetStatusBarLightMode

import java.lang.reflect.Field; //導入方法依賴的package包/類
/**
 * 設置狀態欄圖標為深色和魅族特定的文字風格
 * 可以用來判斷是否為Flyme用戶
 * @param window 需要設置的窗口
 * @param dark 是否把狀態欄字體及圖標顏色設置為深色
 * @return  boolean 成功執行返回true
 *
 */
public static boolean FlymeSetStatusBarLightMode(Window window, boolean dark) {
    boolean result = false;
    if (window != null) {
        try {
            WindowManager.LayoutParams lp = window.getAttributes();
            Field darkFlag = WindowManager.LayoutParams.class
                    .getDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON");
            Field meizuFlags = WindowManager.LayoutParams.class
                    .getDeclaredField("meizuFlags");
            darkFlag.setAccessible(true);
            meizuFlags.setAccessible(true);
            int bit = darkFlag.getInt(null);
            int value = meizuFlags.getInt(lp);
            if (dark) {
                value |= bit;
            } else {
                value &= ~bit;
            }
            meizuFlags.setInt(lp, value);
            window.setAttributes(lp);
            result = true;
        } catch (Exception e) {

        }
    }
    return result;
}
 
開發者ID:zuoni1018,項目名稱:CoordinatorLayoutExample-master,代碼行數:36,代碼來源:StatusBarUtil.java

示例14: getBusID

import java.lang.reflect.Field; //導入方法依賴的package包/類
private int getBusID(EventBus a) {
    try {
        Field declaredField = EventBus.class.getDeclaredField("busID");
        declaredField.setAccessible(true);
        return declaredField.getInt(a);
    } catch (Exception ex) {
        return 0;
    }
}
 
開發者ID:Ygore,項目名稱:bit-client,代碼行數:10,代碼來源:Dispatcher.java

示例15: setMeizuStatusBarDarkMode

import java.lang.reflect.Field; //導入方法依賴的package包/類
/**
 * 設置魅族狀態欄模式
 *
 * @param activity activity
 * @param darkmode 是否是黑暗係
 * @return 是否設置成功
 */
public static boolean setMeizuStatusBarDarkMode(Activity activity, boolean darkmode) {
    boolean result = false;
    if (activity != null) {
        try {
            WindowManager.LayoutParams lp = activity.getWindow().getAttributes();
            Field darkFlag = WindowManager.LayoutParams.class
                    .getDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON");
            Field meizuFlags = WindowManager.LayoutParams.class
                    .getDeclaredField("meizuFlags");
            darkFlag.setAccessible(true);
            meizuFlags.setAccessible(true);
            int bit = darkFlag.getInt(null);
            int value = meizuFlags.getInt(lp);
            if (darkmode) {
                value |= bit;
            } else {
                value &= ~bit;
            }
            meizuFlags.setInt(lp, value);
            activity.getWindow().setAttributes(lp);
            result = true;
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return result;
}
 
開發者ID:6ag,項目名稱:LiuAGeAndroid,代碼行數:35,代碼來源:StatusUtils.java


注:本文中的java.lang.reflect.Field.getInt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。