Search in sources :

Example 1 with AnimatedDrawable2

use of com.facebook.fresco.animation.drawable.AnimatedDrawable2 in project fresco by facebook.

the class MediaControlFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    ImageView imageView = (ImageView) view.findViewById(R.id.animation_container);
    // Create a new animated drawable. The backend will be set by the backend configurator.
    mAnimatedDrawable = new AnimatedDrawable2();
    imageView.setImageDrawable(mAnimatedDrawable);
    mAnimationControlsManager = new AnimationControlsManager(mAnimatedDrawable, (SeekBar) view.findViewById(R.id.seekbar), (ToggleButton) view.findViewById(R.id.playpause), view.findViewById(R.id.reset));
    new SampleAnimationBackendConfigurator((Spinner) view.findViewById(R.id.spinner), this);
}
Also used : AnimatedDrawable2(com.facebook.fresco.animation.drawable.AnimatedDrawable2) ToggleButton(android.widget.ToggleButton) SeekBar(android.widget.SeekBar) SampleAnimationBackendConfigurator(com.facebook.samples.animation2.utils.SampleAnimationBackendConfigurator) AnimationControlsManager(com.facebook.samples.animation2.utils.AnimationControlsManager) ImageView(android.widget.ImageView)

Example 2 with AnimatedDrawable2

use of com.facebook.fresco.animation.drawable.AnimatedDrawable2 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();
}
Also used : AnimatedDrawable2(com.facebook.fresco.animation.drawable.AnimatedDrawable2) NoOpCache(com.facebook.fresco.animation.bitmap.cache.NoOpCache) AnimationBackend(com.facebook.fresco.animation.backend.AnimationBackend) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View)

Example 3 with AnimatedDrawable2

use of com.facebook.fresco.animation.drawable.AnimatedDrawable2 in project fresco by facebook.

the class BitmapAnimationDebugFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    // Get the animation container
    ImageView imageView = (ImageView) view.findViewById(R.id.animation_container);
    mFrameInformationContainer = (LinearLayout) view.findViewById(R.id.frame_information);
    mAnimatedDrawable = new AnimatedDrawable2();
    mAnimationControlsManager = new AnimationControlsManager(mAnimatedDrawable, (SeekBar) getView().findViewById(R.id.seekbar), (ToggleButton) getView().findViewById(R.id.playpause), getView().findViewById(R.id.reset));
    new BitmapAnimationCacheSelectorConfigurator((Spinner) view.findViewById(R.id.spinner), mBitmapFrameCacheChangedListener, mFrameCacheListener);
    imageView.setImageDrawable(mAnimatedDrawable);
}
Also used : AnimatedDrawable2(com.facebook.fresco.animation.drawable.AnimatedDrawable2) ToggleButton(android.widget.ToggleButton) SeekBar(android.widget.SeekBar) AnimationControlsManager(com.facebook.samples.animation2.utils.AnimationControlsManager) ImageView(android.widget.ImageView)

Example 4 with AnimatedDrawable2

use of com.facebook.fresco.animation.drawable.AnimatedDrawable2 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();
}
Also used : AnimatedDrawable2(com.facebook.fresco.animation.drawable.AnimatedDrawable2) AnimationBackend(com.facebook.fresco.animation.backend.AnimationBackend) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View)

Aggregations

ImageView (android.widget.ImageView)4 AnimatedDrawable2 (com.facebook.fresco.animation.drawable.AnimatedDrawable2)4 View (android.view.View)2 SeekBar (android.widget.SeekBar)2 ToggleButton (android.widget.ToggleButton)2 AnimationBackend (com.facebook.fresco.animation.backend.AnimationBackend)2 AnimationControlsManager (com.facebook.samples.animation2.utils.AnimationControlsManager)2 NoOpCache (com.facebook.fresco.animation.bitmap.cache.NoOpCache)1 SampleAnimationBackendConfigurator (com.facebook.samples.animation2.utils.SampleAnimationBackendConfigurator)1