Skip to content

Commit

Permalink
Adding Names to Subscription lists
Browse files Browse the repository at this point in the history
  • Loading branch information
itissid committed Oct 16, 2024
1 parent d00d2da commit aa3e74d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 0 additions & 2 deletions app/src/main/java/me/itissid/privyloci/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ class MainActivity : ComponentActivity() {
@Composable
fun PlacesAndAssetScreenPreview() {
PrivyLociTheme {

val (placesList, assetsList) = DataProvider.getData()
PlacesAndAssetsScreen(placesList+assetsList)
}
Expand Down Expand Up @@ -116,7 +115,6 @@ fun MainScreen(
composable(NavItem.Places.route) {
PlacesAndAssetsScreen(places)
}
// Add other destinations as needed
}
}
}
Expand Down
14 changes: 9 additions & 5 deletions app/src/main/java/me/itissid/privyloci/data/DataProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ object DataProvider {
"subscriptionId": 1,
"eventStateType": "GeofenceEventState",
"type": "USER",
"placeTagId": "1",
"placeTagId": 1,
"appInfo": "",
"createdAt": 1693048323,
"isActive": true,
Expand All @@ -64,7 +64,7 @@ object DataProvider {
{
"subscriptionId": 2,
"type": "USER",
"placeTagId": "2",
"placeTagId": 2,
"appInfo": "",
"createdAt": 1693048323,
"isActive": true,
Expand All @@ -74,7 +74,7 @@ object DataProvider {
{
"subscriptionId": 3,
"type": "APP",
"placeTagId": "1",
"placeTagId": 1,
"appInfo": "{ \"app_name\": \"Grocery Shopping App\", \"app_id\": \"com.example.app\" }",
"createdAt": 1693048323,
"isActive": true,
Expand All @@ -84,7 +84,7 @@ object DataProvider {
{
"subscriptionId": 4,
"type": "USER",
"placeTagId": "3",
"placeTagId": 3,
"appInfo": "",
"createdAt": 1693048323,
"isActive": true,
Expand All @@ -94,7 +94,7 @@ object DataProvider {
{
"subscriptionId": 5,
"type": "APP",
"placeTagId": "4",
"placeTagId": 4,
"appInfo": "{ \"app_name\": \"Car Tracking App\", \"app_id\": \"com.example.dummycarapp\" }",
"createdAt": 1693048323,
"isActive": true,
Expand Down Expand Up @@ -195,6 +195,10 @@ object DataProvider {
val subscriptionsJson = gson.toJson(dataMap["subscriptions"])
val subscriptionListType: Type = object : TypeToken<List<Subscription>>() {}.type
val subscriptionsList: List<Subscription> = gson.fromJson(subscriptionsJson, subscriptionListType)
// Add place names to each of the Subscription objects from placeList lookup
subscriptionsList.forEach {
it.placeTagName = (assetsList+placesList).find { place -> place.id == it.placeTagId }?.name.toString()
}

return Triple(placesList, assetsList, subscriptionsList)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ enum class PlaceTagType {
data class Subscription(
val subscriptionId: Int,
val type: SubscriptionType, // enum {APP, USER}
val placeTagId: String,
val placeTagName: String,
val placeTagId: Int,
var placeTagName: String,
val appInfo: String, // JSON string with app details if type is APP
val createdAt: Long,
val isActive: Boolean,
Expand Down

0 comments on commit aa3e74d

Please sign in to comment.