Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when setting hasStableIds to true #2578

Closed
connyduck opened this issue Apr 5, 2020 · 2 comments
Closed

Crash when setting hasStableIds to true #2578

connyduck opened this issue Apr 5, 2020 · 2 comments

Comments

@connyduck
Copy link
Contributor

connyduck commented Apr 5, 2020

About this issue

IllegalStateException: Cannot change whether this adapter has stable IDs while the adapter has registered observers

Stacktrace
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mikepenz.materialdrawer.app.debug/com.mikepenz.materialdrawer.app.DrawerActivity}: java.lang.IllegalStateException: Cannot change whether this adapter has stable IDs while the adapter has registered observers.
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3270)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
      at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
      at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
      at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
      at android.os.Handler.dispatchMessage(Handler.java:107)
      at android.os.Looper.loop(Looper.java:214)
      at android.app.ActivityThread.main(ActivityThread.java:7356)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
   Caused by: java.lang.IllegalStateException: Cannot change whether this adapter has stable IDs while the adapter has registered observers.
      at androidx.recyclerview.widget.RecyclerView$Adapter.setHasStableIds(RecyclerView.java:7142)
      at com.mikepenz.materialdrawer.widget.MaterialDrawerSliderView.setHasStableIds(MaterialDrawerSliderView.kt:291)
      at com.mikepenz.materialdrawer.app.DrawerActivity$onCreate$2.invoke(DrawerActivity.kt:93)
      at com.mikepenz.materialdrawer.app.DrawerActivity$onCreate$2.invoke(DrawerActivity.kt:29)
      at com.mikepenz.materialdrawer.widget.MaterialDrawerSliderView.apply(MaterialDrawerSliderView.kt:843)
      at com.mikepenz.materialdrawer.app.DrawerActivity.onCreate(DrawerActivity.kt:92)
      at android.app.Activity.performCreate(Activity.java:7802)
      at android.app.Activity.performCreate(Activity.java:7791)
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1299)
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3245)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409) 
      at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83) 
      at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
      at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016) 
      at android.os.Handler.dispatchMessage(Handler.java:107) 
      at android.os.Looper.loop(Looper.java:214) 
      at android.app.ActivityThread.main(ActivityThread.java:7356) 
      at java.lang.reflect.Method.invoke(Native Method) 
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

Details

  • Used library version: 8.0.0 / current develop
@mikepenz
Copy link
Owner

mikepenz commented Apr 5, 2020

@connyduck the FastAdapter should have hasStableIds by default.

I am not sure if this is a real bug of the drawer. as this behavior comes from the adapter itself.
you'd have to remove the adapter from the drawers recyclerview and set it again :/

Ok as we offer this method it should also behave. will have a look

@mikepenz
Copy link
Owner

mikepenz commented Apr 5, 2020

Modified that method to disconnect and reconnect the adapter when you switch that flag in v8.0.1

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

No branches or pull requests

2 participants