| | |
| | | import com.hdl.photovoltaic.ui.adapter.HouseInfoAdapter; |
| | | import com.hdl.photovoltaic.ui.bean.DeviceBean; |
| | | import com.hdl.photovoltaic.ui.bean.HouseIdBean; |
| | | import com.hdl.photovoltaic.ui.bean.StatusOverviewBean; |
| | | import com.hdl.photovoltaic.uni.HDLUniMP; |
| | | import com.hdl.photovoltaic.utils.PermissionUtils; |
| | | import com.hdl.photovoltaic.widget.DefaultFilteringDialog; |
| | |
| | | |
| | | @Override |
| | | public void onBindView(Bundle savedInstanceState) { |
| | | //放在这里也对,这里只是被创建一次 |
| | | // loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true); |
| | | // getStatusOverview(); |
| | | initData(); |
| | | //初始化 |
| | | initView(); |
| | |
| | | isClickPowerStationLabel = true; |
| | | viewBinding.powerStationLabel.setTextAppearance(R.style.Text20Style); |
| | | viewBinding.deviceLabel.setTextAppearance(R.style.Text16Style); |
| | | viewBinding.powerStationLabelParent.setVisibility(View.VISIBLE); |
| | | viewBinding.deviceLabelParent.setVisibility(View.GONE);//设备标签隐藏 |
| | | viewBinding.editIv.setVisibility(View.VISIBLE);//编辑图标隐藏 |
| | | viewBinding.addIv.setVisibility(View.VISIBLE);//添加图标隐藏 |
| | | viewBinding.powerStationLabelParent.setVisibility(View.VISIBLE);//电站标签【父容器】显示 |
| | | viewBinding.deviceLabelParent.setVisibility(View.GONE);//设备标签【父容器】隐藏 |
| | | loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true); |
| | | } |
| | | }); |
| | |
| | | viewBinding.powerStationLabel.setTextAppearance(R.style.Text16Style); |
| | | viewBinding.editIv.setVisibility(View.GONE);//编辑图标隐藏 |
| | | viewBinding.addIv.setVisibility(View.GONE);//添加图标隐藏 |
| | | viewBinding.powerStationLabelParent.setVisibility(View.GONE);//电站标签隐藏 |
| | | viewBinding.deviceLabelParent.setVisibility(View.VISIBLE); |
| | | viewBinding.powerStationLabelParent.setVisibility(View.GONE);//电站标签【父容器】隐藏 |
| | | viewBinding.deviceLabelParent.setVisibility(View.VISIBLE);//设备标签【父容器】显示 |
| | | loadNextPageDeviceList(true, 1, true); |
| | | } |
| | | }); |
| | |
| | | if (visibleItemCount > 0 && visibleItemCount + firstVisibleItemPosition == totalItemCount) { |
| | | if (!isHouseLoadingMore) { |
| | | // 滑动到了底部,执行相应的操作 |
| | | HdlLogLogic.print("--->滑动到了底部"); |
| | | HdlLogLogic.print("---滑动到了底部"); |
| | | loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, ++currentHouseListPage, false); |
| | | } |
| | | } |
| | |
| | | @Override |
| | | public void onClick(int position, HouseIdBean houseIdBean) { |
| | | //点击住宅详情 |
| | | HdlLogLogic.print("点击住宅详情--->" + new Gson().toJson(houseIdBean), false); |
| | | HdlLogLogic.print("点击住宅详情---" + new Gson().toJson(houseIdBean), false); |
| | | HdlResidenceLogic.getInstance().switchHouse(houseIdBean); |
| | | String path = HDLUniMP.UNI_EVENT_OPEN_HOME_DETAILS + "?homeId=" + houseIdBean.getHomeId() + "&homeName=" + houseIdBean.getHomeName() + "&powerStationStatus=" + houseIdBean.getPowerStationStatus(); |
| | | HdlUniLogic.getInstance().openUniMP(path, null); |
| | |
| | | if (visibleItemCount > 0 && visibleItemCount + firstVisibleItemPosition == totalItemCount) { |
| | | if (!isDeviceLoadingMore) { |
| | | // 滑动到了底部,执行相应的操作 |
| | | HdlLogLogic.print("--->滑动到了底部"); |
| | | HdlLogLogic.print("---滑动到了底部"); |
| | | loadNextPageDeviceList(false, ++currentDeviceListPage, false); |
| | | } |
| | | } |
| | |
| | | this.deviceInfoList.add(new DeviceBean()); |
| | | // this.deviceInfoList.addAll(HdlDeviceLogic.getInstance().getListDevice()); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | //接收外部点击事件 |
| | | if (eventBus.getType().equals(HomepageTitleTabSwitch.powerstation.toString())) { |
| | | HdlLogLogic.print("正在点击【电站】"); |
| | | // HdlThreadLogic.runSubThread(new Runnable() { |
| | | // @Override |
| | | // public void run() { |
| | | loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true); |
| | | getStatusOverview(); |
| | | // } |
| | | // }); |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 电站状态概览 |
| | | */ |
| | | private void getStatusOverview() { |
| | | HdlResidenceLogic.getInstance().getStatusOverview(new CloudCallBeak<StatusOverviewBean>() { |
| | | @Override |
| | | public void onSuccess(StatusOverviewBean statusOverviewBean) { |
| | | if (statusOverviewBean == null) { |
| | | return; |
| | | } |
| | | viewBinding.screeningConditionNumber1Tv.setText(statusOverviewBean.getTotal()); |
| | | viewBinding.screeningConditionNumber2Tv.setText(statusOverviewBean.getFault()); |
| | | viewBinding.screeningConditionNumber3Tv.setText(statusOverviewBean.getOffline()); |
| | | viewBinding.screeningConditionNumber4Tv.setText(statusOverviewBean.getConnecting()); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | |
| | | * @param pageNo 页码 |
| | | * @param isClear 是否清除数据 |
| | | */ |
| | | private void loadNextPageHouseList(boolean isRefreshing, |
| | | String key, |
| | | String keyValue, |
| | | String installedCapacityMin, |
| | | String installedCapacityMax, |
| | | String gridType, |
| | | String powerStationStatus, |
| | | long pageNo, |
| | | boolean isClear) { |
| | | private void loadNextPageHouseList(boolean isRefreshing, String key, String keyValue, String installedCapacityMin, String installedCapacityMax, String gridType, String powerStationStatus, long pageNo, boolean isClear) { |
| | | if (isClear) { |
| | | clearData(); |
| | | } |
| | |
| | | } |
| | | |
| | | //获取住宅(电站)ID列表 |
| | | HdlResidenceLogic.getInstance().getResidenceIdList( |
| | | key, |
| | | keyValue, |
| | | installedCapacityMin, |
| | | installedCapacityMax, |
| | | gridType, |
| | | powerStationStatus, |
| | | pageNo, pageSize, new CloudCallBeak<HdlResidenceLogic.HouseBeanClass>() { |
| | | HdlResidenceLogic.getInstance().getResidenceIdList(key, keyValue, installedCapacityMin, installedCapacityMax, gridType, powerStationStatus, pageNo, pageSize, new CloudCallBeak<HdlResidenceLogic.HouseBeanClass>() { |
| | | @Override |
| | | public void onSuccess(HdlResidenceLogic.HouseBeanClass houseBeanClass) { |
| | | HdlThreadLogic.runMainThread(new Runnable() { |
| | | @Override |
| | | public void onSuccess(HdlResidenceLogic.HouseBeanClass houseBeanClass) { |
| | | HdlThreadLogic.runMainThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | if (isRefreshing) { |
| | | hideLoading(); |
| | | } |
| | | isHouseLoadingMore = false; |
| | | if (houseBeanClass != null) { |
| | | currentHouseListTotal = (int) houseBeanClass.getTotalPage(); |
| | | currentHouseListPage = (int) houseBeanClass.getPageNo(); |
| | | //更新缓存 |
| | | HdlResidenceLogic.getInstance().setHouseIdList(houseBeanClass.getList()); |
| | | if (houseInfoAdapter != null) { |
| | | initData(); |
| | | //更新UI |
| | | houseInfoAdapter.setList(houseListBeanIDList); |
| | | } |
| | | } |
| | | nullDataUpdateUi(); |
| | | public void run() { |
| | | if (isRefreshing) { |
| | | hideLoading(); |
| | | } |
| | | isHouseLoadingMore = false; |
| | | if (houseBeanClass != null) { |
| | | currentHouseListTotal = (int) houseBeanClass.getTotalPage(); |
| | | currentHouseListPage = (int) houseBeanClass.getPageNo(); |
| | | //更新缓存 |
| | | HdlResidenceLogic.getInstance().setHouseIdList(houseBeanClass.getList()); |
| | | if (houseInfoAdapter != null) { |
| | | initData(); |
| | | //更新UI |
| | | houseInfoAdapter.setList(houseListBeanIDList); |
| | | } |
| | | }, _mActivity, ShowErrorMode.YES); |
| | | } |
| | | nullDataUpdateUi(); |
| | | } |
| | | }, _mActivity, ShowErrorMode.YES); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | HdlThreadLogic.runMainThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | if (currentHouseListPage > 1) { |
| | | --currentHouseListPage; |
| | | } |
| | | isHouseLoadingMore = false; |
| | | if (isRefreshing) { |
| | | hideLoading(); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | HdlThreadLogic.runMainThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | if (currentHouseListPage > 1) { |
| | | --currentHouseListPage; |
| | | } |
| | | isHouseLoadingMore = false; |
| | | if (isRefreshing) { |
| | | hideLoading(); |
| | | } |
| | | |
| | | } |
| | | }, _mActivity, ShowErrorMode.YES); |
| | | } |
| | | }); |
| | | }, _mActivity, ShowErrorMode.YES); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | for (int i = 0; i < list.size(); i++) { |
| | | GatewayBean gatewayBean = list.get(i); |
| | | HdlDeviceLogic.getInstance().initializeGateway(gatewayBean.getDevice_mac(), new LinkCallBack<Boolean>() { |
| | | HdlDeviceLogic.getInstance().initializeInverter(gatewayBean.getDevice_mac(), new LinkCallBack<Boolean>() { |
| | | @Override |
| | | public void onSuccess(Boolean obj) { |
| | | // HdlLogLogic.print("初始化逆变器成功-->mac:" + cloudInverterDeviceBean.getOsn(),true); |
| | |
| | | @Override |
| | | public void onSuccess(Boolean obj) { |
| | | hideLoading(); |
| | | //发起初始化指令给逆变器; |
| | | initializeInverter(list); |
| | | HdlResidenceLogic.getInstance().delHouseId(homeId); |
| | | initializeInverter(list); //发起初始化指令给逆变器;(注意:只能是本地发送了(要搜索局域网逆变器列表,建立本地通讯通道),删除电站成功后,云端解绑逆变器的关系) |
| | | HdlResidenceLogic.getInstance().delHouseId(homeId);//删除电站缓存 |
| | | initData();//初始化缓存数据 |
| | | houseInfoAdapter.setList(houseListBeanIDList);//重新刷新列表 |
| | | nullDataUpdateUi();//检测数据是否为空 |
| | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | hideLoading(); |
| | | |
| | | HdlThreadLogic.toast(_mActivity, e); |
| | | } |
| | | }); |