O'Reilly logo

Android 3.0 Animations by Alex Shaw

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action—squashing gremlins that use too much power

  1. Open up src/com/packt/animation/buggybubbles/BubblesView.java, the Java file that contains the gremlin method, and take a look at the contents of the method that are as follows:
    private void gremlin(long nextSleep)
    {
    while (nextSleep>0)
    {
    double[] pointlessMemoryAllocation = new double[1337];
    double pointlessCalculationValue =
    Math.random()*66666.66;
    for (
    int i = 0;
    i< pointlessMemoryAllocation.length;
    ++i)
    {
    pointlessMemoryAllocation[i] =
    pointlessCalculationValue / (1+i);
    }
    nextSleep = frameTime - System.currentTimeMillis();
    }
    }
    

    Yuck! That really is a nasty method. It looks like the gremlin has replaced our call to Thread.sleep with a piece of code that just does some meaningless processing ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required