Chris Banes

I work as an engineer in the Android Developer Relations team. This is my personal blog and any views expressed here are mine, and mine alone.

Android Libraries, Maven

Pushing AARs to Maven Central

Over the past few weeks I've been updating ActionBar-PullToRefresh [http://github.com/chrisbanes/ActionBar-PullToRefresh] for the release of v0.7, but have been a bit blocked on publishing the library as an Android Archive (aar) to Maven Central [http://search.maven.org/]. It was the number one issue/request that I received, and while I had a working local Gradle build I could not find an easy way to publish the results. There a few solutions out there but nothing really definitive. The main s
Chris Banes
Android Libraries, Pull to Refresh

ActionBar-PullToRefresh

So this is my first blog post on ActionBar-PullToRefresh. I've been mainly talking about it on Google+ up until now as it simply was not ready for production use. Well today I tagged and push v0.4 of the project, which adds the main missing feature: automatically styling based on your Action Bar style. First of all here's a video of how it works: Features So here's a non-exhaustive list of it's features: * By default mirrors the Gmail implementation: grow from center progress bar. * ListVie
Chris Banes
Android Views

Checkable Views

After a month of not posting anything on here due to being busy, I’ve finally found a bit of time to write a new Snippet post. This post is all about Checkable [https://developer.android.com/reference/android/widget/Checkable.html], and how to properly implement the interface so that your views display as you expect them to. What’s Checkable? Checkable is an interface which can be implemented when your View needs to change state based on a boolean switch. The framework contains a few views whi
Chris Banes
ListView, Android Views

ListView - Keeping Position

Last week Joaquim Verges [https://plus.google.com/107942105369460253496] asked me a question about ListView. I’ve finally got around to writing up this solution and post. The Problem To paraphrase Joaquim, the problem is: > I have a ListView populated from a CursorLoader. When I swap to a cursor with new items on top, I use setSelectionFromTop() [https://developer.android.com/reference/android/widget/ListView.html#setSelectionFromTop(int, int)] to keep the ListView at the same visible position
Chris Banes
Pull to Refresh, Android Libraries

Android-PullToRefresh – Stopping Development

Android-PullToRefresh was started about 18 months ago, as I needed it for a project (Friendcaster). Since then I’ve kept maintaining the project, pushing it forward and adding new features. Well today I’m stopping development. There are two reasons for this, the first is that it is feature complete. The second reason is that the volume of ‘issues’ I get is taking up too much of my time. At the end of the day, it’s open source. If you want something added or fixed, you have the source to do so.
Chris Banes
Animations, Android Views

Snippet: Animated Action Bar Items

This snippet is taken from some of the code I’ve recently released in photup [http://www.senab.co.uk/2013/01/19/photup-is-now-open-source/], and shows you how to make an Action Bar item more noticeable, allowing you to lead the user onto the correct path. You can see what I mean here: So why did I add this in photup? Well, one of the problems that I had with the selection screen was that there were many many clickable items on it: * Each item in the Grid is clickable twice, one for selection
Chris Banes
Android Views, ImageView

Snippet: ImageView Layout Optimisation

Welcome to the second instalment of my new Android Snippet series. This one is a fairly short one as it points out an optimisation which was added in Android v4.0, but which can be easily backported to your applications for use in previous versions of Android. Scenario Imagine you have a 3-column GridView, each item is properly recycled in the Adapter, and contains an ImageView filling the View. You load each ImageView with a Bitmap downloaded from the web, in a background thread, which is cach
Chris Banes
Date & Time

Snippet: DateUtils

This is the first in a new series of posts I’m going to regularly publish (weekly-ish) of code snippets which could save you a lot of #AndroidDev time. The first of which is about one of my favourite classes in Android: DateUtils [http://developer.android.com/reference/android/text/format/DateUtils.html]. It’s Javadoc keeps things nice and short: > This class contains various date-related utilities for creating text for things like elapsed time and date ranges, strings for days of the week and
Chris Banes
Android Libraries

Android-BitmapCache… the rebirth.

A while ago I wrote Android-BitmapMemoryCache, a cache based off of LruCache which would cache Android Bitmap objects in memory in a clever way. You can get the full details from this earlier post [http://www.senab.co.uk/2012/07/01/android-bitmap-caching-revisited/], but the bottom line is that it knew when a Bitmap was no longer being used, and so would recycle it. I left it like that the past 5 months and I knew it worked. I was aware though, that developers were looking for something a littl
Chris Banes