Search in sources :

Example 1 with LayoutModel

use of com.moez.QKSMS.model.LayoutModel in project qksms by moezbhatti.

the class SlideshowActivity method onCreate.

@Override
public void onCreate(Bundle icicle) {
    // Play slide-show in full-screen mode.
    supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
    super.onCreate(icicle);
    mHandler = new Handler();
    getWindow().setFormat(PixelFormat.TRANSLUCENT);
    setContentView(R.layout.view_slideshow);
    Intent intent = getIntent();
    Uri msg = intent.getData();
    final SlideshowModel model;
    try {
        model = SlideshowModel.createFromMessageUri(this, msg);
        mSlideCount = model.size();
    } catch (MmsException e) {
        Log.e(TAG, "Cannot present the slide show.", e);
        finish();
        return;
    }
    mSlideView = (SlideView) findViewById(R.id.slide_view);
    new SlideshowPresenter(this, mSlideView, model);
    mHandler.post(new Runnable() {

        private boolean isRotating() {
            return mSmilPlayer.isPausedState() || mSmilPlayer.isPlayingState() || mSmilPlayer.isPlayedState();
        }

        public void run() {
            mSmilPlayer = SmilPlayer.getPlayer();
            if (mSlideCount > 1) {
                // Only show the slideshow controller if we have more than a single slide.
                // Otherwise, when we play a sound on a single slide, it appears like
                // the slide controller should control the sound (seeking, ff'ing, etc).
                initMediaController();
                mSlideView.setMediaController(mMediaController);
            }
            // Use SmilHelper.getDocument() to ensure rebuilding the
            // entire SMIL document.
            mSmilDoc = SmilHelper.getDocument(model);
            if (isMMSConformance(mSmilDoc)) {
                int imageLeft = 0;
                int imageTop = 0;
                int textLeft = 0;
                int textTop = 0;
                LayoutModel layout = model.getLayout();
                if (layout != null) {
                    RegionModel imageRegion = layout.getImageRegion();
                    if (imageRegion != null) {
                        imageLeft = imageRegion.getLeft();
                        imageTop = imageRegion.getTop();
                    }
                    RegionModel textRegion = layout.getTextRegion();
                    if (textRegion != null) {
                        textLeft = textRegion.getLeft();
                        textTop = textRegion.getTop();
                    }
                }
                mSlideView.enableMMSConformanceMode(textLeft, textTop, imageLeft, imageTop);
            }
            if (DEBUG) {
                ByteArrayOutputStream ostream = new ByteArrayOutputStream();
                SmilXmlSerializer.serialize(mSmilDoc, ostream);
                if (LOCAL_LOGV) {
                    Log.v(TAG, ostream.toString());
                }
            }
            // Add event listener.
            ((EventTarget) mSmilDoc).addEventListener(SmilDocumentImpl.SMIL_DOCUMENT_END_EVENT, SlideshowActivity.this, false);
            mSmilPlayer.init(mSmilDoc);
            if (isRotating()) {
                mSmilPlayer.reload();
            } else {
                mSmilPlayer.play();
            }
        }
    });
}
Also used : MmsException(com.google.android.mms.MmsException) SlideshowModel(com.moez.QKSMS.model.SlideshowModel) Handler(android.os.Handler) Intent(android.content.Intent) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Uri(android.net.Uri) RegionModel(com.moez.QKSMS.model.RegionModel) LayoutModel(com.moez.QKSMS.model.LayoutModel)

Aggregations

Intent (android.content.Intent)1 Uri (android.net.Uri)1 Handler (android.os.Handler)1 MmsException (com.google.android.mms.MmsException)1 LayoutModel (com.moez.QKSMS.model.LayoutModel)1 RegionModel (com.moez.QKSMS.model.RegionModel)1 SlideshowModel (com.moez.QKSMS.model.SlideshowModel)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1