新增排程页面重做
This commit is contained in:
@@ -11,6 +11,8 @@ import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.InputFilter;
|
||||
import android.text.InputType;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
@@ -20,6 +22,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
@@ -30,6 +33,7 @@ import androidx.core.app.ActivityCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.viewbinding.ViewBinding;
|
||||
|
||||
import com.ckkj.water.utils.show.ToastUtil;
|
||||
import com.esafirm.imagepicker.features.ImagePicker;
|
||||
import com.ckkj.water.AppConfig;
|
||||
import com.ckkj.water.ConstantUtil;
|
||||
@@ -70,6 +74,12 @@ public abstract class BaseFragment<T extends ViewBinding,P extends IPresenter> e
|
||||
protected static final int REQUEST_EVENT_CODE_10002 = 10002;
|
||||
protected static final int REQUEST_EVENT_CODE_10003 = 10003;
|
||||
|
||||
public static final int INPUT_TYPE_NORMAL = 0; // 默认
|
||||
public static final int INPUT_TYPE_NUMBER = 1; // 数字
|
||||
public static final int INPUT_TYPE_LETTER = 2; // 英文字母
|
||||
public static final int INPUT_TYPE_CHINESE = 3; // 中文
|
||||
public static final int INPUT_TYPE_NUMBER_LETTER = 4;//数字+字母
|
||||
|
||||
private static final AtomicBoolean isDialogShown = new AtomicBoolean(false); // 使用 AtomicBoolean 保证线程安全
|
||||
|
||||
|
||||
@@ -860,6 +870,193 @@ public abstract class BaseFragment<T extends ViewBinding,P extends IPresenter> e
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* +
|
||||
*
|
||||
* @param title 标题
|
||||
* @param hint 提示内容2
|
||||
* @param content 内容
|
||||
* @param touchOutsideCancel 弹窗类型
|
||||
* @param cancelText 取消 文案
|
||||
* @param confirmText 确定 文案
|
||||
* @param click
|
||||
*/
|
||||
public void showEditDialog(String title,
|
||||
String hint,
|
||||
String content,
|
||||
boolean touchOutsideCancel,
|
||||
String cancelText,
|
||||
String confirmText,
|
||||
int inputType,
|
||||
final BaseActivity.OnDialogClick click) {
|
||||
|
||||
View view = getLayoutInflater().inflate(
|
||||
R.layout.public_dialog_input_text,
|
||||
null
|
||||
);
|
||||
|
||||
EditText editText = view.findViewById(R.id.et_input);
|
||||
|
||||
//设置输入类型
|
||||
setEditInputType(editText,inputType);
|
||||
|
||||
if(TextUtils.isEmpty(content)){
|
||||
editText.setHint(hint);
|
||||
}else{
|
||||
editText.setText(content);
|
||||
editText.setSelection(content.length());
|
||||
}
|
||||
|
||||
setTextView(R.id.tv_title,title,view);
|
||||
|
||||
if (!TextUtils.isEmpty(confirmText)
|
||||
&& !TextUtils.isEmpty(cancelText)) {
|
||||
|
||||
((TextView)view.findViewById(R.id.btnLeft))
|
||||
.setText(cancelText);
|
||||
|
||||
((TextView)view.findViewById(R.id.btnRight))
|
||||
.setText(confirmText);
|
||||
}
|
||||
|
||||
view.findViewById(R.id.btnLeft)
|
||||
.setOnClickListener(v -> {
|
||||
|
||||
if(dialog!=null&&dialog.isShowing())
|
||||
dialog.dismiss();
|
||||
|
||||
if(click!=null)
|
||||
click.onCancelClick();
|
||||
|
||||
});
|
||||
|
||||
view.findViewById(R.id.btnRight)
|
||||
.setOnClickListener(v -> {
|
||||
|
||||
String value=editText.getText()
|
||||
.toString()
|
||||
.trim();
|
||||
|
||||
if(TextUtils.isEmpty(value)){
|
||||
ToastUtil.showShort(mContext,hint);
|
||||
return;
|
||||
}
|
||||
|
||||
if(dialog!=null&&dialog.isShowing())
|
||||
dialog.dismiss();
|
||||
|
||||
if(click!=null)
|
||||
click.onConfirmClisk(value);
|
||||
|
||||
});
|
||||
|
||||
AlertDialog.Builder builder;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||
builder = new AlertDialog.Builder(
|
||||
mContext,
|
||||
AlertDialog.THEME_HOLO_LIGHT
|
||||
);
|
||||
} else {
|
||||
builder = new AlertDialog.Builder(mContext);
|
||||
}
|
||||
|
||||
builder.setInverseBackgroundForced(true);
|
||||
builder.setView(view);
|
||||
|
||||
dialog = builder.show();
|
||||
|
||||
dialog.setCanceledOnTouchOutside(
|
||||
touchOutsideCancel
|
||||
);
|
||||
|
||||
try {
|
||||
((View)dialog.getWindow()
|
||||
.getDecorView()
|
||||
.findViewById(R.id.contentDialog)
|
||||
.getParent()
|
||||
.getParent())
|
||||
.setBackgroundColor(
|
||||
getResources().getColor(
|
||||
R.color.transparent
|
||||
)
|
||||
);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void setEditInputType(EditText editText,int type){
|
||||
|
||||
switch (type){
|
||||
|
||||
case INPUT_TYPE_NUMBER:
|
||||
//纯数字键盘
|
||||
editText.setInputType(
|
||||
InputType.TYPE_CLASS_NUMBER
|
||||
);
|
||||
break;
|
||||
|
||||
case INPUT_TYPE_LETTER:
|
||||
|
||||
//只能输入字母
|
||||
editText.setFilters(
|
||||
new InputFilter[]{
|
||||
(source,start,end,dest,dstart,dend)->{
|
||||
|
||||
if(source.toString()
|
||||
.matches("[a-zA-Z]+")){
|
||||
return source;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
||||
case INPUT_TYPE_CHINESE:
|
||||
|
||||
//只能输入中文
|
||||
editText.setFilters(
|
||||
new InputFilter[]{
|
||||
(source,start,end,dest,dstart,dend)->{
|
||||
|
||||
if(source.toString()
|
||||
.matches("[\\u4e00-\\u9fa5]+")){
|
||||
return source;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
||||
case INPUT_TYPE_NUMBER_LETTER:
|
||||
|
||||
//数字+字母
|
||||
editText.setFilters(
|
||||
new InputFilter[]{
|
||||
(source,start,end,dest,dstart,dend)->{
|
||||
|
||||
if(source.toString()
|
||||
.matches("[a-zA-Z0-9]+")){
|
||||
return source;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
||||
default:
|
||||
editText.setInputType(
|
||||
InputType.TYPE_CLASS_TEXT
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 权限请求结果回调
|
||||
*/
|
||||
|
||||
@@ -26,15 +26,15 @@ public class AddWaterPlanActivity extends BaseActivity<AddWaterPlanLayoutBinding
|
||||
implements WaterPlanContract.WaterPlanView {
|
||||
|
||||
private List<Fragment> mFragmentList = new ArrayList<>();
|
||||
private List<WaterPlanWeekEntity.DeviceEntity> mSelectedDevices = new ArrayList<>();
|
||||
|
||||
public List<WaterPlanWeekEntity.DeviceEntity> getSelectedDevices() {
|
||||
return mSelectedDevices;
|
||||
}
|
||||
|
||||
public void setSelectedDevices(List<WaterPlanWeekEntity.DeviceEntity> selectedDevices) {
|
||||
this.mSelectedDevices = selectedDevices;
|
||||
}
|
||||
// private List<WaterPlanWeekEntity.DeviceEntity> mSelectedDevices = new ArrayList<>();
|
||||
//
|
||||
// public List<WaterPlanWeekEntity.DeviceEntity> getSelectedDevices() {
|
||||
// return mSelectedDevices;
|
||||
// }
|
||||
//
|
||||
// public void setSelectedDevices(List<WaterPlanWeekEntity.DeviceEntity> selectedDevices) {
|
||||
// this.mSelectedDevices = selectedDevices;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public WaterPlanPresenter createPresenter() {
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.ckkj.water.base.BaseFragment;
|
||||
import com.ckkj.water.databinding.PlanBindDeviceLayoutBinding;
|
||||
import com.ckkj.water.main.activity.MainActivity;
|
||||
import com.ckkj.water.network.BaseBean;
|
||||
import com.ckkj.water.plan.adapter.BindDeviceAdapter;
|
||||
//import com.ckkj.water.plan.adapter.BindDeviceAdapter;
|
||||
import com.ckkj.water.plan.entity.WaterPlanWeekEntity;
|
||||
import com.ckkj.water.plan.mvp.WaterPlanContract;
|
||||
import com.ckkj.water.plan.mvp.WaterPlanImpl;
|
||||
@@ -29,35 +29,35 @@ public class BindDeviceFragment extends BaseFragment<PlanBindDeviceLayoutBinding
|
||||
implements WaterPlanContract.WaterPlanView {
|
||||
|
||||
private List<WaterPlanWeekEntity> weekList = new ArrayList<>();
|
||||
private BindDeviceAdapter mAdapter;
|
||||
// private BindDeviceAdapter mAdapter;
|
||||
|
||||
@Override
|
||||
public void initData(Bundle state) {
|
||||
String jsonContent = getString(R.string.plan_water_entity_json);
|
||||
WaterPlanWeekEntity entity = new Gson().fromJson(jsonContent, WaterPlanWeekEntity.class);
|
||||
weekList.add(entity);
|
||||
mAdapter = new BindDeviceAdapter(mContext,R.layout.plan_bind_device_item,weekList.get(0).getDeviceList());
|
||||
viewBinding.rvDevices.setAdapter(mAdapter);
|
||||
mAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
|
||||
mAdapter.toggleSelection(position);
|
||||
syncSelectedDevices();
|
||||
}
|
||||
});
|
||||
// mAdapter = new BindDeviceAdapter(mContext,R.layout.plan_bind_device_item,weekList.get(0).getDeviceList());
|
||||
// viewBinding.rvDevices.setAdapter(mAdapter);
|
||||
// mAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
|
||||
// @Override
|
||||
// public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
|
||||
// mAdapter.toggleSelection(position);
|
||||
// syncSelectedDevices();
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
private void syncSelectedDevices() {
|
||||
Set<Integer> selectedPositions = mAdapter.getSelectedPositions();
|
||||
List<WaterPlanWeekEntity.DeviceEntity> selected = new ArrayList<>();
|
||||
for (int pos : selectedPositions) {
|
||||
if (pos >= 0 && pos < weekList.get(0).getDeviceList().size()) {
|
||||
selected.add(weekList.get(0).getDeviceList().get(pos));
|
||||
}
|
||||
}
|
||||
if (getActivity() instanceof AddWaterPlanActivity) {
|
||||
((AddWaterPlanActivity) getActivity()).setSelectedDevices(selected);
|
||||
}
|
||||
// Set<Integer> selectedPositions = mAdapter.getSelectedPositions();
|
||||
// List<WaterPlanWeekEntity.DeviceEntity> selected = new ArrayList<>();
|
||||
// for (int pos : selectedPositions) {
|
||||
// if (pos >= 0 && pos < weekList.get(0).getDeviceList().size()) {
|
||||
// selected.add(weekList.get(0).getDeviceList().get(pos));
|
||||
// }
|
||||
// }
|
||||
// if (getActivity() instanceof AddWaterPlanActivity) {
|
||||
// ((AddWaterPlanActivity) getActivity()).setSelectedDevices(selected);
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,8 +7,8 @@ import com.ckkj.water.R;
|
||||
import com.ckkj.water.base.BaseActivity;
|
||||
import com.ckkj.water.databinding.WaterPlanDetailLayoutBinding;
|
||||
import com.ckkj.water.network.BaseBean;
|
||||
import com.ckkj.water.plan.adapter.PlanDetailDeviceAdapter;
|
||||
import com.ckkj.water.plan.adapter.PlanDetailTimeAdapter;
|
||||
//import com.ckkj.water.plan.adapter.PlanDetailDeviceAdapter;
|
||||
//import com.ckkj.water.plan.adapter.PlanDetailTimeAdapter;
|
||||
import com.ckkj.water.plan.entity.WaterPlanWeekEntity;
|
||||
import com.ckkj.water.plan.mvp.WaterPlanContract;
|
||||
import com.ckkj.water.plan.mvp.WaterPlanImpl;
|
||||
@@ -35,10 +35,10 @@ public class PlanDetailActivity extends BaseActivity<WaterPlanDetailLayoutBindin
|
||||
.init();
|
||||
viewBinding.includedTitle.tvTitle.setText(R.string.plan_detail_title);
|
||||
initListener();
|
||||
PlanDetailTimeAdapter timeAdapter = new PlanDetailTimeAdapter(R.layout.plan_detail_time_item,entity.getWashCycleList());
|
||||
viewBinding.rvPlanTime.setAdapter(timeAdapter);
|
||||
PlanDetailDeviceAdapter deviceAdapter = new PlanDetailDeviceAdapter(R.layout.plan_detail_bind_device_item,entity.getDeviceList());
|
||||
viewBinding.rvBindDevices.setAdapter(deviceAdapter);
|
||||
// PlanDetailTimeAdapter timeAdapter = new PlanDetailTimeAdapter(R.layout.plan_detail_time_item,entity.getWashCycleList());
|
||||
// viewBinding.rvPlanTime.setAdapter(timeAdapter);
|
||||
// PlanDetailDeviceAdapter deviceAdapter = new PlanDetailDeviceAdapter(R.layout.plan_detail_bind_device_item,entity.getDeviceList());
|
||||
// viewBinding.rvBindDevices.setAdapter(deviceAdapter);
|
||||
}
|
||||
|
||||
private void initListener() {
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.bigkoo.pickerview.listener.OnTimeSelectListener;
|
||||
import com.bigkoo.pickerview.view.TimePickerView;
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.ckkj.water.R;
|
||||
import com.ckkj.water.base.BaseActivity;
|
||||
import com.ckkj.water.base.BaseFragment;
|
||||
import com.ckkj.water.databinding.WaterConfigFragmentLayoutBinding;
|
||||
import com.ckkj.water.network.BaseBean;
|
||||
@@ -19,6 +20,8 @@ import com.ckkj.water.plan.entity.WaterPlanWeekEntity;
|
||||
import com.ckkj.water.plan.mvp.WaterPlanContract;
|
||||
import com.ckkj.water.plan.mvp.WaterPlanImpl;
|
||||
import com.ckkj.water.plan.mvp.WaterPlanPresenter;
|
||||
import com.ckkj.water.utils.show.ToastUtil;
|
||||
import com.ckkj.water.utils.text.TextUtil;
|
||||
import com.ckkj.water.utils.time.ZYTimeUtils;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
@@ -28,70 +31,110 @@ import java.util.List;
|
||||
|
||||
public class WaterConfigFragment extends BaseFragment<WaterConfigFragmentLayoutBinding, WaterPlanPresenter>
|
||||
implements WaterPlanContract.WaterPlanView {
|
||||
private List<WaterPlanWeekEntity> weekList = new ArrayList<>();
|
||||
private List<WaterPlanWeekEntity.DetailsBean> mConfigList = new ArrayList<>();
|
||||
|
||||
private WaterPlanWeekEntity mConfigEntity;
|
||||
private WaterPlanWeekAdapter mWeekAdapter;
|
||||
|
||||
|
||||
@Override
|
||||
public void initData(Bundle state) {
|
||||
String jsonContent = getString(R.string.plan_water_entity_json);
|
||||
WaterPlanWeekEntity entity = new Gson().fromJson(jsonContent, WaterPlanWeekEntity.class);
|
||||
weekList.add(entity);
|
||||
mWeekAdapter = new WaterPlanWeekAdapter(mContext, R.layout.plan_period_item,weekList.get(0).getWashCycleList());
|
||||
viewBinding.rvWeek.setAdapter(mWeekAdapter);
|
||||
mConfigEntity = new WaterPlanWeekEntity();
|
||||
List<WaterPlanWeekEntity.DetailsBean> list = new ArrayList<>();
|
||||
for(int i = 0; i < 7; i++){
|
||||
WaterPlanWeekEntity.DetailsBean bean = new WaterPlanWeekEntity.DetailsBean();
|
||||
bean.setWeekday(i);
|
||||
bean.setStatus("0");
|
||||
bean.setWeekName(ZYTimeUtils.getWeekName(i));
|
||||
list.add(bean);
|
||||
}
|
||||
mConfigEntity.setDetails(list);
|
||||
mWeekAdapter = new WaterPlanWeekAdapter(mContext,R.layout.plan_week_config_item, mConfigEntity.getDetails());
|
||||
viewBinding.rvWeekConfig.setAdapter(mWeekAdapter);
|
||||
initListener();
|
||||
}
|
||||
|
||||
private void initListener() {
|
||||
setClick(viewBinding.tvCommit);
|
||||
setClick(viewBinding.tvSelectTime);
|
||||
viewBinding.etPlanTime.addTextChangedListener(new TextWatcher() {
|
||||
//
|
||||
mWeekAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
if(weekList != null){
|
||||
String time = s.toString();
|
||||
if(TextUtils.isEmpty(time)){
|
||||
weekList.get(0).getWashCycleList().get(mWeekAdapter.getmPos()).setDuration("");
|
||||
public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
|
||||
switch (view.getId()){
|
||||
case R.id.linear_week://选中
|
||||
case R.id.checkbox:
|
||||
if(mConfigEntity.getDetails().get(position).getStatus().equals("1")){
|
||||
mConfigEntity.getDetails().get(position).setStatus("0");
|
||||
}else{
|
||||
weekList.get(0).getWashCycleList().get(mWeekAdapter.getmPos()).setDuration(time);
|
||||
mConfigEntity.getDetails().get(position).setStatus("1");
|
||||
}
|
||||
mWeekAdapter.notifyItemChanged(position);
|
||||
break;
|
||||
|
||||
case R.id.tv_select_time:
|
||||
selectStartTime(position);
|
||||
break;
|
||||
|
||||
case R.id.tv_plan_duration:
|
||||
inputDuration(position);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
mWeekAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
|
||||
private void inputDuration(int position) {
|
||||
showEditDialog(getString(R.string.device_work_times_title),
|
||||
getString(R.string.input_water_plan_time),
|
||||
mConfigEntity.getDetails().get(position).getDurationMin() == 0 ?
|
||||
"" : mConfigEntity.getDetails().get(position).getDurationMin() + "",
|
||||
true,
|
||||
getString(R.string.cancel_text),
|
||||
getString(R.string.confirm_text),
|
||||
BaseFragment.INPUT_TYPE_NUMBER,
|
||||
new BaseActivity.OnDialogClick() {
|
||||
@Override
|
||||
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
|
||||
mWeekAdapter.setSelPos(position);
|
||||
String planStartTime = weekList.get(0).getWashCycleList().get(position).getTime();
|
||||
String planTime = weekList.get(0).getWashCycleList().get(position).getDuration();
|
||||
|
||||
if(TextUtils.isEmpty(planStartTime)){
|
||||
viewBinding.tvSelectTime.setHint(getString(R.string.select_water_time));
|
||||
viewBinding.tvSelectTime.setText("");
|
||||
}else{
|
||||
viewBinding.tvSelectTime.setText(planStartTime);
|
||||
public void onCancelClick() {
|
||||
}
|
||||
|
||||
if(TextUtils.isEmpty(planTime)){
|
||||
viewBinding.etPlanTime.setHint(getString(R.string.input_water_plan_time));
|
||||
viewBinding.etPlanTime.setText("");
|
||||
}else{
|
||||
viewBinding.etPlanTime.setText(planTime);
|
||||
@Override
|
||||
public void onConfirmClisk() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfirmClisk(String content) {
|
||||
if(Integer.parseInt(content) <= 0){
|
||||
ToastUtil.showShort(mContext, getString(R.string.input_water_plan_time_error));
|
||||
return;
|
||||
}
|
||||
mConfigEntity.getDetails().get(position).setDurationMin(Integer.parseInt(content));
|
||||
mWeekAdapter.notifyItemChanged(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onView1Click() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void selectStartTime(int position) {
|
||||
boolean times[] = {false, false, false, true, true, false};
|
||||
//时间选择器
|
||||
TimePickerView pvTime = new TimePickerBuilder(mContext, new OnTimeSelectListener() {
|
||||
@Override
|
||||
public void onTimeSelect(Date date, View v) {
|
||||
mConfigEntity.getDetails().get(position).setStartTime(ZYTimeUtils.getStrTimeData_H_M(date));
|
||||
mWeekAdapter.notifyItemChanged(position);
|
||||
}
|
||||
}).setType(times)
|
||||
.setCancelColor(mContext.getColor(R.color.color_999999))
|
||||
.setSubmitColor(mContext.getColor(R.color.color_zhu))
|
||||
.setTextColorCenter(mContext.getColor(R.color.color_zhu))
|
||||
.build();
|
||||
pvTime.show();
|
||||
}
|
||||
|
||||
private void setClick(View view) {
|
||||
view.setOnClickListener(this::onClick);
|
||||
}
|
||||
@@ -99,41 +142,49 @@ public class WaterConfigFragment extends BaseFragment<WaterConfigFragmentLayoutB
|
||||
public void onClick(View v){
|
||||
switch (v.getId()){
|
||||
case R.id.tv_select_time:
|
||||
boolean times[] = {false, false, false, true, true, false};
|
||||
//时间选择器
|
||||
TimePickerView pvTime = new TimePickerBuilder(mContext, new OnTimeSelectListener() {
|
||||
@Override
|
||||
public void onTimeSelect(Date date, View v) {
|
||||
viewBinding.tvSelectTime.setText(ZYTimeUtils.getStrTimeData_H_M(date));
|
||||
if(weekList != null){
|
||||
String startTime = ZYTimeUtils.getStrTimeData_H_M(date).trim();
|
||||
weekList.get(0).getWashCycleList().get(mWeekAdapter.getmPos()).setTime(startTime);
|
||||
}
|
||||
}
|
||||
}).setType(times)
|
||||
.setCancelColor(mContext.getColor(R.color.color_999999))
|
||||
.setSubmitColor(mContext.getColor(R.color.color_zhu))
|
||||
.setTextColorCenter(mContext.getColor(R.color.color_zhu))
|
||||
.build();
|
||||
pvTime.show();
|
||||
break;
|
||||
|
||||
case R.id.tv_commit:
|
||||
List<WaterPlanWeekEntity.DeviceEntity> list = getSelectedDevices();
|
||||
if(list != null){
|
||||
|
||||
if(checkConfigFinish()){
|
||||
ToastUtil.showShort(mContext,"提交");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkConfigFinish() {
|
||||
if(TextUtils.isEmpty(viewBinding.etPlanName.getText().toString())){
|
||||
ToastUtil.showShort(mContext,getString(R.string.plan_name_text_empty_hint));
|
||||
return false;
|
||||
}
|
||||
List<WaterPlanWeekEntity.DetailsBean> list = mConfigEntity.getDetails();
|
||||
//是否勾选了排程日期
|
||||
boolean isSelectOne = false;
|
||||
if(list != null){
|
||||
for(WaterPlanWeekEntity.DetailsBean bean : list){
|
||||
if(bean.getStatus().equals("1")){
|
||||
isSelectOne = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!isSelectOne){
|
||||
ToastUtil.showShort(mContext,getString(R.string.plan_week_empty_hint));
|
||||
return false;
|
||||
}
|
||||
//是否配置了排程日期的时间
|
||||
boolean isPlanConfig = false;
|
||||
for(WaterPlanWeekEntity.DetailsBean bean : list){
|
||||
if(bean.getStatus().equals("1")){
|
||||
if((TextUtils.isEmpty(bean.getStartTime()) ||
|
||||
bean.getDurationMin() == 0)){
|
||||
ToastUtil.showShort(mContext,"请完成" + bean.getWeekName() + "的时间配置");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private List<WaterPlanWeekEntity.DeviceEntity> getSelectedDevices() {
|
||||
if (getActivity() instanceof AddWaterPlanActivity) {
|
||||
return ((AddWaterPlanActivity) getActivity()).getSelectedDevices();
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WaterPlanPresenter createPresenter() {
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.ckkj.water.base.BaseFragment;
|
||||
import com.ckkj.water.databinding.WaterPlanFragmentBinding;
|
||||
import com.ckkj.water.main.activity.MainActivity;
|
||||
import com.ckkj.water.network.BaseBean;
|
||||
import com.ckkj.water.plan.adapter.WaterPlanListAdapter;
|
||||
//import com.ckkj.water.plan.adapter.WaterPlanListAdapter;
|
||||
import com.ckkj.water.plan.entity.WaterPlanWeekEntity;
|
||||
import com.ckkj.water.plan.mvp.WaterPlanContract;
|
||||
import com.ckkj.water.plan.mvp.WaterPlanImpl;
|
||||
@@ -25,14 +25,14 @@ import java.util.List;
|
||||
|
||||
public class WaterPlanFragment extends BaseFragment<WaterPlanFragmentBinding, WaterPlanPresenter>
|
||||
implements WaterPlanContract.WaterPlanView {
|
||||
private List<WaterPlanWeekEntity.DeviceEntity> mDevList = new ArrayList<>();
|
||||
private WaterPlanListAdapter mAdapter;
|
||||
// private List<WaterPlanWeekEntity.DeviceEntity> mDevList = new ArrayList<>();
|
||||
// private WaterPlanListAdapter mAdapter;
|
||||
@Override
|
||||
public void initData(Bundle state) {
|
||||
|
||||
String jsonContent = getString(R.string.plan_water_entity_json);
|
||||
WaterPlanWeekEntity entity = new Gson().fromJson(jsonContent, WaterPlanWeekEntity.class);
|
||||
mDevList = entity.getDeviceList();
|
||||
// mDevList = entity.getDeviceList();
|
||||
|
||||
ImmersionBar.with(mContext)
|
||||
.statusBarColor(R.color.mainBackgroundColor)
|
||||
@@ -43,14 +43,14 @@ public class WaterPlanFragment extends BaseFragment<WaterPlanFragmentBinding, Wa
|
||||
viewBinding.includedTitle.tvTitle.setText(getString(R.string.plan_title));
|
||||
initListener();
|
||||
|
||||
mAdapter = new WaterPlanListAdapter(mContext,R.layout.water_plan_list_item,mDevList);
|
||||
viewBinding.rvPlans.setAdapter(mAdapter);
|
||||
mAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
|
||||
goTo(mContext, PlanDetailActivity.class,null);
|
||||
}
|
||||
});
|
||||
// mAdapter = new WaterPlanListAdapter(mContext,R.layout.water_plan_list_item,mDevList);
|
||||
// viewBinding.rvPlans.setAdapter(mAdapter);
|
||||
// mAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
|
||||
// @Override
|
||||
// public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
|
||||
// goTo(mContext, PlanDetailActivity.class,null);
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,55 +1,55 @@
|
||||
package com.ckkj.water.plan.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.widget.CheckBox;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.ckkj.water.R;
|
||||
import com.ckkj.water.plan.entity.WaterPlanWeekEntity;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class BindDeviceAdapter extends BaseQuickAdapter<WaterPlanWeekEntity.DeviceEntity, BaseViewHolder> {
|
||||
private Context mContext;
|
||||
private Set<Integer> mSelectedPositions = new HashSet<>();
|
||||
|
||||
public BindDeviceAdapter(Context context, int layoutResId, @Nullable List<WaterPlanWeekEntity.DeviceEntity> data) {
|
||||
super(layoutResId, data);
|
||||
this.mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, WaterPlanWeekEntity.DeviceEntity item) {
|
||||
CheckBox checkBox = helper.getView(R.id.radio);
|
||||
helper.setText(R.id.tv_device_name, item.getDeviceName());
|
||||
helper.setText(R.id.tv_device_serial, item.getDeviceCode());
|
||||
checkBox.setChecked(mSelectedPositions.contains(helper.getLayoutPosition()));
|
||||
}
|
||||
|
||||
public void toggleSelection(int position) {
|
||||
if (mSelectedPositions.contains(position)) {
|
||||
mSelectedPositions.remove(position);
|
||||
} else {
|
||||
mSelectedPositions.add(position);
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void clearSelection() {
|
||||
mSelectedPositions.clear();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public Set<Integer> getSelectedPositions() {
|
||||
return new HashSet<>(mSelectedPositions);
|
||||
}
|
||||
|
||||
public int getSelectedCount() {
|
||||
return mSelectedPositions.size();
|
||||
}
|
||||
}
|
||||
//package com.ckkj.water.plan.adapter;
|
||||
//
|
||||
//import android.content.Context;
|
||||
//import android.widget.CheckBox;
|
||||
//
|
||||
//import androidx.annotation.Nullable;
|
||||
//
|
||||
//import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
//import com.chad.library.adapter.base.BaseViewHolder;
|
||||
//import com.ckkj.water.R;
|
||||
//import com.ckkj.water.plan.entity.WaterPlanWeekEntity;
|
||||
//
|
||||
//import java.util.HashSet;
|
||||
//import java.util.List;
|
||||
//import java.util.Set;
|
||||
//
|
||||
//public class BindDeviceAdapter extends BaseQuickAdapter<WaterPlanWeekEntity.DeviceEntity, BaseViewHolder> {
|
||||
// private Context mContext;
|
||||
// private Set<Integer> mSelectedPositions = new HashSet<>();
|
||||
//
|
||||
// public BindDeviceAdapter(Context context, int layoutResId, @Nullable List<WaterPlanWeekEntity.DeviceEntity> data) {
|
||||
// super(layoutResId, data);
|
||||
// this.mContext = context;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void convert(BaseViewHolder helper, WaterPlanWeekEntity.DeviceEntity item) {
|
||||
// CheckBox checkBox = helper.getView(R.id.radio);
|
||||
// helper.setText(R.id.tv_device_name, item.getDeviceName());
|
||||
// helper.setText(R.id.tv_device_serial, item.getDeviceCode());
|
||||
// checkBox.setChecked(mSelectedPositions.contains(helper.getLayoutPosition()));
|
||||
// }
|
||||
//
|
||||
// public void toggleSelection(int position) {
|
||||
// if (mSelectedPositions.contains(position)) {
|
||||
// mSelectedPositions.remove(position);
|
||||
// } else {
|
||||
// mSelectedPositions.add(position);
|
||||
// }
|
||||
// notifyDataSetChanged();
|
||||
// }
|
||||
//
|
||||
// public void clearSelection() {
|
||||
// mSelectedPositions.clear();
|
||||
// notifyDataSetChanged();
|
||||
// }
|
||||
//
|
||||
// public Set<Integer> getSelectedPositions() {
|
||||
// return new HashSet<>(mSelectedPositions);
|
||||
// }
|
||||
//
|
||||
// public int getSelectedCount() {
|
||||
// return mSelectedPositions.size();
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
package com.ckkj.water.plan.adapter;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.ckkj.water.R;
|
||||
import com.ckkj.water.plan.entity.WaterPlanWeekEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PlanDetailDeviceAdapter extends BaseQuickAdapter<WaterPlanWeekEntity.DeviceEntity, BaseViewHolder> {
|
||||
|
||||
public PlanDetailDeviceAdapter(int layoutResId, @Nullable List<WaterPlanWeekEntity.DeviceEntity> data) {
|
||||
super(layoutResId, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, WaterPlanWeekEntity.DeviceEntity item) {
|
||||
helper.setText(R.id.tv_device_name,item.getDeviceName());
|
||||
helper.setText(R.id.tv_device_serial,item.getDeviceCode());
|
||||
}
|
||||
}
|
||||
//package com.ckkj.water.plan.adapter;
|
||||
//
|
||||
//import androidx.annotation.Nullable;
|
||||
//
|
||||
//import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
//import com.chad.library.adapter.base.BaseViewHolder;
|
||||
//import com.ckkj.water.R;
|
||||
//import com.ckkj.water.plan.entity.WaterPlanWeekEntity;
|
||||
//
|
||||
//import java.util.List;
|
||||
//
|
||||
//public class PlanDetailDeviceAdapter extends BaseQuickAdapter<WaterPlanWeekEntity.DeviceEntity, BaseViewHolder> {
|
||||
//
|
||||
// public PlanDetailDeviceAdapter(int layoutResId, @Nullable List<WaterPlanWeekEntity.DeviceEntity> data) {
|
||||
// super(layoutResId, data);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void convert(BaseViewHolder helper, WaterPlanWeekEntity.DeviceEntity item) {
|
||||
// helper.setText(R.id.tv_device_name,item.getDeviceName());
|
||||
// helper.setText(R.id.tv_device_serial,item.getDeviceCode());
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
package com.ckkj.water.plan.adapter;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.ckkj.water.R;
|
||||
import com.ckkj.water.plan.entity.WaterPlanWeekEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PlanDetailTimeAdapter extends BaseQuickAdapter<WaterPlanWeekEntity.WashCycleEntity, BaseViewHolder> {
|
||||
|
||||
public PlanDetailTimeAdapter(int layoutResId, @Nullable List<WaterPlanWeekEntity.WashCycleEntity> data) {
|
||||
super(layoutResId, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, WaterPlanWeekEntity.WashCycleEntity item) {
|
||||
helper.setText(R.id.tv_week,item.getWeek());
|
||||
helper.setText(R.id.tv_start_time,item.getTime());
|
||||
helper.setText(R.id.tv_duration,item.getDuration());
|
||||
}
|
||||
}
|
||||
//package com.ckkj.water.plan.adapter;
|
||||
//
|
||||
//import androidx.annotation.Nullable;
|
||||
//
|
||||
//import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
//import com.chad.library.adapter.base.BaseViewHolder;
|
||||
//import com.ckkj.water.R;
|
||||
//import com.ckkj.water.plan.entity.WaterPlanWeekEntity;
|
||||
//
|
||||
//import java.util.List;
|
||||
//
|
||||
//public class PlanDetailTimeAdapter extends BaseQuickAdapter<WaterPlanWeekEntity.WashCycleEntity, BaseViewHolder> {
|
||||
//
|
||||
// public PlanDetailTimeAdapter(int layoutResId, @Nullable List<WaterPlanWeekEntity.WashCycleEntity> data) {
|
||||
// super(layoutResId, data);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void convert(BaseViewHolder helper, WaterPlanWeekEntity.WashCycleEntity item) {
|
||||
// helper.setText(R.id.tv_week,item.getWeek());
|
||||
// helper.setText(R.id.tv_start_time,item.getTime());
|
||||
// helper.setText(R.id.tv_duration,item.getDuration());
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
package com.ckkj.water.plan.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.widget.CheckBox;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.ckkj.water.R;
|
||||
import com.ckkj.water.plan.entity.WaterPlanWeekEntity;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class WaterPlanListAdapter extends BaseQuickAdapter<WaterPlanWeekEntity.DeviceEntity, BaseViewHolder> {
|
||||
private Context mContext;
|
||||
|
||||
public WaterPlanListAdapter(Context context, int layoutResId, @Nullable List<WaterPlanWeekEntity.DeviceEntity> data) {
|
||||
super(layoutResId, data);
|
||||
this.mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, WaterPlanWeekEntity.DeviceEntity item) {
|
||||
helper.setText(R.id.tv_device_name, item.getDeviceName());
|
||||
helper.setText(R.id.tv_device_serial, item.getDeviceCode());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
//package com.ckkj.water.plan.adapter;
|
||||
//
|
||||
//import android.content.Context;
|
||||
//import android.widget.CheckBox;
|
||||
//
|
||||
//import androidx.annotation.Nullable;
|
||||
//
|
||||
//import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
//import com.chad.library.adapter.base.BaseViewHolder;
|
||||
//import com.ckkj.water.R;
|
||||
//import com.ckkj.water.plan.entity.WaterPlanWeekEntity;
|
||||
//
|
||||
//import java.util.HashSet;
|
||||
//import java.util.List;
|
||||
//import java.util.Set;
|
||||
//
|
||||
//public class WaterPlanListAdapter extends BaseQuickAdapter<WaterPlanWeekEntity.DeviceEntity, BaseViewHolder> {
|
||||
// private Context mContext;
|
||||
//
|
||||
// public WaterPlanListAdapter(Context context, int layoutResId, @Nullable List<WaterPlanWeekEntity.DeviceEntity> data) {
|
||||
// super(layoutResId, data);
|
||||
// this.mContext = context;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void convert(BaseViewHolder helper, WaterPlanWeekEntity.DeviceEntity item) {
|
||||
// helper.setText(R.id.tv_device_name, item.getDeviceName());
|
||||
// helper.setText(R.id.tv_device_serial, item.getDeviceCode());
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//}
|
||||
|
||||
@@ -7,7 +7,9 @@ import static android.view.View.VISIBLE;
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
@@ -19,36 +21,66 @@ import com.ckkj.water.plan.entity.WaterPlanWeekEntity;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class WaterPlanWeekAdapter extends BaseQuickAdapter<WaterPlanWeekEntity.WashCycleEntity, BaseViewHolder> {
|
||||
private List<WaterPlanWeekEntity.WashCycleEntity> mList = new ArrayList<>();
|
||||
public class WaterPlanWeekAdapter extends BaseQuickAdapter<WaterPlanWeekEntity.DetailsBean, BaseViewHolder> {
|
||||
private List<WaterPlanWeekEntity.DetailsBean> mList = new ArrayList<>();
|
||||
private Context mContext;
|
||||
|
||||
private int mPos = 0;
|
||||
public WaterPlanWeekAdapter(Context context,int layoutResId, @Nullable List<WaterPlanWeekEntity.WashCycleEntity> data) {
|
||||
public WaterPlanWeekAdapter(Context context,int layoutResId, @Nullable List<WaterPlanWeekEntity.DetailsBean> data) {
|
||||
super(layoutResId, data);
|
||||
this.mContext = context;
|
||||
this.mList = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, WaterPlanWeekEntity.WashCycleEntity item) {
|
||||
helper.setText(R.id.tv_week,item.getWeek());
|
||||
LinearLayout linearItem = helper.getView(R.id.linear_item);
|
||||
View viewStatus = helper.getView(R.id.view_status);
|
||||
if(helper.getLayoutPosition() == mPos){
|
||||
linearItem.setBackground(mContext.getResources().getDrawable(R.drawable.shape_water_period_sel_bg));
|
||||
viewStatus.setVisibility(VISIBLE);
|
||||
viewStatus.setBackground(mContext.getResources().getDrawable(R.drawable.shape_green_circle));
|
||||
protected void convert(BaseViewHolder helper, WaterPlanWeekEntity.DetailsBean item) {
|
||||
TextView tvStartTime = helper.getView(R.id.tv_select_time);
|
||||
CheckBox checkBox = helper.getView(R.id.checkbox);
|
||||
TextView tvPlanDuration = helper.getView(R.id.tv_plan_duration);
|
||||
|
||||
|
||||
helper.setText(R.id.tv_week_name,item.getWeekName());
|
||||
|
||||
if(!TextUtils.isEmpty(item.getStartTime())){
|
||||
helper.setText(R.id.tv_select_time,item.getStartTime());
|
||||
}else{
|
||||
linearItem.setBackground(null);
|
||||
if(!TextUtils.isEmpty(item.getTime()) && !TextUtils.isEmpty(item.getDuration())){
|
||||
viewStatus.setVisibility(VISIBLE);
|
||||
viewStatus.setBackground(mContext.getResources().getDrawable(R.drawable.shape_yellow_circle));
|
||||
helper.setText(R.id.tv_select_time,"");
|
||||
tvStartTime.setHint(mContext.getString(R.string.select_water_time));
|
||||
}
|
||||
if(item.getDurationMin() != 0){
|
||||
helper.setText(R.id.tv_plan_duration,item.getDurationMin() + "");
|
||||
}else{
|
||||
viewStatus.setVisibility(INVISIBLE);
|
||||
viewStatus.setBackground(null);
|
||||
helper.setText(R.id.tv_plan_duration,"");
|
||||
tvPlanDuration.setHint(mContext.getString(R.string.input_water_plan_time));
|
||||
}
|
||||
|
||||
if(item.getStatus().equals("1")){
|
||||
checkBox.setChecked(true);
|
||||
}else{
|
||||
checkBox.setChecked(false);
|
||||
}
|
||||
|
||||
helper.addOnClickListener(R.id.linear_week);
|
||||
helper.addOnClickListener(R.id.checkbox);
|
||||
helper.addOnClickListener(R.id.tv_select_time);
|
||||
helper.addOnClickListener(R.id.tv_plan_duration);
|
||||
|
||||
// LinearLayout linearItem = helper.getView(R.id.linear_item);
|
||||
// View viewStatus = helper.getView(R.id.view_status);
|
||||
// if(helper.getLayoutPosition() == mPos){
|
||||
// linearItem.setBackground(mContext.getResources().getDrawable(R.drawable.shape_water_period_sel_bg));
|
||||
// viewStatus.setVisibility(VISIBLE);
|
||||
// viewStatus.setBackground(mContext.getResources().getDrawable(R.drawable.shape_green_circle));
|
||||
// }else{
|
||||
// linearItem.setBackground(null);
|
||||
// if(!TextUtils.isEmpty(item.getTime()) && !TextUtils.isEmpty(item.getDuration())){
|
||||
// viewStatus.setVisibility(VISIBLE);
|
||||
// viewStatus.setBackground(mContext.getResources().getDrawable(R.drawable.shape_yellow_circle));
|
||||
// }else{
|
||||
// viewStatus.setVisibility(INVISIBLE);
|
||||
// viewStatus.setBackground(null);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
public void setSelPos(int position) {
|
||||
|
||||
@@ -3,150 +3,62 @@ package com.ckkj.water.plan.entity;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class WaterPlanWeekEntity implements Serializable {
|
||||
|
||||
/**
|
||||
* 排程名称
|
||||
*/
|
||||
private String scheduleName;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
* id : 2057637613963182082
|
||||
* userId : 2056543507514097665
|
||||
* name : 排程四
|
||||
* deviceIds : null
|
||||
* status : 1
|
||||
* details : [{"createDept":null,"createBy":"2056543507514097665","createTime":"2026-05-22 09:40:10","updateBy":"2056543507514097665","updateTime":"2026-05-22 09:40:10","id":"2057637613963182083","scheduleId":"2057637613963182082","weekday":1,"startTime":"2026-04-11 10:12:12","durationMin":20,"zones":null,"triggerType":"0","status":"1"},{"createDept":null,"createBy":"2056543507514097665","createTime":"2026-05-22 09:40:10","updateBy":"2056543507514097665","updateTime":"2026-05-22 09:40:10","id":"2057637613963182084","scheduleId":"2057637613963182082","weekday":2,"startTime":"2026-04-11 10:12:12","durationMin":20,"zones":null,"triggerType":"0","status":"1"},{"createDept":null,"createBy":"2056543507514097665","createTime":"2026-05-22 09:40:10","updateBy":"2056543507514097665","updateTime":"2026-05-22 09:40:10","id":"2057637613963182085","scheduleId":"2057637613963182082","weekday":3,"startTime":"2026-04-11 10:12:12","durationMin":20,"zones":null,"triggerType":"0","status":"1"}]
|
||||
*/
|
||||
private boolean enable;
|
||||
|
||||
private String id;
|
||||
private String userId;
|
||||
private String name;
|
||||
private Object deviceIds;
|
||||
private String status;
|
||||
private List<DetailsBean> details;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class DetailsBean implements Serializable{
|
||||
/**
|
||||
* 洗水周期列表
|
||||
* createDept : null
|
||||
* createBy : 2056543507514097665
|
||||
* createTime : 2026-05-22 09:40:10
|
||||
* updateBy : 2056543507514097665
|
||||
* updateTime : 2026-05-22 09:40:10
|
||||
* id : 2057637613963182083
|
||||
* scheduleId : 2057637613963182082
|
||||
* weekday : 1
|
||||
* startTime : 2026-04-11 10:12:12
|
||||
* durationMin : 20
|
||||
* zones : null
|
||||
* triggerType : 0
|
||||
* status : 1
|
||||
*/
|
||||
private List<WashCycleEntity> washCycleList;
|
||||
|
||||
/**
|
||||
* 关联设备列表
|
||||
*/
|
||||
private List<DeviceEntity> deviceList;
|
||||
|
||||
public String getScheduleName() {
|
||||
return scheduleName;
|
||||
}
|
||||
|
||||
public void setScheduleName(String scheduleName) {
|
||||
this.scheduleName = scheduleName;
|
||||
}
|
||||
|
||||
public boolean isEnable() {
|
||||
return enable;
|
||||
}
|
||||
|
||||
public void setEnable(boolean enable) {
|
||||
this.enable = enable;
|
||||
}
|
||||
|
||||
public List<WashCycleEntity> getWashCycleList() {
|
||||
return washCycleList;
|
||||
}
|
||||
|
||||
public void setWashCycleList(List<WashCycleEntity> washCycleList) {
|
||||
this.washCycleList = washCycleList;
|
||||
}
|
||||
|
||||
public List<DeviceEntity> getDeviceList() {
|
||||
return deviceList;
|
||||
}
|
||||
|
||||
public void setDeviceList(List<DeviceEntity> deviceList) {
|
||||
this.deviceList = deviceList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 洗水周期
|
||||
*/
|
||||
public static class WashCycleEntity {
|
||||
|
||||
/**
|
||||
* 星期
|
||||
* 如:周一
|
||||
*/
|
||||
private String week;
|
||||
|
||||
/**
|
||||
* 时间
|
||||
* 如:10:30
|
||||
*/
|
||||
private String time;
|
||||
|
||||
/**
|
||||
* 时长
|
||||
* 如:10min
|
||||
*/
|
||||
private String duration;
|
||||
|
||||
public String getWeek() {
|
||||
return week;
|
||||
}
|
||||
|
||||
public void setWeek(String week) {
|
||||
this.week = week;
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(String time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public String getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public void setDuration(String duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备实体
|
||||
*/
|
||||
public static class DeviceEntity {
|
||||
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
private String deviceName;
|
||||
|
||||
/**
|
||||
* 设备编号
|
||||
*/
|
||||
private String deviceCode;
|
||||
|
||||
/**
|
||||
* 是否已关联
|
||||
*/
|
||||
private boolean bind;
|
||||
|
||||
public String getDeviceName() {
|
||||
return deviceName;
|
||||
}
|
||||
|
||||
public void setDeviceName(String deviceName) {
|
||||
this.deviceName = deviceName;
|
||||
}
|
||||
|
||||
public String getDeviceCode() {
|
||||
return deviceCode;
|
||||
}
|
||||
|
||||
public void setDeviceCode(String deviceCode) {
|
||||
this.deviceCode = deviceCode;
|
||||
}
|
||||
|
||||
public boolean isBind() {
|
||||
return bind;
|
||||
}
|
||||
|
||||
public void setBind(boolean bind) {
|
||||
this.bind = bind;
|
||||
}
|
||||
private Object createDept;
|
||||
private String createBy;
|
||||
private String createTime;
|
||||
private String updateBy;
|
||||
private String updateTime;
|
||||
private String id;
|
||||
private String scheduleId;
|
||||
private int weekday;
|
||||
private String weekName;
|
||||
private String startTime;
|
||||
private int durationMin = 0;
|
||||
private Object zones;
|
||||
private String triggerType;
|
||||
private String status;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -974,4 +974,18 @@ public class ZYTimeUtils {
|
||||
}
|
||||
}
|
||||
|
||||
private static final String[] WEEK_NAMES = {"周一", "周二", "周三", "周四", "周五", "周六", "周日"};
|
||||
|
||||
/**
|
||||
* 根据星期索引获取星期名称
|
||||
* @param weekday 星期索引,0=周一,1=周二,...,6=周日
|
||||
* @return 对应的星期名称
|
||||
*/
|
||||
public static String getWeekName(int weekday) {
|
||||
if (weekday >= 0 && weekday < 7) {
|
||||
return WEEK_NAMES[weekday];
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
133
app/src/main/res/layout/plan_week_config_item.xml
Normal file
133
app/src/main/res/layout/plan_week_config_item.xml
Normal file
@@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_20">
|
||||
<LinearLayout
|
||||
android:id="@+id/linear_week"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_marginHorizontal="@dimen/dp_20"
|
||||
android:background="@drawable/shape_zhu_line_radiu_20button_bg">
|
||||
<TextView
|
||||
android:id="@+id/tv_week_name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:paddingVertical="@dimen/dp_10"
|
||||
android:paddingLeft="@dimen/dp_20"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/color_zhu"
|
||||
android:text="星期一"/>
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="3"
|
||||
android:layout_height="0dp"/>
|
||||
<CheckBox
|
||||
android:id="@+id/checkbox"
|
||||
android:layout_width="@dimen/dp_15"
|
||||
android:layout_height="@dimen/dp_15"
|
||||
android:layout_marginRight="@dimen/dp_20"
|
||||
android:background="@drawable/select_radio"
|
||||
android:checked="false"
|
||||
android:button="@null"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_10"
|
||||
android:layout_marginHorizontal="@dimen/dp_20"
|
||||
android:paddingHorizontal="@dimen/dp_20"
|
||||
android:orientation="vertical"
|
||||
android:background="@drawable/shape_water_plan_time_bg">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/red"
|
||||
android:text="*"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/dp_4"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/color_222222"
|
||||
android:text="@string/plan_start_time"
|
||||
android:layout_marginVertical="@dimen/dp_13"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_select_time"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="9"
|
||||
android:gravity="center_vertical"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/color_222222"
|
||||
android:layout_marginLeft="@dimen/dp_10"
|
||||
android:hint="@string/select_water_time"/>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/dp_24"
|
||||
android:layout_weight="0.5"
|
||||
android:src="@mipmap/icon_point_right_wt"/>
|
||||
</LinearLayout>
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@color/color_d9d9d9"/>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/red"
|
||||
android:text="*"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/dp_4"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/color_222222"
|
||||
android:text="@string/plan_time"
|
||||
android:layout_marginVertical="@dimen/dp_13"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_plan_duration"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="9"
|
||||
android:gravity="center_vertical"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/color_222222"
|
||||
android:layout_marginLeft="@dimen/dp_10"
|
||||
android:hint="@string/input_water_plan_time"
|
||||
android:inputType="number"/>
|
||||
<TextView
|
||||
android:id="@+id/tv_time_unit"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="2"
|
||||
android:gravity="center_vertical|right"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/color_222222"
|
||||
android:layout_marginLeft="@dimen/dp_10"
|
||||
android:hint="min"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
@@ -1,10 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.core.widget.NestedScrollView 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:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -28,6 +32,7 @@
|
||||
android:layout_marginVertical="@dimen/dp_13"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/et_plan_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical"
|
||||
@@ -66,112 +71,11 @@
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_week"
|
||||
android:id="@+id/rv_week_config"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="@dimen/dp_12"
|
||||
android:layout_gravity="center"
|
||||
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
|
||||
tools:listitem="@layout/plan_period_item"
|
||||
tools:itemCount="7"
|
||||
app:spanCount="7"/>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_15"
|
||||
android:layout_marginHorizontal="@dimen/dp_20"
|
||||
android:paddingHorizontal="@dimen/dp_20"
|
||||
android:orientation="vertical"
|
||||
android:background="@drawable/shape_water_plan_time_bg">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/red"
|
||||
android:text="*"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/dp_4"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/color_222222"
|
||||
android:text="@string/plan_start_time"
|
||||
android:layout_marginVertical="@dimen/dp_13"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_select_time"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="9"
|
||||
android:gravity="center_vertical"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/color_222222"
|
||||
android:layout_marginLeft="@dimen/dp_10"
|
||||
android:hint="@string/select_water_time"/>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/dp_24"
|
||||
android:layout_weight="0.5"
|
||||
android:src="@mipmap/icon_point_right_wt"/>
|
||||
</LinearLayout>
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@color/color_d9d9d9"/>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/red"
|
||||
android:text="*"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/dp_4"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/color_222222"
|
||||
android:text="@string/plan_time"
|
||||
android:layout_marginVertical="@dimen/dp_13"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/et_plan_time"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="9"
|
||||
android:gravity="center_vertical"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/color_222222"
|
||||
android:background="@null"
|
||||
android:layout_marginLeft="@dimen/dp_10"
|
||||
android:hint="@string/input_water_plan_time"
|
||||
android:imeOptions="actionDone"
|
||||
android:inputType="number"/>
|
||||
<TextView
|
||||
android:id="@+id/tv_time_unit"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="2"
|
||||
android:gravity="center_vertical|right"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/color_222222"
|
||||
android:layout_marginLeft="@dimen/dp_10"
|
||||
android:hint="min"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
tools:listitem="@layout/plan_week_config_item"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"/>
|
||||
<TextView
|
||||
android:id="@+id/tv_commit"
|
||||
android:layout_width="match_parent"
|
||||
@@ -183,5 +87,8 @@
|
||||
android:paddingVertical="@dimen/dp_10"
|
||||
android:layout_marginHorizontal="@dimen/dp_20"
|
||||
android:layout_marginTop="@dimen/dp_40"
|
||||
android:layout_marginBottom="@dimen/dp_20"
|
||||
android:gravity="center"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
@@ -96,6 +96,7 @@
|
||||
<string name="plan_time">浇水时长</string>
|
||||
<string name="plan_start_time">开始时间</string>
|
||||
<string name="select_water_time">请选择浇水时间</string>
|
||||
<string name="input_water_plan_time_error">浇水时长不能小于0</string>
|
||||
<string name="input_water_plan_time">请输入浇水时长</string>
|
||||
<string name="device_status">状态</string>
|
||||
<string name="button_delete">删除</string>
|
||||
|
||||
@@ -92,11 +92,14 @@
|
||||
<string name="water_device_bind">关联设备</string>
|
||||
<string name="add_water_plan_title">新增排程</string>
|
||||
<string name="plan_name_text">排程名称</string>
|
||||
<string name="plan_name_text_empty_hint">排程名称不能为空</string>
|
||||
<string name="plan_week_empty_hint">请选择排程日期</string>
|
||||
<string name="plan_period">浇水周期</string>
|
||||
<string name="plan_time">浇水时长</string>
|
||||
<string name="plan_start_time">开始时间</string>
|
||||
<string name="select_water_time">请选择浇水时间</string>
|
||||
<string name="input_water_plan_time">请输入浇水时长</string>
|
||||
<string name="input_water_plan_time_error">浇水时长不能小于0</string>
|
||||
<string name="device_status">状态</string>
|
||||
<string name="button_delete">删除</string>
|
||||
<string name="button_edit">编辑</string>
|
||||
|
||||
Reference in New Issue
Block a user