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.
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">
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…
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 repositorygit add .
# add all the files from working directory to the staging areagit commit -m "COMMIT_MESSAGE"
# commit all changesgit remote add origin https://github.com/GIT_USER_NAME/REPO_NAME.git
# To add a new remote git push -u origin <new-branch>
# Sync local branch with remote
git clone <url>
# Clone a repository locally
Branching and Merging
In this article, we will learn how to authenticate our api calls in an Android app using Retrofit and OkHttp.
We will be using OkHttp authentication interceptor mechanism for our use case. To add our Authentication Token in authenticated requests we can use an interceptor to pass in the token.
Intercepting Http requests with the help of OkHttp interceptors allows us to manipulate the actual request and apply our customisation. We will be needing the following dependencies for our implementation,
def retrofitVersion = '2.9.0'
Try and think of an application which works without Internet. Give it a minute of two, how many could you come up with? One, two ?
We thrive on the internet and so do our applications.
In this article, we will see how to monitor Internet Connectivity and whether or not your network has Internet Access.
We will be needing the following permissions,
For us to proceed with this, the minSdkVersion should be 21.
We will be creating a class which extends LiveData<Boolean>, which emits Boolean values and can be observed.
class ConnectivityLiveData(context: Context) : LiveData<Boolean>()…
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…
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.
The Data Binding Library is a support library that…
In this article, I will cover the most frequently used terminal commands. The Terminal, also known as the Command line or a Terminal emulator, is an essential component of any useful operating system. The Terminal provides an efficient interface to access the true power of a computer better than any graphical interface. When opening a terminal you are presented with a shell. On Mac and Linux this shell is Bash, but other shells can be used.
Don’t forget knowing the ins and outs of terminal makes you COOL :p
I’ll be using the Terminal for this article. …
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)…
As an Android Developer we have all used findViewById(), (it finds the first descendant view with the given ID in our layout xml file), it uses the getId() method to find the view matching the id in the view hierarchy.
findViewById() does its work but there are a few problems with it:
Null-Crashes: The getId() method returns the view if found, and null in case the ID is invalid or not found in the view hierarchy.
Type-Safety: The views accessed by findViewById() are not type-safe, there can be a possibility of calling findViewById<ImageView>(R.id.textViewName), …
Android Developer | Photographer