From a107796ec28f7a438f11ebb0b7b5213cb3d8f324 Mon Sep 17 00:00:00 2001 From: Albert Vaca Cintora Date: Tue, 8 Oct 2024 22:38:01 +0200 Subject: [PATCH] Change Iterator argument to List --- .../kdeconnect/UserInterface/DeviceFragment.kt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/org/kde/kdeconnect/UserInterface/DeviceFragment.kt b/src/org/kde/kdeconnect/UserInterface/DeviceFragment.kt index cd275213..688df5d4 100644 --- a/src/org/kde/kdeconnect/UserInterface/DeviceFragment.kt +++ b/src/org/kde/kdeconnect/UserInterface/DeviceFragment.kt @@ -281,7 +281,7 @@ class DeviceFragment : Fragment() { requirePairingBinding().pairingButtons.visibility = View.GONE if (device.isReachable) { val context = requireContext() - val pluginsWithButtons = device.loadedPlugins.values.filter { it.displayAsButton(context) }.iterator() + val pluginsWithButtons = device.loadedPlugins.values.filter { it.displayAsButton(context) } val pluginsNeedPermissions = device.pluginsWithoutPermissions.values.filter { device.isPluginEnabled(it.pluginKey) } val pluginsNeedOptionalPermissions = device.pluginsWithoutOptionalPermissions.values.filter { device.isPluginEnabled(it.pluginKey) } requireErrorBinding().errorMessageContainer.visibility = View.GONE @@ -377,7 +377,7 @@ class DeviceFragment : Fragment() { fun PreviewCompose() { val plugins = listOf(MprisPlugin(), RunCommandPlugin(), PresenterPlugin()) plugins.forEach { it.setContext(LocalContext.current, null) } - PluginButtons(plugins.iterator(), 2) + PluginButtons(plugins, 2) } @OptIn(ExperimentalMaterial3Api::class) @@ -409,9 +409,10 @@ class DeviceFragment : Fragment() { } @Composable - fun PluginButtons(plugins: Iterator, numColumns: Int) { + fun PluginButtons(plugins: List, numColumns: Int) { Column(modifier = Modifier.padding(horizontal = 16.dp)) { - while (plugins.hasNext()) { + val pluginIter = plugins.iterator() + while (pluginIter.hasNext()) { Row( modifier = Modifier .fillMaxWidth() @@ -419,9 +420,9 @@ class DeviceFragment : Fragment() { horizontalArrangement = Arrangement.spacedBy(8.dp) ) { repeat(numColumns) { - if (plugins.hasNext()) { + if (pluginIter.hasNext()) { PluginButton( - plugin = plugins.next(), + plugin = pluginIter.next(), modifier = Modifier.weight(1f) ) } else { @@ -453,7 +454,7 @@ class DeviceFragment : Fragment() { @Composable fun PluginList( - pluginsWithButtons: Iterator, + pluginsWithButtons: List, pluginsNeedPermissions: List, pluginsNeedOptionalPermissions: List ) {