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:
@@ -8,8 +8,8 @@ android {
|
||||
applicationId "com.streamplayer"
|
||||
minSdk 21
|
||||
targetSdk 35
|
||||
versionCode 100102
|
||||
versionName "10.1.2"
|
||||
versionCode 100107
|
||||
versionName "10.1.7"
|
||||
buildConfigField "String", "DEVICE_REGISTRY_URL", '"http://194.163.191.200:4000"'
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -129,6 +129,7 @@
|
||||
android:layout_weight="1"
|
||||
android:overScrollMode="never"
|
||||
android:scrollbars="vertical"
|
||||
android:fadeScrollbars="false"
|
||||
android:scrollbarStyle="insideInset"
|
||||
android:scrollbarThumbVertical="@drawable/scrollbar_vertical"
|
||||
android:scrollbarTrackVertical="@color/scrollbar_track"
|
||||
|
||||
Reference in New Issue
Block a user