Skip to content

Commit

Permalink
loading
Browse files Browse the repository at this point in the history
  • Loading branch information
lizongying committed May 16, 2024
1 parent 4edc0af commit 4e2e075
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 15 deletions.
30 changes: 19 additions & 11 deletions app/src/main/java/com/lizongying/mytv1/WebFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class WebFragment : Fragment() {
): View {
webView = WebView(requireContext())
webView.settings.javaScriptEnabled = true
webView.settings.domStorageEnabled = true
// webView.settings.domStorageEnabled = true
webView.settings.databaseEnabled = true
webView.settings.javaScriptCanOpenWindowsAutomatically = true
webView.settings.mediaPlaybackRequiresUserGesture = false
Expand Down Expand Up @@ -68,10 +68,10 @@ class WebFragment : Fragment() {
webView.webChromeClient = object : WebChromeClient() {
override fun onConsoleMessage(consoleMessage: ConsoleMessage?): Boolean {
if (consoleMessage != null) {
Log.e(
"WebViewConsole",
"Message: ${consoleMessage.message()}, Source: ${consoleMessage.sourceId()}, Line: ${consoleMessage.lineNumber()}"
)
// Log.e(
// "WebViewConsole",
// "Message: ${consoleMessage.message()}, Source: ${consoleMessage.sourceId()}, Line: ${consoleMessage.lineNumber()}"
// )

if (consoleMessage.message() == "success") {
Log.e(TAG, "success")
Expand Down Expand Up @@ -114,7 +114,7 @@ class WebFragment : Fragment() {
return WebResourceResponse("text/plain", "utf-8", null)
}

Log.i(TAG, "${request?.method} ${uri.toString()} ${request?.requestHeaders}")
// Log.i(TAG, "${request?.method} ${uri.toString()} ${request?.requestHeaders}")
return null
}

Expand Down Expand Up @@ -188,12 +188,20 @@ class WebFragment : Fragment() {
val uri = Uri.parse(url)
Log.e(TAG, "uri ${uri.host}")
when (uri.host) {
"tv.cctv.com" -> webView.evaluateJavascript(
"localStorage.setItem('cctv_live_resolution', '720');",
null
)
"tv.cctv.com" -> {
webView.evaluateJavascript(
"localStorage.setItem('cctv_live_resolution', '720');",
null
)
webView.loadUrl(url)
}

"www.gdtv.cn" -> {
webView.loadUrl(url)
}

"www.gdtv.cn" -> {}
"www.yangshipin.cn" -> {
}
}
webView.loadUrl(url)
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/loading.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
android:id="@+id/loading"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:background="@android:color/black"
>

<LinearLayout
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/raw/cctv.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
clearInterval(interval);
setTimeout(function () {
console.log('success');
}, 0)
}, 500)
}
}, 10);
});
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/raw/channels.txt

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion app/src/main/res/raw/ysp.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
(function () {
return new Promise(function (resolve, reject) {
// window.location.reload(true);

const divElement = document.createElement('div');
divElement.style.position = 'fixed';
divElement.style.top = '0';
Expand Down Expand Up @@ -29,7 +31,7 @@
clearInterval(interval);
setTimeout(function () {
console.log('success');
}, 0)
}, 1000)
}
}, 10);
});
Expand Down

0 comments on commit 4e2e075

Please sign in to comment.