use of com.odysee.app.adapter.ClaimListAdapter in project odysee-android by OdyseeTeam.
the class LibraryFragment method initContentListAdapter.
private void initContentListAdapter(List<Claim> claims) {
Context context = getContext();
if (context != null) {
contentListAdapter = new ClaimListAdapter(claims, context);
// contentListAdapter.setCanEnterSelectionMode(currentFilter == FILTER_DOWNLOADS);
contentListAdapter.setCanEnterSelectionMode(true);
contentListAdapter.setSelectionModeListener(this);
contentListAdapter.setHideFee(currentFilter != FILTER_PURCHASES);
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("@")) {
activity.openChannelUrl(claim.getPermanentUrl());
} else {
activity.openFileUrl(claim.getPermanentUrl());
}
}
}
});
}
}
use of com.odysee.app.adapter.ClaimListAdapter in project odysee-android by OdyseeTeam.
the class LibraryFragment method initRecentAdapter.
private void initRecentAdapter(List<Claim> claims) {
Context context = getContext();
if (context != null) {
contentListAdapter = new ClaimListAdapter(claims, ClaimListAdapter.STYLE_SMALL_LIST_HORIZONTAL, context);
// contentListAdapter.setCanEnterSelectionMode(currentFilter == FILTER_DOWNLOADS);
contentListAdapter.setCanEnterSelectionMode(true);
contentListAdapter.setSelectionModeListener(this);
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("@")) {
activity.openChannelUrl(claim.getPermanentUrl());
} else {
activity.openFileUrl(claim.getPermanentUrl());
}
}
}
});
}
}
use of com.odysee.app.adapter.ClaimListAdapter in project odysee-android by OdyseeTeam.
the class PlaylistFragment method onPlaylistLoaded.
private void onPlaylistLoaded(OdyseeCollection collection) {
currentCollection = collection;
if (visibilityIcon != null) {
visibilityIcon.setImageResource(collection.getVisibility() == OdyseeCollection.VISIBILITY_PRIVATE ? R.drawable.ic_private : R.drawable.ic_public);
}
Helper.setViewText(textTitle, collection.getName());
Helper.setViewText(textVideoCount, getResources().getQuantityString(R.plurals.video_count, collection.getItems().size(), collection.getItems().size()));
// load the claims
ResolveTask task = new ResolveTask(collection.getItems(), Lbry.API_CONNECTION_STRING, playlistItemsLoading, new ClaimListResultHandler() {
@Override
public void onSuccess(List<Claim> claims) {
// reorder the claims based on the order in the playlist collection, TODO: find a more efficient way to do this
Map<String, Claim> playlistClaimMap = new LinkedHashMap<>();
List<String> claimIds = new ArrayList<>();
List<String> collectionItems = collection.getItems();
for (int i = 0; i < collectionItems.size(); i++) {
LbryUri url = LbryUri.tryParse(collectionItems.get(i));
if (url != null) {
claimIds.add(url.getClaimId());
}
}
for (String id : claimIds) {
for (Claim claim : claims) {
if (id.equalsIgnoreCase(claim.getClaimId())) {
playlistClaimMap.put(id, claim);
break;
}
}
}
collection.setClaims(new ArrayList<>(playlistClaimMap.values()));
adapter = new ClaimListAdapter(collection.getClaims(), ClaimListAdapter.STYLE_SMALL_LIST, getContext());
adapter.setListener(new ClaimListAdapter.ClaimListItemListener() {
@Override
public void onClaimClicked(Claim claim, int position) {
Context context = getContext();
if (context instanceof MainActivity) {
((MainActivity) context).openPrivatePlaylist(collection, claim, position);
}
}
});
if (playlistList != null) {
playlistList.setAdapter(adapter);
}
}
@Override
public void onError(Exception error) {
// pass
Context context = getContext();
if (context instanceof MainActivity) {
((MainActivity) context).showError(getString(R.string.could_not_load_playlist));
}
}
});
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Aggregations