From db937c029a3f9dbaec86cbbc944ebbee3ece13be Mon Sep 17 00:00:00 2001 From: wjc <1243177876@qq.com> Date: 星期四, 31 七月 2025 14:49:17 +0800 Subject: [PATCH] Merge branch '1.4.4' into dev --- app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseAndDeviceFragment.java | 555 +++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 353 insertions(+), 202 deletions(-) diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseAndDeviceFragment.java b/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseAndDeviceFragment.java index 24c5d53..e26b8aa 100644 --- a/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseAndDeviceFragment.java +++ b/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseAndDeviceFragment.java @@ -1,26 +1,23 @@ package com.hdl.photovoltaic.ui.powerstation; import android.Manifest; -import android.app.Dialog; import android.content.Context; -import android.content.DialogInterface; 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.util.Log; +import android.text.TextUtils; 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 androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; -import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import com.google.gson.Gson; import com.hdl.linkpm.sdk.core.exception.HDLException; @@ -32,9 +29,11 @@ import com.hdl.photovoltaic.databinding.FragmentHouseListBinding; import com.hdl.photovoltaic.base.CustomBaseFragment; import com.hdl.photovoltaic.enums.DebugStatus; +import com.hdl.photovoltaic.enums.DebugType; import com.hdl.photovoltaic.enums.HomepageTitleTabSwitch; import com.hdl.photovoltaic.enums.LowerTagType; import com.hdl.photovoltaic.enums.PowerStationStatus; +import com.hdl.photovoltaic.enums.ProjectOperation; import com.hdl.photovoltaic.enums.ShowErrorMode; import com.hdl.photovoltaic.enums.SortType; import com.hdl.photovoltaic.enums.SortValue; @@ -45,7 +44,6 @@ 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; @@ -57,11 +55,14 @@ 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.AddPowerStationDialog; import com.hdl.photovoltaic.widget.ConfirmationCancelDialog; import com.hdl.photovoltaic.widget.DefaultFilteringDialog; import com.hdl.photovoltaic.widget.DelayedConfirmationCancelDialog; +import com.hdl.photovoltaic.widget.adapter.PowerStationDialogAdapter; +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; @@ -106,7 +107,7 @@ private String screeningConditionStatus = DebugStatus.All;//绛涢�夋潯浠剁姸鎬� private String powerStationStatusValue = PowerStationStatus.All;//鐢电珯鐘舵��(鍏ㄩ儴 涓嶄紶璇ヨ繃婊ゅ弬鏁�,1:姝e父(杩愯),2:绂荤嚎,3:寰呮帴鍏�,4:鏁呴殰) - private final long pageSize = 20;//椤垫暟 + private final long pageSize = 100;//涓�椤靛ぇ灏� /** * 杩樺師鏉′欢鐨勫垵濮嬪寲鐘舵�� @@ -128,7 +129,7 @@ @Override public void onBindView(Bundle savedInstanceState) { - getStatusOverview(); +// getStatusOverview(); initData(); //鍒濆鍖� initView(); @@ -169,11 +170,12 @@ 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)); + stationStatusStyle(viewBinding.allLl, viewBinding.allDesTv); + getStatusOverview(); loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true); } }); @@ -181,11 +183,12 @@ 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)); + stationStatusStyle(viewBinding.faultsLl, viewBinding.faultsDesTv); + getStatusOverview(); loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true); } }); @@ -193,11 +196,12 @@ 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)); + stationStatusStyle(viewBinding.offlineLl, viewBinding.offlineDesTv); + getStatusOverview(); loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true); } }); @@ -205,11 +209,12 @@ 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)); + stationStatusStyle(viewBinding.connectedLl, viewBinding.connectedDesTv); + getStatusOverview(); loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true); } }); @@ -218,12 +223,26 @@ viewBinding.addIv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - - requestPermissions(new OnCallBeak() { + AddPowerStationDialog addPowerStationDialog = new AddPowerStationDialog(_mActivity); + addPowerStationDialog.show(); + addPowerStationDialog.setCanceledOnTouchOutside(true); + addPowerStationDialog.setItemOnclickListener(new PowerStationDialogAdapter.OnclickListener() { @Override - public void onClickCallBeak() { -// UserConfigManage.getInstance().setUniBottomSafeDistanceBackgroundColor(1); -// HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null); + public void onClick(int position, String str) { + addPowerStationDialog.dismiss(); + UserConfigManage.getInstance().setUniBottomSafeDistanceBackgroundColor(1); + if (_mActivity.getString(R.string.simple_debugging).equals(str)) { + HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION_SIMPLE, null); + } else { + 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); +// } +// }); } }); @@ -251,43 +270,10 @@ installedCapacityMinValue = min;//鏈�灏忕粍涓插閲�(瑁呮満瀹归噺) installedCapacityMaxValue = max;//鏈�澶х粍涓插閲�(瑁呮満瀹归噺) 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, screeningConditionStatus, 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, screeningConditionStatus, powerStationStatusValue, ++currentHouseListPage, false); - } - } } }); //鐢电珯璇︽儏杩涘叆,鍒犻櫎鐢电珯,绉诲姩鐢电珯浣嶇疆 @@ -333,49 +319,59 @@ @Override public void onDelClick(int position, HouseIdBean houseIdBean) { - + final boolean isWaitDelivered = houseIdBean.getDebugStatus().equals(DebugStatus.WAIT_DELIVERED); DelayedConfirmationCancelDialog delayedConfirmationCancelDialog = new DelayedConfirmationCancelDialog(_mActivity); delayedConfirmationCancelDialog.show(); delayedConfirmationCancelDialog.isHideTitle(true); String homeName = "\"" + houseIdBean.getHomeName() + "\""; - delayedConfirmationCancelDialog.setContent(getString(R.string.delete_power_station).replace("%s", homeName)); - - delayedConfirmationCancelDialog.startCountdown(4); + if (isWaitDelivered) { + //"鏄惁灏嗙數绔欑殑璋冭瘯鐘舵�佸洖閫�鍒拌皟璇曚腑" + delayedConfirmationCancelDialog.setContent(getString(R.string.debug_status_rollback).replace("%s", homeName)); + } else { + delayedConfirmationCancelDialog.startCountdown(4); + delayedConfirmationCancelDialog.setContent(getString(R.string.delete_power_station).replace("%s", homeName)); + } delayedConfirmationCancelDialog.setYesOnclickListener(new DelayedConfirmationCancelDialog.onYesOnclickListener() { @Override public void Confirm() { delayedConfirmationCancelDialog.dismiss(); - showLoading(getString(R.string.deleting_please_wait)); - HdlDeviceLogic.getInstance().getCurrentHomeLocalAndCloudGatewayList(houseIdBean.getHomeId(), new CloudCallBeak<List<GatewayBean>>() { - @Override - public void onSuccess(List<GatewayBean> list) { - //鍙戣捣鍒犻櫎鐢电珯鎸囦护 - deleteResidence(houseIdBean.getHomeId(), list); + if (isWaitDelivered) { + showLoading(); + HdlResidenceLogic.getInstance().setUpdateProjectDebugStatus(houseIdBean.getHomeId(), houseIdBean.getCommunityId(), houseIdBean.getFlowRecordContent(), ProjectOperation.DEBUGGING_AGAIN.toString(), new CloudCallBeak<Boolean>() { + @Override + public void onSuccess(Boolean list) { + hideLoading(); + if (houseInfoAdapter != null) { + houseIdBean.setDebugStatus(DebugStatus.Debugging); + HdlResidenceLogic.getInstance().updateHouseIdBean(houseIdBean); + initData(); + //鏇存柊UI + houseInfoAdapter.notifyItemChanged(position); + } + } - } + @Override + public void onFailure(HDLException e) { + hideLoading(); + } + }); + } else { + showLoading(getString(R.string.deleting_please_wait)); + HdlDeviceLogic.getInstance().getCurrentHomeLocalAndCloudGatewayList(houseIdBean.getHomeId(), new CloudCallBeak<List<GatewayBean>>() { + @Override + public void onSuccess(List<GatewayBean> list) { + //鍙戣捣鍒犻櫎鐢电珯鎸囦护 + deleteResidence(position, houseIdBean, list); - @Override - public void onFailure(HDLException e) { - //鍙戣捣鍒犻櫎鐢电珯鎸囦护 - deleteResidence(houseIdBean.getHomeId(), null); - } - }); + } -// //鍒犻櫎浣忓畢 -// HdlResidenceLogic.getInstance().delResidence(houseIdBean.getHomeId(), new CloudCallBeak<Boolean>() { -// @Override -// public void onSuccess(Boolean obj) { -// HdlResidenceLogic.getInstance().delHouseId(houseIdBean.getHomeId()); -// initData();//鍒濆鍖栫紦瀛樻暟鎹� -// houseInfoAdapter.setList(houseListBeanIDList);//閲嶆柊鍒锋柊鍒楄〃 -// nullDataUpdateUi(houseListBeanIDList);//妫�娴嬫暟鎹槸鍚︿负绌� -// } -// -// @Override -// public void onFailure(HDLException e) { -// HdlThreadLogic.toast(_mActivity, e); -// } -// }); + @Override + public void onFailure(HDLException e) { + //鍙戣捣鍒犻櫎鐢电珯鎸囦护 + deleteResidence(position, houseIdBean, null); + } + }); + } } }); delayedConfirmationCancelDialog.setNoOnclickListener(new DelayedConfirmationCancelDialog.onNoOnclickListener() { @@ -387,43 +383,27 @@ } }); -// //鐢电珯缂栬緫鎸夐挳 -// 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; + 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, screeningConditionStatus, powerStationStatusValue, 1, true); - } - }); - //鐢电珯褰撴棩鍙戠數閲忕瓫閫� - viewBinding.stationDayRl.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - boolean isSelected = !v.isSelected(); - screenIconState(viewBinding.stationDayRl, viewBinding.stationDayIv, isSelected); - key = SortType.todayElectricitySort; - value = isSelected ? SortValue.ascending : SortValue.descending; + getStatusOverview(); loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true); } }); @@ -432,9 +412,22 @@ @Override public void onClick(View v) { boolean isSelected = !v.isSelected(); - screenIconState(viewBinding.stationMonthRl, viewBinding.stationMonthIv, 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); + } + }); + //鐢电珯褰撴棩鍙戠數閲忕瓫閫� + viewBinding.stationDayRl.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + boolean isSelected = !v.isSelected(); + screeningConditionStyle(viewBinding.stationDayRl, viewBinding.stationDayIv, isSelected); + key = SortType.todayElectricitySort; + value = isSelected ? SortValue.ascending : SortValue.descending; + getStatusOverview(); loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true); } }); @@ -442,6 +435,10 @@ deviceInfoAdapter.setOnclickListener(new DeviceInfoAdapter.OnClickListener() { @Override public void onClick(int position, CloudInverterDeviceBean deviceBean) { + if (!deviceBean.isActivate()) { + HdlThreadLogic.toast(_mActivity, getString(R.string.device_not_activated)); + return; + } // GatewayBean gatewayBean = new GatewayBean(); // gatewayBean.setCategorySecondName(deviceBean.getCategorySecondName()); // gatewayBean.setDevice_mac(deviceBean.getOsn()); @@ -469,7 +466,17 @@ 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())) { + //杩欓噷鍙敮鎸佽繙绋嬭皟璇曪紝杩滅▼鎷夸笉鍒癿qtt閫氳绉橀挜浠ュ強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); @@ -480,38 +487,6 @@ } }); - } - }); - //璁惧璁剧疆涓嬫媺绠ご棰滆壊 - 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); - } - } } }); //璁惧鎼滅储 @@ -526,14 +501,36 @@ } + /** - * 鏇存柊绛涢�夋潯浠剁姸鎬� + * 鏇存柊绛涢�夌數绔欑姸鎬佹牱寮� + * + * @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); @@ -546,24 +543,27 @@ 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)); viewBinding.fragmentHouseSrlListRc.setAdapter(houseInfoAdapter); houseInfoAdapter.setList(this.houseListBeanIDList, powerStationStatusValue); - //璁惧鏍囩 deviceInfoAdapter = new DeviceInfoAdapter(_mActivity); viewBinding.fragmentDeviceSrlListRc.setLayoutManager(new LinearLayoutManager(_mActivity)); viewBinding.fragmentDeviceSrlListRc.setAdapter(deviceInfoAdapter); + // // this.nullDataUpdateUi(); + //涓嬫媺鍒锋柊浣忓畢鐨勯�昏緫 + pullToRefreshHome(); + //涓嬫媺鍒锋柊璁惧鐨勯�昏緫 + pullToRefreshDevice(); } @@ -620,15 +620,18 @@ if (HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION.equals(eventBus.getType())) { // 鍙栨秷绮樻�т簨浠� EventBus.getDefault().removeStickyEvent(eventBus); - //uin鍒涘缓鐢电珯鎴愬姛鍚庨�氱煡 - loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true); - if (eventBus.getData() != null) { - Gson gson = new Gson(); - String json = eventBus.getData().toString(); - HouseIdBean houseIdBean = gson.fromJson(json, HouseIdBean.class); - HdlResidenceLogic.getInstance().switchHouse(houseIdBean, true); - - } +// HdlLogLogic.print("杩涙潵浜�---11111" + eventBus.getData().toString()); +// //uin鍒涘缓鐢电珯鎴愬姛鍚庨�氱煡 +// loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true); +// if (eventBus.getData() != null) { +// HdlLogLogic.print("杩涙潵浜�---" + eventBus.getData().toString()); +// Gson gson = new Gson(); +// String json = eventBus.getData().toString(); +// HouseIdBean houseIdBean = gson.fromJson(json, HouseIdBean.class); +// HdlResidenceLogic.getInstance().switchHouse(houseIdBean, true); +// HdlLogLogic.print("杩涙潵浜�---缁撴潫" + eventBus.getData().toString()); +// +// } } else if (HDLUniMP.UNI_EVENT_REPLY_HOME_EDIT.equals(eventBus.getType())) { // 鍙栨秷绮樻�т簨浠� EventBus.getDefault().removeStickyEvent(eventBus); @@ -665,6 +668,7 @@ // if (MqttRecvClient.getInstance() != null) { // MqttRecvClient.getInstance().removeAllTopic(); // } + loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true); } } else if (HDLUniMP.UNI_EVENT_REPLY_DEVICE_LIST.equals(eventBus.getType())) { @@ -706,27 +710,27 @@ isClickPowerStationLabel = true; selectedTitleLabelStyle(); initializationState(); + stationStatusStyle(viewBinding.allLl, viewBinding.allDesTv); getStatusOverview(); 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); @@ -745,7 +749,7 @@ * 鐢电珯鐘舵�佹瑙� */ 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) { @@ -768,7 +772,7 @@ /** * 鍒锋柊UI锛堢數绔欙級 * - * @param isRefreshing 琛ㄧず鏄笅鎷夊埛鏂扮殑 + * @param isRefreshing 鏄惁鏄剧ず鍔犺浇妗嗭紙true鏄剧ず锛宖alse涓嶆樉绀猴級 * @param key 鍙戠數鍔熺巼鎺掑簭(powerSort); * 浠婃棩鍙戠數閲忔帓搴�(todayElectricitySort); * 鍒涘缓鏃堕棿鎺掑簭(createTimeSort); @@ -838,7 +842,7 @@ if (isRefreshing) { hideLoading(); } - + HdlThreadLogic.toast(_mActivity, e.getMsg() + "(" + e.getCode() + ")"); } }, _mActivity, ShowErrorMode.YES); } @@ -848,7 +852,7 @@ /** * 鍒锋柊UI锛堣澶囷級 * - * @param isRefreshing 琛ㄧず鏄笅鎷夊埛鏂扮殑 + * @param isRefreshing 鏄惁鏄剧ず鍔犺浇妗嗭紙true鏄剧ず锛宖alse涓嶆樉绀猴級 * @param pageNo 椤电爜 * @param isClear true琛ㄧず娓呯┖缂撳瓨 */ @@ -907,6 +911,7 @@ if (isRefreshing) { hideLoading(); } + HdlThreadLogic.toast(_mActivity, e.getMsg() + "(" + e.getCode() + ")"); } }, _mActivity, ShowErrorMode.YES); } @@ -943,12 +948,12 @@ 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); @@ -985,20 +990,26 @@ /** * 鍒犻櫎鐢电珯 * - * @param homeId 鐢电珯id - * @param list 閫嗗彉鍣ㄥ垪琛� + * @param position 浣嶇疆 + * @param houseIdBean 鐢电珯id瀵硅薄 + * @param list 閫嗗彉鍣ㄥ垪琛� */ - private void deleteResidence(String homeId, List<GatewayBean> list) { + private void deleteResidence(int position, HouseIdBean houseIdBean, List<GatewayBean> list) { //鍒犻櫎浣忓畢 - HdlResidenceLogic.getInstance().delResidence(homeId, new CloudCallBeak<Boolean>() { + HdlResidenceLogic.getInstance().delResidence(houseIdBean.getHomeId(), new CloudCallBeak<Boolean>() { @Override public void onSuccess(Boolean obj) { hideLoading(); - initializeInverter(list); //鍙戣捣鍒濆鍖栨寚浠ょ粰閫嗗彉鍣�;锛堟敞鎰�:鍙兘鏄湰鍦板彂閫佷簡(瑕佹悳绱㈠眬鍩熺綉閫嗗彉鍣ㄥ垪琛紝寤虹珛鏈湴閫氳閫氶亾),鍒犻櫎鐢电珯鎴愬姛鍚�,浜戠瑙g粦閫嗗彉鍣ㄧ殑鍏崇郴锛� - HdlResidenceLogic.getInstance().delHouseId(homeId);//鍒犻櫎鐢电珯缂撳瓨 + if (houseIdBean.getDebugType().equals(DebugType.NORMAL)) { + initializeInverter(list); //鍙戣捣鍒濆鍖栨寚浠ょ粰閫嗗彉鍣�;锛堟敞鎰�:鍓嶉潰宸插厛瑙g粦浜戠閫嗗彉鍣紝mqtt閫氶亾宸叉柇寮�锛屽垵濮嬪寲鍙兘鏄湰鍦板彂閫�(鍏堟悳绱㈠眬鍩熺綉閫嗗彉鍣ㄥ垪琛紝寤虹珛鏈湴閫氳閫氶亾)锛� + } + HdlResidenceLogic.getInstance().delHouseId(houseIdBean.getHomeId());//鍒犻櫎鐢电珯缂撳瓨 initData();//鍒濆鍖栫紦瀛樻暟鎹� - houseInfoAdapter.setList(houseListBeanIDList, powerStationStatusValue);//閲嶆柊鍒锋柊鍒楄〃 + if (houseInfoAdapter != null) { +// houseInfoAdapter.setList(houseListBeanIDList, powerStationStatusValue);//閲嶆柊鍒锋柊鍒楄〃 + houseInfoAdapter.notifyItemRemoved(position);//鍙埛鏂板綋鍓嶇殑浣嶇疆 + } getStatusOverview();//鍒犻櫎鎴愬姛鍚庡埛鏂扮數绔欑姸鎬佹瑙� nullDataUpdateUi();//妫�娴嬫暟鎹槸鍚︿负绌� } @@ -1045,12 +1056,24 @@ if (ary.length > 0) { this.requestPermissions(ary, PermissionUtils.STATUS_SUCCESS); } else { - - UserConfigManage.getInstance().setUniBottomSafeDistanceBackgroundColor(1); - HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null); - locationUpdates(); - - + AddPowerStationDialog addPowerStationDialog = new AddPowerStationDialog(_mActivity); + addPowerStationDialog.show(); + addPowerStationDialog.setCanceledOnTouchOutside(true); + addPowerStationDialog.setItemOnclickListener(new PowerStationDialogAdapter.OnclickListener() { + @Override + public void onClick(int position, String str) { + addPowerStationDialog.dismiss(); +// UserConfigManage.getInstance().setCurrentAppLanguage(itemData.getLanguage()); +// UserConfigManage.getInstance().Save(); + UserConfigManage.getInstance().setUniBottomSafeDistanceBackgroundColor(1); + if (_mActivity.getString(R.string.simple_debugging).equals(str)) { + HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION_SIMPLE, null); + } else { + HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null); + } + locationUpdates(); + } + }); } } @@ -1090,4 +1113,132 @@ } } + + + /** + * 涓嬫媺鍒锋柊銆愪綇瀹呫�戠殑閫昏緫 + */ + 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); + } + + } \ No newline at end of file -- Gitblit v1.8.0