Skip to content

Commit e416826

Browse files
committed
Fix ktlint and docs.
publish_android_snapshot
1 parent 3dccf51 commit e416826

File tree

9 files changed

+114
-24
lines changed

9 files changed

+114
-24
lines changed

app/src/main/java/com/mapbox/maps/testapp/examples/location/MultipleLocationComponentActivity.kt

-7
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ package com.mapbox.maps.testapp.examples.location
22

33
import android.annotation.SuppressLint
44
import android.os.Bundle
5-
import android.view.ViewGroup
6-
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
7-
import android.widget.Button
8-
import android.widget.LinearLayout
95
import androidx.appcompat.app.AppCompatActivity
106
import com.mapbox.geojson.Point
117
import com.mapbox.maps.*
@@ -19,14 +15,11 @@ import com.mapbox.maps.plugin.locationcomponent.CustomJourneyLocationProvider
1915
import com.mapbox.maps.plugin.locationcomponent.Journey
2016
import com.mapbox.maps.plugin.locationcomponent.LocationComponentInitOptions
2117
import com.mapbox.maps.plugin.locationcomponent.LocationComponentPlugin2
22-
import com.mapbox.maps.plugin.viewport.data.FollowPuckViewportStateBearing
23-
import com.mapbox.maps.plugin.viewport.data.FollowPuckViewportStateOptions
2418
import com.mapbox.maps.plugin.viewport.data.MultiPuckViewportStateBearing
2519
import com.mapbox.maps.plugin.viewport.data.MultiPuckViewportStateOptions
2620
import com.mapbox.maps.plugin.viewport.state.MultiPuckViewportState
2721
import com.mapbox.maps.plugin.viewport.viewport
2822
import com.mapbox.maps.testapp.R
29-
import com.mapbox.maps.testapp.databinding.ActivityMultiDisplayBinding
3023
import com.mapbox.maps.testapp.databinding.ActivityMultiLocationcomponentBinding
3124
import com.mapbox.maps.testapp.utils.BitmapUtils
3225
import com.mapbox.maps.testapp.utils.createLocationComponent

plugin-locationcomponent/src/main/java/com/mapbox/maps/plugin/locationcomponent/CustomJourneyLocationProvider.kt

