use of com.odysee.app.model.Claim in project odysee-android by OdyseeTeam.
the class FileViewFragment method deleteCurrentClaim.
private void deleteCurrentClaim() {
Claim actualClaim = collectionClaimItem != null ? collectionClaimItem : fileClaim;
if (actualClaim != null) {
Helper.setViewVisibility(layoutDisplayArea, View.INVISIBLE);
Helper.setViewVisibility(layoutLoadingState, View.VISIBLE);
Helper.setViewVisibility(layoutNothingAtLocation, View.GONE);
AbandonStreamTask task = new AbandonStreamTask(Arrays.asList(actualClaim.getClaimId()), layoutResolving, new AbandonHandler() {
@Override
public void onComplete(List<String> successfulClaimIds, List<String> failedClaimIds, List<Exception> errors) {
Context context = getContext();
if (context instanceof MainActivity) {
if (failedClaimIds.size() == 0) {
MainActivity activity = (MainActivity) context;
activity.showMessage(R.string.content_deleted);
activity.onBackPressed();
} else {
showError(getString(R.string.content_failed_delete));
}
}
}
});
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
use of com.odysee.app.model.Claim in project odysee-android by OdyseeTeam.
the class FileViewFragment method doFollowUnfollow.
private void doFollowUnfollow(boolean isFollowing, View view) {
Claim actualClaim = collectionClaimItem != null ? collectionClaimItem : fileClaim;
if (actualClaim != null && actualClaim.getSigningChannel() != null) {
Claim publisher = actualClaim.getSigningChannel();
Subscription subscription = Subscription.fromClaim(publisher);
view.setEnabled(false);
Context context = getContext();
new ChannelSubscribeTask(context, publisher.getClaimId(), subscription, isFollowing, new ChannelSubscribeTask.ChannelSubscribeHandler() {
@Override
public void onSuccess() {
if (isFollowing) {
Lbryio.removeSubscription(subscription);
Lbryio.removeCachedResolvedSubscription(publisher);
} else {
Lbryio.addSubscription(subscription);
Lbryio.addCachedResolvedSubscription(publisher);
}
view.setEnabled(true);
checkIsFollowing();
FollowingFragment.resetClaimSearchContent = true;
// Save shared user state
if (context != null) {
context.sendBroadcast(new Intent(MainActivity.ACTION_SAVE_SHARED_USER_STATE));
}
}
@Override
public void onError(Exception exception) {
view.setEnabled(true);
}
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
use of com.odysee.app.model.Claim in project odysee-android by OdyseeTeam.
the class FileViewFragment method startDownload.
public void startDownload() {
downloadInProgress = true;
View root = getView();
if (root != null) {
Helper.setViewVisibility(root.findViewById(R.id.file_view_download_progress), View.VISIBLE);
((ImageView) root.findViewById(R.id.file_view_action_download_icon)).setImageResource(R.drawable.ic_stop);
}
Claim actualClaim = collectionClaimItem != null ? collectionClaimItem : fileClaim;
if (!actualClaim.isFree()) {
downloadRequested = true;
onMainActionButtonClicked();
} else {
// download the file
fileGet(true);
}
}
use of com.odysee.app.model.Claim in project odysee-android by OdyseeTeam.
the class FileViewFragment method checkAndLoadComments.
private void checkAndLoadComments(boolean forceReload) {
View root = getView();
if (root != null) {
Claim actualClaim = collectionClaimItem != null ? collectionClaimItem : fileClaim;
View expandCommentArea = root.findViewById(R.id.expand_commentarea_button);
View commentsDisabledText = root.findViewById(R.id.file_view_disabled_comments);
RecyclerView commentsList = root.findViewById(R.id.file_view_comments_list);
commentLoadingArea.setVisibility(View.VISIBLE);
commentEnabledCheck.checkCommentStatus(actualClaim.getSigningChannel().getClaimId(), actualClaim.getSigningChannel().getName(), (CommentEnabledCheck.CommentStatus) isEnabled -> {
Activity activity = getActivity();
if (activity != null) {
activity.runOnUiThread(() -> {
if (isEnabled) {
showComments(expandCommentArea, commentsDisabledText, commentsList);
if ((commentsList != null && forceReload) || (commentsList == null || commentsList.getAdapter() == null || commentsList.getAdapter().getItemCount() == 0)) {
loadComments();
}
} else {
hideComments(expandCommentArea, commentsDisabledText, commentsList);
}
commentLoadingArea.setVisibility(View.GONE);
});
}
});
}
}
use of com.odysee.app.model.Claim in project odysee-android by OdyseeTeam.
the class FileViewFragment method loadViewCount.
private void loadViewCount() {
Claim actualClaim = collectionClaimItem != null ? collectionClaimItem : fileClaim;
if (actualClaim != null) {
FetchStatCountTask task = new FetchStatCountTask(FetchStatCountTask.STAT_VIEW_COUNT, actualClaim.getClaimId(), null, new FetchStatCountTask.FetchStatCountHandler() {
@Override
public void onSuccess(int count) {
try {
String displayText = getResources().getQuantityString(R.plurals.view_count, count, NumberFormat.getInstance().format(count));
View root = getView();
if (root != null) {
TextView textViewCount = root.findViewById(R.id.file_view_view_count);
Helper.setViewText(textViewCount, displayText);
Helper.setViewVisibility(textViewCount, View.VISIBLE);
}
} catch (IllegalStateException ex) {
// pass
}
}
@Override
public void onError(Exception error) {
// pass
}
});
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
Aggregations