1:在房间设置的时候,展示营业时间
2:修改选择时间展示选择的日期 3:修改了群组全成员展示接界面
This commit is contained in:
@@ -129,6 +129,9 @@ public class RoomBean implements Serializable {
|
|||||||
private int is_pk; //1:接收 2:不接受
|
private int is_pk; //1:接收 2:不接受
|
||||||
private int last_pk_room_id;//记录上次pk的房间id
|
private int last_pk_room_id;//记录上次pk的房间id
|
||||||
|
|
||||||
|
private String start_time="";//营业时间的开始时间
|
||||||
|
private String end_time="";//营业时间的结束时间
|
||||||
|
|
||||||
public int getSceneId() {
|
public int getSceneId() {
|
||||||
if (sound_effect != null) {
|
if (sound_effect != null) {
|
||||||
return sound_effect.getId();
|
return sound_effect.getId();
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ public class ConfirmDialog extends Dialog {
|
|||||||
window.setGravity(Gravity.CENTER); // 居中显示
|
window.setGravity(Gravity.CENTER); // 居中显示
|
||||||
window.setBackgroundDrawableResource(R.drawable.bg_r16_fff); // 透明背景
|
window.setBackgroundDrawableResource(R.drawable.bg_r16_fff); // 透明背景
|
||||||
}
|
}
|
||||||
|
setCanceledOnTouchOutside(false); // 设置点击外部不取消对话框
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TabHost;
|
import android.widget.TabHost;
|
||||||
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@@ -14,8 +15,10 @@ import androidx.annotation.Nullable;
|
|||||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||||
import com.xscm.moduleutil.R;
|
import com.xscm.moduleutil.R;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
public class DoubleTimePickerBottomSheet extends BottomSheetDialogFragment {
|
public class DoubleTimePickerBottomSheet extends BottomSheetDialogFragment {
|
||||||
|
|
||||||
@@ -24,6 +27,31 @@ public class DoubleTimePickerBottomSheet extends BottomSheetDialogFragment {
|
|||||||
private boolean showDate = true; // 默认显示日期
|
private boolean showDate = true; // 默认显示日期
|
||||||
private boolean showSeconds = true; // 默认显示秒
|
private boolean showSeconds = true; // 默认显示秒
|
||||||
|
|
||||||
|
// 格式模板
|
||||||
|
private static final String DATE_FORMAT = "yyyy-MM-dd";
|
||||||
|
private static final String TIME_FORMAT_SECONDS = "HH:mm:ss";
|
||||||
|
private static final String TIME_FORMAT_NO_SECONDS = "HH:mm";
|
||||||
|
private static final String DATETIME_FORMAT_SECONDS = "yyyy-MM-dd HH:mm:ss";
|
||||||
|
private static final String DATETIME_FORMAT_NO_SECONDS = "yyyy-MM-dd HH:mm";
|
||||||
|
|
||||||
|
private SimpleDateFormat dateFormat;
|
||||||
|
private SimpleDateFormat timeFormat;
|
||||||
|
private SimpleDateFormat dateTimeFormat;
|
||||||
|
|
||||||
|
// UI组件
|
||||||
|
private TextView tvStartTime;
|
||||||
|
private TextView tvEndTime;
|
||||||
|
private TabHost tabHost;
|
||||||
|
private WheelDatePicker wheelStartDate;
|
||||||
|
private WheelTimePicker wheelStartTime;
|
||||||
|
private WheelDatePicker wheelEndDate;
|
||||||
|
private WheelTimePicker wheelEndTime;
|
||||||
|
|
||||||
|
// 时间数据
|
||||||
|
private Calendar startCalendar;
|
||||||
|
private Calendar endCalendar;
|
||||||
|
private View view;
|
||||||
|
|
||||||
public interface OnTimeRangeSelectedListener {
|
public interface OnTimeRangeSelectedListener {
|
||||||
void onTimeRangeSelected(Date startDate, Date endDate);
|
void onTimeRangeSelected(Date startDate, Date endDate);
|
||||||
}
|
}
|
||||||
@@ -86,140 +114,309 @@ public class DoubleTimePickerBottomSheet extends BottomSheetDialogFragment {
|
|||||||
return new CustomBottomSheetDialog(requireContext());
|
return new CustomBottomSheetDialog(requireContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
// 初始化格式化工具
|
||||||
|
initFormats();
|
||||||
|
// 初始化时间数据
|
||||||
|
initCalendars();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化日期时间格式化工具
|
||||||
|
*/
|
||||||
|
private void initFormats() {
|
||||||
|
dateFormat = new SimpleDateFormat(DATE_FORMAT, Locale.getDefault());
|
||||||
|
|
||||||
|
if (showSeconds) {
|
||||||
|
timeFormat = new SimpleDateFormat(TIME_FORMAT_SECONDS, Locale.getDefault());
|
||||||
|
dateTimeFormat = new SimpleDateFormat(DATETIME_FORMAT_SECONDS, Locale.getDefault());
|
||||||
|
} else {
|
||||||
|
timeFormat = new SimpleDateFormat(TIME_FORMAT_NO_SECONDS, Locale.getDefault());
|
||||||
|
dateTimeFormat = new SimpleDateFormat(DATETIME_FORMAT_NO_SECONDS, Locale.getDefault());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化时间数据
|
||||||
|
*/
|
||||||
|
private void initCalendars() {
|
||||||
|
startCalendar = Calendar.getInstance();
|
||||||
|
endCalendar = Calendar.getInstance();
|
||||||
|
|
||||||
|
// 设置默认结束时间略晚于开始时间
|
||||||
|
if (showTime) {
|
||||||
|
endCalendar.add(Calendar.HOUR, 1);
|
||||||
|
} else {
|
||||||
|
endCalendar.add(Calendar.DAY_OF_MONTH, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据配置获取显示格式
|
||||||
|
*/
|
||||||
|
private String getFormattedTime(Calendar calendar) {
|
||||||
|
if (showDate && showTime) {
|
||||||
|
return dateTimeFormat.format(calendar.getTime());
|
||||||
|
} else if (showDate && !showTime) {
|
||||||
|
return dateFormat.format(calendar.getTime());
|
||||||
|
} else if (!showDate && showTime) {
|
||||||
|
return timeFormat.format(calendar.getTime());
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新顶部TextView显示
|
||||||
|
*/
|
||||||
|
private void updateDisplayText() {
|
||||||
|
if (tvStartTime != null) {
|
||||||
|
tvStartTime.setText(getFormattedTime(startCalendar));
|
||||||
|
}
|
||||||
|
if (tvEndTime != null) {
|
||||||
|
tvEndTime.setText(getFormattedTime(endCalendar));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.dialog_double_time_picker, container, false);
|
view = inflater.inflate(R.layout.dialog_double_time_picker, container, false);
|
||||||
|
|
||||||
// 初始化 TabHost
|
initViews(view);
|
||||||
TabHost tabHost = view.findViewById(R.id.tabHost);
|
setupWheelPickers();
|
||||||
|
setupTabHost();
|
||||||
|
setupButtons();
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化视图组件
|
||||||
|
*/
|
||||||
|
private void initViews(View view) {
|
||||||
|
tvStartTime = view.findViewById(R.id.tv_start);
|
||||||
|
tvEndTime = view.findViewById(R.id.tv_end);
|
||||||
|
tabHost = view.findViewById(R.id.tabHost);
|
||||||
|
|
||||||
|
wheelStartDate = view.findViewById(R.id.wheel_start_date);
|
||||||
|
wheelStartTime = view.findViewById(R.id.wheel_start_time);
|
||||||
|
wheelEndDate = view.findViewById(R.id.wheel_end_date);
|
||||||
|
wheelEndTime = view.findViewById(R.id.wheel_end_time);
|
||||||
|
|
||||||
|
// 初始化显示文本
|
||||||
|
updateDisplayText();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置滚轮选择器
|
||||||
|
*/
|
||||||
|
private void setupWheelPickers() {
|
||||||
|
// 根据showDate和showTime参数控制日期和时间选择器的显示和布局
|
||||||
|
adjustPickerVisibility();
|
||||||
|
|
||||||
|
// 初始化开始时间
|
||||||
|
if (showDate) {
|
||||||
|
wheelStartDate.init(startCalendar.get(Calendar.YEAR),
|
||||||
|
startCalendar.get(Calendar.MONTH),
|
||||||
|
startCalendar.get(Calendar.DAY_OF_MONTH));
|
||||||
|
wheelStartDate.setOnDateSelectedListener((year, month, day) -> {
|
||||||
|
startCalendar.set(year, month, day);
|
||||||
|
updateDisplayText();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (showTime) {
|
||||||
|
wheelStartTime.init(startCalendar.get(Calendar.HOUR_OF_DAY),
|
||||||
|
startCalendar.get(Calendar.MINUTE),
|
||||||
|
showSeconds ? startCalendar.get(Calendar.SECOND) : 0);
|
||||||
|
wheelStartTime.setShowSeconds(showSeconds);
|
||||||
|
wheelStartTime.setOnValueChangedListener(() -> {
|
||||||
|
startCalendar.set(Calendar.HOUR_OF_DAY, wheelStartTime.getHour());
|
||||||
|
startCalendar.set(Calendar.MINUTE, wheelStartTime.getMinute());
|
||||||
|
if (showSeconds) {
|
||||||
|
startCalendar.set(Calendar.SECOND, wheelStartTime.getSecond());
|
||||||
|
}
|
||||||
|
updateDisplayText();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化结束时间
|
||||||
|
if (showDate) {
|
||||||
|
wheelEndDate.init(endCalendar.get(Calendar.YEAR),
|
||||||
|
endCalendar.get(Calendar.MONTH),
|
||||||
|
endCalendar.get(Calendar.DAY_OF_MONTH));
|
||||||
|
wheelEndDate.setOnDateSelectedListener((year, month, day) -> {
|
||||||
|
endCalendar.set(year, month, day);
|
||||||
|
updateDisplayText();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (showTime) {
|
||||||
|
wheelEndTime.init(endCalendar.get(Calendar.HOUR_OF_DAY),
|
||||||
|
endCalendar.get(Calendar.MINUTE),
|
||||||
|
showSeconds ? endCalendar.get(Calendar.SECOND) : 0);
|
||||||
|
wheelEndTime.setShowSeconds(showSeconds);
|
||||||
|
wheelEndTime.setOnValueChangedListener(() -> {
|
||||||
|
endCalendar.set(Calendar.HOUR_OF_DAY, wheelEndTime.getHour());
|
||||||
|
endCalendar.set(Calendar.MINUTE, wheelEndTime.getMinute());
|
||||||
|
if (showSeconds) {
|
||||||
|
endCalendar.set(Calendar.SECOND, wheelEndTime.getSecond());
|
||||||
|
}
|
||||||
|
updateDisplayText();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调整选择器显示状态和布局
|
||||||
|
*/
|
||||||
|
private void adjustPickerVisibility() {
|
||||||
|
if (showDate && showTime) {
|
||||||
|
// 显示日期和时间时,使用默认布局
|
||||||
|
setPickerVisibility(View.VISIBLE, View.VISIBLE, View.VISIBLE, View.VISIBLE);
|
||||||
|
resetPickerLayoutParams(wheelStartDate, wheelEndDate);
|
||||||
|
} else if (showDate && !showTime) {
|
||||||
|
// 只显示日期时,隐藏时间选择器并让日期选择器铺满宽度
|
||||||
|
setPickerVisibility(View.VISIBLE, View.GONE, View.VISIBLE, View.GONE);
|
||||||
|
setPickerFullWidth(wheelStartDate, wheelEndDate);
|
||||||
|
} else if (!showDate && showTime) {
|
||||||
|
// 只显示时间时,隐藏日期选择器并让时间选择器铺满宽度
|
||||||
|
setPickerVisibility(View.GONE, View.VISIBLE, View.GONE, View.VISIBLE);
|
||||||
|
setPickerFullWidth(wheelStartTime, wheelEndTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setPickerVisibility(int startDateVis, int startTimeVis,
|
||||||
|
int endDateVis, int endTimeVis) {
|
||||||
|
wheelStartDate.setVisibility(startDateVis);
|
||||||
|
wheelStartTime.setVisibility(startTimeVis);
|
||||||
|
wheelEndDate.setVisibility(endDateVis);
|
||||||
|
wheelEndTime.setVisibility(endTimeVis);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void resetPickerLayoutParams(WheelDatePicker... pickers) {
|
||||||
|
for (WheelDatePicker picker : pickers) {
|
||||||
|
ViewGroup.LayoutParams params = picker.getLayoutParams();
|
||||||
|
params.width = ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||||
|
picker.setLayoutParams(params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setPickerFullWidth(View... views) {
|
||||||
|
for (View view : views) {
|
||||||
|
ViewGroup.LayoutParams params = view.getLayoutParams();
|
||||||
|
params.width = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||||
|
view.setLayoutParams(params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置TabHost
|
||||||
|
*/
|
||||||
|
private void setupTabHost() {
|
||||||
tabHost.setup();
|
tabHost.setup();
|
||||||
|
|
||||||
tabHost.addTab(tabHost.newTabSpec("start").setIndicator("开始时间").setContent(R.id.start_time_tab));
|
tabHost.addTab(tabHost.newTabSpec("start").setIndicator("开始时间").setContent(R.id.start_time_tab));
|
||||||
tabHost.addTab(tabHost.newTabSpec("end").setIndicator("结束时间").setContent(R.id.end_time_tab));
|
tabHost.addTab(tabHost.newTabSpec("end").setIndicator("结束时间").setContent(R.id.end_time_tab));
|
||||||
|
|
||||||
// 初始化 Wheel Views
|
tabHost.setOnTabChangedListener(tabId -> {
|
||||||
WheelDatePicker wheelStartDate = view.findViewById(R.id.wheel_start_date);
|
if ("start".equals(tabId)) {
|
||||||
WheelTimePicker wheelStartTime = view.findViewById(R.id.wheel_start_time);
|
restoreStartTimeSelection();
|
||||||
WheelDatePicker wheelEndDate = view.findViewById(R.id.wheel_end_date);
|
} else if ("end".equals(tabId)) {
|
||||||
WheelTimePicker wheelEndTime = view.findViewById(R.id.wheel_end_time);
|
restoreEndTimeSelection();
|
||||||
|
}
|
||||||
// 根据showDate和showTime参数控制日期和时间选择器的显示和布局
|
});
|
||||||
if (showDate && showTime) {
|
|
||||||
// 显示日期和时间时,使用默认布局
|
|
||||||
wheelStartDate.setVisibility(View.VISIBLE);
|
|
||||||
wheelStartTime.setVisibility(View.VISIBLE);
|
|
||||||
wheelEndDate.setVisibility(View.VISIBLE);
|
|
||||||
wheelEndTime.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
// 重置日期选择器的布局参数为默认值
|
|
||||||
ViewGroup.LayoutParams startDateParams = wheelStartDate.getLayoutParams();
|
|
||||||
startDateParams.width = ViewGroup.LayoutParams.WRAP_CONTENT;
|
|
||||||
wheelStartDate.setLayoutParams(startDateParams);
|
|
||||||
|
|
||||||
ViewGroup.LayoutParams endDateParams = wheelEndDate.getLayoutParams();
|
|
||||||
endDateParams.width = ViewGroup.LayoutParams.WRAP_CONTENT;
|
|
||||||
wheelEndDate.setLayoutParams(endDateParams);
|
|
||||||
} else if (showDate && !showTime) {
|
|
||||||
// 只显示日期时,隐藏时间选择器并让日期选择器铺满宽度
|
|
||||||
wheelStartTime.setVisibility(View.GONE);
|
|
||||||
wheelEndTime.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
// 设置日期选择器铺满宽度
|
|
||||||
ViewGroup.LayoutParams startDateParams = wheelStartDate.getLayoutParams();
|
|
||||||
startDateParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
|
|
||||||
wheelStartDate.setLayoutParams(startDateParams);
|
|
||||||
|
|
||||||
ViewGroup.LayoutParams endDateParams = wheelEndDate.getLayoutParams();
|
|
||||||
endDateParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
|
|
||||||
wheelEndDate.setLayoutParams(endDateParams);
|
|
||||||
} else if (!showDate && showTime) {
|
|
||||||
// 只显示时间时,隐藏日期选择器并让时间选择器铺满宽度
|
|
||||||
wheelStartDate.setVisibility(View.GONE);
|
|
||||||
wheelStartTime.setVisibility(View.VISIBLE);
|
|
||||||
wheelEndDate.setVisibility(View.GONE);
|
|
||||||
wheelEndTime.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
// 设置时间选择器铺满宽度
|
|
||||||
ViewGroup.LayoutParams startTimeParams = wheelStartTime.getLayoutParams();
|
|
||||||
startTimeParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
|
|
||||||
wheelStartTime.setLayoutParams(startTimeParams);
|
|
||||||
|
|
||||||
ViewGroup.LayoutParams endTimeParams = wheelEndTime.getLayoutParams();
|
|
||||||
endTimeParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
|
|
||||||
wheelEndTime.setLayoutParams(endTimeParams);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 默认设置当前时间
|
/**
|
||||||
Calendar startCal = Calendar.getInstance();
|
* 恢复开始时间选择
|
||||||
|
*/
|
||||||
|
private void restoreStartTimeSelection() {
|
||||||
if (showDate) {
|
if (showDate) {
|
||||||
wheelStartDate.init(startCal.get(Calendar.YEAR), startCal.get(Calendar.MONTH), startCal.get(Calendar.DAY_OF_MONTH));
|
wheelStartDate.init(startCalendar.get(Calendar.YEAR),
|
||||||
|
startCalendar.get(Calendar.MONTH),
|
||||||
|
startCalendar.get(Calendar.DAY_OF_MONTH));
|
||||||
}
|
}
|
||||||
if (showTime) {
|
if (showTime) {
|
||||||
wheelStartTime.init(startCal.get(Calendar.HOUR_OF_DAY), startCal.get(Calendar.MINUTE), showSeconds ? startCal.get(Calendar.SECOND) : 0);
|
wheelStartTime.init(startCalendar.get(Calendar.HOUR_OF_DAY),
|
||||||
wheelStartTime.setShowSeconds(showSeconds);
|
startCalendar.get(Calendar.MINUTE),
|
||||||
|
showSeconds ? startCalendar.get(Calendar.SECOND) : 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置默认结束时间略晚于开始时间
|
/**
|
||||||
Calendar endCal = (Calendar) startCal.clone();
|
* 恢复结束时间选择
|
||||||
if (showTime) {
|
*/
|
||||||
endCal.add(Calendar.HOUR, 1);
|
private void restoreEndTimeSelection() {
|
||||||
} else {
|
|
||||||
endCal.add(Calendar.DAY_OF_MONTH, 1);
|
|
||||||
}
|
|
||||||
if (showDate) {
|
if (showDate) {
|
||||||
wheelEndDate.init(endCal.get(Calendar.YEAR), endCal.get(Calendar.MONTH), endCal.get(Calendar.DAY_OF_MONTH));
|
wheelEndDate.init(endCalendar.get(Calendar.YEAR),
|
||||||
|
endCalendar.get(Calendar.MONTH),
|
||||||
|
endCalendar.get(Calendar.DAY_OF_MONTH));
|
||||||
}
|
}
|
||||||
if (showTime) {
|
if (showTime) {
|
||||||
wheelEndTime.init(endCal.get(Calendar.HOUR_OF_DAY), endCal.get(Calendar.MINUTE), showSeconds ? endCal.get(Calendar.SECOND) : 0);
|
wheelEndTime.init(endCalendar.get(Calendar.HOUR_OF_DAY),
|
||||||
wheelEndTime.setShowSeconds(showSeconds);
|
endCalendar.get(Calendar.MINUTE),
|
||||||
|
showSeconds ? endCalendar.get(Calendar.SECOND) : 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置按钮事件
|
||||||
|
*/
|
||||||
|
private void setupButtons() {
|
||||||
// 取消按钮
|
// 取消按钮
|
||||||
view.findViewById(R.id.btn_cancel).setOnClickListener(v -> dismiss());
|
view.findViewById(R.id.btn_cancel).setOnClickListener(v -> dismiss());
|
||||||
|
|
||||||
// 确定按钮
|
// 确定按钮
|
||||||
view.findViewById(R.id.btn_sure).setOnClickListener(v -> {
|
view.findViewById(R.id.btn_sure).setOnClickListener(v -> {
|
||||||
Calendar start = Calendar.getInstance();
|
validateAndSubmit();
|
||||||
Calendar end = Calendar.getInstance();
|
});
|
||||||
|
|
||||||
if (showDate && showTime) {
|
|
||||||
// 显示日期和时间
|
|
||||||
start.set(wheelStartDate.getYear(), wheelStartDate.getMonth(), wheelStartDate.getDay(),
|
|
||||||
wheelStartTime.getHour(), wheelStartTime.getMinute(), wheelStartTime.getSecond());
|
|
||||||
end.set(wheelEndDate.getYear(), wheelEndDate.getMonth(), wheelEndDate.getDay(),
|
|
||||||
wheelEndTime.getHour(), wheelEndTime.getMinute(), wheelEndTime.getSecond());
|
|
||||||
} else if (showDate && !showTime) {
|
|
||||||
// 只显示日期
|
|
||||||
start.set(wheelStartDate.getYear(), wheelStartDate.getMonth(), wheelStartDate.getDay(),
|
|
||||||
0, 0, 0);
|
|
||||||
end.set(wheelEndDate.getYear(), wheelEndDate.getMonth(), wheelEndDate.getDay(),
|
|
||||||
23, 59, 59);
|
|
||||||
} else if (!showDate && showTime) {
|
|
||||||
// 只显示时间,使用当前日期
|
|
||||||
int currentYear = start.get(Calendar.YEAR);
|
|
||||||
int currentMonth = start.get(Calendar.MONTH);
|
|
||||||
int currentDay = start.get(Calendar.DAY_OF_MONTH);
|
|
||||||
|
|
||||||
start.set(currentYear, currentMonth, currentDay,
|
|
||||||
wheelStartTime.getHour(), wheelStartTime.getMinute(), wheelStartTime.getSecond());
|
|
||||||
end.set(currentYear, currentMonth, currentDay,
|
|
||||||
wheelEndTime.getHour(), wheelEndTime.getMinute(), wheelEndTime.getSecond());
|
|
||||||
}
|
}
|
||||||
if ((showDate && showTime) || (showDate && !showTime) ) {
|
|
||||||
if (end.getTime().before(start.getTime())) {
|
/**
|
||||||
|
* 验证并提交选择
|
||||||
|
*/
|
||||||
|
private void validateAndSubmit() {
|
||||||
|
// 确保使用最新的选择器值
|
||||||
|
syncPickerValuesToCalendars();
|
||||||
|
|
||||||
|
// 验证时间范围
|
||||||
|
if ((showDate && showTime) || (showDate && !showTime)) {
|
||||||
|
if (endCalendar.getTime().before(startCalendar.getTime())) {
|
||||||
Toast.makeText(requireContext(), "结束时间不能早于开始时间", Toast.LENGTH_SHORT).show();
|
Toast.makeText(requireContext(), "结束时间不能早于开始时间", Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 回调监听器
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
listener.onTimeRangeSelected(start.getTime(), end.getTime());
|
listener.onTimeRangeSelected(startCalendar.getTime(), endCalendar.getTime());
|
||||||
}
|
}
|
||||||
dismiss();
|
dismiss();
|
||||||
});
|
}
|
||||||
|
|
||||||
return view;
|
/**
|
||||||
|
* 同步选择器值到Calendar对象
|
||||||
|
*/
|
||||||
|
private void syncPickerValuesToCalendars() {
|
||||||
|
if (showDate) {
|
||||||
|
startCalendar.set(wheelStartDate.getYear(), wheelStartDate.getMonth(), wheelStartDate.getDay());
|
||||||
|
endCalendar.set(wheelEndDate.getYear(), wheelEndDate.getMonth(), wheelEndDate.getDay());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (showTime) {
|
||||||
|
startCalendar.set(Calendar.HOUR_OF_DAY, wheelStartTime.getHour());
|
||||||
|
startCalendar.set(Calendar.MINUTE, wheelStartTime.getMinute());
|
||||||
|
if (showSeconds) {
|
||||||
|
startCalendar.set(Calendar.SECOND, wheelStartTime.getSecond());
|
||||||
|
}
|
||||||
|
|
||||||
|
endCalendar.set(Calendar.HOUR_OF_DAY, wheelEndTime.getHour());
|
||||||
|
endCalendar.set(Calendar.MINUTE, wheelEndTime.getMinute());
|
||||||
|
if (showSeconds) {
|
||||||
|
endCalendar.set(Calendar.SECOND, wheelEndTime.getSecond());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,13 @@ public class WheelDatePicker extends LinearLayout {
|
|||||||
private NumberPicker yearPicker, monthPicker, dayPicker;
|
private NumberPicker yearPicker, monthPicker, dayPicker;
|
||||||
private int maxDay = 31;
|
private int maxDay = 31;
|
||||||
|
|
||||||
|
// 值变化监听器接口
|
||||||
|
public interface OnDateSelectedListener {
|
||||||
|
void onDateSelected(int year, int month, int day);
|
||||||
|
}
|
||||||
|
|
||||||
|
private OnDateSelectedListener onDateSelectedListener;
|
||||||
|
|
||||||
public WheelDatePicker(Context context) {
|
public WheelDatePicker(Context context) {
|
||||||
this(context, null);
|
this(context, null);
|
||||||
}
|
}
|
||||||
@@ -45,11 +52,28 @@ public class WheelDatePicker extends LinearLayout {
|
|||||||
// 月份从 1 到 12
|
// 月份从 1 到 12
|
||||||
monthPicker.setMinValue(1);
|
monthPicker.setMinValue(1);
|
||||||
monthPicker.setMaxValue(12);
|
monthPicker.setMaxValue(12);
|
||||||
monthPicker.setOnValueChangedListener((picker, oldVal, newVal) -> updateDays());
|
monthPicker.setOnValueChangedListener((picker, oldVal, newVal) -> {
|
||||||
|
updateDays();
|
||||||
|
if (onDateSelectedListener != null) {
|
||||||
|
onDateSelectedListener.onDateSelected(yearPicker.getValue(), monthPicker.getValue() - 1, dayPicker.getValue());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// 默认天数范围
|
// 默认天数范围
|
||||||
dayPicker.setMinValue(1);
|
dayPicker.setMinValue(1);
|
||||||
dayPicker.setMaxValue(maxDay);
|
dayPicker.setMaxValue(maxDay);
|
||||||
|
dayPicker.setOnValueChangedListener((picker, oldVal, newVal) -> {
|
||||||
|
if (onDateSelectedListener != null) {
|
||||||
|
onDateSelectedListener.onDateSelected(yearPicker.getValue(), monthPicker.getValue() - 1, dayPicker.getValue());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
yearPicker.setOnValueChangedListener((picker, oldVal, newVal) -> {
|
||||||
|
updateDays();
|
||||||
|
if (onDateSelectedListener != null) {
|
||||||
|
onDateSelectedListener.onDateSelected(yearPicker.getValue(), monthPicker.getValue() - 1, dayPicker.getValue());
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateDays() {
|
private void updateDays() {
|
||||||
@@ -94,4 +118,12 @@ public class WheelDatePicker extends LinearLayout {
|
|||||||
public int getDay() {
|
public int getDay() {
|
||||||
return dayPicker.getValue();
|
return dayPicker.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置日期选择监听器
|
||||||
|
* @param listener 监听器
|
||||||
|
*/
|
||||||
|
public void setOnDateSelectedListener(OnDateSelectedListener listener) {
|
||||||
|
this.onDateSelectedListener = listener;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -10,6 +10,13 @@ public class WheelTimePicker extends LinearLayout {
|
|||||||
private NumberPicker hourPicker, minutePicker, secondPicker;
|
private NumberPicker hourPicker, minutePicker, secondPicker;
|
||||||
private boolean showSeconds = true; // 默认显示秒
|
private boolean showSeconds = true; // 默认显示秒
|
||||||
|
|
||||||
|
// 值变化监听器接口
|
||||||
|
public interface OnValueChangedListener {
|
||||||
|
void onValueChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private OnValueChangedListener onValueChangedListener;
|
||||||
|
|
||||||
public WheelTimePicker(Context context) {
|
public WheelTimePicker(Context context) {
|
||||||
this(context, null);
|
this(context, null);
|
||||||
}
|
}
|
||||||
@@ -41,14 +48,29 @@ public class WheelTimePicker extends LinearLayout {
|
|||||||
// 设置小时范围
|
// 设置小时范围
|
||||||
hourPicker.setMinValue(0);
|
hourPicker.setMinValue(0);
|
||||||
hourPicker.setMaxValue(23);
|
hourPicker.setMaxValue(23);
|
||||||
|
hourPicker.setOnValueChangedListener((picker, oldVal, newVal) -> {
|
||||||
|
if (onValueChangedListener != null) {
|
||||||
|
onValueChangedListener.onValueChanged();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// 设置分钟范围
|
// 设置分钟范围
|
||||||
minutePicker.setMinValue(0);
|
minutePicker.setMinValue(0);
|
||||||
minutePicker.setMaxValue(59);
|
minutePicker.setMaxValue(59);
|
||||||
|
minutePicker.setOnValueChangedListener((picker, oldVal, newVal) -> {
|
||||||
|
if (onValueChangedListener != null) {
|
||||||
|
onValueChangedListener.onValueChanged();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// 秒范围
|
// 秒范围
|
||||||
secondPicker.setMinValue(0);
|
secondPicker.setMinValue(0);
|
||||||
secondPicker.setMaxValue(59);
|
secondPicker.setMaxValue(59);
|
||||||
|
secondPicker.setOnValueChangedListener((picker, oldVal, newVal) -> {
|
||||||
|
if (onValueChangedListener != null) {
|
||||||
|
onValueChangedListener.onValueChanged();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(int hour, int minute, int second) {
|
public void init(int hour, int minute, int second) {
|
||||||
@@ -79,4 +101,12 @@ public class WheelTimePicker extends LinearLayout {
|
|||||||
secondPicker.setVisibility(showSeconds ? VISIBLE : GONE);
|
secondPicker.setVisibility(showSeconds ? VISIBLE : GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置值变化监听器
|
||||||
|
* @param listener 监听器
|
||||||
|
*/
|
||||||
|
public void setOnValueChangedListener(OnValueChangedListener listener) {
|
||||||
|
this.onValueChangedListener = listener;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,30 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:padding="16dp">
|
android:padding="16dp">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="@dimen/dp_10"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_start"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:textSize="@dimen/sp_12" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_end"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:textSize="@dimen/sp_12" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<TabHost
|
<TabHost
|
||||||
android:id="@+id/tabHost"
|
android:id="@+id/tabHost"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
@@ -84,11 +84,11 @@ class GroupChatSettingsActivity :
|
|||||||
mBinding?.switJy?.setOnCheckedChangeListener { compoundButton, b ->
|
mBinding?.switJy?.setOnCheckedChangeListener { compoundButton, b ->
|
||||||
v2TIMGroupManager?.muteAllGroupMembers(groupId, b, object : V2TIMCallback {
|
v2TIMGroupManager?.muteAllGroupMembers(groupId, b, object : V2TIMCallback {
|
||||||
override fun onSuccess() {
|
override fun onSuccess() {
|
||||||
|
mBinding?.switJy?.isChecked = !b
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onError(code: Int, desc: String?) {
|
override fun onError(code: Int, desc: String?) {
|
||||||
mBinding?.switJy?.isChecked = !b
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,12 +145,15 @@ public class CreatedRoomActivity extends BaseMvpActivity<CreatedRoomPresenter, A
|
|||||||
mBinding.edNickName.setText(roomInfoResp.getRoom_info().getRoom_name());
|
mBinding.edNickName.setText(roomInfoResp.getRoom_info().getRoom_name());
|
||||||
mBinding.etG.setText(roomInfoResp.getRoom_info().getRoom_intro());
|
mBinding.etG.setText(roomInfoResp.getRoom_info().getRoom_intro());
|
||||||
roomUrl=roomInfoResp.getRoom_info().getRoom_cover();
|
roomUrl=roomInfoResp.getRoom_info().getRoom_cover();
|
||||||
|
mBinding.llSj.setVisibility(View.VISIBLE);
|
||||||
|
mBinding.tvSj.setText(roomInfoResp.getRoom_info().getStart_time() + "-" + roomInfoResp.getRoom_info().getEnd_time());
|
||||||
}else {
|
}else {
|
||||||
if (handler!=null ){
|
if (handler!=null ){
|
||||||
if (showPopupRunnable!=null){
|
if (showPopupRunnable!=null){
|
||||||
handler.post(showPopupRunnable);
|
handler.post(showPopupRunnable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mBinding.llSj.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
<data>
|
<data>
|
||||||
|
|
||||||
@@ -25,7 +26,7 @@
|
|||||||
android:id="@+id/top_bar"
|
android:id="@+id/top_bar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="-20dp"/>
|
android:layout_marginTop="-20dp" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -48,9 +49,9 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/dp_12"
|
||||||
android:text="房间封面"
|
android:text="房间封面"
|
||||||
android:textColor="@color/color_FF333333"
|
android:textColor="@color/color_FF333333"
|
||||||
android:layout_marginTop="@dimen/dp_12"
|
|
||||||
android:textSize="@dimen/sp_14" />
|
android:textSize="@dimen/sp_14" />
|
||||||
|
|
||||||
|
|
||||||
@@ -187,6 +188,38 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/ll_sj"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/dp_1"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:gravity="center|start"
|
||||||
|
android:paddingStart="@dimen/dp_16">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/dp_10"
|
||||||
|
android:layout_marginBottom="@dimen/dp_10"
|
||||||
|
android:text="营业时间"
|
||||||
|
android:textColor="@color/colorBlack45"
|
||||||
|
android:textSize="@dimen/sp_14" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_sj"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="@dimen/dp_16"
|
||||||
|
android:layout_marginStart="@dimen/dp_10"
|
||||||
|
tools:text="0/500"
|
||||||
|
android:textColor="@color/color_FF666666"
|
||||||
|
android:textSize="@dimen/sp_14" />
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|||||||
@@ -9,19 +9,18 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
>
|
||||||
|
|
||||||
<com.xscm.moduleutil.widget.CustomTopBar
|
<com.xscm.moduleutil.widget.CustomTopBar
|
||||||
android:id="@+id/top_bar"
|
android:id="@+id/top_bar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/top_bar">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/ll_search"
|
android:id="@+id/ll_search"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
Reference in New Issue
Block a user