From ce0ea2de8b17cec104200ec6c2a6acae37c7f59d Mon Sep 17 00:00:00 2001 From: FongMi Date: Sat, 11 Jan 2025 17:43:13 +0800 Subject: [PATCH] Clean code --- app/src/main/java/com/fongmi/android/tv/event/ErrorEvent.java | 2 +- .../java/com/fongmi/android/tv/player/extractor/TVBus.java | 4 +++- app/src/main/res/values-zh-rCN/strings.xml | 4 +++- app/src/main/res/values-zh-rTW/strings.xml | 4 +++- app/src/main/res/values/strings.xml | 4 +++- app/src/mobile/res/layout/view_widget_live.xml | 2 ++ app/src/mobile/res/layout/view_widget_vod.xml | 2 ++ 7 files changed, 17 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/fongmi/android/tv/event/ErrorEvent.java b/app/src/main/java/com/fongmi/android/tv/event/ErrorEvent.java index af65f199e..3cf1fb2b6 100644 --- a/app/src/main/java/com/fongmi/android/tv/event/ErrorEvent.java +++ b/app/src/main/java/com/fongmi/android/tv/event/ErrorEvent.java @@ -62,7 +62,7 @@ public class ErrorEvent { } public String getMsg() { - if (type == Type.URL) return ResUtil.getString(R.string.error_play_url, code); + if (type == Type.URL) return ResUtil.getString(code == -1 ? R.string.error_play_url : R.string.error_play_url_code, code); if (type == Type.DRM) return ResUtil.getString(R.string.error_play_drm_scheme); if (type == Type.FLAG) return ResUtil.getString(R.string.error_play_flag); if (type == Type.PARSE) return ResUtil.getString(R.string.error_play_parse); diff --git a/app/src/main/java/com/fongmi/android/tv/player/extractor/TVBus.java b/app/src/main/java/com/fongmi/android/tv/player/extractor/TVBus.java index 81f12f84a..893dd4b20 100644 --- a/app/src/main/java/com/fongmi/android/tv/player/extractor/TVBus.java +++ b/app/src/main/java/com/fongmi/android/tv/player/extractor/TVBus.java @@ -3,11 +3,13 @@ package com.fongmi.android.tv.player.extractor; import android.net.Uri; import com.fongmi.android.tv.App; +import com.fongmi.android.tv.R; import com.fongmi.android.tv.Setting; import com.fongmi.android.tv.api.config.LiveConfig; import com.fongmi.android.tv.bean.Core; import com.fongmi.android.tv.exception.ExtractException; import com.fongmi.android.tv.player.Source; +import com.fongmi.android.tv.utils.ResUtil; import com.github.catvod.net.OkHttp; import com.github.catvod.utils.Path; import com.google.gson.JsonObject; @@ -58,7 +60,7 @@ public class TVBus implements Source.Extractor, Listener { } private void onCheck() throws Exception { - if (hls.startsWith("-")) throw new ExtractException("Error code: " + hls); + if (hls.startsWith("-")) throw new ExtractException(ResUtil.getString(R.string.error_play_code, hls)); } private void onWait() throws InterruptedException { diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 9a266f23d..1f95f0ef8 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -118,7 +118,9 @@ 已经是第一集了! 播放地址解析失败 此设备不支持所需的 DRM scheme - 播放地址加载失败\n错误代码:%s + 播放地址加载失败\n错误代码:%s + 错误代码:%s + 播放地址加载失败 暂无线路数据 连接超时 暂无播放数据 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 14ab2dc72..3c3ceed37 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -118,7 +118,9 @@ 已經是第一集了! 播放網址解析失敗 本設備不支援所需的 DRM scheme - 播放網址載入失敗\n錯誤代碼:%s + 播放網址載入失敗\n錯誤代碼:%s + 錯誤代碼:%s + 播放網址載入失敗 暫無線路資料 連線逾時 暫無播放資料 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3888cfe91..6f9d604ca 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -119,7 +119,9 @@ It\'s the first episode! Unable to parse url This device does not support the required DRM scheme - Unable to load url\nError code: %s + Unable to load url\nError code: %s + Error code: %s + Unable to load url No flag data Timed out No play data diff --git a/app/src/mobile/res/layout/view_widget_live.xml b/app/src/mobile/res/layout/view_widget_live.xml index 1b08cb64b..6e927393f 100644 --- a/app/src/mobile/res/layout/view_widget_live.xml +++ b/app/src/mobile/res/layout/view_widget_live.xml @@ -10,8 +10,10 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" + android:background="@drawable/shape_widget" android:gravity="center" android:orientation="vertical" + android:padding="16dp" android:visibility="gone" tools:visibility="visible"> diff --git a/app/src/mobile/res/layout/view_widget_vod.xml b/app/src/mobile/res/layout/view_widget_vod.xml index 8071ec724..1d535e0c9 100644 --- a/app/src/mobile/res/layout/view_widget_vod.xml +++ b/app/src/mobile/res/layout/view_widget_vod.xml @@ -10,8 +10,10 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" + android:background="@drawable/shape_widget" android:gravity="center" android:orientation="vertical" + android:padding="16dp" android:visibility="gone" tools:visibility="visible">