mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Nearby: Fix map moving by itself (#6061)
fixes #6046 the OnFocusChangeListener for nearby place list items sometimes gets invoked when new items aer set, even when the list is hidden, if an item had previously been clicked in it. This in turn causes the onItemClick to be called. This commit adds a check to make sure the list is not hidden when onItemClick is invoked this way.
This commit is contained in:
parent
4dd16054ca
commit
6a32454347
1 changed files with 6 additions and 1 deletions
|
|
@ -5,10 +5,12 @@ import android.view.View
|
|||
import android.view.View.GONE
|
||||
import android.view.View.INVISIBLE
|
||||
import android.view.View.VISIBLE
|
||||
import android.widget.RelativeLayout
|
||||
import androidx.activity.result.ActivityResultLauncher
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.transition.TransitionManager
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import com.hannesdorfmann.adapterdelegates4.dsl.AdapterDelegateViewBindingViewHolder
|
||||
import com.hannesdorfmann.adapterdelegates4.dsl.adapterDelegateViewBinding
|
||||
import fr.free.nrw.commons.R
|
||||
|
|
@ -42,7 +44,10 @@ fun placeAdapterDelegate(
|
|||
root.setOnFocusChangeListener { view1: View?, hasFocus: Boolean ->
|
||||
if (!hasFocus && nearbyButtonLayout.buttonLayout.isShown) {
|
||||
nearbyButtonLayout.buttonLayout.visibility = GONE
|
||||
} else if (hasFocus && !nearbyButtonLayout.buttonLayout.isShown) {
|
||||
} else if (hasFocus && !nearbyButtonLayout.buttonLayout.isShown &&
|
||||
BottomSheetBehavior.from(root.parent.parent.parent as RelativeLayout).state !=
|
||||
BottomSheetBehavior.STATE_HIDDEN
|
||||
) {
|
||||
showOrHideAndScrollToIfLast()
|
||||
onItemClick?.invoke(item)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue