mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-28 10:47:46 +00:00
b308996885
// FREEBIE
29 lines
706 B
Java
29 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);
|
|
}
|
|
|
|
}
|