// Path: app/src/main/java/org/nutritionfacts/dailydozen/controller/Bus.java
// public class Bus {
//     public static void register(Object object) {
//         final EventBus bus = EventBus.getDefault();
//         if (!bus.isRegistered(object)) {
//             bus.register(object);
//         }
//     }
// 
//     public static void unregister(Object object) {
//         final EventBus bus = EventBus.getDefault();
//         if (bus.isRegistered(object)) {
//             bus.unregister(object);
//         }
//     }
// 
//     private static void post(BaseEvent event) {
//         EventBus.getDefault().post(event);
//     }
// 
//     public static void foodServingsChangedEvent(Day day, Food food) {
//         post(new FoodServingsChangedEvent(day.getDateString(), food.getName(), Common.isSupplement(food)));
//     }
// 
//     public static void tweakServingsChangedEvent(Day day, Tweak tweak) {
//         post(new TweakServingsChangedEvent(day.getDateString(), tweak.getName()));
//     }
// 
//     public static void displayLatestDate() {
//         post(new DisplayDateEvent(Day.getToday()));
//     }
// 
//     public static void showExplodingStarAnimation() {
//         post(new ShowExplodingStarAnimation());
//     }
// 
//     public static void restoreCompleteEvent(final boolean success) {
//         post(new RestoreCompleteEvent(success));
//     }
// 
//     public static void backupCompleteEvent(final boolean success) {
//         post(new BackupCompleteEvent(success));
//     }
// 
//     public static void calculateStreaksComplete(final boolean success) {
//         post(new CalculateStreaksTaskCompleteEvent(success));
//     }
// 
//     public static void loadHistoryCompleteEvent(final LoadHistoryCompleteEvent event) {
//         post(event);
//     }
// 
//     public static void timeScaleSelected(final int selectedTimeScale) {
//         post(new TimeScaleSelectedEvent(selectedTimeScale));
//     }
// 
//     public static void timeRangeSelectedEvent() {
//         post(new TimeRangeSelectedEvent());
//     }
// 
//     public static void weightVisibilityChanged() {
//         post(new WeightVisibilityChangedEvent());
//     }
// 
//     public static void reminderRemovedEvent(int adapterPosition) {
//         post(new ReminderRemovedEvent(adapterPosition));
//     }
// }


import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import org.nutritionfacts.dailydozen.controller.Bus;
import org.nutritionfacts.dailydozen.databinding.ReminderTimeBinding;
import java.util.List;
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ViewHolder(ReminderTimeBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        if (reminderTimes == null || reminderTimes.isEmpty()) {
            return;
        }

        holder.reminderTime.setText(reminderTimes.get(position));
    }

    @Override
    public int getItemCount() {
        return reminderTimes != null ? reminderTimes.size() : 0;
    }

    public void setReminders(List<String> reminderTimes) {
        this.reminderTimes = reminderTimes;
        notifyDataSetChanged();
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        TextView reminderTime;

        ViewHolder(ReminderTimeBinding binding) {
            super(binding.getRoot());
            reminderTime = binding.reminderTime;
// Path: app/src/main/java/org/nutritionfacts/dailydozen/controller/Bus.java
// public class Bus {
//     public static void register(Object object) {
//         final EventBus bus = EventBus.getDefault();
//         if (!bus.isRegistered(object)) {
//             bus.register(object);
//         }
//     }
// 
//     public static void unregister(Object object) {
//         final EventBus bus = EventBus.getDefault();
//         if (bus.isRegistered(object)) {
//             bus.unregister(object);
//         }
//     }
// 
//     private static void post(BaseEvent event) {
//         EventBus.getDefault().post(event);
//     }
// 
//     public static void foodServingsChangedEvent(Day day, Food food) {
//         post(new FoodServingsChangedEvent(day.getDateString(), food.getName(), Common.isSupplement(food)));
//     }
// 
//     public static void tweakServingsChangedEvent(Day day, Tweak tweak) {
//         post(new TweakServingsChangedEvent(day.getDateString(), tweak.getName()));
//     }
// 
//     public static void displayLatestDate() {
//         post(new DisplayDateEvent(Day.getToday()));
//     }
// 
//     public static void showExplodingStarAnimation() {
//         post(new ShowExplodingStarAnimation());
//     }
// 
//     public static void restoreCompleteEvent(final boolean success) {
//         post(new RestoreCompleteEvent(success));
//     }
// 
//     public static void backupCompleteEvent(final boolean success) {
//         post(new BackupCompleteEvent(success));
//     }
// 
//     public static void calculateStreaksComplete(final boolean success) {
//         post(new CalculateStreaksTaskCompleteEvent(success));
//     }
// 
//     public static void loadHistoryCompleteEvent(final LoadHistoryCompleteEvent event) {
//         post(event);
//     }
// 
//     public static void timeScaleSelected(final int selectedTimeScale) {
//         post(new TimeScaleSelectedEvent(selectedTimeScale));
//     }
// 
//     public static void timeRangeSelectedEvent() {
//         post(new TimeRangeSelectedEvent());
//     }
// 
//     public static void weightVisibilityChanged() {
//         post(new WeightVisibilityChangedEvent());
//     }
// 
//     public static void reminderRemovedEvent(int adapterPosition) {
//         post(new ReminderRemovedEvent(adapterPosition));
//     }
// }


// Path: app/src/main/java/org/nutritionfacts/dailydozen/adapter/DailyReminderAdapter.java
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import org.nutritionfacts.dailydozen.controller.Bus;
import org.nutritionfacts.dailydozen.databinding.ReminderTimeBinding;
import java.util.List;

    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ViewHolder(ReminderTimeBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        if (reminderTimes == null || reminderTimes.isEmpty()) {
            return;
        }

        holder.reminderTime.setText(reminderTimes.get(position));
    }

    @Override
    public int getItemCount() {
        return reminderTimes != null ? reminderTimes.size() : 0;
    }

    public void setReminders(List<String> reminderTimes) {
        this.reminderTimes = reminderTimes;
        notifyDataSetChanged();
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        TextView reminderTime;

        ViewHolder(ReminderTimeBinding binding) {
            super(binding.getRoot());
            reminderTime = binding.reminderTime;
            binding.reminderDelete.setOnClickListener(v -> Bus.reminderRemovedEvent(getAdapterPosition()));