Posts

Showing posts from December, 2018

Databinding in RecyclerView - Android - Kotlin

Image
Hey Guyss!! Already we have seen the basics of Databinding and how to use it in previous  post . Now let's see how to use Databinding in RecyclerView . And Its gonna be a short post. ;) You can find the Project in GitHub . Prerequisite: build.gradle First, we have enable dataBinding in app-level build.gradle                           android {                                     dataBinding {                                             enabled = true                                     }                            } Next, we hav...

Android JetPack - Scheduling Tasks with WorkManager

Image
Introduction: WorkManager is one of the Android JetPack component. It is specifically designed for scheduling and managing background tasks. If the app is running, task will be executed in a new thread. Otherwise, WorkManager automatically chooses an appropriate way to do so. It can be AlarmManager, JobScheduler or Firebase JobDispatcher, depends on device's API level and its dependencies. WorkManager Basics: Worker WorkRequest WorkManager WorkInfo (i) Worker: It specifies what task need to be performed. class SampleWorker (context: Context, workerParams: WorkerParameters) : Worker(context, workerParams) { override fun doWork (): ListenableWorker. Result { //do the work here return ListenableWorker. Result . SUCCESS } } (ii) WorkRequest: It represents which Worker should perform the task. Also we can specify any constraints/circumstances, based on which the task should be performed. Constraints can be of Net...