// Path: src/edu/bupt/calendar/CalendarEventModel.java
// public static class ReminderEntry implements Comparable<ReminderEntry>, Serializable {
//     private final int mMinutes;
//     private final int mMethod;
// 
//     /**
//      * Returns a new ReminderEntry, with the specified minutes and method.
//      *
//      * @param minutes Number of minutes before the start of the event that the alert will fire.
//      * @param method Type of alert ({@link Reminders#METHOD_ALERT}, etc).
//      */
//     public static ReminderEntry valueOf(int minutes, int method) {
//         // TODO: cache common instances
//         return new ReminderEntry(minutes, method);
//     }
// 
//     /**
//      * Returns a ReminderEntry, with the specified number of minutes and a default alert method.
//      *
//      * @param minutes Number of minutes before the start of the event that the alert will fire.
//      */
//     public static ReminderEntry valueOf(int minutes) {
//         return valueOf(minutes, Reminders.METHOD_DEFAULT);
//     }
// 
//     /**
//      * Constructs a new ReminderEntry.
//      *
//      * @param minutes Number of minutes before the start of the event that the alert will fire.
//      * @param method Type of alert ({@link Reminders#METHOD_ALERT}, etc).
//      */
//     private ReminderEntry(int minutes, int method) {
//         // TODO: error-check args
//         mMinutes = minutes;
//         mMethod = method;
//     }
// 
//     @Override
//     public int hashCode() {
//         return mMinutes * 10 + mMethod;
//     }
// 
//     @Override
//     public boolean equals(Object obj) {
//         if (this == obj) {
//             return true;
//         }
//         if (!(obj instanceof ReminderEntry)) {
//             return false;
//         }
// 
//         ReminderEntry re = (ReminderEntry) obj;
// 
//         if (re.mMinutes != mMinutes) {
//             return false;
//         }
// 
//         // Treat ALERT and DEFAULT as equivalent.  This is useful during the "has anything
//         // "changed" test, so that if DEFAULT is present, but we don't change anything,
//         // the internal conversion of DEFAULT to ALERT doesn't force a database update.
//         return re.mMethod == mMethod ||
//             (re.mMethod == Reminders.METHOD_DEFAULT && mMethod == Reminders.METHOD_ALERT) ||
//             (re.mMethod == Reminders.METHOD_ALERT && mMethod == Reminders.METHOD_DEFAULT);
//     }
// 
//     @Override
//     public String toString() {
//         return "ReminderEntry min=" + mMinutes + " meth=" + mMethod;
//     }
// 
//     /**
//      * Comparison function for a sort ordered primarily descending by minutes,
//      * secondarily ascending by method type.
//      */
//     public int compareTo(ReminderEntry re) {
//         if (re.mMinutes != mMinutes) {
//             return re.mMinutes - mMinutes;
//         }
//         if (re.mMethod != mMethod) {
//             return mMethod - re.mMethod;
//         }
//         return 0;
//     }
// 
//     /** Returns the minutes. */
//     public int getMinutes() {
//         return mMinutes;
//     }
// 
//     /** Returns the alert method. */
//     public int getMethod() {
//         return mMethod;
//     }
// }


import java.util.ArrayList;
import edu.bupt.calendar.CalendarEventModel.ReminderEntry;
import edu.bupt.calendar.R;
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.Spinner;
    /**
     * Finds the index of the given method in the "methods" list.  If the method isn't present
     * (perhaps because we don't think it's allowed for this calendar), we return zero (the
     * first item in the list).
     * <p>
     * With the current definitions, this effectively converts DEFAULT and unsupported method
     * types to ALERT.
     *
     * @param values the list of minutes corresponding to the spinner choices
     * @param method the method to search for in the values list
     * @return the index of the method in the "values" list
     */
    public static int findMethodInReminderList(ArrayList<Integer> values, int method) {
        int index = values.indexOf(method);
        if (index == -1) {
            // If not allowed, or undefined, just use the first entry in the list.
            //Log.d(TAG, "Cannot find method (" + method + ") in allowed list");
            index = 0;
        }
        return index;
    }

    /**
     * Extracts reminder minutes info from UI elements.
     *
     * @param reminderItems UI elements (layouts with spinners) that hold array indices.
     * @param reminderMinuteValues Maps array index to time in minutes.
     * @param reminderMethodValues Maps array index to alert method constant.
     * @return Array with reminder data.
     */
