Code Monkey home page Code Monkey logo

zfilemanager's Introduction

Travis Travis Travis

特点

1. 默认支持 音频,视频,图片,txt,zip,word,excel,ppt,pdf 9种文件

2. 支持音频、视频播放,图片查看,zip解压,文件重命名、复制、移动、删除、查看详情

3. 支持查看指定文件类型,支持文件类型拓展,支持嵌套在Fragment中使用

4. 支持多选,数量、文件大小限制、实时排序、指定文件路径访问

5. 支持QQ、微信文件选择 && 支持自定义获取QQ、微信文件

6. 不含任何三方框架,极高的定制化,支持Android 10/11/12/++、AndroidX、DSL

部分截图

基本使用

温馨提示: targetSdkVersion >= 29 清单文件中加上 android:requestLegacyExternalStorage="true"
温馨提示: targetSdkVersion >= 29 清单文件中加上 android:requestLegacyExternalStorage="true"
温馨提示: targetSdkVersion >= 29 清单文件中加上 android:requestLegacyExternalStorage="true"

Step 0. 添加依赖

    // Android 10 及以上版本  暂只提供 aar

    // Android 10 及以下版本使用(不推荐使用)
    implementation 'com.github.zp:z_file:1.2.6' 

Step 1. 实现ZFileImageListener,并在调用前配置

class MyFileImageListener : ZFileImageListener() {

    override fun loadImage(imageView: ImageView, file: File) {
        // 以Glide为例
        Glide.with(imageView.context)
            .load(file)
            .apply(RequestOptions().apply {
                placeholder(R.drawable.ic_zfile_other)
                error(R.drawable.ic_zfile_other)
            })
            .into(imageView)
    }
}

// 在调用前配置
getZFileHelp().init(MyFileImageListener())

Step 2. 在Activity或Fragment中使用

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        main_defaultMangerBtn.setOnClickListener {
            // DSL 方式  (推荐)
            zfile { 
                result {
                    setFileListData(this)
                }
            }
            // 普通 方式 
            getZFileHelp()
                .result(this) {
                     setFileListData(this)
                }
        }
    }
    
    private fun setFileListData(fileList: MutableList<ZFileBean>?) {
        val sb = StringBuilder()
        fileList?.forEach {
            sb.append(it).append("\n\n")
        }
        main_resultTxt.text = sb.toString()
    }

}

更多使用方式详见wiki

更多操作请查看demo, ^_^ 如果觉得可以 star 一下哦!

Travis Travis Travis

zfilemanager's People

Contributors

zippo88888888 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.