Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(fixes: #31) setOnClickListener getting callback twice #32

Merged
merged 1 commit into from
Jan 29, 2022

Conversation

amankumar367
Copy link
Contributor

@amankumar367 amankumar367 commented Jan 25, 2022

To Verify

Put the below code in MainActivity.kt of demo-programmatically-add-buttons module

val btn2 = ThemedButton(buttonGroup.context)
btn2.text = "Button 2"
btn2.isEnabled = false
buttonGroup.addView(btn2, ViewGroup.LayoutParams(WRAP_CONTENT, MATCH_PARENT))


buttonGroup.buttons.forEach { button ->
      if (button.isEnabled.not()) {
            button.setOnClickListener { 
                    Toast.makeText(this, "${button.text} clicked", Toast.LENGTH_SHORT).show()
            }
      }
}

also don't forget to changes in build.gradle file

// implementation 'nl.bryanderidder:themed-toggle-button-group:1.3.4'
implementation(project(":library"))
implementation 'com.google.android.flexbox:flexbox:3.0.0'

Comment on lines +113 to +116
if (isActionUp) {
selectButtonWithAnimation(btn, event?.x ?: 0f, event?.y ?: 0f)
btn.performClick()
}
Copy link
Contributor Author

@amankumar367 amankumar367 Jan 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btn.performClick() should call only once when action = isActionUp

@Bryanx
Copy link
Owner

Bryanx commented Jan 29, 2022

Hey, thanks for noticing and creating a PR! I will create a patch.

@Bryanx Bryanx merged commit 8020864 into Bryanx:master Jan 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants