当前位置: 首页>>代码示例>>Java>>正文


Java OnCompressListener类代码示例

本文整理汇总了Java中top.zibin.luban.OnCompressListener的典型用法代码示例。如果您正苦于以下问题:Java OnCompressListener类的具体用法?Java OnCompressListener怎么用?Java OnCompressListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


OnCompressListener类属于top.zibin.luban包,在下文中一共展示了OnCompressListener类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: commpress

import top.zibin.luban.OnCompressListener; //导入依赖的package包/类
/**
 * 压缩图片 默认压缩3档  4:质量压缩,尺寸不变,清晰度最好  3 1 都压缩,1的质量不好
 * @param context
 * @param path
 * @param pressedPath
 * @param target
 */
public static void commpress(Context context, String path, String pressedPath, final OnCommpressTarget target){
    Luban.with(context)
            .load(path)                                   // 传人要压缩的图片列表
            .setTargetDir(pressedPath)                        // 设置压缩后文件存储位置
            .ignoreBy(100)
            .setCompressListener(new OnCompressListener() { //设置回调
                @Override
                public void onStart() {
                    // TODO 压缩开始前调用,可以在方法内启动 loading UI
                }

                @Override
                public void onSuccess(File file) {
                    // TODO 压缩成功后调用,返回压缩后的图片文件
                    target.pressSuccess(file);
                }

                @Override
                public void onError(Throwable e) {
                    // TODO 当压缩过程出现问题时调用
                    target.pressFailue(e);
                }
            }).launch();    //启动压缩
}
 
开发者ID:funnyzhaov,项目名称:Tribe,代码行数:32,代码来源:OvCompress.java

示例2: compressByLuban

import top.zibin.luban.OnCompressListener; //导入依赖的package包/类
private void compressByLuban(final List<String> path) {
    final List<String> resultTemp = new ArrayList<>();
    for (String str : path) {
        Luban.get(this).load(new File(str))
                .setCompressListener(new OnCompressListener() {
                    @Override
                    public void onStart() {

                    }

                    @Override
                    public void onSuccess(File file) {
                        resultTemp.add(file.getAbsolutePath());
                        if (resultTemp.size() == path.size()) {
                            toast("压缩完成");
                            setupResultInfo(resultTemp);
                        }
                    }

                    @Override
                    public void onError(Throwable e) {

                    }
                }).launch();
    }
}
 
开发者ID:ghnor,项目名称:Flora,代码行数:27,代码来源:MainActivity.java

示例3: compressWithLs

import top.zibin.luban.OnCompressListener; //导入依赖的package包/类
/**
 * 压缩图片 Listener 方式
 */
private void compressWithLs(final List<String> photos) {
  Luban.with(this)
      .load(photos)
      .ignoreBy(100)
      .setTargetDir(getPath())
      .setCompressListener(new OnCompressListener() {
        @Override
        public void onStart() {
        }

        @Override
        public void onSuccess(File file) {
          showResult(photos, file);
        }

        @Override
        public void onError(Throwable e) {
        }
      }).launch();
}
 
开发者ID:Curzibn,项目名称:Luban,代码行数:24,代码来源:MainActivity.java

示例4: zipImg

import top.zibin.luban.OnCompressListener; //导入依赖的package包/类
public static void zipImg(Context context,File file,OnCompressListener compressListener){
    Luban.get(context)
            .load(file)                     //传人要压缩的图片
            .putGear(Luban.THIRD_GEAR)      //设定压缩档次,默认三挡
            .setCompressListener(compressListener).launch();
}
 
开发者ID:lwd1815,项目名称:Selector,代码行数:7,代码来源:ImgCompress.java

示例5: createGoods

import top.zibin.luban.OnCompressListener; //导入依赖的package包/类
public void createGoods(Activity activity, final List<Uri> uriList) {
    if (ListUtils.isEmpty(uriList)) {
        if (getView() != null) {
            getView().showMessage("未选择图片!");
        }
        return;
    }

    if (getView() != null) {
        getView().showMessage("正在发布,请勿关闭页面!");
    }

    for (int i = 0; i < uriList.size(); i++) {
        if (getView() != null) {
            getView().showMessage(String.valueOf("正在压缩第" + (i + 1) + "图片!"));
        }
        Luban
                .with(activity)
                .load(CommUtil.uri2File(activity, uriList.get(i)))
                .setCompressListener(new OnCompressListener() {
                    @Override
                    public void onStart() {

                    }

                    @Override
                    public void onSuccess(File file) {
                        fileList.add(file);
                        if (!ListUtils.isEmpty(fileList) && fileList.size() == uriList.size()) {
                            for (int i = 0; i < fileList.size(); i++) {
                                Bitmap bitmap = BitmapFactory.decodeFile(fileList.get(i).getPath());
                                uploadImages(bitmap, fileList.size(), i + 1);
                                bitmap.recycle();
                                bitmap = null;
                            }
                            fileList.clear();
                        }
                    }

                    @Override
                    public void onError(Throwable e) {
                        if (getView() != null) {
                            getView().showMessage("压缩失败," + ExceptionEngine.handleException(e).getMsg());
                        }
                    }
                }).launch();
    }

}
 
