Giter Site home page Giter Site logo

Comments (5)

frankiesardo avatar frankiesardo commented on July 23, 2024

Icicle is the old name that the Android platform used for the saveInstanceState and outState parameters. The onSaveInstanceState() method itself used to be called onFreeze(). There's some nostalgia involved here, plus the whole idea of a frozen state is not that bad. Icicle is the frozen state and Icepick is the tool used to manipulate it!

from icepick.

stephanenicolas avatar stephanenicolas commented on July 23, 2024

I can understand this nostalgia, but still believe the API would be more elegant with a name closer to the lib's name.
:)

from icepick.

mttkay avatar mttkay commented on July 23, 2024

Hah, I actually just cooked up a library very similar to this one and for the same nostalgia planned on calling it Icicle, with the annotation name being @memoize. Found this one when googling for icicle to see if the name was taken.

Thing is, I still plan to proceed with my own library since it is actually more widely applicable, since it can retain class fields of arbitrary types and not just things one can stick in a bundle. I need that since I am preserving complex non serializable objects across configuration changes. It's meant to replace the deprecated onRetainNonConfigurationInstance.

I hope I'm not adding too much to the confusion!

from icepick.

frankiesardo avatar frankiesardo commented on July 23, 2024

I'm glad I'm not the only nostalgic in the room ๐Ÿ’ƒ
I use Icepick as a way to avoid repeating the same code over and over again, but it was never intended as something more than what Android provides.
I'm interested in seeing why you need to preserve such complex objects across life cycle.. component state is designed to be nimble and fast. Anyway, feel free to use the bits of code that you need for your end.

from icepick.

mttkay avatar mttkay commented on July 23, 2024

Cool!

To explain: it doesn't do any magic, and certainly nothing that would be against Android's component life-cycle. Google recommend that in order to replace onRetainNonConfigurationInstance, you move that state to fragments. Since there can, however, still be shared state across multiple fragments in a given activity, what my library does is create a data holder fragment for the host activity that is set to retain instance state.

After a call to onCreate, the activity can then rest assured that all annotated member fields will be initialized with whichever state was valid before, by pulling these fields out of the retained fragment (this is all transparent to the activity of course, there is no explicit interaction with the fragment).

A very good use case for this is retaining AsyncTask or any other concurrency objects across orientation changes, since you cannot stuff these into Bundles.

from icepick.

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.