Search in sources :

Example 16 with PublishJob

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

the class SSHUploader 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(SSHSiteController.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, SSHSiteController.SITE_KEY);
    if (Utils.stringNotBlank(path) && (new File(path)).exists()) {
        //  FIXME move to strings.xml
        jobProgress(mJob, 0, "Uploading to SSH server...");
        HashMap<String, String> valueMap = publishJob.getMetadata();
        addValuesToHashmap(valueMap, project.getTitle(), project.getDescription(), path);
        controller.upload(auth.convertToAccountObject(), valueMap);
    } else {
        Timber.d("Can't upload to SSH, 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 SSH server, 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) SiteController(io.scal.secureshare.controller.SiteController) SSHSiteController(io.scal.secureshare.controller.SSHSiteController) File(java.io.File) PublishJob(org.storymaker.app.model.PublishJob)

Example 17 with PublishJob

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

the class YoutubeUploader method start.

@Override
public void start() {
    Timber.d("start()");
    final SiteController controller = SiteController.getSiteController(YoutubeSiteController.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, Auth.SITE_YOUTUBE);
    if (path != null) {
        Handler mainHandler = new Handler(mContext.getMainLooper());
        Runnable myRunnable = new Runnable() {

            @Override
            public void run() {
                Timber.d("run()");
                // FIXME, this might not be wise to run on the main thread youtube, does the youtube SDK automatically run itself on a backgroundthread?
                HashMap<String, String> valueMap = publishJob.getMetadata();
                addValuesToHashmap(valueMap, project.getTitle(), project.getDescription(), path);
                controller.upload(auth.convertToAccountObject(), valueMap);
            }
        };
        mainHandler.post(myRunnable);
    } else {
        Timber.e("youtube upload failed, file path is null");
    }
}
Also used : Project(org.storymaker.app.model.Project) Auth(org.storymaker.app.model.Auth) AuthTable(org.storymaker.app.model.AuthTable) Handler(android.os.Handler) 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