Code review fixes.

This commit is contained in:
Onuray Sahin 2022-04-01 17:04:52 +03:00
parent 922d68cfda
commit 97de6de8f2
3 changed files with 11 additions and 10 deletions

View file

@ -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");
* you may not use this file except in compliance with the License.
@ -14,7 +14,7 @@
* 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.JsonClass

View file

@ -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");
* you may not use this file except in compliance with the License.
@ -14,11 +14,12 @@
* 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.JsonClass
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)
data class LiveLocationBeaconContent(
@ -31,17 +32,17 @@ data class LiveLocationBeaconContent(
* Beacon creation timestamp.
*/
@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.
*/
@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
) {
fun getBestBeaconInfo() = beaconInfo ?: unstableBeaconInfo
fun getBestTimestampAsMilliseconds() = timestampAsMillisecond ?: unstableTimestampAsMilliseconds
fun getBestTimestampAsMilliseconds() = timestampAsMilliseconds ?: unstableTimestampAsMilliseconds
fun getBestLocationAsset() = locationAsset ?: unstableLocationAsset
}

View file

@ -30,8 +30,8 @@ import kotlinx.parcelize.Parcelize
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.toContent
import org.matrix.android.sdk.api.session.room.model.BeaconInfo
import org.matrix.android.sdk.api.session.room.model.LiveLocationBeaconContent
import org.matrix.android.sdk.api.session.room.model.livelocation.BeaconInfo
import org.matrix.android.sdk.api.session.room.model.livelocation.LiveLocationBeaconContent
import timber.log.Timber
import java.util.Timer
import java.util.TimerTask
@ -83,7 +83,7 @@ class LocationSharingService : VectorService(), LocationTracker.Callback {
activeSessionHolder
.getSafeActiveSession()
?.let { session ->
session.coroutineScope.launch {
session.coroutineScope.launch(session.coroutineDispatchers.io) {
sendBeaconInfo(session, roomArgs)
}
}