├── .gitignore
├── BigImageViewer
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── github
│ │ └── piasy
│ │ └── biv
│ │ ├── BigImageViewer.java
│ │ ├── indicator
│ │ └── ProgressIndicator.java
│ │ ├── loader
│ │ └── ImageLoader.java
│ │ ├── metadata
│ │ └── ImageInfoExtractor.java
│ │ ├── utils
│ │ ├── DisplayOptimizeListener.java
│ │ ├── IOUtils.java
│ │ └── ThreadedCallbacks.java
│ │ └── view
│ │ ├── BigImageView.java
│ │ ├── ImageSaveCallback.java
│ │ ├── ImageShownCallback.java
│ │ └── ImageViewFactory.java
│ └── res
│ └── values
│ └── attrs.xml
├── CHANGELOG.md
├── FrescoImageLoader
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── com
│ └── github
│ └── piasy
│ └── biv
│ └── loader
│ └── fresco
│ ├── FrescoImageLoader.java
│ └── ImageDownloadSubscriber.java
├── FrescoImageViewFactory
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── com
│ └── github
│ └── piasy
│ └── biv
│ └── view
│ └── FrescoImageViewFactory.java
├── GlideImageLoader
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── com
│ └── github
│ └── piasy
│ └── biv
│ └── loader
│ └── glide
│ ├── GlideCustomImageLoader.java
│ ├── GlideImageLoader.java
│ ├── GlideLoaderException.java
│ ├── GlideModel.java
│ ├── GlideProgressSupport.java
│ ├── ImageDownloadTarget.java
│ └── PrefetchTarget.java
├── GlideImageViewFactory
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── com
│ └── github
│ └── piasy
│ └── biv
│ └── view
│ └── GlideImageViewFactory.java
├── LICENSE
├── ProgressPieIndicator
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── github
│ │ └── piasy
│ │ └── biv
│ │ └── indicator
│ │ └── progresspie
│ │ └── ProgressPieIndicator.java
│ └── res
│ └── layout
│ └── ui_progress_pie_indicator.xml
├── README.md
├── app
├── .gitignore
├── OpenKey.jks
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── github
│ │ └── piasy
│ │ └── biv
│ │ └── example
│ │ ├── BivDemoGlideModule.java
│ │ ├── CustomSSIVActivity.java
│ │ ├── FirstAnimFrescoActivity.kt
│ │ ├── FirstAnimGlideActivity.kt
│ │ ├── FrescoLoaderActivity.java
│ │ ├── GlideLoaderActivity.java
│ │ ├── ImageLoaderCallbackActivity.java
│ │ ├── ImageTypesActivity.java
│ │ ├── LongImageActivity.java
│ │ ├── MainActivity.java
│ │ ├── MySSIV.java
│ │ ├── RecyclerAdapter.java
│ │ ├── RecyclerViewActivity.java
│ │ ├── ScaleTypeActivity.java
│ │ ├── SecondAnimActivity.kt
│ │ ├── Utils.java
│ │ └── glide
│ │ ├── CustomImageSizeModel.java
│ │ ├── CustomImageSizeUrlLoader.java
│ │ ├── CustomImageSizeUrlLoaderFactory.java
│ │ └── SampleCustomImageSizeModel.java
│ └── res
│ ├── drawable-hdpi
│ └── ic_cloud_off_white.png
│ ├── drawable-ldpi
│ └── ic_cloud_off_white.png
│ ├── drawable-mdpi
│ └── ic_cloud_off_white.png
│ ├── drawable-xhdpi
│ └── ic_cloud_off_white.png
│ ├── drawable-xxhdpi
│ └── ic_cloud_off_white.png
│ ├── drawable-xxxhdpi
│ └── ic_cloud_off_white.png
│ ├── layout
│ ├── activity_anim_first_fresco.xml
│ ├── activity_anim_first_glide.xml
│ ├── activity_anim_second.xml
│ ├── activity_big_image.xml
│ ├── activity_custom_ssiv.xml
│ ├── activity_image_type.xml
│ ├── activity_main.xml
│ ├── activity_recycler_view.xml
│ ├── activity_scale_type.xml
│ ├── dialog_long_image.xml
│ └── item_recycler_view.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxxhdpi
│ └── ic_launcher.png
│ └── values
│ ├── colors.xml
│ ├── strings.xml
│ └── styles.xml
├── art
├── Logotype_primary.png
├── android_studio_memory_monitor.png
├── biv_gif_support.gif
└── fresco_big_image_viewer_demo.gif
├── buckw
├── build.gradle
├── gradle.properties
├── gradle
├── bintray.gradle
├── publish-maven-central.gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | **.iml
2 | .idea
3 | .gradle
4 | /local.properties
5 | bintray.properties
6 | .DS_Store
7 | **/build
8 | /captures
9 |
10 | .buckd
11 | .okbuck
12 | buck-out
13 | .buckconfig
14 | .buckconfig.local
15 | **/BUCK
16 |
--------------------------------------------------------------------------------
/BigImageViewer/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/BigImageViewer/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2018 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | apply plugin: 'com.android.library'
26 | apply plugin: 'com.github.ben-manes.versions'
27 | apply from: "$rootProject.rootDir/gradle/publish-maven-central.gradle"
28 |
29 | android {
30 | compileSdkVersion rootProject.ext.androidCompileSdkVersion
31 |
32 | defaultConfig {
33 | minSdkVersion rootProject.ext.minSdkVersion
34 | targetSdkVersion rootProject.ext.targetSdkVersion
35 | versionCode rootProject.ext.releaseVersionCode
36 | versionName rootProject.ext.releaseVersionName
37 | }
38 | buildTypes {
39 | release {
40 | minifyEnabled false
41 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
42 | }
43 | }
44 | }
45 |
46 | dependencies {
47 | api "com.davemorrissey.labs:subsampling-scale-image-view-androidx:$rootProject.ext.ssivVersion"
48 | }
49 |
--------------------------------------------------------------------------------
/BigImageViewer/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/piasy/tools/android-sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/BigImageViewer/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
24 |
25 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/BigImageViewer/src/main/java/com/github/piasy/biv/BigImageViewer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2018 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.biv;
26 |
27 | import android.net.Uri;
28 | import com.github.piasy.biv.loader.ImageLoader;
29 |
30 | /**
31 | * Created by Piasy{github.com/Piasy} on 06/11/2016.
32 | *
33 | * This is not a singleton, you can initialize it multiple times, but before you initialize it
34 | * again, it will use the same {@link ImageLoader} globally.
35 | */
36 |
37 | public final class BigImageViewer {
38 | private static volatile BigImageViewer sInstance;
39 |
40 | private final ImageLoader mImageLoader;
41 |
42 | private BigImageViewer(ImageLoader imageLoader) {
43 | mImageLoader = imageLoader;
44 | }
45 |
46 | public static void initialize(ImageLoader imageLoader) {
47 | sInstance = new BigImageViewer(imageLoader);
48 | }
49 |
50 | public static ImageLoader imageLoader() {
51 | if (sInstance == null) {
52 | throw new IllegalStateException("You must initialize BigImageViewer before use it!");
53 | }
54 | return sInstance.mImageLoader;
55 | }
56 |
57 | public static void prefetch(Uri... uris) {
58 | if (uris == null) {
59 | return;
60 | }
61 |
62 | ImageLoader imageLoader = imageLoader();
63 | for (Uri uri : uris) {
64 | imageLoader.prefetch(uri);
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/BigImageViewer/src/main/java/com/github/piasy/biv/indicator/ProgressIndicator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2018 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.biv.indicator;
26 |
27 | import android.view.View;
28 | import com.github.piasy.biv.view.BigImageView;
29 |
30 | /**
31 | * Created by Piasy{github.com/Piasy} on 12/11/2016.
32 | */
33 |
34 | public interface ProgressIndicator {
35 | /**
36 | * DO NOT add indicator view into parent! Only called once per load.
37 | * */
38 | View getView(BigImageView parent);
39 |
40 | void onStart();
41 |
42 | /**
43 | * @param progress in range of {@code [0, 100]}
44 | */
45 | void onProgress(int progress);
46 |
47 | void onFinish();
48 | }
49 |
--------------------------------------------------------------------------------
/BigImageViewer/src/main/java/com/github/piasy/biv/loader/ImageLoader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2018 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.biv.loader;
26 |
27 | import android.net.Uri;
28 | import androidx.annotation.UiThread;
29 | import java.io.File;
30 |
31 | /**
32 | * Created by Piasy{github.com/Piasy} on 08/11/2016.
33 | */
34 |
35 | public interface ImageLoader {
36 |
37 | void loadImage(int requestId, Uri uri, Callback callback);
38 |
39 | void prefetch(Uri uri);
40 |
41 | void cancel(int requestId);
42 |
43 | void cancelAll();
44 |
45 | @UiThread
46 | interface Callback {
47 | void onCacheHit(int imageType, File image);
48 |
49 | void onCacheMiss(int imageType, File image);
50 |
51 | void onStart();
52 |
53 | void onProgress(int progress);
54 |
55 | void onFinish();
56 |
57 | void onSuccess(File image);
58 |
59 | void onFail(Exception error);
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/BigImageViewer/src/main/java/com/github/piasy/biv/metadata/ImageInfoExtractor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2018 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.biv.metadata;
26 |
27 | import java.io.File;
28 | import java.io.FileInputStream;
29 | import java.io.IOException;
30 |
31 | /**
32 | * Created by Piasy{github.com/Piasy} on 2018/8/12.
33 | */
34 | public final class ImageInfoExtractor {
35 | public static final int TYPE_STILL_IMAGE = 0;
36 | public static final int TYPE_GIF = 1;
37 | public static final int TYPE_ANIMATED_WEBP = 2;
38 | public static final int TYPE_STILL_WEBP = 3;
39 |
40 | private static final int ANIMATED_WEBP_MASK = 0x02;
41 |
42 | private ImageInfoExtractor() {
43 | // no instance
44 | }
45 |
46 | /**
47 | * For GIF, we only need 3 bytes, 'GIF',
48 | *
49 | * For WebP format, we need 21 bytes, `RIFF` + size + `WEBP` + ChuckHeader(`VP8X`),
50 | * to determine still/animated WebP, we need 9 extra bytes, 8 bytes chunk header to check
51 | * for extended WebP format, 1 byte to check for animated bit.
52 | *
53 | * reference: https://developers.google.com/speed/webp/docs/riff_container
54 | */
55 | public static int getImageType(File file) {
56 | int type = TYPE_STILL_IMAGE;
57 | try {
58 | FileInputStream inputStream = new FileInputStream(file);
59 |
60 | byte[] header = new byte[21];
61 | int read = inputStream.read(header);
62 | if (read >= 3 && isGifHeader(header)) {
63 | type = TYPE_GIF;
64 | } else if (read >= 12 && isWebpHeader(header)) {
65 | if (read >= 17 && isExtendedWebp(header)
66 | && (header[20] & ANIMATED_WEBP_MASK) != 0) {
67 | type = TYPE_ANIMATED_WEBP;
68 | } else {
69 | type = TYPE_STILL_WEBP;
70 | }
71 | }
72 |
73 | inputStream.close();
74 | } catch (IOException e) {
75 | e.printStackTrace();
76 | }
77 |
78 | return type;
79 | }
80 |
81 | public static String typeName(int type) {
82 | switch (type) {
83 | case TYPE_GIF:
84 | return "GIF";
85 | case TYPE_STILL_WEBP:
86 | return "STILL_WEBP";
87 | case TYPE_ANIMATED_WEBP:
88 | return "ANIMATED_WEBP";
89 | case TYPE_STILL_IMAGE:
90 | default:
91 | return "STILL_IMAGE";
92 | }
93 | }
94 |
95 | private static boolean isGifHeader(byte[] header) {
96 | return header[0] == 'G' && header[1] == 'I' && header[2] == 'F';
97 | }
98 |
99 | private static boolean isWebpHeader(byte[] header) {
100 | return header[0] == 'R' && header[1] == 'I' && header[2] == 'F' && header[3] == 'F'
101 | && header[8] == 'W' && header[9] == 'E' && header[10] == 'B' && header[11] == 'P';
102 | }
103 |
104 | private static boolean isExtendedWebp(byte[] header) {
105 | return header[12] == 'V' && header[13] == 'P' && header[14] == '8' && header[15] == 'X';
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/BigImageViewer/src/main/java/com/github/piasy/biv/utils/DisplayOptimizeListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2018 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.biv.utils;
26 |
27 | import android.graphics.PointF;
28 | import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView;
29 | import com.github.piasy.biv.view.BigImageView;
30 |
31 | /**
32 | * credit: https://github.com/Piasy/BigImageViewer/issues/2
33 | */
34 |
35 | public class DisplayOptimizeListener implements SubsamplingScaleImageView.OnImageEventListener {
36 | private static final int LONG_IMAGE_SIZE_RATIO = 2;
37 |
38 | private final SubsamplingScaleImageView mImageView;
39 |
40 | private int mInitScaleType;
41 |
42 | public DisplayOptimizeListener(SubsamplingScaleImageView imageView) {
43 | mImageView = imageView;
44 | }
45 |
46 | @Override
47 | public void onReady() {
48 | float result = 0.5f;
49 | int imageWidth = mImageView.getSWidth();
50 | int imageHeight = mImageView.getSHeight();
51 | int viewWidth = mImageView.getWidth();
52 | int viewHeight = mImageView.getHeight();
53 |
54 | boolean hasZeroValue = false;
55 | if (imageWidth == 0 || imageHeight == 0 || viewWidth == 0 || viewHeight == 0) {
56 | result = 0.5f;
57 | hasZeroValue = true;
58 | }
59 |
60 | if (!hasZeroValue) {
61 | if (imageWidth <= imageHeight) {
62 | result = (float) viewWidth / imageWidth;
63 | } else {
64 | result = (float) viewHeight / imageHeight;
65 | }
66 | }
67 |
68 | if (!hasZeroValue && (float) imageHeight / imageWidth > LONG_IMAGE_SIZE_RATIO) {
69 | // scale at top
70 | mImageView
71 | .animateScaleAndCenter(result, new PointF(imageWidth / 2, 0))
72 | .withEasing(SubsamplingScaleImageView.EASE_OUT_QUAD)
73 | .start();
74 | }
75 |
76 | // `对结果进行放大裁定,防止计算结果跟双击放大结果过于相近`
77 | if (Math.abs(result - 0.1) < 0.2f) {
78 | result += 0.2f;
79 | }
80 |
81 | if (mInitScaleType == BigImageView.INIT_SCALE_TYPE_CUSTOM) {
82 | float maxScale = Math.max((float) viewWidth / imageWidth,
83 | (float) viewHeight / imageHeight);
84 | if (maxScale > 1) {
85 | // image is smaller than screen, it should be zoomed out to its origin size
86 | mImageView.setMinScale(1);
87 |
88 | // and it should be zoomed in to fill the screen
89 | float defaultMaxScale = mImageView.getMaxScale();
90 | mImageView.setMaxScale(Math.max(defaultMaxScale, maxScale * 1.2F));
91 | } else {
92 | // image is bigger than screen, it should be zoomed out to fit the screen
93 | float minScale = Math.min((float) viewWidth / imageWidth,
94 | (float) viewHeight / imageHeight);
95 | mImageView.setMinScale(minScale);
96 | // but no need to set max scale
97 | }
98 | // scale to fit screen, and center
99 | mImageView.setScaleAndCenter(maxScale, new PointF(imageWidth / 2, imageHeight / 2));
100 | }
101 |
102 | mImageView.setDoubleTapZoomScale(result);
103 | }
104 |
105 | @Override
106 | public void onImageLoaded() {
107 |
108 | }
109 |
110 | @Override
111 | public void onPreviewLoadError(Exception e) {
112 |
113 | }
114 |
115 | @Override
116 | public void onImageLoadError(Exception e) {
117 |
118 | }
119 |
120 | @Override
121 | public void onTileLoadError(Exception e) {
122 |
123 | }
124 |
125 | @Override
126 | public void onPreviewReleased() {
127 |
128 | }
129 |
130 | public void setInitScaleType(int initScaleType) {
131 | mInitScaleType = initScaleType;
132 | }
133 | }
134 |
--------------------------------------------------------------------------------
/BigImageViewer/src/main/java/com/github/piasy/biv/utils/ThreadedCallbacks.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2018 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.biv.utils;
26 |
27 | import android.os.Handler;
28 | import android.os.Looper;
29 | import androidx.annotation.Keep;
30 | import java.lang.reflect.InvocationHandler;
31 | import java.lang.reflect.Method;
32 | import java.lang.reflect.Proxy;
33 |
34 | /**
35 | * Created by Piasy{github.com/Piasy} on 08/04/2017.
36 | */
37 | @Keep
38 | public final class ThreadedCallbacks implements InvocationHandler {
39 |
40 | private static final Object NON_SENSE = new Object();
41 | private static final Handler MAIN_HANDLER = new Handler(Looper.getMainLooper());
42 |
43 | private final Object mTarget;
44 | private final Handler mHandler;
45 |
46 | private ThreadedCallbacks(final Handler handler, final Object target) {
47 | mHandler = handler;
48 | mTarget = target;
49 | }
50 |
51 | public static T create(final Class type, final T target) {
52 | return create(MAIN_HANDLER, type, target);
53 | }
54 |
55 | @SuppressWarnings("unchecked")
56 | public static T create(final Handler handler, final Class type, final T target) {
57 | return (T) Proxy.newProxyInstance(type.getClassLoader(),
58 | new Class[] { type }, new ThreadedCallbacks(handler, target));
59 | }
60 |
61 | @Override
62 | public Object invoke(final Object proxy, final Method method, final Object[] args)
63 | throws Throwable {
64 | if (!method.getReturnType().equals(Void.TYPE)) {
65 | throw new RuntimeException("Method should return void: " + method);
66 | }
67 | if (Looper.myLooper() == mHandler.getLooper()) {
68 | method.invoke(mTarget, args);
69 | } else {
70 | mHandler.post(new Runnable() {
71 | @Override
72 | public void run() {
73 | try {
74 | method.invoke(mTarget, args);
75 | } catch (Exception e) {
76 | e.printStackTrace();
77 | }
78 | }
79 | });
80 | }
81 | return NON_SENSE;
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/BigImageViewer/src/main/java/com/github/piasy/biv/view/ImageSaveCallback.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2018 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.biv.view;
26 |
27 | /**
28 | * Created by Piasy{github.com/Piasy} on 10/11/2016.
29 | */
30 |
31 | public interface ImageSaveCallback {
32 | void onSuccess(String uri);
33 |
34 | void onFail(Throwable t);
35 | }
36 |
--------------------------------------------------------------------------------
/BigImageViewer/src/main/java/com/github/piasy/biv/view/ImageShownCallback.java:
--------------------------------------------------------------------------------
1 | package com.github.piasy.biv.view;
2 |
3 | import androidx.annotation.UiThread;
4 |
5 | @UiThread
6 | public interface ImageShownCallback {
7 |
8 | void onThumbnailShown();
9 | void onMainImageShown();
10 | }
11 |
--------------------------------------------------------------------------------
/BigImageViewer/src/main/java/com/github/piasy/biv/view/ImageViewFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2018 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.biv.view;
26 |
27 | import android.content.Context;
28 | import android.net.Uri;
29 | import android.view.View;
30 | import android.widget.ImageView;
31 | import com.davemorrissey.labs.subscaleview.ImageSource;
32 | import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView;
33 | import com.github.piasy.biv.metadata.ImageInfoExtractor;
34 | import java.io.File;
35 |
36 | /**
37 | * Created by Piasy{github.com/Piasy} on 2018/8/12.
38 | */
39 | public class ImageViewFactory {
40 |
41 | public final View createMainView(final Context context, final int imageType,
42 | final int initScaleType) {
43 | switch (imageType) {
44 | case ImageInfoExtractor.TYPE_GIF:
45 | case ImageInfoExtractor.TYPE_ANIMATED_WEBP:
46 | return createAnimatedImageView(context, imageType, initScaleType);
47 | case ImageInfoExtractor.TYPE_STILL_WEBP:
48 | case ImageInfoExtractor.TYPE_STILL_IMAGE:
49 | default:
50 | return createStillImageView(context);
51 | }
52 | }
53 |
54 | public boolean isAnimatedContent(final int imageType) {
55 | switch (imageType) {
56 | case ImageInfoExtractor.TYPE_GIF:
57 | case ImageInfoExtractor.TYPE_ANIMATED_WEBP:
58 | return true;
59 | default:
60 | return false;
61 | }
62 | }
63 |
64 | protected SubsamplingScaleImageView createStillImageView(final Context context) {
65 | return new SubsamplingScaleImageView(context);
66 | }
67 |
68 | public void loadSillContent(final View view, final Uri uri) {
69 | if (view instanceof SubsamplingScaleImageView) {
70 | ((SubsamplingScaleImageView) view).setImage(ImageSource.uri(uri));
71 | }
72 | }
73 |
74 | protected View createAnimatedImageView(final Context context, final int imageType,
75 | final int initScaleType) {
76 | return null;
77 | }
78 |
79 | public void loadAnimatedContent(final View view, final int imageType, final File imageFile) {
80 | }
81 |
82 | public View createThumbnailView(final Context context, final ImageView.ScaleType scaleType,
83 | final boolean willLoadFromNetwork) {
84 | final ImageView thumbnailView = new ImageView(context);
85 | if (scaleType != null) {
86 | thumbnailView.setScaleType(scaleType);
87 | }
88 | return thumbnailView;
89 | }
90 |
91 | public void loadThumbnailContent(final View view, final File thumbnail) {
92 | if (view instanceof ImageView) {
93 | ((ImageView) view).setImageURI(Uri.fromFile(thumbnail));
94 | }
95 | }
96 |
97 | public void loadThumbnailContent(final View view, final Uri thumbnail) {
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/BigImageViewer/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change log
2 |
3 | + v1.8.1
4 | - Fix mime type when save image to gallery;
5 | + v1.8.0
6 | - Migrate to MavenCentral;
7 | + v1.7.1
8 | - Fix webp type check bug;
9 | + v1.7.0
10 | - Remove android-gif-drawable dependency
11 | + v1.6.5
12 | - Fix the CloseableReference not closed problem, #196;
13 | + v1.6.4
14 | - Minor opt;
15 | + v1.6.3
16 | - Fix Android 10 issue for Scoped Storage, #193
17 | + v1.6.2
18 | - Update dependencies, fix #184
19 | + v1.6.1
20 | - Update click handling, fix #180
21 | + v1.6.0
22 | - Experimental support for shared element transition
23 | + v1.5.7
24 | - Add `ImageLoader.cancelAll()` to allow APP cancel all flying requests, avoiding memory leak;
25 | + v1.5.6
26 | - Replace deprecated Glide SimpleTarget, #131
27 | - Fix NPE when thumbnail scale type not specified, #130
28 | + v1.5.5
29 | - Migrate to Android X
30 | + v1.5.4
31 | - Add thumbnail scale type attribute
32 | + v1.5.3
33 | - Determine still/animated webp, show still webp with SSIV
34 | - Use ImageView to display animated webp rather than leave it blank when using GlideImageLoader
35 | + v1.5.2
36 | - Support custom Glide components
37 | + v1.5.1
38 | - Fix #110, click listener bug
39 | + v1.5.0
40 | - Gif support, cheers~ 🍻
41 | - Move thumbnail view creation from `ImageLoader` into `ImageViewFactory`
42 | + v1.4.7
43 | - Fix #91
44 | + v1.4.6
45 | - Remove commons-io dependency
46 | + v1.4.5
47 | - Add `cancel` method
48 | - Auto cancel when detach from window to fix memory leak
49 | + v1.4.4
50 | - Add `INIT_SCALE_TYPE_START` scale type
51 | - Rename `INIT_SCALE_TYPE_AUTO` to `INIT_SCALE_TYPE_CUSTOM`
52 | + v1.4.3
53 | - Fix #72: allow disable tap to retry fail image
54 | + v1.4.2
55 | - Fix crash when pass attr to SSIV in some case
56 | + v1.4.1
57 | - Remove logging
58 | - Update dependencies
59 | + v1.4.0
60 | - Upgrade to Glide 4.x
61 | - Update min sdk version to 14 according to Glide 4.x
62 | + v1.3.2
63 | - Fix Android Studio preview issue
64 | + v1.3.1
65 | - Fix NPE when no failure image specified
66 | - Support custom SSIV
67 | + v1.3.0
68 | - Add events callback for library user
69 | - Support failure image, and tap-to-reload
70 | - `currentImageFile` -> `getCurrentImageFile`
71 | + v1.2.9
72 | - Add access to the internal SSIV, #42
73 | + v1.2.8
74 | - Update fresco to v1.2.0, #41
75 | + v1.2.7
76 | - Allow disable display optimization, #35, #38
77 | + v1.2.6
78 | - Fix #37
79 | + v1.2.5
80 | - let users handle permission check
81 | - animate to hide thumbnail image
82 | + v1.2.4
83 | - fix crash, thanks YOLO
84 | + v1.2.3
85 | - add initScaleType
86 | + v1.2.2
87 | - Fix #16
88 | + v1.2.1
89 | - Change minSdkVersion to 10
90 | + v1.2.0
91 | - Add progress and thumbnail support
92 | + v1.1.3
93 | - Play auto scale animation only when showing long image
94 | + v1.1.2
95 | - Optimize image display effect, including long image support
96 | - Save image file to gallery
97 |
--------------------------------------------------------------------------------
/FrescoImageLoader/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/FrescoImageLoader/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2018 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | apply plugin: 'com.android.library'
26 | apply plugin: 'com.github.ben-manes.versions'
27 | apply from: "$rootProject.rootDir/gradle/publish-maven-central.gradle"
28 |
29 | android {
30 | compileSdkVersion rootProject.ext.androidCompileSdkVersion
31 |
32 | defaultConfig {
33 | minSdkVersion rootProject.ext.minSdkVersion
34 | targetSdkVersion rootProject.ext.targetSdkVersion
35 | versionCode rootProject.ext.releaseVersionCode
36 | versionName rootProject.ext.releaseVersionName
37 |
38 | consumerProguardFiles 'proguard-rules.pro'
39 | }
40 | buildTypes {
41 | release {
42 | minifyEnabled false
43 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
44 | }
45 | }
46 | }
47 |
48 | dependencies {
49 | implementation project(':BigImageViewer')
50 |
51 | api "com.facebook.fresco:fresco:$rootProject.ext.frescoVersion"
52 | implementation "androidx.annotation:annotation:$rootProject.ext.annotationVersion"
53 | }
54 |
--------------------------------------------------------------------------------
/FrescoImageLoader/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Keep our interfaces so they can be used by other ProGuard rules.
2 | # See http://sourceforge.net/p/proguard/bugs/466/
3 | -keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip
4 |
5 | # Do not strip any method/class that is annotated with @DoNotStrip
6 | -keep @com.facebook.common.internal.DoNotStrip class *
7 | -keepclassmembers class * {
8 | @com.facebook.common.internal.DoNotStrip *;
9 | }
10 |
11 | # Keep native methods
12 | -keepclassmembers class * {
13 | native ;
14 | }
15 |
16 | -dontwarn okio.**
17 | -dontwarn com.squareup.okhttp.**
18 | -dontwarn okhttp3.**
19 | -dontwarn javax.annotation.**
20 | -dontwarn com.android.volley.toolbox.**
21 | -dontwarn com.facebook.infer.**
22 |
--------------------------------------------------------------------------------
/FrescoImageLoader/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/FrescoImageLoader/src/main/java/com/github/piasy/biv/loader/fresco/ImageDownloadSubscriber.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2018 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.biv.loader.fresco;
26 |
27 | import android.content.Context;
28 | import androidx.annotation.WorkerThread;
29 | import com.facebook.common.memory.PooledByteBuffer;
30 | import com.facebook.common.memory.PooledByteBufferInputStream;
31 | import com.facebook.common.references.CloseableReference;
32 | import com.facebook.datasource.BaseDataSubscriber;
33 | import com.facebook.datasource.DataSource;
34 | import com.github.piasy.biv.utils.IOUtils;
35 | import java.io.File;
36 | import java.io.FileOutputStream;
37 | import java.io.IOException;
38 |
39 | /**
40 | * Created by Piasy{github.com/Piasy} on 06/11/2016.
41 | */
42 |
43 | public abstract class ImageDownloadSubscriber
44 | extends BaseDataSubscriber> {
45 | private static int sCounter = 0;
46 |
47 | private final File mTempFile;
48 |
49 | private volatile boolean mFinished;
50 |
51 | public ImageDownloadSubscriber(Context context) {
52 | // no need for any file extension, use a counter to avoid conflict.
53 | mTempFile =
54 | new File(context.getCacheDir(), System.currentTimeMillis() + "_" + nextCounter());
55 | }
56 |
57 | private static synchronized int nextCounter() {
58 | sCounter++;
59 | return sCounter;
60 | }
61 |
62 | @Override
63 | public void onProgressUpdate(DataSource> dataSource) {
64 | if (!mFinished) {
65 | onProgress((int) (dataSource.getProgress() * 100));
66 | }
67 | }
68 |
69 | @Override
70 | protected void onNewResultImpl(DataSource> dataSource) {
71 | if (!dataSource.isFinished()) {
72 | return;
73 | }
74 |
75 | CloseableReference closeableRef = dataSource.getResult();
76 | // if we try to retrieve image file by cache key, it will return null
77 | // so we need to create a temp file, little bit hack :(
78 | PooledByteBufferInputStream inputStream = null;
79 | FileOutputStream outputStream = null;
80 | try {
81 | if (closeableRef != null) {
82 | inputStream = new PooledByteBufferInputStream(closeableRef.get());
83 | outputStream = new FileOutputStream(mTempFile);
84 | IOUtils.copy(inputStream, outputStream);
85 |
86 | mFinished = true;
87 | onSuccess(mTempFile);
88 | }
89 | } catch (IOException e) {
90 | onFail(e);
91 | } finally {
92 | CloseableReference.closeSafely(closeableRef);
93 | IOUtils.closeQuietly(inputStream);
94 | IOUtils.closeQuietly(outputStream);
95 | }
96 | }
97 |
98 | @Override
99 | protected void onFailureImpl(DataSource> dataSource) {
100 | mFinished = true;
101 | onFail(new RuntimeException("onFailureImpl"));
102 | }
103 |
104 | @WorkerThread
105 | protected abstract void onProgress(int progress);
106 |
107 | @WorkerThread
108 | protected abstract void onSuccess(File image);
109 |
110 | @WorkerThread
111 | protected abstract void onFail(Throwable t);
112 | }
113 |
--------------------------------------------------------------------------------
/FrescoImageViewFactory/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/FrescoImageViewFactory/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2018 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | apply plugin: 'com.android.library'
26 | apply plugin: 'com.github.ben-manes.versions'
27 | apply from: "$rootProject.rootDir/gradle/publish-maven-central.gradle"
28 |
29 | android {
30 | compileSdkVersion rootProject.ext.androidCompileSdkVersion
31 |
32 | defaultConfig {
33 | minSdkVersion rootProject.ext.minSdkVersion
34 | targetSdkVersion rootProject.ext.targetSdkVersion
35 | versionCode rootProject.ext.releaseVersionCode
36 | versionName rootProject.ext.releaseVersionName
37 |
38 | consumerProguardFiles 'proguard-rules.pro'
39 | }
40 | buildTypes {
41 | release {
42 | minifyEnabled false
43 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
44 | }
45 | }
46 | }
47 |
48 | dependencies {
49 | implementation project(':BigImageViewer')
50 |
51 | api "com.facebook.fresco:fresco:$rootProject.ext.frescoVersion"
52 | api "com.facebook.fresco:animated-gif:$rootProject.ext.frescoVersion"
53 | api "com.facebook.fresco:animated-webp:$rootProject.ext.frescoVersion"
54 | api "com.facebook.fresco:webpsupport:$rootProject.ext.frescoVersion"
55 | }
56 |
--------------------------------------------------------------------------------
/FrescoImageViewFactory/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Keep our interfaces so they can be used by other ProGuard rules.
2 | # See http://sourceforge.net/p/proguard/bugs/466/
3 | -keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip
4 |
5 | # Do not strip any method/class that is annotated with @DoNotStrip
6 | -keep @com.facebook.common.internal.DoNotStrip class *
7 | -keepclassmembers class * {
8 | @com.facebook.common.internal.DoNotStrip *;
9 | }
10 |
11 | # Keep native methods
12 | -keepclassmembers class * {
13 | native ;
14 | }
15 |
16 | -dontwarn okio.**
17 | -dontwarn com.squareup.okhttp.**
18 | -dontwarn okhttp3.**
19 | -dontwarn javax.annotation.**
20 | -dontwarn com.android.volley.toolbox.**
21 | -dontwarn com.facebook.infer.**
22 |
--------------------------------------------------------------------------------
/FrescoImageViewFactory/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/FrescoImageViewFactory/src/main/java/com/github/piasy/biv/view/FrescoImageViewFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2018 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.biv.view;
26 |
27 | import android.content.Context;
28 | import android.net.Uri;
29 | import android.view.View;
30 | import android.widget.ImageView;
31 | import com.facebook.drawee.backends.pipeline.Fresco;
32 | import com.facebook.drawee.drawable.ScalingUtils;
33 | import com.facebook.drawee.interfaces.DraweeController;
34 | import com.facebook.drawee.view.SimpleDraweeView;
35 | import java.io.File;
36 |
37 | /**
38 | * Created by Piasy{github.com/Piasy} on 2018/8/12.
39 | */
40 | public class FrescoImageViewFactory extends ImageViewFactory {
41 | @Override
42 | protected final View createAnimatedImageView(final Context context, final int imageType,
43 | int initScaleType) {
44 | final SimpleDraweeView view = new SimpleDraweeView(context);
45 | view.getHierarchy().setActualImageScaleType(scaleType(initScaleType));
46 | return view;
47 | }
48 |
49 | @Override
50 | public final void loadAnimatedContent(final View view, final int imageType,
51 | final File imageFile) {
52 | if (view instanceof SimpleDraweeView) {
53 | final DraweeController controller = Fresco.newDraweeControllerBuilder()
54 | .setUri(Uri.parse("file://" + imageFile.getAbsolutePath()))
55 | .setAutoPlayAnimations(true)
56 | .build();
57 | ((SimpleDraweeView) view).setController(controller);
58 | }
59 | }
60 |
61 | @Override
62 | public final View createThumbnailView(final Context context,
63 | final ImageView.ScaleType scaleType, final boolean willLoadFromNetwork) {
64 | if (willLoadFromNetwork) {
65 | final SimpleDraweeView thumbnailView = new SimpleDraweeView(context);
66 | if (scaleType != null) {
67 | thumbnailView.getHierarchy().setActualImageScaleType(scaleType(scaleType));
68 | }
69 |
70 | return thumbnailView;
71 | } else {
72 | return super.createThumbnailView(context, scaleType, false);
73 | }
74 | }
75 |
76 | @Override
77 | public void loadThumbnailContent(final View view, final Uri thumbnail) {
78 | if (view instanceof SimpleDraweeView) {
79 | final DraweeController controller = Fresco.newDraweeControllerBuilder()
80 | .setUri(thumbnail)
81 | .build();
82 | ((SimpleDraweeView) view).setController(controller);
83 | }
84 | }
85 |
86 | private ScalingUtils.ScaleType scaleType(int value) {
87 | switch (value) {
88 | case BigImageView.INIT_SCALE_TYPE_CENTER:
89 | return ScalingUtils.ScaleType.CENTER;
90 | case BigImageView.INIT_SCALE_TYPE_CENTER_CROP:
91 | return ScalingUtils.ScaleType.CENTER_CROP;
92 | case BigImageView.INIT_SCALE_TYPE_CENTER_INSIDE:
93 | return ScalingUtils.ScaleType.CENTER_INSIDE;
94 | case BigImageView.INIT_SCALE_TYPE_FIT_END:
95 | return ScalingUtils.ScaleType.FIT_END;
96 | case BigImageView.INIT_SCALE_TYPE_FIT_START:
97 | return ScalingUtils.ScaleType.FIT_START;
98 | case BigImageView.INIT_SCALE_TYPE_FIT_XY:
99 | return ScalingUtils.ScaleType.FIT_XY;
100 | case BigImageView.INIT_SCALE_TYPE_FIT_CENTER:
101 | default:
102 | return ScalingUtils.ScaleType.FIT_CENTER;
103 | }
104 | }
105 |
106 | private ScalingUtils.ScaleType scaleType(ImageView.ScaleType scaleType) {
107 | switch (scaleType) {
108 | case CENTER:
109 | return ScalingUtils.ScaleType.CENTER;
110 | case CENTER_CROP:
111 | return ScalingUtils.ScaleType.CENTER_CROP;
112 | case CENTER_INSIDE:
113 | return ScalingUtils.ScaleType.CENTER_INSIDE;
114 | case FIT_END:
115 | return ScalingUtils.ScaleType.FIT_END;
116 | case FIT_START:
117 | return ScalingUtils.ScaleType.FIT_START;
118 | case FIT_XY:
119 | return ScalingUtils.ScaleType.FIT_XY;
120 | case FIT_CENTER:
121 | default:
122 | return ScalingUtils.ScaleType.FIT_CENTER;
123 | }
124 | }
125 | }
126 |
--------------------------------------------------------------------------------
/GlideImageLoader/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/GlideImageLoader/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2018 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | apply plugin: 'com.android.library'
26 | apply plugin: 'com.github.ben-manes.versions'
27 | apply from: "$rootProject.rootDir/gradle/publish-maven-central.gradle"
28 |
29 | android {
30 | compileSdkVersion rootProject.ext.androidCompileSdkVersion
31 |
32 | defaultConfig {
33 | minSdkVersion rootProject.ext.minSdkVersion
34 | targetSdkVersion rootProject.ext.targetSdkVersion
35 | versionCode rootProject.ext.releaseVersionCode
36 | versionName rootProject.ext.releaseVersionName
37 |
38 | consumerProguardFiles 'proguard-rules.pro'
39 | }
40 | buildTypes {
41 | release {
42 | minifyEnabled false
43 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
44 | }
45 | }
46 | }
47 |
48 | dependencies {
49 | implementation project(':BigImageViewer')
50 |
51 | api "com.github.bumptech.glide:glide:$rootProject.ext.glideVersion"
52 | api "com.github.bumptech.glide:okhttp3-integration:$rootProject.ext.glideVersion"
53 | annotationProcessor "com.github.bumptech.glide:compiler:$rootProject.ext.glideVersion"
54 | implementation "com.squareup.okhttp3:okhttp:$okhttpVersion"
55 |
56 | implementation "androidx.annotation:annotation:$rootProject.ext.annotationVersion"
57 | }
58 |
--------------------------------------------------------------------------------
/GlideImageLoader/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Glide specific rules #
2 | # https://github.com/bumptech/glide
3 |
4 | -keep public class * implements com.bumptech.glide.module.GlideModule
5 | -keep public class * extends com.bumptech.glide.module.AppGlideModule
6 | -keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
7 | **[] $VALUES;
8 | public *;
9 | }
10 |
11 | -dontwarn com.bumptech.glide.**
12 | -dontwarn okio.**
13 | -dontwarn okhttp3.**
14 |
--------------------------------------------------------------------------------
/GlideImageLoader/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/GlideImageLoader/src/main/java/com/github/piasy/biv/loader/glide/GlideCustomImageLoader.java:
--------------------------------------------------------------------------------
1 | package com.github.piasy.biv.loader.glide;
2 |
3 | import android.content.Context;
4 | import android.net.Uri;
5 | import com.bumptech.glide.request.target.Target;
6 | import java.io.File;
7 | import okhttp3.OkHttpClient;
8 |
9 | public class GlideCustomImageLoader extends GlideImageLoader {
10 | private final Class extends GlideModel> mModel;
11 |
12 | private GlideCustomImageLoader(Context context, OkHttpClient okHttpClient,
13 | Class extends GlideModel> model) {
14 | super(context, okHttpClient);
15 | mModel = model;
16 | }
17 |
18 | public static GlideCustomImageLoader with(Context context,
19 | Class extends GlideModel> glideModel) {
20 | return with(context, null, glideModel);
21 | }
22 |
23 | public static GlideCustomImageLoader with(Context context, OkHttpClient okHttpClient,
24 | Class extends GlideModel> glideModel) {
25 | return new GlideCustomImageLoader(context, okHttpClient, glideModel);
26 | }
27 |
28 | @Override
29 | protected void downloadImageInto(Uri uri, Target target) {
30 | if (mModel != null) {
31 | try {
32 | GlideModel glideModel = mModel.newInstance();
33 | glideModel.setBaseImageUrl(uri);
34 | mRequestManager
35 | .downloadOnly()
36 | .load(glideModel)
37 | .into(target);
38 | } catch (InstantiationException e) {
39 | super.downloadImageInto(uri, target);
40 | } catch (IllegalAccessException e) {
41 | super.downloadImageInto(uri, target);
42 | }
43 | } else {
44 | super.downloadImageInto(uri, target);
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/GlideImageLoader/src/main/java/com/github/piasy/biv/loader/glide/GlideImageLoader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2018 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.biv.loader.glide;
26 |
27 | import android.content.Context;
28 | import android.graphics.drawable.Drawable;
29 | import android.net.Uri;
30 | import android.util.Log;
31 | import androidx.annotation.NonNull;
32 | import com.bumptech.glide.Glide;
33 | import com.bumptech.glide.RequestManager;
34 | import com.bumptech.glide.request.target.Target;
35 | import com.bumptech.glide.request.transition.Transition;
36 | import com.github.piasy.biv.loader.ImageLoader;
37 | import com.github.piasy.biv.metadata.ImageInfoExtractor;
38 | import java.io.File;
39 | import java.util.ArrayList;
40 | import java.util.HashMap;
41 | import java.util.List;
42 | import java.util.Map;
43 | import okhttp3.OkHttpClient;
44 |
45 | /**
46 | * Created by Piasy{github.com/Piasy} on 09/11/2016.
47 | */
48 |
49 | public class GlideImageLoader implements ImageLoader {
50 | protected final RequestManager mRequestManager;
51 |
52 | private final Map mFlyingRequestTargets = new HashMap<>(3);
53 |
54 | protected GlideImageLoader(Context context, OkHttpClient okHttpClient) {
55 | GlideProgressSupport.init(Glide.get(context), okHttpClient);
56 | mRequestManager = Glide.with(context);
57 | }
58 |
59 | public static GlideImageLoader with(Context context) {
60 | return with(context, null);
61 | }
62 |
63 | public static GlideImageLoader with(Context context, OkHttpClient okHttpClient) {
64 | return new GlideImageLoader(context, okHttpClient);
65 | }
66 |
67 | @Override
68 | public void loadImage(final int requestId, final Uri uri, final Callback callback) {
69 | final boolean[] cacheMissed = new boolean[1];
70 | ImageDownloadTarget target = new ImageDownloadTarget(uri.toString()) {
71 | @Override
72 | public void onResourceReady(@NonNull File resource,
73 | Transition super File> transition) {
74 | super.onResourceReady(resource, transition);
75 | if (cacheMissed[0]) {
76 | callback.onCacheMiss(ImageInfoExtractor.getImageType(resource), resource);
77 | } else {
78 | callback.onCacheHit(ImageInfoExtractor.getImageType(resource), resource);
79 | }
80 | callback.onSuccess(resource);
81 | }
82 |
83 | @Override
84 | public void onLoadFailed(final Drawable errorDrawable) {
85 | super.onLoadFailed(errorDrawable);
86 | callback.onFail(new GlideLoaderException(errorDrawable));
87 | }
88 |
89 | @Override
90 | public void onDownloadStart() {
91 | cacheMissed[0] = true;
92 | callback.onStart();
93 | }
94 |
95 | @Override
96 | public void onProgress(int progress) {
97 | callback.onProgress(progress);
98 | }
99 |
100 | @Override
101 | public void onDownloadFinish() {
102 | callback.onFinish();
103 | }
104 | };
105 | cancel(requestId);
106 | rememberTarget(requestId, target);
107 |
108 | downloadImageInto(uri, target);
109 | }
110 |
111 | @Override
112 | public void prefetch(Uri uri) {
113 | downloadImageInto(uri, new PrefetchTarget());
114 | }
115 |
116 | @Override
117 | public synchronized void cancel(int requestId) {
118 | clearTarget(mFlyingRequestTargets.remove(requestId));
119 | }
120 |
121 | @Override
122 | public synchronized void cancelAll() {
123 | List targets = new ArrayList<>(mFlyingRequestTargets.values());
124 | for (ImageDownloadTarget target : targets) {
125 | clearTarget(target);
126 | }
127 | }
128 |
129 | protected void downloadImageInto(Uri uri, Target target) {
130 | mRequestManager
131 | .downloadOnly()
132 | .load(uri)
133 | .into(target);
134 | }
135 |
136 | private synchronized void rememberTarget(int requestId, ImageDownloadTarget target) {
137 | mFlyingRequestTargets.put(requestId, target);
138 | }
139 |
140 | private void clearTarget(ImageDownloadTarget target) {
141 | if (target != null) {
142 | mRequestManager.clear(target);
143 | }
144 | }
145 | }
146 |
--------------------------------------------------------------------------------
/GlideImageLoader/src/main/java/com/github/piasy/biv/loader/glide/GlideLoaderException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2018 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.biv.loader.glide;
26 |
27 | import android.graphics.drawable.Drawable;
28 |
29 | /**
30 | * Created by Piasy{github.com/Piasy} on 03/10/2017.
31 | */
32 |
33 | public class GlideLoaderException extends RuntimeException {
34 | private final Drawable mErrorDrawable;
35 |
36 | public GlideLoaderException(final Drawable errorDrawable) {
37 | mErrorDrawable = errorDrawable;
38 | }
39 |
40 | public Drawable getErrorDrawable() {
41 | return mErrorDrawable;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/GlideImageLoader/src/main/java/com/github/piasy/biv/loader/glide/GlideModel.java:
--------------------------------------------------------------------------------
1 | package com.github.piasy.biv.loader.glide;
2 |
3 | import android.net.Uri;
4 |
5 | public interface GlideModel {
6 | void setBaseImageUrl(Uri baseImageUrl);
7 | }
8 |
--------------------------------------------------------------------------------
/GlideImageLoader/src/main/java/com/github/piasy/biv/loader/glide/ImageDownloadTarget.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2018 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.biv.loader.glide;
26 |
27 | import android.graphics.drawable.Drawable;
28 |
29 | import com.bumptech.glide.request.Request;
30 | import com.bumptech.glide.request.target.SizeReadyCallback;
31 | import com.bumptech.glide.request.target.Target;
32 | import com.bumptech.glide.request.transition.Transition;
33 | import com.bumptech.glide.util.Util;
34 |
35 | import java.io.File;
36 |
37 | import androidx.annotation.NonNull;
38 | import androidx.annotation.Nullable;
39 |
40 | /**
41 | * Created by Piasy{github.com/Piasy} on 12/11/2016.
42 | */
43 |
44 | public abstract class ImageDownloadTarget implements Target,
45 | GlideProgressSupport.ProgressListener {
46 |
47 | private Request request;
48 |
49 | private final int width;
50 | private final int height;
51 |
52 | private final String mUrl;
53 |
54 | protected ImageDownloadTarget(String url) {
55 | this(SIZE_ORIGINAL, SIZE_ORIGINAL, url);
56 | }
57 |
58 | private ImageDownloadTarget(int width, int height, String url) {
59 | this.width = width;
60 | this.height = height;
61 | mUrl = url;
62 | }
63 |
64 | @Override
65 | public void onResourceReady(@NonNull File resource, Transition super File> transition) {
66 | GlideProgressSupport.forget(mUrl);
67 | }
68 |
69 | @Override
70 | public void onLoadCleared(Drawable placeholder) {
71 | GlideProgressSupport.forget(mUrl);
72 | }
73 |
74 | @Override
75 | public void onLoadStarted(Drawable placeholder) {
76 | GlideProgressSupport.expect(mUrl, this);
77 | }
78 |
79 | @Override
80 | public void onLoadFailed(Drawable errorDrawable) {
81 | GlideProgressSupport.forget(mUrl);
82 | }
83 |
84 | /**
85 | * Immediately calls the given callback with the sizes given in the constructor.
86 | *
87 | * @param cb {@inheritDoc}
88 | */
89 | @Override
90 | public final void getSize(@NonNull SizeReadyCallback cb) {
91 | if (!Util.isValidDimensions(width, height)) {
92 | throw new IllegalArgumentException(
93 | "Width and height must both be > 0 or Target#SIZE_ORIGINAL, but given" + " width: "
94 | + width + " and height: " + height + ", either provide dimensions in the constructor"
95 | + " or call override()");
96 | }
97 | cb.onSizeReady(width, height);
98 | }
99 |
100 | @Override
101 | public void removeCallback(@NonNull SizeReadyCallback cb) {
102 | // Do nothing, we never retain a reference to the callback.
103 | }
104 |
105 | @Override
106 | public void setRequest(@Nullable Request request) {
107 | this.request = request;
108 | }
109 |
110 | @Override
111 | @Nullable
112 | public Request getRequest() {
113 | return request;
114 | }
115 |
116 | @Override
117 | public void onStart() {
118 | // Do nothing.
119 | }
120 |
121 | @Override
122 | public void onStop() {
123 | // Do nothing.
124 | }
125 |
126 | @Override
127 | public void onDestroy() {
128 | // Do nothing.
129 | }
130 | }
131 |
--------------------------------------------------------------------------------
/GlideImageLoader/src/main/java/com/github/piasy/biv/loader/glide/PrefetchTarget.java:
--------------------------------------------------------------------------------
1 | package com.github.piasy.biv.loader.glide;
2 |
3 | import android.graphics.drawable.Drawable;
4 |
5 | import com.bumptech.glide.request.Request;
6 | import com.bumptech.glide.request.target.SizeReadyCallback;
7 | import com.bumptech.glide.request.target.Target;
8 | import com.bumptech.glide.request.transition.Transition;
9 | import com.bumptech.glide.util.Util;
10 |
11 | import java.io.File;
12 |
13 | import androidx.annotation.NonNull;
14 | import androidx.annotation.Nullable;
15 |
16 | public class PrefetchTarget implements Target {
17 |
18 | private final int width;
19 | private final int height;
20 |
21 | private Request request;
22 |
23 | @SuppressWarnings("WeakerAccess")
24 | public PrefetchTarget() {
25 | this(SIZE_ORIGINAL, SIZE_ORIGINAL);
26 | }
27 |
28 | @SuppressWarnings("WeakerAccess")
29 | private PrefetchTarget(int width, int height) {
30 | this.width = width;
31 | this.height = height;
32 | }
33 |
34 | @Override
35 | public void onResourceReady(@NonNull File resource, @Nullable Transition super File> transition) {
36 | // not interested in result
37 | }
38 |
39 | /**
40 | * Immediately calls the given callback with the sizes given in the constructor.
41 | *
42 | * @param cb {@inheritDoc}
43 | */
44 | @Override
45 | public final void getSize(@NonNull SizeReadyCallback cb) {
46 | if (!Util.isValidDimensions(width, height)) {
47 | throw new IllegalArgumentException(
48 | "Width and height must both be > 0 or Target#SIZE_ORIGINAL, but given" + " width: "
49 | + width + " and height: " + height + ", either provide dimensions in the constructor"
50 | + " or call override()");
51 | }
52 | cb.onSizeReady(width, height);
53 | }
54 |
55 | @Override
56 | public void removeCallback(@NonNull SizeReadyCallback cb) {
57 | // Do nothing, we never retain a reference to the callback.
58 | }
59 |
60 | @Override
61 | public void setRequest(@Nullable Request request) {
62 | this.request = request;
63 | }
64 |
65 | @Override
66 | @Nullable
67 | public Request getRequest() {
68 | return request;
69 | }
70 |
71 | @Override
72 | public void onLoadCleared(@Nullable Drawable placeholder) {
73 | // Do nothing.
74 | }
75 |
76 | @Override
77 | public void onLoadStarted(@Nullable Drawable placeholder) {
78 | // Do nothing.
79 | }
80 |
81 | @Override
82 | public void onLoadFailed(@Nullable Drawable errorDrawable) {
83 | // Do nothing.
84 | }
85 |
86 | @Override
87 | public void onStart() {
88 | // Do nothing.
89 | }
90 |
91 | @Override
92 | public void onStop() {
93 | // Do nothing.
94 | }
95 |
96 | @Override
97 | public void onDestroy() {
98 | // Do nothing.
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/GlideImageViewFactory/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/GlideImageViewFactory/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2018 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | apply plugin: 'com.android.library'
26 | apply plugin: 'com.github.ben-manes.versions'
27 | apply from: "$rootProject.rootDir/gradle/publish-maven-central.gradle"
28 |
29 | android {
30 | compileSdkVersion rootProject.ext.androidCompileSdkVersion
31 |
32 | defaultConfig {
33 | minSdkVersion rootProject.ext.minSdkVersion
34 | targetSdkVersion rootProject.ext.targetSdkVersion
35 | versionCode rootProject.ext.releaseVersionCode
36 | versionName rootProject.ext.releaseVersionName
37 |
38 | consumerProguardFiles 'proguard-rules.pro'
39 | }
40 | buildTypes {
41 | release {
42 | minifyEnabled false
43 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
44 | }
45 | }
46 | }
47 |
48 | dependencies {
49 | implementation project(':BigImageViewer')
50 |
51 | api "com.github.bumptech.glide:glide:$rootProject.ext.glideVersion"
52 | }
53 |
--------------------------------------------------------------------------------
/GlideImageViewFactory/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Glide specific rules #
2 | # https://github.com/bumptech/glide
3 |
4 | -keep public class * implements com.bumptech.glide.module.GlideModule
5 | -keep public class * extends com.bumptech.glide.module.AppGlideModule
6 | -keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
7 | **[] $VALUES;
8 | public *;
9 | }
10 |
11 | -dontwarn com.bumptech.glide.**
12 | -dontwarn okio.**
13 | -dontwarn okhttp3.**
14 |
--------------------------------------------------------------------------------
/GlideImageViewFactory/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/GlideImageViewFactory/src/main/java/com/github/piasy/biv/view/GlideImageViewFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2018 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.biv.view;
26 |
27 | import android.content.Context;
28 | import android.net.Uri;
29 | import android.view.View;
30 | import android.widget.ImageView;
31 | import com.bumptech.glide.Glide;
32 | import com.github.piasy.biv.metadata.ImageInfoExtractor;
33 | import java.io.File;
34 |
35 | /**
36 | * Created by Piasy{github.com/Piasy} on 2018/8/12.
37 | */
38 | public class GlideImageViewFactory extends ImageViewFactory {
39 | @Override
40 | protected final View createAnimatedImageView(final Context context, final int imageType,
41 | final int initScaleType) {
42 | switch (imageType) {
43 | case ImageInfoExtractor.TYPE_GIF:
44 | case ImageInfoExtractor.TYPE_ANIMATED_WEBP: {
45 | final ImageView imageView = new ImageView(context);
46 | imageView.setScaleType(BigImageView.scaleType(initScaleType));
47 | return imageView;
48 | }
49 | default:
50 | return super.createAnimatedImageView(context, imageType, initScaleType);
51 | }
52 | }
53 |
54 | @Override
55 | public final void loadAnimatedContent(final View view, final int imageType,
56 | final File imageFile) {
57 | switch (imageType) {
58 | case ImageInfoExtractor.TYPE_GIF:
59 | case ImageInfoExtractor.TYPE_ANIMATED_WEBP: {
60 | if (view instanceof ImageView) {
61 | Glide.with(view.getContext())
62 | .load(imageFile)
63 | .into((ImageView) view);
64 | }
65 | break;
66 | }
67 |
68 | default:
69 | super.loadAnimatedContent(view, imageType, imageFile);
70 | }
71 | }
72 |
73 | @Override
74 | public void loadThumbnailContent(final View view, final Uri thumbnail) {
75 | if (view instanceof ImageView) {
76 | Glide.with(view.getContext())
77 | .load(thumbnail)
78 | .into((ImageView) view);
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Piasy
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/ProgressPieIndicator/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/ProgressPieIndicator/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2018 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | apply plugin: 'com.android.library'
26 | apply plugin: 'com.github.ben-manes.versions'
27 | apply from: "$rootProject.rootDir/gradle/publish-maven-central.gradle"
28 |
29 | android {
30 | compileSdkVersion rootProject.ext.androidCompileSdkVersion
31 |
32 | defaultConfig {
33 | minSdkVersion rootProject.ext.minSdkVersion
34 | targetSdkVersion rootProject.ext.targetSdkVersion
35 | versionCode rootProject.ext.releaseVersionCode
36 | versionName rootProject.ext.releaseVersionName
37 | }
38 | buildTypes {
39 | release {
40 | minifyEnabled false
41 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
42 | }
43 | }
44 | }
45 |
46 | dependencies {
47 | implementation project(':BigImageViewer')
48 |
49 | api 'com.github.filippudak.progresspieview:library:1.0.4'
50 | }
--------------------------------------------------------------------------------
/ProgressPieIndicator/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/piasy/tools/android-sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/ProgressPieIndicator/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/ProgressPieIndicator/src/main/java/com/github/piasy/biv/indicator/progresspie/ProgressPieIndicator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2018 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.biv.indicator.progresspie;
26 |
27 | import android.view.LayoutInflater;
28 | import android.view.View;
29 | import com.filippudak.ProgressPieView.ProgressPieView;
30 | import com.github.piasy.biv.indicator.ProgressIndicator;
31 | import com.github.piasy.biv.view.BigImageView;
32 | import java.util.Locale;
33 |
34 | /**
35 | * Created by Piasy{github.com/Piasy} on 12/11/2016.
36 | */
37 |
38 | public class ProgressPieIndicator implements ProgressIndicator {
39 | private ProgressPieView mProgressPieView;
40 |
41 | @Override
42 | public View getView(BigImageView parent) {
43 | mProgressPieView = (ProgressPieView) LayoutInflater.from(parent.getContext())
44 | .inflate(R.layout.ui_progress_pie_indicator, parent, false);
45 | return mProgressPieView;
46 | }
47 |
48 | @Override
49 | public void onStart() {
50 | // not interested
51 | }
52 |
53 | @Override
54 | public void onProgress(int progress) {
55 | if (progress < 0 || progress > 100 || mProgressPieView == null) {
56 | return;
57 | }
58 | mProgressPieView.setProgress(progress);
59 | mProgressPieView.setText(String.format(Locale.getDefault(), "%d%%", progress));
60 | }
61 |
62 | @Override
63 | public void onFinish() {
64 | // not interested
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/ProgressPieIndicator/src/main/res/layout/ui_progress_pie_indicator.xml:
--------------------------------------------------------------------------------
1 |
2 |
25 |
26 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/OpenKey.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piasy/BigImageViewer/067f8eb86ee522190ab473f36a1b0de11c21a663/app/OpenKey.jks
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2018 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | apply plugin: 'com.android.application'
26 | apply plugin: 'com.github.ben-manes.versions'
27 | apply plugin: 'kotlin-android'
28 |
29 | android {
30 | compileSdkVersion rootProject.ext.androidCompileSdkVersion
31 |
32 | defaultConfig {
33 | minSdkVersion 15
34 | targetSdkVersion rootProject.ext.targetSdkVersion
35 | versionCode rootProject.ext.releaseVersionCode
36 | versionName rootProject.ext.releaseVersionName
37 |
38 | applicationId "com.github.piasy.biv.example"
39 |
40 | vectorDrawables.useSupportLibrary = true
41 | multiDexEnabled true
42 | }
43 |
44 | signingConfigs {
45 | develop {
46 | storeFile file('OpenKey.jks')
47 | storePassword '123456'
48 | keyAlias '123456'
49 | keyPassword '123456'
50 | }
51 | }
52 |
53 | buildTypes {
54 | debug {
55 | minifyEnabled false
56 | debuggable true
57 | signingConfig signingConfigs.develop
58 | }
59 |
60 | release {
61 | minifyEnabled true
62 | debuggable false
63 | shrinkResources true
64 | signingConfig signingConfigs.develop
65 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
66 | }
67 | }
68 |
69 | compileOptions {
70 | sourceCompatibility JavaVersion.VERSION_1_8
71 | targetCompatibility JavaVersion.VERSION_1_8
72 | }
73 |
74 | kotlinOptions {
75 | jvmTarget = "1.8"
76 | }
77 |
78 | packagingOptions {
79 | exclude 'META-INF/rxjava.properties'
80 | }
81 | }
82 |
83 | dependencies {
84 | implementation "androidx.core:core-ktx:1.9.0"
85 | implementation "androidx.appcompat:appcompat:1.2.0"
86 | implementation "androidx.recyclerview:recyclerview:1.1.0"
87 | implementation "com.google.android.material:material:1.3.0"
88 |
89 | implementation('com.github.tbruyelle:rxpermissions:0.11') {
90 | exclude module: 'rxjava'
91 | }
92 | implementation('com.github.akarnokd:rxjava2-interop:0.13.7') {
93 | exclude module: 'rxjava'
94 | }
95 |
96 | implementation 'io.reactivex.rxjava2:rxjava:2.2.21'
97 | implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
98 | // implementation 'com.github.piasy:RxQrCode:1.3.0'
99 |
100 | debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.10'
101 |
102 | // implementation 'com.github.piasy:BigImageViewer:1.8.0'
103 | // implementation 'com.github.piasy:FrescoImageLoader:1.8.0'
104 | // implementation 'com.github.piasy:GlideImageLoader:1.8.0'
105 | // implementation 'com.github.piasy:FrescoImageViewFactory:1.8.0'
106 | // implementation 'com.github.piasy:GlideImageViewFactory:1.8.0'
107 | // implementation 'com.github.piasy:ProgressPieIndicator:1.8.0'
108 |
109 | implementation project(':BigImageViewer')
110 | implementation project(':FrescoImageLoader')
111 | implementation project(':GlideImageLoader')
112 | implementation project(':FrescoImageViewFactory')
113 | implementation project(':GlideImageViewFactory')
114 | implementation project(':ProgressPieIndicator')
115 | }
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/piasy/tools/android-sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | -dontwarn java.lang.invoke.**
20 | -dontwarn com.github.piasy.cameracompat.**
21 | -dontwarn rx.**
22 | -dontwarn sun.misc.Unsafe
23 |
24 | -keep class android.support.v7.** {
25 | *;
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
25 |
27 |
28 |
35 |
36 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/piasy/biv/example/BivDemoGlideModule.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2018 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.biv.example;
26 |
27 | import android.content.Context;
28 | import androidx.annotation.NonNull;
29 | import com.bumptech.glide.Glide;
30 | import com.bumptech.glide.Registry;
31 | import com.bumptech.glide.annotation.GlideModule;
32 | import com.bumptech.glide.module.AppGlideModule;
33 | import com.github.piasy.biv.example.glide.CustomImageSizeModel;
34 | import com.github.piasy.biv.example.glide.CustomImageSizeUrlLoaderFactory;
35 | import java.io.InputStream;
36 |
37 | /**
38 | * Created by Piasy{github.com/Piasy} on 03/10/2017.
39 | */
40 |
41 | @GlideModule
42 | public class BivDemoGlideModule extends AppGlideModule {
43 |
44 | @Override
45 | public boolean isManifestParsingEnabled() {
46 | return false;
47 | }
48 |
49 | @Override
50 | public void registerComponents(@NonNull Context context, @NonNull Glide glide,
51 | @NonNull Registry registry) {
52 | glide.getRegistry().prepend(CustomImageSizeModel.class, InputStream.class, new
53 | CustomImageSizeUrlLoaderFactory());
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/piasy/biv/example/CustomSSIVActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2018 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.biv.example;
26 |
27 | import android.content.Context;
28 | import android.net.Uri;
29 | import android.os.Bundle;
30 | import android.view.View;
31 | import androidx.appcompat.app.AppCompatActivity;
32 | import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView;
33 | import com.github.piasy.biv.BigImageViewer;
34 | import com.github.piasy.biv.indicator.progresspie.ProgressPieIndicator;
35 | import com.github.piasy.biv.loader.fresco.FrescoImageLoader;
36 | import com.github.piasy.biv.view.BigImageView;
37 | import com.github.piasy.biv.view.ImageViewFactory;
38 |
39 | public class CustomSSIVActivity extends AppCompatActivity {
40 |
41 | @Override
42 | protected void onCreate(Bundle savedInstanceState) {
43 | super.onCreate(savedInstanceState);
44 |
45 | BigImageViewer.initialize(FrescoImageLoader.with(getApplicationContext()));
46 |
47 | setContentView(R.layout.activity_custom_ssiv);
48 |
49 | findViewById(R.id.mBtnLoad).setOnClickListener(new View.OnClickListener() {
50 | @Override
51 | public void onClick(View v) {
52 | BigImageView bigImageView = findViewById(R.id.mBigImage);
53 | bigImageView.setProgressIndicator(new ProgressPieIndicator());
54 |
55 | bigImageView.setImageViewFactory(new ImageViewFactory() {
56 | @Override
57 | protected SubsamplingScaleImageView createStillImageView(final Context context) {
58 | return new MySSIV(context);
59 | }
60 | });
61 |
62 | bigImageView.showImage(
63 | Uri.parse("https://images.unsplash.com/photo-1497240299146-17ff4089466a?dpr=2&auto=compress,format&fit=crop&w=376"),
64 | Uri.parse("https://images.unsplash.com/photo-1497240299146-17ff4089466a")
65 | );
66 | }
67 | });
68 | }
69 |
70 | @Override
71 | protected void onDestroy() {
72 | super.onDestroy();
73 |
74 | BigImageViewer.imageLoader().cancelAll();
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/piasy/biv/example/FirstAnimFrescoActivity.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2019 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.biv.example
26 |
27 | import android.os.Bundle
28 | import android.view.View
29 | import android.widget.CheckBox
30 | import android.widget.RadioButton
31 | import androidx.appcompat.app.AppCompatActivity
32 | import androidx.core.app.ActivityCompat
33 | import androidx.core.app.SharedElementCallback
34 | import com.facebook.drawee.backends.pipeline.Fresco
35 | import com.facebook.drawee.drawable.ScalingUtils
36 | import com.facebook.drawee.view.SimpleDraweeView
37 |
38 | class FirstAnimFrescoActivity : AppCompatActivity() {
39 |
40 | companion object {
41 | private const val THUMB_URL =
42 | "https://images.unsplash.com/photo-1497240299146-17ff4089466a?dpr=2&auto=compress,format&fit=crop&w=376"
43 | private const val SOURCE_URL =
44 | "https://images.unsplash.com/photo-1497240299146-17ff4089466a"
45 | }
46 |
47 | private val thumb by lazy { findViewById(R.id.thumbView) }
48 |
49 | override fun onCreate(savedInstanceState: Bundle?) {
50 | super.onCreate(savedInstanceState)
51 |
52 | Fresco.initialize(this)
53 | setContentView(R.layout.activity_anim_first_fresco)
54 |
55 | ActivityCompat.setExitSharedElementCallback(this, object : SharedElementCallback() {
56 | override fun onSharedElementEnd(
57 | sharedElementNames: MutableList?,
58 | sharedElements: MutableList?,
59 | sharedElementSnapshots: MutableList?
60 | ) {
61 | super.onSharedElementEnd(sharedElementNames, sharedElements, sharedElementSnapshots)
62 | thumb.visibility = View.VISIBLE
63 | thumb.drawable.setVisible(true, true)
64 | }
65 | })
66 |
67 | val useGlide = findViewById(R.id.use_glide)
68 | val useFresco = findViewById(R.id.use_fresco)
69 | val useViewFactory = findViewById(R.id.check_use_view_factory)
70 |
71 | thumb.setOnClickListener {
72 | SecondAnimActivity.start(
73 | this, thumb,
74 | THUMB_URL, SOURCE_URL,
75 | useGlide.isChecked, useFresco.isChecked, useViewFactory.isChecked
76 | )
77 | }
78 |
79 | thumb.setLegacyVisibilityHandlingEnabled(true)
80 | val controller = Fresco.newDraweeControllerBuilder()
81 | .setUri(THUMB_URL)
82 | .build()
83 |
84 | thumb.hierarchy.actualImageScaleType = ScalingUtils.ScaleType.FIT_START
85 | thumb.controller = controller
86 | }
87 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/github/piasy/biv/example/FirstAnimGlideActivity.kt:
--------------------------------------------------------------------------------
1 | package com.github.piasy.biv.example
2 |
3 | import android.os.Bundle
4 | import android.widget.CheckBox
5 | import android.widget.ImageView
6 | import android.widget.RadioButton
7 | import androidx.appcompat.app.AppCompatActivity
8 | import com.bumptech.glide.Glide
9 |
10 | class FirstAnimGlideActivity : AppCompatActivity() {
11 |
12 | companion object {
13 | private const val THUMB_URL =
14 | "https://images.unsplash.com/photo-1497240299146-17ff4089466a?dpr=2&auto=compress,format&fit=crop&w=376"
15 | private const val SOURCE_URL =
16 | "https://images.unsplash.com/photo-1497240299146-17ff4089466a"
17 | }
18 |
19 | private val thumb by lazy { findViewById(R.id.thumbView) }
20 |
21 | override fun onCreate(savedInstanceState: Bundle?) {
22 | super.onCreate(savedInstanceState)
23 | setContentView(R.layout.activity_anim_first_glide)
24 |
25 | val useGlide = findViewById(R.id.use_glide)
26 | val useFresco = findViewById(R.id.use_fresco)
27 | val useViewFactory = findViewById(R.id.check_use_view_factory)
28 |
29 | thumb.setOnClickListener {
30 | SecondAnimActivity.start(
31 | this, thumb,
32 | THUMB_URL, SOURCE_URL,
33 | useGlide.isChecked, useFresco.isChecked, useViewFactory.isChecked
34 | )
35 | }
36 |
37 | val glide = Glide.with(this)
38 | glide.asBitmap()
39 | .load(THUMB_URL)
40 | .into(thumb)
41 | }
42 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/github/piasy/biv/example/FrescoLoaderActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2018 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.biv.example;
26 |
27 | import android.net.Uri;
28 | import android.os.Bundle;
29 | import android.view.View;
30 | import androidx.appcompat.app.AppCompatActivity;
31 | import com.github.piasy.biv.BigImageViewer;
32 | import com.github.piasy.biv.indicator.progresspie.ProgressPieIndicator;
33 | import com.github.piasy.biv.loader.fresco.FrescoImageLoader;
34 | import com.github.piasy.biv.view.BigImageView;
35 | import com.github.piasy.biv.view.FrescoImageViewFactory;
36 |
37 | public class FrescoLoaderActivity extends AppCompatActivity {
38 |
39 | @Override
40 | protected void onCreate(Bundle savedInstanceState) {
41 | super.onCreate(savedInstanceState);
42 |
43 | BigImageViewer.initialize(FrescoImageLoader.with(getApplicationContext()));
44 |
45 | setContentView(R.layout.activity_big_image);
46 |
47 | findViewById(R.id.mBtnLoad).setOnClickListener(new View.OnClickListener() {
48 | @Override
49 | public void onClick(View v) {
50 | BigImageView bigImageView = findViewById(R.id.mBigImage);
51 | bigImageView.setProgressIndicator(new ProgressPieIndicator());
52 | bigImageView.setImageViewFactory(new FrescoImageViewFactory());
53 | bigImageView.showImage(
54 | Uri.parse("http://img1.imgtn.bdimg.com/it/u=1520386803,778399414&fm=21&gp=0.jpg"),
55 | Uri.parse("https://youimg1.c-ctrip.com/target/tg/773/732/734/7ca19416b8cd423f8f6ef2d08366b7dc.jpg")
56 | );
57 | }
58 | });
59 | }
60 |
61 | @Override
62 | protected void onDestroy() {
63 | super.onDestroy();
64 |
65 | BigImageViewer.imageLoader().cancelAll();
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/piasy/biv/example/GlideLoaderActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2018 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.biv.example;
26 |
27 | import android.net.Uri;
28 | import android.os.Bundle;
29 | import android.util.Log;
30 | import android.view.View;
31 | import androidx.appcompat.app.AppCompatActivity;
32 | import com.github.piasy.biv.BigImageViewer;
33 | import com.github.piasy.biv.indicator.progresspie.ProgressPieIndicator;
34 | import com.github.piasy.biv.loader.glide.GlideImageLoader;
35 | import com.github.piasy.biv.view.BigImageView;
36 | import com.github.piasy.biv.view.GlideImageViewFactory;
37 |
38 | public class GlideLoaderActivity extends AppCompatActivity {
39 |
40 | @Override
41 | protected void onCreate(Bundle savedInstanceState) {
42 | super.onCreate(savedInstanceState);
43 |
44 | BigImageViewer.initialize(GlideImageLoader.with(getApplicationContext()));
45 |
46 | setContentView(R.layout.activity_big_image);
47 |
48 | findViewById(R.id.mBtnLoad).setOnClickListener(new View.OnClickListener() {
49 | @Override
50 | public void onClick(View v) {
51 | BigImageView bigImageView = findViewById(R.id.mBigImage);
52 | bigImageView.setProgressIndicator(new ProgressPieIndicator());
53 | bigImageView.setImageViewFactory(new GlideImageViewFactory());
54 | bigImageView.showImage(
55 | Uri.parse("http://img1.imgtn.bdimg.com/it/u=1520386803,778399414&fm=21&gp=0.jpg"),
56 | Uri.parse("https://youimg1.c-ctrip.com/target/tg/773/732/734/7ca19416b8cd423f8f6ef2d08366b7dc.jpg")
57 | );
58 | }
59 | });
60 | }
61 |
62 | @Override
63 | protected void onDestroy() {
64 | super.onDestroy();
65 |
66 | long start = System.nanoTime();
67 | Utils.fixLeakCanary696(getApplicationContext());
68 | long end = System.nanoTime();
69 | Log.w(Utils.TAG, "fixLeakCanary696: " + (end - start));
70 |
71 | BigImageViewer.imageLoader().cancelAll();
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/piasy/biv/example/ImageLoaderCallbackActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2018 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.biv.example;
26 |
27 | import android.net.Uri;
28 | import android.os.Bundle;
29 | import android.util.Log;
30 | import android.view.View;
31 | import android.widget.Toast;
32 |
33 | import androidx.appcompat.app.AppCompatActivity;
34 | import com.github.piasy.biv.BigImageViewer;
35 | import com.github.piasy.biv.indicator.progresspie.ProgressPieIndicator;
36 | import com.github.piasy.biv.loader.ImageLoader;
37 | import com.github.piasy.biv.loader.fresco.FrescoImageLoader;
38 | import com.github.piasy.biv.view.BigImageView;
39 |
40 | import com.github.piasy.biv.view.FrescoImageViewFactory;
41 | import java.io.File;
42 |
43 | public class ImageLoaderCallbackActivity extends AppCompatActivity {
44 |
45 | private void showToastOnUiThread(final String message) {
46 | runOnUiThread(new Runnable() {
47 | public void run() {
48 | showToast(message);
49 | }
50 | });
51 | }
52 |
53 | private void showToast(String message) {
54 | Toast.makeText(ImageLoaderCallbackActivity.this,
55 | message,
56 | Toast.LENGTH_SHORT).show();
57 | }
58 |
59 | @Override
60 | protected void onCreate(Bundle savedInstanceState) {
61 | super.onCreate(savedInstanceState);
62 |
63 | BigImageViewer.initialize(FrescoImageLoader.with(getApplicationContext()));
64 |
65 | setContentView(R.layout.activity_big_image);
66 |
67 | findViewById(R.id.mBtnLoad).setOnClickListener(new View.OnClickListener() {
68 | @Override
69 | public void onClick(View v) {
70 | BigImageView bigImageView = findViewById(R.id.mBigImage);
71 | bigImageView.setProgressIndicator(new ProgressPieIndicator());
72 | bigImageView.setImageViewFactory(new FrescoImageViewFactory());
73 | bigImageView.setImageLoaderCallback(new ImageLoader.Callback() {
74 | @Override
75 | public void onCacheHit(int imageType, File image) {
76 | final String message = "onCacheHit callback called, cached image " + image.getName();
77 | Log.i("onCacheHit", message);
78 | showToast(message);
79 | }
80 |
81 | @Override
82 | public void onCacheMiss(int imageType, File image) {
83 | final String message = "onCacheMiss callback called, fetching image " + image.getName();
84 | Log.i("onCacheMiss", message);
85 | showToastOnUiThread(message);
86 | }
87 |
88 | @Override
89 | public void onStart() {
90 | final String message = "onStart callback called";
91 | Log.i("onStart", message);
92 | showToastOnUiThread(message);
93 |
94 | }
95 |
96 | @Override
97 | public void onProgress(int progress) {
98 | final String message = "onProgress callback called, progress is " + progress;
99 | Log.i("onProgress", message);
100 | }
101 |
102 | @Override
103 | public void onFinish() {
104 | final String message = "onFinish callback called";
105 | Log.i("onFinish", message);
106 | showToastOnUiThread(message);
107 | }
108 |
109 | @Override
110 | public void onSuccess(File image) {
111 | final String message = "onSuccess callback called";
112 | Log.i("onSuccess", message);
113 | showToast(message);
114 | }
115 |
116 | @Override
117 | public void onFail(Exception e) {
118 | final String message = "onFail callback called";
119 | Log.i("onFail", message);
120 | showToast(message);
121 | }
122 | });
123 |
124 | bigImageView.showImage(
125 | Uri.parse("https://images.unsplash.com/photo-1497613913923-e07e0f465b12?dpr=2&auto=compress,format&fit=crop&w=376"),
126 | Uri.parse("https://images.unsplash.com/photo-1497613913923-e07e0f465b12")
127 | );
128 | }
129 | });
130 | }
131 |
132 | @Override
133 | protected void onDestroy() {
134 | super.onDestroy();
135 |
136 | BigImageViewer.imageLoader().cancelAll();
137 | }
138 | }
139 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/piasy/biv/example/MainActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2018 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.biv.example;
26 |
27 | import android.content.Intent;
28 | import android.os.Bundle;
29 | import android.view.View;
30 | import androidx.appcompat.app.AppCompatActivity;
31 |
32 | public class MainActivity extends AppCompatActivity {
33 |
34 | @Override
35 | protected void onCreate(Bundle savedInstanceState) {
36 | super.onCreate(savedInstanceState);
37 | setContentView(R.layout.activity_main);
38 |
39 | findViewById(R.id.mFresco).setOnClickListener(new View.OnClickListener() {
40 | @Override
41 | public void onClick(View v) {
42 | startActivity(new Intent(MainActivity.this, FrescoLoaderActivity.class));
43 | }
44 | });
45 | findViewById(R.id.mGlide).setOnClickListener(new View.OnClickListener() {
46 | @Override
47 | public void onClick(View v) {
48 | startActivity(new Intent(MainActivity.this, GlideLoaderActivity.class));
49 | }
50 | });
51 | findViewById(R.id.mLongImage).setOnClickListener(new View.OnClickListener() {
52 | @Override
53 | public void onClick(View v) {
54 | startActivity(new Intent(MainActivity.this, LongImageActivity.class));
55 | }
56 | });
57 | findViewById(R.id.mScaleType).setOnClickListener(new View.OnClickListener() {
58 | @Override
59 | public void onClick(View v) {
60 | startActivity(new Intent(MainActivity.this, ScaleTypeActivity.class));
61 | }
62 | });
63 | findViewById(R.id.mImageLoaderCallback).setOnClickListener(new View.OnClickListener() {
64 | @Override
65 | public void onClick(View v) {
66 | startActivity(new Intent(MainActivity.this, ImageLoaderCallbackActivity.class));
67 | }
68 | });
69 | findViewById(R.id.mCustomSSIV).setOnClickListener(new View.OnClickListener() {
70 | @Override
71 | public void onClick(View v) {
72 | startActivity(new Intent(MainActivity.this, CustomSSIVActivity.class));
73 | }
74 | });
75 | findViewById(R.id.mRecycler).setOnClickListener(new View.OnClickListener() {
76 | @Override
77 | public void onClick(View v) {
78 | startActivity(new Intent(MainActivity.this, RecyclerViewActivity.class));
79 | }
80 | });
81 | findViewById(R.id.mImageTypes).setOnClickListener(new View.OnClickListener() {
82 | @Override
83 | public void onClick(View v) {
84 | startActivity(new Intent(MainActivity.this, ImageTypesActivity.class));
85 | }
86 | });
87 | findViewById(R.id.mSharedTransitionGlide).setOnClickListener(new View.OnClickListener() {
88 | @Override
89 | public void onClick(View v) {
90 | startActivity(new Intent(MainActivity.this, FirstAnimGlideActivity.class));
91 | }
92 | });
93 | findViewById(R.id.mSharedTransitionFresco).setOnClickListener(new View.OnClickListener() {
94 | @Override
95 | public void onClick(View v) {
96 | startActivity(new Intent(MainActivity.this, FirstAnimFrescoActivity.class));
97 | }
98 | });
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/piasy/biv/example/MySSIV.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2018 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.biv.example;
26 |
27 | import android.content.Context;
28 | import android.util.AttributeSet;
29 | import android.util.Log;
30 | import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView;
31 |
32 | /**
33 | * Created by Piasy{github.com/Piasy} on 27/06/2017.
34 | */
35 |
36 | public class MySSIV extends SubsamplingScaleImageView {
37 | public MySSIV(final Context context, final AttributeSet attr) {
38 | super(context, attr);
39 |
40 | Log.d("MySSIV", "cotr 1");
41 | }
42 |
43 | public MySSIV(final Context context) {
44 | super(context);
45 |
46 | Log.d("MySSIV", "cotr 2");
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/piasy/biv/example/RecyclerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.github.piasy.biv.example;
2 |
3 | import android.net.Uri;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import androidx.recyclerview.widget.RecyclerView;
8 | import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView;
9 | import com.github.piasy.biv.indicator.progresspie.ProgressPieIndicator;
10 | import com.github.piasy.biv.view.BigImageView;
11 | import com.github.piasy.biv.view.GlideImageViewFactory;
12 | import com.github.piasy.biv.view.ImageViewFactory;
13 | import java.util.List;
14 |
15 | public class RecyclerAdapter extends RecyclerView.Adapter {
16 |
17 | private List imageUrls;
18 | private ImageViewFactory viewFactory = new GlideImageViewFactory();
19 |
20 | public RecyclerAdapter(List imageUrls) {
21 | this.imageUrls = imageUrls;
22 | }
23 |
24 | @Override
25 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
26 | View view = LayoutInflater.from(parent.getContext())
27 | .inflate(R.layout.item_recycler_view, parent, false);
28 | return new ViewHolder(view);
29 | }
30 |
31 | @Override
32 | public void onBindViewHolder(ViewHolder holder, int position) {
33 | holder.bind(imageUrls.get(position));
34 | }
35 |
36 | @Override
37 | public int getItemCount() {
38 | return imageUrls.size();
39 | }
40 |
41 | @Override
42 | public void onViewRecycled(ViewHolder holder) {
43 | super.onViewRecycled(holder);
44 | holder.clear();
45 | }
46 |
47 | @Override
48 | public void onViewAttachedToWindow(ViewHolder holder) {
49 | super.onViewAttachedToWindow(holder);
50 | if (holder.hasNoImage()) {
51 | holder.rebind();
52 | }
53 | }
54 |
55 | class ViewHolder extends RecyclerView.ViewHolder {
56 |
57 | private BigImageView itemImage;
58 | private String imageUrl;
59 |
60 | ViewHolder(View itemView) {
61 | super(itemView);
62 | itemImage = itemView.findViewById(R.id.itemImage);
63 | itemImage.setProgressIndicator(new ProgressPieIndicator());
64 | itemImage.setTapToRetry(true);
65 | itemImage.setImageViewFactory(viewFactory);
66 | }
67 |
68 | void bind(String imageUrl) {
69 | this.imageUrl = imageUrl;
70 | itemImage.showImage(Uri.parse(imageUrl));
71 | }
72 |
73 | void rebind() {
74 | itemImage.showImage(Uri.parse(imageUrl));
75 | }
76 |
77 | void clear() {
78 | SubsamplingScaleImageView ssiv = itemImage.getSSIV();
79 | if (ssiv != null) {
80 | ssiv.recycle();
81 | }
82 | }
83 |
84 | boolean hasNoImage() {
85 | SubsamplingScaleImageView ssiv = itemImage.getSSIV();
86 | return ssiv == null || !ssiv.hasImage();
87 | }
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/piasy/biv/example/RecyclerViewActivity.java:
--------------------------------------------------------------------------------
1 | package com.github.piasy.biv.example;
2 |
3 | import android.os.Bundle;
4 | import androidx.annotation.Nullable;
5 | import androidx.appcompat.app.AppCompatActivity;
6 | import androidx.recyclerview.widget.LinearLayoutManager;
7 | import androidx.recyclerview.widget.LinearSnapHelper;
8 | import androidx.recyclerview.widget.RecyclerView;
9 | import com.github.piasy.biv.BigImageViewer;
10 | import com.github.piasy.biv.example.glide.SampleCustomImageSizeModel;
11 | import com.github.piasy.biv.loader.glide.GlideCustomImageLoader;
12 | import java.util.ArrayList;
13 | import java.util.List;
14 |
15 | public class RecyclerViewActivity extends AppCompatActivity {
16 |
17 | @Override
18 | protected void onCreate(@Nullable Bundle savedInstanceState) {
19 | super.onCreate(savedInstanceState);
20 |
21 | BigImageViewer.initialize(GlideCustomImageLoader.with(getApplicationContext(), SampleCustomImageSizeModel.class));
22 |
23 | setContentView(R.layout.activity_recycler_view);
24 |
25 | configRecycler();
26 | }
27 |
28 | @Override
29 | protected void onDestroy() {
30 | super.onDestroy();
31 |
32 | BigImageViewer.imageLoader().cancelAll();
33 | }
34 |
35 | private void configRecycler() {
36 | final List imageUrlsList = new ArrayList<>();
37 |
38 | imageUrlsList.add(
39 | "https://upload.wikimedia.org/wikipedia/commons/3/3f/Francisco_de_Goya_y_Lucientes_-_Los_fusilamientos_del_tres_de_mayo_-_1814.jpg");
40 | imageUrlsList.add(
41 | "https://mathiasbynens.be/demo/animated-webp-supported.webp");
42 | imageUrlsList.add(
43 | "https://upload.wikimedia.org/wikipedia/commons/9/99/Las_Meninas_01.jpg");
44 | imageUrlsList.add(
45 | "https://upload.wikimedia.org/wikipedia/commons/2/2c/Rotating_earth_%28large%29.gif");
46 | imageUrlsList.add(
47 | "https://upload.wikimedia.org/wikipedia/commons/f/f1/El_caballero_de_la_mano_en_el_pecho.jpg");
48 | imageUrlsList.add(
49 | "https://upload.wikimedia.org/wikipedia/commons/a/aa/SmallFullColourGIF.gif");
50 | imageUrlsList.add(
51 | "https://upload.wikimedia.org/wikipedia/commons/6/62/The_Garden_of_Earthly_Delights_by_Bosch_High_Resolution_2.jpg");
52 | imageUrlsList.add(
53 | "https://upload.wikimedia.org/wikipedia/commons/f/fb/La_Anunciaci%C3%B3n_%28Fra_Angelico-Prado%29.jpg");
54 | imageUrlsList.add(
55 | "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d2/Carlos_V_en_M%C3%BChlberg%2C_by_Titian%2C_from_Prado_in_Google_Earth.jpg/3000px-Carlos_V_en_M%C3%BChlberg%2C_by_Titian%2C_from_Prado_in_Google_Earth.jpg");
56 | imageUrlsList.add(
57 | "https://upload.wikimedia.org/wikipedia/commons/b/bb/Rembrandt_Harmensz._van_Rijn_014.jpg");
58 | imageUrlsList.add(
59 | "https://upload.wikimedia.org/wikipedia/commons/b/b2/Peter_Paul_Rubens_-_The_Three_Graces%2C_1635.jpg");
60 | imageUrlsList.add(
61 | "https://upload.wikimedia.org/wikipedia/commons/1/16/Raffael_048.jpg");
62 | imageUrlsList.add(
63 | "https://upload.wikimedia.org/wikipedia/commons/d/d4/Crucifixi%C3%B3n_Juan_de_Flandes.jpg");
64 | imageUrlsList.add(
65 | "https://upload.wikimedia.org/wikipedia/commons/d/da/Albrecht_D%C3%BCrer_103.jpg");
66 | imageUrlsList.add(
67 | "https://upload.wikimedia.org/wikipedia/commons/1/1a/Weyden_Deposition.jpg");
68 | imageUrlsList.add(
69 | "https://upload.wikimedia.org/wikipedia/commons/b/b6/El_sue%C3%B1o_de_Jacob%2C_por_Jos%C3%A9_de_Ribera.jpg");
70 | imageUrlsList.add(
71 | "https://upload.wikimedia.org/wikipedia/commons/8/8b/Giovanni_Battista_Tiepolo_022.jpg");
72 |
73 | RecyclerView recycler = findViewById(R.id.recycler);
74 | recycler.setLayoutManager(
75 | new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
76 | recycler.setAdapter(new RecyclerAdapter(imageUrlsList));
77 |
78 | LinearSnapHelper snapHelper = new LinearSnapHelper();
79 | snapHelper.attachToRecyclerView(recycler);
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/piasy/biv/example/ScaleTypeActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2018 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | package com.github.piasy.biv.example;
26 |
27 | import android.net.Uri;
28 | import android.os.Bundle;
29 | import android.text.TextUtils;
30 | import android.view.View;
31 | import android.widget.Spinner;
32 | import androidx.appcompat.app.AppCompatActivity;
33 | import com.github.piasy.biv.BigImageViewer;
34 | import com.github.piasy.biv.loader.fresco.FrescoImageLoader;
35 | import com.github.piasy.biv.view.BigImageView;
36 |
37 | public class ScaleTypeActivity extends AppCompatActivity {
38 |
39 | private Uri mSmallImage = Uri.parse(
40 | "http://img0.imgtn.bdimg.com/it/u=1404334591,1869466979&fm=21&gp=0.jpg");
41 | private Uri mMediumImage = Uri.parse(
42 | "http://img4.duitang.com/uploads/item/201507/12/20150712205801_UGTdu.png");
43 | private Uri mBigImage = Uri.parse(
44 | "http://h.hiphotos.baidu.com/zhidao/pic/item/1b4c510fd9f9d72afff98f28d22a2834349bbb62.jpg");
45 |
46 | private Spinner mScaleType;
47 | private Spinner mImageSize;
48 | private BigImageView mBigImageView;
49 |
50 | @Override
51 | protected void onCreate(Bundle savedInstanceState) {
52 | super.onCreate(savedInstanceState);
53 |
54 | BigImageViewer.initialize(FrescoImageLoader.with(getApplicationContext()));
55 |
56 | setContentView(R.layout.activity_scale_type);
57 |
58 | mScaleType = findViewById(R.id.mScaleType);
59 | mImageSize = findViewById(R.id.mImageSize);
60 | mBigImageView = findViewById(R.id.mBigImage);
61 |
62 | findViewById(R.id.mBtnLoad).setOnClickListener(new View.OnClickListener() {
63 | @Override
64 | public void onClick(View v) {
65 | setScaleType();
66 | showImage();
67 | }
68 | });
69 | }
70 |
71 | @Override
72 | protected void onDestroy() {
73 | super.onDestroy();
74 |
75 | BigImageViewer.imageLoader().cancelAll();
76 | }
77 |
78 | private void setScaleType() {
79 | String scaleType = (String) mScaleType.getSelectedItem();
80 | if (TextUtils.equals(scaleType, getString(R.string.scale_center_crop))) {
81 | mBigImageView.setInitScaleType(BigImageView.INIT_SCALE_TYPE_CENTER_CROP);
82 | } else if (TextUtils.equals(scaleType, getString(R.string.scale_center_inside))) {
83 | mBigImageView.setInitScaleType(BigImageView.INIT_SCALE_TYPE_CENTER_INSIDE);
84 | } else if (TextUtils.equals(scaleType, getString(R.string.scale_custom))) {
85 | mBigImageView.setInitScaleType(BigImageView.INIT_SCALE_TYPE_CUSTOM);
86 | } else if (TextUtils.equals(scaleType, getString(R.string.scale_start))) {
87 | mBigImageView.setInitScaleType(BigImageView.INIT_SCALE_TYPE_START);
88 | }
89 | }
90 |
91 | private void showImage() {
92 | String imageSize = (String) mImageSize.getSelectedItem();
93 | if (TextUtils.equals(imageSize, getString(R.string.size_small))) {
94 | mBigImageView.showImage(mSmallImage);
95 | } else if (TextUtils.equals(imageSize, getString(R.string.size_medium))) {
96 | mBigImageView.showImage(mMediumImage);
97 | } else if (TextUtils.equals(imageSize, getString(R.string.size_big))) {
98 | mBigImageView.showImage(mBigImage);
99 | }
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/piasy/biv/example/SecondAnimActivity.kt:
--------------------------------------------------------------------------------
1 | package com.github.piasy.biv.example
2 |
3 | import android.app.Activity
4 | import android.app.SharedElementCallback
5 | import android.content.Intent
6 | import android.os.Build
7 | import android.os.Bundle
8 | import android.transition.Transition
9 | import android.util.Log
10 | import android.view.MenuItem
11 | import android.view.View
12 | import android.widget.ImageView
13 | import android.widget.Toast
14 | import androidx.appcompat.app.AppCompatActivity
15 | import androidx.core.app.ActivityOptionsCompat
16 | import androidx.core.net.toUri
17 | import com.facebook.drawee.backends.pipeline.Fresco
18 | import com.facebook.drawee.view.SimpleDraweeView
19 | import com.github.piasy.biv.BigImageViewer
20 | import com.github.piasy.biv.loader.fresco.FrescoImageLoader
21 | import com.github.piasy.biv.loader.glide.GlideImageLoader
22 | import com.github.piasy.biv.view.BigImageView
23 | import com.github.piasy.biv.view.FrescoImageViewFactory
24 | import com.github.piasy.biv.view.GlideImageViewFactory
25 | import com.github.piasy.biv.view.ImageShownCallback
26 |
27 | class SecondAnimActivity : AppCompatActivity() {
28 |
29 | companion object {
30 |
31 | private const val THUMB_PARAM = "intent_param_thumbnail"
32 | private const val SOURCE_PARAM = "intent_param_source"
33 |
34 | private const val FLAG_USEGLIDE = "intent_param_flag_use_glide"
35 | private const val FLAG_USEFRESCO = "intent_param_flag_use_fresco"
36 | private const val FLAG_USEVIEWFACTORY = "intent_param_flag_use_view_factory"
37 |
38 | fun start(activity: Activity, imageView: ImageView,
39 | thumbUrl: String, sourceUrl: String,
40 | useGlide: Boolean, useFresco: Boolean, useViewFactory: Boolean) {
41 |
42 | val intent = Intent(activity, SecondAnimActivity::class.java)
43 | intent.putExtra(THUMB_PARAM, thumbUrl)
44 | intent.putExtra(SOURCE_PARAM, sourceUrl)
45 |
46 | intent.putExtra(FLAG_USEGLIDE, useGlide)
47 | intent.putExtra(FLAG_USEFRESCO, useFresco)
48 | intent.putExtra(FLAG_USEVIEWFACTORY, useViewFactory)
49 |
50 | val transitionName = activity.resources.getString(R.string.transition_name)
51 | val options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, imageView, transitionName)
52 | val bundle = options.toBundle()
53 |
54 | if (Build.VERSION.SDK_INT >= 16) {
55 |
56 | if (Build.VERSION.SDK_INT >= 21) {
57 | activity.setExitSharedElementCallback(object : SharedElementCallback() {
58 |
59 | override fun onSharedElementEnd(
60 | names: MutableList?,
61 | elements: MutableList?,
62 | snapshots: MutableList?
63 | ) {
64 | super.onSharedElementEnd(names, elements, snapshots)
65 |
66 | elements?.forEach {
67 | if (it is SimpleDraweeView) {
68 | it.post { it.setVisibility(View.VISIBLE) }
69 | }
70 | }
71 | }
72 | })
73 | }
74 |
75 | activity.startActivity(intent, bundle)
76 | } else {
77 | Log.i("SecondAnimActivity", "Animation not available for this SDK Versions.")
78 | }
79 | }
80 | }
81 |
82 | private val thumbUrl by lazy { intent.getStringExtra(THUMB_PARAM)!! }
83 | private val sourceUrl by lazy { intent.getStringExtra(SOURCE_PARAM)!! }
84 |
85 | private val useGlide by lazy { intent.getBooleanExtra(FLAG_USEGLIDE, true) }
86 | private val useFresco by lazy { intent.getBooleanExtra(FLAG_USEFRESCO, false) }
87 | private val useViewFactory by lazy { intent.getBooleanExtra(FLAG_USEVIEWFACTORY, false) }
88 |
89 | private val biv by lazy { findViewById(R.id.sourceView) }
90 |
91 | override fun onCreate(savedInstanceState: Bundle?) {
92 | Fresco.initialize(this)
93 |
94 | super.onCreate(savedInstanceState)
95 |
96 | if (useGlide) {
97 | BigImageViewer.initialize(GlideImageLoader.with(applicationContext))
98 | }
99 |
100 | if (useFresco) {
101 | BigImageViewer.initialize(FrescoImageLoader.with(applicationContext))
102 | }
103 |
104 | setContentView(R.layout.activity_anim_second)
105 |
106 | if (Build.VERSION.SDK_INT >= 21) {
107 |
108 | setEnterSharedElementCallback(object : SharedElementCallback() {
109 |
110 | override fun onSharedElementEnd(
111 | names: MutableList?,
112 | elements: MutableList?,
113 | snapshots: MutableList?
114 | ) {
115 | super.onSharedElementEnd(names, elements, snapshots)
116 |
117 | elements?.forEach {
118 | if (it is SimpleDraweeView) {
119 | it.post { it.setVisibility(View.VISIBLE) }
120 | }
121 | }
122 | }
123 | })
124 |
125 | window.sharedElementEnterTransition.addListener(object : Transition.TransitionListener {
126 |
127 | override fun onTransitionStart(transition: Transition?) {}
128 | override fun onTransitionCancel(transition: Transition?) {}
129 | override fun onTransitionPause(transition: Transition?) {}
130 | override fun onTransitionResume(transition: Transition?) {}
131 |
132 | override fun onTransitionEnd(transition: Transition?) {
133 |
134 | biv.loadMainImageNow()
135 | }
136 | })
137 | }
138 |
139 | if (useGlide && useViewFactory) {
140 | biv.setImageViewFactory(GlideImageViewFactory())
141 | }
142 |
143 | if (useFresco && useViewFactory) {
144 | biv.setImageViewFactory(FrescoImageViewFactory())
145 | }
146 |
147 | biv.setImageShownCallback(object : ImageShownCallback {
148 |
149 | override fun onThumbnailShown() {
150 | showToast("onThumbnailShown triggered!")
151 | }
152 |
153 | override fun onMainImageShown() {
154 | showToast("onMainImageShown triggered!")
155 | }
156 | })
157 |
158 | biv.showImage(thumbUrl.toUri(), sourceUrl.toUri(), true)
159 | }
160 |
161 | override fun onOptionsItemSelected(item: MenuItem): Boolean {
162 |
163 | when(item.itemId) {
164 | android.R.id.home -> {
165 | supportFinishAfterTransition()
166 | return true
167 | }
168 | }
169 |
170 | return super.onOptionsItemSelected(item)
171 | }
172 |
173 | private fun showToast(text: String) {
174 | Toast.makeText(this, text, Toast.LENGTH_SHORT).show()
175 | }
176 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/github/piasy/biv/example/Utils.java:
--------------------------------------------------------------------------------
1 | package com.github.piasy.biv.example;
2 |
3 | import android.content.Context;
4 | import android.text.TextUtils;
5 | import android.util.Log;
6 |
7 | import com.github.piasy.biv.utils.IOUtils;
8 |
9 | import java.io.BufferedReader;
10 | import java.io.IOException;
11 | import java.io.InputStreamReader;
12 | import java.lang.reflect.Field;
13 |
14 | public class Utils {
15 |
16 | public static final String TAG = "BIV-App";
17 |
18 | public static void fixLeakCanary696(Context context) {
19 | if (!isEmui()) {
20 | Log.w(TAG, "not emui");
21 | return;
22 | }
23 | try {
24 | Class clazz = Class.forName("android.gestureboost.GestureBoostManager");
25 | Log.w(TAG, "clazz " + clazz);
26 |
27 | Field _sGestureBoostManager = clazz.getDeclaredField("sGestureBoostManager");
28 | _sGestureBoostManager.setAccessible(true);
29 | Field _mContext = clazz.getDeclaredField("mContext");
30 | _mContext.setAccessible(true);
31 |
32 | Object sGestureBoostManager = _sGestureBoostManager.get(null);
33 | if (sGestureBoostManager != null) {
34 | _mContext.set(sGestureBoostManager, context);
35 | }
36 | } catch (Exception ignored) {
37 | ignored.printStackTrace();
38 | }
39 | }
40 |
41 | private static boolean isEmui() {
42 | return !TextUtils.isEmpty(getSystemProperty("ro.build.version.emui"));
43 | }
44 |
45 | private static String getSystemProperty(String propName) {
46 | String line;
47 | BufferedReader input = null;
48 | try {
49 | Process p = Runtime.getRuntime().exec("getprop " + propName);
50 | input = new BufferedReader(new InputStreamReader(p.getInputStream(), "UTF-8"), 1024);
51 | line = input.readLine();
52 | input.close();
53 | } catch (IOException ex) {
54 | Log.w(TAG, "Unable to read sysprop " + propName, ex);
55 | return null;
56 | } finally {
57 | IOUtils.closeQuietly(input);
58 | }
59 | return line;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/piasy/biv/example/glide/CustomImageSizeModel.java:
--------------------------------------------------------------------------------
1 | package com.github.piasy.biv.example.glide;
2 |
3 | import com.github.piasy.biv.loader.glide.GlideModel;
4 |
5 | public interface CustomImageSizeModel extends GlideModel {
6 | String requestCustomSizeUrl(Integer width, Integer height);
7 | }
8 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/piasy/biv/example/glide/CustomImageSizeUrlLoader.java:
--------------------------------------------------------------------------------
1 | package com.github.piasy.biv.example.glide;
2 |
3 | import androidx.annotation.NonNull;
4 | import androidx.annotation.Nullable;
5 | import com.bumptech.glide.load.Options;
6 | import com.bumptech.glide.load.model.GlideUrl;
7 | import com.bumptech.glide.load.model.ModelCache;
8 | import com.bumptech.glide.load.model.ModelLoader;
9 | import com.bumptech.glide.load.model.stream.BaseGlideUrlLoader;
10 | import java.io.InputStream;
11 |
12 | public class CustomImageSizeUrlLoader extends BaseGlideUrlLoader {
13 |
14 | public CustomImageSizeUrlLoader(ModelLoader concreteLoader,
15 | @Nullable ModelCache modelCache) {
16 | super(concreteLoader, modelCache);
17 | }
18 |
19 | @Override
20 | protected String getUrl(CustomImageSizeModel model, int width, int height, Options options) {
21 | return model.requestCustomSizeUrl(width, height);
22 | }
23 |
24 | @Override
25 | public boolean handles(@NonNull CustomImageSizeModel customImageSizeModel) {
26 | return true;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/piasy/biv/example/glide/CustomImageSizeUrlLoaderFactory.java:
--------------------------------------------------------------------------------
1 | package com.github.piasy.biv.example.glide;
2 |
3 | import androidx.annotation.NonNull;
4 | import com.bumptech.glide.load.model.GlideUrl;
5 | import com.bumptech.glide.load.model.ModelCache;
6 | import com.bumptech.glide.load.model.ModelLoader;
7 | import com.bumptech.glide.load.model.ModelLoaderFactory;
8 | import com.bumptech.glide.load.model.MultiModelLoaderFactory;
9 | import java.io.InputStream;
10 |
11 | public class CustomImageSizeUrlLoaderFactory implements ModelLoaderFactory {
12 |
13 | private ModelCache modelCache = new ModelCache(500);
14 |
15 | @NonNull
16 | @Override
17 | public ModelLoader build(@NonNull MultiModelLoaderFactory multiFactory) {
18 | ModelLoader modelLoader = multiFactory.build(GlideUrl.class, InputStream.class);
19 | return new CustomImageSizeUrlLoader(modelLoader, modelCache);
20 | }
21 |
22 | @Override
23 | public void teardown() {
24 |
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/piasy/biv/example/glide/SampleCustomImageSizeModel.java:
--------------------------------------------------------------------------------
1 | package com.github.piasy.biv.example.glide;
2 |
3 | import android.net.Uri;
4 |
5 | public class SampleCustomImageSizeModel implements CustomImageSizeModel {
6 |
7 | private Uri baseImageUrl;
8 |
9 | public void setBaseImageUrl(Uri baseImageUrl) {
10 | this.baseImageUrl = baseImageUrl;
11 | }
12 |
13 | @Override
14 | public String requestCustomSizeUrl(Integer width, Integer height) {
15 | if (baseImageUrl != null) {
16 | return baseImageUrl
17 | .buildUpon()
18 | .appendQueryParameter("width", width.toString())
19 | .appendQueryParameter("height", height.toString())
20 | .build()
21 | .toString();
22 | }
23 | throw new RuntimeException("You have to set the base image url first");
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_cloud_off_white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piasy/BigImageViewer/067f8eb86ee522190ab473f36a1b0de11c21a663/app/src/main/res/drawable-hdpi/ic_cloud_off_white.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-ldpi/ic_cloud_off_white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piasy/BigImageViewer/067f8eb86ee522190ab473f36a1b0de11c21a663/app/src/main/res/drawable-ldpi/ic_cloud_off_white.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_cloud_off_white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piasy/BigImageViewer/067f8eb86ee522190ab473f36a1b0de11c21a663/app/src/main/res/drawable-mdpi/ic_cloud_off_white.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_cloud_off_white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piasy/BigImageViewer/067f8eb86ee522190ab473f36a1b0de11c21a663/app/src/main/res/drawable-xhdpi/ic_cloud_off_white.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_cloud_off_white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piasy/BigImageViewer/067f8eb86ee522190ab473f36a1b0de11c21a663/app/src/main/res/drawable-xxhdpi/ic_cloud_off_white.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_cloud_off_white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piasy/BigImageViewer/067f8eb86ee522190ab473f36a1b0de11c21a663/app/src/main/res/drawable-xxxhdpi/ic_cloud_off_white.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_anim_first_fresco.xml:
--------------------------------------------------------------------------------
1 |
2 |
25 |
26 |
32 |
33 |
44 |
45 |
49 |
50 |
58 |
59 |
66 |
67 |
68 |
69 |
76 |
77 |
86 |
87 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_anim_first_glide.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
20 |
21 |
25 |
26 |
34 |
35 |
42 |
43 |
44 |
45 |
52 |
53 |
62 |
63 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_anim_second.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
21 |
22 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_big_image.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
18 |
19 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_custom_ssiv.xml:
--------------------------------------------------------------------------------
1 |
2 |
25 |
26 |
32 |
33 |
38 |
39 |
45 |
46 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_image_type.xml:
--------------------------------------------------------------------------------
1 |
2 |
25 |
26 |
36 |
37 |
43 |
44 |
52 |
53 |
59 |
60 |
66 |
67 |
68 |
76 |
77 |
83 |
84 |
90 |
91 |
92 |
99 |
100 |
101 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
12 |
17 |
24 |
31 |
38 |
45 |
52 |
59 |
66 |
73 |
80 |
87 |
88 |
89 |
90 |
91 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_recycler_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_scale_type.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
26 |
27 |
36 |
37 |
46 |
47 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_long_image.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
16 |
17 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_recycler_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piasy/BigImageViewer/067f8eb86ee522190ab473f36a1b0de11c21a663/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piasy/BigImageViewer/067f8eb86ee522190ab473f36a1b0de11c21a663/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piasy/BigImageViewer/067f8eb86ee522190ab473f36a1b0de11c21a663/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piasy/BigImageViewer/067f8eb86ee522190ab473f36a1b0de11c21a663/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piasy/BigImageViewer/067f8eb86ee522190ab473f36a1b0de11c21a663/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | BIV
3 |
4 | fresco loader
5 | glide loader
6 | long image
7 | scale type
8 | image loader callback
9 | Custom SSIV
10 | Recycler
11 | image types
12 | shared elem. transition glide
13 | shared elem. transition fresco
14 |
15 | Load
16 |
17 | Use Glide
18 | Use Fresco
19 |
20 | Use view factory
21 |
22 | Image Loader:
23 | Image Type:
24 | First Activity:
25 | Second Activity:
26 |
27 | shared_transition_element_view
28 |
29 | Thumbnail Image
30 | Source Image
31 |
32 | Actions:
33 | recognize qr code
34 | save to gallery
35 |
36 | centerCrop
37 | centerInside
38 | custom
39 | start
40 |
41 | - @string/scale_center_crop
42 | - @string/scale_center_inside
43 | - @string/scale_custom
44 | - @string/scale_start
45 |
46 |
47 | small
48 | medium
49 | big
50 |
51 | - @string/size_small
52 | - @string/size_medium
53 | - @string/size_big
54 |
55 |
56 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/art/Logotype_primary.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piasy/BigImageViewer/067f8eb86ee522190ab473f36a1b0de11c21a663/art/Logotype_primary.png
--------------------------------------------------------------------------------
/art/android_studio_memory_monitor.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piasy/BigImageViewer/067f8eb86ee522190ab473f36a1b0de11c21a663/art/android_studio_memory_monitor.png
--------------------------------------------------------------------------------
/art/biv_gif_support.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piasy/BigImageViewer/067f8eb86ee522190ab473f36a1b0de11c21a663/art/biv_gif_support.gif
--------------------------------------------------------------------------------
/art/fresco_big_image_viewer_demo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piasy/BigImageViewer/067f8eb86ee522190ab473f36a1b0de11c21a663/art/fresco_big_image_viewer_demo.gif
--------------------------------------------------------------------------------
/buckw:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | #########################################################################
4 | ##
5 | ## Buck wrapper script to invoke okbuck when needed, before running buck
6 | ##
7 | ## Created by OkBuck Gradle Plugin on : Sat Dec 03 15:41:27 CST 2016
8 | ##
9 | #########################################################################
10 |
11 | WORKING_DIR=$(pwd)
12 |
13 | red=`tput setab 1 2>/dev/null || true`
14 | yellow=`tput setab 3 2>/dev/null || true`
15 | green=`tput setab 2 2>/dev/null || true`
16 | blue=`tput setab 4 2>/dev/null || true`
17 | reset=`tput sgr0 2>/dev/null || true`
18 | bold=`tput bold 2>/dev/null || true`
19 |
20 | die ( ) {
21 | echo
22 | echo "${bold}${red} $* ${reset}"
23 | echo
24 | exit 1
25 | }
26 |
27 | info ( ) {
28 | echo "${bold}${blue} $* ${reset}"
29 | }
30 |
31 | warn ( ) {
32 | echo "${bold}${yellow} $* ${reset}"
33 | }
34 |
35 | success ( ) {
36 | echo
37 | echo "${bold}${green} $* ${reset}"
38 | echo
39 | }
40 |
41 | ensure ( ) {
42 | command -v $1 >/dev/null 2>&1 || die "ERROR: '$1' could be found in your PATH. Please install $1. $2"
43 | }
44 |
45 | jsonq() {
46 | python -c "import sys,json; obj=json.load(sys.stdin); print($1)"
47 | }
48 |
49 | ensure python 'https://www.python.org'
50 | ensure ant 'http://ant.apache.org/'
51 | INSTALLED_WATCHMAN=`command -v watchman`
52 |
53 | DEFAULT_BUCK_REPO="https://github.com/facebook/buck.git"
54 | DEFAULT_BUCK_INSTALL_DIR="$HOME/.gradle/caches/okbuck/buck"
55 | CUSTOM_BUCK_REPO=""
56 | CUSTOM_REMOTE_NAME="custom"
57 | OKBUCK_SUCCESS="$WORKING_DIR/build/okbuck.success"
58 | OKBUCK_DIR=".okbuck"
59 | MAX_DISPLAY_CHANGES=10
60 |
61 | ensureWatch ( ) {
62 | watchman watch-project $WORKING_DIR >/dev/null 2>&1
63 | }
64 |
65 | getToClean ( ) {
66 | ensureWatch
67 |
68 | watchman --output-encoding=json -j 2>&1 <<-EOT
69 | ["query", "$WORKING_DIR", {
70 | "expression": ["allof",
71 | ["type", "f"],
72 | ["anyof",
73 | ["imatch", ".buckconfig.local", "wholename"],
74 | ["imatch", "**/BUCK", "wholename"]
75 | ],
76 | ["not",
77 | ["imatch", ".okbuck/**/BUCK", "wholename"]
78 | ]
79 | ],
80 | "fields": ["name"]
81 | }]
82 | EOT
83 | }
84 |
85 | getChanges ( ) {
86 | ensureWatch
87 |
88 | WATCHED_CHANGES=`watchman --output-encoding=json -j 2>&1 <<-EOT
89 | ["query", "$WORKING_DIR", {
90 | "since": "n:okbuck_trig",
91 | "expression": ["allof",
92 | ["type", "f"],
93 | ["anyof",
94 | ["imatch", "**/*.gradle", "wholename"],
95 | ["imatch", "**/src/**/AndroidManifest.xml", "wholename"],
96 | ["imatch", "**/gradle-wrapper.properties", "wholename"],
97 | ["imatch", "**/lint.xml", "wholename"]
98 | ]
99 | ],
100 | "fields": ["name"]
101 | }]
102 | EOT`
103 | SOURCE_ROOTS=`watchman --output-encoding=json -j 2>&1 <<-EOT
104 | ["query", ".", {
105 | "since": "n:okbuck_source_roots",
106 | "expression": ["allof",
107 | ["type", "d"],
108 | ["anyof",
109 | ["imatch", "**/src/**/java", "wholename"],
110 | ["imatch", "**/src/**/res", "wholename"],
111 | ["imatch", "**/src/**/resources", "wholename"]
112 | ]
113 | ],
114 | "fields": ["new", "exists", "name"]
115 | }]
116 | EOT`
117 | }
118 |
119 | updateOkBuckSuccess ( ) {
120 | OKBUCK_SUCCESS_DIR=`dirname $OKBUCK_SUCCESS`
121 | mkdir -p $OKBUCK_SUCCESS_DIR
122 | touch "$OKBUCK_SUCCESS"
123 | }
124 |
125 | runOkBuck ( ) {
126 | info "RUNNING OKBUCK..."
127 | echo
128 |
129 | if [[ ! -z "$INSTALLED_WATCHMAN" ]]; then
130 | getToClean | jsonq '"\n".join(obj["files"])' | xargs rm
131 | info "DELETED OLD BUCK FILES"
132 | EXTRA_OKBUCK_ARGS="-xokbuckClean $EXTRA_OKBUCK_ARGS"
133 | fi
134 |
135 | rm -f $OKBUCK_SUCCESS
136 | ( $WORKING_DIR/gradlew -p $WORKING_DIR okbuck -Dokbuck.wrapper=true $EXTRA_OKBUCK_ARGS --stacktrace --offline &&
137 | updateOkBuckSuccess && success "PROCEEDING WITH BUCK" ) || die "OKBUCK FAILED"
138 | }
139 |
140 | watchmanWorkflow ( ) {
141 | # Get list of changed files since last time by querying watchman
142 | getChanges
143 |
144 | # Format list for simpler output
145 | CHANGES=$(echo $WATCHED_CHANGES | jsonq '" ".join(obj["files"])')
146 | NEW_OR_DELETED_SOURCE_ROOTS=$(echo $SOURCE_ROOTS | jsonq '" ".join([f["name"] for f in obj["files"] if (not f["exists"] or f["new"])])')
147 | NUM_CHANGES=$(echo $CHANGES $NEW_OR_DELETED_SOURCE_ROOTS | wc -w)
148 |
149 | if [[ $NUM_CHANGES -gt 0 ]]; then
150 | info "CHANGES DETECTED IN:"
151 | echo $CHANGES $NEW_OR_DELETED_SOURCE_ROOTS | tr ' ' '\n' | head -n $MAX_DISPLAY_CHANGES
152 | if [[ $NUM_CHANGES -gt $MAX_DISPLAY_CHANGES ]]; then
153 | DIFF=`expr $NUM_CHANGES - $MAX_DISPLAY_CHANGES`
154 | echo "...and $DIFF more"
155 | fi
156 | echo
157 | runOkBuck
158 | fi
159 | }
160 |
161 | setupBuckBinary ( ) {
162 | # If no explicit buck binary is set
163 | if [[ -z "$BUCK_BINARY" ]] ; then
164 | # If no buck installation directory is set
165 | if [[ -z "$BUCK_HOME" ]]; then
166 | BUCK_HOME=$DEFAULT_BUCK_INSTALL_DIR
167 | fi
168 |
169 | # Install buck from source if not already available
170 | if [[ ! -d "$BUCK_HOME" ]]; then
171 | warn "BUCK NOT FOUND IN '$BUCK_HOME'. INSTALLING BUCK..."
172 | git clone $DEFAULT_BUCK_REPO $BUCK_HOME
173 | fi
174 |
175 | # Add custom buck remote
176 | if [[ ! -z $CUSTOM_BUCK_REPO ]]; then
177 | cd $BUCK_HOME
178 | REMOTE_EXISTS=$(git remote -v | grep "$CUSTOM_REMOTE_NAME")
179 | if [[ -z "$REMOTE_EXISTS" ]]; then
180 | git remote add $CUSTOM_REMOTE_NAME $CUSTOM_BUCK_REPO
181 | fi
182 | cd $WORKING_DIR
183 | fi
184 |
185 | BUCK_BINARY="$BUCK_HOME/bin/buck"
186 | fi
187 | }
188 |
189 | # Run tasks before buck command
190 | setupBuckRun ( ) {
191 | if [[ ! -z "$SKIP_OKBUCK" ]]; then
192 | :
193 | elif [[ ! -z "$FORCE_OKBUCK" ]]; then
194 | runOkBuck
195 | elif [[ ! -f "$OKBUCK_SUCCESS" ]] || [[ ! -d "$OKBUCK_DIR" ]]; then
196 | warn "NO PREVIOUS SUCCESSFUL OKBUCK RUN"
197 | if [[ ! -z "$INSTALLED_WATCHMAN" ]]; then
198 | getChanges # Prevent watchman from running after this run, since changes would already be accounted for
199 | fi
200 | runOkBuck
201 | elif [[ ! -z "$INSTALLED_WATCHMAN" ]]; then
202 | watchmanWorkflow
203 | else
204 | warn 'ALWAYS RUNNING OKBUCK SINCE WATCHMAN IS NOT INSTALLED'
205 | warn 'INSTALL WATCHMAN FOR FASTER BUILDS'
206 | warn 'https://facebook.github.io/watchman'
207 | echo
208 | runOkBuck
209 | fi
210 |
211 | setupBuckBinary
212 | }
213 |
214 | setupBuckRun
215 |
216 | # Invoke buck binary with arguments
217 | exec "$BUCK_BINARY" "$@"
218 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2018 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
26 |
27 | buildscript {
28 | repositories {
29 | google()
30 | maven {
31 | url "https://plugins.gradle.org/m2/"
32 | }
33 | mavenCentral()
34 | }
35 | dependencies {
36 | classpath 'com.android.tools.build:gradle:7.3.0'
37 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.21"
38 |
39 | // ./gradlew dependencyUpdates
40 | classpath 'com.github.ben-manes:gradle-versions-plugin:0.44.0'
41 |
42 | // ./gradlew publishReleasePublicationToSonatypeRepository
43 | // ./gradlew closeAndReleaseRepository
44 | classpath 'org.jetbrains.dokka:dokka-gradle-plugin:1.7.20'
45 | classpath 'io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.30.0'
46 | }
47 | }
48 |
49 | allprojects {
50 | repositories {
51 | google()
52 | mavenCentral()
53 | maven { url 'https://jitpack.io' }
54 | }
55 | }
56 |
57 | task clean(type: Delete) {
58 | delete rootProject.buildDir
59 | }
60 |
61 | ext {
62 | projectName = 'BigImageViewer'
63 | groupName = 'com.github.piasy'
64 |
65 | artifactDescription = 'Big image viewer supporting pan and zoom, with very little memory ' +
66 | 'usage and full featured image loading choices. Powered by Subsampling Scale ' +
67 | 'Image View, Fresco, Glide, and Picasso.'
68 |
69 | releaseVersionCode = 45
70 | releaseVersionName = '1.9.0'
71 |
72 | PUBLISH_GROUP_ID = groupName
73 | PUBLISH_VERSION = releaseVersionName
74 |
75 | androidCompileSdkVersion = 33
76 | minSdkVersion = 14
77 | targetSdkVersion = 33
78 |
79 | annotationVersion = '1.5.0'
80 |
81 | frescoVersion = '2.6.0'
82 | glideVersion = '4.14.2'
83 | // OkHttp drops support before 5.0 since 3.13.0
84 | okhttpVersion = '3.12.6'
85 | ssivVersion = '3.10.0'
86 | }
87 |
88 | apply plugin: 'io.codearte.nexus-staging'
89 |
--------------------------------------------------------------------------------
/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 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
19 | android.useAndroidX=true
20 | android.enableJetifier=true
21 |
22 | #enable R8
23 | android.enableR8=true
24 | android.enableD8.desugaring=true
25 |
26 | #enables AGP to use gradle workers
27 | android.enableGradleWorkers=true
28 |
--------------------------------------------------------------------------------
/gradle/bintray.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2018 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | import java.text.SimpleDateFormat
25 |
26 | apply plugin: 'com.github.dcendents.android-maven'
27 | apply plugin: "com.jfrog.bintray"
28 |
29 | def siteUrl = "https://github.com/${rootProject.ext.userName}/${rootProject.ext.artifactName}"
30 | def gitUrl = "https://github.com/${rootProject.ext.userName}/${rootProject.ext.artifactName}.git"
31 | def developerInfo = rootProject.ext.developer
32 | def licenseInfo = rootProject.ext.license
33 |
34 | group = rootProject.ext.groupName
35 | version = rootProject.ext.releaseVersionName
36 |
37 | install {
38 | repositories.mavenInstaller {
39 | // This generates POM.xml with proper parameters
40 | pom {
41 | project {
42 | packaging 'aar'
43 | // Add your description here
44 | name rootProject.ext.artifactName
45 | url siteUrl
46 | // Set your license
47 | licenses {
48 | license {
49 | name licenseInfo.name
50 | url licenseInfo.url
51 | }
52 | }
53 | developers {
54 | developer {
55 | id developerInfo.id
56 | name developerInfo.name
57 | email developerInfo.email
58 | }
59 | }
60 | scm {
61 | connection gitUrl
62 | developerConnection gitUrl
63 | url siteUrl
64 | }
65 | }
66 | }
67 | }
68 | }
69 |
70 | task sourcesJar(type: Jar) {
71 | if (project.getPlugins().hasPlugin('com.android.application') ||
72 | project.getPlugins().hasPlugin('com.android.library')) {
73 | from android.sourceSets.main.java.srcDirs
74 | }
75 | classifier = 'sources'
76 | }
77 |
78 | if (project.getPlugins().hasPlugin('com.android.application') ||
79 | project.getPlugins().hasPlugin('com.android.library')) {
80 | task javadoc(type: Javadoc) {
81 | failOnError = false
82 | source = android.sourceSets.main.java.srcDirs
83 | android.compileSdkVersion rootProject.ext.androidCompileSdkVersion
84 | android.buildToolsVersion rootProject.ext.androidBuildToolsVersion
85 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
86 | }
87 | }
88 |
89 | task javadocJar(type: Jar, dependsOn: javadoc) {
90 | classifier = 'javadoc'
91 | from javadoc.destinationDir
92 | }
93 |
94 | artifacts {
95 | archives javadocJar
96 | archives sourcesJar
97 | }
98 |
99 | Properties properties = new Properties()
100 | // for wrapper project structure
101 | File propertyFile = project.rootProject.file('gradle/bintray.properties')
102 | if (propertyFile.exists()) {
103 | properties.load(propertyFile.newDataInputStream())
104 | }
105 |
106 | bintray {
107 | user = properties.getProperty("bintray.user")
108 | key = properties.getProperty("bintray.apikey")
109 | configurations = ['archives'] //When uploading Maven-based publication files
110 | dryRun = false //Whether to run this as dry-run, without deploying
111 | publish = true //If version should be auto published after an upload
112 | pkg {
113 | repo = 'maven'
114 | name = rootProject.ext.artifactName
115 | desc = rootProject.ext.artifactDescription
116 | websiteUrl = siteUrl
117 | issueTrackerUrl = siteUrl + '/issues'
118 | vcsUrl = gitUrl
119 | licenses = [licenseInfo.id]
120 | labels = rootProject.ext.artifactLabels
121 | publicDownloadNumbers = true
122 | //Optional version descriptor
123 | version {
124 | name = rootProject.ext.releaseVersionName //Bintray logical version name
125 | released = new SimpleDateFormat('yyyy-MM-dd\'T\'HH:mm:ss.SSSZZ').format(new Date())
126 | //2 possible values: date in the format of 'yyyy-MM-dd'T'HH:mm:ss.SSSZZ' OR a java.util.Date instance
127 | vcsTag = rootProject.ext.releaseVersionName
128 | }
129 | }
130 | }
131 |
--------------------------------------------------------------------------------
/gradle/publish-maven-central.gradle:
--------------------------------------------------------------------------------
1 | // Credit: https://gist.github.com/zsmb13/bc5957f7d0072742d9c0c2f6b704b3e4
2 |
3 | apply plugin: 'maven-publish'
4 | apply plugin: 'signing'
5 |
6 | task androidSourcesJar(type: Jar) {
7 | archiveClassifier.set('sources')
8 | if (project.plugins.findPlugin("com.android.library")) {
9 | from android.sourceSets.main.java.srcDirs
10 | //from android.sourceSets.main.kotlin.srcDirs
11 | } else {
12 | from sourceSets.main.java.srcDirs
13 | //from sourceSets.main.kotlin.srcDirs
14 | }
15 | }
16 |
17 | artifacts {
18 | archives androidSourcesJar
19 | //archives javadocJar
20 | }
21 |
22 |
23 | group = PUBLISH_GROUP_ID
24 | version = PUBLISH_VERSION
25 |
26 | ext["signing.keyId"] = ''
27 | ext["signing.password"] = ''
28 | ext["signing.secretKeyRingFile"] = ''
29 | ext["ossrhUsername"] = ''
30 | ext["ossrhPassword"] = ''
31 | ext["sonatypeStagingProfileId"] = ''
32 |
33 | File secretPropsFile = project.rootProject.file('local.properties')
34 | if (secretPropsFile.exists()) {
35 | Properties p = new Properties()
36 | p.load(new FileInputStream(secretPropsFile))
37 | p.each { name, value ->
38 | ext[name] = value
39 | }
40 | } else {
41 | ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
42 | ext["signing.password"] = System.getenv('SIGNING_PASSWORD')
43 | ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_SECRET_KEY_RING_FILE')
44 | ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME')
45 | ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD')
46 | ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
47 | }
48 |
49 | publishing {
50 | publications {
51 | release(MavenPublication) {
52 | groupId PUBLISH_GROUP_ID
53 | artifactId project.getName()
54 | version PUBLISH_VERSION
55 |
56 | if (project.plugins.findPlugin("com.android.library")) {
57 | artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
58 | } else {
59 | artifact("$buildDir/libs/${project.getName()}-${version}.jar")
60 | }
61 |
62 | artifact androidSourcesJar
63 |
64 | pom {
65 | name = project.getName()
66 | description = artifactDescription
67 | url = "https://github.com/Piasy/${rootProject.ext.projectName}"
68 | licenses {
69 | license {
70 | name = 'The MIT License (MIT)'
71 | url = 'http://opensource.org/licenses/MIT'
72 | }
73 | }
74 | developers {
75 | developer {
76 | id = 'Piasy'
77 | name = 'Piasy Xu'
78 | email= 'xz4215@gmail.com'
79 | }
80 | }
81 | scm {
82 | connection = "scm:git:github.com/Piasy/${rootProject.ext.projectName}.git"
83 | developerConnection = "scm:git:ssh://github.com/Piasy/${rootProject.ext.projectName}.git"
84 | url = "https://github.com/Piasy/${rootProject.ext.projectName}"
85 | }
86 | withXml {
87 | def dependenciesNode = asNode().appendNode('dependencies')
88 |
89 | project.configurations.implementation.allDependencies.each {
90 | def dependencyNode = dependenciesNode.appendNode('dependency')
91 | dependencyNode.appendNode('groupId', it.group)
92 | dependencyNode.appendNode('artifactId', it.name)
93 | dependencyNode.appendNode('version', it.version)
94 | }
95 | }
96 | }
97 | }
98 | }
99 | repositories {
100 | maven {
101 | name = "sonatype"
102 | url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
103 |
104 | credentials {
105 | username ossrhUsername
106 | password ossrhPassword
107 | }
108 | }
109 | }
110 | }
111 |
112 | signing {
113 | sign publishing.publications
114 | }
115 |
116 | nexusStaging {
117 | packageGroup = PUBLISH_GROUP_ID
118 | stagingProfileId = sonatypeStagingProfileId
119 | username = ossrhUsername
120 | password = ossrhPassword
121 | }
122 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Piasy/BigImageViewer/067f8eb86ee522190ab473f36a1b0de11c21a663/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
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-7.4.2-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2018 Piasy
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 |
25 | include(':app')
26 | include(':BigImageViewer')
27 | include(':FrescoImageLoader')
28 | include(':GlideImageLoader')
29 | include(':FrescoImageViewFactory')
30 | include(':GlideImageViewFactory')
31 | include(':ProgressPieIndicator')
32 |
--------------------------------------------------------------------------------