优化
This commit is contained in:
@@ -61,6 +61,7 @@ public class DeviceSettingsActivity extends BaseActivity<DeviceSettingsLayoutBin
|
||||
setClick(viewBinding.rlDevInfo);
|
||||
setClick(viewBinding.rlDevWifiManager);
|
||||
setClick(viewBinding.rlDevUnbind);
|
||||
setClick(viewBinding.rlResetDevice);
|
||||
}
|
||||
|
||||
private void setClick(View view) {
|
||||
@@ -134,7 +135,7 @@ public class DeviceSettingsActivity extends BaseActivity<DeviceSettingsLayoutBin
|
||||
|
||||
break;
|
||||
|
||||
case R.id.rl_dev_unbind:
|
||||
case R.id.rl_dev_unbind://解绑
|
||||
showDialogtext(null, false, false, true,
|
||||
getString(R.string.tip_text), getString(R.string.tip_unbind_device),
|
||||
getString(R.string.cancel_text), getString(R.string.confirm_text), new BaseFragment.OnDialogClick() {
|
||||
@@ -149,6 +150,21 @@ public class DeviceSettingsActivity extends BaseActivity<DeviceSettingsLayoutBin
|
||||
});
|
||||
break;
|
||||
|
||||
case R.id.rl_reset_device://恢复出厂设置
|
||||
showDialogtext(null, false, false, true,
|
||||
getString(R.string.tip_text), getString(R.string.restore_factory_settings_warning),
|
||||
getString(R.string.cancel_text), getString(R.string.confirm_text), new BaseFragment.OnDialogClick() {
|
||||
@Override
|
||||
public void onCancelClick() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfirmClick() {
|
||||
mPresenter.factoryResetDevice(mDeviceEntity);
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,6 +222,19 @@ public class DeviceSettingsActivity extends BaseActivity<DeviceSettingsLayoutBin
|
||||
},500);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void factoryResetDeviceSuccess(BaseBean bean) {
|
||||
hideDialogLoading();
|
||||
ToastUtil.showShort(mContext, getString(R.string.factory_reset_success));
|
||||
EventBus.getDefault().post(new EventMessage(EventMessage.ACTIVITY_FINISH));
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
finish();
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getLayoutResId(Bundle savedInstanceState) {
|
||||
|
||||
@@ -27,6 +27,9 @@ public class DeviceContract {
|
||||
//删除设备信息
|
||||
void deleteDevice(String id, IndexContract.CallBack callBack);
|
||||
|
||||
//恢复设备出厂设置
|
||||
void factoryResetDevice(String id, IndexContract.CallBack callBack);
|
||||
|
||||
//手动开启关闭设备
|
||||
void turnOnOffDevice(JSONObject json, IndexContract.CallBack callBack);
|
||||
|
||||
@@ -40,6 +43,8 @@ public class DeviceContract {
|
||||
void getDeviceDetailInfo(WaterDeviceEntity bean);
|
||||
void editDeviceInfoSuccess(BaseBean bean);
|
||||
void deleteDeviceSuccess(BaseBean bean);
|
||||
default void factoryResetDeviceSuccess(BaseBean bean) {
|
||||
}
|
||||
void turnOnOffDeviceSuccess(BaseBean bean, String status);
|
||||
|
||||
void queryDeviceBindStatusSuccess(WaterDeviceEntity bean);
|
||||
|
||||
@@ -168,6 +168,46 @@ public class DeviceImpl implements DeviceContract.DataModel{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 恢复设备出厂设置
|
||||
* @param deviceNo 设备编号
|
||||
* @param callBack 请求结果回调
|
||||
*/
|
||||
@Override
|
||||
public void factoryResetDevice(String deviceNo, IndexContract.CallBack callBack) {
|
||||
try {
|
||||
NetWorkManager.getRequest().deviceFactoryReset(NetWorkManager.getToken(), deviceNo)
|
||||
.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, 0);
|
||||
} else {
|
||||
callBack.fail(bean.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
callBack.fail(e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动开启关闭设备
|
||||
* @param json
|
||||
|
||||
@@ -135,6 +135,28 @@ public class DevicePresenter extends BasePresenter<DeviceContract.DeviceView> {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 恢复设备出厂设置
|
||||
* @param deviceEntity 设备信息
|
||||
*/
|
||||
public void factoryResetDevice(WaterDeviceEntity deviceEntity) {
|
||||
impl.factoryResetDevice(deviceEntity.getDeviceNo(), new IndexContract.CallBack<BaseBean>() {
|
||||
@Override
|
||||
public void success(BaseBean bean, int total) {
|
||||
if (DevicePresenter.this.getView() != null) {
|
||||
DevicePresenter.this.getView().factoryResetDeviceSuccess(bean);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fail(String msg) {
|
||||
if (DevicePresenter.this.getView() != null) {
|
||||
DevicePresenter.this.getView().showError(msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启/关闭浇水
|
||||
* @param deviceEntity
|
||||
|
||||
@@ -50,55 +50,10 @@ public class DeviceAdapter extends BaseQuickAdapter<WaterDeviceEntity, BaseViewH
|
||||
viewStatus.setBackground(mContext.getResources().getDrawable(R.drawable.shape_status_dot_red));
|
||||
}
|
||||
|
||||
// if(item.getStatus().equals("1") || item.getStatus().equals("2")){
|
||||
// }else{
|
||||
// holder.setText(R.id.tv_device_status,mContext.getString(R.string.device_status_offline));
|
||||
// holder.setTextColor(R.id.tv_device_status,mContext.getResources().getColor(R.color.color_999999));
|
||||
// viewStatus.setBackground(mContext.getResources().getDrawable(R.drawable.shape_status_dot_999999));
|
||||
// }
|
||||
|
||||
holder.setText(R.id.tv_battery_level,item.getPowerLevel());
|
||||
imgPower.setImageResource(PowerIconManage.getInstance().getPowerIcon(Integer.parseInt(item.getPowerLevel())));
|
||||
}
|
||||
|
||||
|
||||
// public DeviceAdapter() {
|
||||
// super();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void onBindViewHolder(@NonNull ViewHolder holder, int position, @NonNull String data) {
|
||||
// holder.tvDeviceName.setText(deviceNames[position]);
|
||||
// holder.tvDeviceSerial.setText(deviceSerials[position]);
|
||||
// holder.tvDeviceStatus.setText(deviceStatuses[position]);
|
||||
// holder.tvBatteryLevel.setText(batteryLevels[position] + "%");
|
||||
// }
|
||||
//
|
||||
// @NonNull
|
||||
// @Override
|
||||
// public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
// View view = LayoutInflater.from(parent.getContext())
|
||||
// .inflate(R.layout.index_device_list_item, parent, false);
|
||||
// return new ViewHolder(view);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void convert(ViewHolder helper, String item) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
// TextView tvDeviceName;
|
||||
// TextView tvDeviceSerial;
|
||||
// TextView tvDeviceStatus;
|
||||
// TextView tvBatteryLevel;
|
||||
//
|
||||
// public ViewHolder(@NonNull View itemView) {
|
||||
// super(itemView);
|
||||
// tvDeviceName = itemView.findViewById(R.id.tv_device_name);
|
||||
// tvDeviceSerial = itemView.findViewById(R.id.tv_device_serial);
|
||||
// tvDeviceStatus = itemView.findViewById(R.id.tv_device_status);
|
||||
// tvBatteryLevel = itemView.findViewById(R.id.tv_battery_level);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -147,6 +147,10 @@ public interface Request {
|
||||
@DELETE("app/v1/deleteDevice/{deviceNo}")
|
||||
Observable<BaseBean> unBindDevice(@HeaderMap Map<String,String> headMap, @Path("deviceNo") String id);
|
||||
|
||||
//设备恢复出厂设置
|
||||
@DELETE("app/v1/factoryReset/{deviceNo}")
|
||||
Observable<BaseBean> deviceFactoryReset(@HeaderMap Map<String,String> headMap, @Path("deviceNo") String id);
|
||||
|
||||
//排程解绑设备
|
||||
@DELETE("app/v1/deleteScheduleDevice")
|
||||
Observable<BaseBean> planUnBindDevice(@HeaderMap Map<String,String> headMap,@QueryMap Map<String, String> map);
|
||||
|
||||
@@ -134,5 +134,26 @@
|
||||
android:layout_marginRight="@dimen/dp_23"
|
||||
android:layout_alignParentRight="true"/>
|
||||
</RelativeLayout>
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_reset_device"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_45">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/dp_20"
|
||||
android:layout_centerVertical="true"
|
||||
android:textSize="16sp"
|
||||
android:textColor="@color/textPrimaryColor"
|
||||
android:text="@string/restore_factory_settings"/>
|
||||
<ImageView
|
||||
android:id="@+id/img_point5"
|
||||
android:layout_width="@dimen/dp_7"
|
||||
android:layout_height="@dimen/dp_13"
|
||||
android:src="@mipmap/icon_point_right"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginRight="@dimen/dp_23"
|
||||
android:layout_alignParentRight="true"/>
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
@@ -87,6 +87,7 @@
|
||||
<string name="device_setting_wifi_manager">Wi-Fi Settings</string>
|
||||
<string name="device_setting_unbind">Remove Device</string>
|
||||
<string name="unbind_success">Device removed successfully</string>
|
||||
<string name="factory_reset_success">Device restored to factory settings successfully</string>
|
||||
|
||||
<string name="settings_title">Settings</string>
|
||||
<string name="confirm_text">Confirm</string>
|
||||
@@ -106,7 +107,8 @@
|
||||
<string name="closed">Closed</string>
|
||||
<string name="end_watering">Stop Watering</string>
|
||||
<string name="device_offline_tip">Device is offline</string>
|
||||
|
||||
<string name="restore_factory_settings">Restore Factory Settings</string>
|
||||
<string name="restore_factory_settings_warning">This operation will restore the device to factory settings.</string>
|
||||
|
||||
<!-- Schedule -->
|
||||
<string name="input_plan_name">Enter schedule name</string>
|
||||
|
||||
@@ -78,6 +78,7 @@
|
||||
<string name="device_setting_wifi_manager">WiFi管理</string>
|
||||
<string name="device_setting_unbind">解绑设备</string>
|
||||
<string name="unbind_success">设备解绑成功</string>
|
||||
<string name="factory_reset_success">设备恢复出厂设置成功</string>
|
||||
<string name="settings_title">设置</string>
|
||||
<string name="confirm_text">确定</string>
|
||||
<string name="cancel_text">取消</string>
|
||||
@@ -97,7 +98,8 @@
|
||||
<string name="device_offline_tip">设备已离线</string>
|
||||
<string name="reset_device_provision">该操作需要手动将设备重置到配网模式</string>
|
||||
<string name="device_binding_conflict_message">该设备已被其他用户绑定,您可以登录该账号尝试解绑,或重置设备进入配网模式</string>
|
||||
|
||||
<string name="restore_factory_settings">恢复出厂设置</string>
|
||||
<string name="restore_factory_settings_warning">该操作将会使设备恢复出厂设置</string>
|
||||
|
||||
<!--排程-->
|
||||
<string name="input_plan_name">输入排程名称</string>
|
||||
|
||||
Reference in New Issue
Block a user