├── images ├── 0.jpg ├── 1.jpg ├── 2.jpg ├── 3.jpg ├── 4.jpg ├── 5.jpg └── 6.jpg ├── ic_launcher-web.png ├── libs ├── android-support-v4.jar └── universal-image-loader-1.9.3.jar ├── res ├── drawable-hdpi │ └── ic_launcher.png ├── drawable-mdpi │ └── ic_launcher.png ├── drawable-xhdpi │ ├── ic_launcher.png │ ├── loading_01.png │ ├── loading_02.png │ ├── loading_03.png │ ├── loading_04.png │ ├── loading_05.png │ ├── loading_06.png │ ├── loading_07.png │ ├── loading_08.png │ ├── loading_09.png │ ├── loading_10.png │ ├── loading_11.png │ ├── loading_12.png │ ├── default_picture.png │ ├── item_delete_pic.png │ ├── select_new_picture.png │ ├── pull_to_refresh_icon.png │ ├── select_picture_take_picture.png │ └── select_picture_grid_item_flag.png ├── drawable-xxhdpi │ └── ic_launcher.png ├── values │ ├── ids.xml │ ├── dimens.xml │ ├── strings.xml │ ├── colors.xml │ ├── styles.xml │ ├── vpi__attrs.xml │ └── attrs.xml ├── layout │ ├── selected_picture_choose_imageview.xml │ ├── common_im_image_pager_item.xml │ ├── common_im_image_pager.xml │ ├── activity_main.xml │ ├── item_select_picture_grid.xml │ ├── item_select_picture_view.xml │ ├── im_select_picture_view_layout.xml │ ├── pull_to_refresh_header_vertical.xml │ └── activity_select_picture.xml ├── menu │ └── main.xml ├── values-w820dp │ └── dimens.xml ├── drawable │ ├── normal_state_background.xml │ ├── normal_rounderd_state_background.xml │ ├── normal_top_state_background.xml │ ├── normal_bottom_state_background.xml │ ├── alert_single_button_background.xml │ └── im_loading_icon.xml └── anim │ ├── pull_to_refresh_slide_in_from_top.xml │ ├── pull_to_refresh_slide_out_to_top.xml │ ├── pull_to_refresh_slide_in_from_bottom.xml │ └── pull_to_refresh_slide_out_to_bottom.xml ├── .settings └── org.eclipse.jdt.core.prefs ├── .classpath ├── project.properties ├── src └── com │ ├── wuba │ └── bangbang │ │ └── uicomponents │ │ ├── acitonsheet │ │ └── IActionSheetListener.java │ │ ├── pulltorefresh │ │ ├── internal │ │ │ ├── Utils.java │ │ │ ├── EmptyViewMethodAccessor.java │ │ │ ├── IMLoadingLayout.java │ │ │ ├── ViewCompat.java │ │ │ ├── IndicatorLayout.java │ │ │ └── LoadingLayout.java │ │ ├── ILoadingLayout.java │ │ ├── LoadingLayoutProxy.java │ │ ├── PullToRefreshGridView.java │ │ ├── IPullToRefresh.java │ │ └── OverscrollHelper.java │ │ ├── utils │ │ ├── DensityUtil.java │ │ ├── CompatUtil.java │ │ └── ImageLoaderUtils.java │ │ ├── gesture │ │ ├── listener │ │ │ └── OnGestureListener.java │ │ ├── IGestureDetector.java │ │ ├── VersionedGestureGenerator.java │ │ ├── FroyoGestureDetector.java │ │ ├── EclairGestureDetector.java │ │ └── CupcakeGestureDetector.java │ │ ├── scrollerproxy │ │ ├── IcsScroller.java │ │ ├── PreGingerScroller.java │ │ └── GingerScroller.java │ │ ├── viewpagerindicator │ │ ├── HackyViewPager.java │ │ └── PageIndicator.java │ │ ├── photoview │ │ ├── ScrollerProxy.java │ │ ├── DefaultOnDoubleTapListener.java │ │ ├── PhotoView.java │ │ └── IPhotoView.java │ │ └── imselectpicture │ │ └── IMSelectPictureGridAdapter.java │ └── example │ ├── android_select_picture_module │ ├── MyApplication.java │ └── MainActivity.java │ └── uicomponents │ ├── IMPhotoView.java │ ├── IMCirclePageIndicator.java │ ├── IMImageView.java │ ├── IMLocalImageViewFragment.java │ └── IMLocalImagePager.java ├── proguard-project.txt ├── .project ├── README.md └── AndroidManifest.xml /images/0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuningjack/select_picture_module/HEAD/images/0.jpg -------------------------------------------------------------------------------- /images/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuningjack/select_picture_module/HEAD/images/1.jpg -------------------------------------------------------------------------------- /images/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuningjack/select_picture_module/HEAD/images/2.jpg -------------------------------------------------------------------------------- /images/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuningjack/select_picture_module/HEAD/images/3.jpg -------------------------------------------------------------------------------- /images/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuningjack/select_picture_module/HEAD/images/4.jpg -------------------------------------------------------------------------------- /images/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuningjack/select_picture_module/HEAD/images/5.jpg -------------------------------------------------------------------------------- /images/6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuningjack/select_picture_module/HEAD/images/6.jpg -------------------------------------------------------------------------------- /ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuningjack/select_picture_module/HEAD/ic_launcher-web.png -------------------------------------------------------------------------------- /libs/android-support-v4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuningjack/select_picture_module/HEAD/libs/android-support-v4.jar -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuningjack/select_picture_module/HEAD/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuningjack/select_picture_module/HEAD/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuningjack/select_picture_module/HEAD/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/loading_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuningjack/select_picture_module/HEAD/res/drawable-xhdpi/loading_01.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/loading_02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuningjack/select_picture_module/HEAD/res/drawable-xhdpi/loading_02.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/loading_03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuningjack/select_picture_module/HEAD/res/drawable-xhdpi/loading_03.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/loading_04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuningjack/select_picture_module/HEAD/res/drawable-xhdpi/loading_04.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/loading_05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuningjack/select_picture_module/HEAD/res/drawable-xhdpi/loading_05.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/loading_06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuningjack/select_picture_module/HEAD/res/drawable-xhdpi/loading_06.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/loading_07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuningjack/select_picture_module/HEAD/res/drawable-xhdpi/loading_07.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/loading_08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuningjack/select_picture_module/HEAD/res/drawable-xhdpi/loading_08.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/loading_09.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuningjack/select_picture_module/HEAD/res/drawable-xhdpi/loading_09.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/loading_10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuningjack/select_picture_module/HEAD/res/drawable-xhdpi/loading_10.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/loading_11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuningjack/select_picture_module/HEAD/res/drawable-xhdpi/loading_11.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/loading_12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuningjack/select_picture_module/HEAD/res/drawable-xhdpi/loading_12.png -------------------------------------------------------------------------------- /res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuningjack/select_picture_module/HEAD/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /libs/universal-image-loader-1.9.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuningjack/select_picture_module/HEAD/libs/universal-image-loader-1.9.3.jar -------------------------------------------------------------------------------- /res/drawable-xhdpi/default_picture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuningjack/select_picture_module/HEAD/res/drawable-xhdpi/default_picture.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/item_delete_pic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuningjack/select_picture_module/HEAD/res/drawable-xhdpi/item_delete_pic.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/select_new_picture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuningjack/select_picture_module/HEAD/res/drawable-xhdpi/select_new_picture.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/pull_to_refresh_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuningjack/select_picture_module/HEAD/res/drawable-xhdpi/pull_to_refresh_icon.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/select_picture_take_picture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuningjack/select_picture_module/HEAD/res/drawable-xhdpi/select_picture_take_picture.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/select_picture_grid_item_flag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuningjack/select_picture_module/HEAD/res/drawable-xhdpi/select_picture_grid_item_flag.png -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 3 | org.eclipse.jdt.core.compiler.compliance=1.6 4 | org.eclipse.jdt.core.compiler.source=1.6 5 | -------------------------------------------------------------------------------- /res/values/ids.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /res/layout/selected_picture_choose_imageview.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | -------------------------------------------------------------------------------- /res/menu/main.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 64dp 9 | 10 | 11 | -------------------------------------------------------------------------------- /res/drawable/normal_state_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16px 5 | 6 | 18sp 7 | 8 | 9 | 10 | 6dp 11 | 12 | 13 | 10dp 14 | 15 | 16 | 1px 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-19 15 | -------------------------------------------------------------------------------- /res/drawable/normal_rounderd_state_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/com/wuba/bangbang/uicomponents/acitonsheet/IActionSheetListener.java: -------------------------------------------------------------------------------- 1 | package com.wuba.bangbang.uicomponents.acitonsheet; 2 | 3 | import android.support.v4.app.Fragment; 4 | 5 | /** 6 | * ActionSheet的监听 7 | * @date: 2014-8-5 下午9:41:26 8 | */ 9 | public interface IActionSheetListener { 10 | 11 | /** 12 | * 隐藏时调用 13 | * @param actionSheet actionSheet 14 | * @param isCancel isCancel 15 | */ 16 | void onDismiss(Fragment actionSheet, boolean isCancel); 17 | 18 | /** 19 | * 点击取消按钮是调用 20 | * @param actionSheet actionSheet 21 | * @param index index 22 | */ 23 | void onOtherButtonClick(Fragment actionSheet, int index); 24 | } -------------------------------------------------------------------------------- /src/com/example/android_select_picture_module/MyApplication.java: -------------------------------------------------------------------------------- 1 | /** 2 | * @project: 58bangbang 3 | * @file: MyApplication.java 4 | * @date: 2015-2-24 上午7:49:11 5 | * @copyright: 2015 58.com Inc. All rights reserved. 6 | */ 7 | package com.example.android_select_picture_module; 8 | 9 | import android.app.Application; 10 | 11 | import com.wuba.bangbang.uicomponents.utils.ImageLoaderUtils; 12 | 13 | /** 14 | * 自定义的Application类 15 | * @author 徐宁 16 | * @date: 2015-2-24 上午7:49:11 17 | */ 18 | public class MyApplication extends Application { 19 | 20 | @Override 21 | public void onCreate() { 22 | 23 | super.onCreate(); 24 | ImageLoaderUtils.init(getApplicationContext()); 25 | } 26 | } -------------------------------------------------------------------------------- /res/drawable/normal_top_state_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /res/drawable/normal_bottom_state_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /res/drawable/alert_single_button_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /res/layout/common_im_image_pager_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 12 | 13 | 19 | 20 | -------------------------------------------------------------------------------- /src/com/wuba/bangbang/uicomponents/pulltorefresh/internal/Utils.java: -------------------------------------------------------------------------------- 1 | package com.wuba.bangbang.uicomponents.pulltorefresh.internal; 2 | 3 | import android.content.Context; 4 | import android.util.Log; 5 | 6 | public class Utils { 7 | 8 | static final String LOG_TAG = "PullToRefresh"; 9 | 10 | public static void warnDeprecation(String depreacted, String replacement) { 11 | Log.w(LOG_TAG, "You're using the deprecated " + depreacted 12 | + " attr, please switch over to " + replacement); 13 | } 14 | 15 | /** 16 | * 获得手机的android版本号 17 | * @param context 18 | * @return 19 | */ 20 | public static int getVersionCode(Context context){ 21 | 22 | int result = 0; 23 | result = android.os.Build.VERSION.SDK_INT; 24 | return result; 25 | } 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /res/layout/common_im_image_pager.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 18 | 19 | -------------------------------------------------------------------------------- /proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 12 | 13 | 20 | 21 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | Android_select_picture_module 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # select_picture_module 2 | Choose custom chart component, which supports multiple specified folder pictures and supports full screen display and to delete the selected images (自定义选图组件,支持多选指定文件夹的图片,支持全屏展示和删除已选图片) 3 | 最终效果图: 4 | 点击添加图片按钮 5 | ![Alt text](https://github.com/xuningjack/select_picture_module/raw/master/images/0.jpg) 6 | 选择添加图片的方式 7 | ![Alt text](https://github.com/xuningjack/select_picture_module/raw/master/images/1.jpg) 8 | 选择图片 9 | ![Alt text](https://github.com/xuningjack/select_picture_module/raw/master/images/2.jpg) 10 | ![Alt text](https://github.com/xuningjack/select_picture_module/raw/master/images/3.jpg) 11 | 操作已选择的图片,可以点击按钮删除 12 | ![Alt text](https://github.com/xuningjack/select_picture_module/raw/master/images/4.jpg) 13 | ![Alt text](https://github.com/xuningjack/select_picture_module/raw/master/images/5.jpg) 14 | 已选择的图片支持单击查看大图 15 | ![Alt text](https://github.com/xuningjack/select_picture_module/raw/master/images/6.jpg) 16 | 17 | -------------------------------------------------------------------------------- /res/anim/pull_to_refresh_slide_in_from_top.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 22 | -------------------------------------------------------------------------------- /res/anim/pull_to_refresh_slide_out_to_top.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 22 | -------------------------------------------------------------------------------- /res/anim/pull_to_refresh_slide_in_from_bottom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 22 | -------------------------------------------------------------------------------- /res/anim/pull_to_refresh_slide_out_to_bottom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 22 | -------------------------------------------------------------------------------- /res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Android_select_picture_module 5 | 拍照 6 | 从相册选择 7 | 取消 8 | 9 | 10 | 下拉刷新 11 | 松开即可刷新 12 | 正在刷新 13 | 刷新成功 14 | 上拉加载更多 15 | 松开即可加载 16 | 正在加载 17 | 加载成功 18 | 19 | 只能选择%1$d张图片 20 | 21 | -------------------------------------------------------------------------------- /src/com/wuba/bangbang/uicomponents/utils/DensityUtil.java: -------------------------------------------------------------------------------- 1 | /** 2 | * @project: 58bangbang 3 | * @file: DensityUtil.java 4 | * @date: 2014年10月8日 下午4:52:53 5 | * @copyright: 2014 58.com Inc. All rights reserved. 6 | */ 7 | package com.wuba.bangbang.uicomponents.utils; 8 | 9 | import android.content.Context; 10 | 11 | /** 12 | * TODO 添加类的功能描述. 13 | * @author 赵彦辉 14 | * @date: 2014年10月8日 下午4:52:53 15 | */ 16 | public class DensityUtil { 17 | /** 18 | * 根据手机的分辨率从 dip 的单位 转成为 px(像素) 19 | */ 20 | public static int dip2px(Context context, float dpValue) { 21 | final float scale = context.getResources().getDisplayMetrics().density; 22 | return (int) (dpValue * scale + 0.5f); 23 | } 24 | 25 | /** 26 | * 根据手机的分辨率从 px(像素) 的单位 转成为 dp 27 | */ 28 | public static int px2dip(Context context, float pxValue) { 29 | final float scale = context.getResources().getDisplayMetrics().density; 30 | return (int) (pxValue / scale + 0.5f); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | true 5 | #FFFFFFFF 6 | #00000000 7 | 0 8 | 3dp 9 | false 10 | #FFDDDDDD 11 | 1dp 12 | 13 | 14 | #D8D3CE 15 | 16 | 17 | #FDA01D 18 | 19 | 20 | #FFFFFF 21 | 22 | #BBB2A4 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /res/layout/item_select_picture_grid.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 16 | 17 | 24 | 25 | -------------------------------------------------------------------------------- /src/com/example/uicomponents/IMPhotoView.java: -------------------------------------------------------------------------------- 1 | package com.example.uicomponents; 2 | 3 | import android.content.Context; 4 | import android.util.AttributeSet; 5 | 6 | import com.wuba.bangbang.uicomponents.photoview.PhotoView; 7 | 8 | /** 9 | * 自定义的PhotoView 10 | * @author 徐宁 11 | * @date: 2015-2-27 上午10:53:22 12 | */ 13 | public class IMPhotoView extends PhotoView { 14 | 15 | /** 16 | * Creates a new instance of IMPhotoView. 17 | * 18 | * @param context 19 | */ 20 | public IMPhotoView(Context context) { 21 | super(context); 22 | } 23 | 24 | /** 25 | * Creates a new instance of IMPhotoView. 26 | * 27 | * @param context 28 | * @param attr 29 | */ 30 | public IMPhotoView(Context context, AttributeSet attr) { 31 | super(context, attr); 32 | } 33 | 34 | /** 35 | * Creates a new instance of IMPhotoView. 36 | * 37 | * @param context 38 | * @param attr 39 | * @param defStyle 40 | */ 41 | public IMPhotoView(Context context, AttributeSet attr, int defStyle) { 42 | super(context, attr, defStyle); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /res/layout/item_select_picture_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 18 | 19 | 20 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/com/wuba/bangbang/uicomponents/gesture/listener/OnGestureListener.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.wuba.bangbang.uicomponents.gesture.listener; 17 | 18 | /** 19 | * 手势操作的接口 20 | * @author 徐宁 21 | * @date: 2015-2-27 上午11:08:51 22 | */ 23 | public interface OnGestureListener { 24 | 25 | public void onDrag(float dx, float dy); 26 | 27 | public void onFling(float startX, float startY, float velocityX, float velocityY); 28 | 29 | public void onScale(float scaleFactor, float focusX, float focusY); 30 | } -------------------------------------------------------------------------------- /src/com/wuba/bangbang/uicomponents/gesture/IGestureDetector.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.wuba.bangbang.uicomponents.gesture; 17 | 18 | import android.view.MotionEvent; 19 | import com.wuba.bangbang.uicomponents.gesture.listener.OnGestureListener; 20 | 21 | /** 22 | * 不同api的手势监听器需要实现的接口 23 | * TODO 添加类的功能描述. 24 | * @author 徐宁 25 | * @date: 2015-2-27 上午11:26:15 26 | */ 27 | public interface IGestureDetector { 28 | 29 | public boolean onTouchEvent(MotionEvent ev); 30 | 31 | public boolean isScaling(); 32 | 33 | public void setOnGestureListener(OnGestureListener listener); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/com/wuba/bangbang/uicomponents/scrollerproxy/IcsScroller.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.wuba.bangbang.uicomponents.scrollerproxy; 17 | 18 | import android.annotation.TargetApi; 19 | import android.content.Context; 20 | 21 | /** 22 | * API14及以上的Scroller 23 | * @author 徐宁 24 | * @date: 2015-2-27 下午2:00:10 25 | */ 26 | @TargetApi(14) 27 | public class IcsScroller extends GingerScroller { 28 | 29 | public IcsScroller(Context context) { 30 | super(context); 31 | } 32 | 33 | @Override 34 | public boolean computeScrollOffset() { 35 | return mScroller.computeScrollOffset(); 36 | } 37 | } -------------------------------------------------------------------------------- /src/com/wuba/bangbang/uicomponents/viewpagerindicator/HackyViewPager.java: -------------------------------------------------------------------------------- 1 | package com.wuba.bangbang.uicomponents.viewpagerindicator; 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 | * Hacky fix for Issue #4 and 10 | * http://code.google.com/p/android/issues/detail?id=18990 11 | * 12 | * ScaleGestureDetector seems to mess up the touch events, which means that 13 | * ViewGroups which make use of onInterceptTouchEvent throw a lot of 14 | * IllegalArgumentException: pointerIndex out of range. 15 | * 16 | * There's not much I can do in my code for now, but we can mask the result by 17 | * just catching the problem and ignoring it. 18 | * 19 | * @author Chris Banes 20 | */ 21 | public class HackyViewPager extends ViewPager { 22 | 23 | public HackyViewPager(Context context) { 24 | super(context); 25 | } 26 | 27 | public HackyViewPager(Context context, AttributeSet attrs) { 28 | super(context, attrs); 29 | } 30 | 31 | @Override 32 | public boolean onInterceptTouchEvent(MotionEvent ev) { 33 | try { 34 | return super.onInterceptTouchEvent(ev); 35 | } catch (IllegalArgumentException e) { 36 | e.printStackTrace(); 37 | return false; 38 | }catch (ArrayIndexOutOfBoundsException e) { 39 | e.printStackTrace(); 40 | return false; 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /src/com/example/uicomponents/IMCirclePageIndicator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * @project: 58bangbang 3 | * @file: IMCirclePageIndicator.java 4 | * @date: 2014年10月23日 上午9:50:16 5 | * @copyright: 2014 58.com Inc. All rights reserved. 6 | */ 7 | package com.example.uicomponents; 8 | 9 | import android.content.Context; 10 | import android.util.AttributeSet; 11 | 12 | import com.wuba.bangbang.uicomponents.viewpagerindicator.CirclePageIndicator; 13 | 14 | /** 15 | * ViewPager的分页指示器,继承自开源项目viewpagerindicator.
16 | * https://github.com/JakeWharton/Android-ViewPagerIndicator 17 | */ 18 | public class IMCirclePageIndicator extends CirclePageIndicator { 19 | 20 | /** 21 | * Creates a new instance of IMCirclePageIndicator. 22 | * 23 | * @param context 24 | */ 25 | public IMCirclePageIndicator(Context context) { 26 | super(context); 27 | } 28 | 29 | /** 30 | * Creates a new instance of IMCirclePageIndicator. 31 | * 32 | * @param context 33 | * @param attrs 34 | */ 35 | public IMCirclePageIndicator(Context context, AttributeSet attrs) { 36 | super(context, attrs); 37 | } 38 | 39 | /** 40 | * Creates a new instance of IMCirclePageIndicator. 41 | * 42 | * @param context 43 | * @param attrs 44 | * @param defStyle 45 | */ 46 | public IMCirclePageIndicator(Context context, AttributeSet attrs, int defStyle) { 47 | super(context, attrs, defStyle); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /res/layout/im_select_picture_view_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 14 | 15 | 21 | 22 | 29 | 30 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 23 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /res/layout/pull_to_refresh_header_vertical.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 17 | 18 | 23 | 24 | 30 | 31 | 32 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /src/com/example/uicomponents/IMImageView.java: -------------------------------------------------------------------------------- 1 | /** 2 | * @project: 58bangbang 3 | * @file: IMImageView.java 4 | * @date: 2014-8-5 下午3:42:49 5 | * @copyright: 2014 58.com Inc. All rights reserved. 6 | */ 7 | package com.example.uicomponents; 8 | 9 | import android.content.Context; 10 | import android.util.AttributeSet; 11 | import android.widget.ImageView; 12 | 13 | 14 | public class IMImageView extends ImageView { 15 | 16 | /**显示图片的路径*/ 17 | private String url; 18 | 19 | /** 20 | * Creates a new instance of IMImageView. 21 | * 22 | * @param context 23 | * context 24 | */ 25 | public IMImageView(Context context) { 26 | super(context); 27 | } 28 | 29 | /** 30 | * Creates a new instance of IMImageView. 31 | * 32 | * @param context 33 | * context 34 | * @param attrs 35 | * attrs 36 | */ 37 | public IMImageView(Context context, AttributeSet attrs) { 38 | super(context, attrs); 39 | } 40 | 41 | /** 42 | * Creates a new instance of IMImageView. 43 | * 44 | * @param context 45 | * context 46 | * @param attrs 47 | * attrs 48 | * @param defStyle 49 | * defStyle 50 | */ 51 | public IMImageView(Context context, AttributeSet attrs, int defStyle) { 52 | super(context, attrs, defStyle); 53 | } 54 | 55 | /** 56 | * @return the url 57 | */ 58 | public String getUrl() { 59 | return url; 60 | } 61 | 62 | /** 63 | * @param url the url to set 64 | */ 65 | public void setUrl(String url) { 66 | this.url = url; 67 | } 68 | } -------------------------------------------------------------------------------- /src/com/wuba/bangbang/uicomponents/pulltorefresh/internal/EmptyViewMethodAccessor.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.wuba.bangbang.uicomponents.pulltorefresh.internal; 17 | 18 | import android.view.View; 19 | 20 | /** 21 | * Interface that allows PullToRefreshBase to hijack the call to 22 | * AdapterView.setEmptyView() 23 | * 24 | * @author chris 25 | */ 26 | public interface EmptyViewMethodAccessor { 27 | 28 | /** 29 | * Calls upto AdapterView.setEmptyView() 30 | * 31 | * @param emptyView 32 | * - to set as Empty View 33 | */ 34 | public void setEmptyViewInternal(View emptyView); 35 | 36 | /** 37 | * Should call PullToRefreshBase.setEmptyView() which will then 38 | * automatically call through to setEmptyViewInternal() 39 | * 40 | * @param emptyView 41 | * - to set as Empty View 42 | */ 43 | public void setEmptyView(View emptyView); 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/com/wuba/bangbang/uicomponents/pulltorefresh/ILoadingLayout.java: -------------------------------------------------------------------------------- 1 | package com.wuba.bangbang.uicomponents.pulltorefresh; 2 | 3 | import android.graphics.Typeface; 4 | import android.graphics.drawable.Drawable; 5 | 6 | public interface ILoadingLayout { 7 | 8 | /** 9 | * Set the drawable used in the loading layout. This is the same as calling 10 | * setLoadingDrawable(drawable, Mode.BOTH) 11 | * 12 | * @param drawable 13 | * - Drawable to display 14 | */ 15 | public void setLoadingDrawable(Drawable drawable); 16 | 17 | /** 18 | * Set Text to show when the Widget is being Pulled 19 | * setPullLabel(releaseLabel, Mode.BOTH) 20 | * 21 | * @param pullLabel 22 | * - CharSequence to display 23 | */ 24 | public void setPullLabel(CharSequence pullLabel); 25 | 26 | /** 27 | * Set Text to show when the Widget is refreshing 28 | * setRefreshingLabel(releaseLabel, Mode.BOTH) 29 | * 30 | * @param refreshingLabel 31 | * - CharSequence to display 32 | */ 33 | public void setRefreshingLabel(CharSequence refreshingLabel); 34 | 35 | /** 36 | * Set Text to show when the Widget is being pulled, and will refresh when 37 | * released. This is the same as calling 38 | * setReleaseLabel(releaseLabel, Mode.BOTH) 39 | * 40 | * @param releaseLabel 41 | * - CharSequence to display 42 | */ 43 | public void setReleaseLabel(CharSequence releaseLabel); 44 | 45 | /** 46 | * Set's the Sets the typeface and style in which the text should be 47 | * displayed. Please see 48 | * {@link android.widget.TextView#setTypeface(Typeface) 49 | * TextView#setTypeface(Typeface)}. 50 | */ 51 | public void setTextTypeface(Typeface tf); 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/com/wuba/bangbang/uicomponents/pulltorefresh/internal/IMLoadingLayout.java: -------------------------------------------------------------------------------- 1 | package com.wuba.bangbang.uicomponents.pulltorefresh.internal; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.drawable.Drawable; 6 | import android.view.View; 7 | 8 | import com.example.android_select_picture_module.R; 9 | import com.wuba.bangbang.uicomponents.pulltorefresh.PullToRefreshBase.Mode; 10 | 11 | public class IMLoadingLayout extends LoadingLayout { 12 | 13 | public IMLoadingLayout(Context context, Mode mode, TypedArray attrs) { 14 | super(context, mode, attrs); 15 | } 16 | 17 | @Override 18 | protected int getDefaultDrawableResId() { 19 | return R.drawable.pull_to_refresh_icon; 20 | } 21 | 22 | @Override 23 | protected void onLoadingDrawableSet(Drawable imageDrawable) { 24 | 25 | } 26 | 27 | @Override 28 | protected void onPullImpl(float scaleOfLayout) { 29 | 30 | System.out.println("-------->onPullImpl"); 31 | if(mProgressBar.getVisibility() == View.VISIBLE){ 32 | 33 | mProgressBar.setVisibility(View.GONE); 34 | } 35 | if(mInnerLayout.getVisibility() != View.VISIBLE){ 36 | 37 | mInnerLayout.setVisibility(View.VISIBLE); 38 | } 39 | } 40 | 41 | @Override 42 | protected void pullToRefreshImpl() { 43 | System.out.println("-------->pullToRefreshImpl"); 44 | } 45 | 46 | @Override 47 | protected void refreshingImpl() { 48 | System.out.println("-------->refreshingImpl"); 49 | } 50 | 51 | @Override 52 | protected void releaseToRefreshImpl() { 53 | 54 | System.out.println("-------->releaseToRefreshImpl"); 55 | } 56 | 57 | @Override 58 | protected void resetImpl() { 59 | 60 | System.out.println("--------->resetImpl"); 61 | mHeaderText.setText(mFinishLabel); 62 | } 63 | } -------------------------------------------------------------------------------- /src/com/wuba/bangbang/uicomponents/gesture/VersionedGestureGenerator.java: -------------------------------------------------------------------------------- 1 | package com.wuba.bangbang.uicomponents.gesture; 2 | 3 | /******************************************************************************* 4 | * Copyright 2011, 2012 Chris Banes. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | *******************************************************************************/ 18 | 19 | import android.content.Context; 20 | import android.os.Build; 21 | 22 | import com.wuba.bangbang.uicomponents.gesture.listener.OnGestureListener; 23 | 24 | /** 25 | * 根据不同的sdk版本,生成手势监听器 26 | * @author 徐宁 27 | * @date: 2015-2-27 上午11:01:57 28 | */ 29 | public final class VersionedGestureGenerator { 30 | 31 | public static IGestureDetector newInstance(Context context, OnGestureListener listener) { 32 | 33 | final int sdkVersion = Build.VERSION.SDK_INT; 34 | IGestureDetector detector; 35 | 36 | if (sdkVersion < Build.VERSION_CODES.ECLAIR) { //api5 37 | detector = new CupcakeGestureDetector(context); 38 | } else if (sdkVersion < Build.VERSION_CODES.FROYO) { //api8 39 | detector = new EclairGestureDetector(context); 40 | } else { 41 | detector = new FroyoGestureDetector(context); 42 | } 43 | detector.setOnGestureListener(listener); 44 | return detector; 45 | } 46 | } -------------------------------------------------------------------------------- /src/com/wuba/bangbang/uicomponents/viewpagerindicator/PageIndicator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Patrik Akerfeldt 3 | * Copyright (C) 2011 Jake Wharton 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.wuba.bangbang.uicomponents.viewpagerindicator; 19 | 20 | import android.support.v4.view.ViewPager; 21 | 22 | /** 23 | * A PageIndicator is responsible to show an visual indicator on the total views 24 | * number and the current visible view. 25 | */ 26 | public interface PageIndicator extends ViewPager.OnPageChangeListener { 27 | /** 28 | * Bind the indicator to a ViewPager. 29 | * 30 | * @param view 31 | */ 32 | void setViewPager(ViewPager view); 33 | 34 | /** 35 | * Bind the indicator to a ViewPager. 36 | * 37 | * @param view 38 | * @param initialPosition 39 | */ 40 | void setViewPager(ViewPager view, int initialPosition); 41 | 42 | /** 43 | *

Set the current page of both the ViewPager and indicator.

44 | * 45 | *

This must be used if you need to set the page before 46 | * the views are drawn on screen (e.g., default start page).

47 | * 48 | * @param item 49 | */ 50 | void setCurrentItem(int item); 51 | 52 | /** 53 | * Set a page change listener which will receive forwarded events. 54 | * 55 | * @param listener 56 | */ 57 | void setOnPageChangeListener(ViewPager.OnPageChangeListener listener); 58 | 59 | /** 60 | * Notify the indicator that the fragment list has changed. 61 | */ 62 | void notifyDataSetChanged(); 63 | } 64 | -------------------------------------------------------------------------------- /src/com/wuba/bangbang/uicomponents/pulltorefresh/LoadingLayoutProxy.java: -------------------------------------------------------------------------------- 1 | package com.wuba.bangbang.uicomponents.pulltorefresh; 2 | 3 | import java.util.HashSet; 4 | 5 | import android.graphics.Typeface; 6 | import android.graphics.drawable.Drawable; 7 | 8 | import com.wuba.bangbang.uicomponents.pulltorefresh.internal.LoadingLayout; 9 | 10 | public class LoadingLayoutProxy implements ILoadingLayout { 11 | 12 | private final HashSet mLoadingLayouts; 13 | 14 | LoadingLayoutProxy() { 15 | mLoadingLayouts = new HashSet(); 16 | } 17 | 18 | /** 19 | * This allows you to add extra LoadingLayout instances to this proxy. This 20 | * is only necessary if you keep your own instances, and want to have them 21 | * included in any 22 | * {@link PullToRefreshBase#createLoadingLayoutProxy(boolean, boolean) 23 | * createLoadingLayoutProxy(...)} calls. 24 | * 25 | * @param layout 26 | * - LoadingLayout to have included. 27 | */ 28 | public void addLayout(LoadingLayout layout) { 29 | if (null != layout) { 30 | mLoadingLayouts.add(layout); 31 | } 32 | } 33 | 34 | @Override 35 | public void setLoadingDrawable(Drawable drawable) { 36 | for (LoadingLayout layout : mLoadingLayouts) { 37 | layout.setLoadingDrawable(drawable); 38 | } 39 | } 40 | 41 | @Override 42 | public void setRefreshingLabel(CharSequence refreshingLabel) { 43 | for (LoadingLayout layout : mLoadingLayouts) { 44 | layout.setRefreshingLabel(refreshingLabel); 45 | } 46 | } 47 | 48 | @Override 49 | public void setPullLabel(CharSequence label) { 50 | for (LoadingLayout layout : mLoadingLayouts) { 51 | layout.setPullLabel(label); 52 | } 53 | } 54 | 55 | @Override 56 | public void setReleaseLabel(CharSequence label) { 57 | for (LoadingLayout layout : mLoadingLayouts) { 58 | layout.setReleaseLabel(label); 59 | } 60 | } 61 | 62 | public void setTextTypeface(Typeface tf) { 63 | for (LoadingLayout layout : mLoadingLayouts) { 64 | layout.setTextTypeface(tf); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/com/wuba/bangbang/uicomponents/utils/CompatUtil.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.wuba.bangbang.uicomponents.utils; 17 | 18 | import android.annotation.TargetApi; 19 | import android.os.Build; 20 | import android.os.Build.VERSION; 21 | import android.view.MotionEvent; 22 | import android.view.View; 23 | 24 | 25 | 26 | /** 27 | * 适配的工具类 28 | * @author 徐宁 29 | * @date: 2015-2-26 下午6:09:37 30 | */ 31 | public class CompatUtil { 32 | 33 | private static final int SIXTY_FPS_INTERVAL = 1000 / 60; 34 | private static final int VERSION_CODES_HONEYCOMB = 11; 35 | 36 | public static void postOnAnimation(View view, Runnable runnable) { 37 | 38 | view.postDelayed(runnable, SIXTY_FPS_INTERVAL); 39 | } 40 | 41 | 42 | public static int getPointerIndex(int action) { 43 | if (VERSION.SDK_INT >= VERSION_CODES_HONEYCOMB) 44 | return getPointerIndexHoneyComb(action); 45 | else 46 | return getPointerIndexEclair(action); 47 | } 48 | 49 | @TargetApi(Build.VERSION_CODES.ECLAIR) 50 | private static int getPointerIndexEclair(int action) { 51 | return (action & MotionEvent.ACTION_POINTER_ID_MASK) >> MotionEvent.ACTION_POINTER_ID_SHIFT; 52 | } 53 | 54 | @TargetApi(CompatUtil.VERSION_CODES_HONEYCOMB) 55 | private static int getPointerIndexHoneyComb(int action) { 56 | return (action & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT; 57 | } 58 | } -------------------------------------------------------------------------------- /src/com/wuba/bangbang/uicomponents/scrollerproxy/PreGingerScroller.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.wuba.bangbang.uicomponents.scrollerproxy; 17 | 18 | import android.content.Context; 19 | import android.widget.Scroller; 20 | 21 | import com.wuba.bangbang.uicomponents.photoview.ScrollerProxy; 22 | 23 | /** 24 | * 支持API9以下的Scroller 25 | * @author 徐宁 26 | * @date: 2015-2-27 下午1:57:51 27 | */ 28 | public class PreGingerScroller extends ScrollerProxy { 29 | 30 | private final Scroller mScroller; 31 | 32 | public PreGingerScroller(Context context) { 33 | mScroller = new Scroller(context); 34 | } 35 | 36 | @Override 37 | public boolean computeScrollOffset() { 38 | return mScroller.computeScrollOffset(); 39 | } 40 | 41 | @Override 42 | public void fling(int startX, int startY, int velocityX, int velocityY, int minX, int maxX, int minY, int maxY, 43 | int overX, int overY) { 44 | mScroller.fling(startX, startY, velocityX, velocityY, minX, maxX, minY, maxY); 45 | } 46 | 47 | @Override 48 | public void forceFinished(boolean finished) { 49 | mScroller.forceFinished(finished); 50 | } 51 | 52 | public boolean isFinished() { 53 | return mScroller.isFinished(); 54 | } 55 | 56 | @Override 57 | public int getCurrX() { 58 | return mScroller.getCurrX(); 59 | } 60 | 61 | @Override 62 | public int getCurrY() { 63 | return mScroller.getCurrY(); 64 | } 65 | } -------------------------------------------------------------------------------- /src/com/wuba/bangbang/uicomponents/photoview/ScrollerProxy.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.wuba.bangbang.uicomponents.photoview; 17 | 18 | import android.content.Context; 19 | import android.os.Build.VERSION; 20 | import android.os.Build.VERSION_CODES; 21 | 22 | import com.wuba.bangbang.uicomponents.scrollerproxy.GingerScroller; 23 | import com.wuba.bangbang.uicomponents.scrollerproxy.IcsScroller; 24 | import com.wuba.bangbang.uicomponents.scrollerproxy.PreGingerScroller; 25 | 26 | /** 27 | * Scroller的抽象代理类 28 | * @author 徐宁 29 | * @date: 2015-2-27 下午1:54:30 30 | */ 31 | public abstract class ScrollerProxy { 32 | 33 | private static final int VERSION_CODES_ICE_CREAM_SANDWICH = 14; 34 | 35 | public static ScrollerProxy getScroller(Context context) { 36 | if (VERSION.SDK_INT < VERSION_CODES.GINGERBREAD) { 37 | return new PreGingerScroller(context); 38 | } else if (VERSION.SDK_INT < VERSION_CODES_ICE_CREAM_SANDWICH) { 39 | return new GingerScroller(context); 40 | } else { 41 | return new IcsScroller(context); 42 | } 43 | } 44 | 45 | public abstract boolean computeScrollOffset(); 46 | 47 | public abstract void fling(int startX, int startY, int velocityX, int velocityY, int minX, int maxX, int minY, int maxY, int overX, int overY); 48 | 49 | public abstract void forceFinished(boolean finished); 50 | 51 | public abstract boolean isFinished(); 52 | 53 | public abstract int getCurrX(); 54 | 55 | public abstract int getCurrY(); 56 | } 57 | -------------------------------------------------------------------------------- /res/layout/activity_select_picture.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 13 | 14 | 22 | 23 | 24 | 25 | 26 | 34 | 35 | 41 | 42 | 48 | 49 | 50 | 51 |