Coder Social home page Coder Social logo

Comments (5)

renyuneyun avatar renyuneyun commented on August 23, 2024

Wow, seems I need to look into unpredictable human behaviors :P

Thanks for letting me know. It's due to the fact that I didn't explicitly save the state of every UI component, so when you rotate the screen they will be lost (because UI will be redrawn/reloaded).

I'll fix that in the near future, hopefully this week.

from easer.

trikaphundo avatar trikaphundo commented on August 23, 2024

Hahaha, rotating the screen is a good test to see whether an app is robust before configuration changes, a phone call while the activity is showing is pretty unlikely but possible, as other changes :)

Activities manage added fragments and their state, to a certain extent.
I have cloned your project, the problem is that EVERY TIME the main activity is created (onCreate(Bundle)), all fragments are removed and the "FRAGMENT_OUTLINE" is added to the activity. This can be solved by simply checking whether the app was abnormally terminated by the system: (if(savedInstanceState == null)...)

from easer.

renyuneyun avatar renyuneyun commented on August 23, 2024

Hmm, I didn't read those materials talking about how states are preserved / need to be preserved (though I know they can and need to be preserved). That's another reason why I didn't add that part in the code in the first place.

Thanks for your pointing out.
Are there any general rules / behaviors about what states will be preserved by runtime / Android and what states need to be explicitly saved by developers? Then I can give a quick check over other components.

from easer.

trikaphundo avatar trikaphundo commented on August 23, 2024

I recommend reading the Android documentation; as a starting point activity life-cycle
Essentially it says that the Android system will save and restore most of the state of the view hierarchy.

Fragments added to an activity are stored as part of the activity state by the android system. Also, their life-cycle is closely tied to the host activity's life-cycle and their handling is very similar to that of the activities

from easer.

renyuneyun avatar renyuneyun commented on August 23, 2024

Closed as of patch #11 (which is squashed to commit 9e9f051).

Thanks for you work and recommendation :)

from easer.

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.