Giter Site home page Giter Site logo

brook007 / filepicker Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 1.0 841 KB

Android文件选择器,默认提供图片选择的实现,可自行实现其他的文件类型选择

License: Apache License 2.0

Java 100.00%
imagepicker filepicker takephoto image-picker android

filepicker's Introduction

FilePicker

Android文件选择器,默认实现了图片选择器,可自行继承并实现任意的文件类型选择器

Jitpack

引入依赖

  1. 根项目的build.gradle中加入以下代码
allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}
  1. 在需要的模块加入以下的依赖
dependencies {
	implementation 'com.github.Brook007:FilePicker:1.1.1'
}

初始化

初始化一个默认的配置

通过下面的代码配置一个默认的配置

FilePickerConfig defaultConfig = FilePickerConfig.getDefaultConfig();
defaultConfig.setImageLoader(new IPreviewImageLoader() {
    @Override
    public void loadPreviewImage(File sourceFile, ImageView previewImageView) {
        Glide.with(previewImageView.getContext())
             .load(sourceFile)
             .apply(new RequestOptions().centerCrop())
             .into(previewImageView);
    }
});
defaultConfig.setPickerCount(9);

通过链式调用在每次使用的时候创建一个配置

通过下面的代码在每次调用选择器的时候创建一个新的配置,并启动选择器,这个配置不会影响到默认的配置

FilePickerUtils.getInstance()
        .setPickerCount(1)
        // 默认MimeType为image/*
        .setFilePickerType("image/*")
        .launchPicker(MainActivity.this, new FilePickerValueCallback() {
            @Override
            public void onPickResult(List<File> file) {
                Log.d("TAG", "回调" + Arrays.toString(file.toArray()));
            }
        });

使用配置

编写下面的代码来使用指定的配置,并启动选择器

FilePickerUtils.getInstance()
        .setPickerCount(1)
        .setFilePickerConfig(config)
        .launchPicker(MainActivity.this, new FilePickerValueCallback() {
            @Override
            public void onPickResult(List<File> file) {
                Log.d("TAG", "回调" + Arrays.toString(file.toArray()));
            }
        });

filepicker's People

Contributors

brook007 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

waelchateur

filepicker's Issues

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.