use of com.odysee.app.tasks.claim.ClaimSearchResultHandler 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.ClaimSearchResultHandler 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.tasks.claim.ClaimSearchResultHandler in project odysee-android by OdyseeTeam.
the class FollowingFragment method fetchSuggestedChannels.
private void fetchSuggestedChannels() {
if (suggestedClaimSearchLoading) {
return;
}
suggestedClaimSearchLoading = true;
if (discoverDialog != null) {
discoverDialog.setLoading(true);
}
Helper.setViewVisibility(noContentView, View.GONE);
suggestedChannelClaimSearchTask = new ClaimSearchTask(buildSuggestedOptions(), Lbry.API_CONNECTION_STRING, suggestedChannelAdapter == null || suggestedChannelAdapter.getItemCount() == 0 ? bigContentLoading : contentLoading, new ClaimSearchResultHandler() {
@Override
public void onSuccess(List<Claim> claims, boolean hasReachedEnd) {
suggestedHasReachedEnd = hasReachedEnd;
suggestedClaimSearchLoading = false;
if (discoverDialog != null) {
discoverDialog.setLoading(false);
}
if (suggestedChannelAdapter == null) {
suggestedChannelAdapter = new SuggestedChannelGridAdapter(claims, getContext());
suggestedChannelAdapter.setListener(FollowingFragment.this);
if (suggestedChannelGrid != null) {
suggestedChannelGrid.setAdapter(suggestedChannelAdapter);
}
if (discoverDialog != null) {
discoverDialog.setAdapter(suggestedChannelAdapter);
}
} else {
suggestedChannelAdapter.addClaims(claims);
}
if (discoverDialog == null || !discoverDialog.isVisible()) {
checkNoContent(true);
}
}
@Override
public void onError(Exception error) {
suggestedClaimSearchLoading = false;
if (discoverDialog != null) {
discoverDialog.setLoading(false);
}
if (discoverDialog == null || !discoverDialog.isVisible()) {
checkNoContent(true);
}
}
});
suggestedChannelClaimSearchTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Aggregations