Search in sources :

Example 1 with PublishJob

use of org.storymaker.app.model.PublishJob in project storymaker by StoryMaker.

the class PublishFragment method playClicked.

// private void purgePublishTables() {
// net.sqlcipher.database.SQLiteDatabase db = new StoryMakerDB(getActivity().getBaseContext()).getWritableDatabase("foo");
// (new PublishJobTable(db)).debugPurgeTable();
// (new JobTable(db)).debugPurgeTable();
// db.close();
// }
// public String postToStoryMaker (String title, String desc, String mediaEmbed, String[] categories, String medium, String mediaService, String mediaGuid) throws MalformedURLException, XmlRpcFault
// {
// 
// 
// ServerManager sm = StoryMakerApp.getServerManager();
// sm.setContext(mActivity.getBaseContext());
// 
// Message msgStatus = mHandlerPub.obtainMessage(EditorBaseActivity.REQ_OVERLAY_CAM);
// msgStatus.getData().putString("status",
// getActivity().getString(R.string.uploading_to_storymaker));
// mHandlerPub.sendMessage(msgStatus);
// 
// String descWithMedia = desc + "\n\n" + mediaEmbed;
// String postId = sm.post(title, descWithMedia, categories, medium, mediaService, mediaGuid); // FIXME this is burying an exception if the user skipping creating a StoryMaker.cc account
// 
// String urlPost = sm.getPostUrl(postId);
// return urlPost;
// 
// }
private void playClicked() {
    // FIXME grab the last acceptable render and use it instead of this mFileLastExport junk
    if (mFileLastExport != null && mFileLastExport.exists()) {
        // FIXME replace this with a check to make sure render is suitable
        mActivity.mMPM.mMediaHelper.playMedia(mFileLastExport, null);
    } else {
        mUploading = false;
        mPlaying = true;
        // purgePublishTables(); // FIXME DEBUG disable this once we fix the publish table bugs
        // TODO default to a video spec render and kick it off
        // create a dummy publishjob with no sites
        showPlaySpinner(true);
        PublishJob publishJob = new PublishJob(getActivity().getBaseContext(), mActivity.mProject.getId(), new String[] { "preview" }, null);
        publishJob.save();
        startRender(publishJob);
    }
}
Also used : PublishJob(org.storymaker.app.model.PublishJob)

Example 2 with PublishJob

use of org.storymaker.app.model.PublishJob in project storymaker by StoryMaker.

the class PublishFragment method jobSucceeded.

@Override
public void jobSucceeded(Job job) {
    PublishJob publishJob = job.getPublishJob();
    if (job.getType().equals(JobTable.TYPE_RENDER)) {
        if (mPlaying) {
            showUploadSpinner(false);
            showPlaySpinner(false);
            // FIXME this can be null
            String path = publishJob.getLastRenderFilePath();
            if (path != null) {
                // FIXME this won't work when a upload job succeeds
                mFileLastExport = new File(path);
                Handler handlerTimer = new Handler();
                mProgressText.setText("Complete!");
                handlerTimer.postDelayed(new Runnable() {

                    public void run() {
                        showPlayAndUpload(true);
                    }
                }, 200);
            } else {
                Timber.d("last rendered path is empty!");
            }
            if (mFileLastExport != null && mFileLastExport.exists()) {
                // FIXME replace this with a check to make sure render is suitable
                mActivity.mMPM.mMediaHelper.playMedia(mFileLastExport, null);
            }
            mPlaying = false;
        }
        if (mUploading) {
            startUpload(publishJob);
        }
    } else if (job.getType().equals(JobTable.TYPE_UPLOAD)) {
    // FIXME ???
    }
}
Also used : Handler(android.os.Handler) File(java.io.File) PublishJob(org.storymaker.app.model.PublishJob)

Example 3 with PublishJob

use of org.storymaker.app.model.PublishJob in project storymaker by StoryMaker.

the class RenderWorker method start.

