Code Monkey home page Code Monkey logo

Comments (6)

nitrico avatar nitrico commented on August 10, 2024

Hi @LissF, thanks for reporting the problem. I'll try to reproduce it to see where the problem is.

According to the log, it seems like you are using an ObservableList and you are modifying it when you are in that other activity, is it right?

Meanwhile, can you please tell me if that happens also in version 1.1.1?

from lastadapter.

LissF avatar LissF commented on August 10, 2024

@nitrico, I've updated LastAdapter to 1.2.1. I've also made a lot of development/fixes in my project and I'm not able to reproduce the issue anymore.

I don't think I was changing my ObservableArrayList from another activity. But maybe I change some fields of items of that list in really indirect way. It could be the issue, right? I'll try to fix that behavior. Sorry, I'm new with databinding :)

from lastadapter.

nitrico avatar nitrico commented on August 10, 2024

It should be OK to change the items or their fields at any time, just asked to try to reproduce the situation where it happened.

I close the issue as it looks like is not happening anymore but feel free to reopen if it happens again or you have any other question. Thank you.

from lastadapter.

LissF avatar LissF commented on August 10, 2024

Hello again :)

Got same issue on switching tabs. I have 4 tabs, so fragments got recreated on switch between 1 and 4. This issue happens not all the time but I'm able to reproduce it if I switch between tabs some time. It looks like databinding holds old callback. Is it possible? Maybe I have to add some code to "onDestroyView()" to clear that CallbackRegistry?

java.lang.IllegalStateException: reference.get() must not be null
    at com.github.nitrico.lastadapter.WeakReferenceOnListChangedCallback.getAdapter(WeakReferenceOnListChangedCallback.kt:30)
    at com.github.nitrico.lastadapter.WeakReferenceOnListChangedCallback.onItemRangeRemoved(WeakReferenceOnListChangedCallback.kt:44)
    at android.databinding.ListChangeRegistry$1.onNotifyCallback(ListChangeRegistry.java:54)
    at android.databinding.ListChangeRegistry$1.onNotifyCallback(ListChangeRegistry.java:38)
    at android.databinding.CallbackRegistry.notifyCallbacks(CallbackRegistry.java:201)
    at android.databinding.CallbackRegistry.notifyFirst64(CallbackRegistry.java:122)
    at android.databinding.CallbackRegistry.notifyRemainder(CallbackRegistry.java:169)
    at android.databinding.CallbackRegistry.notifyRecurse(CallbackRegistry.java:145)
    at android.databinding.CallbackRegistry.notifyCallbacks(CallbackRegistry.java:91)
    at android.databinding.ListChangeRegistry.notifyCallbacks(ListChangeRegistry.java:135)
    at android.databinding.ListChangeRegistry.notifyRemoved(ListChangeRegistry.java:118)
    at android.databinding.ObservableArrayList.notifyRemove(ObservableArrayList.java:124)
    at android.databinding.ObservableArrayList.clear(ObservableArrayList.java:79)
    at my.package.view.MyFragment.onActivityCreated(MyFragment.java:90)
    at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:2083)
    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1129)
    at android.support.v4.app.FragmentManagerImpl.attachFragment(FragmentManager.java:1464)
    at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:748)
    at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:1632)
    at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:637)
    at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:143)
    at android.support.v4.view.ViewPager.populate(ViewPager.java:1237)
    at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:668)
    at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:630)
    at android.support.v4.view.ViewPager.setCurrentItem(ViewPager.java:611)
    at android.support.design.widget.TabLayout$ViewPagerOnTabSelectedListener.onTabSelected(TabLayout.java:2156)
    at android.support.design.widget.TabLayout.dispatchTabSelected(TabLayout.java:1138)
    at android.support.design.widget.TabLayout.selectTab(TabLayout.java:1132)
    at android.support.design.widget.TabLayout.selectTab(TabLayout.java:1105)
    at android.support.design.widget.TabLayout$Tab.select(TabLayout.java:1396)
    at android.support.design.widget.TabLayout$TabView.performClick(TabLayout.java:1501)
    at android.view.View$PerformClick.run(View.java:19881)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5294)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)
    at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:102)

from lastadapter.

LissF avatar LissF commented on August 10, 2024

OK, it looks like I've fixed it by recreating my ObservableArrayList. Previously I held it in final field and created only once. Now I recreate my ObservableArrayList in "onActivityCreated()" and crash is gone.

from lastadapter.

nitrico avatar nitrico commented on August 10, 2024

I found a very similar problem myself. It is "fixed" in version 1.2.2.

And I say "fixed" because this exception won't be thrown anymore (in this new version at least), but I'm not sure if I did the right thing as I think the exception is more related to the way the ObservableList is manipulated and the RecyclerView being attached and detached than the library itself.

If I discover the exact reason and is it is what I mentioned, future versions could throw this exception again as it can help to handle the ObservableList and/or RecyclerView in a more proper way.

from lastadapter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.