Skip to content

Commit

Permalink
release as 1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
liyujiang-gzu committed Jan 7, 2017
1 parent 8c4b806 commit 9500624
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 193 deletions.
7 changes: 3 additions & 4 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
### v1.3.5 - 2017.01.04
解决默认主题设置为Material时顶部按钮内边距过宽问题;
demo添加沉浸式状态栏功能;
优化颜色选择器及文件选择器;
### v1.4.0 - 2017.01.07
重构WheelView,大批量数据时滑动性能显著提升;
滑轮选择器可设置阴影效果;
### v1.3.4 - 2017.01.01
重构日期时间选择器,默认选中当前日期时间;
支持设置顶部的左右边距;
Expand Down
199 changes: 13 additions & 186 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![JitPack](https://jitpack.io/v/gzu-liyujiang/AndroidPicker.svg)](https://jitpack.io/#gzu-liyujiang/AndroidPicker)
[![Build Status](https://travis-ci.org/gzu-liyujiang/AndroidPicker.svg?branch=master)](https://travis-ci.org/gzu-liyujiang/AndroidPicker)

安卓选择器类库,包括日期选择器、时间选择器、单项选择器城市地址选择器、车牌号选择器、数字选择器、星座选择器、生肖选择器、颜色选择器、文件选择器、目录选择器等,可自定义顶部及底部界面,可自定义窗口动画……
安卓选择器类库,包括日期及时间选择器(可设置范围)、单项选择器(可用于性别、职业、学历、星座等)、城市地址选择器(分省级、地级及县级)、数字选择器(可用于年龄、身高、体重、温度等)、颜色选择器、文件及目录选择器等,可自定义顶部及底部界面,可自定义窗口动画……
欢迎大伙儿在[Issues](https://github.com/gzu-liyujiang/AndroidPicker/issues)提交你的意见或建议。
欢迎Fork & Pull requests贡献您的代码,大家共同学习【[AndroidPicker交流群 604235437](https://jq.qq.com/?_wv=1027&k=42bKOeD)】。
[查看更新日志](https://github.com/gzu-liyujiang/AndroidPicker/blob/master/ChangeLog.md),新版本可能未对旧版API作兼容处理,升级后若编译报错请根据错误提示更改。
Expand Down Expand Up @@ -51,56 +51,8 @@ dependencies {
-keep class cn.qqtheme.framework.entity.** { *;}
```

# Custom
#### 自定义视图
WheelView这个类是滑轮选择器的核心,可以扩展出各种效果,参见demo的[NestActivity.java](https://github.com/gzu-liyujiang/AndroidPicker/blob/master/app/src/main/java/cn/qqtheme/androidpicker/NestActivity.java)
```java
WheelView wheelView = (WheelView) findViewById(R.id.wheelview);
wheelView.setTextColor(0xFFFF00FF);
WheelView.LineConfig config = new WheelView.LineConfig();
config.setColor(0xFFFF00FF);//线颜色
config.setAlpha(100);//线透明度
config.setRatio((float) (1.0 / 10.0));//线比率
config.setThick(ConvertUtils.toPx(this, 10));//线粗
wheelView.setLineConfig(config);
wheelView.setItems(new String[]{"贵州穿青人", "少数民族", "不在56个少数民族之列", "第57个民族"});
wheelView.setOnWheelListener(new WheelView.OnWheelListener() {
@Override
public void onSelected(boolean isUserScroll, int index, String item) {
// do something
}
});
```
#### 自定义窗口进入退出动画
在xml里定义好动画,然后调用setAnimationStyle()即可,如:
```xml
<style name="Animation.Popup" parent="@android:style/Animation">
<item name="android:windowEnterAnimation">@android:anim/fade_in</item>
<item name="android:windowExitAnimation">@android:anim/fade_out</item>
</style>

```
```java
picker.setAnimationStyle(R.style.Animation_Popup);
```
推荐使用[ViewAnimator](https://github.com/gzu-liyujiang/ViewAnimator)这个动画库来实现:
```groovy
dependencies {
compile 'com.github.florent37:viewanimator:1.0.3'
}
```
```java
ViewAnimator.animate(picker.getRootView())
.slideBottomIn()
.interpolator(new AccelerateInterpolator())
.start();
```
#### 自定义顶部及底部界面
添加自己的类,继承自现有的选择器,覆盖makeHeaderView、makeFooterView、onSubmit、onCancel,在确定选择时调用onSubmit,
取消选择时调用onCancel。详见示例:[CustomHeaderAndFooterPicker.java](https://github.com/gzu-liyujiang/AndroidPicker/blob/master/app/src/main/java/cn/qqtheme/androidpicker/CustomHeaderAndFooterPicker.java)

# Sample (更多用法详见示例项目)
自定义选择器
继承自定义扩展选择器
```java
CustomHeaderAndFooterPicker picker = new CustomHeaderAndFooterPicker(this);
picker.setGravity(Gravity.CENTER);//居中
Expand Down Expand Up @@ -129,92 +81,7 @@ dependencies {
ViewGroup viewGroup = (ViewGroup) findViewById(R.id.wheelview_container);
viewGroup.addView(picker.getContentView());
```

日期选择器:
```java
DatePicker picker = new DatePicker(this, DatePicker.YEAR_MONTH_DAY);
picker.setRangeStart(2016, 8, 29);//开始范围
picker.setRangeEnd(2022, 1, 1);//结束范围
picker.setOnDatePickListener(new DatePicker.OnYearMonthDayPickListener() {
@Override
public void onDatePicked(String year, String month, String day) {
showToast(year + "-" + month + "-" + day);
}
});
picker.show();
```

时间选择器:
```java
TimePicker picker = new TimePicker(this, TimePicker.HOUR_12);
picker.setRangeStart(9, 0);//09:00
picker.setRangeEnd(12, 30);//12:30
picker.setTopLineVisible(false);
picker.setOnTimePickListener(new TimePicker.OnTimePickListener() {
@Override
public void onTimePicked(String hour, String minute) {
showToast(hour + ":" + minute);
}
});
picker.show();
```

单项选择器(可用于性别、学历、职业、生肖、星座等选择):
```java
OptionPicker picker = new OptionPicker(this, new String[]{
"第一项", "第二项", "这是一个很长很长很长很长很长很长很长很长很长的很长很长的很长很长的项"
});
picker.setOffset(2);
picker.setSelectedIndex(1);
picker.setTextSize(11);
picker.setLineConfig(new WheelView.LineConfig(0));//使用最长的线
picker.setOnOptionPickListener(new OptionPicker.OnOptionPickListener() {
@Override
public void onOptionPicked(String option) {
showToast(option);
}
});
picker.show();
```

数字选择器(可用于身高、体重、年龄、温度等选择):
```java
NumberPicker picker = new NumberPicker(this);
picker.setOffset(2);//偏移量
picker.setRange(145, 200, 1);//数字范围
picker.setSelectedItem(172);
picker.setLabel("厘米");
picker.setOnNumberPickListener(new NumberPicker.OnNumberPickListener() {
@Override
public void onNumberPicked(int index, Number item) {
showToast("index=" + index + ", item=" + item.intValue());
}
});
picker.show();
```

二三级联动选择器(详见示例项目,参见AddressPicker)

地址选择器(含省级、地级、县级):
```java
ArrayList<Province> data = new ArrayList<Province>();
String json = AssetsUtils.readText(this, "city.json");
data.addAll(JSON.parseArray(json, Province.class));
AddressPicker picker = new AddressPicker(this, result);
picker.setSelectedItem("贵州", "贵阳", "花溪");
//picker.setHideProvince(true);//加上此句举将只显示地级及县级
//picker.setHideCounty(true);//加上此句举将只显示省级及地级
//picker.setColumnWeight(2/8.0, 3/8.0, 3/8.0);//省级、地级和县级的比例为2:3:3
picker.setOnAddressPickListener(new AddressPicker.OnAddressPickListener() {
@Override
public void onAddressPicked(Province province, City city, County county) {
showToast(province + city + county);
}
});
picker.show();
```

星座选择器:
选择器各个设置项:
```java
boolean isChinese = Locale.getDefault().getDisplayLanguage().contains("中文");
OptionPicker picker = new OptionPicker(this,
Expand All @@ -241,7 +108,6 @@ dependencies {
WheelView.LineConfig config = new WheelView.LineConfig();
config.setColor(0xFFEE0000);//线颜色
config.setAlpha(140);//线透明度
config.setRatio((float) (1.0 / 8.0));//线比率
picker.setLineConfig(config);
picker.setBackgroundColor(0xFFE1E1E1);
//picker.setSelectedItem(isChinese ? "射手" : "Sagittarius");
Expand All @@ -255,59 +121,20 @@ dependencies {
picker.show();
```

颜色选择器:
```java
ColorPicker picker = new ColorPicker(this);
picker.setInitColor(0xFFDD00DD);
picker.setOnColorPickListener(new ColorPicker.OnColorPickListener() {
@Override
public void onColorPicked(int pickedColor) {
showToast(ConvertUtils.toColorString(pickedColor));
}
});
picker.show();
```

文件选择器(需要权限android.permission.READ_EXTERNAL_STORAGE):
```java
FilePicker picker = new FilePicker(this, FilePicker.FILE);
picker.setShowHideDir(false);
picker.setRootPath(StorageUtils.getExternalRootPath() + "Download/");
//picker.setAllowExtensions(new String[]{".apk"});
picker.setOnFilePickListener(new FilePicker.OnFilePickListener() {
@Override
public void onFilePicked(String currentPath) {
showToast(currentPath);
}
});
picker.show();
```

目录选择器(需要权限android.permission.READ_EXTERNAL_STORAGE):
```java
FilePicker picker = new FilePicker(this, FilePicker.DIRECTORY);
picker.setOnFilePickListener(new FilePicker.OnFilePickListener() {
@Override
public void onFilePicked(String currentPath) {
showToast(currentPath);
}
});
picker.show();
```

# Screenshots
![滑轮选择器内嵌效果图](/screenshots/nestwheelview.jpg)
![自定义选择器效果图](/screenshots/custom.gif)
![日期选择器效果图](/screenshots/date.gif)
![日期选择器效果图](/screenshots/monthday.jpg)
![时间选择器效果图](/screenshots/time.gif)
![单项选择器效果图](/screenshots/option.gif)
![地址选择器效果图](/screenshots/address.gif)
![日期选择器效果图](/screenshots/date.gif)
![日期选择器效果图](/screenshots/monthday.jpg)
![时间选择器效果图](/screenshots/time.gif)
![单项选择器效果图](/screenshots/option.gif)
![地址选择器效果图](/screenshots/address.gif)
![城市选择器效果图](/screenshots/city.png)
![数字选择器效果图](/screenshots/number.gif)
![星座选择器效果图](/screenshots/constellation.jpg)
![颜色选择器效果图](/screenshots/color.gif)
![文件选择器效果图](/screenshots/file.gif)
![目录选择器效果图](/screenshots/dir.gif)
![星座选择器效果图](/screenshots/constellation.jpg)
![颜色选择器效果图](/screenshots/color.gif)
![文件选择器效果图](/screenshots/file.gif)
![目录选择器效果图](/screenshots/dir.gif)

# Contact
<a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=1032694760&site=穿青人&menu=yes"><img border="0" src="http://wpa.qq.com/pa?p=2:1032694760:51" alt="点击这里给我发消息" title="点击这里给我发消息"/></a>
Expand Down
Binary file added app/libs/AndroidPicker-1.4.0.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ com.android.build.gradle.overridePathCheck=true
#android.useDeprecatedNdk=true

#下面定义一些常量供gradle脚本使用
VERSION_NAME=1.3.5
VERSION_CODE=135
VERSION_NAME=1.4.0
VERSION_CODE=140
COMPILE_SDK_VERSION=23
MIN_SDK_VERSION=11
#安卓6.0开始(API23+),需要动态申请权限
Expand Down
2 changes: 1 addition & 1 deletion publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ task releaseJar(type: Jar) {
//from 'build/intermediates/bundles/release/'
//exclude '**/aidl', '**/jni', '**/libs', '**/res'
//exclude '**/AndroidManifest.xml', '**/classes.jar', '**/R.txt'
//exclude '**/wheelpicker', '**/colorpicker', '**/filepicker'
exclude '**/wheelpicker', '**/colorpicker', '**/filepicker'
exclude '**/BuildConfig.class', '**/R.class'
exclude { it.name.startsWith('R$'); }
}
Expand Down
Binary file added screenshots/city.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9500624

Please sign in to comment.