fix the bug of map reset (#6509)

Co-authored-by: Chengxu Yang <u7954427@anu.edu.au>
Co-authored-by: Nicolas Raoul <nicolas.raoul@gmail.com>
This commit is contained in:
Xinyu Yang 2025-10-16 21:34:17 +11:00 committed by GitHub
parent 864884e7b2
commit 7a865df909
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 27 additions and 1 deletions

View file

@ -91,6 +91,7 @@ public class NearbyFilterSearchRecyclerViewAdapter
label.setSelected(!label.isSelected());
holder.placeTypeLayout.setSelected(label.isSelected());
NearbyFilterState.setSelectedLabels(new ArrayList<>(selectedLabels));
callback.filterByMarkerType(selectedLabels, 0, false, false);
});
}
@ -152,6 +153,7 @@ public class NearbyFilterSearchRecyclerViewAdapter
label.setSelected(false);
selectedLabels.remove(label);
}
NearbyFilterState.setSelectedLabels(new ArrayList<>(selectedLabels));
notifyDataSetChanged();
}
@ -163,6 +165,7 @@ public class NearbyFilterSearchRecyclerViewAdapter
selectedLabels.add(label);
}
}
NearbyFilterState.setSelectedLabels(new ArrayList<>(selectedLabels));
notifyDataSetChanged();
}

View file

@ -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,
@ -924,6 +930,7 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(),
return _isDarkTheme
}
})
restoreStoredFilterSelection()
binding!!.nearbyFilterList.root
.layoutParams.width = getScreenWidth(
requireActivity(),
@ -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
@ -2987,4 +3010,4 @@ class NearbyParentFragment : CommonsDaggerSupportFragment(),
return input.contains("(") || input.contains(")")
}
}
}
}