lucasr is currently certified at Master level.

Name: Lucas Rocha
Member since: 2002-11-28 14:12:04
Last Login: 2014-10-10 09:05:27

FOAF RDF Share This



Recent blog entries by lucasr

Syndication: RSS 2.0

Joining Facebook

I am really excited to announce that I’m joining Facebook. I start in January next year. I’ll be bootstrapping Android UI efforts—frameworks and user-facing stuff—in the London office. There are still a lot of details to sort out but that’s the general plan.

Why Facebook? They have an amazing hacker-driven culture, they’re striving to do open source the right way, there’s a lot of space for experimentation, and they have massive reach in the Android space.

I’m really looking forward to learning a lot at Facebook. And there is so much to be done! I can’t wait to start :-)

Syndicated 2014-11-27 11:24:04 from Lucas Rocha

Leaving Mozilla

I joined Mozilla 3 years, 4 months, and 6 days ago. Time flies!

I was very lucky to join the company a few months before the Firefox Mobile team decided to rewrite the product from scratch to make it more competitive on Android. And we made it: Firefox for Android is now one of the highest rated mobile browsers on Android!

This has been the best team I’ve ever worked with. The talent, energy, and trust within the Firefox for Android group is simply amazing.

I’ve thoroughly enjoyed my time here but an exciting opportunity outside Mozilla came up and decided to take it.

What’s next? That’s a topic for another post ;-)

Syndicated 2014-11-26 16:57:50 from Lucas Rocha

Probing with Gradle

Up until now, Probe relied on dynamic view proxies generated at runtime to intercept View calls. Although very convenient, this approach greatly affects the time to inflate your layouts—which limits the number of use cases for the library, especially in more complex apps.

This is all changing now with Probe’s brand new Gradle plugin which seamlessly generates build-time proxies for your app. This means virtually no overhead at runtime!

Using Probe’s Gradle plugin is very simple. First, add the Gradle plugin as a dependency in your build script.

