From e42236b87bc024693e0a07df4e81f95b87da990a Mon Sep 17 00:00:00 2001 From: fatih ergin Date: Thu, 17 Aug 2023 23:59:22 +0300 Subject: [PATCH] fix bit set check --- .../com/simplemobiletools/clock/extensions/Int.kt | 2 +- .../simplemobiletools/clock/helpers/Constants.kt | 13 +------------ gradle.properties | 1 + 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/clock/extensions/Int.kt b/app/src/main/kotlin/com/simplemobiletools/clock/extensions/Int.kt index 8b0938e..dcf929e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/clock/extensions/Int.kt +++ b/app/src/main/kotlin/com/simplemobiletools/clock/extensions/Int.kt @@ -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 diff --git a/app/src/main/kotlin/com/simplemobiletools/clock/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/clock/helpers/Constants.kt index 2622a49..84fad56 100644 --- a/app/src/main/kotlin/com/simplemobiletools/clock/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/clock/helpers/Constants.kt @@ -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 diff --git a/gradle.properties b/gradle.properties index b2d106e..24c6f86 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,4 @@ android.enableJetifier=true android.useAndroidX=true android.nonTransitiveRClass=true +org.gradle.jvmargs=-Xmx4g