Skip to content

Instantly share code, notes, and snippets.

@px-amaac
Last active August 29, 2015 14:24
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 px-amaac/3f659b633de4c004e6b9 to your computer and use it in GitHub Desktop.
Save px-amaac/3f659b633de4c004e6b9 to your computer and use it in GitHub Desktop.
Problem with parcelable data
public class Host implements Parcelable {
@Expose
private String id;
@SerializedName("display_name")
@Expose
private String displayName;
@Expose
private String username;
@Expose
private String image;
/**
* @return The id
*/
public String getId() {
return id;
}
/**
* @param id The id
*/
public void setId(String id) {
this.id = id;
}
/**
* @return The displayName
*/
public String getDisplayName() {
return displayName;
}
/**
* @param displayName The display_name
*/
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
/**
* @return The username
*/
public String getUsername() {
return username;
}
/**
* @param username The username
*/
public void setUsername(String username) {
this.username = username;
}
/**
* @return The image
*/
public String getImage() {
return image;
}
/**
* @param image The image
*/
public void setImage(String image) {
this.image = image;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.id);
dest.writeString(this.displayName);
dest.writeString(this.username);
dest.writeValue(this.image);
}
public Host() {
}
protected Host(Parcel in) {
this.id = in.readString();
this.displayName = in.readString();
this.username = in.readString();
this.image = in.readString();
}
public static final Parcelable.Creator<Host> CREATOR = new Parcelable.Creator<Host>() {
public Host createFromParcel(Parcel source) {
return new Host(source);
}
public Host[] newArray(int size) {
return new Host[size];
}
};
}
{
"Airtime": {
"start": "17:00:00",
"end": "19:30:00",
"start_x": "17:00:00",
"end_x": "19:30:00",
"start_f": "17:00:00",
"end_f": "19:30:00",
"start_gmt": "00:00:00",
"end_gmt": "02:30:00",
"weekday": "7"
},
"id": "66",
"title": "Miles Ahead, Miles Behind",
"short_name": "miles",
"full_description": "Tune in each Sunday from 5 until 7:30 for a strictly a spontaneous exploration of jazz in all of its styles and colors. You will hear the legends of jazz: Louis Armstrong, Sidney Bechet, Count Basie, Duke Ellington, Charlie Parker, Dizzy Gillespie, Max Roach, Ornette Coleman, John Coltrane, Thelonious Monk, Bill Evans, Miles Davis, Wayne Shorter, Sonny Rollins and many more. With current jazz ambassadors like Joshua Redman, Brad Mehdau, Ravi Coltrane, Danilo Perez, Kenny Garrett, Joey DeFrancesco and whoever else comes by. There will be vocalist like Billie Holiday, Sarah Vaughan, Ella Fitzgerald, Betty Carter, Carmen McCrae, Joe Williams, Ray Charles, Andy Bey, Jon Hendricks, Kurt Elling, Tierney Sutton, Dee Dee Bridgewater, Melody Gardot and a lot more. There will also be Latin music from Puerto Rico, Cuba, Central and South America. \r\n\r\nSo Join your host Clay Hilligas as he takes you on a jazz exploration that will change each and every week!",
"short_description": "Featuring jazz from the 20's all the way up to the present. There will also be some Latin music in the last 30 to 45 minutes.",
"Image": {
"url": "https:\/\/s3.amazonaws.com\/image\/original\/MilesAheadMilesBehind.jpg",
"url_sm": "https:\/\/s3.amazonaws.com\/image\/small\/MilesAheadMilesBehind.jpg",
"url_md": "https:\/\/s3.amazonaws.com\/image\/medium\/MilesAheadMilesBehind.jpg",
"url_lg": "https:\/\/s3.amazonaws.com\/image\/large\/MilesAheadMilesBehind.jpg"
},
"image": "MilesAheadMilesBehind.jpg",
"hosts": [{
"id": "95",
"display_name": "Clay Hilligas and Bill Bathurst",
"username": "milesab",
"image": false
}],
"categories": [{
"id": "66",
"title": "Jazz",
"short_name": "jazz"
}]
},
private void getDataFromIntent(Intent intent) {
mProgram = intent.getParcelableExtra(PROGRAM_DATA_KEY);
if(mProgram != null) {
mCollapsingToolbarLayout.setTitle(mProgram.getTitle());
mProgramDescription.setText(mProgram.getShortDescription());
mProgramAirtimes.setText(Utils.getFriendlyAirTime(mProgram.getAirtime()));
mHostName.setText(getHostFriendlyText(mProgram.getHosts()));
if(mProgram.getImage() != null) {
setupProgramImage();
}
}
}
private String getHostFriendlyText(List<Host> hosts) {
String hostsString = "";
if(hosts != null && !hosts.isEmpty()){
for(Host host: hosts) {
hostsString = hostsString.concat(host.getDisplayName() + "\n");
}
}
return hostsString;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment