mirror of
https://github.com/oxen-io/session-android.git
synced 2023-12-14 02:53:01 +01:00
b308996885
// FREEBIE
28 lines
706 B
Java
28 lines
706 B
Java
package org.thoughtcrime.securesms.util;
|
|
|
|
import android.os.Parcel;
|
|
import android.os.Parcelable;
|
|
|
|
public class ParcelUtil {
|
|
|
|
public static byte[] serialize(Parcelable parceable) {
|
|
Parcel parcel = Parcel.obtain();
|
|
parceable.writeToParcel(parcel, 0);
|
|
byte[] bytes = parcel.marshall();
|
|
parcel.recycle();
|
|
return bytes;
|
|
}
|
|
|
|
public static Parcel deserialize(byte[] bytes) {
|
|
Parcel parcel = Parcel.obtain();
|
|
parcel.unmarshall(bytes, 0, bytes.length);
|
|
parcel.setDataPosition(0);
|
|
return parcel;
|
|
}
|
|
|
|
public static <T> T deserialize(byte[] bytes, Parcelable.Creator<T> creator) {
|
|
Parcel parcel = deserialize(bytes);
|
|
return creator.createFromParcel(parcel);
|
|
}
|
|
|
|
}
|