From 356a845b69fc1437ea83401ab18ad7638270bb5b Mon Sep 17 00:00:00 2001 From: ForestL <45709305+ForestL18@users.noreply.github.com> Date: Wed, 19 Feb 2025 18:15:58 +0800 Subject: [PATCH] hide update function of inline (#415) --- .../github/kr328/clash/design/ProvidersDesign.kt | 5 +++-- .../kr328/clash/design/adapter/ProviderAdapter.kt | 15 +++++++++++---- design/src/main/res/layout/adapter_provider.xml | 1 + 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/design/src/main/java/com/github/kr328/clash/design/ProvidersDesign.kt b/design/src/main/java/com/github/kr328/clash/design/ProvidersDesign.kt index b193783c..a717bc28 100644 --- a/design/src/main/java/com/github/kr328/clash/design/ProvidersDesign.kt +++ b/design/src/main/java/com/github/kr328/clash/design/ProvidersDesign.kt @@ -55,8 +55,9 @@ class ProvidersDesign( fun requestUpdateAll() { adapter.states.filter { !it.updating }.forEachIndexed { index, state -> state.updating = true - - requests.trySend(Request.Update(index, state.provider)) + if (state.provider.vehicleType != Provider.VehicleType.Inline) { + requests.trySend(Request.Update(index, state.provider)) + } } } } \ No newline at end of file diff --git a/design/src/main/java/com/github/kr328/clash/design/adapter/ProviderAdapter.kt b/design/src/main/java/com/github/kr328/clash/design/adapter/ProviderAdapter.kt index bb7b1eb7..b076827a 100644 --- a/design/src/main/java/com/github/kr328/clash/design/adapter/ProviderAdapter.kt +++ b/design/src/main/java/com/github/kr328/clash/design/adapter/ProviderAdapter.kt @@ -55,10 +55,17 @@ class ProviderAdapter( holder.binding.provider = state.provider holder.binding.state = state - holder.binding.update = View.OnClickListener { - state.updating = true - - requestUpdate(position, state.provider) + if (state.provider.vehicleType == Provider.VehicleType.Inline) { + holder.binding.endView.visibility = View.GONE + holder.binding.elapsedView.visibility = View.GONE + holder.binding.divider.visibility = View.GONE + } else { + holder.binding.endView.visibility = View.VISIBLE + holder.binding.elapsedView.visibility = View.VISIBLE + holder.binding.update = View.OnClickListener { + state.updating = true + requestUpdate(position, state.provider) + } } } diff --git a/design/src/main/res/layout/adapter_provider.xml b/design/src/main/res/layout/adapter_provider.xml index 12b99fe9..4625574f 100644 --- a/design/src/main/res/layout/adapter_provider.xml +++ b/design/src/main/res/layout/adapter_provider.xml @@ -58,6 +58,7 @@ android:text="@{IntervalKt.elapsedIntervalString(currentTime.value - state.updatedAt, context)}" />