zetbaitsu / Compressor

An android image compression library.
7.08k stars 963 forks source link

How to compress multiple images ? #55

Closed FielddddMMMMarshal closed 7 years ago

zetbaitsu commented 7 years ago
        List<File> imageFiles = new ArrayList<>();
        Flowable.fromIterable(imageFiles)
                .flatMap(new Function<File, Publisher<File>>() {
                    @Override
                    public Publisher<File> apply(@NonNull File file) throws Exception {
                        return new Compressor(MainActivity.this).compressToFileAsFlowable(file);
                    }
                }).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer<File>() {
                    @Override
                    public void accept(File file) {
                        compressedImage = file;
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) {
                        throwable.printStackTrace();
                    }
                });
aldocano commented 6 years ago

Can you please help out on how to compress all images in one folder by also keeping the file name?

abdulsalam90 commented 5 years ago

@zetbaitsu i am new to Rxjava. how do we know that our all images are compressed in the list, so that we can return?