/** * Unpacks the recipes extra from the intent that started this activity and returns an * ObservableArrayList containing the same recipes. * * @return a list of recipes */ private ObservableArrayList<Recipe> unpackRecipes() { final Parcelable[] parcelables = getIntent().getParcelableArrayExtra(EXTRA_RECIPES); Objects.requireNonNull( parcelables, "MealRecipeAddActivity must be started with a recipes extra"); final ObservableArrayList<Recipe> recipes = new ObservableArrayList<>(); recipes.ensureCapacity(parcelables.length); for (Parcelable parcelable : parcelables) { recipes.add((Recipe) parcelable); } return recipes; }
/** * Unpacks the recipes existing in the meal from the intent that started this activity and returns * a List of those recipes * * @return list of recipes */ private List<Recipe> existRecipes() { final Parcelable[] parcelables = getIntent().getParcelableArrayExtra(MealRecipeAddActivity.EXIST_RECIPES); Objects.requireNonNull( parcelables, "MealRecipeAddActivity must be started with a exist recipe list"); final ObservableArrayList<Recipe> exist = new ObservableArrayList<>(); exist.ensureCapacity(parcelables.length); for (Parcelable parcelable : parcelables) { exist.add((Recipe) parcelable); } return exist; }