FileDocCategorySizeDatePackage
SlideshowEditor.javaAPI DocAndroid 1.5 API5657Wed May 06 22:42:46 BST 2009com.android.mms.ui

SlideshowEditor

public class SlideshowEditor extends Object
An utility to edit contents of a slide.

Fields Summary
private static final String
TAG
private static final int
MAX_SLIDE_NUM
private final android.content.Context
mContext
private final com.android.mms.model.SlideshowModel
mModel
Constructors Summary
public SlideshowEditor(android.content.Context context, com.android.mms.model.SlideshowModel model)


         
        mContext = context;
        mModel = model;
    
Methods Summary
public booleanaddNewSlide()
Add a new slide to the end of message.

return
true if success, false if reach the max slide number.

        int position = mModel.size();
        return addNewSlide(position);
    
public booleanaddNewSlide(int position)
Add a new slide at the specified position in the message.

return
true if success, false if reach the max slide number.
throws
IndexOutOfBoundsException - if position is out of range (position < 0 || position > size()).

        int size = mModel.size();
        if (size < MAX_SLIDE_NUM) {
            SlideModel slide = new SlideModel(mModel);

            TextModel text = new TextModel(
                    mContext, ContentType.TEXT_PLAIN, "text_" + size + ".txt",
                    mModel.getLayout().getTextRegion());
            slide.add(text);

            mModel.add(position, slide);
            return true;
        } else {
            Log.w(TAG, "The limitation of the number of slides is reached.");
            return false;
        }
    
public voidchangeAudio(int position, android.net.Uri newAudio)

        AudioModel audio = new AudioModel(mContext, newAudio);
        SlideModel slide = mModel.get(position);
        slide.add(audio);
        slide.updateDuration(audio.getDuration());
    
public voidchangeDuration(int position, int dur)

        if (dur >= 0) {
            mModel.get(position).setDuration(dur);
        }
    
public voidchangeImage(int position, android.net.Uri newImage)

        mModel.get(position).add(new ImageModel(
                mContext, newImage, mModel.getLayout().getImageRegion()));
    
public voidchangeLayout(int layout)

        mModel.getLayout().changeTo(layout);
    
public voidchangeText(int position, java.lang.String newText)

        if (newText != null) {
            SlideModel slide = mModel.get(position);
            TextModel text = slide.getText();
            if (text == null) {
                text = new TextModel(mContext,
                        ContentType.TEXT_PLAIN, "text_" + position + ".txt",
                        mModel.getLayout().getTextRegion());
                text.setText(newText);
                slide.add(text);
            } else if (!newText.equals(text.getText())) {
                text.setText(newText);
            }
        }
    
public voidchangeVideo(int position, android.net.Uri newVideo)

        VideoModel video = new VideoModel(mContext, newVideo,
                mModel.getLayout().getImageRegion());
        SlideModel slide = mModel.get(position);
        slide.add(video);
        slide.updateDuration(video.getDuration());
    
public com.android.mms.model.RegionModelgetImageRegion()

        return mModel.getLayout().getImageRegion();
    
public com.android.mms.model.RegionModelgetTextRegion()

        return mModel.getLayout().getTextRegion();
    
public voidmoveSlideDown(int position)

        mModel.add(position + 1, mModel.remove(position));
    
public voidmoveSlideUp(int position)

        mModel.add(position - 1, mModel.remove(position));
    
public voidremoveAllSlides()
Remove all slides.

        while (mModel.size() > 0) {
            removeSlide(0);
        }
    
public booleanremoveAudio(int position)

        return mModel.get(position).removeAudio();
    
public booleanremoveImage(int position)

        return mModel.get(position).removeImage();
    
public voidremoveSlide(int position)
Remove one slide.

param
position

        mModel.remove(position);
    
public booleanremoveText(int position)
Remove the text of the specified slide.

param
position index of the slide
return
true if success, false if no text in the slide.

        return mModel.get(position).removeText();
    
public booleanremoveVideo(int position)

        return mModel.get(position).removeVideo();