HDLLinkLocalSdk/src/main/java/com/hdl/sdk/link/socket/TcpSocketBoot.java
@@ -30,17 +30,19 @@ private final IClient client; private IHeartbeat iHeartbeat; public void SetHeartbeat(IHeartbeat iHeartbeat){ this.iHeartbeat=iHeartbeat; public void SetHeartbeat(IHeartbeat iHeartbeat) { this.iHeartbeat = iHeartbeat; } /** * 当前接收到数据的时间 */ private long time=System.currentTimeMillis(); private long time = System.currentTimeMillis(); /** * tcp是否已经连接 */ private boolean connected=false; private boolean connected = false; public IClient getClient() { return client; @@ -54,7 +56,7 @@ private final ArrayMap<String, SendListener> sendMap = new ArrayMap<>(); public TcpSocketBoot(IClient client) { public TcpSocketBoot(IClient client) { TCP_SOCKET_BOOT_LIST.add(this); this.client = client; initConnectThread(); @@ -66,25 +68,25 @@ /** * 记录所有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 */ public static TcpSocketBoot getByEndPoint(String ipAddress, int port){ if(ipAddress==null){ return null; public static TcpSocketBoot getByEndPoint(String ipAddress, int port) { if (ipAddress == null) { return null; } for(TcpSocketBoot tcpSocketBoot : TCP_SOCKET_BOOT_LIST){ if(ipAddress.equals(tcpSocketBoot.getClient().getOptions().getIp())&& tcpSocketBoot.getClient().getOptions().getPort()==port) { for (TcpSocketBoot tcpSocketBoot : TCP_SOCKET_BOOT_LIST) { if (ipAddress.equals(tcpSocketBoot.getClient().getOptions().getIp()) && tcpSocketBoot.getClient().getOptions().getPort() == port) { return tcpSocketBoot; } } return null; return null; } /** @@ -92,14 +94,14 @@ */ private synchronized void connect() { try { LogUtils.i("TCP连接:"+this.getClient().getOptions().getIp()); LogUtils.i("TCP连接:" + this.getClient().getOptions().getIp()); client.onConnectStatus(ConnectStatus.CONNECTING); // Thread.sleep(700); client.connect(); LogUtils.i("TCP连接成功:"+this.getClient().getOptions().getIp()); connected=true; LogUtils.i("TCP连接成功:" + this.getClient().getOptions().getIp()); connected = true; client.onConnectStatus(ConnectStatus.CONNECTED); }catch(Exception e) { } catch (Exception e) { LogUtils.e(e.getMessage()); } } @@ -116,7 +118,7 @@ public void run() { while (true) { try { if(connected==false){ if (!connected) { Thread.sleep(100); continue; } @@ -163,7 +165,7 @@ if (connected) { //读取数据 client.onHandleResponse(); time= System.currentTimeMillis(); time = System.currentTimeMillis(); } else { try { Thread.sleep(1000); @@ -196,7 +198,7 @@ if (!connected) { reconect(); } Thread.sleep(5*1000); Thread.sleep(5 * 1000); } catch (Exception e) { LogUtils.e("定时连接线程异常:" + e.getMessage()); @@ -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(); //初始化界面监听器 @@ -135,9 +136,9 @@ * 初始化 */ private void initView() { viewBinding.toolbarTopFragmentHouseListRl.topBarView.setBackgroundColor(getResources().getColor(R.color.text_FFFFFFFF,null)); viewBinding.toolbarTopFragmentHouseListRl.topBarView.setBackgroundColor(getResources().getColor(R.color.text_FFFFFFFF, null)); viewBinding.toolbarTopFragmentHouseListRl.topTitleTv.setText(R.string.home_login_change_password); viewBinding.toolbarTopFragmentHouseListRl.topTitleTv.setTextColor(getResources().getColor(R.color.text_030D1C,null)); viewBinding.toolbarTopFragmentHouseListRl.topTitleTv.setTextColor(getResources().getColor(R.color.text_030D1C, null)); viewBinding.toolbarTopFragmentHouseListRl.topBackBtn.setVisibility(View.VISIBLE); viewBinding.meChangePasswordOldIc.mePswTitleTv.setText(R.string.home_login_old_pws); viewBinding.meChangePasswordOldIc.mePswEt.setHint(R.string.home_login_input_old_pws); 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>