use of com.odysee.app.utils.LbryUri in project odysee-android by OdyseeTeam.
the class Subscription method fromClaim.
public static Subscription fromClaim(Claim claim) {
String u = claim.getPermanentUrl();
LbryUri lbryUri = LbryUri.tryParse(u);
if (lbryUri != null)
u = lbryUri.toString();
return new Subscription(claim.getName(), u, false);
}
use of com.odysee.app.utils.LbryUri in project odysee-android by OdyseeTeam.
the class Claim method fromViewHistory.
public static Claim fromViewHistory(ViewHistory viewHistory) {
// only for stream claims
Claim claim = new Claim();
claim.setClaimId(viewHistory.getClaimId());
claim.setName(viewHistory.getClaimName());
claim.setValueType(TYPE_STREAM);
claim.setPermanentUrl(viewHistory.getUri().toString());
claim.setDevice(viewHistory.getDevice());
claim.setConfirmations(1);
StreamMetadata value = new StreamMetadata();
value.setTitle(viewHistory.getTitle());
value.setReleaseTime(viewHistory.getReleaseTime());
if (!Helper.isNullOrEmpty(viewHistory.getThumbnailUrl())) {
Resource thumbnail = new Resource();
thumbnail.setUrl(viewHistory.getThumbnailUrl());
value.setThumbnail(thumbnail);
}
if (viewHistory.getCost() != null && viewHistory.getCost().doubleValue() > 0) {
Fee fee = new Fee();
fee.setAmount(String.valueOf(viewHistory.getCost().doubleValue()));
fee.setCurrency(viewHistory.getCurrency());
value.setFee(fee);
}
claim.setValue(value);
if (!Helper.isNullOrEmpty(viewHistory.getPublisherClaimId())) {
Claim signingChannel = new Claim();
signingChannel.setClaimId(viewHistory.getPublisherClaimId());
signingChannel.setName(viewHistory.getPublisherName());
LbryUri channelUrl = LbryUri.tryParse(String.format("%s#%s", signingChannel.getName(), signingChannel.getClaimId()));
signingChannel.setPermanentUrl(channelUrl != null ? channelUrl.toString() : null);
if (!Helper.isNullOrEmpty(viewHistory.getPublisherTitle())) {
GenericMetadata channelValue = new GenericMetadata();
channelValue.setTitle(viewHistory.getPublisherTitle());
signingChannel.setValue(channelValue);
}
claim.setSigningChannel(signingChannel);
}
return claim;
}
use of com.odysee.app.utils.LbryUri in project odysee-android by OdyseeTeam.
the class ClaimCacheKey method fromClaim.
public static ClaimCacheKey fromClaim(Claim claim) {
ClaimCacheKey key = new ClaimCacheKey();
key.setClaimId(claim.getClaimId());
LbryUri claimUrl = !Helper.isNullOrEmpty(claim.getShortUrl()) ? LbryUri.tryParse(claim.getShortUrl()) : LbryUri.tryParse(claim.getPermanentUrl());
if (claimUrl != null) {
key.setUrl(claimUrl.toString());
}
return key;
}
use of com.odysee.app.utils.LbryUri in project odysee-android by OdyseeTeam.
the class ClaimCacheKey method fromClaimShortUrl.
public static ClaimCacheKey fromClaimShortUrl(Claim claim) {
ClaimCacheKey key = new ClaimCacheKey();
LbryUri url = LbryUri.tryParse(claim.getShortUrl());
if (url != null) {
key.setUrl(url.toString());
}
return key;
}
use of com.odysee.app.utils.LbryUri 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