Photo by Steve Johnson on Unsplash

While working in Java to represent a fixed set of constants, a classic choice was to use an enum. An enum type is a special data type that enables a variable to be a set of predefined constants. The variable must be equal to one of the values that have been predefined for it.

For instance, suits in the deck of a card (CLUB, DIAMOND, HEART, SPADE), the response of an API (SUCCESS, ERROR, LOADING), etc.

public enum Response {

Similarly, we can have enums in Kotlin as well,

enum class Response {

Photo by Nick Fewings on Unsplash

I am assuming you are aware of the RecyclerView and it’s implementation!

Almost every app that we use has some sort of a list, be it a vertical list or a horizontal list. RecyclerView was introduced as a successor to ListView and GridView, and it has been here ever since, rendering any adapter-based views in an efficient way. But there is always some room for improvement, isn’t there?
There comes ListAdapter in the picture. As per the google docs,
ListAdapter is RecyclerView.Adapter base class for presenting List data in a RecyclerView, including computing diffs between Lists on a background thread.

Photo by Kvistholt Photography on Unsplash

While working on production level android applications, we come across scenarios where we need to make multiple network requests which can be either be chained requests or paralleled requests and we might want to combine their results as well. In this article we will see how to handle the mentioned scenarios using Kotlin Coroutines.

Brief Overview of Coroutines

A coroutine is a concurrency design pattern that we can use in Android to simplify code that executes asynchronously. A coroutine is an instance of suspendable computation. It is conceptually similar to a thread, in the sense that it takes a block of code to run…

Photo by Susan Q Yin on Unsplash

Working with images in Android is one of the most common parts of Android Applications Development. The image may be from the web or from the device's local storage. Loading images into views needs to be effective so that fewer resources are being used, and the views are rendered gracefully. There are scenarios when we would like to load other content from the web or the database with the images or we would want to perform certain actions once the images are downloaded.

There are many libraries which make our lives easy by providing us with efficient image downloading and…

Photo by Lukenn Sabellano on Unsplash

Android Architecture Components provide guidance on app architecture, with libraries for common tasks like lifecycle management and data persistence. Architecture Components help you structure your app in a way that is robust, testable, and maintainable with less boilerplate code, and via this article, we will be doing the same. I have gone through a few projects and picked up the best approach as per my understanding.

For the following implementation, I am assuming you know the basics of MVVM, Hilt, Coroutines, Flow, Retrofit, and Coil. I will try to explain these as per our requirements as we go through the…

Photo by Marcus Ganahl on Unsplash

We talked about creating a Splash Screen the old school way in one of my previous articles. In this article, I will talk about a way to implement splash screen by just using styles/themes.xml. This will eliminate the need to create another activity just to show the splash screen.

So to begin we need to create a style for our Splash Screen in styles/themes.xml file.

<style name="SplashScreenTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="android:windowBackground">@drawable/ic_splash_screen</item>

I have created a style named SplashScreenTheme, with the parent with no action bar. I have added an item with the property windowBackground, this is where we need to…

Photo by Roman Synkevych on Unsplash

This will be a quick guide to Git’s most common commands which you will be using on day to day basis.

Add Git and Push a Project to Github

cd project/git init                    
# initialises a repository
git add .
# add all the files from working directory to the staging area
git commit -m "COMMIT_MESSAGE"
# commit all changes
git remote add origin
# To add a new remote
git push -u origin <new-branch>
# Sync local branch with remote

Clone Repository

git clone <url>
# Clone a repository locally

Branching and Merging

git branch…

Photo by Franki Chamaki on Unsplash

Almost every application we use stores data for one purpose or another, be it to store images, files, user preferences, etc. One of the most common use cases is to cache relevant pieces of data so that when the device cannot access the network, the user can still browse that content while they are offline. Android is full of ways to store data, depending on our use case. In this article, I will be talking about the best-recommended way to store structured data, and that is the Room library.

The Room persistence library provides an abstraction layer over SQLite to…

Photo by Pierre Bamin on Unsplash

In the previous article I had talked about the benefits of using View Binding over findViewById(). I highly recommend you give it a read before going through this article.

In this article I will be talking about Data Binding and the main differences between View Binding and Data Binding and when either of them should be used in your projects.

Assuming you have already gone through View Binding, I will jump straight to Data Binding, it’s implementation and then get to the differences between View Binding and Data Binding.

Data Binding

The Data Binding Library is a support library that…

Photo by Hope House Press - Leather Diary Studio on Unsplash

In this article, I will walk you through the steps to run a Kotlin program using the Kotlin compiler.

I will start by answering some basic questions in brief.

What is a compiler?

A compiler is a program that converts human-readable code (Source Code) into machine-understandable code (Byte Code).

What is Kotlin’s compiler?

The name of the Kotlin compiler is kotlinc.

How does a Kotlin compiler work?

Similar to Java, where the Java compiler (javac) takes the Java source code and compiles it into byte code(.class), Kotlin compiler (kotlinc) takes the Kotlin source code and compiles it into byte code(.class)…

Anubhav Arora

Engineer | Photographer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store