buildscript {
    repositories {

    dependencies {
        classpath ''
        classpath 'org.lucasr.probe:gradle-plugin:0.1.2'

Then add Probe’s library as a dependency in your app.

repositories {

dependencies {
    compile 'org.lucasr.probe:probe:0.1.2'

Next, apply the plugin to your app’s build.gradle.

apply plugin: 'probe'

Probe’s proxy generation is disabled by default and needs to be explicitly enabled on specific build variants (build type + product flavour). For example, this is how you enable Probe proxies in debug builds.

probe {
    buildVariants {
        debug {
            enabled = true

And that’s all! You should now be able to deploy interceptors on any part of your UI. Here’s how you could deploy an OvermeasureInterceptor in an activity.

public final class MainActivity extends Activity {
   protected void onCreate(Bundle savedInstanceState) {
       Probe.deploy(this, new OvermeasureInterceptor());

While working on this feature, I have changed DexMaker to be an optional dependency i.e. you have to explicitly add DexMaker as a build dependency in your app in order to use it.

This is my first Gradle plugin. There’s definitely a lot of room for improvement here. These features are available in the 0.1.2 release in Maven Central.

As usual, feedback, bug reports, and fixes are very welcome. Enjoy!

Syndicated 2014-10-07 23:12:03 from Lucas Rocha

New Features in Picasso

I’ve always been a big fan of Picasso, the Android image loading library by the Square folks. It provides some powerful features with a rather simple API.

Recently, I started working on a set of new features for Picasso that will make it even more awesome: request handlers, request management, and request priorities. These features have all been merged to the main repo now. Let me give you a quick overview of what they enable you to do.

Request Handlers

Picasso supports a wide variety of image sources, from simple resources to content providers, network, and more. Sometimes though, you need to load images in unconventional ways that are not supported by default in Picasso.

Wouldn’t it be nice if you could easily integrate your custom image loading logic with Picasso? That’s what the new request handlers are about. All you need to do is subclass RequestHandler and implement a couple of methods. For example:

public class PonyRequestHandler extends RequestHandler {
    private static final String PONY_SCHEME = "pony";

    @Override public boolean canHandleRequest(Request data) {
        return PONY_SCHEME.equals(data.uri.getScheme());

    @Override public Result load(Request data) {
         return new Result(somePonyBitmap, MEMORY);

Then you register your request handler when instantiating Picasso:

Picasso picasso = new Picasso.Builder(context)
    .addRequestHandler(new PonyHandler())

Voilà! Now Picasso can handle pony URIs:


This pull request also involved rewriting all built-in bitmap loaders on top of the new API. This means you can also override the built-in request handlers if you need to.

Request Management

Even though Picasso handles view recycling, it does so in an inefficient way. For instance, if you do a fling gesture on a ListView, Picasso will still keep triggering and canceling requests blindly because there was no way to make it pause/resume requests according to the user interaction. Not anymore!

The new request management APIs allow you to tag associated requests that should be managed together. You can then pause, resume, or cancel requests associated with specific tags. The first thing you have to do is tag your requests as follows:


Then you can pause and resume requests with this tag based on, say, the scroll state of a ListView. For example, Picasso’s sample app now has the following scroll listener:

public class SampleScrollListener implements AbsListView.OnScrollListener {
    public void onScrollStateChanged(AbsListView view, int scrollState) {
        Picasso picasso = Picasso.with(context);
        if (scrollState == SCROLL_STATE_IDLE ||
            scrollState == SCROLL_STATE_TOUCH_SCROLL) {
        } else {

These APIs give you a much finer control over your image requests. The scroll listener case is just the canonical use case.

Request Priorities

It’s very common for images in your Android UI to have different priorities. For instance, you may want to give higher priority to the big hero image in your activity in relation to other secondary images in the same screen.

Up until now, there was no way to hint Picasso about the relative priorities between images. The new priority API allows you to tell Picasso about the intended order of your image requests. You can just do:


These priorities don’t guarantee a specific order, they just tilt the balance towards higher-priority requests.

That’s all for now. Big thanks to Jake Wharton and Dimitris Koutsogiorgas for the prompt code and API reviews!

You can try these new APIs now by fetching the latest Picasso code on Github. These features will probably be available in the 2.4 release. Enjoy!

Syndicated 2014-09-23 15:52:54 from Lucas Rocha

Introducing Probe

We’ve all heard of the best practices regarding layouts on Android: keep your view tree as simple as possible, avoid multi-pass layouts high up in the hierarchy, etc. But the truth is, it’s pretty hard to see what’s actually going on in your view tree in each platform traversal (measure → layout → draw).

We’re well served with developer options for tracking graphics performance—debug GPU overdraw, show hardware layers updates, profile GPU rendering, and others. However, there is a big gap in terms of development tools for tracking layout traversals and figuring out how your layouts actually behave. This is why I created Probe.

Probe is a small library that allows you to intercept view method calls during Android’s layout traversals e.g. onMeasure(), onLayout(), onDraw(), etc. Once a method call is intercepted, you can either do extra things on top of the view’s original implementation or completely override the method on-the-fly.

Using Probe is super simple. All you have to do is implement an Interceptor. Here’s an interceptor that completely overrides a view’s onDraw(). Calling super.onDraw() would call the view’s original implementation.

public class DrawGreen extends Interceptor {
    private final Paint mPaint;

    public DrawGreen() {
        mPaint = new Paint();

    public void onDraw(View view, Canvas canvas) {

Then deploy your Interceptor by inflating your layout with a Probe:

Probe probe = new Probe(this, new DrawGreen(), new Filter.ViewId(;
View root = probe.inflate(R.layout.main_activity, null);

Just to give you an idea of the kind of things you can do with Probe, I’ve already implemented a couple of built-in interceptors. OvermeasureInterceptor tints views according to the number of times they got measured in a single traversal i.e. equivalent to overdraw but for measurement.

LayoutBoundsInterceptor is equivalent to Android’s “Show layout bounds” developer option. The main difference is that you can show bounds only for specific views.

Under the hood, Probe uses Google’s DexMaker to generate dynamic View proxies during layout inflation. The stock ProxyBuilder implementation was not good enough for Probe because I wanted avoid using reflection entirely after the proxy classes were generated. So I created a specialized View proxy builder that generates proxy classes tailored for Probe’s use case.

This means Probe takes longer than your usual LayoutInflater to inflate layout resources. There’s no use of reflection after layout inflation though. Your views should perform the same. For now, Probe is meant to be a developer tool only and I don’t recommend using it in production.

The code is available on Github. As usual, contributions are very welcome.

Syndicated 2014-09-16 10:32:49 from Lucas Rocha

287 older entries...


lucasr certified others as follows:

  • lucasr certified lucasr as Journeyer
  • lucasr certified terceiro as Journeyer
  • lucasr certified gman as Master
  • lucasr certified andersca as Master
  • lucasr certified jamesh as Master
  • lucasr certified jdahlin as Master
  • lucasr certified kiko as Journeyer
  • lucasr certified Uraeus as Master
  • lucasr certified kov as Journeyer
  • lucasr certified thomasvs as Master
  • lucasr certified jdub as Master
  • lucasr certified rbultje as Master
  • lucasr certified company as Master
  • lucasr certified hub as Master
  • lucasr certified DV as Master
  • lucasr certified behdad as Master
  • lucasr certified pbor as Journeyer
  • lucasr certified ebassi as Journeyer
  • lucasr certified gicmo as Master
  • lucasr certified seb128 as Master
  • lucasr certified murrayc as Master
  • lucasr certified garnacho as Journeyer
  • lucasr certified miguel as Master
  • lucasr certified federico as Master
  • lucasr certified gpoo as Journeyer
  • lucasr certified menthos as Master
  • lucasr certified roozbeh as Master
  • lucasr certified Jody as Master
  • lucasr certified hp as Master
  • lucasr certified aurium as Journeyer
  • lucasr certified calum as Master
  • lucasr certified clarkbw as Journeyer
  • lucasr certified kristian as Journeyer
  • lucasr certified valessio as Apprentice
  • lucasr certified tigert as Master
  • lucasr certified garrett as Master
  • lucasr certified campd as Master
  • lucasr certified jimmac as Master
  • lucasr certified dobey as Master
  • lucasr certified dsandras as Master
  • lucasr certified Iain as Master
  • lucasr certified hadess as Master
  • lucasr certified chipx86 as Journeyer
  • lucasr certified wingo as Master
  • lucasr certified cinamod as Master
  • lucasr certified pvanhoof as Journeyer
  • lucasr certified Jimbob as Journeyer
  • lucasr certified timg as Journeyer
  • lucasr certified mjs as Master
  • lucasr certified timj as Master
  • lucasr certified rms as Master
  • lucasr certified jpr as Master
  • lucasr certified rodrigo as Master
  • lucasr certified mathieu as Master
  • lucasr certified kmaraas as Master
  • lucasr certified lewing as Master
  • lucasr certified notzed as Master
  • lucasr certified jrb as Master
  • lucasr certified vicious as Master
  • lucasr certified anderson as Journeyer
  • lucasr certified jvic as Apprentice
  • lucasr certified csv as Master
  • lucasr certified RossBurton as Master
  • lucasr certified AlanHorkan as Journeyer
  • lucasr certified faw as Apprentice
  • lucasr certified zwnj as Journeyer
  • lucasr certified bilboed as Journeyer
  • lucasr certified orph as Master
  • lucasr certified caio1982 as Apprentice
  • lucasr certified sdodji as Master
  • lucasr certified paolo as Master
  • lucasr certified blizzard as Master
  • lucasr certified bratsche as Journeyer
  • lucasr certified snorp as Journeyer
  • lucasr certified sopwith as Master
  • lucasr certified otavio as Master

Others have certified lucasr as follows:

  • lucasr certified lucasr as Journeyer
  • terceiro certified lucasr as Apprentice
  • Lobster certified lucasr as Journeyer
  • tiagovaz certified lucasr as Apprentice
  • nikole certified lucasr as Journeyer
  • jvic certified lucasr as Journeyer
  • valessio certified lucasr as Master
  • aurium certified lucasr as Master
  • pbor certified lucasr as Journeyer
  • gicmo certified lucasr as Master
  • cinamod certified lucasr as Master
  • faw certified lucasr as Journeyer
  • zwnj certified lucasr as Journeyer
  • gpoo certified lucasr as Journeyer
  • company certified lucasr as Master
  • eopadoan certified lucasr as Master
  • csv certified lucasr as Master
  • phplev certified lucasr as Master

[ Certification disabled because you're not logged in. ]

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!

Share this page