Local KtLint configuration for Android

KtLint & Detekt are tools that help us keep our code formatted in the same way and sometimes even help us spot errors before they are actually merged to master or develop.

Most of the CI integrations already include a detekt step before the unit tests are run. To avoid waiting for the CI, you can easily integrate ktlint as part of Git hooks. So every time when you decide to commit, Git hooks run and ktlint analyzes the committed files and prevents you from pushing until you fix your errors.

Continue reading “Local KtLint configuration for Android”

RecyclerView loses focus when scrolling fast … or how to use it on Android TV

We had a project where we were aiming to reuse the same codebase across mobile and TV. You have this care very often and there is this consideration of:

Should we use the Leanback Fragments?

The experienced Android TV developer

that is always ignored. We give the project a quick go and check how it works on the Android TV emulator and decide it is not worth the effort to work on TV specific codebase that may require additional devs to support it. And this is where hell breaks loose.

Continue reading “RecyclerView loses focus when scrolling fast … or how to use it on Android TV”

Don’t forget about the difference between android:windowActionBar vs windowActionBar in your theme

What is the difference between this piece of code:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="windowActionBar">false</item>
</style>

and this one:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="android:windowActionBar">false</item>
</style>
Continue reading “Don’t forget about the difference between android:windowActionBar vs windowActionBar in your theme”

Approaches not to cause a crash when setting toolbar title on the activity through a fragment

Setting a toolbar title on the activity should be easy, right? But what about if you want do it through a fragment? Still easy? Well, not exactly.

The issue is that you may try to touch the toolbar in a moment where the activity is actually still not inflated. This will cause an exception immediately and your app will crash. What is the exact issue?

Continue reading “Approaches not to cause a crash when setting toolbar title on the activity through a fragment”

Publishing a private Android library

Recently I played around with a library that is used in multiple projects. This library has a huge list of dependencies like: coroutines, rxjava, navigation library from Google, material library, custom edit texts that come from 3rd party libraries and many more. Basically this library has also a rich set of screens available to the users that open given certain conditions. But our issues was bigger.

Continue reading “Publishing a private Android library”

Android Oauth2 token refresh mechanism – OkHttp vs RxJava layering

The RxJava approach

I am currently working on an app where the devs before me took this strange decision in regard to the refresh token mechanism – have a single entry point of the app which is called every time whenever you need to have a fresh token. What I mean is this:

Continue reading “Android Oauth2 token refresh mechanism – OkHttp vs RxJava layering”