• Eventbus in Android: an Otto example

    Loose coupling is a great invention: it allows components to have less dependencies, resulting in a far more reusable code. A common way to achieve this is via using interfaces, with a downside of an excessive amount of boilerplate code. Instead of using interfaces, loose coupling can also be achieved with the publisher-subcsriber model. One of Square’s open source library can be very helpful in this case, it requires far less extra code than using interfaces. This post will show the basic usage of Otto. (more)

  • Create ViewPager transitions: a PagerTransformer example

    The ViewPager is a great UI element, providing a smooth swipe animation for switching between pages. But what if a different scrolling effect is required? Fear not, the support library provides a useful solution called the PagerTransformer. It was introduced in revision 11, and is supported from API level 11 (Honeycomb) or greater. (more)

  • How to use the PagerTabStrip and the PagerTitleStrip

    The ViewPager is one of the best and most versatile part of the Android UI, it enables the developer/designer to show more content on a small screen than possible. The user can swipe between pages, but it is important that the app shows some hints for a proper user experience. Can I swipe some more or is it the last page? What awaits on the previous and next pages? (more)

  • How to use and customize the DrawerLayout

    The DrawerLayout was introduced in the latest support library (revision 13), and has many similarities with the SlidingPaneLayout. It is used to add navigation capabilities and to display more information in the same activity, with just a swipe from the sides - a great way to add extra functionality without stuffing the screen with controls. Just tell the user the panels are there, otherwise no one will know about them. (more)

  • How to add distance to coordinates

    A few weeks ago I had to translate geocoordinates (latitude and longitude) having a given directon (aka an angle) and a distance in an Android app. Searching the web I found a few good solutions, this is my take on the problem shaped to my needs, heavily based on one of the suggestions of this thread. (more)