Search in sources :

Example 6 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)

Example 7 with PublishJob

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

the class PublishController method jobFailed.

public void jobFailed(Job job, Exception exception, int errorCode, String errorMessage) {
    Timber.d("jobFailed: " + job + ", with errorCode: " + errorCode + ", and errorMessage: " + errorMessage);
    // TODO need to raise this to the interested activities here
    PublishJob publishJob = job.getPublishJob();
    PublisherBase publisher = getPublisher(publishJob);
    if (publisher != null) {
        publisher.jobFailed(job, exception, errorCode, errorMessage);
    } else {
    // TODO how to handle null publisher?
    }
    mListener.jobFailed(job, errorCode, errorMessage);
}
Also used : PublishJob(org.storymaker.app.model.PublishJob)

Example 8 with PublishJob

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

the class PublishController method startUpload.

//    public void startUpload(Project project, String[] siteKeys, String metadataString) {
public void startUpload(int publishJobId) {
    PublishJob publishJob = getPublishJob(publishJobId);
    PublisherBase publisher = getPublisher(publishJob);
    // TODO this needs to loop a few times until publisher start returns false or something to tell us that the publish job is totally finished
    if (publisher != null) {
        publisher.startUpload();
    }
}
Also used : PublishJob(org.storymaker.app.model.PublishJob)

Example 9 with PublishJob

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

the class PublishController method jobProgress.

/**
     * 
     * @param job
     * @param progress 0 to 1
     * @param message Message displayed to user
     */
public void jobProgress(Job job, float progress, String message) {
    PublishJob publishJob = job.getPublishJob();
    PublisherBase publisher = getPublisher(publishJob);
    if (publisher != null) {
        publisher.jobProgress(job, progress, message);
    } else {
    // TODO how to handle null publisher?
    }
}
Also used : PublishJob(org.storymaker.app.model.PublishJob)

Example 10 with PublishJob

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

the class PublishController method jobSucceeded.

public void jobSucceeded(Job job, String code) {
    Timber.d("jobSucceeded: " + job + ", with code: " + code);
    // TODO need to raise this to the interested activities here
    PublishJob publishJob = job.getPublishJob();
    PublisherBase publisher = getPublisher(publishJob);
    if (publisher != null) {
        publisher.jobSucceeded(job);
    } else {
    // TODO how to handle null publisher?
    }
    mListener.jobSucceeded(job);
}
Also used : 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