Skip to content

Commit

Permalink
make the time between updates editable, set to 60s for now
Browse files Browse the repository at this point in the history
  • Loading branch information
benjy3gg committed Oct 25, 2020
1 parent 61d84af commit 588ccb1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 0 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
implementation 'com.github.kittinunf.fuel:fuel:2.1.0'
implementation 'com.github.kittinunf.fuel:fuel-android:2.1.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0-M2'

testImplementation 'junit:junit:4.12'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class EndlessService : Service() {
private var wakeLock: PowerManager.WakeLock? = null
private var isServiceStarted = false
private lateinit var mContext: Context;
private var timer: Long = 1 * 60 * 1000;

override fun onBind(intent: Intent): IBinder? {
log("Some component want to bind with the service")
Expand Down Expand Up @@ -78,12 +79,13 @@ class EndlessService : Service() {
setServiceState(this, ServiceState.STARTED)

// we need this lock so our service gets not affected by Doze Mode
wakeLock =
/*wakeLock =
(getSystemService(Context.POWER_SERVICE) as PowerManager).run {
newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "EndlessService::lock").apply {
acquire()
}
}
*/


// we're starting a loop in a coroutine
Expand All @@ -92,7 +94,7 @@ class EndlessService : Service() {
launch(Dispatchers.IO) {
setBrightness(0);
}
delay(5000)
delay(timer)
}
log("End of the loop for the service")
}
Expand All @@ -102,11 +104,11 @@ class EndlessService : Service() {
log("Stopping the foreground service")
Toast.makeText(this, "Service stopping", Toast.LENGTH_SHORT).show()
try {
wakeLock?.let {
/*wakeLock?.let {
if (it.isHeld) {
it.release()
}
}
}*/
setBrightness(255);
stopForeground(true)
stopSelf()
Expand Down

0 comments on commit 588ccb1

Please sign in to comment.