// Path: app/src/main/java/com/lambdasoup/quickfit/model/DayOfWeek.java
// public enum DayOfWeek implements Parcelable {
//     MONDAY(Calendar.MONDAY, R.string.monday),
//     TUESDAY(Calendar.TUESDAY, R.string.tuesday),
//     WEDNESDAY(Calendar.WEDNESDAY, R.string.wednesday),
//     THURSDAY(Calendar.THURSDAY, R.string.thursday),
//     FRIDAY(Calendar.FRIDAY, R.string.friday),
//     SATURDAY(Calendar.SATURDAY, R.string.saturday),
//     SUNDAY(Calendar.SUNDAY, R.string.sunday);
// 
//     public final int calendarConst;
//     public final int fullNameResId;
// 
//     DayOfWeek(int calendarConst, @StringRes int fullNameResId) {
//         this.calendarConst = calendarConst;
//         this.fullNameResId = fullNameResId;
//     }
// 
//     @NonNull
//     public static DayOfWeek[] getWeek() {
//         return getWeek(Calendar.getInstance());
//     }
// 
//     @NonNull
//     protected static DayOfWeek[] getWeek(Calendar calendar) {
//         int firstDay = calendar.getFirstDayOfWeek();
//         DayOfWeek[] week = new DayOfWeek[7];
//         for (int i = 0; i < 7; i++) {
//             int calendarConst = firstDay + i;
//             if (calendarConst > 7) {
//                 calendarConst -= 7;
//             }
//             week[i] = getByCalendarConst(calendarConst);
//         }
//         return week;
//     }
// 
//     public static DayOfWeek getByCalendarConst(int calendarConst) {
//         switch (calendarConst) {
//             case Calendar.MONDAY:
//                 return MONDAY;
//             case Calendar.TUESDAY:
//                 return TUESDAY;
//             case Calendar.WEDNESDAY:
//                 return WEDNESDAY;
//             case Calendar.THURSDAY:
//                 return THURSDAY;
//             case Calendar.FRIDAY:
//                 return FRIDAY;
//             case Calendar.SATURDAY:
//                 return SATURDAY;
//             case Calendar.SUNDAY:
//                 return SUNDAY;
//             default:
//                 throw new IllegalArgumentException("Not a java.util.Calendar weekday constant: " + calendarConst);
//         }
//     }
// 
//     // GENERATED START
//     // by parcelable AndroidStudio plugin
// 
//     @Override
//     public int describeContents() {
//         return 0;
//     }
// 
//     @Override
//     public void writeToParcel(final Parcel dest, final int flags) {
//         dest.writeString(name());
//     }
// 
//     public static final Creator<DayOfWeek> CREATOR = new Creator<DayOfWeek>() {
//         @Override
//         public DayOfWeek createFromParcel(final Parcel source) {
//             return DayOfWeek.valueOf(source.readString());
//         }
// 
//         @Override
//         public DayOfWeek[] newArray(final int size) {
//             return new DayOfWeek[size];
//         }
//     };
// 
//     // GENERATED END
// }
// 
// Path: app/src/main/java/com/lambdasoup/quickfit/util/Arrays.java
// public class Arrays {
//     public static <S, T> T[] map(S[] source, Class<T[]> targetClass, Function<S, T> transformation) {
//         T[] target = targetClass.cast(Array.newInstance(targetClass.getComponentType(), source.length));
//         for (int i = 0; i < source.length; i++) {
//             target[i] = transformation.apply(source[i]);
//         }
//         return target;
//     }
// 
//     public static <T> int firstIndexOf(@NonNull T[] array, @NonNull T item) {
//         for (int i = 0; i < array.length; i++) {
//             if (item.equals(array[i])) {
//                 return i;
//             }
//         }
//         throw new NoSuchElementException();
//     }
// }


import android.app.Activity;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.fragment.app.DialogFragment;
import androidx.appcompat.app.AlertDialog;
import com.lambdasoup.quickfit.R;
import com.lambdasoup.quickfit.model.DayOfWeek;
import com.lambdasoup.quickfit.util.Arrays;
    public static DayOfWeekDialogFragment newInstance(long objectId, DayOfWeek oldValue) {
        DayOfWeekDialogFragment fragment = new DayOfWeekDialogFragment();
        Bundle args = new Bundle();
        args.putLong(KEY_SCHEDULE_ID, objectId);
        args.putParcelable(KEY_OLD_VALUE, oldValue);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        if (activity instanceof OnFragmentInteractionListenerProvider) {
            listener = ((OnFragmentInteractionListenerProvider) activity).getOnDayOfWeekDialogFragmentInteractionListener();
        } else {
            throw new IllegalArgumentException(activity.toString() + " must implement OnFragmentInteractionListenerProvider");
        }
    }

    @Override
    public void onDetach() {
        super.onDetach();
        listener = null;
    }

    @NonNull
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        week = DayOfWeek.getWeek();
        //noinspection ConstantConditions
