qingmei2 / RxImagePicker

:rocket:RxJava2 and RxJava3 external support. Android flexible picture selector, provides the support for theme of Zhihu and WeChat (灵活的Android图片选择器,提供了知乎和微信主题的支持).
MIT License
1.2k stars 155 forks source link

屏幕旋转会崩溃 #84

Closed turingking closed 4 years ago

turingking commented 4 years ago

Caused by: kotlin.KotlinNullPointerException at com.qingmei2.rximagepicker_extension.model.SelectedItemCollection.onCreate(SelectedItemCollection.kt:55) at com.qingmei2.rximagepicker_extension_wechat.ui.WechatImagePickerFragment.onViewCreated(WechatImagePickerFragment.kt:81) at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:892) at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238) at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303) at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2659) at androidx.fragment.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManagerImpl.java:2613) at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:246) at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:542) at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:201) at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1249) at android.app.Activity.performStart(Activity.java:6880) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2719) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2817)  at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4652)  at android.app.ActivityThread.-wrap19(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1564)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:163)  at android.app.ActivityThread.main(ActivityThread.java:6388)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:930)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:820) 

很奇怪,单独跑你的demo是可以的,集成进项目打开再旋转屏幕就报错

turingking commented 4 years ago

补充下,不知道为什么,现在单独跑你的demo 也会出现这个问题。。

turingking commented 4 years ago

经过排查 ,是因为 SelectedItemCollection 的onSaveInstanceState() 方法没有在 WechatImagePickerActivity等activity中调用。

qingmei2 commented 4 years ago

@turingking

谢谢你的issue,该问题已经修复于 2.5.4版本。