Skip to content

Instantly share code, notes, and snippets.

@canberkozcelik
Last active December 22, 2017 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save canberkozcelik/f73a159b8254fde6a755b250cd027797 to your computer and use it in GitHub Desktop.
Save canberkozcelik/f73a159b8254fde6a755b250cd027797 to your computer and use it in GitHub Desktop.
-----------------------------------com.example.packagename.Friend.java-----------------------------------
package com.example.packagename;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable.Creator;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Friend implements Parcelable
{
@SerializedName("id")
@Expose
public Integer id;
@SerializedName("name")
@Expose
public String name;
public final static Parcelable.Creator<Friend> CREATOR = new Creator<Friend>() {
@SuppressWarnings({
"unchecked"
})
public Friend createFromParcel(Parcel in) {
return new Friend(in);
}
public Friend[] newArray(int size) {
return (new Friend[size]);
}
}
;
protected Friend(Parcel in) {
this.id = ((Integer) in.readValue((Integer.class.getClassLoader())));
this.name = ((String) in.readValue((String.class.getClassLoader())));
}
public Friend() {
}
public void writeToParcel(Parcel dest, int flags) {
dest.writeValue(id);
dest.writeValue(name);
}
public int describeContents() {
return 0;
}
}
-----------------------------------com.example.packagename.Response.java-----------------------------------
package com.example.packagename;
import java.util.List;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable.Creator;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Response implements Parcelable
{
@SerializedName("_id")
@Expose
public String id;
@SerializedName("index")
@Expose
public Integer index;
@SerializedName("guid")
@Expose
public String guid;
@SerializedName("isActive")
@Expose
public Boolean isActive;
@SerializedName("balance")
@Expose
public String balance;
@SerializedName("picture")
@Expose
public String picture;
@SerializedName("age")
@Expose
public Integer age;
@SerializedName("eyeColor")
@Expose
public String eyeColor;
@SerializedName("name")
@Expose
public String name;
@SerializedName("gender")
@Expose
public String gender;
@SerializedName("company")
@Expose
public String company;
@SerializedName("email")
@Expose
public String email;
@SerializedName("phone")
@Expose
public String phone;
@SerializedName("address")
@Expose
public String address;
@SerializedName("about")
@Expose
public String about;
@SerializedName("registered")
@Expose
public String registered;
@SerializedName("latitude")
@Expose
public Double latitude;
@SerializedName("longitude")
@Expose
public Double longitude;
@SerializedName("tags")
@Expose
public List<String> tags = null;
@SerializedName("friends")
@Expose
public List<Friend> friends = null;
@SerializedName("greeting")
@Expose
public String greeting;
@SerializedName("favoriteFruit")
@Expose
public String favoriteFruit;
public final static Parcelable.Creator<Response> CREATOR = new Creator<Response>() {
@SuppressWarnings({
"unchecked"
})
public Response createFromParcel(Parcel in) {
return new Response(in);
}
public Response[] newArray(int size) {
return (new Response[size]);
}
}
;
protected Response(Parcel in) {
this.id = ((String) in.readValue((String.class.getClassLoader())));
this.index = ((Integer) in.readValue((Integer.class.getClassLoader())));
this.guid = ((String) in.readValue((String.class.getClassLoader())));
this.isActive = ((Boolean) in.readValue((Boolean.class.getClassLoader())));
this.balance = ((String) in.readValue((String.class.getClassLoader())));
this.picture = ((String) in.readValue((String.class.getClassLoader())));
this.age = ((Integer) in.readValue((Integer.class.getClassLoader())));
this.eyeColor = ((String) in.readValue((String.class.getClassLoader())));
this.name = ((String) in.readValue((String.class.getClassLoader())));
this.gender = ((String) in.readValue((String.class.getClassLoader())));
this.company = ((String) in.readValue((String.class.getClassLoader())));
this.email = ((String) in.readValue((String.class.getClassLoader())));
this.phone = ((String) in.readValue((String.class.getClassLoader())));
this.address = ((String) in.readValue((String.class.getClassLoader())));
this.about = ((String) in.readValue((String.class.getClassLoader())));
this.registered = ((String) in.readValue((String.class.getClassLoader())));
this.latitude = ((Double) in.readValue((Double.class.getClassLoader())));
this.longitude = ((Double) in.readValue((Double.class.getClassLoader())));
in.readList(this.tags, (java.lang.String.class.getClassLoader()));
in.readList(this.friends, (com.example.packagename.Friend.class.getClassLoader()));
this.greeting = ((String) in.readValue((String.class.getClassLoader())));
this.favoriteFruit = ((String) in.readValue((String.class.getClassLoader())));
}
public Response() {
}
public void writeToParcel(Parcel dest, int flags) {
dest.writeValue(id);
dest.writeValue(index);
dest.writeValue(guid);
dest.writeValue(isActive);
dest.writeValue(balance);
dest.writeValue(picture);
dest.writeValue(age);
dest.writeValue(eyeColor);
dest.writeValue(name);
dest.writeValue(gender);
dest.writeValue(company);
dest.writeValue(email);
dest.writeValue(phone);
dest.writeValue(address);
dest.writeValue(about);
dest.writeValue(registered);
dest.writeValue(latitude);
dest.writeValue(longitude);
dest.writeList(tags);
dest.writeList(friends);
dest.writeValue(greeting);
dest.writeValue(favoriteFruit);
}
public int describeContents() {
return 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment