Android : Good to know, Part-1

Anubhav
1 min readMay 12, 2021
Photo by Waldemar Brandt on Unsplash

This will be a series, where I will be posting good to know tidbits in the world of Android Development and Kotlin.

Thread.sleep(x) v/s Coroutine’s delay(x)

Thread.sleep(x) causes the current thread to suspend execution for a specified period, where as delay(x) only suspends a specific couroutines running on a thread, p.s: there can be multiple couroutines running on a single thread, and hence the rest of the couroutines will continue with their execution.

On which thread does DiffUtil.ItemCallBack<T> work ?

Diffs are calculated on a background thread and the adapter is notified with the results on the main thread.

ListAdapter in two words :D

RecycleView + DiffUtil

What is IdRes ?

Denotes that an integer parameter, field or method return value is expected to be an id resource reference.

eg: @IdRes val layoutId: Int

How to disable ViewBinding file generation for a specific layout file ?

<androidx.constraintlayout.widget.ConstraintLayout
...
tools:viewBindingIgnore="true">

//your layout views go here
</androidx.constraintlayout.widget.ConstraintLayout>

--

--