修改有关于设备相关的接口,入参参数更改
This commit is contained in:
@@ -73,7 +73,7 @@ public class BindDeviceFragment extends BaseFragment<PlanBindDeviceLayoutBinding
|
||||
for(WaterDeviceEntity.DeviceListBean bean : mDeviceList){
|
||||
if(bean.getStatus().equals("1")){
|
||||
isSelected = true;
|
||||
selected.add(bean.getId());
|
||||
selected.add(bean.getDeviceNo());
|
||||
}
|
||||
}
|
||||
if(!isSelected){
|
||||
|
||||
@@ -32,12 +32,12 @@ public class PlanBoundDeviceFragment extends BaseFragment<PlanBoundDeviceLayoutB
|
||||
@Override
|
||||
public void initData(Bundle state) {
|
||||
// 初始化适配器,如果有数据则设置
|
||||
if (mEditEntity != null && mEditEntity.getDeviceIds() != null) {
|
||||
mAdapter = new PlanBoundDeviceAdapter(mContext, R.layout.plan_bound_device_item, mEditEntity.getDeviceIds());
|
||||
if (mEditEntity != null && mEditEntity.getDeviceNos() != null) {
|
||||
mAdapter = new PlanBoundDeviceAdapter(mContext, R.layout.plan_bound_device_item, mEditEntity.getDeviceNos());
|
||||
viewBinding.rvDevices.setAdapter(mAdapter);
|
||||
|
||||
// 根据数据状态显示/隐藏视图
|
||||
if (mEditEntity.getDeviceIds().isEmpty()) {
|
||||
if (mEditEntity.getDeviceNos().isEmpty()) {
|
||||
viewBinding.linearContent.setVisibility(View.GONE);
|
||||
viewBinding.relNoresult.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
@@ -66,7 +66,7 @@ public class PlanBoundDeviceFragment extends BaseFragment<PlanBoundDeviceLayoutB
|
||||
public void onConfirmClick() {
|
||||
showLoadingDialog();
|
||||
mPresenter.planUnbindDevice(mEditEntity.getId(),
|
||||
mEditEntity.getDeviceIds().get(position).getId(),
|
||||
mEditEntity.getDeviceNos().get(position).getDeviceNo(),
|
||||
position);
|
||||
}
|
||||
});
|
||||
@@ -94,20 +94,20 @@ public class PlanBoundDeviceFragment extends BaseFragment<PlanBoundDeviceLayoutB
|
||||
if (viewBinding == null) {
|
||||
return;
|
||||
}
|
||||
if (mEditEntity == null || mEditEntity.getDeviceIds() == null) {
|
||||
if (mEditEntity == null || mEditEntity.getDeviceNos() == null) {
|
||||
viewBinding.linearContent.setVisibility(View.GONE);
|
||||
viewBinding.relNoresult.setVisibility(View.VISIBLE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mEditEntity.getDeviceIds().isEmpty()) {
|
||||
if (mEditEntity.getDeviceNos().isEmpty()) {
|
||||
viewBinding.linearContent.setVisibility(View.GONE);
|
||||
viewBinding.relNoresult.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
viewBinding.linearContent.setVisibility(View.VISIBLE);
|
||||
viewBinding.relNoresult.setVisibility(View.GONE);
|
||||
if (mAdapter != null) {
|
||||
mAdapter.setNewData(mEditEntity.getDeviceIds());
|
||||
mAdapter.setNewData(mEditEntity.getDeviceNos());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -166,7 +166,7 @@ public class PlanBoundDeviceFragment extends BaseFragment<PlanBoundDeviceLayoutB
|
||||
hideDialogLoading();
|
||||
ToastUtil.showShort(mContext, "解绑成功");
|
||||
mAdapter.notifyItemRemoved(position);
|
||||
mEditEntity.getDeviceIds().remove(position);
|
||||
mEditEntity.getDeviceNos().remove(position);
|
||||
if (mAdapter.getItemCount() != 0) {
|
||||
viewBinding.relNoresult.setVisibility(View.GONE);
|
||||
viewBinding.linearContent.setVisibility(View.VISIBLE);
|
||||
|
||||
@@ -26,6 +26,7 @@ public class WaterPlanWeekEntity implements Serializable {
|
||||
private String userId;
|
||||
private String name;
|
||||
private List<WaterDeviceEntity> deviceIds;
|
||||
private List<WaterDeviceEntity> deviceNos;
|
||||
private String status = "1";
|
||||
private List<DetailsBean> details;
|
||||
|
||||
|
||||
@@ -195,19 +195,19 @@ public class WaterPlanPresenter extends BasePresenter<WaterPlanContract.WaterPla
|
||||
/**
|
||||
* 排程绑定设备
|
||||
* @param entity
|
||||
* @param deviceIds
|
||||
* @param deviceNo
|
||||
*/
|
||||
public void planBindWithDevices(WaterPlanWeekEntity entity, String deviceIds) {
|
||||
public void planBindWithDevices(WaterPlanWeekEntity entity, String deviceNo) {
|
||||
try {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("scheduleId", entity.getId());
|
||||
// 将逗号分隔的字符串转换为 JSONArray (数字类型)
|
||||
JSONArray deviceIdArray = new JSONArray();
|
||||
String[] idArray = deviceIds.split(",");
|
||||
String[] idArray = deviceNo.split(",");
|
||||
for (String id : idArray) {
|
||||
deviceIdArray.put(id);
|
||||
}
|
||||
json.put("deviceIds", deviceIdArray);
|
||||
json.put("deviceNos", deviceIdArray);
|
||||
impl.planBindDevice(json, new WaterPlanContract.CallBack<BaseBean>() {
|
||||
@Override
|
||||
public void success(BaseBean bean, int total) {
|
||||
@@ -288,7 +288,7 @@ public class WaterPlanPresenter extends BasePresenter<WaterPlanContract.WaterPla
|
||||
public void planUnbindDevice(String planID, String deviceID,int position) {
|
||||
Map<String,String> map = new HashMap<>();
|
||||
map.put("scheduleId",planID);
|
||||
map.put("deviceId",deviceID);
|
||||
map.put("deviceNo",deviceID);
|
||||
impl.planUnbindDevice(map, new WaterPlanContract.CallBack<BaseBean>() {
|
||||
@Override
|
||||
public void success(BaseBean bean, int total) {
|
||||
|
||||
Reference in New Issue
Block a user