新增排程接口+排程更新
This commit is contained in:
@@ -79,9 +79,11 @@ public interface Request {
|
||||
@PUT("app/v1/updataschedule")
|
||||
Observable<BaseBean<WaterPlanWeekEntity>> updateSchedule(@HeaderMap Map<String, String> headMap, @Body RequestBody requestBody);
|
||||
|
||||
//查询排程可绑定设备列表
|
||||
@GET("app/v1/scheduleDeviceList/{id}")
|
||||
Observable<BaseBean> getPlanBindDeviceList(@HeaderMap Map<String, String> headMap, @Path("id") String id);
|
||||
|
||||
//解绑信息
|
||||
// 示例:ids array[string]
|
||||
//["2052921001527869441"]
|
||||
@DELETE("app/v1/deleteDevice/{ids}")
|
||||
Observable<BaseBean> unBindDevice(@HeaderMap Map<String,String> headMap, @Path("ids") String id);
|
||||
|
||||
|
||||
@@ -135,6 +135,9 @@ public class AddWaterPlanActivity extends BaseActivity<AddWaterPlanLayoutBinding
|
||||
|
||||
public void onConfigSaved(WaterPlanWeekEntity entity) {
|
||||
selectTabBind();
|
||||
// 传递 WaterPlanWeekEntity 给 BindDeviceFragment
|
||||
BindDeviceFragment bindDeviceFragment = (BindDeviceFragment) mFragmentList.get(1);
|
||||
bindDeviceFragment.setPlanEntity(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,22 +29,46 @@ public class BindDeviceFragment extends BaseFragment<PlanBindDeviceLayoutBinding
|
||||
implements WaterPlanContract.WaterPlanView {
|
||||
|
||||
private List<WaterPlanWeekEntity> weekList = new ArrayList<>();
|
||||
private WaterPlanWeekEntity mPlanEntity;
|
||||
// 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);
|
||||
// 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();
|
||||
// }
|
||||
// });
|
||||
// @Override
|
||||
// public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
|
||||
// mAdapter.toggleSelection(position);
|
||||
// syncSelectedDevices();
|
||||
// }
|
||||
// });
|
||||
// 接收来自AddWaterPlanActivity的WaterPlanWeekEntity对象,并使用传参。
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResumeInitData() {
|
||||
super.onResumeInitData();
|
||||
if (mPlanEntity != null) {
|
||||
mPresenter.getPlanBindDevices(mPlanEntity);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置排程实体,用于关联设备接口请求
|
||||
* @param entity 排程实体
|
||||
*/
|
||||
public void setPlanEntity(WaterPlanWeekEntity entity) {
|
||||
this.mPlanEntity = entity;
|
||||
if (mPlanEntity != null) {
|
||||
if(mPresenter != null){
|
||||
mPresenter.getPlanBindDevices(mPlanEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void syncSelectedDevices() {
|
||||
|
||||
@@ -286,9 +286,14 @@ public class WaterConfigFragment extends BaseFragment<WaterConfigFragmentLayoutB
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新排程成功
|
||||
* @param entity
|
||||
*/
|
||||
@Override
|
||||
public void updateConfigSuccess(WaterPlanWeekEntity entity) {
|
||||
|
||||
ToastUtil.showShort(mContext, "排程更新成功");
|
||||
mRemoteConfigEntity = entity;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -18,8 +18,10 @@ public class WaterPlanContract {
|
||||
void getWaterConfigList(Map<String, String> map,CallBack callBack);
|
||||
//新增排程
|
||||
void saveConfig(JSONObject json,CallBack callBack);
|
||||
|
||||
//更新排程
|
||||
void updateConfig(JSONObject json,CallBack callBack);
|
||||
//查询排程可绑定的设备列表
|
||||
void getPlanBindDeviceList(Map<String, String> map,CallBack callBack);
|
||||
}
|
||||
|
||||
public interface WaterPlanView extends IView {
|
||||
|
||||
@@ -133,4 +133,39 @@ public class WaterPlanImpl implements WaterPlanContract.DataModel{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询可绑定排程的设备列表
|
||||
* @param map
|
||||
* @param callBack
|
||||
*/
|
||||
@Override
|
||||
public void getPlanBindDeviceList(Map<String, String> map, WaterPlanContract.CallBack callBack) {
|
||||
String deviceID = map.get("id");
|
||||
NetWorkManager.getRequest().getPlanBindDeviceList(NetWorkManager.getToken(), deviceID)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.unsubscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseBean>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseBean bean) {
|
||||
if (bean.getCode() == 200) {
|
||||
callBack.success(bean.getData(),0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
callBack.fail(e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,9 @@ import com.ckkj.water.base.BasePresenter;
|
||||
import com.ckkj.water.base.entity.MineUserInfoBean;
|
||||
import com.ckkj.water.device.mvp.DeviceContract;
|
||||
import com.ckkj.water.device.mvp.DeviceImpl;
|
||||
import com.ckkj.water.device.mvp.DevicePresenter;
|
||||
import com.ckkj.water.index.entity.IndexDeviceEntity;
|
||||
import com.ckkj.water.index.mvp.IndexContract;
|
||||
import com.ckkj.water.login.mvp.LoginContract;
|
||||
import com.ckkj.water.login.mvp.LoginPresenter;
|
||||
import com.ckkj.water.mine.mvp.MineContract;
|
||||
@@ -137,5 +140,27 @@ public class WaterPlanPresenter extends BasePresenter<WaterPlanContract.WaterPla
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询排程可绑定的设备列表
|
||||
* @param entity
|
||||
*/
|
||||
public void getPlanBindDevices(WaterPlanWeekEntity entity) {
|
||||
Map<String,String> map = new HashMap<>();
|
||||
map.put("id",entity.getId());
|
||||
impl.getPlanBindDeviceList(map, new WaterPlanContract.CallBack<BaseBean>() {
|
||||
@Override
|
||||
public void success(BaseBean bean, int total) {
|
||||
if(WaterPlanPresenter.this.getView() != null){
|
||||
// WaterPlanPresenter.this.getView().getDeviceDetailInfo(bean);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fail(String msg) {
|
||||
if(WaterPlanPresenter.this.getView() != null){
|
||||
WaterPlanPresenter.this.getView().showError( msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user