mac
2024-05-15 eb8097cb8517726094115410777083d5f63701f0
2024年05月15日15:08:47

备份代码
1个文件已添加
11个文件已修改
3 文件已重命名
513 ■■■■ 已修改文件
app/build.gradle 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/photovoltaic/internet/api/TopicApi.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/photovoltaic/other/HdlLogLogic.java 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java 129 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/photovoltaic/ui/BPowerStationActivity.java 121 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/photovoltaic/ui/StartActivity.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/photovoltaic/ui/home/AutoSizeMyAAChart.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/photovoltaic/ui/home/HomePageFragment.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/photovoltaic/ui/home/aachart/AAChartSymbolConst.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/photovoltaic/ui/home/aachart/BasicChartComposer.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/photovoltaic/ui/home/aachart/CustomStyleChartComposer.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMP.java 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/layout/activity_my_power_station.xml 51 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/res/layout/fragment_home_page.xml 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/build.gradle
@@ -30,7 +30,7 @@
        minSdk 23
        targetSdk 30
        versionCode 1
        versionName "1.3.3"//版本规则1.3是产品功能迭代用的,最后一位0是我们修复bug用的
        versionName "1.4.0"//版本规则1.3是产品功能迭代用的,最后一位0是我们修复bug用的
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
        manifestPlaceholders = mfph
@@ -180,7 +180,6 @@
    implementation 'cn.jiguang.sdk:jpush-google:5.2.2'
    //分析和用户标签等功能(可选,集成极光分析SDK后,即可支持行为触发推送消息、推送转化率统计,用户行为分)
    implementation 'cn.jiguang.sdk:joperate:2.0.2'
    //若不集成厂商通道,可直接跳过以下依赖
