1 Star 0 Fork 0

vee / JTFilePicker

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

JTFilePicker jCenter License

一个超轻量级,简单好用的多文件选择器。

image

功能:

  1. 支持自定义文件图标
  2. 以字符串集合返回
  3. 超级轻量,超级简单
  4. 基于kotlin

安装:

首先在你的项目配置kotlin环境, 在你的moudle里添加如下代码:

dependencies {
    ......
    implementation 'com.william:JTFilePicker:1.3.1'
}

用法:

Kotlin(推荐):

/**
* kotlin启动
* @param 参数1:可以是activity或者fragment
*/
JTFilePicker.from(activity||fragment, object :OnFileIconLoadListener{
    override fun fileIconLoad(imageView: ImageView, fileBean: FileBean) {
        when (fileBean.extension) {
            "txt" ->
                //可以用普通方式设置drawable
                imageView.setImageDrawable(R.drawable.txt)
            "jpg"->//图片类型可以直接在图标中预览
                //推荐完全交给Glide或者其他图片加载框架
                Glide.with(context).load(fileBean.path).into(imageView)
        }
    }
})
//可选,设置首页路径(即能打开的根目录)默认为内存卡根目录
//.setRoot(Environment.getExternalStorageDirectory().path)
.open(0)

/**
* kotlin接收
*/
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    if (resultCode == Activity.RESULT_OK){
        Toast.makeText(this,"已成功:${data!!.getStringArrayListExtra("paths")}",Toast.LENGTH_SHORT).show()
    } else {
        Toast.makeText(this,"已取消",Toast.LENGTH_SHORT).show()
    }
}

java:

/**
* java 启动
* @param 参数1:可以是activity或者fragment
*/
JTFilePicker.Companion.from(this, new OnFileIconLoadListener() {
    @Override
    public void fileIconLoad(ImageView imageView, FileBean fileBean) {
        switch (fileBean.getExtension()) {
            case "txt":
                //可以用普通方式设置drawable
                imageView.setImageDrawable(R.drawable.txt);
                break;
            case "jpg"://图片类型可以直接在图标中预览
                //推荐完全交给Glide或者其他图片加载框架
                Glide.with(context).load(fileBean.getPath()).into(imageView);
                break;
                default:
        }

    }
})
//可选,设置首页路径(即能打开的根目录)默认为内存卡根目录
//.setRoot(Environment.getExternalStorageDirectory().path)
.open(0);

/**
* java java接收
*/
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_CANCELED) {
        return;
    }
    switch (requestCode) {
        case REQUEST_PICK_FILE://从选择文件页面返回
            List<String> paths = data.getStringArrayListExtra("paths");
        break;
        default:
    }
}

License

Copyright 2018 william Inc.

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.

空文件

简介

一个超轻量级,简单好用的多文件选择器。 展开 收起
Kotlin
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Kotlin
1
https://gitee.com/william198824/JTFilePicker.git
git@gitee.com:william198824/JTFilePicker.git
william198824
JTFilePicker
JTFilePicker
master

搜索帮助