Last active
January 8, 2018 00:04
-
-
Save pedromassango/5358ba1caf56af3278a85e1bad920bb5 to your computer and use it in GitHub Desktop.
A java model class with 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
/** | |
* Created by pedromassango on 1/8/18. | |
*/ | |
public class UserJava implements Parcelable { | |
private String username; | |
private int age; | |
protected UserJava(Parcel in, String username, int age) { | |
this.username = username; | |
this.age = age; | |
} | |
protected UserJava(Parcel in) { | |
username = in.readString(); | |
age = in.readInt(); | |
} | |
@Override | |
public void writeToParcel(Parcel dest, int flags) { | |
dest.writeString(username); | |
dest.writeInt(age); | |
} | |
@Override | |
public int describeContents() { | |
return 0; | |
} | |
public static final Creator<UserJava> CREATOR = new Creator<UserJava>() { | |
@Override | |
public UserJava createFromParcel(Parcel in) { | |
return new UserJava(in); | |
} | |
@Override | |
public UserJava[] newArray(int size) { | |
return new UserJava[size]; | |
} | |
}; | |
public String getUsername() { | |
return username; | |
} | |
public void setUsername(String username) { | |
this.username = username; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment