├── app ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── values │ │ │ ├── strings.xml │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ └── styles.xml │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ ├── image_add_nor.png │ │ │ └── image_add_sel.png │ │ ├── drawable │ │ │ └── selector_image_add.xml │ │ └── layout │ │ │ ├── list_item_image.xml │ │ │ ├── video_item.xml │ │ │ └── activity_wxdemo.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── com │ │ └── pbq │ │ └── imagepickerdemo │ │ ├── imageloader │ │ ├── UILImageLoader.java │ │ ├── PicassoImageLoader.java │ │ ├── GlideImageLoader.java │ │ └── XUtils3ImageLoader.java │ │ ├── GApp.java │ │ └── wxdemo │ │ ├── ImagePickerAdapter.java │ │ └── WxDemoActivity.java ├── proguard-rules.pro └── build.gradle ├── imagepicker ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── mipmap-xxhdpi │ │ │ ├── play.png │ │ │ ├── ic_back.png │ │ │ ├── ic_del.png │ │ │ ├── default_image.png │ │ │ ├── grid_camera.png │ │ │ ├── grid_record.png │ │ │ ├── list_selected.png │ │ │ ├── checkbox_normal.png │ │ │ ├── text_indicator.png │ │ │ ├── checkbox_checked.png │ │ │ └── grid_record_white.png │ │ ├── drawable-xxhdpi │ │ │ ├── bg_btn_dis.9.png │ │ │ ├── bg_btn_nor.9.png │ │ │ └── bg_btn_pre.9.png │ │ ├── anim │ │ │ ├── top_in.xml │ │ │ ├── show_from_bottom.xml │ │ │ ├── hide_to_bottom.xml │ │ │ ├── fade_in.xml │ │ │ ├── fade_out.xml │ │ │ ├── left_out.xml │ │ │ ├── right_out.xml │ │ │ ├── bottom_in.xml │ │ │ ├── bottom_out.xml │ │ │ ├── top_out.xml │ │ │ ├── left_in.xml │ │ │ ├── right_in.xml │ │ │ ├── scale_in.xml │ │ │ └── scale_out.xml │ │ ├── drawable │ │ │ ├── selector_grid_camera_bg.xml │ │ │ ├── selector_item_checked.xml │ │ │ ├── selector_back_press.xml │ │ │ └── selector_top_ok.xml │ │ ├── values │ │ │ ├── colors.xml │ │ │ ├── attrs.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ └── layout │ │ │ ├── viewpager_video_item.xml │ │ │ ├── adapter_camera_item.xml │ │ │ ├── adapter_record_item.xml │ │ │ ├── pop_folder.xml │ │ │ ├── adapter_image_item.xml │ │ │ ├── activity_image_crop.xml │ │ │ ├── adapter_folder_image_item.xml │ │ │ ├── activity_image_preview.xml │ │ │ ├── activity_video_preview.xml │ │ │ ├── adapter_video_item.xml │ │ │ ├── adapter_folder_video_item.xml │ │ │ ├── include_top_bar.xml │ │ │ ├── activity_image_grid.xml │ │ │ └── activity_video_grid.xml │ │ ├── java │ │ └── com │ │ │ └── pbq │ │ │ └── imagepicker │ │ │ ├── loader │ │ │ └── ImageLoader.java │ │ │ ├── bean │ │ │ ├── VideoFolder.java │ │ │ ├── ImageFolder.java │ │ │ ├── ImageItem.java │ │ │ └── VideoItem.java │ │ │ ├── view │ │ │ ├── SuperCheckBox.java │ │ │ ├── ViewPagerFixed.java │ │ │ └── FolderPopUpWindow.java │ │ │ ├── ui │ │ │ ├── image │ │ │ │ ├── ImageBaseActivity.java │ │ │ │ ├── ImagePreviewBaseActivity.java │ │ │ │ ├── ImagePreviewDelActivity.java │ │ │ │ ├── ImageCropActivity.java │ │ │ │ └── ImagePreviewActivity.java │ │ │ └── video │ │ │ │ ├── VideoPreviewBaseActivity.java │ │ │ │ └── VideoPreviewActivity.java │ │ │ ├── Utils.java │ │ │ ├── adapter │ │ │ ├── image │ │ │ │ ├── ImagePageAdapter.java │ │ │ │ ├── ImageFolderAdapter.java │ │ │ │ └── ImageGridAdapter.java │ │ │ └── video │ │ │ │ ├── VideoFolderAdapter.java │ │ │ │ ├── VideoPageAdapter.java │ │ │ │ └── VideoGridAdapter.java │ │ │ ├── ImageDataSource.java │ │ │ ├── VideoDataSource.java │ │ │ ├── VideoPicker.java │ │ │ └── ImagePicker.java │ │ └── AndroidManifest.xml ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── README.md ├── .gitignore ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── gradlew.bat └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /imagepicker/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':imagepicker' 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ImagePicker 2 | ###Android自定义相册,完全仿微信UI,实现了拍照、图片、录像、视频选择(单选/多选)、 裁剪 、旋转、等功能。 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | .idea 4 | /local.properties 5 | .DS_Store 6 | /build 7 | /captures 8 | /screenshots 9 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ImagePicker 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolanda0628/ImagePicker-master/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolanda0628/ImagePicker-master/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/image_add_nor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolanda0628/ImagePicker-master/HEAD/app/src/main/res/mipmap-hdpi/image_add_nor.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/image_add_sel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolanda0628/ImagePicker-master/HEAD/app/src/main/res/mipmap-hdpi/image_add_sel.png -------------------------------------------------------------------------------- /imagepicker/src/main/res/mipmap-xxhdpi/play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolanda0628/ImagePicker-master/HEAD/imagepicker/src/main/res/mipmap-xxhdpi/play.png -------------------------------------------------------------------------------- /imagepicker/src/main/res/mipmap-xxhdpi/ic_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolanda0628/ImagePicker-master/HEAD/imagepicker/src/main/res/mipmap-xxhdpi/ic_back.png -------------------------------------------------------------------------------- /imagepicker/src/main/res/mipmap-xxhdpi/ic_del.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolanda0628/ImagePicker-master/HEAD/imagepicker/src/main/res/mipmap-xxhdpi/ic_del.png -------------------------------------------------------------------------------- /imagepicker/src/main/res/mipmap-xxhdpi/default_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolanda0628/ImagePicker-master/HEAD/imagepicker/src/main/res/mipmap-xxhdpi/default_image.png -------------------------------------------------------------------------------- /imagepicker/src/main/res/mipmap-xxhdpi/grid_camera.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolanda0628/ImagePicker-master/HEAD/imagepicker/src/main/res/mipmap-xxhdpi/grid_camera.png -------------------------------------------------------------------------------- /imagepicker/src/main/res/mipmap-xxhdpi/grid_record.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolanda0628/ImagePicker-master/HEAD/imagepicker/src/main/res/mipmap-xxhdpi/grid_record.png -------------------------------------------------------------------------------- /imagepicker/src/main/res/mipmap-xxhdpi/list_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolanda0628/ImagePicker-master/HEAD/imagepicker/src/main/res/mipmap-xxhdpi/list_selected.png -------------------------------------------------------------------------------- /imagepicker/src/main/res/drawable-xxhdpi/bg_btn_dis.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolanda0628/ImagePicker-master/HEAD/imagepicker/src/main/res/drawable-xxhdpi/bg_btn_dis.9.png -------------------------------------------------------------------------------- /imagepicker/src/main/res/drawable-xxhdpi/bg_btn_nor.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolanda0628/ImagePicker-master/HEAD/imagepicker/src/main/res/drawable-xxhdpi/bg_btn_nor.9.png -------------------------------------------------------------------------------- /imagepicker/src/main/res/drawable-xxhdpi/bg_btn_pre.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolanda0628/ImagePicker-master/HEAD/imagepicker/src/main/res/drawable-xxhdpi/bg_btn_pre.9.png -------------------------------------------------------------------------------- /imagepicker/src/main/res/mipmap-xxhdpi/checkbox_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolanda0628/ImagePicker-master/HEAD/imagepicker/src/main/res/mipmap-xxhdpi/checkbox_normal.png -------------------------------------------------------------------------------- /imagepicker/src/main/res/mipmap-xxhdpi/text_indicator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolanda0628/ImagePicker-master/HEAD/imagepicker/src/main/res/mipmap-xxhdpi/text_indicator.png -------------------------------------------------------------------------------- /imagepicker/src/main/res/mipmap-xxhdpi/checkbox_checked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolanda0628/ImagePicker-master/HEAD/imagepicker/src/main/res/mipmap-xxhdpi/checkbox_checked.png -------------------------------------------------------------------------------- /imagepicker/src/main/res/mipmap-xxhdpi/grid_record_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yolanda0628/ImagePicker-master/HEAD/imagepicker/src/main/res/mipmap-xxhdpi/grid_record_white.png -------------------------------------------------------------------------------- /imagepicker/src/main/res/anim/top_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Oct 07 00:32:14 CST 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 7 | -------------------------------------------------------------------------------- /imagepicker/src/main/res/drawable/selector_grid_camera_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /imagepicker/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #cc22292c 4 | #000000 5 | #303135 6 | #9f556061 7 | #00000000 8 | -------------------------------------------------------------------------------- /imagepicker/src/main/res/drawable/selector_item_checked.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /imagepicker/src/main/res/anim/show_from_bottom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /imagepicker/src/main/res/anim/hide_to_bottom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/selector_image_add.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /imagepicker/src/main/res/drawable/selector_back_press.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /imagepicker/src/main/res/drawable/selector_top_ok.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /imagepicker/src/main/java/com/pbq/imagepicker/loader/ImageLoader.java: -------------------------------------------------------------------------------- 1 | package com.pbq.imagepicker.loader; 2 | 3 | import android.app.Activity; 4 | import android.widget.ImageView; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * ImageLoader抽象类,外部需要实现这个类去加载图片, 尽力减少对第三方库的依赖,所以这么干了 10 | */ 11 | public interface ImageLoader extends Serializable { 12 | 13 | void displayImage(Activity activity, String path, ImageView imageView, int width, int height); 14 | 15 | void clearMemoryCache(Activity activity); 16 | } 17 | -------------------------------------------------------------------------------- /app/src/main/res/layout/list_item_image.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 15 | 16 | -------------------------------------------------------------------------------- /imagepicker/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /imagepicker/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 全部图片 3 | 共%1$d张 4 | %1$s/%2$s 5 | 最多选择%1$s张图片 6 | 最多选择%1$s个视频 7 | 完成 8 | 完成(%1$s/%2$s) 9 | 预览(%1$s) 10 | 图片裁剪 11 | 原图 12 | 原图(%1$s) 13 | 14 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in 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 | -------------------------------------------------------------------------------- /imagepicker/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 | -------------------------------------------------------------------------------- /app/src/main/res/layout/video_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 12 | 19 | -------------------------------------------------------------------------------- /imagepicker/src/main/res/layout/viewpager_video_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 12 | 19 | -------------------------------------------------------------------------------- /imagepicker/src/main/res/layout/adapter_camera_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 20 | 21 | -------------------------------------------------------------------------------- /imagepicker/src/main/res/layout/adapter_record_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 20 | 21 | -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /imagepicker/src/main/java/com/pbq/imagepicker/bean/VideoFolder.java: -------------------------------------------------------------------------------- 1 | package com.pbq.imagepicker.bean; 2 | 3 | /** 4 | * Created by pengbangqin on 2016/12/27. 5 | * 视频文件夹 6 | */ 7 | 8 | import java.io.Serializable; 9 | import java.util.ArrayList; 10 | 11 | public class VideoFolder implements Serializable { 12 | 13 | public String name; //当前文件夹的名字 14 | public String path; //当前文件夹的路径 15 | public VideoItem cover; //当前文件夹需要要显示的缩略图,默认为最近的一次视频 16 | public ArrayList videos; //当前文件夹下所有视频的集合 17 | 18 | /** 只要文件夹的路径和名字相同,就认为是相同的文件夹 */ 19 | @Override 20 | public boolean equals(Object o) { 21 | try { 22 | VideoFolder other = (VideoFolder) o; 23 | return this.path.equalsIgnoreCase(other.path) && this.name.equalsIgnoreCase(other.name); 24 | } catch (ClassCastException e) { 25 | e.printStackTrace(); 26 | } 27 | return super.equals(o); 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /imagepicker/src/main/res/anim/fade_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | -------------------------------------------------------------------------------- /imagepicker/src/main/res/anim/fade_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | -------------------------------------------------------------------------------- /imagepicker/src/main/res/anim/left_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | -------------------------------------------------------------------------------- /imagepicker/src/main/res/anim/right_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | -------------------------------------------------------------------------------- /imagepicker/src/main/res/anim/bottom_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | -------------------------------------------------------------------------------- /imagepicker/src/main/res/anim/bottom_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | -------------------------------------------------------------------------------- /imagepicker/src/main/res/anim/top_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | -------------------------------------------------------------------------------- /imagepicker/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 11 | 12 | 13 | 16 | 17 | 23 | -------------------------------------------------------------------------------- /imagepicker/src/main/res/anim/left_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 23 | -------------------------------------------------------------------------------- /imagepicker/src/main/res/anim/right_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 23 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_wxdemo.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 22 | 23 | -------------------------------------------------------------------------------- /imagepicker/src/main/res/anim/scale_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | -------------------------------------------------------------------------------- /imagepicker/src/main/res/anim/scale_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | -------------------------------------------------------------------------------- /imagepicker/src/main/res/layout/pop_folder.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 | 18 | 19 | 24 | 25 | 26 | 31 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 24 5 | buildToolsVersion "24.0.2" 6 | 7 | defaultConfig { 8 | applicationId "com.lzy.imagepickerdemo" 9 | minSdkVersion 14 10 | targetSdkVersion 24 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(include: ['*.jar'], dir: 'libs') 24 | compile 'com.android.support:appcompat-v7:24.2.1' 25 | compile 'com.android.support:recyclerview-v7:24.2.1' 26 | 27 | compile 'com.squareup.picasso:picasso:2.5.2' 28 | compile 'org.xutils:xutils:3.3.36' 29 | compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5' 30 | // compile 'com.pbq:imagepicker:1.1.0' 31 | compile 'com.lzy.widget:view-core:0.2.1' 32 | // compile 'com.lzy.widget:imagepicker:+' 33 | compile project(':imagepicker') 34 | } 35 | -------------------------------------------------------------------------------- /imagepicker/src/main/java/com/pbq/imagepicker/bean/ImageFolder.java: -------------------------------------------------------------------------------- 1 | package com.pbq.imagepicker.bean; 2 | 3 | import java.io.Serializable; 4 | import java.util.ArrayList; 5 | 6 | /** 7 | * ================================================ 8 | * 作 者:jeasonlzy(廖子尧 Github地址:https://github.com/jeasonlzy0216 9 | * 版 本:1.0 10 | * 创建日期:2016/5/19 11 | * 描 述:图片文件夹 12 | * 修订历史: 13 | * ================================================ 14 | */ 15 | public class ImageFolder implements Serializable { 16 | 17 | public String name; //当前文件夹的名字 18 | public String path; //当前文件夹的路径 19 | public ImageItem cover; //当前文件夹需要要显示的缩略图,默认为最近的一次图片 20 | public ArrayList images; //当前文件夹下所有图片的集合 21 | 22 | /** 只要文件夹的路径和名字相同,就认为是相同的文件夹 */ 23 | @Override 24 | public boolean equals(Object o) { 25 | try { 26 | ImageFolder other = (ImageFolder) o; 27 | return this.path.equalsIgnoreCase(other.path) && this.name.equalsIgnoreCase(other.name); 28 | } catch (ClassCastException e) { 29 | e.printStackTrace(); 30 | } 31 | return super.equals(o); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/pbq/imagepickerdemo/imageloader/UILImageLoader.java: -------------------------------------------------------------------------------- 1 | package com.pbq.imagepickerdemo.imageloader; 2 | 3 | /** 4 | * ================================================ 5 | * 作 者:jeasonlzy(廖子尧) 6 | * 版 本:1.0 7 | * 创建日期:2016/3/28 8 | * 描 述:我的Github地址 https://github.com/jeasonlzy0216 9 | * 修订历史: 10 | * ================================================ 11 | */ 12 | 13 | import android.app.Activity; 14 | import android.net.Uri; 15 | import android.widget.ImageView; 16 | 17 | import com.pbq.imagepicker.loader.ImageLoader; 18 | import com.nostra13.universalimageloader.core.assist.ImageSize; 19 | 20 | import java.io.File; 21 | 22 | public class UILImageLoader implements ImageLoader { 23 | 24 | @Override 25 | public void displayImage(Activity activity, String path, ImageView imageView, int width, int height) { 26 | ImageSize size = new ImageSize(width, height); 27 | com.nostra13.universalimageloader.core.ImageLoader.getInstance().displayImage(Uri.fromFile(new File(path)).toString(), imageView, size); 28 | } 29 | 30 | @Override 31 | public void clearMemoryCache(Activity activity) { 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /imagepicker/src/main/res/layout/adapter_image_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 13 | 14 | 20 | 21 | 29 | -------------------------------------------------------------------------------- /imagepicker/src/main/java/com/pbq/imagepicker/bean/ImageItem.java: -------------------------------------------------------------------------------- 1 | package com.pbq.imagepicker.bean; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * ================================================ 7 | * 作 者:jeasonlzy(廖子尧 Github地址:https://github.com/jeasonlzy0216 8 | * 版 本:1.0 9 | * 创建日期:2016/5/19 10 | * 描 述:图片信息 11 | * 修订历史: 12 | * ================================================ 13 | */ 14 | public class ImageItem implements Serializable { 15 | 16 | public String name; //图片的名字 17 | public String path; //图片的路径 18 | public long size; //图片的大小 19 | public int width; //图片的宽度 20 | public int height; //图片的高度 21 | public String mimeType; //图片的类型 22 | public long addTime; //图片的创建时间 23 | 24 | /** 图片的路径和创建时间相同就认为是同一张图片 */ 25 | @Override 26 | public boolean equals(Object o) { 27 | try { 28 | ImageItem other = (ImageItem) o; 29 | return this.path.equalsIgnoreCase(other.path) && this.addTime == other.addTime; 30 | } catch (ClassCastException e) { 31 | e.printStackTrace(); 32 | } 33 | return super.equals(o); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /imagepicker/src/main/java/com/pbq/imagepicker/bean/VideoItem.java: -------------------------------------------------------------------------------- 1 | package com.pbq.imagepicker.bean; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * ================================================ 7 | * 作 者:jeasonlzy(廖子尧 Github地址:https://github.com/jeasonlzy0216 8 | * 版 本:1.0 9 | * 创建日期:2016/5/19 10 | * 描 述:视频信息 11 | * 修订历史: 12 | * ================================================ 13 | */ 14 | public class VideoItem implements Serializable { 15 | 16 | public String name; //视频的名字 17 | public String path; //视频的路径 18 | public long size; //视频的大小 19 | public int width; //视频的宽度 20 | public int height; //视频的高度 21 | public String mimeType; //视频的类型 22 | public long addTime; //视频的创建时间 23 | public long timeLong; //视频的时长 24 | 25 | /** 视频的路径和创建时间相同就认为是同一个视频 */ 26 | @Override 27 | public boolean equals(Object o) { 28 | try { 29 | VideoItem other = (VideoItem) o; 30 | return this.path.equalsIgnoreCase(other.path) && this.addTime == other.addTime; 31 | } catch (ClassCastException e) { 32 | e.printStackTrace(); 33 | } 34 | return super.equals(o); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /imagepicker/src/main/java/com/pbq/imagepicker/view/SuperCheckBox.java: -------------------------------------------------------------------------------- 1 | package com.pbq.imagepicker.view; 2 | 3 | import android.content.Context; 4 | import android.util.AttributeSet; 5 | import android.view.SoundEffectConstants; 6 | import android.widget.CheckBox; 7 | 8 | /** 9 | * ================================================ 10 | * 作 者:jeasonlzy(廖子尧 Github地址:https://github.com/jeasonlzy0216 11 | * 版 本:1.0 12 | * 创建日期:2016/5/19 13 | * 描 述:带声音的CheckBox 14 | * 修订历史: 15 | * ================================================ 16 | */ 17 | public class SuperCheckBox extends CheckBox { 18 | 19 | public SuperCheckBox(Context context) { 20 | super(context); 21 | } 22 | 23 | public SuperCheckBox(Context context, AttributeSet attrs) { 24 | super(context, attrs); 25 | } 26 | 27 | public SuperCheckBox(Context context, AttributeSet attrs, int defStyle) { 28 | super(context, attrs, defStyle); 29 | } 30 | 31 | @Override 32 | public boolean performClick() { 33 | final boolean handled = super.performClick(); 34 | if (!handled) { 35 | // View only makes a sound effect if the onClickListener was 36 | // called, so we'll need to make one here instead. 37 | playSoundEffect(SoundEffectConstants.CLICK); 38 | } 39 | return handled; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/com/pbq/imagepickerdemo/imageloader/PicassoImageLoader.java: -------------------------------------------------------------------------------- 1 | package com.pbq.imagepickerdemo.imageloader; 2 | 3 | /** 4 | * ================================================ 5 | * 作 者:jeasonlzy(廖子尧) 6 | * 版 本:1.0 7 | * 创建日期:2016/3/28 8 | * 描 述:我的Github地址 https://github.com/jeasonlzy0216 9 | * 修订历史: 10 | * ================================================ 11 | */ 12 | 13 | import android.app.Activity; 14 | import android.widget.ImageView; 15 | 16 | import com.pbq.imagepicker.loader.ImageLoader; 17 | import com.pbq.imagepickerdemo.R; 18 | import com.squareup.picasso.MemoryPolicy; 19 | import com.squareup.picasso.Picasso; 20 | 21 | import java.io.File; 22 | 23 | public class PicassoImageLoader implements ImageLoader { 24 | 25 | @Override 26 | public void displayImage(Activity activity, String path, ImageView imageView, int width, int height) { 27 | Picasso.with(activity)// 28 | .load(new File(path))// 29 | .placeholder(R.mipmap.default_image)// 30 | .error(R.mipmap.default_image)// 31 | .resize(width, height)// 32 | .centerInside()// 33 | .memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE)// 34 | .into(imageView); 35 | } 36 | 37 | @Override 38 | public void clearMemoryCache(Activity activity) { 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /imagepicker/src/main/java/com/pbq/imagepicker/view/ViewPagerFixed.java: -------------------------------------------------------------------------------- 1 | package com.pbq.imagepicker.view; 2 | 3 | import android.content.Context; 4 | import android.support.v4.view.ViewPager; 5 | import android.util.AttributeSet; 6 | import android.view.MotionEvent; 7 | 8 | /** 9 | * ================================================ 10 | * 作 者:jeasonlzy(廖子尧 Github地址:https://github.com/jeasonlzy0216 11 | * 版 本:1.0 12 | * 创建日期:2016/5/19 13 | * 描 述:修复图片在ViewPager控件中缩放报错的BUG 14 | * 修订历史: 15 | * ================================================ 16 | */ 17 | public class ViewPagerFixed extends ViewPager { 18 | 19 | public ViewPagerFixed(Context context) { 20 | super(context); 21 | } 22 | 23 | public ViewPagerFixed(Context context, AttributeSet attrs) { 24 | super(context, attrs); 25 | } 26 | 27 | @Override 28 | public boolean onTouchEvent(MotionEvent ev) { 29 | try { 30 | return super.onTouchEvent(ev); 31 | } catch (IllegalArgumentException ex) { 32 | ex.printStackTrace(); 33 | } 34 | return false; 35 | } 36 | 37 | @Override 38 | public boolean onInterceptTouchEvent(MotionEvent ev) { 39 | try { 40 | return super.onInterceptTouchEvent(ev); 41 | } catch (IllegalArgumentException ex) { 42 | ex.printStackTrace(); 43 | } 44 | return false; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /app/src/main/java/com/pbq/imagepickerdemo/imageloader/GlideImageLoader.java: -------------------------------------------------------------------------------- 1 | package com.pbq.imagepickerdemo.imageloader; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.net.Uri; 6 | import android.os.Environment; 7 | import android.widget.ImageView; 8 | 9 | import com.bumptech.glide.Glide; 10 | import com.bumptech.glide.load.engine.DiskCacheStrategy; 11 | import com.pbq.imagepicker.loader.ImageLoader; 12 | import com.pbq.imagepickerdemo.R; 13 | 14 | import java.io.File; 15 | 16 | /** 17 | * ================================================ 18 | * 作 者:jeasonlzy(廖子尧 Github地址:https://github.com/jeasonlzy0216 19 | * 版 本:1.0 20 | * 创建日期:2016/5/19 21 | * 描 述: 22 | * 修订历史: 23 | * ================================================ 24 | */ 25 | public class GlideImageLoader implements ImageLoader { 26 | 27 | @Override 28 | public void displayImage(Activity activity, String path, ImageView imageView, int width, int height) { 29 | Glide.with(activity) //配置上下文 30 | .load(Uri.fromFile(new File(path))) //设置图片路径(fix #8,文件名包含%符号 无法识别和显示) 31 | .error(R.mipmap.default_image) //设置错误图片 32 | .placeholder(R.mipmap.default_image) //设置占位图片 33 | .diskCacheStrategy( DiskCacheStrategy.NONE ) 34 | .skipMemoryCache(true) 35 | .into(imageView); 36 | } 37 | 38 | @Override 39 | public void clearMemoryCache(Activity activity) { 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/com/pbq/imagepickerdemo/imageloader/XUtils3ImageLoader.java: -------------------------------------------------------------------------------- 1 | package com.pbq.imagepickerdemo.imageloader; 2 | 3 | /** 4 | * ================================================ 5 | * 作 者:jeasonlzy(廖子尧) 6 | * 版 本:1.0 7 | * 创建日期:2016/3/28 8 | * 描 述:我的Github地址 https://github.com/jeasonlzy0216 9 | * 修订历史: 10 | * ================================================ 11 | */ 12 | 13 | import android.app.Activity; 14 | import android.graphics.Bitmap; 15 | import android.net.Uri; 16 | import android.widget.ImageView; 17 | 18 | import com.pbq.imagepicker.loader.ImageLoader; 19 | import com.pbq.imagepickerdemo.R; 20 | 21 | import org.xutils.image.ImageOptions; 22 | import org.xutils.x; 23 | 24 | import java.io.File; 25 | 26 | public class XUtils3ImageLoader implements ImageLoader { 27 | @Override 28 | public void displayImage(Activity activity, String path, ImageView imageView, int width, int height) { 29 | ImageOptions options = new ImageOptions.Builder()// 30 | .setLoadingDrawableId(R.mipmap.default_image)// 31 | .setFailureDrawableId(R.mipmap.default_image)// 32 | .setConfig(Bitmap.Config.RGB_565)// 33 | .setSize(width, height)// 34 | .setCrop(false)// 35 | .setUseMemCache(true)// 36 | .build(); 37 | x.image().bind(imageView, Uri.fromFile(new File(path)).toString(), options); 38 | } 39 | 40 | @Override 41 | public void clearMemoryCache(Activity activity) { 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /imagepicker/src/main/res/layout/activity_image_crop.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 15 | 16 | 20 | 21 | 39 | 40 | -------------------------------------------------------------------------------- /imagepicker/src/main/res/layout/adapter_folder_image_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 16 | 17 | 23 | 24 | 31 | 32 | 40 | 41 | 42 | 49 | 50 | -------------------------------------------------------------------------------- /imagepicker/src/main/res/layout/activity_image_preview.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 13 | 14 | 17 | 18 | 25 | 26 | 35 | 36 | 49 | 50 | -------------------------------------------------------------------------------- /imagepicker/src/main/res/layout/activity_video_preview.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 13 | 14 | 17 | 18 | 25 | 26 | 35 | 36 | 49 | 50 | -------------------------------------------------------------------------------- /app/src/main/java/com/pbq/imagepickerdemo/GApp.java: -------------------------------------------------------------------------------- 1 | package com.pbq.imagepickerdemo; 2 | 3 | import android.app.Application; 4 | import android.widget.ImageView; 5 | 6 | import com.nostra13.universalimageloader.core.DisplayImageOptions; 7 | import com.nostra13.universalimageloader.core.ImageLoader; 8 | import com.nostra13.universalimageloader.core.ImageLoaderConfiguration; 9 | 10 | import org.xutils.image.ImageOptions; 11 | import org.xutils.x; 12 | 13 | /** 14 | * ================================================ 15 | * 作 者:jeasonlzy(廖子尧) 16 | * 版 本:1.0 17 | * 创建日期:2016/4/13 18 | * 描 述:我的Github地址 https://github.com/jeasonlzy0216 19 | * 修订历史: 20 | * ================================================ 21 | */ 22 | public class GApp extends Application { 23 | 24 | public static DisplayImageOptions imageLoaderOptions = new DisplayImageOptions.Builder()// 25 | .showImageOnLoading(R.mipmap.default_image) //设置图片在下载期间显示的图片 26 | .showImageForEmptyUri(R.mipmap.default_image) //设置图片Uri为空或是错误的时候显示的图片 27 | .showImageOnFail(R.mipmap.default_image) //设置图片加载/解码过程中错误时候显示的图片 28 | .cacheInMemory(true) //设置下载的图片是否缓存在内存中 29 | .cacheOnDisk(true) //设置下载的图片是否缓存在SD卡中 30 | .build(); //构建完成 31 | 32 | public static ImageOptions xUtilsOptions = new ImageOptions.Builder()// 33 | .setIgnoreGif(false) //是否忽略GIF格式的图片 34 | .setImageScaleType(ImageView.ScaleType.FIT_CENTER) //缩放模式 35 | .setLoadingDrawableId(R.mipmap.default_image) //下载中显示的图片 36 | .setFailureDrawableId(R.mipmap.default_image) //下载失败显示的图片 37 | .build(); //得到ImageOptions对象 38 | 39 | @Override 40 | public void onCreate() { 41 | super.onCreate(); 42 | ImageLoaderConfiguration config = ImageLoaderConfiguration.createDefault(this); 43 | 44 | ImageLoader.getInstance().init(config); //UniversalImageLoader初始化 45 | x.Ext.init(this); //xUtils3初始化 46 | } 47 | } -------------------------------------------------------------------------------- /imagepicker/src/main/res/layout/adapter_video_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 13 | 14 | 20 | 21 | 24 | 33 | 38 | 43 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /imagepicker/src/main/java/com/pbq/imagepicker/ui/image/ImageBaseActivity.java: -------------------------------------------------------------------------------- 1 | package com.pbq.imagepicker.ui.image; 2 | 3 | import android.annotation.TargetApi; 4 | import android.content.pm.PackageManager; 5 | import android.os.Build; 6 | import android.os.Bundle; 7 | import android.support.annotation.NonNull; 8 | import android.support.v4.app.ActivityCompat; 9 | import android.support.v7.app.AppCompatActivity; 10 | import android.view.Window; 11 | import android.view.WindowManager; 12 | import android.widget.Toast; 13 | 14 | import com.pbq.imagepicker.R; 15 | import com.pbq.imagepicker.view.SystemBarTintManager; 16 | 17 | /** 18 | * ================================================ 19 | * 作 者:jeasonlzy(廖子尧 Github地址:https://github.com/jeasonlzy0216 20 | * 版 本:1.0 21 | * 创建日期:2016/5/19 22 | * 描 述: 23 | * 修订历史: 24 | * ================================================ 25 | */ 26 | public class ImageBaseActivity extends AppCompatActivity { 27 | 28 | protected SystemBarTintManager tintManager; 29 | 30 | @Override 31 | protected void onCreate(Bundle savedInstanceState) { 32 | super.onCreate(savedInstanceState); 33 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { 34 | setTranslucentStatus(true); 35 | } 36 | tintManager = new SystemBarTintManager(this); 37 | tintManager.setStatusBarTintEnabled(true); 38 | tintManager.setStatusBarTintResource(R.color.status_bar); //设置上方状态栏的颜色 39 | } 40 | 41 | @TargetApi(19) 42 | private void setTranslucentStatus(boolean on) { 43 | Window win = getWindow(); 44 | WindowManager.LayoutParams winParams = win.getAttributes(); 45 | final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS; 46 | if (on) { 47 | winParams.flags |= bits; 48 | } else { 49 | winParams.flags &= ~bits; 50 | } 51 | win.setAttributes(winParams); 52 | } 53 | 54 | public boolean checkPermission(@NonNull String permission) { 55 | return ActivityCompat.checkSelfPermission(this, permission) == PackageManager.PERMISSION_GRANTED; 56 | } 57 | 58 | public void showToast(String toastText) { 59 | Toast.makeText(getApplicationContext(), toastText, Toast.LENGTH_SHORT).show(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /imagepicker/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 23 | 28 | 32 | 33 | 36 | 40 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /imagepicker/src/main/res/layout/adapter_folder_video_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 19 | 26 | 27 | 28 | 34 | 35 | 42 | 43 | 51 | 52 | 53 | 60 | 61 | -------------------------------------------------------------------------------- /imagepicker/src/main/java/com/pbq/imagepicker/Utils.java: -------------------------------------------------------------------------------- 1 | package com.pbq.imagepicker; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.graphics.Bitmap; 6 | import android.graphics.BitmapFactory; 7 | import android.graphics.Matrix; 8 | import android.os.Environment; 9 | import android.util.DisplayMetrics; 10 | 11 | import java.io.File; 12 | import java.io.FileOutputStream; 13 | import java.util.Random; 14 | 15 | /** 16 | * ================================================ 17 | * 作 者:jeasonlzy(廖子尧 Github地址:https://github.com/jeasonlzy0216 18 | * 版 本:1.0 19 | * 创建日期:2016/5/19 20 | * 描 述: 21 | * 修订历史: 22 | * ================================================ 23 | */ 24 | public class Utils { 25 | 26 | /** 获得状态栏的高度 */ 27 | public static int getStatusHeight(Context context) { 28 | int statusHeight = -1; 29 | try { 30 | Class clazz = Class.forName("com.android.internal.R$dimen"); 31 | Object object = clazz.newInstance(); 32 | int height = Integer.parseInt(clazz.getField("status_bar_height").get(object).toString()); 33 | statusHeight = context.getResources().getDimensionPixelSize(height); 34 | } catch (Exception e) { 35 | e.printStackTrace(); 36 | } 37 | return statusHeight; 38 | } 39 | 40 | /** 根据屏幕宽度与密度计算GridView显示的列数, 最少为三列,并获取Item宽度 */ 41 | public static int getImageItemWidth(Activity activity) { 42 | int screenWidth = activity.getResources().getDisplayMetrics().widthPixels; 43 | int densityDpi = activity.getResources().getDisplayMetrics().densityDpi; 44 | int cols = screenWidth / densityDpi; 45 | cols = cols < 3 ? 3 : cols; 46 | int columnSpace = (int) (2 * activity.getResources().getDisplayMetrics().density); 47 | return (screenWidth - columnSpace * (cols - 1)) / cols; 48 | } 49 | 50 | /** 51 | * 判断SDCard是否可用 52 | */ 53 | public static boolean existSDCard() { 54 | return Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED); 55 | } 56 | 57 | /** 58 | * 获取手机大小(分辨率) 59 | */ 60 | public static DisplayMetrics getScreenPix(Activity activity) { 61 | DisplayMetrics displaysMetrics = new DisplayMetrics(); 62 | activity.getWindowManager().getDefaultDisplay().getMetrics(displaysMetrics); 63 | return displaysMetrics; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /imagepicker/src/main/res/layout/include_top_bar.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 17 | 18 | 25 | 26 | 36 | 37 |