OpenSooq / Pluto

Pluto is an Easy, lightweight and high performance slider view library for Android. You have the flexibility to customize it to any view since it based RecyclerView.
https://engineering.opensooq.com
109 stars 16 forks source link

IllegalStateException #7

Closed timtsj closed 5 years ago

timtsj commented 5 years ago

Hello, if I back from other activity and rotation phone i get error: java.lang.IllegalStateException: Observer com.opensooq.pluto.PlutoIndicator$initObserver$1@3c676736 was not registered.

But I'm not using custom indicator.

tamtom commented 5 years ago

@timtsj can you please paste the full stack trace of the crash and where the crash happens

timtsj commented 5 years ago

new 6.txt

tamtom commented 5 years ago

and you are passing the right lifecycle instance to Pluto right? if you don't mind showing me your create method of Pluto?

timtsj commented 5 years ago

i m use Pluto in fragment, now if i give getActivity().getLifecycle(), app stoped crush after rotation but i still catch IllegalStateException


        PlutoView mPluto = rootView.findViewById(R.id.slider_view);
        List<Balance> balanceList = sharedPrefsHelper.getUserInfo().getBalance();

        BalanceAdapter adapter = new BalanceAdapter(balanceList);
        try {
            mPluto.create(adapter, getActivity().getLifecycle());
        } catch (IllegalStateException e) {
            e.printStackTrace();
        }
tamtom commented 5 years ago

@timtsj have you tried using getLifecycle() this method also available in fragments since the lifecycle of the activity is different from the lifecycle fragment please pass the fragment lifecycle and let me know if the crash still occurs

timtsj commented 5 years ago

if I give getLifecycle() from fragment app crashed and close, if I give activity getLifecycle() app stopped crash but I still catch IllegalStateException

tamtom commented 5 years ago

when you pass the fragment lifecycle, is it the same crash?

timtsj commented 5 years ago

yes. if fragment lifecycle -> catch IllegalStateException, rotation phone and app crash and close if activity lifecycle -> only catch IllegalStateException

tamtom commented 5 years ago

thanks for reporting the issue I will check it and will release a fix if it a bug

OhJeongGyu commented 5 years ago

Hello, thanks for your nice library.

Will this bug be fixed? I'm waiting for fix

tamtom commented 5 years ago

@OhJeongGyu I couldn't reproduce can you tell me your scenario and show me code how to reproduce it? thanks

OhJeongGyu commented 5 years ago

These issues don't occur in user app. I am reported on only fabric, and I just saw this issue in android studio logcat without crash.

could you please check the log as below?

0. Crashed: main

   at android.app.ActivityThread.performDestroyActivity + 4702(ActivityThread.java:4702)
   at android.app.ActivityThread.handleDestroyActivity + 4725(ActivityThread.java:4725)
   at android.app.servertransaction.DestroyActivityItem.execute + 39(DestroyActivityItem.java:39)
   at android.app.servertransaction.TransactionExecutor.executeLifecycleState + 145(TransactionExecutor.java:145)
   at android.app.servertransaction.TransactionExecutor.execute + 70(TransactionExecutor.java:70)
   at android.app.ActivityThread$H.handleMessage + 1947(ActivityThread.java:1947)
   at android.os.Handler.dispatchMessage + 106(Handler.java:106)
   at android.os.Looper.loop + 214(Looper.java:214)
   at android.app.ActivityThread.main + 7032(ActivityThread.java:7032)
   at java.lang.reflect.Method.invoke(Method.java)
   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run + 494(RuntimeInit.java:494)
   at com.android.internal.os.ZygoteInit.main + 965(ZygoteInit.java:965)

--

Fatal Exception: java.lang.RuntimeException: Unable to destroy activity {com.smellab.kimcaddie/com.smellab.kimcaddie.presentation.main.view.ContainerActivity}: java.lang.IllegalStateException: Observer com.opensooq.pluto.PlutoIndicator$initObserver$1@db9569e was not registered. at android.app.ActivityThread.performDestroyActivity + 4702(ActivityThread.java:4702) at android.app.ActivityThread.handleDestroyActivity + 4725(ActivityThread.java:4725) at android.app.servertransaction.DestroyActivityItem.execute + 39(DestroyActivityItem.java:39) at android.app.servertransaction.TransactionExecutor.executeLifecycleState + 145(TransactionExecutor.java:145) at android.app.servertransaction.TransactionExecutor.execute + 70(TransactionExecutor.java:70) at android.app.ActivityThread$H.handleMessage + 1947(ActivityThread.java:1947) at android.os.Handler.dispatchMessage + 106(Handler.java:106) at android.os.Looper.loop + 214(Looper.java:214) at android.app.ActivityThread.main + 7032(ActivityThread.java:7032) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run + 494(RuntimeInit.java:494) at com.android.internal.os.ZygoteInit.main + 965(ZygoteInit.java:965)

