其他
文件选择器看这个就够了—轻量级、支持多种文件类型
一款轻量级的文件选择器,支持多种文件类型
博文地址:
http://www.jianshu.com/p/f0660a5feb1e
一款轻量级的文件选择器,支持多种文件类型
本项目所使用的库为: Android-FilePicker PhotoView Glide
使用步骤:
第一步导入:
compile 'com.vincent.filepicker:MultiTypeFilePicker:latestVersion'
第二步重写Start Activity For Result
......
case R.id.btn_pick_image:
Intent intent1 = new Intent(this, ImagePickActivity.class);
intent1.putExtra(IS_NEED_CAMERA, true);
intent1.putExtra(Constant.MAX_NUMBER, 9);
startActivityForResult(intent1, Constant.REQUEST_CODE_PICK_IMAGE);
break;
case R.id.btn_pick_video:
intent2 = new Intent(this, VideoPickActivity.class);
intent2.putExtra(IS_NEED_CAMERA, true);
intent2.putExtra(Constant.MAX_NUMBER, 9);
startActivityForResult(intent2, Constant.REQUEST_CODE_PICK_VIDEO);
break;
case R.id.btn_pick_audio:
Intent intent3 = new Intent(this, AudioPickActivity.class);
intent3.putExtra(IS_NEED_RECORDER, true);
intent3.putExtra(Constant.MAX_NUMBER, 9);
startActivityForResult(intent3, Constant.REQUEST_CODE_PICK_AUDIO);
break;
case R.id.btn_pick_file:
Intent intent4 = new Intent(this, NormalFilePickActivity.class);
intent4.putExtra(Constant.MAX_NUMBER, 9);
intent4.putExtra(NormalFilePickActivity.SUFFIX, new String[] {"xlsx", "xls", "doc", "docx", "ppt", "pptx", "pdf"});
startActivityForResult(intent4, Constant.REQUEST_CODE_PICK_FILE);
break;
......
第三步重写Activity的Result
case Constant.REQUEST_CODE_PICK_IMAGE:
if (resultCode == RESULT_OK) {
ArrayList<ImageFile> list = data.getParcelableArrayListExtra(Constant.RESULT_PICK_IMAGE);
}
break;
case Constant.REQUEST_CODE_PICK_VIDEO:
if (resultCode == RESULT_OK) {
ArrayList<VideoFile> list = data.getParcelableArrayListExtra(Constant.RESULT_PICK_VIDEO);
}
break;
case Constant.REQUEST_CODE_PICK_AUDIO:
if (resultCode == RESULT_OK) {
ArrayList<AudioFile> list = data.getParcelableArrayListExtra(Constant.RESULT_PICK_AUDIO);
}
break;
case Constant.REQUEST_CODE_PICK_FILE:
if (resultCode == RESULT_OK) {
ArrayList<NormalFile> list = data.getParcelableArrayListExtra(Constant.RESULT_PICK_FILE);
}
break;
github项目:
https://github.com/fishwjy/MultiType-FilePicker
终端研发部提倡: 没有做不到的,只有想不到的。
在这里获得的不仅仅是技术!
这里学到不仅仅是技术