Kotlin Coroutines 1.2.0 introduces cold stream called Flow. It makes easy to cooperate UI and ViewModel (or some your logic).
Create an extension function to treat LiveData as Flow. Flow has the builder like
flowViaChannel. To observe LiveData value change and emit it, we should use
flowViaChannel builder, because
flow has only suspend function to emit value then we can’t call it in
This is nothing special. Bounding two LiveData to texts of two EditText using Two-way Data Binding.
In this article, we’ll implement the incremental GitHub repository search with two EditText. One is inputted the…
Kotlin Coroutine is the very easy and high-efficiency async processing mechanism. But, less understanding coroutine scope will cause unintended crashes of your app.
We have to understand below essential specification.
launch) don’t create scope
withContext) create scope
If we don’t understand the above specification and Exception Propagation, thrown Exception may through try-catch and crash your application.
This example may seem no problem to handle the exception, but this code will crash caused by
Because of the specification…
This article shows how can we know user decision on intent chooser you created.
If you want know which app was selected by user when showing intent chooser, you should implement the chooser with
IntentSender that will callback the user selection.
IntentSender is created from
PendingIntent. It means you can/should launch
BroadcastReceiver instead of your
Activity to prevent interrupting the user operation on the selected app.
Service can extract
Intent. You can get class name or package name from it.
Google has published Paging Library as part of Android Architecture Components. It makes easier to handle pagination data and show it in RecyclerView.
This library include
PagedListAdapter to integrate
PagedList data with
RecyclerView. We can use this adapter in match the same way as normal
But now, we have excellent libraries to show easily complex items like Groupie.
We’ve to use GroupAdapter to show items in RecyclerView using Groupie. How can we use Paging Library with GroupAdapter?
To understand how PagedListAdapter treat PagedList, let’s see the implementation briefly.
PagedListAdapter should be passed
submitList method. …
Using SharedPreferences needs some little boilerplate code. And if we store much more data or include/exclude specific data from auto backup, we should consider to split XML file.
Kotpref is the library to make you realizing it simply and ease.
To install, just add app dependency in build.gradle.
Kotpref.init(context) function in
onCreate at Application class.
Kotpref requires defining data model to save into SharedPreferences. Data model can be created by extending `KotprefModel` like below.
You can now write and read by same way with normal property access!!
Saved SharedPreferences XML through Kotpref is separated…