├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── dimens.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ └── layout │ │ │ │ └── activity_main.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── airsaid │ │ │ └── android_pickerview_library │ │ │ └── MainActivity.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── airsaid │ │ │ └── android_pickerview_library │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── airsaid │ │ └── android_pickerview_library │ │ └── ApplicationTest.java ├── proguard-rules.pro └── build.gradle ├── pickerview ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── integers.xml │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── dimens.xml │ │ │ │ └── attrs.xml │ │ │ ├── drawable │ │ │ │ └── selector_pickerview_btn.xml │ │ │ ├── anim │ │ │ │ ├── slide_in_bottom.xml │ │ │ │ └── slide_out_bottom.xml │ │ │ └── layout │ │ │ │ ├── layout_basepickerview.xml │ │ │ │ ├── pickerview_options.xml │ │ │ │ ├── pickerview_time.xml │ │ │ │ └── include_pickerview_topbar.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── airsaid │ │ │ │ └── pickerviewlibrary │ │ │ │ ├── listener │ │ │ │ ├── OnItemSelectedListener.java │ │ │ │ ├── OnDismissListener.java │ │ │ │ ├── OnCitySelectListener.java │ │ │ │ └── OnSimpleCitySelectListener.java │ │ │ │ ├── model │ │ │ │ └── IPickerViewData.java │ │ │ │ ├── widget │ │ │ │ ├── wheelview │ │ │ │ │ ├── OnItemSelectedRunnable.java │ │ │ │ │ ├── LoopViewGestureListener.java │ │ │ │ │ ├── MessageHandler.java │ │ │ │ │ ├── SmoothScrollTimerTask.java │ │ │ │ │ ├── InertiaTimerTask.java │ │ │ │ │ └── WheelView.java │ │ │ │ ├── BasePickerView.java │ │ │ │ ├── WheelOptions.java │ │ │ │ └── WheelTime.java │ │ │ │ ├── adapter │ │ │ │ ├── WheelAdapter.java │ │ │ │ ├── ArrayWheelAdapter.java │ │ │ │ └── NumericWheelAdapter.java │ │ │ │ ├── utils │ │ │ │ └── PickerViewAnimateUtil.java │ │ │ │ ├── CityPickerView.java │ │ │ │ ├── OptionsPickerView.java │ │ │ │ └── TimePickerView.java │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── airsaid │ │ │ └── pickerviewlibrary │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── airsaid │ │ └── pickerviewlibrary │ │ └── ApplicationTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── gif └── pickerview.gif ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── gradle.properties ├── gradlew.bat ├── README.md └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /pickerview/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':pickerview' 2 | -------------------------------------------------------------------------------- /gif/pickerview.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Airsaid/Android-PickerView-Library/HEAD/gif/pickerview.gif -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Android-PickerView-Library 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Airsaid/Android-PickerView-Library/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Airsaid/Android-PickerView-Library/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Airsaid/Android-PickerView-Library/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Airsaid/Android-PickerView-Library/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Airsaid/Android-PickerView-Library/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Airsaid/Android-PickerView-Library/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /pickerview/src/main/res/values/integers.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 300 4 | -------------------------------------------------------------------------------- /pickerview/src/main/java/com/airsaid/pickerviewlibrary/listener/OnItemSelectedListener.java: -------------------------------------------------------------------------------- 1 | package com.airsaid.pickerviewlibrary.listener; 2 | 3 | 4 | public interface OnItemSelectedListener { 5 | void onItemSelected(int index); 6 | } 7 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /pickerview/src/main/java/com/airsaid/pickerviewlibrary/model/IPickerViewData.java: -------------------------------------------------------------------------------- 1 | package com.airsaid.pickerviewlibrary.model; 2 | 3 | /** 4 | * Created by Sai on 2016/7/13. 5 | */ 6 | public interface IPickerViewData { 7 | String getPickerViewText(); 8 | } 9 | -------------------------------------------------------------------------------- /pickerview/src/main/java/com/airsaid/pickerviewlibrary/listener/OnDismissListener.java: -------------------------------------------------------------------------------- 1 | package com.airsaid.pickerviewlibrary.listener; 2 | 3 | /** 4 | * Created by Sai on 15/8/9. 5 | */ 6 | public interface OnDismissListener { 7 | public void onDismiss(Object o); 8 | } 9 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Dec 02 13:57:31 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 | -------------------------------------------------------------------------------- /pickerview/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /pickerview/src/main/res/drawable/selector_pickerview_btn.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /pickerview/src/main/java/com/airsaid/pickerviewlibrary/listener/OnCitySelectListener.java: -------------------------------------------------------------------------------- 1 | package com.airsaid.pickerviewlibrary.listener; 2 | 3 | /** 4 | * Created by zhouyou on 2017/1/10. 5 | * Class desc: 城市选择回调 6 | */ 7 | public interface OnCitySelectListener { 8 | void onCitySelect(String str); 9 | void onCitySelect(String prov, String city, String area); 10 | } 11 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /pickerview/src/main/res/anim/slide_in_bottom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | -------------------------------------------------------------------------------- /pickerview/src/main/res/anim/slide_out_bottom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | -------------------------------------------------------------------------------- /pickerview/src/test/java/com/airsaid/pickerviewlibrary/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.airsaid.pickerviewlibrary; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/airsaid/android_pickerview_library/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.airsaid.android_pickerview_library; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /pickerview/src/androidTest/java/com/airsaid/pickerviewlibrary/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.airsaid.pickerviewlibrary; 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 | } -------------------------------------------------------------------------------- /pickerview/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 取消 3 | 确定 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/airsaid/android_pickerview_library/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.airsaid.android_pickerview_library; 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 | } -------------------------------------------------------------------------------- /pickerview/src/main/java/com/airsaid/pickerviewlibrary/listener/OnSimpleCitySelectListener.java: -------------------------------------------------------------------------------- 1 | package com.airsaid.pickerviewlibrary.listener; 2 | 3 | /** 4 | * Created by zhouyou on 2017/1/10. 5 | * Class desc: 6 | */ 7 | public class OnSimpleCitySelectListener implements OnCitySelectListener { 8 | 9 | @Override 10 | public void onCitySelect(String str) { 11 | 12 | } 13 | 14 | @Override 15 | public void onCitySelect(String prov, String city, String area) { 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /pickerview/src/main/java/com/airsaid/pickerviewlibrary/widget/wheelview/OnItemSelectedRunnable.java: -------------------------------------------------------------------------------- 1 | package com.airsaid.pickerviewlibrary.widget.wheelview; 2 | 3 | final class OnItemSelectedRunnable implements Runnable { 4 | final WheelView loopView; 5 | 6 | OnItemSelectedRunnable(WheelView loopview) { 7 | loopView = loopview; 8 | } 9 | 10 | @Override 11 | public final void run() { 12 | loopView.onItemSelectedListener.onItemSelected(loopView.getCurrentItem()); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /pickerview/src/main/res/layout/layout_basepickerview.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /pickerview/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #057dff 4 | #c2daf5 5 | #f5f5f5 6 | #000000 7 | #a8a8a8 8 | #2a2a2a 9 | #d5d5d5 10 | #60000000 11 | 12 | -------------------------------------------------------------------------------- /pickerview/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 44dp 4 | 5 | 10dp 6 | 7 | 30dp 8 | 9 | 16sp 10 | 18sp 11 | 12 | 20sp 13 | 14 | -------------------------------------------------------------------------------- /pickerview/src/main/java/com/airsaid/pickerviewlibrary/widget/wheelview/LoopViewGestureListener.java: -------------------------------------------------------------------------------- 1 | package com.airsaid.pickerviewlibrary.widget.wheelview; 2 | 3 | import android.view.MotionEvent; 4 | 5 | final class LoopViewGestureListener extends android.view.GestureDetector.SimpleOnGestureListener { 6 | 7 | final WheelView loopView; 8 | 9 | LoopViewGestureListener(WheelView loopview) { 10 | loopView = loopview; 11 | } 12 | 13 | @Override 14 | public final boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { 15 | loopView.scrollBy(velocityY); 16 | return true; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /pickerview/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /pickerview/src/main/java/com/airsaid/pickerviewlibrary/adapter/WheelAdapter.java: -------------------------------------------------------------------------------- 1 | package com.airsaid.pickerviewlibrary.adapter; 2 | 3 | public interface WheelAdapter { 4 | /** 5 | * Gets items count 6 | * @return the count of wheel items 7 | */ 8 | int getItemsCount(); 9 | 10 | /** 11 | * Gets a wheel item by index. 12 | * @param index the item index 13 | * @return the wheel item text or null 14 | */ 15 | T getItem(int index); 16 | 17 | /** 18 | * Gets maximum item length. It is used to determine the wheel width. 19 | * If -1 is returned there will be used the default wheel width. 20 | * @param o 21 | * @return the maximum item length or -1 22 | */ 23 | int indexOf(T o); 24 | } 25 | -------------------------------------------------------------------------------- /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:\WorkSoft\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 | -------------------------------------------------------------------------------- /pickerview/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:\WorkSoft\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/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 24 5 | buildToolsVersion "24.0.3" 6 | 7 | defaultConfig { 8 | applicationId "com.airsaid.android_pickerview_library" 9 | minSdkVersion 15 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(dir: 'libs', include: ['*.jar']) 24 | testCompile 'junit:junit:4.12' 25 | compile 'com.android.support:appcompat-v7:24.2.1' 26 | compile project(path: ':pickerview') 27 | } 28 | -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /pickerview/src/main/java/com/airsaid/pickerviewlibrary/utils/PickerViewAnimateUtil.java: -------------------------------------------------------------------------------- 1 | package com.airsaid.pickerviewlibrary.utils; 2 | 3 | import android.view.Gravity; 4 | 5 | import com.airsaid.pickerviewlibrary.R; 6 | 7 | 8 | /** 9 | * Created by Sai on 15/8/9. 10 | */ 11 | public class PickerViewAnimateUtil { 12 | private static final int INVALID = -1; 13 | /** 14 | * Get default animation resource when not defined by the user 15 | * 16 | * @param gravity the gravity of the dialog 17 | * @param isInAnimation determine if is in or out animation. true when is is 18 | * @return the id of the animation resource 19 | */ 20 | public static int getAnimationResource(int gravity, boolean isInAnimation) { 21 | switch (gravity) { 22 | case Gravity.BOTTOM: 23 | return isInAnimation ? R.anim.slide_in_bottom : R.anim.slide_out_bottom; 24 | } 25 | return INVALID; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /pickerview/src/main/java/com/airsaid/pickerviewlibrary/widget/wheelview/MessageHandler.java: -------------------------------------------------------------------------------- 1 | package com.airsaid.pickerviewlibrary.widget.wheelview; 2 | 3 | import android.os.Handler; 4 | import android.os.Message; 5 | 6 | final class MessageHandler extends Handler { 7 | public static final int WHAT_INVALIDATE_LOOP_VIEW = 1000; 8 | public static final int WHAT_SMOOTH_SCROLL = 2000; 9 | public static final int WHAT_ITEM_SELECTED = 3000; 10 | 11 | final WheelView loopview; 12 | 13 | MessageHandler(WheelView loopview) { 14 | this.loopview = loopview; 15 | } 16 | 17 | @Override 18 | public final void handleMessage(Message msg) { 19 | switch (msg.what) { 20 | case WHAT_INVALIDATE_LOOP_VIEW: 21 | loopview.invalidate(); 22 | break; 23 | 24 | case WHAT_SMOOTH_SCROLL: 25 | loopview.smoothScroll(WheelView.ACTION.FLING); 26 | break; 27 | 28 | case WHAT_ITEM_SELECTED: 29 | loopview.onItemSelected(); 30 | break; 31 | } 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 |