GithubHelp home page GithubHelp logo

yb1994917 / matisse Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zhihu/matisse

0.0 1.0 0.0 1.89 MB

:fireworks: A well-designed local image and video selector for Android

License: Apache License 2.0

Java 100.00%

matisse's Introduction

Image

Matisse

Build Status Download

Matisse is a well-designed local image and video selector for Android. You can

  • Use it in Activity or Fragment
  • Select images including JPEG, PNG, GIF and videos including MPEG, MP4
  • Apply different themes, including two built-in themes and custom themes
  • Different image loaders
  • Define custom filter rules
  • More to find out yourself
Zhihu Style Dracula Style Preview

Download

Gradle:

repositories {
    jcenter()
}

dependencies {
    compile 'com.zhihu.android:matisse:$latest_version'
}

Check out Matisse releases to see more unstable versions.

ProGuard

If you use Glide as your image engine, add rules as Glide's README says.
And add extra rule:

-dontwarn com.squareup.picasso.**

If you use Picasso as your image engine, add rules as Picasso's README says.
And add extra rule:

-dontwarn com.bumptech.glide.**

Attention: The above progurad rules are correct.

How do I use Matisse?

Permission

The library requires two permissions:

  • android.permission.READ_EXTERNAL_STORAGE
  • android.permission.WRITE_EXTERNAL_STORAGE

So if you are targeting Android 6.0+, you need to handle runtime permission request before next step.

Simple usage snippet


Start MatisseActivity from current Activity or Fragment:

Matisse.from(MainActivity.this)
        .choose(MimeType.allOf())
        .countable(true)
        .maxSelectable(9)
        .addFilter(new GifSizeFilter(320, 320, 5 * Filter.K * Filter.K))
        .gridExpectedSize(getResources().getDimensionPixelSize(R.dimen.grid_expected_size))
        .restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)
        .thumbnailScale(0.85f)
        .imageEngine(new GlideEngine())
        .forResult(REQUEST_CODE_CHOOSE);

Themes

There are two built-in themes you can use to start MatisseActivity:

  • R.style.Matisse_Zhihu (light mode)
  • R.style.Matisse_Dracula (dark mode)

And Also you can define your own theme as you wish.

Receive Result

In onActivityResult() callback of the starting Activity or Fragment:

List<Uri> mSelected;

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == REQUEST_CODE_CHOOSE && resultCode == RESULT_OK) {
        mSelected = Matisse.obtainResult(data);
        Log.d("Matisse", "mSelected: " + mSelected);
    }
}

For Glide V4

To be honest,the library can't supply GlideEngine for Glide both v3 and v4 at the same time. (Anyone who have good idea to achieve this. PR is welcomed)

GlideEngine with Glide v3 is default.

So if your project's glide version is 4.0+ ,then you must realize GlideEngine by yourself. More details could refer with Glide4Engine in the sample.

More

Find more details about Matisse in wiki.

Contributing

Matisse is an Open Source Project

Thanks

This library is inspired by Laevatein and uses some of its source code.

License

Copyright 2017 Zhihu 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.

matisse's People

Contributors

gejiaheng avatar rebooters avatar coxier avatar smelfungus avatar dreamersoul avatar venkat20390 avatar mthli avatar meyersurix avatar davidllorca avatar marcinkunert avatar unixzii avatar tanlehua avatar nevermore1000 avatar eprendre avatar coderkan avatar greenskinmonster avatar oxc avatar borisdamato avatar bruferrari avatar dima-369 avatar drizzlezhang avatar junyuecao avatar romantruba 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.