Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ProTalk #1 | Android Architecture Component

ProTalk #1 | Android Architecture Component

Dalam Talks ini kita akan membahas design pattern dan arsitektur yang dapat membantu pengembangan aplikasi android yang digunakan di industry-grade android apps.

Proclub Telkom University

February 19, 2019
Tweet

More Decks by Proclub Telkom University

Other Decks in Programming

Transcript

  1. My activity is so big! Need to change UI? Where

    do i put the logic for this action? How to test this function? A new team member! A new wild bug appear!
  2. • Separation of Concern • Easier unit testing • Easier

    to manage big project • Make your code understandable • Avoid GOD activity
  3. • Model — the data layer. Responsible for handling the business logic

    and communication with the network and database layers. • View — the UI layer. Displays the data and notifies the Presenter about user actions. • Presenter — retrieves the data from the Model, applies the UI logic and manages the state of the View, decides what to display and reacts to user input notifications from the View.
  4. • Model: abstracts the data source. The ViewModel works with

    the DataModel to get and save the data. • View: that informs the ViewModel about the user’s actions • View Model: exposes streams of data relevant to the View • Recommended by Google
  5. Lets talk about the problem • State loss on orientation

    change. handling it with onSaveInstanceState() and onCreate() is tedious especially when the data is large
  6. LiveData is an observable data holder class. Unlike a regular

    observable, LiveData is lifecycle-aware, meaning it respects the lifecycle of other app components, such as activities, fragments, or services. This awareness ensures LiveData only updates app component observers that are in an active lifecycle state.
  7. Advantage of LiveData • Ensures your UI matches your data

    state • No memory leaks • No crashes due to stopped activities • No more manual lifecycle handling • Always up to date data • Proper configuration changes • Sharing resources
  8. Advantages • Single Activity for entire application • Graphical navigation

    flow editor • Shared ViewModel • Currently still beta
  9. MVI Model-View-Intent • Unidirectional data flow • Reactive • Take

    inspiration from JavaScript framework like React.js and Redux • Use functional principle • Used by Bukalapak but simplified Reference: http://hannesdorfmann.com/android/model-view-intent