From aa3e74dadbbcc7c4cd8c9dc80f96af9a8d8cab1d Mon Sep 17 00:00:00 2001 From: Sidharth Gupta Date: Wed, 16 Oct 2024 12:47:39 -0400 Subject: [PATCH] Adding Names to Subscription lists --- .../main/java/me/itissid/privyloci/MainActivity.kt | 2 -- .../java/me/itissid/privyloci/data/DataProvider.kt | 14 +++++++++----- .../me/itissid/privyloci/datamodels/DataModels.kt | 4 ++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/me/itissid/privyloci/MainActivity.kt b/app/src/main/java/me/itissid/privyloci/MainActivity.kt index ec40411..b6b477c 100644 --- a/app/src/main/java/me/itissid/privyloci/MainActivity.kt +++ b/app/src/main/java/me/itissid/privyloci/MainActivity.kt @@ -88,7 +88,6 @@ class MainActivity : ComponentActivity() { @Composable fun PlacesAndAssetScreenPreview() { PrivyLociTheme { - val (placesList, assetsList) = DataProvider.getData() PlacesAndAssetsScreen(placesList+assetsList) } @@ -116,7 +115,6 @@ fun MainScreen( composable(NavItem.Places.route) { PlacesAndAssetsScreen(places) } - // Add other destinations as needed } } } diff --git a/app/src/main/java/me/itissid/privyloci/data/DataProvider.kt b/app/src/main/java/me/itissid/privyloci/data/DataProvider.kt index 47da3bb..69fb759 100644 --- a/app/src/main/java/me/itissid/privyloci/data/DataProvider.kt +++ b/app/src/main/java/me/itissid/privyloci/data/DataProvider.kt @@ -54,7 +54,7 @@ object DataProvider { "subscriptionId": 1, "eventStateType": "GeofenceEventState", "type": "USER", - "placeTagId": "1", + "placeTagId": 1, "appInfo": "", "createdAt": 1693048323, "isActive": true, @@ -64,7 +64,7 @@ object DataProvider { { "subscriptionId": 2, "type": "USER", - "placeTagId": "2", + "placeTagId": 2, "appInfo": "", "createdAt": 1693048323, "isActive": true, @@ -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, @@ -84,7 +84,7 @@ object DataProvider { { "subscriptionId": 4, "type": "USER", - "placeTagId": "3", + "placeTagId": 3, "appInfo": "", "createdAt": 1693048323, "isActive": true, @@ -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, @@ -195,6 +195,10 @@ object DataProvider { val subscriptionsJson = gson.toJson(dataMap["subscriptions"]) val subscriptionListType: Type = object : TypeToken>() {}.type val subscriptionsList: List = 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) } diff --git a/app/src/main/java/me/itissid/privyloci/datamodels/DataModels.kt b/app/src/main/java/me/itissid/privyloci/datamodels/DataModels.kt index 03e29eb..0f51d36 100644 --- a/app/src/main/java/me/itissid/privyloci/datamodels/DataModels.kt +++ b/app/src/main/java/me/itissid/privyloci/datamodels/DataModels.kt @@ -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,