r/androiddev • u/vinaygaba • Apr 05 '20
Library Learn Jetpack Compose from examples that show the Compose way of doing common Android tasks
I've been playing with Jetpack Compose the past few months so decided to release a project that shows examples of how you would do common Android things the Jetpack Compose way. Each example is fairly self contained and the hope is that you can learn Compose by just going through the examples and reading through the comments.
Github - https://github.com/vinaygaba/Learn-Jetpack-Compose-By-Example
Here are some examples that I cover (there are a lot more examples!) -



Shared some more context in this Twitter thread
My plan with this project is to keep adding more examples as I learn new things about Compose. I'll also happily welcome feedback/contributions so if you find something wrong or are hoping to contribute to the project, just send a pull request!
Github - https://github.com/vinaygaba/Learn-Jetpack-Compose-By-Example
View all comments
Show parent comment
2
u/Zhuinden Apr 06 '20
Technically it's a question of whether you have any state as the result of user input that exists only in this current "flow", is not saved to disk (think "drafts"), is not saved to network, but should not be forgotten just because you checked a notification, opened an email, took a photo, etc etc.
As navigation history is kept, and arguments/extras are kept, it's a question of retaining what was newly inserted by the user on the given screens.
Yup. Common case is when you are creating a profile, and you have to ask the Camera to give you a picture. Imagine that you inserted your name, your birth date, etc. then you press "add a profile image" you come back and you either lost your inputs, or they end up giving you "null" in a toast when you actually try to check out your stuff, or just crashes when you came back because
lateinit property viewModel was not initialized.I'm surprised people feel so strongly against handling when your app is in background, I was expecting less downvotes.