Coder Social home page Coder Social logo

Comments (9)

maxtroy avatar maxtroy commented on May 16, 2024 1

Hi.

Fine-grained events are not available because Repositories themselves don't have fine-grained events. To fire such events, either the RepositoryPresenter (client code) will be responsible for the job -- which makes it very difficult to implement, or RepositoryAdapter needs to magically discover the right sequence of events to notify the RecyclerView, which requires RepositoryPresenters to provide more information; most probably the data items' stable IDs.

However, with one single "the world has changed" event, just the stable IDs can already enable smooth animation in RV. Let all RepositoryPresenters provide stable IDs (implement RepositoryPresenter.getItemId(...)), and then enable stable ID in the RepositoryAdapter. Some predictive animations will be "wrong" (items fading in and out rather than sliding in and out, because RV doesn't know where those newly-on-screen items come from), but items that have not changed will not "flash" (disappear and appear).

from agera.

LouisCAD avatar LouisCAD commented on May 16, 2024 1

@maxtroy Thanks for the stable IDs tip! It would be a good candidate for Agera's rvadapter documentation!

It does not completely solves the little performance hit though (but is good enough to be implemented if Agera use can improve code quality in the use case), so I'll let this issue open, if anyone have a solution to make fine grained RecyclerView Adapter notifications usable with Agera.

from agera.

maxtroy avatar maxtroy commented on May 16, 2024 1

It's a solution that enables client code to use DiffUtils easily. Client code doesn't need to actually use DiffUtils.

from agera.

maxtroy avatar maxtroy commented on May 16, 2024

I have a better plan for this issue. Stay tuned for Agera 1.5 (or 1.6) :)

from agera.

LouisCAD avatar LouisCAD commented on May 16, 2024

@maxtroy You plan to use DiffUtil, right?

from agera.

maxtroy avatar maxtroy commented on May 16, 2024

@LouisCAD please try out the new fine-grained event support and let us know what you think!

from agera.

LouisCAD avatar LouisCAD commented on May 16, 2024

@maxtroy How can I test it? Need to clone the repository? Is there an example in the sample?

from agera.

maxtroy avatar maxtroy commented on May 16, 2024

The sample isn't in the perfect shape to demo the fine-grained events right now. In particular there's no change and move events. It needs a bit of tweaking.

Meanwhile, you can try out by doing one of the following:

  • In your subclass(es) of RepositoryPresenter, override the new getUpdates() method to provide your own fine-grained events.
  • In your compiled RepositoryPresenter (RepositoryPresenters.repositoryPresenterOf(...)), or compiled data-binding RepositoryPresenter, add a .diffWith(...) directive to enable using DiffUtil to compute the fine-grained events.

You can now turn off stable IDs, if you like.

You can get the complete information in the documentation of RepositoryPresenter.getUpdates(), and the compilers' diffWith() and diff() directives.

from agera.

 avatar commented on May 16, 2024

This is now included in 1.4.0-alpha4

from agera.

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.