Lock in $30 Savings on PRO—Offer Ends Soon! ⏳

What's new in Android Architecture Components (...

What's new in Android Architecture Components (Korean)

Sa-ryong Kang

June 21, 2019
Tweet

More Decks by Sa-ryong Kang

Other Decks in Programming

Transcript

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

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

    ViewModel • WorkManager • Room • Paging • Navigation ݾର
  3. • Annotation Processing ࢿמ ೱ࢚: 20% • ࠙࢑ ஹ౵ੌ நद

    ૑ਗ • Incremental Annotation Processing੄ ࣻഌ੗ • Android Studio৬੄ োز ъച • XML ղਊ੄ ૊द ߈৔ • XMLীࢲ UIਃࣗܳ ୶оೞݶ, ஹ౵ੌ হ੉ب ೙٘о ୶оؽ • ܻಂష݂ ӝמ੉ XMLীب ੸ਊ Data Binding (3.5~)
  4. 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) } }
  5. 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; } ~~~~~~~~~~~~~~~
  6. 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>
  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) 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>
  8. • DataBinding ࢎਊ੄ о੢ ௾ ೲٜ੉ ݽف ઁѢ (ই݃ب..) •

    ؀۝੄ ߡӒب ೣԋ ࣗѐؼ оמࢿ ֪റ.. • ࠁ׮ ViewModel ׮਍ ViewModelਸ ݅٘ח ؘী ݆਷ ب਑੉ ؼ ٠ Implication
  9. • DataBindingҗ੄ ഐജࢿ • XML ਃࣗ੄ ੽Ӕ݅ਸ ࢎਊೞҊ र׮ݶ, औѱ

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

    Gradle Pluginী ੄೧ ௿ېझܳ ࢤࢿೞҊ ੉ח Android Studioীࢲ ಞ૘ ઺ী ੌয ա޲۽.. • Compile time safety / Build speed নଃীࢲ ੉ٙ • Data Bindingب э਷ ݒழפ્੄ ࣻഌܳ যו ੿ب ߉ਸ ٠ Implication
  11. 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) } }
  12. 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) } }
  13. 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" }) } }
  14. 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
  15. 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 } } } }
  16. 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") }
  17. 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)) } }
  18. • ই૒ ߓ Ҋ೐׮.. • ࢜۽ द੘ೞח ೐۽ં౟ or ѐੋ/ࣗӏݽ

    ઑ૒ীח ݫܻ౟о ੓ѷਵա.. • ӝઓ ҳഅਸ ыҊ ੓ח ҃਋, AAC ViewModel۽ ৤ѹఋঠೡ ഛҊೠ ݫܻ౟ח ই ૒ হח ٠ Implication
  19. • 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
  20. • On-demand Initialization (2.1.0) • App ௿ېझী ജ҃ ࢸ੿ ҙ۲

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

    Test Support in alpha (2.1.0): 
 TestWorkerBuilder, TestListenableWorkerBuilder • Foreground Support! • Job Scheduler۽ 10࠙ ૞ܻ স۽٘ө૑ ೡ ࣻ ੓૑݅, ӒѪࠁ׮ ӡ׮ݶ? • োղ ୹द ৘੿ Work Manager
  22. • Coroutine ૑ਗ: Cancelableೠ ௏٘ ࢤࢿ оמ • Transactionب naturalೞѱ

    ҳഅ оמ • Full-text Search • SQLite ഛ੢ӝמ Room 2.1
  23. • ӒܻҊ ખ ؊ ٍীח.. • Incremental Annotation Processing ૑ਗ

    • Many-to-many Relation ૑ਗ • ݃੉Ӓۨ੉࣌ਸ ࠁ׮ औѱ.. • Coroutines Channel/Flow ૑ਗ Room
  24. • Before • RecyclerViewী ܻझ౟ܳ lazy load ೧઱ח ۄ੉࠳۞ܻ, but..

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

    to Navigation Graphs • Navigation by URI • Dialog • Future • Dynamic Delivery ૑ਗ Navigation
  26. • ☀ • 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)