homeAndroid Stuff

Create custom layouts

Sep 18, 2016

More often than not you will find yourself in a position where you need some…custom behavior. Whether you want a view to keep a 16:9 aspect ratio, or want a view to scroll—and still fill the screen.

Don’t be afraid to create and use your own layouts. Not only will they have great reusability, they will save you time and ease your life. If you start repeating the same pattern in your layout files…maybe you should just create a custom View. Your layout will stay clean and simple while you have better maintainability when something changes.

Most important of all: If you like using ViewTreeObserver to adjust your layouts drop everything right now. This post is for you.

Read More

Annotation Processors

Aug 18, 2016

If you feel like generating your own source code there is little information available on how to start or where to begin. In this post I want to offer some introduction into Java annotation processors, how to generate source code, and—most importantly—how to test it.

For the sake of this guide I just want to stub out a simple interface.

interface Teapot {
void boilWater();
boolean isBoiling();

Yea…this should not be too hard…and who does not like tea?

Read More

Retrofit 2, converters and unwrapping json objects with RxJava

Jul 12, 2016

My two cents on how to deal with wrapped json objects by using Retrofit converters

I’m sure everyone has had the joy of dealing with wrapped objects in json. The best part of them is that you get to check for errors 3 times: IOException, isSuccessful, and the response’s custom result code, if you were to use the default Call<> object provided by Retrofit 2.

Read More

Basics for views and how to create your own

Jul 10, 2016

What is a view? Why would I create my own? and…how does it work?

If you don’t know whether you need a custom view or not, you probably don’t. Most UI elements can be easily expressed using the elements of the Android framework, the support library, or the Google design library.

If you still did not find what you were looking for try GitHub first. Especially for Android there are thousands of libraries, some of them might do what you want. And now that you still didn’t find anything that you can or want to use, because your usecase is very special in some way…Now I have to admit: You probably need a custom view.

Read More

Settling in with Firebase Analytics

Jun 12, 2016

You might have heard: Firebase is the new thing. It is here, it is awesome, and I believe it will make all of our lives somewhat easier.

If you decide to switch to Firebase you will end up using analytics within your app. The default reports alone are worth the few steps it takes to set it all up. Tracking events has never been easier and I am hooked, although, to me, Firebase Analytics seems more like something that I want to use in addition to Google Analytics. While Firebase helps me to get my app up and running, Google Analytics still shares some valuable insights.

Read More

Dagger 2 Basics

May 4, 2016

Dagger 2 can be confusing. This shall shed some light on the key concepts and highlight their proper use. You could start by reading the User’s Guide to acquire the general and official knowledge, and once you have brewed your coffee, pray, continue.

Read More

Relative Timespans

Feb 22, 2016

This is going to be a short post because I’ve seen a lot of custom implementations to provide the well known a few minutes ago labels, which are often hard to maintain and rarely properly localized.

There already is an implementation for this—no, it’s not JodaTime.

Read More

Custom Drawables and Animations

Jan 5, 2016

There are many opportunities where the usage of a custom drawable will lead to nice, clean, and reusable results. If you need to display changing text inside an icon or introduce a custom progress indicator like in Modifying the resource image of Progress Bar on Stack Overflow, you can easily do so with custom drawables.

Read More