Bladeren bron

增加日志显示,增加服务器IP地址显示

weizhengliang 3 jaren geleden
bovenliggende
commit
5d38434cdc

+ 5 - 1
callingbed/src/main/java/com/wdkl/app/ncs/callingbed/activity/CallingbedActivity.kt

@@ -293,22 +293,26 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
                     .get()
                     .build()
 
+                Log.d(TAG, "start checkServer: $url:$port")
                 try {
                     val response = okHttpClient.newCall(request).execute()
                     if (response != null && response.isSuccessful) {
+                        Log.d(TAG, "checkServer response success")
                         //接口数据获取成功
                         serverSuccess = true
                         presenter.loadServerInfo()
                     } else {
+                        Log.e(TAG, "checkServer response fail")
                         //接口数据获取失败,可能服务器ip不对,尝试重新获取服务器ip
                         val info = ServerInfoUtil.get(Constant.LOCAL_MAC)
                         checkServerInfo(info)
                     }
                 } catch (e: Exception) {
+                    Log.e(TAG, "checkServer exception: ")
+                    e.printStackTrace()
                     //接口数据获取失败,可能服务器ip不对,尝试重新获取服务器ip
                     val info = ServerInfoUtil.get(Constant.LOCAL_MAC)
                     checkServerInfo(info)
-                    //e.printStackTrace()
                 }
 
                 try {

+ 1 - 4
callingbed/src/main/java/com/wdkl/app/ncs/callingbed/fragment/QrCodeFragment.kt

@@ -77,10 +77,7 @@ class QrCodeFragment : BaseFragment<QrCodeFragmentPresenter, QrcodeViewBinding>(
             tv_device_id.text = "Device ID: " + Constant.DEVICE_ID
         }
 
-        var serverIp = ""
-        if (UrlManager.build().base.length > 14) {
-            serverIp = UrlManager.build().base.substring(7, 14)
-        }
+        val serverIp =  UrlManager.build().base.substringAfterLast("//").substringBefore(":")
         tv_local_ip.text = "IP: " + ipAddr + " - " + serverIp
         tv_local_mac.text = "MAC: " + macAddr
         tv_app_version.text = "Version: V" + BuildConfig.VERSION_NAME + "_" + BuildConfig.VERSION_CODE

+ 5 - 5
callingbed/src/main/res/layout/qrcode_view.xml

@@ -27,7 +27,7 @@
                 android:id="@+id/tv_device_id"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:layout_marginLeft="40dp"
+                android:layout_marginLeft="10dp"
                 android:text="ID:"
                 android:textColor="@color/black"
                 android:textSize="20sp" />
@@ -37,7 +37,7 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_marginTop="4dp"
-                android:layout_marginLeft="40dp"
+                android:layout_marginLeft="10dp"
                 android:text="IP:"
                 android:textColor="@color/black"
                 android:textSize="20sp" />
@@ -47,7 +47,7 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_marginTop="4dp"
-                android:layout_marginLeft="40dp"
+                android:layout_marginLeft="10dp"
                 android:text="MAC:"
                 android:textColor="@color/black"
                 android:textSize="20sp" />
@@ -57,7 +57,7 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_marginTop="4dp"
-                android:layout_marginLeft="40dp"
+                android:layout_marginLeft="10dp"
                 android:text="Version:"
                 android:textColor="@color/black"
                 android:textSize="20sp" />
@@ -67,7 +67,7 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_marginTop="4dp"
-                android:layout_marginLeft="40dp"
+                android:layout_marginLeft="10dp"
                 android:text="MCU:"
                 android:textColor="@color/black"
                 android:textSize="20sp" />