Search in sources :

Example 1 with DeleteFileTask

use of com.odysee.app.tasks.file.DeleteFileTask in project odysee-android by OdyseeTeam.

the class FileViewFragment method deleteClaimFile.

private void deleteClaimFile() {
    Claim actualClaim = collectionClaimItem != null ? collectionClaimItem : fileClaim;
    if (actualClaim != null) {
        View actionDelete = getView().findViewById(R.id.file_view_action_delete);
        DeleteFileTask task = new DeleteFileTask(actualClaim.getClaimId(), new GenericTaskHandler() {

            @Override
            public void beforeStart() {
                actionDelete.setEnabled(false);
            }

            @Override
            public void onSuccess() {
                Helper.setViewVisibility(actionDelete, View.GONE);
                View root = getView();
                if (root != null) {
                    // root.findViewById(R.id.file_view_action_download).setVisibility(View.VISIBLE);
                    root.findViewById(R.id.file_view_unsupported_container).setVisibility(View.GONE);
                }
                Helper.setViewEnabled(actionDelete, true);
                actualClaim.setFile(null);
                Lbry.unsetFilesForCachedClaims(Arrays.asList(actualClaim.getClaimId()));
                restoreMainActionButton();
            }

            @Override
            public void onError(Exception error) {
                actionDelete.setEnabled(true);
                if (error != null) {
                    showError(error.getMessage());
                }
            }
        });
        task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    }
}
Also used : GenericTaskHandler(com.odysee.app.tasks.GenericTaskHandler) SolidIconView(com.odysee.app.ui.controls.SolidIconView) PlayerView(com.google.android.exoplayer2.ui.PlayerView) NestedScrollView(androidx.core.widget.NestedScrollView) AdapterView(android.widget.AdapterView) RecyclerView(androidx.recyclerview.widget.RecyclerView) PhotoView(com.github.chrisbanes.photoview.PhotoView) ImageView(android.widget.ImageView) View(android.view.View) WebView(android.webkit.WebView) TextView(android.widget.TextView) DeleteFileTask(com.odysee.app.tasks.file.DeleteFileTask) 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

View (android.view.View)1 WebView (android.webkit.WebView)1 AdapterView (android.widget.AdapterView)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 NestedScrollView (androidx.core.widget.NestedScrollView)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 PhotoView (com.github.chrisbanes.photoview.PhotoView)1 TrackSelectionOverride (com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride)1 PlayerView (com.google.android.exoplayer2.ui.PlayerView)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 Claim (com.odysee.app.model.Claim)1 GenericTaskHandler (com.odysee.app.tasks.GenericTaskHandler)1 DeleteFileTask (com.odysee.app.tasks.file.DeleteFileTask)1 SolidIconView (com.odysee.app.ui.controls.SolidIconView)1