+34-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ import kotlin.math.*
1717
class CustomJourneyLocationProvider : LocationProvider {
1818
private var locationConsumers = CopyOnWriteArraySet<LocationConsumer>()
1919

20+
/**
21+
* Load a journey to the CustomJourneyLocationProvider.
22+
*/
2023
fun loadJourney(journey: Journey) {
2124
journey.observeJourneyUpdates { point, bearing, locationAnimationDurationMs, bearingAnimationDurationMs ->
2225
emitLocationUpdated(point, bearing, locationAnimationDurationMs, bearingAnimationDurationMs)
@@ -41,17 +44,35 @@ class CustomJourneyLocationProvider : LocationProvider {
4144
}
4245
}
4346

47+
/**
48+
* Handling of registered location consumers.
49+
*/
4450
override fun registerLocationConsumer(locationConsumer: LocationConsumer) {
4551
this.locationConsumers.add(locationConsumer)
4652
}
4753

54+
/**
55+
* Handling of unregistered location consumer.
56+
*/
4857
override fun unRegisterLocationConsumer(locationConsumer: LocationConsumer) {
4958
this.locationConsumers.remove(locationConsumer)
5059
}
5160
}
5261

62+
/**
63+
* Abstraction of a Journey.
64+
*/
5365
@MapboxExperimental
54-
class Journey(val speed: Double = 100.0, val angularSpeed: Double = 500.0) {
66+
class Journey(
67+
/**
68+
* The speed to playback the journey.
69+
*/
70+
val speed: Double = 100.0,
71+
/**
72+
* The angular speed to playback the journey.
73+
*/
74+
val angularSpeed: Double = 500.0
75+
) {
5576
private val locationList = CopyOnWriteArrayList<QueueData>()
5677
private val initialTimeStamp: Long = 0
5778
private val remainingPoints = ConcurrentLinkedQueue<QueueData>()
@@ -70,6 +91,9 @@ class Journey(val speed: Double = 100.0, val angularSpeed: Double = 500.0) {
7091
}
7192
}
7293

94+
/**
95+
* Observe the journey updates.
96+
*/
7397
fun observeJourneyUpdates(observer: JourneyDataObserver) {
7498
observers.add(observer)
7599
}
@@ -120,7 +144,12 @@ class Journey(val speed: Double = 100.0, val angularSpeed: Double = 500.0) {
120144
(distanceInMeter(it, location) / speed) * 1000.0
121145
} ?: 1000L
122146
val bearingAnimateDurationMs =
123-
abs(shortestRotation(bearing, locationList.lastOrNull()?.bearing ?: 0.0) / angularSpeed) * 1000.0
147+
abs(
148+
shortestRotation(
149+
bearing,
150+
locationList.lastOrNull()?.bearing ?: 0.0
151+
) / angularSpeed
152+
) * 1000.0
124153

125154
val nextData =
126155
QueueData(location, bearing, animationDurationMs.toLong(), bearingAnimateDurationMs.toLong())
@@ -235,6 +264,9 @@ class Journey(val speed: Double = 100.0, val angularSpeed: Double = 500.0) {
235264
}
236265
}
237266

267+
/**
268+
* Defines the interface to observe the journey data uppdates.
269+
*/
238270
fun interface JourneyDataObserver {
239271
/**
240272
* Notifies that new data is available.

plugin-locationcomponent/src/main/java/com/mapbox/maps/plugin/locationcomponent/LocationComponentInitOptions.kt

+55-7
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,47 @@ import com.mapbox.maps.plugin.locationcomponent.LocationComponentConstants.MODEL
66
import com.mapbox.maps.plugin.locationcomponent.LocationComponentConstants.MODEL_SOURCE
77
import com.mapbox.maps.plugin.locationcomponent.LocationComponentConstants.SHADOW_ICON
88
import com.mapbox.maps.plugin.locationcomponent.LocationComponentConstants.TOP_ICON
9-
import java.util.Objects
10-
import kotlin.Any
11-
import kotlin.Boolean
12-
import kotlin.Int
13-
import kotlin.String
14-
import kotlin.Unit
15-
import kotlin.jvm.JvmSynthetic
9+
import java.util.*
1610

1711
/**
1812
* Initialisation options for location component to allow multiple instances
1913
* of LocationComponent.
2014
*/
2115
public class LocationComponentInitOptions private constructor(
16+
/**
17+
* The layer id of the location indicator layer used to draw the 2d puck.
18+
*/
2219
public val puck2DLayerId: String,
20+
/**
21+
* The layer id of the model layer used to draw the 3d puck.
22+
*/
2323
public val puck3DLayerId: String,
24+
/**
25+
* The source id of the model layer used to draw the 3d puck.
26+
*/
2427
public val puck3DSourceId: String,
28+
/**
29+
* The top icon image id for the 2d puck.
30+
*/
2531
public val topIconImageId: String,
32+
/**
33+
* The shadow icon image id for the 2d puck.
34+
*/
2635
public val shadowIconImageId: String,
36+
/**
37+
* The bearing icon image id for the 2d puck.
38+
*/
2739
public val bearingIconImageId: String
2840
) {
41+
/**
42+
* Convert the LocationComponentInitOptions to a String.
43+
*/
2944
public override fun toString() =
3045
"LocationComponentInitOptions(puck2DLayerId=$puck2DLayerId,puck3DLayerId=$puck3DLayerId, puck3DSourceId=$puck3DSourceId, topIconImageId=$topIconImageId,shadowIconImageId=$shadowIconImageId, bearingIconImageId=$bearingIconImageId)"
3146

47+
/**
48+
* Compares two LocationComponentOptions.
49+
*/
3250
public override fun equals(other: Any?): Boolean = other is LocationComponentInitOptions &&
3351
puck2DLayerId == other.puck2DLayerId &&
3452
puck3DLayerId == other.puck3DLayerId &&
@@ -37,11 +55,17 @@ public class LocationComponentInitOptions private constructor(
3755
shadowIconImageId == other.shadowIconImageId &&
3856
bearingIconImageId == other.bearingIconImageId
3957

58+
/**
59+
* The hashcode of the LocationComponentOptions.
60+
*/
4061
public override fun hashCode(): Int = Objects.hash(
4162
puck2DLayerId, puck3DLayerId, puck3DSourceId,
4263
topIconImageId, shadowIconImageId, bearingIconImageId
4364
)
4465

66+
/**
67+
* Convert LocationComponentOptions to a Builder.
68+
*/
4569
public fun toBuilder(): Builder = Builder()
4670
.setPuck2DLayerId(this.puck2DLayerId)
4771
.setPuck3DLayerId(this.puck3DLayerId)
@@ -58,21 +82,39 @@ public class LocationComponentInitOptions private constructor(
5882
* @property
5983
*/
6084
public class Builder {
85+
/**
86+
* The layer id of the location indicator layer used to draw the 2d puck.
87+
*/
6188
@set:JvmSynthetic
6289
public var puck2DLayerId: String = LOCATION_INDICATOR_LAYER
6390

91+
/**
92+
* The layer id of the model layer used to draw the 3d puck.
93+
*/
6494
@set:JvmSynthetic
6595
public var puck3DLayerId: String = MODEL_LAYER
6696

97+
/**
98+
* The source id of the model layer used to draw the 3d puck.
99+
*/
67100
@set:JvmSynthetic
68101
public var puck3DSourceId: String = MODEL_SOURCE
69102

103+
/**
104+
* The top icon image id for the 2d puck.
105+
*/
70106
@set:JvmSynthetic
71107
public var topIconImageId: String = TOP_ICON
72108

109+
/**
110+
* The shadow icon image id for the 2d puck.
111+
*/
73112
@set:JvmSynthetic
74113
public var shadowIconImageId: String = SHADOW_ICON
75114

115+
/**
116+
* The bearing icon image id for the 2d puck.
117+
*/
76118
@set:JvmSynthetic
77119
public var bearingIconImageId: String = BEARING_ICON
78120

@@ -158,9 +200,15 @@ public class LocationComponentInitOptions private constructor(
158200
}
159201
}
160202

203+
/**
204+
* Companion object of [LocationComponentInitOptions].
205+
*/
161206
companion object {
162207
private var customLocationComponentCount = 0
163208

209+
/**
210+
* Create a unique LocationComponentInitOptions with incremental layer/source/image ids.
211+
*/
164212
@JvmStatic
165213
fun getNextUniqueLocationComponentOptions() = LocationComponentInitOptions {
166214
puck2DLayerId = "custom_location_component_2d_layer_$customLocationComponentCount"

plugin-locationcomponent/src/main/java/com/mapbox/maps/plugin/locationcomponent/LocationComponentPluginImpl.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import com.mapbox.maps.extension.style.StyleInterface
1313
import com.mapbox.maps.plugin.delegates.MapDelegateProvider
1414
import com.mapbox.maps.plugin.locationcomponent.animators.PuckAnimatorManager
1515
import com.mapbox.maps.plugin.locationcomponent.generated.*
16-
import com.mapbox.maps.plugin.locationcomponent.generated.LocationComponentAttributeParser
1716
import java.lang.ref.WeakReference
1817
import java.util.concurrent.CopyOnWriteArraySet
1918

@@ -22,6 +21,9 @@ import java.util.concurrent.CopyOnWriteArraySet
2221
* to the user's current location.
2322
*/
2423
class LocationComponentPluginImpl(
24+
/**
25+
* The initialisation options for the location component, defaults to the default LocationComponent configurations.
26+
*/
2527
val locationComponentInitOptions: LocationComponentInitOptions = LocationComponentInitOptions.Builder()
2628
.build()
2729
) : LocationComponentPlugin2, LocationConsumer2,

plugin-viewport/src/main/kotlin/com/mapbox/maps/plugin/viewport/ViewportPluginImpl.kt

+6
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,12 @@ class ViewportPluginImpl(private val handler: Handler = Handler(Looper.getMainLo
234234
return FollowPuckViewportStateImpl(delegateProvider, options)
235235
}
236236

237+
/**
238+
* Create a new [MultiPuckViewportState] instance with provided [MultiPuckViewportStateOptions].
239+
*
240+
* @param options The desired [MultiPuckViewportStateOptions], defaults to [MultiPuckViewportStateOptions] that's initialised with default parameters.
241+
* @return The newly-created [MultiPuckViewportState] instance.
242+
*/
237243
override fun makeMultiPuckViewportState(
238244
options: MultiPuckViewportStateOptions,
239245
locationComponents: List<LocationComponentPlugin2>

plugin-viewport/src/main/kotlin/com/mapbox/maps/plugin/viewport/state/MultiPuckViewportStateImpl.kt

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import com.mapbox.geojson.MultiPoint
88
import com.mapbox.geojson.Point
99
import com.mapbox.maps.CameraOptions
1010
import com.mapbox.maps.EdgeInsets
11-
import com.mapbox.maps.logE
1211
import com.mapbox.maps.logW
1312
import com.mapbox.maps.plugin.animation.Cancelable
1413
import com.mapbox.maps.plugin.animation.camera
@@ -105,8 +104,7 @@ internal class MultiPuckViewportStateImpl(
105104
with(options.bearing) {
106105
when (this) {
107106
is MultiPuckViewportStateBearing.Constant -> bearing
108-
is MultiPuckViewportStateBearing.SyncWithLocationPuck -> lastBearings[locationComponent]
109-
?: 0.0
107+
is MultiPuckViewportStateBearing.SyncWithLocationPuck -> lastBearings[locationComponent] ?: 0.0
110108
else -> 0.0
111109
}
112110
},

sdk-base/src/main/java/com/mapbox/maps/plugin/viewport/ViewportPlugin.kt

+6
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ interface ViewportPlugin : MapPlugin {
120120
options: FollowPuckViewportStateOptions = FollowPuckViewportStateOptions.Builder().build()
121121
): FollowPuckViewportState
122122

123+
/**
124+
* Create a new [MultiPuckViewportState] instance with provided [MultiPuckViewportStateOptions].
125+
*
126+
* @param options The desired [MultiPuckViewportStateOptions], defaults to [MultiPuckViewportStateOptions] that's initialised with default parameters.
127+
* @return The newly-created [MultiPuckViewportState] instance.
128+
*/
123129
fun makeMultiPuckViewportState(
124130
options: MultiPuckViewportStateOptions = MultiPuckViewportStateOptions.Builder().build(),
125131
locationComponents: List<LocationComponentPlugin2>

sdk-base/src/main/java/com/mapbox/maps/plugin/viewport/data/MultiPuckViewportStateBearing.kt

+9-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package com.mapbox.maps.plugin.viewport.data
33
import com.mapbox.maps.CameraOptions
44
import com.mapbox.maps.plugin.locationcomponent.LocationComponentPlugin2
55
import com.mapbox.maps.plugin.viewport.state.MultiPuckViewportState
6-
import java.util.Objects
6+
import java.util.*
77

88
/**
99
* Describes different ways that [MultiPuckViewportState] can obtain values to use when setting
@@ -38,11 +38,17 @@ sealed class MultiPuckViewportStateBearing {
3838
* When set to this mode, the viewport's bearing is driven by the location, thus guarantees
3939
* the synchronization of the location puck and camera position.
4040
*/
41-
class SyncWithLocationPuck(val locationComponent: LocationComponentPlugin2) : MultiPuckViewportStateBearing() {
41+
class SyncWithLocationPuck(
42+
/**
43+
* The location component instance to be synced with.
44+
*/
45+
val locationComponent: LocationComponentPlugin2
46+
) : MultiPuckViewportStateBearing() {
4247
/**
4348
* Indicates whether some other object is "equal to" this one.
4449
*/
45-
override fun equals(other: Any?) = other is SyncWithLocationPuck && locationComponent == other.locationComponent
50+
override fun equals(other: Any?) =
51+
other is SyncWithLocationPuck && locationComponent == other.locationComponent
4652

4753
/**
4854
* Returns a hash code value for the object.

sdk-base/src/main/java/com/mapbox/maps/plugin/viewport/state/MultiPuckViewportState.kt

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.mapbox.maps.plugin.viewport.state
22

33
import com.mapbox.maps.plugin.locationcomponent.LocationComponentPlugin
44
import com.mapbox.maps.plugin.viewport.ViewportPlugin
5-
import com.mapbox.maps.plugin.viewport.data.FollowPuckViewportStateOptions
65
import com.mapbox.maps.plugin.viewport.data.MultiPuckViewportStateOptions
76

87
/**

0 commit comments

Comments
 (0)