| | |
| | | package com.hdl.photovoltaic.ui.powerstation; |
| | | |
| | | import android.app.Dialog; |
| | | import android.content.DialogInterface; |
| | | import android.Manifest; |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.content.pm.PackageManager; |
| | | import android.location.LocationManager; |
| | | import android.os.AsyncTask; |
| | | import android.os.Bundle; |
| | | import android.os.SystemClock; |
| | | import android.provider.Settings; |
| | | import android.text.TextUtils; |
| | | import android.util.Log; |
| | | import android.view.View; |
| | | import android.view.Window; |
| | | import android.widget.ImageView; |
| | | import android.widget.LinearLayout; |
| | | import android.widget.RelativeLayout; |
| | | import android.widget.TextView; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | import androidx.appcompat.content.res.AppCompatResources; |
| | |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.hdl.linkpm.sdk.core.exception.HDLException; |
| | | import com.hdl.photovoltaic.HDLApp; |
| | | import com.hdl.photovoltaic.R; |
| | | import com.hdl.photovoltaic.bean.PageNumberObject; |
| | | import com.hdl.photovoltaic.config.ConstantManage; |
| | | import com.hdl.photovoltaic.config.UserConfigManage; |
| | | import com.hdl.photovoltaic.databinding.FragmentHouseListBinding; |
| | | import com.hdl.photovoltaic.base.CustomBaseFragment; |
| | | import com.hdl.photovoltaic.enums.DebugStatus; |
| | | import com.hdl.photovoltaic.enums.HomepageTitleTabSwitch; |
| | | import com.hdl.photovoltaic.enums.LowerTagType; |
| | | import com.hdl.photovoltaic.enums.PowerStationStatus; |
| | |
| | | import com.hdl.photovoltaic.enums.SortValue; |
| | | import com.hdl.photovoltaic.listener.CloudCallBeak; |
| | | import com.hdl.photovoltaic.listener.LinkCallBack; |
| | | import com.hdl.photovoltaic.listener.OnCallBeak; |
| | | import com.hdl.photovoltaic.other.HdlCommonLogic; |
| | | import com.hdl.photovoltaic.other.HdlDeviceLogic; |
| | | import com.hdl.photovoltaic.other.HdlDialogLogic; |
| | | import com.hdl.photovoltaic.other.HdlLogLogic; |
| | | import com.hdl.photovoltaic.other.HdlOtaLogic; |
| | | import com.hdl.photovoltaic.other.HdlResidenceLogic; |
| | | import com.hdl.photovoltaic.other.HdlThreadLogic; |
| | | import com.hdl.photovoltaic.other.HdlUniLogic; |
| | |
| | | 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.GPSManagerUtils; |
| | | import com.hdl.photovoltaic.utils.PermissionUtils; |
| | | import com.hdl.photovoltaic.utils.ProcessManagerUtils; |
| | | import com.hdl.photovoltaic.utils.URLEncodingUtils; |
| | | import com.hdl.photovoltaic.widget.ConfirmationCancelDialog; |
| | | import com.hdl.photovoltaic.widget.DefaultFilteringDialog; |
| | | import com.hdl.photovoltaic.widget.DelayedConfirmationCancelDialog; |
| | | import com.hdl.photovoltaic.widget.refreshlayout.BGARefreshLayout; |
| | | import com.hdl.photovoltaic.widget.refreshlayout.HDLRefreshViewHolder; |
| | | import com.hdl.sdk.link.common.exception.HDLLinkException; |
| | | import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus; |
| | | import com.hdl.sdk.link.core.bean.gateway.GatewayBean; |
| | |
| | | private String value = SortValue.all;//descending:降序,ascending:升序 |
| | | private String installedCapacityMinValue = "";//最小组串容量(装机容量) |
| | | private String installedCapacityMaxValue = "";//最大组串容量(装机容量) |
| | | private String gridTypeValue = "";//并网状态(全部 不传该过滤参数,FULL_GRID:并网,OFFLINE:离网) |
| | | private String screeningConditionStatus = DebugStatus.All;//筛选条件状态 |
| | | private String powerStationStatusValue = PowerStationStatus.All;//电站状态(全部 不传该过滤参数,1:正常(运行),2:离线,3:待接入,4:故障) |
| | | |
| | | private final long pageSize = 20;//页数 |
| | | private final long pageSize = 100;//一页大小 |
| | | |
| | | /** |
| | | * 还原条件的初始化状态 |
| | |
| | | value = SortValue.all; |
| | | installedCapacityMinValue = ""; |
| | | installedCapacityMaxValue = ""; |
| | | gridTypeValue = ""; |
| | | screeningConditionStatus = DebugStatus.All; |
| | | powerStationStatusValue = PowerStationStatus.All; |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public void onBindView(Bundle savedInstanceState) { |
| | | getStatusOverview(); |
| | | // getStatusOverview(); |
| | | initData(); |
| | | //初始化 |
| | | initView(); |
| | |
| | | selectedTitleLabelStyle(); |
| | | initializationState(); |
| | | getStatusOverview(); |
| | | loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true); |
| | | loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true); |
| | | |
| | | } |
| | | }); |
| | |
| | | viewBinding.allLl.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | if (powerStationStatusValue.equals(PowerStationStatus.All)) { |
| | | return; |
| | | } |
| | | powerStationStatusValue = PowerStationStatus.All; |
| | | viewBinding.allLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_yes_ffffff)); |
| | | viewBinding.faultsLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff)); |
| | | viewBinding.offlineLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff)); |
| | | viewBinding.connectedLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff)); |
| | | loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true); |
| | | stationStatusStyle(viewBinding.allLl, viewBinding.allDesTv); |
| | | getStatusOverview(); |
| | | loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true); |
| | | } |
| | | }); |
| | | //故障 |
| | | viewBinding.faultsLl.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | if (powerStationStatusValue.equals(PowerStationStatus.malfunction)) { |
| | | return; |
| | | } |
| | | powerStationStatusValue = PowerStationStatus.malfunction; |
| | | viewBinding.allLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff)); |
| | | viewBinding.faultsLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_yes_ffffff)); |
| | | viewBinding.offlineLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff)); |
| | | viewBinding.connectedLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff)); |
| | | loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true); |
| | | stationStatusStyle(viewBinding.faultsLl, viewBinding.faultsDesTv); |
| | | getStatusOverview(); |
| | | loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true); |
| | | } |
| | | }); |
| | | //离线 |
| | | viewBinding.offlineLl.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | if (powerStationStatusValue.equals(PowerStationStatus.off)) { |
| | | return; |
| | | } |
| | | powerStationStatusValue = PowerStationStatus.off; |
| | | viewBinding.allLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff)); |
| | | viewBinding.faultsLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff)); |
| | | viewBinding.offlineLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_yes_ffffff)); |
| | | viewBinding.connectedLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff)); |
| | | loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true); |
| | | stationStatusStyle(viewBinding.offlineLl, viewBinding.offlineDesTv); |
| | | getStatusOverview(); |
| | | loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true); |
| | | } |
| | | }); |
| | | //待接入 |
| | | viewBinding.connectedLl.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | if (powerStationStatusValue.equals(PowerStationStatus.connecting)) { |
| | | return; |
| | | } |
| | | powerStationStatusValue = PowerStationStatus.connecting; |
| | | viewBinding.allLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff)); |
| | | viewBinding.faultsLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff)); |
| | | viewBinding.offlineLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff)); |
| | | viewBinding.connectedLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_yes_ffffff)); |
| | | loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true); |
| | | stationStatusStyle(viewBinding.connectedLl, viewBinding.connectedDesTv); |
| | | getStatusOverview(); |
| | | loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true); |
| | | } |
| | | }); |
| | | |
| | |
| | | viewBinding.addIv.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | UserConfigManage.getInstance().setUniBottomSafeDistanceBackgroundColor(1); |
| | | HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null); |
| | | |
| | | requestPermissions(new OnCallBeak() { |
| | | @Override |
| | | public void onClickCallBeak() { |
| | | // UserConfigManage.getInstance().setUniBottomSafeDistanceBackgroundColor(1); |
| | | // HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | }); |
| | |
| | | public void onClick(View v) { |
| | | DefaultFilteringDialog defaultFilteringDialog = new DefaultFilteringDialog(_mActivity); |
| | | defaultFilteringDialog.show(); |
| | | defaultFilteringDialog.initState(installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue); |
| | | defaultFilteringDialog.initState(installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus); |
| | | defaultFilteringDialog.setOnClickListener(new DefaultFilteringDialog.OnClickListener() { |
| | | @Override |
| | | public void confirm(String min, String max, String state) { |
| | | installedCapacityMinValue = min;//最小组串容量(装机容量) |
| | | installedCapacityMaxValue = max;//最大组串容量(装机容量) |
| | | gridTypeValue = state;//并网状态(全部 不传该过滤参数,FULL_GRID:并网,OFFLINE:离网) |
| | | loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true); |
| | | screeningConditionStatus = state;//调试状态(全部;调试中;调试完成;已交付;授权调试) |
| | | getStatusOverview(); |
| | | loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true); |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | |
| | | //电站设置下拉箭头颜色 |
| | | viewBinding.fragmentHouseSrl.setColorSchemeResources(R.color.text_FF245EC3); |
| | | //电站下拉读取 |
| | | viewBinding.fragmentHouseSrl.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { |
| | | @Override |
| | | public void onRefresh() { |
| | | viewBinding.fragmentHouseSrl.setRefreshing(false); |
| | | loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true); |
| | | getStatusOverview(); |
| | | } |
| | | }); |
| | | //电站上拉读取 |
| | | viewBinding.fragmentHouseSrlListRc.addOnScrollListener(new RecyclerView.OnScrollListener() { |
| | | @Override |
| | | public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { |
| | | // super.onScrolled(recyclerView, dx, dy); |
| | | |
| | | LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager(); |
| | | if (layoutManager == null) { |
| | | return; |
| | | } |
| | | int visibleItemCount = layoutManager.getChildCount(); |
| | | int totalItemCount = layoutManager.getItemCount(); |
| | | int firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition(); |
| | | if (visibleItemCount > 0 && visibleItemCount + firstVisibleItemPosition == totalItemCount) { |
| | | if (!isHouseLoadingMore) { |
| | | // 滑动到了底部,执行相应的操作 |
| | | HdlLogLogic.print("---滑动到了底部"); |
| | | loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, ++currentHouseListPage, false); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | //电站详情进入,删除电站,移动电站位置 |
| | |
| | | |
| | | } |
| | | }); |
| | | //电站编辑按钮 |
| | | viewBinding.editIv.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | startActivity(HouseListEditActivity.class); |
| | | } |
| | | }); |
| | | //电站名称筛选 |
| | | //PV筛选 |
| | | viewBinding.stationNameRl.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | boolean isSelected = !v.isSelected(); |
| | | screenIconState(viewBinding.stationNameRl, viewBinding.stationNameIv, isSelected); |
| | | key = SortType.homeNameSort; |
| | | screeningConditionStyle(viewBinding.stationNameRl, viewBinding.stationNameIv, isSelected); |
| | | key = SortType.installedCapacitySort; |
| | | value = isSelected ? SortValue.ascending : SortValue.descending; |
| | | loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true); |
| | | getStatusOverview(); |
| | | loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true); |
| | | } |
| | | }); |
| | | //电站发电功率筛选 |
| | | //额定功率筛选 |
| | | viewBinding.stationPowerRl.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | boolean isSelected = !v.isSelected(); |
| | | screenIconState(viewBinding.stationPowerRl, viewBinding.stationPowerIv, isSelected); |
| | | key = SortType.powerSort; |
| | | screeningConditionStyle(viewBinding.stationPowerRl, viewBinding.stationPowerIv, isSelected); |
| | | key = SortType.invPowerSort; |
| | | value = isSelected ? SortValue.ascending : SortValue.descending; |
| | | loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true); |
| | | getStatusOverview(); |
| | | loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true); |
| | | } |
| | | }); |
| | | //电站电池容量筛选 |
| | | viewBinding.stationMonthRl.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | boolean isSelected = !v.isSelected(); |
| | | screeningConditionStyle(viewBinding.stationMonthRl, viewBinding.stationMonthIv, isSelected); |
| | | key = SortType.batteryCapacitySort; |
| | | value = isSelected ? SortValue.ascending : SortValue.descending; |
| | | getStatusOverview(); |
| | | loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true); |
| | | } |
| | | }); |
| | | //电站当日发电量筛选 |
| | |
| | | @Override |
| | | public void onClick(View v) { |
| | | boolean isSelected = !v.isSelected(); |
| | | screenIconState(viewBinding.stationDayRl, viewBinding.stationDayIv, isSelected); |
| | | screeningConditionStyle(viewBinding.stationDayRl, viewBinding.stationDayIv, isSelected); |
| | | key = SortType.todayElectricitySort; |
| | | value = isSelected ? SortValue.ascending : SortValue.descending; |
| | | loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true); |
| | | } |
| | | }); |
| | | //电站当月发电量筛选 |
| | | viewBinding.stationMonthRl.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | boolean isSelected = !v.isSelected(); |
| | | screenIconState(viewBinding.stationMonthRl, viewBinding.stationMonthIv, isSelected); |
| | | key = SortType.monthElectricitySort; |
| | | value = isSelected ? SortValue.ascending : SortValue.descending; |
| | | loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true); |
| | | getStatusOverview(); |
| | | loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true); |
| | | } |
| | | }); |
| | | //设备点击 |
| | |
| | | HdlDeviceLogic.getInstance().setDeviceRemoteInfo(newList, deviceBean.getHomeId(), new CloudCallBeak<List<GatewayBean>>() { |
| | | @Override |
| | | public void onSuccess(List<GatewayBean> obj) { |
| | | |
| | | GatewayBean newGatewayBean = HDLLinkLocalGateway.getInstance().getLocalGateway(deviceBean.getOsn()); |
| | | if (newGatewayBean == null) { |
| | | HdlThreadLogic.toast(_mActivity, getString(R.string.device_off)); |
| | | return; |
| | | } |
| | | if (TextUtils.isEmpty(newGatewayBean.getGatewayId()) || TextUtils.isEmpty(newGatewayBean.getAesKey())) { |
| | | //这里只支持远程调试,远程拿不到mqtt通讯秘钥以及gatewayId; |
| | | HdlThreadLogic.toast(_mActivity, getString(R.string.Device_failed_to_certificate) + "(124004)"); |
| | | return; |
| | | } |
| | | String jsonEncryption = URLEncodingUtils.encodeURIComponent(new Gson().toJson(newGatewayBean)); |
| | | String path = HDLUniMP.UNI_EVENT_OPEN_DEVICE_DETAILS + "?inverterInfo=" + jsonEncryption; |
| | | HdlUniLogic.getInstance().openUniMP(path, null); |
| | |
| | | |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | //设备设置下拉箭头颜色 |
| | | viewBinding.fragmentDeviceSrl.setColorSchemeResources(R.color.text_FF245EC3); |
| | | //设备下拉读取 |
| | | viewBinding.fragmentDeviceSrl.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { |
| | | @Override |
| | | public void onRefresh() { |
| | | viewBinding.fragmentDeviceSrl.setRefreshing(false); |
| | | loadNextPageDeviceList(false, 1, true); |
| | | } |
| | | }); |
| | | //设备上拉读取 |
| | | viewBinding.fragmentDeviceSrlListRc.addOnScrollListener(new RecyclerView.OnScrollListener() { |
| | | @Override |
| | | public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { |
| | | // super.onScrolled(recyclerView, dx, dy); |
| | | |
| | | LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager(); |
| | | if (layoutManager == null) { |
| | | return; |
| | | } |
| | | int visibleItemCount = layoutManager.getChildCount(); |
| | | int totalItemCount = layoutManager.getItemCount(); |
| | | int firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition(); |
| | | if (visibleItemCount > 0 && visibleItemCount + firstVisibleItemPosition == totalItemCount) { |
| | | if (!isDeviceLoadingMore) { |
| | | // 滑动到了底部,执行相应的操作 |
| | | HdlLogLogic.print("---滑动到了底部"); |
| | | loadNextPageDeviceList(false, ++currentDeviceListPage, false); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | //设备搜索 |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 更新筛选条件状态 |
| | | * 更新筛选电站状态样式 |
| | | * |
| | | * @param ll 组件名称 |
| | | * @param tv 组件名称 |
| | | */ |
| | | private void stationStatusStyle(LinearLayout ll, TextView tv) { |
| | | viewBinding.allLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff)); |
| | | viewBinding.faultsLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff)); |
| | | viewBinding.offlineLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff)); |
| | | viewBinding.connectedLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff)); |
| | | viewBinding.allDesTv.setTextColor(getResources().getColor(R.color.text_FF5B5B5B)); |
| | | viewBinding.faultsDesTv.setTextColor(getResources().getColor(R.color.text_FF5B5B5B)); |
| | | viewBinding.offlineDesTv.setTextColor(getResources().getColor(R.color.text_FF5B5B5B)); |
| | | viewBinding.connectedDesTv.setTextColor(getResources().getColor(R.color.text_FF5B5B5B)); |
| | | |
| | | ll.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_yes_ffffff)); |
| | | tv.setTextColor(getResources().getColor(R.color.text_FFACACAC)); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 更新筛选条件状态样式 |
| | | * |
| | | * @param relativeLayout 组件名称 |
| | | * @param imageView 组件名称 |
| | | * @param isSelected 状态 |
| | | */ |
| | | private void screenIconState(RelativeLayout relativeLayout, ImageView imageView, boolean isSelected) { |
| | | private void screeningConditionStyle(RelativeLayout relativeLayout, ImageView imageView, boolean isSelected) { |
| | | viewBinding.stationNameRl.setSelected(false); |
| | | viewBinding.stationNameIv.setSelected(false); |
| | | viewBinding.stationPowerRl.setSelected(false); |
| | |
| | | imageView.setSelected(isSelected); |
| | | } |
| | | |
| | | |
| | | private void initView() { |
| | | viewBinding.powerStationLabelParent.setVisibility(View.VISIBLE); |
| | | viewBinding.deviceLabelParent.setVisibility(View.GONE); |
| | | viewBinding.allLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_yes_ffffff)); |
| | | viewBinding.faultsLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff)); |
| | | viewBinding.offlineLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff)); |
| | | viewBinding.connectedLl.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.station_status_no_ffffff)); |
| | | |
| | | stationStatusStyle(viewBinding.allLl, viewBinding.allDesTv); |
| | | //电站标签 |
| | | houseInfoAdapter = new HouseInfoAdapter(_mActivity); |
| | | viewBinding.fragmentHouseSrlListRc.setLayoutManager(new LinearLayoutManager(_mActivity)); |
| | |
| | | deviceInfoAdapter = new DeviceInfoAdapter(_mActivity); |
| | | viewBinding.fragmentDeviceSrlListRc.setLayoutManager(new LinearLayoutManager(_mActivity)); |
| | | viewBinding.fragmentDeviceSrlListRc.setAdapter(deviceInfoAdapter); |
| | | // |
| | | // this.nullDataUpdateUi(); |
| | | //下拉刷新住宅的逻辑 |
| | | pullToRefreshHome(); |
| | | //下拉刷新设备的逻辑 |
| | | pullToRefreshDevice(); |
| | | |
| | | } |
| | | |
| | |
| | | // 取消粘性事件 |
| | | EventBus.getDefault().removeStickyEvent(eventBus); |
| | | //uin创建电站成功后通知 |
| | | loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true); |
| | | loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true); |
| | | if (eventBus.getData() != null) { |
| | | Gson gson = new Gson(); |
| | | String json = eventBus.getData().toString(); |
| | |
| | | // if (MqttRecvClient.getInstance() != null) { |
| | | // MqttRecvClient.getInstance().removeAllTopic(); |
| | | // } |
| | | loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true); |
| | | |
| | | loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true); |
| | | } |
| | | } else if (HDLUniMP.UNI_EVENT_REPLY_DEVICE_LIST.equals(eventBus.getType())) { |
| | | // 取消粘性事件 |
| | |
| | | } |
| | | String homeId = eventBus.getData().toString(); |
| | | //进去住宅详情uni读取逆变器列表成功后通知 |
| | | for (int i = 0; i < HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(homeId).size(); i++) { |
| | | String gatewayId = HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(homeId).get(i).getGatewayId(); |
| | | for (int i = 0; i < HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(homeId, null).size(); i++) { |
| | | String gatewayId = HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(homeId, null).get(i).getGatewayId(); |
| | | //字符串是自己按规则拼接的,里面注册主题时会解析字符串,只拿getGatewayId()值; |
| | | String topic = "/user/" + gatewayId + "/#"; |
| | | //进去住宅详情开始订阅主题 |
| | |
| | | isClickPowerStationLabel = true; |
| | | selectedTitleLabelStyle(); |
| | | initializationState(); |
| | | stationStatusStyle(viewBinding.allLl, viewBinding.allDesTv); |
| | | getStatusOverview(); |
| | | loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true); |
| | | loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true); |
| | | } else if (eventBus.getType().equals(ConstantManage.station_page)) { |
| | | // 取消粘性事件 |
| | | EventBus.getDefault().removeStickyEvent(eventBus); |
| | | isClickPowerStationLabel = true; |
| | | selectedTitleLabelStyle(); |
| | | powerStationStatusValue = eventBus.getData() == null ? "" : eventBus.getData().toString(); |
| | | //通过首页电站进来的 |
| | | if (eventBus.getData().equals(PowerStationStatus.All)) { |
| | | isClickPowerStationLabel = true; |
| | | selectedTitleLabelStyle(); |
| | | viewBinding.allLl.performClick(); |
| | | stationStatusStyle(viewBinding.allLl, viewBinding.allDesTv); |
| | | } else if (eventBus.getData().equals(PowerStationStatus.malfunction)) { |
| | | isClickPowerStationLabel = true; |
| | | selectedTitleLabelStyle(); |
| | | viewBinding.faultsLl.performClick(); |
| | | stationStatusStyle(viewBinding.faultsLl, viewBinding.faultsDesTv); |
| | | } else if (eventBus.getData().equals(PowerStationStatus.off)) { |
| | | isClickPowerStationLabel = true; |
| | | selectedTitleLabelStyle(); |
| | | viewBinding.offlineLl.performClick(); |
| | | stationStatusStyle(viewBinding.offlineLl, viewBinding.offlineDesTv); |
| | | } else if (eventBus.getData().equals(PowerStationStatus.connecting)) { |
| | | isClickPowerStationLabel = true; |
| | | selectedTitleLabelStyle(); |
| | | viewBinding.connectedLl.performClick(); |
| | | stationStatusStyle(viewBinding.connectedLl, viewBinding.connectedDesTv); |
| | | } |
| | | getStatusOverview(); |
| | | loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true); |
| | | } else if (eventBus.getType().equals(ConstantManage.station_edit)) { |
| | | //编辑后更新一下住宅列表 |
| | | //loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true); |
| | |
| | | * 电站状态概览 |
| | | */ |
| | | private void getStatusOverview() { |
| | | HdlResidenceLogic.getInstance().getStatusOverview(new CloudCallBeak<StatusOverviewBean>() { |
| | | HdlResidenceLogic.getInstance().getStatusOverview(screeningConditionStatus, installedCapacityMinValue, installedCapacityMaxValue, new CloudCallBeak<StatusOverviewBean>() { |
| | | @Override |
| | | public void onSuccess(StatusOverviewBean statusOverviewBean) { |
| | | if (statusOverviewBean == null) { |
| | |
| | | /** |
| | | * 刷新UI(电站) |
| | | * |
| | | * @param isRefreshing 表示是下拉刷新的 |
| | | * @param isRefreshing 是否显示加载框(true显示,false不显示) |
| | | * @param key 发电功率排序(powerSort); |
| | | * 今日发电量排序(todayElectricitySort); |
| | | * 创建时间排序(createTimeSort); |
| | | * 电池容量排序(batteryCapacitySort); |
| | | * @param keyValue (descending:降序 |
| | | * ascending:升序), |
| | | * @param installedCapacityMin 最小组串容量(装机容量) |
| | | * @param installedCapacityMax 最大组串容量(装机容量) |
| | | * @param gridType 并网状态 (全部 :"";FULL_GRID : 并网;OFFLINE :离网) |
| | | * @param gridType 调试状态(全部;调试中;调试完成;已交付;授权调试) |
| | | * @param powerStationStatus 电站状态 (全部 :"";1 : 正常;2 : 离线; 3 : 待接入;4 : 故障) |
| | | * @param pageNo 页码 |
| | | * @param isClear 是否清除数据 |
| | |
| | | if (isRefreshing) { |
| | | hideLoading(); |
| | | } |
| | | |
| | | HdlThreadLogic.toast(_mActivity, e.getMsg() + "(" + e.getCode() + ")"); |
| | | } |
| | | }, _mActivity, ShowErrorMode.YES); |
| | | } |
| | |
| | | /** |
| | | * 刷新UI(设备) |
| | | * |
| | | * @param isRefreshing 表示是下拉刷新的 |
| | | * @param isRefreshing 是否显示加载框(true显示,false不显示) |
| | | * @param pageNo 页码 |
| | | * @param isClear true表示清空缓存 |
| | | */ |
| | |
| | | if (isRefreshing) { |
| | | hideLoading(); |
| | | } |
| | | HdlThreadLogic.toast(_mActivity, e.getMsg() + "(" + e.getCode() + ")"); |
| | | } |
| | | }, _mActivity, ShowErrorMode.YES); |
| | | } |
| | |
| | | boolean is_data; |
| | | String tipText = ""; |
| | | if (isClickPowerStationLabel) { |
| | | is_data = houseListBeanIDList != null && houseListBeanIDList.size() > 0; |
| | | is_data = houseListBeanIDList != null && !houseListBeanIDList.isEmpty(); |
| | | tipText = getString(R.string.my_power_station_data_null); |
| | | HdlCommonLogic.getInstance().nullDataUpdateUi(_mActivity, viewBinding.homeNullDataIc.getRoot(), viewBinding.homeNullDataIc.nullDataGifAnimationIv, viewBinding.homeNullDataIc.nullDataTv, tipText, is_data); |
| | | |
| | | } else { |
| | | is_data = deviceInfoList != null && deviceInfoList.size() > 0; |
| | | is_data = deviceInfoList != null && !deviceInfoList.isEmpty(); |
| | | tipText = getString(R.string.no_equipment); |
| | | |
| | | HdlCommonLogic.getInstance().nullDataUpdateUi(_mActivity, viewBinding.deviceNullDataIc.getRoot(), viewBinding.deviceNullDataIc.nullDataGifAnimationIv, viewBinding.deviceNullDataIc.nullDataTv, tipText, is_data); |
| | |
| | | if (requestCode == PermissionUtils.STATUS_SUCCESS) { |
| | | for (int i = 0; i < permissions.length; i++) { |
| | | if (grantResults[i] == PackageManager.PERMISSION_GRANTED) { |
| | | if (mPermissionsResultCallback != null) { |
| | | mPermissionsResultCallback.succeed(); |
| | | switch (permissions[i]) { |
| | | case Manifest.permission.ACCESS_FINE_LOCATION: { |
| | | UserConfigManage.getInstance().setUniBottomSafeDistanceBackgroundColor(1); |
| | | HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null); |
| | | locationUpdates(); |
| | | } |
| | | break; |
| | | } |
| | | |
| | | } else { |
| | | if (mPermissionsResultCallback != null) { |
| | | mPermissionsResultCallback.failing(); |
| | | } |
| | | HdlDialogLogic.getInstance().showSettingPermissionDialog(_mActivity, _mActivity.getString(R.string.set_location_permissions)); |
| | | break; |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | } |
| | | |
| | | public void requestPermissions(OnCallBeak onCallBeak) { |
| | | |
| | | private PermissionsResultCallback mPermissionsResultCallback; |
| | | //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 { |
| | | |
| | | public interface PermissionsResultCallback { |
| | | UserConfigManage.getInstance().setUniBottomSafeDistanceBackgroundColor(1); |
| | | HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null); |
| | | locationUpdates(); |
| | | |
| | | void succeed(); |
| | | |
| | | void failing(); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 初始化【开启定位】和【位置信息】权限 |
| | | */ |
| | | private void locationUpdates() { |
| | | // 初始化LocationManager对象 |
| | | LocationManager locationManager = (LocationManager) _mActivity.getSystemService(Context.LOCATION_SERVICE); |
| | | GPSManagerUtils.getInstance().getLocation(_mActivity); |
| | | // 判断设备是否支持定位功能 |
| | | if (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { |
| | | // 提示用户打开定位功能或者引导用户去系统设置页面打开定位功能 |
| | | ConfirmationCancelDialog confirmationCancelDialog = new ConfirmationCancelDialog(_mActivity); |
| | | confirmationCancelDialog.setContent(getString(R.string.system_positioning_switch)); |
| | | confirmationCancelDialog.setConfirmation(getString(R.string.go_to_settings)); |
| | | confirmationCancelDialog.show(); |
| | | confirmationCancelDialog.isHideTitle(true); |
| | | confirmationCancelDialog.setYesOnclickListener(new ConfirmationCancelDialog.onYesOnclickListener() { |
| | | @Override |
| | | public void Confirm() { |
| | | confirmationCancelDialog.dismiss(); |
| | | Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); |
| | | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| | | HDLApp.getInstance().startActivity(intent); |
| | | |
| | | } |
| | | }); |
| | | confirmationCancelDialog.setNoOnclickListener(new ConfirmationCancelDialog.onNoOnclickListener() { |
| | | @Override |
| | | public void Cancel() { |
| | | confirmationCancelDialog.dismiss(); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 下拉刷新【住宅】的逻辑 |
| | | */ |
| | | protected void pullToRefreshHome() { |
| | | viewBinding.fragmentHouseSrl.setDelegate(new BGARefreshLayout.BGARefreshLayoutDelegate() { |
| | | @Override |
| | | public void onBGARefreshLayoutBeginRefreshing(BGARefreshLayout refreshLayout) { |
| | | new AsyncTask<Void, Void, Void>() { |
| | | |
| | | @Override |
| | | protected Void doInBackground(Void... params) { |
| | | try { |
| | | Thread.sleep(1000); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | protected void onPostExecute(Void aVoid) { |
| | | // 执行任务(如更新UI、跳转等) |
| | | viewBinding.fragmentHouseSrl.endRefreshing(); |
| | | //加载最新数据完成 |
| | | loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true); |
| | | getStatusOverview(); |
| | | } |
| | | }.execute(); |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public boolean onBGARefreshLayoutBeginLoadingMore(BGARefreshLayout refreshLayout) { |
| | | new AsyncTask<Void, Void, Void>() { |
| | | @Override |
| | | protected Void doInBackground(Void... params) { |
| | | try { |
| | | Thread.sleep(10); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | protected void onPostExecute(Void aVoid) { |
| | | viewBinding.fragmentHouseSrl.endLoadingMore(); |
| | | if (!isHouseLoadingMore) { |
| | | // 滑动到了底部,执行相应的操作 |
| | | loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, ++currentHouseListPage, false); |
| | | } |
| | | } |
| | | }.execute(); |
| | | return true; |
| | | } |
| | | }); |
| | | HDLRefreshViewHolder hdlRefreshViewHolder = new HDLRefreshViewHolder(_mActivity, true); |
| | | hdlRefreshViewHolder.setPullDownImageResource(R.mipmap.loading_44); |
| | | hdlRefreshViewHolder.setChangeToReleaseRefreshAnimResId(R.drawable.loading_refresh); |
| | | hdlRefreshViewHolder.setRefreshingAnimResId(R.drawable.loading_refresh_end); |
| | | viewBinding.fragmentHouseSrl.setRefreshViewHolder(hdlRefreshViewHolder); |
| | | } |
| | | |
| | | /** |
| | | * 下拉刷新【设备】的逻辑 |
| | | */ |
| | | protected void pullToRefreshDevice() { |
| | | viewBinding.fragmentDeviceSrl.setDelegate(new BGARefreshLayout.BGARefreshLayoutDelegate() { |
| | | @Override |
| | | public void onBGARefreshLayoutBeginRefreshing(BGARefreshLayout refreshLayout) { |
| | | |
| | | new AsyncTask<Void, Void, Void>() { |
| | | @Override |
| | | protected Void doInBackground(Void... params) { |
| | | try { |
| | | Thread.sleep(1000); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | protected void onPostExecute(Void aVoid) { |
| | | viewBinding.fragmentDeviceSrl.endRefreshing(); |
| | | loadNextPageDeviceList(false, 1, true); |
| | | } |
| | | }.execute(); |
| | | } |
| | | |
| | | @Override |
| | | public boolean onBGARefreshLayoutBeginLoadingMore(BGARefreshLayout refreshLayout) { |
| | | new AsyncTask<Void, Void, Void>() { |
| | | @Override |
| | | protected Void doInBackground(Void... params) { |
| | | try { |
| | | Thread.sleep(10); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | protected void onPostExecute(Void aVoid) { |
| | | // 执行任务(如更新UI、跳转等) |
| | | viewBinding.fragmentDeviceSrl.endLoadingMore(); |
| | | if (!isDeviceLoadingMore) { |
| | | // 滑动到了底部,执行相应的操作 |
| | | loadNextPageDeviceList(false, ++currentDeviceListPage, false); |
| | | } |
| | | } |
| | | }.execute(); |
| | | return true; |
| | | } |
| | | }); |
| | | HDLRefreshViewHolder hdlRefreshViewHolder = new HDLRefreshViewHolder(_mActivity, true); |
| | | hdlRefreshViewHolder.setPullDownImageResource(R.mipmap.loading_44); |
| | | hdlRefreshViewHolder.setChangeToReleaseRefreshAnimResId(R.drawable.loading_refresh); |
| | | hdlRefreshViewHolder.setRefreshingAnimResId(R.drawable.loading_refresh_end); |
| | | viewBinding.fragmentDeviceSrl.setRefreshViewHolder(hdlRefreshViewHolder); |
| | | } |
| | | |
| | | |
| | | } |