) getIntent().getSerializableExtra(ImagePicker.INTENT_KEY_PICKER_RESULT);
31 | ImagesViewPager viewPager = findViewById(R.id.viewpager);
32 | viewPager.setImageViewList(imageItems);
33 | }
34 |
35 | public void click(View view) {
36 | ImagePicker.closePickerWithCallback(imageItems);
37 | finish();
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/app/src/main/java/com/ypx/imagepickerdemo/style/custom/CustomCropControllerView.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepickerdemo.style.custom;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.graphics.Color;
6 | import android.view.View;
7 | import android.widget.ImageView;
8 |
9 | import com.ypx.imagepicker.utils.PStatusBarUtil;
10 | import com.ypx.imagepicker.views.base.SingleCropControllerView;
11 | import com.ypx.imagepicker.widget.cropimage.CropImageView;
12 | import com.ypx.imagepickerdemo.R;
13 |
14 | public class CustomCropControllerView extends SingleCropControllerView {
15 | private ImageView mCloseImg;
16 | private ImageView mOkImg;
17 |
18 | public CustomCropControllerView(Context context) {
19 | super(context);
20 | }
21 |
22 | /**
23 | * @return item布局id
24 | */
25 | @Override
26 | protected int getLayoutId() {
27 | return R.layout.layout_custom_crop;
28 | }
29 |
30 | /**
31 | * @param view 初始化view
32 | */
33 | @Override
34 | protected void initView(View view) {
35 | mCloseImg = view.findViewById(R.id.mCloseImg);
36 | mOkImg = view.findViewById(R.id.mOkImg);
37 | mCloseImg.setOnClickListener(new OnClickListener() {
38 | @Override
39 | public void onClick(View v) {
40 | onBackPressed();
41 | }
42 | });
43 | }
44 |
45 | @Override
46 | public void setStatusBar() {
47 | PStatusBarUtil.fullScreenWithCheckNotch((Activity) getContext(), Color.BLACK);
48 | }
49 |
50 | @Override
51 | public View getCompleteView() {
52 | return mOkImg;
53 | }
54 |
55 | @Override
56 | public void setCropViewParams(CropImageView cropImageView, MarginLayoutParams params) {
57 | params.bottomMargin = dp(60);
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/app/src/main/res/layout/a_layout_pic_select.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
21 |
22 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/app/src/main/res/layout/activity_second.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
13 |
14 |
21 |
22 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/app/src/main/res/layout/layout_custom_crop.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
23 |
24 |
31 |
32 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/app/src/main/res/layout/layout_custom_preview.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
11 |
12 |
19 |
20 |
30 |
31 |
32 |
33 |
34 |
45 |
46 |
52 |
53 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_androidx/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/app/src/main/res/mipmap-ldpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_androidx/app/src/main/res/mipmap-ldpi/ic_launcher.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_androidx/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_androidx/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/app/src/main/res/mipmap-xhdpi/picker_crop_close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_androidx/app/src/main/res/mipmap-xhdpi/picker_crop_close.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/app/src/main/res/mipmap-xhdpi/picker_crop_ok.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_androidx/app/src/main/res/mipmap-xhdpi/picker_crop_ok.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/app/src/main/res/mipmap-xhdpi/ypx_pic_selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_androidx/app/src/main/res/mipmap-xhdpi/ypx_pic_selected.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/app/src/main/res/mipmap-xhdpi/ypx_pic_unselected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_androidx/app/src/main/res/mipmap-xhdpi/ypx_pic_unselected.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/app/src/main/res/mipmap-xxhdpi/add_pic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_androidx/app/src/main/res/mipmap-xxhdpi/add_pic.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_androidx/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/app/src/main/res/mipmap-xxhdpi/image_close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_androidx/app/src/main/res/mipmap-xxhdpi/image_close.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_androidx/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #019DAC
4 | #019DAC
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | YImagePicker
3 | 点错了
4 | 确定
5 |
6 | 在string中修改文本
7 | 下一步
8 | yyyy年MM月
9 |
10 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 |
5 | repositories {
6 | google()
7 | jcenter()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.6.1'
11 |
12 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
13 | //classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.0.0"
14 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
15 |
16 | // NOTE: Do not place your application dependencies here; they belong
17 | // in the individual module build.gradle files
18 | }
19 | }
20 |
21 | allprojects {
22 | repositories {
23 | google()
24 | jcenter()
25 |
26 | }
27 | }
28 |
29 | task clean(type: Delete) {
30 | delete rootProject.buildDir
31 | }
32 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 | android.useAndroidX=true
14 | android.enableJetifier=true
15 |
16 | # When configured, Gradle will run in incubating parallel mode.
17 | # This option should only be used with decoupled projects. More details, visit
18 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
19 | # org.gradle.parallel=true
20 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_androidx/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Mar 04 09:51:46 CST 2020
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
7 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 29
5 | defaultConfig {
6 | minSdkVersion 19
7 | targetSdkVersion 29
8 | }
9 | }
10 |
11 | dependencies {
12 | api fileTree(dir: 'libs', include: ['*.jar'])
13 | implementation 'androidx.appcompat:appcompat:1.1.0'
14 | implementation 'androidx.recyclerview:recyclerview:1.1.0'
15 | }
16 |
17 |
18 | apply from: 'generate.gradle'
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/local.properties:
--------------------------------------------------------------------------------
1 | ## This file must *NOT* be checked into Version Control Systems,
2 | # as it contains information specific to your local configuration.
3 | #
4 | # Location of the SDK. This is only used by Gradle.
5 | # For customization when using a Version Control System, please read the
6 | # header note.
7 | #Thu Sep 19 14:17:17 CST 2019
8 | sdk.dir=E\:\\sdk
9 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
20 |
24 |
25 |
30 |
31 |
36 |
37 |
42 |
43 |
48 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/java/com/ypx/imagepicker/bean/ImageCropMode.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.bean;
2 |
3 | /**
4 | * Description: 图片剪裁模式
5 | *
6 | * Author: peixing.yang
7 | * Date: 2019/2/21
8 | */
9 | public class ImageCropMode {
10 | /**
11 | * 填充模式,按照图片宽度填充到容器(屏幕)宽度
12 | */
13 | public static int CropViewScale_FULL = -5;
14 | /**
15 | * 自适应模式,按照图片高度自适应容器高度
16 | */
17 | public static int CropViewScale_FIT = -6;
18 | /**
19 | * imageView图片显示模式 填充
20 | */
21 | public static int ImageScale_FILL = -7;
22 |
23 | /**
24 | * imageView图片显示模式 留白
25 | */
26 | public static int ImageScale_GAP = -8;
27 | }
28 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/java/com/ypx/imagepicker/bean/PickerError.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.bean;
2 |
3 | /**
4 | * Time: 2019/10/18 9:18
5 | * Author:ypx
6 | * Description: 选择器调用失败的回调
7 | */
8 | public enum PickerError {
9 |
10 | CANCEL(-26883, "pick cancel"),
11 | MEDIA_NOT_FOUND(-26884, "not found media files"),
12 | PRESENTER_NOT_FOUND(-26885, "not found presenter,you must be implements IMultiPickerBindPresenter or ICropPickerBindPresenter"),
13 | UI_CONFIG_NOT_FOUND(-26886, "presenter not found uiConfig,please check IMultiPickerBindPresenter or ICropPickerBindPresenter's getUiConfig() method realize"),
14 | SELECT_CONFIG_NOT_FOUND(-26887, "not found selectConfig or cropConfig"),
15 | CROP_URL_NOT_FOUND(-26888, "not found imagePath to crop"),
16 | CROP_EXCEPTION(-26889, "crop exception"),
17 | TAKE_PHOTO_FAILED(-268890, "takePhoto failed"),
18 | MIMETYPES_EMPTY(-268892, "mimeTypes size is 0"),
19 | OTHER(-26891, "other error");
20 |
21 |
22 | private int mCode = 0;
23 | private String mMessage = "";
24 |
25 | PickerError(int code, String msg) {
26 | mCode = code;
27 | mMessage = msg;
28 | }
29 |
30 | public void setMessage(String mMessage) {
31 | this.mMessage = mMessage;
32 | }
33 |
34 | public static PickerError valueOf(int code) {
35 | if (code == CANCEL.getCode()) {
36 | return CANCEL;
37 | } else if (code == PRESENTER_NOT_FOUND.getCode()) {
38 | return PRESENTER_NOT_FOUND;
39 | } else if (code == UI_CONFIG_NOT_FOUND.getCode()) {
40 | return UI_CONFIG_NOT_FOUND;
41 | } else if (code == SELECT_CONFIG_NOT_FOUND.getCode()) {
42 | return SELECT_CONFIG_NOT_FOUND;
43 | } else if (code == MEDIA_NOT_FOUND.getCode()) {
44 | return MEDIA_NOT_FOUND;
45 | }
46 | return OTHER;
47 | }
48 |
49 | public int getCode() {
50 | return mCode;
51 | }
52 |
53 | public String getMessage() {
54 | return mMessage;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/java/com/ypx/imagepicker/bean/SelectMode.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.bean;
2 |
3 | /**
4 | * Description: 图片选择模式
5 | *
6 | * Author: peixing.yang
7 | * Date: 2019/2/21
8 | */
9 | public interface SelectMode {
10 | int MODE_SINGLE = 0;
11 | int MODE_MULTI = 1;
12 | int MODE_CROP = 3;
13 | }
14 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/java/com/ypx/imagepicker/bean/UriPathInfo.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.bean;
2 |
3 | import android.net.Uri;
4 | import android.os.Parcel;
5 | import android.os.Parcelable;
6 |
7 | import java.io.Serializable;
8 |
9 | public class UriPathInfo implements Serializable, Parcelable {
10 | public Uri uri;
11 | public String absolutePath;
12 |
13 | public UriPathInfo(Uri uri, String absolutePath) {
14 | this.uri = uri;
15 | this.absolutePath = absolutePath;
16 | }
17 |
18 | protected UriPathInfo(Parcel in) {
19 | uri = in.readParcelable(Uri.class.getClassLoader());
20 | absolutePath = in.readString();
21 | }
22 |
23 | public static final Creator CREATOR = new Creator() {
24 | @Override
25 | public UriPathInfo createFromParcel(Parcel in) {
26 | return new UriPathInfo(in);
27 | }
28 |
29 | @Override
30 | public UriPathInfo[] newArray(int size) {
31 | return new UriPathInfo[size];
32 | }
33 | };
34 |
35 | /**
36 | * Describe the kinds of special objects contained in this Parcelable
37 | * instance's marshaled representation. For example, if the object will
38 | * include a file descriptor in the output of {@link #writeToParcel(Parcel, int)},
39 | * the return value of this method must include the
40 | * {@link #CONTENTS_FILE_DESCRIPTOR} bit.
41 | *
42 | * @return a bitmask indicating the set of special object types marshaled
43 | * by this Parcelable object instance.
44 | */
45 | @Override
46 | public int describeContents() {
47 | return 0;
48 | }
49 |
50 | /**
51 | * Flatten this object in to a Parcel.
52 | *
53 | * @param dest The Parcel in which the object should be written.
54 | * @param flags Additional flags about how the object should be written.
55 | * May be 0 or {@link #PARCELABLE_WRITE_RETURN_VALUE}.
56 | */
57 | @Override
58 | public void writeToParcel(Parcel dest, int flags) {
59 | dest.writeParcelable(uri, flags);
60 | dest.writeString(absolutePath);
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/java/com/ypx/imagepicker/bean/selectconfig/CropSelectConfig.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.bean.selectconfig;
2 |
3 | import com.ypx.imagepicker.bean.ImageItem;
4 |
5 |
6 | /**
7 | * Time: 2019/9/3 13:46
8 | * Author:ypx
9 | * Description:小红书剪裁配置类
10 | */
11 | public class CropSelectConfig extends BaseSelectConfig {
12 | private ImageItem firstImageItem;
13 | private boolean assignGapState = false;
14 |
15 | public CropSelectConfig() {
16 | setSinglePickImageOrVideoType(true);
17 | }
18 |
19 | public ImageItem getFirstImageItem() {
20 | return firstImageItem;
21 | }
22 |
23 |
24 | public void setFirstImageItem(ImageItem firstImageItem) {
25 | this.firstImageItem = firstImageItem;
26 | }
27 |
28 | public boolean hasFirstImageItem() {
29 | return firstImageItem != null && firstImageItem.width > 0 && firstImageItem.height > 0;
30 | }
31 |
32 | public boolean isAssignGapState() {
33 | return assignGapState;
34 | }
35 |
36 | public void setAssignGapState(boolean assignGapState) {
37 | this.assignGapState = assignGapState;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/java/com/ypx/imagepicker/data/ICameraExecutor.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.data;
2 |
3 | import androidx.annotation.Nullable;
4 |
5 | import com.ypx.imagepicker.bean.ImageItem;
6 |
7 | public interface ICameraExecutor {
8 |
9 | void takePhoto();
10 |
11 | void takeVideo();
12 |
13 | void onTakePhotoResult(@Nullable ImageItem imageItem);
14 | }
15 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/java/com/ypx/imagepicker/data/IReloadExecutor.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.data;
2 |
3 | import com.ypx.imagepicker.bean.ImageItem;
4 |
5 | import java.util.List;
6 |
7 | public interface IReloadExecutor {
8 |
9 | /**
10 | * 根据当前选择列表,重新刷新选择器选择状态
11 | *
12 | * @param selectedList 当前选中列表
13 | */
14 | void reloadPickerWithList(List selectedList);
15 | }
16 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/java/com/ypx/imagepicker/data/MediaStoreConstants.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.data;
2 |
3 | import android.net.Uri;
4 | import android.provider.MediaStore;
5 |
6 | /**
7 | * Time: 2019/10/29 20:38
8 | * Author:ypx
9 | * Description:
10 | */
11 | class MediaStoreConstants {
12 | static final String MIME_TYPE = MediaStore.MediaColumns.MIME_TYPE;
13 | static final String MEDIA_TYPE = MediaStore.Files.FileColumns.MEDIA_TYPE;
14 | static final String DISPLAY_NAME = MediaStore.Files.FileColumns.DISPLAY_NAME;
15 | static final int MEDIA_TYPE_VIDEO = MediaStore.Files.FileColumns.MEDIA_TYPE_VIDEO;
16 | static final int MEDIA_TYPE_IMAGE = MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE;
17 | static final String WIDTH = MediaStore.Files.FileColumns.WIDTH;
18 | static final String HEIGHT = MediaStore.Files.FileColumns.HEIGHT;
19 | static final String DATE_MODIFIED = MediaStore.Files.FileColumns.DATE_MODIFIED;
20 | static final String DURATION = MediaStore.MediaColumns.DURATION;
21 | static final String SIZE = MediaStore.MediaColumns.SIZE;
22 | static final String _ID = MediaStore.Files.FileColumns._ID;
23 | static final String COLUMN_BUCKET_ID = "bucket_id";
24 | static final String COLUMN_BUCKET_DISPLAY_NAME = "bucket_display_name";
25 | static final String COLUMN_URI = "uri";
26 | static final String COLUMN_COUNT = "count";
27 | static final String BUCKET_ORDER_BY = MediaStore.MediaColumns.DATE_MODIFIED + " DESC";
28 | /**
29 | * @deprecated android 10 已废弃此常亮
30 | */
31 | static final String DATA = MediaStore.MediaColumns.DATA;
32 | static final Uri QUERY_URI = MediaStore.Files.getContentUri("external");
33 |
34 | /**
35 | * @return 是否是Android10之前版本
36 | */
37 | static boolean isBeforeAndroidQ() {
38 | return android.os.Build.VERSION.SDK_INT < 29;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/java/com/ypx/imagepicker/data/OnImagePickCompleteListener.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.data;
2 |
3 |
4 | import com.ypx.imagepicker.bean.ImageItem;
5 |
6 | import java.io.Serializable;
7 | import java.util.ArrayList;
8 | import java.util.List;
9 |
10 | /**
11 | * Description: 图片选择器回调
12 | *
13 | * Author: peixing.yang
14 | * Date: 2019/2/21
15 | */
16 | public interface OnImagePickCompleteListener extends Serializable {
17 | void onImagePickComplete(ArrayList items);
18 | }
19 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/java/com/ypx/imagepicker/data/OnImagePickCompleteListener2.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.data;
2 |
3 |
4 | import com.ypx.imagepicker.bean.ImageItem;
5 | import com.ypx.imagepicker.bean.PickerError;
6 |
7 | import java.io.Serializable;
8 | import java.util.ArrayList;
9 |
10 | /**
11 | * Description: 图片选择器回调
12 | *
13 | * Author: peixing.yang
14 | * Date: 2019/2/21
15 | */
16 | public interface OnImagePickCompleteListener2 extends OnImagePickCompleteListener {
17 | void onPickFailed(PickerError error);
18 | }
19 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/java/com/ypx/imagepicker/data/OnPickerCompleteListener.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.data;
2 |
3 | import com.ypx.imagepicker.bean.ImageItem;
4 | import com.ypx.imagepicker.bean.PickerError;
5 |
6 | import java.util.ArrayList;
7 |
8 | /**
9 | * Time: 2019/10/27 22:02
10 | * Author:ypx
11 | * Description: 类型回调类,调用者可自己定制回调的返回类型
12 | */
13 | public abstract class OnPickerCompleteListener implements OnImagePickCompleteListener2 {
14 |
15 | /**
16 | * 默认回调出来的是 ArrayList 类型,调用者自己实现类型间转化
17 | *
18 | * @param items 选择器回调
19 | * @return 用户自己类型
20 | */
21 | public abstract T onTransit(ArrayList items);
22 |
23 | /**
24 | * 选择器完成回调
25 | *
26 | * @param t 回调类型
27 | */
28 | public abstract void onPickComplete(T t);
29 |
30 | @Override
31 | public void onPickFailed(PickerError error) {
32 |
33 | }
34 |
35 | @Override
36 | public void onImagePickComplete(ArrayList items) {
37 | onPickComplete(onTransit(items));
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/java/com/ypx/imagepicker/data/OnStringCompleteListener.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.data;
2 |
3 | import com.ypx.imagepicker.bean.ImageItem;
4 | import com.ypx.imagepicker.bean.PickerError;
5 |
6 | import java.util.ArrayList;
7 |
8 | /**
9 | * Time: 2019/10/27 21:26
10 | * Author:ypx
11 | * Description: OnPickerCompleteListener 子类,实现了String 类型回调
12 | */
13 | public abstract class OnStringCompleteListener extends OnPickerCompleteListener {
14 |
15 | public abstract void onPickComplete(String path);
16 |
17 | @Override
18 | public String onTransit(ArrayList items) {
19 | if (items.size() > 0 && items.get(0) != null) {
20 | return items.get(0).path;
21 | }
22 | return null;
23 | }
24 |
25 | @Override
26 | public void onPickFailed(PickerError error) {
27 |
28 | }
29 |
30 | @Override
31 | public void onImagePickComplete(ArrayList items) {
32 | onPickComplete(onTransit(items));
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/java/com/ypx/imagepicker/data/OnStringListCompleteListener.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.data;
2 |
3 | import com.ypx.imagepicker.bean.ImageItem;
4 | import com.ypx.imagepicker.bean.PickerError;
5 |
6 | import java.util.ArrayList;
7 |
8 | /**
9 | * Time: 2019/10/27 21:26
10 | * Author:ypx
11 | * Description:OnPickerCompleteListener子类,实现了ArrayList 回调
12 | */
13 | public abstract class OnStringListCompleteListener extends OnPickerCompleteListener> {
14 |
15 | public abstract void onPickComplete(ArrayList list);
16 |
17 | @Override
18 | public void onPickFailed(PickerError error) {
19 |
20 | }
21 |
22 | @Override
23 | public void onImagePickComplete(ArrayList items) {
24 | onPickComplete(onTransit(items));
25 | }
26 |
27 | @Override
28 | public ArrayList onTransit(ArrayList items) {
29 | ArrayList list = new ArrayList<>();
30 | for (ImageItem item : items) {
31 | list.add(item.path);
32 | }
33 | return list;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/java/com/ypx/imagepicker/data/PickerActivityCallBack.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.data;
2 |
3 | import android.content.Intent;
4 |
5 | import com.ypx.imagepicker.ImagePicker;
6 | import com.ypx.imagepicker.bean.PickerError;
7 | import com.ypx.imagepicker.helper.launcher.PLauncher;
8 |
9 | import java.util.ArrayList;
10 |
11 | /**
12 | * Time: 2019/11/6 17:35
13 | * Author:ypx
14 | * Description:选择器activityResult处理类
15 | */
16 | public class PickerActivityCallBack implements PLauncher.Callback {
17 | private OnImagePickCompleteListener listener;
18 |
19 | public static PickerActivityCallBack create(OnImagePickCompleteListener listener) {
20 | return new PickerActivityCallBack(listener);
21 | }
22 |
23 | private PickerActivityCallBack(OnImagePickCompleteListener listener) {
24 | this.listener = listener;
25 | }
26 |
27 | @Override
28 | public void onActivityResult(int resultCode, Intent data) {
29 | if (listener != null
30 | && resultCode == ImagePicker.REQ_PICKER_RESULT_CODE
31 | && data.hasExtra(ImagePicker.INTENT_KEY_PICKER_RESULT)) {
32 | ArrayList list = (ArrayList) data.getSerializableExtra(ImagePicker.INTENT_KEY_PICKER_RESULT);
33 | listener.onImagePickComplete(list);
34 | } else if (listener instanceof OnImagePickCompleteListener2) {
35 | if (resultCode == 0) {
36 | resultCode = PickerError.CANCEL.getCode();
37 | }
38 | ((OnImagePickCompleteListener2) listener).onPickFailed(PickerError.valueOf(resultCode));
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/java/com/ypx/imagepicker/data/ProgressSceneEnum.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.data;
2 |
3 | public enum ProgressSceneEnum {
4 | loadMediaItem,
5 | crop
6 | }
7 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/java/com/ypx/imagepicker/helper/DetailImageLoadHelper.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.helper;
2 |
3 | import android.widget.ImageView;
4 |
5 | import com.ypx.imagepicker.ImagePicker;
6 | import com.ypx.imagepicker.bean.ImageItem;
7 | import com.ypx.imagepicker.presenter.IPickerPresenter;
8 |
9 | public class DetailImageLoadHelper {
10 |
11 | public static void displayDetailImage(boolean isCrop, final ImageView imageView,
12 | final IPickerPresenter presenter, final ImageItem imageItem) {
13 | if (presenter != null) {
14 | //剪裁不压缩,大图预览尺寸超过2K的图片需要压缩,不能使用ARGB-8888加载,滑动会卡顿,并且浪费内存,
15 | // 其实最好的做法是分段加载,但是cropImageView在支持剪裁的基础上不能支持分段加载
16 | if (isCrop || ImagePicker.isPreviewWithHighQuality()) {
17 | presenter.displayImage(imageView, imageItem, imageView.getWidth(), false);
18 | } else {
19 | presenter.displayImage(imageView, imageItem, imageView.getWidth(), imageItem.isOver2KImage());
20 | }
21 |
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/java/com/ypx/imagepicker/helper/ILifeCycleCallBack.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.helper;
2 |
3 | import androidx.lifecycle.Lifecycle;
4 | import androidx.lifecycle.LifecycleObserver;
5 | import androidx.lifecycle.OnLifecycleEvent;
6 |
7 | public interface ILifeCycleCallBack extends LifecycleObserver {
8 |
9 | @OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
10 | void onResume();
11 |
12 | @OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
13 | void onPause();
14 |
15 | @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
16 | void onDestroy();
17 | }
18 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/java/com/ypx/imagepicker/helper/PickerErrorExecutor.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.helper;
2 |
3 | import android.app.Activity;
4 |
5 | import com.ypx.imagepicker.bean.PickerError;
6 | import com.ypx.imagepicker.data.OnImagePickCompleteListener;
7 | import com.ypx.imagepicker.data.OnImagePickCompleteListener2;
8 |
9 | /**
10 | * Time: 2019/10/18 9:53
11 | * Author:ypx
12 | * Description: 调用选择器失败回调
13 | */
14 | public class PickerErrorExecutor {
15 |
16 | public static void executeError(Activity activity, int code) {
17 | activity.setResult(code);
18 | activity.finish();
19 | }
20 |
21 | public static void executeError(OnImagePickCompleteListener listener, int code) {
22 | if (listener instanceof OnImagePickCompleteListener2) {
23 | ((OnImagePickCompleteListener2) listener).onPickFailed(PickerError.valueOf(code));
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/java/com/ypx/imagepicker/helper/launcher/PRouter.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.helper.launcher;
2 |
3 | import android.app.Fragment;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.util.SparseArray;
7 |
8 | import java.util.Random;
9 |
10 | /**
11 | * 把OnActivityResult方式转换为Callback方式的空Fragment(标准SDK)
12 | *
13 | * Created by XiaoFeng on 2018/9/5.
14 | */
15 | public class PRouter extends Fragment {
16 |
17 | private SparseArray mCallbacks = new SparseArray<>();
18 | private Random mCodeGenerator = new Random();
19 |
20 | public PRouter() {
21 | // Required empty public constructor
22 | }
23 |
24 | public static PRouter newInstance() {
25 | return new PRouter();
26 | }
27 |
28 | @Override
29 | public void onCreate(Bundle savedInstanceState) {
30 | super.onCreate(savedInstanceState);
31 | setRetainInstance(true);
32 | }
33 |
34 | public void startActivityForResult(Intent intent, PLauncher.Callback callback) {
35 | int requestCode = makeRequestCode();
36 | mCallbacks.put(requestCode, callback);
37 | startActivityForResult(intent, requestCode);
38 | }
39 |
40 | /**
41 | * 随机生成唯一的requestCode,最多尝试10次
42 | *
43 | * @return
44 | */
45 | private int makeRequestCode() {
46 | int requestCode;
47 | int tryCount = 0;
48 | do {
49 | requestCode = mCodeGenerator.nextInt(0x0000FFFF);
50 | tryCount++;
51 | } while (mCallbacks.indexOfKey(requestCode) >= 0 && tryCount < 10);
52 | return requestCode;
53 | }
54 |
55 | @Override
56 | public void onActivityResult(int requestCode, int resultCode, Intent data) {
57 | super.onActivityResult(requestCode, resultCode, data);
58 | PLauncher.Callback callback = mCallbacks.get(requestCode);
59 | mCallbacks.remove(requestCode);
60 | if (callback != null) {
61 | callback.onActivityResult(resultCode, data);
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/java/com/ypx/imagepicker/helper/launcher/PRouterV4.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.helper.launcher;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import androidx.fragment.app.Fragment;
6 | import android.util.SparseArray;
7 |
8 | import java.util.Random;
9 |
10 | /**
11 | * 把OnActivityResult方式转换为Callback方式的空Fragment(V4兼容包)
12 | *
13 | * Created by XiaoFeng on 2018/9/5.
14 | */
15 | public class PRouterV4 extends Fragment {
16 |
17 | private SparseArray mCallbacks = new SparseArray<>();
18 | private Random mCodeGenerator = new Random();
19 |
20 | public PRouterV4() {
21 | // Required empty public constructor
22 | }
23 |
24 | public static PRouterV4 newInstance() {
25 | return new PRouterV4();
26 | }
27 |
28 | @Override
29 | public void onCreate(Bundle savedInstanceState) {
30 | super.onCreate(savedInstanceState);
31 | setRetainInstance(true);
32 | }
33 |
34 | public void startActivityForResult(Intent intent, PLauncher.Callback callback) {
35 | int requestCode = makeRequestCode();
36 | mCallbacks.put(requestCode, callback);
37 | startActivityForResult(intent, requestCode);
38 | }
39 |
40 | /**
41 | * 随机生成唯一的requestCode,最多尝试10次
42 | *
43 | * @return
44 | */
45 | private int makeRequestCode() {
46 | int requestCode;
47 | int tryCount = 0;
48 | do {
49 | requestCode = mCodeGenerator.nextInt(0x0000FFFF);
50 | tryCount++;
51 | } while (mCallbacks.indexOfKey(requestCode) >= 0 && tryCount < 10);
52 | return requestCode;
53 | }
54 |
55 | @Override
56 | public void onActivityResult(int requestCode, int resultCode, Intent data) {
57 | super.onActivityResult(requestCode, resultCode, data);
58 | PLauncher.Callback callback = mCallbacks.get(requestCode);
59 | mCallbacks.remove(requestCode);
60 | if (callback != null) {
61 | callback.onActivityResult(resultCode, data);
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/java/com/ypx/imagepicker/helper/recyclerviewitemhelper/ItemTouchHelperViewHolder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Paul Burke
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.ypx.imagepicker.helper.recyclerviewitemhelper;
18 |
19 | import androidx.recyclerview.widget.ItemTouchHelper;
20 |
21 | /**
22 | * Interface to notify an item ViewHolder of relevant callbacks from {@link
23 | * androidx.recyclerview.widget.ItemTouchHelper.Callback}.
24 | *
25 | * @author Paul Burke (ipaulpro)
26 | */
27 | public interface ItemTouchHelperViewHolder {
28 |
29 | /**
30 | * Called when the {@link ItemTouchHelper} first registers an item as being moved or swiped.
31 | * Implementations should update the item view to indicate it's active state.
32 | */
33 | void onItemSelected();
34 |
35 |
36 | /**
37 | * Called when the {@link ItemTouchHelper} has completed the move or swipe, and the active item
38 | * state should be cleared.
39 | */
40 | void onItemClear();
41 | }
42 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/java/com/ypx/imagepicker/utils/PSingleMediaScanner.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.utils;
2 |
3 | import android.content.Context;
4 | import android.media.MediaScannerConnection;
5 | import android.net.Uri;
6 | import android.util.Log;
7 |
8 | /**
9 | * @author yangpeixing
10 | * 媒体扫描刷新类
11 | */
12 | public class PSingleMediaScanner implements MediaScannerConnection.MediaScannerConnectionClient {
13 | private MediaScannerConnection mediaScannerConnection;
14 | private String mPath;
15 | private ScanListener mListener;
16 |
17 | public interface ScanListener {
18 | void onScanFinish();
19 | }
20 |
21 | public PSingleMediaScanner(Context context, String mPath, ScanListener mListener) {
22 | this.mPath = mPath;
23 | this.mListener = mListener;
24 | this.mediaScannerConnection = new MediaScannerConnection(context, this);
25 | this.mediaScannerConnection.connect();
26 | }
27 |
28 | @Override
29 | public void onMediaScannerConnected() {
30 | mediaScannerConnection.scanFile(mPath, null);
31 | }
32 |
33 | @Override
34 | public void onScanCompleted(String mPath, Uri mUri) {
35 | mediaScannerConnection.disconnect();
36 | if (mListener != null) {
37 | mListener.onScanFinish();
38 | }
39 | }
40 |
41 | public static void refresh(Context context, String path, PSingleMediaScanner.ScanListener scanListener) {
42 | new PSingleMediaScanner(context.getApplicationContext(), path, scanListener);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/java/com/ypx/imagepicker/utils/PickerFileProvider.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.utils;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.net.Uri;
6 |
7 | import androidx.annotation.NonNull;
8 | import androidx.core.content.FileProvider;
9 |
10 | import java.io.File;
11 |
12 | /**
13 | * Time: 2019/7/24 15:43
14 | * Author:ypx
15 | * Description:
16 | */
17 | public class PickerFileProvider extends FileProvider {
18 |
19 | public static Uri getUriForFile(@NonNull Activity context,
20 | @NonNull File file) {
21 | Uri uri;
22 | if (android.os.Build.VERSION.SDK_INT < 24) {
23 | uri = Uri.fromFile(file);
24 | } else {
25 | uri = getUriForFile(context, context.getApplication().getPackageName()
26 | + ".picker.fileprovider", file);
27 | }
28 |
29 | return uri;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/java/com/ypx/imagepicker/views/base/PickerFolderItemView.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.views.base;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 |
6 | import androidx.annotation.Nullable;
7 |
8 | import com.ypx.imagepicker.bean.ImageSet;
9 | import com.ypx.imagepicker.presenter.IPickerPresenter;
10 |
11 | /**
12 | * Time: 2019/11/13 14:39
13 | * Author:ypx
14 | * Description:自定义文件夹item
15 | */
16 | public abstract class PickerFolderItemView extends PBaseLayout {
17 |
18 | /**
19 | * @return 获取每个item的高度,如果自适应返回-1
20 | */
21 | public abstract int getItemHeight();
22 |
23 | /**
24 | * 加载文件夹缩略图
25 | *
26 | * @param imageSet 文件夹
27 | * @param presenter presenter
28 | */
29 | public abstract void displayCoverImage(ImageSet imageSet, IPickerPresenter presenter);
30 |
31 | /**
32 | * 加载item
33 | *
34 | * @param imageSet 当前文件夹信息
35 | */
36 | public abstract void loadItem(ImageSet imageSet);
37 |
38 | public PickerFolderItemView(Context context) {
39 | super(context);
40 | }
41 |
42 | public PickerFolderItemView(Context context, @Nullable AttributeSet attrs) {
43 | super(context, attrs);
44 | }
45 |
46 | public PickerFolderItemView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
47 | super(context, attrs, defStyleAttr);
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/java/com/ypx/imagepicker/views/base/SingleCropControllerView.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.views.base;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.View;
6 |
7 | import androidx.annotation.Nullable;
8 |
9 | import com.ypx.imagepicker.widget.cropimage.CropImageView;
10 |
11 | /**
12 | * Time: 2019/11/13 14:39
13 | * Author:ypx
14 | * Description:自定义剪裁页面
15 | */
16 | public abstract class SingleCropControllerView extends PBaseLayout {
17 |
18 | /**
19 | * 设置状态栏
20 | */
21 | public abstract void setStatusBar();
22 |
23 | /**
24 | * @return 获取可以点击完成的View
25 | */
26 | public abstract View getCompleteView();
27 |
28 | /**
29 | * @param cropImageView 剪裁的ImageView
30 | * @param params params
31 | */
32 | public abstract void setCropViewParams(CropImageView cropImageView, MarginLayoutParams params);
33 |
34 | public SingleCropControllerView(Context context) {
35 | super(context);
36 | }
37 |
38 | public SingleCropControllerView(Context context, @Nullable AttributeSet attrs) {
39 | super(context, attrs);
40 | }
41 |
42 | public SingleCropControllerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
43 | super(context, attrs, defStyleAttr);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/java/com/ypx/imagepicker/views/redbook/RedBookUiProvider.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.views.redbook;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 |
6 | import com.ypx.imagepicker.views.PickerUiProvider;
7 | import com.ypx.imagepicker.views.base.PickerControllerView;
8 | import com.ypx.imagepicker.views.base.PickerFolderItemView;
9 | import com.ypx.imagepicker.views.base.PickerItemView;
10 | import com.ypx.imagepicker.views.wx.WXFolderItemView;
11 |
12 | public class RedBookUiProvider extends PickerUiProvider {
13 | @Override
14 | public PickerControllerView getBottomBar(Context context) {
15 | return null;
16 | }
17 |
18 | @Override
19 | public PickerControllerView getTitleBar(Context context) {
20 | return new RedBookTitleBar(context);
21 | }
22 |
23 | @Override
24 | public PickerItemView getItemView(Context context) {
25 | return new RedBookItemView(context);
26 | }
27 |
28 | @Override
29 | public PickerFolderItemView getFolderItemView(Context context) {
30 | WXFolderItemView itemView = (WXFolderItemView) super.getFolderItemView(context);
31 | itemView.setIndicatorColor(Color.RED);
32 | itemView.setBackgroundColor(Color.BLACK);
33 | itemView.setNameTextColor(Color.WHITE);
34 | itemView.setCountTextColor(Color.parseColor("#50F5f5f5"));
35 | itemView.setDividerColor(Color.parseColor("#50F5f5f5"));
36 | return itemView;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/java/com/ypx/imagepicker/widget/cropimage/RotateGestureDetector.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.widget.cropimage;
2 |
3 | import android.view.MotionEvent;
4 |
5 | /**
6 | * Description: 旋转手势
7 | *
8 | * Author: peixing.yang
9 | * Date: 2019/2/21
10 | */
11 | public class RotateGestureDetector {
12 |
13 | private static final int MAX_DEGREES_STEP = 120;
14 |
15 | private OnRotateListener mListener;
16 |
17 | private float mPrevSlope;
18 | private float mCurrSlope;
19 |
20 | private float x1;
21 | private float y1;
22 | private float x2;
23 | private float y2;
24 |
25 | public RotateGestureDetector(OnRotateListener l) {
26 | mListener = l;
27 | }
28 |
29 | public void onTouchEvent(MotionEvent event) {
30 |
31 | final int Action = event.getActionMasked();
32 |
33 | switch (Action) {
34 | case MotionEvent.ACTION_POINTER_DOWN:
35 | case MotionEvent.ACTION_POINTER_UP:
36 | if (event.getPointerCount() == 2) mPrevSlope = caculateSlope(event);
37 | break;
38 | case MotionEvent.ACTION_MOVE:
39 | if (event.getPointerCount() > 1) {
40 | mCurrSlope = caculateSlope(event);
41 |
42 | double currDegrees = Math.toDegrees(Math.atan(mCurrSlope));
43 | double prevDegrees = Math.toDegrees(Math.atan(mPrevSlope));
44 |
45 | double deltaSlope = currDegrees - prevDegrees;
46 |
47 | if (Math.abs(deltaSlope) <= MAX_DEGREES_STEP) {
48 | mListener.onRotate((float) deltaSlope, (x2 + x1) / 2, (y2 + y1) / 2);
49 | }
50 | mPrevSlope = mCurrSlope;
51 | }
52 | break;
53 | default:
54 | break;
55 | }
56 | }
57 |
58 | private float caculateSlope(MotionEvent event) {
59 | x1 = event.getX(0);
60 | y1 = event.getY(0);
61 | x2 = event.getX(1);
62 | y2 = event.getY(1);
63 | return (y2 - y1) / (x2 - x1);
64 | }
65 |
66 | public interface OnRotateListener {
67 | void onRotate(float degrees, float focusX, float focusY);
68 | }
69 | }
70 |
71 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/anim/picker_anim_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
7 |
8 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/anim/picker_anim_up.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
7 |
8 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/anim/picker_fade_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/anim/picker_fade_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
20 |
21 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/anim/picker_hide2bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
26 |
27 |
31 |
32 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/anim/picker_show2bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
13 |
14 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/anim/picker_top_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/anim/picker_top_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/drawable/picker_selector_list_item_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/layout/picker_activity_crop.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
10 |
11 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/layout/picker_activity_crop_cover.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
10 |
11 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/layout/picker_activity_fragment_wrapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
12 |
17 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/layout/picker_activity_preview.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
10 |
11 |
15 |
16 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/layout/picker_default_bottombar.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
28 |
29 |
30 |
41 |
42 |
43 |
48 |
49 |
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/layout/picker_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
18 |
19 |
31 |
32 |
36 |
37 |
42 |
43 |
54 |
55 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/layout/picker_item_camera.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
20 |
21 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/layout/picker_item_image_set.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
17 |
18 |
31 |
32 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/layout/picker_item_root.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/layout/picker_wx_crop_titlebar.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
26 |
27 |
28 |
44 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/mipmap-xxhdpi/picker_arrow_down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_androidx/imagepicker/src/main/res/mipmap-xxhdpi/picker_arrow_down.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/mipmap-xxhdpi/picker_ic_camera.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_androidx/imagepicker/src/main/res/mipmap-xxhdpi/picker_ic_camera.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/mipmap-xxhdpi/picker_icon_back_black.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_androidx/imagepicker/src/main/res/mipmap-xxhdpi/picker_icon_back_black.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/mipmap-xxhdpi/picker_icon_close_black.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_androidx/imagepicker/src/main/res/mipmap-xxhdpi/picker_icon_close_black.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/mipmap-xxhdpi/picker_icon_fill.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_androidx/imagepicker/src/main/res/mipmap-xxhdpi/picker_icon_fill.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/mipmap-xxhdpi/picker_icon_fit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_androidx/imagepicker/src/main/res/mipmap-xxhdpi/picker_icon_fit.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/mipmap-xxhdpi/picker_icon_full.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_androidx/imagepicker/src/main/res/mipmap-xxhdpi/picker_icon_full.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/mipmap-xxhdpi/picker_icon_haswhite.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_androidx/imagepicker/src/main/res/mipmap-xxhdpi/picker_icon_haswhite.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/mipmap-xxhdpi/picker_icon_item_photo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_androidx/imagepicker/src/main/res/mipmap-xxhdpi/picker_icon_item_photo.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/mipmap-xxhdpi/picker_icon_unselect.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_androidx/imagepicker/src/main/res/mipmap-xxhdpi/picker_icon_unselect.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/mipmap-xxhdpi/picker_icon_video.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_androidx/imagepicker/src/main/res/mipmap-xxhdpi/picker_icon_video.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/mipmap-xxhdpi/picker_item_video.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_androidx/imagepicker/src/main/res/mipmap-xxhdpi/picker_item_video.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/mipmap-xxhdpi/picker_item_video_mask.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_androidx/imagepicker/src/main/res/mipmap-xxhdpi/picker_item_video_mask.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/mipmap-xxhdpi/picker_text_indicator.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_androidx/imagepicker/src/main/res/mipmap-xxhdpi/picker_text_indicator.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/mipmap-xxhdpi/picker_wechat_select.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_androidx/imagepicker/src/main/res/mipmap-xxhdpi/picker_wechat_select.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/mipmap-xxhdpi/picker_wechat_unselect.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_androidx/imagepicker/src/main/res/mipmap-xxhdpi/picker_wechat_unselect.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/mipmap-xxhdpi/pricker_drop_down_checked.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_androidx/imagepicker/src/main/res/mipmap-xxhdpi/pricker_drop_down_checked.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/mipmap-xxhdpi/video_play_small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_androidx/imagepicker/src/main/res/mipmap-xxhdpi/video_play_small.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #F5F5F5
4 |
5 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/imagepicker/src/main/res/xml/picker_file_paths.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_androidx/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app',"imagepicker"
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 29
5 | defaultConfig {
6 | applicationId "com.example.imagepicker_support"
7 | minSdkVersion 19
8 | targetSdkVersion 29
9 | versionCode 1
10 | versionName "1.0"
11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | implementation fileTree(dir: 'libs', include: ['*.jar'])
23 | implementation 'com.android.support:appcompat-v7:28.0.0'
24 | implementation 'com.android.support:recyclerview-v7:28.0.0'
25 | implementation 'com.github.bumptech.glide:glide:4.9.0'
26 | implementation project(path: ':imagepicker-support')
27 | implementation 'com.android.support:cardview-v7:28.0.0'
28 | //implementation 'com.ypx.yimagepicker:support:3.1.4.1'
29 | }
30 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/app/src/androidTest/java/com/example/imagepicker_support/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.example.imagepicker_support;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.example.imagepicker_support", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/app/src/main/java/com/example/imagepicker_support/preview/PreviewResultListActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.imagepicker_support.preview;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.view.View;
6 |
7 | import android.support.annotation.Nullable;
8 |
9 | import com.example.imagepicker_support.R;
10 | import com.ypx.imagepicker.ImagePicker;
11 | import com.ypx.imagepicker.bean.ImageItem;
12 | import com.ypx.imagepicker.utils.PStatusBarUtil;
13 |
14 | import java.util.ArrayList;
15 |
16 | /**
17 | * Time: 2019/11/6 18:24
18 | * Author:ypx
19 | * Description:简单的多图预览界面,用于演示ImagePicker.closePickerWithCallback(imageItems);
20 | */
21 | public class PreviewResultListActivity extends Activity {
22 | ArrayList imageItems = new ArrayList<>();
23 |
24 | @Override
25 | protected void onCreate(@Nullable Bundle savedInstanceState) {
26 | super.onCreate(savedInstanceState);
27 | PStatusBarUtil.fullScreen(this);
28 | setContentView(R.layout.activity_second);
29 | imageItems = (ArrayList) getIntent().getSerializableExtra(ImagePicker.INTENT_KEY_PICKER_RESULT);
30 | ImagesViewPager viewPager = findViewById(R.id.viewpager);
31 | viewPager.setImageViewList(imageItems);
32 | }
33 |
34 | public void click(View view) {
35 | ImagePicker.closePickerWithCallback(imageItems);
36 | finish();
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/app/src/main/java/com/example/imagepicker_support/style/custom/CustomCropControllerView.java:
--------------------------------------------------------------------------------
1 | package com.example.imagepicker_support.style.custom;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.graphics.Color;
6 | import android.view.View;
7 | import android.widget.ImageView;
8 |
9 | import com.example.imagepicker_support.R;
10 | import com.ypx.imagepicker.utils.PStatusBarUtil;
11 | import com.ypx.imagepicker.views.base.SingleCropControllerView;
12 | import com.ypx.imagepicker.widget.cropimage.CropImageView;
13 |
14 | public class CustomCropControllerView extends SingleCropControllerView {
15 | private ImageView mCloseImg;
16 | private ImageView mOkImg;
17 |
18 | public CustomCropControllerView(Context context) {
19 | super(context);
20 | }
21 |
22 | /**
23 | * @return item布局id
24 | */
25 | @Override
26 | protected int getLayoutId() {
27 | return R.layout.layout_custom_crop;
28 | }
29 |
30 | /**
31 | * @param view 初始化view
32 | */
33 | @Override
34 | protected void initView(View view) {
35 | mCloseImg = view.findViewById(R.id.mCloseImg);
36 | mOkImg = view.findViewById(R.id.mOkImg);
37 | mCloseImg.setOnClickListener(new OnClickListener() {
38 | @Override
39 | public void onClick(View v) {
40 | onBackPressed();
41 | }
42 | });
43 | }
44 |
45 | @Override
46 | public void setStatusBar() {
47 | PStatusBarUtil.fullScreenWithCheckNotch((Activity) getContext(), Color.BLACK);
48 | }
49 |
50 | @Override
51 | public View getCompleteView() {
52 | return mOkImg;
53 | }
54 |
55 | @Override
56 | public void setCropViewParams(CropImageView cropImageView, MarginLayoutParams params) {
57 | params.bottomMargin = dp(60);
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/app/src/main/res/layout/a_layout_pic_select.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
21 |
22 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/app/src/main/res/layout/activity_second.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
13 |
14 |
21 |
22 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/app/src/main/res/layout/layout_custom_crop.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
23 |
24 |
31 |
32 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/app/src/main/res/layout/layout_custom_preview.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
11 |
12 |
19 |
20 |
30 |
31 |
32 |
33 |
34 |
45 |
46 |
52 |
53 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_support/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/app/src/main/res/mipmap-ldpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_support/app/src/main/res/mipmap-ldpi/ic_launcher.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_support/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_support/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/app/src/main/res/mipmap-xhdpi/picker_crop_close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_support/app/src/main/res/mipmap-xhdpi/picker_crop_close.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/app/src/main/res/mipmap-xhdpi/picker_crop_ok.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_support/app/src/main/res/mipmap-xhdpi/picker_crop_ok.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/app/src/main/res/mipmap-xhdpi/ypx_pic_selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_support/app/src/main/res/mipmap-xhdpi/ypx_pic_selected.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/app/src/main/res/mipmap-xhdpi/ypx_pic_unselected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_support/app/src/main/res/mipmap-xhdpi/ypx_pic_unselected.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/app/src/main/res/mipmap-xxhdpi/add_pic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_support/app/src/main/res/mipmap-xxhdpi/add_pic.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_support/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/app/src/main/res/mipmap-xxhdpi/image_close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_support/app/src/main/res/mipmap-xxhdpi/image_close.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_support/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #019DAC
4 | #019DAC
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | YImagePicker_S
3 | 点错了
4 | 确定
5 |
6 | 在string中修改文本
7 | 下一步
8 | yyyy年MM月
9 |
10 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/app/src/test/java/com/example/imagepicker_support/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.example.imagepicker_support;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | google()
6 | jcenter()
7 |
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.5.2'
11 |
12 | // NOTE: Do not place your application dependencies here; they belong
13 | // in the individual module build.gradle files
14 | }
15 | }
16 |
17 | allprojects {
18 | repositories {
19 | google()
20 | jcenter()
21 | }
22 | }
23 |
24 | task clean(type: Delete) {
25 | delete rootProject.buildDir
26 | }
27 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 |
15 |
16 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_support/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 09 14:42:49 CST 2019
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
7 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 29
5 | defaultConfig {
6 | minSdkVersion 19
7 | targetSdkVersion 29
8 | }
9 | }
10 |
11 | dependencies {
12 | api fileTree(dir: 'libs', include: ['*.jar'])
13 | implementation 'com.android.support:appcompat-v7:28.0.0'
14 | implementation 'com.android.support:recyclerview-v7:28.0.0'
15 | implementation 'org.jetbrains:annotations-java5:15.0'
16 | }
17 |
18 |
19 | apply from: 'generate.gradle'
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
20 |
24 |
25 |
30 |
31 |
36 |
37 |
42 |
43 |
48 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/java/com/ypx/imagepicker/bean/ImageCropMode.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.bean;
2 |
3 | /**
4 | * Description: 图片剪裁模式
5 | *
6 | * Author: peixing.yang
7 | * Date: 2019/2/21
8 | */
9 | public class ImageCropMode {
10 | /**
11 | * 填充模式,按照图片宽度填充到容器(屏幕)宽度
12 | */
13 | public static int CropViewScale_FULL = -5;
14 | /**
15 | * 自适应模式,按照图片高度自适应容器高度
16 | */
17 | public static int CropViewScale_FIT = -6;
18 | /**
19 | * imageView图片显示模式 填充
20 | */
21 | public static int ImageScale_FILL = -7;
22 |
23 | /**
24 | * imageView图片显示模式 留白
25 | */
26 | public static int ImageScale_GAP = -8;
27 | }
28 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/java/com/ypx/imagepicker/bean/PickerError.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.bean;
2 |
3 | /**
4 | * Time: 2019/10/18 9:18
5 | * Author:ypx
6 | * Description: 选择器调用失败的回调
7 | */
8 | public enum PickerError {
9 |
10 | CANCEL(-26883, "pick cancel"),
11 | MEDIA_NOT_FOUND(-26884, "not found media files"),
12 | PRESENTER_NOT_FOUND(-26885, "not found presenter,you must be implements IMultiPickerBindPresenter or ICropPickerBindPresenter"),
13 | UI_CONFIG_NOT_FOUND(-26886, "presenter not found uiConfig,please check IMultiPickerBindPresenter or ICropPickerBindPresenter's getUiConfig() method realize"),
14 | SELECT_CONFIG_NOT_FOUND(-26887, "not found selectConfig or cropConfig"),
15 | CROP_URL_NOT_FOUND(-26888, "not found imagePath to crop"),
16 | CROP_EXCEPTION(-26889, "crop exception"),
17 | TAKE_PHOTO_FAILED(-268890, "takePhoto failed"),
18 | MIMETYPES_EMPTY(-268892, "mimeTypes size is 0"),
19 | OTHER(-26891, "other error");
20 |
21 |
22 | private int mCode = 0;
23 | private String mMessage = "";
24 |
25 | PickerError(int code, String msg) {
26 | mCode = code;
27 | mMessage = msg;
28 | }
29 |
30 | public void setMessage(String mMessage) {
31 | this.mMessage = mMessage;
32 | }
33 |
34 | public static PickerError valueOf(int code) {
35 | if (code == CANCEL.getCode()) {
36 | return CANCEL;
37 | } else if (code == PRESENTER_NOT_FOUND.getCode()) {
38 | return PRESENTER_NOT_FOUND;
39 | } else if (code == UI_CONFIG_NOT_FOUND.getCode()) {
40 | return UI_CONFIG_NOT_FOUND;
41 | } else if (code == SELECT_CONFIG_NOT_FOUND.getCode()) {
42 | return SELECT_CONFIG_NOT_FOUND;
43 | } else if (code == MEDIA_NOT_FOUND.getCode()) {
44 | return MEDIA_NOT_FOUND;
45 | }
46 | return OTHER;
47 | }
48 |
49 | public int getCode() {
50 | return mCode;
51 | }
52 |
53 | public String getMessage() {
54 | return mMessage;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/java/com/ypx/imagepicker/bean/SelectMode.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.bean;
2 |
3 | /**
4 | * Description: 图片选择模式
5 | *
6 | * Author: peixing.yang
7 | * Date: 2019/2/21
8 | */
9 | public interface SelectMode {
10 | int MODE_SINGLE = 0;
11 | int MODE_MULTI = 1;
12 | int MODE_CROP = 3;
13 | }
14 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/java/com/ypx/imagepicker/bean/UriPathInfo.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.bean;
2 |
3 | import android.net.Uri;
4 | import android.os.Parcel;
5 | import android.os.Parcelable;
6 |
7 | import java.io.Serializable;
8 |
9 | public class UriPathInfo implements Serializable, Parcelable {
10 | public Uri uri;
11 | public String absolutePath;
12 |
13 | public UriPathInfo(Uri uri, String absolutePath) {
14 | this.uri = uri;
15 | this.absolutePath = absolutePath;
16 | }
17 |
18 | protected UriPathInfo(Parcel in) {
19 | uri = in.readParcelable(Uri.class.getClassLoader());
20 | absolutePath = in.readString();
21 | }
22 |
23 | public static final Creator CREATOR = new Creator() {
24 | @Override
25 | public UriPathInfo createFromParcel(Parcel in) {
26 | return new UriPathInfo(in);
27 | }
28 |
29 | @Override
30 | public UriPathInfo[] newArray(int size) {
31 | return new UriPathInfo[size];
32 | }
33 | };
34 |
35 | /**
36 | * Describe the kinds of special objects contained in this Parcelable
37 | * instance's marshaled representation. For example, if the object will
38 | * include a file descriptor in the output of {@link #writeToParcel(Parcel, int)},
39 | * the return value of this method must include the
40 | * {@link #CONTENTS_FILE_DESCRIPTOR} bit.
41 | *
42 | * @return a bitmask indicating the set of special object types marshaled
43 | * by this Parcelable object instance.
44 | */
45 | @Override
46 | public int describeContents() {
47 | return 0;
48 | }
49 |
50 | /**
51 | * Flatten this object in to a Parcel.
52 | *
53 | * @param dest The Parcel in which the object should be written.
54 | * @param flags Additional flags about how the object should be written.
55 | * May be 0 or {@link #PARCELABLE_WRITE_RETURN_VALUE}.
56 | */
57 | @Override
58 | public void writeToParcel(Parcel dest, int flags) {
59 | dest.writeParcelable(uri, flags);
60 | dest.writeString(absolutePath);
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/java/com/ypx/imagepicker/bean/selectconfig/CropSelectConfig.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.bean.selectconfig;
2 |
3 | import com.ypx.imagepicker.bean.ImageItem;
4 |
5 |
6 | /**
7 | * Time: 2019/9/3 13:46
8 | * Author:ypx
9 | * Description:小红书剪裁配置类
10 | */
11 | public class CropSelectConfig extends BaseSelectConfig {
12 | private ImageItem firstImageItem;
13 | private boolean assignGapState = false;
14 |
15 | public CropSelectConfig() {
16 | setSinglePickImageOrVideoType(true);
17 | }
18 |
19 | public ImageItem getFirstImageItem() {
20 | return firstImageItem;
21 | }
22 |
23 |
24 | public void setFirstImageItem(ImageItem firstImageItem) {
25 | this.firstImageItem = firstImageItem;
26 | }
27 |
28 | public boolean hasFirstImageItem() {
29 | return firstImageItem != null && firstImageItem.width > 0 && firstImageItem.height > 0;
30 | }
31 |
32 | public boolean isAssignGapState() {
33 | return assignGapState;
34 | }
35 |
36 | public void setAssignGapState(boolean assignGapState) {
37 | this.assignGapState = assignGapState;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/java/com/ypx/imagepicker/data/ICameraExecutor.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.data;
2 |
3 | import android.support.annotation.Nullable;
4 |
5 | import com.ypx.imagepicker.bean.ImageItem;
6 |
7 | public interface ICameraExecutor {
8 |
9 | void takePhoto();
10 |
11 | void takeVideo();
12 |
13 | void onTakePhotoResult(@Nullable ImageItem imageItem);
14 | }
15 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/java/com/ypx/imagepicker/data/IReloadExecutor.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.data;
2 |
3 | import com.ypx.imagepicker.bean.ImageItem;
4 |
5 | import java.util.List;
6 |
7 | public interface IReloadExecutor {
8 |
9 | /**
10 | * 根据当前选择列表,重新刷新选择器选择状态
11 | *
12 | * @param selectedList 当前选中列表
13 | */
14 | void reloadPickerWithList(List selectedList);
15 | }
16 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/java/com/ypx/imagepicker/data/MediaStoreConstants.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.data;
2 |
3 | import android.net.Uri;
4 | import android.provider.MediaStore;
5 |
6 | /**
7 | * Time: 2019/10/29 20:38
8 | * Author:ypx
9 | * Description:
10 | */
11 | class MediaStoreConstants {
12 | static final String MIME_TYPE = MediaStore.MediaColumns.MIME_TYPE;
13 | static final String MEDIA_TYPE = MediaStore.Files.FileColumns.MEDIA_TYPE;
14 | static final String DISPLAY_NAME = MediaStore.Files.FileColumns.DISPLAY_NAME;
15 | static final int MEDIA_TYPE_VIDEO = MediaStore.Files.FileColumns.MEDIA_TYPE_VIDEO;
16 | static final int MEDIA_TYPE_IMAGE = MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE;
17 | static final String WIDTH = MediaStore.Files.FileColumns.WIDTH;
18 | static final String HEIGHT = MediaStore.Files.FileColumns.HEIGHT;
19 | static final String DATE_MODIFIED = MediaStore.Files.FileColumns.DATE_MODIFIED;
20 | static final String DURATION = MediaStore.MediaColumns.DURATION;
21 | static final String SIZE = MediaStore.MediaColumns.SIZE;
22 | static final String _ID = MediaStore.Files.FileColumns._ID;
23 | static final String COLUMN_BUCKET_ID = "bucket_id";
24 | static final String COLUMN_BUCKET_DISPLAY_NAME = "bucket_display_name";
25 | static final String COLUMN_URI = "uri";
26 | static final String COLUMN_COUNT = "count";
27 | static final String BUCKET_ORDER_BY = MediaStore.MediaColumns.DATE_MODIFIED + " DESC";
28 | /**
29 | * @deprecated android 10 已废弃此常亮
30 | */
31 | static final String DATA = MediaStore.MediaColumns.DATA;
32 | static final Uri QUERY_URI = MediaStore.Files.getContentUri("external");
33 |
34 | /**
35 | * @return 是否是Android10之前版本
36 | */
37 | static boolean isBeforeAndroidQ() {
38 | return android.os.Build.VERSION.SDK_INT < 29;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/java/com/ypx/imagepicker/data/OnImagePickCompleteListener.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.data;
2 |
3 |
4 | import com.ypx.imagepicker.bean.ImageItem;
5 |
6 | import java.io.Serializable;
7 | import java.util.ArrayList;
8 | import java.util.List;
9 |
10 | /**
11 | * Description: 图片选择器回调
12 | *
13 | * Author: peixing.yang
14 | * Date: 2019/2/21
15 | */
16 | public interface OnImagePickCompleteListener extends Serializable {
17 | void onImagePickComplete(ArrayList items);
18 | }
19 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/java/com/ypx/imagepicker/data/OnImagePickCompleteListener2.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.data;
2 |
3 |
4 | import com.ypx.imagepicker.bean.ImageItem;
5 | import com.ypx.imagepicker.bean.PickerError;
6 |
7 | import java.io.Serializable;
8 | import java.util.ArrayList;
9 |
10 | /**
11 | * Description: 图片选择器回调
12 | *
13 | * Author: peixing.yang
14 | * Date: 2019/2/21
15 | */
16 | public interface OnImagePickCompleteListener2 extends OnImagePickCompleteListener {
17 | void onPickFailed(PickerError error);
18 | }
19 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/java/com/ypx/imagepicker/data/OnPickerCompleteListener.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.data;
2 |
3 | import com.ypx.imagepicker.bean.ImageItem;
4 | import com.ypx.imagepicker.bean.PickerError;
5 |
6 | import java.util.ArrayList;
7 |
8 | /**
9 | * Time: 2019/10/27 22:02
10 | * Author:ypx
11 | * Description: 类型回调类,调用者可自己定制回调的返回类型
12 | */
13 | public abstract class OnPickerCompleteListener implements OnImagePickCompleteListener2 {
14 |
15 | /**
16 | * 默认回调出来的是 ArrayList 类型,调用者自己实现类型间转化
17 | *
18 | * @param items 选择器回调
19 | * @return 用户自己类型
20 | */
21 | public abstract T onTransit(ArrayList items);
22 |
23 | /**
24 | * 选择器完成回调
25 | *
26 | * @param t 回调类型
27 | */
28 | public abstract void onPickComplete(T t);
29 |
30 | @Override
31 | public void onPickFailed(PickerError error) {
32 |
33 | }
34 |
35 | @Override
36 | public void onImagePickComplete(ArrayList items) {
37 | onPickComplete(onTransit(items));
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/java/com/ypx/imagepicker/data/OnStringCompleteListener.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.data;
2 |
3 | import com.ypx.imagepicker.bean.ImageItem;
4 | import com.ypx.imagepicker.bean.PickerError;
5 |
6 | import java.util.ArrayList;
7 |
8 | /**
9 | * Time: 2019/10/27 21:26
10 | * Author:ypx
11 | * Description: OnPickerCompleteListener 子类,实现了String 类型回调
12 | */
13 | public abstract class OnStringCompleteListener extends OnPickerCompleteListener {
14 |
15 | public abstract void onPickComplete(String path);
16 |
17 | @Override
18 | public String onTransit(ArrayList items) {
19 | if (items.size() > 0 && items.get(0) != null) {
20 | return items.get(0).path;
21 | }
22 | return null;
23 | }
24 |
25 | @Override
26 | public void onPickFailed(PickerError error) {
27 |
28 | }
29 |
30 | @Override
31 | public void onImagePickComplete(ArrayList items) {
32 | onPickComplete(onTransit(items));
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/java/com/ypx/imagepicker/data/OnStringListCompleteListener.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.data;
2 |
3 | import com.ypx.imagepicker.bean.ImageItem;
4 | import com.ypx.imagepicker.bean.PickerError;
5 |
6 | import java.util.ArrayList;
7 |
8 | /**
9 | * Time: 2019/10/27 21:26
10 | * Author:ypx
11 | * Description:OnPickerCompleteListener子类,实现了ArrayList 回调
12 | */
13 | public abstract class OnStringListCompleteListener extends OnPickerCompleteListener> {
14 |
15 | public abstract void onPickComplete(ArrayList list);
16 |
17 | @Override
18 | public void onPickFailed(PickerError error) {
19 |
20 | }
21 |
22 | @Override
23 | public void onImagePickComplete(ArrayList items) {
24 | onPickComplete(onTransit(items));
25 | }
26 |
27 | @Override
28 | public ArrayList onTransit(ArrayList items) {
29 | ArrayList list = new ArrayList<>();
30 | for (ImageItem item : items) {
31 | list.add(item.path);
32 | }
33 | return list;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/java/com/ypx/imagepicker/data/PickerActivityCallBack.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.data;
2 |
3 | import android.content.Intent;
4 |
5 | import com.ypx.imagepicker.ImagePicker;
6 | import com.ypx.imagepicker.bean.PickerError;
7 | import com.ypx.imagepicker.helper.launcher.PLauncher;
8 |
9 | import java.util.ArrayList;
10 |
11 | /**
12 | * Time: 2019/11/6 17:35
13 | * Author:ypx
14 | * Description:选择器activityResult处理类
15 | */
16 | public class PickerActivityCallBack implements PLauncher.Callback {
17 | private OnImagePickCompleteListener listener;
18 |
19 | public static PickerActivityCallBack create(OnImagePickCompleteListener listener) {
20 | return new PickerActivityCallBack(listener);
21 | }
22 |
23 | private PickerActivityCallBack(OnImagePickCompleteListener listener) {
24 | this.listener = listener;
25 | }
26 |
27 | @Override
28 | public void onActivityResult(int resultCode, Intent data) {
29 | if (listener != null
30 | && resultCode == ImagePicker.REQ_PICKER_RESULT_CODE
31 | && data.hasExtra(ImagePicker.INTENT_KEY_PICKER_RESULT)) {
32 | ArrayList list = (ArrayList) data.getSerializableExtra(ImagePicker.INTENT_KEY_PICKER_RESULT);
33 | listener.onImagePickComplete(list);
34 | } else if (listener instanceof OnImagePickCompleteListener2) {
35 | if (resultCode == 0) {
36 | resultCode = PickerError.CANCEL.getCode();
37 | }
38 | ((OnImagePickCompleteListener2) listener).onPickFailed(PickerError.valueOf(resultCode));
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/java/com/ypx/imagepicker/data/ProgressSceneEnum.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.data;
2 |
3 | public enum ProgressSceneEnum {
4 | loadMediaItem,
5 | crop
6 | }
7 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/java/com/ypx/imagepicker/helper/DetailImageLoadHelper.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.helper;
2 |
3 | import android.widget.ImageView;
4 |
5 | import com.ypx.imagepicker.ImagePicker;
6 | import com.ypx.imagepicker.bean.ImageItem;
7 | import com.ypx.imagepicker.presenter.IPickerPresenter;
8 |
9 | public class DetailImageLoadHelper {
10 |
11 | public static void displayDetailImage(boolean isCrop, final ImageView imageView,
12 | final IPickerPresenter presenter, final ImageItem imageItem) {
13 | if (presenter != null) {
14 | //剪裁不压缩,大图预览尺寸超过2K的图片需要压缩,不能使用ARGB-8888加载,滑动会卡顿,并且浪费内存,
15 | // 其实最好的做法是分段加载,但是cropImageView在支持剪裁的基础上不能支持分段加载
16 | if (isCrop || ImagePicker.isPreviewWithHighQuality()) {
17 | presenter.displayImage(imageView, imageItem, imageView.getWidth(), false);
18 | } else {
19 | presenter.displayImage(imageView, imageItem, imageView.getWidth(), imageItem.isOver2KImage());
20 | }
21 |
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/java/com/ypx/imagepicker/helper/ILifeCycleCallBack.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.helper;
2 |
3 |
4 | import android.arch.lifecycle.Lifecycle;
5 | import android.arch.lifecycle.LifecycleObserver;
6 | import android.arch.lifecycle.OnLifecycleEvent;
7 |
8 | public interface ILifeCycleCallBack extends LifecycleObserver {
9 |
10 | @OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
11 | void onResume();
12 |
13 | @OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
14 | void onPause();
15 |
16 | @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
17 | void onDestroy();
18 | }
19 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/java/com/ypx/imagepicker/helper/PickerErrorExecutor.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.helper;
2 |
3 | import android.app.Activity;
4 |
5 | import com.ypx.imagepicker.bean.PickerError;
6 | import com.ypx.imagepicker.data.OnImagePickCompleteListener;
7 | import com.ypx.imagepicker.data.OnImagePickCompleteListener2;
8 |
9 | /**
10 | * Time: 2019/10/18 9:53
11 | * Author:ypx
12 | * Description: 调用选择器失败回调
13 | */
14 | public class PickerErrorExecutor {
15 |
16 | public static void executeError(Activity activity, int code) {
17 | activity.setResult(code);
18 | activity.finish();
19 | }
20 |
21 | public static void executeError(OnImagePickCompleteListener listener, int code) {
22 | if (listener instanceof OnImagePickCompleteListener2) {
23 | ((OnImagePickCompleteListener2) listener).onPickFailed(PickerError.valueOf(code));
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/java/com/ypx/imagepicker/helper/launcher/PRouter.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.helper.launcher;
2 |
3 | import android.app.Fragment;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.util.SparseArray;
7 |
8 | import java.util.Random;
9 |
10 | /**
11 | * 把OnActivityResult方式转换为Callback方式的空Fragment(标准SDK)
12 | *
13 | * Created by XiaoFeng on 2018/9/5.
14 | */
15 | public class PRouter extends Fragment {
16 |
17 | private SparseArray mCallbacks = new SparseArray<>();
18 | private Random mCodeGenerator = new Random();
19 |
20 | public PRouter() {
21 | // Required empty public constructor
22 | }
23 |
24 | public static PRouter newInstance() {
25 | return new PRouter();
26 | }
27 |
28 | @Override
29 | public void onCreate(Bundle savedInstanceState) {
30 | super.onCreate(savedInstanceState);
31 | setRetainInstance(true);
32 | }
33 |
34 | public void startActivityForResult(Intent intent, PLauncher.Callback callback) {
35 | int requestCode = makeRequestCode();
36 | mCallbacks.put(requestCode, callback);
37 | startActivityForResult(intent, requestCode);
38 | }
39 |
40 | /**
41 | * 随机生成唯一的requestCode,最多尝试10次
42 | *
43 | * @return
44 | */
45 | private int makeRequestCode() {
46 | int requestCode;
47 | int tryCount = 0;
48 | do {
49 | requestCode = mCodeGenerator.nextInt(0x0000FFFF);
50 | tryCount++;
51 | } while (mCallbacks.indexOfKey(requestCode) >= 0 && tryCount < 10);
52 | return requestCode;
53 | }
54 |
55 | @Override
56 | public void onActivityResult(int requestCode, int resultCode, Intent data) {
57 | super.onActivityResult(requestCode, resultCode, data);
58 | PLauncher.Callback callback = mCallbacks.get(requestCode);
59 | mCallbacks.remove(requestCode);
60 | if (callback != null) {
61 | callback.onActivityResult(resultCode, data);
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/java/com/ypx/imagepicker/helper/launcher/PRouterV4.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.helper.launcher;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v4.app.Fragment;
6 | import android.util.SparseArray;
7 |
8 | import java.util.Random;
9 |
10 | /**
11 | * 把OnActivityResult方式转换为Callback方式的空Fragment(V4兼容包)
12 | *
13 | * Created by XiaoFeng on 2018/9/5.
14 | */
15 | public class PRouterV4 extends Fragment {
16 |
17 | private SparseArray mCallbacks = new SparseArray<>();
18 | private Random mCodeGenerator = new Random();
19 |
20 | public PRouterV4() {
21 | // Required empty public constructor
22 | }
23 |
24 | public static PRouterV4 newInstance() {
25 | return new PRouterV4();
26 | }
27 |
28 | @Override
29 | public void onCreate(Bundle savedInstanceState) {
30 | super.onCreate(savedInstanceState);
31 | setRetainInstance(true);
32 | }
33 |
34 | public void startActivityForResult(Intent intent, PLauncher.Callback callback) {
35 | int requestCode = makeRequestCode();
36 | mCallbacks.put(requestCode, callback);
37 | startActivityForResult(intent, requestCode);
38 | }
39 |
40 | /**
41 | * 随机生成唯一的requestCode,最多尝试10次
42 | *
43 | * @return
44 | */
45 | private int makeRequestCode() {
46 | int requestCode;
47 | int tryCount = 0;
48 | do {
49 | requestCode = mCodeGenerator.nextInt(0x0000FFFF);
50 | tryCount++;
51 | } while (mCallbacks.indexOfKey(requestCode) >= 0 && tryCount < 10);
52 | return requestCode;
53 | }
54 |
55 | @Override
56 | public void onActivityResult(int requestCode, int resultCode, Intent data) {
57 | super.onActivityResult(requestCode, resultCode, data);
58 | PLauncher.Callback callback = mCallbacks.get(requestCode);
59 | mCallbacks.remove(requestCode);
60 | if (callback != null) {
61 | callback.onActivityResult(resultCode, data);
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/java/com/ypx/imagepicker/helper/recyclerviewitemhelper/ItemTouchHelperViewHolder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Paul Burke
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.ypx.imagepicker.helper.recyclerviewitemhelper;
18 |
19 |
20 | /**
21 | * Interface to notify an item ViewHolder of relevant callbacks from {@link
22 | * androidx.recyclerview.widget.ItemTouchHelper.Callback}.
23 | *
24 | * @author Paul Burke (ipaulpro)
25 | */
26 | public interface ItemTouchHelperViewHolder {
27 |
28 | /**
29 | * Called when the {@link ItemTouchHelper} first registers an item as being moved or swiped.
30 | * Implementations should update the item view to indicate it's active state.
31 | */
32 | void onItemSelected();
33 |
34 |
35 | /**
36 | * Called when the {@link ItemTouchHelper} has completed the move or swipe, and the active item
37 | * state should be cleared.
38 | */
39 | void onItemClear();
40 | }
41 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/java/com/ypx/imagepicker/utils/PSingleMediaScanner.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.utils;
2 |
3 | import android.content.Context;
4 | import android.media.MediaScannerConnection;
5 | import android.net.Uri;
6 | import android.util.Log;
7 |
8 | /**
9 | * @author yangpeixing
10 | * 媒体扫描刷新类
11 | */
12 | public class PSingleMediaScanner implements MediaScannerConnection.MediaScannerConnectionClient {
13 | private MediaScannerConnection mediaScannerConnection;
14 | private String mPath;
15 | private ScanListener mListener;
16 |
17 | public interface ScanListener {
18 | void onScanFinish();
19 | }
20 |
21 | public PSingleMediaScanner(Context context, String mPath, ScanListener mListener) {
22 | this.mPath = mPath;
23 | this.mListener = mListener;
24 | this.mediaScannerConnection = new MediaScannerConnection(context, this);
25 | this.mediaScannerConnection.connect();
26 | }
27 |
28 | @Override
29 | public void onMediaScannerConnected() {
30 | mediaScannerConnection.scanFile(mPath, null);
31 | }
32 |
33 | @Override
34 | public void onScanCompleted(String mPath, Uri mUri) {
35 | mediaScannerConnection.disconnect();
36 | if (mListener != null) {
37 | mListener.onScanFinish();
38 | }
39 | }
40 |
41 | public static void refresh(Context context, String path, ScanListener scanListener) {
42 | new PSingleMediaScanner(context.getApplicationContext(), path, scanListener);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/java/com/ypx/imagepicker/utils/PickerFileProvider.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.utils;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.net.Uri;
6 |
7 | import android.support.annotation.NonNull;
8 | import android.support.v4.content.FileProvider;
9 |
10 | import java.io.File;
11 |
12 | /**
13 | * Time: 2019/7/24 15:43
14 | * Author:ypx
15 | * Description:
16 | */
17 | public class PickerFileProvider extends FileProvider {
18 |
19 | public static Uri getUriForFile(@NonNull Activity context,
20 | @NonNull File file) {
21 | Uri uri;
22 | if (android.os.Build.VERSION.SDK_INT < 24) {
23 | uri = Uri.fromFile(file);
24 | } else {
25 | uri = getUriForFile(context, context.getApplication().getPackageName()
26 | + ".picker.fileprovider", file);
27 | }
28 |
29 | return uri;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/java/com/ypx/imagepicker/views/base/PickerFolderItemView.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.views.base;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 |
6 | import android.support.annotation.NonNull;
7 |
8 | import com.ypx.imagepicker.bean.ImageSet;
9 | import com.ypx.imagepicker.presenter.IPickerPresenter;
10 |
11 | import org.jetbrains.annotations.Nullable;
12 |
13 | /**
14 | * Time: 2019/11/13 14:39
15 | * Author:ypx
16 | * Description:自定义文件夹item
17 | */
18 | public abstract class PickerFolderItemView extends PBaseLayout {
19 |
20 | /**
21 | * @return 获取每个item的高度,如果自适应返回-1
22 | */
23 | public abstract int getItemHeight();
24 |
25 | /**
26 | * 加载文件夹缩略图
27 | *
28 | * @param imageSet 文件夹
29 | * @param presenter presenter
30 | */
31 | public abstract void displayCoverImage(ImageSet imageSet, IPickerPresenter presenter);
32 |
33 | /**
34 | * 加载item
35 | *
36 | * @param imageSet 当前文件夹信息
37 | */
38 | public abstract void loadItem(ImageSet imageSet);
39 |
40 | public PickerFolderItemView(Context context) {
41 | super(context);
42 | }
43 |
44 | public PickerFolderItemView(Context context, @Nullable AttributeSet attrs) {
45 | super(context, attrs);
46 | }
47 |
48 | public PickerFolderItemView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
49 | super(context, attrs, defStyleAttr);
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/java/com/ypx/imagepicker/views/base/SingleCropControllerView.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.views.base;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.Nullable;
5 | import android.util.AttributeSet;
6 | import android.view.View;
7 |
8 | import android.support.annotation.NonNull;
9 |
10 | import com.ypx.imagepicker.widget.cropimage.CropImageView;
11 |
12 | /**
13 | * Time: 2019/11/13 14:39
14 | * Author:ypx
15 | * Description:自定义剪裁页面
16 | */
17 | public abstract class SingleCropControllerView extends PBaseLayout {
18 |
19 | /**
20 | * 设置状态栏
21 | */
22 | public abstract void setStatusBar();
23 |
24 | /**
25 | * @return 获取可以点击完成的View
26 | */
27 | public abstract View getCompleteView();
28 |
29 | /**
30 | * @param cropImageView 剪裁的ImageView
31 | * @param params params
32 | */
33 | public abstract void setCropViewParams(CropImageView cropImageView, MarginLayoutParams params);
34 |
35 | public SingleCropControllerView(Context context) {
36 | super(context);
37 | }
38 |
39 | public SingleCropControllerView(Context context, @Nullable AttributeSet attrs) {
40 | super(context, attrs);
41 | }
42 |
43 | public SingleCropControllerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
44 | super(context, attrs, defStyleAttr);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/java/com/ypx/imagepicker/views/redbook/RedBookUiProvider.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.views.redbook;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 |
6 | import com.ypx.imagepicker.views.PickerUiProvider;
7 | import com.ypx.imagepicker.views.base.PickerControllerView;
8 | import com.ypx.imagepicker.views.base.PickerFolderItemView;
9 | import com.ypx.imagepicker.views.base.PickerItemView;
10 | import com.ypx.imagepicker.views.wx.WXFolderItemView;
11 |
12 | public class RedBookUiProvider extends PickerUiProvider {
13 | @Override
14 | public PickerControllerView getBottomBar(Context context) {
15 | return null;
16 | }
17 |
18 | @Override
19 | public PickerControllerView getTitleBar(Context context) {
20 | return new RedBookTitleBar(context);
21 | }
22 |
23 | @Override
24 | public PickerItemView getItemView(Context context) {
25 | return new RedBookItemView(context);
26 | }
27 |
28 | @Override
29 | public PickerFolderItemView getFolderItemView(Context context) {
30 | WXFolderItemView itemView = (WXFolderItemView) super.getFolderItemView(context);
31 | itemView.setIndicatorColor(Color.RED);
32 | itemView.setBackgroundColor(Color.BLACK);
33 | itemView.setNameTextColor(Color.WHITE);
34 | itemView.setCountTextColor(Color.parseColor("#50F5f5f5"));
35 | itemView.setDividerColor(Color.parseColor("#50F5f5f5"));
36 | return itemView;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/java/com/ypx/imagepicker/widget/cropimage/RotateGestureDetector.java:
--------------------------------------------------------------------------------
1 | package com.ypx.imagepicker.widget.cropimage;
2 |
3 | import android.view.MotionEvent;
4 |
5 | /**
6 | * Description: 旋转手势
7 | *
8 | * Author: peixing.yang
9 | * Date: 2019/2/21
10 | */
11 | public class RotateGestureDetector {
12 |
13 | private static final int MAX_DEGREES_STEP = 120;
14 |
15 | private OnRotateListener mListener;
16 |
17 | private float mPrevSlope;
18 | private float mCurrSlope;
19 |
20 | private float x1;
21 | private float y1;
22 | private float x2;
23 | private float y2;
24 |
25 | public RotateGestureDetector(OnRotateListener l) {
26 | mListener = l;
27 | }
28 |
29 | public void onTouchEvent(MotionEvent event) {
30 |
31 | final int Action = event.getActionMasked();
32 |
33 | switch (Action) {
34 | case MotionEvent.ACTION_POINTER_DOWN:
35 | case MotionEvent.ACTION_POINTER_UP:
36 | if (event.getPointerCount() == 2) mPrevSlope = caculateSlope(event);
37 | break;
38 | case MotionEvent.ACTION_MOVE:
39 | if (event.getPointerCount() > 1) {
40 | mCurrSlope = caculateSlope(event);
41 |
42 | double currDegrees = Math.toDegrees(Math.atan(mCurrSlope));
43 | double prevDegrees = Math.toDegrees(Math.atan(mPrevSlope));
44 |
45 | double deltaSlope = currDegrees - prevDegrees;
46 |
47 | if (Math.abs(deltaSlope) <= MAX_DEGREES_STEP) {
48 | mListener.onRotate((float) deltaSlope, (x2 + x1) / 2, (y2 + y1) / 2);
49 | }
50 | mPrevSlope = mCurrSlope;
51 | }
52 | break;
53 | default:
54 | break;
55 | }
56 | }
57 |
58 | private float caculateSlope(MotionEvent event) {
59 | x1 = event.getX(0);
60 | y1 = event.getY(0);
61 | x2 = event.getX(1);
62 | y2 = event.getY(1);
63 | return (y2 - y1) / (x2 - x1);
64 | }
65 |
66 | public interface OnRotateListener {
67 | void onRotate(float degrees, float focusX, float focusY);
68 | }
69 | }
70 |
71 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/anim/picker_anim_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
7 |
8 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/anim/picker_anim_up.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
7 |
8 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/anim/picker_fade_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/anim/picker_fade_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
20 |
21 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/anim/picker_hide2bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
26 |
27 |
31 |
32 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/anim/picker_show2bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
13 |
14 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/anim/picker_top_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/anim/picker_top_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/drawable/picker_selector_list_item_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/layout/picker_activity_crop.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
10 |
11 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/layout/picker_activity_crop_cover.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
10 |
11 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/layout/picker_activity_fragment_wrapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
12 |
17 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/layout/picker_activity_preview.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
10 |
11 |
15 |
16 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/layout/picker_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
18 |
19 |
31 |
32 |
36 |
37 |
42 |
43 |
54 |
55 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/layout/picker_item_camera.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
20 |
21 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/layout/picker_item_image_set.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
17 |
18 |
31 |
32 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/layout/picker_item_root.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/layout/picker_wx_crop_titlebar.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
26 |
27 |
28 |
44 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/mipmap-xxhdpi/picker_arrow_down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_support/imagepicker-support/src/main/res/mipmap-xxhdpi/picker_arrow_down.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/mipmap-xxhdpi/picker_ic_camera.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_support/imagepicker-support/src/main/res/mipmap-xxhdpi/picker_ic_camera.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/mipmap-xxhdpi/picker_icon_back_black.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_support/imagepicker-support/src/main/res/mipmap-xxhdpi/picker_icon_back_black.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/mipmap-xxhdpi/picker_icon_close_black.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_support/imagepicker-support/src/main/res/mipmap-xxhdpi/picker_icon_close_black.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/mipmap-xxhdpi/picker_icon_fill.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_support/imagepicker-support/src/main/res/mipmap-xxhdpi/picker_icon_fill.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/mipmap-xxhdpi/picker_icon_fit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_support/imagepicker-support/src/main/res/mipmap-xxhdpi/picker_icon_fit.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/mipmap-xxhdpi/picker_icon_full.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_support/imagepicker-support/src/main/res/mipmap-xxhdpi/picker_icon_full.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/mipmap-xxhdpi/picker_icon_haswhite.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_support/imagepicker-support/src/main/res/mipmap-xxhdpi/picker_icon_haswhite.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/mipmap-xxhdpi/picker_icon_item_photo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_support/imagepicker-support/src/main/res/mipmap-xxhdpi/picker_icon_item_photo.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/mipmap-xxhdpi/picker_icon_unselect.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_support/imagepicker-support/src/main/res/mipmap-xxhdpi/picker_icon_unselect.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/mipmap-xxhdpi/picker_icon_video.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_support/imagepicker-support/src/main/res/mipmap-xxhdpi/picker_icon_video.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/mipmap-xxhdpi/picker_item_video.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_support/imagepicker-support/src/main/res/mipmap-xxhdpi/picker_item_video.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/mipmap-xxhdpi/picker_item_video_mask.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_support/imagepicker-support/src/main/res/mipmap-xxhdpi/picker_item_video_mask.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/mipmap-xxhdpi/picker_text_indicator.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_support/imagepicker-support/src/main/res/mipmap-xxhdpi/picker_text_indicator.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/mipmap-xxhdpi/picker_wechat_select.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_support/imagepicker-support/src/main/res/mipmap-xxhdpi/picker_wechat_select.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/mipmap-xxhdpi/picker_wechat_unselect.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_support/imagepicker-support/src/main/res/mipmap-xxhdpi/picker_wechat_unselect.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/mipmap-xxhdpi/pricker_drop_down_checked.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_support/imagepicker-support/src/main/res/mipmap-xxhdpi/pricker_drop_down_checked.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/mipmap-xxhdpi/video_play_small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/YPX_ImagePicker_support/imagepicker-support/src/main/res/mipmap-xxhdpi/video_play_small.png
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #F5F5F5
4 |
5 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/imagepicker-support/src/main/res/xml/picker_file_paths.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/YPX_ImagePicker_support/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':imagepicker-support'
2 |
3 | //include ':imagepicker-support'
4 | //
5 | //project(':imagepicker-support').projectDir = new File('E:/github_project/YPX_ImagePicker/YPX_ImagePicker_demo/imagepicker-support')
6 |
--------------------------------------------------------------------------------
/picker:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangpeixing/YImagePicker/e092d9d4ae416e2e576dc5b6dc9d562aa74643af/picker
--------------------------------------------------------------------------------