https://refactoring.guru/design-patterns/visitor

Per AndroidX Lifecycle docs:

It is nice example of inheritance-over-composition approach, where you add logic to your component instead of subclassing it to just override some methods.

However, AndroidX Lifecycle is not specific towards components and has unified set of callbacks. If you need to listen to, say, specific methods of DialogFragment, you are out of luck and need to implement this yourself.

In…


Unreadable RxJava error stacktrace is a known problem. Chances are you also faced cryptic crash log from your QA team and was scratching your head for hours before finding solution or even abandoning said crash altogether.

Relevant discussion on RxJava Github.

This article is intended for both Java and Android devs. Part of snippets are currently in Kotlin, I am in process of migrating it to Java (to be compatible with both worlds). Ignore code irrelevant for your platform.

TL;DR

  1. Use RxDogTag safely.
  2. Prefer to use RxJavaAssembly in debug as it is performance-costly.
  3. You can use assembly tracking and RxDogTag…


https://depositphotos.com/37033543

Clean Architecture is current standard in Android development.

At its core is dependency rule: inner layers do not interact with outer layers.

For instance, you have domain layer (library) with entity BankAccount. This layershould be platform-agnostic.

In Android we use Kotlin, and data class is a natural choice for it. Now we may need to store this entity in database with ORM (like Room) or Realm. First one requires adding bunch of annotations on existing data class, second one requires extending RealmObject. Both approaches make your domain layer non-portable and dependent on platform (outer layer) thus violating Dependency Rule.

In…


https://www.thenews.com.pk/tns/detail/560285-torn-two-places

Google’s Jetpack initiative is truly amazing. Throughout past several years it made tremendous progress, which will be culminated by stable release of Jetpack Compose.

Yet there are sometimes gaps, obscure parts in their libraries.

Recently I had to implement dynamic navigation, i.e. first app screen is selected based on some logic inside Activity’s onCreate.

As application is screen-based, Jetpack Navigation is a natural choice.

For static nav graph, you simply set navigation xml in NavHostFragment.

For dynamic nav graph, you need to set navigation xml manually.

First step is to obtain NavController. It appeared that inside Activity’s onCreate calling findNavController…


During course in Inertial Nav Systems I tried to implement sample sensor calibration on Android. It appeared that Android already applies online calibration, and starting from certain API it is possible to obtain this calibration separately from raw output (previously it was reported as single value).

Theory

First, let’s clear what our sensor model look like:

Now, let’s clear what calibration actually means. For sensors two types of calibration exist: factory and online. Factory calibration is done one time once sensor is manufactured and is hardwired into sensor memory. Online calibration is done while sensor is operating and supplied separately.

API

Once…


While it is well-known fact that DLT fails for coplanar points, I couldn’t find concise proof for it.

So I want to present my own proof here:

Alexander Shafir

Software Engineer, mostly Android. linkedin.com/in/alexander-shafir/

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