use of com.odysee.app.tasks.claim.ClaimSearchTask in project odysee-android by OdyseeTeam.
the class FileViewFragment method resolvePlaylistClaimsAndPlayFirst.
private void resolvePlaylistClaimsAndPlayFirst() {
if (playlistResolved) {
return;
}
Helper.setViewVisibility(layoutLoadingState, View.VISIBLE);
Helper.setViewVisibility(layoutResolving, View.VISIBLE);
Helper.setViewVisibility(layoutNothingAtLocation, View.GONE);
Helper.setViewVisibility(layoutDisplayArea, View.GONE);
Map<String, Object> options = new HashMap<>();
options.put("claim_type", "stream");
options.put("page", 1);
options.put("page_size", 999);
options.put("claim_ids", fileClaim.getClaimIds());
ClaimSearchTask task = new ClaimSearchTask(options, Lbry.API_CONNECTION_STRING, null, new ClaimSearchResultHandler() {
@Override
public void onSuccess(List<Claim> claims, boolean hasReachedEnd) {
playlistResolved = true;
// reorder the claims based on the order in the list, TODO: find a more efficient way to do this
Map<String, Claim> playlistClaimMap = new LinkedHashMap<>();
List<String> claimIds = fileClaim.getClaimIds();
for (String id : claimIds) {
for (Claim claim : claims) {
if (id.equalsIgnoreCase(claim.getClaimId())) {
playlistClaimMap.put(id, claim);
break;
}
}
}
playlistClaims = new ArrayList<>(playlistClaimMap.values());
if (playlistClaims.size() > 0) {
playClaimFromCollection(playlistClaims.get(0), 0);
}
relatedContentAdapter = new ClaimListAdapter(playlistClaims, getContext());
relatedContentAdapter.setListener(FileViewFragment.this);
View root = getView();
if (root != null) {
RecyclerView relatedContentList = root.findViewById(R.id.file_view_related_content_list);
relatedContentList.setAdapter(relatedContentAdapter);
}
}
@Override
public void onError(Exception error) {
showError(getString(R.string.comment_error));
}
});
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
use of com.odysee.app.tasks.claim.ClaimSearchTask in project odysee-android by OdyseeTeam.
the class FollowingFragment method fetchClaimSearchContent.
private 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);
Date d = new Date();
Calendar cal = new GregorianCalendar();
cal.setTime(d);
// Remove claims with a release time in the future
claims.removeIf(e -> {
Claim.GenericMetadata metadata = e.getValue();
return metadata instanceof Claim.StreamMetadata && (((Claim.StreamMetadata) metadata).getReleaseTime()) > (cal.getTimeInMillis() / 1000L);
});
// Sort claims so those which are livestreaming now are shwon on the top of the list
Collections.sort(claims, new Comparator<Claim>() {
@Override
public int compare(Claim claim, Claim t1) {
if (claim.isLive() && !t1.isLive())
return -1;
else if (!claim.isLive() && t1.isLive())
return 1;
else
return 0;
}
});
if (contentListAdapter == null) {
Context context = getContext();
if (context != null) {
contentListAdapter = new ClaimListAdapter(claims, context);
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(false);
}
@Override
public void onError(Exception error) {
contentClaimSearchLoading = false;
checkNoContent(false);
}
});
contentClaimSearchTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
use of com.odysee.app.tasks.claim.ClaimSearchTask in project odysee-android by OdyseeTeam.
the class ChannelContentFragment method fetchClaimSearchContent.
private 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);
if (contentListAdapter == null) {
Context context = getContext();
if (context != null) {
contentListAdapter = new ClaimListAdapter(claims, context);
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.tasks.claim.ClaimSearchTask 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.tasks.claim.ClaimSearchTask 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);
}
Aggregations