Vegetarian/Vegan filter
This commit is contained in:
@@ -58,7 +58,6 @@ class MealAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
position = position + 1;
|
||||
if (holder.getItemViewType() == TYPE_MEAL) {
|
||||
MealViewHolder viewHolder = ((MealViewHolder) holder);
|
||||
viewHolder.reset();
|
||||
@@ -131,18 +130,18 @@ class MealAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
public int getItemViewType(int position) {
|
||||
if (position == 0)
|
||||
return TYPE_LEGEND;
|
||||
return matches.get(position + 1) instanceof String ? TYPE_HEADER : TYPE_MEAL;
|
||||
return matches.get(position - 1) instanceof String ? TYPE_HEADER : TYPE_MEAL;
|
||||
}
|
||||
|
||||
private Meal getMeal(int position) {
|
||||
if (this.mDay != null)
|
||||
return this.mDay.get((Integer) matches.get(position));
|
||||
return this.mDay.get((Integer) matches.get(position - 1));
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getHeading(int position) {
|
||||
return (String) matches.get(position);
|
||||
return (String) matches.get(position - 1);
|
||||
}
|
||||
|
||||
public void setDay(Day day) {
|
||||
@@ -152,8 +151,13 @@ class MealAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
public void setDay() {
|
||||
HashMap<String, ArrayList<Integer>> map = new HashMap<>();
|
||||
String foodLevel = Preferences.getStringArray(mContext, R.array.pref_food_level);
|
||||
for (int i = 0; i < this.mDay.size(); i++) {
|
||||
String category = this.mDay.get(i).getCategory();
|
||||
Meal meal = this.mDay.get(i);
|
||||
if (!(meal.getVegan() == Meal.VEGAN_VEGAN || ("vegetarian".equals(foodLevel) && meal.getVegan() == Meal.VEGAN_VEGETARIAN) || "all".equals(foodLevel))) {
|
||||
continue;
|
||||
}
|
||||
String category = meal.getCategory();
|
||||
boolean found = false;
|
||||
for (String category_key : CATEGORY_KEYS) {
|
||||
if (category_key.equals(category)) {
|
||||
|
||||
Reference in New Issue
Block a user