├── .github ├── CONTRIBUTING.md └── ISSUE_TEMPLATE.md ├── .gitignore ├── .idea ├── codeStyles │ └── Project.xml ├── dictionaries │ └── saulgoodman.xml ├── inspectionProfiles │ └── Project_Default.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── LICENSE.md ├── README.md ├── art ├── crop_menu_1.png ├── crop_menu_2.png ├── crop_menu_3.png ├── cropping.png ├── ic_launcher.psd ├── kerad_logo.png ├── slide_menu_left.jpg ├── slide_menu_right.jpg └── web_hi_res_512.png ├── build.gradle ├── circle.yml ├── code-quality ├── checkstyle.xml └── custom-lint.xml ├── documentation ├── IMAGE_CROP.md ├── ROUNDED_CORNERS.md ├── THANKS.md └── TOOLING.md ├── gradle.properties ├── gradle ├── code-quality-android.gradle ├── code-quality.gradle ├── maven-2.gradle ├── maven-deployment.gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── projectFilesBackup └── .idea │ └── workspace.xml ├── samples ├── build.gradle ├── lint.xml └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── codeforvictory │ │ └── superimageview │ │ └── samples │ │ └── superimageview │ │ ├── HomeActivity.java │ │ ├── image_cropping │ │ ├── ImageCroppingActivity.java │ │ ├── ImagesPagerAdapter.java │ │ ├── ImagesRecyclerAdapter.java │ │ └── NetworkImageCroppingActivity.java │ │ ├── rounded_corners │ │ ├── Image.java │ │ ├── ImageFactory.java │ │ ├── ImagesRecyclerAdapter.java │ │ └── RoundedCornerImagesActivity.java │ │ └── shared │ │ ├── ImageLocalDataSource.java │ │ ├── LocalImage.java │ │ ├── NetworkImage.java │ │ └── widget │ │ └── VerticalTransparentItemDecorator.java │ └── res │ ├── drawable-xxhdpi │ ├── ball_horizontal.png │ └── ball_vertical.png │ ├── layout │ ├── activity_home.xml │ ├── activity_image_cropping.xml │ ├── activity_images.xml │ ├── item_local_image.xml │ ├── item_network_cropped_image.xml │ └── item_network_rounded_image.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-v19 │ └── styles.xml │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── attrs.xml │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── settings.gradle ├── superimageview-imagecrop ├── CHANGELOG.md ├── build.gradle ├── gradle.properties └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── codeforvictory │ │ └── android │ │ └── superimageview │ │ └── crop │ │ ├── CropType.java │ │ ├── CroppedImage.java │ │ ├── ImageTransformation.java │ │ └── error │ │ └── IllegalTransformationType.java │ └── res │ └── values │ └── attrs.xml ├── superimageview-roundedcorners ├── CHANGELOG.md ├── build.gradle ├── gradle.properties └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── codeforvictory │ │ └── roundedcorners │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── codeforvictory │ │ │ └── android │ │ │ └── superimageview │ │ │ └── roundedcorners │ │ │ ├── Corner.java │ │ │ ├── RoundedBitmapViewDrawable.java │ │ │ ├── RoundedCornerImageViewHook.java │ │ │ ├── RoundedCornersImage.java │ │ │ └── RoundedCornerss.java │ └── res │ │ └── values │ │ └── attrs.xml │ └── test │ └── java │ └── com │ └── codeforvictory │ └── roundedcorners │ └── ExampleUnitTest.java └── superimageview ├── build.gradle ├── gradle.properties └── src └── main ├── AndroidManifest.xml ├── java └── com │ └── codeforvictory │ └── android │ └── superimageview │ ├── Crop.java │ ├── RoundedCorners.java │ └── SuperImageView.java └── res └── values └── attrs.xml /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contibuting 2 | 3 | If you would like to contribute code to [**SuperImageView**](github.com/cesards/SuperImageView) you can do so through GitHub by forking the repository and sending a pull request. 4 | 5 | When submitting code, please make every effort to follow existing conventions and style in order to keep the code as readable as possible. Please also make sure your code compiles by running ./gradlew clean build. Checkstyle failures during compilation indicate errors in your style and can be viewed in files located at */build/report/checkstyle directories. -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | # Issue Template 2 | 3 | Welcome and thank you for reporting an issue and with doing so, improving the library! 4 | 5 | **Important**: Please, before submitting a new issue, verify that your issue hasn't already been reported by 6 | [**searching over all issues**](https://github.com/cesards/SuperImageView/issues). 7 | 8 | 9 | What kind of issue is this? 10 | 11 | - **Help wanted**: If you have questions about how the library works, please, use the `help wanted` [**label**](https://github.com/cesards/SuperImageView/labels) before submitting. 12 | 13 | - **Bug**: If you found a bug, try to spend some time writing a report and a failing test. Bugs with tests get fixed much more easily. [**Here is a good example**](https://gist.github.com/swankjesse/981fcae102f513eb13ed). 14 | 15 | - **Enhancement**: Try to explain what's the problem you are willing to solve. Don't send pull requests with new features' implementations without asking first. 16 | 17 | 18 | ^^^^^ DELETE FROM THIS LINE UP ^^^^^ 19 | 20 | ``` 21 | 22 | REPLACE THIS LINE WITH YOUR STACKTRACE OR OUTPUT FROM LEAKCANARY 23 | 24 | ``` -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Gradle 2 | .gradle/ 3 | gradlew.bat 4 | build/ 5 | local.properties 6 | 7 | # Maven 8 | target 9 | pom.xml.* 10 | release.properties 11 | gen-external-apklibs 12 | 13 | # Eclipse 14 | .classpath 15 | .project 16 | .settings 17 | eclipsebin 18 | proguard/ 19 | 20 | # IntelliJ IDEA 21 | *.iml 22 | *.ipl 23 | *.iws 24 | /.idea/* 25 | 26 | !/.idea/vcs.xml 27 | !/.idea/fileTemplates/ 28 | !/.idea/inspectionProfiles/ 29 | !/.idea/scopes/ 30 | !/.idea/codeStyles/ 31 | !/.idea/encodings.xml 32 | !/.idea/copyright/ 33 | !/.idea/compiler.xml 34 | 35 | 36 | 37 | 38 | idea-classes/ 39 | coverage-error.log 40 | ############################## TO CHECK ############################## 41 | #.idea/markdown-navigator/ # 42 | # .idea/tasks.xml # 43 | # .idea/dictionaries # SHOULD THIS BE INCLUDED IN THE FOLDER? # 44 | # /.idea/assetWizardSettings.xml SHOULD THIS BE EXCLUDED ?? # 45 | # /.idea/navEditor.xml SHOULD THIS BE EXCLUDED ?? # 46 | ###################################################################### 47 | 48 | # Android Studio 49 | captures/ 50 | .navigation/ 51 | 52 | # Android 53 | gen 54 | bin 55 | project.properties 56 | 57 | # Finder 58 | .DS_Store 59 | 60 | # Windows 61 | Thumbs.db 62 | 63 | # Logs 64 | *.log 65 | 66 | # Google Services (e.g. APIs or Firebase) 67 | google-services.json 68 | -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /.idea/dictionaries/saulgoodman.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 37 | 38 | 39 | 40 | 41 | 42 | 44 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2018 César Díez Sánchez - Code For Victory 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

SuperImageView

2 |

Extra features for your ImageView provided in a modularized way

3 | 4 | 5 |

Documentation for v2 coming this week.

6 | 7 | --- 8 | --- 9 | --- 10 | 11 | 12 |

CropImageView

13 |

14 | 15 | 16 | 17 | 18 | 19 |

