Search in sources :

Example 6 with ProjectTable

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);
    }
}
Also used : Project(org.storymaker.app.model.Project) MediaProjectManager(org.storymaker.app.media.MediaProjectManager) FullMetadata(scal.io.liger.model.FullMetadata) Intent(android.content.Intent) Parcelable(android.os.Parcelable) Scene(org.storymaker.app.model.Scene) ProjectTable(org.storymaker.app.model.ProjectTable) IOException(java.io.IOException) ActionBar(android.app.ActionBar)

Aggregations

ProjectTable (org.storymaker.app.model.ProjectTable)6 SQLiteDatabase (net.sqlcipher.database.SQLiteDatabase)4 AudioClipTable (org.storymaker.app.model.AudioClipTable)4 AuthTable (org.storymaker.app.model.AuthTable)4 JobTable (org.storymaker.app.model.JobTable)4 LessonTable (org.storymaker.app.model.LessonTable)4 MediaTable (org.storymaker.app.model.MediaTable)4 PublishJobTable (org.storymaker.app.model.PublishJobTable)4 SceneTable (org.storymaker.app.model.SceneTable)4 TagTable (org.storymaker.app.model.TagTable)4 Nullable (android.support.annotation.Nullable)2 Project (org.storymaker.app.model.Project)2 ActionBar (android.app.ActionBar)1 Intent (android.content.Intent)1 Parcelable (android.os.Parcelable)1 IOException (java.io.IOException)1 MediaProjectManager (org.storymaker.app.media.MediaProjectManager)1 Job (org.storymaker.app.model.Job)1 PublishJob (org.storymaker.app.model.PublishJob)1 Scene (org.storymaker.app.model.Scene)1