What's new in Android Architecture Components (Korean)

What's new in Android Architecture Components (Korean)

1ff3242c5f6acd42dcccecdbef78961f?s=128

Sa-ryong Kang

June 21, 2019
Tweet

Transcript

  1. What’s new in
 Architecture Components I/0 ’19 Extended Pangyo Sa-ryong

    Kang
  2. Who is this guy? • ҃۱ 19֙ର SW ূ૑פয •

    ತস ੹ޙо: ޷Ҵীࢲ ೠ ߣ, ೠҴীࢲ ف ߣ झఋ౟স ହস ҃೷ • IBM iX Japanীࢲ Android/iOS ׸׼ Senior Specialist۽ Ӕޖ ઺ • YouTubeীࢲ ݅աਃ! • Droid Knights 2018 - ղо উ٘۽੉٘ ূ૑פযо غ঻ਸ ٸ ইޖب ঌ۰઱ ૑ ঋ਷ Ѫٜ • Droid Nights 2019 - Android Architecture ୨੿ܻ
  3. • Data Binding • View Binding • Life Cycle +

    ViewModel • WorkManager • Room • Paging • Navigation ݾର
  4. Data Binding

  5. • Annotation Processing ࢿמ ೱ࢚: 20% • ࠙࢑ ஹ౵ੌ நद

    ૑ਗ • Incremental Annotation Processing੄ ࣻഌ੗ • Android Studio৬੄ োز ъച • XML ղਊ੄ ૊द ߈৔ • XMLীࢲ UIਃࣗܳ ୶оೞݶ, ஹ౵ੌ হ੉ب ೙٘о ୶оؽ • ܻಂష݂ ӝמ੉ XMLীب ੸ਊ Data Binding (3.5~)
  6. • ஹ౵ੌ ী۞ ಴द ѐࢶ • 1000ѐ੄ ী۞ݫद૑ ਬഋ ୶о

    Data Binding (3.5~)
  7. Data Binding (3.5~) class MainActivity : AppCompatActivity() { private val

    binding by lazy { ActivityMainBinding.inflate(layoutInflater) } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(binding.root) } }
  8. Data Binding (3.5~) class MainActivity : AppCompatActivity() { private val

    binding by lazy { ActivityMainBinding.inflate(layoutInflater) } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(binding.root) } } public abstract class ActivityMainBinding extends ViewDataBinding { @NonNull public final TextView textView; protected ActivityMainBinding(Object _bindingComponent, View _root, int _localFieldCount, TextView textView) { super(_bindingComponent, _root, _localFieldCount); this.textView = textView; } ~~~~~~~~~~~~~~~
  9. Data Binding (3.5~) class MainActivity : AppCompatActivity() { private val

    binding by lazy { ActivityMainBinding.inflate(layoutInflater) } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(binding.root) } } <?xml version="1.0" encoding="utf-8"?> <layout> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent"/> </androidx.constraintlayout.widget.ConstraintLayout> </layout>
  10. Data Binding (3.5~) class MainActivity : AppCompatActivity() { private val

    binding by lazy { ActivityMainBinding.inflate(layoutInflater) } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(binding.root) binding.textView } } <?xml version="1.0" encoding="utf-8"?> <layout> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent"/> </androidx.constraintlayout.widget.ConstraintLayout> </layout>
  11. • DataBinding ࢎਊ੄ о੢ ௾ ೲٜ੉ ݽف ઁѢ (ই݃ب..) •

    ؀۝੄ ߡӒب ೣԋ ࣗѐؼ оמࢿ ֪റ.. • ࠁ׮ ViewModel ׮਍ ViewModelਸ ݅٘ח ؘী ݆਷ ب਑੉ ؼ ٠ Implication
  12. View Binding

  13. View Binding (3.6~)

  14. View Binding (3.6~)

  15. View Binding (3.6~)

  16. • DataBindingҗ੄ ഐജࢿ • XML ਃࣗ੄ ੽Ӕ݅ਸ ࢎਊೞҊ र׮ݶ, औѱ

    ViewBindingਵ۽ тইఎ ࣻ ੓਺ • <layout></layout> కӒ݅ ઁѢೞݶ ؽ • ࢎਊߨب, ޙߨب ৮੹ زੌ • ߈؀۽, ୊਺ بੑೠ׮ݶ XML਷ ইޖ Ѫب ࣻ੿ೡ ೙ਃ হ੉ Data Bindingҗ ڙ э਷ ࢶ঱ ف ઴۽ ࢎਊ оמ • Kotlin Extensionী ؀ೠ ೤ܻ੸ ؀উ View Binding (3.6~)
  17. • Kotlin Synthetic Extension, Butter Knifeী ؀ೠ ೤ܻ੸ ؀উ •

    Gradle Pluginী ੄೧ ௿ېझܳ ࢤࢿೞҊ ੉ח Android Studioীࢲ ಞ૘ ઺ী ੌয ա޲۽.. • Compile time safety / Build speed নଃীࢲ ੉ٙ • Data Bindingب э਷ ݒழפ્੄ ࣻഌܳ যו ੿ب ߉ਸ ٠ Implication
  18. Life Cycle + ViewModel

  19. View Model class MainViewModel : ViewModel() { val counter =

    MutableLiveData(0) } class MainActivity : AppCompatActivity() { private val binding by lazy { ActivityMainBinding.inflate(layoutInflater) } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(binding.root) } }
  20. View Model class MainViewModel : ViewModel() { val counter =

    MutableLiveData(0) } class MainActivity : AppCompatActivity() { private val binding by lazy { ActivityMainBinding.inflate(layoutInflater) } private val viewModel by viewModels<MainViewModel>() { } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(binding.root) } }
  21. View Model class MainViewModel : ViewModel() { val counter =

    MutableLiveData(0) } class MainActivity : AppCompatActivity() { private val binding by lazy { ActivityMainBinding.inflate(layoutInflater) } private val viewModel by viewModels<MainViewModel>() { } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(binding.root) viewModel.counter .observe(this, Observer { binding.textView.text = "count = $it" }) } }
  22. View Model class MainViewModel : ViewModel() { val counter =

    MutableLiveData(0) } class MainActivity : AppCompatActivity() { private val binding by lazy { ActivityMainBinding.inflate(layoutInflater) } private val viewModel by viewModels<MainViewModel>() { } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(binding.root) viewModel.counter .observe(this) { binding.textView.text = "count = $it" } } } lifecycle-livedata-core-ktx lifecycle-livedata-core-ktx
  23. View Model class MainViewModel : ViewModel() { val counter =

    MutableLiveData(0) } class MainActivity : AppCompatActivity() { private val binding by lazy { ActivityMainBinding.inflate(layoutInflater) } private val viewModel by viewModels<MainViewModel>() { } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(binding.root) viewModel.counter .observe(this) { binding.textView.text = "count = $it" } binding.countButton.setOnClickListener { viewModel.counter.apply { value = value?.plus(1) ?: 1 } } } }
  24. View Model override fun onSaveInstanceState(outState: Bundle) { super.onSaveInstanceState(outState) viewModel.counter.value?.also {

    outState.putInt("counter", it) } } override fun onRestoreInstanceState(savedInstanceState: Bundle?) { super.onRestoreInstanceState(savedInstanceState) savedInstanceState ?: return viewModel.counter.value = savedInstanceState.getInt("counter") }
  25. View Model class MainViewModel( handle: SavedStateHandle ) : ViewModel() {

    val counter: MutableLiveData<Int> = handle.getLiveData("counter") } class MainActivity : AppCompatActivity() { private val binding by lazy { ActivityMainBinding.inflate(layoutInflater) } private val viewModel by viewModels<MainViewModel> { SavedStateVMFactory(this, bundleOf("counter” to 0)) } }
  26. • ই૒ ߓ Ҋ೐׮.. • ࢜۽ द੘ೞח ೐۽ં౟ or ѐੋ/ࣗӏݽ

    ઑ૒ীח ݫܻ౟о ੓ѷਵա.. • ӝઓ ҳഅਸ ыҊ ੓ח ҃਋, AAC ViewModel۽ ৤ѹఋঠೡ ഛҊೠ ݫܻ౟ח ই ૒ হח ٠ Implication
  27. WorkManager

  28. • What is it? • Background processing that is deferrable,

    persistent, constraint-based and backward compatible. • 1.0੉ 3ਘ 1ੌ ୹द ع਺.. which means.. ೡ݆ঋ • 2.0ب زद ୹द ع਺.. WTF? Work Manager
  29. • On-demand Initialization (2.1.0) • App ௿ېझী ജ҃ ࢸ੿ ҙ۲

    ղਊਸ ҳഅ • ੋझఢझ ஂٙ दী contextܳ ֈѹ.. ೙ਃೡ ٸী ੋझఢझо ࢤࢿ ؽ • Google Play Service৬੄ ా೤ (ழ߁.. २ & optional) - ҳഋ ױ݈ীࢲ੄ ࢿמ ೱ࢚ • ഐജࢿ ѐࢶ (ongoing) • ӝӝী ٮܲ ز੘੄ ର੉: ࢎਊ੗о ૒੽ জਸ ઙܐೞݶ.. • Pixel → ೐۽ࣁझ ઙܐ. যڃ ױ݈ٜ → force stop (job੉ ࢎۄઉߡܿ-0-; FCMب..;;;) Work Manager
  30. • Test Support • Robolectric Support (Available now!) • Unit

    Test Support in alpha (2.1.0): 
 TestWorkerBuilder, TestListenableWorkerBuilder • Foreground Support! • Job Scheduler۽ 10࠙ ૞ܻ স۽٘ө૑ ೡ ࣻ ੓૑݅, ӒѪࠁ׮ ӡ׮ݶ? • োղ ୹द ৘੿ Work Manager
  31. Room

  32. • Coroutine ૑ਗ: Cancelableೠ ௏٘ ࢤࢿ оמ • Transactionب naturalೞѱ

    ҳഅ оמ • Full-text Search • SQLite ഛ੢ӝמ Room 2.1
  33. • RxJava ૑ਗ! • Ӕؘ Flowable੉ غח૑ח ࠛݺഛ • View

    ࢤࢿ оמ Room 2.1
  34. • ӒܻҊ ખ ؊ ٍীח.. • Incremental Annotation Processing ૑ਗ

    • Many-to-many Relation ૑ਗ • ݃੉Ӓۨ੉࣌ਸ ࠁ׮ औѱ.. • Coroutines Channel/Flow ૑ਗ Room
  35. Etc. : Paging & Navigation

  36. • Before • RecyclerViewী ܻझ౟ܳ lazy load ೧઱ח ۄ੉࠳۞ܻ, but..

    • Room, Realm, Retrofit ૑ਗ • Soon in EAP, alpha this summer • Built in network ૑ਗ with ী۞ ೩ٜ݂ • ೻؊ / footer ૑ਗ • RxJava / Coroutines ా೤ ъച! Paging
  37. • 3/19 1.0, 2.0 ୹द • 2.1 • ViewModels scoped

    to Navigation Graphs • Navigation by URI • Dialog • Future • Dynamic Delivery ૑ਗ Navigation
  38. Conclusion

  39. • ☀ • MVVM with Data Binding • Coroutine •

    Redux-like architecture for Jetpack Compose • Many companies have already adopt it, such as Netflix • ⛈ • Schedule for other libraries can be postponed, because of tough competition between Swift UI and Jetpack Compose. • Already happened last year: Some of promise in 2018 were not yet kept, because of AS 3.4/3.5 and R8 Forecast (in my personal opinion)
  40. Thank you very much!