20 | 21 | An ImageView that supports different kind of cropping rather than the only Android is currently supporting: `centerCrop` 22 | 23 | Using this library, you can crop your desired image by sides described below: 24 | 25 | ![Crop options](https://github.com/cesards/CropImageView/blob/master/art/cropping.png) 26 | 27 | Development idea borns at the point in [Kerad Games] we needed images cropped by somewhere no matter the image size. 28 | 29 | The original images we had to deal with (we wanted the half size of the ball shown whatever screen size), below 30 | 31 | ![Menu Left Side](https://github.com/cesards/CropImageView/blob/master/art/slide_menu_left.jpg) 32 | ![Menu Right Side](https://github.com/cesards/CropImageView/blob/master/art/slide_menu_right.jpg) 33 | 34 | Here are some screenshots what we got thanks to this widget :-) 35 | 36 | ![Menu Post Left Side](https://github.com/cesards/CropImageView/blob/master/art/crop_menu_1.png) 37 | ![Menu Post Right Side](https://github.com/cesards/CropImageView/blob/master/art/crop_menu_2.png) 38 | ![Menu Centered](https://github.com/cesards/CropImageView/blob/master/art/crop_menu_3.png) 39 | 40 | Usage 41 | ----- 42 | ### Step 1 43 | ##### Gradle 44 | ```groovy 45 | dependencies { 46 | compile 'com.cesards.android:cropimageview:1.0.2.1' 47 | } 48 | ``` 49 | ##### Maven 50 | ```xml 51 | 52 | com.cesards.android 53 | CropImageView 54 | 1.0.2 55 | aar 56 | 57 | ``` 58 | ### Step 2 59 | Define in xml: 60 | ```xml 61 | 66 | ``` 67 | where `value` can take values 68 | ```xml 69 | topLeft|centerLeft|bottomLeft|topRight|centerRight|bottomRight|centerTop|centerBottom 70 | ``` 71 | Or in code: 72 | ```java 73 | final CropImageView cropImageView = new CropImageView(CropActivity.this); 74 | final Resources res = getResources(); 75 | cropImageView.setImageDrawable(res.getDrawable(images[position])); 76 | final CropImageView.CropType cropType = imageCrops[position]; 77 | cropImageView.setCropType(cropType); 78 | ``` 79 | Performance tests (using [Hugo](https://github.com/jakeWharton/hugo)) 80 | --------- 81 | 82 | ### Center Crop Sample (ImageView) 83 | ``` 84 | V/TestForegroundImageView﹕ ⇢ setFrame(l=0, t=0, r=1080, b=1557) 85 | V/TestForegroundImageView﹕ ⇠ setFrame [0ms] = true 86 | V/TestForegroundImageView﹕ ⇢ setFrame(l=1080, t=0, r=2160, b=1557) 87 | V/TestForegroundImageView﹕ ⇠ setFrame [0ms] = true 88 | V/TestForegroundImageView﹕ ⇢ setFrame(l=0, t=0, r=1080, b=1557) 89 | V/TestForegroundImageView﹕ ⇠ setFrame [0ms] = false 90 | V/TestForegroundImageView﹕ ⇢ setFrame(l=1080, t=0, r=2160, b=1557) 91 | V/TestForegroundImageView﹕ ⇠ setFrame [0ms] = false 92 | V/TestForegroundImageView﹕ ⇢ setFrame(l=0, t=0, r=1080, b=1701) 93 | V/TestForegroundImageView﹕ ⇠ setFrame [0ms] = true 94 | V/TestForegroundImageView﹕ ⇢ setFrame(l=1080, t=0, r=2160, b=1701) 95 | V/TestForegroundImageView﹕ ⇠ setFrame [0ms] = true` 96 | ``` 97 | 98 | ### Custom Crop Sample (CropImageView) 99 | ``` 100 | V/TestForegroundCropImageView﹕ ⇢ setFrame(l=0, t=0, r=1080, b=1557) 101 | V/TestForegroundCropImageView﹕ ⇠ setFrame [0ms] = true 102 | V/TestForegroundCropImageView﹕ ⇢ setFrame(l=1080, t=0, r=2160, b=1557) 103 | V/TestForegroundCropImageView﹕ ⇠ setFrame [0ms] = true 104 | V/TestForegroundCropImageView﹕ ⇢ setFrame(l=0, t=0, r=1080, b=1557) 105 | V/TestForegroundCropImageView﹕ ⇠ setFrame [0ms] = false 106 | V/TestForegroundCropImageView﹕ ⇢ setFrame(l=1080, t=0, r=2160, b=1557) 107 | V/TestForegroundCropImageView﹕ ⇠ setFrame [0ms] = false 108 | V/TestForegroundCropImageView﹕ ⇢ setFrame(l=0, t=0, r=1080, b=1701) 109 | V/TestForegroundCropImageView﹕ ⇠ setFrame [0ms] = true 110 | V/TestForegroundCropImageView﹕ ⇢ setFrame(l=1080, t=0, r=2160, b=1701) 111 | V/TestForegroundCropImageView﹕ ⇠ setFrame [0ms] = true 112 | ``` 113 | Results: code used does not cause overhead in the UI thread. 114 | 115 | ChangeLog 116 | --------- 117 | * __1.0.2.1 (2015-10-22)__ 118 | * ImageView crashes in devices with API < 18 due to a `@TargetApi` annotation 119 | * __1.0.2 (2015-10-22)__ 120 | * Changed `minSdkVersion` to 7 121 | * Solved a bug related with ImageView and API < 18. 122 | * __1.0.1 (2015-02-17)__ 123 | * Changed Samples UI and removed unused resources. 124 | * Added performance tests to Samples. 125 | * Added code styles for contributions. 126 | * Improved CropImageView widget. Removed `onLayout()` overhead. `ImageView` `onLayout()` is empty, so we only need logic in `setFrame()` method. 127 | * __1.0.0 (2015-02-15)__ 128 | * Initial release. (`minSdkVersion="14"`). 129 | 130 | Developed By 131 | ------------ 132 | * César Díez Sánchez - 133 | 134 | 135 | Follow me on Twitter 136 | 137 | 138 | Follow me on Google Plus 139 | 140 | 141 | Follow me on Medium 142 | 143 | 144 | Follow me on Pinterest 145 | 146 | 147 | Follow me on Dribbble 148 | 149 | 150 | Add me to Linkedin 151 | 152 | 153 | Who's using it 154 | -------------- 155 | * [Golden Manager](https://play.google.com/store/apps/details?id=com.keradgames.goldenmanager) 156 | * [Slipstream Music](https://play.google.com/store/apps/details?id=com.cypher.slipstream&hl=en) 157 | * [Vueling](https://play.google.com/store/apps/details?id=com.mo2o.vueling) 158 | * Does your app use CropImageView? Let me know if you want to be featured in this list :-) 159 | 160 | Do you want to contribute? 161 | -------------------------- 162 | I'm pretty sure you there are some awesome hidden features you need in your daily dev life. Just let me know or collaborate to improve this librar 163 | 164 | I'd like to improve this library with your help, there are some new features to implement waiting for you ;) 165 | 166 | If you want to contribute, you should use [my code styles](https://github.com/cesards/CropImageView/blob/master/codestyles_DogmaLabs.xml) available in the root of the project! 167 | 168 |
169 | 170 |

License

171 | 172 | __The MIT License (MIT)__ 173 | 174 | Copyright (c) 2016 César Díez Sánchez 175 | 176 | Permission is hereby granted, free of charge, to any person obtaining a copy 177 | of this software and associated documentation files (the "Software"), to deal 178 | in the Software without restriction, including without limitation the rights 179 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 180 | copies of the Software, and to permit persons to whom the Software is 181 | furnished to do so, subject to the following conditions: 182 | 183 | The above copyright notice and this permission notice shall be included in all 184 | copies or substantial portions of the Software. 185 | 186 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 187 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 188 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 189 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 190 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 191 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 192 | SOFTWARE. 193 | -------------------------------------------------------------------------------- /art/crop_menu_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesards/SuperImageView/9b161d53bc8642604107b5c848d0614af8f00bb6/art/crop_menu_1.png -------------------------------------------------------------------------------- /art/crop_menu_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesards/SuperImageView/9b161d53bc8642604107b5c848d0614af8f00bb6/art/crop_menu_2.png -------------------------------------------------------------------------------- /art/crop_menu_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesards/SuperImageView/9b161d53bc8642604107b5c848d0614af8f00bb6/art/crop_menu_3.png -------------------------------------------------------------------------------- /art/cropping.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesards/SuperImageView/9b161d53bc8642604107b5c848d0614af8f00bb6/art/cropping.png -------------------------------------------------------------------------------- /art/ic_launcher.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesards/SuperImageView/9b161d53bc8642604107b5c848d0614af8f00bb6/art/ic_launcher.psd -------------------------------------------------------------------------------- /art/kerad_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesards/SuperImageView/9b161d53bc8642604107b5c848d0614af8f00bb6/art/kerad_logo.png -------------------------------------------------------------------------------- /art/slide_menu_left.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesards/SuperImageView/9b161d53bc8642604107b5c848d0614af8f00bb6/art/slide_menu_left.jpg -------------------------------------------------------------------------------- /art/slide_menu_right.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesards/SuperImageView/9b161d53bc8642604107b5c848d0614af8f00bb6/art/slide_menu_right.jpg -------------------------------------------------------------------------------- /art/web_hi_res_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesards/SuperImageView/9b161d53bc8642604107b5c848d0614af8f00bb6/art/web_hi_res_512.png -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // apply plugin: 'com.github.ben-manes.versions' 2 | 3 | buildscript { 4 | ext.versions = [ 5 | 'minSdk': 14, 6 | 'compileSdk': 28, 7 | 'errorProne': '2.3.1', 8 | ] 9 | 10 | repositories { 11 | google() 12 | jcenter() 13 | maven { url 'https://plugins.gradle.org/m2/' } // Error Prone Plugin 14 | } 15 | 16 | dependencies { 17 | classpath 'com.android.tools.build:gradle:3.3.0-alpha13' 18 | classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.16' 19 | classpath 'com.github.ben-manes:gradle-versions-plugin:0.20.0' 20 | } 21 | } 22 | 23 | subprojects { 24 | group = GROUP 25 | version = VERSION_NAME 26 | 27 | repositories { 28 | google() 29 | jcenter() 30 | } 31 | 32 | apply from: "${rootDir}/gradle/code-quality.gradle" 33 | } 34 | 35 | task clean(type: Delete) { 36 | delete rootProject.buildDir 37 | } -------------------------------------------------------------------------------- /circle.yml: -------------------------------------------------------------------------------- 1 | ## Customize the test machine 2 | machine: 3 | environment: 4 | _JAVA_OPTIONS: "-Xms512m -Xmx2048m" 5 | GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xms512m -Xmx2048m -XX:+HeapDumpOnOutOfMemoryError"' 6 | ANDROID_HOME: /usr/local/android-sdk-linux 7 | 8 | dependencies: 9 | pre: 10 | - wget "https://services.gradle.org/distributions/gradle-2.10-bin.zip"; unzip gradle-2.10-bin.zip 11 | - echo y | android update sdk --no-ui --all --filter tool,extra-android-m2repository,extra-android-support,extra-google-google_play_services,extra-google-m2repository,android-23 12 | - echo y | android update sdk --no-ui --all --filter build-tools-23.0.2 13 | 14 | test: 15 | override: 16 | # When running the apk build, unit tests, lint, checkstyle etc sequentially is slow, so we run them in parallel. 17 | # Using bash case statement, choose which command to run on which node (machine). 18 | - ./gradlew assembleDebug 19 | 20 | 21 | 22 | # - ./gradlew clean assembleDebug test lint -------------------------------------------------------------------------------- /code-quality/checkstyle.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 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 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | -------------------------------------------------------------------------------- /code-quality/custom-lint.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /documentation/IMAGE_CROP.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesards/SuperImageView/9b161d53bc8642604107b5c848d0614af8f00bb6/documentation/IMAGE_CROP.md -------------------------------------------------------------------------------- /documentation/ROUNDED_CORNERS.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesards/SuperImageView/9b161d53bc8642604107b5c848d0614af8f00bb6/documentation/ROUNDED_CORNERS.md -------------------------------------------------------------------------------- /documentation/THANKS.md: -------------------------------------------------------------------------------- 1 | https://github.com/square/leakcanary -------------------------------------------------------------------------------- /documentation/TOOLING.md: -------------------------------------------------------------------------------- 1 | # Tooling 2 | 3 | ## Table of contents 4 | 5 | - Gradle Versions Plugin 6 | - Checkstyle 7 | - Lint 8 | 9 | 10 | ## [Gradle Versions Plugin](https://github.com/ben-manes/gradle-versions-plugin) 11 | 12 | This plugin provides a task to determine which dependencies have updates. Additionally, the plugin checks for updates to Gradle itself. 13 | 14 | Run: 15 | ``` 16 | ./gradlew dependencyUpdates 17 | ``` 18 | 19 | to display a report of the project dependencies that are up-to-date, exceed the latest version found, have upgrades, or failed to be resolved. When a dependency cannot be resolved the exception is logged at the info level. 20 | 21 | 22 | ## Checkstyle 23 | 24 | Execute `./gradlew checkstyle` 25 | 26 | 27 | ## Lint 28 | 29 | - Every module has its correspondant lint.xml files if needed. 30 | 31 | To run lint, you can use: 32 | ``` 33 | gradlew lint --profile 34 | ``` 35 | or 36 | ``` 37 | gradlew lint --profile 38 | ``` 39 | this will generate reports under the `/build/reports/lint-results.xml`. -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | GROUP=com.codeforvictory 3 | VERSION_NAME=2.0-RC1 4 | POM_DESCRIPTION=SuperImageView, an ImageView with super powers like rounded corners and different image crops not supported by the original widget. 5 | POM_URL=http://github.com/cesards/SuperImageView 6 | POM_SCM_URL=http://github.com/cesards/SuperImageView 7 | POM_SCM_CONNECTION=scm:git:https://github.com/cesards/SuperImageView.git 8 | POM_SCM_DEV_CONNECTION=scm:git:git@github.com:cesards/SuperImageView.git 9 | POM_LICENCE_NAME=The MIT License (MIT) 10 | POM_LICENCE_URL=https://tldrlegal.com/license/mit-license 11 | POM_LICENCE_DIST=repo 12 | POM_DEVELOPER_ID=com.codeforvictory 13 | POM_DEVELOPER_NAME=Code For Victory 14 | 15 | android.enableJetifier=true 16 | android.useAndroidX=true 17 | -------------------------------------------------------------------------------- /gradle/code-quality-android.gradle: -------------------------------------------------------------------------------- 1 | android { 2 | lintOptions { 3 | lintConfig file("${project.rootDir}/code-quality/custom-lint.xml") 4 | htmlReport true 5 | abortOnError true 6 | // baseline file("lint-baseline.xml") 7 | // htmlOutput file("lint-report.html") 8 | // warningsAsErrors true 9 | // check[IDs of Issues to run] 10 | } 11 | } -------------------------------------------------------------------------------- /gradle/code-quality.gradle: -------------------------------------------------------------------------------- 1 | // This should be executed under subprojects {} or allProjects {} functions. 2 | 3 | /** 4 | * Error-prone 5 | */ 6 | apply plugin: 'net.ltgt.errorprone' 7 | 8 | configurations.all { 9 | resolutionStrategy { 10 | eachDependency { details -> 11 | // Force all the error-prone dependencies to use the same version. 12 | if (details.requested.group == 'com.google.errorprone' && details.requested.name.startsWith('error_prone_')) { 13 | details.useVersion versions.errorProne 14 | } 15 | } 16 | } 17 | } 18 | 19 | /** 20 | * Checkstyle 21 | */ 22 | apply plugin: 'checkstyle' 23 | 24 | checkstyle { 25 | configFile rootProject.file('code-quality/checkstyle.xml') 26 | ignoreFailures false 27 | showViolations true 28 | } 29 | 30 | task checkstyle(type: Checkstyle) { 31 | configFile rootProject.file('code-quality/checkstyle.xml') 32 | source 'src/main/java' 33 | ignoreFailures false 34 | showViolations true 35 | include '**/*.java' 36 | 37 | // reports { 38 | // xml.enabled = true 39 | // } 40 | 41 | classpath = files() 42 | } 43 | 44 | afterEvaluate { 45 | if (project.tasks.getByName("check")) { 46 | check.dependsOn('checkstyle') 47 | } 48 | } 49 | 50 | /** 51 | * Tools dependencies 52 | */ 53 | dependencies { 54 | // Error-prone 55 | errorprone "com.google.errorprone:error_prone_core:${versions.errorProne}" 56 | } 57 | 58 | /** 59 | * Useful links: 60 | * - http://errorprone.info/index 61 | * - https://github.com/tbroyer/gradle-errorprone-plugin-v0.0.x 62 | * - https://github.com/tbroyer/gradle-errorprone-plugin 63 | */ -------------------------------------------------------------------------------- /gradle/maven-2.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'maven-publish' 2 | 3 | repositories { 4 | maven { 5 | url "http://internal.repo" 6 | } 7 | } 8 | 9 | group 'com.group.binaries' 10 | version = externalVersion 11 | 12 | publishing { 13 | publications { 14 | mavenJava(MavenPublication) { 15 | from components.java 16 | } 17 | } 18 | repositories { 19 | maven { 20 | group 'com.group.binaries' 21 | version = externalVersion 22 | credentials { 23 | username "admin" 24 | password "password" 25 | } 26 | 27 | if(project.version.endsWith('-SNAPSHOT')) { 28 | // url 'https://oss.sonatype.org/content/repositories/snapshots/' 29 | url "http://example/artifactory/libs-snapshot-local" 30 | } else { 31 | url "http://example/artifactory/libs-release-local" 32 | //"http://internal.repo/libs-snapshot-local" 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /gradle/maven-deployment.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Chris Banes 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | apply plugin: 'maven' 18 | apply plugin: 'signing' 19 | 20 | def isReleaseBuild() { 21 | return VERSION_NAME.contains("SNAPSHOT") == false 22 | } 23 | 24 | def getReleaseRepositoryUrl() { 25 | return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL : "https://oss.sonatype.org/service/local/staging/deploy/maven2/" 26 | } 27 | 28 | def getSnapshotRepositoryUrl() { 29 | return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL : "https://oss.sonatype.org/content/repositories/snapshots/" 30 | } 31 | 32 | def getRepositoryUsername() { 33 | return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : "" 34 | } 35 | 36 | def getRepositoryPassword() { 37 | return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : "" 38 | } 39 | 40 | afterEvaluate { project -> 41 | uploadArchives { 42 | repositories { 43 | mavenDeployer { 44 | beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } 45 | 46 | pom.groupId = GROUP 47 | pom.artifactId = POM_ARTIFACT_ID 48 | pom.version = VERSION_NAME 49 | 50 | repository(url: getReleaseRepositoryUrl()) { 51 | authentication(userName: getRepositoryUsername(), password: getRepositoryPassword()) 52 | } 53 | snapshotRepository(url: getSnapshotRepositoryUrl()) { 54 | authentication(userName: getRepositoryUsername(), password: getRepositoryPassword()) 55 | } 56 | 57 | pom.project { 58 | name POM_NAME 59 | packaging POM_PACKAGING 60 | description POM_DESCRIPTION 61 | url POM_URL 62 | 63 | scm { 64 | url POM_SCM_URL 65 | connection POM_SCM_CONNECTION 66 | developerConnection POM_SCM_DEV_CONNECTION 67 | } 68 | 69 | licenses { 70 | license { 71 | name POM_LICENCE_NAME 72 | url POM_LICENCE_URL 73 | distribution POM_LICENCE_DIST 74 | } 75 | } 76 | 77 | developers { 78 | developer { 79 | id POM_DEVELOPER_ID 80 | name POM_DEVELOPER_NAME 81 | } 82 | } 83 | } 84 | } 85 | } 86 | } 87 | 88 | 89 | 90 | 91 | 92 | signing { 93 | required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") } 94 | sign configurations.archives 95 | } 96 | 97 | // task androidJavadocs(type: Javadoc) { 98 | // source = android.sourceSets.main.java.srcDirs 99 | // classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) 100 | // } 101 | 102 | // task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) { 103 | // classifier = 'javadoc' 104 | // from androidJavadocs.destinationDir 105 | // } 106 | 107 | task androidSourcesJar(type: Jar) { 108 | classifier = 'sources' 109 | from android.sourceSets.main.java.sourceFiles 110 | } 111 | 112 | artifacts { 113 | archives androidSourcesJar 114 | // archives androidJavadocsJar 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesards/SuperImageView/9b161d53bc8642604107b5c848d0614af8f00bb6/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /samples/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion versions.compileSdk 5 | 6 | defaultConfig { 7 | applicationId 'com.codeforvictory.android.superimageview.samples' 8 | minSdkVersion versions.minSdk 9 | targetSdkVersion versions.compileSdk 10 | 11 | versionCode 2000 12 | versionName VERSION_NAME 13 | 14 | testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner' 15 | } 16 | 17 | // In case we used Java: https://developer.android.com/studio/write/java8-support 18 | compileOptions { 19 | sourceCompatibility JavaVersion.VERSION_1_8 20 | targetCompatibility JavaVersion.VERSION_1_8 21 | } 22 | 23 | buildTypes { 24 | release { 25 | minifyEnabled true 26 | shrinkResources true 27 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 28 | } 29 | } 30 | 31 | testOptions { 32 | animationsDisabled = true 33 | } 34 | 35 | // bundle { 36 | // density.enableSplit = true 37 | // abi.enableSplit = true 38 | // language.enableSplit = true 39 | // } 40 | 41 | /** Due to third party libraries. Not good to exclude everytyhing since APK signature v1 is there */ 42 | packagingOptions { 43 | exclude 'META-INF/LICENSE' 44 | exclude 'META-INF/LICENSE.txt' 45 | exclude 'META-INF/NOTICE' 46 | exclude 'META-INF/NOTICE.txt' 47 | exclude 'META-INF/*.version' 48 | } 49 | } 50 | 51 | //apply from: rootProject.file('gradle/code-quality-android.gradle') 52 | 53 | dependencies { 54 | implementation project(':superimageview-imagecrop') 55 | implementation project(':superimageview-roundedcorners') 56 | implementation 'androidx.core:core:1.0.0' 57 | implementation 'com.android.support.constraint:constraint-layout:1.1.3' 58 | implementation 'com.google.android.material:material:1.0.0' 59 | implementation 'com.github.bumptech.glide:glide:4.8.0' 60 | annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0' 61 | 62 | testImplementation "junit:junit:4.12" 63 | testImplementation "org.robolectric:robolectric:4.0-alpha-3" 64 | androidTestImplementation 'androidx.test:runner:1.1.0-alpha4' 65 | androidTestImplementation 'androidx.test:rules:1.1.0-alpha4' 66 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4' 67 | } 68 | -------------------------------------------------------------------------------- /samples/lint.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /samples/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 23 | 24 | 27 | 28 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /samples/src/main/java/com/codeforvictory/superimageview/samples/superimageview/HomeActivity.java: -------------------------------------------------------------------------------- 1 | package com.codeforvictory.superimageview.samples.superimageview; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | 6 | import com.codeforvictory.superimageview.samples.superimageview.rounded_corners.RoundedCornerImagesActivity; 7 | import com.codeforvictory.superimageview.samples.superimageview.image_cropping.ImageCroppingActivity; 8 | import com.codeforvictory.superimageview.samples.superimageview.image_cropping.NetworkImageCroppingActivity; 9 | 10 | import androidx.appcompat.app.AppCompatActivity; 11 | 12 | public class HomeActivity extends AppCompatActivity { 13 | 14 | @Override 15 | protected void onCreate(Bundle savedInstanceState) { 16 | super.onCreate(savedInstanceState); 17 | setContentView(R.layout.activity_home); 18 | findViewById(R.id.image_cropping).setOnClickListener(view -> 19 | startActivity(new Intent(this, ImageCroppingActivity.class)) 20 | ); 21 | findViewById(R.id.image_cropping_network).setOnClickListener(view -> 22 | startActivity(new Intent(this, NetworkImageCroppingActivity.class)) 23 | ); 24 | findViewById(R.id.rounded_corners).setOnClickListener(view -> 25 | startActivity(new Intent(this, RoundedCornerImagesActivity.class)) 26 | ); 27 | // findViewById(R.id.rounded_corners_image_cropping).setOnClickListener(view -> 28 | // startActivity(new Intent(this, RoundedCornerImagesActivity.class)) 29 | // ); 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /samples/src/main/java/com/codeforvictory/superimageview/samples/superimageview/image_cropping/ImageCroppingActivity.java: -------------------------------------------------------------------------------- 1 | package com.codeforvictory.superimageview.samples.superimageview.image_cropping; 2 | 3 | import android.os.Bundle; 4 | 5 | import com.codeforvictory.superimageview.samples.superimageview.R; 6 | import com.codeforvictory.superimageview.samples.superimageview.shared.ImageLocalDataSource; 7 | import androidx.appcompat.app.AppCompatActivity; 8 | import androidx.viewpager.widget.ViewPager; 9 | 10 | public final class ImageCroppingActivity extends AppCompatActivity { 11 | 12 | @Override 13 | protected void onCreate(Bundle savedInstanceState) { 14 | super.onCreate(savedInstanceState); 15 | setContentView(R.layout.activity_image_cropping); 16 | ((ViewPager) findViewById(R.id.cropped_images)).setAdapter(new ImagesPagerAdapter(ImageLocalDataSource.localImages())); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /samples/src/main/java/com/codeforvictory/superimageview/samples/superimageview/image_cropping/ImagesPagerAdapter.java: -------------------------------------------------------------------------------- 1 | package com.codeforvictory.superimageview.samples.superimageview.image_cropping; 2 | 3 | import android.view.LayoutInflater; 4 | import android.view.View; 5 | import android.view.ViewGroup; 6 | import android.widget.ImageView; 7 | import android.widget.TextView; 8 | 9 | import com.codeforvictory.android.superimageview.SuperImageView; 10 | import com.codeforvictory.android.superimageview.crop.CropType; 11 | import com.codeforvictory.android.superimageview.crop.CroppedImage; 12 | import com.codeforvictory.superimageview.samples.superimageview.R; 13 | import com.codeforvictory.superimageview.samples.superimageview.shared.LocalImage; 14 | 15 | import java.util.List; 16 | import java.util.Objects; 17 | 18 | import androidx.annotation.NonNull; 19 | import androidx.core.content.ContextCompat; 20 | import androidx.viewpager.widget.PagerAdapter; 21 | 22 | final class ImagesPagerAdapter extends PagerAdapter { 23 | 24 | private final List localImages; 25 | 26 | ImagesPagerAdapter(List localImages) { 27 | this.localImages = localImages; 28 | } 29 | 30 | @NonNull 31 | @Override 32 | public Object instantiateItem(ViewGroup container, int position) { 33 | View view = LayoutInflater.from(container.getContext()).inflate(R.layout.item_local_image, container, false); 34 | 35 | LocalImage localImage = localImages.get(position); 36 | 37 | int cropType = localImage.getCropType(); 38 | if (cropType == CropType.NONE) { 39 | ((ImageView) view.findViewById(R.id.image)).setScaleType(ImageView.ScaleType.FIT_CENTER); 40 | ((ImageView) view.findViewById(R.id.image)).setImageDrawable( 41 | ContextCompat.getDrawable(container.getContext(), localImage.getDrawableResource()) 42 | ); 43 | } else { 44 | SuperImageView superImageView = view.findViewById(R.id.image); 45 | Objects.requireNonNull(superImageView.getFeature(CroppedImage.class)).setCropType(cropType); 46 | superImageView.setImageDrawable( 47 | ContextCompat.getDrawable(container.getContext(), localImage.getDrawableResource()) 48 | ); 49 | } 50 | 51 | ((TextView) view.findViewById(R.id.crop_type)).setText(localImage.getTitle()); 52 | 53 | container.addView(view); 54 | return view; 55 | } 56 | 57 | @Override 58 | public void destroyItem(ViewGroup container, int position, Object object) { 59 | container.removeView((View) object); 60 | } 61 | 62 | @Override 63 | public int getCount() { 64 | return localImages.size(); 65 | } 66 | 67 | @Override 68 | public boolean isViewFromObject(View view, Object object) { 69 | return view == object; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /samples/src/main/java/com/codeforvictory/superimageview/samples/superimageview/image_cropping/ImagesRecyclerAdapter.java: -------------------------------------------------------------------------------- 1 | package com.codeforvictory.superimageview.samples.superimageview.image_cropping; 2 | 3 | import android.view.LayoutInflater; 4 | import android.view.View; 5 | import android.view.ViewGroup; 6 | import com.bumptech.glide.Glide; 7 | import com.codeforvictory.android.superimageview.SuperImageView; 8 | import com.codeforvictory.android.superimageview.crop.CroppedImage; 9 | import com.codeforvictory.superimageview.samples.superimageview.R; 10 | import com.codeforvictory.superimageview.samples.superimageview.shared.NetworkImage; 11 | import java.util.List; 12 | import java.util.Objects; 13 | import androidx.annotation.NonNull; 14 | import androidx.recyclerview.widget.RecyclerView; 15 | 16 | final class ImagesRecyclerAdapter extends RecyclerView.Adapter { 17 | 18 | private final List networkImages; 19 | 20 | ImagesRecyclerAdapter(List networkImages) { 21 | this.networkImages = networkImages; 22 | } 23 | 24 | @NonNull 25 | @Override 26 | public ItemImageViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { 27 | return new ItemImageViewHolder(LayoutInflater.from( 28 | parent.getContext()).inflate(R.layout.item_network_cropped_image, parent, false) 29 | ); 30 | } 31 | 32 | @Override 33 | public void onBindViewHolder(@NonNull ItemImageViewHolder holder, int position) { 34 | holder.bind(networkImages.get(position)); 35 | } 36 | 37 | @Override 38 | public int getItemCount() { 39 | return networkImages.size(); 40 | } 41 | 42 | static final class ItemImageViewHolder extends RecyclerView.ViewHolder { 43 | 44 | private final SuperImageView superImageView; 45 | 46 | ItemImageViewHolder(@NonNull View itemView) { 47 | super(itemView); 48 | this.superImageView = (SuperImageView) itemView; 49 | } 50 | 51 | void bind(NetworkImage networkImage) { 52 | Objects.requireNonNull(superImageView.getFeature(CroppedImage.class)).setCropType(networkImage.cropType()); 53 | Glide.with(itemView.getContext()).load(networkImage.imageUrl()).into(superImageView); 54 | } 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /samples/src/main/java/com/codeforvictory/superimageview/samples/superimageview/image_cropping/NetworkImageCroppingActivity.java: -------------------------------------------------------------------------------- 1 | package com.codeforvictory.superimageview.samples.superimageview.image_cropping; 2 | 3 | import android.os.Bundle; 4 | 5 | import com.codeforvictory.superimageview.samples.superimageview.R; 6 | import com.codeforvictory.superimageview.samples.superimageview.shared.ImageLocalDataSource; 7 | import com.codeforvictory.superimageview.samples.superimageview.shared.widget.VerticalTransparentItemDecorator; 8 | 9 | import androidx.appcompat.app.AppCompatActivity; 10 | import androidx.recyclerview.widget.RecyclerView; 11 | 12 | public final class NetworkImageCroppingActivity extends AppCompatActivity { 13 | 14 | @Override 15 | protected void onCreate(Bundle savedInstanceState) { 16 | super.onCreate(savedInstanceState); 17 | setContentView(R.layout.activity_images); 18 | setupViews(); 19 | } 20 | 21 | private void setupViews() { 22 | RecyclerView images = findViewById(R.id.images); 23 | images.addItemDecoration(new VerticalTransparentItemDecorator(getResources().getDimensionPixelOffset(R.dimen.activity_horizontal_margin))); 24 | images.setAdapter(new ImagesRecyclerAdapter(ImageLocalDataSource.networkImages())); 25 | } 26 | } -------------------------------------------------------------------------------- /samples/src/main/java/com/codeforvictory/superimageview/samples/superimageview/rounded_corners/Image.java: -------------------------------------------------------------------------------- 1 | package com.codeforvictory.superimageview.samples.superimageview.rounded_corners; 2 | 3 | import com.codeforvictory.android.superimageview.crop.CropType; 4 | 5 | import androidx.annotation.DrawableRes; 6 | 7 | final class Image { 8 | 9 | @DrawableRes private final int drawableResource; 10 | private final boolean roundedCorners; 11 | @CropType private final int cropType; 12 | 13 | Image(@DrawableRes int drawableResource, boolean roundedCorners, int cropType) { 14 | this.drawableResource = drawableResource; 15 | this.roundedCorners = roundedCorners; 16 | this.cropType = cropType; 17 | } 18 | 19 | public int drawableResource() { 20 | return drawableResource; 21 | } 22 | 23 | public boolean roundedCorners() { 24 | return roundedCorners; 25 | } 26 | 27 | public int cropType() { 28 | return cropType; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /samples/src/main/java/com/codeforvictory/superimageview/samples/superimageview/rounded_corners/ImageFactory.java: -------------------------------------------------------------------------------- 1 | package com.codeforvictory.superimageview.samples.superimageview.rounded_corners; 2 | 3 | import com.codeforvictory.android.superimageview.crop.CropType; 4 | import com.codeforvictory.superimageview.samples.superimageview.R; 5 | 6 | import java.util.Arrays; 7 | import java.util.List; 8 | 9 | public final class ImageFactory { 10 | 11 | private ImageFactory() { 12 | throw new AssertionError("This shouldn't be initialized!"); 13 | } 14 | 15 | public static List imagesWithoutRoundedCorners() { 16 | return Arrays.asList( 17 | // new Image(R.drawable.ball_vertical, false, CropType.NONE), 18 | // new Image(R.drawable.ball_horizontal, false, CropType.NONE), 19 | new Image(R.drawable.ball_vertical, false, CropType.TOP), 20 | new Image(R.drawable.ball_vertical, false, CropType.BOTTOM), 21 | new Image(R.drawable.ball_horizontal, false, CropType.TOP_LEFT), 22 | new Image(R.drawable.ball_horizontal, false, CropType.LEFT), 23 | new Image(R.drawable.ball_horizontal, false, CropType.BOTTOM_LEFT), 24 | new Image(R.drawable.ball_horizontal, false, CropType.TOP_RIGHT), 25 | new Image(R.drawable.ball_horizontal, false, CropType.BOTTOM_RIGHT), 26 | new Image(R.drawable.ball_horizontal, false, CropType.RIGHT), 27 | new Image(R.drawable.ball_vertical, false, CropType.TOP), 28 | new Image(R.drawable.ball_vertical, false, CropType.BOTTOM), 29 | new Image(R.drawable.ball_horizontal, false, CropType.TOP_LEFT), 30 | new Image(R.drawable.ball_horizontal, false, CropType.LEFT), 31 | new Image(R.drawable.ball_horizontal, false, CropType.BOTTOM_LEFT), 32 | new Image(R.drawable.ball_horizontal, false, CropType.TOP_RIGHT), 33 | new Image(R.drawable.ball_horizontal, false, CropType.BOTTOM_RIGHT), 34 | new Image(R.drawable.ball_horizontal, false, CropType.RIGHT), 35 | new Image(R.drawable.ball_vertical, false, CropType.TOP), 36 | new Image(R.drawable.ball_vertical, false, CropType.BOTTOM), 37 | new Image(R.drawable.ball_horizontal, false, CropType.TOP_LEFT), 38 | new Image(R.drawable.ball_horizontal, false, CropType.LEFT), 39 | new Image(R.drawable.ball_horizontal, false, CropType.BOTTOM_LEFT), 40 | new Image(R.drawable.ball_horizontal, false, CropType.TOP_RIGHT), 41 | new Image(R.drawable.ball_horizontal, false, CropType.BOTTOM_RIGHT), 42 | new Image(R.drawable.ball_horizontal, false, CropType.RIGHT), 43 | new Image(R.drawable.ball_vertical, false, CropType.TOP), 44 | new Image(R.drawable.ball_vertical, false, CropType.BOTTOM), 45 | new Image(R.drawable.ball_horizontal, false, CropType.TOP_LEFT), 46 | new Image(R.drawable.ball_horizontal, false, CropType.LEFT), 47 | new Image(R.drawable.ball_horizontal, false, CropType.BOTTOM_LEFT), 48 | new Image(R.drawable.ball_horizontal, false, CropType.TOP_RIGHT), 49 | new Image(R.drawable.ball_horizontal, false, CropType.BOTTOM_RIGHT), 50 | new Image(R.drawable.ball_horizontal, false, CropType.RIGHT) 51 | ); 52 | } 53 | 54 | public static List imagesWithRoundedCorners() { 55 | return Arrays.asList( 56 | // new Image(R.drawable.ball_vertical, false, CropType.NONE), 57 | // new Image(R.drawable.ball_horizontal, false, CropType.NONE), 58 | new Image(R.drawable.ball_vertical, true, CropType.TOP), 59 | new Image(R.drawable.ball_vertical, true, CropType.BOTTOM), 60 | new Image(R.drawable.ball_horizontal, true, CropType.TOP_LEFT), 61 | new Image(R.drawable.ball_horizontal, true, CropType.LEFT), 62 | new Image(R.drawable.ball_horizontal, true, CropType.BOTTOM_LEFT), 63 | new Image(R.drawable.ball_horizontal, true, CropType.TOP_RIGHT), 64 | new Image(R.drawable.ball_horizontal, true, CropType.BOTTOM_RIGHT), 65 | new Image(R.drawable.ball_horizontal, true, CropType.RIGHT), 66 | new Image(R.drawable.ball_vertical, false, CropType.TOP), 67 | new Image(R.drawable.ball_vertical, false, CropType.BOTTOM), 68 | new Image(R.drawable.ball_horizontal, false, CropType.TOP_LEFT), 69 | new Image(R.drawable.ball_horizontal, false, CropType.LEFT), 70 | new Image(R.drawable.ball_horizontal, false, CropType.BOTTOM_LEFT), 71 | new Image(R.drawable.ball_horizontal, false, CropType.TOP_RIGHT), 72 | new Image(R.drawable.ball_horizontal, false, CropType.BOTTOM_RIGHT), 73 | new Image(R.drawable.ball_horizontal, false, CropType.RIGHT), 74 | new Image(R.drawable.ball_vertical, false, CropType.TOP), 75 | new Image(R.drawable.ball_vertical, false, CropType.BOTTOM), 76 | new Image(R.drawable.ball_horizontal, false, CropType.TOP_LEFT), 77 | new Image(R.drawable.ball_horizontal, false, CropType.LEFT), 78 | new Image(R.drawable.ball_horizontal, false, CropType.BOTTOM_LEFT), 79 | new Image(R.drawable.ball_horizontal, false, CropType.TOP_RIGHT), 80 | new Image(R.drawable.ball_horizontal, false, CropType.BOTTOM_RIGHT), 81 | new Image(R.drawable.ball_horizontal, false, CropType.RIGHT), 82 | new Image(R.drawable.ball_vertical, false, CropType.TOP), 83 | new Image(R.drawable.ball_vertical, false, CropType.BOTTOM), 84 | new Image(R.drawable.ball_horizontal, false, CropType.TOP_LEFT), 85 | new Image(R.drawable.ball_horizontal, false, CropType.LEFT), 86 | new Image(R.drawable.ball_horizontal, false, CropType.BOTTOM_LEFT), 87 | new Image(R.drawable.ball_horizontal, false, CropType.TOP_RIGHT), 88 | new Image(R.drawable.ball_horizontal, false, CropType.BOTTOM_RIGHT), 89 | new Image(R.drawable.ball_horizontal, false, CropType.RIGHT) 90 | ); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /samples/src/main/java/com/codeforvictory/superimageview/samples/superimageview/rounded_corners/ImagesRecyclerAdapter.java: -------------------------------------------------------------------------------- 1 | package com.codeforvictory.superimageview.samples.superimageview.rounded_corners; 2 | 3 | import android.view.LayoutInflater; 4 | import android.view.View; 5 | import android.view.ViewGroup; 6 | 7 | import com.bumptech.glide.Glide; 8 | import com.codeforvictory.android.superimageview.SuperImageView; 9 | import com.codeforvictory.superimageview.samples.superimageview.R; 10 | import com.codeforvictory.superimageview.samples.superimageview.shared.NetworkImage; 11 | import java.util.List; 12 | import androidx.annotation.NonNull; 13 | import androidx.recyclerview.widget.RecyclerView; 14 | 15 | final class ImagesRecyclerAdapter extends RecyclerView.Adapter { 16 | 17 | private final List networkImages; 18 | 19 | ImagesRecyclerAdapter(List networkImages) { 20 | this.networkImages = networkImages; 21 | } 22 | 23 | @NonNull 24 | @Override 25 | public ItemImageViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { 26 | return new ImagesRecyclerAdapter.ItemImageViewHolder(LayoutInflater.from( 27 | parent.getContext()).inflate(R.layout.item_network_rounded_image, parent, false) 28 | ); 29 | } 30 | 31 | @Override 32 | public void onBindViewHolder(@NonNull ItemImageViewHolder holder, int position) { 33 | holder.bind(networkImages.get(position)); 34 | } 35 | 36 | @Override 37 | public int getItemCount() { 38 | return networkImages.size(); 39 | } 40 | 41 | static final class ItemImageViewHolder extends RecyclerView.ViewHolder { 42 | 43 | private final SuperImageView superImageView; 44 | 45 | ItemImageViewHolder(@NonNull View itemView) { 46 | super(itemView); 47 | this.superImageView = (SuperImageView) itemView; 48 | } 49 | 50 | void bind(NetworkImage networkImage) { 51 | Glide.with(itemView.getContext()).load(networkImage.imageUrl()).into(superImageView); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /samples/src/main/java/com/codeforvictory/superimageview/samples/superimageview/rounded_corners/RoundedCornerImagesActivity.java: -------------------------------------------------------------------------------- 1 | package com.codeforvictory.superimageview.samples.superimageview.rounded_corners; 2 | 3 | import android.os.Bundle; 4 | 5 | import com.codeforvictory.superimageview.samples.superimageview.R; 6 | import com.codeforvictory.superimageview.samples.superimageview.shared.ImageLocalDataSource; 7 | import com.codeforvictory.superimageview.samples.superimageview.shared.widget.VerticalTransparentItemDecorator; 8 | import androidx.appcompat.app.AppCompatActivity; 9 | import androidx.recyclerview.widget.RecyclerView; 10 | 11 | public final class RoundedCornerImagesActivity extends AppCompatActivity { 12 | 13 | @Override 14 | protected void onCreate(Bundle savedInstanceState) { 15 | super.onCreate(savedInstanceState); 16 | setContentView(R.layout.activity_images); 17 | setupViews(); 18 | } 19 | 20 | private void setupViews() { 21 | RecyclerView images = findViewById(R.id.images); 22 | images.addItemDecoration(new VerticalTransparentItemDecorator(getResources().getDimensionPixelOffset(R.dimen.activity_horizontal_margin))); 23 | images.setAdapter(new ImagesRecyclerAdapter(ImageLocalDataSource.networkImages())); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /samples/src/main/java/com/codeforvictory/superimageview/samples/superimageview/shared/ImageLocalDataSource.java: -------------------------------------------------------------------------------- 1 | package com.codeforvictory.superimageview.samples.superimageview.shared; 2 | 3 | import com.codeforvictory.android.superimageview.crop.CropType; 4 | import com.codeforvictory.superimageview.samples.superimageview.R; 5 | 6 | import java.util.Arrays; 7 | import java.util.List; 8 | 9 | public final class ImageLocalDataSource { 10 | 11 | private ImageLocalDataSource() { 12 | throw new AssertionError("This shouldn't be initialized!"); 13 | } 14 | 15 | private static final LocalImage[] localImages = { 16 | new LocalImage(CropType.NONE, "Original horizontal image", R.drawable.ball_horizontal), 17 | new LocalImage(CropType.NONE, "Original vertical image", R.drawable.ball_vertical), 18 | new LocalImage(CropType.TOP_LEFT, "Left Top crop of the horizontal image", R.drawable.ball_horizontal), 19 | new LocalImage(CropType.TOP, "Center Top crop of the vertical image", R.drawable.ball_vertical), 20 | new LocalImage(CropType.TOP_RIGHT, "Right Top crop of the horizontal image", R.drawable.ball_horizontal), 21 | new LocalImage(CropType.LEFT, "Left Center crop of the horizontal image", R.drawable.ball_horizontal), 22 | new LocalImage(CropType.RIGHT, "Right Center crop of the horizontal image", R.drawable.ball_horizontal), 23 | new LocalImage(CropType.BOTTOM_LEFT, "Left Bottom crop of the horizontal image", R.drawable.ball_horizontal), 24 | new LocalImage(CropType.BOTTOM, "Center Bottom crop of the vertical image", R.drawable.ball_vertical), 25 | new LocalImage(CropType.BOTTOM_RIGHT, "Right Bottom crop of the horizontal image", R.drawable.ball_horizontal), 26 | }; 27 | 28 | private static final NetworkImage[] networkImages = { 29 | // Provided by https://unsplash.com 30 | new NetworkImage( 31 | CropType.NONE, 32 | "Original image (vertical)", 33 | "https://images.unsplash.com/photo-1512061203001-0c4d837c6882?w=600" 34 | ), 35 | new NetworkImage( 36 | CropType.TOP, 37 | "Top crop of the original image", 38 | "https://images.unsplash.com/photo-1512061203001-0c4d837c6882?w=600" 39 | ), 40 | new NetworkImage( 41 | CropType.RIGHT, 42 | "Right crop of the original image", 43 | "https://images.unsplash.com/photo-1512061203001-0c4d837c6882?w=600" 44 | ), 45 | new NetworkImage( 46 | CropType.BOTTOM, 47 | "Bottom crop of the original image", 48 | "https://images.unsplash.com/photo-1512061203001-0c4d837c6882?w=600" 49 | ), 50 | new NetworkImage( 51 | CropType.LEFT, 52 | "Left crop of the original image", 53 | "https://images.unsplash.com/photo-1512061203001-0c4d837c6882?w=600" 54 | ), 55 | new NetworkImage( 56 | CropType.TOP_LEFT, 57 | "Top left crop of the original image", 58 | "https://images.unsplash.com/photo-1512061203001-0c4d837c6882?w=600" 59 | ), 60 | new NetworkImage( 61 | CropType.TOP_RIGHT, 62 | "Top right crop of the original image", 63 | "https://images.unsplash.com/photo-1512061203001-0c4d837c6882?w=600" 64 | ), 65 | new NetworkImage( 66 | CropType.BOTTOM_RIGHT, 67 | "Bottom right crop of the original image", 68 | "https://images.unsplash.com/photo-1512061203001-0c4d837c6882?w=600" 69 | ), 70 | new NetworkImage( 71 | CropType.BOTTOM_LEFT, 72 | "Bottom left crop of the original image", 73 | "https://images.unsplash.com/photo-1512061203001-0c4d837c6882?w=600" 74 | ), 75 | new NetworkImage( 76 | CropType.NONE, 77 | "Original image (horizontal)", 78 | "https://images.pexels.com/photos/161798/stonehenge-architecture-history-monolith-161798.jpeg?auto=compress&h=400" 79 | ), 80 | new NetworkImage( 81 | CropType.TOP, 82 | "Top crop of the original image", 83 | "https://images.pexels.com/photos/161798/stonehenge-architecture-history-monolith-161798.jpeg?auto=compress&h=400" 84 | ), 85 | new NetworkImage( 86 | CropType.RIGHT, 87 | "Right crop of the original image", 88 | "https://images.pexels.com/photos/161798/stonehenge-architecture-history-monolith-161798.jpeg?auto=compress&h=400" 89 | ), 90 | new NetworkImage( 91 | CropType.BOTTOM, 92 | "Bottom crop of the original image", 93 | "https://images.pexels.com/photos/161798/stonehenge-architecture-history-monolith-161798.jpeg?auto=compress&h=400" 94 | ), 95 | new NetworkImage( 96 | CropType.LEFT, 97 | "Left crop of the original image", 98 | "https://images.pexels.com/photos/161798/stonehenge-architecture-history-monolith-161798.jpeg?auto=compress&h=400" 99 | ), 100 | new NetworkImage( 101 | CropType.TOP_LEFT, 102 | "Top left crop of the original image", 103 | "https://images.pexels.com/photos/161798/stonehenge-architecture-history-monolith-161798.jpeg?auto=compress&h=400" 104 | ), 105 | new NetworkImage( 106 | CropType.TOP_RIGHT, 107 | "Top right crop of the original image", 108 | "https://images.pexels.com/photos/161798/stonehenge-architecture-history-monolith-161798.jpeg?auto=compress&h=400" 109 | ), 110 | new NetworkImage( 111 | CropType.BOTTOM_RIGHT, 112 | "Bottom right crop of the original image", 113 | "https://images.pexels.com/photos/161798/stonehenge-architecture-history-monolith-161798.jpeg?auto=compress&h=400" 114 | ), 115 | new NetworkImage( 116 | CropType.BOTTOM_LEFT, 117 | "Bottom left crop of the original image", 118 | "https://images.pexels.com/photos/161798/stonehenge-architecture-history-monolith-161798.jpeg?auto=compress&h=400" 119 | ), 120 | }; 121 | 122 | public static List localImages() { 123 | return Arrays.asList(localImages); 124 | } 125 | 126 | public static List networkImages() { 127 | return Arrays.asList(networkImages); 128 | } 129 | 130 | } 131 | -------------------------------------------------------------------------------- /samples/src/main/java/com/codeforvictory/superimageview/samples/superimageview/shared/LocalImage.java: -------------------------------------------------------------------------------- 1 | package com.codeforvictory.superimageview.samples.superimageview.shared; 2 | 3 | import com.codeforvictory.android.superimageview.crop.CropType; 4 | 5 | import androidx.annotation.DrawableRes; 6 | 7 | public final class LocalImage { 8 | 9 | @CropType private final int cropType; 10 | private final String title; 11 | @DrawableRes private final int drawableResource; 12 | 13 | LocalImage(@CropType int cropType, String title, @DrawableRes int drawableResource) { 14 | this.cropType = cropType; 15 | this.title = title; 16 | this.drawableResource = drawableResource; 17 | } 18 | 19 | @CropType 20 | public int getCropType() { 21 | return cropType; 22 | } 23 | 24 | public String getTitle() { 25 | return title; 26 | } 27 | 28 | @DrawableRes 29 | public int getDrawableResource() { 30 | return drawableResource; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /samples/src/main/java/com/codeforvictory/superimageview/samples/superimageview/shared/NetworkImage.java: -------------------------------------------------------------------------------- 1 | package com.codeforvictory.superimageview.samples.superimageview.shared; 2 | 3 | import com.codeforvictory.android.superimageview.crop.CropType; 4 | 5 | public final class NetworkImage { 6 | 7 | @CropType private final int cropType; 8 | private final String title; 9 | private final String imageUrl; 10 | 11 | NetworkImage(@CropType int cropType, String title, String imageUrl) { 12 | this.cropType = cropType; 13 | this.title = title; 14 | this.imageUrl = imageUrl; 15 | } 16 | 17 | @CropType 18 | public int cropType() { 19 | return cropType; 20 | } 21 | 22 | public String title() { 23 | return title; 24 | } 25 | 26 | public String imageUrl() { 27 | return imageUrl; 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /samples/src/main/java/com/codeforvictory/superimageview/samples/superimageview/shared/widget/VerticalTransparentItemDecorator.java: -------------------------------------------------------------------------------- 1 | package com.codeforvictory.superimageview.samples.superimageview.shared.widget; 2 | 3 | import android.graphics.Rect; 4 | import android.view.View; 5 | 6 | import androidx.recyclerview.widget.RecyclerView; 7 | 8 | public final class VerticalTransparentItemDecorator extends RecyclerView.ItemDecoration { 9 | 10 | private int space; 11 | 12 | public VerticalTransparentItemDecorator(int value) { 13 | this.space = value; 14 | } 15 | 16 | @Override 17 | public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { 18 | // Skip first item in the list. 19 | if (parent.getChildAdapterPosition(view) != 0) { 20 | outRect.set(0, space, 0, 0); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /samples/src/main/res/drawable-xxhdpi/ball_horizontal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesards/SuperImageView/9b161d53bc8642604107b5c848d0614af8f00bb6/samples/src/main/res/drawable-xxhdpi/ball_horizontal.png -------------------------------------------------------------------------------- /samples/src/main/res/drawable-xxhdpi/ball_vertical.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesards/SuperImageView/9b161d53bc8642604107b5c848d0614af8f00bb6/samples/src/main/res/drawable-xxhdpi/ball_vertical.png -------------------------------------------------------------------------------- /samples/src/main/res/layout/activity_home.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 19 | 20 | 29 | 30 | 39 | 40 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /samples/src/main/res/layout/activity_image_cropping.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /samples/src/main/res/layout/activity_images.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | -------------------------------------------------------------------------------- /samples/src/main/res/layout/item_local_image.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 15 | 16 | 26 | 27 | -------------------------------------------------------------------------------- /samples/src/main/res/layout/item_network_cropped_image.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /samples/src/main/res/layout/item_network_rounded_image.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /samples/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesards/SuperImageView/9b161d53bc8642604107b5c848d0614af8f00bb6/samples/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesards/SuperImageView/9b161d53bc8642604107b5c848d0614af8f00bb6/samples/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesards/SuperImageView/9b161d53bc8642604107b5c848d0614af8f00bb6/samples/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesards/SuperImageView/9b161d53bc8642604107b5c848d0614af8f00bb6/samples/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cesards/SuperImageView/9b161d53bc8642604107b5c848d0614af8f00bb6/samples/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /samples/src/main/res/values-v19/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /samples/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /samples/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /samples/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #AB000000 5 | 6 | -------------------------------------------------------------------------------- /samples/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 5 | -------------------------------------------------------------------------------- /samples/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | SuperImageView Samples 4 | Image Cropping 5 | Image Cropping From Network 6 | Rounded Corners 7 | Rounded Corners with Image Cropping 8 | 9 | -------------------------------------------------------------------------------- /samples/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 |