Skip to content

Commit f54ed34

Browse files
committed
Fix handler posting
1 parent 92a0962 commit f54ed34

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ apply plugin: 'kotlin-android'
44
apply plugin: 'kotlin-android-extensions'
55

66
group = 'com.kylecorry'
7-
version = '2.6.1'
7+
version = '2.6.2'
88

99
android {
1010
compileSdkVersion 30

app/src/main/java/com/kylecorry/trailsensecore/infrastructure/sensors/ISensor.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.kylecorry.trailsensecore.infrastructure.sensors
22

3+
import android.os.Handler
4+
import android.os.Looper
35
import androidx.lifecycle.LiveData
46
import androidx.lifecycle.MutableLiveData
57
import com.kylecorry.trailsensecore.domain.units.Quality
@@ -20,9 +22,12 @@ interface ISensor {
2022

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

2427
val callback: () -> Boolean = {
25-
liveData.value = this
28+
handler.post {
29+
liveData.value = this
30+
}
2631
true
2732
}
2833

0 commit comments

Comments
 (0)