Skip to content

Commit

Permalink
Fix Adapter for ListWithPopUpPreference
Browse files Browse the repository at this point in the history
  • Loading branch information
DHD2280 committed Apr 22, 2024
1 parent 5463d4a commit 771cb8c
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -44,6 +45,7 @@ public class ListPreferenceAdapter extends RecyclerView.Adapter<RecyclerView.Vie
private static final int HEADER_COUNT = 24;
String mSelectedImage;
String mAppliedImage;
int prevPos = -1;


public ListPreferenceAdapter(CharSequence[] entries,
Expand Down Expand Up @@ -174,16 +176,16 @@ else if (mEntryDrawables != null && mEntryDrawables.length > 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);
});
}
Expand Down

0 comments on commit 771cb8c

Please sign in to comment.