Search in sources :

Example 1 with AbandonChannelTask

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

the class ChannelFragment method deleteCurrentClaim.

private void deleteCurrentClaim() {
    if (claim != null) {
        Helper.setViewVisibility(layoutDisplayArea, View.GONE);
        Helper.setViewVisibility(layoutLoadingState, View.VISIBLE);
        AbandonChannelTask task = new AbandonChannelTask(Collections.singletonList(claim.getClaimId()), layoutResolving, Lbryio.AUTH_TOKEN, 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.channel_deleted);
                        activity.onBackPressed();
                    } else {
                        View root = getView();
                        if (root != null) {
                            Snackbar.make(root, R.string.channel_failed_delete, Snackbar.LENGTH_LONG).setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
                        }
                    }
                }
            }
        });
        task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    }
}
Also used : Context(android.content.Context) AbandonChannelTask(com.odysee.app.tasks.claim.AbandonChannelTask) AbandonHandler(com.odysee.app.tasks.claim.AbandonHandler) MainActivity(com.odysee.app.MainActivity) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) SolidIconView(com.odysee.app.ui.controls.SolidIconView) OutlineIconView(com.odysee.app.ui.controls.OutlineIconView) LbryUriException(com.odysee.app.exceptions.LbryUriException)

Example 2 with AbandonChannelTask

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

the class ChannelManagerFragment 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(channelList, View.INVISIBLE);
    Helper.setViewVisibility(fabNewChannel, View.INVISIBLE);
    AbandonChannelTask task = new AbandonChannelTask(claimIds, bigLoading, Lbryio.AUTH_TOKEN, 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_channels_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.channels_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(channelList, View.VISIBLE);
            Helper.setViewVisibility(fabNewChannel, View.VISIBLE);
            checkNoChannels();
        }
    });
    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Also used : AbandonChannelTask(com.odysee.app.tasks.claim.AbandonChannelTask) 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)

Aggregations

View (android.view.View)2 AbandonChannelTask (com.odysee.app.tasks.claim.AbandonChannelTask)2 AbandonHandler (com.odysee.app.tasks.claim.AbandonHandler)2 Context (android.content.Context)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 MainActivity (com.odysee.app.MainActivity)1 LbryUriException (com.odysee.app.exceptions.LbryUriException)1 Claim (com.odysee.app.model.Claim)1 OutlineIconView (com.odysee.app.ui.controls.OutlineIconView)1 SolidIconView (com.odysee.app.ui.controls.SolidIconView)1 ArrayList (java.util.ArrayList)1