app/src/main/java/com/hdl/photovoltaic/internet/api/TopicApi.java
@@ -1,6 +1,40 @@
package com.hdl.photovoltaic.internet.api;
public class TopicApi {
    /*
     *逆变器热点配置
     * */
    public static final String DELETING_GATEWAY_HOTSPOT_EDIT = "/user/%s/custom/hotspot/edit";
    /*
     *逆变器热点获取
     * */
    public static final String DELETING_GATEWAY_HOTSPOT_GET = "/user/%s/custom/hotspot/get";
    /*
     *逆变器wif配置
     * */
    public static final String DELETING_GATEWAY_WIFI_EDIT = "/user/%s/custom/wifi/edit";
    /*
     *逆变器wifi获取
     * */
    public static final String DELETING_GATEWAY_WIFI_GET = "/user/%s/custom/wifi/get";
    /*
     *逆变器wifi状态通知
     * */
    public static final String DELETING_GATEWAY_WIFI_NOTIFY = "/user/%s/custom/wifi/notify";
    /*
     *逆变器以太网配置
     * */
    public static final String DELETING_GATEWAY_ETHERNET_EDIT = "/user/%s/custom/ethernet/edit";
    /*
     *逆变器以太网获取
     * */
    public static final String DELETING_GATEWAY_ETHERNET_GET = "/user/%s/custom/ethernet/get";
    /*
     *通知删除并退网子设备拓扑关系
     *删除从网关
app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java
@@ -1382,6 +1382,9 @@
    }
    /**
     * 刷新逆变器缓存信息(包括设置mqtt秘钥)
     * 注:
app/src/main/java/com/hdl/photovoltaic/other/HdlLogLogic.java
@@ -1,6 +1,8 @@
package com.hdl.photovoltaic.other;
import android.util.LruCache;
import com.google.gson.Gson;
import com.hdl.photovoltaic.config.UserConfigManage;
import com.hdl.photovoltaic.utils.TimeUtils;
@@ -15,6 +17,8 @@
    //默认打印标题
    private static String logTitle = "自定义输出打印信息";
    private static Gson gson = new Gson();
    /**
     * java打印
@@ -55,16 +59,18 @@
     * @param isAddToMemory 是否加入内存(本地日志用到)
     */
    private static void printBase(String msg, String code, boolean isAddToMemory) {
        CustomLogObject customLogObject = new CustomLogObject();
        customLogObject.msgOrData = msg;
        customLogObject.code = code;
        String json = logTitle + (UserConfigManage.getInstance().isBAccount() ? "(B端):" : "(C端):");
        json += customLogObject.getJointMessage();
        if (isPrintLogcat) {
            System.out.println(json);
        }
        if (isAddToMemory) {
            writeLog(customLogObject.getJointMessage());
        try {
            CustomLogObject customLogObject = new CustomLogObject();
            customLogObject.setMsgOrData(msg);
            customLogObject.setCode(code);
            String json = logTitle + (UserConfigManage.getInstance().isBAccount() ? "(B端)==" : "(C端)==") + gson.toJson(customLogObject);
            if (isPrintLogcat) {
                System.out.println(json);
            }
            if (isAddToMemory) {
                writeLog(json);
            }
        } catch (Exception ignored) {
        }
    }
@@ -95,19 +101,30 @@
     * 自定义日志类
     */
    static class CustomLogObject {
        //信息描述
        public String msgOrData = "";
        private String msgOrData;
        //状态码
        public String code = "0";
        private String code;
        public String getJointMessage() {
            if ("0".equals(code)) {
                return msgOrData;
            }
            return msgOrData + "(" + code + ")";
        public String getMsgOrData() {
            return msgOrData == null ? "" : msgOrData;
        }
        public void setMsgOrData(String msgOrData) {
            this.msgOrData = msgOrData;
        }
        public String getCode() {
            return code == null ? "0" : code;
        }
        public void setCode(String code) {
            this.code = code;
        }
    }
app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
@@ -34,6 +34,7 @@
import com.hdl.photovoltaic.config.UserConfigManage;
import com.hdl.photovoltaic.internet.HttpServer.MyNanoHttpServer;
import com.hdl.photovoltaic.internet.TcpClient;
import com.hdl.photovoltaic.internet.api.HttpApi;
import com.hdl.photovoltaic.internet.api.TopicApi;
import com.hdl.photovoltaic.listener.CloudCallBeak;
import com.hdl.photovoltaic.listener.LinkCallBack;
@@ -64,6 +65,7 @@
import com.hdl.sdk.link.core.connect.HDLModBusConnect;
import com.hdl.sdk.link.core.connect.HDLUdpConnect;
import com.hdl.sdk.link.gateway.HDLLinkLocalGateway;
import com.huawei.hms.api.Api;
import org.greenrobot.eventbus.EventBus;
import org.json.JSONObject;
@@ -90,6 +92,8 @@
 */
public class HdlUniLogic implements HDLUniMPSDKManager.IOnOtherUniMPEventCallBack {
    private static volatile HdlUniLogic sHdlUniLogic;
    public final static String separator="---";
    /**
     * 获取当前对象
@@ -127,8 +131,8 @@
            }
            String type = getKeyValue("type", data);//小类
            String logTag = getKeyValue("logTag", data);//标记uni指令
            String mode_type = "大类->" + topic + "--->" + "小类->" + type;//用来打印的
            HdlLogLogic.print(logTag + ":" + "uni--->发送--->" + mode_type + "\r\n" + data, true);
            String mode_type = "大类-" + topic + "---" + "小类-" + type;//用来打印的
            HdlLogLogic.print(logTag + ":" + "uni---发送---" + mode_type + "\r\n" + data, true);
            if (HDLUniMP.UNI_EVENT_REPLY_USER_MODEL.equals(topic)) {
                //用户模块
                switch (type) {
@@ -280,37 +284,57 @@
                WifiUtils wifiUtils = WifiUtils.getInstance();
                //wifi模块
                switch (type) {
                    //获取wifi列表
                    case HDLUniMP.UNI_EVENT_REPLY_WIFI_LIST: {
                    //获取手机wifi列表
                    case HDLUniMP.UNI_EVENT_REPLY_PHONE_WIFI_LIST: {
                        if (callback != null) {
                            uniCallbackData(mode_type, wifiUtils.getScanResult(), callback);
                        }
                    }
                    break;
                    //当前wifi详情
                    case HDLUniMP.UNI_EVENT_REPLY_WIFI_PHONE_INFO: {
                    //获取手机当前wifi详情
                    case HDLUniMP.UNI_EVENT_REPLY_PHONE_WIFI_INFO: {
                        if (callback != null) {
                            uniCallbackData(mode_type, wifiUtils.getCurrentConnectWifiInfo(), callback);
                        }
                    }
                    break;
                    //配置WiFi信息给逆变器
                    case HDLUniMP.UNI_EVENT_REPLY_WIFI_SET_DEVICE: {
                        String mac = getKeyValue("mac", getKeyValue("data", data));//
                        String wif_type = getKeyValue("wif_type", getKeyValue("data", data));//1:热点,2:无线wifi,3:以太网
                        String ssid = getKeyValue("ssid", getKeyValue("data", data));//
                        String password = getKeyValue("password", getKeyValue("data", data));//
                        startTcpThreadSendAccountAndPassword(mode_type, ssid, password, callback);
                    }
                    break;
                    //打开手机Wifi设置界面
                    case HDLUniMP.UNI_EVENT_REPLY_OPEN_WIFI_SETTINGS: {
                    case HDLUniMP.UNI_EVENT_REPLY_PHONE_OPEN_WIFI_SETTINGS: {
                        Intent intent = new Intent(Settings.ACTION_WIFI_SETTINGS);
                        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                        HDLApp.getInstance().startActivity(intent);
                    }
                    //逆变器WiFi信息配置
                    case HDLUniMP.UNI_EVENT_REPLY_DEVICE_WIFI_SET: {
                        uniGetAndSetNetwork(mode_type, data, TopicApi.DELETING_GATEWAY_WIFI_EDIT, callback);
                    }
                    break;
                    //逆变器WiFi信息获取
                    case HDLUniMP.UNI_EVENT_REPLY_DEVICE_WIFI_GET: {
                        uniGetAndSetNetwork(mode_type, data, TopicApi.DELETING_GATEWAY_WIFI_GET, callback);
                    }
                    break;
                    //逆变器热点配置
                    case HDLUniMP.UNI_EVENT_REPLY_DEVICE_HOTSPOT_SET: {
                        uniGetAndSetNetwork(mode_type, data, TopicApi.DELETING_GATEWAY_HOTSPOT_EDIT, callback);
                    }
                    break;
                    //逆变器热点获取
                    case HDLUniMP.UNI_EVENT_REPLY_DEVICE_HOTSPOT_GET: {
                        uniGetAndSetNetwork(mode_type, data, TopicApi.DELETING_GATEWAY_HOTSPOT_GET, callback);
                    }
                    break;
                    //逆变器以太网配置
                    case HDLUniMP.UNI_EVENT_REPLY_DEVICE_ETHERNET_SET: {
                        uniGetAndSetNetwork(mode_type, data, TopicApi.DELETING_GATEWAY_ETHERNET_EDIT, callback);
                    }
                    break;
                    //逆变器以太网获取
                    case HDLUniMP.UNI_EVENT_REPLY_DEVICE_ETHERNET_GET: {
                        uniGetAndSetNetwork(mode_type, data, TopicApi.DELETING_GATEWAY_ETHERNET_GET, callback);
                    }
                    break;
                }
            } else if (HDLUniMP.UNI_EVENT_REPLY_OTA_MODEL.equals(topic)) {
                //OTA升级模块
@@ -467,7 +491,7 @@
                    //专门收集uni日志
                    case HDLUniMP.UNI_EVENT_REPLY_OTHER_UNI_LOG: {
                        String customizeContentFormat = getKeyValue("customizeContentFormat", getKeyValue("data", data));
                        HdlLogLogic.print("uni--->log--->" + customizeContentFormat, true);
                        HdlLogLogic.print("uni---log---" + customizeContentFormat, true);
                    }
                    break;
@@ -490,7 +514,7 @@
            }
        } catch (Exception e) {
            HdlLogLogic.print("uni--->发送--->" + e.getMessage(), true);
            HdlLogLogic.print("uni---发送---" + e.getMessage(), true);
        }
    }
@@ -505,7 +529,7 @@
    public void openUniMP(String path, JSONObject jsonObject) {
        JSONObject json = this.createdJSONObject(jsonObject, true);
        HDLUniMPSDKManager.getInstance().openUniMP(HDLUniMP.UNI_APP_ID, path, json, HdlUniLogic.this);
        HdlLogLogic.print("uni--->组装uni发送数据格式--->" + json, false);
        HdlLogLogic.print("uni---组装uni发送数据格式---" + json, false);
    }
    /**
@@ -519,7 +543,7 @@
        try {
            HDLUniMPSDKManager.getInstance().sendUniMPEvent(HDLUniMP.UNI_APP_ID, topic, getJSONObject(callBackBaseBean));
        } catch (Exception e) {
            HdlLogLogic.print("uni--->原生主动向小程序发送通知事件--->" + e.getMessage(), false);
            HdlLogLogic.print("uni---原生主动向小程序发送通知事件---" + e.getMessage(), false);
        }
    }
@@ -532,6 +556,41 @@
    //endregion
    //region ******uni接口方法******
    /**
     * 获取或者配置逆变器网络(包括逆变器热点,wifi,以太网)信息
     */
    private void uniGetAndSetNetwork(String type, Object data, String TopicApi, DCUniMPJSCallback callback) {
        String mac = getKeyValue("mac", getKeyValue("data", data));
        JsonObject jObject = null;
        String attribute_data = getKeyValue("attribute_data", getKeyValue("data", data));
        if (!TextUtils.isEmpty(attribute_data)) {
            try {
                jObject = new Gson().fromJson(attribute_data, JsonObject.class);
            } catch (Exception ignored) {
                jObject = new JsonObject();
            }
        }
        //解密负载数据(写密钥给网关一定是明文,因为那时网关还没有密钥)
        TcpClient.getInstance().sendDataToLinkGateway(mac, false, TopicApi, jObject, "", new HDLLinkCallBack() {
            @Override
            public void onSuccess(String msg) {
                if (callback != null) {
                    uniCallbackData(type, msg, callback);
                }
            }
            @Override
            public void onError(HDLLinkException e) {
                if (callback != null) {
                    uniCallbackData(type, null, e.getCode(), e.getMsg(), callback);
                }
            }
        });
    }
    /**
     * 获取位置信息,包括经纬度
@@ -737,7 +796,7 @@
            @Override
            public void onSuccess(Boolean b) {
                if (b) {
                    HdlLogLogic.print("本地升级--->", true);
                    HdlLogLogic.print("本地升级---", true);
                    //本地
                    //1,建立本地服务;
                    //2,告诉网关手机ip和端口;
@@ -775,7 +834,7 @@
                        }
                    });
                } else {
                    HdlLogLogic.print("在线升级--->", true);
                    HdlLogLogic.print("在线升级---", true);
                    //远程升级需要检测在逆变器有没有连接上云
                    HdlDeviceLogic.getInstance().checkInverterConnectedCloud(homeId, deviceMac, new CloudCallBeak<CloudInverterDeviceBean>() {
                        @Override
@@ -814,7 +873,7 @@
            @Override
            public void onFailure(HDLException e) {
                HdlLogLogic.print("在线升级--->", true);
                HdlLogLogic.print("在线升级---", true);
                //远程升级需要检测在逆变器有没有连接上云
                HdlDeviceLogic.getInstance().checkInverterConnectedCloud(homeId, deviceMac, new CloudCallBeak<CloudInverterDeviceBean>() {
                    @Override
@@ -989,7 +1048,7 @@
            @Override
            public void onSuccess(Boolean b) {
                if (b) {
                    HdlLogLogic.print("本地升级--->", true);
                    HdlLogLogic.print("本地升级---", true);
                    //本地
                    //1,建立本地服务;
                    // 2,告诉网关手机ip和端口;
@@ -1027,7 +1086,7 @@
                        }
                    });
                } else {
                    HdlLogLogic.print("在线升级--->", true);
                    HdlLogLogic.print("在线升级---", true);
                    //远程升级需要【检测】在逆变器有没有连接上云
                    HdlDeviceLogic.getInstance().checkInverterConnectedCloud(homeId, deviceMac, new CloudCallBeak<CloudInverterDeviceBean>() {
                        @Override
@@ -1066,7 +1125,7 @@
            @Override
            public void onFailure(HDLException e) {
                HdlLogLogic.print("在线升级--->", true);
                HdlLogLogic.print("在线升级---", true);
                //远程升级需要【检测】在逆变器有没有连接上云
                HdlDeviceLogic.getInstance().checkInverterConnectedCloud(homeId, deviceMac, new CloudCallBeak<CloudInverterDeviceBean>() {
                    @Override
@@ -1768,7 +1827,7 @@
        String tempData = getKeyValue("data", data);
        if (TextUtils.isEmpty(tempData)) {
            uniCallbackData(type, null, -2, "data内容为空", callback);
            //HdlLogLogic.print("data内容为空--->", false);
            //HdlLogLogic.print("data内容为空---", false);
            return;
        }
        ModBusBean modBusBean = new Gson().fromJson(tempData, ModBusBean.class);
@@ -1780,24 +1839,24 @@
//        }
        if (modBusBean.getMac() == null || modBusBean.getData() == null) {
            uniCallbackData(type, null, -2, "发送失败,(mac或者oid)为空", callback);
            //HdlLogLogic.print("uni--->发送--->ModBus--->发送失败,(mac或者oid)为空." + Arrays.toString(modBusBean.getData()), true);
            //HdlLogLogic.print("uni---发送---ModBus---发送失败,(mac或者oid)为空." + Arrays.toString(modBusBean.getData()), true);
            return;
        }
        //HdlLogLogic.print("uni--->发送--->ModBus--->" + Arrays.toString(modBusBean.getData()), true);
        //HdlLogLogic.print("uni---发送---ModBus---" + Arrays.toString(modBusBean.getData()), true);
        //发送modbus协议
        HDLModBusConnect.getInstance().Send(modBusBean.getMac(), modBusBean.getData(), new ModbusCallBack() {
            @Override
            public void onSuccess(int[] data) {
                uniCallbackData(type, data, callback);
//                HdlLogLogic.print("uni--->接收--->ModBus--->" + Arrays.toString(data), true);
//                HdlLogLogic.print("uni---接收---ModBus---" + Arrays.toString(data), true);
            }
            @Override
            public void onError(HDLLinkException e) {
                uniCallbackData(type, null, e.getCode(), e.getMsg(), callback);
//                HdlLogLogic.print("uni--->接收--->ModBus--->" + e.getMsg() + "(" + e.getCode() + ")", true);
//                HdlLogLogic.print("uni---接收---ModBus---" + e.getMsg() + "(" + e.getCode() + ")", true);
            }
        });
    }
@@ -1833,7 +1892,7 @@
            uniCallBackBaseBean.setData(data);
            return getJSONObject(uniCallBackBaseBean);
        } catch (Exception e) {
            HdlLogLogic.print("uni--->组装发送给uni数据格式有异常--->" + e.getMessage(), false);
            HdlLogLogic.print("uni---组装发送给uni数据格式有异常---" + e.getMessage(), false);
        }
        return new JSONObject();
    }
@@ -1858,10 +1917,10 @@
            if (callback != null) {
                callback.invoke(getJSONObject(uniCallBackBaseBean));
//                callback.invoke(uniCallBackBaseBean);
                HdlLogLogic.print("uni--->回复--->" + type + "--->" + new Gson().toJson(uniCallBackBaseBean), true);
                HdlLogLogic.print("uni---回复---" + type + "---" + new Gson().toJson(uniCallBackBaseBean), true);
            }
        } catch (Exception e) {
            HdlLogLogic.print("uni--->回复--->" + type + "--->" + e.getMessage(), true);
            HdlLogLogic.print("uni---回复---" + type + "---" + e.getMessage(), true);
        }
app/src/main/java/com/hdl/photovoltaic/ui/BPowerStationActivity.java
@@ -2,6 +2,9 @@
import androidx.annotation.NonNull;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import android.Manifest;
import android.content.Context;
@@ -38,6 +41,10 @@
import com.hdl.photovoltaic.other.HdlUniLogic;
import com.hdl.photovoltaic.ui.bean.DeviceRemoteInfo;
import com.hdl.photovoltaic.ui.bean.OidBean;
import com.hdl.photovoltaic.ui.home.HomePageFragment;
import com.hdl.photovoltaic.ui.me.MeFragment;
import com.hdl.photovoltaic.ui.message.MessageFragment;
import com.hdl.photovoltaic.ui.powerstation.HouseListFragment;
import com.hdl.photovoltaic.uni.HDLUniMP;
import com.hdl.photovoltaic.utils.AppManagerUtils;
import com.hdl.photovoltaic.utils.GPSManagerUtils;
@@ -59,6 +66,7 @@
import org.greenrobot.eventbus.ThreadMode;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import cn.jpush.android.api.JPushInterface;
@@ -69,9 +77,13 @@
 */
public class BPowerStationActivity extends CustomBaseActivity {
    private static final String CURRENT_FRAGMENT = "state_fragment_show";
    private FragmentManager mFragmentManager;
    private Fragment currentFragment = new Fragment();
    private final List<Fragment> fragmentList = new ArrayList<>();
    private int currentFragmentIndex = 0;
    private ActivityMyPowerStationBinding viewBinding;
    private int currentFragmentIndex = 0;
    private EventListener allTopicsListener;
    private int backPressTimes;
@@ -85,6 +97,8 @@
    public void onBindView(Bundle savedInstanceState) {
//        setNotificationBarBackgroundColor(CustomColor.blue);
        setStatusBarTranslucent();
        //初始化碎片
        initFragment(savedInstanceState);
        //初始化
        this.initView();
        //初始化界面监听器
@@ -99,6 +113,79 @@
        this.clickJpushNotificationMessage();
        //初始化权限
        this.requestPermissions();
    }
    /**
     * 初始化Fragment
     *
     * @param savedInstanceState -
     */
    private void initFragment(Bundle savedInstanceState) {
        mFragmentManager = getSupportFragmentManager();
        //碎片初始化
        HomePageFragment mHomePageFragment = new HomePageFragment();
        HouseListFragment mHouseListFragment = new HouseListFragment();
        MessageFragment mMessageFragment = new MessageFragment();
        MeFragment mMeFragment = new MeFragment();
        if (savedInstanceState != null) {
            //“内存重启”时调用 获取“内存重启”时保存的索引下标
            currentFragmentIndex = savedInstanceState.getInt(CURRENT_FRAGMENT, 0);
            if (fragmentList.size() != 0) {
                fragmentList.clear();
            }
            fragmentList.add(mFragmentManager.findFragmentByTag(0 + ""));
            fragmentList.add(mFragmentManager.findFragmentByTag(1 + ""));
            fragmentList.add(mFragmentManager.findFragmentByTag(2 + ""));
            fragmentList.add(mFragmentManager.findFragmentByTag(3 + ""));
            restoreFragment();//恢复fragment页面
        } else {
            //正常启动时调用
            fragmentList.add(mHomePageFragment);
            fragmentList.add(mHouseListFragment);
            fragmentList.add(mMessageFragment);
            fragmentList.add(mMeFragment);
            showFragment();
        }
    }
    /**
     * 使用show() hide()切换页面
     * 显示fragment
     */
    private void showFragment() {
        FragmentTransaction ft = mFragmentManager.beginTransaction();
        //如果之前没有添加过
        if (!fragmentList.get(currentFragmentIndex).isAdded()) {
            //第三个参数为添加当前的fragment时绑定一个tag
            ft.hide(currentFragment).add(R.id.module_fcv, fragmentList.get(currentFragmentIndex), currentFragmentIndex + "");
        } else {
            ft.hide(currentFragment).show(fragmentList.get(currentFragmentIndex));
        }
        currentFragment = fragmentList.get(currentFragmentIndex);
        ft.commit();
        //把当前显示的fragment记录下来
        currentFragment = fragmentList.get(currentFragmentIndex);
    }
    /**
     * 恢复fragment
     */
    private void restoreFragment() {
        FragmentTransaction ft = mFragmentManager.beginTransaction();
        for (int i = 0; i < fragmentList.size(); i++) {
            if (i == currentFragmentIndex) {
                ft.show(fragmentList.get(i));
            } else {
                ft.hide(fragmentList.get(i));
            }
        }
        ft.commit();
    }
@@ -213,6 +300,7 @@
                }
                currentFragmentIndex = 0;
                bottomViewChangeOfStyle();
                showFragment();
                postEventBus(HomepageTitleTabSwitch.homepage);
            }
        });
@@ -224,6 +312,7 @@
                }
                currentFragmentIndex = 1;
                bottomViewChangeOfStyle();
                showFragment();
                postEventBus(HomepageTitleTabSwitch.powerstation);
            }
        });
