UpyaSelectFileOrFolder
是一个用于挑选文件或文件夹,获取路径信息的库,可单选、多选、混选。😍
- 步骤1:将以下代码添加到工程的build.gradle中:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
android{
...
// 需启用Java8
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
...
// 将下方的 ${latestVersion} 替换为当前最新的版本,最新版本参见下文
implementation 'com.github.TYUpya:UpyaSelectFileOrFolder:${latestVersion}'
// PS:如果集成以上依赖后项目运行报错,请再添加以下赖
implementation 'androidx.recyclerview:recyclerview:1.1.0'
}
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<!-- 将下方的 ${latestVersion} 替换为当前最新的版本,最新版本参见下文 -->
<dependency>
<groupId>com.github.TYUpya</groupId>
<artifactId>UpyaSelectFileOrFolder</artifactId>
<version>${latestVersion}</version>
</dependency>
<!-- PS:如果集成以上依赖后项目运行报错,请再添加以下依赖 -->
<dependency>
<groupId>androidx.recyclerview</groupId>
<artifactId>recyclerview</artifactId>
<version>1.1.0</version>
<scope>runtime</scope>
</dependency>
latestVersion |
|
序号 |
权限 |
说明 |
1 |
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> |
读取储存的文件权限 |
public void onClick01(View view) {
new SelectFileOrFolderDialog(this, true, SelectFileOrFolderDialog.CHOICEMODE_ONLY_FILE,
new SelectFileOrFolderDialog.OnSelectFileOrFolderListener() {
@Override
public void onSelectFileOrFolder(List<File> selectedFileList) {
mainText.setText("选择的文件:" + selectedFileList.get(0).getAbsolutePath());
}
}).show();
}
public void onClick02(View view) {
new SelectFileOrFolderDialog(this, false, SelectFileOrFolderDialog.CHOICEMODE_ONLY_FILE,
new SelectFileOrFolderDialog.OnSelectFileOrFolderListener() {
@Override
public void onSelectFileOrFolder(List<File> selectedFileList) {
mainText.setText("选择的文件:\n");
for (File file : selectedFileList) {
mainText.append(file.getAbsolutePath());
mainText.append("\n");
}
}
}).show();
}
public void onClick03(View view) {
new SelectFileOrFolderDialog(this, true, SelectFileOrFolderDialog.CHOICEMODE_ONLY_FOLDER,
new SelectFileOrFolderDialog.OnSelectFileOrFolderListener() {
@Override
public void onSelectFileOrFolder(List<File> selectedFileList) {
mainText.setText("选择的文件:" + selectedFileList.get(0).getAbsolutePath());
}
}).show();
}
public void onClick04(View view) {
new SelectFileOrFolderDialog(this, false, SelectFileOrFolderDialog.CHOICEMODE_ONLY_FOLDER,
new SelectFileOrFolderDialog.OnSelectFileOrFolderListener() {
@Override
public void onSelectFileOrFolder(List<File> selectedFileList) {
mainText.setText("选择的文件:\n");
for (File file : selectedFileList) {
mainText.append(file.getAbsolutePath());
mainText.append("\n");
}
}
}).show();
}
public void onClick05(View view) {
new SelectFileOrFolderDialog(this, true, SelectFileOrFolderDialog.CHOICEMODE_UNLIMITED,
new SelectFileOrFolderDialog.OnSelectFileOrFolderListener() {
@Override
public void onSelectFileOrFolder(List<File> selectedFileList) {
mainText.setText("选择的文件:" + selectedFileList.get(0).getAbsolutePath());
}
}).show();
}
public void onClick06(View view) {
new SelectFileOrFolderDialog(this, false, SelectFileOrFolderDialog.CHOICEMODE_UNLIMITED,
new SelectFileOrFolderDialog.OnSelectFileOrFolderListener() {
@Override
public void onSelectFileOrFolder(List<File> selectedFileList) {
mainText.setText("选择的文件:\n");
for (File file : selectedFileList) {
mainText.append(file.getAbsolutePath());
mainText.append("\n");
}
}
}).show();
}
-dontwarn vip.upya.lib.sfof.**
-keep class vip.upya.lib.sfof.**{*;}
😂나 자신🤣
Copyright 2020 TYUpya
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.