├── .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 mModel; 11 | 12 | private GlideCustomImageLoader(Context context, OkHttpClient okHttpClient, 13 | Class model) { 14 | super(context, okHttpClient); 15 | mModel = model; 16 | } 17 | 18 | public static GlideCustomImageLoader with(Context context, 19 | Class glideModel) { 20 | return with(context, null, glideModel); 21 | } 22 | 23 | public static GlideCustomImageLoader with(Context context, OkHttpClient okHttpClient, 24 | Class 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 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 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 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 |