From 771cb8c6f51bfdef5cf63b3088bcf959582e89b9 Mon Sep 17 00:00:00 2001 From: DHD2280 Date: Mon, 22 Apr 2024 08:52:29 +0200 Subject: [PATCH] Fix Adapter for ListWithPopUpPreference --- .../customprefs/dialogadapter/ListPreferenceAdapter.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/it/dhd/oxygencustomizer/customprefs/dialogadapter/ListPreferenceAdapter.java b/app/src/main/java/it/dhd/oxygencustomizer/customprefs/dialogadapter/ListPreferenceAdapter.java index aefcd0407..4d06dca10 100644 --- a/app/src/main/java/it/dhd/oxygencustomizer/customprefs/dialogadapter/ListPreferenceAdapter.java +++ b/app/src/main/java/it/dhd/oxygencustomizer/customprefs/dialogadapter/ListPreferenceAdapter.java @@ -17,6 +17,7 @@ import androidx.recyclerview.widget.RecyclerView; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import it.dhd.oxygencustomizer.BuildConfig; @@ -44,6 +45,7 @@ public class ListPreferenceAdapter extends RecyclerView.Adapter 0) if (TextUtils.equals(mEntryValues[position].toString(), mValue)) { + prevPos = position; ((ViewHolder)holder).binding.rootLayout.setStrokeColor(getAppContext().getColor(android.R.color.system_accent1_400)); } else { ((ViewHolder)holder).binding.rootLayout.setStrokeColor(Color.TRANSPARENT); } ((ViewHolder)holder).binding.rootLayout.setOnClickListener(v -> { - int previousPosition = Integer.parseInt(mValue); onItemClickListener.onItemClick(v, position); - mValue = String.valueOf(position); - notifyItemChanged(previousPosition); + mValue = String.valueOf(mEntryValues[position]); + notifyItemChanged(prevPos); notifyItemChanged(position); }); }