GitHub - zhihu/Matisse: A well-designed local image and video selector for Andro...
source link: https://github.com/zhihu/Matisse
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Matisse
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 {
implementation '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())
.showPreview(false) // Default is `true`
.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);
}
}
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.
Recommend
-
76
[ROM][UNOFFICIAL][matisse][millet] LineageOS 17.1 M
-
3
MATISSE:电动飞机固态电池研究项目启动2024/01/11 19:37|By
-
54
README.md
-
42
README.md Rucene - Rust implementation of Lucene Introduction Rucene is a Rust port of the popular Apache Lucene project. Rucene is not a comp...
-
24
-
1
This site can’t be reached The webpage at https://zhuanlan.zhihu.com/p/389201653 might be temporarily down or it may have moved permanently to a new web address....
-
6
Zhihu shares plummet in Hong Kong debut due to questionable profitability Zhihu Zhihu shares plummet in Hong Kong debut due to questionable profitability
-
4
zhihu markdown导入(2022年6月) 我最近想把写的东西弄到知乎上,但是发现一堆问题,按照之前的方式出现了老多错误,因此记录一下. 按照
-
2
...
-
79
✨ Charles is a local multi-media selector for Android.
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK