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

Feat: Open only a single fragment instance incase of multiple clicks … #322

Merged

Conversation

Prakhar-Agarwal-byte
Copy link
Contributor

…within 800ms

Fixes #287

@thunderbiscuit
Copy link
Owner

This works, but I'd like to get more information as to why you chose this particular architecture. At first glance it looks like the companion object is there to ensure there is only one instance of the class? Why was this solution preferred to using a Kotlinobject?

In general, you can make it easier for reviewers to understand your approach if your PRs have a bit more information. Use the opening thread item to explain what you tried, where you found the solution, why it's better than other approaches, etc. As is, reviewers are just left wondering why this particular approach was chosen, and have to retrace your steps by themselves (Googling, chatGPT, ect.)

@Prakhar-Agarwal-byte
Copy link
Contributor Author

Prakhar-Agarwal-byte commented Jul 21, 2023

I think using Kotlin "object" here is better. The "companion object" that I used before also achieves the same result of creating a singleton. The "object" provides this functionality out of the box.

I took inspiration from #295 PR.
First I am storing the last time a button was clicked, then when an event is raised again using the ClickHelper then it calculates the difference between the last time the event was raised and now. Only if the difference is more than 800ms the event is allowed to go through.

Copy link
Owner

@thunderbiscuit thunderbiscuit left a comment

Choose a reason for hiding this comment

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

ACK b8980b7.

Cool thanks for the extra information!

@thunderbiscuit thunderbiscuit merged commit 6fda520 into thunderbiscuit:master Jul 21, 2023
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.

Bug: Double click on receive or send button opens fragment multiple times
2 participants