properly handle week days string creation if sunday is the first day

This commit is contained in:
tibbi 2018-03-04 20:32:17 +01:00
parent 2bfc40c83d
commit 08fd5e155c

View file

@ -357,8 +357,16 @@ fun Context.isPackageInstalled(pkgName: String): Boolean {
// format day bits to strings like "Mon, Tue, Wed"
fun Context.getSelectedDaysString(bitMask: Int): String {
val dayBits = arrayListOf(MONDAY_BIT, TUESDAY_BIT, WEDNESDAY_BIT, THURSDAY_BIT, FRIDAY_BIT, SATURDAY_BIT, SUNDAY_BIT)
val weekDays = resources.getStringArray(R.array.week_days).toList() as ArrayList<String>
if (baseConfig.isSundayFirst) {
val sundayBit = dayBits.removeAt(dayBits.size - 1)
dayBits.add(0, sundayBit)
val sunday = weekDays.removeAt(weekDays.size - 1)
weekDays.add(0, sunday)
}
val weekDays = resources.getStringArray(R.array.week_days)
var days = ""
dayBits.forEachIndexed { index, bit ->
if (bitMask and bit != 0) {