FileDocCategorySizeDatePackage
AnimatedGifTest.javaAPI DocAndroid 5.1 API4104Thu Mar 12 22:22:48 GMT 2015com.android.rastermill.samples

AnimatedGifTest

public class AnimatedGifTest extends android.app.Activity

Fields Summary
android.support.rastermill.FrameSequenceDrawable
mDrawable
final CheckingProvider
mProvider
Constructors Summary
Methods Summary
public voidonCreate(android.os.Bundle savedInstanceState)


    
        
        super.onCreate(savedInstanceState);

        setContentView(R.layout.basic_test_activity);
        findViewById(R.id.start).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mDrawable.start();
            }
        });
        findViewById(R.id.stop).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mDrawable.stop();
            }
        });
        findViewById(R.id.vis).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mDrawable.setVisible(true, true);
            }
        });
        findViewById(R.id.invis).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mDrawable.setVisible(false, true);
            }
        });
    
protected voidonPause()

        super.onPause();
        ImageView imageView = (ImageView) findViewById(R.id.imageview);

        mDrawable.destroy();
        if (!mProvider.isEmpty()) throw new IllegalStateException("All bitmaps not recycled");

        mDrawable = null;
        imageView.setImageDrawable(null);

    
protected voidonResume()

        super.onResume();

        ImageView imageView = (ImageView) findViewById(R.id.imageview);
        InputStream is = getResources().openRawResource(R.raw.animated);

        FrameSequence fs = FrameSequence.decodeStream(is);
        mDrawable = new FrameSequenceDrawable(fs, mProvider);
        mDrawable.setOnFinishedListener(new FrameSequenceDrawable.OnFinishedListener() {
            @Override
            public void onFinished(FrameSequenceDrawable drawable) {
                Toast.makeText(getApplicationContext(),
                        "THE ANIMATION HAS FINISHED", Toast.LENGTH_SHORT).show();
            }
        });
        imageView.setImageDrawable(mDrawable);