Skip to content
This repository has been archived by the owner on Dec 23, 2020. It is now read-only.

Crash when not overriding clearItem() inside FragmentAdapter #9

Open
Gnzlt opened this issue Sep 20, 2017 · 2 comments
Open

Crash when not overriding clearItem() inside FragmentAdapter #9

Gnzlt opened this issue Sep 20, 2017 · 2 comments

Comments

@Gnzlt
Copy link

Gnzlt commented Sep 20, 2017

I found a crash which occurs when using a custom adapter that extends from FragmentAdapter.

Whenever the ViewSwapper makes a call to clearItem() it throws a custom UnsupportedOperationException inside ViewSwapperAdapter since clearItem() is not overrided by default.

E/AndroidRuntime: FATAL EXCEPTION: main
 Process: com.example, PID: 12089
 java.lang.UnsupportedOperationException: Required method destroyItem was not overridden
     at org.buffer.adaptablebottomnavigation.adapter.ViewSwapperAdapter.destroyItem(ViewSwapperAdapter.java:196)
     at org.buffer.adaptablebottomnavigation.adapter.ViewSwapperAdapter.clearItem(ViewSwapperAdapter.java:126)
     at org.buffer.adaptablebottomnavigation.view.ViewSwapper.showItemAt(ViewSwapper.java:122)
     at org.buffer.adaptablebottomnavigation.view.AdaptableBottomNavigationView$ViewSwapperOnItemSelectedListener.onNavigationItemSelected(AdaptableBottomNavigationView.java:83)
     at android.support.design.widget.BottomNavigationView$1.onMenuItemSelected(BottomNavigationView.java:182)
     at android.support.v7.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:822)
     at android.support.v7.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:171)
     at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:973)
     at android.support.design.internal.BottomNavigationMenuView$1.onClick(BottomNavigationMenuView.java:95)
     at android.view.View.performClick(View.java:6256)
     at android.view.View$PerformClick.run(View.java:24697)
     at android.os.Handler.handleCallback(Handler.java:789)
     at android.os.Handler.dispatchMessage(Handler.java:98)
     at android.os.Looper.loop(Looper.java:164)
     at android.app.ActivityThread.main(ActivityThread.java:6541)
     at java.lang.reflect.Method.invoke(Native Method)
     at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

I temporary fixed it by overriding clearItem() with a call to destroyItem() inside my custom FragmentAdapter.

@Override
public void clearItem(ViewGroup container, int position, Object object) {
    super.destroyItem(container, position, object);
}
@kzotin
Copy link

kzotin commented Nov 17, 2017

@Gnzlt Kudos for workaround!

@hitherejoe
Copy link
Collaborator

Thanks for pointing this out, will take a look :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants