Open tsengstudios opened 5 years ago
My current workaround is to try preventing the crashes inside the Hover library. I added two if's into HoverViewStateExpanded.java.
private void removeSection(int sectionIndex) {
final FloatingTab chainedTab = mChainedTabs.remove(sectionIndex);
TabChain tabChain = mTabChains.remove(sectionIndex);
tabChain.unchain(new Runnable() {
@Override
public void run() {
if (mHoverView != null) // prevent use of null pointer
mHoverView.mScreen.destroyChainedTab(chainedTab);
}
});
// If the removed section was the selected section then select a new section.
HoverMenu.Section removedSection = mSections.get(chainedTab);
if (removedSection.getId().equals(mHoverView.mSelectedSectionId)) {
int newSelectionIndex = 0;
if (sectionIndex - 1 < 0) { // prevent index out of bounds
newSelectionIndex = 0; // zero is a fine choice for the new selected section
} else if (sectionIndex - 1 < mHoverView.mMenu.getSectionCount() - 1) {
newSelectionIndex = sectionIndex - 1;
} else {
newSelectionIndex = mHoverView.mMenu.getSectionCount() - 1;
}
selectSection(mHoverView.mMenu.getSection(newSelectionIndex));
}
If mycustomHoverMenu removes a selected Section from
mSections
(theArrayList<Section>
) while it is expanded, then callingnotifyMenuChanged()
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: