Sign in

Android dev @ hotstar
Photo by American Public Power Association on Unsplash

RxJava 2 introduced the concept of back-pressure. Back-pressure is nothing but a way for the subscriber to limit the number of items emitted by the emitter. In this blog, we’ll deep dive and review the mechanics.


The concept of back-pressure is that if the subscriber cannot accept any more of new events, then the emitter should not send more events.

Imagine this case where the subscriber is writing every item that it receives to a database. Now if the items are emitted at a very high frequency the subscriber will not be able to keep up with the emitted items…

The Hotstar social feed has an extensive set of features, which continues to grow as we continue to deepen engagement vectors in the product. Presently there are about 20 cards, each having a unique design & structure, varying functionality and in some cases, different teams developing and collaborating. This would have soon gotten out of hand and become unmanageable, however, we solved this by adopting a novel modular approach using RecyclerView for our Android app.

Our ultimate goal was to create a heterogeneous list with the ability to support several views and multiple teams to work in parallel on the…

“stocked yarns” by Alex Block on Unsplash

Realm is one of the finest alternatives to SQLite DB we have in Android. It is really easy to set up and fun to work with. Since realm lazy loads the data it is really fast to read.

Realm has its own pain points the biggest one being the multithreading. The realm managed objects (the objects that read from realm) cannot be passed across threads unless you convert them to POJO. The writes to the realm are painfully slow in certain cases(when you have listeners to the item you are changing).

Here are some of the things to remember when…

Anyone who has worked with the android custom views will be familiar with the onDraw method. This is where we draw the view to the android canvas to be shown on the screen.

We had to create a view which would rotate corresponding to a given viewRotation value. So my on draw method looked like this.

Here the canvas is rotated with its centre as the pivot point. Everything works fine. The view is rotated and drawn to the screen according to the specified viewRotation value.

The view looks fine with the rotation.

Everything looked fine till…

A RecyclerView is more advanced version of ListView which reuses the same view to prevent additional creation of views to provide a smooth scrolling experience. The RecyclerView achieves this by keeping a View pool that holds the views that are no longer visible and can be recycled.

Sometimes we need to nest RecyclerViews to create some layouts. Consider the case where you have a horizontal RecyclerView inside a Vertical RecyclerView.

In the Image you can see vertical scroling list of horizontal scroling lists.This is achieved by placing a recyclerView inside another recyclerView.

When the user swipes the side-wise the inner…

SubscribeOn and ObserveOn, two concepts that eludes most Rx beginners . I too belonged to this before my experiments using them. Below is a snippet of code that has been used by me to gain deeper understanding about this.

I am emitting an empty string and the map is used to print the thread in which the method was called. The output of the logs can be seen as comment next to the code.


ObserveOn works only downstream. All the methods following the observeOn have been moved to the IO thread. …

Ninad MG

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