@@ -235,6 +324,7 @@
                }
                currentFragmentIndex = 2;
                bottomViewChangeOfStyle();
                showFragment();
                postEventBus(HomepageTitleTabSwitch.message);
            }
        });
@@ -246,6 +336,7 @@
                }
                currentFragmentIndex = 3;
                bottomViewChangeOfStyle();
                showFragment();
                postEventBus(HomepageTitleTabSwitch.me);
            }
        });
@@ -272,10 +363,7 @@
    private void bottomViewChangeOfStyle() {
        if (this.currentFragmentIndex == 0) {
            viewBinding.myHomePageFcv0.setVisibility(View.VISIBLE);//显示首页界面
            viewBinding.myPowerStationFcv1.setVisibility(View.GONE);//显示电站界面
            viewBinding.myMessageFcv2.setVisibility(View.GONE);//隐藏消息界面
            viewBinding.myMeFcv3.setVisibility(View.GONE);//隐藏我的界面
            //首页界面
            viewBinding.myPowerStationBottomIl0.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.home_page_selected));
            viewBinding.myPowerStationBottomIl0.titleTv.setTextColor(getColor(R.color.text_90000000));
            viewBinding.myPowerStationBottomIl1.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.power_station_unselected));
@@ -285,10 +373,7 @@
            viewBinding.myMeBottomIl3.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.me_unselected));
            viewBinding.myMeBottomIl3.titleTv.setTextColor(getColor(R.color.text_65000000));
        } else if (this.currentFragmentIndex == 1) {
            viewBinding.myHomePageFcv0.setVisibility(View.GONE);//隐藏首页界面
            viewBinding.myPowerStationFcv1.setVisibility(View.VISIBLE);//显示电站界面
            viewBinding.myMessageFcv2.setVisibility(View.GONE);//隐藏消息界面
            viewBinding.myMeFcv3.setVisibility(View.GONE);//隐藏我的界面
            //电站界面
            viewBinding.myPowerStationBottomIl0.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.home_page_unselected));
            viewBinding.myPowerStationBottomIl0.titleTv.setTextColor(getColor(R.color.text_65000000));
            viewBinding.myPowerStationBottomIl1.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.power_station_selected));
@@ -298,10 +383,7 @@
            viewBinding.myMeBottomIl3.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.me_unselected));
            viewBinding.myMeBottomIl3.titleTv.setTextColor(getColor(R.color.text_65000000));
        } else if (this.currentFragmentIndex == 2) {
            viewBinding.myHomePageFcv0.setVisibility(View.GONE);//隐藏首页界面
            viewBinding.myPowerStationFcv1.setVisibility(View.GONE);//隐藏电站界面
            viewBinding.myMessageFcv2.setVisibility(View.VISIBLE);//显示消息界面
            viewBinding.myMeFcv3.setVisibility(View.GONE);//隐藏我的界面
            //消息界面
            viewBinding.myPowerStationBottomIl0.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.home_page_unselected));
            viewBinding.myPowerStationBottomIl0.titleTv.setTextColor(getColor(R.color.text_65000000));
            viewBinding.myPowerStationBottomIl1.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.power_station_unselected));
@@ -311,10 +393,7 @@
            viewBinding.myMeBottomIl3.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.me_unselected));
            viewBinding.myMeBottomIl3.titleTv.setTextColor(getColor(R.color.text_65000000));
        } else if (this.currentFragmentIndex == 3) {
            viewBinding.myHomePageFcv0.setVisibility(View.GONE);//隐藏首页界面
            viewBinding.myPowerStationFcv1.setVisibility(View.GONE);//隐藏电站界面
            viewBinding.myMessageFcv2.setVisibility(View.GONE);//隐藏消息界面
            viewBinding.myMeFcv3.setVisibility(View.VISIBLE);//显示我的界面
            //我的界面
            viewBinding.myPowerStationBottomIl0.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.home_page_unselected));
            viewBinding.myPowerStationBottomIl0.titleTv.setTextColor(getColor(R.color.text_65000000));
            viewBinding.myPowerStationBottomIl1.iconIv.setImageDrawable(AppCompatResources.getDrawable(_mActivity, R.drawable.power_station_unselected));
