├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── dimens.xml │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-hdpi │ │ │ │ ├── find_add_img.png │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ ├── drawable │ │ │ │ └── border_red_roval_sign.xml │ │ │ └── layout │ │ │ │ ├── item.xml │ │ │ │ └── activity_main.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── zq │ │ │ └── weixinselectpicture │ │ │ └── MainActivity.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── zq │ │ │ └── weixinselectpicture │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── zq │ │ └── weixinselectpicture │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── pictureselector ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── asv.png │ │ │ │ ├── asy.png │ │ │ │ ├── btn_selected.png │ │ │ │ ├── default_check.png │ │ │ │ ├── default_error.png │ │ │ │ ├── btn_unselected.png │ │ │ │ └── ic_action_discard.png │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_action_discard.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_action_discard.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_action_discard.png │ │ │ │ ├── text_indicator_normal.png │ │ │ │ └── text_indicator_pressed.png │ │ │ ├── values │ │ │ │ ├── colors.xml │ │ │ │ ├── dimens.xml │ │ │ │ └── strings.xml │ │ │ ├── drawable │ │ │ │ └── text_indicator.xml │ │ │ ├── menu │ │ │ │ ├── menu_picker.xml │ │ │ │ └── menu_preview.xml │ │ │ ├── layout │ │ │ │ ├── item_preview.xml │ │ │ │ ├── activity_image_preview.xml │ │ │ │ ├── photopicker_toolbar.xml │ │ │ │ ├── item_camera.xml │ │ │ │ ├── item_select_image.xml │ │ │ │ ├── activity_photopicker.xml │ │ │ │ └── item_folder.xml │ │ │ └── color │ │ │ │ └── action_text_color.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── lidong │ │ │ └── photopicker │ │ │ ├── SelectModel.java │ │ │ ├── Folder.java │ │ │ ├── Image.java │ │ │ ├── intent │ │ │ ├── PhotoPreviewIntent.java │ │ │ └── PhotoPickerIntent.java │ │ │ ├── widget │ │ │ └── ViewPagerFixed.java │ │ │ ├── ImageConfig.java │ │ │ ├── PhotoPagerAdapter.java │ │ │ ├── ImageCaptureManager.java │ │ │ ├── FolderAdapter.java │ │ │ ├── PhotoPreviewActivity.java │ │ │ ├── ImageGridAdapter.java │ │ │ └── PhotoPickerActivity.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── lidong │ │ └── photopicker │ │ └── ApplicationTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── .idea ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── vcs.xml ├── modules.xml ├── runConfigurations.xml ├── compiler.xml ├── gradle.xml └── misc.xml ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── README.md ├── gradle.properties ├── gradlew.bat └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /pictureselector/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':pictureselector' 2 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 仿微信选择图片 3 | 4 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DickyQie/android-advanced-effect/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/find_add_img.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DickyQie/android-advanced-effect/HEAD/app/src/main/res/mipmap-hdpi/find_add_img.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DickyQie/android-advanced-effect/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DickyQie/android-advanced-effect/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DickyQie/android-advanced-effect/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DickyQie/android-advanced-effect/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DickyQie/android-advanced-effect/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /pictureselector/src/main/res/mipmap-xxhdpi/asv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DickyQie/android-advanced-effect/HEAD/pictureselector/src/main/res/mipmap-xxhdpi/asv.png -------------------------------------------------------------------------------- /pictureselector/src/main/res/mipmap-xxhdpi/asy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DickyQie/android-advanced-effect/HEAD/pictureselector/src/main/res/mipmap-xxhdpi/asy.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /pictureselector/src/main/res/mipmap-xxhdpi/btn_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DickyQie/android-advanced-effect/HEAD/pictureselector/src/main/res/mipmap-xxhdpi/btn_selected.png -------------------------------------------------------------------------------- /pictureselector/src/main/res/mipmap-xxhdpi/default_check.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DickyQie/android-advanced-effect/HEAD/pictureselector/src/main/res/mipmap-xxhdpi/default_check.png -------------------------------------------------------------------------------- /pictureselector/src/main/res/mipmap-xxhdpi/default_error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DickyQie/android-advanced-effect/HEAD/pictureselector/src/main/res/mipmap-xxhdpi/default_error.png -------------------------------------------------------------------------------- /pictureselector/src/main/res/mipmap-hdpi/ic_action_discard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DickyQie/android-advanced-effect/HEAD/pictureselector/src/main/res/mipmap-hdpi/ic_action_discard.png -------------------------------------------------------------------------------- /pictureselector/src/main/res/mipmap-mdpi/ic_action_discard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DickyQie/android-advanced-effect/HEAD/pictureselector/src/main/res/mipmap-mdpi/ic_action_discard.png -------------------------------------------------------------------------------- /pictureselector/src/main/res/mipmap-xxhdpi/btn_unselected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DickyQie/android-advanced-effect/HEAD/pictureselector/src/main/res/mipmap-xxhdpi/btn_unselected.png -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /pictureselector/src/main/res/mipmap-xhdpi/ic_action_discard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DickyQie/android-advanced-effect/HEAD/pictureselector/src/main/res/mipmap-xhdpi/ic_action_discard.png -------------------------------------------------------------------------------- /pictureselector/src/main/res/mipmap-xxhdpi/ic_action_discard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DickyQie/android-advanced-effect/HEAD/pictureselector/src/main/res/mipmap-xxhdpi/ic_action_discard.png -------------------------------------------------------------------------------- /pictureselector/src/main/res/mipmap-xhdpi/text_indicator_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DickyQie/android-advanced-effect/HEAD/pictureselector/src/main/res/mipmap-xhdpi/text_indicator_normal.png -------------------------------------------------------------------------------- /pictureselector/src/main/res/mipmap-xhdpi/text_indicator_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DickyQie/android-advanced-effect/HEAD/pictureselector/src/main/res/mipmap-xhdpi/text_indicator_pressed.png -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /pictureselector/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 7 | -------------------------------------------------------------------------------- /pictureselector/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #cfcfcf 4 | #353535 5 | #818585 6 | -------------------------------------------------------------------------------- /pictureselector/src/main/res/drawable/text_indicator.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Android之仿微信发朋友圈图片选择功能 2 |

