Search in sources :

Example 1 with StreamRepostTask

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

the class RepostClaimDialogFragment method validateAndRepostClaim.

private void validateAndRepostClaim() {
    String name = Helper.getValue(inputName.getText());
    if (Helper.isNullOrEmpty(name) || !LbryUri.isNameValid(name)) {
        showError(getString(R.string.repost_name_invalid_characters));
        return;
    }
    String depositString = Helper.getValue(inputDeposit.getText());
    if (Helper.isNullOrEmpty(depositString)) {
        showError(getString(R.string.invalid_amount));
        return;
    }
    BigDecimal bid = new BigDecimal(depositString);
    if (bid.doubleValue() > Lbry.getAvailableBalance()) {
        showError(getString(R.string.insufficient_balance));
        return;
    }
    if (bid.doubleValue() < Helper.MIN_DEPOSIT) {
        String message = getResources().getQuantityString(R.plurals.min_deposit_required, 2, String.valueOf(Helper.MIN_DEPOSIT));
        showError(message);
        return;
    }
    Claim channel = (Claim) channelSpinner.getSelectedItem();
    if (channel == null) {
        showError(getString(R.string.please_select_repost_channel));
        return;
    }
    StreamRepostTask task = new StreamRepostTask(name, bid, claim.getClaimId(), channel.getClaimId(), repostProgress, new ClaimResultHandler() {

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

        @Override
        public void onSuccess(Claim claimResult) {
            if (listener != null) {
                listener.onClaimReposted(claimResult);
            }
            finishLoading();
            dismiss();
        }

        @Override
        public void onError(Exception error) {
            showError(error.getMessage());
            finishLoading();
        }
    });
    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Also used : ClaimResultHandler(com.odysee.app.tasks.claim.ClaimResultHandler) StreamRepostTask(com.odysee.app.tasks.claim.StreamRepostTask) BigDecimal(java.math.BigDecimal) Claim(com.odysee.app.model.Claim)

Aggregations

Claim (com.odysee.app.model.Claim)1 ClaimResultHandler (com.odysee.app.tasks.claim.ClaimResultHandler)1 StreamRepostTask (com.odysee.app.tasks.claim.StreamRepostTask)1 BigDecimal (java.math.BigDecimal)1