梦幻许愿池逻辑bugfix

This commit is contained in:
oujunhui
2020-07-01 00:13:06 +08:00
parent 833a912084
commit a3fc0093a0
2 changed files with 21 additions and 21 deletions

View File

@@ -70,15 +70,13 @@ public class ChooseTreasureBoxDialogFragment extends DialogFragment implements V
clBoxNormal.setOnClickListener(this);
clBoxHonour.setOnClickListener(this);
tvOpenTime.setText("限时 "+ mOpenTime);
int currentTime = TimeUtils.getTime24();
String mOpenTime = "10:10-13:00";
int startTime = Integer.parseInt(mOpenTime.substring(0,mOpenTime.indexOf("-")).replace(":",""));
int endTime = Integer.parseInt(mOpenTime.substring(mOpenTime.indexOf("-") + 1).replace(":",""));
LogUtils.e("startTime"+startTime);
LogUtils.e("endTime"+endTime);
LogUtils.e("当前小时"+TimeUtils.getTime24());
LogUtils.e("范围:"+TimeUtils.getTimeLimit(17,59,13,20));
// LogUtils.e("范围:"+TimeUtils.getTimeLimit());
if (TimeUtils.getTimeLimit(10,10,18,20)){
LogUtils.e("范围:"+TimeUtils.getTimeLimit(startTime,endTime));
if (TimeUtils.getTimeLimit(startTime,endTime)){
mTvOpenHonour.setEnabled(true);
}else {
mTvOpenHonour.setEnabled(false);

View File

@@ -824,13 +824,6 @@ public class TimeUtils {
* @return HashMap
*/
public static int getTime24(){
Calendar calendar=Calendar.getInstance();
String hour = String.valueOf(calendar.get(Calendar.HOUR_OF_DAY));
String minute = String.valueOf(calendar.get(Calendar.MINUTE));
return Integer.parseInt(hour +minute);
}
public static boolean getTimeLimit(int start_hour,int start_minute,int end_hour,int end_minute) {
SimpleDateFormat hh = new SimpleDateFormat("HH", Locale.CHINA);
SimpleDateFormat mm = new SimpleDateFormat("mm", Locale.CHINA);
hh.setTimeZone(TimeZone.getTimeZone("GMT+08")); // 获取指定时区的时间
@@ -838,19 +831,28 @@ public class TimeUtils {
Date date = new Date();
String hour = hh.format(date);
String minute = mm.format(date);
final int start = start_hour * start_minute;// 起始时间 8:00的分钟数
final int end = end_hour * end_minute;// 结束时间 19:00的分钟数
int minuteOfDay = Integer.parseInt(hour) * 60 + Integer.parseInt(minute);
return Integer.parseInt(hour +minute);
}
public static boolean getTimeLimit(int start_hour,int end_hour) {
SimpleDateFormat hh = new SimpleDateFormat("HH", Locale.CHINA);
SimpleDateFormat mm = new SimpleDateFormat("mm", Locale.CHINA);
hh.setTimeZone(TimeZone.getTimeZone("GMT+08")); // 获取指定时区的时间
mm.setTimeZone(TimeZone.getTimeZone("GMT+08"));
Date date = new Date();
String hour = hh.format(date);
String minute = mm.format(date);
Log.i("stf", "--hour:minute-->" + hour + ":" + minute);
LogUtil.print("start" +start);
LogUtil.print("end" +end);
LogUtil.print("minuteOfDay" +minuteOfDay);
if (minuteOfDay >= start && minuteOfDay <= end) {
int currentTime = Integer.parseInt(hour +minute);
LogUtil.print("start" +start_hour);
LogUtil.print("end" +end_hour);
LogUtil.print("minuteOfDay" +currentTime);
if (currentTime >= start_hour && currentTime <= end_hour) {
LogUtil.print("工作时间内" + hour + ":" + minute);
return true;
} else {
if (start > end){
if (minuteOfDay >= start || minuteOfDay <= end){
if (start_hour > end_hour){
if (currentTime >= start_hour || currentTime <= end_hour){
return true;
}
}