最近项目中需要用到发表评论选择多张图片和拍照的功能,于是就仿照微信发表朋友圈的选择图片和拍照做了一个这样的案例,经过查找资料终于完成了此功能,

3 |

最近有时间就写出来和大家分享一下,希望对大家有所帮助。

4 |

效果如下图:

5 |

               

6 |

 

7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /pictureselector/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10dp 4 | 72dp 5 | 120dp 6 | 5dp 7 | 16sp 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/border_red_roval_sign.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | 8 | #181819 9 | 10 | #2988CC 11 | #6c6c6c 12 | 13 | -------------------------------------------------------------------------------- /pictureselector/src/androidTest/java/com/lidong/photopicker/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.lidong.photopicker; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /pictureselector/src/main/res/menu/menu_picker.xml: -------------------------------------------------------------------------------- 1 | 5 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/zq/weixinselectpicture/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.zq.weixinselectpicture; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /pictureselector/src/main/java/com/lidong/photopicker/SelectModel.java: -------------------------------------------------------------------------------- 1 | package com.lidong.photopicker; 2 | 3 | /** 4 | * 照片选择类型 5 | * Created by foamtrace on 2015/8/25. 6 | */ 7 | public enum SelectModel { 8 | SINGLE(PhotoPickerActivity.MODE_SINGLE), 9 | MULTI(PhotoPickerActivity.MODE_MULTI); 10 | 11 | private int model; 12 | 13 | SelectModel(int model) { 14 | this.model = model; 15 | } 16 | 17 | @Override 18 | public String toString() { 19 | return String.valueOf(this.model); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /pictureselector/src/main/res/menu/menu_preview.xml: -------------------------------------------------------------------------------- 1 | 6 | 13 | 14 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /pictureselector/src/main/res/layout/item_preview.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | -------------------------------------------------------------------------------- /pictureselector/src/main/java/com/lidong/photopicker/Folder.java: -------------------------------------------------------------------------------- 1 | package com.lidong.photopicker; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * 文件夹 7 | */ 8 | public class Folder { 9 | public String name; 10 | public String path; 11 | public Image cover; 12 | public List images; 13 | 14 | @Override 15 | public boolean equals(Object o) { 16 | try { 17 | Folder other = (Folder) o; 18 | return this.path.equalsIgnoreCase(other.path); 19 | }catch (ClassCastException e){ 20 | e.printStackTrace(); 21 | } 22 | return super.equals(o); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /pictureselector/src/main/res/color/action_text_color.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /pictureselector/src/main/res/layout/activity_image_preview.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 15 | 16 | -------------------------------------------------------------------------------- /pictureselector/src/main/res/layout/photopicker_toolbar.xml: -------------------------------------------------------------------------------- 1 | 2 | 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 D:\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 | -------------------------------------------------------------------------------- /pictureselector/src/main/java/com/lidong/photopicker/Image.java: -------------------------------------------------------------------------------- 1 | package com.lidong.photopicker; 2 | 3 | /** 4 | * 图片实体 5 | */ 6 | public class Image { 7 | public String path; 8 | public String name; 9 | public long time; 10 | 11 | public Image(String path, String name, long time){ 12 | this.path = path; 13 | this.name = name; 14 | this.time = time; 15 | } 16 | 17 | @Override 18 | public boolean equals(Object o) { 19 | try { 20 | Image other = (Image) o; 21 | return this.path.equalsIgnoreCase(other.path); 22 | }catch (ClassCastException e){ 23 | e.printStackTrace(); 24 | } 25 | return super.equals(o); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /pictureselector/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 D:\DevSofrware\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 | -------------------------------------------------------------------------------- /pictureselector/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 图片 3 | 所有图片 4 | 预览 5 | 无法启用系统相机 6 | 已经达到最高选择数量 7 | 完成 8 | 完成(%1$d/%2$d) 9 | %1$d/%2$d 10 | 删除 11 | 删除了一张图片 12 | 确认删除? 13 | 确定 14 | 取消 15 | 撤消 16 | 17 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /pictureselector/src/main/res/layout/item_camera.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 18 | 19 | -------------------------------------------------------------------------------- /pictureselector/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | 4 | 5 | android { 6 | compileSdkVersion 22 7 | buildToolsVersion "22.0.1" 8 | 9 | defaultConfig { 10 | minSdkVersion 15 11 | targetSdkVersion 22 12 | versionCode 1 13 | versionName "1.0" 14 | } 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | } 22 | 23 | dependencies { 24 | compile fileTree(dir: 'libs', include: ['*.jar']) 25 | compile 'com.android.support:appcompat-v7:22.+' 26 | compile 'com.android.support:design:22.+' 27 | compile 'com.github.bumptech.glide:glide:3.7.0' 28 | compile 'com.github.chrisbanes.photoview:library:+' 29 | } -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/zq/weixinselectpicture/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.zq.weixinselectpicture; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.zq.weixinselectpicture", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /pictureselector/src/main/java/com/lidong/photopicker/intent/PhotoPreviewIntent.java: -------------------------------------------------------------------------------- 1 | package com.lidong.photopicker.intent; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | 6 | import com.lidong.photopicker.PhotoPreviewActivity; 7 | 8 | import java.util.ArrayList; 9 | 10 | /** 11 | * 预览照片 12 | */ 13 | public class PhotoPreviewIntent extends Intent{ 14 | 15 | public PhotoPreviewIntent(Context packageContext) { 16 | super(packageContext, PhotoPreviewActivity.class); 17 | } 18 | 19 | /** 20 | * 照片地址 21 | * @param paths 22 | */ 23 | public void setPhotoPaths(ArrayList paths){ 24 | this.putStringArrayListExtra(PhotoPreviewActivity.EXTRA_PHOTOS, paths); 25 | } 26 | 27 | /** 28 | * 当前照片的下标 29 | * @param currentItem 30 | */ 31 | public void setCurrentItem(int currentItem){ 32 | this.putExtra(PhotoPreviewActivity.EXTRA_CURRENT_ITEM, currentItem); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 22 5 | buildToolsVersion '22.0.1' 6 | defaultConfig { 7 | applicationId "com.zq.weixinselectpicture" 8 | minSdkVersion 15 9 | targetSdkVersion 22 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 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 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 25 | exclude group: 'com.android.support', module: 'support-annotations' 26 | }) 27 | compile 'com.android.support:appcompat-v7:22.2.1' 28 | testCompile 'junit:junit:4.12' 29 | compile project(':pictureselector') 30 | } 31 | -------------------------------------------------------------------------------- /pictureselector/src/main/java/com/lidong/photopicker/widget/ViewPagerFixed.java: -------------------------------------------------------------------------------- 1 | package com.lidong.photopicker.widget; 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 | * 修复图片在ViewPager控件中缩放报错的BUG 10 | */ 11 | public class ViewPagerFixed extends ViewPager { 12 | 13 | public ViewPagerFixed(Context context) { 14 | super(context); 15 | } 16 | 17 | public ViewPagerFixed(Context context, AttributeSet attrs) { 18 | super(context, attrs); 19 | } 20 | 21 | @Override 22 | public boolean onTouchEvent(MotionEvent ev) { 23 | try { 24 | return super.onTouchEvent(ev); 25 | } catch (IllegalArgumentException ex) { 26 | ex.printStackTrace(); 27 | } 28 | return false; 29 | } 30 | 31 | @Override 32 | public boolean onInterceptTouchEvent(MotionEvent ev) { 33 | try { 34 | return super.onInterceptTouchEvent(ev); 35 | } catch (IllegalArgumentException ex) { 36 | ex.printStackTrace(); 37 | } 38 | return false; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /pictureselector/src/main/res/layout/item_select_image.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 13 | 14 | 20 | 21 | 29 | 30 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 23 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | 16 | 17 | 19 | 20 | 22 | 23 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /pictureselector/src/main/java/com/lidong/photopicker/ImageConfig.java: -------------------------------------------------------------------------------- 1 | package com.lidong.photopicker; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | 6 | /** 7 | * 读取手机照片的限制参数 8 | */ 9 | public class ImageConfig implements Parcelable { 10 | 11 | // 图片最小宽度 12 | public int minWidth; 13 | // 图片最小高度 14 | public int minHeight; 15 | // 图片大小,单位字节 16 | public long minSize; 17 | // 照片类型: 例如 { image/jpeg, image/png, ... } 18 | public String[] mimeType; 19 | 20 | @Override 21 | public int describeContents() { 22 | return 0; 23 | } 24 | 25 | @Override 26 | public void writeToParcel(Parcel dest, int flags) { 27 | dest.writeInt(this.minWidth); 28 | dest.writeInt(this.minHeight); 29 | dest.writeLong(this.minSize); 30 | dest.writeStringArray(this.mimeType); 31 | } 32 | 33 | public ImageConfig() { 34 | } 35 | 36 | protected ImageConfig(Parcel in) { 37 | this.minWidth = in.readInt(); 38 | this.minHeight = in.readInt(); 39 | this.minSize = in.readLong(); 40 | this.mimeType = in.createStringArray(); 41 | } 42 | 43 | public static final Creator CREATOR = new Creator() { 44 | public ImageConfig createFromParcel(Parcel source) { 45 | return new ImageConfig(source); 46 | } 47 | 48 | public ImageConfig[] newArray(int size) { 49 | return new ImageConfig[size]; 50 | } 51 | }; 52 | } 53 | -------------------------------------------------------------------------------- /pictureselector/src/main/java/com/lidong/photopicker/intent/PhotoPickerIntent.java: -------------------------------------------------------------------------------- 1 | package com.lidong.photopicker.intent; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | 6 | import com.lidong.photopicker.ImageConfig; 7 | import com.lidong.photopicker.PhotoPickerActivity; 8 | import com.lidong.photopicker.SelectModel; 9 | 10 | import java.util.ArrayList; 11 | 12 | /** 13 | * 选择照片 14 | */ 15 | public class PhotoPickerIntent extends Intent{ 16 | 17 | public PhotoPickerIntent(Context packageContext) { 18 | super(packageContext, PhotoPickerActivity.class); 19 | } 20 | 21 | public void setShowCarema(boolean bool){ 22 | this.putExtra(PhotoPickerActivity.EXTRA_SHOW_CAMERA, bool); 23 | } 24 | 25 | public void setMaxTotal(int total){ 26 | this.putExtra(PhotoPickerActivity.EXTRA_SELECT_COUNT, total); 27 | } 28 | 29 | /** 30 | * 选择 31 | * @param model 32 | */ 33 | public void setSelectModel(SelectModel model){ 34 | this.putExtra(PhotoPickerActivity.EXTRA_SELECT_MODE, Integer.parseInt(model.toString())); 35 | } 36 | 37 | /** 38 | * 已选择的照片地址 39 | * @param imagePathis 40 | */ 41 | public void setSelectedPaths(ArrayList imagePathis){ 42 | this.putStringArrayListExtra(PhotoPickerActivity.EXTRA_DEFAULT_SELECTED_LIST, imagePathis); 43 | } 44 | 45 | /** 46 | * 显示相册图片的属性 47 | * @param config 48 | */ 49 | public void setImageConfig(ImageConfig config){ 50 | this.putExtra(PhotoPickerActivity.EXTRA_IMAGE_CONFIG, config); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 20 | 27 | 28 | 34 | 46 | 47 | -------------------------------------------------------------------------------- /pictureselector/src/main/res/layout/activity_photopicker.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 20 | 21 | 28 | 29 |