android 鲁班压缩 Context的使用 luban.with()这里应该使用什么

public class LubanCompressUtils {

//压缩文件存放路径
final static String STOREPATH = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "shop";

/**
 *  压缩文件
 * @param filePath 本地文件路径
 * @param compressListener
 */
public static void compressFile(String filePath,OnCompressListener compressListener){
    File file = new File(filePath);
    Log.e("Luban", "file "+file.getPath() +" "+file.length());
    File directory = new File(STOREPATH);
    if(!directory.exists()){
        directory.mkdir();
    }
    if(file.length() > 1024*1024/2){//是否大于500k
        Luban.with(this)
                .load(file)                                   // 传人要压缩的图片列表
                .ignoreBy(100)                                  // 忽略不压缩图片的大小
                .setTargetDir(STOREPATH)                        // 设置压缩后文件存储位置
                .setCompressListener(compressListener)/*设置回调*/
                .launch();    //启动压缩
    }else {
        compressListener.onSuccess(file);
    }
}

new一个这个监听就行了,然后这个方法会在压缩成功的时候调用,压缩成功了你想进行的处理逻辑谢爱这个方法里面。

再加个Context参数就行了呀

public static void compressFile(Context context,String filePath,OnCompressListener compressListener){
    File file = new File(filePath);
    Log.e("Luban", "file "+file.getPath() +" "+file.length());
    File directory = new File(STOREPATH);
    if(!directory.exists()){
        directory.mkdir();
    }
    if(file.length() > 1024*1024/2){//是否大于500k
        Luban.with(context)
                .load(file)                                   // 传人要压缩的图片列表
                .ignoreBy(100)                                  // 忽略不压缩图片的大小
                .setTargetDir(STOREPATH)                        // 设置压缩后文件存储位置
                .setCompressListener(compressListener)/*设置回调*/
                .launch();    //启动压缩
    }else {
        compressListener.onSuccess(file);
    }
}


compressFile(context,"path",new OnCompressListener(){
            //todo 具体接口实现
        });