Skip to content

Commit

Permalink
2.0 优化
Browse files Browse the repository at this point in the history
  • Loading branch information
addappcn committed Jan 30, 2020
1 parent 1842242 commit b735896
Show file tree
Hide file tree
Showing 64 changed files with 5,054 additions and 1,125 deletions.
6 changes: 5 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@ picker.setLineColor(Color.parseColor("#ffdb2e"));这个设置线的方法没有
地址选择点击确定后下标越界问题(不联动问题造成)
增加可以设置dialog确认取消按钮位置(可以显示上面或下面)
更新最新demo apk
升级gradle
升级gradle
### v2.0.0 - 2020.01.30
优化代码
去掉基本不用的普通模式
demo 增加日期段的选择
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
欢迎Fork & Pull requests贡献您的代码,大家共同学习【android-pickers交流群 : 456738690】。
[查看更新日志](https://github.com/addappcn/android-pickers/blob/master/ChangeLog.md)

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

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

## License

Copyright 2017 马广涛 (android-pickers)
Copyright 2017 matt (android-pickers)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;

import com.blankj.utilcode.util.SizeUtils;

import cn.addapp.pickers.util.LogUtils;
import cn.addapp.pickers.util.ScreenUtils;

Expand Down Expand Up @@ -51,13 +54,20 @@ private void initDialog() {
contentLayout.setFocusableInTouchMode(true);
//contentLayout.setFitsSystemWindows(true);
dialog = new Dialog(activity);
dialog.setCanceledOnTouchOutside(false);//触摸屏幕取消窗体
dialog.setCancelable(false);//按返回键取消窗体
dialog.setCanceledOnTouchOutside(true);//触摸屏幕取消窗体
dialog.setCancelable(true);//按返回键取消窗体
dialog.setOnKeyListener(this);
dialog.setOnDismissListener(this);
Window window = dialog.getWindow();
if (window != null) {
window.setGravity(Gravity.BOTTOM);
// window.setGravity(Gravity.BOTTOM);
////解决宽度问题
window.setGravity(Gravity.CENTER);
// dialogWindow.getDecorView().setPadding(0, 0, 0, 0);
WindowManager.LayoutParams params = window.getAttributes();
params.width = getScreenWidthPixels()- SizeUtils.dp2px(10);
params.height = WindowManager.LayoutParams.WRAP_CONTENT;
window.setAttributes(params);
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
//AndroidRuntimeException: requestFeature() must be called before adding content
window.requestFeature(Window.FEATURE_NO_TITLE);
Expand Down Expand Up @@ -105,7 +115,7 @@ public void setHalfScreen(boolean halfScreen) {

/**
* 位于屏幕何处
*
* 可以调整宽度和高度
* @see Gravity
*/
public void setGravity(int gravity) {
Expand All @@ -115,7 +125,7 @@ public void setGravity(int gravity) {
}
if (gravity == Gravity.CENTER) {
//居于屏幕正中间时,宽度不允许填充屏幕
setWidth((int) (screenWidthPixels * 0.7f));
setWidth((int) (screenWidthPixels * 0.9f));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.app.Activity;
import android.graphics.Color;
import android.support.annotation.ColorInt;
import android.support.annotation.DrawableRes;
import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
Expand All @@ -15,6 +16,7 @@
import android.widget.TextView;

import cn.addapp.pickers.util.ConvertUtils;
import cn.addapp.pickers.wheelpicker.R;

/**
* 带确定及取消按钮的弹窗
Expand Down Expand Up @@ -46,6 +48,8 @@ public void setActionButtonTop(boolean actionButtonTop) {
protected int submitTextSize = 0;
protected int titleTextSize = 0;
protected int backgroundColor = Color.WHITE;
@DrawableRes
protected int backgroundRes = 0;
private TextView cancelButton, submitButton;
private View titleView;

Expand Down Expand Up @@ -229,7 +233,9 @@ public void setTitleTextSize(@IntRange(from = 10, to = 40) int titleTextSize) {
public void setBackgroundColor(@ColorInt int backgroundColor) {
this.backgroundColor = backgroundColor;
}

public void setBackgroundRes(@DrawableRes int res) {
this.backgroundRes = res;
}
public void setTitleView(View titleView) {
this.titleView = titleView;
}
Expand Down Expand Up @@ -265,6 +271,9 @@ protected final View makeContentView() {
LinearLayout rootLayout = new LinearLayout(activity);
rootLayout.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
rootLayout.setBackgroundColor(backgroundColor);
if(0!=backgroundRes){
rootLayout.setBackgroundResource(backgroundRes);
}
rootLayout.setOrientation(LinearLayout.VERTICAL);
rootLayout.setGravity(Gravity.CENTER);
rootLayout.setPadding(0, 0, 0, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ public enum DividerType { // 分隔线类型
private int itemHeight = 0;
private int wheelSize = 0;

public DividerType getDividerType() {
return dividerType;
}

public void setDividerType(DividerType dividerType) {
this.dividerType = dividerType;
}

private DividerType dividerType = DividerType.WRAP;

public LineConfig() {
super();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package cn.addapp.pickers.entity;

import java.util.List;

public class BaseData {
public List<String> getShowContents() {
return showContents;
}

public void setShowContents(List<String> showContents) {
this.showContents = showContents;
}

public List<TimeWrapperEntity> getContentEntity() {
return contentEntity;
}

public void setContentEntity(List<TimeWrapperEntity> contentEntity) {
this.contentEntity = contentEntity;
}

private List<String> showContents;
private List<TimeWrapperEntity> contentEntity;

public BaseData() {
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
package cn.addapp.pickers.entity;

import android.os.Parcel;
import android.os.Parcelable;

/**
* 项目名称:UtoApp
* 类描述:封装服务器返回的时间
* 创建人:matt
*/
public class TimeWrapperEntity implements Parcelable {
private long slotBegin;//开始时间
private long slotEnd;//结束时间
private String startTime;//HH:mm
private String endTime;//HH:mm
private String showTime;//用于界面显示的字符串

public TimeWrapperEntity(long slotBegin, String startTime, long slotEnd, String endTime) {
this.slotBegin = slotBegin;
this.slotEnd = slotEnd;
this.startTime = startTime;
this.endTime = endTime;
}
public TimeWrapperEntity(long slotBegin, String startTime, long slotEnd, String endTime,String showTime) {
this.slotBegin = slotBegin;
this.slotEnd = slotEnd;
this.startTime = startTime;
this.endTime = endTime;
this.showTime = showTime;
}

public String getShowTime() {
return showTime;
}

public void setShowTime(String showTime) {
this.showTime = showTime;
}


public TimeWrapperEntity(String showTime) {
this.showTime = showTime;
}
public long getSlotBegin() {
return slotBegin;
}

public void setSlotBegin(long slotBegin) {
this.slotBegin = slotBegin;
}

public long getSlotEnd() {
return slotEnd;
}

public void setSlotEnd(long slotEnd) {
this.slotEnd = slotEnd;
}

public String getStartTime() {
return startTime;
}

public void setStartTime(String startTime) {
this.startTime = startTime;
}

public String getEndTime() {
return endTime;
}

public void setEndTime(String endTime) {
this.endTime = endTime;
}

@Override
public int describeContents() {
return 0;
}

@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(this.slotBegin);
dest.writeLong(this.slotEnd);
dest.writeString(this.startTime);
dest.writeString(this.endTime);
dest.writeString(this.showTime);
}

protected TimeWrapperEntity(Parcel in) {
this.slotBegin = in.readLong();
this.slotEnd = in.readLong();
this.startTime = in.readString();
this.endTime = in.readString();
this.showTime = in.readString();
}

public static final Creator<TimeWrapperEntity> CREATOR = new Creator<TimeWrapperEntity>() {
@Override
public TimeWrapperEntity createFromParcel(Parcel source) {
return new TimeWrapperEntity(source);
}

@Override
public TimeWrapperEntity[] newArray(int size) {
return new TimeWrapperEntity[size];
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
*/

public interface OnMoreWheelListener {
public abstract void onFirstWheeled(int index, String item);
void onFirstWheeled(int index, String item);

public abstract void onSecondWheeled(int index, String item);
void onSecondWheeled(int index, String item);

public abstract void onThirdWheeled(int index, String item);
void onThirdWheeled(int index, String item);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

final public class WheelViewGestureListener extends GestureDetector.SimpleOnGestureListener {

final WheelView wheelView;
private final WheelView wheelView;

public WheelViewGestureListener(WheelView wheelView) {
this.wheelView = wheelView;
Expand Down
Loading

0 comments on commit b735896

Please sign in to comment.