@@ -433,6 +512,13 @@
                        }
                    } else if (linkResponse.getTopic().endsWith("custom/wifi/notify")) {
                        //逆变器连接路由状态通知
                        HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean();
                        uniCallBackBaseBean.setType(linkResponse.getTopic());
                        uniCallBackBaseBean.setData(linkResponse.getData());
                        HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, uniCallBackBaseBean);
                        HdlLogLogic.print(linkResponse.getTopic() + new Gson().toJson(linkResponse.getData()), true);
                    }
                }
            }
@@ -649,4 +735,5 @@
        }
    }
}
app/src/main/java/com/hdl/photovoltaic/ui/StartActivity.java
@@ -17,6 +17,8 @@
import java.util.List;
/**
 * App启动页(目的是为了让用户点击APP图标的时候有一个瞬间响应的交互体验。)
 */
@@ -74,6 +76,8 @@
            intent.setClass(this, LoginActivity.class);
            openActivity(intent);
        }
    }
    @Override
@@ -92,4 +96,7 @@
        super.onDestroy();
        overridePendingTransition(0, 0);
    }
}
app/src/main/java/com/hdl/photovoltaic/ui/home/AutoSizeMyAAChart.java
New file
@@ -0,0 +1,32 @@
package com.hdl.photovoltaic.ui.home;
import android.app.Activity;
import android.content.Context;
import android.util.AttributeSet;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartView;
import me.jessyan.autosize.AutoSize;
public class AutoSizeMyAAChart extends AAChartView {
    public AutoSizeMyAAChart(Context context) {
        super(context);
    }
    public AutoSizeMyAAChart(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
    public AutoSizeMyAAChart(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }
    @Override
    public void setOverScrollMode(int mode) {
        super.setOverScrollMode(mode);
        //图表屏幕适配
        AutoSize.autoConvertDensityOfGlobal((Activity) getContext());
    }
}
app/src/main/java/com/hdl/photovoltaic/ui/home/HomePageFragment.java
@@ -1,7 +1,7 @@
package com.hdl.photovoltaic.ui.home;
import static com.hdl.photovoltaic.ui.powerstation.aachart.CustomStyleChartComposer.configureColorfulColumnChart;
import static com.hdl.photovoltaic.ui.home.aachart.CustomStyleChartComposer.configureColorfulColumnChart;
import android.os.Bundle;
import android.text.TextUtils;
@@ -33,7 +33,7 @@
import com.hdl.photovoltaic.ui.bean.DataOverBean;
import com.hdl.photovoltaic.ui.bean.SocialContributionBean;
import com.hdl.photovoltaic.ui.bean.StatisticsBean;
import com.hdl.photovoltaic.ui.powerstation.aachart.BasicChartComposer;
import com.hdl.photovoltaic.ui.home.aachart.BasicChartComposer;
import com.hdl.photovoltaic.utils.TimeUtils;
import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus;
@@ -54,7 +54,7 @@
    FragmentHomePageBinding viewBinding;
    AAChartView aaChartView;
    AutoSizeMyAAChart aaChartView;
    AAChartModel aaChartModel;
@@ -74,14 +74,15 @@
    @Override
    public void onBindView(Bundle savedInstanceState) {
        //初始化
        initView();
        //初始化界面监听器
        initEvent();
        //读取数据
        readDate();
    }
    /**
     * 读取数据
@@ -275,6 +276,8 @@
                readDate();
            }
        });
    }
    /**
@@ -338,7 +341,7 @@
     * 图表加载
     */
    private void setUpAAChartView() {
        aaChartView = viewBinding.AAChartView;
        aaChartView = viewBinding.autoSizeMyAAChart;
        aaChartView.callBack = this;
        if (TimeType.day.equals(timeType)) {
            aaChartModel = BasicChartComposer.configureAreaChart("Pv发电功率", fieldNames, fieldValues);
@@ -348,6 +351,7 @@
            aaChartModel = configureColorfulColumnChart("Pv发电功率", fieldNames, fieldValues);
        }
        aaChartView.aa_drawChartWithChartModel(aaChartModel);
    }
    private void initView() {
app/src/main/java/com/hdl/photovoltaic/ui/home/aachart/AAChartSymbolConst.java
File was renamed from app/src/main/java/com/hdl/photovoltaic/ui/powerstation/aachart/AAChartSymbolConst.java
@@ -1,4 +1,4 @@
package com.hdl.photovoltaic.ui.powerstation.aachart;
package com.hdl.photovoltaic.ui.home.aachart;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartSymbolType;
app/src/main/java/com/hdl/photovoltaic/ui/home/aachart/BasicChartComposer.java
File was renamed from app/src/main/java/com/hdl/photovoltaic/ui/powerstation/aachart/BasicChartComposer.java
@@ -1,4 +1,4 @@
package com.hdl.photovoltaic.ui.powerstation.aachart;
package com.hdl.photovoltaic.ui.home.aachart;
import static com.github.AAChartModel.AAChartCore.AATools.AAColor.AARgba;
@@ -8,6 +8,7 @@
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartSymbolStyleType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartSymbolType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType;
import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartZoomType;
import com.github.AAChartModel.AAChartCore.AAOptionsModel.AAStyle;
import com.github.AAChartModel.AAChartCore.AATools.AAColor;
import com.github.AAChartModel.AAChartCore.AATools.AAGradientColor;
@@ -94,6 +95,7 @@
//                .markerSymbolStyle(AAChartSymbolStyleType.Normal)
                .chartType(AAChartType.Area)
                .categories(categories)
//                .zoomType(AAChartZoomType.None)//手势缩放
//                .yAxisMax(500)
                .yAxisMin(0)
                .series(new AASeriesElement[]{element1});
app/src/main/java/com/hdl/photovoltaic/ui/home/aachart/CustomStyleChartComposer.java
File was renamed from app/src/main/java/com/hdl/photovoltaic/ui/powerstation/aachart/CustomStyleChartComposer.java
@@ -1,10 +1,6 @@
package com.hdl.photovoltaic.ui.powerstation.aachart;
package com.hdl.photovoltaic.ui.home.aachart;
import static com.github.AAChartModel.AAChartCore.AATools.AAColor.AARgba;
import static com.hdl.photovoltaic.ui.powerstation.aachart.AAChartSymbolConst.base64Symbol;
import static com.hdl.photovoltaic.ui.powerstation.aachart.AAChartSymbolConst.imageSymbol;
import static com.hdl.photovoltaic.ui.powerstation.aachart.AAChartSymbolConst.predefinedSymbol1;
import static com.hdl.photovoltaic.ui.powerstation.aachart.AAChartSymbolConst.predefinedSymbol2;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartModel;
import com.github.AAChartModel.AAChartCore.AAChartCreator.AASeriesElement;
@@ -444,25 +440,25 @@
                .name("Predefined symbol")
                .data(new Object[]{0.45, 0.43, 0.50, 0.55, 0.58, 0.62, 0.83, 0.39, 0.56, 0.67, 0.50, 0.34, 0.50, 0.67, 0.58, 0.29, 0.46, 0.23, 0.47, 0.46, 0.38, 0.56, 0.48, 0.36})
                .marker(new AAMarker()
                        .symbol(predefinedSymbol1));
                        .symbol(AAChartSymbolConst.predefinedSymbol1));
        AASeriesElement element2 = new AASeriesElement()
                .name("Image symbol")
                .data(new Object[]{0.38, 0.31, 0.32, 0.32, 0.64, 0.66, 0.86, 0.47, 0.52, 0.75, 0.52, 0.56, 0.54, 0.60, 0.46, 0.63, 0.54, 0.51, 0.58, 0.64, 0.60, 0.45, 0.36, 0.67})
                .marker(new AAMarker()
                        .symbol(imageSymbol));
                        .symbol(AAChartSymbolConst.imageSymbol));
        AASeriesElement element3 = new AASeriesElement()
                .name("Base64 symbol (*)")
                .data(new Object[]{0.46, 0.32, 0.53, 0.58, 0.86, 0.68, 0.85, 0.73, 0.69, 0.71, 0.91, 0.74, 0.60, 0.50, 0.39, 0.67, 0.55, 0.49, 0.65, 0.45, 0.64, 0.47, 0.63, 0.64})
                .marker(new AAMarker()
                        .symbol(base64Symbol));
                        .symbol(AAChartSymbolConst.base64Symbol));
        AASeriesElement element4 = new AASeriesElement()
                .name("Custom symbol")
                .data(new Object[]{0.60, 0.51, 0.52, 0.53, 0.64, 0.84, 0.65, 0.68, 0.63, 0.47, 0.72, 0.60, 0.65, 0.74, 0.66, 0.65, 0.71, 0.59, 0.65, 0.77, 0.52, 0.53, 0.58, 0.53})
                .marker(new AAMarker()
                        .symbol(predefinedSymbol2));
                        .symbol(AAChartSymbolConst.predefinedSymbol2));
        return new AAChartModel()
                .chartType(AAChartType.Scatter)
