question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

setOnSpinnerOutsideTouchListener does not fire

See original GitHub issue

Please complete the following information:

  • Library Version [e.g. v1.0.0] : 1.0.5
  • Affected Device(s) : Google Pixel 3a

Describe the Bug:

Im using Kotlin with PowerSpinner, setting the onSpinnerOutsideTouchListener using setOnSpinnerOutsideTouchListener { view, motionEvent -> } does not get fired while touching outside spinner when the spinner is open

Expected Behavior:

Expect to get event fired when touching outside spinner when the spinner is open, so that I could close the spinner. It would be good if the spinner could be closed when user click the physical back button.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
davischungcommented, Apr 29, 2020

@skydoves There is a side-issue produced by this setOnSpinnerItemSelectedListener fix. If you click on the PowerSpinnerView it will shows the dropdown, clicking one more time should dismiss the dropdown.

The intention to add a setOnSpinnerOutsideTouchListener is to dismiss the dropdown while click was being detected outside the dropdown, to implement is to call dismiss() in the callback function. However, by adding a setOnSpinnerOutsideTouchListener, clicking on the PowerSpinnerView when dropdown is showing will fire showOrDismiss twice if dismiss() is being called within setOnSpinnerOutsideTouchListener {}, resulting unable to dismiss the PowerSpinnerView dropdown by clicking it again.

One quick fix on my side is to add some handling like below to override the onClickListener:

var dismissTime: Date? = null
binding.spinnerRegionCode.apply {
    ...
    setOnSpinnerOutsideTouchListener { _, _ ->
        dismissTime = Date()
        binding.spinnerRegionCode.dismiss()
    }
}
binding.spinnerRegionCode.setOnClickListener {
    if (Date().time - (dismissTime?.time ?: 0) > 200) {
        binding.spinnerRegionCode.showOrDismiss()
    }
    dismissTime = null
}

See if you could handle it within the library. Thanks.

1reaction
skydovescommented, May 10, 2020

It is released on the new version 1.0.8! And you can set the new attribute debounce_duration.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android Spinner setOnItemSelectedListener does not fire ...
I download data from API using Volley and put it into Spinner. I can see all items that I get from API. However...
Read more >
PowerSpinner - 🌀 A lightweight dropdown popup spinner, ...
If the popup is not showing, shows the spinner popup menu. // If the popup is already ... setOnSpinnerOutsideTouchListener does not fire.
Read more >
A lightweight dropdown popup spinner with fully customizable ...
Here is a basic example of implementing PowerSpinnerView in XML layout. ... setOnClickListener { } // the spinner popup will not be dismissed...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found