public void start(PublishJob publishJob) {
    // // TODO guard against multiple calls if we are running already
    // //		ArrayList<Job> jobs = (ArrayList<Job>) (new JobTable(db)).getUnfinishedAsList(context, JobTable.TYPE_UPLOAD);
    // //	    SQLiteDatabase db = (new StoryMakerDB(context)).getWritableDatabase("foo");
    // Job job = (new JobTable(null)).getNextUnfinished(mContext, JobTable.TYPE_RENDER, publishJob, null);
    // RendererBase renderer = null;
    // if (job != null) {
    // if (job.isSpec(VideoRenderer.SPEC_KEY)) {
    // renderer = new VideoRenderer(mContext, this, job);
    // } else if (job.isSpec(AudioRenderer.SPEC_KEY)) {
    // renderer = new AudioRenderer(mContext, this, job);
    // } //else if (job.isSpec(Auth.SITE_STORYMAKER)) {
    // //			renderer = new StoryMakerUploader(context, this, job);
    // //		}
    // renderer.start();
    // }
    // TODO guard against multiple calls if we are running already
    // Job job = (new JobTable(null)).getNextUnfinished(mContext, JobTable.TYPE_RENDER, publishJob, null);
    // this should just just grab the new job, ignore old ones for now
    // FIXME extend this to multiple render jobs, for now its hard coded to 1 at a time
    ArrayList<Job> jobs = publishJob.getRenderJobsAsList();
    if (jobs != null && jobs.size() > 0) {
        Job job = jobs.get(0);
        RendererBase renderer = null;
        if (job != null) {
            if (job.isSpec(VideoRenderer.SPEC_KEY)) {
                renderer = new VideoRenderer(mContext, this, job);
            } else if (job.isSpec(AudioRenderer.SPEC_KEY)) {
                renderer = new AudioRenderer(mContext, this, job);
            }
            // FIXME need a slideshow renderer?
            renderer.start();
        }
    } else {
        jobFailed(null, null, 98129129, "No render job in db");
    }
}
Also used : AudioRenderer(org.storymaker.app.publish.sites.AudioRenderer) Job(org.storymaker.app.model.Job) PublishJob(org.storymaker.app.model.PublishJob)

Example 4 with PublishJob

use of org.storymaker.app.model.PublishJob in project storymaker by StoryMaker.

the class FacebookUploader method start.

// FIXME move the render file checks into base class
@Override
public void start() {
    // TODO Auto-generated constructor stub
    final SiteController controller = SiteController.getSiteController(FacebookSiteController.SITE_KEY, mContext, mHandler, "" + mJob.getId());
    final Project project = mJob.getProject();
    final PublishJob publishJob = mJob.getPublishJob();
    final String path = publishJob.getLastRenderFilePath();
    final Auth auth = (new AuthTable()).getAuthDefault(mContext, FacebookSiteController.SITE_KEY);
    if (Utils.stringNotBlank(path) && (new File(path)).exists()) {
        Handler mainHandler = new Handler(mContext.getMainLooper());
        Runnable myRunnable = new Runnable() {

            // facebook seems to freak out if our service's looper is dead when it tries to send message back
            @Override
            public void run() {
                jobProgress(mJob, 0, mContext.getString(R.string.uploading_to_facebook));
                HashMap<String, String> valueMap = publishJob.getMetadata();
                // need to extract raw photos
                // what happened to STORY_TYPE_PHOTO?
                // TODO: currently checking preferences, will revisit when ui is updated
                SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(mContext);
                boolean uploadPhotos = sharedPref.getBoolean("pphotoformat", false);
                if ((publishJob.getProject().getStoryType() == Project.STORY_TYPE_ESSAY) && uploadPhotos) {
                    ArrayList<Media> photos = publishJob.getProject().getMediaAsList();
                    String photoString = "";
                    for (Media photo : photos) {
                        photoString = photoString + photo.getPath() + ";";
                    }
                    // drop trailing ;
                    photoString = photoString.substring(0, photoString.length() - 1);
                    valueMap.put(FacebookSiteController.PHOTO_SET_KEY, photoString);
                }
                addValuesToHashmap(valueMap, project.getTitle(), project.getDescription(), path);
                controller.upload(auth.convertToAccountObject(), valueMap);
            }
        };
        mainHandler.post(myRunnable);
    } else {
        Timber.d("Can't upload to facebook, last rendered file doesn't exist.");
        // TODO get this error back to the activity for display
        // FIXME move to strings.xml
        jobFailed(null, ERROR_NO_RENDER_FILE, "Can't upload to facebook, last rendered file doesn't exist.");
    }
}
Also used : SharedPreferences(android.content.SharedPreferences) AuthTable(org.storymaker.app.model.AuthTable) Media(org.storymaker.app.model.Media) Handler(android.os.Handler) SiteController(io.scal.secureshare.controller.SiteController) FacebookSiteController(io.scal.secureshare.controller.FacebookSiteController) PublishJob(org.storymaker.app.model.PublishJob) Project(org.storymaker.app.model.Project) Auth(org.storymaker.app.model.Auth) File(java.io.File)

