Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package local.example.guessthenumber;
- import android.os.Parcel;
- import android.os.Parcelable;
- /**
- * Created by Nello on 11/01/2018.
- */
- public class UserInfo implements Parcelable {
- public final String userName;
- public final String password;
- private int version;
- public UserInfo(String userName, String password) {
- this.userName = userName;
- this.password = password;
- this.version = 1;
- }
- protected UserInfo(Parcel in) {
- version = in.readInt();
- if (version == 1) {
- userName = in.readString();
- password = in.readString();
- }
- else
- {
- userName = "Noname";
- password = "";
- }
- }
- public static final Creator<UserInfo> CREATOR = new Creator<UserInfo>() {
- @Override
- public UserInfo createFromParcel(Parcel in) {
- return new UserInfo(in);
- }
- @Override
- public UserInfo[] newArray(int size) {
- return new UserInfo[size];
- }
- };
- @Override
- public int describeContents() {
- return 0;
- }
- @Override
- public void writeToParcel(Parcel parcel, int i) {
- parcel.writeInt(version);
- parcel.writeString(userName);
- parcel.writeString(password);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement