From e386fbfdbbd17a28d37dc1e5084c0751a8a4cc93 Mon Sep 17 00:00:00 2001 From: hch <16607480311@163.com> Date: Tue, 26 Mar 2024 16:48:37 +0800 Subject: [PATCH] =?UTF-8?q?fix=20[=E4=BF=AE=E5=A4=8D=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E5=8F=91=E5=B8=83=EF=BC=8C=E6=97=B6=E9=97=B4=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E9=97=AE=E9=A2=98]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/src/main/res/values-en-rUS/strings.xml | 1 + common/src/main/res/values-zh-rHK/strings.xml | 1 + common/src/main/res/values-zh-rTW/strings.xml | 1 + common/src/main/res/values-zh/strings.xml | 1 + common/src/main/res/values/strings.xml | 1 + .../main/activity/CommunitySendActivity.java | 21 ++++++++++--------- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/common/src/main/res/values-en-rUS/strings.xml b/common/src/main/res/values-en-rUS/strings.xml index 31c5c0d..a16b1aa 100644 --- a/common/src/main/res/values-en-rUS/strings.xml +++ b/common/src/main/res/values-en-rUS/strings.xml @@ -27,4 +27,5 @@ Focus on See more close + Time cannot be greater than the current time \ No newline at end of file diff --git a/common/src/main/res/values-zh-rHK/strings.xml b/common/src/main/res/values-zh-rHK/strings.xml index f75e705..f9997b3 100644 --- a/common/src/main/res/values-zh-rHK/strings.xml +++ b/common/src/main/res/values-zh-rHK/strings.xml @@ -1492,4 +1492,5 @@ 關注 查看更多 收起 + 时间不能大于当前时间 diff --git a/common/src/main/res/values-zh-rTW/strings.xml b/common/src/main/res/values-zh-rTW/strings.xml index aaf1ba5..200bff4 100644 --- a/common/src/main/res/values-zh-rTW/strings.xml +++ b/common/src/main/res/values-zh-rTW/strings.xml @@ -1492,4 +1492,5 @@ 關注 查看更多 收起 + 时间不能大于当前时间 diff --git a/common/src/main/res/values-zh/strings.xml b/common/src/main/res/values-zh/strings.xml index 99f4032..2d15a99 100644 --- a/common/src/main/res/values-zh/strings.xml +++ b/common/src/main/res/values-zh/strings.xml @@ -1490,4 +1490,5 @@ 關注 查看更多 收起 + 时间不能大于当前时间 diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index 1c7f32e..94d835b 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -1512,6 +1512,7 @@ Limited ride And limited avatar frame 關注 查看更多 收起 + 时间不能大于当前时间 diff --git a/main/src/main/java/com/yunbao/main/activity/CommunitySendActivity.java b/main/src/main/java/com/yunbao/main/activity/CommunitySendActivity.java index 97f620c..2358379 100644 --- a/main/src/main/java/com/yunbao/main/activity/CommunitySendActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/CommunitySendActivity.java @@ -288,24 +288,31 @@ public class CommunitySendActivity extends AbsActivity { } } + TimePickerView timePickerView; + public void showTimeChooseDialog() { Calendar startCalendar = Calendar.getInstance(); startCalendar.set(1990, 1, 1); Calendar endCalendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance(); int year = calendar.get(Calendar.YEAR); - int month = calendar.get(Calendar.MONTH) + 1; // Calendar.MONTH 从0开始计数 + int month = calendar.get(Calendar.MONTH); // Calendar.MONTH 从0开始计数 int day = calendar.get(Calendar.DAY_OF_MONTH); - int hour = calendar.get(Calendar.HOUR); // 使用24小时制 + int hour = calendar.get(Calendar.HOUR_OF_DAY); // 使用24小时制 int minute = calendar.get(Calendar.MINUTE); int second = calendar.get(Calendar.SECOND); endCalendar.set(year, month, day, hour, minute, second); - TimePickerView timePickerView = new TimePickerBuilder(CommunitySendActivity.this, new OnTimeSelectListener() { + timePickerView = new TimePickerBuilder(CommunitySendActivity.this, new OnTimeSelectListener() { @SuppressLint("SetTextI18n") @Override public void onTimeSelect(Date date, View v) { - chooseTime.setText(DateFormatUtil.getTimeStrings(date.getTime())); + if (date.getTime() > new Date().getTime()) { + ToastUtil.show(getResources().getString(com.yunbao.main.R.string.time_cannot_be_greater_than_the_current_time)); + timePickerView.show(); + } else { + chooseTime.setText(DateFormatUtil.getTimeStrings(date.getTime())); + } } }).setType(new boolean[]{true, true, true, true, true, false})// 默认全部显示 .setCancelText(getResources().getString(R.string.cancel))//取消按钮文字 @@ -318,12 +325,6 @@ public class CommunitySendActivity extends AbsActivity { .isCenterLabel(false) //是否只显示中间选中项的label文字,false则每项item全部都带有label。 .build(); timePickerView.show(); - timePickerView.setOnDismissListener(new OnDismissListener() { - @Override - public void onDismiss(Object o) { - - } - }); } private void openImageChooserActivity() {