Skip to content

Commit

Permalink
[Finder] Fix selecting/deselecting checkboxes
Browse files Browse the repository at this point in the history
Signed-off-by: Muntashir Al-Islam <[email protected]>
  • Loading branch information
MuntashirAkon committed Nov 19, 2024
1 parent 5da368d commit a2f2d3a
Showing 1 changed file with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
});
}
Expand Down

0 comments on commit a2f2d3a

Please sign in to comment.