mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 02:05:06 +08:00
Lint fixes.
This commit is contained in:
parent
fc4d18f84e
commit
6e1911e686
@ -33,6 +33,7 @@ import im.vector.app.core.resources.ColorProvider
|
||||
import im.vector.app.core.resources.StringProvider
|
||||
import im.vector.app.core.utils.DimensionConverter
|
||||
import im.vector.app.core.utils.containsOnlyEmojis
|
||||
import im.vector.app.features.home.room.detail.RoomDetailAction
|
||||
import im.vector.app.features.home.room.detail.timeline.TimelineEventController
|
||||
import im.vector.app.features.home.room.detail.timeline.helper.AvatarSizeProvider
|
||||
import im.vector.app.features.home.room.detail.timeline.helper.ContentDownloadStateTrackerBinder
|
||||
@ -71,6 +72,7 @@ import im.vector.app.features.html.PillsPostProcessor
|
||||
import im.vector.app.features.html.SpanUtils
|
||||
import im.vector.app.features.html.VectorHtmlCompressor
|
||||
import im.vector.app.features.location.LocationData
|
||||
import im.vector.app.features.location.VectorMapView
|
||||
import im.vector.app.features.media.ImageContentRenderer
|
||||
import im.vector.app.features.media.VideoContentRenderer
|
||||
import me.gujun.android.span.span
|
||||
@ -188,6 +190,16 @@ class MessageItemFactory @Inject constructor(
|
||||
val geoUri = locationContent.locationInfo?.geoUri ?: locationContent.geoUri
|
||||
val locationData = LocationData.create(geoUri)
|
||||
|
||||
val mapCallback: MessageLocationItem.Callback = object: MessageLocationItem.Callback {
|
||||
override fun onMapReady(mapView: VectorMapView) {
|
||||
mapView.onClick {
|
||||
locationData?.let {
|
||||
callback?.onTimelineItemAction(RoomDetailAction.ShowLocation(it, informationData.senderId))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return MessageLocationItem_()
|
||||
.attributes(attributes)
|
||||
.locationData(locationData)
|
||||
@ -195,7 +207,7 @@ class MessageItemFactory @Inject constructor(
|
||||
.locationPinProvider(locationPinProvider)
|
||||
.highlighted(highlight)
|
||||
.leftGuideline(avatarSizeProvider.leftGuideline)
|
||||
.callback(callback)
|
||||
.callback(mapCallback)
|
||||
}
|
||||
|
||||
private fun buildPollItem(pollContent: MessagePollContent,
|
||||
|
@ -27,12 +27,17 @@ import im.vector.app.features.home.room.detail.timeline.helper.LocationPinProvid
|
||||
import im.vector.app.features.location.LocationData
|
||||
import im.vector.app.features.location.MapTilerMapView
|
||||
import im.vector.app.features.location.VectorMapListener
|
||||
import im.vector.app.features.location.VectorMapView
|
||||
|
||||
@EpoxyModelClass(layout = R.layout.item_timeline_event_base)
|
||||
abstract class MessageLocationItem : AbsMessageItem<MessageLocationItem.Holder>() {
|
||||
|
||||
interface Callback {
|
||||
fun onMapReady(mapView: VectorMapView)
|
||||
}
|
||||
|
||||
@EpoxyAttribute
|
||||
var callback: TimelineEventController.Callback? = null
|
||||
var callback: Callback? = null
|
||||
|
||||
@EpoxyAttribute
|
||||
var locationData: LocationData? = null
|
||||
@ -50,20 +55,20 @@ abstract class MessageLocationItem : AbsMessageItem<MessageLocationItem.Holder>(
|
||||
val location = locationData ?: return
|
||||
val locationOwnerId = userId ?: return
|
||||
|
||||
holder.mapView.initialize(object : VectorMapListener {
|
||||
override fun onMapReady() {
|
||||
holder.mapView.zoomToLocation(location.latitude, location.longitude, INITIAL_ZOOM)
|
||||
holder.mapView.apply {
|
||||
initialize(object : VectorMapListener {
|
||||
override fun onMapReady() {
|
||||
zoomToLocation(location.latitude, location.longitude, INITIAL_ZOOM)
|
||||
|
||||
locationPinProvider?.create(locationOwnerId) { pinDrawable ->
|
||||
holder.mapView.addPinToMap(locationOwnerId, pinDrawable)
|
||||
holder.mapView.updatePinLocation(locationOwnerId, location.latitude, location.longitude)
|
||||
}
|
||||
locationPinProvider?.create(locationOwnerId) { pinDrawable ->
|
||||
addPinToMap(locationOwnerId, pinDrawable)
|
||||
updatePinLocation(locationOwnerId, location.latitude, location.longitude)
|
||||
}
|
||||
|
||||
holder.mapView.onClick {
|
||||
callback?.onTimelineItemAction(RoomDetailAction.ShowLocation(location, locationOwnerId))
|
||||
callback?.onMapReady(this@apply)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
override fun getViewType() = STUB_ID
|
||||
|
@ -24,6 +24,7 @@ import android.location.LocationManager
|
||||
import androidx.annotation.RequiresPermission
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
import androidx.core.content.getSystemService
|
||||
|
||||
class LocationTracker @Inject constructor(
|
||||
private val context: Context) : LocationListener {
|
||||
@ -36,7 +37,7 @@ class LocationTracker @Inject constructor(
|
||||
var callback: Callback? = null
|
||||
|
||||
fun start() {
|
||||
val locationManager = context.getSystemService(Context.LOCATION_SERVICE) as? LocationManager
|
||||
val locationManager = context.getSystemService<LocationManager>()
|
||||
|
||||
locationManager?.let {
|
||||
val isGpsEnabled = it.isProviderEnabled(LocationManager.GPS_PROVIDER)
|
||||
|
Loading…
Reference in New Issue
Block a user