Activities Subcomponents Multibinding in Dagger 2

A couple months ago, during MCE³ conference, Gregory Kick in his presentation showed a new concept of providing Subcomponents (e.g. to Activities). New approach should give us a way to create ActivitySubcomponent without having AppComponent object reference (which used to be a factory for Activities Subcomponents).
To make it real we had to wait for a new release of Dagger: version 2.7.

Continue reading “Activities Subcomponents Multibinding in Dagger 2”

Iron Man’s Jarvis — is it still a fiction?

Who doesn’t dream about Iron Man’s suit? Infinite power source — Vibranium Arc Reactor, ability to fly and dive thanks to Repulsors and oxygen supplies, almost indestructible single-crystal titanium armor with extremely danger weaponry.

Since we’re still years or even decades (are we?) from having at least prototype of flying metal suite, there is one piece of it which can be closer than we think.

JARVIS

While Vibranium Arc Reactor is a heart of Iron Man suit, the equally important thing is its brain — Jarvis.
“Jarvis is a highly advanced computerized A.I. developed by Tony Stark, (…) to manage almost everything, especially matters related to technology, in Tony’s life.” Does it sound familiar? Continue reading “Iron Man’s Jarvis — is it still a fiction?”

Building UserScope with Dagger2

In Azimo Android app we use Dagger 2 as a framework for Dependency Injection to make our code architecture clean and easy to scale. Like in our previous post we would like to share our experience so today I’ll show how to avoid issues and build custom UserScope which can be used in production app.

TL;DR

Custom scopes in Dagger 2 can give better control on dependencies which should live unusual amount of time (different than application and screen lifetime). But to implement it properly in Android app we need to keep in mind things like: scope cannot live longer than application process, process can be killed by system and restored in the middle of user flow with new objects instances.

Example source code is available here: Dagger 2 recipes: UserScope.

Continue reading “Building UserScope with Dagger2”

Dagger 2 on production — reducing methods count

Dagger 2 — fully static, compile-time dependency injection framework is a backbone of code architecture in Azimo Android app. We already know that with growing dev team clean code structure is one of the most important things in every project. Initialisation/usage separation, easier testing (unit or functional), better scalability —those are just a few of the benefits that come from use of dependency injection framework like Dagger 2.

Continue reading “Dagger 2 on production — reducing methods count”

Inject everything — ViewHolder and Dagger 2 (with Multibinding and AutoFactory example)

This post is a part of series of posts showing Dependency Injection with Dagger 2 framework in Android. Today we’re going to take a look at Multibinding and Autofactory and we’ll try to implement ViewHolder pattern with Dagger 2. Continue reading “Inject everything — ViewHolder and Dagger 2 (with Multibinding and AutoFactory example)”

Async Injection in Dagger 2 with RxJava

This post is a part of series of posts showing Dependency Injection with Dagger 2 framework in Android. Today we’re going to take a look at Asynchronous injection 2 with RxJava — alternative for Dagger 2 Producers Continue reading “Async Injection in Dagger 2 with RxJava”

AndroidDevMetrics — Activity lifecycle methods tracing

AndroidDevMetrics is a performance metrics library which will help you find potential performance issues in your Android app. Thanks to it we are able to measure objects graph initialization in Dagger 2, Activities lifecycle methods timings and frame drops for each screen in app.

Continue reading “AndroidDevMetrics — Activity lifecycle methods tracing”

Dependency injection with Dagger 2 — Producers

This post is a part of series of posts showing Dependency Injection with Dagger 2 framework in Android. Today we’re going to take a look at Dagger Producers — an extension to Dagger 2 that implements asynchronous dependency injection in Java.

Continue reading “Dependency injection with Dagger 2 — Producers”

AndroidDevMetrics — app performance metrics for Android development

We live in times where mobile apps have to not only do their job but also do it smooth and delightful. In times where almost every Android device has huge computing power and operating system is really mature (and I’m not saying only about Lollipop or Marshmallow). Less and less things limit us to to deliver really beautiful apps.

But it also means that there are no excuses for us — the developers. We cannot say anymore: “this is because your crappy Android device… Do you want smoothness? Let’s check it on iPhone.”. Now it’s our fault that app works and looks good only on this year’s high-end device. We cannot blame platform developers anymore because they already did awesome job with optimizations in Android.

Moreover, they started sharing their knowledge about performance, optimizations and how things work under the hood. If you haven’t seen it yet just take a look at this videos collection — Android Performance Patterns. Do we need more proves that now everything is really in our hands? Continue reading “AndroidDevMetrics — app performance metrics for Android development”

Dagger2Metrics – measure performance of DI graph initialization

A couple months ago we went through possible issues with Dagger 2 – graph creation performance. Thanks to TraceView tool we can see exactly how much time is needed to initialize all requested dependencies. But it’s not easy – we have to find places in our code to start and stop measuring, dump results and analyze them in Android Studio. To make it bit easier, I’ve prepared simple library which can help with catching potential performance issues. Continue reading “Dagger2Metrics – measure performance of DI graph initialization”