app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMP.java
@@ -95,12 +95,18 @@
    public final static String UNI_EVENT_REPLY_MINE_SETTING = "setting";//设置
    /*********Wifi模块*********/ //卫锦定义
    /*********Wifi模块*********/
    public final static String UNI_EVENT_REPLY_WIFI_MODEL = "uni_wifi_model";//wifi模块(大类)
    public final static String UNI_EVENT_REPLY_WIFI_LIST = "list";//获取wifi列表
    public final static String UNI_EVENT_REPLY_WIFI_PHONE_INFO = "wifi_phone_info";//获取当前wifi信息
    public final static String UNI_EVENT_REPLY_WIFI_SET_DEVICE = "wifi_set_device";//设置wifi给设备
    public final static String UNI_EVENT_REPLY_OPEN_WIFI_SETTINGS = "open_wifi_settings";//调用打开手机Wifi设置界面
    public final static String UNI_EVENT_REPLY_PHONE_WIFI_LIST = "phone_wifi_list";//手机获取wifi列表
    public final static String UNI_EVENT_REPLY_PHONE_WIFI_INFO = "phone_wifi_info";//手机获取当前wifi信息
    public final static String UNI_EVENT_REPLY_PHONE_OPEN_WIFI_SETTINGS = "phone_open_wifi_settings";//调用打开手机Wifi设置界面
    public final static String UNI_EVENT_REPLY_DEVICE_WIFI_SET = "device_wifi_set";//逆变器WiFi信息配置
    public final static String UNI_EVENT_REPLY_DEVICE_WIFI_GET = "device_wifi_get";//逆变器WiFi信息获取
    public final static String UNI_EVENT_REPLY_DEVICE_HOTSPOT_SET = "device_hotspot_set";//逆变器热点配置
    public final static String UNI_EVENT_REPLY_DEVICE_HOTSPOT_GET = "device_hotspot_get";//逆变器热点获取
    public final static String UNI_EVENT_REPLY_DEVICE_ETHERNET_SET = "device_ethernet_set";//逆变器以太网配置
    public final static String UNI_EVENT_REPLY_DEVICE_ETHERNET_GET = "device_ethernet_get";//逆变器以太网获取
    //endregion
    //region --------【原生】主动发送到【小程序】--------
