|
@@ -1,7 +1,6 @@
|
|
|
package com.silence.commonframe.activity.presenter;
|
|
package com.silence.commonframe.activity.presenter;
|
|
|
|
|
|
|
|
import android.app.Activity;
|
|
import android.app.Activity;
|
|
|
-import android.widget.Toast;
|
|
|
|
|
|
|
|
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.Gson;
|
|
|
import com.google.gson.reflect.TypeToken;
|
|
import com.google.gson.reflect.TypeToken;
|
|
@@ -9,12 +8,10 @@ import com.lzy.okgo.OkGo;
|
|
|
import com.lzy.okgo.cache.CacheMode;
|
|
import com.lzy.okgo.cache.CacheMode;
|
|
|
import com.lzy.okgo.callback.StringCallback;
|
|
import com.lzy.okgo.callback.StringCallback;
|
|
|
import com.silence.commonframe.ApiService;
|
|
import com.silence.commonframe.ApiService;
|
|
|
-import com.silence.commonframe.activity.Interface.AirGuardListener;
|
|
|
|
|
import com.silence.commonframe.activity.Interface.AirGuardWordTimeListener;
|
|
import com.silence.commonframe.activity.Interface.AirGuardWordTimeListener;
|
|
|
-import com.silence.commonframe.bean.AirGuardDetailBean;
|
|
|
|
|
-import com.silence.commonframe.bean.AirGuardWordTimeBean;
|
|
|
|
|
import com.silence.commonframe.bean.BaseBean;
|
|
import com.silence.commonframe.bean.BaseBean;
|
|
|
import com.silence.commonframe.common.constant.UrlConstants;
|
|
import com.silence.commonframe.common.constant.UrlConstants;
|
|
|
|
|
+import com.silence.commonframe.model.AirGuardRunTimeListModel;
|
|
|
import com.silence.commonframe.utils.Data;
|
|
import com.silence.commonframe.utils.Data;
|
|
|
import com.silence.commonframe.utils.LoginIn;
|
|
import com.silence.commonframe.utils.LoginIn;
|
|
|
|
|
|
|
@@ -28,9 +25,11 @@ public class AirGuardWordTimePresenter extends AirGuardWordTimeListener.Presente
|
|
|
this.mContext=mContext;
|
|
this.mContext=mContext;
|
|
|
this.mView=mView;
|
|
this.mView=mView;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ //获取运行时间间隔
|
|
|
@Override
|
|
@Override
|
|
|
public void getData() {
|
|
public void getData() {
|
|
|
- OkGo.get(ApiService.httpUrl1 + Data.getConfigUrl()+UrlConstants.AIR_RUN_TIME)
|
|
|
|
|
|
|
+ OkGo.get(ApiService.httpUrl1 + Data.getConfigUrl() + UrlConstants.AIR_RUN_TIME)
|
|
|
.params("deviceId",mView.getDevId())
|
|
.params("deviceId",mView.getDevId())
|
|
|
.tag(this)
|
|
.tag(this)
|
|
|
.cacheKey("cachePostRegister11")
|
|
.cacheKey("cachePostRegister11")
|
|
@@ -39,14 +38,132 @@ public class AirGuardWordTimePresenter extends AirGuardWordTimeListener.Presente
|
|
|
.execute(new StringCallback() {
|
|
.execute(new StringCallback() {
|
|
|
@Override
|
|
@Override
|
|
|
public void onSuccess(String s, Call call, Response response) {
|
|
public void onSuccess(String s, Call call, Response response) {
|
|
|
- BaseBean<AirGuardWordTimeBean> data=new Gson().fromJson(s,new TypeToken<BaseBean<AirGuardWordTimeBean>>(){}.getType());
|
|
|
|
|
- if (data.code==0){
|
|
|
|
|
- mView.onSuccess(data.data);
|
|
|
|
|
|
|
+// BaseBean<AirGuardWordTimeBean> data=new Gson().fromJson(s,new TypeToken<BaseBean<AirGuardWordTimeBean>>(){}.getType());
|
|
|
|
|
+ AirGuardRunTimeListModel data = new Gson().fromJson(s,AirGuardRunTimeListModel.class);
|
|
|
|
|
+ if (data.getCode()==0){
|
|
|
|
|
+ mView.onSuccess(data.getData());
|
|
|
|
|
+ }else {
|
|
|
|
|
+ LoginIn.tokenOut(data.getCode(),data.getMsg(),mContext);
|
|
|
|
|
+ mView.onFile(data.getMsg());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onError(Call call, Response response, Exception e) {
|
|
|
|
|
+ super.onError(call, response, e);
|
|
|
|
|
+ mView.onFile("信息获取失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //删除运行时间间隔
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void delRunTime(int position) {
|
|
|
|
|
+ OkGo.get(ApiService.httpUrl1 + Data.getConfigUrl() +UrlConstants.AIRGUARD_DEL_RUNTIME)
|
|
|
|
|
+ .tag(this)
|
|
|
|
|
+ .params("id",mView.getListTime().get(position).getId())
|
|
|
|
|
+ .cacheKey("cacheGetKey")
|
|
|
|
|
+ .cacheMode(CacheMode.DEFAULT)
|
|
|
|
|
+ .headers("token", Data.getToken())
|
|
|
|
|
+ .execute(new StringCallback() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onSuccess(String s, Call call, Response response) {
|
|
|
|
|
+ BaseBean data = new Gson().fromJson(s,new TypeToken<BaseBean>(){}.getType());
|
|
|
|
|
+ if (data.code == 0){
|
|
|
|
|
+ mView.onFile("删除成功");
|
|
|
|
|
+ }else {
|
|
|
|
|
+ LoginIn.tokenOut(data.code,mContext);
|
|
|
|
|
+ mView.onFile(data.msg);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onError(Call call, Response response, Exception e) {
|
|
|
|
|
+ super.onError(call, response, e);
|
|
|
|
|
+ mView.onFile("信息获取失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //打开或关闭运行时间
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void openCloseRunTime(int position) {
|
|
|
|
|
+ OkGo.get(ApiService.httpUrl1 + Data.getConfigUrl() +UrlConstants.AIRGUARD_OPEN_CLOSE_RUNTIME)
|
|
|
|
|
+ .tag(this)
|
|
|
|
|
+ .params("id",mView.getListTime().get(position).getId())
|
|
|
|
|
+ .cacheKey("cacheGetKey")
|
|
|
|
|
+ .cacheMode(CacheMode.DEFAULT)
|
|
|
|
|
+ .headers("token", Data.getToken())
|
|
|
|
|
+ .execute(new StringCallback() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onSuccess(String s, Call call, Response response) {
|
|
|
|
|
+ BaseBean data = new Gson().fromJson(s,new TypeToken<BaseBean>(){}.getType());
|
|
|
|
|
+ if (data.code == 0){
|
|
|
|
|
+ mView.onFile(data.msg);
|
|
|
}else {
|
|
}else {
|
|
|
- LoginIn.tokenOut(data.code,data.msg,mContext);
|
|
|
|
|
- Toast.makeText(mContext,""+data.msg,Toast.LENGTH_SHORT).show();
|
|
|
|
|
|
|
+ LoginIn.tokenOut(data.code,mContext);
|
|
|
|
|
+ mView.onFile(data.msg);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onError(Call call, Response response, Exception e) {
|
|
|
|
|
+ super.onError(call, response, e);
|
|
|
|
|
+ mView.onFile("信息获取失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //修改运行时间间隔
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void updateRunTime(int position) {
|
|
|
|
|
+ OkGo.get(ApiService.httpUrl1 + Data.getConfigUrl() +UrlConstants.AIRGUARD_RUNTIMELIST)
|
|
|
|
|
+ .tag(this)
|
|
|
|
|
+ .params("deviceId",mView.getDevId())
|
|
|
|
|
+ .cacheKey("cacheGetKey")
|
|
|
|
|
+ .cacheMode(CacheMode.DEFAULT)
|
|
|
|
|
+ .headers("token", Data.getToken())
|
|
|
|
|
+ .execute(new StringCallback() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onSuccess(String s, Call call, Response response) {
|
|
|
|
|
+ AirGuardRunTimeListModel data = new Gson().fromJson(s,AirGuardRunTimeListModel.class);
|
|
|
|
|
+ System.out.println(data.getData());
|
|
|
|
|
+ if (data.getCode() == 0){
|
|
|
|
|
+ mView.onUpdateSuccess(position,data);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ LoginIn.tokenOut(data.getCode(),mContext);
|
|
|
|
|
+ mView.onFile(data.getMsg());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onError(Call call, Response response, Exception e) {
|
|
|
|
|
+ super.onError(call, response, e);
|
|
|
|
|
+ mView.onFile("信息获取失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //更新数据
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void updateRunTime() {
|
|
|
|
|
+ OkGo.get(ApiService.httpUrl1 + Data.getConfigUrl() +UrlConstants.AIRGUARD_RUNTIMELIST)
|
|
|
|
|
+ .tag(this)
|
|
|
|
|
+ .params("deviceId",mView.getDevId())
|
|
|
|
|
+ .cacheKey("cacheGetKey")
|
|
|
|
|
+ .cacheMode(CacheMode.DEFAULT)
|
|
|
|
|
+ .headers("token", Data.getToken())
|
|
|
|
|
+ .execute(new StringCallback() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onSuccess(String s, Call call, Response response) {
|
|
|
|
|
+ AirGuardRunTimeListModel data = new Gson().fromJson(s,AirGuardRunTimeListModel.class);
|
|
|
|
|
+ if (data.getCode() == 0){
|
|
|
|
|
+ mView.onUpdateSuccess(data);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ LoginIn.tokenOut(data.getCode(),mContext);
|
|
|
|
|
+ mView.onFile(data.getMsg());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public void onError(Call call, Response response, Exception e) {
|
|
public void onError(Call call, Response response, Exception e) {
|
|
|
super.onError(call, response, e);
|
|
super.onError(call, response, e);
|