Example usage for java.lang Integer TYPE

List of usage examples for java.lang Integer TYPE

Introduction

In this page you can find the example usage for java.lang Integer TYPE.

Prototype

Class TYPE

To view the source code for java.lang Integer TYPE.

Click Source Link

Document

The Class instance representing the primitive type int .

Usage

From source file:Main.java

public static void putTextToViewById(Activity a, int id, int text) {

    View view = a.findViewById(id);

    Method m = null;/* w  w  w.  j  a  v a 2 s . co m*/

    try {
        m = view.getClass().getMethod("setText", new Class[] { Integer.TYPE });
    } catch (NoSuchMethodException e) {

    }
    if (m != null) {
        try {
            m.invoke(view, text);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}

From source file:Main.java

private static Map<Class<?>, Class<?>> getWrapperTypes() {
    Map<Class<?>, Class<?>> ret = new HashMap<Class<?>, Class<?>>();
    ret.put(Boolean.TYPE, Boolean.class);
    ret.put(Character.TYPE, Character.class);
    ret.put(Byte.TYPE, Byte.class);
    ret.put(Short.TYPE, Short.class);
    ret.put(Integer.TYPE, Integer.class);
    ret.put(Long.TYPE, Long.class);
    ret.put(Float.TYPE, Float.class);
    ret.put(Double.TYPE, Double.class);
    ret.put(Void.TYPE, Void.class);
    return ret;//from   www .  java 2 s. c om
}

From source file:Main.java

public static void hideSmartBar(Activity activity) {
    if (!hasSmartBar())
        return;//  w w  w  . ja v a2s  .  co m

    try {
        @SuppressWarnings("rawtypes")
        Class[] arrayOfClass = new Class[1];
        arrayOfClass[0] = Integer.TYPE;
        Method localMethod = View.class.getMethod("setSystemUiVisibility", arrayOfClass);
        Field localField = View.class.getField("SYSTEM_UI_FLAG_HIDE_NAVIGATION");
        Object[] arrayOfObject = new Object[1];
        try {
            arrayOfObject[0] = localField.get(null);
        } catch (Exception e) {

        }
        localMethod.invoke(activity.getWindow().getDecorView(), arrayOfObject);
        return;
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void addBaseClassMappings() {
    mappings.put("byte", Byte.TYPE);
    mappings.put("short", Short.TYPE);
    mappings.put("int", Integer.TYPE);
    mappings.put("long", Long.TYPE);
    mappings.put("float", Float.TYPE);
    mappings.put("double", Double.TYPE);
    mappings.put("boolean", Boolean.TYPE);
    mappings.put("char", Character.TYPE);
    mappings.put("[byte", byte[].class);
    mappings.put("[short", short[].class);
    mappings.put("[int", int[].class);
    mappings.put("[long", long[].class);
    mappings.put("[float", float[].class);
    mappings.put("[double", double[].class);
    mappings.put("[boolean", boolean[].class);
    mappings.put("[char", char[].class);
    mappings.put(HashMap.class.getName(), HashMap.class);
}

From source file:Main.java

public static void hide(View decorView) {
    if (!hasSmartBar())
        return;//  w  w  w.j a  va 2s.  co m

    try {
        @SuppressWarnings("rawtypes")
        Class[] arrayOfClass = new Class[1];
        arrayOfClass[0] = Integer.TYPE;
        Method localMethod = View.class.getMethod("setSystemUiVisibility", arrayOfClass);
        Field localField = View.class.getField("SYSTEM_UI_FLAG_HIDE_NAVIGATION");
        Object[] arrayOfObject = new Object[1];
        try {
            arrayOfObject[0] = localField.get(null);
        } catch (Exception e) {

        }
        localMethod.invoke(decorView, arrayOfObject);
        return;
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void enterA2Mode() {
    System.err.println("Orion::enterA2Mode");
    try {/*  w ww . j  av  a2s . c  om*/

        Constructor RegionParamsConstructor = epdControllerRegionParamsClass.getConstructor(new Class[] {
                Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE, epdControllerWaveClass, Integer.TYPE });

        Object localRegionParams = RegionParamsConstructor
                .newInstance(new Object[] { 0, 0, 600, 800, waveEnums[2], 16 }); // Wave = DU

        Method epdControllerSetRegionMethod = epdControllerClass.getMethod("setRegion",
                new Class[] { String.class, epdControllerRegionClass, epdControllerRegionParamsClass });
        epdControllerSetRegionMethod.invoke(null, new Object[] { "Orion", regionEnums[2], localRegionParams });

        Thread.sleep(100L);
        localRegionParams = RegionParamsConstructor
                .newInstance(new Object[] { 0, 0, 600, 800, waveEnums[3], 14 }); // Wave = A2
        epdControllerSetRegionMethod.invoke(null, new Object[] { "Orion", regionEnums[2], localRegionParams });
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:Main.java

/**
 * see http://habrahabr.ru/post/144547///from  w  w  w.  j  a  v a2s  .co m
 */
public static BluetoothSocket createRfcommSocket(BluetoothDevice device) {
    BluetoothSocket tmp = null;
    try {
        Class class1 = device.getClass();
        Class aclass[] = new Class[1];
        aclass[0] = Integer.TYPE;
        Method method = class1.getMethod("createRfcommSocket", aclass);
        Object aobj[] = new Object[1];
        aobj[0] = Integer.valueOf(1);

        tmp = (BluetoothSocket) method.invoke(device, aobj);
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
        if (D)
            Log.e(TAG, "createRfcommSocket() failed", e);
    } catch (InvocationTargetException e) {
        e.printStackTrace();
        if (D)
            Log.e(TAG, "createRfcommSocket() failed", e);
    } catch (IllegalAccessException e) {
        e.printStackTrace();
        if (D)
            Log.e(TAG, "createRfcommSocket() failed", e);
    }
    return tmp;
}

From source file:Main.java

public static void setDUMode() {
    System.err.println("Orion::setDUMode");
    try {/*from w  w w .  j  av a2s  .co m*/
        if (successful) {
            Constructor RegionParamsConstructor = epdControllerRegionParamsClass
                    .getConstructor(new Class[] { Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE,
                            epdControllerWaveClass, Integer.TYPE });

            Object localRegionParams = RegionParamsConstructor
                    .newInstance(new Object[] { 0, 0, 600, 800, waveEnums[2], 14 });

            Method epdControllerSetRegionMethod = epdControllerClass.getMethod("setRegion",
                    new Class[] { String.class, epdControllerRegionClass, epdControllerRegionParamsClass });
            epdControllerSetRegionMethod.invoke(null,
                    new Object[] { "Orion", regionEnums[2], localRegionParams });
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Main.java

/**
 * This method parses the given value into the specified primitive or wrapper class.
 * @param clazz - primitive or wrapper class used to parse
 * @param value - string to be parsed//  www . jav a  2s . c o  m
 * @return object of type clazz parsed from the string
 * @author Trisan Bepler
 */
public static Object toObject(Class<?> clazz, String value) {
    if (Boolean.TYPE == clazz)
        return Boolean.parseBoolean(value);
    if (Byte.TYPE == clazz)
        return Byte.parseByte(value);
    if (Short.TYPE == clazz)
        return Short.parseShort(value);
    if (Integer.TYPE == clazz)
        return Integer.parseInt(value);
    if (Long.TYPE == clazz)
        return Long.parseLong(value);
    if (Float.TYPE == clazz)
        return Float.parseFloat(value);
    if (Double.TYPE == clazz)
        return Double.parseDouble(value);
    if (Boolean.class == clazz)
        return Boolean.parseBoolean(value);
    if (Byte.class == clazz)
        return Byte.parseByte(value);
    if (Short.class == clazz)
        return Short.parseShort(value);
    if (Integer.class == clazz)
        return Integer.parseInt(value);
    if (Long.class == clazz)
        return Long.parseLong(value);
    if (Float.class == clazz)
        return Float.parseFloat(value);
    if (Double.class == clazz)
        return Double.parseDouble(value);
    if (Character.class == clazz)
        return value.charAt(0);
    if (Character.TYPE == clazz)
        return value.charAt(0);
    return value;
}

From source file:Main.java

private static boolean setWebkitProxyICS(Context ctx, String host, int port) throws Exception {

    // PSIPHON: added support for Android 4.x WebView proxy
    try {//  www .j  a  v a 2s .  c o m
        Class webViewCoreClass = Class.forName("android.webkit.WebViewCore");

        Class proxyPropertiesClass = Class.forName("android.net.ProxyProperties");
        if (webViewCoreClass != null && proxyPropertiesClass != null) {
            Method m = webViewCoreClass.getDeclaredMethod("sendStaticMessage", Integer.TYPE, Object.class);
            Constructor c = proxyPropertiesClass.getConstructor(String.class, Integer.TYPE, String.class);

            if (m != null && c != null) {
                m.setAccessible(true);
                c.setAccessible(true);
                Object properties = c.newInstance(host, port, null);

                // android.webkit.WebViewCore.EventHub.PROXY_CHANGED = 193;
                m.invoke(null, 193, properties);
                return true;
            } else
                return false;
        }
    } catch (Exception e) {
        Log.e("ProxySettings",
                "Exception setting WebKit proxy through android.net.ProxyProperties: " + e.toString());
    } catch (Error e) {
        Log.e("ProxySettings",
                "Exception setting WebKit proxy through android.webkit.Network: " + e.toString());
    }

    return false;

}