// Path: src/edu/bupt/calendar/CalendarEventModel.java
// public static class ReminderEntry implements Comparable<ReminderEntry>, Serializable {
//     private final int mMinutes;
//     private final int mMethod;
// 
//     /**
//      * Returns a new ReminderEntry, with the specified minutes and method.
//      *
//      * @param minutes Number of minutes before the start of the event that the alert will fire.
//      * @param method Type of alert ({@link Reminders#METHOD_ALERT}, etc).
//      */
//     public static ReminderEntry valueOf(int minutes, int method) {
//         // TODO: cache common instances
//         return new ReminderEntry(minutes, method);
//     }
// 
//     /**
//      * Returns a ReminderEntry, with the specified number of minutes and a default alert method.
//      *
//      * @param minutes Number of minutes before the start of the event that the alert will fire.
//      */
//     public static ReminderEntry valueOf(int minutes) {
//         return valueOf(minutes, Reminders.METHOD_DEFAULT);
//     }
// 
//     /**
//      * Constructs a new ReminderEntry.
//      *
//      * @param minutes Number of minutes before the start of the event that the alert will fire.
//      * @param method Type of alert ({@link Reminders#METHOD_ALERT}, etc).
//      */
//     private ReminderEntry(int minutes, int method) {
//         // TODO: error-check args
//         mMinutes = minutes;
//         mMethod = method;
//     }
// 
//     @Override
//     public int hashCode() {
//         return mMinutes * 10 + mMethod;
//     }
// 
//     @Override
//     public boolean equals(Object obj) {
//         if (this == obj) {
//             return true;
//         }
//         if (!(obj instanceof ReminderEntry)) {
//             return false;
//         }
// 
//         ReminderEntry re = (ReminderEntry) obj;
// 
//         if (re.mMinutes != mMinutes) {
//             return false;
//         }
// 
//         // Treat ALERT and DEFAULT as equivalent.  This is useful during the "has anything
//         // "changed" test, so that if DEFAULT is present, but we don't change anything,
//         // the internal conversion of DEFAULT to ALERT doesn't force a database update.
//         return re.mMethod == mMethod ||
//             (re.mMethod == Reminders.METHOD_DEFAULT && mMethod == Reminders.METHOD_ALERT) ||
//             (re.mMethod == Reminders.METHOD_ALERT && mMethod == Reminders.METHOD_DEFAULT);
//     }
// 
//     @Override
//     public String toString() {
//         return "ReminderEntry min=" + mMinutes + " meth=" + mMethod;
//     }
// 
//     /**
//      * Comparison function for a sort ordered primarily descending by minutes,
//      * secondarily ascending by method type.
//      */
//     public int compareTo(ReminderEntry re) {
//         if (re.mMinutes != mMinutes) {
//             return re.mMinutes - mMinutes;
//         }
//         if (re.mMethod != mMethod) {
//             return mMethod - re.mMethod;
//         }
//         return 0;
//     }
// 
//     /** Returns the minutes. */
//     public int getMinutes() {
//         return mMinutes;
//     }
// 
//     /** Returns the alert method. */
//     public int getMethod() {
//         return mMethod;
//     }
// }


// Path: src/edu/bupt/calendar/event/EventViewUtils.java
import java.util.ArrayList;
import edu.bupt.calendar.CalendarEventModel.ReminderEntry;
import edu.bupt.calendar.R;
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.Spinner;

    /**
     * Finds the index of the given method in the "methods" list.  If the method isn't present
     * (perhaps because we don't think it's allowed for this calendar), we return zero (the
     * first item in the list).
     * <p>
     * With the current definitions, this effectively converts DEFAULT and unsupported method
     * types to ALERT.
     *
     * @param values the list of minutes corresponding to the spinner choices
     * @param method the method to search for in the values list
     * @return the index of the method in the "values" list
     */
    public static int findMethodInReminderList(ArrayList<Integer> values, int method) {
        int index = values.indexOf(method);
        if (index == -1) {
            // If not allowed, or undefined, just use the first entry in the list.
            //Log.d(TAG, "Cannot find method (" + method + ") in allowed list");
            index = 0;
        }
        return index;
    }

    /**
     * Extracts reminder minutes info from UI elements.
     *
     * @param reminderItems UI elements (layouts with spinners) that hold array indices.
     * @param reminderMinuteValues Maps array index to time in minutes.
     * @param reminderMethodValues Maps array index to alert method constant.
     * @return Array with reminder data.
     */
    public static ArrayList<ReminderEntry> reminderItemsToReminders(