Changed recurring days array in Alarm to have no actual concept of which week days are recurring or not, just that a position in the week recurs or not.
This commit is contained in:
parent
ba41c1311e
commit
2ad3cca872
@ -43,7 +43,7 @@ public class DaysOfWeek {
|
|||||||
sAppContext = context.getApplicationContext();
|
sAppContext = context.getApplicationContext();
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
// TODO First day of week preference. Entries are the full days' names and values are their respective integers.
|
// TODO First day of week preference. Entries are the full days' names and values are their respective integers.
|
||||||
String preferredFirstDay = prefs.getString("", "1");
|
String preferredFirstDay = prefs.getString("", "0");
|
||||||
if (sInstance == null || !preferredFirstDay.equals(sLastPreferredFirstDay)) {
|
if (sInstance == null || !preferredFirstDay.equals(sLastPreferredFirstDay)) {
|
||||||
sLastPreferredFirstDay = preferredFirstDay;
|
sLastPreferredFirstDay = preferredFirstDay;
|
||||||
sInstance = new DaysOfWeek(Integer.parseInt(preferredFirstDay));
|
sInstance = new DaysOfWeek(Integer.parseInt(preferredFirstDay));
|
||||||
|
|||||||
@ -154,14 +154,15 @@ public class AlarmsAdapter extends RecyclerView.Adapter<AlarmsAdapter.ViewHolder
|
|||||||
int numRecurringDays = alarm.numRecurringDays();
|
int numRecurringDays = alarm.numRecurringDays();
|
||||||
if (numRecurringDays > 0) {
|
if (numRecurringDays > 0) {
|
||||||
String text;
|
String text;
|
||||||
if (numRecurringDays == NUM_DAYS+1) /*TODO: Remove +1*/ {
|
if (numRecurringDays == NUM_DAYS) {
|
||||||
text = mContext.getString(R.string.every_day);
|
text = mContext.getString(R.string.every_day);
|
||||||
} else {
|
} else {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (int i = 0; i < NUM_DAYS; i++) {
|
for (int i = 0; // ordinal number, i.e. the position in the week, not an actual day!
|
||||||
// The day at this position in the week
|
i < NUM_DAYS; i++) {
|
||||||
int weekDay = DaysOfWeek.getInstance(mContext).weekDay(i);
|
if (alarm.isRecurring(i)) { // Is the i-th day in the week recurring?
|
||||||
if (alarm.isRecurring(weekDay)) {
|
// This is the actual day at the i-th position in the week.
|
||||||
|
int weekDay = DaysOfWeek.getInstance(mContext).weekDay(i);
|
||||||
sb.append(DaysOfWeek.getLabel(weekDay)).append(", ");
|
sb.append(DaysOfWeek.getLabel(weekDay)).append(", ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,8 +38,8 @@ public class DummyContent {
|
|||||||
b.hour(21).minutes(0);
|
b.hour(21).minutes(0);
|
||||||
}
|
}
|
||||||
boolean[] recurrences = new boolean[DaysOfWeek.NUM_DAYS];
|
boolean[] recurrences = new boolean[DaysOfWeek.NUM_DAYS];
|
||||||
recurrences[0] = true;
|
recurrences[1] = true;
|
||||||
recurrences[5] = true;
|
recurrences[3] = true;
|
||||||
Alarm a = b.id(position).recurringDays(recurrences).build();
|
Alarm a = b.id(position).recurringDays(recurrences).build();
|
||||||
a.setEnabled(true);
|
a.setEnabled(true);
|
||||||
return a;
|
return a;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user