Last active
January 25, 2017 14:42
-
-
Save npu3pak/3a8d297b51bb3da549a5342baddeca1a to your computer and use it in GitHub Desktop.
Android. Parcelable без необходимости реализовывать довольно сложный интерфейс. В теории должно работать медленнее чем полноценные Parcelable, на практике разницы нет.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.os.Parcel; | |
import android.os.Parcelable; | |
import java.io.Serializable; | |
public class EasyParcelable implements Parcelable, Serializable { | |
protected EasyParcelable() { | |
} | |
public static final Creator<EasyParcelable> CREATOR = new Creator<EasyParcelable>() { | |
@Override | |
public EasyParcelable createFromParcel(Parcel in) { | |
return (EasyParcelable) in.readSerializable(); | |
} | |
@Override | |
public EasyParcelable[] newArray(int size) { | |
return new EasyParcelable[size]; | |
} | |
}; | |
@Override | |
public int describeContents() { | |
return 0; | |
} | |
@Override | |
public void writeToParcel(Parcel parcel, int flags) { | |
parcel.writeSerializable(this); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment