use of com.odysee.app.model.Claim in project odysee-android by OdyseeTeam.
the class ChannelPlaylistsFragment method fetchClaimSearchPlaylists.
private void fetchClaimSearchPlaylists(boolean reset) {
if (reset && playlistsListAdapter != null) {
playlistsListAdapter.clearItems();
currentClaimSearchPage = 1;
}
playlistsClaimSearchLoading = true;
Helper.setViewVisibility(noPlaylistsView, View.GONE);
Map<String, Object> claimSearchOptions = buildPlaylistsOptions();
// channel claim
ClaimSearchTask playlistsClaimSearchTask = new ClaimSearchTask(claimSearchOptions, Lbry.API_CONNECTION_STRING, getLoadingView(), new ClaimSearchResultHandler() {
@Override
public void onSuccess(List<Claim> claims, boolean hasReachedEnd) {
claims = Helper.filterClaimsByOutpoint(claims);
if (playlistsListAdapter == null) {
Context context = getContext();
if (context != null) {
playlistsListAdapter = new ClaimListAdapter(claims, context);
playlistsListAdapter.setListener(new ClaimListAdapter.ClaimListItemListener() {
@Override
public void onClaimClicked(Claim claim, int position) {
Context context = getContext();
if (context instanceof MainActivity) {
MainActivity activity = (MainActivity) context;
activity.openFileClaim(claim);
}
}
});
}
} else {
playlistsListAdapter.addItems(claims);
}
if (playlistsList != null && playlistsList.getAdapter() == null) {
playlistsList.setAdapter(playlistsListAdapter);
}
playlistsHasReachedEnd = hasReachedEnd;
playlistsClaimSearchLoading = false;
checkNoPlaylists();
}
@Override
public void onError(Exception error) {
playlistsClaimSearchLoading = false;
checkNoPlaylists();
}
});
playlistsClaimSearchTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
use of com.odysee.app.model.Claim in project odysee-android by OdyseeTeam.
the class AllContentFragment method fetchClaimSearchContent.
public void fetchClaimSearchContent(boolean reset) {
if (reset && contentListAdapter != null) {
contentListAdapter.clearItems();
currentClaimSearchPage = 1;
}
contentClaimSearchLoading = true;
Helper.setViewVisibility(noContentView, View.GONE);
Map<String, Object> claimSearchOptions = buildContentOptions();
contentClaimSearchTask = new ClaimSearchTask(claimSearchOptions, Lbry.API_CONNECTION_STRING, getLoadingView(), new ClaimSearchResultHandler() {
@Override
public void onSuccess(List<Claim> claims, boolean hasReachedEnd) {
claims = Helper.filterClaimsByOutpoint(claims);
claims = Helper.filterClaimsByBlockedChannels(claims, Lbryio.blockedChannels);
if (contentListAdapter == null) {
Context context = getContext();
if (context != null) {
contentListAdapter = new ClaimListAdapter(claims, context);
contentListAdapter.setContextGroupId(ALL_CONTENT_CONTEXT_GROUP_ID);
contentListAdapter.setListener(new ClaimListAdapter.ClaimListItemListener() {
@Override
public void onClaimClicked(Claim claim, int position) {
Context context = getContext();
if (context instanceof MainActivity) {
MainActivity activity = (MainActivity) context;
if (claim.getName().startsWith("@")) {
// channel claim
activity.openChannelClaim(claim);
} else {
activity.openFileClaim(claim);
}
}
}
});
}
} else {
contentListAdapter.addItems(claims);
}
if (contentList != null && contentList.getAdapter() == null) {
contentList.setAdapter(contentListAdapter);
}
contentHasReachedEnd = hasReachedEnd;
contentClaimSearchLoading = false;
checkNoContent();
}
@Override
public void onError(Exception error) {
contentClaimSearchLoading = false;
checkNoContent();
}
});
contentClaimSearchTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
use of com.odysee.app.model.Claim in project odysee-android by OdyseeTeam.
the class AllContentFragment method onContextItemSelected.
@Override
public boolean onContextItemSelected(MenuItem item) {
if (item.getGroupId() == ALL_CONTENT_CONTEXT_GROUP_ID && item.getItemId() == R.id.action_block) {
if (contentListAdapter != null) {
int position = contentListAdapter.getPosition();
Claim claim = contentListAdapter.getItems().get(position);
if (claim != null && claim.getSigningChannel() != null) {
Claim channel = claim.getSigningChannel();
Context context = getContext();
if (context instanceof MainActivity) {
((MainActivity) context).handleBlockChannel(channel);
}
}
}
return true;
}
if (item.getGroupId() == ALL_CONTENT_CONTEXT_GROUP_ID) {
if (contentListAdapter != null) {
int position = contentListAdapter.getPosition();
Claim claim = contentListAdapter.getItems().get(position);
String url = claim.getPermanentUrl();
Context context = getContext();
if (context instanceof MainActivity) {
MainActivity activity = (MainActivity) context;
if (item.getItemId() == R.id.action_add_to_watch_later) {
activity.handleAddUrlToList(url, OdyseeCollection.BUILT_IN_ID_WATCHLATER);
} else if (item.getItemId() == R.id.action_add_to_favorites) {
activity.handleAddUrlToList(url, OdyseeCollection.BUILT_IN_ID_FAVORITES);
} else if (item.getItemId() == R.id.action_add_to_lists) {
activity.handleAddUrlToList(url, null);
}
}
}
}
return super.onContextItemSelected(item);
}
use of com.odysee.app.model.Claim in project odysee-android by OdyseeTeam.
the class PurchaseListTask method doInBackground.
protected List<Claim> doInBackground(Void... params) {
List<Claim> claims = null;
try {
Map<String, Object> options = new HashMap<>();
if (!Helper.isNullOrEmpty(claimId)) {
options.put("claim_id", claimId);
}
if (page > 0) {
options.put("page", page);
}
if (pageSize > 0) {
options.put("page_size", pageSize);
}
options.put("resolve", true);
JSONObject result = (JSONObject) Lbry.genericApiCall(Lbry.METHOD_PURCHASE_LIST, options);
JSONArray items = result.getJSONArray("items");
claims = new ArrayList<>();
for (int i = 0; i < items.length(); i++) {
Claim claim = Claim.fromJSONObject(items.getJSONObject(i).getJSONObject("claim"));
if (!Helper.isNullOrEmpty(claim.getClaimId())) {
claims.add(claim);
Lbry.addClaimToCache(claim);
}
}
} catch (ApiCallException | JSONException | ClassCastException ex) {
error = ex;
}
return claims;
}
use of com.odysee.app.model.Claim in project odysee-android by OdyseeTeam.
the class StreamRepostTask method doInBackground.
protected Claim doInBackground(Void... params) {
Claim claimResult = null;
try {
Map<String, Object> options = new HashMap<>();
options.put("name", name);
options.put("bid", new DecimalFormat(Helper.SDK_AMOUNT_FORMAT, new DecimalFormatSymbols(Locale.US)).format(bid.doubleValue()));
options.put("claim_id", claimId);
options.put("channel_id", channelId);
JSONObject result = (JSONObject) Lbry.genericApiCall(Lbry.METHOD_STREAM_REPOST, options);
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 (ApiCallException | ClassCastException | JSONException ex) {
error = ex;
}
return claimResult;
}
Aggregations