HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/TcpSocketBoot.java
@@ -30,9 +30,11 @@ private final IClient client; private IHeartbeat iHeartbeat; public void SetHeartbeat(IHeartbeat iHeartbeat){ this.iHeartbeat=iHeartbeat; } /** * 当前接收到数据的时间 */ @@ -66,10 +68,11 @@ /** * 记录所有SocketBoot */ final static List<TcpSocketBoot> TCP_SOCKET_BOOT_LIST = new ArrayList(); final static List<TcpSocketBoot> TCP_SOCKET_BOOT_LIST = new ArrayList<>(); /** * 根据IP地址及端口获取当前socketBoot * * @param ipAddress * @param port * @return @@ -79,8 +82,7 @@ return null; } for(TcpSocketBoot tcpSocketBoot : TCP_SOCKET_BOOT_LIST){ if(ipAddress.equals(tcpSocketBoot.getClient().getOptions().getIp())&& tcpSocketBoot.getClient().getOptions().getPort()==port) { if (ipAddress.equals(tcpSocketBoot.getClient().getOptions().getIp()) && tcpSocketBoot.getClient().getOptions().getPort() == port) { return tcpSocketBoot; } } @@ -116,7 +118,7 @@ public void run() { while (true) { try { if(connected==false){ if (!connected) { Thread.sleep(100); continue; } @@ -234,6 +236,7 @@ }); } } /** * 重新连接 */ @@ -244,6 +247,7 @@ /** * 发送无需回调 * * @param msg 发送的数据 */ public void sendMsg(byte[] msg) { @@ -278,4 +282,31 @@ } } // /** // * 断开全部的Link网关连接 // */ // public static void stopAllConnectLinkGateway() { // for (TcpSocketBoot data : TCP_SOCKET_BOOT_LIST) { // //断开指定的link网关连接 // stopConnectLinkGateway(data); // } // // } // // /** // * 断开指定的link网关连接 // * // * @param tcpSocketBoot tcp对象 // */ // public static void stopConnectLinkGateway(TcpSocketBoot tcpSocketBoot) { // synchronized (TCP_SOCKET_BOOT_LIST) { // try { // TCP_SOCKET_BOOT_LIST.remove(tcpSocketBoot); // tcpSocketBoot.client.disconnect(); // } catch (Exception ignored) { // } // } // } } HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/interceptor/HDLEncryptInterceptor.java
@@ -19,6 +19,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -116,7 +117,7 @@ if (body != null) { Buffer buffer = new Buffer(); body.writeTo(buffer); Charset charset = Charset.forName("UTF-8"); Charset charset = StandardCharsets.UTF_8; MediaType contentType = body.contentType(); charset = contentType.charset(charset); return buffer.readString(charset); HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/interceptor/HDLLoginInterceptor.java
@@ -60,7 +60,7 @@ // source2.request(Long.MAX_VALUE); // Buffer buffer2 = source2.getBuffer().clone(); // String respString2 = buffer2.readString(Charset.defaultCharset()); //http标准状态码 if (401 == response.code() || 402 == response.code() || 403 == response.code()) { final String token = refreshToken(); if (!TextUtils.isEmpty(token)) { app/build.gradle
@@ -8,6 +8,20 @@ ] android { signingConfigs { debug { storeFile file('../keystore/Untitled') keyAlias 'hdlphotovotaic' storePassword '85521566' keyPassword '85521566' } release { storeFile file('../keystore/Untitled') keyAlias 'photovoltaic' storePassword '85521566' keyPassword '85521566' } } compileSdk 30 defaultConfig { @@ -41,6 +55,10 @@ release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' signingConfig signingConfigs.release } debug { signingConfig signingConfigs.debug } } app/release/output-metadata.json
File was deleted app/src/main/java/com/hdl/photovoltaic/HDLApp.java
@@ -29,6 +29,7 @@ import com.hdl.sdk.link.core.connect.HDLUdpConnect; import com.hdl.sdk.link.core.utils.QueueUtils; import com.hdl.sdk.link.core.utils.mqtt.MqttRecvClient; import com.hdl.sdk.link.socket.TcpSocketBoot; import java.util.HashMap; import java.util.Locale; @@ -59,6 +60,7 @@ public void onCreate() { super.onCreate(); mHDLApp = this; initThirdSDK(); } @@ -149,6 +151,14 @@ //设定一个时间 UserConfigManage.getInstance().setLoginDateTime(0); UserConfigManage.getInstance().Save(); //断开mqtt连接 if (MqttRecvClient.getInstance() != null) { MqttRecvClient.getInstance().stop(); } //断开所有tcp连接且清空连接缓存 // TODO: 10/10/23 // TcpSocketBoot.stopAllConnectLinkGateway(); // if(null!=HDLUniMPSDKManager.getInstance().getUniMP()){ // LogUtils.d("asdfasdfasdfsdf我被删除啦"); // HDLUniMPSDKManager.getInstance().getUniMP().closeUniMP(); @@ -160,11 +170,7 @@ intent.putExtra("isJpush", true); } startActivity(intent); if (MqttRecvClient.getInstance() != null) { MqttRecvClient.getInstance().stop(); } //要清空之前tcp连接缓存 // TODO: 10/10/23 } }); app/src/main/java/com/hdl/photovoltaic/base/BaseActivity.java
@@ -28,6 +28,7 @@ @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); _mActivity = this; Object content = getContentView(); //添加Activity到堆栈 app/src/main/java/com/hdl/photovoltaic/base/CustomBaseActivity.java
@@ -1,9 +1,37 @@ package com.hdl.photovoltaic.base; import android.os.Bundle; import androidx.annotation.Nullable; import com.hdl.photovoltaic.R; /** * 自定义方法,用于实现个性化 */ public abstract class CustomBaseActivity extends BaseActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setNotificationBarBackgroundColor(0); } /** * 设置通知栏背景颜色 * * @param color 颜色值(0=蓝色;1=白色;) */ public void setNotificationBarBackgroundColor(int color) { if (color == 0) { color = R.color.text_245EC3; } else if (color == 1) { if (color == 1) { color = R.color.text_FFFFFFFF; } } getWindow().setStatusBarColor(getColor(color)); } } app/src/main/java/com/hdl/photovoltaic/config/UserConfigManage.java
@@ -4,10 +4,12 @@ import android.text.TextUtils; import com.google.gson.Gson; import com.hdl.photovoltaic.HDLApp; import com.hdl.photovoltaic.other.HdlFileLogic; import com.hdl.photovoltaic.other.HdlLogLogic; import com.hdl.photovoltaic.other.HdlResidenceLogic; import com.hdl.photovoltaic.ui.bean.HouseInfoBean; import com.hdl.photovoltaic.utils.SharedPreUtils; import java.util.ArrayList; import java.util.List; @@ -224,6 +226,7 @@ */ private void reFresh() { String str = HdlFileLogic.getInstance().readFile(FILENAME); // String str =SharedPreUtils.getSharedPreferencesKey("UserConfigManage.json",HDLApp.getInstance()); if (!TextUtils.isEmpty(str) && str.length() > 0) { //读取保存的数据 Gson gson = new Gson(); @@ -233,6 +236,7 @@ } } } /** * 保存 @@ -245,8 +249,10 @@ Gson gson = new Gson(); String json = gson.toJson(sUserConfigManage); HdlFileLogic.getInstance().writeFile(FILENAME, json); // SharedPreUtils.saveMyDataInfo("UserConfigManage.json", json, HDLApp.getInstance()); } /// <summary> /// Config文件名 /// </summary> app/src/main/java/com/hdl/photovoltaic/ui/MyPowerStationActivity.java
@@ -57,7 +57,7 @@ @Override public void onBindView(Bundle savedInstanceState) { getWindow().setStatusBarColor(getColor(R.color.text_245EC3)); //初始化 initView(); //初始化界面监听器 app/src/main/java/com/hdl/photovoltaic/ui/StartActivity.java
@@ -24,7 +24,6 @@ @Override public void onBindView(Bundle savedInstanceState) { if (UserConfigManage.getInstance().isAutoLogin()) { // showLoading(); HdlResidenceLogic.getInstance().getResidenceIdList("", "", new CloudCallBeak<List<HouseIdBean>>() { app/src/main/java/com/hdl/photovoltaic/ui/me/MeChangePasswordActivity.java
@@ -14,7 +14,7 @@ import com.hdl.linkpm.sdk.core.exception.HDLException; import com.hdl.photovoltaic.R; import com.hdl.photovoltaic.base.BaseActivity; import com.hdl.photovoltaic.base.CustomBaseActivity; import com.hdl.photovoltaic.config.UserConfigManage; import com.hdl.photovoltaic.databinding.ActivityMeChangePasswordBinding; import com.hdl.photovoltaic.listener.CloudCallBeak; @@ -24,7 +24,7 @@ /** * 我的-修改密码-界面 */ public class MeChangePasswordActivity extends BaseActivity { public class MeChangePasswordActivity extends CustomBaseActivity { private ActivityMeChangePasswordBinding viewBinding; @@ -36,6 +36,7 @@ @Override public void onBindView(Bundle savedInstanceState) { //初始化 initView(); //初始化界面监听器 app/src/main/java/com/hdl/photovoltaic/ui/me/SetActivity.java
@@ -31,6 +31,7 @@ @Override public void onBindView(Bundle savedInstanceState) { //初始化 initView(); //初始化界面监听器 app/src/main/res/values/attrs.xml
@@ -3,4 +3,5 @@ <attr name="fullscreenBackgroundColor" format="color" /> <attr name="fullscreenTextColor" format="color" /> </declare-styleable> </resources> app/src/main/res/values/strings.xml
@@ -1,5 +1,6 @@ <resources> <string name="app_name">PhotovoltaicDebug</string> <!-- <string name="app_name">PhotovoltaicDebug</string>--> <string name="app_name">智慧能源</string> <string name="title_activity_home_login">HomeLoginActivity</string> <!-- Strings used for fragments for navigation --> <string name="first_fragment_label">First Fragment</string>