-
Notifications
You must be signed in to change notification settings - Fork 1
[NEC_NT] Bug fixes #219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
MichaelReyes
wants to merge
5
commits into
develop
Choose a base branch
from
bugfix/nec_nt-bug-fixes
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[NEC_NT] Bug fixes #219
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
00287ec
[24369] - create a NonClickableInfoWindowAdapter and apply to markers…
MichaelReyes 47e9a5d
[24391] - control the map markers for stops and map camera when timet…
MichaelReyes ccdd83e
[24388] - add manager to manage time format detection and apply check…
MichaelReyes 79be7f1
[24474] - disable name edit on Home and Work favorite items
MichaelReyes 339ea25
[24474] - fix failing tests caused by recent bug fixes
MichaelReyes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...ndroidUI/src/main/java/com/skedgo/tripkit/ui/map/adapter/NonClickableInfoWindowAdapter.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.skedgo.tripkit.ui.map.adapter | ||
|
||
import android.view.LayoutInflater | ||
import android.view.View | ||
import com.google.android.gms.maps.model.Marker | ||
import com.skedgo.tripkit.ui.map.SimpleCalloutView | ||
import javax.inject.Inject | ||
|
||
class NonClickableInfoWindowAdapter @Inject constructor(private val inflater: LayoutInflater) : | ||
StopInfoWindowAdapter { | ||
private var view: SimpleCalloutView? = null | ||
|
||
override fun getInfoContents(marker: Marker): View { | ||
if (view == null) { | ||
view = SimpleCalloutView.create(inflater) | ||
} | ||
assert(view != null) | ||
view!!.setTitle(marker.title) | ||
view!!.setSnippet(marker.snippet) | ||
// Explicitly hide the right image (arrow icon) for non-clickable POIs | ||
view!!.setRightImage(0) // This will hide the image via ViewUtils.setImage | ||
return view!! | ||
} | ||
|
||
override fun windowInfoHeightInPixel(marker: Marker): Int { | ||
return if (view != null) { | ||
view!!.height | ||
} else { | ||
0 | ||
} | ||
} | ||
|
||
override fun onInfoWindowClosed(marker: Marker) { | ||
} | ||
|
||
override fun getInfoWindow(marker: Marker): View? { | ||
return null | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ import com.google.android.gms.maps.model.Marker | |
import com.google.android.gms.maps.model.MarkerOptions | ||
import com.google.android.gms.maps.model.Polyline | ||
import com.google.android.gms.maps.model.PolylineOptions | ||
import com.skedgo.rxtry.printThrowableStackTrace | ||
import com.skedgo.rxtry.subscribeWithErrorHandling | ||
import com.skedgo.tripkit.common.model.stop.ScheduledStop | ||
import com.skedgo.tripkit.common.model.stop.ServiceStop | ||
|
@@ -155,12 +156,15 @@ class TimetableMapContributor(val fragment: Fragment) : TripKitMapContributor { | |
val marker = map.addMarker(first) | ||
stopCodesToMarkerMap[second!!] = marker | ||
} | ||
fitAllMapElementsToBounds() | ||
} | ||
) | ||
|
||
|
||
autoDisposable.add(viewModel.viewPort | ||
.subscribeWithErrorHandling { coordinates: List<LatLng>? -> this.centerMapOver(map, coordinates) }) | ||
// autoDisposable.add(viewModel.viewPort | ||
// .subscribeWithErrorHandling { coordinates: List<LatLng>? -> | ||
// this.centerMapOver(map, coordinates) } | ||
// ) | ||
|
||
autoDisposable.add(viewModel.drawServiceLine | ||
.subscribeWithErrorHandling { polylineOptions: List<PolylineOptions?> -> | ||
|
@@ -179,10 +183,7 @@ class TimetableMapContributor(val fragment: Fragment) : TripKitMapContributor { | |
} | ||
} | ||
|
||
val bounds = builder.build() | ||
val padding = 50 // Optional padding around the bounds | ||
val cameraUpdate = CameraUpdateFactory.newLatLngBounds(bounds, padding) | ||
map.animateCamera(cameraUpdate) | ||
fitAllMapElementsToBounds() | ||
}) | ||
|
||
autoDisposable.add(viewModel.realtimeVehicle | ||
|
@@ -192,6 +193,7 @@ class TimetableMapContributor(val fragment: Fragment) : TripKitMapContributor { | |
} else { | ||
setRealTimeVehicle(null) // Handle empty OptionalCompat | ||
} | ||
fitAllMapElementsToBounds() | ||
}) | ||
} | ||
|
||
|
@@ -419,4 +421,65 @@ class TimetableMapContributor(val fragment: Fragment) : TripKitMapContributor { | |
fun getMapPreviousPosition(): CameraPosition? { | ||
return previousCameraPosition | ||
} | ||
|
||
private fun fitAllMapElementsToBounds( | ||
paddingPx: Int = 160, | ||
includeRealtimeVehicle: Boolean = true, | ||
singlePointZoom: Float = 16f | ||
) { | ||
val map = googleMap ?: return | ||
|
||
val builder = LatLngBounds.Builder() | ||
var count = 0 | ||
var firstPoint: LatLng? = null | ||
|
||
// 1) All stop markers | ||
for (marker in stopCodesToMarkerMap.values) { | ||
val p = marker.position | ||
builder.include(p) | ||
if (count == 0) firstPoint = p | ||
count++ | ||
} | ||
|
||
// 2) All polyline points | ||
for (poly in serviceLines) { | ||
for (p in poly.points) { | ||
builder.include(p) | ||
if (count == 0) firstPoint = p | ||
count++ | ||
} | ||
} | ||
|
||
// 3) Realtime vehicle marker | ||
if (includeRealtimeVehicle) { | ||
realTimeVehicleMarker?.position?.let { p -> | ||
builder.include(p) | ||
if (count == 0) firstPoint = p | ||
count++ | ||
} | ||
} | ||
|
||
if (count == 0) return // nothing to show | ||
|
||
try { | ||
if (count == 1) { | ||
// Only one point -> just zoom to it | ||
map.animateCamera(CameraUpdateFactory.newLatLngZoom(firstPoint!!, singlePointZoom)) | ||
} else { | ||
// Multiple points -> fit bounds | ||
val bounds = builder.build() | ||
try { | ||
map.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, paddingPx)) | ||
} catch (_: IllegalStateException) { | ||
// Fallback if called before map has size; post to the view to retry | ||
fragment.view?.post { | ||
map.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, paddingPx)) | ||
} | ||
} | ||
} | ||
} catch (e: Exception) { | ||
e.printThrowableStackTrace() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can be replaced by Timber or Log |
||
} | ||
} | ||
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some identical logics can be extracted.