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;
}
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);
}
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);
}
}
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);
}
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);
}
}
Aggregations