| | |
| | | import android.widget.TextView; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.JsonObject; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.hdl.linkpm.sdk.core.exception.HDLException; |
| | | import com.hdl.linkpm.sdk.home.type.HomeType; |
| | |
| | | import com.hdl.photovoltaic.other.HdlThreadLogic; |
| | | import com.hdl.photovoltaic.other.HdlUniLogic; |
| | | import com.hdl.photovoltaic.ui.bean.DeviceRemoteInfo; |
| | | import com.hdl.photovoltaic.ui.bean.HouseIdBean; |
| | | import com.hdl.photovoltaic.ui.bean.OidBean; |
| | | import com.hdl.photovoltaic.ui.bean.UnCountBean; |
| | | import com.hdl.photovoltaic.ui.home.HomePageFragment; |
| | | import com.hdl.photovoltaic.ui.me.MeFragment; |
| | | import com.hdl.photovoltaic.ui.message.MessageFragment; |
| | | import com.hdl.photovoltaic.ui.newC.PowerStationsListActivity; |
| | | import com.hdl.photovoltaic.ui.newC.PowerStationsMoveActivity; |
| | | import com.hdl.photovoltaic.ui.powerstation.HouseAndDeviceFragment; |
| | | import com.hdl.photovoltaic.uni.HDLUniMP; |
| | | import com.hdl.photovoltaic.utils.AppManagerUtils; |
| | |
| | | this.restoreFragment();//恢复fragment页面 |
| | | } else { |
| | | // |
| | | this.removeAllFragments(); |
| | | this.removeAllFragments(mFragmentManager); |
| | | //正常启动时调用 |
| | | if (!fragmentList.isEmpty()) { |
| | | fragmentList.clear(); |
| | |
| | | ft.commit(); |
| | | } |
| | | |
| | | private void removeAllFragments() { |
| | | if (mFragmentManager == null) return; |
| | | private void removeAllFragments(FragmentManager manager) { |
| | | if (manager == null) return; |
| | | try { |
| | | final List<Fragment> fragments = mFragmentManager.getFragments(); |
| | | final List<Fragment> fragments = manager.getFragments(); |
| | | if (fragments.isEmpty()) { |
| | | return; |
| | | } |
| | | FragmentTransaction transaction = mFragmentManager.beginTransaction(); |
| | | FragmentTransaction transaction = manager.beginTransaction(); |
| | | for (int i = 0; i < fragments.size(); i++) { |
| | | Fragment fragment = fragments.get(i); |
| | | if (fragment != null) { |
| | | // FragmentManager childManager = fragment.getChildFragmentManager(); |
| | | // removeAllFragments(childManager); |
| | | transaction.remove(fragment); |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | if (!TextUtils.isEmpty(registrationID)) { |
| | | UserConfigManage.getInstance().setRegistrationID(registrationID); |
| | | UserConfigManage.getInstance().Save(); |
| | | // UserConfigManage.getInstance().setRegistrationID(registrationID); |
| | | // UserConfigManage.getInstance().Save(); |
| | | String finalRegistrationID = registrationID; |
| | | HdlResidenceLogic.getInstance().pushAdd(new CloudCallBeak<String>() { |
| | | @Override |
| | | public void onSuccess(String pushId) { |
| | | |
| | | if (!TextUtils.isEmpty(pushId)) { |
| | | UserConfigManage.getInstance().setRegistrationID(finalRegistrationID); |
| | | UserConfigManage.getInstance().setPushId(pushId); |
| | | UserConfigManage.getInstance().Save(); |
| | | } |
| | |
| | | this.notificationSet(); |
| | | //ACCESS_FINE_LOCATION 允许使用GPS定位 |
| | | //ACCESS_COARSE_LOCATION 允许使用WIFI热点或基站来获取粗略的定位 |
| | | // String[] ary = PermissionUtils.checkPermission(_mActivity, new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}); |
| | | // if (ary.length > 0) { |
| | | // this.requestPermissions(ary, PermissionUtils.STATUS_SUCCESS); |
| | | // } else { |
| | | // locationUpdates(); |
| | | // } |
| | | String[] ary = PermissionUtils.checkPermission(_mActivity, new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}); |
| | | if (ary.length > 0) { |
| | | this.requestPermissions(ary, PermissionUtils.STATUS_SUCCESS); |
| | | } else { |
| | | locationUpdates(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | uniCallBackBaseBean.setData(linkResponse.getData()); |
| | | HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, uniCallBackBaseBean); |
| | | HdlLogLogic.print(linkResponse.getTopic() + new Gson().toJson(linkResponse.getData()), true); |
| | | // HdlDeviceLogic.getInstance().searchAllNetworkGateway(null);//逆变器wifi状态-重新搜索一下逆变器-重新更新连接状态 |
| | | } else if (linkResponse.getTopic().endsWith("/app/thing/event/appHomeRemoveRefresh/up")) { |
| | | String[] topicArray = linkResponse.getTopic().split("/"); |
| | | //住宅删除通知 |
| | |
| | | uniCallBackBaseBean.setData(topicArray[1]); |
| | | HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, uniCallBackBaseBean); |
| | | HdlLogLogic.print(linkResponse.getTopic() + new Gson().toJson(linkResponse.getData()), true); |
| | | } else if (linkResponse.getTopic().endsWith("/app/thing/event/appHomeRefresh/up")) { |
| | | //B端登录电站回滚时,收到回滚的事件时,发个通知给uniapp,uniapp刷新下电站的权限,调整下菜单栏的内容。 |
| | | String[] topicArray = linkResponse.getTopic().split("/"); |
| | | if (topicArray.length < 2) { |
| | | return; |
| | | } |
| | | final String HomeId = topicArray[1]; |
| | | HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean(); |
| | | uniCallBackBaseBean.setType(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_home_delivery_rollback); |
| | | uniCallBackBaseBean.setData(HomeId); |
| | | HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, uniCallBackBaseBean); |
| | | } else if (linkResponse.getTopic().endsWith("/app/thing/property/send")) { |
| | | //设备状态变更topic:/user/${homeId}/app/thing/property/send |
| | | if (linkResponse.getData() == null) { |
| | |
| | | return; |
| | | } |
| | | int index = -1; |
| | | List<GatewayBean> list = HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(UserConfigManage.getInstance().getHomeId(), null); |
| | | List<GatewayBean> list = HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(UserConfigManage.getInstance().getHomeId()); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | GatewayBean gatewayBean = list.get(i); |
| | | if (gatewayBean.getGatewayId().equals(topics[2])) { |