use of com.odysee.app.adapter.ClaimListAdapter in project odysee-android by OdyseeTeam.
the class PublishesFragment method fetchPublishes.
private void fetchPublishes() {
Helper.setViewVisibility(emptyView, View.GONE);
ClaimListTask task = new ClaimListTask(Arrays.asList(Claim.TYPE_STREAM, Claim.TYPE_REPOST), getLoading(), new ClaimListResultHandler() {
@Override
public void onSuccess(List<Claim> claims) {
Lbry.ownClaims = Helper.filterDeletedClaims(new ArrayList<>(claims));
if (adapter == null) {
Context context = getContext();
if (context != null) {
adapter = new ClaimListAdapter(claims, context);
adapter.setCanEnterSelectionMode(true);
adapter.setSelectionModeListener(PublishesFragment.this);
adapter.setListener(new ClaimListAdapter.ClaimListItemListener() {
@Override
public void onClaimClicked(Claim claim, int position) {
if (context instanceof MainActivity) {
MainActivity activity = (MainActivity) context;
if (claim.getName().startsWith("@")) {
activity.openChannelClaim(claim);
} else {
activity.openFileClaim(claim);
}
}
}
});
if (contentList != null) {
contentList.setAdapter(adapter);
}
}
} else {
adapter.setItems(claims);
}
checkNoPublishes();
}
@Override
public void onError(Exception error) {
checkNoPublishes();
}
});
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
use of com.odysee.app.adapter.ClaimListAdapter in project odysee-android by OdyseeTeam.
the class ChannelManagerFragment method fetchChannels.
private void fetchChannels() {
Helper.setViewVisibility(emptyView, View.GONE);
AccountManager am = AccountManager.get(getContext());
Account odyseeAccount = Helper.getOdyseeAccount(am.getAccounts());
String authToken = am.peekAuthToken(odyseeAccount, "auth_token_type");
MainActivity activity = (MainActivity) getActivity();
final View progressView = getLoading();
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
progressView.setVisibility(View.VISIBLE);
Supplier<List<Claim>> s = new ClaimListSupplier(Collections.singletonList(Claim.TYPE_CHANNEL), authToken);
CompletableFuture<List<Claim>> cf = CompletableFuture.supplyAsync(s);
cf.whenComplete((result, e) -> {
if (e != null && activity != null) {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
Throwable t = e.getCause();
if (t != null) {
activity.showError(t.getMessage());
}
}
});
}
if (result != null && activity != null) {
activity.runOnUiThread(new Runnable() {
public void run() {
Lbry.ownChannels = Helper.filterDeletedClaims(new ArrayList<>(result));
if (adapter == null) {
Context context = getContext();
if (context != null) {
adapter = new ClaimListAdapter(result, context);
adapter.setCanEnterSelectionMode(true);
adapter.setSelectionModeListener(ChannelManagerFragment.this);
adapter.setListener(new ClaimListAdapter.ClaimListItemListener() {
@Override
public void onClaimClicked(Claim claim, int position) {
if (context instanceof MainActivity) {
((MainActivity) context).openChannelClaim(claim);
}
}
});
if (channelList != null) {
channelList.setAdapter(adapter);
}
}
} else {
adapter.setItems(result);
}
checkNoChannels();
}
});
}
if (activity != null)
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
progressView.setVisibility(View.GONE);
}
});
});
} else {
ClaimListTask task = new ClaimListTask(Claim.TYPE_CHANNEL, getLoading(), Lbryio.AUTH_TOKEN, new ClaimListResultHandler() {
@Override
public void onSuccess(List<Claim> claims) {
Lbry.ownChannels = Helper.filterDeletedClaims(new ArrayList<>(claims));
if (adapter == null) {
Context context = getContext();
if (context != null) {
adapter = new ClaimListAdapter(claims, context);
adapter.setCanEnterSelectionMode(true);
adapter.setSelectionModeListener(ChannelManagerFragment.this);
adapter.setListener(new ClaimListAdapter.ClaimListItemListener() {
@Override
public void onClaimClicked(Claim claim, int position) {
if (context instanceof MainActivity) {
((MainActivity) context).openChannelClaim(claim);
}
}
});
if (channelList != null) {
channelList.setAdapter(adapter);
}
}
} else {
adapter.setItems(claims);
}
checkNoChannels();
}
@Override
public void onError(Exception error) {
checkNoChannels();
}
});
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
use of com.odysee.app.adapter.ClaimListAdapter 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.adapter.ClaimListAdapter 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.adapter.ClaimListAdapter 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