Caused by java.lang.IllegalStateException: Observer com.opensooq.pluto.PlutoIndicator$initObserver$1@db9569e was not registered. at android.database.Observable.unregisterObserver + 69(Observable.java:69) at androidx.recyclerview.widget.RecyclerView$Adapter.unregisterAdapterDataObserver + 7017(RecyclerView.java:7017) at com.opensooq.pluto.PlutoIndicator.destroySelf + 337(PlutoIndicator.kt:337) at com.opensooq.pluto.PlutoIndicator.onDetachedFromWindow + 450(PlutoIndicator.kt:450) at android.view.View.dispatchDetachedFromWindow + 20067(View.java:20067) at android.view.ViewGroup.dispatchDetachedFromWindow + 3995(ViewGroup.java:3995) at android.view.ViewGroup.dispatchDetachedFromWindow + 3987(ViewGroup.java:3987) at android.view.ViewGroup.dispatchDetachedFromWindow + 3987(ViewGroup.java:3987) at android.view.ViewGroup.dispatchDetachedFromWindow + 3987(ViewGroup.java:3987) at android.view.ViewGroup.dispatchDetachedFromWindow + 3987(ViewGroup.java:3987) at android.view.ViewGroup.dispatchDetachedFromWindow + 3987(ViewGroup.java:3987) at android.view.ViewGroup.dispatchDetachedFromWindow + 3987(ViewGroup.java:3987) at android.view.ViewGroup.removeViewInternal + 5588(ViewGroup.java:5588) at android.view.ViewGroup.removeViewInternal + 5559(ViewGroup.java:5559) at android.view.ViewGroup.removeView + 5490(ViewGroup.java:5490) at androidx.fragment.app.FragmentManagerImpl.moveToState + 1550(FragmentManager.java:1550) at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState + 1784(FragmentManager.java:1784) at androidx.fragment.app.FragmentManagerImpl.moveToState + 1852(FragmentManager.java:1852) at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange + 3269(FragmentManager.java:3269) at androidx.fragment.app.FragmentManagerImpl.dispatchDestroy + 3260(FragmentManager.java:3260) at androidx.fragment.app.FragmentController.dispatchDestroy + 274(FragmentController.java:274) at androidx.fragment.app.FragmentActivity.onDestroy + 419(FragmentActivity.java:419) at androidx.appcompat.app.AppCompatActivity.onDestroy + 210(AppCompatActivity.java:210) at android.app.Activity.performDestroy + 7681(Activity.java:7681) at android.app.Instrumentation.callActivityOnDestroy + 1306(Instrumentation.java:1306) at android.app.ActivityThread.performDestroyActivity + 4687(ActivityThread.java:4687) at android.app.ActivityThread.handleDestroyActivity + 4725(ActivityThread.java:4725) at android.app.servertransaction.DestroyActivityItem.execute + 39(DestroyActivityItem.java:39) at android.app.servertransaction.TransactionExecutor.executeLifecycleState + 145(TransactionExecutor.java:145) at android.app.servertransaction.TransactionExecutor.execute + 70(TransactionExecutor.java:70) at android.app.ActivityThread$H.handleMessage + 1947(ActivityThread.java:1947) at android.os.Handler.dispatchMessage + 106(Handler.java:106) at android.os.Looper.loop + 214(Looper.java:214) at android.app.ActivityThread.main + 7032(ActivityThread.java:7032) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run + 494(RuntimeInit.java:494) at com.android.internal.os.ZygoteInit.main + 965(ZygoteInit.java:965)

0. Crashed: main

   at android.app.ActivityThread.performDestroyActivity + 4702(ActivityThread.java:4702)
   at android.app.ActivityThread.handleDestroyActivity + 4725(ActivityThread.java:4725)
   at android.app.servertransaction.DestroyActivityItem.execute + 39(DestroyActivityItem.java:39)
   at android.app.servertransaction.TransactionExecutor.executeLifecycleState + 145(TransactionExecutor.java:145)
   at android.app.servertransaction.TransactionExecutor.execute + 70(TransactionExecutor.java:70)
   at android.app.ActivityThread$H.handleMessage + 1947(ActivityThread.java:1947)
   at android.os.Handler.dispatchMessage + 106(Handler.java:106)
   at android.os.Looper.loop + 214(Looper.java:214)
   at android.app.ActivityThread.main + 7032(ActivityThread.java:7032)
   at java.lang.reflect.Method.invoke(Method.java)
   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run + 494(RuntimeInit.java:494)
   at com.android.internal.os.ZygoteInit.main + 965(ZygoteInit.java:965)
OhJeongGyu commented 5 years ago

Hello. Can I update items dynamically?

I added this view in scrollable and updatable view (swiperefreshlayout)

I want to make adding new data to this view when pulling down.

I added new data like below, and after adding new data, the crash appears.

sliderView.create(SliderAdapter(banners, object: OnItemClickListener { ... }

tamtom commented 5 years ago

@OhJeongGyu do recreate the pluto view you need to add the data to your adapter, not plutoView