fix bit set check
This commit is contained in:
parent
c88b9af155
commit
e42236b87b
3 changed files with 3 additions and 13 deletions
|
@ -5,4 +5,4 @@ import java.util.concurrent.TimeUnit
|
|||
val Int.secondsToMillis get() = TimeUnit.SECONDS.toMillis(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 {
|
||||
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 isAlarmEnabledForDay(day: Int, alarmDays: Int) = alarmDays.isBitSet(day)
|
||||
|
||||
fun getTimeDifferenceInMinutes(currentTimeInMinutes: Int, alarmTimeInMinutes: Int, daysUntilAlarm: Int): Int {
|
||||
val minutesInADay = 24 * 60
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
android.enableJetifier=true
|
||||
android.useAndroidX=true
|
||||
android.nonTransitiveRClass=true
|
||||
org.gradle.jvmargs=-Xmx4g
|
||||
|
|
Loading…
Reference in a new issue