Example usage for android.view.animation Animation initialize

List of usage examples for android.view.animation Animation initialize

Introduction

In this page you can find the example usage for android.view.animation Animation initialize.

Prototype

public void initialize(int width, int height, int parentWidth, int parentHeight) 

Source Link

Document

Initialize this animation with the dimensions of the object being animated as well as the objects parents.

Usage

From source file:com.dbeginc.dbweather.utils.animations.widgets.RainFallView.java

@Override
protected void onSizeChanged(int width, int height, int oldWidth, int oldHeight) {
    super.onSizeChanged(width, height, oldWidth, oldHeight);
    SecureRandom random = new SecureRandom();
    Interpolator interpolator = new LinearInterpolator();

    mRainFlakeCount = Math.max(width, height) / 20;
    coords = new int[mRainFlakeCount][];
    drawables.clear();/*w  ww .j  a  va  2s  .com*/
    for (int i = 0; i < mRainFlakeCount; i++) {
        Animation animation = new TranslateAnimation(0, height / 10 - random.nextInt(height / 5), 0,
                height + 30);
        animation.setDuration(10 * height + random.nextInt(5 * height));
        animation.setRepeatCount(-1);
        animation.initialize(10, 10, 10, 10);
        animation.setInterpolator(interpolator);

        coords[i] = new int[] { random.nextInt(width - 30), -30 };

        drawables.add(new AnimateDrawable(mRainDrop, animation));
        animation.setStartOffset(random.nextInt(20 * height));
        animation.startNow();
        int y;
        y = random.nextInt(2);
        if (y == 0) {
            drawables.add(new AnimateDrawable(mRainDrop, animation));
        } else {
            drawables.add(new AnimateDrawable(mRainDrop));
        }
    }
}

From source file:com.dbeginc.dbweather.utils.animations.widgets.SnowFallView.java

@Override
protected void onSizeChanged(int width, int height, int oldWidth, int oldHeight) {
    super.onSizeChanged(width, height, oldWidth, oldHeight);
    Random random = new SecureRandom();
    Interpolator interpolator = new LinearInterpolator();

    snow_flake_count = Math.max(width, height) / 20;
    coords = new int[snow_flake_count][];
    drawables.clear();/*from w  ww. j a v a2 s  .  c  o m*/
    for (int i = 0; i < snow_flake_count; i++) {
        Animation animation = new TranslateAnimation(0, height / 10 - random.nextInt(height / 5), 0,
                height + 30);
        animation.setDuration(10 * height + random.nextInt(5 * height));
        animation.setRepeatCount(-1);
        animation.initialize(10, 10, 10, 10);
        animation.setInterpolator(interpolator);

        coords[i] = new int[] { random.nextInt(width - 30), -30 };

        drawables.add(new AnimateDrawable(snow_flake, animation));
        animation.setStartOffset(random.nextInt(20 * height));
        animation.startNow();
        int y;
        y = random.nextInt(2);
        if (y == 0) {
            drawables.add(new AnimateDrawable(snow_flake, animation));
        } else {
            drawables.add(new AnimateDrawable(snow_flake));
        }
    }
}