List of usage examples for android.os Parcel setDataPosition
public final void setDataPosition(int pos)
From source file:Main.java
public static Parcel deserialize(byte[] bytes) { Parcel parcel = Parcel.obtain(); parcel.unmarshall(bytes, 0, bytes.length); parcel.setDataPosition(0); return parcel; }
From source file:Main.java
private static Parcel unmarshall(byte[] bytes) { Parcel parcel = Parcel.obtain(); parcel.unmarshall(bytes, 0, bytes.length); parcel.setDataPosition(0); return parcel; }
From source file:Main.java
private static <T> T bytes2Parcelable(final byte[] bytes, final Parcelable.Creator<T> creator) { if (bytes == null) return null; Parcel parcel = Parcel.obtain(); parcel.unmarshall(bytes, 0, bytes.length); parcel.setDataPosition(0); T result = creator.createFromParcel(parcel); parcel.recycle();/* w ww.j a v a2 s . c om*/ return result; }
From source file:Main.java
public static Bundle bundleFromByteArray(byte[] byteArray) { Parcel obtain = Parcel.obtain(); obtain.unmarshall(byteArray, 0, byteArray.length); obtain.setDataPosition(0); Bundle result = Bundle.CREATOR.createFromParcel(obtain); obtain.recycle();/*from w w w . j ava 2 s. c om*/ return result; }
From source file:Main.java
public static ContentValues contentValuesFromByteArray(byte[] byteArray) { Parcel obtain = Parcel.obtain(); obtain.unmarshall(byteArray, 0, byteArray.length); obtain.setDataPosition(0); ContentValues createFromParcel = ContentValues.CREATOR.createFromParcel(obtain); obtain.recycle();//from w w w . j a va 2s .co m return createFromParcel; }
From source file:Main.java
public static Intent intentFromByteArray(byte[] byteArray) { Parcel obtain = Parcel.obtain(); obtain.unmarshall(byteArray, 0, byteArray.length); obtain.setDataPosition(0); Intent createFromParcel = Intent.CREATOR.createFromParcel(obtain); obtain.recycle();//ww w .j ava 2 s. c o m return createFromParcel; }
From source file:Main.java
public static Spanned spannedFromByteArray(byte[] byteArray) { Parcel obtain = Parcel.obtain(); obtain.unmarshall(byteArray, 0, byteArray.length); obtain.setDataPosition(0); Spanned result = (Spanned) TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(obtain); obtain.recycle();/*from w w w.j av a 2 s. com*/ return result; }
From source file:Main.java
public static <T extends Parcelable> T clone(final T original, final Parcelable.Creator<T> creator) { final Parcel parcel = Parcel.obtain(); original.writeToParcel(parcel, 0);//ww w . j ava 2 s .com parcel.setDataPosition(0); final T copy = creator.createFromParcel(parcel); parcel.recycle(); return copy; }
From source file:Main.java
public static ContentValues[] arrayContentValuesFromByteArray(byte[] byteArray) { Parcel obtain = Parcel.obtain(); obtain.unmarshall(byteArray, 0, byteArray.length); obtain.setDataPosition(0); Parcelable[] contentValues = obtain.readParcelableArray(ContentValues.class.getClassLoader()); ContentValues[] values = new ContentValues[contentValues.length]; for (int i = 0; i < contentValues.length; i++) { values[i] = (ContentValues) contentValues[i]; }/*w w w . j a v a 2 s . com*/ obtain.recycle(); return values; }
From source file:Main.java
public static Bundle mutate(Bundle bundle) { if (bundle == null) { return null; }// w w w .j a v a2 s. c om final Parcel in = Parcel.obtain(); in.writeBundle(bundle); final byte[] bytes = in.marshall(); final Parcel out = Parcel.obtain(); out.unmarshall(bytes, 0, bytes.length); out.setDataPosition(0); try { return out.readBundle(); } finally { in.recycle(); out.recycle(); } }