feat: Add persistent scrollbar to events list

- Enable fadeScrollbars=false in RecyclerView
- Improve visibility of scrollbar

fix: Prevent navigation focus escape at end of list

- Implement custom LinearLayoutManager to intercept focus search
- Block FOCUS_DOWN action at the last item
- Remove legacy OnKeyListener and OnScrollListener
This commit is contained in:
StreamPlayer Bot
2026-02-09 22:05:54 -03:00
parent 907c97464b
commit ab69fd1aa4
4 changed files with 37 additions and 38 deletions

View File

@@ -73,7 +73,18 @@ public class MainActivity extends AppCompatActivity {
eventAdapter = new EventAdapter(event -> openPlayer(event.getTitle(), event.getPageUrl()));
eventRepository = new EventRepository();
channelLayoutManager = new GridLayoutManager(this, getSpanCount());
eventLayoutManager = new LinearLayoutManager(this);
eventLayoutManager = new LinearLayoutManager(this) {
@Override
public View onInterceptFocusSearch(View focused, int direction) {
if (direction == View.FOCUS_DOWN) {
int pos = getPosition(focused);
if (pos == getItemCount() - 1) {
return focused;
}
}
return super.onInterceptFocusSearch(focused, direction);
}
};
sections = buildSections();
sectionList.setLayoutManager(new LinearLayoutManager(this));
@@ -192,41 +203,6 @@ public class MainActivity extends AppCompatActivity {
// Clear existing listeners
contentList.clearOnScrollListeners();
// Prevent navigation out of events section via remote control
contentList.setOnKeyListener((v, keyCode, event) -> {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
int totalItemCount = eventLayoutManager.getItemCount();
if (totalItemCount > 0) {
int lastVisiblePosition = eventLayoutManager.findLastVisibleItemPosition();
// Prevent going down if we're at or near the last item
if (lastVisiblePosition >= totalItemCount - 1) {
// Consume the event to prevent navigation
return true;
}
}
}
}
return false;
});
// Also prevent scroll-based navigation
contentList.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
if (dy > 0) { // Scrolling down
int totalItemCount = eventLayoutManager.getItemCount();
if (totalItemCount > 0) {
int lastCompletelyVisiblePosition = eventLayoutManager.findLastCompletelyVisibleItemPosition();
if (lastCompletelyVisiblePosition == totalItemCount - 1) {
recyclerView.stopScroll();
}
}
}
}
});
if (cachedEvents.isEmpty()) {
loadEvents(false);
} else {