0

I'm trying to delete a file without allowing the user to make further input to the application which is why I'm using an AsyncTask to show a Process Dialog while the delete occurs. I have the following code:

public class EpgActionProcessor {
    private final Logger logger;
    private final IAdrAccountManager accountManager;
    private ProgressDialogFragment fragment;
    private MiddlewareAsyncOperationProcessor<EpgDeleterWorkItem> processorDeleteItem;
    private MiddlewareAsyncOperationProcessor<EpgScheduleWorkItem> processorScheduleItem;

    @Inject
    public EpgActionProcessor(Logger logger, IAdrAccountManager accountManager) {
        this.logger = logger;
        this.accountManager = accountManager;
    }


    public boolean deleteRecording(ActivityBase activity, EpgBrowserCurrentItem epgCurrent, AsyncOperationListener<EpgDeleterWorkItem>
            asyncOperationListener) {

        Opt<EpgProgramInfo> info = epgCurrent.getEpgProgramInfo();
        if (!info.isPresent()) {
            return false;
        }

        DeleteRecordingParams params = new DeleteRecordingParams(info, activity, asyncOperationListener);
        DeletePartialRecordingTask task = new DeletePartialRecordingTask(params);
        task.execute(params);
        return true;
    }

    private class DeletePartialRecordingTask extends AsyncTask<DeleteRecordingParams,Void,Void> {
        private Opt<EpgProgramInfo> info;
        private ActivityBase activityBase;
        private AsyncOperationListener asyncOperationListener;

        DeletePartialRecordingTask(DeleteRecordingParams deleteRecordingParams){
            this.info = deleteRecordingParams.info;
            this.activityBase = deleteRecordingParams.activity;
            this.asyncOperationListener = deleteRecordingParams.asyncOperationListener;
        }

        @Override
        protected void onPreExecute() {
            // Show dialog indicating that content is being deleted 
            if(fragment == null){
                    fragment = (ProgressDialogFragment) activityBase.getSupportFragmentManager().findFragmentByTag(ProgressDialogFragment.class
                            .getSimpleName());
                }
                if (fragment != null) {
                    fragment.setTitle("Deleting content...");
                }                
            }



        @Override
        protected Void doInBackground(DeleteRecordingParams params) {
            //Delete
            CMwEpgProgramDeleteScheduledWorkerEnabler enabler = info.get().getScheduledRecordingDeleter();
            IMwEpgProgramDeleteScheduledWorker worker = enabler.getWorkItem();
            worker.shouldDeletePartialRecording(true);
            processorDeleteItem = new MiddlewareAsyncOperationProcessor<EpgDeleterWorkItem>(
                new EpgDeleterWorkItem(worker),
                accountManager,
                asyncOperationListener,
                logger);
            processorDeleteItem.start();
            enabler.enable();
            return null;
        }

        @Override
        protected void onPostExecute(Void result){
            super.onPostExecute(result);
            fragment.dismiss();
            fragment = null;
        }
    }

    private static class DeleteRecordingParams {
        Opt<EpgProgramInfo> info;
        ActivityBase activity;
        AsyncOperationListener asyncOperationListener;

        DeleteRecordingParams(Opt<EpgProgramInfo> info, ActivityBase activity, AsyncOperationListener asyncOperationListener){
            this.info = info;
            this.activity = activity;
            this.asyncOperationListener = asyncOperationListener;
        }
    }
}

I've been following the implementations from these two posts: How to use AsyncTask correctly in Android and How can you pass multiple primitive parameters to AsyncTask?

However, I am still getting the following error: EpgActionProcessor.DeletePartialRecordingTask is not abstract and does not override abstract method doInBackground(DeleteRecordingParams...) in AsyncTask

Community
  • 1
  • 1
Jvalant Dave
  • 511
  • 1
  • 3
  • 18
  • `doInBackground(DeleteRecordingParams...)` - Notice the trailing `...` on the parameter type. It's a varargs parameter. – Mike M. Dec 01 '16 at 19:01
  • 1
    @MikeM. Wow that did it, I knew it had to be something simple that would slap me in the face once pointed out to me. Thank you so much! – Jvalant Dave Dec 01 '16 at 19:11

0 Answers0