Skip to content

fix(navigation-view): highlighting menu item, fixes index out of bound error#16808

Merged
alperozturk96 merged 1 commit into
masterfrom
fix/index-out-of-navigation-item
Apr 8, 2026
Merged

fix(navigation-view): highlighting menu item, fixes index out of bound error#16808
alperozturk96 merged 1 commit into
masterfrom
fix/index-out-of-navigation-item

Conversation

@alperozturk96

@alperozturk96 alperozturk96 commented Apr 7, 2026

Copy link
Copy Markdown
Collaborator

Issue

unsetAllNavigationItems introduced to fix highlighting wrong item in bottom navigation view since user can highligt more item for drawer e.g. user navigates to media bottom navigation view and drawer view highlighted then user navigates to on device but bottom navigation view still shows the media. However sometimes causing an following exception:

Exception java.lang.IndexOutOfBoundsException: Index 2 out of bounds for length 1
  at jdk.internal.util.Preconditions.outOfBounds (Preconditions.java:64)
  at jdk.internal.util.Preconditions.outOfBoundsCheckIndex (Preconditions.java:70)
  at jdk.internal.util.Preconditions.checkIndex (Preconditions.java:266)
  at java.util.Objects.checkIndex (Objects.java:391)
  at java.util.ArrayList.get (ArrayList.java:434)
  at com.google.android.material.internal.NavigationMenuPresenter$NavigationMenuAdapter.onBindViewHolder (NavigationMenuPresenter.java:618)
  at com.google.android.material.internal.NavigationMenuPresenter$NavigationMenuAdapter.onBindViewHolder (NavigationMenuPresenter.java:540)

because navigation drawer menu items are modified while the bottom navigation view's MenuPresenter is mid-layout-pass.

Source

Fix

  • Uncheck previous item that exists in drawer if that ID doesn't belong to bottom navigation view
  • Uses set checked item since its interally does same thing
  • Uses Kotlin file since it's way more less code and safer

Set checked item

Screenshot 2026-04-07 at 10 39 54

…d error

Signed-off-by: alperozturk96 <alper_ozturk@proton.me>
@alperozturk96 alperozturk96 changed the title fix(navigation-view): highlighting menu item, fixes index out of boun… fix(navigation-view): highlighting menu item, fixes index out of bound error Apr 7, 2026
@alperozturk96 alperozturk96 added this to the Nextcloud App 33.1.0 milestone Apr 7, 2026
@github-actions

github-actions Bot commented Apr 7, 2026

Copy link
Copy Markdown

Codacy

SpotBugs

CategoryBaseNew
Bad practice3636
Correctness6969
Dodgy code229228
Experimental11
Internationalization77
Malicious code vulnerability22
Multithreaded correctness3434
Performance4242
Security1616
Total436435

@github-actions

github-actions Bot commented Apr 7, 2026

Copy link
Copy Markdown

APK file: https://github.com/nextcloud/android/actions/runs/24073989692/artifacts/6302747581
To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.
qrcode (please click on link to get QR code displayed)

@github-actions

github-actions Bot commented Apr 7, 2026

Copy link
Copy Markdown

blue-Light-Screenshot test failed, but no output was generated. Maybe a preliminary stage failed.

@alperozturk96 alperozturk96 merged commit 965f47c into master Apr 8, 2026
17 of 21 checks passed
@alperozturk96 alperozturk96 deleted the fix/index-out-of-navigation-item branch April 8, 2026 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants