Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
RvApp
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lify
RvApp
Commits
84e5c9a2
Commit
84e5c9a2
authored
Oct 29, 2019
by
jianglx
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://113.105.137.151:22280/lify/rvapp
into dev_im
parents
d0c3418d
767904ad
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
161 additions
and
47 deletions
+161
-47
DateUtils.java
...utils/src/main/java/com/rv/component/utils/DateUtils.java
+57
-14
CarRentalListActivity.java
...rv/home/rv/module/ui/main/home/CarRentalListActivity.java
+25
-4
HomeFragment.java
...java/com/rv/home/rv/module/ui/main/home/HomeFragment.java
+59
-10
CalendarActivity.java
...rc/main/java/com/rv/plugin/calendar/CalendarActivity.java
+17
-16
activity_calendar2.xml
plugin_calendar/src/main/res/layout/activity_calendar2.xml
+3
-3
No files found.
component_utils/src/main/java/com/rv/component/utils/DateUtils.java
View file @
84e5c9a2
...
...
@@ -241,9 +241,9 @@ public class DateUtils {
* @return 失败返回-1 ,所以尽量是datetime1大于datetime2
*/
public
static
long
compareDateSecond2
(
String
datetime1
,
String
datetime2
)
{
String
date1
=
formatDate7
(
datetime1
);
String
date2
=
formatDate7
(
datetime2
);
return
compareDateSecond
(
date1
,
date2
);
String
date1
=
formatDate7
(
datetime1
);
String
date2
=
formatDate7
(
datetime2
);
return
compareDateSecond
(
date1
,
date2
);
}
/**
...
...
@@ -264,6 +264,24 @@ public class DateUtils {
}
}
/**
* 比较两个时间相差多少秒 datetime1-datetime2
*
* @param datetime1 yyyy-MM-dd HH:mm
* @param datetime2 yyyy-MM-dd HH:mm
* @return 失败返回-1 ,所以尽量是datetime1大于datetime2
*/
public
static
long
compareDateSecond3
(
String
datetime1
,
String
datetime2
)
{
try
{
Date
date1
=
sdf7
.
parse
(
datetime1
);
Date
date2
=
sdf7
.
parse
(
datetime2
);
return
compareDateSecond
(
date1
.
getTime
(),
date2
.
getTime
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
-
1
;
}
}
/**
* 比较两个时间相差多少秒 datetime1-datetime2
*
...
...
@@ -430,6 +448,7 @@ public class DateUtils {
/**
* yyyy-MM 转化成 yyyy年MM月
*
* @param dateStr yyyy-MM
* @return yyyy年MM月
*/
...
...
@@ -567,6 +586,31 @@ public class DateUtils {
return
day
;
}
/**
* 给时间加上几个小时
*
* @param dateStr 当前时间 格式:yyyy-MM-dd HH:mm
* @param hour 需要加的时间
* @return
*/
public
static
String
formatDate28
(
String
dateStr
,
int
hour
)
{
Date
date
=
null
;
try
{
date
=
sdf7
.
parse
(
dateStr
);
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
}
if
(
date
==
null
)
return
""
;
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
setTime
(
date
);
cal
.
add
(
Calendar
.
HOUR
,
hour
);
// 24小时制
date
=
cal
.
getTime
();
cal
=
null
;
return
sdf7
.
format
(
date
);
}
/**
* 将yyyy-MM-dd HH:mm格式成yy-MM-dd HH:mm
...
...
@@ -593,7 +637,7 @@ public class DateUtils {
String
day
=
""
;
try
{
long
time
=
sdf12
.
parse
(
dateStr
).
getTime
();
time
+=
30
*
60
*
1000
;
time
+=
30
*
60
*
1000
;
Date
da
=
new
Date
(
time
);
day
=
sdf12
.
format
(
da
);
}
catch
(
Exception
e
)
{
...
...
@@ -609,7 +653,7 @@ public class DateUtils {
String
day
=
""
;
try
{
long
time
=
sdf12
.
parse
(
dateStr
).
getTime
();
time
-=
30
*
60
*
1000
;
time
-=
30
*
60
*
1000
;
Date
da
=
new
Date
(
time
);
day
=
sdf12
.
format
(
da
);
}
catch
(
Exception
e
)
{
...
...
@@ -619,12 +663,11 @@ public class DateUtils {
}
/**
* 把时分转成毫秒
*/
public
static
long
formatDate20
(
String
dateStr
)
{
long
time
=
0
;
long
time
=
0
;
try
{
time
=
sdf12
.
parse
(
dateStr
).
getTime
();
}
catch
(
Exception
e
)
{
...
...
@@ -806,7 +849,6 @@ public class DateUtils {
}
/**
* 获取网络时间
*
...
...
@@ -834,13 +876,14 @@ public class DateUtils {
/**
* 获取手机当前时间yyMMddHHmmss
*
* @return
*/
public
static
String
getPhoneCurTime
(){
String
timeStr
=
""
;
public
static
String
getPhoneCurTime
()
{
String
timeStr
=
""
;
try
{
Date
date
=
new
Date
(
System
.
currentTimeMillis
());
timeStr
=
sdf3
.
format
(
date
);
Date
date
=
new
Date
(
System
.
currentTimeMillis
());
timeStr
=
sdf3
.
format
(
date
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
...
...
module_home/src/main/java/com/rv/home/rv/module/ui/main/home/CarRentalListActivity.java
View file @
84e5c9a2
...
...
@@ -157,13 +157,13 @@ public class CarRentalListActivity extends BaseStatusActivity<CommonPresenter> i
onFresh
();
}
@Override
public
void
onShowResult
(
int
requestType
,
BaseBean
result
)
{
mSimpleRefreshLayout
.
onRefreshComplete
();
switch
(
requestType
)
{
case
0
:
initData
((
CarAttributeListBean
)
result
);
break
;
case
1
:
processData
((
CarTypeListBean
)
result
);
...
...
@@ -273,8 +273,8 @@ public class CarRentalListActivity extends BaseStatusActivity<CommonPresenter> i
map
.
put
(
"lat"
,
mLat
);
map
.
put
(
"lon"
,
mLon
);
map
.
put
(
"parkBranchCompanyId"
,
dataBean
.
getStartCompanyId
());
map
.
put
(
"startCompanyId"
,
dataBean
.
getStartCompanyId
());
map
.
put
(
"endCompanyId"
,
dataBean
.
getEndCompanyId
());
map
.
put
(
"startCompanyId"
,
dataBean
.
getStartCompanyId
());
map
.
put
(
"endCompanyId"
,
dataBean
.
getEndCompanyId
());
try
{
map
.
put
(
"startDateTamp"
,
TimeManager
.
dateToStamp
(
begDate
));
map
.
put
(
"endDateTamp"
,
TimeManager
.
dateToStamp
(
endDate
));
...
...
@@ -437,7 +437,7 @@ public class CarRentalListActivity extends BaseStatusActivity<CommonPresenter> i
if
(
resultCode
==
200
&&
requestCode
==
109
)
{
begDate
=
data
.
getStringExtra
(
"begDate"
);
endDate
=
data
.
getStringExtra
(
"endDate"
);
copyDay
=
DateUtils
.
compareDateDay
(
endDate
,
begDate
)
+
1
;
copyDay
=
getCountDay
(
begDate
,
endDate
);
//天数
tvGetDate
.
setText
(
"取"
+
DateUtils
.
formatDate66
(
begDate
));
tvOutDate
.
setText
(
"还"
+
DateUtils
.
formatDate66
(
endDate
));
dataBean
.
setDayNum
(
Integer
.
valueOf
(
copyDay
+
""
));
...
...
@@ -459,6 +459,27 @@ public class CarRentalListActivity extends BaseStatusActivity<CommonPresenter> i
}
}
/**
* 计算天数
*
* @param endDate2
* @param begDate2
* @return
*/
private
long
getCountDay
(
String
begDate2
,
String
endDate2
)
{
long
second
=
DateUtils
.
compareDateSecond3
(
endDate2
,
begDate2
);
//两个时间相差的秒数
long
day
=
(
long
)
second
/
86400
;
//天数
long
remainder
=
(
long
)
second
%
86400
;
//余数 秒
if
(
day
==
0
)
{
//不够24小时也算一天
day
=
day
+
1
;
}
else
if
(
remainder
>
14400
)
{
//4小时内天数不增加,否则加一
day
=
day
+
1
;
}
return
day
;
}
private
void
setRequestData
(
int
type
,
String
requestData
,
double
lat
,
double
lon
,
String
compangy
,
int
cityId
,
int
companyId
,
String
cityName
)
{
if
(
type
==
1
)
{
tvGetAddress
.
setText
(
compangy
);
...
...
module_home/src/main/java/com/rv/home/rv/module/ui/main/home/HomeFragment.java
View file @
84e5c9a2
...
...
@@ -47,6 +47,7 @@ import com.ruiwenliu.wrapper.util.UtilsManager;
import
com.ruiwenliu.wrapper.util.glide.GlideManager
;
import
com.ruiwenliu.wrapper.util.listener.SwitchFragment
;
import
com.ruiwenliu.wrapper.util.permission.RxPermission
;
import
com.ruiwenliu.wrapper.weight.refresh.IFooterWrapper
;
import
com.ruiwenliu.wrapper.weight.refresh.SimpleRefreshLayout
;
import
com.ruiwenliu.wrapper.weight.refresh.SimpleRefreshView
;
import
com.rv.component.utils.Cookie
;
...
...
@@ -262,19 +263,12 @@ public class HomeFragment extends BaseFragment<HomePresenter> implements Observa
mSimpleRefreshLayout
.
setOnSimpleRefreshListener
(
this
);
permissionProcess
();
setBanner
();
tvDay
.
setText
(
String
.
format
(
"%1$s%2$s"
,
copyDay
,
getContext
().
getString
(
R
.
string
.
rv_days
)));
Drawable
drawable
=
getResources
().
getDrawable
(
R
.
drawable
.
icon_day_times
);
drawable
.
setBounds
(
0
,
0
,
DisplayUtil
.
dip2px
(
getContext
(),
25
),
DisplayUtil
.
dip2px
(
getContext
(),
5
));
tvDay
.
setCompoundDrawables
(
null
,
null
,
null
,
drawable
);
begDate
=
MyUtils
.
getFetureDate
(
1
)
+
" 09:00"
;
tvGetTime
.
setText
(
DateUtils
.
formatDate66
(
begDate
));
tvGetWeek
.
setText
(
"周"
+
MyUtils
.
getWeek
(
MyUtils
.
getFetureDate
(
1
)));
endDate
=
MyUtils
.
getFetureDate
(
2
)
+
" 18:00"
;
tvOutTime
.
setText
(
DateUtils
.
formatDate66
(
endDate
));
tvOutWeek
.
setText
(
"周"
+
MyUtils
.
getWeek
(
MyUtils
.
getFetureDate
(
2
)));
copyDay
=
DateUtils
.
compareDateDay
(
MyUtils
.
getFetureDate
(
1
),
DateUtils
.
getCurDate
())
+
1
;
setDefaultTime
();
llItemHotRvtour
.
setSelected
(
true
);
tvItemRvTour
.
setSelected
(
true
);
hotType
=
"2"
;
...
...
@@ -443,6 +437,38 @@ public class HomeFragment extends BaseFragment<HomePresenter> implements Observa
});
}
/**
* 设置默认时间
*/
private
void
setDefaultTime
()
{
String
time
=
DateUtils
.
formatDate28
(
DateUtils
.
timestampToString1
(
DateUtils
.
getCurTimeMillis
()),
2
);
String
hh
=
DateUtils
.
formatDate21
(
time
);
String
mm
=
DateUtils
.
formatDate22
(
time
);
String
begTime
=
""
;
if
(
Double
.
valueOf
(
mm
)
>
30
)
{
//判断当前分钟是否已经超过30,如果超过了取整加30分钟
begTime
=
DateUtils
.
formatDate19
(
hh
+
":30"
);
}
else
{
begTime
=
hh
+
":30"
;
}
if
(
DateUtils
.
formatDate20
(
begTime
)
>
DateUtils
.
formatDate20
(
"19:30"
))
{
//如果当前时间大于 19:30,日期往后加一,时间改成早上8:00
begDate
=
MyUtils
.
getFetureDate
(
1
)
+
" "
+
"08:00"
;
endDate
=
MyUtils
.
getFetureDate
(
3
)
+
" "
+
"08:00"
;
}
else
{
begDate
=
MyUtils
.
getFetureDate
(
0
)
+
" "
+
begTime
;
endDate
=
MyUtils
.
getFetureDate
(
2
)
+
" "
+
begTime
;
}
tvGetTime
.
setText
(
DateUtils
.
formatDate66
(
begDate
));
tvGetWeek
.
setText
(
"周"
+
MyUtils
.
getWeek
(
DateUtils
.
formatDate16
(
begDate
)));
tvOutTime
.
setText
(
DateUtils
.
formatDate66
(
endDate
));
tvOutWeek
.
setText
(
"周"
+
MyUtils
.
getWeek
(
DateUtils
.
formatDate16
(
endDate
)));
copyDay
=
getCountDay
(
begDate
,
endDate
);
tvDay
.
setText
(
String
.
format
(
"%1$s%2$s"
,
copyDay
,
getContext
().
getString
(
R
.
string
.
rv_days
)));
}
@Override
public
void
onRefresh
()
{
...
...
@@ -989,7 +1015,10 @@ public class HomeFragment extends BaseFragment<HomePresenter> implements Observa
}
else
if
(
resultCode
==
200
&&
requestCode
==
108
)
{
begDate
=
data
.
getStringExtra
(
"begDate"
);
endDate
=
data
.
getStringExtra
(
"endDate"
);
copyDay
=
DateUtils
.
compareDateDay
(
endDate
,
begDate
)
+
1
;
copyDay
=
getCountDay
(
begDate
,
endDate
);
//天数
// copyDay = DateUtils.compareDateDay(endDate, begDate) + 1;
if
(
tvGetTime
!=
null
)
{
tvGetTime
.
setText
(
DateUtils
.
formatDate66
(
begDate
));
}
...
...
@@ -1008,6 +1037,26 @@ public class HomeFragment extends BaseFragment<HomePresenter> implements Observa
}
}
/**
* 计算天数
*
* @param endDate2
* @param begDate2
* @return
*/
private
long
getCountDay
(
String
begDate2
,
String
endDate2
)
{
long
second
=
DateUtils
.
compareDateSecond3
(
endDate2
,
begDate2
);
//两个时间相差的秒数
long
day
=
(
long
)
second
/
86400
;
//天数
long
remainder
=
(
long
)
second
%
86400
;
//余数 秒
if
(
day
==
0
)
{
//不够24小时也算一天
day
=
day
+
1
;
}
else
if
(
remainder
>
14400
)
{
//4小时内天数不增加,否则加一
day
=
day
+
1
;
}
return
day
;
}
/**
* 设置返回结果参数
...
...
plugin_calendar/src/main/java/com/rv/plugin/calendar/CalendarActivity.java
View file @
84e5c9a2
...
...
@@ -141,10 +141,16 @@ public class CalendarActivity extends BaseStatusActivity<CalendarPresenter> {
wheelViewLeft
.
setOnWheelViewListener
(
new
WheelView
.
OnWheelViewListener
()
{
@Override
public
void
onSelected
(
int
selectedIndex
,
String
item
)
{
String
s
=
DateUtils
.
formatDate17
(
DateUtils
.
formatDate8
(
DateUtils
.
getCurDateTime
()));
if
(
s_begDate
.
equals
(
DateUtils
.
getCurDate
())
&&
DateUtils
.
formatDate20
(
item
)
<
DateUtils
.
formatDate20
(
s
))
{
wheelViewLeft
.
setSeletion
(
begSelected
);
tvGetTime
.
setText
(
s_begTime
);
}
else
{
begSelected
=
selectedIndex
;
s_begTime
=
item
;
tvGetTime
.
setText
(
item
);
}
}
});
wheelViewRight
.
setOffset
(
1
);
// 对话框中当前项上面和下面的项数
...
...
@@ -172,20 +178,12 @@ public class CalendarActivity extends BaseStatusActivity<CalendarPresenter> {
begSelected
=
i
;
wheelViewLeft
.
setSeletion
(
i
);
s_begTime
=
begTime
;
}
else
if
(
timeList
.
get
(
i
).
equals
(
"08:00"
))
{
begSelected
=
i
;
wheelViewLeft
.
setSeletion
(
i
);
s_begTime
=
"08:00"
;
}
if
(
timeList
.
get
(
i
).
equals
(
endTime
))
{
endSelected
=
i
;
wheelViewRight
.
setSeletion
(
i
);
s_endTime
=
endTime
;
}
else
if
(
timeList
.
get
(
i
).
equals
(
"18:00"
))
{
endSelected
=
i
;
wheelViewRight
.
setSeletion
(
i
);
s_endTime
=
"18:00"
;
}
}
}
...
...
@@ -212,6 +210,11 @@ public class CalendarActivity extends BaseStatusActivity<CalendarPresenter> {
showToast
(
"还车时刻要大于取车时刻!"
);
return
;
}
String
s
=
DateUtils
.
formatDate17
(
DateUtils
.
formatDate8
(
DateUtils
.
getCurDateTime
()));
if
(
s_begDate
.
equals
(
DateUtils
.
getCurDate
())
&&
DateUtils
.
formatDate20
(
s_begTime
)
<
DateUtils
.
formatDate20
(
s
))
{
showToast
(
"取车时刻要大于现在时刻!"
);
return
;
}
Intent
intent
=
new
Intent
();
intent
.
putExtra
(
"begDate"
,
s_begDate
+
" "
+
s_begTime
);
...
...
@@ -309,7 +312,7 @@ public class CalendarActivity extends BaseStatusActivity<CalendarPresenter> {
day
.
setCurDay
(
true
);
day
.
setDefTextColor
(
context
.
getResources
().
getColor
(
R
.
color
.
gray_FFB74B
));
day
.
setDefNongTextColor
(
context
.
getResources
().
getColor
(
R
.
color
.
gray_FFB74B
));
day
.
setCanBeChoose
(
fals
e
);
day
.
setCanBeChoose
(
tru
e
);
}
else
if
(
CalendarDateUtil
.
compareDateDay
(
CalendarDateUtil
.
getCurDate
(),
curDay
)
>
0
||
spanIndex
>=
MAX_SPAN
)
{
//如果是今天以前
day
.
setDefTextColor
(
context
.
getResources
().
getColor
(
R
.
color
.
ri_lhui
));
...
...
@@ -368,11 +371,9 @@ public class CalendarActivity extends BaseStatusActivity<CalendarPresenter> {
* 初始化时间数据
*/
private
void
initTime
()
{
for
(
int
i
=
9
;
i
<
22
;
i
++)
{
for
(
int
i
=
8
;
i
<
20
;
i
++)
{
timeList
.
add
(
String
.
format
(
"%02d"
,
i
)
+
":00"
);
if
(
i
<
21
)
{
timeList
.
add
(
String
.
format
(
"%02d"
,
i
)
+
":30"
);
}
}
}
}
plugin_calendar/src/main/res/layout/activity_calendar2.xml
View file @
84e5c9a2
...
...
@@ -107,9 +107,9 @@
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:
paddingBottom=
"@dimen/size_5
"
android:
orientation=
"horizontal
"
android:paddingTop=
"@dimen/size_5"
android:
orientation=
"horizontal"
>
android:
paddingBottom=
"@dimen/size_5"
>
<TextView
android:layout_width=
"0dip"
...
...
@@ -201,7 +201,7 @@
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"@dimen/size_2
2
0"
android:layout_height=
"@dimen/size_2
0
0"
android:background=
"@color/colorWrite"
android:orientation=
"vertical"
>
...
...
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