-
Notifications
You must be signed in to change notification settings - Fork 279
removing selected section causes invisible FAB (still draggable) #91
Description
If mycustomHoverMenu removes a selected Section from mSections (the ArrayList<Section>) while it is expanded, then calling notifyMenuChanged() causes a crash. To demonstrate, change 1 to 0 on line 123 of MutatingSectionsHoverMenuService.java of the hoverdemo-helloworld app. And manually expand the FAB after starting the "Launch Changing Sections".
removeTab(0);
That change just targets the currently selected section/tab for removal instead of a non-selected section. If I collapse the hoverView first, I can avoid the crash, but then I've seen the FAB ends up invisible (still referring to the removed section if it is at the end of the list), or sometimes crash after manually clicking the FAB, but I wonder if there's a better/safer procedure to removing sections.
I realize this is unsupported. But just in case there's a community using this cool library, I thought I'd post this question. And hopefully, my workaround shortly.
The crash details:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: org.codecanon.hover.hoverdemo.helloworld, PID: 27913
java.lang.ArrayIndexOutOfBoundsException: length=10; index=-1
at java.util.ArrayList.get(ArrayList.java:439)
at io.mattcarroll.hover.hoverdemo.helloworld.MutatingSectionsHoverMenuService$MutatingHoverMenu.getSection(MutatingSectionsHoverMenuService.java:179)
at io.mattcarroll.hover.HoverViewStateExpanded.removeSection(HoverViewStateExpanded.java:492)
at io.mattcarroll.hover.HoverViewStateExpanded.removeSections(HoverViewStateExpanded.java:466)
at io.mattcarroll.hover.HoverViewStateExpanded.access$600(HoverViewStateExpanded.java:39)
at io.mattcarroll.hover.HoverViewStateExpanded$6.onRemoved(HoverViewStateExpanded.java:327)
at android.support.v7.util.BatchingListUpdateCallback.dispatchLastEvent(BatchingListUpdateCallback.java:62)
at android.support.v7.util.DiffUtil$DiffResult.dispatchUpdatesTo(DiffUtil.java:729)
at io.mattcarroll.hover.HoverMenu.notifyMenuChanged(HoverMenu.java:76)
at io.mattcarroll.hover.hoverdemo.helloworld.MutatingSectionsHoverMenuService$MutatingHoverMenu.removeTab(MutatingSectionsHoverMenuService.java:224)
at io.mattcarroll.hover.hoverdemo.helloworld.MutatingSectionsHoverMenuService$MutatingHoverMenu.access$100(MutatingSectionsHoverMenuService.java:59)
at io.mattcarroll.hover.hoverdemo.helloworld.MutatingSectionsHoverMenuService$MutatingHoverMenu$10.run(MutatingSectionsHoverMenuService.java:123)
at io.mattcarroll.hover.hoverdemo.helloworld.MutatingSectionsHoverMenuService$MutatingHoverMenu$12.run(MutatingSectionsHoverMenuService.java:142)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6718)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)