Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public void onBindViewHolder(@NonNull RecyclerViewHolder holder, int position) {
label.setSelected(!label.isSelected());
holder.placeTypeLayout.setSelected(label.isSelected());

NearbyFilterState.setSelectedLabels(new ArrayList<>(selectedLabels));
callback.filterByMarkerType(selectedLabels, 0, false, false);
});
}
Expand Down Expand Up @@ -152,6 +153,7 @@ public void setRecyclerViewAdapterItemsGreyedOut() {
label.setSelected(false);
selectedLabels.remove(label);
}
NearbyFilterState.setSelectedLabels(new ArrayList<>(selectedLabels));
notifyDataSetChanged();
}

Expand All @@ -163,6 +165,7 @@ public void setRecyclerViewAdapterAllSelected() {
selectedLabels.add(label);
}
}
NearbyFilterState.setSelectedLabels(new ArrayList<>(selectedLabels));
notifyDataSetChanged();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,12 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(),
fun initNearbyFilter() {
binding!!.nearbyFilterList.root.visibility = View.GONE
hideBottomSheet()
binding!!.nearbyFilter.searchViewLayout.searchView.apply {
setIconifiedByDefault(false)
isIconified = false
setQuery("", false)
clearFocus()
}
binding!!.nearbyFilter.searchViewLayout.searchView.setOnQueryTextFocusChangeListener { v, hasFocus ->
setLayoutHeightAlignedToWidth(
1.25,
Expand Down Expand Up @@ -924,6 +930,7 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(),
return _isDarkTheme
}
})
restoreStoredFilterSelection()
binding!!.nearbyFilterList.root
.layoutParams.width = getScreenWidth(
requireActivity(),
Expand All @@ -942,6 +949,22 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(),
})
}

private fun restoreStoredFilterSelection() {
val adapter = nearbyFilterSearchRecyclerViewAdapter ?: return
val savedLabels = ArrayList(NearbyFilterState.getInstance().selectedLabels)
adapter.selectedLabels.clear()
val savedSet = savedLabels.toSet()
Label.valuesAsList().forEach { label ->
val isSelected = savedSet.contains(label)
label.setSelected(isSelected)
if (isSelected) {
adapter.selectedLabels.add(label)
}
}
NearbyFilterState.setSelectedLabels(ArrayList(adapter.selectedLabels))
adapter.notifyDataSetChanged()
}

override fun setCheckBoxAction() {
binding!!.nearbyFilterList.checkboxTriStates.addAction()
binding!!.nearbyFilterList.checkboxTriStates.state = CheckBoxTriStates.UNKNOWN
Expand Down Expand Up @@ -2987,4 +3010,4 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(),
return input.contains("(") || input.contains(")")
}
}
}
}