Add quick scroll-to-top functionality via long press on Home button#1763
Conversation
…g click listener in MainActivity
fire-light42
left a comment
There was a problem hiding this comment.
I do not understand why you need 160 lines of code when you can accomplish the same result in 7.
for (view in listOf(binding?.navView, binding?.navRailView)) {
view?.findViewById<View?>(R.id.navigation_home)?.setOnLongClickListener {
val recycler = binding?.root?.findViewById<RecyclerView?>(R.id.home_master_recycler)
recycler?.smoothScrollToPosition(0)
return@setOnLongClickListener recycler != null
}
}There was a problem hiding this comment.
Pull Request Overview
This PR adds scroll-to-top functionality that allows users to quickly return to the top of the main page by long-pressing the Home button in the navigation. This addresses the inconvenience of manually scrolling to the top on long pages.
- Implements long press listener on Home navigation button to trigger scroll-to-top
- Targets the home master recycler view for smooth scrolling to position 0
- Applies functionality to both standard navigation view and rail navigation view
Files not reviewed (5)
- .idea/AndroidProjectSystem.xml: Language not supported
- .idea/compiler.xml: Language not supported
- .idea/deploymentTargetSelector.xml: Language not supported
- .idea/deviceManager.xml: Language not supported
- .idea/runConfigurations.xml: Language not supported
Comments suppressed due to low confidence (3)
|
I reviewed and updated the codes. Thank you. |
That is good, however you still have auto-generated files from your IDE in the .idea and .kotlin folder. Please remove those files as they are not relevant to other people. 👍 |
|
You're right. Thank you for your help and information. I've updated the code again. |
|
This is a great feature, however it's only applicable to the Homepage, it would be better if it was the same for Library, especially since Library would normally be a long page and contain a lot of Movies/Series, in the "completed" section for e.g. |
When users scroll down extensively on long pages, returning to the top can be inconvenient. With this update, users can now quickly return to the top of the main page by long-pressing the Home button, improving overall navigation and user experience.