Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic architecture with loading and error screens #80

Merged
merged 9 commits into from Apr 22, 2020

Conversation

manuelvicnt
Copy link
Contributor

@manuelvicnt manuelvicnt commented Apr 22, 2020

Basic architecture has been added to JetNews following the Guide to app architecture:

  • The repository layer is in charge of fetching/caching data. The repository performs these operations on a background thread. Because of the lack of coroutines support, the Executors + callback pattern is used (this will change when Compose fully supports coroutines).
  • No ViewModel layer as of today. Instead, an effect is used to asynchronously load data to display on the UI. This is the pattern to use for now. ViewModel support will come in the future and therefore, this will be revisited. refreshableUiStateFrom and uiStateFrom are the go-to classes to see how effects are implemented and how the connection between UI - Repository layer happens.

Given the possibilities a more realistic app architecture provide:

  • A new loading screen is added when the information is fetched for the first time.
  • Swipe to refresh is implemented in the home screen to allow refreshing the latest articles (disclaimer: the same response is always returned from the repo).
  • A Snackbar error is displayed on the home screen when the repository failed fetching new data.

New screens:

Loading screen
loading

Error
error

Pull to refresh
pull to refresh

chrisbanes and others added 9 commits April 16, 2020 13:17
* Bump to AGP 4.1.0-alpha05

Also made gradlew executable (not sure why it wasn't).

* Update JetNews to dev09

- Move to new ContentScale API
- Import functions for using state as a delegate

* Fix test activity

Compose now requires to be run in a ComponentActivity
Error and loading screens will come in future PRs.

Change-Id: Id92d3a334c6953d61b342d852a08893bb7cc300d
Change-Id: Ic8f7a6bb5643bd01c0cb5124d3dd6f2bc9b5b912
Change-Id: Id50630adbfeec9d1ee41087fef66c453f96196d7
Change-Id: Ib84d4250420e64575502ad454818d46a796ab107
Change-Id: Ide5958e050d237b2e15843cf37ea47084ff1b250
Change-Id: I02d4feb28dde34443c1c2734c60787f265d99f45
Change-Id: I89aaa57ea888753c12f5fabe226129e4a6963e43
Add basic architecture with loading and error screens
Copy link
Contributor

@chrisbanes chrisbanes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants