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); }); }