Search in sources :

Example 1 with PublishClaimTask

use of com.odysee.app.tasks.claim.PublishClaimTask in project odysee-android by OdyseeTeam.

the class PublishFormFragment method publishClaim.

private void publishClaim(Claim claim) {
    String finalFilePath = transcodedFilePath;
    if (Helper.isNullOrEmpty(finalFilePath)) {
        finalFilePath = currentGalleryItem != null ? currentGalleryItem.getFilePath() : currentFilePath;
    }
    saveInProgress = true;
    PublishClaimTask task = new PublishClaimTask(claim, finalFilePath, progressPublish, new ClaimResultHandler() {

        @Override
        public void beforeStart() {
            preSave();
        }

        @Override
        public void onSuccess(Claim claimResult) {
            postSave();
            // Run the logPublish task
            if (!BuildConfig.DEBUG) {
                claimResult.setSigningChannel(claim.getSigningChannel());
                LogPublishTask logPublish = new LogPublishTask(claimResult);
                logPublish.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
            }
            // publish done
            Bundle bundle = new Bundle();
            bundle.putString("claim_id", claimResult.getClaimId());
            bundle.putString("claim_name", claimResult.getName());
            LbryAnalytics.logEvent(editMode ? LbryAnalytics.EVENT_PUBLISH_UPDATE : LbryAnalytics.EVENT_PUBLISH, bundle);
            Context context = getContext();
            if (context instanceof MainActivity) {
                MainActivity activity = (MainActivity) context;
                activity.showMessage(R.string.publish_successful);
                activity.sendBroadcast(new Intent(MainActivity.ACTION_PUBLISH_SUCCESSFUL));
            }
        }

        @Override
        public void onError(Exception error) {
            showError(error.getMessage());
            postSave();
        }
    });
    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Also used : PublishClaimTask(com.odysee.app.tasks.claim.PublishClaimTask) Context(android.content.Context) ClaimResultHandler(com.odysee.app.tasks.claim.ClaimResultHandler) Bundle(android.os.Bundle) LogPublishTask(com.odysee.app.tasks.lbryinc.LogPublishTask) Intent(android.content.Intent) MainActivity(com.odysee.app.MainActivity) Claim(com.odysee.app.model.Claim) JSONException(org.json.JSONException)

Aggregations

Context (android.content.Context)1 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 MainActivity (com.odysee.app.MainActivity)1 Claim (com.odysee.app.model.Claim)1 ClaimResultHandler (com.odysee.app.tasks.claim.ClaimResultHandler)1 PublishClaimTask (com.odysee.app.tasks.claim.PublishClaimTask)1 LogPublishTask (com.odysee.app.tasks.lbryinc.LogPublishTask)1 JSONException (org.json.JSONException)1