use of com.odysee.app.model.Claim 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.model.Claim in project odysee-android by OdyseeTeam.
the class FileViewFragment method loadLastPlaybackPosition.
private long loadLastPlaybackPosition() {
long position = -1;
Claim actualClaim = collectionClaimItem != null ? collectionClaimItem : fileClaim;
if (actualClaim != null) {
String key = String.format("PlayPos_%s", !Helper.isNullOrEmpty(actualClaim.getShortUrl()) ? actualClaim.getShortUrl() : actualClaim.getPermanentUrl());
Context context = getContext();
if (context != null) {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
position = sp.getLong(key, -1);
}
}
return position;
}
use of com.odysee.app.model.Claim in project odysee-android by OdyseeTeam.
the class FileViewFragment method checkOwnClaim.
private void checkOwnClaim() {
Claim claimToCheck = collectionClaimItem != null ? collectionClaimItem : fileClaim;
if (claimToCheck != null) {
boolean isOwnClaim = Lbry.ownClaims.contains(claimToCheck);
View root = getView();
if (root != null) {
Helper.setViewVisibility(root.findViewById(R.id.file_view_action_report), isOwnClaim ? View.GONE : View.VISIBLE);
// TODO Re-enable this when implemented
// Helper.setViewVisibility(root.findViewById(R.id.file_view_action_edit), isOwnClaim ? View.VISIBLE : View.GONE);
// Helper.setViewVisibility(root.findViewById(R.id.file_view_action_unpublish), isOwnClaim ? View.VISIBLE : View.GONE);
LinearLayout fileViewActionsArea = root.findViewById(R.id.file_view_actions_area);
fileViewActionsArea.setWeightSum(isOwnClaim ? 6 : 5);
}
}
}
use of com.odysee.app.model.Claim in project odysee-android by OdyseeTeam.
the class FileViewFragment method playOrViewMedia.
private void playOrViewMedia() {
boolean handled = false;
Claim actualClaim = collectionClaimItem != null ? collectionClaimItem : fileClaim;
String mediaType = actualClaim.getMediaType();
if (!Helper.isNullOrEmpty(mediaType)) {
if (actualClaim.isPlayable()) {
startTimeMillis = System.currentTimeMillis();
showExoplayerView();
playMedia();
handled = true;
} else if (actualClaim.isViewable()) {
// check type and display
boolean fileExists = false;
LbryFile claimFile = actualClaim.getFile();
Uri fileUri = null;
if (claimFile != null && !Helper.isNullOrEmpty(claimFile.getDownloadPath())) {
File file = new File(claimFile.getDownloadPath());
fileUri = Uri.fromFile(file);
fileExists = file.exists();
}
if (!fileExists) {
showError(getString(R.string.claim_file_not_found, claimFile != null ? claimFile.getDownloadPath() : ""));
} else if (fileUri != null) {
View root = getView();
Context context = getContext();
if (root != null) {
if (mediaType.startsWith("image")) {
// display the image
View container = root.findViewById(R.id.file_view_imageviewer_container);
PhotoView photoView = root.findViewById(R.id.file_view_imageviewer);
if (context != null) {
Glide.with(context.getApplicationContext()).load(fileUri).centerInside().into(photoView);
}
container.setVisibility(View.VISIBLE);
} else if (mediaType.startsWith("text")) {
// show web view (and parse markdown too)
View container = root.findViewById(R.id.file_view_webview_container);
initWebView(root);
applyThemeToWebView();
if (Arrays.asList("text/markdown", "text/md").contains(mediaType.toLowerCase())) {
loadMarkdownFromFile(claimFile.getDownloadPath());
} else {
webView.loadUrl(fileUri.toString());
}
container.setVisibility(View.VISIBLE);
}
}
handled = true;
}
} else {
openClaimExternally(actualClaim, mediaType);
}
}
if (!handled) {
showUnsupportedView();
}
}
use of com.odysee.app.model.Claim in project odysee-android by OdyseeTeam.
the class ChannelFormFragment method buildChannelClaimToSave.
private Claim buildChannelClaimToSave() {
Claim claim = new Claim();
String name = Helper.getValue(inputChannelName.getText());
if (!name.startsWith("@")) {
name = String.format("@%s", name);
}
claim.setName(name);
if (currentClaim != null) {
claim.setClaimId(currentClaim.getClaimId());
}
Claim.ChannelMetadata metadata = new Claim.ChannelMetadata();
metadata.setTitle(Helper.getValue(inputTitle.getText()));
metadata.setDescription(Helper.getValue(inputDescription.getText()));
metadata.setWebsiteUrl(Helper.getValue(inputWebsite.getText()));
metadata.setEmail(Helper.getValue(inputEmail.getText()));
Claim.Resource cover = new Claim.Resource();
cover.setUrl(coverUrl == null ? "" : coverUrl);
Claim.Resource thumbnail = new Claim.Resource();
thumbnail.setUrl(thumbnailUrl == null ? "" : thumbnailUrl);
metadata.setThumbnail(thumbnail);
metadata.setCover(cover);
List<Tag> addedTags = addedTagsAdapter != null ? new ArrayList<>(addedTagsAdapter.getTags()) : new ArrayList<>();
metadata.setTags(Helper.getTagsForTagObjects(addedTags));
claim.setValue(metadata);
return claim;
}
Aggregations