public class

AnimatedDrawableUtil

extends Object
java.lang.Object
   ↳ com.facebook.imagepipeline.animated.util.AnimatedDrawableUtil

Class Overview

Utility methods for AnimatedDrawable.

Summary

Public Constructors
AnimatedDrawableUtil()
Public Methods
void fixFrameDurations(int[] frameDurationMs)
Adjusts the frame duration array to respect logic for minimum frame duration time.
int getFrameForTimestampMs(int[] frameTimestampsMs, int timestampMs)
Gets the frame index for specified timestamp.
int[] getFrameTimeStampsFromDurations(int[] frameDurationsMs)
Given an array of frame durations, generate an array of timestamps corresponding to when each frame beings.
int getSizeOfBitmap(Bitmap bitmap)
int getTotalDurationFromFrameDurations(int[] frameDurationMs)
Gets the total duration of an image by summing up the duration of the frames.
static boolean isOutsideRange(int startFrame, int endFrame, int frameNumber)
Checks whether the specified frame number is outside the range inclusive of both start and end.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public AnimatedDrawableUtil ()

Public Methods

public void fixFrameDurations (int[] frameDurationMs)

Adjusts the frame duration array to respect logic for minimum frame duration time.

Parameters
frameDurationMs the frame duration array

public int getFrameForTimestampMs (int[] frameTimestampsMs, int timestampMs)

Gets the frame index for specified timestamp.

Parameters
frameTimestampsMs an array of timestamps generated by
timestampMs the timestamp
Returns
  • the frame index for the timestamp or the last frame number if the timestamp is outside the duration of the entire animation

public int[] getFrameTimeStampsFromDurations (int[] frameDurationsMs)

Given an array of frame durations, generate an array of timestamps corresponding to when each frame beings.

Parameters
frameDurationsMs an array of frame durations
Returns
  • an array of timestamps

public int getSizeOfBitmap (Bitmap bitmap)

public int getTotalDurationFromFrameDurations (int[] frameDurationMs)

Gets the total duration of an image by summing up the duration of the frames.

Parameters
frameDurationMs the frame duration array
Returns
  • the total duration in milliseconds

public static boolean isOutsideRange (int startFrame, int endFrame, int frameNumber)

Checks whether the specified frame number is outside the range inclusive of both start and end. If start <= end, start is within, end is within, and everything in between is within. If start > end, start is within, end is within, everything less than start is within and everything greater than end is within. This behavior is useful for handling the wrapping case.

Parameters
startFrame the start frame
endFrame the end frame
frameNumber the frame number
Returns
  • whether the frame is outside the range of [start, end]