Last active
December 11, 2015 01:39
-
-
Save joshdholtz/4525240 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
private int id; | |
private String name; | |
private String description; | |
private double fee; | |
private int startAge; | |
private int endAge; | |
private int size; | |
private boolean adultOnly; | |
private int min; | |
private int max; | |
private double lat; | |
private double lng; | |
private ActivityModel activity; | |
private Date startDate; | |
private Date endDate; | |
private int registrationCount; | |
private int friendCount; | |
public EventModel() { | |
super(); | |
} | |
public EventModel(JSONObject jsonObject) { | |
super(jsonObject); | |
} | |
@Override | |
public void mapToClass(String key, Object value) { | |
if (key.equals("id")) { | |
this.id = (Integer)value; | |
} else if (key.equals("name")) { | |
this.name = (String)value; | |
} else if (key.equals("description")) { | |
this.description = (String)value; | |
} else if (key.equals("fee")) { | |
this.fee = Double.parseDouble(value.toString()); | |
} else if (key.equals("start_age")) { | |
this.startAge = (Integer)value; | |
} else if (key.equals("end_age")) { | |
this.endAge = (Integer)value; | |
} else if (key.equals("adult_only")) { | |
this.adultOnly = (Boolean)value; | |
} else if (key.equals("size")) { | |
this.size = (Integer)value; | |
} else if (key.equals("min")) { | |
this.min = (Integer)value; | |
} else if (key.equals("max")) { | |
this.max = (Integer)value; | |
} else if (key.equals("lat")) { | |
this.lat = Double.parseDouble(value.toString()); | |
} else if (key.equals("lng")) { | |
this.lng = Double.parseDouble(value.toString()); | |
} else if (key.equals("images")) { | |
} else if (key.equals("thumbnails")) { | |
} else if (key.equals("activity")) { | |
this.activity = ProtocolModel.createModel(ActivityModel.class, value.toString()); | |
} else if (key.equals("start_date")) { | |
this.startDate = BaseModel.stringToDate(value.toString()); | |
} else if (key.equals("end_date")) { | |
this.endDate = BaseModel.stringToDate(value.toString()); | |
} else if (key.equals("instructor")) { | |
} else if (key.equals("registration_count")) { | |
this.registrationCount = (Integer)value; | |
} else if (key.equals("friend_count")) { | |
this.friendCount = (Integer)value; | |
} | |
} |
This file contains hidden or 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
@MapConfig(key = "id") private int id; | |
@MapConfig(key = "name") private String name; | |
@MapConfig(key = "description") private String description; | |
@MapConfig(key = "fee") private double fee; | |
@MapConfig(key = "start_age") private int startAge; | |
@MapConfig(key = "end_age") private int endAge; | |
@MapConfig(key = "size") private int size; | |
@MapConfig(key = "adult_only") private boolean adultOnly; | |
@MapConfig(key = "min") private int min; | |
@MapConfig(key = "max") private int max; | |
@MapConfig(key = "lat") private double lat; | |
@MapConfig(key = "lng") private double lng; | |
@MapModelConfig(key = "activity", modelClass = ActivityModel.class) private ActivityModel activity; | |
@MapConfig(key = "start_date", format = "date") private Date startDate; | |
@MapConfig(key = "end_date", format = "date") private Date endDate; | |
@MapConfig(key = "registration_count") private int registrationCount; | |
@MapConfig(key = "friend_count") private int friendCount; |
This file contains hidden or 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
ProtocolModelFormats.set("date", new MapFormat() { | |
@Override | |
public Object format(Object value) { | |
SimpleDateFormat sdf = new SimpleDateFormat("yyyy'-'MM'-'dd'T'HH':'mm':'ssZ"); | |
try { | |
return sdf.parse(value.toString()); | |
} catch (ParseException e) {e.printStackTrace();} | |
return null; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment