添加进度条
This commit is contained in:
@@ -21,6 +21,7 @@ import io.legado.app.help.SourceVerificationHelp
|
|||||||
import io.legado.app.help.config.AppConfig
|
import io.legado.app.help.config.AppConfig
|
||||||
import io.legado.app.help.http.CookieStore
|
import io.legado.app.help.http.CookieStore
|
||||||
import io.legado.app.lib.dialogs.SelectItem
|
import io.legado.app.lib.dialogs.SelectItem
|
||||||
|
import io.legado.app.lib.theme.accentColor
|
||||||
import io.legado.app.model.Download
|
import io.legado.app.model.Download
|
||||||
import io.legado.app.ui.association.OnLineImportActivity
|
import io.legado.app.ui.association.OnLineImportActivity
|
||||||
import io.legado.app.ui.document.HandleFileContract
|
import io.legado.app.ui.document.HandleFileContract
|
||||||
@@ -81,6 +82,7 @@ class WebViewActivity : VMBaseActivity<ActivityWebViewBinding, WebViewModel>() {
|
|||||||
|
|
||||||
@SuppressLint("JavascriptInterface", "SetJavaScriptEnabled")
|
@SuppressLint("JavascriptInterface", "SetJavaScriptEnabled")
|
||||||
private fun initWebView(url: String, headerMap: HashMap<String, String>) {
|
private fun initWebView(url: String, headerMap: HashMap<String, String>) {
|
||||||
|
binding.progressBar.fontColor = accentColor
|
||||||
binding.webView.webChromeClient = CustomWebChromeClient()
|
binding.webView.webChromeClient = CustomWebChromeClient()
|
||||||
binding.webView.webViewClient = CustomWebViewClient()
|
binding.webView.webViewClient = CustomWebViewClient()
|
||||||
binding.webView.settings.apply {
|
binding.webView.settings.apply {
|
||||||
@@ -191,6 +193,12 @@ class WebViewActivity : VMBaseActivity<ActivityWebViewBinding, WebViewModel>() {
|
|||||||
|
|
||||||
inner class CustomWebChromeClient : WebChromeClient() {
|
inner class CustomWebChromeClient : WebChromeClient() {
|
||||||
|
|
||||||
|
override fun onProgressChanged(view: WebView?, newProgress: Int) {
|
||||||
|
super.onProgressChanged(view, newProgress)
|
||||||
|
binding.progressBar.setDurProgress(newProgress)
|
||||||
|
binding.progressBar.gone(newProgress == 100)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onShowCustomView(view: View?, callback: CustomViewCallback?) {
|
override fun onShowCustomView(view: View?, callback: CustomViewCallback?) {
|
||||||
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR
|
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR
|
||||||
binding.llView.invisible()
|
binding.llView.invisible()
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/ll_view"
|
android:id="@+id/ll_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
@@ -15,14 +15,24 @@
|
|||||||
android:id="@+id/title_bar"
|
android:id="@+id/title_bar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:fitStatusBar="false" />
|
app:fitStatusBar="false"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<io.legado.app.ui.rss.read.VisibleWebView
|
<io.legado.app.ui.rss.read.VisibleWebView
|
||||||
android:id="@+id/web_view"
|
android:id="@+id/web_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="0dp"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/title_bar"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent" />
|
||||||
|
|
||||||
</LinearLayout>
|
<io.legado.app.ui.widget.anima.RefreshProgressBar
|
||||||
|
android:id="@+id/progress_bar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
app:max_progress="100"
|
||||||
|
app:layout_constraintTop_toTopOf="@id/web_view" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/custom_web_view"
|
android:id="@+id/custom_web_view"
|
||||||
|
|||||||
Reference in New Issue
Block a user