Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
supplier
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王宇航
supplier
Commits
a7b7159a
Commit
a7b7159a
authored
Oct 22, 2020
by
Wyh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.限制時間範圍的選擇器 2、查詢prj功能 3、新訂單優化
Signed-off-by: Wyh <1239658231>
parent
d56efe83
Hide whitespace changes
Inline
Side-by-side
Showing
41 changed files
with
3877 additions
and
1031 deletions
+3877
-1031
base-module/build.gradle
+2
-3
base-module/src/main/java/com/gingersoft/gsa/cloud/base/utils/time/TimePickerUtils.java
+20
-26
base-module/src/main/java/com/gingersoft/gsa/cloud/constans/AppConstans.java
+1
-0
base-module/src/main/java/com/gingersoft/gsa/cloud/print/bean/PrjBean.java
+88
-0
base-module/src/main/java/com/gingersoft/gsa/cloud/ui/view/MyEditText.java
+0
-475
base-module/src/main/java/com/gingersoft/gsa/cloud/ui/view/timeselect/BasePickerView.java
+361
-0
base-module/src/main/java/com/gingersoft/gsa/cloud/ui/view/timeselect/OptionsPickerView.java
+197
-0
base-module/src/main/java/com/gingersoft/gsa/cloud/ui/view/timeselect/TimePickerView.java
+289
-0
base-module/src/main/java/com/gingersoft/gsa/cloud/ui/view/timeselect/WheelOptions.java
+429
-0
base-module/src/main/java/com/gingersoft/gsa/cloud/ui/view/timeselect/WheelTime.java
+956
-0
base-module/src/main/java/com/gingersoft/gsa/cloud/ui/view/timeselect/builder/OptionsPickerBuilder.java
+292
-0
base-module/src/main/java/com/gingersoft/gsa/cloud/ui/view/timeselect/builder/TimePickerBuilder.java
+315
-0
base-module/src/main/res/values/ids.xml
+3
-0
delivery_pick_module/src/main/AndroidManifest.xml
+4
-0
delivery_pick_module/src/main/debug/AndroidManifest.xml
+1
-0
delivery_pick_module/src/main/java/com/gingersoft/gsa/delivery_pick_mode/DeliveryPickComponent.java
+5
-0
delivery_pick_module/src/main/java/com/gingersoft/gsa/delivery_pick_mode/data/network/ServiceCreator.kt
+3
-0
delivery_pick_module/src/main/java/com/gingersoft/gsa/delivery_pick_mode/di/component/PrjQueryComponent.java
+42
-0
delivery_pick_module/src/main/java/com/gingersoft/gsa/delivery_pick_mode/di/module/PrjQueryModule.java
+31
-0
delivery_pick_module/src/main/java/com/gingersoft/gsa/delivery_pick_mode/mvp/bean/PrjQueryBean.java
+20
-0
delivery_pick_module/src/main/java/com/gingersoft/gsa/delivery_pick_mode/mvp/contract/PrjQueryContract.java
+32
-0
delivery_pick_module/src/main/java/com/gingersoft/gsa/delivery_pick_mode/mvp/model/PrjQueryModel.java
+56
-0
delivery_pick_module/src/main/java/com/gingersoft/gsa/delivery_pick_mode/mvp/presenter/PrjQueryPresenter.java
+91
-0
delivery_pick_module/src/main/java/com/gingersoft/gsa/delivery_pick_mode/mvp/presenter/SendOrderPresenter.java
+2
-1
delivery_pick_module/src/main/java/com/gingersoft/gsa/delivery_pick_mode/mvp/server/PrjQueryServer.java
+15
-0
delivery_pick_module/src/main/java/com/gingersoft/gsa/delivery_pick_mode/mvp/ui/activity/AddressListActivity.java
+1
-1
delivery_pick_module/src/main/java/com/gingersoft/gsa/delivery_pick_mode/mvp/ui/activity/PrjQueryActivity.java
+233
-0
delivery_pick_module/src/main/java/com/gingersoft/gsa/delivery_pick_mode/mvp/ui/adapter/PrjStateAdapter.java
+58
-0
delivery_pick_module/src/main/java/com/gingersoft/gsa/delivery_pick_mode/ui/activity/OrderDetailsActivity.kt
+7
-0
delivery_pick_module/src/main/res/layout/activity_prj_query.xml
+137
-0
delivery_pick_module/src/main/res/layout/item_prj_state.xml
+58
-0
main-module/build.gradle
+1
-0
main-module/src/main/java/com/gingersoft/gsa/cloud/main/mvp/ui/activity/NewMainActivity.java
+64
-85
main-module/src/main/java/com/gingersoft/gsa/cloud/main/mvp/ui/adapter/ExpandListAdapter.java
+4
-4
print-module/src/main/java/com/joe/print/mvp/model/bean/PrintInfoBean.java
+1
-0
print-module/src/main/java/com/joe/print/mvp/model/bean/PrjBean.java
+0
-377
print-module/src/main/java/com/joe/print/mvp/print/PrintPrjKitchen.java
+2
-1
print-module/src/main/java/com/joe/print/mvp/print/service/PrjService.java
+1
-1
print-module/src/main/java/com/joe/print/mvp/ui/activity/PrintActivity.java
+10
-12
print-module/src/main/java/com/joe/print/mvp/ui/activity/PrintTestActivity.java
+44
-44
print-module/src/main/java/com/joe/print/mvp/ui/adapter/KitChenPrjPrintFoodAdapter.java
+1
-1
No files found.
base-module/build.gradle
View file @
a7b7159a
...
...
@@ -115,8 +115,6 @@ dependencies {
implementation
'com.gcssloop.recyclerview:pagerlayoutmanager:2.3.8'
//陰影背景
api
'com.github.lihangleo2:ShadowLayout:2.1.6'
//時間選擇控件
api
'com.contrarywind:Android-PickerView:3.2.4'
implementation
'org.aspectj:aspectjrt:1.8.9'
//商米打印庫
api
'com.sunmi:printerlibrary:1.0.7'
...
...
@@ -129,7 +127,8 @@ dependencies {
implementation
'cn.bingoogolapple:bga-photopicker:1.2.8@aar'
implementation
'cn.bingoogolapple:bga-baseadapter:1.2.9@aar'
implementation
'cn.bingoogolapple:bga-flowlayout:1.0.0@aar'
//时间选择器
api
rootProject
.
ext
.
dependencies
[
"pickerview"
]
api
'androidx.core:core-ktx:+'
implementation
'org.projectlombok:lombok:1.18.8'
...
...
base-module/src/main/java/com/gingersoft/gsa/cloud/base/utils/time/TimePickerUtils.java
View file @
a7b7159a
...
...
@@ -3,7 +3,9 @@ package com.gingersoft.gsa.cloud.base.utils.time;
import
android.content.Context
;
import
android.graphics.Color
;
import
com.bigkoo.pickerview.TimePickerView
;
import
com.bigkoo.pickerview.builder.TimePickerBuilder
;
import
com.bigkoo.pickerview.listener.OnTimeSelectListener
;
import
com.bigkoo.pickerview.view.TimePickerView
;
import
java.util.Calendar
;
...
...
@@ -19,16 +21,16 @@ public class TimePickerUtils {
* @param defaultTime 默認選中時間
* @param onTimeSelectListener 選中時間回調
*/
public
static
TimePickerView
showReportTimePicker
(
Context
mContext
,
Calendar
defaultTime
,
TimePickerView
.
OnTimeSelectListener
onTimeSelectListener
)
{
public
static
TimePickerView
showReportTimePicker
(
Context
mContext
,
Calendar
defaultTime
,
OnTimeSelectListener
onTimeSelectListener
)
{
//獲取今年第一天的日期
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
set
(
Calendar
.
DAY_OF_YEAR
,
cal
.
getActualMinimum
(
Calendar
.
DAY_OF_YEAR
));
//打開時間選擇器
TimePickerView
pvTime
=
new
TimePicker
View
.
Builder
(
mContext
,
onTimeSelectListener
)
.
setType
(
TimePickerView
.
Type
.
YEAR_MONTH_DAY
)
//默认全部显示
TimePickerView
pvTime
=
new
TimePickerBuilder
(
mContext
,
onTimeSelectListener
)
.
setType
(
new
boolean
[]{
true
,
true
,
true
,
false
,
false
,
false
}
)
//默认全部显示
.
setCancelText
(
"取消"
)
//取消按钮文字
.
setSubmitText
(
"確認"
)
//确认按钮文字
.
setContentSize
(
20
)
//滚轮文字大小
.
setContent
Text
Size
(
20
)
//滚轮文字大小
.
setTitleSize
(
20
)
//标题文字大小
// .setTitleText("请选择时间")//标题文字
.
setOutSideCancelable
(
true
)
//点击屏幕,点在控件外部范围时,是否取消显示
...
...
@@ -39,7 +41,6 @@ public class TimePickerUtils {
.
setCancelColor
(
Color
.
BLUE
)
//取消按钮文字颜色
// .setTitleBgColor(0xFF666666)//标题背景颜色 Night mode
// .setBgColor(0xFF333333)//滚轮背景颜色 Night mode
.
setRange
(
Calendar
.
getInstance
().
get
(
Calendar
.
YEAR
),
Calendar
.
getInstance
().
get
(
Calendar
.
YEAR
))
// .setDate(selectedDate)// 如果不设置的话,默认是系统时间*/
.
setRangDate
(
cal
,
Calendar
.
getInstance
())
//時間是今年第一天到今天
.
setLabel
(
""
,
""
,
""
,
""
,
""
,
""
)
...
...
@@ -60,16 +61,17 @@ public class TimePickerUtils {
* @param onTimeSelectListener 選中時間後點擊確認 回調
* @return
*/
public
static
TimePickerView
showReportTimePicker
(
Context
mContext
,
Calendar
startTime
,
Calendar
endTime
,
Calendar
defaultTime
,
TimePickerView
.
OnTimeSelectListener
onTimeSelectListener
)
{
public
static
TimePickerView
showReportTimePicker
(
Context
mContext
,
Calendar
startTime
,
Calendar
endTime
,
Calendar
defaultTime
,
OnTimeSelectListener
onTimeSelectListener
)
{
//獲取今年第一天的日期
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
set
(
Calendar
.
DAY_OF_YEAR
,
cal
.
getActualMinimum
(
Calendar
.
DAY_OF_YEAR
));
//打開時間選擇器
TimePickerView
pvTime
=
new
TimePicker
View
.
Builder
(
mContext
,
onTimeSelectListener
)
.
setType
(
TimePickerView
.
Type
.
YEAR_MONTH_DAY
)
//默认全部显示
TimePickerView
pvTime
=
new
TimePickerBuilder
(
mContext
,
onTimeSelectListener
)
.
setType
(
new
boolean
[]{
true
,
true
,
true
,
false
,
false
,
false
})
.
setCancelText
(
"取消"
)
//取消按钮文字
.
setSubmitText
(
"確認"
)
//确认按钮文字
.
setContentSize
(
20
)
//滚轮文字大小
.
setContent
Text
Size
(
20
)
//滚轮文字大小
.
setTitleSize
(
20
)
//标题文字大小
// .setTitleText("请选择时间")//标题文字
.
setOutSideCancelable
(
true
)
//点击屏幕,点在控件外部范围时,是否取消显示
...
...
@@ -80,7 +82,6 @@ public class TimePickerUtils {
.
setCancelColor
(
Color
.
BLUE
)
//取消按钮文字颜色
// .setTitleBgColor(0xFF666666)//标题背景颜色 Night mode
// .setBgColor(0xFF333333)//滚轮背景颜色 Night mode
.
setRange
(
Calendar
.
getInstance
().
get
(
Calendar
.
YEAR
),
Calendar
.
getInstance
().
get
(
Calendar
.
YEAR
))
// .setDate(selectedDate)// 如果不设置的话,默认是系统时间*/
.
setRangDate
(
startTime
,
endTime
)
//時間是今年第一天到今天
.
setLabel
(
""
,
""
,
""
,
""
,
""
,
""
)
...
...
@@ -100,35 +101,28 @@ public class TimePickerUtils {
* @param defaultTime 默認選中時間
* @param onTimeSelectListener 選中時間回調
*/
public
static
TimePickerView
showTimePicker
(
Context
mContext
,
Calendar
defaultTime
,
TimePickerView
.
OnTimeSelectListener
onTimeSelectListener
)
{
public
static
com
.
gingersoft
.
gsa
.
cloud
.
ui
.
view
.
timeselect
.
TimePickerView
showTimePicker
(
Context
mContext
,
Calendar
defaultTime
,
OnTimeSelectListener
onTimeSelectListener
)
{
//獲取今年第一天的日期
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
set
(
Calendar
.
HOUR
,
cal
.
getActualMaximum
(
Calendar
.
HOUR_OF_DAY
));
Calendar
endTime
=
Calendar
.
getInstance
();
endTime
.
set
(
Calendar
.
HOUR_OF_DAY
,
endTime
.
getActualMaximum
(
Calendar
.
HOUR_OF_DAY
));
endTime
.
set
(
Calendar
.
MINUTE
,
endTime
.
getActualMaximum
(
Calendar
.
MINUTE
));
//打開時間選擇器
TimePickerView
pvTime
=
new
TimePickerView
.
Builder
(
mContext
,
onTimeSelectListener
)
.
setType
(
TimePickerView
.
Type
.
HOURS_MINS
)
//默认全部显示
com
.
gingersoft
.
gsa
.
cloud
.
ui
.
view
.
timeselect
.
TimePickerView
pvTime
=
new
com
.
gingersoft
.
gsa
.
cloud
.
ui
.
view
.
timeselect
.
builder
.
TimePicker
Builder
(
mContext
,
onTimeSelectListener
)
.
setType
(
new
boolean
[]{
false
,
false
,
false
,
true
,
true
,
false
}
)
//默认全部显示
.
setCancelText
(
"取消"
)
//取消按钮文字
.
setSubmitText
(
"確認"
)
//确认按钮文字
.
setContentSize
(
20
)
//滚轮文字大小
.
setContent
Text
Size
(
20
)
//滚轮文字大小
.
setTitleSize
(
20
)
//标题文字大小
// .setTitleText("请选择时间")//标题文字
.
setOutSideCancelable
(
true
)
//点击屏幕,点在控件外部范围时,是否取消显示
.
isCyclic
(
false
)
//是否循环滚动
.
setTextColorCenter
(
Color
.
BLACK
)
//设置选中项的颜色
.
setTitleColor
(
Color
.
BLACK
)
//标题文字颜色
.
setSubmitColor
(
Color
.
BLUE
)
//确定按钮文字颜色
.
setCancelColor
(
Color
.
BLUE
)
//取消按钮文字颜色
// .setTitleBgColor(0xFF666666)//标题背景颜色 Night mode
// .setBgColor(0xFF333333)//滚轮背景颜色 Night mode
// .setRange(Calendar.getInstance().get(Calendar.YEAR), Calendar.getInstance().get(Calendar.YEAR))
// .setDate(selectedDate)// 如果不设置的话,默认是系统时间*/
.
setRangDate
(
Calendar
.
getInstance
(),
cal
)
//時間是今年第一天到今天
.
setRangDate
(
Calendar
.
getInstance
(),
endTime
)
//限制時間範圍
.
setLabel
(
""
,
""
,
""
,
""
,
""
,
""
)
.
isCenterLabel
(
false
)
//是否只显示中间选中项的label文字,false则每项item全部都带有label。
// .isDialog(true)//是否显示为对话框样式
.
build
();
//設置默認選中時間
// pvTime.setDate(defaultTime);//注:根据需求来决定是否使用该方法(一般是精确到秒的情况),此项可以在弹出选择器的时候重新设置当前时间,避免在初始化之后由于时间已经设定,导致选中时间与当前时间不匹配的问题。
pvTime
.
show
();
return
pvTime
;
}
...
...
base-module/src/main/java/com/gingersoft/gsa/cloud/constans/AppConstans.java
View file @
a7b7159a
...
...
@@ -10,6 +10,7 @@ public class AppConstans {
public
static
final
String
RP_THIRE_LOGISTICS_ERROR
=
"RP_WL003"
;
//第三方物流接口錯誤碼
public
static
final
String
RP_UPDATE_ORDER_STATE_ERROR
=
"RP_UO004"
;
//修改訂單狀態失敗錯誤碼
public
static
final
String
RP_LOGIN_ERROR
=
"RP_LOGIN"
;
//登陸報錯錯誤碼
public
static
final
String
RP_REPRINT_CODE
=
"RP_REPRINT_CODE"
;
//登陸報錯錯誤碼
public
static
final
String
SECRETKEY_VALUES
=
"2309485937845783"
;
...
...
base-module/src/main/java/com/gingersoft/gsa/cloud/print/bean/PrjBean.java
0 → 100644
View file @
a7b7159a
package
com
.
gingersoft
.
gsa
.
cloud
.
print
.
bean
;
import
java.io.Serializable
;
import
java.util.List
;
import
java.util.Map
;
import
lombok.Data
;
@Data
public
class
PrjBean
{
/**
* success : true
* sysTime : 1589177793623
* data : {"-1":[{"id":1,"printerDeviceId":-1,"status":1,"tableName":"51536","orderNo":"gs201351936242891","orderTime":2020,"person":2,"orderDetailsTime":"May 7, 2020 6:47:16 PM","orderDetailsId":48827589,"productName":"炸鸡翅","parentId":0,"type":3},{"id":2,"printerDeviceId":-1,"status":1,"tableName":"51536","orderNo":"gs201351936242891","orderTime":2020,"person":2,"orderDetailsTime":"May 7, 2020 6:47:16 PM","orderDetailsId":48827590,"productName":"鮮茄汁藍青口","parentId":0,"type":3}],"k1":[{"id":77,"printerDeviceId":1,"status":1,"tableName":"51536","orderNo":"gs201351936242891","orderTime":2020,"person":2,"orderDetailsTime":"May 11, 2020 11:41:41 AM","orderDetailsId":48828004,"productName":"走青檸測試","parentId":48827589,"type":4},{"id":78,"printerDeviceId":1,"status":1,"tableName":"51536","orderNo":"gs201351936242891","orderTime":2020,"person":2,"orderDetailsTime":"May 11, 2020 11:41:41 AM","orderDetailsId":48828005,"productName":"走豆測試","parentId":48827590,"type":4},{"id":79,"printerDeviceId":1,"status":1,"tableName":"51536","orderNo":"gs201351936242891","orderTime":2020,"person":2,"orderDetailsTime":"May 11, 2020 11:41:41 AM","orderDetailsId":48828006,"productName":"精選牛肉","parentId":0,"type":3},{"id":80,"printerDeviceId":1,"status":1,"tableName":"51536","orderNo":"gs201351936242891","orderTime":2020,"person":2,"orderDetailsTime":"May 11, 2020 11:41:41 AM","orderDetailsId":48828007,"productName":"走豆測試","parentId":48828006,"type":4},{"id":81,"printerDeviceId":1,"status":1,"tableName":"51536","orderNo":"gs201351936242891","orderTime":2020,"person":2,"orderDetailsTime":"May 11, 2020 11:41:41 AM","orderDetailsId":48828008,"productName":"雞飯(四客)","parentId":48828006,"type":3},{"id":82,"printerDeviceId":1,"status":1,"tableName":"51536","orderNo":"gs201351936242891","orderTime":2020,"person":2,"orderDetailsTime":"May 11, 2020 11:41:41 AM","orderDetailsId":48828009,"productName":"精選牛肉","parentId":48828006,"type":3}]}
*/
private
boolean
success
;
private
long
sysTime
;
private
String
data
;
@Data
public
static
class
DataBean
{
public
Map
<
String
,
List
<
Bean
>>
prjMap
;
@Data
public
static
class
Bean
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
3210457151279539745L
;
/**
* id : 77
* printerDeviceId : 1
* status : 1
* tableName : 51536
* orderNo : gs201351936242891
* orderTime : 2020
* person : 2
* orderDetailsTime : May 11, 2020 11:41:41 AM
* orderDetailsId : 48828004
* productName : 走青檸測試
* parentId : 48827589
* type : 4
*/
private
int
id
;
private
int
printerDeviceId
;
private
int
status
;
//為2是帶*,需要切紙的
private
String
tableName
;
private
String
orderNo
;
private
int
orderTime
;
private
int
person
;
private
String
orderDetailsTime
;
private
int
orderDetailsId
;
private
String
productName
;
private
String
productName2
;
private
String
productName3
;
private
int
parentId
;
private
int
type
;
private
int
printerType
;
private
Long
printerTime
;
private
int
number
;
private
String
productId
;
private
Long
createTime
;
private
int
requests
;
private
int
actualPrinterDeviceId
;
private
String
takeFoodCode
;
//取餐碼
private
String
billNo
;
//訂單碼
private
int
orderType
;
//訂單類型
private
String
userName
;
/***
* 層級
* 1:主食品
* 2:子項or細項
* 3:細項
*/
private
int
itemType
;
private
String
sender
;
private
String
takeTime
;
private
String
sendTime
;
private
int
currentIndex
;
//當前是第幾張prj
private
int
totalPrj
;
//本次總共有多少張prj
private
int
isFirstSendOrder
;
//是否首次送單,1是 2否
private
int
quantity
;
//統計打印數量
private
int
presence
;
//presence:是否生成prj記錄 0:否,1:是
private
String
printPosition
;
//廚房位置
}
}
}
base-module/src/main/java/com/gingersoft/gsa/cloud/ui/view/MyEditText.java
deleted
100644 → 0
View file @
d56efe83
//package com.gingersoft.gsa.cloud.ui.view;
//
//import android.content.Context;
//import android.content.res.TypedArray;
//import android.graphics.drawable.Drawable;
//import android.text.Editable;
//import android.text.InputFilter;
//import android.text.Spanned;
//import android.text.TextUtils;
//import android.text.TextWatcher;
//import android.text.method.HideReturnsTransformationMethod;
//import android.text.method.PasswordTransformationMethod;
//import android.util.AttributeSet;
//import android.view.View;
//import android.view.ViewGroup;
//import android.widget.CheckBox;
//import android.widget.EditText;
//import android.widget.ImageView;
//import android.widget.RelativeLayout;
//import android.widget.TextView;
//import android.widget.Toast;
//
//import com.gingersoft.gsa.cloud.base.R;
//import com.gingersoft.gsa.cloud.base.utils.screen.ConvertDpAndPx;
//
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * Created by Wyh on 2019/12/19.
// */
//public class MyEditText extends RelativeLayout {
//
// private Context context;
// //輸入最大長度
// private int maxLeght;
//
// private String maxLengthTip;
// //是否顯示輸入最大字數限制
// private boolean isShowMaxLenght;
// private int maxLenghtTextColor;
// private int maxLenghtTextSize;
// private int maxTextMarginLeft;
// private int maxTextMarginRight;
// private int maxTextMarginTop;
// private int maxTextMarginBottom;
// //是否允許輸入表情
// private boolean isInputIcon;
// //輸入表情時提示的內容,不設置內容不提示
// private String inputIconTipText;
//
// private String hint;
// private int hintColor;
// private int edTextColor;
// private String edText;
// private int edTextSize;
// //清除按鈕的大小
// private int clearIconSiZe;
// //清除按鈕圖標
// private Drawable clearIcon;
// //清除按鈕右間距
// private int clearRightMargin;
// //清除按鈕點擊事件
// private OnClickListener clearOnClickListener;
//
// //查看密碼按鈕圖標兩種狀態
// private Drawable lookIconUncheck;
//
// private Drawable lookIconChecked;
//
// //"查看密碼"圖標的大小
// private int lookIconSiZe;
// //查看密碼按鈕右間距
// private int lookRightMargin;
// //查看密碼按鈕點擊事件
// private OnClickListener lookOnClickListener;
//
// private int btnMarginTop;
// private int btnMarginRight;
// private int btnMarginBottom;
// private int btnMarginLeft;
//
//
// //設置輸入密碼替換符
// private String pwdChar;
// //是否換行
// private boolean singleLine;
//
// private int inputType;
//
// private int contentGravity;
//
// private int btnGravity;
// private EditText editText;
// //顯示最大字數的textview
// private TextView maxLenghtTextView;
//
// private ImageView ivClear;
// private CheckBox ivLook;
//
//
// private List<InputFilter> mInputFilter = new ArrayList<>();
//
// private AsteriskPasswordTransformationMethod passwordTransformationMethod;
//
// public MyEditText(Context context) {
// this(context, null);
// }
//
// public MyEditText(Context context, AttributeSet attrs) {
// this(context, attrs, -1);//R.attr.editTextStyle
// }
//
// public MyEditText(Context context, AttributeSet attrs, int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// this.context = context;
// TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.MyEditText);
// maxLeght = typedArray.getInt(R.styleable.MyEditText_ed_MaxLength, 0);
// maxLengthTip = typedArray.getString(R.styleable.MyEditText_ed_MaxLengthTip);
// isShowMaxLenght = typedArray.getBoolean(R.styleable.MyEditText_ed_showMaxLenght, false);
// maxLenghtTextColor = typedArray.getColor(R.styleable.MyEditText_ed_maxLengthTextColor, 0x10);
// maxLenghtTextSize = ConvertDpAndPx.Px2Dp(context, typedArray.getDimensionPixelSize(R.styleable.MyEditText_ed_maxLengthTextSize, 12));
// isInputIcon = typedArray.getBoolean(R.styleable.MyEditText_ed_isInputIcon, false);
// inputIconTipText = typedArray.getString(R.styleable.MyEditText_ed_putIconTip);
// clearIconSiZe = typedArray.getDimensionPixelSize(R.styleable.MyEditText_ed_clearIconSize, 0);
// clearIcon = typedArray.getDrawable(R.styleable.MyEditText_ed_clearRes);
// clearRightMargin = ConvertDpAndPx.Px2Dp(context, typedArray.getDimensionPixelSize(R.styleable.MyEditText_ed_clearMarginRight, 0));
// lookIconUncheck = typedArray.getDrawable(R.styleable.MyEditText_ed_lookIcon_uncheck);
// lookIconChecked = typedArray.getDrawable(R.styleable.MyEditText_ed_lookIcon_checked);
// lookIconSiZe = ConvertDpAndPx.Px2Dp(context, typedArray.getDimensionPixelSize(R.styleable.MyEditText_ed_lookIconSize, 0));
// lookRightMargin = ConvertDpAndPx.Px2Dp(context, typedArray.getDimensionPixelSize(R.styleable.MyEditText_ed_lookMarginRight, 0));
// pwdChar = typedArray.getString(R.styleable.MyEditText_ed_pwdChar);
// singleLine = typedArray.getBoolean(R.styleable.MyEditText_ed_singLeLine, false);
// inputType = typedArray.getInteger(R.styleable.MyEditText_inputType, 0);
// contentGravity = typedArray.getInteger(R.styleable.MyEditText_ed_gravity, 0);
//
// maxTextMarginLeft = ConvertDpAndPx.Px2Dp(context, typedArray.getDimensionPixelSize(R.styleable.MyEditText_ed_maxLengthMarginLeft, 0));
// maxTextMarginRight = ConvertDpAndPx.Px2Dp(context, typedArray.getDimensionPixelSize(R.styleable.MyEditText_ed_maxLengthMarginRight, 0));
// maxTextMarginTop = ConvertDpAndPx.Px2Dp(context, typedArray.getDimensionPixelSize(R.styleable.MyEditText_ed_maxLengthMarginTop, 0));
// maxTextMarginBottom = ConvertDpAndPx.Px2Dp(context, typedArray.getDimensionPixelSize(R.styleable.MyEditText_ed_maxLengthMarginBottom, 0));
// btnGravity = typedArray.getInteger(R.styleable.MyEditText_ed_clear_gravity, 2);
//
// btnMarginTop = ConvertDpAndPx.Px2Dp(context, typedArray.getDimensionPixelSize(R.styleable.MyEditText_ed_btn_marginTop, 0));
// btnMarginRight = ConvertDpAndPx.Px2Dp(context, typedArray.getDimensionPixelSize(R.styleable.MyEditText_ed_btn_marginRight, 0));
// btnMarginBottom = ConvertDpAndPx.Px2Dp(context, typedArray.getDimensionPixelSize(R.styleable.MyEditText_ed_btn_marginBottom, 0));
// btnMarginLeft = ConvertDpAndPx.Px2Dp(context, typedArray.getDimensionPixelSize(R.styleable.MyEditText_ed_btn_marginLeft, 0));
//
// hint = typedArray.getString(R.styleable.MyEditText_ed_hint);
// hintColor = typedArray.getColor(R.styleable.MyEditText_ed_hintColor, 0x10);
// edTextColor = typedArray.getColor(R.styleable.MyEditText_ed_textColor, 0x10);
// edText = typedArray.getString(R.styleable.MyEditText_ed_text);
// edTextSize = ConvertDpAndPx.Px2Dp(context, typedArray.getDimensionPixelSize(R.styleable.MyEditText_ed_textSize, 12));
//
// typedArray.recycle();
//
// initLeght();
// initEditText();
// initClearIcon();
// initLookIcon();
// }
//
// @Override
// protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// super.onMeasure(widthMeasureSpec, heightMeasureSpec);
// int height = 0;
// for (int i = 0; i < getChildCount(); i++) {
// View childView = getChildAt(i);
// measureChild(childView, widthMeasureSpec, heightMeasureSpec);
// height += childView.getMeasuredHeight();
// }
// setMeasuredDimension(widthMeasureSpec, height);
// }
//
// private void initEditText() {
// if (!isInputIcon) {
// mInputFilter.add(new EmojiInputFilter());
// }
// editText = new EditText(context);
// editText.setText(edText);
// editText.setTextColor(edTextColor);
// editText.setHint(hint);
// editText.setHintTextColor(hintColor);
// editText.setTextSize(edTextSize);
// editText.setGravity(contentGravity);
// InputFilter[] inputFilters = new InputFilter[mInputFilter.size()];
// for (int i = 0; i < mInputFilter.size(); i++) {
// inputFilters[i] = mInputFilter.get(i);
// }
// editText.setFilters(inputFilters);
// if (!TextUtils.isEmpty(pwdChar)) {
// passwordTransformationMethod = new AsteriskPasswordTransformationMethod();
// editText.setTransformationMethod(passwordTransformationMethod);//必須在setsingleLine之後才有效
// }
// if (inputType != 0) {
// editText.setInputType(inputType);
// }
//
// LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
// editText.setPadding(0, 0, clearIconSiZe + lookIconSiZe + clearRightMargin + lookRightMargin, 0);
// editText.setBackgroundColor(0);
// editText.setLayoutParams(params);
//// editText.setSingleLine();這個方法會改變edittext的TransformationMethod,不適用
// if (singleLine) {
// editText.setMaxLines(1);
// editText.setHorizontallyScrolling(true);
// } else {
// editText.setMaxLines(Integer.MAX_VALUE);
// //水平滚动设置为False
// editText.setHorizontallyScrolling(false);
// }
//
// editText.addTextChangedListener(new TextWatcher() {
// @Override
// public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
//
// }
//
// @Override
// public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
//
// }
//
// @Override
// public void afterTextChanged(Editable editable) {
// setMaxLengthText(editable.toString().length());
// if (ivClear != null) {
// if (editable.toString().length() > 0) {
// ivClear.setVisibility(VISIBLE);
// } else {
// ivClear.setVisibility(GONE);
// }
// }
// }
// });
// this.addView(editText);
// }
//
// /**
// * 初始化查看密碼按鈕
// */
// private void initLookIcon() {
// if (lookIconUncheck != null) {
// ivLook = new CheckBox(context);
// LayoutParams ivLookParams = getImgLayoutParams(lookIconSiZe, lookIconSiZe, lookRightMargin);
// ivLook.setButtonDrawable(null);
// if (ivClear != null) {
// ivLookParams.rightMargin = clearIconSiZe + lookRightMargin + clearRightMargin;
// } else {
// ivLookParams.rightMargin = lookRightMargin;
// }
//
// ivLook.setLayoutParams(ivLookParams);
// ivLook.setBackground(lookIconUncheck);
//
// this.addView(ivLook);
// ivLook.setOnCheckedChangeListener((buttonView, isChecked) -> {
// if (isChecked) {
// ivLook.setBackground(lookIconChecked);
// editText.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
// } else {
// ivLook.setBackground(lookIconUncheck);
// if (passwordTransformationMethod == null) {
// editText.setTransformationMethod(new PasswordTransformationMethod());
// } else {
// editText.setTransformationMethod(passwordTransformationMethod);//讓密碼顯示為*
// }
// }
// editText.setSelection(editText.getText().toString().length());
// if (lookOnClickListener != null) {
// lookOnClickListener.onClick(buttonView);
// }
// });
// }
// }
//
// /**
// * 初始化清空按鈕
// */
// private void initClearIcon() {
// if (clearIcon != null) {
// ivClear = new ImageView(context);
// ivClear.setImageDrawable(clearIcon);
// ivClear.setLayoutParams(getImgLayoutParams(clearIconSiZe, clearIconSiZe, clearRightMargin));
// this.addView(ivClear);
// //有了內容才顯示清除按鈕
// ivClear.setVisibility(GONE);
// ivClear.setOnClickListener(view -> {
// editText.setText("");
// if (clearOnClickListener != null) {
// clearOnClickListener.onClick(view);
// }
// });
// }
// }
//
// public EditText getEditText() {
// return editText;
// }
//
// public void setEditText(EditText editText) {
// this.editText = editText;
// }
//
// public Editable getText() {
// return editText.getText();
// }
//
// public EditText setText(String text){
// editText.setText(text);
// return editText;
// }
//
// private void setMaxLengthText(int currentLenght) {
// if (maxLenghtTextView != null)
// maxLenghtTextView.setText(currentLenght + "/" + maxLeght);
// }
//
//
// private LayoutParams getImgLayoutParams(int widht, int height, int rightMargin) {
// LayoutParams params;
// if (widht == 0) {
// params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
// } else {
// params = new LayoutParams(widht, height);
// }
// params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
// switch (btnGravity) {
// case 1:
// params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
// break;
// case 2:
// params.addRule(RelativeLayout.CENTER_VERTICAL);
// break;
// case 3:
// params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
// break;
// }
// params.setMargins(btnMarginLeft, btnMarginTop, btnMarginRight, btnMarginBottom);
// params.rightMargin = rightMargin;
// return params;
// }
//
// /**
// * 初始化長度監聽和長度顯示文字
// */
// private void initLeght() {
// if (maxLeght > 0) {
// mInputFilter.add(new MaxTextLengthFilter(maxLeght));
// }
// if (isShowMaxLenght) {
// maxLenghtTextView = new TextView(context);
// maxLenghtTextView.setTextColor(maxLenghtTextColor);
// maxLenghtTextView.setTextSize(maxLenghtTextSize);
// LayoutParams textParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
// textParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
// textParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
// textParams.setMargins(maxTextMarginLeft, maxTextMarginTop, maxTextMarginRight, maxTextMarginBottom);
// maxLenghtTextView.setLayoutParams(textParams);
// setMaxLengthText(0);
// this.addView(maxLenghtTextView);
// }
// }
//
// /**
// * 检测是否有emoji表情
// *
// * @param source
// * @return
// */
// private boolean containsEmoji(String source) {
// int len = source.length();
// for (int i = 0; i < len; i++) {
// char codePoint = source.charAt(i);
// if (!isEmojiCharacter(codePoint)) { //如果不能匹配,则该字符是Emoji表情
// return true;
// }
// }
// return false;
// }
//
// /**
// * 判断是否是Emoji
// *
// * @param codePoint 比较的单个字符
// * @return
// */
// private boolean isEmojiCharacter(char codePoint) {
// return codePoint == 0x0 || codePoint == 0x9 || codePoint == 0xA || codePoint == 0xD || codePoint >= 0x20 && codePoint <= 0xD7FF || codePoint >= 0xE000 && codePoint <= 0xFFFD;
// }
//
//
// public void setClearOnClickListener(OnClickListener clearOnClickListener) {
// this.clearOnClickListener = clearOnClickListener;
// }
//
//
// public void setLookOnClickListener(OnClickListener lookOnClickListener) {
// this.lookOnClickListener = lookOnClickListener;
// }
//
// //最大字數限制器
// class MaxTextLengthFilter implements InputFilter {
// private int mMaxLength;
//
// public MaxTextLengthFilter(int max) {
// mMaxLength = max;
// }
//
// public CharSequence filter(CharSequence source, int start, int end,
// Spanned dest, int dstart, int dend) {
// int keep = mMaxLength - (dest.length() - (dend - dstart));
// if (keep < (end - start)) {
// if (!TextUtils.isEmpty(maxLengthTip)) {
//// ToastUtils.showShort();
// Toast.makeText(context, maxLengthTip, Toast.LENGTH_SHORT).show();
// }
// }
// if (keep <= 0) {
// return "";
// } else if (keep >= end - start) {
// return null;
// } else {
// return source.subSequence(start, start + keep);
// }
// }
// }
//
// class EmojiInputFilter implements InputFilter {
//
// @Override
// public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
// if (containsEmoji(source.toString())) {
// //如果輸入了表情
// if (!TextUtils.isEmpty(inputIconTipText)) {
// //提示文字不為空,就彈出提示,並移除掉表情
//// ToastUtils.showShort(inputIconTipText);
// Toast.makeText(context, inputIconTipText, Toast.LENGTH_SHORT).show();
// return "";
// }
// return "";
// }
// return source;
// }
// }
//
// //替換密碼輸入框顯示的密碼樣式
// public class AsteriskPasswordTransformationMethod extends PasswordTransformationMethod {
// @Override
// public CharSequence getTransformation(CharSequence source, View view) {
// return new PasswordCharSequence(source);
// }
//
// private class PasswordCharSequence implements CharSequence {
// private CharSequence mSource;
//
// public PasswordCharSequence(CharSequence source) {
// mSource = source;
// }
//
// public char charAt(int index) {
// return pwdChar.charAt(0);
// }
//
// public int length() {
// return mSource.length();
// }
//
// public CharSequence subSequence(int start, int end) {
// return mSource.subSequence(start, end);
// }
// }
// }
//
//
//}
base-module/src/main/java/com/gingersoft/gsa/cloud/ui/view/timeselect/BasePickerView.java
0 → 100644
View file @
a7b7159a
package
com
.
gingersoft
.
gsa
.
cloud
.
ui
.
view
.
timeselect
;
import
android.app.Activity
;
import
android.app.Dialog
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.graphics.Color
;
import
android.view.Gravity
;
import
android.view.KeyEvent
;
import
android.view.LayoutInflater
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.Window
;
import
android.view.animation.Animation
;
import
android.view.animation.AnimationUtils
;
import
android.widget.FrameLayout
;
import
com.bigkoo.pickerview.R
;
import
com.bigkoo.pickerview.configure.PickerOptions
;
import
com.bigkoo.pickerview.listener.OnDismissListener
;
import
com.bigkoo.pickerview.utils.PickerViewAnimateUtil
;
/**
* Created by Sai on 15/11/22.
* 精仿iOSPickerViewController控件
*/
public
class
BasePickerView
{
private
Context
context
;
protected
ViewGroup
contentContainer
;
private
ViewGroup
rootView
;
//附加View 的 根View
private
ViewGroup
dialogView
;
//附加Dialog 的 根View
protected
PickerOptions
mPickerOptions
;
private
OnDismissListener
onDismissListener
;
private
boolean
dismissing
;
private
Animation
outAnim
;
private
Animation
inAnim
;
private
boolean
isShowing
;
protected
int
animGravity
=
Gravity
.
BOTTOM
;
private
Dialog
mDialog
;
protected
View
clickView
;
//是通过哪个View弹出的
private
boolean
isAnim
=
true
;
public
BasePickerView
(
Context
context
)
{
this
.
context
=
context
;
}
protected
void
initViews
()
{
FrameLayout
.
LayoutParams
params
=
new
FrameLayout
.
LayoutParams
(
ViewGroup
.
LayoutParams
.
MATCH_PARENT
,
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
,
Gravity
.
BOTTOM
);
LayoutInflater
layoutInflater
=
LayoutInflater
.
from
(
context
);
if
(
isDialog
())
{
//如果是对话框模式
dialogView
=
(
ViewGroup
)
layoutInflater
.
inflate
(
R
.
layout
.
layout_basepickerview
,
null
,
false
);
//设置界面的背景为透明
dialogView
.
setBackgroundColor
(
Color
.
TRANSPARENT
);
//这个是真正要加载选择器的父布局
contentContainer
=
(
ViewGroup
)
dialogView
.
findViewById
(
R
.
id
.
content_container
);
//设置对话框 默认左右间距屏幕30
params
.
leftMargin
=
30
;
params
.
rightMargin
=
30
;
contentContainer
.
setLayoutParams
(
params
);
//创建对话框
createDialog
();
//给背景设置点击事件,这样当点击内容以外的地方会关闭界面
dialogView
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
dismiss
();
}
});
}
else
{
//如果只是要显示在屏幕的下方
//decorView是activity的根View,包含 contentView 和 titleView
if
(
mPickerOptions
.
decorView
==
null
)
{
mPickerOptions
.
decorView
=
(
ViewGroup
)
((
Activity
)
context
).
getWindow
().
getDecorView
();
}
//将控件添加到decorView中
rootView
=
(
ViewGroup
)
layoutInflater
.
inflate
(
R
.
layout
.
layout_basepickerview
,
mPickerOptions
.
decorView
,
false
);
rootView
.
setLayoutParams
(
new
FrameLayout
.
LayoutParams
(
ViewGroup
.
LayoutParams
.
MATCH_PARENT
,
ViewGroup
.
LayoutParams
.
MATCH_PARENT
));
if
(
mPickerOptions
.
outSideColor
!=
-
1
)
{
rootView
.
setBackgroundColor
(
mPickerOptions
.
outSideColor
);
}
//这个是真正要加载时间选取器的父布局
contentContainer
=
(
ViewGroup
)
rootView
.
findViewById
(
R
.
id
.
content_container
);
contentContainer
.
setLayoutParams
(
params
);
}
setKeyBackCancelable
(
true
);
}
protected
void
initAnim
()
{
inAnim
=
getInAnimation
();
outAnim
=
getOutAnimation
();
}
protected
void
initEvents
()
{
}
/**
* @param v (是通过哪个View弹出的)
* @param isAnim 是否显示动画效果
*/
public
void
show
(
View
v
,
boolean
isAnim
)
{
this
.
clickView
=
v
;
this
.
isAnim
=
isAnim
;
show
();
}
public
void
show
(
boolean
isAnim
)
{
show
(
null
,
isAnim
);
}
public
void
show
(
View
v
)
{
this
.
clickView
=
v
;
show
();
}
/**
* 添加View到根视图
*/
public
void
show
()
{
if
(
isDialog
())
{
showDialog
();
}
else
{
if
(
isShowing
())
{
return
;
}
isShowing
=
true
;
onAttached
(
rootView
);
rootView
.
requestFocus
();
}
}
/**
* show的时候调用
*
* @param view 这个View
*/
private
void
onAttached
(
View
view
)
{
mPickerOptions
.
decorView
.
addView
(
view
);
if
(
isAnim
)
{
contentContainer
.
startAnimation
(
inAnim
);
}
}
/**
* 检测该View是不是已经添加到根视图
*
* @return 如果视图已经存在该View返回true
*/
public
boolean
isShowing
()
{
if
(
isDialog
())
{
return
false
;
}
else
{
return
rootView
.
getParent
()
!=
null
||
isShowing
;
}
}
public
void
dismiss
()
{
if
(
isDialog
())
{
dismissDialog
();
}
else
{
if
(
dismissing
)
{
return
;
}
if
(
isAnim
)
{
//消失动画
outAnim
.
setAnimationListener
(
new
Animation
.
AnimationListener
()
{
@Override
public
void
onAnimationStart
(
Animation
animation
)
{
}
@Override
public
void
onAnimationEnd
(
Animation
animation
)
{
dismissImmediately
();
}
@Override
public
void
onAnimationRepeat
(
Animation
animation
)
{
}
});
contentContainer
.
startAnimation
(
outAnim
);
}
else
{
dismissImmediately
();
}
dismissing
=
true
;
}
}
public
void
dismissImmediately
()
{
mPickerOptions
.
decorView
.
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
//从根视图移除
mPickerOptions
.
decorView
.
removeView
(
rootView
);
isShowing
=
false
;
dismissing
=
false
;
if
(
onDismissListener
!=
null
)
{
onDismissListener
.
onDismiss
(
BasePickerView
.
this
);
}
}
});
}
private
Animation
getInAnimation
()
{
int
res
=
PickerViewAnimateUtil
.
getAnimationResource
(
this
.
animGravity
,
true
);
return
AnimationUtils
.
loadAnimation
(
context
,
res
);
}
private
Animation
getOutAnimation
()
{
int
res
=
PickerViewAnimateUtil
.
getAnimationResource
(
this
.
animGravity
,
false
);
return
AnimationUtils
.
loadAnimation
(
context
,
res
);
}
public
BasePickerView
setOnDismissListener
(
OnDismissListener
onDismissListener
)
{
this
.
onDismissListener
=
onDismissListener
;
return
this
;
}
public
void
setKeyBackCancelable
(
boolean
isCancelable
)
{
ViewGroup
View
;
if
(
isDialog
())
{
View
=
dialogView
;
}
else
{
View
=
rootView
;
}
View
.
setFocusable
(
isCancelable
);
View
.
setFocusableInTouchMode
(
isCancelable
);
if
(
isCancelable
)
{
View
.
setOnKeyListener
(
onKeyBackListener
);
}
else
{
View
.
setOnKeyListener
(
null
);
}
}
private
View
.
OnKeyListener
onKeyBackListener
=
new
View
.
OnKeyListener
()
{
@Override
public
boolean
onKey
(
View
v
,
int
keyCode
,
KeyEvent
event
)
{
if
(
keyCode
==
KeyEvent
.
KEYCODE_BACK
&&
event
.
getAction
()
==
MotionEvent
.
ACTION_DOWN
&&
isShowing
())
{
dismiss
();
return
true
;
}
return
false
;
}
};
protected
BasePickerView
setOutSideCancelable
(
boolean
isCancelable
)
{
if
(
rootView
!=
null
)
{
View
view
=
rootView
.
findViewById
(
R
.
id
.
outmost_container
);
if
(
isCancelable
)
{
view
.
setOnTouchListener
(
onCancelableTouchListener
);
}
else
{
view
.
setOnTouchListener
(
null
);
}
}
return
this
;
}
/**
* 设置对话框模式是否可以点击外部取消
*/
public
void
setDialogOutSideCancelable
()
{
if
(
mDialog
!=
null
)
{
mDialog
.
setCancelable
(
mPickerOptions
.
cancelable
);
}
}
/**
* Called when the user touch on black overlay, in order to dismiss the dialog.
*/
private
final
View
.
OnTouchListener
onCancelableTouchListener
=
new
View
.
OnTouchListener
()
{
@Override
public
boolean
onTouch
(
View
v
,
MotionEvent
event
)
{
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_DOWN
)
{
dismiss
();
}
return
false
;
}
};
public
View
findViewById
(
int
id
)
{
return
contentContainer
.
findViewById
(
id
);
}
public
void
createDialog
()
{
if
(
dialogView
!=
null
)
{
mDialog
=
new
Dialog
(
context
,
R
.
style
.
custom_dialog2
);
mDialog
.
setCancelable
(
mPickerOptions
.
cancelable
);
//不能点外面取消,也不能点back取消
mDialog
.
setContentView
(
dialogView
);
Window
dialogWindow
=
mDialog
.
getWindow
();
if
(
dialogWindow
!=
null
)
{
dialogWindow
.
setWindowAnimations
(
R
.
style
.
picker_view_scale_anim
);
dialogWindow
.
setGravity
(
Gravity
.
CENTER
);
//可以改成Bottom
}
mDialog
.
setOnDismissListener
(
new
DialogInterface
.
OnDismissListener
()
{
@Override
public
void
onDismiss
(
DialogInterface
dialog
)
{
if
(
onDismissListener
!=
null
)
{
onDismissListener
.
onDismiss
(
BasePickerView
.
this
);
}
}
});
}
}
private
void
showDialog
()
{
if
(
mDialog
!=
null
)
{
mDialog
.
show
();
}
}
private
void
dismissDialog
()
{
if
(
mDialog
!=
null
)
{
mDialog
.
dismiss
();
}
}
public
ViewGroup
getDialogContainerLayout
()
{
return
contentContainer
;
}
public
Dialog
getDialog
()
{
return
mDialog
;
}
public
boolean
isDialog
()
{
return
false
;
}
}
base-module/src/main/java/com/gingersoft/gsa/cloud/ui/view/timeselect/OptionsPickerView.java
0 → 100644
View file @
a7b7159a
package
com
.
gingersoft
.
gsa
.
cloud
.
ui
.
view
.
timeselect
;
import
android.content.Context
;
import
android.text.TextUtils
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.widget.Button
;
import
android.widget.LinearLayout
;
import
android.widget.RelativeLayout
;
import
android.widget.TextView
;
import
com.bigkoo.pickerview.R
;
import
com.bigkoo.pickerview.configure.PickerOptions
;
import
java.util.List
;
/**
* 条件选择器
* Created by Sai on 15/11/22.
*/
public
class
OptionsPickerView
<
T
>
extends
BasePickerView
implements
View
.
OnClickListener
{
private
WheelOptions
<
T
>
wheelOptions
;
private
static
final
String
TAG_SUBMIT
=
"submit"
;
private
static
final
String
TAG_CANCEL
=
"cancel"
;
public
OptionsPickerView
(
PickerOptions
pickerOptions
)
{
super
(
pickerOptions
.
context
);
mPickerOptions
=
pickerOptions
;
initView
(
pickerOptions
.
context
);
}
private
void
initView
(
Context
context
)
{
setDialogOutSideCancelable
();
initViews
();
initAnim
();
initEvents
();
if
(
mPickerOptions
.
customListener
==
null
)
{
LayoutInflater
.
from
(
context
).
inflate
(
mPickerOptions
.
layoutRes
,
contentContainer
);
//顶部标题
TextView
tvTitle
=
(
TextView
)
findViewById
(
R
.
id
.
tvTitle
);
RelativeLayout
rv_top_bar
=
(
RelativeLayout
)
findViewById
(
R
.
id
.
rv_topbar
);
//确定和取消按钮
Button
btnSubmit
=
(
Button
)
findViewById
(
R
.
id
.
btnSubmit
);
Button
btnCancel
=
(
Button
)
findViewById
(
R
.
id
.
btnCancel
);
btnSubmit
.
setTag
(
TAG_SUBMIT
);
btnCancel
.
setTag
(
TAG_CANCEL
);
btnSubmit
.
setOnClickListener
(
this
);
btnCancel
.
setOnClickListener
(
this
);
//设置文字
btnSubmit
.
setText
(
TextUtils
.
isEmpty
(
mPickerOptions
.
textContentConfirm
)
?
context
.
getResources
().
getString
(
R
.
string
.
pickerview_submit
)
:
mPickerOptions
.
textContentConfirm
);
btnCancel
.
setText
(
TextUtils
.
isEmpty
(
mPickerOptions
.
textContentCancel
)
?
context
.
getResources
().
getString
(
R
.
string
.
pickerview_cancel
)
:
mPickerOptions
.
textContentCancel
);
tvTitle
.
setText
(
TextUtils
.
isEmpty
(
mPickerOptions
.
textContentTitle
)
?
""
:
mPickerOptions
.
textContentTitle
);
//默认为空
//设置color
btnSubmit
.
setTextColor
(
mPickerOptions
.
textColorConfirm
);
btnCancel
.
setTextColor
(
mPickerOptions
.
textColorCancel
);
tvTitle
.
setTextColor
(
mPickerOptions
.
textColorTitle
);
rv_top_bar
.
setBackgroundColor
(
mPickerOptions
.
bgColorTitle
);
//设置文字大小
btnSubmit
.
setTextSize
(
mPickerOptions
.
textSizeSubmitCancel
);
btnCancel
.
setTextSize
(
mPickerOptions
.
textSizeSubmitCancel
);
tvTitle
.
setTextSize
(
mPickerOptions
.
textSizeTitle
);
}
else
{
mPickerOptions
.
customListener
.
customLayout
(
LayoutInflater
.
from
(
context
).
inflate
(
mPickerOptions
.
layoutRes
,
contentContainer
));
}
// ----滚轮布局
final
LinearLayout
optionsPicker
=
(
LinearLayout
)
findViewById
(
R
.
id
.
optionspicker
);
optionsPicker
.
setBackgroundColor
(
mPickerOptions
.
bgColorWheel
);
wheelOptions
=
new
WheelOptions
<>(
optionsPicker
,
mPickerOptions
.
isRestoreItem
);
if
(
mPickerOptions
.
optionsSelectChangeListener
!=
null
)
{
wheelOptions
.
setOptionsSelectChangeListener
(
mPickerOptions
.
optionsSelectChangeListener
);
}
wheelOptions
.
setTextContentSize
(
mPickerOptions
.
textSizeContent
);
wheelOptions
.
setItemsVisible
(
mPickerOptions
.
itemsVisibleCount
);
wheelOptions
.
setAlphaGradient
(
mPickerOptions
.
isAlphaGradient
);
wheelOptions
.
setLabels
(
mPickerOptions
.
label1
,
mPickerOptions
.
label2
,
mPickerOptions
.
label3
);
wheelOptions
.
setTextXOffset
(
mPickerOptions
.
x_offset_one
,
mPickerOptions
.
x_offset_two
,
mPickerOptions
.
x_offset_three
);
wheelOptions
.
setCyclic
(
mPickerOptions
.
cyclic1
,
mPickerOptions
.
cyclic2
,
mPickerOptions
.
cyclic3
);
wheelOptions
.
setTypeface
(
mPickerOptions
.
font
);
setOutSideCancelable
(
mPickerOptions
.
cancelable
);
wheelOptions
.
setDividerColor
(
mPickerOptions
.
dividerColor
);
wheelOptions
.
setDividerType
(
mPickerOptions
.
dividerType
);
wheelOptions
.
setLineSpacingMultiplier
(
mPickerOptions
.
lineSpacingMultiplier
);
wheelOptions
.
setTextColorOut
(
mPickerOptions
.
textColorOut
);
wheelOptions
.
setTextColorCenter
(
mPickerOptions
.
textColorCenter
);
wheelOptions
.
isCenterLabel
(
mPickerOptions
.
isCenterLabel
);
}
/**
* 动态设置标题
*
* @param text 标题文本内容
*/
public
void
setTitleText
(
String
text
)
{
TextView
tvTitle
=
(
TextView
)
findViewById
(
R
.
id
.
tvTitle
);
if
(
tvTitle
!=
null
)
{
tvTitle
.
setText
(
text
);
}
}
/**
* 设置默认选中项
*
* @param option1
*/
public
void
setSelectOptions
(
int
option1
)
{
mPickerOptions
.
option1
=
option1
;
reSetCurrentItems
();
}
public
void
setSelectOptions
(
int
option1
,
int
option2
)
{
mPickerOptions
.
option1
=
option1
;
mPickerOptions
.
option2
=
option2
;
reSetCurrentItems
();
}
public
void
setSelectOptions
(
int
option1
,
int
option2
,
int
option3
)
{
mPickerOptions
.
option1
=
option1
;
mPickerOptions
.
option2
=
option2
;
mPickerOptions
.
option3
=
option3
;
reSetCurrentItems
();
}
private
void
reSetCurrentItems
()
{
if
(
wheelOptions
!=
null
)
{
wheelOptions
.
setCurrentItems
(
mPickerOptions
.
option1
,
mPickerOptions
.
option2
,
mPickerOptions
.
option3
);
}
}
public
void
setPicker
(
List
<
T
>
optionsItems
)
{
this
.
setPicker
(
optionsItems
,
null
,
null
);
}
public
void
setPicker
(
List
<
T
>
options1Items
,
List
<
List
<
T
>>
options2Items
)
{
this
.
setPicker
(
options1Items
,
options2Items
,
null
);
}
public
void
setPicker
(
List
<
T
>
options1Items
,
List
<
List
<
T
>>
options2Items
,
List
<
List
<
List
<
T
>>>
options3Items
)
{
wheelOptions
.
setPicker
(
options1Items
,
options2Items
,
options3Items
);
reSetCurrentItems
();
}
//不联动情况下调用
public
void
setNPicker
(
List
<
T
>
options1Items
,
List
<
T
>
options2Items
,
List
<
T
>
options3Items
)
{
wheelOptions
.
setLinkage
(
false
);
wheelOptions
.
setNPicker
(
options1Items
,
options2Items
,
options3Items
);
reSetCurrentItems
();
}
@Override
public
void
onClick
(
View
v
)
{
String
tag
=
(
String
)
v
.
getTag
();
if
(
tag
.
equals
(
TAG_SUBMIT
))
{
returnData
();
}
else
if
(
tag
.
equals
(
TAG_CANCEL
))
{
if
(
mPickerOptions
.
cancelListener
!=
null
)
{
mPickerOptions
.
cancelListener
.
onClick
(
v
);
}
}
dismiss
();
}
//抽离接口回调的方法
public
void
returnData
()
{
if
(
mPickerOptions
.
optionsSelectListener
!=
null
)
{
int
[]
optionsCurrentItems
=
wheelOptions
.
getCurrentItems
();
mPickerOptions
.
optionsSelectListener
.
onOptionsSelect
(
optionsCurrentItems
[
0
],
optionsCurrentItems
[
1
],
optionsCurrentItems
[
2
],
clickView
);
}
}
@Override
public
boolean
isDialog
()
{
return
mPickerOptions
.
isDialog
;
}
}
base-module/src/main/java/com/gingersoft/gsa/cloud/ui/view/timeselect/TimePickerView.java
0 → 100644
View file @
a7b7159a
package
com
.
gingersoft
.
gsa
.
cloud
.
ui
.
view
.
timeselect
;
import
android.content.Context
;
import
android.text.TextUtils
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.widget.Button
;
import
android.widget.LinearLayout
;
import
android.widget.RelativeLayout
;
import
android.widget.TextView
;
import
com.bigkoo.pickerview.R
;
import
com.bigkoo.pickerview.configure.PickerOptions
;
import
com.bigkoo.pickerview.listener.ISelectTimeCallback
;
import
java.text.ParseException
;
import
java.util.Calendar
;
import
java.util.Date
;
/**
* 时间选择器
* Created by Sai on 15/11/22.
* Updated by XiaoSong on 2017-2-22.
*/
public
class
TimePickerView
extends
BasePickerView
implements
View
.
OnClickListener
{
private
WheelTime
wheelTime
;
//自定义控件
private
static
final
String
TAG_SUBMIT
=
"submit"
;
private
static
final
String
TAG_CANCEL
=
"cancel"
;
public
TimePickerView
(
PickerOptions
pickerOptions
)
{
super
(
pickerOptions
.
context
);
mPickerOptions
=
pickerOptions
;
initView
(
pickerOptions
.
context
);
}
private
void
initView
(
Context
context
)
{
setDialogOutSideCancelable
();
initViews
();
initAnim
();
if
(
mPickerOptions
.
customListener
==
null
)
{
LayoutInflater
.
from
(
context
).
inflate
(
R
.
layout
.
pickerview_time
,
contentContainer
);
//顶部标题
TextView
tvTitle
=
(
TextView
)
findViewById
(
R
.
id
.
tvTitle
);
RelativeLayout
rv_top_bar
=
(
RelativeLayout
)
findViewById
(
R
.
id
.
rv_topbar
);
//确定和取消按钮
Button
btnSubmit
=
(
Button
)
findViewById
(
R
.
id
.
btnSubmit
);
Button
btnCancel
=
(
Button
)
findViewById
(
R
.
id
.
btnCancel
);
btnSubmit
.
setTag
(
TAG_SUBMIT
);
btnCancel
.
setTag
(
TAG_CANCEL
);
btnSubmit
.
setOnClickListener
(
this
);
btnCancel
.
setOnClickListener
(
this
);
//设置文字
btnSubmit
.
setText
(
TextUtils
.
isEmpty
(
mPickerOptions
.
textContentConfirm
)
?
context
.
getResources
().
getString
(
R
.
string
.
pickerview_submit
)
:
mPickerOptions
.
textContentConfirm
);
btnCancel
.
setText
(
TextUtils
.
isEmpty
(
mPickerOptions
.
textContentCancel
)
?
context
.
getResources
().
getString
(
R
.
string
.
pickerview_cancel
)
:
mPickerOptions
.
textContentCancel
);
tvTitle
.
setText
(
TextUtils
.
isEmpty
(
mPickerOptions
.
textContentTitle
)
?
""
:
mPickerOptions
.
textContentTitle
);
//默认为空
//设置color
btnSubmit
.
setTextColor
(
mPickerOptions
.
textColorConfirm
);
btnCancel
.
setTextColor
(
mPickerOptions
.
textColorCancel
);
tvTitle
.
setTextColor
(
mPickerOptions
.
textColorTitle
);
rv_top_bar
.
setBackgroundColor
(
mPickerOptions
.
bgColorTitle
);
//设置文字大小
btnSubmit
.
setTextSize
(
mPickerOptions
.
textSizeSubmitCancel
);
btnCancel
.
setTextSize
(
mPickerOptions
.
textSizeSubmitCancel
);
tvTitle
.
setTextSize
(
mPickerOptions
.
textSizeTitle
);
}
else
{
mPickerOptions
.
customListener
.
customLayout
(
LayoutInflater
.
from
(
context
).
inflate
(
mPickerOptions
.
layoutRes
,
contentContainer
));
}
// 时间转轮 自定义控件
LinearLayout
timePickerView
=
(
LinearLayout
)
findViewById
(
R
.
id
.
timepicker
);
timePickerView
.
setBackgroundColor
(
mPickerOptions
.
bgColorWheel
);
initWheelTime
(
timePickerView
);
}
private
void
initWheelTime
(
LinearLayout
timePickerView
)
{
wheelTime
=
new
WheelTime
(
timePickerView
,
mPickerOptions
.
type
,
mPickerOptions
.
textGravity
,
mPickerOptions
.
textSizeContent
);
if
(
mPickerOptions
.
timeSelectChangeListener
!=
null
)
{
wheelTime
.
setSelectChangeCallback
(
new
ISelectTimeCallback
()
{
@Override
public
void
onTimeSelectChanged
()
{
try
{
Date
date
=
WheelTime
.
dateFormat
.
parse
(
wheelTime
.
getTime
());
mPickerOptions
.
timeSelectChangeListener
.
onTimeSelectChanged
(
date
);
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
}
});
}
wheelTime
.
setLunarMode
(
mPickerOptions
.
isLunarCalendar
);
if
(
mPickerOptions
.
startYear
!=
0
&&
mPickerOptions
.
endYear
!=
0
&&
mPickerOptions
.
startYear
<=
mPickerOptions
.
endYear
)
{
setRange
();
}
//若手动设置了时间范围限制
if
(
mPickerOptions
.
startDate
!=
null
&&
mPickerOptions
.
endDate
!=
null
)
{
if
(
mPickerOptions
.
startDate
.
getTimeInMillis
()
>
mPickerOptions
.
endDate
.
getTimeInMillis
())
{
throw
new
IllegalArgumentException
(
"startDate can't be later than endDate"
);
}
else
{
setRangDate
();
}
}
else
if
(
mPickerOptions
.
startDate
!=
null
)
{
if
(
mPickerOptions
.
startDate
.
get
(
Calendar
.
YEAR
)
<
1900
)
{
throw
new
IllegalArgumentException
(
"The startDate can not as early as 1900"
);
}
else
{
setRangDate
();
}
}
else
if
(
mPickerOptions
.
endDate
!=
null
)
{
if
(
mPickerOptions
.
endDate
.
get
(
Calendar
.
YEAR
)
>
2100
)
{
throw
new
IllegalArgumentException
(
"The endDate should not be later than 2100"
);
}
else
{
setRangDate
();
}
}
else
{
//没有设置时间范围限制,则会使用默认范围。
setRangDate
();
}
setTime
();
wheelTime
.
setLabels
(
mPickerOptions
.
label_year
,
mPickerOptions
.
label_month
,
mPickerOptions
.
label_day
,
mPickerOptions
.
label_hours
,
mPickerOptions
.
label_minutes
,
mPickerOptions
.
label_seconds
);
wheelTime
.
setTextXOffset
(
mPickerOptions
.
x_offset_year
,
mPickerOptions
.
x_offset_month
,
mPickerOptions
.
x_offset_day
,
mPickerOptions
.
x_offset_hours
,
mPickerOptions
.
x_offset_minutes
,
mPickerOptions
.
x_offset_seconds
);
wheelTime
.
setItemsVisible
(
mPickerOptions
.
itemsVisibleCount
);
wheelTime
.
setAlphaGradient
(
mPickerOptions
.
isAlphaGradient
);
setOutSideCancelable
(
mPickerOptions
.
cancelable
);
wheelTime
.
setCyclic
(
mPickerOptions
.
cyclic
);
wheelTime
.
setDividerColor
(
mPickerOptions
.
dividerColor
);
wheelTime
.
setDividerType
(
mPickerOptions
.
dividerType
);
wheelTime
.
setLineSpacingMultiplier
(
mPickerOptions
.
lineSpacingMultiplier
);
wheelTime
.
setTextColorOut
(
mPickerOptions
.
textColorOut
);
wheelTime
.
setTextColorCenter
(
mPickerOptions
.
textColorCenter
);
wheelTime
.
isCenterLabel
(
mPickerOptions
.
isCenterLabel
);
}
/**
* 设置默认时间
*/
public
void
setDate
(
Calendar
date
)
{
mPickerOptions
.
date
=
date
;
setTime
();
}
/**
* 设置可以选择的时间范围, 要在setTime之前调用才有效果
*/
private
void
setRange
()
{
wheelTime
.
setStartYear
(
mPickerOptions
.
startYear
);
wheelTime
.
setEndYear
(
mPickerOptions
.
endYear
);
}
/**
* 设置可以选择的时间范围, 要在setTime之前调用才有效果
*/
private
void
setRangDate
()
{
wheelTime
.
setRangDate
(
mPickerOptions
.
startDate
,
mPickerOptions
.
endDate
);
initDefaultSelectedDate
();
}
private
void
initDefaultSelectedDate
()
{
//如果手动设置了时间范围
if
(
mPickerOptions
.
startDate
!=
null
&&
mPickerOptions
.
endDate
!=
null
)
{
//若默认时间未设置,或者设置的默认时间越界了,则设置默认选中时间为开始时间。
if
(
mPickerOptions
.
date
==
null
||
mPickerOptions
.
date
.
getTimeInMillis
()
<
mPickerOptions
.
startDate
.
getTimeInMillis
()
||
mPickerOptions
.
date
.
getTimeInMillis
()
>
mPickerOptions
.
endDate
.
getTimeInMillis
())
{
mPickerOptions
.
date
=
mPickerOptions
.
startDate
;
}
}
else
if
(
mPickerOptions
.
startDate
!=
null
)
{
//没有设置默认选中时间,那就拿开始时间当默认时间
mPickerOptions
.
date
=
mPickerOptions
.
startDate
;
}
else
if
(
mPickerOptions
.
endDate
!=
null
)
{
mPickerOptions
.
date
=
mPickerOptions
.
endDate
;
}
}
/**
* 设置选中时间,默认选中当前时间
*/
private
void
setTime
()
{
int
year
,
month
,
day
,
hours
,
minute
,
seconds
;
Calendar
calendar
=
Calendar
.
getInstance
();
if
(
mPickerOptions
.
date
==
null
)
{
calendar
.
setTimeInMillis
(
System
.
currentTimeMillis
());
year
=
calendar
.
get
(
Calendar
.
YEAR
);
month
=
calendar
.
get
(
Calendar
.
MONTH
);
day
=
calendar
.
get
(
Calendar
.
DAY_OF_MONTH
);
hours
=
calendar
.
get
(
Calendar
.
HOUR_OF_DAY
);
minute
=
calendar
.
get
(
Calendar
.
MINUTE
);
seconds
=
calendar
.
get
(
Calendar
.
SECOND
);
}
else
{
year
=
mPickerOptions
.
date
.
get
(
Calendar
.
YEAR
);
month
=
mPickerOptions
.
date
.
get
(
Calendar
.
MONTH
);
day
=
mPickerOptions
.
date
.
get
(
Calendar
.
DAY_OF_MONTH
);
hours
=
mPickerOptions
.
date
.
get
(
Calendar
.
HOUR_OF_DAY
);
minute
=
mPickerOptions
.
date
.
get
(
Calendar
.
MINUTE
);
seconds
=
mPickerOptions
.
date
.
get
(
Calendar
.
SECOND
);
}
wheelTime
.
setPicker
(
year
,
month
,
day
,
hours
,
minute
,
seconds
);
}
@Override
public
void
onClick
(
View
v
)
{
String
tag
=
(
String
)
v
.
getTag
();
if
(
tag
.
equals
(
TAG_SUBMIT
))
{
returnData
();
}
else
if
(
tag
.
equals
(
TAG_CANCEL
))
{
if
(
mPickerOptions
.
cancelListener
!=
null
)
{
mPickerOptions
.
cancelListener
.
onClick
(
v
);
}
}
dismiss
();
}
public
void
returnData
()
{
if
(
mPickerOptions
.
timeSelectListener
!=
null
)
{
try
{
Date
date
=
WheelTime
.
dateFormat
.
parse
(
wheelTime
.
getTime
());
mPickerOptions
.
timeSelectListener
.
onTimeSelect
(
date
,
clickView
);
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
}
}
/**
* 动态设置标题
*
* @param text 标题文本内容
*/
public
void
setTitleText
(
String
text
)
{
TextView
tvTitle
=
(
TextView
)
findViewById
(
R
.
id
.
tvTitle
);
if
(
tvTitle
!=
null
)
{
tvTitle
.
setText
(
text
);
}
}
/**
* 目前暂时只支持设置1900 - 2100年
*
* @param lunar 农历的开关
*/
public
void
setLunarCalendar
(
boolean
lunar
)
{
try
{
int
year
,
month
,
day
,
hours
,
minute
,
seconds
;
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
WheelTime
.
dateFormat
.
parse
(
wheelTime
.
getTime
()));
year
=
calendar
.
get
(
Calendar
.
YEAR
);
month
=
calendar
.
get
(
Calendar
.
MONTH
);
day
=
calendar
.
get
(
Calendar
.
DAY_OF_MONTH
);
hours
=
calendar
.
get
(
Calendar
.
HOUR_OF_DAY
);
minute
=
calendar
.
get
(
Calendar
.
MINUTE
);
seconds
=
calendar
.
get
(
Calendar
.
SECOND
);
wheelTime
.
setLunarMode
(
lunar
);
wheelTime
.
setLabels
(
mPickerOptions
.
label_year
,
mPickerOptions
.
label_month
,
mPickerOptions
.
label_day
,
mPickerOptions
.
label_hours
,
mPickerOptions
.
label_minutes
,
mPickerOptions
.
label_seconds
);
wheelTime
.
setPicker
(
year
,
month
,
day
,
hours
,
minute
,
seconds
);
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
}
public
boolean
isLunarCalendar
()
{
return
wheelTime
.
isLunarMode
();
}
@Override
public
boolean
isDialog
()
{
return
mPickerOptions
.
isDialog
;
}
}
base-module/src/main/java/com/gingersoft/gsa/cloud/ui/view/timeselect/WheelOptions.java
0 → 100644
View file @
a7b7159a
package
com
.
gingersoft
.
gsa
.
cloud
.
ui
.
view
.
timeselect
;
import
android.graphics.Typeface
;
import
android.view.View
;
import
com.bigkoo.pickerview.R
;
import
com.bigkoo.pickerview.adapter.ArrayWheelAdapter
;
import
com.bigkoo.pickerview.listener.OnOptionsSelectChangeListener
;
import
com.contrarywind.listener.OnItemSelectedListener
;
import
com.contrarywind.view.WheelView
;
import
java.util.List
;
public
class
WheelOptions
<
T
>
{
private
View
view
;
private
WheelView
wv_option1
;
private
WheelView
wv_option2
;
private
WheelView
wv_option3
;
private
List
<
T
>
mOptions1Items
;
private
List
<
List
<
T
>>
mOptions2Items
;
private
List
<
List
<
List
<
T
>>>
mOptions3Items
;
private
boolean
linkage
=
true
;
//默认联动
private
boolean
isRestoreItem
;
//切换时,还原第一项
private
OnItemSelectedListener
wheelListener_option1
;
private
OnItemSelectedListener
wheelListener_option2
;
private
OnOptionsSelectChangeListener
optionsSelectChangeListener
;
public
View
getView
()
{
return
view
;
}
public
void
setView
(
View
view
)
{
this
.
view
=
view
;
}
public
WheelOptions
(
View
view
,
boolean
isRestoreItem
)
{
super
();
this
.
isRestoreItem
=
isRestoreItem
;
this
.
view
=
view
;
wv_option1
=
(
WheelView
)
view
.
findViewById
(
R
.
id
.
options1
);
// 初始化时显示的数据
wv_option2
=
(
WheelView
)
view
.
findViewById
(
R
.
id
.
options2
);
wv_option3
=
(
WheelView
)
view
.
findViewById
(
R
.
id
.
options3
);
}
public
void
setPicker
(
List
<
T
>
options1Items
,
List
<
List
<
T
>>
options2Items
,
List
<
List
<
List
<
T
>>>
options3Items
)
{
this
.
mOptions1Items
=
options1Items
;
this
.
mOptions2Items
=
options2Items
;
this
.
mOptions3Items
=
options3Items
;
// 选项1
wv_option1
.
setAdapter
(
new
ArrayWheelAdapter
(
mOptions1Items
));
// 设置显示数据
wv_option1
.
setCurrentItem
(
0
);
// 初始化时显示的数据
// 选项2
if
(
mOptions2Items
!=
null
)
{
wv_option2
.
setAdapter
(
new
ArrayWheelAdapter
(
mOptions2Items
.
get
(
0
)));
// 设置显示数据
}
wv_option2
.
setCurrentItem
(
wv_option2
.
getCurrentItem
());
// 初始化时显示的数据
// 选项3
if
(
mOptions3Items
!=
null
)
{
wv_option3
.
setAdapter
(
new
ArrayWheelAdapter
(
mOptions3Items
.
get
(
0
).
get
(
0
)));
// 设置显示数据
}
wv_option3
.
setCurrentItem
(
wv_option3
.
getCurrentItem
());
wv_option1
.
setIsOptions
(
true
);
wv_option2
.
setIsOptions
(
true
);
wv_option3
.
setIsOptions
(
true
);
if
(
this
.
mOptions2Items
==
null
)
{
wv_option2
.
setVisibility
(
View
.
GONE
);
}
else
{
wv_option2
.
setVisibility
(
View
.
VISIBLE
);
}
if
(
this
.
mOptions3Items
==
null
)
{
wv_option3
.
setVisibility
(
View
.
GONE
);
}
else
{
wv_option3
.
setVisibility
(
View
.
VISIBLE
);
}
// 联动监听器
wheelListener_option1
=
new
OnItemSelectedListener
()
{
@Override
public
void
onItemSelected
(
int
index
)
{
int
opt2Select
=
0
;
if
(
mOptions2Items
==
null
)
{
//只有1级联动数据
if
(
optionsSelectChangeListener
!=
null
)
{
optionsSelectChangeListener
.
onOptionsSelectChanged
(
wv_option1
.
getCurrentItem
(),
0
,
0
);
}
}
else
{
if
(!
isRestoreItem
)
{
opt2Select
=
wv_option2
.
getCurrentItem
();
//上一个opt2的选中位置
//新opt2的位置,判断如果旧位置没有超过数据范围,则沿用旧位置,否则选中最后一项
opt2Select
=
opt2Select
>=
mOptions2Items
.
get
(
index
).
size
()
-
1
?
mOptions2Items
.
get
(
index
).
size
()
-
1
:
opt2Select
;
}
wv_option2
.
setAdapter
(
new
ArrayWheelAdapter
(
mOptions2Items
.
get
(
index
)));
wv_option2
.
setCurrentItem
(
opt2Select
);
if
(
mOptions3Items
!=
null
)
{
wheelListener_option2
.
onItemSelected
(
opt2Select
);
}
else
{
//只有2级联动数据,滑动第1项回调
if
(
optionsSelectChangeListener
!=
null
)
{
optionsSelectChangeListener
.
onOptionsSelectChanged
(
index
,
opt2Select
,
0
);
}
}
}
}
};
wheelListener_option2
=
new
OnItemSelectedListener
()
{
@Override
public
void
onItemSelected
(
int
index
)
{
if
(
mOptions3Items
!=
null
)
{
int
opt1Select
=
wv_option1
.
getCurrentItem
();
opt1Select
=
opt1Select
>=
mOptions3Items
.
size
()
-
1
?
mOptions3Items
.
size
()
-
1
:
opt1Select
;
index
=
index
>=
mOptions2Items
.
get
(
opt1Select
).
size
()
-
1
?
mOptions2Items
.
get
(
opt1Select
).
size
()
-
1
:
index
;
int
opt3
=
0
;
if
(!
isRestoreItem
)
{
// wv_option3.getCurrentItem() 上一个opt3的选中位置
//新opt3的位置,判断如果旧位置没有超过数据范围,则沿用旧位置,否则选中最后一项
opt3
=
wv_option3
.
getCurrentItem
()
>=
mOptions3Items
.
get
(
opt1Select
).
get
(
index
).
size
()
-
1
?
mOptions3Items
.
get
(
opt1Select
).
get
(
index
).
size
()
-
1
:
wv_option3
.
getCurrentItem
();
}
wv_option3
.
setAdapter
(
new
ArrayWheelAdapter
(
mOptions3Items
.
get
(
wv_option1
.
getCurrentItem
()).
get
(
index
)));
wv_option3
.
setCurrentItem
(
opt3
);
//3级联动数据实时回调
if
(
optionsSelectChangeListener
!=
null
)
{
optionsSelectChangeListener
.
onOptionsSelectChanged
(
wv_option1
.
getCurrentItem
(),
index
,
opt3
);
}
}
else
{
//只有2级联动数据,滑动第2项回调
if
(
optionsSelectChangeListener
!=
null
)
{
optionsSelectChangeListener
.
onOptionsSelectChanged
(
wv_option1
.
getCurrentItem
(),
index
,
0
);
}
}
}
};
// 添加联动监听
if
(
options1Items
!=
null
&&
linkage
)
{
wv_option1
.
setOnItemSelectedListener
(
wheelListener_option1
);
}
if
(
options2Items
!=
null
&&
linkage
)
{
wv_option2
.
setOnItemSelectedListener
(
wheelListener_option2
);
}
if
(
options3Items
!=
null
&&
linkage
&&
optionsSelectChangeListener
!=
null
)
{
wv_option3
.
setOnItemSelectedListener
(
new
OnItemSelectedListener
()
{
@Override
public
void
onItemSelected
(
int
index
)
{
optionsSelectChangeListener
.
onOptionsSelectChanged
(
wv_option1
.
getCurrentItem
(),
wv_option2
.
getCurrentItem
(),
index
);
}
});
}
}
//不联动情况下
public
void
setNPicker
(
List
<
T
>
options1Items
,
List
<
T
>
options2Items
,
List
<
T
>
options3Items
)
{
// 选项1
wv_option1
.
setAdapter
(
new
ArrayWheelAdapter
<>(
options1Items
));
// 设置显示数据
wv_option1
.
setCurrentItem
(
0
);
// 初始化时显示的数据
// 选项2
if
(
options2Items
!=
null
)
{
wv_option2
.
setAdapter
(
new
ArrayWheelAdapter
<>(
options2Items
));
// 设置显示数据
}
wv_option2
.
setCurrentItem
(
wv_option2
.
getCurrentItem
());
// 初始化时显示的数据
// 选项3
if
(
options3Items
!=
null
)
{
wv_option3
.
setAdapter
(
new
ArrayWheelAdapter
<>(
options3Items
));
// 设置显示数据
}
wv_option3
.
setCurrentItem
(
wv_option3
.
getCurrentItem
());
wv_option1
.
setIsOptions
(
true
);
wv_option2
.
setIsOptions
(
true
);
wv_option3
.
setIsOptions
(
true
);
if
(
optionsSelectChangeListener
!=
null
)
{
wv_option1
.
setOnItemSelectedListener
(
new
OnItemSelectedListener
()
{
@Override
public
void
onItemSelected
(
int
index
)
{
optionsSelectChangeListener
.
onOptionsSelectChanged
(
index
,
wv_option2
.
getCurrentItem
(),
wv_option3
.
getCurrentItem
());
}
});
}
if
(
options2Items
==
null
)
{
wv_option2
.
setVisibility
(
View
.
GONE
);
}
else
{
wv_option2
.
setVisibility
(
View
.
VISIBLE
);
if
(
optionsSelectChangeListener
!=
null
)
{
wv_option2
.
setOnItemSelectedListener
(
new
OnItemSelectedListener
()
{
@Override
public
void
onItemSelected
(
int
index
)
{
optionsSelectChangeListener
.
onOptionsSelectChanged
(
wv_option1
.
getCurrentItem
(),
index
,
wv_option3
.
getCurrentItem
());
}
});
}
}
if
(
options3Items
==
null
)
{
wv_option3
.
setVisibility
(
View
.
GONE
);
}
else
{
wv_option3
.
setVisibility
(
View
.
VISIBLE
);
if
(
optionsSelectChangeListener
!=
null
)
{
wv_option3
.
setOnItemSelectedListener
(
new
OnItemSelectedListener
()
{
@Override
public
void
onItemSelected
(
int
index
)
{
optionsSelectChangeListener
.
onOptionsSelectChanged
(
wv_option1
.
getCurrentItem
(),
wv_option2
.
getCurrentItem
(),
index
);
}
});
}
}
}
public
void
setTextContentSize
(
int
textSize
)
{
wv_option1
.
setTextSize
(
textSize
);
wv_option2
.
setTextSize
(
textSize
);
wv_option3
.
setTextSize
(
textSize
);
}
private
void
setLineSpacingMultiplier
()
{
}
/**
* 设置选项的单位
*
* @param label1 单位
* @param label2 单位
* @param label3 单位
*/
public
void
setLabels
(
String
label1
,
String
label2
,
String
label3
)
{
if
(
label1
!=
null
)
{
wv_option1
.
setLabel
(
label1
);
}
if
(
label2
!=
null
)
{
wv_option2
.
setLabel
(
label2
);
}
if
(
label3
!=
null
)
{
wv_option3
.
setLabel
(
label3
);
}
}
/**
* 设置x轴偏移量
*/
public
void
setTextXOffset
(
int
x_offset_one
,
int
x_offset_two
,
int
x_offset_three
)
{
wv_option1
.
setTextXOffset
(
x_offset_one
);
wv_option2
.
setTextXOffset
(
x_offset_two
);
wv_option3
.
setTextXOffset
(
x_offset_three
);
}
/**
* 设置是否循环滚动
*
* @param cyclic 是否循环
*/
public
void
setCyclic
(
boolean
cyclic
)
{
wv_option1
.
setCyclic
(
cyclic
);
wv_option2
.
setCyclic
(
cyclic
);
wv_option3
.
setCyclic
(
cyclic
);
}
/**
* 设置字体样式
*
* @param font 系统提供的几种样式
*/
public
void
setTypeface
(
Typeface
font
)
{
wv_option1
.
setTypeface
(
font
);
wv_option2
.
setTypeface
(
font
);
wv_option3
.
setTypeface
(
font
);
}
/**
* 分别设置第一二三级是否循环滚动
*
* @param cyclic1,cyclic2,cyclic3 是否循环
*/
public
void
setCyclic
(
boolean
cyclic1
,
boolean
cyclic2
,
boolean
cyclic3
)
{
wv_option1
.
setCyclic
(
cyclic1
);
wv_option2
.
setCyclic
(
cyclic2
);
wv_option3
.
setCyclic
(
cyclic3
);
}
/**
* 返回当前选中的结果对应的位置数组 因为支持三级联动效果,分三个级别索引,0,1,2。
* 在快速滑动未停止时,点击确定按钮,会进行判断,如果匹配数据越界,则设为0,防止index出错导致崩溃。
*
* @return 索引数组
*/
public
int
[]
getCurrentItems
()
{
int
[]
currentItems
=
new
int
[
3
];
currentItems
[
0
]
=
wv_option1
.
getCurrentItem
();
if
(
mOptions2Items
!=
null
&&
mOptions2Items
.
size
()
>
0
)
{
//非空判断
currentItems
[
1
]
=
wv_option2
.
getCurrentItem
()
>
(
mOptions2Items
.
get
(
currentItems
[
0
]).
size
()
-
1
)
?
0
:
wv_option2
.
getCurrentItem
();
}
else
{
currentItems
[
1
]
=
wv_option2
.
getCurrentItem
();
}
if
(
mOptions3Items
!=
null
&&
mOptions3Items
.
size
()
>
0
)
{
//非空判断
currentItems
[
2
]
=
wv_option3
.
getCurrentItem
()
>
(
mOptions3Items
.
get
(
currentItems
[
0
]).
get
(
currentItems
[
1
]).
size
()
-
1
)
?
0
:
wv_option3
.
getCurrentItem
();
}
else
{
currentItems
[
2
]
=
wv_option3
.
getCurrentItem
();
}
return
currentItems
;
}
public
void
setCurrentItems
(
int
option1
,
int
option2
,
int
option3
)
{
if
(
linkage
)
{
itemSelected
(
option1
,
option2
,
option3
);
}
else
{
wv_option1
.
setCurrentItem
(
option1
);
wv_option2
.
setCurrentItem
(
option2
);
wv_option3
.
setCurrentItem
(
option3
);
}
}
private
void
itemSelected
(
int
opt1Select
,
int
opt2Select
,
int
opt3Select
)
{
if
(
mOptions1Items
!=
null
)
{
wv_option1
.
setCurrentItem
(
opt1Select
);
}
if
(
mOptions2Items
!=
null
)
{
wv_option2
.
setAdapter
(
new
ArrayWheelAdapter
(
mOptions2Items
.
get
(
opt1Select
)));
wv_option2
.
setCurrentItem
(
opt2Select
);
}
if
(
mOptions3Items
!=
null
)
{
wv_option3
.
setAdapter
(
new
ArrayWheelAdapter
(
mOptions3Items
.
get
(
opt1Select
).
get
(
opt2Select
)));
wv_option3
.
setCurrentItem
(
opt3Select
);
}
}
/**
* 设置间距倍数,但是只能在1.2-4.0f之间
*
* @param lineSpacingMultiplier
*/
public
void
setLineSpacingMultiplier
(
float
lineSpacingMultiplier
)
{
wv_option1
.
setLineSpacingMultiplier
(
lineSpacingMultiplier
);
wv_option2
.
setLineSpacingMultiplier
(
lineSpacingMultiplier
);
wv_option3
.
setLineSpacingMultiplier
(
lineSpacingMultiplier
);
}
/**
* 设置分割线的颜色
*
* @param dividerColor
*/
public
void
setDividerColor
(
int
dividerColor
)
{
wv_option1
.
setDividerColor
(
dividerColor
);
wv_option2
.
setDividerColor
(
dividerColor
);
wv_option3
.
setDividerColor
(
dividerColor
);
}
/**
* 设置分割线的类型
*
* @param dividerType
*/
public
void
setDividerType
(
WheelView
.
DividerType
dividerType
)
{
wv_option1
.
setDividerType
(
dividerType
);
wv_option2
.
setDividerType
(
dividerType
);
wv_option3
.
setDividerType
(
dividerType
);
}
/**
* 设置分割线之间的文字的颜色
*
* @param textColorCenter
*/
public
void
setTextColorCenter
(
int
textColorCenter
)
{
wv_option1
.
setTextColorCenter
(
textColorCenter
);
wv_option2
.
setTextColorCenter
(
textColorCenter
);
wv_option3
.
setTextColorCenter
(
textColorCenter
);
}
/**
* 设置分割线以外文字的颜色
*
* @param textColorOut
*/
public
void
setTextColorOut
(
int
textColorOut
)
{
wv_option1
.
setTextColorOut
(
textColorOut
);
wv_option2
.
setTextColorOut
(
textColorOut
);
wv_option3
.
setTextColorOut
(
textColorOut
);
}
/**
* Label 是否只显示中间选中项的
*
* @param isCenterLabel
*/
public
void
isCenterLabel
(
boolean
isCenterLabel
)
{
wv_option1
.
isCenterLabel
(
isCenterLabel
);
wv_option2
.
isCenterLabel
(
isCenterLabel
);
wv_option3
.
isCenterLabel
(
isCenterLabel
);
}
public
void
setOptionsSelectChangeListener
(
OnOptionsSelectChangeListener
optionsSelectChangeListener
)
{
this
.
optionsSelectChangeListener
=
optionsSelectChangeListener
;
}
public
void
setLinkage
(
boolean
linkage
)
{
this
.
linkage
=
linkage
;
}
/**
* 设置最大可见数目
*
* @param itemsVisible 建议设置为 3 ~ 9之间。
*/
public
void
setItemsVisible
(
int
itemsVisible
)
{
wv_option1
.
setItemsVisibleCount
(
itemsVisible
);
wv_option2
.
setItemsVisibleCount
(
itemsVisible
);
wv_option3
.
setItemsVisibleCount
(
itemsVisible
);
}
public
void
setAlphaGradient
(
boolean
isAlphaGradient
)
{
wv_option1
.
setAlphaGradient
(
isAlphaGradient
);
wv_option2
.
setAlphaGradient
(
isAlphaGradient
);
wv_option3
.
setAlphaGradient
(
isAlphaGradient
);
}
}
base-module/src/main/java/com/gingersoft/gsa/cloud/ui/view/timeselect/WheelTime.java
0 → 100644
View file @
a7b7159a
package
com
.
gingersoft
.
gsa
.
cloud
.
ui
.
view
.
timeselect
;
import
android.view.View
;
import
com.bigkoo.pickerview.R
;
import
com.bigkoo.pickerview.adapter.ArrayWheelAdapter
;
import
com.bigkoo.pickerview.adapter.NumericWheelAdapter
;
import
com.bigkoo.pickerview.listener.ISelectTimeCallback
;
import
com.bigkoo.pickerview.utils.ChinaDate
;
import
com.bigkoo.pickerview.utils.LunarCalendar
;
import
com.contrarywind.listener.OnItemSelectedListener
;
import
com.contrarywind.view.WheelView
;
import
java.text.DateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.Arrays
;
import
java.util.Calendar
;
import
java.util.List
;
public
class
WheelTime
{
public
static
DateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
private
View
view
;
private
WheelView
wv_year
;
private
WheelView
wv_month
;
private
WheelView
wv_day
;
private
WheelView
wv_hours
;
private
WheelView
wv_minutes
;
private
WheelView
wv_seconds
;
private
int
gravity
;
private
boolean
[]
type
;
private
static
final
int
DEFAULT_START_YEAR
=
1900
;
private
static
final
int
DEFAULT_END_YEAR
=
2100
;
private
static
final
int
DEFAULT_START_MONTH
=
1
;
private
static
final
int
DEFAULT_END_MONTH
=
12
;
private
static
final
int
DEFAULT_START_DAY
=
1
;
private
static
final
int
DEFAULT_END_DAY
=
31
;
private
static
final
int
DEFAULT_START_HOUR
=
0
;
private
static
final
int
DEFAULT_END_HOUR
=
23
;
private
static
final
int
DEFAULT_START_MIN
=
0
;
private
static
final
int
DEFAULT_END_MIN
=
59
;
private
static
final
int
DEFAULT_START_SECOND
=
0
;
private
static
final
int
DEFAULT_END_SECOND
=
59
;
private
int
startYear
=
DEFAULT_START_YEAR
;
private
int
endYear
=
DEFAULT_END_YEAR
;
private
int
startMonth
=
DEFAULT_START_MONTH
;
private
int
endMonth
=
DEFAULT_END_MONTH
;
private
int
startDay
=
DEFAULT_START_DAY
;
private
int
endDay
=
DEFAULT_END_DAY
;
//表示31天的
private
int
startHour
=
DEFAULT_START_HOUR
;
private
int
endHour
=
DEFAULT_END_HOUR
;
private
int
startMin
=
DEFAULT_START_MIN
;
private
int
endMin
=
DEFAULT_END_MIN
;
private
int
startSecond
=
DEFAULT_START_SECOND
;
private
int
endSecond
=
DEFAULT_END_SECOND
;
private
int
currentYear
;
private
int
textSize
;
private
boolean
isLunarCalendar
=
false
;
private
ISelectTimeCallback
mSelectChangeCallback
;
public
WheelTime
(
View
view
,
boolean
[]
type
,
int
gravity
,
int
textSize
)
{
super
();
this
.
view
=
view
;
this
.
type
=
type
;
this
.
gravity
=
gravity
;
this
.
textSize
=
textSize
;
}
public
void
setLunarMode
(
boolean
isLunarCalendar
)
{
this
.
isLunarCalendar
=
isLunarCalendar
;
}
public
boolean
isLunarMode
()
{
return
isLunarCalendar
;
}
public
void
setPicker
(
int
year
,
int
month
,
int
day
)
{
this
.
setPicker
(
year
,
month
,
day
,
0
,
0
,
0
);
}
public
void
setPicker
(
int
year
,
final
int
month
,
int
day
,
int
h
,
int
m
,
int
s
)
{
if
(
isLunarCalendar
)
{
int
[]
lunar
=
LunarCalendar
.
solarToLunar
(
year
,
month
+
1
,
day
);
setLunar
(
lunar
[
0
],
lunar
[
1
]
-
1
,
lunar
[
2
],
lunar
[
3
]
==
1
,
h
,
m
,
s
);
}
else
{
setSolar
(
year
,
month
,
day
,
h
,
m
,
s
);
}
}
/**
* 设置农历
*
* @param year
* @param month
* @param day
* @param h
* @param m
* @param s
*/
private
void
setLunar
(
int
year
,
final
int
month
,
int
day
,
boolean
isLeap
,
int
h
,
int
m
,
int
s
)
{
// 年
wv_year
=
(
WheelView
)
view
.
findViewById
(
R
.
id
.
year
);
wv_year
.
setAdapter
(
new
ArrayWheelAdapter
(
ChinaDate
.
getYears
(
startYear
,
endYear
)));
// 设置"年"的显示数据
wv_year
.
setLabel
(
""
);
// 添加文字
wv_year
.
setCurrentItem
(
year
-
startYear
);
// 初始化时显示的数据
wv_year
.
setGravity
(
gravity
);
// 月
wv_month
=
(
WheelView
)
view
.
findViewById
(
R
.
id
.
month
);
wv_month
.
setAdapter
(
new
ArrayWheelAdapter
(
ChinaDate
.
getMonths
(
year
)));
wv_month
.
setLabel
(
""
);
int
leapMonth
=
ChinaDate
.
leapMonth
(
year
);
if
(
leapMonth
!=
0
&&
(
month
>
leapMonth
-
1
||
isLeap
))
{
//选中月是闰月或大于闰月
wv_month
.
setCurrentItem
(
month
+
1
);
}
else
{
wv_month
.
setCurrentItem
(
month
);
}
wv_month
.
setGravity
(
gravity
);
// 日
wv_day
=
(
WheelView
)
view
.
findViewById
(
R
.
id
.
day
);
// 判断大小月及是否闰年,用来确定"日"的数据
if
(
ChinaDate
.
leapMonth
(
year
)
==
0
)
{
wv_day
.
setAdapter
(
new
ArrayWheelAdapter
(
ChinaDate
.
getLunarDays
(
ChinaDate
.
monthDays
(
year
,
month
))));
}
else
{
wv_day
.
setAdapter
(
new
ArrayWheelAdapter
(
ChinaDate
.
getLunarDays
(
ChinaDate
.
leapDays
(
year
))));
}
wv_day
.
setLabel
(
""
);
wv_day
.
setCurrentItem
(
day
-
1
);
wv_day
.
setGravity
(
gravity
);
wv_hours
=
(
WheelView
)
view
.
findViewById
(
R
.
id
.
hour
);
wv_hours
.
setAdapter
(
new
NumericWheelAdapter
(
0
,
23
));
//wv_hours.setLabel(context.getString(R.string.pickerview_hours));// 添加文字
wv_hours
.
setCurrentItem
(
h
);
wv_hours
.
setGravity
(
gravity
);
wv_minutes
=
(
WheelView
)
view
.
findViewById
(
R
.
id
.
min
);
wv_minutes
.
setAdapter
(
new
NumericWheelAdapter
(
0
,
59
));
//wv_minutes.setLabel(context.getString(R.string.pickerview_minutes));// 添加文字
wv_minutes
.
setCurrentItem
(
m
);
wv_minutes
.
setGravity
(
gravity
);
wv_seconds
=
(
WheelView
)
view
.
findViewById
(
R
.
id
.
second
);
wv_seconds
.
setAdapter
(
new
NumericWheelAdapter
(
0
,
59
));
//wv_seconds.setLabel(context.getString(R.string.pickerview_minutes));// 添加文字
wv_seconds
.
setCurrentItem
(
m
);
wv_seconds
.
setGravity
(
gravity
);
// 添加"年"监听
wv_year
.
setOnItemSelectedListener
(
new
OnItemSelectedListener
()
{
@Override
public
void
onItemSelected
(
int
index
)
{
int
year_num
=
index
+
startYear
;
// 判断是不是闰年,来确定月和日的选择
wv_month
.
setAdapter
(
new
ArrayWheelAdapter
(
ChinaDate
.
getMonths
(
year_num
)));
if
(
ChinaDate
.
leapMonth
(
year_num
)
!=
0
&&
wv_month
.
getCurrentItem
()
>
ChinaDate
.
leapMonth
(
year_num
)
-
1
)
{
wv_month
.
setCurrentItem
(
wv_month
.
getCurrentItem
()
+
1
);
}
else
{
wv_month
.
setCurrentItem
(
wv_month
.
getCurrentItem
());
}
int
currentIndex
=
wv_day
.
getCurrentItem
();
int
maxItem
=
29
;
if
(
ChinaDate
.
leapMonth
(
year_num
)
!=
0
&&
wv_month
.
getCurrentItem
()
>
ChinaDate
.
leapMonth
(
year_num
)
-
1
)
{
if
(
wv_month
.
getCurrentItem
()
==
ChinaDate
.
leapMonth
(
year_num
)
+
1
)
{
wv_day
.
setAdapter
(
new
ArrayWheelAdapter
(
ChinaDate
.
getLunarDays
(
ChinaDate
.
leapDays
(
year_num
))));
maxItem
=
ChinaDate
.
leapDays
(
year_num
);
}
else
{
wv_day
.
setAdapter
(
new
ArrayWheelAdapter
(
ChinaDate
.
getLunarDays
(
ChinaDate
.
monthDays
(
year_num
,
wv_month
.
getCurrentItem
()))));
maxItem
=
ChinaDate
.
monthDays
(
year_num
,
wv_month
.
getCurrentItem
());
}
}
else
{
wv_day
.
setAdapter
(
new
ArrayWheelAdapter
(
ChinaDate
.
getLunarDays
(
ChinaDate
.
monthDays
(
year_num
,
wv_month
.
getCurrentItem
()
+
1
))));
maxItem
=
ChinaDate
.
monthDays
(
year_num
,
wv_month
.
getCurrentItem
()
+
1
);
}
if
(
currentIndex
>
maxItem
-
1
)
{
wv_day
.
setCurrentItem
(
maxItem
-
1
);
}
if
(
mSelectChangeCallback
!=
null
)
{
mSelectChangeCallback
.
onTimeSelectChanged
();
}
}
});
// 添加"月"监听
wv_month
.
setOnItemSelectedListener
(
new
OnItemSelectedListener
()
{
@Override
public
void
onItemSelected
(
int
index
)
{
int
month_num
=
index
;
int
year_num
=
wv_year
.
getCurrentItem
()
+
startYear
;
int
currentIndex
=
wv_day
.
getCurrentItem
();
int
maxItem
=
29
;
if
(
ChinaDate
.
leapMonth
(
year_num
)
!=
0
&&
month_num
>
ChinaDate
.
leapMonth
(
year_num
)
-
1
)
{
if
(
wv_month
.
getCurrentItem
()
==
ChinaDate
.
leapMonth
(
year_num
)
+
1
)
{
wv_day
.
setAdapter
(
new
ArrayWheelAdapter
(
ChinaDate
.
getLunarDays
(
ChinaDate
.
leapDays
(
year_num
))));
maxItem
=
ChinaDate
.
leapDays
(
year_num
);
}
else
{
wv_day
.
setAdapter
(
new
ArrayWheelAdapter
(
ChinaDate
.
getLunarDays
(
ChinaDate
.
monthDays
(
year_num
,
month_num
))));
maxItem
=
ChinaDate
.
monthDays
(
year_num
,
month_num
);
}
}
else
{
wv_day
.
setAdapter
(
new
ArrayWheelAdapter
(
ChinaDate
.
getLunarDays
(
ChinaDate
.
monthDays
(
year_num
,
month_num
+
1
))));
maxItem
=
ChinaDate
.
monthDays
(
year_num
,
month_num
+
1
);
}
if
(
currentIndex
>
maxItem
-
1
)
{
wv_day
.
setCurrentItem
(
maxItem
-
1
);
}
if
(
mSelectChangeCallback
!=
null
)
{
mSelectChangeCallback
.
onTimeSelectChanged
();
}
}
});
setChangedListener
(
wv_day
);
setChangedListener
(
wv_hours
);
setChangedListener
(
wv_minutes
);
setChangedListener
(
wv_seconds
);
if
(
type
.
length
!=
6
)
{
throw
new
RuntimeException
(
"type[] length is not 6"
);
}
wv_year
.
setVisibility
(
type
[
0
]
?
View
.
VISIBLE
:
View
.
GONE
);
wv_month
.
setVisibility
(
type
[
1
]
?
View
.
VISIBLE
:
View
.
GONE
);
wv_day
.
setVisibility
(
type
[
2
]
?
View
.
VISIBLE
:
View
.
GONE
);
wv_hours
.
setVisibility
(
type
[
3
]
?
View
.
VISIBLE
:
View
.
GONE
);
wv_minutes
.
setVisibility
(
type
[
4
]
?
View
.
VISIBLE
:
View
.
GONE
);
wv_seconds
.
setVisibility
(
type
[
5
]
?
View
.
VISIBLE
:
View
.
GONE
);
setContentTextSize
();
}
/**
* 设置公历
*
* @param year
* @param month
* @param day
* @param h
* @param m
* @param s
*/
private
void
setSolar
(
int
year
,
final
int
month
,
int
day
,
int
h
,
int
m
,
int
s
)
{
// 添加大小月月份并将其转换为list,方便之后的判断
String
[]
months_big
=
{
"1"
,
"3"
,
"5"
,
"7"
,
"8"
,
"10"
,
"12"
};
String
[]
months_little
=
{
"4"
,
"6"
,
"9"
,
"11"
};
final
List
<
String
>
list_big
=
Arrays
.
asList
(
months_big
);
final
List
<
String
>
list_little
=
Arrays
.
asList
(
months_little
);
currentYear
=
year
;
// 年
wv_year
=
(
WheelView
)
view
.
findViewById
(
R
.
id
.
year
);
wv_year
.
setAdapter
(
new
NumericWheelAdapter
(
startYear
,
endYear
));
// 设置"年"的显示数据
wv_year
.
setCurrentItem
(
year
-
startYear
);
// 初始化时显示的数据
wv_year
.
setGravity
(
gravity
);
// 月
wv_month
=
(
WheelView
)
view
.
findViewById
(
R
.
id
.
month
);
if
(
startYear
==
endYear
)
{
//开始年等于终止年
wv_month
.
setAdapter
(
new
NumericWheelAdapter
(
startMonth
,
endMonth
));
wv_month
.
setCurrentItem
(
month
+
1
-
startMonth
);
}
else
if
(
year
==
startYear
)
{
//起始日期的月份控制
wv_month
.
setAdapter
(
new
NumericWheelAdapter
(
startMonth
,
12
));
wv_month
.
setCurrentItem
(
month
+
1
-
startMonth
);
}
else
if
(
year
==
endYear
)
{
//终止日期的月份控制
wv_month
.
setAdapter
(
new
NumericWheelAdapter
(
1
,
endMonth
));
wv_month
.
setCurrentItem
(
month
);
}
else
{
wv_month
.
setAdapter
(
new
NumericWheelAdapter
(
1
,
12
));
wv_month
.
setCurrentItem
(
month
);
}
wv_month
.
setGravity
(
gravity
);
// 日
wv_day
=
(
WheelView
)
view
.
findViewById
(
R
.
id
.
day
);
boolean
leapYear
=
(
year
%
4
==
0
&&
year
%
100
!=
0
)
||
year
%
400
==
0
;
if
(
startYear
==
endYear
&&
startMonth
==
endMonth
)
{
if
(
list_big
.
contains
(
String
.
valueOf
(
month
+
1
)))
{
if
(
endDay
>
31
)
{
endDay
=
31
;
}
wv_day
.
setAdapter
(
new
NumericWheelAdapter
(
startDay
,
endDay
));
}
else
if
(
list_little
.
contains
(
String
.
valueOf
(
month
+
1
)))
{
if
(
endDay
>
30
)
{
endDay
=
30
;
}
wv_day
.
setAdapter
(
new
NumericWheelAdapter
(
startDay
,
endDay
));
}
else
{
// 闰年
if
(
leapYear
)
{
if
(
endDay
>
29
)
{
endDay
=
29
;
}
wv_day
.
setAdapter
(
new
NumericWheelAdapter
(
startDay
,
endDay
));
}
else
{
if
(
endDay
>
28
)
{
endDay
=
28
;
}
wv_day
.
setAdapter
(
new
NumericWheelAdapter
(
startDay
,
endDay
));
}
}
wv_day
.
setCurrentItem
(
day
-
startDay
);
}
else
if
(
year
==
startYear
&&
month
+
1
==
startMonth
)
{
// 起始日期的天数控制
if
(
list_big
.
contains
(
String
.
valueOf
(
month
+
1
)))
{
wv_day
.
setAdapter
(
new
NumericWheelAdapter
(
startDay
,
31
));
}
else
if
(
list_little
.
contains
(
String
.
valueOf
(
month
+
1
)))
{
wv_day
.
setAdapter
(
new
NumericWheelAdapter
(
startDay
,
30
));
}
else
{
// 闰年 29,平年 28
wv_day
.
setAdapter
(
new
NumericWheelAdapter
(
startDay
,
leapYear
?
29
:
28
));
}
wv_day
.
setCurrentItem
(
day
-
startDay
);
}
else
if
(
year
==
endYear
&&
month
+
1
==
endMonth
)
{
// 终止日期的天数控制
if
(
list_big
.
contains
(
String
.
valueOf
(
month
+
1
)))
{
if
(
endDay
>
31
)
{
endDay
=
31
;
}
wv_day
.
setAdapter
(
new
NumericWheelAdapter
(
1
,
endDay
));
}
else
if
(
list_little
.
contains
(
String
.
valueOf
(
month
+
1
)))
{
if
(
endDay
>
30
)
{
endDay
=
30
;
}
wv_day
.
setAdapter
(
new
NumericWheelAdapter
(
1
,
endDay
));
}
else
{
// 闰年
if
(
leapYear
)
{
if
(
endDay
>
29
)
{
endDay
=
29
;
}
wv_day
.
setAdapter
(
new
NumericWheelAdapter
(
1
,
endDay
));
}
else
{
if
(
endDay
>
28
)
{
endDay
=
28
;
}
wv_day
.
setAdapter
(
new
NumericWheelAdapter
(
1
,
endDay
));
}
}
wv_day
.
setCurrentItem
(
day
-
1
);
}
else
{
// 判断大小月及是否闰年,用来确定"日"的数据
if
(
list_big
.
contains
(
String
.
valueOf
(
month
+
1
)))
{
wv_day
.
setAdapter
(
new
NumericWheelAdapter
(
1
,
31
));
}
else
if
(
list_little
.
contains
(
String
.
valueOf
(
month
+
1
)))
{
wv_day
.
setAdapter
(
new
NumericWheelAdapter
(
1
,
30
));
}
else
{
// 闰年 29,平年 28
wv_day
.
setAdapter
(
new
NumericWheelAdapter
(
startDay
,
leapYear
?
29
:
28
));
}
wv_day
.
setCurrentItem
(
day
-
1
);
}
wv_day
.
setGravity
(
gravity
);
//时
wv_hours
=
view
.
findViewById
(
R
.
id
.
hour
);
//分
wv_minutes
=
view
.
findViewById
(
R
.
id
.
min
);
if
(
startYear
==
endYear
&&
startMonth
==
endMonth
&&
startDay
==
endDay
)
{
wv_hours
.
setAdapter
(
new
NumericWheelAdapter
(
startHour
,
endHour
));
if
(
startHour
==
endHour
||
h
==
endHour
)
{
wv_minutes
.
setAdapter
(
new
NumericWheelAdapter
(
startMin
,
endMin
));
}
else
{
wv_minutes
.
setAdapter
(
new
NumericWheelAdapter
(
0
,
59
));
}
}
else
{
wv_hours
.
setAdapter
(
new
NumericWheelAdapter
(
0
,
23
));
wv_minutes
.
setAdapter
(
new
NumericWheelAdapter
(
0
,
59
));
}
wv_hours
.
setCurrentItem
(
h
);
wv_hours
.
setGravity
(
gravity
);
wv_minutes
.
setCurrentItem
(
m
);
wv_minutes
.
setGravity
(
gravity
);
//秒
wv_seconds
=
(
WheelView
)
view
.
findViewById
(
R
.
id
.
second
);
wv_seconds
.
setAdapter
(
new
NumericWheelAdapter
(
0
,
59
));
wv_seconds
.
setCurrentItem
(
s
);
wv_seconds
.
setGravity
(
gravity
);
// 添加"年"监听
wv_year
.
setOnItemSelectedListener
(
new
OnItemSelectedListener
()
{
@Override
public
void
onItemSelected
(
int
index
)
{
int
year_num
=
index
+
startYear
;
currentYear
=
year_num
;
int
currentMonthItem
=
wv_month
.
getCurrentItem
();
//记录上一次的item位置
// 判断大小月及是否闰年,用来确定"日"的数据
if
(
startYear
==
endYear
)
{
//重新设置月份
wv_month
.
setAdapter
(
new
NumericWheelAdapter
(
startMonth
,
endMonth
));
if
(
currentMonthItem
>
wv_month
.
getAdapter
().
getItemsCount
()
-
1
)
{
currentMonthItem
=
wv_month
.
getAdapter
().
getItemsCount
()
-
1
;
wv_month
.
setCurrentItem
(
currentMonthItem
);
}
int
monthNum
=
currentMonthItem
+
startMonth
;
if
(
startMonth
==
endMonth
)
{
//重新设置日
setReDay
(
year_num
,
monthNum
,
startDay
,
endDay
,
list_big
,
list_little
);
}
else
if
(
monthNum
==
startMonth
)
{
//重新设置日
setReDay
(
year_num
,
monthNum
,
startDay
,
31
,
list_big
,
list_little
);
}
else
if
(
monthNum
==
endMonth
)
{
setReDay
(
year_num
,
monthNum
,
1
,
endDay
,
list_big
,
list_little
);
}
else
{
//重新设置日
setReDay
(
year_num
,
monthNum
,
1
,
31
,
list_big
,
list_little
);
}
}
else
if
(
year_num
==
startYear
)
{
//等于开始的年
//重新设置月份
wv_month
.
setAdapter
(
new
NumericWheelAdapter
(
startMonth
,
12
));
if
(
currentMonthItem
>
wv_month
.
getAdapter
().
getItemsCount
()
-
1
)
{
currentMonthItem
=
wv_month
.
getAdapter
().
getItemsCount
()
-
1
;
wv_month
.
setCurrentItem
(
currentMonthItem
);
}
int
month
=
currentMonthItem
+
startMonth
;
if
(
month
==
startMonth
)
{
//重新设置日
setReDay
(
year_num
,
month
,
startDay
,
31
,
list_big
,
list_little
);
}
else
{
//重新设置日
setReDay
(
year_num
,
month
,
1
,
31
,
list_big
,
list_little
);
}
}
else
if
(
year_num
==
endYear
)
{
//重新设置月份
wv_month
.
setAdapter
(
new
NumericWheelAdapter
(
1
,
endMonth
));
if
(
currentMonthItem
>
wv_month
.
getAdapter
().
getItemsCount
()
-
1
)
{
currentMonthItem
=
wv_month
.
getAdapter
().
getItemsCount
()
-
1
;
wv_month
.
setCurrentItem
(
currentMonthItem
);
}
int
monthNum
=
currentMonthItem
+
1
;
if
(
monthNum
==
endMonth
)
{
//重新设置日
setReDay
(
year_num
,
monthNum
,
1
,
endDay
,
list_big
,
list_little
);
}
else
{
//重新设置日
setReDay
(
year_num
,
monthNum
,
1
,
31
,
list_big
,
list_little
);
}
}
else
{
//重新设置月份
wv_month
.
setAdapter
(
new
NumericWheelAdapter
(
1
,
12
));
//重新设置日
setReDay
(
year_num
,
wv_month
.
getCurrentItem
()
+
1
,
1
,
31
,
list_big
,
list_little
);
}
if
(
mSelectChangeCallback
!=
null
)
{
mSelectChangeCallback
.
onTimeSelectChanged
();
}
}
});
// 添加"月"监听
wv_month
.
setOnItemSelectedListener
(
new
OnItemSelectedListener
()
{
@Override
public
void
onItemSelected
(
int
index
)
{
int
month_num
=
index
+
1
;
if
(
startYear
==
endYear
)
{
month_num
=
month_num
+
startMonth
-
1
;
if
(
startMonth
==
endMonth
)
{
//重新设置日
setReDay
(
currentYear
,
month_num
,
startDay
,
endDay
,
list_big
,
list_little
);
}
else
if
(
startMonth
==
month_num
)
{
//重新设置日
setReDay
(
currentYear
,
month_num
,
startDay
,
31
,
list_big
,
list_little
);
}
else
if
(
endMonth
==
month_num
)
{
setReDay
(
currentYear
,
month_num
,
1
,
endDay
,
list_big
,
list_little
);
}
else
{
setReDay
(
currentYear
,
month_num
,
1
,
31
,
list_big
,
list_little
);
}
}
else
if
(
currentYear
==
startYear
)
{
month_num
=
month_num
+
startMonth
-
1
;
if
(
month_num
==
startMonth
)
{
//重新设置日
setReDay
(
currentYear
,
month_num
,
startDay
,
31
,
list_big
,
list_little
);
}
else
{
//重新设置日
setReDay
(
currentYear
,
month_num
,
1
,
31
,
list_big
,
list_little
);
}
}
else
if
(
currentYear
==
endYear
)
{
if
(
month_num
==
endMonth
)
{
//重新设置日
setReDay
(
currentYear
,
wv_month
.
getCurrentItem
()
+
1
,
1
,
endDay
,
list_big
,
list_little
);
}
else
{
setReDay
(
currentYear
,
wv_month
.
getCurrentItem
()
+
1
,
1
,
31
,
list_big
,
list_little
);
}
}
else
{
//重新设置日
setReDay
(
currentYear
,
month_num
,
1
,
31
,
list_big
,
list_little
);
}
if
(
mSelectChangeCallback
!=
null
)
{
mSelectChangeCallback
.
onTimeSelectChanged
();
}
}
});
wv_hours
.
setOnItemSelectedListener
(
index
->
{
if
(
startYear
==
endYear
&&
startMonth
==
endMonth
&&
startDay
==
endDay
)
{
int
currentMin
=
wv_minutes
.
getCurrentItem
();
if
(
startHour
==
endHour
||
index
+
startHour
==
endHour
)
{
wv_minutes
.
setAdapter
(
new
NumericWheelAdapter
(
startMin
,
endMin
));
}
else
if
(
h
+
index
==
startHour
)
{
wv_minutes
.
setAdapter
(
new
NumericWheelAdapter
(
startMin
,
endMin
));
}
else
if
(
index
==
endHour
)
{
wv_minutes
.
setAdapter
(
new
NumericWheelAdapter
(
startMin
,
endMin
));
}
else
{
wv_minutes
.
setAdapter
(
new
NumericWheelAdapter
(
0
,
59
));
}
if
(
currentMin
>
wv_minutes
.
getAdapter
().
getItemsCount
()
-
1
)
{
currentMin
=
0
;
wv_minutes
.
setCurrentItem
(
currentMin
);
}
}
if
(
mSelectChangeCallback
!=
null
)
{
mSelectChangeCallback
.
onTimeSelectChanged
();
}
});
setChangedListener
(
wv_day
);
setChangedListener
(
wv_minutes
);
setChangedListener
(
wv_seconds
);
if
(
type
.
length
!=
6
)
{
throw
new
IllegalArgumentException
(
"type[] length is not 6"
);
}
wv_year
.
setVisibility
(
type
[
0
]
?
View
.
VISIBLE
:
View
.
GONE
);
wv_month
.
setVisibility
(
type
[
1
]
?
View
.
VISIBLE
:
View
.
GONE
);
wv_day
.
setVisibility
(
type
[
2
]
?
View
.
VISIBLE
:
View
.
GONE
);
wv_hours
.
setVisibility
(
type
[
3
]
?
View
.
VISIBLE
:
View
.
GONE
);
wv_minutes
.
setVisibility
(
type
[
4
]
?
View
.
VISIBLE
:
View
.
GONE
);
wv_seconds
.
setVisibility
(
type
[
5
]
?
View
.
VISIBLE
:
View
.
GONE
);
setContentTextSize
();
}
private
void
setChangedListener
(
WheelView
wheelView
)
{
if
(
mSelectChangeCallback
!=
null
)
{
wheelView
.
setOnItemSelectedListener
(
new
OnItemSelectedListener
()
{
@Override
public
void
onItemSelected
(
int
index
)
{
mSelectChangeCallback
.
onTimeSelectChanged
();
}
});
}
}
private
void
setReDay
(
int
year_num
,
int
monthNum
,
int
startD
,
int
endD
,
List
<
String
>
list_big
,
List
<
String
>
list_little
)
{
int
currentItem
=
wv_day
.
getCurrentItem
();
// int maxItem;
if
(
list_big
.
contains
(
String
.
valueOf
(
monthNum
)))
{
if
(
endD
>
31
)
{
endD
=
31
;
}
wv_day
.
setAdapter
(
new
NumericWheelAdapter
(
startD
,
endD
));
// maxItem = endD;
}
else
if
(
list_little
.
contains
(
String
.
valueOf
(
monthNum
)))
{
if
(
endD
>
30
)
{
endD
=
30
;
}
wv_day
.
setAdapter
(
new
NumericWheelAdapter
(
startD
,
endD
));
// maxItem = endD;
}
else
{
if
((
year_num
%
4
==
0
&&
year_num
%
100
!=
0
)
||
year_num
%
400
==
0
)
{
if
(
endD
>
29
)
{
endD
=
29
;
}
wv_day
.
setAdapter
(
new
NumericWheelAdapter
(
startD
,
endD
));
// maxItem = endD;
}
else
{
if
(
endD
>
28
)
{
endD
=
28
;
}
wv_day
.
setAdapter
(
new
NumericWheelAdapter
(
startD
,
endD
));
// maxItem = endD;
}
}
if
(
currentItem
>
wv_day
.
getAdapter
().
getItemsCount
()
-
1
)
{
currentItem
=
wv_day
.
getAdapter
().
getItemsCount
()
-
1
;
wv_day
.
setCurrentItem
(
currentItem
);
}
}
private
void
setContentTextSize
()
{
wv_day
.
setTextSize
(
textSize
);
wv_month
.
setTextSize
(
textSize
);
wv_year
.
setTextSize
(
textSize
);
wv_hours
.
setTextSize
(
textSize
);
wv_minutes
.
setTextSize
(
textSize
);
wv_seconds
.
setTextSize
(
textSize
);
}
public
void
setLabels
(
String
label_year
,
String
label_month
,
String
label_day
,
String
label_hours
,
String
label_mins
,
String
label_seconds
)
{
if
(
isLunarCalendar
)
{
return
;
}
if
(
label_year
!=
null
)
{
wv_year
.
setLabel
(
label_year
);
}
else
{
wv_year
.
setLabel
(
view
.
getContext
().
getString
(
R
.
string
.
pickerview_year
));
}
if
(
label_month
!=
null
)
{
wv_month
.
setLabel
(
label_month
);
}
else
{
wv_month
.
setLabel
(
view
.
getContext
().
getString
(
R
.
string
.
pickerview_month
));
}
if
(
label_day
!=
null
)
{
wv_day
.
setLabel
(
label_day
);
}
else
{
wv_day
.
setLabel
(
view
.
getContext
().
getString
(
R
.
string
.
pickerview_day
));
}
if
(
label_hours
!=
null
)
{
wv_hours
.
setLabel
(
label_hours
);
}
else
{
wv_hours
.
setLabel
(
view
.
getContext
().
getString
(
R
.
string
.
pickerview_hours
));
}
if
(
label_mins
!=
null
)
{
wv_minutes
.
setLabel
(
label_mins
);
}
else
{
wv_minutes
.
setLabel
(
view
.
getContext
().
getString
(
R
.
string
.
pickerview_minutes
));
}
if
(
label_seconds
!=
null
)
{
wv_seconds
.
setLabel
(
label_seconds
);
}
else
{
wv_seconds
.
setLabel
(
view
.
getContext
().
getString
(
R
.
string
.
pickerview_seconds
));
}
}
public
void
setTextXOffset
(
int
x_offset_year
,
int
x_offset_month
,
int
x_offset_day
,
int
x_offset_hours
,
int
x_offset_minutes
,
int
x_offset_seconds
)
{
wv_year
.
setTextXOffset
(
x_offset_year
);
wv_month
.
setTextXOffset
(
x_offset_month
);
wv_day
.
setTextXOffset
(
x_offset_day
);
wv_hours
.
setTextXOffset
(
x_offset_hours
);
wv_minutes
.
setTextXOffset
(
x_offset_minutes
);
wv_seconds
.
setTextXOffset
(
x_offset_seconds
);
}
/**
* 设置是否循环滚动
*
* @param cyclic
*/
public
void
setCyclic
(
boolean
cyclic
)
{
wv_year
.
setCyclic
(
cyclic
);
wv_month
.
setCyclic
(
cyclic
);
wv_day
.
setCyclic
(
cyclic
);
wv_hours
.
setCyclic
(
cyclic
);
wv_minutes
.
setCyclic
(
cyclic
);
wv_seconds
.
setCyclic
(
cyclic
);
}
public
String
getTime
()
{
if
(
isLunarCalendar
)
{
//如果是农历 返回对应的公历时间
return
getLunarTime
();
}
StringBuilder
sb
=
new
StringBuilder
();
if
(
currentYear
==
startYear
)
{
/* int i = wv_month.getCurrentItem() + startMonth;
System.out.println("i:" + i);*/
if
((
wv_month
.
getCurrentItem
()
+
startMonth
)
==
startMonth
)
{
sb
.
append
((
wv_year
.
getCurrentItem
()
+
startYear
)).
append
(
"-"
)
.
append
((
wv_month
.
getCurrentItem
()
+
startMonth
)).
append
(
"-"
)
.
append
((
wv_day
.
getCurrentItem
()
+
startDay
)).
append
(
" "
)
.
append
(
wv_hours
.
getCurrentItem
()).
append
(
":"
)
.
append
(
wv_minutes
.
getCurrentItem
()).
append
(
":"
)
.
append
(
wv_seconds
.
getCurrentItem
());
}
else
{
sb
.
append
((
wv_year
.
getCurrentItem
()
+
startYear
)).
append
(
"-"
)
.
append
((
wv_month
.
getCurrentItem
()
+
startMonth
)).
append
(
"-"
)
.
append
((
wv_day
.
getCurrentItem
()
+
1
)).
append
(
" "
)
.
append
(
wv_hours
.
getCurrentItem
()).
append
(
":"
)
.
append
(
wv_minutes
.
getCurrentItem
()).
append
(
":"
)
.
append
(
wv_seconds
.
getCurrentItem
());
}
}
else
{
sb
.
append
((
wv_year
.
getCurrentItem
()
+
startYear
)).
append
(
"-"
)
.
append
((
wv_month
.
getCurrentItem
()
+
1
)).
append
(
"-"
)
.
append
((
wv_day
.
getCurrentItem
()
+
1
)).
append
(
" "
)
.
append
(
wv_hours
.
getCurrentItem
()).
append
(
":"
)
.
append
(
wv_minutes
.
getCurrentItem
()).
append
(
":"
)
.
append
(
wv_seconds
.
getCurrentItem
());
}
return
sb
.
toString
();
}
/**
* 农历返回对应的公历时间
*
* @return
*/
private
String
getLunarTime
()
{
StringBuilder
sb
=
new
StringBuilder
();
int
year
=
wv_year
.
getCurrentItem
()
+
startYear
;
int
month
=
1
;
boolean
isLeapMonth
=
false
;
if
(
ChinaDate
.
leapMonth
(
year
)
==
0
)
{
month
=
wv_month
.
getCurrentItem
()
+
1
;
}
else
{
if
((
wv_month
.
getCurrentItem
()
+
1
)
-
ChinaDate
.
leapMonth
(
year
)
<=
0
)
{
month
=
wv_month
.
getCurrentItem
()
+
1
;
}
else
if
((
wv_month
.
getCurrentItem
()
+
1
)
-
ChinaDate
.
leapMonth
(
year
)
==
1
)
{
month
=
wv_month
.
getCurrentItem
();
isLeapMonth
=
true
;
}
else
{
month
=
wv_month
.
getCurrentItem
();
}
}
int
day
=
wv_day
.
getCurrentItem
()
+
1
;
int
[]
solar
=
LunarCalendar
.
lunarToSolar
(
year
,
month
,
day
,
isLeapMonth
);
sb
.
append
(
solar
[
0
]).
append
(
"-"
)
.
append
(
solar
[
1
]).
append
(
"-"
)
.
append
(
solar
[
2
]).
append
(
" "
)
.
append
(
wv_hours
.
getCurrentItem
()).
append
(
":"
)
.
append
(
wv_minutes
.
getCurrentItem
()).
append
(
":"
)
.
append
(
wv_seconds
.
getCurrentItem
());
return
sb
.
toString
();
}
public
View
getView
()
{
return
view
;
}
public
int
getStartYear
()
{
return
startYear
;
}
public
void
setStartYear
(
int
startYear
)
{
this
.
startYear
=
startYear
;
}
public
int
getEndYear
()
{
return
endYear
;
}
public
void
setEndYear
(
int
endYear
)
{
this
.
endYear
=
endYear
;
}
public
void
setRangDate
(
Calendar
startDate
,
Calendar
endDate
)
{
if
(
startDate
==
null
&&
endDate
!=
null
)
{
int
year
=
endDate
.
get
(
Calendar
.
YEAR
);
int
month
=
endDate
.
get
(
Calendar
.
MONTH
)
+
1
;
int
day
=
endDate
.
get
(
Calendar
.
DAY_OF_MONTH
);
endHour
=
endDate
.
get
(
Calendar
.
HOUR_OF_DAY
);
endMin
=
endDate
.
get
(
Calendar
.
MINUTE
);
endSecond
=
endDate
.
get
(
Calendar
.
SECOND
);
if
(
year
>
startYear
)
{
this
.
endYear
=
year
;
this
.
endMonth
=
month
;
this
.
endDay
=
day
;
}
else
if
(
year
==
startYear
)
{
if
(
month
>
startMonth
)
{
this
.
endYear
=
year
;
this
.
endMonth
=
month
;
this
.
endDay
=
day
;
}
else
if
(
month
==
startMonth
)
{
if
(
day
>
startDay
)
{
this
.
endYear
=
year
;
this
.
endMonth
=
month
;
this
.
endDay
=
day
;
}
}
}
}
else
if
(
startDate
!=
null
&&
endDate
==
null
)
{
int
year
=
startDate
.
get
(
Calendar
.
YEAR
);
int
month
=
startDate
.
get
(
Calendar
.
MONTH
)
+
1
;
int
day
=
startDate
.
get
(
Calendar
.
DAY_OF_MONTH
);
startHour
=
startDate
.
get
(
Calendar
.
HOUR_OF_DAY
);
startMin
=
startDate
.
get
(
Calendar
.
MINUTE
);
startSecond
=
startDate
.
get
(
Calendar
.
SECOND
);
if
(
year
<
endYear
)
{
this
.
startMonth
=
month
;
this
.
startDay
=
day
;
this
.
startYear
=
year
;
}
else
if
(
year
==
endYear
)
{
if
(
month
<
endMonth
)
{
this
.
startMonth
=
month
;
this
.
startDay
=
day
;
this
.
startYear
=
year
;
}
else
if
(
month
==
endMonth
)
{
if
(
day
<
endDay
)
{
this
.
startMonth
=
month
;
this
.
startDay
=
day
;
this
.
startYear
=
year
;
}
}
}
}
else
if
(
startDate
!=
null
&&
endDate
!=
null
)
{
this
.
startYear
=
startDate
.
get
(
Calendar
.
YEAR
);
this
.
endYear
=
endDate
.
get
(
Calendar
.
YEAR
);
this
.
startMonth
=
startDate
.
get
(
Calendar
.
MONTH
)
+
1
;
this
.
endMonth
=
endDate
.
get
(
Calendar
.
MONTH
)
+
1
;
this
.
startDay
=
startDate
.
get
(
Calendar
.
DAY_OF_MONTH
);
this
.
endDay
=
endDate
.
get
(
Calendar
.
DAY_OF_MONTH
);
endHour
=
endDate
.
get
(
Calendar
.
HOUR_OF_DAY
);
endMin
=
endDate
.
get
(
Calendar
.
MINUTE
);
endSecond
=
endDate
.
get
(
Calendar
.
SECOND
);
startHour
=
startDate
.
get
(
Calendar
.
HOUR_OF_DAY
);
startMin
=
startDate
.
get
(
Calendar
.
MINUTE
);
startSecond
=
startDate
.
get
(
Calendar
.
SECOND
);
}
}
/**
* 设置间距倍数,但是只能在1.0-4.0f之间
*
* @param lineSpacingMultiplier
*/
public
void
setLineSpacingMultiplier
(
float
lineSpacingMultiplier
)
{
wv_day
.
setLineSpacingMultiplier
(
lineSpacingMultiplier
);
wv_month
.
setLineSpacingMultiplier
(
lineSpacingMultiplier
);
wv_year
.
setLineSpacingMultiplier
(
lineSpacingMultiplier
);
wv_hours
.
setLineSpacingMultiplier
(
lineSpacingMultiplier
);
wv_minutes
.
setLineSpacingMultiplier
(
lineSpacingMultiplier
);
wv_seconds
.
setLineSpacingMultiplier
(
lineSpacingMultiplier
);
}
/**
* 设置分割线的颜色
*
* @param dividerColor
*/
public
void
setDividerColor
(
int
dividerColor
)
{
wv_day
.
setDividerColor
(
dividerColor
);
wv_month
.
setDividerColor
(
dividerColor
);
wv_year
.
setDividerColor
(
dividerColor
);
wv_hours
.
setDividerColor
(
dividerColor
);
wv_minutes
.
setDividerColor
(
dividerColor
);
wv_seconds
.
setDividerColor
(
dividerColor
);
}
/**
* 设置分割线的类型
*
* @param dividerType
*/
public
void
setDividerType
(
WheelView
.
DividerType
dividerType
)
{
wv_day
.
setDividerType
(
dividerType
);
wv_month
.
setDividerType
(
dividerType
);
wv_year
.
setDividerType
(
dividerType
);
wv_hours
.
setDividerType
(
dividerType
);
wv_minutes
.
setDividerType
(
dividerType
);
wv_seconds
.
setDividerType
(
dividerType
);
}
/**
* 设置分割线之间的文字的颜色
*
* @param textColorCenter
*/
public
void
setTextColorCenter
(
int
textColorCenter
)
{
wv_day
.
setTextColorCenter
(
textColorCenter
);
wv_month
.
setTextColorCenter
(
textColorCenter
);
wv_year
.
setTextColorCenter
(
textColorCenter
);
wv_hours
.
setTextColorCenter
(
textColorCenter
);
wv_minutes
.
setTextColorCenter
(
textColorCenter
);
wv_seconds
.
setTextColorCenter
(
textColorCenter
);
}
/**
* 设置分割线以外文字的颜色
*
* @param textColorOut
*/
public
void
setTextColorOut
(
int
textColorOut
)
{
wv_day
.
setTextColorOut
(
textColorOut
);
wv_month
.
setTextColorOut
(
textColorOut
);
wv_year
.
setTextColorOut
(
textColorOut
);
wv_hours
.
setTextColorOut
(
textColorOut
);
wv_minutes
.
setTextColorOut
(
textColorOut
);
wv_seconds
.
setTextColorOut
(
textColorOut
);
}
/**
* @param isCenterLabel 是否只显示中间选中项的
*/
public
void
isCenterLabel
(
boolean
isCenterLabel
)
{
wv_day
.
isCenterLabel
(
isCenterLabel
);
wv_month
.
isCenterLabel
(
isCenterLabel
);
wv_year
.
isCenterLabel
(
isCenterLabel
);
wv_hours
.
isCenterLabel
(
isCenterLabel
);
wv_minutes
.
isCenterLabel
(
isCenterLabel
);
wv_seconds
.
isCenterLabel
(
isCenterLabel
);
}
public
void
setSelectChangeCallback
(
ISelectTimeCallback
mSelectChangeCallback
)
{
this
.
mSelectChangeCallback
=
mSelectChangeCallback
;
}
public
void
setItemsVisible
(
int
itemsVisibleCount
)
{
wv_day
.
setItemsVisibleCount
(
itemsVisibleCount
);
wv_month
.
setItemsVisibleCount
(
itemsVisibleCount
);
wv_year
.
setItemsVisibleCount
(
itemsVisibleCount
);
wv_hours
.
setItemsVisibleCount
(
itemsVisibleCount
);
wv_minutes
.
setItemsVisibleCount
(
itemsVisibleCount
);
wv_seconds
.
setItemsVisibleCount
(
itemsVisibleCount
);
}
public
void
setAlphaGradient
(
boolean
isAlphaGradient
)
{
wv_day
.
setAlphaGradient
(
isAlphaGradient
);
wv_month
.
setAlphaGradient
(
isAlphaGradient
);
wv_year
.
setAlphaGradient
(
isAlphaGradient
);
wv_hours
.
setAlphaGradient
(
isAlphaGradient
);
wv_minutes
.
setAlphaGradient
(
isAlphaGradient
);
wv_seconds
.
setAlphaGradient
(
isAlphaGradient
);
}
}
base-module/src/main/java/com/gingersoft/gsa/cloud/ui/view/timeselect/builder/OptionsPickerBuilder.java
0 → 100644
View file @
a7b7159a
package
com
.
gingersoft
.
gsa
.
cloud
.
ui
.
view
.
timeselect
.
builder
;
import
android.content.Context
;
import
android.graphics.Typeface
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
androidx.annotation.ColorInt
;
import
com.bigkoo.pickerview.configure.PickerOptions
;
import
com.bigkoo.pickerview.listener.CustomListener
;
import
com.bigkoo.pickerview.listener.OnOptionsSelectChangeListener
;
import
com.bigkoo.pickerview.listener.OnOptionsSelectListener
;
import
com.bigkoo.pickerview.view.OptionsPickerView
;
import
com.contrarywind.view.WheelView
;
/**
* Created by xiaosongzeem on 2018/3/20.
*/
public
class
OptionsPickerBuilder
{
//配置类
private
PickerOptions
mPickerOptions
;
//Required
public
OptionsPickerBuilder
(
Context
context
,
OnOptionsSelectListener
listener
)
{
mPickerOptions
=
new
PickerOptions
(
PickerOptions
.
TYPE_PICKER_OPTIONS
);
mPickerOptions
.
context
=
context
;
mPickerOptions
.
optionsSelectListener
=
listener
;
}
//Option
public
OptionsPickerBuilder
setSubmitText
(
String
textContentConfirm
)
{
mPickerOptions
.
textContentConfirm
=
textContentConfirm
;
return
this
;
}
public
OptionsPickerBuilder
setCancelText
(
String
textContentCancel
)
{
mPickerOptions
.
textContentCancel
=
textContentCancel
;
return
this
;
}
public
OptionsPickerBuilder
setTitleText
(
String
textContentTitle
)
{
mPickerOptions
.
textContentTitle
=
textContentTitle
;
return
this
;
}
public
OptionsPickerBuilder
isDialog
(
boolean
isDialog
)
{
mPickerOptions
.
isDialog
=
isDialog
;
return
this
;
}
public
OptionsPickerBuilder
addOnCancelClickListener
(
View
.
OnClickListener
cancelListener
)
{
mPickerOptions
.
cancelListener
=
cancelListener
;
return
this
;
}
public
OptionsPickerBuilder
setSubmitColor
(
int
textColorConfirm
)
{
mPickerOptions
.
textColorConfirm
=
textColorConfirm
;
return
this
;
}
public
OptionsPickerBuilder
setCancelColor
(
int
textColorCancel
)
{
mPickerOptions
.
textColorCancel
=
textColorCancel
;
return
this
;
}
/**
* {@link #setOutSideColor} instead.
*
* @param backgroundId color resId.
*/
@Deprecated
public
OptionsPickerBuilder
setBackgroundId
(
int
backgroundId
)
{
mPickerOptions
.
outSideColor
=
backgroundId
;
return
this
;
}
/**
* 显示时的外部背景色颜色,默认是灰色
*
* @param outSideColor color resId.
* @return
*/
public
OptionsPickerBuilder
setOutSideColor
(
int
outSideColor
)
{
mPickerOptions
.
outSideColor
=
outSideColor
;
return
this
;
}
/**
* ViewGroup 类型
* 设置PickerView的显示容器
*
* @param decorView Parent View.
* @return
*/
public
OptionsPickerBuilder
setDecorView
(
ViewGroup
decorView
)
{
mPickerOptions
.
decorView
=
decorView
;
return
this
;
}
public
OptionsPickerBuilder
setLayoutRes
(
int
res
,
CustomListener
listener
)
{
mPickerOptions
.
layoutRes
=
res
;
mPickerOptions
.
customListener
=
listener
;
return
this
;
}
public
OptionsPickerBuilder
setBgColor
(
int
bgColorWheel
)
{
mPickerOptions
.
bgColorWheel
=
bgColorWheel
;
return
this
;
}
public
OptionsPickerBuilder
setTitleBgColor
(
int
bgColorTitle
)
{
mPickerOptions
.
bgColorTitle
=
bgColorTitle
;
return
this
;
}
public
OptionsPickerBuilder
setTitleColor
(
int
textColorTitle
)
{
mPickerOptions
.
textColorTitle
=
textColorTitle
;
return
this
;
}
public
OptionsPickerBuilder
setSubCalSize
(
int
textSizeSubmitCancel
)
{
mPickerOptions
.
textSizeSubmitCancel
=
textSizeSubmitCancel
;
return
this
;
}
public
OptionsPickerBuilder
setTitleSize
(
int
textSizeTitle
)
{
mPickerOptions
.
textSizeTitle
=
textSizeTitle
;
return
this
;
}
public
OptionsPickerBuilder
setContentTextSize
(
int
textSizeContent
)
{
mPickerOptions
.
textSizeContent
=
textSizeContent
;
return
this
;
}
public
OptionsPickerBuilder
setOutSideCancelable
(
boolean
cancelable
)
{
mPickerOptions
.
cancelable
=
cancelable
;
return
this
;
}
public
OptionsPickerBuilder
setLabels
(
String
label1
,
String
label2
,
String
label3
)
{
mPickerOptions
.
label1
=
label1
;
mPickerOptions
.
label2
=
label2
;
mPickerOptions
.
label3
=
label3
;
return
this
;
}
/**
* 设置Item 的间距倍数,用于控制 Item 高度间隔
*
* @param lineSpacingMultiplier 浮点型,1.0-4.0f 之间有效,超过则取极值。
*/
public
OptionsPickerBuilder
setLineSpacingMultiplier
(
float
lineSpacingMultiplier
)
{
mPickerOptions
.
lineSpacingMultiplier
=
lineSpacingMultiplier
;
return
this
;
}
/**
* Set item divider line type color.
*
* @param dividerColor color resId.
*/
public
OptionsPickerBuilder
setDividerColor
(
@ColorInt
int
dividerColor
)
{
mPickerOptions
.
dividerColor
=
dividerColor
;
return
this
;
}
/**
* Set item divider line type.
*
* @param dividerType enum Type {@link WheelView.DividerType}
*/
public
OptionsPickerBuilder
setDividerType
(
WheelView
.
DividerType
dividerType
)
{
mPickerOptions
.
dividerType
=
dividerType
;
return
this
;
}
/**
* Set the textColor of selected item.
*
* @param textColorCenter color res.
*/
public
OptionsPickerBuilder
setTextColorCenter
(
int
textColorCenter
)
{
mPickerOptions
.
textColorCenter
=
textColorCenter
;
return
this
;
}
/**
* Set the textColor of outside item.
*
* @param textColorOut color resId.
*/
public
OptionsPickerBuilder
setTextColorOut
(
@ColorInt
int
textColorOut
)
{
mPickerOptions
.
textColorOut
=
textColorOut
;
return
this
;
}
public
OptionsPickerBuilder
setTypeface
(
Typeface
font
)
{
mPickerOptions
.
font
=
font
;
return
this
;
}
public
OptionsPickerBuilder
setCyclic
(
boolean
cyclic1
,
boolean
cyclic2
,
boolean
cyclic3
)
{
mPickerOptions
.
cyclic1
=
cyclic1
;
mPickerOptions
.
cyclic2
=
cyclic2
;
mPickerOptions
.
cyclic3
=
cyclic3
;
return
this
;
}
public
OptionsPickerBuilder
setSelectOptions
(
int
option1
)
{
mPickerOptions
.
option1
=
option1
;
return
this
;
}
public
OptionsPickerBuilder
setSelectOptions
(
int
option1
,
int
option2
)
{
mPickerOptions
.
option1
=
option1
;
mPickerOptions
.
option2
=
option2
;
return
this
;
}
public
OptionsPickerBuilder
setSelectOptions
(
int
option1
,
int
option2
,
int
option3
)
{
mPickerOptions
.
option1
=
option1
;
mPickerOptions
.
option2
=
option2
;
mPickerOptions
.
option3
=
option3
;
return
this
;
}
public
OptionsPickerBuilder
setTextXOffset
(
int
xoffset_one
,
int
xoffset_two
,
int
xoffset_three
)
{
mPickerOptions
.
x_offset_one
=
xoffset_one
;
mPickerOptions
.
x_offset_two
=
xoffset_two
;
mPickerOptions
.
x_offset_three
=
xoffset_three
;
return
this
;
}
public
OptionsPickerBuilder
isCenterLabel
(
boolean
isCenterLabel
)
{
mPickerOptions
.
isCenterLabel
=
isCenterLabel
;
return
this
;
}
/**
* 设置最大可见数目
*
* @param count 建议设置为 3 ~ 9之间。
*/
public
OptionsPickerBuilder
setItemVisibleCount
(
int
count
)
{
mPickerOptions
.
itemsVisibleCount
=
count
;
return
this
;
}
/**
* 透明度是否渐变
*
* @param isAlphaGradient true of false
*/
public
OptionsPickerBuilder
isAlphaGradient
(
boolean
isAlphaGradient
)
{
mPickerOptions
.
isAlphaGradient
=
isAlphaGradient
;
return
this
;
}
/**
* 切换选项时,是否还原第一项
*
* @param isRestoreItem true:还原; false: 保持上一个选项
* @return TimePickerBuilder
*/
public
OptionsPickerBuilder
isRestoreItem
(
boolean
isRestoreItem
)
{
mPickerOptions
.
isRestoreItem
=
isRestoreItem
;
return
this
;
}
/**
* @param listener 切换item项滚动停止时,实时回调监听。
* @return
*/
public
OptionsPickerBuilder
setOptionsSelectChangeListener
(
OnOptionsSelectChangeListener
listener
)
{
mPickerOptions
.
optionsSelectChangeListener
=
listener
;
return
this
;
}
public
<
T
>
OptionsPickerView
<
T
>
build
()
{
return
new
OptionsPickerView
<>(
mPickerOptions
);
}
}
base-module/src/main/java/com/gingersoft/gsa/cloud/ui/view/timeselect/builder/TimePickerBuilder.java
0 → 100644
View file @
a7b7159a
package
com
.
gingersoft
.
gsa
.
cloud
.
ui
.
view
.
timeselect
.
builder
;
import
android.content.Context
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
androidx.annotation.ColorInt
;
import
com.bigkoo.pickerview.configure.PickerOptions
;
import
com.bigkoo.pickerview.listener.CustomListener
;
import
com.bigkoo.pickerview.listener.OnTimeSelectChangeListener
;
import
com.bigkoo.pickerview.listener.OnTimeSelectListener
;
import
com.contrarywind.view.WheelView
;
import
com.gingersoft.gsa.cloud.ui.view.timeselect.TimePickerView
;
import
java.util.Calendar
;
/**
* Created by xiaosongzeem on 2018/3/20.
*/
public
class
TimePickerBuilder
{
private
PickerOptions
mPickerOptions
;
//Required
public
TimePickerBuilder
(
Context
context
,
OnTimeSelectListener
listener
)
{
mPickerOptions
=
new
PickerOptions
(
PickerOptions
.
TYPE_PICKER_TIME
);
mPickerOptions
.
context
=
context
;
mPickerOptions
.
timeSelectListener
=
listener
;
}
//Option
public
TimePickerBuilder
setGravity
(
int
gravity
)
{
mPickerOptions
.
textGravity
=
gravity
;
return
this
;
}
public
TimePickerBuilder
addOnCancelClickListener
(
View
.
OnClickListener
cancelListener
)
{
mPickerOptions
.
cancelListener
=
cancelListener
;
return
this
;
}
/**
* new boolean[]{true, true, true, false, false, false}
* control the "year","month","day","hours","minutes","seconds " display or hide.
* 分别控制“年”“月”“日”“时”“分”“秒”的显示或隐藏。
*
* @param type 布尔型数组,长度需要设置为6。
* @return TimePickerBuilder
*/
public
TimePickerBuilder
setType
(
boolean
[]
type
)
{
mPickerOptions
.
type
=
type
;
return
this
;
}
public
TimePickerBuilder
setSubmitText
(
String
textContentConfirm
)
{
mPickerOptions
.
textContentConfirm
=
textContentConfirm
;
return
this
;
}
public
TimePickerBuilder
isDialog
(
boolean
isDialog
)
{
mPickerOptions
.
isDialog
=
isDialog
;
return
this
;
}
public
TimePickerBuilder
setCancelText
(
String
textContentCancel
)
{
mPickerOptions
.
textContentCancel
=
textContentCancel
;
return
this
;
}
public
TimePickerBuilder
setTitleText
(
String
textContentTitle
)
{
mPickerOptions
.
textContentTitle
=
textContentTitle
;
return
this
;
}
public
TimePickerBuilder
setSubmitColor
(
int
textColorConfirm
)
{
mPickerOptions
.
textColorConfirm
=
textColorConfirm
;
return
this
;
}
public
TimePickerBuilder
setCancelColor
(
int
textColorCancel
)
{
mPickerOptions
.
textColorCancel
=
textColorCancel
;
return
this
;
}
/**
* ViewGroup 类型的容器
*
* @param decorView 选择器会被添加到此容器中
* @return TimePickerBuilder
*/
public
TimePickerBuilder
setDecorView
(
ViewGroup
decorView
)
{
mPickerOptions
.
decorView
=
decorView
;
return
this
;
}
public
TimePickerBuilder
setBgColor
(
int
bgColorWheel
)
{
mPickerOptions
.
bgColorWheel
=
bgColorWheel
;
return
this
;
}
public
TimePickerBuilder
setTitleBgColor
(
int
bgColorTitle
)
{
mPickerOptions
.
bgColorTitle
=
bgColorTitle
;
return
this
;
}
public
TimePickerBuilder
setTitleColor
(
int
textColorTitle
)
{
mPickerOptions
.
textColorTitle
=
textColorTitle
;
return
this
;
}
public
TimePickerBuilder
setSubCalSize
(
int
textSizeSubmitCancel
)
{
mPickerOptions
.
textSizeSubmitCancel
=
textSizeSubmitCancel
;
return
this
;
}
public
TimePickerBuilder
setTitleSize
(
int
textSizeTitle
)
{
mPickerOptions
.
textSizeTitle
=
textSizeTitle
;
return
this
;
}
public
TimePickerBuilder
setContentTextSize
(
int
textSizeContent
)
{
mPickerOptions
.
textSizeContent
=
textSizeContent
;
return
this
;
}
/**
* 设置最大可见数目
*
* @param count suggest value: 3, 5, 7, 9
*/
public
TimePickerBuilder
setItemVisibleCount
(
int
count
)
{
mPickerOptions
.
itemsVisibleCount
=
count
;
return
this
;
}
/**
* 透明度是否渐变
*
* @param isAlphaGradient true of false
*/
public
TimePickerBuilder
isAlphaGradient
(
boolean
isAlphaGradient
)
{
mPickerOptions
.
isAlphaGradient
=
isAlphaGradient
;
return
this
;
}
/**
* 因为系统Calendar的月份是从0-11的,所以如果是调用Calendar的set方法来设置时间,月份的范围也要是从0-11
*
* @param date
* @return TimePickerBuilder
*/
public
TimePickerBuilder
setDate
(
Calendar
date
)
{
mPickerOptions
.
date
=
date
;
return
this
;
}
public
TimePickerBuilder
setLayoutRes
(
int
res
,
CustomListener
customListener
)
{
mPickerOptions
.
layoutRes
=
res
;
mPickerOptions
.
customListener
=
customListener
;
return
this
;
}
/**
* 设置起始时间
* 因为系统Calendar的月份是从0-11的,所以如果是调用Calendar的set方法来设置时间,月份的范围也要是从0-11
*/
public
TimePickerBuilder
setRangDate
(
Calendar
startDate
,
Calendar
endDate
)
{
mPickerOptions
.
startDate
=
startDate
;
mPickerOptions
.
endDate
=
endDate
;
return
this
;
}
/**
* 设置间距倍数,但是只能在1.0-4.0f之间
*
* @param lineSpacingMultiplier
*/
public
TimePickerBuilder
setLineSpacingMultiplier
(
float
lineSpacingMultiplier
)
{
mPickerOptions
.
lineSpacingMultiplier
=
lineSpacingMultiplier
;
return
this
;
}
/**
* 设置分割线的颜色
*
* @param dividerColor
*/
public
TimePickerBuilder
setDividerColor
(
@ColorInt
int
dividerColor
)
{
mPickerOptions
.
dividerColor
=
dividerColor
;
return
this
;
}
/**
* 设置分割线的类型
*
* @param dividerType
*/
public
TimePickerBuilder
setDividerType
(
WheelView
.
DividerType
dividerType
)
{
mPickerOptions
.
dividerType
=
dividerType
;
return
this
;
}
/**
* {@link #setOutSideColor} instead.
*
* @param backgroundId color resId.
*/
@Deprecated
public
TimePickerBuilder
setBackgroundId
(
int
backgroundId
)
{
mPickerOptions
.
outSideColor
=
backgroundId
;
return
this
;
}
/**
* 显示时的外部背景色颜色,默认是灰色
*
* @param outSideColor
*/
public
TimePickerBuilder
setOutSideColor
(
@ColorInt
int
outSideColor
)
{
mPickerOptions
.
outSideColor
=
outSideColor
;
return
this
;
}
/**
* 设置分割线之间的文字的颜色
*
* @param textColorCenter
*/
public
TimePickerBuilder
setTextColorCenter
(
@ColorInt
int
textColorCenter
)
{
mPickerOptions
.
textColorCenter
=
textColorCenter
;
return
this
;
}
/**
* 设置分割线以外文字的颜色
*
* @param textColorOut
*/
public
TimePickerBuilder
setTextColorOut
(
@ColorInt
int
textColorOut
)
{
mPickerOptions
.
textColorOut
=
textColorOut
;
return
this
;
}
public
TimePickerBuilder
isCyclic
(
boolean
cyclic
)
{
mPickerOptions
.
cyclic
=
cyclic
;
return
this
;
}
public
TimePickerBuilder
setOutSideCancelable
(
boolean
cancelable
)
{
mPickerOptions
.
cancelable
=
cancelable
;
return
this
;
}
public
TimePickerBuilder
setLunarCalendar
(
boolean
lunarCalendar
)
{
mPickerOptions
.
isLunarCalendar
=
lunarCalendar
;
return
this
;
}
public
TimePickerBuilder
setLabel
(
String
label_year
,
String
label_month
,
String
label_day
,
String
label_hours
,
String
label_mins
,
String
label_seconds
)
{
mPickerOptions
.
label_year
=
label_year
;
mPickerOptions
.
label_month
=
label_month
;
mPickerOptions
.
label_day
=
label_day
;
mPickerOptions
.
label_hours
=
label_hours
;
mPickerOptions
.
label_minutes
=
label_mins
;
mPickerOptions
.
label_seconds
=
label_seconds
;
return
this
;
}
/**
* 设置X轴倾斜角度[ -90 , 90°]
*
* @param x_offset_year 年
* @param x_offset_month 月
* @param x_offset_day 日
* @param x_offset_hours 时
* @param x_offset_minutes 分
* @param x_offset_seconds 秒
* @return
*/
public
TimePickerBuilder
setTextXOffset
(
int
x_offset_year
,
int
x_offset_month
,
int
x_offset_day
,
int
x_offset_hours
,
int
x_offset_minutes
,
int
x_offset_seconds
)
{
mPickerOptions
.
x_offset_year
=
x_offset_year
;
mPickerOptions
.
x_offset_month
=
x_offset_month
;
mPickerOptions
.
x_offset_day
=
x_offset_day
;
mPickerOptions
.
x_offset_hours
=
x_offset_hours
;
mPickerOptions
.
x_offset_minutes
=
x_offset_minutes
;
mPickerOptions
.
x_offset_seconds
=
x_offset_seconds
;
return
this
;
}
public
TimePickerBuilder
isCenterLabel
(
boolean
isCenterLabel
)
{
mPickerOptions
.
isCenterLabel
=
isCenterLabel
;
return
this
;
}
/**
* @param listener 切换item项滚动停止时,实时回调监听。
* @return
*/
public
TimePickerBuilder
setTimeSelectChangeListener
(
OnTimeSelectChangeListener
listener
)
{
mPickerOptions
.
timeSelectChangeListener
=
listener
;
return
this
;
}
public
TimePickerView
build
()
{
return
new
TimePickerView
(
mPickerOptions
);
}
}
base-module/src/main/res/values/ids.xml
View file @
a7b7159a
...
...
@@ -43,4 +43,6 @@
<item
name=
"about_version_code"
type=
"id"
/>
<item
name=
"split"
type=
"id"
/>
<item
name=
"layout_replace"
type=
"id"
/>
<item
name=
"iv_prj_history"
type=
"id"
/>
</resources>
\ No newline at end of file
delivery_pick_module/src/main/AndroidManifest.xml
View file @
a7b7159a
...
...
@@ -43,5 +43,8 @@
<activity
android:name=
".mvp.ui.activity.AddressListActivity"
android:screenOrientation=
"portrait"
/>
<activity
android:name=
".mvp.ui.activity.PrjQueryActivity"
android:screenOrientation=
"portrait"
/>
</application>
</manifest>
\ No newline at end of file
delivery_pick_module/src/main/debug/AndroidManifest.xml
View file @
a7b7159a
...
...
@@ -13,6 +13,7 @@
android:networkSecurityConfig=
"@xml/network_android"
android:supportsRtl=
"true"
android:theme=
"@style/AppTheme"
>
<activity
android:name=
".mvp.ui.activity.PrjQueryActivity"
/>
<activity
android:name=
".mvp.ui.activity.AddressListActivity"
/>
<activity
android:name=
".ui.activity.LogActivity"
/>
<activity
android:name=
".ui.activity.OrderDetailsActivity"
/>
...
...
delivery_pick_module/src/main/java/com/gingersoft/gsa/delivery_pick_mode/DeliveryPickComponent.java
View file @
a7b7159a
...
...
@@ -8,6 +8,7 @@ import com.billy.cc.core.component.CCUtil;
import
com.billy.cc.core.component.IComponent
;
import
com.gingersoft.gsa.cloud.service.GetInfoUpdateService
;
import
com.gingersoft.gsa.delivery_pick_mode.data.network.ServiceCreator
;
import
com.gingersoft.gsa.delivery_pick_mode.mvp.ui.activity.PrjQueryActivity
;
import
com.gingersoft.gsa.delivery_pick_mode.mvp.ui.activity.SendOrderActivity
;
import
com.gingersoft.gsa.delivery_pick_mode.ui.activity.DeliveryOrderMainActivity
;
import
com.gingersoft.gsa.delivery_pick_mode.ui.activity.HistoryOrderActivity
;
...
...
@@ -64,6 +65,10 @@ public class DeliveryPickComponent implements IComponent {
CCUtil
.
navigateTo
(
cc
,
SendOrderActivity
.
class
);
CC
.
sendCCResult
(
cc
.
getCallId
(),
CCResult
.
success
());
break
;
case
"PrjQueryActivity"
:
CCUtil
.
navigateTo
(
cc
,
PrjQueryActivity
.
class
);
CC
.
sendCCResult
(
cc
.
getCallId
(),
CCResult
.
success
());
break
;
default
:
// cc.callAsync(new IComponentCallback() {
// @Override
...
...
delivery_pick_module/src/main/java/com/gingersoft/gsa/delivery_pick_mode/data/network/ServiceCreator.kt
View file @
a7b7159a
package
com.gingersoft.gsa.delivery_pick_mode.data.network
import
android.util.Log
import
com.gingersoft.gsa.cloud.base.application.GsaCloudApplication
import
com.gingersoft.gsa.cloud.base.utils.encryption.Aes
import
com.gingersoft.gsa.cloud.constans.AppConstans
...
...
@@ -45,6 +46,7 @@ object ServiceCreator {
builder
=
Retrofit
.
Builder
()
.
baseUrl
(
HttpsConstans
.
ricepon_wechat
)
.
client
(
httpClient
.
build
())
.
addConverterFactory
(
ScalarsConverterFactory
.
create
())
.
addConverterFactory
(
GsonConverterFactory
.
create
())
builder2
=
Retrofit
.
Builder
()
...
...
@@ -131,6 +133,7 @@ object ServiceCreator {
token
=
Aes
.
aesEncrypt
(
"9_"
+
memberId
+
"_"
+
System
.
currentTimeMillis
()
+
"_"
+
loginToken
)
token
=
token
.
replace
(
"\r|\n"
.
toRegex
(),
""
)
builder
.
set
(
"token"
,
token
)
Log
.
e
(
"eee"
,
"添加Token:"
+
token
);
}
val
request1
=
chain
.
request
().
newBuilder
().
headers
(
builder
.
build
()).
build
()
return
chain
.
proceed
(
request1
)
...
...
delivery_pick_module/src/main/java/com/gingersoft/gsa/delivery_pick_mode/di/component/PrjQueryComponent.java
0 → 100644
View file @
a7b7159a
package
com
.
gingersoft
.
gsa
.
delivery_pick_mode
.
di
.
component
;
import
dagger.BindsInstance
;
import
dagger.Component
;
import
com.jess.arms.di.component.AppComponent
;
import
com.gingersoft.gsa.delivery_pick_mode.di.module.PrjQueryModule
;
import
com.gingersoft.gsa.delivery_pick_mode.mvp.contract.PrjQueryContract
;
import
com.jess.arms.di.scope.ActivityScope
;
import
com.gingersoft.gsa.delivery_pick_mode.mvp.ui.activity.PrjQueryActivity
;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 10/20/2020 09:34
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
@ActivityScope
@Component
(
modules
=
PrjQueryModule
.
class
,
dependencies
=
AppComponent
.
class
)
public
interface
PrjQueryComponent
{
void
inject
(
PrjQueryActivity
activity
);
@Component
.
Builder
interface
Builder
{
@BindsInstance
PrjQueryComponent
.
Builder
view
(
PrjQueryContract
.
View
view
);
PrjQueryComponent
.
Builder
appComponent
(
AppComponent
appComponent
);
PrjQueryComponent
build
();
}
}
\ No newline at end of file
delivery_pick_module/src/main/java/com/gingersoft/gsa/delivery_pick_mode/di/module/PrjQueryModule.java
0 → 100644
View file @
a7b7159a
package
com
.
gingersoft
.
gsa
.
delivery_pick_mode
.
di
.
module
;
import
com.jess.arms.di.scope.ActivityScope
;
import
dagger.Binds
;
import
dagger.Module
;
import
dagger.Provides
;
import
com.gingersoft.gsa.delivery_pick_mode.mvp.contract.PrjQueryContract
;
import
com.gingersoft.gsa.delivery_pick_mode.mvp.model.PrjQueryModel
;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 10/20/2020 09:34
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
@Module
public
abstract
class
PrjQueryModule
{
@Binds
abstract
PrjQueryContract
.
Model
bindPrjQueryModel
(
PrjQueryModel
model
);
}
\ No newline at end of file
delivery_pick_module/src/main/java/com/gingersoft/gsa/delivery_pick_mode/mvp/bean/PrjQueryBean.java
0 → 100644
View file @
a7b7159a
package
com
.
gingersoft
.
gsa
.
delivery_pick_mode
.
mvp
.
bean
;
import
com.gingersoft.gsa.cloud.print.bean.PrjBean
;
import
java.util.List
;
import
lombok.Data
;
@Data
public
class
PrjQueryBean
{
/**
* success : true
* sysTime : 1603245617207
* data : [{"id":48865917,"orderNo":"26200413276048171","orderTime":2020,"sender":"","sendTime":"","person":0,"number":1,"orderDetailsTime":"Aug 6, 2020 6:08:29 PM","orderDetailsId":48865917,"productName":"蟹膏軍艦 (2件)","productName2":"","productName3":"","parentId":0,"type":3,"productId":34985,"requests":0,"takeFoodCode":"A241","takeTime":"08-06 (週四)立即","billNo":"0685","orderType":7,"presence":1}]
*/
private
boolean
success
;
private
long
sysTime
;
private
String
errMsg
;
private
List
<
PrjBean
.
DataBean
.
Bean
>
data
;
}
delivery_pick_module/src/main/java/com/gingersoft/gsa/delivery_pick_mode/mvp/contract/PrjQueryContract.java
0 → 100644
View file @
a7b7159a
package
com
.
gingersoft
.
gsa
.
delivery_pick_mode
.
mvp
.
contract
;
import
com.gingersoft.gsa.delivery_pick_mode.mvp.bean.PrjQueryBean
;
import
com.jess.arms.mvp.IModel
;
import
com.jess.arms.mvp.IView
;
import
io.reactivex.Observable
;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 10/20/2020 09:34
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
public
interface
PrjQueryContract
{
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface
View
extends
IView
{
void
loadPrjInfo
(
PrjQueryBean
prjQueryBean
);
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface
Model
extends
IModel
{
Observable
<
PrjQueryBean
>
getKitchenPrint
(
String
orderId
);
}
}
delivery_pick_module/src/main/java/com/gingersoft/gsa/delivery_pick_mode/mvp/model/PrjQueryModel.java
0 → 100644
View file @
a7b7159a
package
com
.
gingersoft
.
gsa
.
delivery_pick_mode
.
mvp
.
model
;
import
android.app.Application
;
import
com.gingersoft.gsa.cloud.base.application.GsaCloudApplication
;
import
com.gingersoft.gsa.delivery_pick_mode.mvp.bean.PrjQueryBean
;
import
com.gingersoft.gsa.delivery_pick_mode.mvp.contract.PrjQueryContract
;
import
com.gingersoft.gsa.delivery_pick_mode.mvp.server.PrjQueryServer
;
import
com.google.gson.Gson
;
import
com.jess.arms.di.scope.ActivityScope
;
import
com.jess.arms.integration.IRepositoryManager
;
import
com.jess.arms.mvp.BaseModel
;
import
javax.inject.Inject
;
import
io.reactivex.Observable
;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 10/20/2020 09:34
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
@ActivityScope
public
class
PrjQueryModel
extends
BaseModel
implements
PrjQueryContract
.
Model
{
@Inject
Gson
mGson
;
@Inject
Application
mApplication
;
@Inject
public
PrjQueryModel
(
IRepositoryManager
repositoryManager
)
{
super
(
repositoryManager
);
}
@Override
public
void
onDestroy
()
{
super
.
onDestroy
();
this
.
mGson
=
null
;
this
.
mApplication
=
null
;
}
@Override
public
Observable
<
PrjQueryBean
>
getKitchenPrint
(
String
orderId
)
{
return
mRepositoryManager
.
obtainRetrofitService
(
PrjQueryServer
.
class
).
getKitchenPrint
(
orderId
,
GsaCloudApplication
.
getRestaurantId
()
+
""
);
}
}
\ No newline at end of file
delivery_pick_module/src/main/java/com/gingersoft/gsa/delivery_pick_mode/mvp/presenter/PrjQueryPresenter.java
0 → 100644
View file @
a7b7159a
package
com
.
gingersoft
.
gsa
.
delivery_pick_mode
.
mvp
.
presenter
;
import
android.app.Application
;
import
com.gingersoft.gsa.cloud.base.utils.other.TextUtil
;
import
com.gingersoft.gsa.delivery_pick_mode.mvp.bean.PrjQueryBean
;
import
com.gingersoft.gsa.delivery_pick_mode.mvp.contract.PrjQueryContract
;
import
com.jess.arms.di.scope.ActivityScope
;
import
com.jess.arms.http.imageloader.ImageLoader
;
import
com.jess.arms.integration.AppManager
;
import
com.jess.arms.mvp.BasePresenter
;
import
com.jess.arms.utils.RxLifecycleUtils
;
import
javax.inject.Inject
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
import
io.reactivex.annotations.NonNull
;
import
io.reactivex.schedulers.Schedulers
;
import
me.jessyan.rxerrorhandler.core.RxErrorHandler
;
import
me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber
;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 10/20/2020 09:34
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
@ActivityScope
public
class
PrjQueryPresenter
extends
BasePresenter
<
PrjQueryContract
.
Model
,
PrjQueryContract
.
View
>
{
@Inject
RxErrorHandler
mErrorHandler
;
@Inject
Application
mApplication
;
@Inject
ImageLoader
mImageLoader
;
@Inject
AppManager
mAppManager
;
@Inject
public
PrjQueryPresenter
(
PrjQueryContract
.
Model
model
,
PrjQueryContract
.
View
rootView
)
{
super
(
model
,
rootView
);
}
@Override
public
void
onDestroy
()
{
super
.
onDestroy
();
this
.
mErrorHandler
=
null
;
this
.
mAppManager
=
null
;
this
.
mImageLoader
=
null
;
this
.
mApplication
=
null
;
}
public
void
getKitchenPrint
(
String
orderNo
)
{
mModel
.
getKitchenPrint
(
orderNo
)
.
subscribeOn
(
Schedulers
.
io
())
.
doOnSubscribe
(
disposable
->
mRootView
.
showLoading
(
"查詢打印信息 ..."
))
.
subscribeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
doAfterTerminate
(()
->
mRootView
.
hideLoading
())
.
compose
(
RxLifecycleUtils
.
bindToLifecycle
(
mRootView
))
.
subscribe
(
new
ErrorHandleSubscriber
<
PrjQueryBean
>(
mErrorHandler
)
{
@Override
public
void
onNext
(
@NonNull
PrjQueryBean
info
)
{
if
(
info
!=
null
)
{
if
(
info
.
getData
()
!=
null
)
{
mRootView
.
loadPrjInfo
(
info
);
}
else
if
(
TextUtil
.
isNotEmptyOrNullOrUndefined
(
info
.
getErrMsg
()))
{
mRootView
.
showMessage
(
info
.
getErrMsg
());
}
else
{
mRootView
.
showMessage
(
"打印信息查詢失敗"
);
}
}
else
{
mRootView
.
showMessage
(
"打印信息查詢失敗"
);
}
}
@Override
public
void
onError
(
Throwable
t
)
{
super
.
onError
(
t
);
}
});
}
}
delivery_pick_module/src/main/java/com/gingersoft/gsa/delivery_pick_mode/mvp/presenter/SendOrderPresenter.java
View file @
a7b7159a
...
...
@@ -172,7 +172,7 @@ public class SendOrderPresenter extends BasePresenter<SendOrderContract.Model, S
for
(
OrderDetails
.
DataBean
.
PRODUCTNAMEBean
productnameBean
:
productnameBeans
)
{
if
(
productnameBean
.
getChild
()
!=
null
)
{
for
(
OrderDetails
.
DataBean
.
PRODUCTNAMEBean
.
ChildBeanX
childBeanX
:
productnameBean
.
getChild
())
{
if
(
childBeanX
!=
null
)
{
if
(
childBeanX
.
getChild
()
!=
null
)
{
for
(
OrderDetails
.
DataBean
.
PRODUCTNAMEBean
.
ChildBeanX
.
ChildBean
childBean
:
childBeanX
.
getChild
())
{
ids
.
append
(
childBean
.
getOdsId
());
ids
.
append
(
","
);
...
...
@@ -232,6 +232,7 @@ public class SendOrderPresenter extends BasePresenter<SendOrderContract.Model, S
json
.
put
(
"addressDetail"
,
address
);
json
.
put
(
"orderRemark"
,
""
);
json
.
put
(
"payType"
,
1
);
json
.
put
(
"receiver"
,
name
);
//原价
json
.
put
(
"originalAmount"
,
MyOrderManage
.
getInstance
().
getWholeAmount
());
json
.
put
(
"orderType"
,
2
);
//訂單類型#1:餐廳訂單;2:線上外賣訂單3:扫码点餐;4固定二维码订单;5:预点餐;6:積分訂單;7:自取订单
...
...
delivery_pick_module/src/main/java/com/gingersoft/gsa/delivery_pick_mode/mvp/server/PrjQueryServer.java
0 → 100644
View file @
a7b7159a
package
com
.
gingersoft
.
gsa
.
delivery_pick_mode
.
mvp
.
server
;
import
com.gingersoft.gsa.delivery_pick_mode.mvp.bean.PrjQueryBean
;
import
io.reactivex.Observable
;
import
me.jessyan.retrofiturlmanager.RetrofitUrlManager
;
import
retrofit2.http.GET
;
import
retrofit2.http.Query
;
public
interface
PrjQueryServer
{
@GET
(
"printerRecording/getKitchenPrint"
+
RetrofitUrlManager
.
IDENTIFICATION_PATH_SIZE
+
2
)
Observable
<
PrjQueryBean
>
getKitchenPrint
(
@Query
(
"orderNo"
)
String
orderId
,
@Query
(
"restaurantId"
)
String
restaurantId
);
}
delivery_pick_module/src/main/java/com/gingersoft/gsa/delivery_pick_mode/mvp/ui/activity/AddressListActivity.java
View file @
a7b7159a
...
...
@@ -74,7 +74,7 @@ public class AddressListActivity extends BaseActivity<AddressListPresenter> impl
List
<
MemberAddressInfoBean
.
DataBean
>
dataBeanList
=
(
List
<
MemberAddressInfoBean
.
DataBean
>)
getIntent
().
getSerializableExtra
(
REQUEST_ADDRESS_LIST_NAME
);
int
resultCode
=
getIntent
().
getIntExtra
(
RESULT_CODE
,
0
);
AddressAdapter
addressAdapter
=
new
AddressAdapter
(
dataBeanList
);
addressAdapter
.
setOnItemC
hildC
lickListener
((
adapter
,
view
,
position
)
->
{
addressAdapter
.
setOnItemClickListener
((
adapter
,
view
,
position
)
->
{
Intent
intent
=
new
Intent
();
intent
.
putExtra
(
RESULT_DATA_NAME
,
dataBeanList
.
get
(
position
));
setResult
(
resultCode
,
intent
);
...
...
delivery_pick_module/src/main/java/com/gingersoft/gsa/delivery_pick_mode/mvp/ui/activity/PrjQueryActivity.java
0 → 100644
View file @
a7b7159a
package
com
.
gingersoft
.
gsa
.
delivery_pick_mode
.
mvp
.
ui
.
activity
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.view.View
;
import
android.widget.EditText
;
import
android.widget.ImageView
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
androidx.constraintlayout.widget.ConstraintLayout
;
import
androidx.core.content.ContextCompat
;
import
androidx.recyclerview.widget.LinearLayoutManager
;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.billy.cc.core.component.CC
;
import
com.gingersoft.gsa.cloud.base.utils.okhttpUtils.OkHttp3Utils
;
import
com.gingersoft.gsa.cloud.base.utils.other.TextUtil
;
import
com.gingersoft.gsa.cloud.constans.AppConstans
;
import
com.gingersoft.gsa.cloud.constans.PrintConstans
;
import
com.gingersoft.gsa.cloud.print.bean.PrjBean
;
import
com.gingersoft.gsa.cloud.ui.widget.dialog.LoadingDialog
;
import
com.gingersoft.gsa.delivery_pick_mode.R
;
import
com.gingersoft.gsa.delivery_pick_mode.R2
;
import
com.gingersoft.gsa.delivery_pick_mode.di.component.DaggerPrjQueryComponent
;
import
com.gingersoft.gsa.delivery_pick_mode.mvp.bean.PrjQueryBean
;
import
com.gingersoft.gsa.delivery_pick_mode.mvp.contract.PrjQueryContract
;
import
com.gingersoft.gsa.delivery_pick_mode.mvp.presenter.PrjQueryPresenter
;
import
com.gingersoft.gsa.delivery_pick_mode.mvp.ui.adapter.PrjStateAdapter
;
import
com.jess.arms.base.BaseActivity
;
import
com.jess.arms.di.component.AppComponent
;
import
com.jess.arms.utils.ArmsUtils
;
import
com.qmuiteam.qmui.widget.QMUITopBar
;
import
java.util.ArrayList
;
import
java.util.List
;
import
butterknife.BindView
;
import
butterknife.OnClick
;
import
static
com
.
jess
.
arms
.
utils
.
Preconditions
.
checkNotNull
;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 10/20/2020 09:34
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
public
class
PrjQueryActivity
extends
BaseActivity
<
PrjQueryPresenter
>
implements
PrjQueryContract
.
View
,
View
.
OnClickListener
{
@BindView
(
R2
.
id
.
top_bar_prj_print
)
QMUITopBar
topBarPrjPrint
;
@BindView
(
R2
.
id
.
tv_prj_record_order_id
)
TextView
tvPrjRecordOrderId
;
@BindView
(
R2
.
id
.
rv_prj_record_list
)
RecyclerView
rvPrjRecordList
;
@BindView
(
R2
.
id
.
layout_edit_prj_order_number
)
ConstraintLayout
editLayout
;
@BindView
(
R2
.
id
.
iv_search_order_prj
)
ImageView
ivSearchOrderPrj
;
@BindView
(
R2
.
id
.
layout_prj_order_number
)
LinearLayout
layoutPrjOrderNumber
;
@BindView
(
R2
.
id
.
ed_input_order_number
)
EditText
edOrderNumber
;
private
static
final
String
ORDERID_EXTRA_NAME
=
"orderId"
;
@Override
public
void
setupActivityComponent
(
@NonNull
AppComponent
appComponent
)
{
DaggerPrjQueryComponent
//如找不到该类,请编译一下项目
.
builder
()
.
appComponent
(
appComponent
)
.
view
(
this
)
.
build
()
.
inject
(
this
);
}
@Override
public
int
initView
(
@Nullable
Bundle
savedInstanceState
)
{
return
R
.
layout
.
activity_prj_query
;
}
@Override
public
void
initData
(
@Nullable
Bundle
savedInstanceState
)
{
String
orderId
=
getIntent
().
getStringExtra
(
ORDERID_EXTRA_NAME
);
if
(
TextUtil
.
isNotEmptyOrNullOrUndefined
(
orderId
))
{
layoutPrjOrderNumber
.
setVisibility
(
View
.
VISIBLE
);
tvPrjRecordOrderId
.
setText
(
orderId
);
mPresenter
.
getKitchenPrint
(
orderId
);
}
else
{
editLayout
.
setVisibility
(
View
.
VISIBLE
);
}
}
public
static
void
startPrjQueryActivity
(
Context
context
,
String
orderId
)
{
Intent
intent
=
new
Intent
(
context
,
PrjQueryActivity
.
class
);
intent
.
putExtra
(
ORDERID_EXTRA_NAME
,
orderId
);
context
.
startActivity
(
intent
);
}
@Override
public
void
initIntent
()
{
}
@Override
public
void
initTopBar
()
{
topBarPrjPrint
.
setTitle
(
"廚房打印查詢"
);
topBarPrjPrint
.
setBackgroundColor
(
ContextCompat
.
getColor
(
this
,
R
.
color
.
theme_color
));
topBarPrjPrint
.
addLeftImageButton
(
R
.
drawable
.
icon_return
,
R
.
id
.
iv_left_back
).
setOnClickListener
(
v
->
killMyself
());
}
@Override
public
void
initLanguage
()
{
}
@Override
public
void
initLayoutParams
()
{
}
@Override
public
void
initLayoutVisible
()
{
}
@Override
public
void
showLoading
(
String
message
)
{
if
(
message
!=
null
)
{
LoadingDialog
.
showDialogForLoading
(
this
,
message
,
true
);
}
else
{
LoadingDialog
.
showDialogForLoading
(
this
);
}
}
@Override
public
void
hideLoading
()
{
LoadingDialog
.
cancelDialogForLoading
();
}
@Override
public
void
showMessage
(
@NonNull
String
message
)
{
ArmsUtils
.
makeText
(
this
,
message
);
}
@Override
public
void
launchActivity
(
@NonNull
Intent
intent
)
{
checkNotNull
(
intent
);
ArmsUtils
.
startActivity
(
intent
);
}
@Override
public
void
killMyself
()
{
finish
();
}
@OnClick
({
R2
.
id
.
iv_search_order_prj
})
@Override
public
void
onClick
(
View
v
)
{
int
viewId
=
v
.
getId
();
if
(
viewId
==
R
.
id
.
iv_search_order_prj
)
{
if
(
TextUtil
.
isNotEmptyOrNullOrUndefined
(
edOrderNumber
))
{
mPresenter
.
getKitchenPrint
(
edOrderNumber
.
getText
().
toString
());
}
}
}
@Override
public
void
loadPrjInfo
(
PrjQueryBean
prjQueryBean
)
{
PrjStateAdapter
prjStateAdapter
=
new
PrjStateAdapter
(
mContext
,
prjQueryBean
.
getData
());
rvPrjRecordList
.
setAdapter
(
prjStateAdapter
);
prjStateAdapter
.
setOnItemChildClickListener
((
adapter
,
view
,
position
)
->
{
if
(
view
.
getId
()
==
R
.
id
.
tv_prj_record_print_operation
)
{
//重印
List
<
PrjBean
.
DataBean
.
Bean
>
prjData
=
prjQueryBean
.
getData
();
if
(
prjData
.
get
(
position
).
getParentId
()
==
0
)
{
//是主食品,判斷有沒有子食品,如果沒有子食品,直接打印主食品
if
(
position
+
1
>
prjData
.
size
()
||
prjData
.
get
(
position
+
1
).
getParentId
()
==
0
)
{
//沒有子食品
//直接打印
List
<
PrjBean
.
DataBean
.
Bean
>
printDatas
=
new
ArrayList
<>();
printDatas
.
add
(
prjData
.
get
(
position
));
printPrj
(
printDatas
);
}
else
if
(
prjData
.
get
(
position
).
getProductId
().
equals
(
prjData
.
get
(
position
+
1
).
getParentId
()
+
""
))
{
//有子食品
List
<
PrjBean
.
DataBean
.
Bean
>
printDatas
=
new
ArrayList
<>();
printDatas
.
add
(
prjData
.
get
(
position
));
for
(
int
i
=
position
;
i
<
prjData
.
size
();
i
++)
{
if
(
prjData
.
get
(
position
).
getProductId
().
equals
(
prjData
.
get
(
i
).
getParentId
()
+
""
))
{
printDatas
.
add
(
prjData
.
get
(
i
));
}
else
{
break
;
}
}
printPrj
(
printDatas
);
}
}
else
{
//是子食品,直接打印子食品
List
<
PrjBean
.
DataBean
.
Bean
>
printDatas
=
new
ArrayList
<>();
printDatas
.
add
(
prjData
.
get
(
position
));
printPrj
(
printDatas
);
}
//添加重印的報警推送
OkHttp3Utils
.
noticePersonnel
(
AppConstans
.
RP_REPRINT_CODE
,
"重印,訂單號:"
+
prjData
.
get
(
position
).
getOrderNo
());
}
});
rvPrjRecordList
.
setLayoutManager
(
new
LinearLayoutManager
(
mContext
));
}
private
void
printPrj
(
List
<
PrjBean
.
DataBean
.
Bean
>
printDatas
)
{
CC
.
obtainBuilder
(
"Component.Print"
)
.
addParam
(
PrintConstans
.
PRINT_TYPE
,
PrintConstans
.
PRINT_KITCHEN
)
.
addParam
(
"prjBeans"
,
printDatas
)
.
setActionName
(
"printActivity"
)
.
build
()
.
callAsyncCallbackOnMainThread
((
cc
,
result
)
->
{
});
}
}
delivery_pick_module/src/main/java/com/gingersoft/gsa/delivery_pick_mode/mvp/ui/adapter/PrjStateAdapter.java
0 → 100644
View file @
a7b7159a
package
com
.
gingersoft
.
gsa
.
delivery_pick_mode
.
mvp
.
ui
.
adapter
;
import
android.content.Context
;
import
android.widget.TextView
;
import
androidx.core.content.ContextCompat
;
import
com.chad.library.adapter.base.BaseQuickAdapter
;
import
com.chad.library.adapter.base.viewholder.BaseViewHolder
;
import
com.gingersoft.gsa.cloud.print.bean.PrjBean
;
import
com.gingersoft.gsa.delivery_pick_mode.R
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
import
java.math.BigDecimal
;
import
java.util.List
;
public
class
PrjStateAdapter
extends
BaseQuickAdapter
<
PrjBean
.
DataBean
.
Bean
,
BaseViewHolder
>
{
private
Context
context
;
private
int
indentation
;
public
PrjStateAdapter
(
Context
context
,
@Nullable
List
<
PrjBean
.
DataBean
.
Bean
>
data
)
{
super
(
R
.
layout
.
item_prj_state
,
data
);
this
.
context
=
context
;
addChildClickViewIds
(
R
.
id
.
tv_prj_record_print_operation
);
}
@Override
protected
void
convert
(
@NotNull
BaseViewHolder
baseViewHolder
,
PrjBean
.
DataBean
.
Bean
dataBean
)
{
TextView
state
=
baseViewHolder
.
getView
(
R
.
id
.
tv_prj_record_print_state
);
TextView
foodName
=
baseViewHolder
.
getView
(
R
.
id
.
tv_prj_record_food_name
);
foodName
.
setText
(
dataBean
.
getProductName
());
if
(
dataBean
.
getPresence
()
==
0
)
{
state
.
setText
(
"沒有生成"
);
state
.
setTextColor
(
ContextCompat
.
getColor
(
context
,
R
.
color
.
red
));
}
else
if
(
dataBean
.
getType
()
==
3
)
{
state
.
setText
(
"已打印"
);
state
.
setTextColor
(
ContextCompat
.
getColor
(
context
,
R
.
color
.
order_state4_color
));
}
else
if
(
dataBean
.
getType
()
==
1
)
{
state
.
setText
(
"打印失敗"
);
state
.
setTextColor
(
ContextCompat
.
getColor
(
context
,
R
.
color
.
red
));
}
else
{
state
.
setText
(
"未知"
);
state
.
setTextColor
(
ContextCompat
.
getColor
(
context
,
R
.
color
.
gray
));
}
if
(
baseViewHolder
.
getAdapterPosition
()
==
0
)
{
//只第一次測量一下
indentation
=
new
BigDecimal
(
foodName
.
getPaint
().
measureText
(
"哈"
)).
setScale
(
0
,
BigDecimal
.
ROUND_HALF_UP
).
intValue
();
}
if
(
dataBean
.
getParentId
()
!=
0
)
{
foodName
.
setPadding
(
indentation
,
foodName
.
getPaddingTop
(),
foodName
.
getPaddingRight
(),
foodName
.
getPaddingBottom
());
}
else
{
foodName
.
setPadding
(
0
,
foodName
.
getPaddingTop
(),
foodName
.
getPaddingRight
(),
foodName
.
getPaddingBottom
());
}
}
}
delivery_pick_module/src/main/java/com/gingersoft/gsa/delivery_pick_mode/ui/activity/OrderDetailsActivity.kt
View file @
a7b7159a
...
...
@@ -37,6 +37,7 @@ import com.gingersoft.gsa.delivery_pick_mode.model.viewModel.PageViewModel.Compa
import
com.gingersoft.gsa.delivery_pick_mode.model.viewModel.PageViewModel.Companion.OrderDelivery
import
com.gingersoft.gsa.delivery_pick_mode.model.viewModel.PageViewModel.Companion.PrintCode
import
com.gingersoft.gsa.delivery_pick_mode.model.viewModel.PageViewModel.Companion.Transportation
import
com.gingersoft.gsa.delivery_pick_mode.mvp.ui.activity.PrjQueryActivity
import
com.gingersoft.gsa.delivery_pick_mode.ui.adapter.DeliveryAdapter
import
com.gingersoft.gsa.delivery_pick_mode.ui.adapter.FoodListAdapter
import
com.gingersoft.gsa.delivery_pick_mode.ui.adapter.OrderDetailsAdapter
...
...
@@ -67,6 +68,7 @@ class OrderDetailsActivity : BaseActivity<IPresenter>() {
lateinit
var
skeletonScreen
:
ViewSkeletonScreen
var
restaurantId
:
Int
=
-
1
private
var
orderNo
:
String
?
=
null
lateinit
var
rvThirdExpenses
:
RecyclerView
lateinit
var
thirdExpensesLayout
:
LinearLayout
...
...
@@ -114,6 +116,7 @@ class OrderDetailsActivity : BaseActivity<IPresenter>() {
topbar
.
setTitle
(
GsaCloudApplication
.
getRestaurantName
())
topbar
.
addLeftImageButton
(
R
.
drawable
.
icon_return
,
R
.
id
.
iv_left_back
).
setOnClickListener
{
finish
()
}
topbar
.
setBackgroundColor
(
ContextCompat
.
getColor
(
this
,
R
.
color
.
theme_color
))
}
private
fun
PageViewModel
.
getOrderDetails
(
orderId
:
String
,
binding
:
ActivityOrderDetailsBinding
)
{
...
...
@@ -124,6 +127,10 @@ class OrderDetailsActivity : BaseActivity<IPresenter>() {
if
(
it
?.
data
!=
null
&&
it
.
data
!!
.
isNotEmpty
())
{
//初始化頁面佈局
val
orderDetails
=
it
.
data
!!
[
0
]
orderNo
=
orderDetails
.
ORDER_NO
.
toString
()
qm_order_details_bar
.
addRightImageButton
(
R
.
drawable
.
ic_print
,
R
.
id
.
iv_prj_history
).
setOnClickListener
{
PrjQueryActivity
.
startPrjQueryActivity
(
this
@OrderDetailsActivity
,
orderNo
)
}
orderDetails
.
order_type
=
orderType
orderDetails
.
orderPayType
=
orderPayType
binding
.
data
=
orderDetails
...
...
delivery_pick_module/src/main/res/layout/activity_prj_query.xml
0 → 100644
View file @
a7b7159a
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
<com.qmuiteam.qmui.widget.QMUITopBar
android:id=
"@+id/top_bar_prj_print"
android:layout_width=
"match_parent"
android:layout_height=
"@dimen/head_height"
android:fitsSystemWindows=
"true"
app:qmui_topbar_text_btn_color_state_list=
"@color/theme_white_color"
app:qmui_topbar_title_color=
"@color/theme_white_color"
/>
<androidx.constraintlayout.widget.ConstraintLayout
android:id=
"@+id/layout_edit_prj_order_number"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"@dimen/dp_10"
android:visibility=
"gone"
android:layout_marginRight=
"@dimen/dp_10"
android:orientation=
"horizontal"
android:paddingTop=
"@dimen/dp_20"
android:paddingBottom=
"@dimen/dp_20"
>
<EditText
android:id=
"@+id/ed_input_order_number"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"@drawable/shape_login_edit_border"
android:hint=
"請輸入訂單號"
android:padding=
"@dimen/dp_10"
app:layout_constraintTop_toTopOf=
"parent"
/>
<ImageView
android:id=
"@+id/iv_search_order_prj"
android:layout_width=
"@dimen/dp_50"
android:layout_height=
"0dp"
android:padding=
"@dimen/dp_8"
android:src=
"@drawable/ic_search"
app:layout_constraintBottom_toBottomOf=
"@id/ed_input_order_number"
app:layout_constraintRight_toRightOf=
"@id/ed_input_order_number"
app:layout_constraintTop_toTopOf=
"@id/ed_input_order_number"
/>
<View
android:layout_width=
"@dimen/dp_0_5"
android:layout_height=
"0dp"
android:background=
"@color/color_aaa"
app:layout_constraintBottom_toBottomOf=
"@id/iv_search_order_prj"
app:layout_constraintRight_toLeftOf=
"@id/iv_search_order_prj"
app:layout_constraintTop_toTopOf=
"@id/iv_search_order_prj"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<LinearLayout
android:id=
"@+id/layout_prj_order_number"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"@dimen/dp_10"
android:layout_marginRight=
"@dimen/dp_10"
android:orientation=
"horizontal"
android:paddingTop=
"@dimen/dp_20"
android:paddingBottom=
"@dimen/dp_20"
android:visibility=
"gone"
>
<TextView
android:id=
"@+id/tv_prj_record_order_number_text"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"訂單號:"
android:textColor=
"@color/theme_333_color"
android:textSize=
"@dimen/dp_18"
android:textStyle=
"bold"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
<TextView
android:id=
"@+id/tv_prj_record_order_id"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textColor=
"@color/theme_333_color"
android:textSize=
"@dimen/dp_18"
app:layout_constraintLeft_toRightOf=
"@id/tv_prj_record_order_number_text"
app:layout_constraintTop_toTopOf=
"parent"
tools:text=
"746932158462315"
/>
</LinearLayout>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"@dimen/dp_10"
android:layout_marginRight=
"@dimen/dp_10"
android:background=
"@color/color_e4"
android:orientation=
"horizontal"
android:paddingLeft=
"@dimen/dp_10"
android:paddingTop=
"@dimen/dp_5"
android:paddingRight=
"@dimen/dp_10"
android:paddingBottom=
"@dimen/dp_5"
>
<TextView
android:layout_width=
"0dp"
android:layout_weight=
"1"
android:layout_height=
"wrap_content"
android:text=
"食品名稱"
android:textColor=
"@color/theme_color"
android:textSize=
"@dimen/dp_16"
/>
<TextView
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:gravity=
"center_horizontal"
android:text=
"打印狀態"
android:textColor=
"@color/theme_color"
android:textSize=
"@dimen/dp_16"
/>
<TextView
android:layout_width=
"0dp"
android:layout_weight=
"0.5"
android:gravity=
"center"
android:layout_height=
"wrap_content"
android:text=
"操作"
android:textColor=
"@color/theme_color"
android:textSize=
"@dimen/dp_16"
/>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rv_prj_record_list"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_marginLeft=
"@dimen/dp_10"
android:layout_marginRight=
"@dimen/dp_10"
/>
</LinearLayout>
\ No newline at end of file
delivery_pick_module/src/main/res/layout/item_prj_state.xml
0 → 100644
View file @
a7b7159a
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
android:paddingLeft=
"@dimen/dp_10"
android:paddingTop=
"@dimen/dp_5"
android:gravity=
"center"
android:paddingRight=
"@dimen/dp_10"
android:paddingBottom=
"@dimen/dp_5"
>
<TextView
android:id=
"@+id/tv_prj_record_food_name"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:textColor=
"@color/theme_333_color"
android:textSize=
"@dimen/dp_16"
tools:text=
"食品名稱一"
/>
<TextView
android:id=
"@+id/tv_prj_record_print_state"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:gravity=
"center"
android:textColor=
"@color/theme_333_color"
android:textSize=
"@dimen/dp_16"
tools:text=
"打印狀態"
/>
<LinearLayout
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"0.5"
android:orientation=
"vertical"
>
<TextView
android:id=
"@+id/tv_prj_record_print_operation"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:background=
"@color/theme_color"
android:gravity=
"right"
android:paddingLeft=
"@dimen/dp_10"
android:paddingTop=
"@dimen/dp_2"
android:paddingRight=
"@dimen/dp_10"
android:paddingBottom=
"@dimen/dp_2"
android:text=
"重印"
android:textColor=
"@color/white"
android:textSize=
"@dimen/dp_16"
/>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
main-module/build.gradle
View file @
a7b7159a
...
...
@@ -55,6 +55,7 @@ dependencies {
// implementation fileTree(include: ['*.jar'], dir: 'libs')
api
project
(
':updateApk'
)
implementation
project
(
path:
':android_internal'
)
annotationProcessor
rootProject
.
ext
.
dependencies
[
"dagger2-compiler"
]
debugImplementation
rootProject
.
ext
.
dependencies
[
"canary-debug"
]
...
...
main-module/src/main/java/com/gingersoft/gsa/cloud/main/mvp/ui/activity/NewMainActivity.java
View file @
a7b7159a
...
...
@@ -256,44 +256,10 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
}
private
void
initFuncationData
()
{
//拿到功能列表數據
// FunctionDaoUtils functionDao = new FunctionDaoUtils(mContext);
// List<Function> functions = functionDao.queryAllFunction();
// if (functions == null) {
// return;
// }
List
<
Function
>
functions
=
new
ArrayList
<>();
// functions.add(new Function((long) 150, 0, 5, "點餐", 0, 0));
// functions.add(new Function((long) 140, 150, 5, "冷鏈接單", R.drawable.ic_pre_order_mode, 0));
//// if (!BuildConfig.DEBUG) {
// functions.add(new Function((long) 150, 0, 5, "點餐", 0, 0));
// if (BuildConfig.DEBUG) {
// functions.add(new Function((long) 138, 150, 5, "餐檯模式", R.drawable.ic_dining_table_mode, 0));
// }
// functions.add(new Function((long) 139, 150, 5, "外送/自取", R.drawable.ic_delivery_mode, 0));
//// functions.add(new Function((long) 140, 150, 5, "外賣模式", R.drawable.ic_outsourcing_model_close, 0));
//// functions.add(new Function((long) 141, 150, 5, "預點餐模式", R.drawable.ic_pre_order_mode_close, 1));
// functions.add(new Function((long) 151, 0, 5, "管理", 0, 0));
// if (BuildConfig.DEBUG) {
// functions.add(new Function((long) 142, 151, 5, "賬單管理", R.drawable.ic_meals_menu_management, 0));
// functions.add(new Function((long) 143, 151, 5, "餐檯管理", R.drawable.ic_dining_table_management, 0));
// }
// functions.add(new Function((long) 144, 151, 5, "打印管理", R.drawable.ic_print_management, 0));
// if (BuildConfig.DEBUG) {
// functions.add(new Function((long) 145, 151, 5, "支付管理", R.drawable.ic_pay_management_close, 1));
// functions.add(new Function((long) 146, 151, 5, "折扣管理", R.drawable.ic_discount_management_close, 1));
// functions.add(new Function((long) 147, 151, 5, "沽清管理", R.drawable.ic_sell_off_manger, 0));
// }
// functions.add(new Function((long) 152, 0, 5, "員工", 0, 0));
// functions.add(new Function((long) 147, 152, 5, "員工管理", R.drawable.ic_staff_management_close, 1));
// functions.add(new Function((long) 148, 152, 5, "權限管理", R.drawable.ic_authority_management_close, 1));
// functions.add(new Function((long) 149, 152, 5, "操作記錄", R.drawable.ic_operation_record_close, 1));
// } else {
List
<
Function
>
orderFuncations
=
FunctionManager
.
getDefault
().
getFunctionByResModule
(
this
,
ComponentMain
.
main
.
class
,
ComponentMain
.
main
.
order
,
"order"
);
if
(
orderFuncations
.
size
()
>
0
)
{
functions
.
addAll
(
orderFuncations
);
List
<
Function
>
orderFunctions
=
FunctionManager
.
getDefault
().
getFunctionByResModule
(
this
,
ComponentMain
.
main
.
class
,
ComponentMain
.
main
.
order
,
"order"
);
if
(
orderFunctions
.
size
()
>
0
)
{
functions
.
addAll
(
orderFunctions
);
sl_order
.
setVisibility
(
View
.
VISIBLE
);
}
else
{
sl_order
.
setVisibility
(
View
.
INVISIBLE
);
...
...
@@ -303,6 +269,7 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
managerFuncations
.
add
(
new
Function
((
long
)
171
,
163
,
5
,
"二維碼"
,
R
.
drawable
.
ic_authority_management_close
,
0
));
managerFuncations
.
add
(
new
Function
((
long
)
171
,
163
,
5
,
"配置列表"
,
R
.
drawable
.
ic_authority_management_close
,
0
));
managerFuncations
.
add
(
new
Function
((
long
)
171
,
163
,
5
,
"廚房打印查詢"
,
R
.
drawable
.
ic_authority_management_close
,
0
));
if
(
managerFuncations
.
size
()
>
0
)
{
functions
.
addAll
(
managerFuncations
);
...
...
@@ -337,7 +304,7 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
}
}
}
if
(
orderFunc
a
tions
.
size
()
>
0
)
{
if
(
orderFunctions
.
size
()
>
0
)
{
initAdapter
(
parents
,
funMap
,
0
,
R
.
layout
.
main_home_funcation_item
,
rvOrdering
,
4
);
}
if
(
managerFuncations
.
size
()
>
0
)
{
...
...
@@ -365,53 +332,65 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
}
private
void
functionClick
(
String
name
,
int
status
)
{
// switch (status) {
// case STATUS_NONACTIVATED:
// ToastUtils.show(mContext, "服務暫未開通,請前往開通");
// return;
// case STATUS_TIME_LIMIT:
// ToastUtils.show(mContext, "服務已到期,請前往續費");
// return;
// }
if
(
name
.
equals
(
"餐檯模式"
))
{
CC
.
obtainBuilder
(
"Component.Table"
)
.
setActionName
(
"showTableActivity"
)
.
build
()
.
call
();
}
else
if
(
name
.
equals
(
"打印管理"
))
{
CC
.
obtainBuilder
(
"Component.Print"
)
.
setActionName
(
"showPrintActivity"
)
.
build
()
.
call
();
}
else
if
(
name
.
equals
(
"賬單管理"
))
{
CC
.
obtainBuilder
(
"Component.Table"
)
.
setActionName
(
"showOrderCenterActivity"
)
.
build
()
.
call
();
}
else
if
(
name
.
equals
(
"外送/自取"
))
{
CC
.
obtainBuilder
(
"ComponentDeliveryPick"
)
.
setActionName
(
"orderActivity"
)
.
build
()
.
call
();
}
else
if
(
name
.
equals
(
"沽清管理"
))
{
CC
.
obtainBuilder
(
"Component.Table"
)
.
setActionName
(
"showSoldoutCtrlActivity"
)
.
build
()
.
call
();
}
else
if
(
name
.
equals
(
"餐檯管理"
))
{
CC
.
obtainBuilder
(
"Component.Manager"
)
.
setActionName
(
"showTableManageActivity"
)
.
build
()
.
call
();
}
else
if
(
name
.
equals
(
"冷鏈接單"
)
||
name
.
equals
(
"凍鏈接單"
))
{
CC
.
obtainBuilder
(
"Component.ColdChain"
)
.
setActionName
(
"Component.ColdChain"
)
.
build
()
.
call
();
}
else
if
(
name
.
equals
(
"二維碼"
))
{
launchActivity
(
new
Intent
(
mContext
,
RestaurantQrCodeActivity
.
class
));
}
else
if
(
name
.
equals
(
"配置列表"
))
{
launchActivity
(
new
Intent
(
mContext
,
ExpandListActivity
.
class
));
switch
(
name
){
case
"餐檯模式"
:
CC
.
obtainBuilder
(
"Component.Table"
)
.
setActionName
(
"showTableActivity"
)
.
build
()
.
call
();
break
;
case
"打印管理"
:
CC
.
obtainBuilder
(
"Component.Print"
)
.
setActionName
(
"showPrintActivity"
)
.
build
()
.
call
();
break
;
case
"賬單管理"
:
CC
.
obtainBuilder
(
"Component.Table"
)
.
setActionName
(
"showOrderCenterActivity"
)
.
build
()
.
call
();
break
;
case
"外送/自取"
:
CC
.
obtainBuilder
(
"ComponentDeliveryPick"
)
.
setActionName
(
"orderActivity"
)
.
build
()
.
call
();
break
;
case
"沽清管理"
:
CC
.
obtainBuilder
(
"Component.Table"
)
.
setActionName
(
"showSoldoutCtrlActivity"
)
.
build
()
.
call
();
break
;
case
"餐檯管理"
:
CC
.
obtainBuilder
(
"Component.Manager"
)
.
setActionName
(
"showTableManageActivity"
)
.
build
()
.
call
();
break
;
case
"冷鏈接單"
:
case
"凍鏈接單"
:
CC
.
obtainBuilder
(
"Component.ColdChain"
)
.
setActionName
(
"Component.ColdChain"
)
.
build
()
.
call
();
break
;
case
"二維碼"
:
launchActivity
(
new
Intent
(
mContext
,
RestaurantQrCodeActivity
.
class
));
break
;
case
"配置列表"
:
launchActivity
(
new
Intent
(
mContext
,
ExpandListActivity
.
class
));
break
;
case
"廚房打印查詢"
:
CC
.
obtainBuilder
(
"ComponentDeliveryPick"
)
.
setActionName
(
"PrjQueryActivity"
)
.
build
()
.
call
();
break
;
default
:
break
;
}
}
...
...
main-module/src/main/java/com/gingersoft/gsa/cloud/main/mvp/ui/adapter/ExpandListAdapter.java
View file @
a7b7159a
...
...
@@ -8,7 +8,7 @@ import android.widget.EditText;
import
android.widget.Switch
;
import
android.widget.TextView
;
import
com.bigkoo.pickerview.
TimePickerView
;
import
com.bigkoo.pickerview.
builder.TimePickerBuilder
;
import
com.chad.library.adapter.base.BaseQuickAdapter
;
import
com.chad.library.adapter.base.viewholder.BaseViewHolder
;
import
com.gingersoft.gsa.cloud.base.utils.other.TextUtil
;
...
...
@@ -83,13 +83,13 @@ public class ExpandListAdapter extends BaseQuickAdapter<ExpandInfo, BaseViewHold
//Sep 11, 2020 6:10:42 PM
tvTime
.
setOnClickListener
(
v
->
{
//时间选择器
new
TimePicker
View
.
Builder
(
getContext
(),
(
date
,
view
)
->
{
new
TimePickerBuilder
(
getContext
(),
(
date
,
view
)
->
{
tvTime
.
setText
(
TimeUtils
.
parseDateToString
(
date
,
TimeUtils
.
DATE_FORMAT_DATE
));
function
.
setUpdate
(
true
);
})
.
setDate
(
calendar
)
.
setType
(
TimePickerView
.
Type
.
YEAR_MONTH_DAY
)
.
setContentSize
(
24
)
.
setType
(
new
boolean
[]{
true
,
true
,
true
,
false
,
false
,
false
}
)
.
setContent
Text
Size
(
24
)
.
setLabel
(
""
,
""
,
""
,
""
,
""
,
""
)
.
build
()
.
show
();
...
...
print-module/src/main/java/com/joe/print/mvp/model/bean/PrintInfoBean.java
View file @
a7b7159a
...
...
@@ -9,6 +9,7 @@ import com.gingersoft.gsa.cloud.base.utils.time.TimeUtils;
import
com.gingersoft.gsa.cloud.database.bean.PrintCurrencyBean
;
import
com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean
;
import
com.gingersoft.gsa.cloud.print.bean.OrderDetails
;
import
com.gingersoft.gsa.cloud.print.bean.PrjBean
;
import
com.joe.print.R
;
import
com.joe.print.mvp.print.utils.MyPrintUtils
;
...
...
print-module/src/main/java/com/joe/print/mvp/model/bean/PrjBean.java
deleted
100644 → 0
View file @
d56efe83
package
com
.
joe
.
print
.
mvp
.
model
.
bean
;
import
java.util.List
;
import
java.util.Map
;
public
class
PrjBean
{
/**
* success : true
* sysTime : 1589177793623
* data : {"-1":[{"id":1,"printerDeviceId":-1,"status":1,"tableName":"51536","orderNo":"gs201351936242891","orderTime":2020,"person":2,"orderDetailsTime":"May 7, 2020 6:47:16 PM","orderDetailsId":48827589,"productName":"炸鸡翅","parentId":0,"type":3},{"id":2,"printerDeviceId":-1,"status":1,"tableName":"51536","orderNo":"gs201351936242891","orderTime":2020,"person":2,"orderDetailsTime":"May 7, 2020 6:47:16 PM","orderDetailsId":48827590,"productName":"鮮茄汁藍青口","parentId":0,"type":3}],"k1":[{"id":77,"printerDeviceId":1,"status":1,"tableName":"51536","orderNo":"gs201351936242891","orderTime":2020,"person":2,"orderDetailsTime":"May 11, 2020 11:41:41 AM","orderDetailsId":48828004,"productName":"走青檸測試","parentId":48827589,"type":4},{"id":78,"printerDeviceId":1,"status":1,"tableName":"51536","orderNo":"gs201351936242891","orderTime":2020,"person":2,"orderDetailsTime":"May 11, 2020 11:41:41 AM","orderDetailsId":48828005,"productName":"走豆測試","parentId":48827590,"type":4},{"id":79,"printerDeviceId":1,"status":1,"tableName":"51536","orderNo":"gs201351936242891","orderTime":2020,"person":2,"orderDetailsTime":"May 11, 2020 11:41:41 AM","orderDetailsId":48828006,"productName":"精選牛肉","parentId":0,"type":3},{"id":80,"printerDeviceId":1,"status":1,"tableName":"51536","orderNo":"gs201351936242891","orderTime":2020,"person":2,"orderDetailsTime":"May 11, 2020 11:41:41 AM","orderDetailsId":48828007,"productName":"走豆測試","parentId":48828006,"type":4},{"id":81,"printerDeviceId":1,"status":1,"tableName":"51536","orderNo":"gs201351936242891","orderTime":2020,"person":2,"orderDetailsTime":"May 11, 2020 11:41:41 AM","orderDetailsId":48828008,"productName":"雞飯(四客)","parentId":48828006,"type":3},{"id":82,"printerDeviceId":1,"status":1,"tableName":"51536","orderNo":"gs201351936242891","orderTime":2020,"person":2,"orderDetailsTime":"May 11, 2020 11:41:41 AM","orderDetailsId":48828009,"productName":"精選牛肉","parentId":48828006,"type":3}]}
*/
private
boolean
success
;
private
long
sysTime
;
private
String
data
;
public
boolean
isSuccess
()
{
return
success
;
}
public
void
setSuccess
(
boolean
success
)
{
this
.
success
=
success
;
}
public
long
getSysTime
()
{
return
sysTime
;
}
public
void
setSysTime
(
long
sysTime
)
{
this
.
sysTime
=
sysTime
;
}
public
String
getData
()
{
return
data
;
}
public
void
setData
(
String
data
)
{
this
.
data
=
data
;
}
public
static
class
DataBean
{
public
Map
<
String
,
List
<
Bean
>>
prjMap
;
public
static
class
Bean
{
/**
* id : 77
* printerDeviceId : 1
* status : 1
* tableName : 51536
* orderNo : gs201351936242891
* orderTime : 2020
* person : 2
* orderDetailsTime : May 11, 2020 11:41:41 AM
* orderDetailsId : 48828004
* productName : 走青檸測試
* parentId : 48827589
* type : 4
*/
private
int
id
;
private
int
printerDeviceId
;
private
int
status
;
//為2是帶*,需要切紙的
private
String
tableName
;
private
String
orderNo
;
private
int
orderTime
;
private
int
person
;
private
String
orderDetailsTime
;
private
int
orderDetailsId
;
private
String
productName
;
private
String
productName2
;
private
String
productName3
;
private
int
parentId
;
private
int
type
;
private
int
printerType
;
private
Long
printerTime
;
private
int
number
;
private
String
productId
;
private
Long
createTime
;
private
int
requests
;
private
int
actualPrinterDeviceId
;
private
String
takeFoodCode
;
//取餐碼
private
String
billNo
;
//訂單碼
private
int
orderType
;
//訂單類型
private
String
userName
;
/***
* 層級
* 1:主食品
* 2:子項or細項
* 3:細項
*/
private
int
itemType
;
private
String
sender
;
private
String
takeTime
;
private
String
sendTime
;
private
int
currentIndex
;
//當前是第幾張prj
private
int
totalPrj
;
//本次總共有多少張prj
private
int
isFirstSendOrder
;
//是否首次送單,1是 2否
private
int
quantity
;
//統計打印數量
public
int
getId
()
{
return
id
;
}
public
void
setId
(
int
id
)
{
this
.
id
=
id
;
}
public
int
getPrinterDeviceId
()
{
return
printerDeviceId
;
}
public
void
setPrinterDeviceId
(
int
printerDeviceId
)
{
this
.
printerDeviceId
=
printerDeviceId
;
}
public
int
getStatus
()
{
return
status
;
}
public
void
setStatus
(
int
status
)
{
this
.
status
=
status
;
}
public
String
getTableName
()
{
return
tableName
;
}
public
void
setTableName
(
String
tableName
)
{
this
.
tableName
=
tableName
;
}
public
String
getOrderNo
()
{
return
orderNo
;
}
public
void
setOrderNo
(
String
orderNo
)
{
this
.
orderNo
=
orderNo
;
}
public
int
getOrderTime
()
{
return
orderTime
;
}
public
void
setOrderTime
(
int
orderTime
)
{
this
.
orderTime
=
orderTime
;
}
public
int
getPerson
()
{
return
person
;
}
public
void
setPerson
(
int
person
)
{
this
.
person
=
person
;
}
public
String
getOrderDetailsTime
()
{
return
orderDetailsTime
;
}
public
void
setOrderDetailsTime
(
String
orderDetailsTime
)
{
this
.
orderDetailsTime
=
orderDetailsTime
;
}
public
int
getOrderDetailsId
()
{
return
orderDetailsId
;
}
public
void
setOrderDetailsId
(
int
orderDetailsId
)
{
this
.
orderDetailsId
=
orderDetailsId
;
}
public
String
getProductName
()
{
return
productName
;
}
public
void
setProductName
(
String
productName
)
{
this
.
productName
=
productName
;
}
public
String
getProductName2
()
{
return
productName2
;
}
public
void
setProductName2
(
String
productName2
)
{
this
.
productName2
=
productName2
;
}
public
String
getProductName3
()
{
return
productName3
;
}
public
void
setProductName3
(
String
productName3
)
{
this
.
productName3
=
productName3
;
}
public
int
getParentId
()
{
return
parentId
;
}
public
void
setParentId
(
int
parentId
)
{
this
.
parentId
=
parentId
;
}
public
int
getType
()
{
return
type
;
}
public
void
setType
(
int
type
)
{
this
.
type
=
type
;
}
public
int
getItemType
()
{
return
itemType
;
}
public
void
setItemType
(
int
itemType
)
{
this
.
itemType
=
itemType
;
}
public
int
getPrinterType
()
{
return
printerType
;
}
public
void
setPrinterType
(
int
printerType
)
{
this
.
printerType
=
printerType
;
}
public
Long
getPrinterTime
()
{
return
printerTime
;
}
public
void
setPrinterTime
(
Long
printerTime
)
{
this
.
printerTime
=
printerTime
;
}
public
int
getNumber
()
{
return
number
;
}
public
void
setNumber
(
int
number
)
{
this
.
number
=
number
;
}
public
String
getProductId
()
{
return
productId
;
}
public
void
setProductId
(
String
productId
)
{
this
.
productId
=
productId
;
}
public
Long
getCreateTime
()
{
return
createTime
;
}
public
void
setCreateTime
(
Long
createTime
)
{
this
.
createTime
=
createTime
;
}
public
int
getRequests
()
{
return
requests
;
}
public
void
setRequests
(
int
requests
)
{
this
.
requests
=
requests
;
}
public
int
getActualPrinterDeviceId
()
{
return
actualPrinterDeviceId
;
}
public
void
setActualPrinterDeviceId
(
int
actualPrinterDeviceId
)
{
this
.
actualPrinterDeviceId
=
actualPrinterDeviceId
;
}
public
String
getTakeFoodCode
()
{
return
takeFoodCode
;
}
public
void
setTakeFoodCode
(
String
takeFoodCode
)
{
this
.
takeFoodCode
=
takeFoodCode
;
}
public
String
getBillNo
()
{
return
billNo
;
}
public
void
setBillNo
(
String
billNo
)
{
this
.
billNo
=
billNo
;
}
public
int
getOrderType
()
{
return
orderType
;
}
public
void
setOrderType
(
int
orderType
)
{
this
.
orderType
=
orderType
;
}
public
String
getSender
()
{
return
sender
;
}
public
void
setSender
(
String
sender
)
{
this
.
sender
=
sender
;
}
public
String
getUserName
()
{
return
userName
;
}
public
void
setUserName
(
String
userName
)
{
this
.
userName
=
userName
;
}
public
String
getTakeTime
()
{
return
takeTime
;
}
public
void
setTakeTime
(
String
takeTime
)
{
this
.
takeTime
=
takeTime
;
}
public
String
getSendTime
()
{
return
sendTime
;
}
public
void
setSendTime
(
String
sendTime
)
{
this
.
sendTime
=
sendTime
;
}
public
int
getCurrentIndex
()
{
return
currentIndex
;
}
public
void
setCurrentIndex
(
int
currentIndex
)
{
this
.
currentIndex
=
currentIndex
;
}
public
int
getTotalPrj
()
{
return
totalPrj
;
}
public
void
setTotalPrj
(
int
totalPrj
)
{
this
.
totalPrj
=
totalPrj
;
}
public
int
getIsFirstSendOrder
()
{
return
isFirstSendOrder
;
}
public
void
setIsFirstSendOrder
(
int
isFirstSendOrder
)
{
this
.
isFirstSendOrder
=
isFirstSendOrder
;
}
public
int
getQuantity
()
{
return
quantity
;
}
public
void
setQuantity
(
int
quantity
)
{
this
.
quantity
=
quantity
;
}
}
public
Map
<
String
,
List
<
Bean
>>
getPrjMap
()
{
return
prjMap
;
}
public
void
setPrjMap
(
Map
<
String
,
List
<
Bean
>>
prjMap
)
{
this
.
prjMap
=
prjMap
;
}
}
}
print-module/src/main/java/com/joe/print/mvp/print/PrintPrjKitchen.java
View file @
a7b7159a
...
...
@@ -15,7 +15,7 @@ import com.gingersoft.gsa.cloud.base.utils.time.TimeUtils;
import
com.gingersoft.gsa.cloud.constans.ExpandConstant
;
import
com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean
;
import
com.joe.print.R
;
import
com.
joe.print.mvp.model
.bean.PrjBean
;
import
com.
gingersoft.gsa.cloud.print
.bean.PrjBean
;
import
com.joe.print.mvp.ui.adapter.KitChenPrjPrintFoodAdapter
;
import
java.util.ArrayList
;
...
...
@@ -50,6 +50,7 @@ public class PrintPrjKitchen extends PrinterRoot {
noCut
.
add
(
bean
);
}
}
if
(
noCut
.
size
()
>
0
)
{
Bitmap
bitmap
=
getKitChenPrintBitmap
(
mContext
,
key
,
noCut
,
deviceBean
);
bitmaps
.
add
(
bitmap
);
...
...
print-module/src/main/java/com/joe/print/mvp/print/service/PrjService.java
View file @
a7b7159a
...
...
@@ -33,7 +33,7 @@ import com.gingersoft.gsa.cloud.print.PrinterWriter58mm;
import
com.hyweb.n5.lib.constant.PrinterConstant
;
import
com.hyweb.n5.lib.util.PrinterUtil
;
import
com.hyweb.n5.server.aidl.IOnPrintCallback
;
import
com.
joe.print.mvp.model
.bean.PrjBean
;
import
com.
gingersoft.gsa.cloud.print
.bean.PrjBean
;
import
com.joe.print.mvp.print.PrintPrjKitchen
;
import
com.joe.print.mvp.print.PrinterRoot
;
import
com.joe.print.mvp.print.common.PrinterFinderCallback
;
...
...
print-module/src/main/java/com/joe/print/mvp/ui/activity/PrintActivity.java
View file @
a7b7159a
...
...
@@ -35,6 +35,7 @@ import com.gingersoft.gsa.cloud.database.bean.PrintCurrencyBean;
import
com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean
;
import
com.gingersoft.gsa.cloud.print.PrintExecutor
;
import
com.gingersoft.gsa.cloud.print.PrintSocketHolder
;
import
com.gingersoft.gsa.cloud.print.bean.PrjBean
;
import
com.jess.arms.base.BaseActivity
;
import
com.jess.arms.di.component.AppComponent
;
import
com.jess.arms.utils.ArmsUtils
;
...
...
@@ -45,6 +46,7 @@ import com.joe.print.mvp.presenter.PrintPresenter;
import
com.joe.print.mvp.print.OpenCashBoxMaker
;
import
com.joe.print.mvp.print.PrintInstruction
;
import
com.joe.print.mvp.print.PrintListener
;
import
com.joe.print.mvp.print.PrintPrjKitchen
;
import
com.joe.print.mvp.print.PrinterRoot
;
import
com.joe.print.mvp.print.utils.MyPrintUtils
;
import
com.joe.print.mvp.ui.adapter.DialogPrinterListAdapter
;
...
...
@@ -123,11 +125,8 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
return
0
;
//R.layout.print_bitmap如果你不需要框架帮你设置 setContentView(id) 需要 自行设置,请返回 0
}
// ImageView bitmapIv;
@Override
public
void
initData
(
@Nullable
Bundle
savedInstanceState
)
{
// bitmapIv = findViewById(R.id.iv_bitmap);
callId
=
CCUtil
.
getNavigateCallId
(
this
);
//獲取打印類型,根據打印類型生成對應的bitmap
type
=
CCUtil
.
getNavigateParam
(
this
,
PRINT_TYPE
,
PrintConstans
.
PRINT_TEST
);
...
...
@@ -138,21 +137,13 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
printerInIt
.
setPrintListener
(
this
);
}
initPrintConfig
();
// new Thread(new Runnable() {
// @Override
// public void run() {
// Handler handler = new Handler(Looper.getMainLooper());
// handler.sendMessage()
// }
// });
}
private
int
selectPrint
=
-
1
;
private
void
initPrintConfig
()
{
PrintCurrencyBean
printCurrencyBean
=
null
;
PrinterDeviceBean
defaultPrint
;
PrinterDeviceBean
defaultPrint
=
null
;
//獲取通用打印配置,不同的打印
if
(
type
==
5
||
type
==
7
)
{
//外賣的通用打印配置
...
...
@@ -175,6 +166,13 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
// 如果沒有最近使用的打印機,並且當前餐廳只有一台打印機,就用這一台打印機打印
defaultPrint
=
mPresenter
.
getDefaultPrintInList
(
printerDeviceBeans
,
(
String
)
SPUtils
.
get
(
mContext
,
"defaultPrint"
,
""
));
}
if
(
type
==
PrintConstans
.
PRINT_KITCHEN
)
{
// List<PrjBean.DataBean.Bean> printDatas = (List<PrjBean.DataBean.Bean>) getIntent().getSerializableExtra("prjBeans");
List
<
PrjBean
.
DataBean
.
Bean
>
printDatas
=
CCUtil
.
getNavigateParam
(
this
,
"prjBeans"
,
null
);
Map
<
String
,
List
<
PrjBean
.
DataBean
.
Bean
>>
prjMap
=
PrintPrjKitchen
.
getPrjMap
();
prjMap
.
put
(
""
,
printDatas
);
}
if
(
defaultPrint
==
null
)
{
//沒有默認打印機,查看當前餐廳有沒有打印機
//如果當前餐廳有打印機,彈出彈窗讓用戶選擇一個打印機打印
...
...
print-module/src/main/java/com/joe/print/mvp/ui/activity/PrintTestActivity.java
View file @
a7b7159a
...
...
@@ -3,7 +3,6 @@ package com.joe.print.mvp.ui.activity;
import
android.annotation.SuppressLint
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.widget.EditText
;
import
androidx.appcompat.app.AppCompatActivity
;
...
...
@@ -11,8 +10,7 @@ import com.epson.epos2.printer.Printer;
import
com.epson.epos2.printer.PrinterStatusInfo
;
import
com.epson.epos2.printer.ReceiveListener
;
import
com.gingersoft.gsa.cloud.base.order.bean.OrderDetail
;
import
com.gingersoft.gsa.cloud.base.utils.okhttpUtils.OkHttp3Utils
;
import
com.gingersoft.gsa.cloud.base.utils.time.TimeUtils
;
import
com.gingersoft.gsa.cloud.base.utils.time.TimePickerUtils
;
import
com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils
;
import
com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean
;
import
com.gingersoft.gsa.cloud.print.PrintExecutor
;
...
...
@@ -22,15 +20,12 @@ import com.joe.print.mvp.print.common.PrinterFinderCallback;
import
com.joe.print.mvp.print.common.SendCallback
;
import
com.joe.print.mvp.print.common.SendResultCode
;
import
com.joe.print.mvp.print.usb.UsbPrinter
;
import
com.joe.print.mvp.print.usb.UsbPrinterFinder
;
import
java.nio.charset.Charset
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.List
;
import
io.reactivex.Observer
;
import
io.reactivex.disposables.Disposable
;
public
class
PrintTestActivity
extends
AppCompatActivity
implements
PrintSocketHolder
.
OnStateChangedListener
,
PrintExecutor
.
OnPrintResultListener
,
ReceiveListener
{
private
int
lineLength
=
42
;
//一行42個 17.5
...
...
@@ -176,43 +171,48 @@ public class PrintTestActivity extends AppCompatActivity implements PrintSocketH
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_print_test
);
EditText
ed_ip
=
findViewById
(
R
.
id
.
ed_ip
);
UsbPrinterFinder
printerFinder
=
new
UsbPrinterFinder
(
this
,
printerFinderCallback
);
printerFinder
.
startFinder
();
List
<
OrderDetail
>
foodList
=
new
ArrayList
<>();
foodList
.
add
(
new
OrderDetail
(
"牛肉拉麵"
,
10
,
1
));
foodList
.
add
(
new
OrderDetail
(
"紅燒牛肉拉麵"
,
200
,
2
));
findViewById
(
R
.
id
.
btn_test
).
setOnClickListener
(
view
->
{
//打印測試
String
stringBuilder
=
"<html><body>"
+
getPLable
(
"GingerSoft"
)
+
getPLable
(
"Gs1"
)
+
getPLable
(
"開檯時間:"
+
TimeUtils
.
getCurrentTimeInString
(
TimeUtils
.
DEFAULT_DATE_FORMAT
))
+
getPLable
(
getLineChar
(
lineLength
,
"_"
))
+
getPLable
(
getFoodListStr
(
foodList
))
+
"</body></html>"
;
OkHttp3Utils
.
get
(
"http://localhost:8080/pos?transactionType=PRINT&isExternal=false&apiVersion=21&printData="
+
stringBuilder
).
subscribe
(
new
Observer
<
String
>()
{
@Override
public
void
onSubscribe
(
Disposable
d
)
{
}
@Override
public
void
onNext
(
String
s
)
{
}
@Override
public
void
onError
(
Throwable
e
)
{
}
@Override
public
void
onComplete
()
{
}
});
// EditText ed_ip = findViewById(R.id.ed_ip);
// UsbPrinterFinder printerFinder = new UsbPrinterFinder(this, printerFinderCallback);
// printerFinder.startFinder();
//
// List<OrderDetail> foodList = new ArrayList<>();
// foodList.add(new OrderDetail("牛肉拉麵", 10, 1));
// foodList.add(new OrderDetail("紅燒牛肉拉麵", 200, 2));
//
// findViewById(R.id.btn_test).setOnClickListener(view -> {
// //打印測試
// String stringBuilder = "<html><body>" +
// getPLable("GingerSoft") +
// getPLable("Gs1") +
// getPLable("開檯時間:" + TimeUtils.getCurrentTimeInString(TimeUtils.DEFAULT_DATE_FORMAT)) +
// getPLable(getLineChar(lineLength, "_")) +
// getPLable(getFoodListStr(foodList)) +
// "</body></html>";
// OkHttp3Utils.get("http://localhost:8080/pos?transactionType=PRINT&isExternal=false&apiVersion=21&printData=" + stringBuilder).subscribe(new Observer<String>() {
// @Override
// public void onSubscribe(Disposable d) {
//
// }
//
// @Override
// public void onNext(String s) {
// }
//
// @Override
// public void onError(Throwable e) {
//
// }
//
// @Override
// public void onComplete() {
//
// }
// });
// });
TimePickerUtils
.
showTimePicker
(
this
,
null
,
(
date
,
v1
)
->
{
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
date
);
});
}
...
...
print-module/src/main/java/com/joe/print/mvp/ui/adapter/KitChenPrjPrintFoodAdapter.java
View file @
a7b7159a
...
...
@@ -12,7 +12,7 @@ import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import
com.gingersoft.gsa.cloud.base.R
;
import
com.gingersoft.gsa.cloud.base.utils.other.TextUtil
;
import
com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean
;
import
com.
joe.print.mvp.model
.bean.PrjBean
;
import
com.
gingersoft.gsa.cloud.print
.bean.PrjBean
;
import
java.math.BigDecimal
;
import
java.util.List
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment