Skip to content

Commit

Permalink
Fix handler posting
Browse files Browse the repository at this point in the history
  • Loading branch information
kylecorry31 committed Feb 13, 2021
1 parent 92a0962 commit f54ed34
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

group = 'com.kylecorry'
version = '2.6.1'
version = '2.6.2'

android {
compileSdkVersion 30
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.kylecorry.trailsensecore.infrastructure.sensors

import android.os.Handler
import android.os.Looper
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.kylecorry.trailsensecore.domain.units.Quality
Expand All @@ -20,9 +22,12 @@ interface ISensor {

fun <T: ISensor> T.asLiveData(): LiveData<T> {
lateinit var liveData: MutableLiveData<T>
val handler = Handler(Looper.getMainLooper())

val callback: () -> Boolean = {
liveData.value = this
handler.post {
liveData.value = this
}
true
}

Expand Down

0 comments on commit f54ed34

Please sign in to comment.