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.");
}
}
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);
}
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();
}
}
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?
}
}
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);
}
Aggregations