Skip to content

Commit b735896

Browse files
committed
2.0 优化
1 parent 1842242 commit b735896

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+5054
-1125
lines changed

ChangeLog.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,8 @@ picker.setLineColor(Color.parseColor("#ffdb2e"));这个设置线的方法没有
1313
地址选择点击确定后下标越界问题(不联动问题造成)
1414
增加可以设置dialog确认取消按钮位置(可以显示上面或下面)
1515
更新最新demo apk
16-
升级gradle
16+
升级gradle
17+
### v2.0.0 - 2020.01.30
18+
优化代码
19+
去掉基本不用的普通模式
20+
demo 增加日期段的选择

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
欢迎Fork & Pull requests贡献您的代码,大家共同学习【android-pickers交流群 : 456738690】。
88
[查看更新日志](https://github.com/addappcn/android-pickers/blob/master/ChangeLog.md)
99

10-
类库是基于[Android-PickerView](https://github.com/Bigkoo/Android-PickerView)[AndroidPicker](https://github.com/gzu-liyujiang/AndroidPicker)修改整合的,主要提供可以切换不同模式的view,
11-
同时也优化了部分代码和适配问题,后期也会增加其他模式的切换。
1210

1311
# 安装
1412
“app”是Sample;“android-pickers”是library 包括WheelPicker、SinglePicker、DatePicker、TimePicker、LinkagePicker、AddressPicker、NumberPicker、CarNumberPicker等。
@@ -155,7 +153,7 @@ dependencies {
155153

156154
## License
157155

158-
Copyright 2017 马广涛 (android-pickers)
156+
Copyright 2017 matt (android-pickers)
159157

160158
Licensed under the Apache License, Version 2.0 (the "License");
161159
you may not use this file except in compliance with the License.

android-pickers/src/main/java/cn/addapp/pickers/common/BaseDialog.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@
1313
import android.view.View;
1414
import android.view.ViewGroup;
1515
import android.view.Window;
16+
import android.view.WindowManager;
1617
import android.widget.FrameLayout;
1718

19+
import com.blankj.utilcode.util.SizeUtils;
20+
1821
import cn.addapp.pickers.util.LogUtils;
1922
import cn.addapp.pickers.util.ScreenUtils;
2023

@@ -51,13 +54,20 @@ private void initDialog() {
5154
contentLayout.setFocusableInTouchMode(true);
5255
//contentLayout.setFitsSystemWindows(true);
5356
dialog = new Dialog(activity);
54-
dialog.setCanceledOnTouchOutside(false);//触摸屏幕取消窗体
55-
dialog.setCancelable(false);//按返回键取消窗体
57+
dialog.setCanceledOnTouchOutside(true);//触摸屏幕取消窗体
58+
dialog.setCancelable(true);//按返回键取消窗体
5659
dialog.setOnKeyListener(this);
5760
dialog.setOnDismissListener(this);
5861
Window window = dialog.getWindow();
5962
if (window != null) {
60-
window.setGravity(Gravity.BOTTOM);
63+
// window.setGravity(Gravity.BOTTOM);
64+
////解决宽度问题
65+
window.setGravity(Gravity.CENTER);
66+
// dialogWindow.getDecorView().setPadding(0, 0, 0, 0);
67+
WindowManager.LayoutParams params = window.getAttributes();
68+
params.width = getScreenWidthPixels()- SizeUtils.dp2px(10);
69+
params.height = WindowManager.LayoutParams.WRAP_CONTENT;
70+
window.setAttributes(params);
6171
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
6272
//AndroidRuntimeException: requestFeature() must be called before adding content
6373
window.requestFeature(Window.FEATURE_NO_TITLE);
@@ -105,7 +115,7 @@ public void setHalfScreen(boolean halfScreen) {
105115

106116
/**
107117
* 位于屏幕何处
108-
*
118+
* 可以调整宽度和高度
109119
* @see Gravity
110120
*/
111121
public void setGravity(int gravity) {
@@ -115,7 +125,7 @@ public void setGravity(int gravity) {
115125
}
116126
if (gravity == Gravity.CENTER) {
117127
//居于屏幕正中间时,宽度不允许填充屏幕
118-
setWidth((int) (screenWidthPixels * 0.7f));
128+
setWidth((int) (screenWidthPixels * 0.9f));
119129
}
120130
}
121131

android-pickers/src/main/java/cn/addapp/pickers/common/ConfirmDialog.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.app.Activity;
44
import android.graphics.Color;
55
import android.support.annotation.ColorInt;
6+
import android.support.annotation.DrawableRes;
67
import android.support.annotation.IntRange;
78
import android.support.annotation.NonNull;
89
import android.support.annotation.Nullable;
@@ -15,6 +16,7 @@
1516
import android.widget.TextView;
1617

1718
import cn.addapp.pickers.util.ConvertUtils;
19+
import cn.addapp.pickers.wheelpicker.R;
1820

1921
/**
2022
* 带确定及取消按钮的弹窗
@@ -46,6 +48,8 @@ public void setActionButtonTop(boolean actionButtonTop) {
4648
protected int submitTextSize = 0;
4749
protected int titleTextSize = 0;
4850
protected int backgroundColor = Color.WHITE;
51+
@DrawableRes
52+
protected int backgroundRes = 0;
4953
private TextView cancelButton, submitButton;
5054
private View titleView;
5155

@@ -229,7 +233,9 @@ public void setTitleTextSize(@IntRange(from = 10, to = 40) int titleTextSize) {
229233
public void setBackgroundColor(@ColorInt int backgroundColor) {
230234
this.backgroundColor = backgroundColor;
231235
}
232-
236+
public void setBackgroundRes(@DrawableRes int res) {
237+
this.backgroundRes = res;
238+
}
233239
public void setTitleView(View titleView) {
234240
this.titleView = titleView;
235241
}
@@ -265,6 +271,9 @@ protected final View makeContentView() {
265271
LinearLayout rootLayout = new LinearLayout(activity);
266272
rootLayout.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
267273
rootLayout.setBackgroundColor(backgroundColor);
274+
if(0!=backgroundRes){
275+
rootLayout.setBackgroundResource(backgroundRes);
276+
}
268277
rootLayout.setOrientation(LinearLayout.VERTICAL);
269278
rootLayout.setGravity(Gravity.CENTER);
270279
rootLayout.setPadding(0, 0, 0, 0);

android-pickers/src/main/java/cn/addapp/pickers/common/LineConfig.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ public enum DividerType { // 分隔线类型
2626
private int itemHeight = 0;
2727
private int wheelSize = 0;
2828

29+
public DividerType getDividerType() {
30+
return dividerType;
31+
}
32+
33+
public void setDividerType(DividerType dividerType) {
34+
this.dividerType = dividerType;
35+
}
36+
37+
private DividerType dividerType = DividerType.WRAP;
38+
2939
public LineConfig() {
3040
super();
3141
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package cn.addapp.pickers.entity;
2+
3+
import java.util.List;
4+
5+
public class BaseData {
6+
public List<String> getShowContents() {
7+
return showContents;
8+
}
9+
10+
public void setShowContents(List<String> showContents) {
11+
this.showContents = showContents;
12+
}
13+
14+
public List<TimeWrapperEntity> getContentEntity() {
15+
return contentEntity;
16+
}
17+
18+
public void setContentEntity(List<TimeWrapperEntity> contentEntity) {
19+
this.contentEntity = contentEntity;
20+
}
21+
22+
private List<String> showContents;
23+
private List<TimeWrapperEntity> contentEntity;
24+
25+
public BaseData() {
26+
}
27+
28+
29+
}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
package cn.addapp.pickers.entity;
2+
3+
import android.os.Parcel;
4+
import android.os.Parcelable;
5+
6+
/**
7+
* 项目名称:UtoApp
8+
* 类描述:封装服务器返回的时间
9+
* 创建人:matt
10+
*/
11+
public class TimeWrapperEntity implements Parcelable {
12+
private long slotBegin;//开始时间
13+
private long slotEnd;//结束时间
14+
private String startTime;//HH:mm
15+
private String endTime;//HH:mm
16+
private String showTime;//用于界面显示的字符串
17+
18+
public TimeWrapperEntity(long slotBegin, String startTime, long slotEnd, String endTime) {
19+
this.slotBegin = slotBegin;
20+
this.slotEnd = slotEnd;
21+
this.startTime = startTime;
22+
this.endTime = endTime;
23+
}
24+
public TimeWrapperEntity(long slotBegin, String startTime, long slotEnd, String endTime,String showTime) {
25+
this.slotBegin = slotBegin;
26+
this.slotEnd = slotEnd;
27+
this.startTime = startTime;
28+
this.endTime = endTime;
29+
this.showTime = showTime;
30+
}
31+
32+
public String getShowTime() {
33+
return showTime;
34+
}
35+
36+
public void setShowTime(String showTime) {
37+
this.showTime = showTime;
38+
}
39+
40+
41+
public TimeWrapperEntity(String showTime) {
42+
this.showTime = showTime;
43+
}
44+
public long getSlotBegin() {
45+
return slotBegin;
46+
}
47+
48+
public void setSlotBegin(long slotBegin) {
49+
this.slotBegin = slotBegin;
50+
}
51+
52+
public long getSlotEnd() {
53+
return slotEnd;
54+
}
55+
56+
public void setSlotEnd(long slotEnd) {
57+
this.slotEnd = slotEnd;
58+
}
59+
60+
public String getStartTime() {
61+
return startTime;
62+
}
63+
64+
public void setStartTime(String startTime) {
65+
this.startTime = startTime;
66+
}
67+
68+
public String getEndTime() {
69+
return endTime;
70+
}
71+
72+
public void setEndTime(String endTime) {
73+
this.endTime = endTime;
74+
}
75+
76+
@Override
77+
public int describeContents() {
78+
return 0;
79+
}
80+
81+
@Override
82+
public void writeToParcel(Parcel dest, int flags) {
83+
dest.writeLong(this.slotBegin);
84+
dest.writeLong(this.slotEnd);
85+
dest.writeString(this.startTime);
86+
dest.writeString(this.endTime);
87+
dest.writeString(this.showTime);
88+
}
89+
90+
protected TimeWrapperEntity(Parcel in) {
91+
this.slotBegin = in.readLong();
92+
this.slotEnd = in.readLong();
93+
this.startTime = in.readString();
94+
this.endTime = in.readString();
95+
this.showTime = in.readString();
96+
}
97+
98+
public static final Creator<TimeWrapperEntity> CREATOR = new Creator<TimeWrapperEntity>() {
99+
@Override
100+
public TimeWrapperEntity createFromParcel(Parcel source) {
101+
return new TimeWrapperEntity(source);
102+
}
103+
104+
@Override
105+
public TimeWrapperEntity[] newArray(int size) {
106+
return new TimeWrapperEntity[size];
107+
}
108+
};
109+
}

android-pickers/src/main/java/cn/addapp/pickers/listeners/OnMoreWheelListener.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
*/
99

1010
public interface OnMoreWheelListener {
11-
public abstract void onFirstWheeled(int index, String item);
11+
void onFirstWheeled(int index, String item);
1212

13-
public abstract void onSecondWheeled(int index, String item);
13+
void onSecondWheeled(int index, String item);
1414

15-
public abstract void onThirdWheeled(int index, String item);
15+
void onThirdWheeled(int index, String item);
1616
}

android-pickers/src/main/java/cn/addapp/pickers/listeners/WheelViewGestureListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
final public class WheelViewGestureListener extends GestureDetector.SimpleOnGestureListener {
1010

11-
final WheelView wheelView;
11+
private final WheelView wheelView;
1212

1313
public WheelViewGestureListener(WheelView wheelView) {
1414
this.wheelView = wheelView;

0 commit comments

Comments
 (0)