Page Menu
Home
GitPull.it
Search
Configure Global Search
Log In
Files
F13635880
D204.1785869067.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None
D204.1785869067.diff
View Options
diff --git a/app/src/main/java/it/reyboz/bustorino/backend/mato/MQTTMatoClient.kt b/app/src/main/java/it/reyboz/bustorino/backend/mato/MQTTMatoClient.kt
--- a/app/src/main/java/it/reyboz/bustorino/backend/mato/MQTTMatoClient.kt
+++ b/app/src/main/java/it/reyboz/bustorino/backend/mato/MQTTMatoClient.kt
@@ -9,6 +9,7 @@
import com.hivemq.client.mqtt.mqtt3.Mqtt3AsyncClient
import com.hivemq.client.mqtt.mqtt3.Mqtt3ClientBuilder
import com.hivemq.client.mqtt.mqtt3.message.publish.Mqtt3Publish
+import it.reyboz.bustorino.BuildConfig
import it.reyboz.bustorino.backend.gtfs.LivePositionUpdate
import org.json.JSONArray
import org.json.JSONException
@@ -78,7 +79,7 @@
}
*/
- private fun subscribeTopic(topic: String){
+ private fun subscribeMQTTTopic(topic: String){
if(context==null){
Log.e(DEBUG_TAG, "Trying to connect but context is null")
return
@@ -99,24 +100,31 @@
}
+ private fun subscribeTopicAddResponder(topic: String, responderWR: WeakReference<MQTTMatoListener>, lineId: String){
+ if (!respondersMap.contains(lineId)){
+ respondersMap[lineId] = ArrayList()
+ }
+ respondersMap[lineId]!!.add(responderWR)
+ subscribeMQTTTopic(topic)
+ }
+
fun startAndSubscribe(lineId: String, responder: MQTTMatoListener, context: Context): Boolean{
//start the client, and then subscribe to the topic
val topic = mapTopic(lineId)
+ val vrResp = WeakReference(responder)
this.context = context.applicationContext
synchronized(this) {
- if(!isStarted){
+ if(!isStarted || (client == null)){
connect(context.applicationContext) {
//when connection is done, run this
- if (!respondersMap.contains(lineId)){
- respondersMap[lineId] = ArrayList()
- }
- respondersMap[lineId]!!.add(WeakReference(responder))
- subscribeTopic(topic)
+ subscribeTopicAddResponder(topic, vrResp, lineId)
}
//wait for connection
+ } else {
+ subscribeTopicAddResponder(topic, vrResp, lineId)
}
//recheck if it is started
}
@@ -265,7 +273,8 @@
val messString = String(message.payloadAsBytes)
- Log.d(DEBUG_TAG, "Received message on topic: $topic")
+ if(BuildConfig.DEBUG)
+ Log.d(DEBUG_TAG, "Received message on topic: $topic")
try {
val jsonList = JSONArray(messString)
diff --git a/app/src/main/java/it/reyboz/bustorino/map/MapLibreUtils.kt b/app/src/main/java/it/reyboz/bustorino/map/MapLibreUtils.kt
--- a/app/src/main/java/it/reyboz/bustorino/map/MapLibreUtils.kt
+++ b/app/src/main/java/it/reyboz/bustorino/map/MapLibreUtils.kt
@@ -3,6 +3,7 @@
import android.animation.TypeEvaluator
import android.content.Context
import android.util.Log
+import it.reyboz.bustorino.BuildConfig
import it.reyboz.bustorino.backend.Stop
import org.maplibre.android.geometry.LatLng
import org.maplibre.android.location.LocationComponentActivationOptions
@@ -99,7 +100,8 @@
//check if sum is above dist
if (distFromLastPoint >= distanceIcon){
- Log.d(DEBUG_TAG, "Add between stop ${stops[i-1]} and stop ${stops[i]}, distance between: $dd")
+ if(BuildConfig.DEBUG)
+ Log.d(DEBUG_TAG, "Add between stop ${stops[i-1]} and stop ${stops[i]}, distance between: $dd")
if(dd>100) {
val imid = findIndexMidPoint(polyPoints, pi, newi, dd / 2)
pointsOutput.add(imid)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Aug 4, 20:44 (7 h, 11 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2035439
Default Alt Text
D204.1785869067.diff (3 KB)
Attached To
Mode
D204: Fix problem with not receiving MQTT location updates after pause
Attached
Detach File
Event Timeline