天天看點

Android檔案選擇器Github,GitHub - maning0303/FilePicker: Android檔案、圖檔選擇器,可按檔案夾查找,檔案類型查找,支援自定義相機...

介紹

可在檔案浏覽器中選擇指定字尾名檔案

可通過掃描全盤的方式,選擇指定字尾名的檔案

類似微信圖檔選擇器選擇圖檔或視訊

圖檔選擇頁面可以自定義主題

支援Activity、Fragment

Example

Android檔案選擇器Github,GitHub - maning0303/FilePicker: Android檔案、圖檔選擇器,可按檔案夾查找,檔案類型查找,支援自定義相機...
Android檔案選擇器Github,GitHub - maning0303/FilePicker: Android檔案、圖檔選擇器,可按檔案夾查找,檔案類型查找,支援自定義相機...
Android檔案選擇器Github,GitHub - maning0303/FilePicker: Android檔案、圖檔選擇器,可按檔案夾查找,檔案類型查找,支援自定義相機...
Android檔案選擇器Github,GitHub - maning0303/FilePicker: Android檔案、圖檔選擇器,可按檔案夾查找,檔案類型查找,支援自定義相機...
Android檔案選擇器Github,GitHub - maning0303/FilePicker: Android檔案、圖檔選擇器,可按檔案夾查找,檔案類型查找,支援自定義相機...
Android檔案選擇器Github,GitHub - maning0303/FilePicker: Android檔案、圖檔選擇器,可按檔案夾查找,檔案類型查找,支援自定義相機...

可下載下傳APK直接體驗

用法

implementation 'cn.imlibo:FilePicker:v0.0.5_alpha'

一、 在檔案浏覽器中選擇指定檔案

FilePicker.from(this)

.chooseForBrowser()

.setMaxCount(2)

.setFileTypes("png", "doc","apk", "mp3", "gif", "txt", "mp4", "zip")

.requestCode(REQUEST_CODE_CHOOSE)

.start();

二、 分類查找指定字尾名檔案

FilePicker

.from(this)

.chooseForMimeType()

.setMaxCount(10)

.setFileTypes("png", "doc","apk", "mp3", "gif", "txt", "mp4", "zip")

.requestCode(REQUEST_CODE_CHOOSE)

.start();

三、 在圖檔選擇器中選擇圖檔或視訊

FilePicker

.from(this)

.chooseMedia()

.enabledCapture(true)

.setTheme(R.style.FilePicker_Dracula)

.requestCode(REQUEST_CODE_CHOOSE)

.start();

四、 接收傳回的檔案資料,在 ++onActivityResult++ 方法中擷取。選中檔案以連結清單方式傳回, ++EssFile++ 類為載體

@Override

protected void onActivityResult(int requestCode, int resultCode, Intent data) {

super.onActivityResult(requestCode, resultCode, data);

if (resultCode != RESULT_OK) {

return;

}

if (requestCode == REQUEST_CODE_CHOOSE) {

ArrayList essFileList = data.getParcelableArrayListExtra(Const.EXTRA_RESULT_SELECTION);

StringBuilder builder = new StringBuilder();

for (EssFile file :

essFileList) {

builder.append(file.getMimeType()).append(" | ").append(file.getName()).append("\n\n");

}

textView.setText(builder.toString());

}

}

屬性清單

名稱

描述

預設值

FileTypes

需要顯示的檔案類型

SortType

排序類型

按名字排序 BY_NAME_ASC

isSingle

是否單選

false

maxCount

最大可選中數量

10

request_code

請求碼

onlyShowImages

是否僅顯示圖檔(僅當其實chooseMedia時有效)

false

onlyShowVideos

是否僅顯示視訊(僅當其實chooseMedia時有效)

false

enabledCapture

chooseMedia時是否顯示照相機

false

placeHolder

圖檔的PlaceHolder

png_holder

themeId

主題ID

R.Style.FilePicker_Elec

自定義主題

@color/elec_primary

@color/elec_primary_dark

@style/Toolbar.elec

@color/elec_album_dropdown_title_text

@color/elec_album_dropdown_count_text

@android:color/white

@color/elec_album_dropdown_thumbnail_placeholder

@drawable/ic_empty_elec

@color/elec_album_empty_view

@color/elec_item_placeholder

@color/elec_item_checkCircle_backgroundColor

@color/elec_item_checkCircle_borderColor

@color/elec_page_bg

@color/elec_bottom_toolbar_bg

@color/elec_bottom_toolbar_preview

@color/elec_bottom_toolbar_apply

@color/elec_preview_bottom_toolbar_back_text

@color/elec_preview_bottom_toolbar_apply

@style/Popup.elec

@color/elec_capture

Feature TODO

根據檔案類型打開/預覽檔案

預覽圖檔界面

壓縮圖檔

裁剪圖檔

自定義相機拍照

去掉AndPermission依賴,用原生代碼申請權限

增加多種圖檔加載架構支援

檔案浏覽器支援自定義主題

分類選擇檔案界面支援自定義主題

THANKS

LICENSE

MIT License

Copyright (c) 2018

Permission is hereby granted, free of charge, to any person obtaining a copy

of this software and associated documentation files (the "Software"), to deal

in the Software without restriction, including without limitation the rights

to use, copy, modify, merge, publish, distribute, sublicense, and/or sell

copies of the Software, and to permit persons to whom the Software is

furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all

copies or substantial portions of the Software.