@@ -114,6 +120,7 @@
    public final static String UNI_EVENT_NOTIFICATION_DEVICE_ADD = "add";//设备添加
    public final static String UNI_EVENT_NOTIFICATION_DEVICE_DEL = "del";//设备删除
    public final static String UNI_EVENT_NOTIFICATION_DEVICE_OID = "oid";//设备【包括下挂设备】oid列表Remove interface
    public final static String UNI_EVENT_NOTIFICATION_DEVICE_CONNECTION_STATUS = "connection_status";//逆变器连接路由器状态
    //endregion
    //region --------【原生】打开【小程序】--------
app/src/main/res/layout/activity_my_power_station.xml
@@ -7,51 +7,16 @@
    android:background="@drawable/bj"
    tools:context="com.hdl.photovoltaic.ui.BPowerStationActivity">
    <!--首页-Fragment-->
    <!--(首页-电站-消息-我的)-Fragment-->
    <androidx.fragment.app.FragmentContainerView
        android:id="@+id/module_fcv"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toTopOf="@+id/my_power_station_bottom_ll"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
        android:id="@+id/my_home_page_fcv0"
        android:name="com.hdl.photovoltaic.ui.home.HomePageFragment"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:visibility="gone"
        app:layout_constraintBottom_toTopOf="@+id/my_power_station_bottom_ll"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
    <!--电站-Fragment-->
    <androidx.fragment.app.FragmentContainerView
        android:id="@+id/my_power_station_fcv1"
        android:name="com.hdl.photovoltaic.ui.powerstation.HouseListFragment"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:visibility="gone"
        app:layout_constraintBottom_toTopOf="@+id/my_power_station_bottom_ll"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
    <!--报警-Fragment-->
    <androidx.fragment.app.FragmentContainerView
        android:id="@+id/my_message_fcv2"
        android:name="com.hdl.photovoltaic.ui.message.MessageFragment"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:visibility="gone"
        app:layout_constraintBottom_toTopOf="@+id/my_power_station_bottom_ll"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
    <!--我的-Fragment-->
    <androidx.fragment.app.FragmentContainerView
        android:id="@+id/my_me_fcv3"
        android:name="com.hdl.photovoltaic.ui.me.MeFragment"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:visibility="gone"
        app:layout_constraintBottom_toTopOf="@+id/my_power_station_bottom_ll"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
    <LinearLayout
        android:id="@+id/my_power_station_bottom_ll"
