Skip to content

Commit

Permalink
fix style
Browse files Browse the repository at this point in the history
  • Loading branch information
lizongying committed May 16, 2024
1 parent 4e2e075 commit 7954b1f
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 30 deletions.
1 change: 0 additions & 1 deletion app/src/main/java/com/lizongying/mytv1/InfoFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class InfoFragment : Fragment() {
): View {
_binding = InfoBinding.inflate(inflater, container, false)


val application = requireActivity().applicationContext as MyTVApplication

binding.info.layoutParams.width = application.px2Px(binding.info.layoutParams.width)
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/lizongying/mytv1/MenuFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ class MenuFragment : Fragment(), GroupAdapter.ItemListener, ListAdapter.ItemList
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View {
val context = requireContext()
_binding = MenuBinding.inflate(inflater, container, false)

groupAdapter = GroupAdapter(
context!!,
context,
binding.group,
TVList.groupModel,
)
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/com/lizongying/mytv1/ModalFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import android.view.ViewGroup
import android.view.WindowManager
import androidx.fragment.app.DialogFragment
import com.bumptech.glide.Glide
import com.lizongying.mytv1.databinding.AppreciateBinding
import com.lizongying.mytv1.databinding.ModalBinding


class ModalFragment : DialogFragment() {

private var _binding: AppreciateBinding? = null
private var _binding: ModalBinding? = null
private val binding get() = _binding!!

private val handler = Handler(Looper.myLooper()!!)
Expand All @@ -34,7 +34,7 @@ class ModalFragment : DialogFragment() {
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
_binding = AppreciateBinding.inflate(inflater, container, false)
_binding = ModalBinding.inflate(inflater, container, false)
return binding.root
}

Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/com/lizongying/mytv1/MyTVApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.content.res.Resources
import android.os.Handler
import android.os.Looper
import android.util.DisplayMetrics
import android.util.Log
import android.view.WindowManager
import android.widget.Toast
import androidx.multidex.MultiDex
Expand Down
28 changes: 20 additions & 8 deletions app/src/main/java/com/lizongying/mytv1/WebFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import android.webkit.WebSettings
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.fragment.app.Fragment
import com.lizongying.mytv1.databinding.InfoBinding
import com.lizongying.mytv1.databinding.PlayerBinding
import com.lizongying.mytv1.models.TVModel


Expand All @@ -26,6 +28,9 @@ class WebFragment : Fragment() {

private var tvModel: TVModel? = null

private var _binding: PlayerBinding? = null
private val binding get() = _binding!!

override fun onActivityCreated(savedInstanceState: Bundle?) {
mainActivity = activity as MainActivity
super.onActivityCreated(savedInstanceState)
Expand All @@ -35,7 +40,15 @@ class WebFragment : Fragment() {
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View {
webView = WebView(requireContext())
_binding = PlayerBinding.inflate(inflater, container, false)

webView = binding.webView

val application = requireActivity().applicationContext as MyTVApplication

webView.layoutParams.width = application.shouldWidthPx()
webView.layoutParams.height = application.shouldHeightPx()

webView.settings.javaScriptEnabled = true
// webView.settings.domStorageEnabled = true
webView.settings.databaseEnabled = true
Expand All @@ -58,7 +71,7 @@ class WebFragment : Fragment() {
}

(activity as MainActivity).ready(TAG)
return webView
return binding.root
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
Expand All @@ -68,10 +81,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 @@ -101,7 +114,7 @@ class WebFragment : Fragment() {
) == true || uri?.path?.endsWith(
".gif"
) == true || uri?.path?.endsWith(
".csss"
".css"
) == true)
) {
return WebResourceResponse("text/plain", "utf-8", null)
Expand All @@ -113,7 +126,6 @@ class WebFragment : Fragment() {
) {
return WebResourceResponse("text/plain", "utf-8", null)
}

// Log.i(TAG, "${request?.method} ${uri.toString()} ${request?.requestHeaders}")
return null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
android:layout_width="200dp"
android:layout_height="200dp"
android:background="@color/white"
android:contentDescription="@string/appreciate"
android:contentDescription="@string/app_name"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/res/layout/player.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/player"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black"
android:keepScreenOn="true">

<WebView
android:id="@+id/web_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center" />
</FrameLayout>
16 changes: 3 additions & 13 deletions app/src/main/res/raw/cctv.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,17 @@
body.style.position = 'fixed';
body.style.left = '100%';
body.style.backgroundColor = '#000';
// const divElement = document.createElement('div');
// divElement.style.position = 'fixed';
// divElement.style.top = '0';
// divElement.style.left = '0';
// divElement.style.width = '100%';
// divElement.style.height = '100%';
// divElement.style.backgroundColor = '#000';
// divElement.style.zIndex = '9998';
// document.body.appendChild(divElement);

const height = document.documentElement.clientHeight;
const interval = setInterval(() => {
const video = document.querySelector('video');
if (video !== null) {
video.style.objectFit = 'contain';
video.style.position = 'fixed';
video.style.width = height * 16 / 9 + 'px';
video.style.height = height + 'px';
video.style.width = "100vw";
video.style.height = "100vh";
video.style.top = '0';
video.style.left = '0';
video.style.zIndex = '9998';
video.style.zIndex = '9999';

const images = document.querySelectorAll('img');
for(let i = 0; i < images.length; i++) {
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/res/raw/gdtv.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
divElement.style.zIndex = '9998';
document.body.appendChild(divElement);

const height = document.documentElement.clientHeight;
const interval = setInterval(() => {
const video = document.querySelector('video');
if (video !== null) {
video.style.objectFit = 'contain';
video.style.position = 'fixed';
video.style.width = height * 16 / 9 + 'px';
video.style.height = height + 'px';
video.style.width = "100vw";
video.style.height = "100vh";
video.style.top = '0';
video.style.left = '0';
video.style.zIndex = '9999';
Expand Down

0 comments on commit 7954b1f

Please sign in to comment.