Search in sources :

Example 1 with AbandonStreamTask

use of com.odysee.app.tasks.claim.AbandonStreamTask in project odysee-android by OdyseeTeam.

the class PublishesFragment method handleDeleteSelectedClaims.

private void handleDeleteSelectedClaims(List<Claim> selectedClaims) {
    List<String> claimIds = new ArrayList<>();
    for (Claim claim : selectedClaims) {
        claimIds.add(claim.getClaimId());
    }
    if (actionMode != null) {
        actionMode.finish();
    }
    Helper.setViewVisibility(contentList, View.INVISIBLE);
    Helper.setViewVisibility(fabNewPublish, View.INVISIBLE);
    AbandonStreamTask task = new AbandonStreamTask(claimIds, bigLoading, new AbandonHandler() {

        @Override
        public void onComplete(List<String> successfulClaimIds, List<String> failedClaimIds, List<Exception> errors) {
            View root = getView();
            if (root != null) {
                if (failedClaimIds.size() > 0) {
                    Snackbar.make(root, R.string.one_or_more_publishes_failed_abandon, Snackbar.LENGTH_LONG).setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
                } else if (successfulClaimIds.size() == claimIds.size()) {
                    try {
                        String message = getResources().getQuantityString(R.plurals.publishes_deleted, successfulClaimIds.size());
                        Snackbar.make(root, message, Snackbar.LENGTH_LONG).show();
                    } catch (IllegalStateException ex) {
                    // pass
                    }
                }
            }
            Lbry.abandonedClaimIds.addAll(successfulClaimIds);
            if (adapter != null) {
                adapter.setItems(Helper.filterDeletedClaims(adapter.getItems()));
            }
            Helper.setViewVisibility(contentList, View.VISIBLE);
            Helper.setViewVisibility(fabNewPublish, View.VISIBLE);
            checkNoPublishes();
        }
    });
    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Also used : AbandonStreamTask(com.odysee.app.tasks.claim.AbandonStreamTask) ArrayList(java.util.ArrayList) AbandonHandler(com.odysee.app.tasks.claim.AbandonHandler) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) Claim(com.odysee.app.model.Claim)

Example 2 with AbandonStreamTask

use of com.odysee.app.tasks.claim.AbandonStreamTask 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);
    }
}
Also used : AttributeProviderContext(org.commonmark.renderer.html.AttributeProviderContext) Context(android.content.Context) AbandonStreamTask(com.odysee.app.tasks.claim.AbandonStreamTask) AbandonHandler(com.odysee.app.tasks.claim.AbandonHandler) MainActivity(com.odysee.app.MainActivity) TrackSelectionOverride(com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride) Claim(com.odysee.app.model.Claim) LbryRequestException(com.odysee.app.exceptions.LbryRequestException) JSONException(org.json.JSONException) LbryUriException(com.odysee.app.exceptions.LbryUriException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) LbryResponseException(com.odysee.app.exceptions.LbryResponseException) LbryioRequestException(com.odysee.app.exceptions.LbryioRequestException) LbryioResponseException(com.odysee.app.exceptions.LbryioResponseException) ApiCallException(com.odysee.app.exceptions.ApiCallException)

Aggregations

Claim (com.odysee.app.model.Claim)2 AbandonHandler (com.odysee.app.tasks.claim.AbandonHandler)2 AbandonStreamTask (com.odysee.app.tasks.claim.AbandonStreamTask)2 Context (android.content.Context)1 View (android.view.View)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 TrackSelectionOverride (com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride)1 MainActivity (com.odysee.app.MainActivity)1 ApiCallException (com.odysee.app.exceptions.ApiCallException)1 LbryRequestException (com.odysee.app.exceptions.LbryRequestException)1 LbryResponseException (com.odysee.app.exceptions.LbryResponseException)1 LbryUriException (com.odysee.app.exceptions.LbryUriException)1 LbryioRequestException (com.odysee.app.exceptions.LbryioRequestException)1 LbryioResponseException (com.odysee.app.exceptions.LbryioResponseException)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 ExecutionException (java.util.concurrent.ExecutionException)1 AttributeProviderContext (org.commonmark.renderer.html.AttributeProviderContext)1 JSONException (org.json.JSONException)1