├── .gitattributes ├── .gitignore ├── LICENSE.txt ├── MultipleImageSelect.iml ├── README.md ├── build.gradle ├── gradle.properties ├── gradlew ├── gradlew.bat ├── multipleimageselect ├── .gitignore ├── build.gradle ├── multipleimageselect.iml ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── darsh │ │ └── multipleimageselect │ │ ├── activities │ │ ├── AlbumSelectActivity.java │ │ └── ImageSelectActivity.java │ │ ├── adapters │ │ ├── CustomAlbumSelectAdapter.java │ │ ├── CustomGenericAdapter.java │ │ └── CustomImageSelectAdapter.java │ │ ├── helpers │ │ └── Constants.java │ │ └── models │ │ ├── Album.java │ │ └── Image.java │ └── res │ ├── drawable-hdpi │ ├── ic_arrow_back.png │ └── ic_done_white.png │ ├── drawable-mdpi │ ├── ic_arrow_back.png │ └── ic_done_white.png │ ├── drawable-xhdpi │ ├── ic_arrow_back.png │ └── ic_done_white.png │ ├── drawable-xxhdpi │ ├── ic_arrow_back.png │ └── ic_done_white.png │ ├── drawable │ └── image_placeholder.xml │ ├── layout │ ├── activity_album_select.xml │ ├── activity_image_select.xml │ ├── grid_view_item_album_select.xml │ ├── grid_view_item_image_select.xml │ └── toolbar.xml │ ├── menu │ └── menu_contextual_action_bar.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── values-de │ └── strings.xml │ ├── values-fr │ └── strings.xml │ ├── values-ru │ └── strings.xml │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── sample ├── .gitignore ├── build.gradle ├── proguard-rules.pro ├── sample.iml └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── darsh │ │ └── example │ │ └── sample │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── darsh │ │ └── example │ │ └── sample │ │ └── MainActivity.java │ └── res │ ├── layout │ └── activity_main.xml │ ├── menu │ └── menu_main.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── screenshots ├── mis.gif ├── mis1.png ├── mis2.png ├── mis3.png ├── mis4.png ├── mis5.png ├── mis6.png ├── mis7.png ├── misCC.gif └── misCT.gif └── settings.gradle /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | bintrayUpload.gradle 10 | gradle/ 11 | *.iml 12 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /MultipleImageSelect.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #MultipleImageSelect 2 | 3 | ![Alt text](/screenshots/mis.gif) 4 | 5 | An android library that allows selection of multiple images from gallery. It shows an initial 6 | album (buckets) chooser and then images in selected album. Can limit the number of images that 7 | can be selected. Can be used in apps with APK 11 onwards. 8 | 9 | Sample app can be found [here](https://github.com/darsh2/MultipleImageSelect/tree/master/sample) 10 | #Usage 11 | Include this library in your project using gradle (thanks to [JitPack.io](https://github.com/jitpack-io)). 12 | 13 | For stable build: 14 | ```gradle 15 | repositories { 16 | maven { 17 | url "https://jitpack.io" 18 | } 19 | } 20 | 21 | dependencies { 22 | compile 'com.github.darsh2:MultipleImageSelect:v0.0.4' 23 | } 24 | ``` 25 | 26 | For using the latest build, replace the tag in dependencies above with latest commit hash. Example: 27 | ```gradle 28 | repositories { 29 | maven { 30 | url "https://jitpack.io" 31 | } 32 | } 33 | 34 | dependencies { 35 | compile 'com.github.darsh2:MultipleImageSelect:3474549' 36 | } 37 | ``` 38 | 39 | In project's AndroidManifest.xml, add the following under application node: 40 | ```xml 41 | 44 | 45 | 46 | 47 | 48 | ``` 49 | In the activity from where you want to call image selector, create Intent as follows: 50 | ```java 51 | Intent intent = new Intent(this, AlbumSelectActivity.class); 52 | //set limit on number of images that can be selected, default is 10 53 | intent.putExtra(Constants.INTENT_EXTRA_LIMIT, numberOfImagesToSelect); 54 | startActivityForResult(intent, Constants.REQUEST_CODE); 55 | ``` 56 | and override onActivityResult as follows: 57 | ```java 58 | @Override 59 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { 60 | if (requestCode == Constants.REQUEST_CODE && resultCode == RESULT_OK && data != null) { 61 | //The array list has the image paths of the selected images 62 | ArrayList images = data.getParcelableArrayListExtra(Constants.INTENT_EXTRA_IMAGES); 63 | ... 64 | } 65 | ``` 66 | #Custom Styles 67 | ![Alt text](/screenshots/misCC.gif) 68 | 69 | 1. To change the color of UI elements, in colors.xml file, override the following attributes with the desired colors. Example: 70 | 71 | ```xml 72 | #673AB7 73 | #512DA8 74 | #D1C4E9 75 | #536DFE 76 | #212121 77 | #727272 78 | #B6B6B6 79 | #FFFFFF 80 | #99FFFFFF 81 | #000000 82 | ``` 83 | 84 | ![Alt text](/screenshots/misCT.gif) 85 | 86 | 2. To change the theme altogether, do step 1, and make the following changes in styles.xml and manifest file: 87 | 88 | styles.xml: 89 | Create the theme you want to use along with a theme for toolbar and actionmode. Example: 90 | 91 | ```xml 92 | 99 | 102 | 104 | ``` 105 | 106 | AndroidManifest.xml: 107 | Add ```tools:replace="android:theme"``` to AlbumSelectActivity and ImageSelectActivity and specify theme to use. Example: 108 | 109 | ```xml 110 | 113 | 114 | 117 | 118 | 119 | 120 | 121 | 124 | 125 | 126 | 127 | 128 | ``` 129 | #Screenshots 130 | Can be found [here](https://github.com/darsh2/MultipleImageSelect/tree/master/screenshots) 131 | #Apps using this 132 | [Gallery Organizer](https://play.google.com/store/apps/details?id=com.darsh.galleryorganizer2) 133 | 134 | [PictureJam Collage Maker](https://play.google.com/store/apps/details?id=xyz.pichancer.picturejam.free) 135 | #Similar Projects 136 | Similar libraries can be found [here](https://android-arsenal.com/tag/157) 137 | #Acknowledgements 138 | This library makes use of [Glide](https://github.com/bumptech/glide) by Bump Technologies. 139 | (Thanks to [WindSekirun](https://github.com/WindSekirun) for suggesting Glide) 140 | #License 141 | ```license 142 | Copyright 2015 Darshan Dorai 143 | 144 | Licensed under the Apache License, Version 2.0 (the "License"); 145 | you may not use this file except in compliance with the License. 146 | You may obtain a copy of the License at 147 | 148 | http://www.apache.org/licenses/LICENSE-2.0 149 | 150 | Unless required by applicable law or agreed to in writing, software 151 | distributed under the License is distributed on an "AS IS" BASIS, 152 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 153 | See the License for the specific language governing permissions and 154 | limitations under the License. 155 | ``` 156 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | google() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:3.0.1' 10 | // classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' 11 | // classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' 12 | // classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3' 13 | // NOTE: Do not place your application dependencies here; they belong 14 | // in the individual module build.gradle files 15 | } 16 | } 17 | 18 | allprojects { 19 | repositories { 20 | jcenter() 21 | google() 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 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 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /multipleimageselect/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | *.iml -------------------------------------------------------------------------------- /multipleimageselect/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 26 5 | buildToolsVersion '26.0.3' 6 | 7 | defaultConfig { 8 | minSdkVersion 14 9 | targetSdkVersion 26 10 | versionCode 2 11 | versionName "1.0.5" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | compile fileTree(dir: 'libs', include: ['*.jar']) 23 | compile 'com.android.support:appcompat-v7:27.0.1' 24 | compile 'com.github.bumptech.glide:glide:4.6.1' 25 | } 26 | //apply from: "bintrayUpload.gradle" -------------------------------------------------------------------------------- /multipleimageselect/multipleimageselect.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 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 | -------------------------------------------------------------------------------- /multipleimageselect/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 E:\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 | -------------------------------------------------------------------------------- /multipleimageselect/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 10 | 15 | 16 | 17 | 18 | 19 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /multipleimageselect/src/main/java/com/darsh/multipleimageselect/activities/AlbumSelectActivity.java: -------------------------------------------------------------------------------- 1 | package com.darsh.multipleimageselect.activities; 2 | 3 | import android.Manifest; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.content.pm.PackageManager; 7 | import android.content.res.Configuration; 8 | import android.database.ContentObserver; 9 | import android.database.Cursor; 10 | import android.net.Uri; 11 | import android.os.Bundle; 12 | import android.os.Handler; 13 | import android.os.Message; 14 | import android.os.Process; 15 | import android.provider.MediaStore; 16 | import android.support.v4.app.ActivityCompat; 17 | import android.support.v4.content.ContextCompat; 18 | import android.support.v7.app.ActionBar; 19 | import android.support.v7.app.AppCompatActivity; 20 | import android.support.v7.widget.Toolbar; 21 | import android.util.DisplayMetrics; 22 | import android.view.MenuItem; 23 | import android.view.View; 24 | import android.view.WindowManager; 25 | import android.widget.AdapterView; 26 | import android.widget.Button; 27 | import android.widget.GridView; 28 | import android.widget.ProgressBar; 29 | import android.widget.TextView; 30 | 31 | import com.darsh.multipleimageselect.R; 32 | import com.darsh.multipleimageselect.adapters.CustomAlbumSelectAdapter; 33 | import com.darsh.multipleimageselect.helpers.Constants; 34 | import com.darsh.multipleimageselect.models.Album; 35 | 36 | import java.io.File; 37 | import java.util.ArrayList; 38 | import java.util.HashSet; 39 | 40 | /** 41 | * Created by Darshan on 4/14/2015. 42 | */ 43 | public class AlbumSelectActivity extends AppCompatActivity { 44 | private final String TAG = AlbumSelectActivity.class.getName(); 45 | 46 | private ArrayList albums; 47 | 48 | private TextView requestPermission; 49 | private Button grantPermission; 50 | private final String[] requiredPermissions = new String[]{ Manifest.permission.READ_EXTERNAL_STORAGE }; 51 | 52 | private TextView errorDisplay; 53 | 54 | private ProgressBar progressBar; 55 | private GridView gridView; 56 | private CustomAlbumSelectAdapter adapter; 57 | 58 | private ActionBar actionBar; 59 | 60 | private ContentObserver observer; 61 | private Handler handler; 62 | private Thread thread; 63 | 64 | private final String[] projection = new String[]{ MediaStore.Images.Media.BUCKET_DISPLAY_NAME, MediaStore.Images.Media.DATA }; 65 | 66 | @Override 67 | protected void onCreate(Bundle savedInstanceState) { 68 | super.onCreate(savedInstanceState); 69 | setContentView(R.layout.activity_album_select); 70 | 71 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 72 | setSupportActionBar(toolbar); 73 | 74 | actionBar = getSupportActionBar(); 75 | if (actionBar != null) { 76 | actionBar.setDisplayHomeAsUpEnabled(true); 77 | actionBar.setHomeAsUpIndicator(R.drawable.ic_arrow_back); 78 | 79 | actionBar.setDisplayShowTitleEnabled(true); 80 | actionBar.setTitle(R.string.album_view); 81 | } 82 | 83 | Intent intent = getIntent(); 84 | if (intent == null) { 85 | finish(); 86 | } 87 | Constants.limit = intent.getIntExtra(Constants.INTENT_EXTRA_LIMIT, Constants.DEFAULT_LIMIT); 88 | 89 | errorDisplay = (TextView) findViewById(R.id.text_view_error); 90 | errorDisplay.setVisibility(View.INVISIBLE); 91 | 92 | requestPermission = (TextView) findViewById(R.id.text_view_request_permission); 93 | grantPermission = (Button) findViewById(R.id.button_grant_permission); 94 | grantPermission.setOnClickListener(new View.OnClickListener() { 95 | @Override 96 | public void onClick(View v) { 97 | requestPermission(); 98 | } 99 | }); 100 | hidePermissionHelperUI(); 101 | 102 | progressBar = (ProgressBar) findViewById(R.id.progress_bar_album_select); 103 | gridView = (GridView) findViewById(R.id.grid_view_album_select); 104 | gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { 105 | @Override 106 | public void onItemClick(AdapterView parent, View view, int position, long id) { 107 | Intent intent = new Intent(getApplicationContext(), ImageSelectActivity.class); 108 | intent.putExtra(Constants.INTENT_EXTRA_ALBUM, albums.get(position).name); 109 | startActivityForResult(intent, Constants.REQUEST_CODE); 110 | } 111 | }); 112 | } 113 | 114 | @Override 115 | protected void onStart() { 116 | super.onStart(); 117 | 118 | handler = new Handler() { 119 | @Override 120 | public void handleMessage(Message msg) { 121 | switch (msg.what) { 122 | case Constants.PERMISSION_GRANTED: { 123 | hidePermissionHelperUI(); 124 | 125 | loadAlbums(); 126 | 127 | break; 128 | } 129 | 130 | case Constants.PERMISSION_DENIED: { 131 | showPermissionHelperUI(); 132 | 133 | progressBar.setVisibility(View.INVISIBLE); 134 | gridView.setVisibility(View.INVISIBLE); 135 | 136 | break; 137 | } 138 | 139 | case Constants.FETCH_STARTED: { 140 | progressBar.setVisibility(View.VISIBLE); 141 | gridView.setVisibility(View.INVISIBLE); 142 | 143 | break; 144 | } 145 | 146 | case Constants.FETCH_COMPLETED: { 147 | if (adapter == null) { 148 | adapter = new CustomAlbumSelectAdapter(getApplicationContext(), albums); 149 | gridView.setAdapter(adapter); 150 | 151 | progressBar.setVisibility(View.INVISIBLE); 152 | gridView.setVisibility(View.VISIBLE); 153 | orientationBasedUI(getResources().getConfiguration().orientation); 154 | 155 | } else { 156 | adapter.notifyDataSetChanged(); 157 | } 158 | 159 | break; 160 | } 161 | 162 | case Constants.ERROR: { 163 | progressBar.setVisibility(View.INVISIBLE); 164 | errorDisplay.setVisibility(View.VISIBLE); 165 | 166 | break; 167 | } 168 | 169 | default: { 170 | super.handleMessage(msg); 171 | } 172 | } 173 | } 174 | }; 175 | observer = new ContentObserver(handler) { 176 | @Override 177 | public void onChange(boolean selfChange, Uri uri) { 178 | loadAlbums(); 179 | } 180 | }; 181 | getContentResolver().registerContentObserver(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, false, observer); 182 | 183 | checkIfPermissionGranted(); 184 | } 185 | 186 | private void checkIfPermissionGranted() { 187 | if (ContextCompat.checkSelfPermission(AlbumSelectActivity.this, 188 | Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { 189 | requestPermission(); 190 | return; 191 | } 192 | 193 | Message message = handler.obtainMessage(); 194 | message.what = Constants.PERMISSION_GRANTED; 195 | message.sendToTarget(); 196 | } 197 | 198 | private void requestPermission() { 199 | ActivityCompat.requestPermissions(AlbumSelectActivity.this, 200 | requiredPermissions, 201 | Constants.PERMISSION_REQUEST_READ_EXTERNAL_STORAGE); 202 | } 203 | 204 | @Override 205 | public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { 206 | if (requestCode == Constants.PERMISSION_REQUEST_READ_EXTERNAL_STORAGE) { 207 | Message message = handler.obtainMessage(); 208 | message.what = grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED ? Constants.PERMISSION_GRANTED : Constants.PERMISSION_DENIED; 209 | message.sendToTarget(); 210 | } 211 | } 212 | 213 | private void hidePermissionHelperUI() { 214 | requestPermission.setVisibility(View.INVISIBLE); 215 | grantPermission.setVisibility(View.INVISIBLE); 216 | } 217 | 218 | private void showPermissionHelperUI() { 219 | requestPermission.setVisibility(View.VISIBLE); 220 | grantPermission.setVisibility(View.VISIBLE); 221 | } 222 | 223 | @Override 224 | protected void onStop() { 225 | super.onStop(); 226 | 227 | abortLoading(); 228 | 229 | getContentResolver().unregisterContentObserver(observer); 230 | observer = null; 231 | 232 | if (handler != null) { 233 | handler.removeCallbacksAndMessages(null); 234 | handler = null; 235 | } 236 | } 237 | 238 | @Override 239 | protected void onDestroy() { 240 | super.onDestroy(); 241 | 242 | if (actionBar != null) { 243 | actionBar.setHomeAsUpIndicator(null); 244 | } 245 | albums = null; 246 | if (adapter != null) { 247 | adapter.releaseResources(); 248 | } 249 | gridView.setOnItemClickListener(null); 250 | } 251 | 252 | @Override 253 | public void onConfigurationChanged(Configuration newConfig) { 254 | super.onConfigurationChanged(newConfig); 255 | orientationBasedUI(newConfig.orientation); 256 | } 257 | 258 | private void orientationBasedUI(int orientation) { 259 | final WindowManager windowManager = (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE); 260 | final DisplayMetrics metrics = new DisplayMetrics(); 261 | windowManager.getDefaultDisplay().getMetrics(metrics); 262 | 263 | if (adapter != null) { 264 | int size = orientation == Configuration.ORIENTATION_PORTRAIT ? metrics.widthPixels / 2 : metrics.widthPixels / 4; 265 | adapter.setLayoutParams(size); 266 | } 267 | gridView.setNumColumns(orientation == Configuration.ORIENTATION_PORTRAIT ? 2 : 4); 268 | } 269 | 270 | @Override 271 | public void onBackPressed() { 272 | super.onBackPressed(); 273 | setResult(RESULT_CANCELED); 274 | finish(); 275 | } 276 | 277 | @Override 278 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { 279 | super.onActivityResult(requestCode, resultCode, data); 280 | 281 | if (requestCode == Constants.REQUEST_CODE && resultCode == RESULT_OK && data != null) { 282 | setResult(RESULT_OK, data); 283 | finish(); 284 | } 285 | } 286 | 287 | @Override 288 | public boolean onOptionsItemSelected(MenuItem item) { 289 | switch (item.getItemId()) { 290 | case android.R.id.home: { 291 | onBackPressed(); 292 | return true; 293 | } 294 | 295 | default: { 296 | return false; 297 | } 298 | } 299 | } 300 | 301 | private void loadAlbums() { 302 | abortLoading(); 303 | 304 | AlbumLoaderRunnable runnable = new AlbumLoaderRunnable(); 305 | thread = new Thread(runnable); 306 | thread.start(); 307 | } 308 | 309 | 310 | private void abortLoading() { 311 | if (thread == null) { 312 | return; 313 | } 314 | 315 | if (thread.isAlive()) { 316 | thread.interrupt(); 317 | try { 318 | thread.join(); 319 | } catch (InterruptedException e) { 320 | e.printStackTrace(); 321 | } 322 | } 323 | } 324 | 325 | private class AlbumLoaderRunnable implements Runnable { 326 | @Override 327 | public void run() { 328 | android.os.Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); 329 | 330 | Message message; 331 | if (adapter == null) { 332 | message = handler.obtainMessage(); 333 | message.what = Constants.FETCH_STARTED; 334 | message.sendToTarget(); 335 | } 336 | 337 | if (Thread.interrupted()) { 338 | return; 339 | } 340 | 341 | Cursor cursor = getApplicationContext().getContentResolver() 342 | .query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection, 343 | null, null, MediaStore.Images.Media.DATE_ADDED); 344 | 345 | if (cursor == null) { 346 | message = handler.obtainMessage(); 347 | message.what = Constants.ERROR; 348 | message.sendToTarget(); 349 | return; 350 | } 351 | 352 | ArrayList temp = new ArrayList<>(cursor.getCount()); 353 | HashSet albumSet = new HashSet<>(); 354 | File file; 355 | 356 | if (cursor.moveToLast()) { 357 | do { 358 | if (Thread.interrupted()) { 359 | return; 360 | } 361 | 362 | String album = cursor.getString(cursor.getColumnIndex(projection[0])); 363 | String image = cursor.getString(cursor.getColumnIndex(projection[1])); 364 | 365 | /* 366 | It may happen that some image file paths are still present in cache, 367 | though image file does not exist. These last as long as media 368 | scanner is not run again. To avoid get such image file paths, check 369 | if image file exists. 370 | */ 371 | file = new File(image); 372 | if (file.exists() && !albumSet.contains(album)) { 373 | temp.add(new Album(album, image)); 374 | albumSet.add(album); 375 | } 376 | 377 | } while (cursor.moveToPrevious()); 378 | } 379 | cursor.close(); 380 | 381 | if (albums == null) { 382 | albums = new ArrayList<>(); 383 | } 384 | albums.clear(); 385 | albums.addAll(temp); 386 | 387 | message = handler.obtainMessage(); 388 | message.what = Constants.FETCH_COMPLETED; 389 | message.sendToTarget(); 390 | 391 | Thread.interrupted(); 392 | } 393 | } 394 | } 395 | -------------------------------------------------------------------------------- /multipleimageselect/src/main/java/com/darsh/multipleimageselect/activities/ImageSelectActivity.java: -------------------------------------------------------------------------------- 1 | package com.darsh.multipleimageselect.activities; 2 | 3 | import android.Manifest; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.content.pm.PackageManager; 7 | import android.content.res.Configuration; 8 | import android.database.ContentObserver; 9 | import android.database.Cursor; 10 | import android.os.Bundle; 11 | import android.os.Handler; 12 | import android.os.Message; 13 | import android.os.Process; 14 | import android.provider.MediaStore; 15 | import android.support.v4.app.ActivityCompat; 16 | import android.support.v4.content.ContextCompat; 17 | import android.support.v7.app.ActionBar; 18 | import android.support.v7.app.AppCompatActivity; 19 | import android.support.v7.widget.Toolbar; 20 | import android.util.DisplayMetrics; 21 | import android.view.ActionMode; 22 | import android.view.Menu; 23 | import android.view.MenuInflater; 24 | import android.view.MenuItem; 25 | import android.view.View; 26 | import android.view.WindowManager; 27 | import android.widget.AdapterView; 28 | import android.widget.Button; 29 | import android.widget.GridView; 30 | import android.widget.ProgressBar; 31 | import android.widget.TextView; 32 | import android.widget.Toast; 33 | 34 | import com.darsh.multipleimageselect.R; 35 | import com.darsh.multipleimageselect.adapters.CustomImageSelectAdapter; 36 | import com.darsh.multipleimageselect.helpers.Constants; 37 | import com.darsh.multipleimageselect.models.Image; 38 | 39 | import java.io.File; 40 | import java.util.ArrayList; 41 | import java.util.HashSet; 42 | 43 | /** 44 | * Created by Darshan on 4/18/2015. 45 | */ 46 | public class ImageSelectActivity extends AppCompatActivity { 47 | private ArrayList images; 48 | private String album; 49 | 50 | private TextView requestPermission; 51 | private Button grantPermission; 52 | private final String[] requiredPermissions = new String[]{ Manifest.permission.READ_EXTERNAL_STORAGE }; 53 | 54 | private TextView errorDisplay; 55 | 56 | private ProgressBar progressBar; 57 | private GridView gridView; 58 | private CustomImageSelectAdapter adapter; 59 | 60 | private ActionBar actionBar; 61 | 62 | private ActionMode actionMode; 63 | private int countSelected; 64 | 65 | private ContentObserver observer; 66 | private Handler handler; 67 | private Thread thread; 68 | 69 | private final String[] projection = new String[]{ MediaStore.Images.Media._ID, MediaStore.Images.Media.DISPLAY_NAME, MediaStore.Images.Media.DATA }; 70 | 71 | @Override 72 | protected void onCreate(Bundle savedInstanceState) { 73 | super.onCreate(savedInstanceState); 74 | setContentView(R.layout.activity_image_select); 75 | 76 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 77 | setSupportActionBar(toolbar); 78 | 79 | actionBar = getSupportActionBar(); 80 | if (actionBar != null) { 81 | actionBar.setDisplayHomeAsUpEnabled(true); 82 | actionBar.setHomeAsUpIndicator(R.drawable.ic_arrow_back); 83 | 84 | actionBar.setDisplayShowTitleEnabled(true); 85 | actionBar.setTitle(R.string.image_view); 86 | } 87 | 88 | Intent intent = getIntent(); 89 | if (intent == null) { 90 | finish(); 91 | } 92 | album = intent.getStringExtra(Constants.INTENT_EXTRA_ALBUM); 93 | 94 | errorDisplay = (TextView) findViewById(R.id.text_view_error); 95 | errorDisplay.setVisibility(View.INVISIBLE); 96 | 97 | requestPermission = (TextView) findViewById(R.id.text_view_request_permission); 98 | grantPermission = (Button) findViewById(R.id.button_grant_permission); 99 | grantPermission.setOnClickListener(new View.OnClickListener() { 100 | @Override 101 | public void onClick(View v) { 102 | requestPermission(); 103 | } 104 | }); 105 | hidePermissionHelperUI(); 106 | 107 | progressBar = (ProgressBar) findViewById(R.id.progress_bar_image_select); 108 | gridView = (GridView) findViewById(R.id.grid_view_image_select); 109 | gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { 110 | @Override 111 | public void onItemClick(AdapterView parent, View view, int position, long id) { 112 | if (actionMode == null) { 113 | actionMode = ImageSelectActivity.this.startActionMode(callback); 114 | } 115 | toggleSelection(position); 116 | actionMode.setTitle(countSelected + " " + getString(R.string.selected)); 117 | 118 | if (countSelected == 0) { 119 | actionMode.finish(); 120 | } 121 | } 122 | }); 123 | } 124 | 125 | @Override 126 | protected void onStart() { 127 | super.onStart(); 128 | 129 | handler = new Handler() { 130 | @Override 131 | public void handleMessage(Message msg) { 132 | switch (msg.what) { 133 | case Constants.PERMISSION_GRANTED: { 134 | hidePermissionHelperUI(); 135 | 136 | loadImages(); 137 | 138 | break; 139 | } 140 | 141 | case Constants.PERMISSION_DENIED: { 142 | showPermissionHelperUI(); 143 | 144 | progressBar.setVisibility(View.INVISIBLE); 145 | gridView.setVisibility(View.INVISIBLE); 146 | 147 | break; 148 | } 149 | 150 | case Constants.FETCH_STARTED: { 151 | progressBar.setVisibility(View.VISIBLE); 152 | gridView.setVisibility(View.INVISIBLE); 153 | 154 | break; 155 | } 156 | 157 | case Constants.FETCH_COMPLETED: { 158 | /* 159 | If adapter is null, this implies that the loaded images will be shown 160 | for the first time, hence send FETCH_COMPLETED message. 161 | However, if adapter has been initialised, this thread was run either 162 | due to the activity being restarted or content being changed. 163 | */ 164 | if (adapter == null) { 165 | adapter = new CustomImageSelectAdapter(getApplicationContext(), images); 166 | gridView.setAdapter(adapter); 167 | 168 | progressBar.setVisibility(View.INVISIBLE); 169 | gridView.setVisibility(View.VISIBLE); 170 | orientationBasedUI(getResources().getConfiguration().orientation); 171 | 172 | } else { 173 | adapter.notifyDataSetChanged(); 174 | /* 175 | Some selected images may have been deleted 176 | hence update action mode title 177 | */ 178 | if (actionMode != null) { 179 | countSelected = msg.arg1; 180 | actionMode.setTitle(countSelected + " " + getString(R.string.selected)); 181 | } 182 | } 183 | 184 | break; 185 | } 186 | 187 | case Constants.ERROR: { 188 | progressBar.setVisibility(View.INVISIBLE); 189 | errorDisplay.setVisibility(View.VISIBLE); 190 | } 191 | 192 | default: { 193 | super.handleMessage(msg); 194 | } 195 | } 196 | } 197 | }; 198 | observer = new ContentObserver(handler) { 199 | @Override 200 | public void onChange(boolean selfChange) { 201 | loadImages(); 202 | } 203 | }; 204 | getContentResolver().registerContentObserver(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, false, observer); 205 | 206 | checkIfPermissionGranted(); 207 | } 208 | 209 | private void checkIfPermissionGranted() { 210 | if (ContextCompat.checkSelfPermission(ImageSelectActivity.this, 211 | Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { 212 | requestPermission(); 213 | return; 214 | } 215 | 216 | Message message = handler.obtainMessage(); 217 | message.what = Constants.PERMISSION_GRANTED; 218 | message.sendToTarget(); 219 | } 220 | 221 | private void requestPermission() { 222 | ActivityCompat.requestPermissions(ImageSelectActivity.this, 223 | requiredPermissions, 224 | Constants.PERMISSION_REQUEST_READ_EXTERNAL_STORAGE); 225 | } 226 | 227 | @Override 228 | public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { 229 | if (requestCode == Constants.PERMISSION_REQUEST_READ_EXTERNAL_STORAGE) { 230 | Message message = handler.obtainMessage(); 231 | message.what = grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED ? Constants.PERMISSION_GRANTED : Constants.PERMISSION_DENIED; 232 | message.sendToTarget(); 233 | } 234 | } 235 | 236 | private void hidePermissionHelperUI() { 237 | requestPermission.setVisibility(View.INVISIBLE); 238 | grantPermission.setVisibility(View.INVISIBLE); 239 | } 240 | 241 | private void showPermissionHelperUI() { 242 | requestPermission.setVisibility(View.VISIBLE); 243 | grantPermission.setVisibility(View.VISIBLE); 244 | } 245 | 246 | @Override 247 | protected void onStop() { 248 | super.onStop(); 249 | 250 | abortLoading(); 251 | 252 | getContentResolver().unregisterContentObserver(observer); 253 | observer = null; 254 | 255 | if (handler != null) { 256 | handler.removeCallbacksAndMessages(null); 257 | handler = null; 258 | } 259 | } 260 | 261 | @Override 262 | protected void onDestroy() { 263 | super.onDestroy(); 264 | 265 | if (actionBar != null) { 266 | actionBar.setHomeAsUpIndicator(null); 267 | } 268 | images = null; 269 | if (adapter != null) { 270 | adapter.releaseResources(); 271 | } 272 | gridView.setOnItemClickListener(null); 273 | } 274 | 275 | @Override 276 | public void onConfigurationChanged(Configuration newConfig) { 277 | super.onConfigurationChanged(newConfig); 278 | orientationBasedUI(newConfig.orientation); 279 | } 280 | 281 | private void orientationBasedUI(int orientation) { 282 | final WindowManager windowManager = (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE); 283 | final DisplayMetrics metrics = new DisplayMetrics(); 284 | windowManager.getDefaultDisplay().getMetrics(metrics); 285 | 286 | if (adapter != null) { 287 | int size = orientation == Configuration.ORIENTATION_PORTRAIT ? metrics.widthPixels / 3 : metrics.widthPixels / 5; 288 | adapter.setLayoutParams(size); 289 | } 290 | gridView.setNumColumns(orientation == Configuration.ORIENTATION_PORTRAIT ? 3 : 5); 291 | } 292 | 293 | @Override 294 | public boolean onOptionsItemSelected(MenuItem item) { 295 | switch (item.getItemId()) { 296 | case android.R.id.home: { 297 | onBackPressed(); 298 | return true; 299 | } 300 | 301 | default: { 302 | return false; 303 | } 304 | } 305 | } 306 | 307 | private ActionMode.Callback callback = new ActionMode.Callback() { 308 | @Override 309 | public boolean onCreateActionMode(ActionMode mode, Menu menu) { 310 | MenuInflater menuInflater = mode.getMenuInflater(); 311 | menuInflater.inflate(R.menu.menu_contextual_action_bar, menu); 312 | 313 | actionMode = mode; 314 | countSelected = 0; 315 | 316 | return true; 317 | } 318 | 319 | @Override 320 | public boolean onPrepareActionMode(ActionMode mode, Menu menu) { 321 | return false; 322 | } 323 | 324 | @Override 325 | public boolean onActionItemClicked(ActionMode mode, MenuItem item) {int i = item.getItemId(); 326 | if (i == R.id.menu_item_add_image) { 327 | sendIntent(); 328 | return true; 329 | } 330 | return false; 331 | } 332 | 333 | @Override 334 | public void onDestroyActionMode(ActionMode mode) { 335 | if (countSelected > 0) { 336 | deselectAll(); 337 | } 338 | actionMode = null; 339 | } 340 | }; 341 | 342 | private void toggleSelection(int position) { 343 | if (!images.get(position).isSelected && countSelected >= Constants.limit) { 344 | Toast.makeText(getApplicationContext(), String.format(getString(R.string.limit_exceeded), Constants.limit), Toast.LENGTH_SHORT).show(); 345 | return; 346 | } 347 | 348 | images.get(position).isSelected = !images.get(position).isSelected; 349 | if (images.get(position).isSelected) { 350 | countSelected++; 351 | } else { 352 | countSelected--; 353 | } 354 | adapter.notifyDataSetChanged(); 355 | } 356 | 357 | private void deselectAll() { 358 | for (int i = 0, l = images.size(); i < l; i++) { 359 | images.get(i).isSelected = false; 360 | } 361 | countSelected = 0; 362 | adapter.notifyDataSetChanged(); 363 | } 364 | 365 | private ArrayList getSelected() { 366 | ArrayList selectedImages = new ArrayList<>(); 367 | for (int i = 0, l = images.size(); i < l; i++) { 368 | if (images.get(i).isSelected) { 369 | selectedImages.add(images.get(i)); 370 | } 371 | } 372 | return selectedImages; 373 | } 374 | 375 | private void sendIntent() { 376 | Intent intent = new Intent(); 377 | intent.putParcelableArrayListExtra(Constants.INTENT_EXTRA_IMAGES, getSelected()); 378 | setResult(RESULT_OK, intent); 379 | finish(); 380 | } 381 | 382 | private void loadImages() { 383 | abortLoading(); 384 | 385 | ImageLoaderRunnable runnable = new ImageLoaderRunnable(); 386 | thread = new Thread(runnable); 387 | thread.start(); 388 | } 389 | 390 | private void abortLoading() { 391 | if (thread == null) { 392 | return; 393 | } 394 | 395 | if (thread.isAlive()) { 396 | thread.interrupt(); 397 | try { 398 | thread.join(); 399 | } catch (InterruptedException e) { 400 | e.printStackTrace(); 401 | } 402 | } 403 | } 404 | 405 | private class ImageLoaderRunnable implements Runnable { 406 | @Override 407 | public void run() { 408 | android.os.Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); 409 | 410 | Message message; 411 | if (adapter == null) { 412 | message = handler.obtainMessage(); 413 | /* 414 | If the adapter is null, this is first time this activity's view is 415 | being shown, hence send FETCH_STARTED message to show progress bar 416 | while images are loaded from phone 417 | */ 418 | message.what = Constants.FETCH_STARTED; 419 | message.sendToTarget(); 420 | } 421 | 422 | if (Thread.interrupted()) { 423 | return; 424 | } 425 | 426 | File file; 427 | HashSet selectedImages = new HashSet<>(); 428 | if (images != null) { 429 | Image image; 430 | for (int i = 0, l = images.size(); i < l; i++) { 431 | image = images.get(i); 432 | file = new File(image.path); 433 | if (file.exists() && image.isSelected) { 434 | selectedImages.add(image.id); 435 | } 436 | } 437 | } 438 | 439 | Cursor cursor = getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection, 440 | MediaStore.Images.Media.BUCKET_DISPLAY_NAME + " =?", new String[]{ album }, MediaStore.Images.Media.DATE_ADDED); 441 | 442 | if (cursor == null) { 443 | message = handler.obtainMessage(); 444 | message.what = Constants.ERROR; 445 | message.sendToTarget(); 446 | return; 447 | } 448 | 449 | /* 450 | In case this runnable is executed to onChange calling loadImages, 451 | using countSelected variable can result in a race condition. To avoid that, 452 | tempCountSelected keeps track of number of selected images. On handling 453 | FETCH_COMPLETED message, countSelected is assigned value of tempCountSelected. 454 | */ 455 | int tempCountSelected = 0; 456 | ArrayList temp = new ArrayList<>(cursor.getCount()); 457 | 458 | if (cursor.moveToLast()) { 459 | do { 460 | if (Thread.interrupted()) { 461 | return; 462 | } 463 | 464 | long id = cursor.getLong(cursor.getColumnIndex(projection[0])); 465 | String name = cursor.getString(cursor.getColumnIndex(projection[1])); 466 | String path = cursor.getString(cursor.getColumnIndex(projection[2])); 467 | boolean isSelected = selectedImages.contains(id); 468 | if (isSelected) { 469 | tempCountSelected++; 470 | } 471 | 472 | file = new File(path); 473 | if (file.exists()) { 474 | temp.add(new Image(id, name, path, isSelected)); 475 | } 476 | 477 | } while (cursor.moveToPrevious()); 478 | } 479 | cursor.close(); 480 | 481 | if (images == null) { 482 | images = new ArrayList<>(); 483 | } 484 | images.clear(); 485 | images.addAll(temp); 486 | 487 | message = handler.obtainMessage(); 488 | message.what = Constants.FETCH_COMPLETED; 489 | message.arg1 = tempCountSelected; 490 | message.sendToTarget(); 491 | 492 | Thread.interrupted(); 493 | } 494 | } 495 | } 496 | -------------------------------------------------------------------------------- /multipleimageselect/src/main/java/com/darsh/multipleimageselect/adapters/CustomAlbumSelectAdapter.java: -------------------------------------------------------------------------------- 1 | package com.darsh.multipleimageselect.adapters; 2 | 3 | import android.content.Context; 4 | import android.view.View; 5 | import android.view.ViewGroup; 6 | import android.widget.ImageView; 7 | import android.widget.TextView; 8 | 9 | import com.bumptech.glide.Glide; 10 | import com.bumptech.glide.request.RequestOptions; 11 | import com.darsh.multipleimageselect.R; 12 | import com.darsh.multipleimageselect.models.Album; 13 | 14 | import java.util.ArrayList; 15 | 16 | /** 17 | * Created by Darshan on 4/14/2015. 18 | */ 19 | public class CustomAlbumSelectAdapter extends CustomGenericAdapter { 20 | public CustomAlbumSelectAdapter(Context context, ArrayList albums) { 21 | super(context, albums); 22 | } 23 | 24 | @Override 25 | public View getView(int position, View convertView, ViewGroup parent) { 26 | ViewHolder viewHolder; 27 | 28 | if (convertView == null) { 29 | convertView = layoutInflater.inflate(R.layout.grid_view_item_album_select, null); 30 | 31 | viewHolder = new ViewHolder(); 32 | viewHolder.imageView = (ImageView) convertView.findViewById(R.id.image_view_album_image); 33 | viewHolder.textView = (TextView) convertView.findViewById(R.id.text_view_album_name); 34 | 35 | convertView.setTag(viewHolder); 36 | 37 | } else { 38 | viewHolder = (ViewHolder) convertView.getTag(); 39 | } 40 | 41 | viewHolder.imageView.getLayoutParams().width = size; 42 | viewHolder.imageView.getLayoutParams().height = size; 43 | 44 | viewHolder.textView.setText(arrayList.get(position).name); 45 | RequestOptions options = new RequestOptions().centerCrop().placeholder(R.drawable.image_placeholder); 46 | Glide.with(context) 47 | .load(arrayList.get(position).cover) 48 | .apply(options).into(viewHolder.imageView); 49 | return convertView; 50 | } 51 | 52 | private static class ViewHolder { 53 | public ImageView imageView; 54 | public TextView textView; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /multipleimageselect/src/main/java/com/darsh/multipleimageselect/adapters/CustomGenericAdapter.java: -------------------------------------------------------------------------------- 1 | package com.darsh.multipleimageselect.adapters; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.widget.BaseAdapter; 6 | 7 | import java.util.ArrayList; 8 | 9 | /** 10 | * Created by Darshan on 4/24/2015. 11 | */ 12 | public abstract class CustomGenericAdapter extends BaseAdapter { 13 | protected ArrayList arrayList; 14 | protected Context context; 15 | protected LayoutInflater layoutInflater; 16 | 17 | protected int size; 18 | 19 | public CustomGenericAdapter(Context context, ArrayList arrayList) { 20 | this.arrayList = arrayList; 21 | this.context = context; 22 | this.layoutInflater = LayoutInflater.from(this.context); 23 | } 24 | 25 | @Override 26 | public int getCount() { 27 | return arrayList.size(); 28 | } 29 | 30 | public T getItem(int position) { 31 | return arrayList.get(position); 32 | } 33 | 34 | @Override 35 | public long getItemId(int position) { 36 | return position; 37 | } 38 | 39 | public void setLayoutParams(int size) { 40 | this.size = size; 41 | } 42 | 43 | public void releaseResources() { 44 | arrayList = null; 45 | context = null; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /multipleimageselect/src/main/java/com/darsh/multipleimageselect/adapters/CustomImageSelectAdapter.java: -------------------------------------------------------------------------------- 1 | package com.darsh.multipleimageselect.adapters; 2 | 3 | import android.content.Context; 4 | import android.view.View; 5 | import android.view.ViewGroup; 6 | import android.widget.FrameLayout; 7 | import android.widget.ImageView; 8 | 9 | import com.bumptech.glide.Glide; 10 | import com.bumptech.glide.request.RequestOptions; 11 | import com.darsh.multipleimageselect.R; 12 | import com.darsh.multipleimageselect.models.Image; 13 | 14 | import java.util.ArrayList; 15 | 16 | /** 17 | * Created by Darshan on 4/18/2015. 18 | */ 19 | public class CustomImageSelectAdapter extends CustomGenericAdapter { 20 | public CustomImageSelectAdapter(Context context, ArrayList images) { 21 | super(context, images); 22 | } 23 | 24 | @Override 25 | public View getView(int position, View convertView, ViewGroup parent) { 26 | ViewHolder viewHolder; 27 | 28 | if (convertView == null) { 29 | convertView = layoutInflater.inflate(R.layout.grid_view_item_image_select, null); 30 | 31 | viewHolder = new ViewHolder(); 32 | viewHolder.imageView = (ImageView) convertView.findViewById(R.id.image_view_image_select); 33 | viewHolder.view = convertView.findViewById(R.id.view_alpha); 34 | 35 | convertView.setTag(viewHolder); 36 | 37 | } else { 38 | viewHolder = (ViewHolder) convertView.getTag(); 39 | } 40 | 41 | viewHolder.imageView.getLayoutParams().width = size; 42 | viewHolder.imageView.getLayoutParams().height = size; 43 | 44 | viewHolder.view.getLayoutParams().width = size; 45 | viewHolder.view.getLayoutParams().height = size; 46 | 47 | if (arrayList.get(position).isSelected) { 48 | viewHolder.view.setAlpha(0.5f); 49 | ((FrameLayout) convertView).setForeground(context.getResources().getDrawable(R.drawable.ic_done_white)); 50 | 51 | } else { 52 | viewHolder.view.setAlpha(0.0f); 53 | ((FrameLayout) convertView).setForeground(null); 54 | } 55 | RequestOptions options = new RequestOptions().placeholder(R.drawable.image_placeholder); 56 | Glide.with(context) 57 | .load(arrayList.get(position).path) 58 | .apply(options).into(viewHolder.imageView); 59 | 60 | return convertView; 61 | } 62 | 63 | private static class ViewHolder { 64 | public ImageView imageView; 65 | public View view; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /multipleimageselect/src/main/java/com/darsh/multipleimageselect/helpers/Constants.java: -------------------------------------------------------------------------------- 1 | package com.darsh.multipleimageselect.helpers; 2 | 3 | /** 4 | * Created by Darshan on 5/26/2015. 5 | */ 6 | public class Constants { 7 | public static final int REQUEST_CODE = 2000; 8 | 9 | public static final int FETCH_STARTED = 2001; 10 | public static final int FETCH_COMPLETED = 2002; 11 | public static final int PERMISSION_GRANTED = 2003; 12 | public static final int PERMISSION_DENIED = 2004; 13 | public static final int ERROR = 2005; 14 | 15 | /** 16 | * Request code for permission has to be < (1 << 8) 17 | * Otherwise throws java.lang.IllegalArgumentException: Can only use lower 8 bits for requestCode 18 | */ 19 | public static final int PERMISSION_REQUEST_READ_EXTERNAL_STORAGE = 23; 20 | 21 | public static final String INTENT_EXTRA_ALBUM = "album"; 22 | public static final String INTENT_EXTRA_IMAGES = "images"; 23 | public static final String INTENT_EXTRA_LIMIT = "limit"; 24 | public static final int DEFAULT_LIMIT = 10; 25 | 26 | //Maximum number of images that can be selected at a time 27 | public static int limit; 28 | } 29 | -------------------------------------------------------------------------------- /multipleimageselect/src/main/java/com/darsh/multipleimageselect/models/Album.java: -------------------------------------------------------------------------------- 1 | package com.darsh.multipleimageselect.models; 2 | 3 | /** 4 | * Created by Darshan on 4/14/2015. 5 | */ 6 | public class Album { 7 | public String name; 8 | public String cover; 9 | 10 | public Album(String name, String cover) { 11 | this.name = name; 12 | this.cover = cover; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /multipleimageselect/src/main/java/com/darsh/multipleimageselect/models/Image.java: -------------------------------------------------------------------------------- 1 | package com.darsh.multipleimageselect.models; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | 6 | /** 7 | * Created by Darshan on 4/18/2015. 8 | */ 9 | public class Image implements Parcelable { 10 | public long id; 11 | public String name; 12 | public String path; 13 | public boolean isSelected; 14 | 15 | public Image(long id, String name, String path, boolean isSelected) { 16 | this.id = id; 17 | this.name = name; 18 | this.path = path; 19 | this.isSelected = isSelected; 20 | } 21 | 22 | @Override 23 | public int describeContents() { 24 | return 0; 25 | } 26 | 27 | @Override 28 | public void writeToParcel(Parcel dest, int flags) { 29 | dest.writeLong(id); 30 | dest.writeString(name); 31 | dest.writeString(path); 32 | } 33 | 34 | public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { 35 | @Override 36 | public Image createFromParcel(Parcel source) { 37 | return new Image(source); 38 | } 39 | 40 | @Override 41 | public Image[] newArray(int size) { 42 | return new Image[size]; 43 | } 44 | }; 45 | 46 | private Image(Parcel in) { 47 | id = in.readLong(); 48 | name = in.readString(); 49 | path = in.readString(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /multipleimageselect/src/main/res/drawable-hdpi/ic_arrow_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazycodeboy/MultipleImageSelect/81fd3914d4d21d6f249a07f354fcb6edeb8b45f0/multipleimageselect/src/main/res/drawable-hdpi/ic_arrow_back.png -------------------------------------------------------------------------------- /multipleimageselect/src/main/res/drawable-hdpi/ic_done_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazycodeboy/MultipleImageSelect/81fd3914d4d21d6f249a07f354fcb6edeb8b45f0/multipleimageselect/src/main/res/drawable-hdpi/ic_done_white.png -------------------------------------------------------------------------------- /multipleimageselect/src/main/res/drawable-mdpi/ic_arrow_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazycodeboy/MultipleImageSelect/81fd3914d4d21d6f249a07f354fcb6edeb8b45f0/multipleimageselect/src/main/res/drawable-mdpi/ic_arrow_back.png -------------------------------------------------------------------------------- /multipleimageselect/src/main/res/drawable-mdpi/ic_done_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazycodeboy/MultipleImageSelect/81fd3914d4d21d6f249a07f354fcb6edeb8b45f0/multipleimageselect/src/main/res/drawable-mdpi/ic_done_white.png -------------------------------------------------------------------------------- /multipleimageselect/src/main/res/drawable-xhdpi/ic_arrow_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazycodeboy/MultipleImageSelect/81fd3914d4d21d6f249a07f354fcb6edeb8b45f0/multipleimageselect/src/main/res/drawable-xhdpi/ic_arrow_back.png -------------------------------------------------------------------------------- /multipleimageselect/src/main/res/drawable-xhdpi/ic_done_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazycodeboy/MultipleImageSelect/81fd3914d4d21d6f249a07f354fcb6edeb8b45f0/multipleimageselect/src/main/res/drawable-xhdpi/ic_done_white.png -------------------------------------------------------------------------------- /multipleimageselect/src/main/res/drawable-xxhdpi/ic_arrow_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazycodeboy/MultipleImageSelect/81fd3914d4d21d6f249a07f354fcb6edeb8b45f0/multipleimageselect/src/main/res/drawable-xxhdpi/ic_arrow_back.png -------------------------------------------------------------------------------- /multipleimageselect/src/main/res/drawable-xxhdpi/ic_done_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crazycodeboy/MultipleImageSelect/81fd3914d4d21d6f249a07f354fcb6edeb8b45f0/multipleimageselect/src/main/res/drawable-xxhdpi/ic_done_white.png -------------------------------------------------------------------------------- /multipleimageselect/src/main/res/drawable/image_placeholder.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /multipleimageselect/src/main/res/layout/activity_album_select.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 11 | 19 | 20 | 25 | 26 | 32 | 33 | 43 | 44 |