| | |
| | | import androidx.lifecycle.MutableLiveData; |
| | | |
| | | import com.doumee.keyCabinet.MApplication; |
| | | import com.doumee.keyCabinet.bean.CabinetFaceBean; |
| | | import com.doumee.keyCabinet.bean.FaceUserBean; |
| | | import com.doumee.keyCabinet.event.ReLoginEvent; |
| | | import com.doumee.keyCabinet.http.Apis; |
| | | import com.doumee.keyCabinet.http.param.BaseResponse; |
| | | import com.doumee.keyCabinet.http.param.DevLoginParam; |
| | | import com.doumee.keyCabinet.http.param.FaceUserParam; |
| | | import com.doumee.keyCabinet.http.param.RequestBaseObject; |
| | | import com.doumee.keyCabinet.utils.LMobileInfo; |
| | | import com.doumee.keyCabinet.utils.ParamsUtil; |
| | | import com.doumee.lib_coremodel.base.BaseModel; |
| | | import com.doumee.lib_coremodel.base.DataViewModel; |
| | | import com.doumee.lib_coremodel.http.rxJava.SimpleObserver; |
| | | import com.doumee.lib_coremodel.http.utils.RxUtils; |
| | | |
| | | import org.greenrobot.eventbus.EventBus; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | public class AddFaceVM extends DataViewModel { |
| | |
| | | doAction(type); |
| | | } |
| | | |
| | | public void getDatas(String name){ |
| | | if (true) { |
| | | return; |
| | | } |
| | | RequestBaseObject<FaceUserParam> request = new RequestBaseObject<>(); |
| | | FaceUserParam param = new FaceUserParam(); |
| | | param.setLastTime(""); |
| | | param.setName(name); |
| | | param.setType("0"); |
| | | request.setParam(param); |
| | | public void getDatas(){ |
| | | DevLoginParam param = new DevLoginParam(); |
| | | param.setCode(LMobileInfo.getDeviceUniqueId()); |
| | | showLoading(true); |
| | | getRetrofitService(Apis.class).allFaceList(MApplication.getConfigBean().getLanguage(),MApplication.getCookie(),MApplication.getConfigBean().getShopId(), |
| | | MApplication.getConfigBean().getGymId(), ParamsUtil.encodeRequestBody(request)) |
| | | getRetrofitService(Apis.class).allFaceList(ParamsUtil.encodeRequestBody(param)) |
| | | .compose(RxUtils.schedulersTransformer()) |
| | | .subscribe(new SimpleObserver<BaseResponse<FaceUserBean>>(rxJavaGcManager) { |
| | | .subscribe(new SimpleObserver<BaseResponse<CabinetFaceBean>>(rxJavaGcManager) { |
| | | @Override |
| | | public void onNext(@NonNull BaseResponse<FaceUserBean> response) { |
| | | if("000000".equals(response.getErrorCode())){ |
| | | public void onNext(@NonNull BaseResponse<CabinetFaceBean> response) { |
| | | if(200==response.getCode()){ |
| | | //查询数据 |
| | | if(response.getRecordList()!=null&&response.getRecordList().size()>0){ |
| | | datasLD.setValue(response.getRecordList()); |
| | | if(response.getData()!=null){ |
| | | CabinetFaceBean faceBean = response.getData(); |
| | | List<FaceUserBean> datas = new ArrayList<>(); |
| | | if(faceBean!=null&&faceBean.getAutoFaceList()!=null){ |
| | | for(FaceUserBean bean:faceBean.getAutoFaceList()){ |
| | | bean.setGroupId("1"); |
| | | } |
| | | datas.addAll(faceBean.getAutoFaceList()); |
| | | } |
| | | if(faceBean!=null&&faceBean.getDriverFaceList()!=null){ |
| | | for(FaceUserBean bean:faceBean.getDriverFaceList()){ |
| | | bean.setGroupId("0"); |
| | | } |
| | | datas.addAll(faceBean.getDriverFaceList()); |
| | | } |
| | | datasLD.setValue(datas); |
| | | } |
| | | }else if("00016".equals(response.getErrorCode())||"00068".equals(response.getErrorCode())) { |
| | | EventBus.getDefault().post(new ReLoginEvent()); |
| | | toast(response.getErrorMsg()); |
| | | }else { |
| | | toast(response.getErrorMsg()); |
| | | toast(response.getMessage()); |
| | | } |
| | | } |
| | | |