Fragment Lifecycle from Android Developer

If you are developing Android apps using Kotlin, lazy property is one of the useful features that helps us save some memory by delaying the initialisation until they are requested and keeping that instance for the rest of the usage. However, recently I have encountered a nasty bug, which causes a memory-leak, while using it in fragment. In this article, I will show you the potential bug you might face with lazy property in activity/fragment and how to solve it.

What is the problem?

The bug happened when I was showing a bottom sheet in Fragment. In order to have the sheet collapse, expand…


Photo by Ridham Nagralawala on Unsplash

RxJava is a Java implementation of ReactiveExtensions (or ReactiveX) which supports writing programs in asynchronous and event-based style through observable streams. SubscribeOn is one of the most-used operators in Rx so it is important to know how it works. This article assumes that you’re already familiar with basic RxJava’s concepts. Now let’s dive in!

What is SubscribeOn?

As the official doc has pointed out:

By default, an Observable and the chain of operators that you apply to it will do its work, and will notify its observers, on the same thread on which its Subscribe method is called. The SubscribeOn operator changes this…


Photo by GR Stocks on Unsplash

While working with Recycler View in Android, we usually have to deal with various adapters specifically built for different lists. In someway, this has burdened us with more code to maintain. Therefore, I’ve created a common adapter that, together with data binding, can be used for any data set. This means you only have to create these classes once and reuse them multiple times.

Intent

  • Build an adapter that can be reusable in many places.
  • Encourage MVVM pattern so that models have all the logic and view is as dumb as possible.

Implementation

This post assumes that you’re familiar with Android and…

longv

Android Developer @ Maas Global

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