| | |
| | | //网络请求库 |
| | | implementation 'com.alibaba:fastjson:1.2.66' |
| | | api 'com.hdl.hdlhttp:hxhttp:1.0.4' |
| | | api project(path: ':HDLLog') |
| | | api 'com.hdl.android:log:1.0.0' |
| | | |
| | | } |
| | |
| | | */ |
| | | public static final String POST_HOUSE_SECURITY_FULL_UPDATE = "/home-wisdom/program/security/sync"; |
| | | /** |
| | | * 群控全量更新 |
| | | */ |
| | | public static final String POST_HOUSE_GROUPCONTROL_FULL_UPDATE = "/home-wisdom/program/device/groupcontrol/syncData"; |
| | | /** |
| | | * 更改住宅名称 |
| | | */ |
| | | public static final String POST_HOUSENAME_UPDATE = "/home-wisdom/program/home/updateName"; |
| | |
| | | public void setProductModel(@NonNull String productModel) { |
| | | this.productModel = productModel; |
| | | } |
| | | |
| | | public ProductInfo() { |
| | | } |
| | | |
| | | public ProductInfo(String productName, String productModel, String imageUrl) { |
| | | this.productName = productName; |
| | | this.productModel = productModel; |
| | | this.imageUrl = imageUrl; |
| | | } |
| | | } |
| | |
| | | public void fullUpdateSecuritysListInfo(String homeId,String gatewayId ,JsonArray data ,IDefaultCallBack callBack) { |
| | | HDLPMProjectController.getInstance().fullUpdateSecuritysListInfo(homeId, gatewayId, data, callBack); |
| | | } |
| | | public void fullUpdateGroupControlListInfo(String homeId,String gatewayId ,JsonArray data ,IDefaultCallBack callBack) { |
| | | HDLPMProjectController.getInstance().fullUpdateSecuritysListInfo(homeId, gatewayId, data, callBack); |
| | | } |
| | | |
| | | |
| | | public void fullAddGroupControlList(String homeId,String gatewayId ,JsonArray data ,IDefaultCallBack callBack) { |
| | | HDLPMProjectController.getInstance().fullAddGroupControlList(homeId, gatewayId, data, callBack); |
| | | } |
| | | |
| | | } |
| | |
| | | } |
| | | }); |
| | | } |
| | | public Disposable fullAddGroupControlList(String homeId, String gatewayId, JsonArray data, IDefaultCallBack callBack) { |
| | | JsonObject json = new JsonObject(); |
| | | json.addProperty("homeId", homeId); |
| | | json.addProperty("gatewayId", gatewayId); |
| | | json.add("infos", data); |
| | | String requestUrl = HDLCloudProjectApi.getRequestUrl(HDLCloudProjectApi.POST_HOUSE_GROUPCONTROL_FULL_UPDATE); |
| | | return HxHttp.builder() |
| | | .url(requestUrl) |
| | | .raw(json.toString()) |
| | | .build() |
| | | .executePost() |
| | | .subscribeWith(new HDLResponse<String>() { |
| | | @Override |
| | | public void onResponse(String response) { |
| | | if (callBack != null) { |
| | | callBack.onSuccess(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | HDLExceptionSubmitUtils.submit(requestUrl, json, e); |
| | | if (callBack != null) { |
| | | callBack.onFailure(e); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | public Disposable updateHouseName(String homeId, String homeName, IDefaultCallBack callBack) { |
| | | JsonObject json = new JsonObject(); |
| | |
| | | |
| | | /** |
| | | * 通知退出重新登录 |
| | | * |
| | | * @param type: 0:正常退出 1:极光推送强制退出 |
| | | */ |
| | | private void notificationRelogin(int type) { |
| | |
| | | |
| | | /** |
| | | * 退出登录 |
| | | * |
| | | * @param type: 0:正常退出 1:极光推送强制退出 |
| | | */ |
| | | public void logout(int type) { |
| | |
| | | removeAll(); |
| | | //2.发出重新登录通知 |
| | | notificationRelogin(type); |
| | | } |
| | | |
| | | /****************************请求接口****************************/ |
| | | /** |
| | | * 获取账号所在区域 |
| | | * |
| | | * @param account 账号 |
| | | * @param callBack 结果回调 |
| | | */ |
| | | public void regionByAccount(String account, IRegionByAccountCallBack callBack) { |
| | | HDLPMUserController.getInstance().regionByAccount(account, new IRegionByAccountCallBack() { |
| | | @Override |
| | | public void onSuccess(HDLUserRegionBean regionBean) { |
| | | if (regionBean != null) { |
| | | //查询成功记录一次 |
| | | setUserRegionUrl(regionBean.getRegionUrl()); |
| | | if (callBack != null) { |
| | | callBack.onSuccess(regionBean); |
| | | } |
| | | } else { |
| | | if (callBack != null) { |
| | | callBack.onFailure(HDLException.getErrorWithCode(HDLErrorCode.HDL_DATA_PARSING_ERROR)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException error) { |
| | | if (callBack != null) { |
| | | callBack.onFailure(error); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 通过账号和密码登录 |
| | | * |
| | | * @param account 账号 |
| | | * @param loginPwd 密码 |
| | | * @param callBack 结果回调 |
| | | */ |
| | | public void loginByPassword(String account, String loginPwd, ILoginCallBack callBack) { |
| | | HDLPMUserController.getInstance().loginByPassword(account, loginPwd, new ILoginCallBack() { |
| | | @Override |
| | | public void onSuccess(HDLLoginBean loginBean) { |
| | | loginSuccess(loginBean); |
| | | if (callBack != null) { |
| | | callBack.onSuccess(loginBean); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException error) { |
| | | if (callBack != null) { |
| | | callBack.onFailure(error); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /****************************请求接口****************************/ |
| | |
| | | }); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 通过账号和密码登录 |
| | | * |
| | |
| | | * |
| | | * @param account |
| | | * @param callBack |
| | | * @return https://nearest.hdlchina.com/smart-footstone/region/regionByUserAccount |
| | | */ |
| | | public Disposable regionByAccount(String account, IRegionByAccountCallBack callBack) { |
| | | String requestUrl = HDLLinkPMSdk.getInitUrl() + HDLCloudUserApi.POST_RegionByAccount; |
| | | return HxHttp.builder() |
| | | .url(requestUrl) |
| | | .params("account", account) |
| | | .build() |
| | | .post() |
| | | .subscribeWith(new HDLResponse<HDLUserRegionBean>() { |
| | | @Override |
| | | public void onResponse(HDLUserRegionBean response) { |
| | | if (callBack != null) { |
| | | callBack.onSuccess(response); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | HDLExceptionSubmitUtils.submit(requestUrl, account, e); |
| | | if (callBack != null) { |
| | | callBack.onFailure(e); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 登录 |
| | | * 通过账号和密码 |
| | | * |
| | | * @param account 手机或者邮箱 |
| | | * @param loginPwd 密码 |
| | | * @param callBack |
| | | * @return |
| | | */ |
| | | public Disposable loginByPassword(String account, String loginPwd, ILoginCallBack callBack) { |
| | | String requestUrl = HDLCloudUserApi.getRequestUrl(HDLCloudUserApi.POST_LOGIN); |
| | | JsonObject json = new JsonObject(); |
| | | json.addProperty("account", account); |
| | | json.addProperty("loginPwd", loginPwd); |
| | | // json.addProperty("platform", "APP"); |
| | | json.addProperty("grantType", "password"); |
| | | |
| | | return HxHttp.builder() |
| | | .url(requestUrl) |
| | | .raw(json.toString()) |
| | | .build() |
| | | .post() |
| | | .subscribeWith(new HDLResponse<HDLLoginBean>() { |
| | | @Override |
| | | public void onResponse(HDLLoginBean response) { |
| | | if (callBack != null) { |
| | | callBack.onSuccess(response); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | HDLExceptionSubmitUtils.submit(requestUrl, json, e); |
| | | if (callBack != null) { |
| | | callBack.onFailure(e); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 获取账号所在区域 |
| | | * |
| | | * @param account |
| | | * @param callBack |
| | | * @return https://nearest.hdlcontrol.com/smart-footstone/region/regionByUserAccount |
| | | */ |
| | | public Disposable regionByAccount(boolean isBooleanB, String account, IRegionByAccountCallBack callBack) { |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 登录 |
| | | * 通过验证码 |
| | |
| | | package com.hdl.linkpm.sdk.utils; |
| | | |
| | | import android.text.TextUtils; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.google.gson.JsonObject; |
| | | import com.hdl.linkpm.sdk.core.exception.HDLException; |
| | | import com.hdl.linkpm.sdk.core.exception.HDLLinkCopyException; |
| | |
| | | |
| | | public static void submit(String requestUrl, Object json, HDLLinkCopyException e) { |
| | | try { |
| | | JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(json)); |
| | | String utfStr = ""; |
| | | if (jsonObject != null) { |
| | | try { |
| | | byte[] data = jsonObject.getBytes("data"); |
| | | utfStr = new String(data); |
| | | } catch (Exception e1) { |
| | | |
| | | } |
| | | } |
| | | if (!TextUtils.isEmpty(utfStr)) { |
| | | LogUtil.log(requestUrl, "code:" + e.getCode() + "--msg:" + e.getMsg() + "--params:" + HDLGsonUtils.toJson(json) + "--utf-8:" + utfStr, null, Level.high); |
| | | } else { |
| | | LogUtil.log(requestUrl, "code:" + e.getCode() + "--msg:" + e.getMsg() + "--params:" + HDLGsonUtils.toJson(json), null, Level.high); |
| | | |
| | | } |
| | | } catch (Exception e1) { |
| | | |
| | | } |
| | |
| | | delAllFile(folderPath); // 删除完里面所有内容 |
| | | String filePath = folderPath; |
| | | filePath = filePath.toString(); |
| | | java.io.File myFilePath = new java.io.File(filePath); |
| | | File myFilePath = new File(filePath); |
| | | myFilePath.delete(); // 删除空文件夹 |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | //二维码库 |
| | | implementation project(path: ':third-zxing') |
| | | //Link本地库 |
| | | implementation project(path: ':HDLLinkPMSdk') |
| | | implementation 'com.hdl.android.link.local.sdk:localsdk:1.0.0' |
| | | // implementation project(path: ':HDLLinkPMSdk') |
| | | implementation 'com.hdl.android:pmsdk:1.0.1' |
| | | implementation 'com.hdl.android:debugsdk:1.0.1' |
| | | |
| | | testImplementation 'junit:junit:4.13.2' |
| | | androidTestImplementation 'androidx.test.ext:junit:1.1.3' |
| | |
| | | include ':app' |
| | | include ':third-zxing' |
| | | //include ':HDLLinkLocalSdk' |
| | | include ':HDLLinkPMSdk' |
| | | include ':HDLLog' |
| | | //include ':HDLLinkPMSdk' |
| | | //include ':HDLLog' |
| | | include ':countrypicker' |