Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d8e9f60f25 | ||
|
|
c7556a42ab | ||
|
|
548419cf29 | ||
|
|
dff152e7e7 |
@@ -121,7 +121,7 @@ public class AddDeviceActivity extends BaseActivity<AddDeviceLayoutBinding, Devi
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化监听g
|
||||
* 初始化监听g111
|
||||
*/
|
||||
private void initListener() {
|
||||
setClick(viewBinding.includedTitle.imgBack);
|
||||
|
||||
@@ -34,6 +34,7 @@ public class DeviceConnectActivity extends BaseActivity<DeviceConnectLayoutBindi
|
||||
private AnimationDrawable animationDrawable;
|
||||
private Handler handler = new Handler(Looper.getMainLooper());
|
||||
private static final long ANIMATION_DURATION = 5000L; // 5秒
|
||||
private static final long PROVISION_TIMEOUT_MS = 60_000L;
|
||||
|
||||
private String mWifiName;
|
||||
private String mWifiPassword;
|
||||
@@ -42,6 +43,17 @@ public class DeviceConnectActivity extends BaseActivity<DeviceConnectLayoutBindi
|
||||
private boolean isBleConnecting = false;
|
||||
private boolean isBleConnected = false;
|
||||
private boolean provisioningStarted = false;
|
||||
private boolean provisionTimeoutHandled;
|
||||
private final Runnable provisionTimeoutRunnable = () -> {
|
||||
if (provisionTimeoutHandled || isFinishing()) return;
|
||||
provisionTimeoutHandled = true;
|
||||
if (espProvisionManager != null) {
|
||||
espProvisionManager.setCallback(null);
|
||||
espProvisionManager.disconnect();
|
||||
}
|
||||
ToastUtil.showShort(mContext, getString(R.string.device_provision_timeout));
|
||||
finish();
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -101,6 +113,9 @@ public class DeviceConnectActivity extends BaseActivity<DeviceConnectLayoutBindi
|
||||
|
||||
|
||||
private void initEspProvision() {
|
||||
provisionTimeoutHandled = false;
|
||||
handler.removeCallbacks(provisionTimeoutRunnable);
|
||||
handler.postDelayed(provisionTimeoutRunnable, PROVISION_TIMEOUT_MS);
|
||||
espProvisionManager = EspProvisionManager.init(mContext).setCallback(new ProvisionCallback() {
|
||||
@Override
|
||||
public void onConnecting() {
|
||||
@@ -128,6 +143,7 @@ public class DeviceConnectActivity extends BaseActivity<DeviceConnectLayoutBindi
|
||||
|
||||
@Override
|
||||
public void onSuccess(String deviceName, String deviceType) {
|
||||
handler.removeCallbacks(provisionTimeoutRunnable);
|
||||
Log.i("TEST", "DeviceConnectActivity===== deviceName:" + deviceName + "配网成功");
|
||||
ToastUtil.showShort(mContext, deviceName + "配网成功");
|
||||
handler.postDelayed(new Runnable() {
|
||||
@@ -145,6 +161,7 @@ public class DeviceConnectActivity extends BaseActivity<DeviceConnectLayoutBindi
|
||||
|
||||
@Override
|
||||
public void onFailed(int errorCode, String message) {
|
||||
handler.removeCallbacks(provisionTimeoutRunnable);
|
||||
isBleConnecting = false;
|
||||
if (errorCode != 0) {
|
||||
isBleConnected = espProvisionManager != null && espProvisionManager.isConnected();
|
||||
@@ -200,9 +217,13 @@ public class DeviceConnectActivity extends BaseActivity<DeviceConnectLayoutBindi
|
||||
|
||||
Intent intent = new Intent(this, AddDeviceActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
handler.postDelayed(() -> {
|
||||
if (!isFinishing()) {
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
}, 1500L);
|
||||
}
|
||||
|
||||
private void connectBleDevice() {
|
||||
if (mBleDeviceEntity == null || espProvisionManager == null) {
|
||||
@@ -247,14 +268,15 @@ public class DeviceConnectActivity extends BaseActivity<DeviceConnectLayoutBindi
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
handler.removeCallbacks(provisionTimeoutRunnable);
|
||||
super.onDestroy();
|
||||
handler.removeCallbacksAndMessages(null);
|
||||
if (animationDrawable != null && animationDrawable.isRunning()) {
|
||||
animationDrawable.stop();
|
||||
}
|
||||
if (espProvisionManager != null) {
|
||||
espProvisionManager.disconnect();
|
||||
espProvisionManager.setCallback(null);
|
||||
espProvisionManager.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,3 +335,6 @@ public class DeviceConnectActivity extends BaseActivity<DeviceConnectLayoutBindi
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -65,6 +65,9 @@ public class DeviceControlActivity extends BaseActivity<DeviceControlLayoutBindi
|
||||
updateWorkProgress();
|
||||
}
|
||||
};
|
||||
/**
|
||||
* 轮询请求设备详情
|
||||
*/
|
||||
private final Runnable mDeviceDetailPollRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -398,12 +401,29 @@ public class DeviceControlActivity extends BaseActivity<DeviceControlLayoutBindi
|
||||
@Override
|
||||
public void getDeviceDetailInfo(WaterDeviceEntity bean) {
|
||||
hideDialogLoading();
|
||||
if(!TextUtils.isEmpty(bean.getPowerStatus()) && bean.getPowerStatus().equals("1")){
|
||||
viewBinding.imgBatStatus.setImageResource(R.mipmap.icon_charging);
|
||||
}else{
|
||||
viewBinding.imgBatStatus.setImageResource(PowerIconManage.getInstance().
|
||||
getPowerVerIcon(Integer.parseInt(bean.getPowerLevel())));
|
||||
mDeviceEntity = bean;
|
||||
updateDeviceStatus( bean);
|
||||
}
|
||||
|
||||
mDeviceEntity = bean;
|
||||
updateDeviceStatus( bean);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void deviceAccessLost() {
|
||||
stopDeviceDetailPolling();
|
||||
showDialogtextInterBackKey(null, false, false, false,
|
||||
getString(R.string.tip_text), getString(R.string.device_control_access_lost),
|
||||
"", getString(R.string.confirm_text), new BaseFragment.OnDialogClick() {
|
||||
@Override public void onCancelClick() { finish(); }
|
||||
@Override public void onConfirmClick() { finish(); }
|
||||
}, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开关设备成功
|
||||
@@ -588,3 +608,5 @@ public class DeviceControlActivity extends BaseActivity<DeviceControlLayoutBindi
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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) {
|
||||
@@ -214,7 +243,8 @@ public class DeviceSettingsActivity extends BaseActivity<DeviceSettingsLayoutBin
|
||||
|
||||
@Override
|
||||
public void showError(String message) {
|
||||
|
||||
hideDialogLoading();
|
||||
ToastUtil.showShort(mContext,message);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -38,8 +41,12 @@ public class DeviceContract {
|
||||
//添加设备成功g
|
||||
void addDeviceSuccess(WaterDeviceEntity bean);
|
||||
void getDeviceDetailInfo(WaterDeviceEntity bean);
|
||||
default void deviceAccessLost() {
|
||||
}
|
||||
void editDeviceInfoSuccess(BaseBean bean);
|
||||
void deleteDeviceSuccess(BaseBean bean);
|
||||
default void factoryResetDeviceSuccess(BaseBean bean) {
|
||||
}
|
||||
void turnOnOffDeviceSuccess(BaseBean bean, String status);
|
||||
|
||||
void queryDeviceBindStatusSuccess(WaterDeviceEntity bean);
|
||||
@@ -47,3 +54,5 @@ public class DeviceContract {
|
||||
void queryDeviceWorkTimeSuccess(WaterDeviceEntity bean);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -35,6 +35,8 @@ public class DeviceImpl implements DeviceContract.DataModel{
|
||||
public void onNext(@NonNull BaseBean<WaterDeviceEntity> bean) {
|
||||
if (bean.getCode() == 200) {
|
||||
callBack.success(bean.getData(),0);
|
||||
} else {
|
||||
callBack.fail(bean.getCode() == 501 ? "DEVICE_ACCESS_LOST" : bean.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,6 +170,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
|
||||
@@ -228,6 +270,8 @@ public class DeviceImpl implements DeviceContract.DataModel{
|
||||
public void onNext(@NonNull BaseBean<WaterDeviceEntity> bean) {
|
||||
if (bean.getCode() == 200) {
|
||||
callBack.success(bean.getData(),0);
|
||||
} else {
|
||||
callBack.fail(bean.getCode() == 501 ? "DEVICE_ACCESS_LOST" : bean.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,3 +286,4 @@ public class DeviceImpl implements DeviceContract.DataModel{
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,9 +49,13 @@ public class DevicePresenter extends BasePresenter<DeviceContract.DeviceView> {
|
||||
@Override
|
||||
public void fail(String msg) {
|
||||
if(DevicePresenter.this.getView() != null){
|
||||
if ("DEVICE_ACCESS_LOST".equals(msg)) {
|
||||
DevicePresenter.this.getView().deviceAccessLost();
|
||||
} else {
|
||||
DevicePresenter.this.getView().showError(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (JSONException e) {
|
||||
throw new RuntimeException(e);
|
||||
@@ -76,9 +80,13 @@ public class DevicePresenter extends BasePresenter<DeviceContract.DeviceView> {
|
||||
@Override
|
||||
public void fail(String msg) {
|
||||
if(DevicePresenter.this.getView() != null){
|
||||
if ("DEVICE_ACCESS_LOST".equals(msg)) {
|
||||
DevicePresenter.this.getView().deviceAccessLost();
|
||||
} else {
|
||||
DevicePresenter.this.getView().showError(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -104,9 +112,13 @@ public class DevicePresenter extends BasePresenter<DeviceContract.DeviceView> {
|
||||
@Override
|
||||
public void fail(String msg) {
|
||||
if(DevicePresenter.this.getView() != null){
|
||||
if ("DEVICE_ACCESS_LOST".equals(msg)) {
|
||||
DevicePresenter.this.getView().deviceAccessLost();
|
||||
} else {
|
||||
DevicePresenter.this.getView().showError(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (JSONException e) {
|
||||
throw new RuntimeException(e);
|
||||
@@ -135,6 +147,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
|
||||
@@ -159,9 +193,13 @@ public class DevicePresenter extends BasePresenter<DeviceContract.DeviceView> {
|
||||
@Override
|
||||
public void fail(String msg) {
|
||||
if(DevicePresenter.this.getView() != null){
|
||||
if ("DEVICE_ACCESS_LOST".equals(msg)) {
|
||||
DevicePresenter.this.getView().deviceAccessLost();
|
||||
} else {
|
||||
DevicePresenter.this.getView().showError(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (JSONException e) {
|
||||
throw new RuntimeException(e);
|
||||
@@ -218,9 +256,14 @@ public class DevicePresenter extends BasePresenter<DeviceContract.DeviceView> {
|
||||
@Override
|
||||
public void fail(String msg) {
|
||||
if(DevicePresenter.this.getView() != null){
|
||||
if ("DEVICE_ACCESS_LOST".equals(msg)) {
|
||||
DevicePresenter.this.getView().deviceAccessLost();
|
||||
} else {
|
||||
DevicePresenter.this.getView().showError(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -210,6 +210,21 @@ public class IndexFragment extends BaseFragment<IndexFragmentLayoutBinding, Inde
|
||||
deviceAdapter = new DeviceAdapter(mContext,R.layout.index_device_list_item,devList);
|
||||
viewBinding.rvDevices.setAdapter(deviceAdapter);
|
||||
deviceAdapter.setOnItemClickListener((adapter, view, position) -> {
|
||||
if(!devList.get(position).getBindingStatus().equals("ACTIVE")){
|
||||
showDialogtext(null, false, false,
|
||||
getString(R.string.tip_text), getString(R.string.device_no_permission_delete_message),
|
||||
getString(R.string.cancel_text), getString(R.string.confirm_text), new BaseFragment.OnDialogClick() {
|
||||
@Override
|
||||
public void onCancelClick() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfirmClick() {
|
||||
mPresenter.removeDeviceEntry(devList.get(position).getDeviceNo());
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable("device_info",devList.get(position));
|
||||
goTo(mContext, DeviceControlActivity.class,bundle);
|
||||
@@ -253,6 +268,12 @@ public class IndexFragment extends BaseFragment<IndexFragmentLayoutBinding, Inde
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeDeviceEntrySuccess(BaseBean bean) {
|
||||
ToastUtil.showShort(mContext, getString(R.string.remove_success));
|
||||
mCurrentPage = 1;
|
||||
mPresenter.getDevicesList(mCurrentPage);
|
||||
}
|
||||
/**
|
||||
* 查询当前设备绑定状态
|
||||
* @param entity
|
||||
@@ -477,3 +498,5 @@ public class IndexFragment extends BaseFragment<IndexFragmentLayoutBinding, Inde
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.ckkj.water.R;
|
||||
import com.ckkj.water.index.entity.WaterDeviceEntity;
|
||||
import com.ckkj.water.utils.manager.PowerIconManage;
|
||||
import com.esafirm.imagepicker.model.Image;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -28,10 +27,10 @@ public class DeviceAdapter extends BaseQuickAdapter<WaterDeviceEntity, BaseViewH
|
||||
ImageView imgPower = holder.getView(R.id.img_battery);
|
||||
View viewStatus = holder.getView(R.id.view_status_dot);
|
||||
holder.setText(R.id.tv_device_name,item.getDeviceName());
|
||||
holder.setText(R.id.tv_device_serial,item.getDeviceSn());
|
||||
holder.setText(R.id.tv_device_serial,item.getDeviceNo());
|
||||
//设备联网在线
|
||||
if(item.getStatus().equals("1")){
|
||||
switch (item.getWorkStatus()){
|
||||
if ("1".equals(item.getStatus())) {
|
||||
switch (item.getWorkStatus() == null ? "0" : item.getWorkStatus()){
|
||||
case "0"://待机
|
||||
holder.setText(R.id.tv_device_status,mContext.getString(R.string.device_status_not_working));
|
||||
holder.setTextColor(R.id.tv_device_status,mContext.getResources().getColor(R.color.color_999999));
|
||||
@@ -50,55 +49,27 @@ 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())));
|
||||
String powerLevel = item.getPowerLevel();
|
||||
int power = 0;
|
||||
if (powerLevel != null) {
|
||||
try {
|
||||
power = Integer.parseInt(powerLevel.trim());
|
||||
} catch (NumberFormatException ignored) {
|
||||
power = 0;
|
||||
}
|
||||
}
|
||||
if ("1".equals(item.getPowerStatus())) {
|
||||
holder.setText(R.id.tv_battery_level, "充电中 " + (powerLevel == null ? "0%" : powerLevel + "%"));
|
||||
imgPower.setImageResource(R.mipmap.icon_charging);
|
||||
} else {
|
||||
holder.setText(R.id.tv_battery_level, powerLevel == null ? "0%" : powerLevel + "%");
|
||||
imgPower.setImageResource(PowerIconManage.getInstance().getPowerIcon(power));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 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);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ public class WaterDeviceEntity implements Serializable {
|
||||
private String status;
|
||||
private String workStatus;
|
||||
private String powerLevel;
|
||||
private String powerStatus;
|
||||
private String powerLevelUpdatatime;
|
||||
private String wifiName;
|
||||
private String wifiPassword;
|
||||
@@ -50,6 +51,7 @@ public class WaterDeviceEntity implements Serializable {
|
||||
private WaterDeviceEntity bindDevice;
|
||||
private String startTime;
|
||||
private String endTime;
|
||||
private String bindingStatus;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@@ -80,5 +82,8 @@ public class WaterDeviceEntity implements Serializable {
|
||||
private String powerLevelUpdatatimeX;
|
||||
private Object expirationTimeX;
|
||||
private String checkStatus = "0";
|
||||
private String bindingStatus;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.ckkj.water.index.mvp;
|
||||
|
||||
import com.ckkj.water.base.IView;
|
||||
import com.ckkj.water.index.entity.WaterDeviceEntity;
|
||||
import com.ckkj.water.network.BaseBean;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
@@ -25,6 +26,8 @@ public class IndexContract {
|
||||
void getDeviceList(Map<String,String> map,CallBack callBack);
|
||||
//查询二维码当前设备绑定状态
|
||||
void queryDeviceBindStatus(JSONObject json, CallBack callBack);
|
||||
//从设备列表中移除设备
|
||||
void removeDeviceEntry(String deviceNo, CallBack callBack);
|
||||
|
||||
}
|
||||
|
||||
@@ -32,5 +35,8 @@ public class IndexContract {
|
||||
void getDeviceListSuccess(List<WaterDeviceEntity> list, int total);
|
||||
//查询二维码当前设备绑定状态
|
||||
void queryDeviceBindStatusSuccess(WaterDeviceEntity entity);
|
||||
//从设备列表中移除设备成功
|
||||
void removeDeviceEntrySuccess(BaseBean bean);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -91,4 +91,35 @@ public class IndexImpl implements IndexContract.DataModel{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void removeDeviceEntry(String deviceNo, IndexContract.CallBack callBack) {
|
||||
NetWorkManager.getRequest().removeDeviceEntry(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() {
|
||||
}
|
||||
});
|
||||
}}
|
||||
|
||||
|
||||
@@ -71,4 +71,22 @@ public class IndexPresenter extends BasePresenter<IndexContract.IndexView>{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void removeDeviceEntry(String deviceNo) {
|
||||
mImpl.removeDeviceEntry(deviceNo, new IndexContract.CallBack<BaseBean>() {
|
||||
@Override
|
||||
public void success(BaseBean bean, int total) {
|
||||
if (IndexPresenter.this.getView() != null) {
|
||||
IndexPresenter.this.getView().removeDeviceEntrySuccess(bean);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fail(String msg) {
|
||||
if (IndexPresenter.this.getView() != null) {
|
||||
IndexPresenter.this.getView().showError(msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
}}
|
||||
|
||||
|
||||
@@ -147,6 +147,17 @@ public interface Request {
|
||||
@DELETE("app/v1/deleteDevice/{deviceNo}")
|
||||
Observable<BaseBean> unBindDevice(@HeaderMap Map<String,String> headMap, @Path("deviceNo") String id);
|
||||
|
||||
|
||||
//设备列表中,移除该设备
|
||||
@DELETE("app/v1/removeDeviceEntry/{deviceNo}")
|
||||
Observable<BaseBean> removeDeviceEntry(@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,27 @@
|
||||
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"
|
||||
android:visibility="gone">
|
||||
<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>
|
||||
@@ -10,7 +10,7 @@
|
||||
android:id="@+id/img_noresult"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@mipmap/icon_no_result"
|
||||
android:src="@mipmap/img_nodata"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_centerHorizontal="true"/>
|
||||
<TextView
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:padding="@dimen/dp_10">
|
||||
android:paddingVertical="@dimen/dp_10"
|
||||
android:paddingHorizontal="@dimen/dp_15">
|
||||
<!-- 左侧:设备信息 -->
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
|
||||
BIN
app/src/main/res/mipmap-xhdpi/icon_charging.png
Normal file
BIN
app/src/main/res/mipmap-xhdpi/icon_charging.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 873 B |
BIN
app/src/main/res/mipmap-xxhdpi/icon_charging.png
Normal file
BIN
app/src/main/res/mipmap-xxhdpi/icon_charging.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/img_nodata.png
Normal file
BIN
app/src/main/res/mipmap-xxhdpi/img_nodata.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.7 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/icon_charging.png
Normal file
BIN
app/src/main/res/mipmap-xxxhdpi/icon_charging.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/img_nodata.png
Normal file
BIN
app/src/main/res/mipmap-xxxhdpi/img_nodata.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@@ -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,10 @@
|
||||
<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>
|
||||
<string name="device_no_permission_delete_message">This device has been reset or bound to a new user. You no longer have permission to operate this device. Do you want to delete it now?</string>
|
||||
<string name="remove_success">Removed successfully</string>
|
||||
|
||||
<!-- Schedule -->
|
||||
<string name="input_plan_name">Enter schedule name</string>
|
||||
@@ -333,4 +337,8 @@
|
||||
|
||||
|
||||
|
||||
<string name="device_control_access_lost">You have lost control of this device</string>
|
||||
<string name="device_provision_timeout">Network configuration timed out. Please try again.</string>
|
||||
</resources>
|
||||
|
||||
|
||||
|
||||
@@ -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,6 +98,9 @@
|
||||
<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="device_no_permission_delete_message">当前设备已被重置或被新用户绑定,您已无权限继续操作该设备,是否立即删除?</string>
|
||||
|
||||
|
||||
<!--排程-->
|
||||
@@ -131,7 +135,7 @@
|
||||
<string name="associated">已关联</string>
|
||||
<string name="plan_on">开启</string>
|
||||
<string name="plan_off">关闭</string>
|
||||
|
||||
<string name="remove_success">移除成功</string>
|
||||
|
||||
<!--历史-->
|
||||
<string name="history_title">历史</string>
|
||||
@@ -611,4 +615,8 @@
|
||||
书法艺术体现了中华文化的深厚底蕴,学习书法有助于增强文化自信和民族认同感。
|
||||
</string>
|
||||
|
||||
<string name="device_control_access_lost">已失去对该设备的控制权</string>
|
||||
<string name="device_provision_timeout">配网超时,请重试</string>
|
||||
</resources>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user