Guest User

Untitled

a guest
Jun 25th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. public class Recipe implements Parcelable{
  2. private int id;
  3. private String name;
  4. private ArrayList<Ingredient> ingredients;
  5. private ArrayList<RecipeStep> steps;
  6. private int servings;
  7. private String image;
  8.  
  9. public String getName() {
  10. return this.name;
  11. }
  12.  
  13. private Recipe(Parcel src) {
  14. if (src != null) {
  15. this.id = src.readInt();
  16. this.name = src.readString();
  17. this.ingredients = src.createTypedArrayList(Ingredient.CREATOR);
  18. this.steps = src.createTypedArrayList(RecipeStep.CREATOR);
  19. this.servings = src.readInt();
  20. this.image = src.readString();
  21. }
  22. }
  23.  
  24. public static final Parcelable.Creator<Recipe> CREATOR = new Parcelable.Creator<Recipe>() {
  25. @Override
  26. public Recipe createFromParcel(Parcel source) {
  27. return new Recipe(source);
  28. }
  29.  
  30. @Override
  31. public Recipe[] newArray(int size) {
  32. if (size < 1) {
  33. return new Recipe[0];
  34. }
  35. else {
  36. return new Recipe[size];
  37. }
  38. }
  39. };
  40.  
  41. @Override
  42. public int describeContents() {
  43. return 0;
  44. }
  45.  
  46. @Override
  47. public void writeToParcel(Parcel dest, int flags) {
  48. if (dest != null) {
  49. dest.writeInt(this.id);
  50. dest.writeString(this.name);
  51. dest.writeTypedList(this.ingredients);
  52. dest.writeTypedList(this.steps);
  53. dest.writeInt(this.servings);
  54. dest.writeString(this.image);
  55. }
  56. }
  57. }
Add Comment
Please, Sign In to add comment