;
89 | }
90 | -keepclassmembers public class * extends android.view.View {
91 | void set*(***);
92 | *** get*();
93 | }
94 |
95 | #8.support-design
96 | -dontwarn android.support.design.**
97 | -keep class android.support.design.** { *; }
98 | -keep interface android.support.design.** { *; }
99 | -keep public class android.support.design.R$* { *; }
100 |
101 | #9.picasso
102 | -dontwarn com.squareup.okhttp.**
103 | -keep class com.squareup.okhttp.**{*;}
104 | # okhttp
105 | -keep class okhttp3.** { *; }
106 | -keep interface okhttp3.** { *; }
107 | -dontwarn okhttp3.**
108 |
109 | # okio
110 | -keep class sun.misc.Unsafe { *; }
111 | -dontwarn java.nio.file.*
112 | -dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
113 | -keep class okio.**{*;}
114 | -dontwarn okio.**
--------------------------------------------------------------------------------
/sample/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
17 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
31 |
32 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/sample/src/main/java/cn/finalteam/rxgalleryfinal/sample/IApplication.java:
--------------------------------------------------------------------------------
1 | package cn.finalteam.rxgalleryfinal.sample;
2 |
3 | import android.app.Application;
4 |
5 | import com.facebook.drawee.backends.pipeline.Fresco;
6 | import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
7 | import com.nostra13.universalimageloader.core.ImageLoader;
8 | import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
9 | import com.nostra13.universalimageloader.core.assist.QueueProcessingType;
10 | import com.squareup.leakcanary.LeakCanary;
11 |
12 | import cn.finalteam.rxgalleryfinal.utils.ModelUtils;
13 |
14 | /**
15 | * Desction:
16 | * Author:pengjianbo Dujinyang
17 | * Date:16/5/16 上午9:17
18 | */
19 | public class IApplication extends Application {
20 |
21 | @Override
22 | public void onCreate() {
23 | super.onCreate();
24 | //打开日志
25 | ModelUtils.setDebugModel(true);
26 | Fresco.initialize(this);
27 | ImageLoaderConfiguration.Builder config = new ImageLoaderConfiguration.Builder(this);
28 | config.threadPriority(Thread.NORM_PRIORITY - 2);
29 | config.denyCacheImageMultipleSizesInMemory();
30 | config.diskCacheFileNameGenerator(new Md5FileNameGenerator());
31 | config.diskCacheSize(50 * 1024 * 1024); // 50 MiB
32 | config.tasksProcessingOrder(QueueProcessingType.LIFO);
33 | ImageLoader.getInstance().init(config.build());
34 |
35 | if (LeakCanary.isInAnalyzerProcess(this)) {
36 | return;
37 | }
38 | LeakCanary.install(this);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/sample/src/main/java/cn/finalteam/rxgalleryfinal/sample/SimpleRxGalleryFinal.java:
--------------------------------------------------------------------------------
1 | package cn.finalteam.rxgalleryfinal.sample;
2 |
3 | import android.app.Activity;
4 | import android.content.ContentValues;
5 | import android.content.Context;
6 | import android.content.Intent;
7 | import android.net.Uri;
8 | import android.os.Build;
9 | import android.os.Environment;
10 | import android.provider.MediaStore;
11 |
12 | import androidx.annotation.NonNull;
13 | import androidx.annotation.Nullable;
14 | import androidx.appcompat.app.AppCompatActivity;
15 |
16 | import com.yalantis.ucrop.UCrop;
17 |
18 | import java.io.File;
19 | import java.io.FileNotFoundException;
20 |
21 | /**
22 | * by y on 17/07/2017.
23 | *
24 | * 使用相机拍照并裁剪
25 | */
26 |
27 | public class SimpleRxGalleryFinal {
28 |
29 | private static final String IMAGE_TYPE = "image/jpeg";
30 | private static final int TYPE_CAMERA = 1111;
31 |
32 | private RxGalleryFinalCropListener listener = null;
33 |
34 | private Uri imagePath;
35 |
36 |
37 | private static final class SimpleRxGalleryFinalHolder {
38 | private static final SimpleRxGalleryFinal SIMPLE_RX_GALLERY_FINAL = new SimpleRxGalleryFinal();
39 | }
40 |
41 | public static SimpleRxGalleryFinal get() {
42 | return SimpleRxGalleryFinalHolder.SIMPLE_RX_GALLERY_FINAL;
43 | }
44 |
45 |
46 | public SimpleRxGalleryFinal init(RxGalleryFinalCropListener listener) {
47 | this.listener = listener;
48 | return this;
49 | }
50 |
51 |
52 | public void openCamera() {
53 | Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
54 | imagePath = Uri.fromFile(getDiskCacheDir());
55 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
56 | intent.putExtra(MediaStore.EXTRA_OUTPUT, imagePath);
57 | } else {
58 | ContentValues contentValues = new ContentValues(1);
59 | contentValues.put(MediaStore.Images.Media.DATA, imagePath.getPath());
60 | contentValues.put(MediaStore.Images.Media.MIME_TYPE, IMAGE_TYPE);
61 | Uri uri = listener.getSimpleActivity().getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues);
62 | intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
63 | }
64 | listener
65 | .getSimpleActivity()
66 | .startActivityForResult(intent, TYPE_CAMERA);
67 | }
68 |
69 | public void onActivityResult(int requestCode, int resultCode, Intent data) {
70 | switch (resultCode) {
71 | case Activity.RESULT_CANCELED:
72 | listener.onCropCancel();
73 | break;
74 | case UCrop.RESULT_ERROR:
75 | if (data != null) {
76 | Throwable cropError = UCrop.getError(data);
77 | if (cropError != null) {
78 | listener.onCropError(cropError.getMessage());
79 | } else {
80 | listener.onCropError("裁剪出现未知错误");
81 | }
82 | } else {
83 | listener.onCropError("获取相册图片出现错误");
84 | }
85 | break;
86 |
87 | case Activity.RESULT_OK:
88 | switch (requestCode) {
89 | case TYPE_CAMERA:
90 | notifyImageToCamera(listener.getSimpleActivity(), imagePath);
91 | UCrop of = UCrop.of(imagePath, Uri.fromFile(getDiskCacheDir()));
92 | of.start(listener.getSimpleActivity());
93 | break;
94 | case UCrop.REQUEST_CROP:
95 | listener.onCropSuccess(UCrop.getOutput(data));
96 | break;
97 | }
98 | break;
99 | }
100 | }
101 |
102 | private File getDiskCacheDir() {
103 | String cachePath;
104 | if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) || !Environment.isExternalStorageRemovable()) {
105 | File externalCacheDir = listener.getSimpleActivity().getExternalCacheDir();
106 | if (externalCacheDir != null) {
107 | cachePath = externalCacheDir.getPath();
108 | } else {
109 | cachePath = listener.getSimpleActivity().getCacheDir().getPath();
110 | }
111 | } else {
112 | cachePath = listener.getSimpleActivity().getCacheDir().getPath();
113 | }
114 | return new File(cachePath, imageName());
115 | }
116 |
117 | private void notifyImageToCamera(Context context, Uri uri) {
118 | try {
119 | File file = new File(uri.getPath());
120 | MediaStore.Images.Media.insertImage(context.getContentResolver(), file.getAbsolutePath(), file.getName(), null);
121 | } catch (FileNotFoundException e) {
122 | e.printStackTrace();
123 | }
124 | context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, uri));
125 | }
126 |
127 | private String imageName() {
128 | return System.currentTimeMillis() + ".jpg";
129 | }
130 |
131 |
132 | public interface RxGalleryFinalCropListener {
133 |
134 | @NonNull
135 | AppCompatActivity getSimpleActivity();
136 |
137 |
138 | /**
139 | * 裁剪被取消
140 | */
141 | void onCropCancel();
142 |
143 | /**
144 | * 裁剪成功
145 | *
146 | * @param uri 裁剪的 Uri , 有可能会为Null
147 | */
148 | void onCropSuccess(@Nullable Uri uri);
149 |
150 |
151 | /**
152 | * 裁剪失败
153 | *
154 | * @param errorMessage 错误信息
155 | */
156 | void onCropError(@NonNull String errorMessage);
157 |
158 | }
159 | }
160 |
--------------------------------------------------------------------------------
/sample/src/main/java/cn/finalteam/rxgalleryfinal/sample/imageloader/ImageLoaderActivity.java:
--------------------------------------------------------------------------------
1 | package cn.finalteam.rxgalleryfinal.sample.imageloader;
2 |
3 | import android.os.Bundle;
4 | import android.view.View;
5 | import android.widget.Toast;
6 |
7 | import androidx.annotation.Nullable;
8 | import androidx.appcompat.app.AppCompatActivity;
9 | import androidx.appcompat.widget.AppCompatCheckBox;
10 |
11 | import cn.finalteam.rxgalleryfinal.RxGalleryFinal;
12 | import cn.finalteam.rxgalleryfinal.imageloader.ImageLoaderType;
13 | import cn.finalteam.rxgalleryfinal.rxbus.RxBusResultDisposable;
14 | import cn.finalteam.rxgalleryfinal.rxbus.event.ImageRadioResultEvent;
15 | import cn.finalteam.rxgalleryfinal.sample.R;
16 | import cn.finalteam.rxgalleryfinal.utils.Logger;
17 |
18 | /**
19 | * by y on 2017/6/7.
20 | */
21 |
22 | public class ImageLoaderActivity extends AppCompatActivity {
23 |
24 | private AppCompatCheckBox appCompatCheckBox;
25 | private RxGalleryFinal with;
26 |
27 | @Override
28 | protected void onCreate(@Nullable Bundle savedInstanceState) {
29 | super.onCreate(savedInstanceState);
30 | setContentView(R.layout.activity_imageloader);
31 | appCompatCheckBox = findViewById(R.id.cb_gif);
32 | findViewById(R.id.btn_glide).setOnClickListener(v -> start(ImageLoaderType.GLIDE));
33 | findViewById(R.id.btn_picasso).setOnClickListener(v -> start(ImageLoaderType.PICASSO));
34 | findViewById(R.id.btn_fresco).setOnClickListener(v -> start(ImageLoaderType.FRESCO));
35 | findViewById(R.id.btn_universal).setOnClickListener(v -> start(ImageLoaderType.UNIVERSAL));
36 | }
37 |
38 | private void start(ImageLoaderType imageLoaderType) {
39 | switch (imageLoaderType) {
40 | case PICASSO:
41 | case UNIVERSAL:
42 | Toast.makeText(getApplicationContext(), imageLoaderType + "不支持Gif", Toast.LENGTH_SHORT).show();
43 | break;
44 | }
45 | if (with == null)
46 | with = RxGalleryFinal.with(this);
47 | with.image()
48 | .radio()
49 | .gif(appCompatCheckBox.isChecked())
50 | .imageLoader(imageLoaderType)
51 | .subscribe(new RxBusResultDisposable() {
52 | @Override
53 | protected void onEvent(ImageRadioResultEvent imageRadioResultEvent) throws Exception {
54 | Toast.makeText(getBaseContext(), "选中了图片路径:" + imageRadioResultEvent.getResult().getOriginalPath(), Toast.LENGTH_SHORT).show();
55 | }
56 | }).openGallery();
57 | }
58 |
59 | @Override
60 | protected void onDestroy() {
61 | if (with != null) {
62 | Logger.i("RxGalleryFinal == null");
63 | with = null;
64 | }
65 | super.onDestroy();
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/activity_imageloader.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
19 |
20 |
25 |
26 |
31 |
32 |
37 |
38 |
43 |
44 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
14 |
19 |
20 |
21 |
26 |
27 |
28 |
33 |
34 |
39 |
40 |
45 |
46 |
51 |
52 |
56 |
57 |
64 |
65 |
71 |
72 |
73 |
79 |
80 |
81 |
82 |
87 |
88 |
89 |
94 |
95 |
99 |
100 |
107 |
108 |
114 |
115 |
116 |
117 |
118 |
123 |
124 |
129 |
130 |
134 |
135 |
142 |
143 |
149 |
150 |
151 |
156 |
157 |
158 |
163 |
164 |
169 |
170 |
171 |
176 |
177 |
178 |
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FinalTeam/RxGalleryFinal/e61b3085605fdf5125ce9ef2d02f13720aa64702/sample/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FinalTeam/RxGalleryFinal/e61b3085605fdf5125ce9ef2d02f13720aa64702/sample/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FinalTeam/RxGalleryFinal/e61b3085605fdf5125ce9ef2d02f13720aa64702/sample/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/a1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FinalTeam/RxGalleryFinal/e61b3085605fdf5125ce9ef2d02f13720aa64702/sample/src/main/res/mipmap-xxhdpi/a1.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FinalTeam/RxGalleryFinal/e61b3085605fdf5125ce9ef2d02f13720aa64702/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FinalTeam/RxGalleryFinal/e61b3085605fdf5125ce9ef2d02f13720aa64702/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | #FFFFFF
6 | #FFFFFF
7 | #000000
8 |
9 | #2196F3
10 | #1976D2
11 | #FF4081
12 |
13 | #FF5722
14 | #E64A19
15 | #FF4081
16 |
17 | #00BCD4
18 | #0097A7
19 | #FF4081
20 |
21 | #4CAF50
22 | #388E3C
23 | #FF4081
24 |
25 | #009688
26 | #00796B
27 | #FF4081
28 |
29 | #da4336
30 | #b93221
31 | #3D5AFE
32 |
33 | #E91E63
34 | #C2185B
35 | #3D5AFE
36 |
37 | #673AB7
38 | #512DA8
39 | #FF4081
40 |
41 | #616161
42 | #424242
43 | #00E676
44 |
45 | #2A2A2F
46 | #151515
47 | #FF4081
48 |
49 | #785447
50 | #5C3F36
51 | #785447
52 |
53 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
7 | 8dp
8 | 8dp
9 |
10 | 80dp
11 |
12 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | RxGalleryFinal
3 |
4 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/screenshots/a1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FinalTeam/RxGalleryFinal/e61b3085605fdf5125ce9ef2d02f13720aa64702/screenshots/a1.png
--------------------------------------------------------------------------------
/screenshots/device-2017-03-24-181216.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FinalTeam/RxGalleryFinal/e61b3085605fdf5125ce9ef2d02f13720aa64702/screenshots/device-2017-03-24-181216.png
--------------------------------------------------------------------------------
/screenshots/device-2017-04-11-154816.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FinalTeam/RxGalleryFinal/e61b3085605fdf5125ce9ef2d02f13720aa64702/screenshots/device-2017-04-11-154816.png
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':library'
2 | include ':sample'
3 |
4 |
--------------------------------------------------------------------------------