use of org.storymaker.app.model.ProjectTable in project storymaker by StoryMaker.
the class SceneEditorActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
//project id
int pid = intent.getIntExtra("pid", -1);
ArrayList<Parcelable> parcelables = intent.getParcelableArrayListExtra(Constants.EXTRA_EXPORT_CLIPS);
mSceneIndex = getIntent().getIntExtra("scene", 0);
if (parcelables != null) {
// FIXME this should be split into a method, probably in the model.Project class?
mProject = new Project(this, 1);
mProject.setTitle("export from liger");
mProject.setTemplatePath("");
mProject.setStoryType(Project.STORY_TYPE_VIDEO);
mProject.save();
Scene scene = new Scene(this, parcelables.size());
scene.setTitle("ligerscene1");
scene.setProjectId(mProject.getId());
scene.setProjectIndex(0);
scene.save();
// FIXME convert export into project
int i = 0;
for (Parcelable p : parcelables) {
// index, cliptype, path, mimetype
FullMetadata m = ((FullMetadata) p);
scene.setMedia(i, m.getFilePath(), m.getFilePath(), "video/mp4");
i++;
}
scene.save();
// FIXME load project
mMPM = new MediaProjectManager(this, getApplicationContext(), mHandlerPub, mProject, scene);
} else if (pid != -1) {
// FIXME ugly
mProject = (Project) (new ProjectTable()).get(getApplicationContext(), pid);
Scene scene = null;
if ((mSceneIndex != -1) && (mSceneIndex < mProject.getScenesAsArray().length)) {
scene = mProject.getScenesAsArray()[mSceneIndex];
}
mMPM = new MediaProjectManager(this, getApplicationContext(), mHandlerPub, mProject, scene);
mMPM.initProject();
} else {
// FIXME get rid of hardcoded clipCount = 5
int clipCount = 5;
String title = intent.getStringExtra("title");
mProject = new Project(getApplicationContext(), clipCount);
mProject.setTitle(title);
mProject.save();
mMPM = new MediaProjectManager(this, getApplicationContext(), mHandlerPub, mProject);
mMPM.initProject();
}
try {
if (mProject.getScenesAsList().size() > 1) {
mTemplate = Template.parseAsset(this, mProject.getTemplatePath(), Project.getSimpleTemplateForMode(getApplicationContext(), mProject.getStoryType()));
} else {
mTemplate = Template.parseAsset(this, Project.getSimpleTemplateForMode(getApplicationContext(), mProject.getStoryType()));
}
} catch (Exception e) {
Timber.e(e, "could not parse templates");
}
setContentView(R.layout.activity_scene_editor_no_swipe);
// Set up the action bar.
final ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
addPublishFragement();
actionBar.setTitle(getString(R.string.tab_publish));
if (intent.hasExtra("auto_capture") && intent.getBooleanExtra("auto_capture", false)) {
openCaptureMode(0, 0);
}
}
Aggregations