Skip to content

CollisionLoadingRenderer

dinus_developer edited this page Aug 14, 2016 · 9 revisions

Builder class for CollisionLoadingRenderer objects. Provides a convenient way to set the various fields of a CollisionLoadingRenderer.
Example:

LoadingRenderer loadingRenderer = new CollisionLoadingRenderer.Builder(this)
        .setWidth((int) DensityUtil.dip2px(this, 150))
        .setHeight((int) DensityUtil.dip2px(this, 40))
        .setColors(new int[] {Color.GRAY, Color.CYAN})
        .setBallRadius((int) DensityUtil.dip2px(this, 10))
        .setBallMoveXOffsets((int) DensityUtil.dip2px(this, 20))
        .setBallQuadCoefficient(0.04f)
        .setBallCount(5)
        .setDuration(4000)
        .build();

setWidth

public Builder setWidth(int width)

Sets the width in px of the LoadingDrawable which apply this LoadingRenderer.

setHeight

public Builder setHeight(int height)

Sets the height in px of the LoadingDrawable which apply this LoadingRenderer.

setDuration

public Builder setDuration(int duration)

The length of the animation, in milliseconds. If this value is negative or zero will be ignored.

setOvalVerticalRadius

public Builder setOvalVerticalRadius(int ballRadius)

Sets the radius of the bottom oval in the vertical direction. Besides, in the horizontal direction, the radius of the bottom oval always equals the radius of the ball. If this value is negative or zero will be ignored.

setBallMoveXOffsets

public Builder setBallMoveXOffsets(int ballMoveXOffsets)

The animation parabola of the both side ball is y = ax^2, this value represents the maximum value of the x-axis direction. If this value is negative or zero will be ignored.

setBallQuadCoefficient

public Builder setBallQuadCoefficient(int ballQuadCoefficient)

The animation parabola of the both side ball is y = ax^2, this value represents the quadratic coefficient a. If this value is negative or zero will be ignored.

setBallCount

public Builder setBallCount(int ballCount)

Sets the count of these balls. if this value is negative or zero will be ignored.

setColors

public Builder setColors(int[] colors)

Sets the colors these balls gradient between, @param colors must be an array of two integers. if this value is null will be ignored.