开发者ID:NICOLITE,项目名称:HutHelper,代码行数:50,代码来源:CreateLostAndFoundPresenter.java

示例6: createSay

import top.zibin.luban.OnCompressListener; //导入依赖的package包/类
public void createSay(Activity activity, final List<Uri> uriList) {
    if (ListUtils.isEmpty(uriList)) {
        if (getView() != null) {
            getView().showMessage("未选择图片!");
        }
        return;
    }

    if (getView() != null) {
        getView().showMessage("正在发布,请勿关闭页面!");
    }

    for (int i = 0; i < uriList.size(); i++) {
        if (getView() != null) {
            getView().showMessage(String.valueOf("正在压缩第" + (i + 1) + "图片!"));
        }

        Luban
                .with(activity)
                .load(CommUtil.uri2File(activity, uriList.get(i)))
                .setCompressListener(new OnCompressListener() {
                    @Override
                    public void onStart() {

                    }

                    @Override
                    public void onSuccess(File file) {
                        fileList.add(file);
                        if (!ListUtils.isEmpty(fileList) && fileList.size() == uriList.size()) {
                            for (int i = 0; i < fileList.size(); i++) {
                                Bitmap bitmap = BitmapFactory.decodeFile(fileList.get(i).getPath());
                                uploadImages(bitmap, fileList.size(), i + 1);
                                bitmap.recycle();
                                bitmap = null;
                            }
                            fileList.clear();
                        }
                    }

                    @Override
                    public void onError(Throwable e) {
                        if (getView() != null) {
                            getView().showMessage("压缩失败," + ExceptionEngine.handleException(e).getMsg());
                        }
                    }
                }).launch();
    }

}
 
开发者ID:NICOLITE,项目名称:HutHelper,代码行数:51,代码来源:CreateSayPresenter.java

示例7: onActivityResult

import top.zibin.luban.OnCompressListener; //导入依赖的package包/类
@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
     /*   if (requestCode == REQUEST_CODE_CHOOSE && resultCode == RESULT_OK) {
            mSelected = Matisse.obtainResult(data);
//            Toast.makeText(this, mSelected.get(0).toString(), Toast.LENGTH_SHORT).show();
            CropImage.activity( mSelected.get(0))
                    .start(this);

        }
        if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
            CropImage.ActivityResult result = CropImage.getActivityResult(data);
            if (resultCode == RESULT_OK) {
                Uri resultUri = result.getUri();
                Glide.with(this).load(resultUri).into(imageView);
            } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
                Exception error = result.getError();
            }
        }*/

      /*  if (resultCode == Activity.RESULT_OK && requestCode == REQUEST_CODE_IMAGE) {
            final ArrayList<String> pathList =
                    data.getStringArrayListExtra(PhotoPickerActivity.EXTRA_RESULT_SELECTION);
            final boolean original =
                    data.getBooleanExtra(PhotoPickerActivity.EXTRA_RESULT_ORIGINAL, false);
        }*/
        if (requestCode == ImageSelector.IMAGE_REQUEST_CODE && resultCode == RESULT_OK && data != null) {
            // 获取选中的图片路径列表 Get Images Path List
            List<String> pathList = data.getStringArrayListExtra(ImageSelectorActivity.EXTRA_RESULT);
            Toast.makeText(this, pathList.get(0).toString(), Toast.LENGTH_SHORT).show();
                 File file1=new File(pathList.get(0).toString());

           Luban.get(this)
                    .load(file1)                     //传人要压缩的图片
                    .putGear(Luban.THIRD_GEAR)      //设定压缩档次,默认三挡
                    .setCompressListener(new OnCompressListener() { //设置回调

                        @Override
                        public void onStart() {
                            // TODO 压缩开始前调用,可以在方法内启动 loading UI
                        }
                        @Override
                        public void onSuccess(File file) {
                            uploadFile(file);
                            // TODO 压缩成功后调用,返回压缩后的图片文件
                        }

                        @Override
                        public void onError(Throwable e) {
                            // TODO 当压缩过去出现问题时调用
                        }
                    }).launch();    //启动压缩

        }

    }
 
开发者ID:Shmilyz,项目名称:Swap,代码行数:57,代码来源:A.java


注:本文中的top.zibin.luban.OnCompressListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。