Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

API Documentation

Wangsun Hakhun edited this page May 6, 2019 · 3 revisions

Declare and Initialize DocPicker.

Java

ArrayList<String> docs = new ArrayList<>();
docs.add(DocPicker.DocTypes.PDF);
docs.add(DocPicker.DocTypes.MS_POWERPOINT);
docs.add(DocPicker.DocTypes.MS_EXCEL);
docs.add(DocPicker.DocTypes.TEXT);


DocPickerConfig pickerConfig = new DocPickerConfig()
        .setAllowMultiSelection(false)
        .setShowConfirmationDialog(true)
        .setExtArgs(docs);

DocPicker.with(this)
        .setConfig(pickerConfig)
        .onResult()
        .subscribe(new Observer<ArrayList<Uri>>() {
            @Override
            public void onSubscribe(Disposable d) { }

            @Override
            public void onNext(ArrayList<Uri> uris) {
                //uris: list of uri
            }

            @Override
            public void onError(Throwable e) { }

            @Override
            public void onComplete() { }
        });

Kotlin

val docs = arrayListOf<String>(
    DocPicker.DocTypes.PDF,
    DocPicker.DocTypes.MS_WORD,
    DocPicker.DocTypes.MS_POWERPOINT,
    DocPicker.DocTypes.MS_EXCEL,
    DocPicker.DocTypes.TEXT)

val pickerConfig = DocPickerConfig()
    .setShowConfirmationDialog(true)
    .setAllowMultiSelection(false)
    .setExtArgs(docs)

DocPicker.with(this)
    .setConfig(pickerConfig)
    .onResult()
    .subscribe({
        println ( "here is the list: $it" )
    },{
        println ( "error: ${it.printStackTrace()}")
    })

Explanation:

1. DocPickerConfig:

It is use to set the configuration.

  1. .setAllowMultiSelection(booleanValue): tells whether to select single file or multiple file.
  2. .setShowConfirmationDialog(booleanValue): tells whether to show confirmation dialog on selecting the file(only work in single file selection).
  3. .setExtArgs(stringArrayValue): this will help in filtering the docs base on this speficied extentions(values in stringArray).

eg.

//Pick single file with confirmation dialog and set extentions arguments
ArrayList<String> docs = new ArrayList<String>();
docs.add(DocPicker.DocTypes.PDF);
docs.add(DocPicker.DocTypes.MS_POWERPOINT);
docs.add(DocPicker.DocTypes.MS_EXCEL);
docs.add(DocPicker.DocTypes.TEXT);


DocPickerConfig pickerConfig = new DocPickerConfig()
        .setAllowMultiSelection(false)
        .setShowConfirmationDialog(true)
        .setExtArgs(docs);
Clone this wiki locally