fix bit set check
This commit is contained in:
parent
c88b9af155
commit
e42236b87b
|
@ -5,4 +5,4 @@ import java.util.concurrent.TimeUnit
|
||||||
val Int.secondsToMillis get() = TimeUnit.SECONDS.toMillis(this.toLong())
|
val Int.secondsToMillis get() = TimeUnit.SECONDS.toMillis(this.toLong())
|
||||||
val Int.millisToSeconds get() = TimeUnit.MILLISECONDS.toSeconds(this.toLong())
|
val Int.millisToSeconds get() = TimeUnit.MILLISECONDS.toSeconds(this.toLong())
|
||||||
|
|
||||||
fun Int.isBitSet(bit: Int) = this and bit == bit
|
fun Int.isBitSet(bit: Int) = (this shr bit and 1) > 0
|
||||||
|
|
|
@ -227,18 +227,7 @@ fun getTimeUntilNextAlarm(alarmTimeInMinutes: Int, days: Int): Int? {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isAlarmEnabledForDay(day: Int, alarmDays: Int): Boolean {
|
fun isAlarmEnabledForDay(day: Int, alarmDays: Int) = alarmDays.isBitSet(day)
|
||||||
val bit = createBit(day)
|
|
||||||
return alarmDays.isBitSet(bit)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun createBit(day: Int): Int {
|
|
||||||
var bit = 1
|
|
||||||
repeat(day) {
|
|
||||||
bit = bit.addBit(bit)
|
|
||||||
}
|
|
||||||
return bit
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getTimeDifferenceInMinutes(currentTimeInMinutes: Int, alarmTimeInMinutes: Int, daysUntilAlarm: Int): Int {
|
fun getTimeDifferenceInMinutes(currentTimeInMinutes: Int, alarmTimeInMinutes: Int, daysUntilAlarm: Int): Int {
|
||||||
val minutesInADay = 24 * 60
|
val minutesInADay = 24 * 60
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
android.enableJetifier=true
|
android.enableJetifier=true
|
||||||
android.useAndroidX=true
|
android.useAndroidX=true
|
||||||
android.nonTransitiveRClass=true
|
android.nonTransitiveRClass=true
|
||||||
|
org.gradle.jvmargs=-Xmx4g
|
||||||
|
|
Loading…
Reference in New Issue