修复问题
This commit is contained in:
parent
4f90e270fd
commit
225a966f88
|
|
@ -1 +1,5 @@
|
|||
/build
|
||||
/build
|
||||
/release/baselineProfiles/0/app-release.dm
|
||||
/release/baselineProfiles/1/app-release.dm
|
||||
/release/app-release-V1.0.3.apk
|
||||
/release/output-metadata.json
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ android {
|
|||
applicationId = "com.stand.standapp"
|
||||
minSdk = 24
|
||||
targetSdk = 34
|
||||
versionCode = 3
|
||||
versionName = "1.0.2"
|
||||
versionCode = 5
|
||||
versionName = "1.0.4"
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ class AndroidInterface(private val activity: MainActivity) {
|
|||
fun onPageFinished() {
|
||||
Handler(Looper.getMainLooper()).post {
|
||||
try {
|
||||
activity.cancelTimeoutTimer()
|
||||
// activity.cancelTimeoutTimer()
|
||||
activity.findViewById<android.view.View>(R.id.loading_layout)?.visibility = android.view.View.GONE
|
||||
} catch (e: Exception) {
|
||||
Log.e("UI", "隐藏加载布局失败", e)
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@ import com.stand.standapp.R
|
|||
class MainActivity : AppCompatActivity() {
|
||||
|
||||
private var mAgentWeb: AgentWeb? = null
|
||||
private val mHandler = android.os.Handler(android.os.Looper.getMainLooper())
|
||||
private val TIMEOUT_MS = 30000L
|
||||
|
||||
private val timeoutRunnable = Runnable {
|
||||
showErrorPage()
|
||||
}
|
||||
// private val mHandler = android.os.Handler(android.os.Looper.getMainLooper())
|
||||
// private val TIMEOUT_MS = 30000L
|
||||
//
|
||||
// private val timeoutRunnable = Runnable {
|
||||
// showErrorPage()
|
||||
// }
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
|
@ -29,15 +29,16 @@ class MainActivity : AppCompatActivity() {
|
|||
val container = findViewById<LinearLayout>(R.id.container)
|
||||
if (container == null) return
|
||||
|
||||
findViewById<android.widget.Button>(R.id.btn_retry)?.setOnClickListener {
|
||||
hideErrorPage()
|
||||
mAgentWeb?.webCreator?.webView?.reload()
|
||||
startTimeoutTimer()
|
||||
}
|
||||
// findViewById<android.widget.Button>(R.id.btn_retry)?.setOnClickListener {
|
||||
// hideErrorPage()
|
||||
// mAgentWeb?.webCreator?.webView?.reload()
|
||||
// startTimeoutTimer()
|
||||
// }
|
||||
|
||||
// 从配置中获取服务器地址
|
||||
val serverUrl = AppConfig.getServerUrl(this)
|
||||
val finalUrl = "$serverUrl/example/print_demo.html?t=${System.currentTimeMillis()}"
|
||||
val finalUrl = "$serverUrl/example/print_demo.html?t=\${System.currentTimeMillis()}"
|
||||
// val finalUrl = "$serverUrl/example/print_demo.html?t=${System.currentTimeMillis()}"
|
||||
Log.d("MainActivity", "Loading URL: $finalUrl")
|
||||
|
||||
mAgentWeb = AgentWeb.with(this)
|
||||
|
|
@ -48,7 +49,7 @@ class MainActivity : AppCompatActivity() {
|
|||
.ready()
|
||||
.go(finalUrl)
|
||||
|
||||
startTimeoutTimer()
|
||||
// startTimeoutTimer()
|
||||
|
||||
// 配置 WebView 属性以支持 SSE 和跨域
|
||||
|
||||
|
|
@ -119,26 +120,26 @@ class MainActivity : AppCompatActivity() {
|
|||
|
||||
override fun onDestroy() {
|
||||
mAgentWeb?.webLifeCycle?.onDestroy()
|
||||
cancelTimeoutTimer()
|
||||
// cancelTimeoutTimer()
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
private fun startTimeoutTimer() {
|
||||
cancelTimeoutTimer()
|
||||
mHandler.postDelayed(timeoutRunnable, TIMEOUT_MS)
|
||||
}
|
||||
|
||||
fun cancelTimeoutTimer() {
|
||||
mHandler.removeCallbacks(timeoutRunnable)
|
||||
}
|
||||
|
||||
private fun showErrorPage() {
|
||||
findViewById<android.view.View>(R.id.loading_layout)?.visibility = android.view.View.GONE
|
||||
findViewById<android.view.View>(R.id.error_layout)?.visibility = android.view.View.VISIBLE
|
||||
}
|
||||
|
||||
private fun hideErrorPage() {
|
||||
findViewById<android.view.View>(R.id.error_layout)?.visibility = android.view.View.GONE
|
||||
findViewById<android.view.View>(R.id.loading_layout)?.visibility = android.view.View.VISIBLE
|
||||
}
|
||||
// private fun startTimeoutTimer() {
|
||||
// cancelTimeoutTimer()
|
||||
// mHandler.postDelayed(timeoutRunnable, TIMEOUT_MS)
|
||||
// }
|
||||
//
|
||||
// fun cancelTimeoutTimer() {
|
||||
// mHandler.removeCallbacks(timeoutRunnable)
|
||||
// }
|
||||
//
|
||||
// private fun showErrorPage() {
|
||||
// findViewById<android.view.View>(R.id.loading_layout)?.visibility = android.view.View.GONE
|
||||
// findViewById<android.view.View>(R.id.error_layout)?.visibility = android.view.View.VISIBLE
|
||||
// }
|
||||
//
|
||||
// private fun hideErrorPage() {
|
||||
// findViewById<android.view.View>(R.id.error_layout)?.visibility = android.view.View.GONE
|
||||
// findViewById<android.view.View>(R.id.loading_layout)?.visibility = android.view.View.VISIBLE
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/bg_login"
|
||||
|
|
@ -22,7 +23,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="50dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
|
@ -41,26 +42,36 @@
|
|||
android:textStyle="bold" />
|
||||
</LinearLayout>
|
||||
|
||||
<!-- 中间登录框 -->
|
||||
<LinearLayout
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:background="@drawable/shape_login_box"
|
||||
android:elevation="8dp"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical"
|
||||
android:padding="30dp">
|
||||
android:layout_centerInParent="true">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="25dp"
|
||||
android:text="用户登录"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="20sp" />
|
||||
android:background="@drawable/shape_login_box"
|
||||
android:elevation="8dp"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical"
|
||||
android:padding="30dp"
|
||||
app:layout_constraintWidth_max="450dp"
|
||||
app:layout_constraintWidth_default="percent"
|
||||
app:layout_constraintWidth_percent="0.85"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent">
|
||||
|
||||
<TextView
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="25dp"
|
||||
android:text="用户登录"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="15dp"
|
||||
|
|
@ -127,7 +138,8 @@
|
|||
android:textColor="#FFFFFF"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<!-- 底部版权 -->
|
||||
<TextView
|
||||
|
|
|
|||
|
|
@ -1,89 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" />
|
||||
|
||||
<!-- 加载等待页 -->
|
||||
<LinearLayout
|
||||
android:id="@+id/loading_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#FFFFFF"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:visibility="visible">
|
||||
|
||||
<ProgressBar
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:indeterminateTint="#004A8F" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:text="消防值守台系统加载中..."
|
||||
android:textColor="#333333"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="正在初始化智能调度引擎..."
|
||||
android:textColor="#999999"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<!-- 异常提示页 (超时或网络错误) -->
|
||||
<LinearLayout
|
||||
android:id="@+id/error_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#F8F9FA"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
android:src="@android:drawable/stat_notify_error"
|
||||
android:tint="#D62828" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:text="系统响应超时"
|
||||
android:textColor="#333333"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="280dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:gravity="center"
|
||||
android:text="检测到网络环境不稳定或服务器未响应,请检查网络连接后重试。"
|
||||
android:textColor="#666666"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_retry"
|
||||
android:layout_width="160dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginTop="30dp"
|
||||
android:backgroundTint="#004A8F"
|
||||
android:text="重新加载"
|
||||
android:textColor="#FFFFFF" />
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,89 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" />
|
||||
|
||||
<!-- 加载等待页 -->
|
||||
<LinearLayout
|
||||
android:id="@+id/loading_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#FFFFFF"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:visibility="visible">
|
||||
|
||||
<ProgressBar
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:indeterminateTint="#004A8F" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:text="消防值守台系统加载中..."
|
||||
android:textColor="#333333"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="正在初始化智能调度引擎..."
|
||||
android:textColor="#999999"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<!-- 异常提示页 (超时或网络错误) -->
|
||||
<LinearLayout
|
||||
android:id="@+id/error_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#F8F9FA"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
android:src="@android:drawable/stat_notify_error"
|
||||
android:tint="#D62828" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:text="系统响应超时"
|
||||
android:textColor="#333333"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="280dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:gravity="center"
|
||||
android:text="检测到网络环境不稳定或服务器未响应,请检查网络连接后重试。"
|
||||
android:textColor="#666666"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_retry"
|
||||
android:layout_width="160dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginTop="30dp"
|
||||
android:backgroundTint="#004A8F"
|
||||
android:text="重新加载"
|
||||
android:textColor="#FFFFFF" />
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
||||
Loading…
Reference in New Issue