use of com.facebook.fresco.animation.backend.AnimationBackend in project fresco by facebook.
the class BitmapAnimationFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
// Get the animation container
ImageView imageView = (ImageView) view.findViewById(R.id.animation_container);
// Create the animation backend
// In addition, we wrap it with an activity check. Tap the view to stop the animation to see
// an inactivity toast message after 2 seconds.
// In order to remove the inactivity check, just remove the wrapper method and set it to
// the backend directly.
AnimationBackend animationBackend = AnimationBackendUtils.wrapAnimationBackendWithInactivityCheck(getContext(), ExampleBitmapAnimationFactory.createColorBitmapAnimationBackend(SampleData.COLORS, 300, new NoOpCache()));
// Create a new animated drawable, assign it to the image view and start the animation.
final AnimatedDrawable2 animatedDrawable = new AnimatedDrawable2(animationBackend);
imageView.setImageDrawable(animatedDrawable);
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (animatedDrawable.isRunning()) {
animatedDrawable.stop();
} else {
animatedDrawable.start();
}
}
});
animatedDrawable.start();
}
use of com.facebook.fresco.animation.backend.AnimationBackend in project fresco by facebook.
the class BitmapAnimationDebugFragment method updateBitmapFrameCache.
private void updateBitmapFrameCache(BitmapFrameCache bitmapFrameCache) {
mActiveFrameNumber = -1;
mBitmapAnimationBackend = ExampleBitmapAnimationFactory.createColorBitmapAnimationBackend(SampleData.COLORS, 300, bitmapFrameCache);
AnimationBackend backendWithInactivityCheck = AnimationBackendUtils.wrapAnimationBackendWithInactivityCheck(getContext(), mBitmapAnimationBackend);
setupFrameInformationContainer(mBitmapAnimationBackend);
mAnimationControlsManager.updateBackendData(backendWithInactivityCheck);
mAnimatedDrawable.setAnimationBackend(backendWithInactivityCheck);
mAnimatedDrawable.invalidateSelf();
}
use of com.facebook.fresco.animation.backend.AnimationBackend in project fresco by facebook.
the class SimpleColorFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
// Get the animation container
ImageView animationContainer = (ImageView) view.findViewById(R.id.animation_container);
// Create the animation backend
// In addition, we wrap it with an activity check. Tap the view to stop the animation to see
// an inactivity toast message after 2 seconds.
// In order to remove the inactivity check, just remove the wrapper method and set it to
// the backend directly.
AnimationBackend animationBackend = AnimationBackendUtils.wrapAnimationBackendWithInactivityCheck(getContext(), ExampleColorBackend.createSampleColorAnimationBackend(getResources()));
// Create a new animated drawable with the example backend
final AnimatedDrawable2 animatedDrawable = new AnimatedDrawable2(animationBackend);
// Set the animation as a background
animationContainer.setImageDrawable(animatedDrawable);
// Add a click listener to start / stop the animation
animationContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (animatedDrawable.isRunning()) {
animatedDrawable.stop();
} else {
animatedDrawable.start();
}
}
});
// Start the animation
animatedDrawable.start();
}
Aggregations