美文网首页Android开发成长
Android Weekly Notes #407

Android Weekly Notes #407

作者: 圣骑士wind | 来源:发表于2020-03-30 14:21 被阅读0次

Android Weekly Issue #407

Unboxing Koin 2.1

Koin的新改进.

App size reduction at Microsoft SwiftKey

安装包体积减小. 来自微软的SwiftKey team.

BackPress handling in Android Fragments, The old and the new!

新的方式:

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    activity?.onBackPressedDispatcher?.addCallback(this, object : OnBackPressedCallback(true) {
        override fun handleOnBackPressed() {
            // in here you can do logic when backPress is clicked
        }
    })
}

Context free Android navigation

将导航代码抽离出来.

思想:

Use ActivityLifecycleCallbacks or FragmentLifecycleCallback to prevent activities and fragments poisoning all your business logic code.

Retrofit cancelling multiple API calls

应用场景: 搜索, 一遍输入一边发起搜索请求, 需要取消之前的请求.

demo api: https://demo.dataverse.org/

没啥特殊的就是保存了个job然后cancel.

Fast Lane to Coroutines

协程的一些基础的东西.

Introducing the Activity Result APIs

新的Activity Results API.

private val takePicture = prepareCall(ActivityResultContracts.TakePicture()) { bitmap: Bitmap? ->
    // Do something with the Bitmap, if present
}

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    button.setOnClickListener { takePicture() }
}

A cautionary tale on Android: do not call System.exit()

不要用System.exit(n) or in Kotlin exitProcess(n).

要杀死所有的activity可以用finishAffinity().

Android GitHub Actions Setup

用GitHub Action做CI.

Android Components Architecture in a Modular World

一个程序例子: https://github.com/VMadalin/kotlin-sample-app

多模块程序构架.

有一些很棒的资源合辑链接.

Code

漫威英雄sample: https://github.com/skydoves/MarvelHeroes
MVVM (ViewModel, Coroutines, LiveData, Room, Repository, Koin) architecture.

News

Introducing dual-screen layouts for Android

微软的双屏.

Video

Assembling your Jetpack

  • What is Jetpack? -> 加速, 减少代码, 更稳健.
  • Jetpack categories -> Foundation, Architecture, Behavior, UI.
  • AndroidX migration.
  • Sunflower app.
    后面就讲述代码具体了.

相关文章

网友评论

    本文标题:Android Weekly Notes #407

    本文链接:https://www.haomeiwen.com/subject/kskvuhtx.html