From 636c4bb04e4fcd723766b82732990cdb4ae4ea2e Mon Sep 17 00:00:00 2001
From: hxb <hxb@hdlchina.com.cn>
Date: 星期四, 22 二月 2024 15:48:23 +0800
Subject: [PATCH] 删除掉本地库
---
app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseListFragment.java | 155 +++++++++++++++++++++++++++++++++++++--------------
1 files changed, 112 insertions(+), 43 deletions(-)
diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseListFragment.java b/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseListFragment.java
index 1e2a415..cd222e3 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseListFragment.java
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseListFragment.java
@@ -1,25 +1,38 @@
package com.hdl.photovoltaic.ui.powerstation;
import android.Manifest;
+import android.annotation.SuppressLint;
import android.content.Context;
import android.content.pm.PackageManager;
+import android.graphics.Movie;
import android.hardware.camera2.CameraManager;
import android.os.Bundle;
import android.view.View;
import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
+import com.bumptech.glide.Glide;
+import com.bumptech.glide.load.DataSource;
+import com.bumptech.glide.load.engine.DiskCacheStrategy;
+import com.bumptech.glide.load.engine.GlideException;
+import com.bumptech.glide.load.resource.gif.GifDrawable;
+import com.bumptech.glide.request.RequestListener;
+import com.bumptech.glide.request.target.Target;
import com.google.gson.Gson;
import com.hdl.linkpm.sdk.core.exception.HDLException;
import com.hdl.photovoltaic.R;
-import com.hdl.photovoltaic.bean.BaseEventBus;
+import com.hdl.photovoltaic.config.AppConfigManage;
+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.HomepageTitleTabSwitch;
import com.hdl.photovoltaic.enums.ShowErrorMode;
import com.hdl.photovoltaic.listener.CloudCallBeak;
-import com.hdl.photovoltaic.other.HdlDeviceLogic;
+import com.hdl.photovoltaic.other.HdlCommonLogic;
import com.hdl.photovoltaic.other.HdlLogLogic;
import com.hdl.photovoltaic.other.HdlResidenceLogic;
import com.hdl.photovoltaic.other.HdlThreadLogic;
@@ -27,7 +40,10 @@
import com.hdl.photovoltaic.ui.adapter.HouseInfoAdapter;
import com.hdl.photovoltaic.ui.bean.HouseIdBean;
import com.hdl.photovoltaic.uni.HDLUniMP;
+import com.hdl.photovoltaic.utils.GlideUtils;
import com.hdl.photovoltaic.utils.PermissionUtils;
+import com.hdl.photovoltaic.widget.MovieDrawable;
+import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus;
import com.hdl.sdk.link.core.utils.mqtt.MqttRecvClient;
import java.util.ArrayList;
@@ -67,29 +83,34 @@
initView();
//鍒濆鍖栫晫闈㈢洃鍚櫒
initEvent();
-
-
}
private void initEvent() {
+
+ //娣诲姞鐢电珯
viewBinding.toolbarTopFragmentHouseListRl.topMoreIv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- // 鎵撳紑灏忕▼搴忛〉闈�
-// HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null);
- requestPermissions(new PermissionsResultCallback() {
- @Override
- public void succeed() {
- // 鎵撳紑灏忕▼搴忛〉闈�
- HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null);
- }
+ HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null);
- @Override
- public void failing() {
- }
- });
+// requestPermissions(new PermissionsResultCallback() {
+// @Override
+// public void succeed() {
+//// Intent intent = new Intent();
+//// intent.setClass(_mActivity, FastScanActivity.class);
+//// startActivity(intent);
+//// // 鎵撳紑灏忕▼搴忛〉闈�
+// HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null);
+// }
+//
+// @Override
+// public void failing() {
+// HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null);
+// }
+// });
+
}
});
@@ -106,9 +127,12 @@
@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();
+ String path = HDLUniMP.UNI_EVENT_OPEN_HOME_DETAILS
+ + "?homeId=" + houseIdBean.getHomeId()
+ + "&homeName=" + houseIdBean.getHomeName()
+ + "&powerStationStatus=" + houseIdBean.getPowerStationStatus();
HdlUniLogic.getInstance().openUniMP(path, null);
}
@@ -120,20 +144,17 @@
viewBinding.toolbarTopFragmentHouseListRl.topMoreIv.setVisibility(View.VISIBLE);
viewBinding.toolbarTopFragmentHouseListRl.topMoreIv.setImageResource(R.drawable.add);
LinearLayoutManager linearLayout = new LinearLayoutManager(_mActivity);
- houseInfoAdapter = new HouseInfoAdapter(this.houseListBeanIDList, _mActivity);
+ houseInfoAdapter = new HouseInfoAdapter(_mActivity);
viewBinding.fragmentHouseSrlListRc.setLayoutManager(linearLayout);
viewBinding.fragmentHouseSrlListRc.setAdapter(houseInfoAdapter);
+ houseInfoAdapter.setList(this.houseListBeanIDList);
+ this.nullDataUpdateUi(houseListBeanIDList);
}
private void initData() {
this.houseListBeanIDList = new ArrayList<>();
-// for (int i = 0; i < 11; i++) {
-// HouseListBean houseListBean = new HouseListBean();
-// houseListBean.setHomeName("鐢电珯" + i);
-// this.houseListBeanList.add(houseListBean);
-// }
this.houseListBeanIDList.addAll(HdlResidenceLogic.getInstance().getHouseIdList());
}
@@ -145,14 +166,41 @@
@Override
public void onEventMessage(BaseEventBus eventBus) {
super.onEventMessage(eventBus);
- if (HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION.equals(eventBus.getType())) {
- //uin鍒涘缓鐢电珯鎴愬姛鍚庨�氱煡
- updateUIData(false);
- if (eventBus.getData() != null) {
- Gson gson = new Gson();
- String json = eventBus.getData().toString();
- HouseIdBean houseIdBean = gson.fromJson(json, HouseIdBean.class);
- HdlResidenceLogic.getInstance().switchHouse(houseIdBean);
+ if (HDLUniMP.UNI_EVENT_REPLY_HOME_MODEL.equals(eventBus.getTopic())) {
+ if (HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION.equals(eventBus.getType())) {
+ //uin鍒涘缓鐢电珯鎴愬姛鍚庨�氱煡
+ updateUIData(false);
+ if (eventBus.getData() != null) {
+ Gson gson = new Gson();
+ String json = eventBus.getData().toString();
+ HouseIdBean houseIdBean = gson.fromJson(json, HouseIdBean.class);
+ HdlResidenceLogic.getInstance().switchHouse(houseIdBean);
+
+ }
+ } else if (HDLUniMP.UNI_EVENT_REPLY_HOME_EDIT.equals(eventBus.getType())) {
+ //todo 鐜板湪榛樿鍒锋柊鍏ㄩ儴
+ //uin缂栬緫浣忓畢閫氱煡
+// String homeId = HdlUniLogic.getInstance().getKeyValue("homeId", eventBus.getData());
+// String home_name = HdlUniLogic.getInstance().getKeyValue("powerStationName", eventBus.getData());
+// if (TextUtils.isEmpty(homeId) || TextUtils.isEmpty(home_name)) {
+// return;
+// }
+// int index = -1;
+// for (int i = 0; i < houseListBeanIDList.size(); i++) {
+// HouseIdBean houseIdBean = houseListBeanIDList.get(i);
+// if (houseIdBean.getHomeId().equals(homeId)) {
+// index = i;
+// houseIdBean.setHomeName(home_name);
+// break;
+// }
+// }
+// if (index > -1) {
+// if (houseInfoAdapter != null) {
+// //鏇存柊鍗曚釜鏁版嵁
+// houseInfoAdapter.notifyItemChanged(index);
+// }
+// }
+
}
} else if (HDLUniMP.UNI_EVENT_REPLY_HOME_CLOSE_HOME_DETAILS_PAGE.equals(eventBus.getType())) {
@@ -160,14 +208,21 @@
if (MqttRecvClient.getInstance() != null) {
MqttRecvClient.getInstance().removeAllTopic();
}
+ updateUIData(false);
+
} else if (HDLUniMP.UNI_EVENT_REPLY_DEVICE_LIST.equals(eventBus.getType())) {
//杩涘幓浣忓畢璇︽儏uni璇诲彇閫嗗彉鍣ㄥ垪琛ㄦ垚鍔熷悗閫氱煡
- for (int i = 0; i < HdlDeviceLogic.getInstance().getCurrentHomeGatewayList().size(); i++) {
- //String gatewayId = HdlDeviceLogic.getInstance().getCurrentHomeGatewayList().get(i).getGatewayId();
- //瀛楃涓叉槸鑷繁鎸夎鍒欐嫾鎺ョ殑,閲岄潰娉ㄥ唽涓婚鏃朵細瑙f瀽瀛楃涓�,鍙嬁getGatewayId()鍊�;
- //String topic = "/user/" + gatewayId+"/1";
- //杩涘幓浣忓畢璇︽儏寮�濮嬭闃呬富棰�
- MqttRecvClient.getInstance().checkAndsubscribeAllTopics("");
+// for (int i = 0; i < HdlDeviceLogic.getInstance().getCurrentHomeGatewayList().size(); i++) {
+ //String gatewayId = HdlDeviceLogic.getInstance().getCurrentHomeGatewayList().get(i).getGatewayId();
+ //瀛楃涓叉槸鑷繁鎸夎鍒欐嫾鎺ョ殑,閲岄潰娉ㄥ唽涓婚鏃朵細瑙f瀽瀛楃涓�,鍙嬁getGatewayId()鍊�;
+ //String topic = "/user/" + gatewayId+"/1";
+ //杩涘幓浣忓畢璇︽儏寮�濮嬭闃呬富棰�
+ MqttRecvClient.getInstance().checkAndsubscribeAllTopics("");
+// }
+ } else if (eventBus.getTopic().equals(ConstantManage.homepage_title_tab_switch)) {
+ //鎺ユ敹澶栭儴鐐瑰嚮浜嬩欢
+ if (eventBus.getType().equals(HomepageTitleTabSwitch.powerstation.toString())) {
+ HdlLogLogic.print("姝e湪鐐瑰嚮銆愮數绔欍��");
}
}
}
@@ -195,10 +250,10 @@
if (houseInfoAdapter != null) {
//鏇存柊UI
houseInfoAdapter.setList(list);
- houseInfoAdapter.notifyDataSetChanged();
}
}
+ nullDataUpdateUi(list);
}
}, _mActivity, ShowErrorMode.YES);
@@ -227,10 +282,8 @@
mPermissionsResultCallback = permissionsResultCallback;
- //Manifest.permission.CAMERA,
- String[] s = new String[]{
- Manifest.permission.ACCESS_FINE_LOCATION,
- };
+
+ String[] s = new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.CAMERA,};
String[] ary = PermissionUtils.checkPermission(_mActivity, s);
if (ary.length > 0) {
requestPermissions(ary, PermissionUtils.STATUS_SUCCESS);
@@ -250,12 +303,17 @@
if (mPermissionsResultCallback != null) {
mPermissionsResultCallback.succeed();
}
+ } else {
+ if (mPermissionsResultCallback != null) {
+ mPermissionsResultCallback.failing();
+ }
}
}
}
}
+
private PermissionsResultCallback mPermissionsResultCallback;
@@ -267,4 +325,15 @@
}
+ /**
+ * 娌℃湁鐢电珯鍒楄〃鐨勬牱寮�
+ */
+ private void nullDataUpdateUi(List<HouseIdBean> list) {
+ HdlCommonLogic.getInstance().nullDataUpdateUi(_mActivity,
+ viewBinding.nullDataIc.getRoot(),
+ viewBinding.nullDataIc.nullDataGifAnimationIv,
+ viewBinding.nullDataIc.nullDataTv, getString(R.string.my_power_station_data_null), list != null && list.size() > 0);
+ }
+
+
}
--
Gitblit v1.8.0