FileDocCategorySizeDatePackage
SlideShow.javaAPI DocAndroid 1.5 API12779Wed May 06 22:42:42 BST 2009com.android.camera

SlideShow

public class SlideShow extends android.app.Activity implements ViewSwitcher.ViewFactory

Fields Summary
private static final String
TAG
static final int
sLag
static final int
sNextImageInterval
private com.android.camera.ImageManager.IImageList
mImageList
private int
mCurrentPosition
private android.widget.ImageView
mSwitcher
private boolean
mPosted
private Runnable
mNextImageRunnable
private final android.os.Handler
mHandler
Constructors Summary
Methods Summary
private voidcancelPost()

        mHandler.removeCallbacks(mNextImageRunnable);
        mPosted = false;
    
private voidloadImage()

        ImageManager.IImage image = mImageList.getImageAt(mCurrentPosition);
        if (image == null)
            return;

        Bitmap bitmap = image.thumbBitmap();
        if (bitmap == null)
            return;

        mSwitcher.setImageDrawable(new BitmapDrawable(bitmap));
        post();
    
private voidloadNextImage()


       
        if (++mCurrentPosition >= mImageList.getCount())
            mCurrentPosition = 0;
        loadImage();
    
private voidloadPreviousImage()

        if (mCurrentPosition == 0)
            mCurrentPosition = mImageList.getCount() - 1;
        else
            mCurrentPosition -= 1;

        loadImage();
    
public android.view.ViewmakeView()

        ImageView i = new ImageView(this);
        i.setBackgroundColor(0xFF000000);
        i.setScaleType(ImageView.ScaleType.FIT_CENTER);
        i.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
        return i;
    
protected voidonCreate(android.os.Bundle icicle)


    
       
    
        super.onCreate(icicle);
        Window wp = getWindow();
        wp.setFlags(FLAG_KEEP_SCREEN_ON, FLAG_KEEP_SCREEN_ON);

        setContentView(R.layout.slide_show);

        mSwitcher = (ImageView)findViewById(R.id.imageview);
        if (android.util.Config.LOGV)
            Log.v(TAG, "mSwitcher " + mSwitcher);
    
public booleanonKeyDown(int keyCode, android.view.KeyEvent event)

        switch (keyCode) {
            case KeyEvent.KEYCODE_DPAD_LEFT:
                cancelPost();
                loadPreviousImage();
                return true;

            case KeyEvent.KEYCODE_DPAD_RIGHT:
                cancelPost();
                loadNextImage();
                return true;

            case KeyEvent.KEYCODE_DPAD_CENTER:
                if (mPosted)
                    cancelPost();
                else
                    loadNextImage();
                return true;
        }
        return super.onKeyDown(keyCode, event);
    
protected voidonPause()

        super.onPause();
        cancelPost();
    
protected voidonResume()

        super.onResume();

        if (mImageList == null) {
            mImageList = new FileImageList();
            mCurrentPosition = 0;
        }
        loadImage();
    
private voidpost()

        mHandler.postDelayed(mNextImageRunnable, sNextImageInterval);
        mPosted = true;