From 038051fc7b2fdfea623caa21f399f31f4f0d2fd1 Mon Sep 17 00:00:00 2001 From: septs Date: Thu, 14 Nov 2024 18:19:50 +0800 Subject: [PATCH] chore: simplify iccid finder --- .../angry/openeuicc/ui/NotificationsActivity.kt | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/app-common/src/main/java/im/angry/openeuicc/ui/NotificationsActivity.kt b/app-common/src/main/java/im/angry/openeuicc/ui/NotificationsActivity.kt index 31b7d7e..39d3468 100644 --- a/app-common/src/main/java/im/angry/openeuicc/ui/NotificationsActivity.kt +++ b/app-common/src/main/java/im/angry/openeuicc/ui/NotificationsActivity.kt @@ -115,15 +115,18 @@ class NotificationsActivity: BaseEuiccAccessActivity(), OpenEuiccContextMarker { private fun refresh() { launchTask { - notificationAdapter.notifications = - euiccChannelManager.withEuiccChannel(logicalSlotId) { channel -> - val profiles = channel.lpa.profiles - - channel.lpa.notifications.map { - val profile = profiles.find { p -> p.iccid == it.iccid } - LocalProfileNotificationWrapper(it, profile?.displayName ?: "???") + euiccChannelManager.withEuiccChannel(logicalSlotId) { channel -> + val profiles = buildMap { + for (profile in channel.lpa.profiles) { + put(profile.iccid, profile) } } + + notificationAdapter.notifications = channel.lpa.notifications.map { + val name = profiles[it.iccid]?.displayName ?: "???" + LocalProfileNotificationWrapper(it, name) + } + } } } -- 2.45.3