Example 5 with PublishJob

use of org.storymaker.app.model.PublishJob in project storymaker by StoryMaker.

the class SoundCloudUploader method start.

// FIXME move the render file checks into base class
@Override
public void start() {
    // TODO Auto-generated constructor stub
    final SiteController controller = SiteController.getSiteController(SoundCloudSiteController.SITE_KEY, mContext, mHandler, "" + mJob.getId());
    final Project project = mJob.getProject();
    final PublishJob publishJob = mJob.getPublishJob();
    final String path = publishJob.getLastRenderFilePath();
    final Auth auth = (new AuthTable()).getAuthDefault(mContext, SoundCloudSiteController.SITE_KEY);
    // FIXME deal with lack of auth credentials here
    if (Utils.stringNotBlank(path) && (new File(path)).exists()) {
        Handler mainHandler = new Handler(mContext.getMainLooper());
        Runnable myRunnable = new Runnable() {

            // facebook seems to freak out if our service's looper is dead when it tries to send message back
            @Override
            public void run() {
                jobProgress(mJob, 0, mContext.getString(R.string.uploading_to_soundcloud));
                HashMap<String, String> valueMap = publishJob.getMetadata();
                addValuesToHashmap(valueMap, project.getTitle(), project.getDescription(), path);
                controller.upload(auth.convertToAccountObject(), valueMap);
            }
        };
        mainHandler.post(myRunnable);
    } else {
        Timber.d("Can't upload to SoundCloud, last rendered file doesn't exist.");
        // TODO get this error back to the activity for display
        // FIXME move to strings.xml
        jobFailed(null, ERROR_NO_RENDER_FILE, "Can't upload to SoundCloud, last rendered file doesn't exist.");
    }
}
Also used : Project(org.storymaker.app.model.Project) Auth(org.storymaker.app.model.Auth) AuthTable(org.storymaker.app.model.AuthTable) Handler(android.os.Handler) SiteController(io.scal.secureshare.controller.SiteController) SoundCloudSiteController(io.scal.secureshare.controller.SoundCloudSiteController) File(java.io.File) PublishJob(org.storymaker.app.model.PublishJob)

Aggregations

PublishJob (org.storymaker.app.model.PublishJob)17 Project (org.storymaker.app.model.Project)7 Handler (android.os.Handler)6 SiteController (io.scal.secureshare.controller.SiteController)6 File (java.io.File)6 Auth (org.storymaker.app.model.Auth)6 AuthTable (org.storymaker.app.model.AuthTable)6 SharedPreferences (android.content.SharedPreferences)2 Job (org.storymaker.app.model.Job)2 Media (org.storymaker.app.model.Media)2 Gson (com.google.gson.Gson)1 ArchiveSiteController (io.scal.secureshare.controller.ArchiveSiteController)1 FacebookSiteController (io.scal.secureshare.controller.FacebookSiteController)1 FlickrSiteController (io.scal.secureshare.controller.FlickrSiteController)1 S3SiteController (io.scal.secureshare.controller.S3SiteController)1 SSHSiteController (io.scal.secureshare.controller.SSHSiteController)1 SoundCloudSiteController (io.scal.secureshare.controller.SoundCloudSiteController)1 HashMap (java.util.HashMap)1 ArchiveUploader (org.storymaker.app.publish.sites.ArchiveUploader)1 AudioRenderer (org.storymaker.app.publish.sites.AudioRenderer)1