ByteBuffer byteBuffer = new ByteBuffer();
@Implementation @HiddenApi synchronized public static Number nativeCreate() { long nativePtr = nextNativePtr++; NATIVE_PTR_TO_PARCEL.put(nativePtr, new ByteBuffer()); return castNativePtr(nativePtr); }
/** * Creates a Byte buffer from a raw byte array. * * @param array byte array to read from * @param offset starting position in bytes to start reading array at * @param length number of bytes to read from array */ public static ByteBuffer fromByteArray(byte[] array, int offset, int length) { ByteBuffer byteBuffer = new ByteBuffer(); try { ByteArrayInputStream bis = new ByteArrayInputStream(array, offset, length); ObjectInputStream ois = new ObjectInputStream(bis); int numElements = ois.readInt(); for (int i = 0; i < numElements; i++) { int sizeOf = ois.readInt(); Object value = ois.readObject(); byteBuffer.buffer.add(Pair.create(sizeOf, value)); } return byteBuffer; } catch (Exception e) { throw new RuntimeException(e); } }
/** * Creates a Byte buffer from a raw byte array. * * @param array byte array to read from * @param offset starting position in bytes to start reading array at * @param length number of bytes to read from array */ public static ByteBuffer fromByteArray(byte[] array, int offset, int length) { ByteBuffer byteBuffer = new ByteBuffer(); try { ByteArrayInputStream bis = new ByteArrayInputStream(array, offset, length); ObjectInputStream ois = new ObjectInputStream(bis); int numElements = ois.readInt(); for (int i = 0; i < numElements; i++) { int sizeOf = ois.readInt(); Object value = ois.readObject(); byteBuffer.buffer.add(Pair.create(sizeOf, value)); } return byteBuffer; } catch (Exception e) { throw new RuntimeException(e); } }
/** * Creates a Byte buffer from a raw byte array. * * @param array byte array to read from * @param offset starting position in bytes to start reading array at * @param length number of bytes to read from array */ public static ByteBuffer fromByteArray(byte[] array, int offset, int length) { ByteBuffer byteBuffer = new ByteBuffer(); try { ByteArrayInputStream bis = new ByteArrayInputStream(array, offset, length); ObjectInputStream ois = new ObjectInputStream(bis); int numElements = ois.readInt(); for (int i = 0; i < numElements; i++) { int sizeOf = ois.readInt(); Object value = ois.readObject(); byteBuffer.buffer.add(Pair.create(sizeOf, value)); } return byteBuffer; } catch (Exception e) { throw new RuntimeException(e); } }
/** * Creates a Byte buffer from a raw byte array. * * @param array byte array to read from * @param offset starting position in bytes to start reading array at * @param length number of bytes to read from array */ public static ByteBuffer fromByteArray(byte[] array, int offset, int length) { ByteBuffer byteBuffer = new ByteBuffer(); try { ByteArrayInputStream bis = new ByteArrayInputStream(array, offset, length); ObjectInputStream ois = new ObjectInputStream(bis); int numElements = ois.readInt(); for (int i = 0; i < numElements; i++) { int sizeOf = ois.readInt(); Object value = ois.readObject(); byteBuffer.buffer.add(Pair.create(sizeOf, value)); } return byteBuffer; } catch (Exception e) { throw new RuntimeException(e); } }
@Implementation @HiddenApi synchronized public static Number nativeCreate() { long nativePtr = nextNativePtr++; NATIVE_PTR_TO_PARCEL.put(nativePtr, new ByteBuffer()); return castNativePtr(nativePtr); }
@Implementation @HiddenApi synchronized public static Number nativeCreate() { long nativePtr = nextNativePtr++; NATIVE_PTR_TO_PARCEL.put(nativePtr, new ByteBuffer()); return castNativePtr(nativePtr); }
@Implementation @HiddenApi synchronized public static Number nativeCreate() { long nativePtr = nextNativePtr++; NATIVE_PTR_TO_PARCEL.put(nativePtr, new ByteBuffer()); return castNativePtr(nativePtr); }
@Implementation @HiddenApi public static long nativeCreate() { // Pick a native ptr that hasn't been used. long nativePtrUsed = 0; while (NATIVE_PTR_TO_PARCEL.containsKey(nativePtrUsed)) { nativePtrUsed++; } NATIVE_PTR_TO_PARCEL.put(nativePtrUsed, new ByteBuffer()); return nativePtrUsed; }