Android-FilePicker 选择照片

来源:互联网 发布:安卓录屏软件不用root 编辑:程序博客网 时间:2024/05/29 15:25
 

Android-FilePicker

项目地址:DroidNinja/Android-FilePicker
简介:Photopicker and document picker for android

A photopicker to select and click photos and document picker to select different types of documents.

demo demodemo

Installation

  • As of now, It is only available in jCenter(), So just put this in your app dependencies:

      compile 'com.droidninja:filepicker:1.0.6'

    Usage

    Just include this in your onclick function:

    • For photopicker:

      FilePickerBuilder.getInstance().setMaxCount(5)            .setSelectedFiles(filePaths)            .setActivityTheme(R.style.AppTheme)            .pickPhoto(this);
    • For document picker:

      FilePickerBuilder.getInstance().setMaxCount(10)            .setSelectedFiles(filePaths)            .setActivityTheme(R.style.AppTheme)            .pickDocument(this);

    After this, you will get list of file paths in activity result:

    @Override   public void onActivityResult(int requestCode, int resultCode, Intent data) {          switch (requestCode)          {              case FilePickerConst.REQUEST_CODE_PHOTO:                  if(resultCode== Activity.RESULT_OK && data!=null)                  {                      photoPaths = new ArrayList<>();                      photoPaths.addAll(data.getStringArrayListExtra(FilePickerConst.KEY_SELECTED_PHOTOS));                  }                  break;              case FilePickerConst.REQUEST_CODE_DOC:                  if(resultCode== Activity.RESULT_OK && data!=null)                  {                      docPaths = new ArrayList<>();                      docPaths.addAll(data.getStringArrayListExtra(FilePickerConst.KEY_SELECTED_DOCS));                  }                  break;          }          addThemToView(photoPaths,docPaths);      }

    Credits

    Inspired by PhotoPicker

    SmoothCheckbox

Youtube Demo

Demo

0 0
原创粉丝点击