Using Kotlin Jetpack in Production

Kotlin语言概念介绍和实际移动开发现状

展开查看详情

1.Using Kotlin Jetpack in Production ——朱涛

2.从⼀一个段⼦子讲起……

3.刚毕业,成为 Android ⼯工程师

4. 5 年年后 肚⼦子好饿,头发不不⻅见了了,早知道不不做 Android 开发了了……

5. Google 宣传的 Kotlin 和 Jetpack 学会 Kotlin Jetpack 肚⼦子好饿 我要打⼗十个

6. 实际情况可能是: 踩坑,读⽂文档,源码,填坑 肚⼦子好饿 我变秃了了 也变强了了

7. Android 存在的问题 编译慢 ⼚厂商兼容 系统版本兼容 屏幕适配 状态栏适配 Fragment 坑 Support 包 过渡动画兼容 AndroidX 包 运⾏行行时权限兼容 Notification 兼容

8.Android 近⼏几年年推出的新技术 MVP MVVM Kotlin Jetpack Coroutines Flutter React Native Architecture Component

9.Kotlin Jetpack MVVM Basic Syntax Function Type KTX Extension Higher-Order Function Data Binding Functional Programming Data Class Inline Function Lifecycle Sealed Class Inline Class Collections LiveData Delegation ViewModel Navigation Room Coroutines Paging launch Producer Continuation WorkManger async Channel Mutex CameraX Job Actor Flow View Binding Deferred suspendCancellableCoroutine suspend

10.

11.

12.那就学吧……

13. Coroutines Kotlin, as a language, provides only minimal low-level APIs in its standard library to enable various other libraries to utilize coroutines. Unlike many other languages with similar capabilities, async and await are not keywords in Kotlin and are not even part of its standard library. Moreover, Kotlin's concept of suspending function provides a safer and less error-prone abstraction for asynchronous operations than futures and promises. kotlinx.coroutines is a rich library for coroutines developed by JetBrains. It contains a number of high- level coroutine-enabled primitives that this guide covers, including launch, async and others.

14.坚持⼀一周,读完后……

15. Coroutines 是啥? 好像知道,轻量量级的线程?

16.Coroutines 咋⽤用? 好像不不太清楚

17.Coroutines 原理理是什什么? 不不知道

18.认知层次 What:是啥 How:咋⽤用 Why:原理理

19. ⽅方法⽐比努⼒力力重要 源码 实战 ⽂文档

20.从 Kotlin Jetpack 的 What 说起:

21.Kotlin Jetpack MVVM Basic Syntax Function Type KTX Extension Higher-Order Function Data Binding Functional Programming Data Class Inline Function Lifecycle Sealed Class Inline Class Collections LiveData Delegation ViewModel Navigation Room Coroutines Paging launch Producer Continuation WorkManger async Channel Mutex CameraX Job Actor Flow View Binding Deferred suspendCancellableCoroutine suspend

22.Kotlin 更更好⽤用的 Java。 What Coroutines 更更好⽤用的线程。 MVVM 更更适合 Jetpack 的架构。 Jetpack 帮助开发者提⾼高开发效率和稳定性的框架。 Data Binding 在 xml ⾥里里绑定 data 与 view Lifecycle 让普通类感知⽣生命周期 LiveData 感知⽣生命周期的观察者 ViewModel 为 Activity/Fragment 持有数据 Navigation ⽅方便便的 Fragment 跳转框架,适合单 Activity 架构 Room 更更⽅方便便的 SQLite

23. Lifecycle Room Coroutines MVVM Kotlin HowLiveData Navigation Data Binding Jetpack ViewModel

24.How Clean Architecture

25.Clean Architecture On Android View How LiveData ViewModel UseCase Repository Local Data Remote Data Source Source Entities

26. View How LiveData Presentation Layer ViewModel UseCase Domain Layer Repository Data Layer Local Data Remote Data Source Source Entities Entities

27. LiveD View UseCase Repository Remote Data Entities ViewModel Source One-Activity-Multiple-Fragments + Navigation <fragment android:id="@+id/nav_host_fragment" android:name="androidx.navigation.fragment.NavHostFragment" android:layout_width="match_parent" android:layout_height="match_parent" app:defaultNavHost="true" app:navGraph="@navigation/nav_graph" />

28. LiveD View UseCase Repository Remote Data Entities ViewModel Source Navigation 1. Preview Unavailable <fragment android:id="@+id/loginFragment" android:name="com.test.LoginFragment" android:label="LoginFragment"> </fragment>

29. LiveD View UseCase Repository Remote Data Entities ViewModel Source Navigation 1. Preview Unavailable <fragment android:id="@+id/loginFragment" android:name="com.test.LoginFragment" android:label="LoginFragment" tools:layout="@layout/layout_login"> </fragment>