public static String getRepeatString(Resources r, EventRecurrence recurrence) { // TODO Implement "Until" portion of string, as well as custom settings switch (recurrence.freq) { case EventRecurrence.DAILY: return r.getString(R.string.daily); case EventRecurrence.WEEKLY: { if (recurrence.repeatsOnEveryWeekDay()) { return r.getString(R.string.every_weekday); } else { String format = r.getString(R.string.weekly); StringBuilder days = new StringBuilder(); // Do one less iteration in the loop so the last element is added out of the // loop. This is done so the comma is not placed after the last item. int count = recurrence.bydayCount - 1; if (count >= 0) { for (int i = 0; i < count; i++) { days.append(dayToString(recurrence.byday[i])); days.append(","); } days.append(dayToString(recurrence.byday[count])); return String.format(format, days.toString()); } // There is no "BYDAY" specifier, so use the day of the // first event. For this to work, the setStartDate() // method must have been used by the caller to set the // date of the first event in the recurrence. if (recurrence.startDate == null) { return null; } int day = EventRecurrence.timeDay2Day(recurrence.startDate.weekDay); return String.format(format, dayToString(day)); } } case EventRecurrence.MONTHLY: { return r.getString(R.string.monthly); } case EventRecurrence.YEARLY: return r.getString(R.string.yearly_plain); } return null; }