From a2f2d3a7b2649938fa5a6095b4ffc714cbd619a9 Mon Sep 17 00:00:00 2001 From: Muntashir Al-Islam Date: Tue, 19 Nov 2024 10:11:07 -0800 Subject: [PATCH] [Finder] Fix selecting/deselecting checkboxes Signed-off-by: Muntashir Al-Islam --- .../filters/EditFilterOptionFragment.java | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/io/github/muntashirakon/AppManager/filters/EditFilterOptionFragment.java b/app/src/main/java/io/github/muntashirakon/AppManager/filters/EditFilterOptionFragment.java index 300bd3fb747..920616573c8 100644 --- a/app/src/main/java/io/github/muntashirakon/AppManager/filters/EditFilterOptionFragment.java +++ b/app/src/main/java/io/github/muntashirakon/AppManager/filters/EditFilterOptionFragment.java @@ -87,9 +87,9 @@ public WrappedFilterOption() { } protected WrappedFilterOption(@NonNull Parcel in) { - logic = in.readString().charAt(0); - filterOption = FilterOptions.create(in.readString()); - filterOption.setKeyValue(in.readString(), in.readString()); + logic = Objects.requireNonNull(in.readString()).charAt(0); + filterOption = FilterOptions.create(Objects.requireNonNull(in.readString())); + filterOption.setKeyValue(Objects.requireNonNull(in.readString()), in.readString()); } @Override @@ -297,7 +297,7 @@ private void updateUiForFilter(@NonNull FilterOption filterOption) { mCurrentKey = filterOption.getKey(); mCurrentKeyType = filterOption.getKeyType(); mKeySpinner.setSelection(mKeyAdapter.getPosition(mCurrentKey)); - // Update the textfield + // Update the text field mGenericEditText.setText(filterOption.getValue()); updateUiForType(mCurrentKeyType); } @@ -419,12 +419,18 @@ public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { public void onBindViewHolder(@NonNull ViewHolder holder, int position) { int flag = mFlags.get(position); CharSequence flagName = mFlagMap.get(flag); - boolean selected = (mFlag & flag) != 0; holder.item.setText(flagName); - holder.item.setChecked(selected); + holder.item.setChecked((mFlag & flag) != 0); holder.item.setOnClickListener(v -> { - mFlag |= flag; - holder.item.setChecked(true); + if ((mFlag & flag) != 0) { + // Already selected, deselect + mFlag &= ~flag; + holder.item.setChecked(false); + } else { + // Not yet selected, select + mFlag |= flag; + holder.item.setChecked(true); + } mItemClickListener.onClick(v); }); }