package com.zhaohaoting.framework.mvchelper.okhttp.okhttp;

import java.io.IOException;

import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;

/**
 * author：Created by ZHT on 2017/12/26 14:54
 * email：526309416@qq.com
 * desc：文件下载
 */
public class DownloadResultCallback implements Callback {

    private DownloadFile downloadFile;

    @Override
    public void onFailure(final Call call, final IOException e) {
        downloadFile.threadMainFailure(e);
    }

    @Override
    public void onResponse(Call call, Response response) throws IOException {
        downloadFile.downloadAsyn(response);
    }

    public DownloadResultCallback(String fileDir, String fileName, DownloadCallBack downloadCallBack) {
        downloadFile = new DownloadFile(fileDir, fileName, downloadCallBack);
    }
}
