Sign in

Kennay Kermani

Handle app wide events easily without unnecessary coupling

Photo by Karol D from Pexels

The Event Bus design pattern is a well-known practice that has been widely used in many Android apps in the past to achieve an event-driven architecture.

With the slow replacement of Java by Kotlin over the recent years, this approach was almost forgotten. Kotlin itself and also other popular frameworks nowadays offer various options for implementing a publisher/subscriber architecture, such as Kotlin Flow, RxJava, or LiveData.

Because of that, the Event Bus approach has almost been forgotten, even if there were possibilities to reimplement this pattern. …


How to easily change and order your function or method parameters

Photo by Markus Spiske from Pexels

This article will be the second post in my new series about refactoring tips for Android Studio and IntelliJ IDEA.

In my last article, I talked about the “Find and Replace” feature which lets you easily change specific keywords across your whole project or scoped to explicit sections of your codebase.

This succeeding post will be covering another feature that astonishingly facilitates the refactoring of your code.

We will be talking about the “Change Signature”. As the name already implies, this feature allows you to easily refactor function signatures.

Change Signature

The “Change Signature” refactoring function can be found in the refactoring…


A brief introduction to the new wrapper class

Photo from Pixabay by Pexels

Kotlin Inline Classes are a subset of the Kotlin Value classes. An inline class can be used as a wrapper around some other type, described on a very high level.

Within this article, we take a detailed look at the new syntax for inline classes, introduced with Kotlin 1.5, and how to use the feature in practice.

Wrapper Classes

If you come from Java, a very good example for understanding the basic principle is to look at the wrapper classes for primitive types. Let’s take a look at the class Boolean, that wraps the primitive type boolean.

In contradiction to its companion…


How to easily find and replace keywords in your AndroidStudio or IntelliJ IDEA project

Photo by Maurício Mascaro on Pexels

This article will be the start of a new series of mine. Within this series, I will cover some quick and simple tricks that will help you to refactor and maintain your Android app.

I would like to start by talking about Android Studio’s Find and Replace feature. Since Android Studio is built on top of IntelliJ IDEA, this tip applies to IntelliJ as well, of course.

However, for the sake of simplicity, I will refer to Android Studio for the rest of the article.

Replace in Path

As you probably know, Android Studio provides a very good search tool “Find in Path”


A deep dive into the Constraint Layout helper components

Photo by Pawel Czerwinski on Unsplash

The ConstraintLayout is one of the most dynamic and powerful available Android ViewGroup components. Besides its variety of possibilities, it allows us to implement a flat view hierarchy, leading to improved performances when it comes to layout inflation compared to deeply nested layouts.

When it comes to the alignment of different components, the ConstraintLayoutprovides various helper components.

In this article, I want to talk about some of these helper components. In particular, we will review the Guideline, Barrier and Group components.

The Constraint Layout

The layout editor window allows us to adapt the View constraints directly inside the window without writing a single…


A short introduction to the ActivityResult API pre-built contracts

Photo by Markus Spiske from Pexels

Retrieving an image by user input is a common task in Android development. Yet it is far from straightforward to implement it. In earlier stages of Android Development, letting the user take a picture and preview it took quite some effort. The same goes for selecting an image via the gallery app.

But as time goes by, Google provides more and more APIs that make these tasks, and thus our everyday life as developers, easier. Nowadays we have access to the ActivityResult API, which allows us to use ActivityResultContract API.

In earlier stages, if we wanted to get a result…


A short guide about all possible WorkManager cancellation methods

Foto von Dids von Pexels

The Android WorkManager API is made for scheduling deferrable, asynchronous tasks. We reference tasks that got scheduled with this API as “work”. Your scheduled work is intended to run reliably by using this API, even if the device restarted.

But sometimes you need to cancel your scheduled work. Within this article, we will have a quick look at the four methods for implementing this task with the WorkManager API.

Work cancellation

When you schedule your work, you have various possibilities to identify your scheduled work.

The first option is to use the id that will be automatically generated when you create a…


A quick tip on how to combine these three layouts

Photo by Lucas George Wendt on Unsplash

The ConstraintLayout is a very powerful component that allows you to build complex layouts while retaining a flat hierarchy. In most cases, we have only a static layout that easily fits on one screen.

Nevertheless, we often come to the point where we have layouts that can dynamically expand their sizes. That is often the case when we use a RecyclerView which can contain an unknown number of items.

In such situations you have either the option to give the RecyclerView a fixed size and the user can scroll the items within that box or you wrap it in a…


Where and how to use the bottom sheet according to Material Design guidelines

Foto von Vladislav Vasnetsov von Pexels

Just as its name implies, a bottom sheet is anchored to the bottom of your screen and can be displayed either as modal dialog or directly be integrated into a layout.

In this article, we will take a look at this helpful component. We will see in what type of situations you can use it and how to implement each of its variations.

At the end of this article, you should have a deep understanding of how the Android Bottom Sheet component works and how to make use of it.

Usage

The component takes part in the Material Design Guidelines. For…


CODEX

Realize an infinite social media-like feed

Photo by Maxime Lebrun on Unsplash

You may know these infinite lists from e.g. your Pinterest, TikTok, or even your Instagram “explore” feed. It makes you want to scroll and scroll but unfortunately, you will never reach the end.

Features like these can really hook up your user, in terms like Nir Eyal describes in his famous book “Hooked — How to Build Habit-Forming Products”.

Today I will show you how you can easily achieve an infinite scrolling list for a RecyclerView with a combination of Android Room and Paging 3.

To follow along with this article, as the only requirement you should know how to…

Kennay Kermani

Passionated Mobile & Backend Developer

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