use of com.android.mms.model.LayoutModel in project android-aosp-mms by slvn.
the class SlideshowActivity method onCreate.
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
mHandler = new Handler();
// Play slide-show in full-screen mode.
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFormat(PixelFormat.TRANSLUCENT);
setContentView(R.layout.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);
PresenterFactory.getPresenter("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();
}
}
});
}
Aggregations