Example usage for android.os Parcel readInt

List of usage examples for android.os Parcel readInt

Introduction

In this page you can find the example usage for android.os Parcel readInt.

Prototype

public final int readInt() 

Source Link

Document

Read an integer value from the parcel at the current dataPosition().

Usage

From source file:Main.java

/**
 * read boolean//from  w w  w.  j  av a  2s  . c  o  m
 * 
 * @param in
 * @return
 */
public static boolean readBoolean(Parcel in) {
    return in.readInt() == 1;
}

From source file:Main.java

public static String readStringFromParcel(Parcel in) {
    int flag = in.readInt();
    if (flag == 1) {
        return in.readString();
    } else {/*from  w w w  .  ja  va 2  s .  c o m*/
        return null;
    }
}

From source file:Main.java

public static Integer readIntegerFromParcel(Parcel in) {
    return (in.readByte() != 0) ? in.readInt() : null;
}

From source file:Main.java

public static Map<String, String> readStringMap(Parcel parcel) {
    Map<String, String> map = null;
    int size = parcel.readInt();
    if (size > 0) {
        map = new HashMap<String, String>(size);
        for (int i = 0; i < size; i++) {
            String key = parcel.readString();
            String value = parcel.readString();
            map.put(key, value);//from  ww w  . ja v  a 2 s .  com
        }
    }
    return map;
}

From source file:Main.java

/**
 * Read a HashMap from a Parcel, class of key and value are both String
 * /*from  ww  w .  ja  va2  s.c  o m*/
 * @param in
 * @return
 */
public static Map<String, String> readHashMapStringAndString(Parcel in) {
    if (in == null) {
        return null;
    }

    int size = in.readInt();
    if (size == -1) {
        return null;
    }

    Map<String, String> map = new HashMap<String, String>();
    for (int i = 0; i < size; i++) {
        String key = in.readString();
        map.put(key, in.readString());
    }
    return map;
}

From source file:com.nestlabs.sdk.Utils.java

/**
 * Reads a boolean value from a Parcel./*  w w  w .  ja  v a 2  s  .  c  o  m*/
 *
 * @param in the Parcel to read.
 * @return the boolean value read from the Parcel.
 */
static boolean readBoolean(Parcel in) {
    return in.readInt() != 0;
}

From source file:Main.java

public static List<Integer> readIntegerListFromParcel(Parcel in) {
    boolean hasValue = (in.readByte() != 0);

    if (hasValue) {
        List<Integer> list = new ArrayList<>();
        int N = in.readInt();
        for (int i = 0; i < N; i++) {
            list.add(in.readInt());//from  w  w  w  .  j  a  v  a  2  s.com
        }
        return list;
    }

    return null;
}

From source file:com.v2soft.dnremote.dao.Server.java

private static byte[] readIPAddr(Parcel in) {
    int count = in.readInt();
    byte[] res = new byte[count];
    in.readByteArray(res);//from  w w w .j av  a  2s .co  m
    return res;
}

From source file:org.opendatakit.database.queries.BindArgs.java

private static Object unmarshallObject(Parcel in) {
    int dataType = in.readInt();
    switch (dataType) {
    case 0:/*from   w w  w . ja v  a2 s  .c  om*/
        return null;
    case 1:
        return in.readString();
    case 2:
        return in.readInt();
    case 3:
        return Boolean.TRUE;
    case 4:
        return Boolean.FALSE;
    case 5:
        return in.readDouble();
    case 6:
        return in.readFloat();
    case 7:
        return in.readLong();
    default:
        throw new IllegalStateException("should have been prevented in constructor");
    }
}

From source file:ua.setcom.developertools.Onscreen.DevToolsViewState.java

private static DevToolsViewState fromParcel(Parcel in) {
    final DevToolsViewState result = new DevToolsViewState();
    result.width = in.readInt();
    result.height = in.readInt();/*from   ww w . j a  v a 2s  .  c  o m*/
    result.x = in.readInt();
    result.y = in.readInt();
    return result;
}