优化开启浇水
This commit is contained in:
@@ -207,7 +207,7 @@ public class AddDeviceActivity extends BaseActivity<AddDeviceLayoutBinding, Devi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void turnOnOffDeviceSuccess(BaseBean bean) {
|
public void turnOnOffDeviceSuccess(BaseBean bean, String status) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -444,7 +444,7 @@ public class AddDeviceActivity_copy extends BaseActivity<AddDeviceLayoutBinding,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void turnOnOffDeviceSuccess(BaseBean bean) {
|
public void turnOnOffDeviceSuccess(BaseBean bean, String status) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -273,7 +273,7 @@ public class DeviceConnectActivity extends BaseActivity<DeviceConnectLayoutBindi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void turnOnOffDeviceSuccess(BaseBean bean) {
|
public void turnOnOffDeviceSuccess(BaseBean bean, String status) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -188,18 +188,21 @@ public class DeviceControlActivity extends BaseActivity<DeviceControlLayoutBindi
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case R.id.tv_confirm:
|
case R.id.tv_confirm:
|
||||||
if(mCustomDuration == 0 && mAdapter.getmSelPostion() == -1){
|
if(mDeviceEntity.getWorkStatus().equals("0")){
|
||||||
ToastUtil.showShort(mContext,getString(R.string.select_watering_duration));
|
if(mCustomDuration == 0 && mAdapter.getmSelPostion() == -1){
|
||||||
return;
|
ToastUtil.showShort(mContext,getString(R.string.select_watering_duration));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
showCenterTipDialog(R.mipmap.icon_dialog_success,getString(R.string.start_watering));//
|
int duration = 0;
|
||||||
String status = mDeviceEntity.getStatus();
|
String workStatus = mDeviceEntity.getWorkStatus();
|
||||||
if(status.equals("1")){
|
if(workStatus.equals("1")){
|
||||||
status = "0";
|
workStatus = "0";
|
||||||
}else{
|
}else{
|
||||||
status = "1";
|
workStatus = "1";
|
||||||
|
duration = convertToMinutes(mTimeList.get(mAdapter.getmSelPostion()));
|
||||||
}
|
}
|
||||||
mPresenter.switchDeviceWork(mDeviceEntity.getId(),status,
|
mPresenter.switchDeviceWork(mDeviceEntity,workStatus,
|
||||||
mCustomDuration == 0 ? convertToMinutes(mTimeList.get(mAdapter.getmSelPostion()))
|
mCustomDuration == 0 ? convertToMinutes(mTimeList.get(mAdapter.getmSelPostion()))
|
||||||
: mCustomDuration);
|
: mCustomDuration);
|
||||||
break;
|
break;
|
||||||
@@ -316,6 +319,27 @@ public class DeviceControlActivity extends BaseActivity<DeviceControlLayoutBindi
|
|||||||
mRemoteDeviceEntity = bean;
|
mRemoteDeviceEntity = bean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开关设备成功
|
||||||
|
* @param bean
|
||||||
|
* @param status
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void turnOnOffDeviceSuccess(BaseBean bean, String status) {
|
||||||
|
mDeviceEntity.setWorkStatus(status);
|
||||||
|
mCustomDuration = 0;
|
||||||
|
mAdapter.setOnSelPosition(-1);
|
||||||
|
if(status.equals("0")){
|
||||||
|
showCenterTipDialog(R.mipmap.icon_dialog_success,getString(R.string.end_watering));
|
||||||
|
viewBinding.tvConfirm.setText(getString(R.string.start_watering));
|
||||||
|
}else{
|
||||||
|
showCenterTipDialog(R.mipmap.icon_dialog_success,getString(R.string.start_watering));
|
||||||
|
viewBinding.tvConfirm.setText(getString(R.string.end_watering));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getLayoutResId(Bundle savedInstanceState) {
|
public int getLayoutResId(Bundle savedInstanceState) {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -349,10 +373,6 @@ public class DeviceControlActivity extends BaseActivity<DeviceControlLayoutBindi
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void turnOnOffDeviceSuccess(BaseBean bean) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void queryDeviceBindStatusSuccess(WaterDeviceEntity bean) {
|
public void queryDeviceBindStatusSuccess(WaterDeviceEntity bean) {
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ public class DeviceInfoActivity extends BaseActivity<DeviceInfoLayoutBinding, De
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void turnOnOffDeviceSuccess(BaseBean bean) {
|
public void turnOnOffDeviceSuccess(BaseBean bean, String status) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ public class DeviceReNameActivity extends BaseActivity<SetDeviceNameLayoutBindin
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void turnOnOffDeviceSuccess(BaseBean bean) {
|
public void turnOnOffDeviceSuccess(BaseBean bean, String status) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ public class DeviceSettingsActivity extends BaseActivity<DeviceSettingsLayoutBin
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void turnOnOffDeviceSuccess(BaseBean bean) {
|
public void turnOnOffDeviceSuccess(BaseBean bean, String status) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,7 @@ import static android.view.View.GONE;
|
|||||||
import static android.view.View.VISIBLE;
|
import static android.view.View.VISIBLE;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.graphics.drawable.AnimationDrawable;
|
import android.graphics.drawable.AnimationDrawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
@@ -15,8 +13,6 @@ import android.text.TextUtils;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import androidx.core.app.ActivityCompat;
|
|
||||||
|
|
||||||
import com.ckkj.water.ConstantUtil;
|
import com.ckkj.water.ConstantUtil;
|
||||||
import com.ckkj.water.R;
|
import com.ckkj.water.R;
|
||||||
import com.ckkj.water.base.BaseActivity;
|
import com.ckkj.water.base.BaseActivity;
|
||||||
@@ -407,7 +403,7 @@ public class SelectWifiActivity extends BaseActivity<DeviceResetWifiBinding, Dev
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void turnOnOffDeviceSuccess(BaseBean bean) {
|
public void turnOnOffDeviceSuccess(BaseBean bean, String status) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -340,7 +340,7 @@ public class SelectWifiActivity_copy extends BaseActivity<DeviceResetWifiBinding
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void turnOnOffDeviceSuccess(BaseBean bean) {
|
public void turnOnOffDeviceSuccess(BaseBean bean, String status) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class DeviceContract {
|
|||||||
void getDeviceDetailInfo(WaterDeviceEntity bean);
|
void getDeviceDetailInfo(WaterDeviceEntity bean);
|
||||||
void editDeviceInfoSuccess(BaseBean bean);
|
void editDeviceInfoSuccess(BaseBean bean);
|
||||||
void deleteDeviceSuccess(BaseBean bean);
|
void deleteDeviceSuccess(BaseBean bean);
|
||||||
void turnOnOffDeviceSuccess(BaseBean bean);
|
void turnOnOffDeviceSuccess(BaseBean bean, String status);
|
||||||
|
|
||||||
void queryDeviceBindStatusSuccess(WaterDeviceEntity bean);
|
void queryDeviceBindStatusSuccess(WaterDeviceEntity bean);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,14 +137,14 @@ public class DevicePresenter extends BasePresenter<DeviceContract.DeviceView> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 开启/关闭浇水
|
* 开启/关闭浇水
|
||||||
* @param id
|
* @param deviceEntity
|
||||||
* @param status
|
* @param status
|
||||||
* @param duration
|
* @param duration
|
||||||
*/
|
*/
|
||||||
public void switchDeviceWork(String id, String status, int duration) {
|
public void switchDeviceWork(WaterDeviceEntity deviceEntity, String status, int duration) {
|
||||||
try {
|
try {
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
json.put("id",id);
|
json.put("deviceNo",deviceEntity.getDeviceNo());
|
||||||
json.put("workStatus",status);
|
json.put("workStatus",status);
|
||||||
// json.put("startTime","09:50");
|
// json.put("startTime","09:50");
|
||||||
json.put("durationMin",duration + "");
|
json.put("durationMin",duration + "");
|
||||||
@@ -152,7 +152,7 @@ public class DevicePresenter extends BasePresenter<DeviceContract.DeviceView> {
|
|||||||
@Override
|
@Override
|
||||||
public void success(BaseBean bean,int total) {
|
public void success(BaseBean bean,int total) {
|
||||||
if(DevicePresenter.this.getView() != null){
|
if(DevicePresenter.this.getView() != null){
|
||||||
DevicePresenter.this.getView().turnOnOffDeviceSuccess(bean);
|
DevicePresenter.this.getView().turnOnOffDeviceSuccess(bean,status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,8 @@
|
|||||||
<string name="device_status_not_working">待机中</string>
|
<string name="device_status_not_working">待机中</string>
|
||||||
<string name="device_status_offline">离线</string>
|
<string name="device_status_offline">离线</string>
|
||||||
<string name="select_watering_duration">请选择浇水时长</string>
|
<string name="select_watering_duration">请选择浇水时长</string>
|
||||||
<string name="start_watering">开始浇水</string>
|
<string name="start_watering">开启浇水</string>
|
||||||
|
<string name="end_watering">关闭浇水</string>
|
||||||
<string name="reset_device_provision">该操作需要手动将设备重置到配网模式</string>
|
<string name="reset_device_provision">该操作需要手动将设备重置到配网模式</string>
|
||||||
<string name="device_binding_conflict_message">该设备已被其他用户绑定,您可以登录该账号尝试解绑,或重置设备进入配网模式</string>
|
<string name="device_binding_conflict_message">该设备已被其他用户绑定,您可以登录该账号尝试解绑,或重置设备进入配网模式</string>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user