app/src/main/res/layout/fragment_home_page.xml
@@ -29,7 +29,7 @@
    <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
        android:id="@+id/srl"
        android:layout_width="0dp"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_marginTop="@dimen/dp_26"
        app:layout_constraintBottom_toBottomOf="parent"
@@ -39,13 +39,9 @@
        <ScrollView
            android:id="@+id/sl"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_marginTop="@dimen/dp_26"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/home_page_title_tv">
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginTop="@dimen/dp_26">
            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="match_parent"
@@ -349,7 +345,7 @@
                    </RelativeLayout>
                </androidx.constraintlayout.widget.ConstraintLayout>
                <!--日期-->
                <androidx.constraintlayout.widget.ConstraintLayout
                    android:id="@+id/home_page_station_data_cl"
                    android:layout_width="match_parent"
@@ -547,14 +543,21 @@
                    </RelativeLayout>
                    <com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartView
                        android:id="@+id/AAChartView"
                    <FrameLayout
                        android:layout_width="0dp"
                        android:layout_height="284dp"
                        android:layout_marginTop="@dimen/dp_18"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toBottomOf="@+id/chart_title_rl" />
                        app:layout_constraintTop_toBottomOf="@+id/chart_title_rl">
                        <com.hdl.photovoltaic.ui.home.AutoSizeMyAAChart
                            android:id="@+id/autoSizeMyAAChart"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            />
                    </FrameLayout>
                </androidx.constraintlayout.widget.ConstraintLayout>
                <androidx.constraintlayout.widget.ConstraintLayout