Remove non necessary main Handler in LocationSharingService
This commit is contained in:
parent
f57c46de9a
commit
c581564bb1
|
@ -18,7 +18,6 @@ package im.vector.app.features.location
|
||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Binder
|
import android.os.Binder
|
||||||
import android.os.Handler
|
|
||||||
import android.os.IBinder
|
import android.os.IBinder
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
@ -64,7 +63,6 @@ class LocationSharingService : VectorService(), LocationTracker.Callback {
|
||||||
private val roomArgsMap = mutableMapOf<String, RoomArgs>()
|
private val roomArgsMap = mutableMapOf<String, RoomArgs>()
|
||||||
var callback: Callback? = null
|
var callback: Callback? = null
|
||||||
private val jobs = mutableListOf<Job>()
|
private val jobs = mutableListOf<Job>()
|
||||||
private val mainHandler by lazy { Handler(mainLooper) }
|
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
|
@ -86,7 +84,7 @@ class LocationSharingService : VectorService(), LocationTracker.Callback {
|
||||||
startForeground(roomArgs.roomId.hashCode(), notification)
|
startForeground(roomArgs.roomId.hashCode(), notification)
|
||||||
|
|
||||||
// Send beacon info state event
|
// Send beacon info state event
|
||||||
launchInIO { session ->
|
launchWithActiveSession { session ->
|
||||||
sendStartingLiveBeaconInfo(session, roomArgs)
|
sendStartingLiveBeaconInfo(session, roomArgs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,7 +139,7 @@ class LocationSharingService : VectorService(), LocationTracker.Callback {
|
||||||
beaconInfoEventId: String,
|
beaconInfoEventId: String,
|
||||||
locationData: LocationData
|
locationData: LocationData
|
||||||
) {
|
) {
|
||||||
launchInIO { session ->
|
launchWithActiveSession { session ->
|
||||||
session.getRoom(roomId)
|
session.getRoom(roomId)
|
||||||
?.locationSharingService()
|
?.locationSharingService()
|
||||||
?.sendLiveLocation(
|
?.sendLiveLocation(
|
||||||
|
@ -195,7 +193,6 @@ class LocationSharingService : VectorService(), LocationTracker.Callback {
|
||||||
activeSessionHolder
|
activeSessionHolder
|
||||||
.getSafeActiveSession()
|
.getSafeActiveSession()
|
||||||
?.let { session ->
|
?.let { session ->
|
||||||
mainHandler.post {
|
|
||||||
val job = getLiveLocationShareSummaryUseCase.execute(roomId, eventId)
|
val job = getLiveLocationShareSummaryUseCase.execute(roomId, eventId)
|
||||||
.distinctUntilChangedBy { it.isActive }
|
.distinctUntilChangedBy { it.isActive }
|
||||||
.filter { it.isActive == false }
|
.filter { it.isActive == false }
|
||||||
|
@ -204,14 +201,12 @@ class LocationSharingService : VectorService(), LocationTracker.Callback {
|
||||||
jobs.add(job)
|
jobs.add(job)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private fun launchInIO(block: suspend CoroutineScope.(Session) -> Unit) =
|
private fun launchWithActiveSession(block: suspend CoroutineScope.(Session) -> Unit) =
|
||||||
activeSessionHolder
|
activeSessionHolder
|
||||||
.getSafeActiveSession()
|
.getSafeActiveSession()
|
||||||
?.let { session ->
|
?.let { session ->
|
||||||
session.coroutineScope.launch(
|
session.coroutineScope.launch(
|
||||||
context = session.coroutineDispatchers.io,
|
|
||||||
block = { block(session) }
|
block = { block(session) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue