package in.techware.carrefour.net.WSTasks;

import android.os.AsyncTask;

import in.techware.carrefour.util.FTPUtil;

/**
 * Created by Jemsheer K D on 26 July, 2018.
 * Package in.techware.carrefour.net.WSTasks
 * Project Carrefour
 */
public class FTPUploadTask extends AsyncTask<String, Integer, Boolean> {

    private String filePath = "";
    private FTPUploadTaskListener ftpUploadTaskListener;


    public FTPUploadTask(String filePath) {
        super();
        this.filePath = filePath;
    }

    @Override
    protected Boolean doInBackground(String... params) {
        return FTPUtil.INSTANCE.uploadFile(filePath);
    }

    @Override
    protected void onPostExecute(Boolean result) {
        super.onPostExecute(result);
        if (result)
            ftpUploadTaskListener.dataDownloadedSuccessfully(true);
        else
            ftpUploadTaskListener.dataDownloadFailed();
    }

    public static interface FTPUploadTaskListener {
        void dataDownloadedSuccessfully(Boolean result);

        void dataDownloadFailed();
    }

    public FTPUploadTaskListener getFTPUploadTaskListener() {
        return ftpUploadTaskListener;
    }

    public void setFTPUploadTaskListener(FTPUploadTaskListener ftpUploadTaskListener) {
        this.ftpUploadTaskListener = ftpUploadTaskListener;
    }
}
