Skip to content

Commit

Permalink
Add tags support in Kotlin RouteActivityHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
RZR-UA committed Nov 25, 2024
1 parent 7f5a9c5 commit ea5507d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ object RouteActivityHelper {
return cachedActivities
}

fun findActivityByTag(tag: String): RouteActivity? {
for (activity in getActivities()) {
if (activity.tags != null && activity.tags.contains(tag)) {
return activity
}
}
return null
}

fun saveRouteActivity(trackItems: Collection<TrackItem>, routeActivity: RouteActivity?) {
runAsync {
trackItems.forEach { trackItem ->
Expand Down Expand Up @@ -121,7 +130,8 @@ object RouteActivityHelper {
val activityId = activityJson["id"]!!.jsonPrimitive.content
val activityLabel = activityJson["label"]!!.jsonPrimitive.content
val iconName = activityJson["icon_name"]!!.jsonPrimitive.content
val activity = RouteActivity(activityId, activityLabel, iconName, activitiesGroup)
val tags = activityJson["tags"]?.jsonArray?.map { it.jsonPrimitive.content }?.toSet()
val activity = RouteActivity(activityId, activityLabel, iconName, activitiesGroup, tags)
cachedActivities.add(activity)
activities.add(activity)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ data class RouteActivity(
val id: String,
val label: String,
val iconName: String,
val group: RouteActivityGroup
val group: RouteActivityGroup,
val tags: Set<String>? = null
) {
override fun toString(): String {
return id
Expand Down

0 comments on commit ea5507d

Please sign in to comment.