Search in sources :

Example 61 with Claim

use of com.odysee.app.model.Claim in project odysee-android by OdyseeTeam.

the class ChannelCreateUpdate method call.

@Override
public Claim call() throws ApiCallException {
    Map<String, Object> options = new HashMap<>();
    if (!update) {
        options.put("name", claim.getName());
    } else {
        options.put("claim_id", claim.getClaimId());
    }
    options.put("bid", new DecimalFormat(Helper.SDK_AMOUNT_FORMAT, new DecimalFormatSymbols(Locale.US)).format(deposit.doubleValue()));
    if (!Helper.isNullOrEmpty(claim.getTitle())) {
        options.put("title", claim.getTitle());
    }
    if (!Helper.isNullOrEmpty(claim.getCoverUrl())) {
        options.put("cover_url", claim.getCoverUrl());
    }
    if (!Helper.isNullOrEmpty(claim.getThumbnailUrl())) {
        options.put("thumbnail_url", claim.getThumbnailUrl());
    }
    if (!Helper.isNullOrEmpty(claim.getDescription())) {
        options.put("description", claim.getDescription());
    }
    if (!Helper.isNullOrEmpty(claim.getWebsiteUrl())) {
        options.put("website_url", claim.getWebsiteUrl());
    }
    if (!Helper.isNullOrEmpty(claim.getEmail())) {
        options.put("email", claim.getEmail());
    }
    if (claim.getTags() != null && claim.getTags().size() > 0) {
        options.put("tags", claim.getTags());
    }
    options.put("blocking", true);
    Claim claimResult = null;
    String method = !update ? Lbry.METHOD_CHANNEL_CREATE : Lbry.METHOD_CHANNEL_UPDATE;
    try {
        JSONObject result = (JSONObject) Lbry.authenticatedGenericApiCall(method, options, authToken);
        if (result.has("outputs")) {
            JSONArray outputs = result.getJSONArray("outputs");
            for (int i = 0; i < outputs.length(); i++) {
                JSONObject output = outputs.getJSONObject(i);
                if (output.has("claim_id") && output.has("claim_op")) {
                    claimResult = Claim.claimFromOutput(output);
                    break;
                }
            }
        }
    } catch (ClassCastException | JSONException ex) {
        ex.printStackTrace();
    }
    return claimResult;
}
Also used : DecimalFormatSymbols(java.text.DecimalFormatSymbols) HashMap(java.util.HashMap) DecimalFormat(java.text.DecimalFormat) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException) JSONObject(org.json.JSONObject) JSONObject(org.json.JSONObject) Claim(com.odysee.app.model.Claim)

Example 62 with Claim

use of com.odysee.app.model.Claim in project odysee-android by OdyseeTeam.

the class InlineChannelSpinnerAdapter method addAnonymousPlaceholder.

public void addAnonymousPlaceholder() {
    Claim anonymous = new Claim();
    anonymous.setPlaceholderAnonymous(true);
    insert(anonymous, 0);
    channels.add(0, anonymous);
}
Also used : Claim(com.odysee.app.model.Claim)

Example 63 with Claim

use of com.odysee.app.model.Claim in project odysee-android by OdyseeTeam.

the class InlineChannelSpinnerAdapter method addPlaceholder.

public void addPlaceholder(boolean includeAnonymous) {
    Claim placeholder = new Claim();
    placeholder.setPlaceholder(true);
    insert(placeholder, 0);
    channels.add(0, placeholder);
    if (includeAnonymous) {
        Claim anonymous = new Claim();
        anonymous.setPlaceholderAnonymous(true);
        insert(anonymous, 1);
        channels.add(1, anonymous);
    }
}
Also used : Claim(com.odysee.app.model.Claim)

Example 64 with Claim

use of com.odysee.app.model.Claim 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)

Example 65 with Claim

use of com.odysee.app.model.Claim in project odysee-android by OdyseeTeam.

the class RepostClaimDialogFragment method fetchChannels.

private void fetchChannels() {
    if (Lbry.ownChannels == null || Lbry.ownChannels.size() == 0) {
        startLoading();
        ClaimListTask task = new ClaimListTask(Claim.TYPE_CHANNEL, repostProgress, new ClaimListResultHandler() {

            @Override
            public void onSuccess(List<Claim> claims) {
                Lbry.ownChannels = new ArrayList<>(claims);
                loadChannels(claims);
                finishLoading();
            }

            @Override
            public void onError(Exception error) {
                // could not fetch channels
                Context context = getContext();
                if (context instanceof MainActivity) {
                    ((MainActivity) context).showError(error.getMessage());
                }
                dismiss();
            }
        });
        task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    } else {
        loadChannels(Lbry.ownChannels);
    }
}
Also used : Context(android.content.Context) ClaimListResultHandler(com.odysee.app.tasks.claim.ClaimListResultHandler) ArrayList(java.util.ArrayList) ClaimListTask(com.odysee.app.tasks.claim.ClaimListTask) MainActivity(com.odysee.app.MainActivity) Claim(com.odysee.app.model.Claim)

Aggregations

Claim (com.odysee.app.model.Claim)133 Context (android.content.Context)51 MainActivity (com.odysee.app.MainActivity)44 JSONException (org.json.JSONException)42 View (android.view.View)41 TextView (android.widget.TextView)37 RecyclerView (androidx.recyclerview.widget.RecyclerView)36 ApiCallException (com.odysee.app.exceptions.ApiCallException)36 ArrayList (java.util.ArrayList)32 ImageView (android.widget.ImageView)31 AdapterView (android.widget.AdapterView)29 NestedScrollView (androidx.core.widget.NestedScrollView)28 ClaimListResultHandler (com.odysee.app.tasks.claim.ClaimListResultHandler)26 JSONObject (org.json.JSONObject)26 ExecutionException (java.util.concurrent.ExecutionException)25 TrackSelectionOverride (com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride)24 LbryUriException (com.odysee.app.exceptions.LbryUriException)24 SolidIconView (com.odysee.app.ui.controls.SolidIconView)24 WebView (android.webkit.WebView)23 PhotoView (com.github.chrisbanes.photoview.PhotoView)23