Skip to content

Conversation

@graycreate
Copy link
Member

Summary

  • Make MainActivity implement HackRecyclerView.AppBarTracking interface
  • Add AppBar offset tracking fields (mAppBarOffset, mAppBarIdle, mAppBarMaxOffset)
  • Update NewsFragment and MsgFragment to call setAppBarTracking() on their RecyclerViews
  • Fixes issue where navbar doesn't auto-hide when scrolling on some devices (e.g., Pixel 10)

Root Cause

HackRecyclerView.dispatchNestedPreScroll() has custom nested scroll handling logic to prevent "wobbly" AppBar behavior. This logic depends on the AppBarTracking interface to get the current AppBar state (expanded/idle).

UserHomeActivity correctly implements this interface, but MainActivity was missing it. This caused the scroll behavior to be unreliable on devices with different scroll physics (like Pixel 10 running Android 15).

Test plan

  • Cold start the app on Pixel 10 (or similar device)
  • Scroll the home page list up and down
  • Verify navbar auto-hides when scrolling down
  • Verify navbar reappears when scrolling up
  • Test on both "全部" (News) and "消息" (Messages) tabs

🤖 Generated with Claude Code

- Make MainActivity implement HackRecyclerView.AppBarTracking interface
- Add AppBar offset tracking fields and methods
- Update NewsFragment and MsgFragment to set AppBarTracking on their RecyclerViews
- Fixes issue where navbar doesn't auto-hide when scrolling on some devices (e.g., Pixel 10)

The root cause was that HackRecyclerView's custom nested scroll handling
in dispatchNestedPreScroll() relies on AppBarTracking interface to get
the AppBar state, but MainActivity wasn't implementing this interface.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Copilot AI review requested due to automatic review settings December 1, 2025 10:59
Copilot finished reviewing on behalf of graycreate December 1, 2025 11:02
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes the navbar scroll behavior on devices like Pixel 10 by implementing the AppBarTracking interface in MainActivity. The issue occurred because HackRecyclerView has custom nested scroll handling logic that depends on the AppBarTracking interface to track AppBar state (expanded/idle), which was previously only implemented in UserHomeActivity.

  • Implements HackRecyclerView.AppBarTracking interface in MainActivity with proper AppBar offset tracking
  • Updates NewsFragment and MsgFragment to use the correct HackRecyclerView type and connect to MainActivity's AppBarTracking
  • Follows the established pattern from UserHomeActivity

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
MainActivity.java Implements AppBarTracking interface, adds offset tracking fields (mAppBarOffset, mAppBarIdle, mAppBarMaxOffset), tracks AppBar offset in onOffsetChanged callback, and implements isAppBarExpanded() and isAppBarIdle() methods
NewsFragment.java Changes mRecyclerView type from LoadMoreRecyclerView to HackRecyclerView (matches XML layout) and adds setAppBarTracking() call to connect with MainActivity's AppBarTracking implementation
MsgFragment.java Changes mRecyclerView type from LoadMoreRecyclerView to HackRecyclerView (matches XML layout) and adds setAppBarTracking() call to connect with MainActivity's AppBarTracking implementation

@graycreate graycreate closed this Dec 1, 2025
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