// Path: app/src/main/java/com/lambdasoup/quickfit/model/DayOfWeek.java
// public enum DayOfWeek implements Parcelable {
//     MONDAY(Calendar.MONDAY, R.string.monday),
//     TUESDAY(Calendar.TUESDAY, R.string.tuesday),
//     WEDNESDAY(Calendar.WEDNESDAY, R.string.wednesday),
//     THURSDAY(Calendar.THURSDAY, R.string.thursday),
//     FRIDAY(Calendar.FRIDAY, R.string.friday),
//     SATURDAY(Calendar.SATURDAY, R.string.saturday),
//     SUNDAY(Calendar.SUNDAY, R.string.sunday);
// 
//     public final int calendarConst;
//     public final int fullNameResId;
// 
//     DayOfWeek(int calendarConst, @StringRes int fullNameResId) {
//         this.calendarConst = calendarConst;
//         this.fullNameResId = fullNameResId;
//     }
// 
//     @NonNull
//     public static DayOfWeek[] getWeek() {
//         return getWeek(Calendar.getInstance());
//     }
// 
//     @NonNull
//     protected static DayOfWeek[] getWeek(Calendar calendar) {
//         int firstDay = calendar.getFirstDayOfWeek();
//         DayOfWeek[] week = new DayOfWeek[7];
//         for (int i = 0; i < 7; i++) {
//             int calendarConst = firstDay + i;
//             if (calendarConst > 7) {
//                 calendarConst -= 7;
//             }
//             week[i] = getByCalendarConst(calendarConst);
//         }
//         return week;
//     }
// 
//     public static DayOfWeek getByCalendarConst(int calendarConst) {
//         switch (calendarConst) {
//             case Calendar.MONDAY:
//                 return MONDAY;
//             case Calendar.TUESDAY:
//                 return TUESDAY;
//             case Calendar.WEDNESDAY:
//                 return WEDNESDAY;
//             case Calendar.THURSDAY:
//                 return THURSDAY;
//             case Calendar.FRIDAY:
//                 return FRIDAY;
//             case Calendar.SATURDAY:
//                 return SATURDAY;
//             case Calendar.SUNDAY:
//                 return SUNDAY;
//             default:
//                 throw new IllegalArgumentException("Not a java.util.Calendar weekday constant: " + calendarConst);
//         }
//     }
// 
//     // GENERATED START
//     // by parcelable AndroidStudio plugin
// 
//     @Override
//     public int describeContents() {
//         return 0;
//     }
// 
//     @Override
//     public void writeToParcel(final Parcel dest, final int flags) {
//         dest.writeString(name());
//     }
// 
//     public static final Creator<DayOfWeek> CREATOR = new Creator<DayOfWeek>() {
//         @Override
//         public DayOfWeek createFromParcel(final Parcel source) {
//             return DayOfWeek.valueOf(source.readString());
//         }
// 
//         @Override
//         public DayOfWeek[] newArray(final int size) {
//             return new DayOfWeek[size];
//         }
//     };
// 
//     // GENERATED END
// }
// 
// Path: app/src/main/java/com/lambdasoup/quickfit/util/Arrays.java
// public class Arrays {
//     public static <S, T> T[] map(S[] source, Class<T[]> targetClass, Function<S, T> transformation) {
//         T[] target = targetClass.cast(Array.newInstance(targetClass.getComponentType(), source.length));
//         for (int i = 0; i < source.length; i++) {
//             target[i] = transformation.apply(source[i]);
//         }
//         return target;
//     }
// 
//     public static <T> int firstIndexOf(@NonNull T[] array, @NonNull T item) {
//         for (int i = 0; i < array.length; i++) {
//             if (item.equals(array[i])) {
//                 return i;
//             }
//         }
//         throw new NoSuchElementException();
//     }
// }


// Path: app/src/main/java/com/lambdasoup/quickfit/ui/DayOfWeekDialogFragment.java
import android.app.Activity;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.fragment.app.DialogFragment;
import androidx.appcompat.app.AlertDialog;
import com.lambdasoup.quickfit.R;
import com.lambdasoup.quickfit.model.DayOfWeek;
import com.lambdasoup.quickfit.util.Arrays;

    public static DayOfWeekDialogFragment newInstance(long objectId, DayOfWeek oldValue) {
        DayOfWeekDialogFragment fragment = new DayOfWeekDialogFragment();
        Bundle args = new Bundle();
        args.putLong(KEY_SCHEDULE_ID, objectId);
        args.putParcelable(KEY_OLD_VALUE, oldValue);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        if (activity instanceof OnFragmentInteractionListenerProvider) {
            listener = ((OnFragmentInteractionListenerProvider) activity).getOnDayOfWeekDialogFragmentInteractionListener();
        } else {
            throw new IllegalArgumentException(activity.toString() + " must implement OnFragmentInteractionListenerProvider");
        }
    }

    @Override
    public void onDetach() {
        super.onDetach();
        listener = null;
    }

    @NonNull
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        week = DayOfWeek.getWeek();
        //noinspection ConstantConditions
        checkedItemPosition = Arrays.firstIndexOf(week, getArguments().getParcelable(KEY_OLD_VALUE));