mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 02:05:06 +08:00
Code review fixes.
This commit is contained in:
parent
922d68cfda
commit
97de6de8f2
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020 The Matrix.org Foundation C.I.C.
|
* Copyright 2022 The Matrix.org Foundation C.I.C.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.matrix.android.sdk.api.session.room.model
|
package org.matrix.android.sdk.api.session.room.model.livelocation
|
||||||
|
|
||||||
import com.squareup.moshi.Json
|
import com.squareup.moshi.Json
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2020 The Matrix.org Foundation C.I.C.
|
* Copyright (c) 2022 New Vector Ltd
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -14,11 +14,12 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.matrix.android.sdk.api.session.room.model
|
package org.matrix.android.sdk.api.session.room.model.livelocation
|
||||||
|
|
||||||
import com.squareup.moshi.Json
|
import com.squareup.moshi.Json
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
||||||
import org.matrix.android.sdk.api.session.room.model.message.LocationAsset
|
import org.matrix.android.sdk.api.session.room.model.message.LocationAsset
|
||||||
|
import org.matrix.android.sdk.api.session.room.model.message.LocationAssetType
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
data class LiveLocationBeaconContent(
|
data class LiveLocationBeaconContent(
|
||||||
@ -31,17 +32,17 @@ data class LiveLocationBeaconContent(
|
|||||||
* Beacon creation timestamp.
|
* Beacon creation timestamp.
|
||||||
*/
|
*/
|
||||||
@Json(name = "org.matrix.msc3488.ts") val unstableTimestampAsMilliseconds: Long? = null,
|
@Json(name = "org.matrix.msc3488.ts") val unstableTimestampAsMilliseconds: Long? = null,
|
||||||
@Json(name = "m.ts") val timestampAsMillisecond: Long? = null,
|
@Json(name = "m.ts") val timestampAsMilliseconds: Long? = null,
|
||||||
/**
|
/**
|
||||||
* Live location asset type.
|
* Live location asset type.
|
||||||
*/
|
*/
|
||||||
@Json(name = "org.matrix.msc3488.asset") val unstableLocationAsset: LocationAsset = LocationAsset("m.self"),
|
@Json(name = "org.matrix.msc3488.asset") val unstableLocationAsset: LocationAsset = LocationAsset(LocationAssetType.SELF),
|
||||||
@Json(name = "m.asset") val locationAsset: LocationAsset? = null
|
@Json(name = "m.asset") val locationAsset: LocationAsset? = null
|
||||||
) {
|
) {
|
||||||
|
|
||||||
fun getBestBeaconInfo() = beaconInfo ?: unstableBeaconInfo
|
fun getBestBeaconInfo() = beaconInfo ?: unstableBeaconInfo
|
||||||
|
|
||||||
fun getBestTimestampAsMilliseconds() = timestampAsMillisecond ?: unstableTimestampAsMilliseconds
|
fun getBestTimestampAsMilliseconds() = timestampAsMilliseconds ?: unstableTimestampAsMilliseconds
|
||||||
|
|
||||||
fun getBestLocationAsset() = locationAsset ?: unstableLocationAsset
|
fun getBestLocationAsset() = locationAsset ?: unstableLocationAsset
|
||||||
}
|
}
|
@ -30,8 +30,8 @@ import kotlinx.parcelize.Parcelize
|
|||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
import org.matrix.android.sdk.api.session.events.model.EventType.generateBeaconInfoStateEventType
|
import org.matrix.android.sdk.api.session.events.model.EventType.generateBeaconInfoStateEventType
|
||||||
import org.matrix.android.sdk.api.session.events.model.toContent
|
import org.matrix.android.sdk.api.session.events.model.toContent
|
||||||
import org.matrix.android.sdk.api.session.room.model.BeaconInfo
|
import org.matrix.android.sdk.api.session.room.model.livelocation.BeaconInfo
|
||||||
import org.matrix.android.sdk.api.session.room.model.LiveLocationBeaconContent
|
import org.matrix.android.sdk.api.session.room.model.livelocation.LiveLocationBeaconContent
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.util.Timer
|
import java.util.Timer
|
||||||
import java.util.TimerTask
|
import java.util.TimerTask
|
||||||
@ -83,7 +83,7 @@ class LocationSharingService : VectorService(), LocationTracker.Callback {
|
|||||||
activeSessionHolder
|
activeSessionHolder
|
||||||
.getSafeActiveSession()
|
.getSafeActiveSession()
|
||||||
?.let { session ->
|
?.let { session ->
|
||||||
session.coroutineScope.launch {
|
session.coroutineScope.launch(session.coroutineDispatchers.io) {
|
||||||
sendBeaconInfo(session, roomArgs)
|
sendBeaconInfo(session, roomArgs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user