# PictureSelector
**Repository Path**: imoji/PictureSelector
## Basic Information
- **Project Name**: PictureSelector
- **Description**: No description available
- **Primary Language**: Java
- **License**: Apache-2.0
- **Default Branch**: version_component
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2022-01-18
- **Last Updated**: 2022-01-18
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# PictureSelector 3.0
A PictureSelector for Android platform, which supports obtaining pictures, videos, audio & photos from photo albums, cutting (single picture or multi picture cutting), compression, theme custom configuration and other functions, and supports dynamic access & an open source picture selection framework suitable for Android 5.0 + system
[简体中文🇨🇳](README_CN.md)
[Demo](https://github.com/LuckSiege/PictureSelector/raw/version_component/app/demo/demo_2022-01-16_050949_v3.0.2.apk)
[](https://github.com/LuckSiege)
[](http://blog.csdn.net/luck_mw)
[](https://github.com/LuckSiege/PictureSelector/issues)
[](https://github.com/LuckSiege/PictureSelector)
## Contents
-[Download](#Download)
-[Usage](#Usage)
-[Result description](https://github.com/LuckSiege/PictureSelector/wiki/PictureSelector-3.0-LocalMedia%E8%AF%B4%E6%98%8E)
-[Effect](#Effect)
-[ProGuard](#ProGuard)
-[Common errors](https://github.com/LuckSiege/PictureSelector/wiki/PictureSelector-3.0-%E5%B8%B8%E8%A7%81%E9%94%99%E8%AF%AF)
-[Issues](https://github.com/LuckSiege/PictureSelector/wiki/%E5%A6%82%E4%BD%95%E6%8F%90Issues%3F)
-[License](#License)
## Download
Use Gradle
```sh
repositories {
google()
mavenCentral()
}
dependencies {
// PictureSelector basic (Necessary)
implementation 'io.github.lucksiege:pictureselector:v3.0.2'
// image compress library (Not necessary)
implementation 'io.github.lucksiege:compress:v3.0.2'
// uCrop library (Not necessary)
implementation 'io.github.lucksiege:ucrop:v3.0.2'
// simple camerax library (Not necessary)
implementation 'io.github.lucksiege:camerax:v3.0.2'
}
```
Or Maven:
```sh
io.github.lucksiege
pictureselector
v3.0.2
io.github.lucksiege
compress
v3.0.2
io.github.lucksiege
ucrop
v3.0.2
io.github.lucksiege
camerax
v3.0.2
```
## Usage
For more features, see [documentation](https://github.com/LuckSiege/PictureSelector/wiki/PictureSelector-3.0-%E5%8A%9F%E8%83%BDapi%E8%AF%B4%E6%98%8E)
A simple use case is shown below:
1、Get picture [GlideEngine](https://github.com/LuckSiege/PictureSelector/blob/version_component/app/src/main/java/com/luck/pictureselector/GlideEngine.java)
```sh
PictureSelector.create(this)
.openGallery(SelectMimeType.ofImage())
.setImageEngine(GlideEngine.createGlideEngine())
.forResult(new OnResultCallbackListener() {
@Override
public void onResult(List result) {
}
@Override
public void onCancel() {
}
});
```
2、Only use camera
```sh
PictureSelector.create(this)
.openCamera(SelectMimeType.ofImage())
.forResult(new OnResultCallbackListener() {
@Override
public void onResult(List result) {
}
@Override
public void onCancel() {
}
});
```
3、You can also use the following example:
(1)、Inject into any view fragment
```sh
PictureSelector.create(this)
.openGallery(SelectMimeType.ofAll())
.setImageEngine(GlideEngine.createGlideEngine())
.buildLaunch(R.id.fragment_container, new OnResultCallbackListener() {
@Override
public void onResult(ArrayList result) {
}
@Override
public void onCancel() {
}
});
```
(2)、Custom Inject into any view fragment
```sh
PictureSelectorFragment selectorFragment = PictureSelector.create(this)
.openGallery(SelectMimeType.ofAll())
.setImageEngine(GlideEngine.createGlideEngine())
.build();
getSupportFragmentManager().beginTransaction()
.add(R.id.fragment_container, selectorFragment, selectorFragment.getFragmentTag())
.addToBackStack(selectorFragment.getFragmentTag())
.commitAllowingStateLoss();
```
4、Preview image or video
```sh
PictureSelector.create(this)
.openPreview()
.setImageEngine(GlideEngine.createGlideEngine())
.setExternalPreviewEventListener(new OnExternalPreviewEventListener() {
@Override
public void onPreviewDelete(int position) {
}
@Override
public boolean onLongPressDownload(LocalMedia media) {
return false;
}
}).startActivityPreview(position, true, "data");
```
5、Preview audio
```sh
AudioPlayDialog.showPlayAudioDialog(getContext(), "path");
```
Set theme,see [documentation](https://github.com/LuckSiege/PictureSelector/wiki/PictureSelector-3.0-%E4%B8%BB%E9%A2%98api%E8%AF%B4%E6%98%8E)
```sh
.setSelectorUIStyle();
```
Or Overload layout,see [documentation](https://github.com/LuckSiege/PictureSelector/wiki/PictureSelector-3.0-%E5%A6%82%E4%BD%95%E9%87%8D%E8%BD%BD%E5%B8%83%E5%B1%80%EF%BC%9F)
```sh
.setInjectLayoutResourceListener(new OnInjectLayoutResourceListener() {
@Override
public int getLayoutResourceId(Context context, int resourceSource) {
return 0;
}
```
The advanced use cases are as follow:
1、Use the custom camera,See [documentation](https://github.com/LuckSiege/PictureSelector/wiki/PictureSelector-3.0-%E5%A6%82%E4%BD%95%E8%87%AA%E5%AE%9A%E4%B9%89%E7%9B%B8%E6%9C%BA%EF%BC%9F)
```sh
.setCameraInterceptListener(new OnCameraInterceptListener() {
@Override
public void openCamera(Fragment fragment, int cameraMode, int requestCode){
}
});
```
2、Use the image compress,See [documentation](https://github.com/LuckSiege/PictureSelector/wiki/PictureSelector-3.0-%E5%A6%82%E4%BD%95%E5%8E%8B%E7%BC%A9%EF%BC%9F)
```sh
.setCompressEngine(new CompressEngine() {
@Override
public void onStartCompress(Context context, ArrayList list, OnCallbackListener> call){
}
});
```
3、Use the image uCrop,See [documentation](https://github.com/LuckSiege/PictureSelector/wiki/PictureSelector-3.0-%E5%A6%82%E4%BD%95%E8%A3%81%E5%89%AA%EF%BC%9F)
```sh
.setCropEngine(new CropEngine() {
@Override
public void onStartCrop(Fragment fragment, LocalMedia currentLocalMedia, ArrayList dataSource, int requestCode) {
}
});
```
4、Use the image edit,See [documentation](https://github.com/LuckSiege/PictureSelector/wiki/PictureSelector-3.0-%E5%A6%82%E4%BD%95%E7%BC%96%E8%BE%91%E5%9B%BE%E7%89%87%EF%BC%9F)
```sh
.setEditMediaInterceptListener(new OnMediaEditInterceptListener() {
@Override
public void onStartMediaEdit(Fragment fragment, LocalMedia currentLocalMedia, int requestCode) {
}
});
```
5、Use the custom load data,See [documentation](https://github.com/LuckSiege/PictureSelector/wiki/PictureSelector-3.0-%E5%A6%82%E4%BD%95%E5%8A%A0%E8%BD%BD%E8%87%AA%E5%AE%9A%E4%B9%89%E6%95%B0%E6%8D%AE%E6%BA%90%EF%BC%9F)
```sh
.setExtendLoaderEngine(new ExtendLoaderEngine() {
@Override
public void loadAllAlbumData(Context context, OnQueryAllAlbumListener query) {
}
@Override
public void loadOnlyInAppDirAllMediaData(Context context, OnQueryAlbumListener query) {
}
@Override
public void loadFirstPageMediaData(Context context, long bucketId, int page, int pageSize, OnQueryDataResultListener query) {
}
@Override
public void loadMoreMediaData(Context context, long bucketId, int page, int limit, int pageSize, OnQueryDataResultListener query) {
}
});
```
6、Use the custom apply Permissions,See [documentation](https://github.com/LuckSiege/PictureSelector/wiki/PictureSelector-3.0-%E5%A6%82%E4%BD%95%E8%87%AA%E5%AE%9A%E4%B9%89%E6%9D%83%E9%99%90%E7%94%B3%E8%AF%B7-%EF%BC%9F)
```sh
.setPermissionsInterceptListener(new OnPermissionsInterceptListener() {
@Override
public void requestPermission(Fragment fragment, String[] permissionArray, OnCallbackListener call) {
}
@Override
public boolean hasPermissions(Fragment fragment) {
return false;
}
});
```
## ProGuard
```sh
-keep class com.luck.picture.lib.** { *; }
-keep class com.luck.lib.camerax.** { *; }
// use uCrop
-dontwarn com.yalantis.ucrop**
-keep class com.yalantis.ucrop** { *; }
-keep interface com.yalantis.ucrop** { *; }
```
## License
```sh
Copyright 2016 Luck
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.
```
## Effect
| Single Mode | Mixed Mode |
|:-----------:|:-----------:|
|||
| Default Style | Preview | Multiple Crop |
|:-----------:|:--------:|:---------:|
| |
| |
| Digital Style | Preview | Multiple Crop |
|:-----------:|:--------:|:---------:|
| |  | |
| White Style | Preview | Single Crop |
|:-----------:|:--------:|:---------:|
| |  | |
| New Style | Preview | Multiple Crop |
|:-----------:|:--------:|:---------:|
| |  | |
| Photo Album Directory | Single Mode | Circular Crop|
|:-----------:|:--------:|:--------:|
| | | |
| White Style | Video | Audio |
|:-----------:|:-----------:|:--------:|
| | | |