修复leanback版本更新提示和视频源选中状态问题
This commit is contained in:
@@ -72,6 +72,11 @@ public class Updater implements Download.Callback {
|
||||
}
|
||||
|
||||
public void start(Activity activity) {
|
||||
// 检查是否启用启动时自动检查更新
|
||||
if (!Setting.getAutoUpdateCheck()) {
|
||||
Logger.d("Auto update check is disabled");
|
||||
return;
|
||||
}
|
||||
App.execute(() -> doInBackground(activity));
|
||||
}
|
||||
|
||||
|
||||
@@ -98,8 +98,8 @@ public class SiteDialog implements SiteAdapter.OnClickListener {
|
||||
if (!binding.mode.hasFocus()) {
|
||||
binding.recycler.post(() -> {
|
||||
binding.recycler.scrollToPosition(VodConfig.getHomeIndex());
|
||||
// 清除焦点,避免滚动后自动获得焦点显示黄色背景
|
||||
binding.recycler.post(() -> binding.recycler.clearFocus());
|
||||
// 请求焦点,确保选中项保持高亮状态
|
||||
binding.recycler.post(() -> binding.recycler.requestFocus());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="@color/black" android:state_focused="true" />
|
||||
<item android:color="@color/black" android:state_activated="true" />
|
||||
<item android:color="@color/black" android:state_selected="true" />
|
||||
<item android:color="@color/black" android:state_pressed="true" />
|
||||
<item android:color="@color/white" />
|
||||
</selector>
|
||||
@@ -19,6 +19,7 @@
|
||||
android:singleLine="true"
|
||||
android:textColor="@color/button_text"
|
||||
android:textSize="18sp"
|
||||
android:duplicateParentState="true"
|
||||
tools:text="泥巴" />
|
||||
|
||||
<com.google.android.material.checkbox.MaterialCheckBox
|
||||
|
||||
@@ -201,6 +201,14 @@ public class Setting {
|
||||
Prefers.put("update", update);
|
||||
}
|
||||
|
||||
public static boolean getAutoUpdateCheck() {
|
||||
return Prefers.getBoolean("auto_update_check", false);
|
||||
}
|
||||
|
||||
public static void putAutoUpdateCheck(boolean autoUpdateCheck) {
|
||||
Prefers.put("auto_update_check", autoUpdateCheck);
|
||||
}
|
||||
|
||||
public static boolean getUseCnMirror() {
|
||||
return Prefers.getBoolean("use_cn_mirror", false);
|
||||
}
|
||||
|
||||
@@ -60,6 +60,14 @@ public class CustomSeekView extends FrameLayout implements TimeBar.OnScrubListen
|
||||
public void setListener(Players player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public void setPosition(long position) {
|
||||
timeBar.setPosition(position);
|
||||
}
|
||||
|
||||
public void setDuration(long duration) {
|
||||
timeBar.setDuration(duration);
|
||||
}
|
||||
|
||||
private void start() {
|
||||
removeCallbacks(refresh);
|
||||
@@ -102,7 +110,7 @@ public class CustomSeekView extends FrameLayout implements TimeBar.OnScrubListen
|
||||
}
|
||||
}
|
||||
|
||||
private void setKeyTimeIncrement(long duration) {
|
||||
public void setKeyTimeIncrement(long duration) {
|
||||
if (duration > TimeUnit.HOURS.toMillis(3)) {
|
||||
timeBar.setKeyTimeIncrement(TimeUnit.MINUTES.toMillis(5));
|
||||
} else if (duration > TimeUnit.MINUTES.toMillis(30)) {
|
||||
@@ -124,8 +132,19 @@ public class CustomSeekView extends FrameLayout implements TimeBar.OnScrubListen
|
||||
}
|
||||
|
||||
private void seekToTimeBarPosition(long positionMs) {
|
||||
// 先设置播放位置
|
||||
player.seekTo(positionMs);
|
||||
refresh();
|
||||
// 延迟刷新进度条,确保播放器已经处理了跳转操作
|
||||
removeCallbacks(refresh);
|
||||
postDelayed(() -> {
|
||||
refresh();
|
||||
// 确保进度条位置与实际播放位置一致
|
||||
long actualPosition = player.getPosition();
|
||||
if (Math.abs(actualPosition - positionMs) > 100) { // 如果差异超过100ms,再次调整
|
||||
timeBar.setPosition(actualPosition);
|
||||
positionView.setText(player.stringToTime(actualPosition));
|
||||
}
|
||||
}, 50); // 延迟50ms刷新
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -148,6 +167,16 @@ public class CustomSeekView extends FrameLayout implements TimeBar.OnScrubListen
|
||||
@Override
|
||||
public void onScrubStop(@NonNull TimeBar timeBar, long position, boolean canceled) {
|
||||
scrubbing = false;
|
||||
if (!canceled) seekToTimeBarPosition(position);
|
||||
if (!canceled) {
|
||||
// 先隐藏进度条提示,避免用户看到不一致的状态
|
||||
// 注意:这里不能直接访问mBinding.widget.seek,因为CustomSeekView不包含这个引用
|
||||
// 这个优化将在VideoActivity的onSeekEnd方法中实现
|
||||
// 调整播放位置
|
||||
seekToTimeBarPosition(position);
|
||||
// 确保播放状态正确
|
||||
if (!player.isPlaying()) {
|
||||
player.play();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10s10,-4.48 10,-10S17.52,2 12,2zM12,5c1.66,0 3,1.34 3,3s-1.34,3 -3,3S9,9.66 9,8S10.34,5 12,5zM12,19.2c-2.5,0 -4.71,-1.28 -6,-3.22c0.03,-1.99 4,-3.08 6,-3.08c1.99,0 5.97,1.09 6,3.08C16.71,17.92 14.5,19.2 12,19.2z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M12,7c-2.76,0 -5,2.24 -5,5s2.24,5 5,5 5,-2.24 5,-5 -2.24,-5 -5,-5zM15.19,14.85L13.2,12.86c.5,-1.19.25,-2.58 -0.73,-3.55 -1.17,-1.18 -3.01,-1.39 -4.39,-0.51l1.99,1.99c0.22,0.22 0.22,0.57 0,0.79l-0.79,0.79c-0.22,0.22 -0.57,0.22 -0.79,0L6.5,10.38c-0.88,1.37 -0.67,3.22 0.51,4.39 0.97,0.98 2.36,1.23 3.55,0.73l1.99,1.99c0.22,0.22 0.57,0.22 0.79,0l0.79,-0.79c0.22,-0.22 0.22,-0.57 0,-0.79z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M12,19c1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3s-3,1.34 -3,3S10.34,19 12,19zM12,17c-0.55,0 -1,-0.45 -1,-1s0.45,-1 1,-1s1,0.45 1,1S12.55,17 12,17zM17,9c0,-2.76 -2.24,-5 -5,-5S7,6.24 7,9c0,1.59 0.76,3 1.95,3.91C7.58,13.71 6.5,15.27 6.5,17c0,0.55 0.45,1 1,1s1,-0.45 1,-1c0,-1.65 1.35,-3 3,-3s3,1.35 3,3c0,0.55 0.45,1 1,1s1,-0.45 1,-1c0,-1.73 -1.08,-3.29 -2.45,-4.09C15.24,12 16,10.59 16,9zM12,12c-1.66,0 -3,-1.34 -3,-3s1.34,-3 3,-3s3,1.34 3,3S13.66,12 12,12z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M19,5v14L5,19L5,5h14m1.1,-2L3.9,3c-0.5,0 -0.9,0.4 -0.9,0.9v16.2c0,0.4 0.4,0.9 0.9,0.9h16.2c0.4,0 0.9,-0.5 0.9,-0.9L21,3.9c0,-0.5 -0.4,-0.9 -0.9,-0.9zM11,7h6v2h-6L11,7zM11,11h6v2h-6v-2zM11,15h6v2h-6zM7,7h2v2L7,9zM7,11h2v2L7,13zM7,15h2v2L7,17z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M12,3C8.69,3 6,5.69 6,9s2.69,6 6,6s6,-2.69 6,-6S15.31,3 12,3zM12,13c-2.21,0 -4,-1.79 -4,-4s1.79,-4 4,-4s4,1.79 4,4S14.21,13 12,13zM21,18h-2v2h-1.5v-2h-2v-1.5h2v-2h1.5v2h2V18zM11,18c0,-0.28 0.05,-0.54 0.12,-0.8c-0.87,-0.54 -1.89,-0.88 -3,-0.99C5.73,15.91 3,16.71 3,18.5V20h8.26C11.1,19.36 11,18.69 11,18z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M21,15h2v2h-2v-2zM21,11h2v2h-2v-2zM23,19h-2v2c1,0 2,-1 2,-2zM13,3h2v2h-2L13,3zM21,7h2v2h-2L21,7zM21,3v2h2c0,-1 -1,-2 -2,-2zM1,7h2v2L1,9L1,7zM17,3h2v2h-2L17,3zM17,19h2v2h-2v-2zM3,3C2,3 1,4 1,5h2L3,3zM9,3h2v2L9,5L9,3zM5,3h2v2L5,5L5,3zM1,11v8c0,1.1 0.9,2 2,2h12L15,11L1,11zM3,19l2.5,-3.21 1.79,2.15 2.5,-3.22L13,19L3,19z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M21,3H3C2,3 1,4 1,5v14c0,1.1 0.9,2 2,2h18c1,0 2,-1 2,-2V5c0,-1 -1,-2 -2,-2zM21,19H3V5h18v14zM14.5,11.5c0,0.83 -0.67,1.5 -1.5,1.5h-2v2h2v1h-3v-4c0,-0.83 0.67,-1.5 1.5,-1.5h2c0.83,0 1.5,0.67 1.5,1.5zM11.5,8.5H13v1h-2V7h2v1h-1.5zM16,13.5c0,0.83 -0.67,1.5 -1.5,1.5h-2v-2h2v-1h-2v-2h2c0.83,0 1.5,0.67 1.5,1.5v2z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M18.5,8C19.88,8 21,6.88 21,5.5C21,4.12 19.88,3 18.5,3C17.12,3 16,4.12 16,5.5C16,6.88 17.12,8 18.5,8zM5.5,8C6.88,8 8,6.88 8,5.5C8,4.12 6.88,3 5.5,3C4.12,3 3,4.12 3,5.5C3,6.88 4.12,8 5.5,8zM7.5,17H16.5C17.6,17 18.5,16.1 18.5,15V11.41C18.5,10.08 16.92,9.43 16,10.36C14.55,11.8 13.45,11.8 12,10.36C10.55,8.91 9.45,8.91 8,10.36C7.07,11.29 5.5,10.64 5.5,9.31V15C5.5,16.1 6.4,17 7.5,17z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M15,8v8H5V8h10m1,-2H4C3.45,6 3,6.45 3,7v10c0,0.55 0.45,1 1,1h12c0.55,0 1,-0.45 1,-1v-3.5l4,4v-11l-4,4V7c0,-0.55 -0.45,-1 -1,-1z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M12,16c-1.79,0 -3.23,-1.43 -3.23,-3.23 0,-0.36 0.06,-0.7 0.17,-1.02l4.08,4.08c-0.32,0.11 -0.66,0.17 -1.02,0.17zM12,8c1.79,0 3.23,1.43 3.23,3.23 0,0.36 -0.06,0.7 -0.17,1.02L10.98,8.17C11.3,8.06 11.64,8 12,8zM19.94,19.5L17.77,17.33C16.68,18.15 15.39,18.75 14,19.08v-2.11c0.63,-0.23 1.21,-0.54 1.73,-0.92l-1.4,-1.4c-0.64,0.51 -1.44,0.81 -2.33,0.81 -2.09,0 -3.77,-1.68 -3.77,-3.77 0,-0.89 0.31,-1.69 0.81,-2.33L7.65,8.97c-0.92,0.74 -1.73,1.61 -2.38,2.57C5.09,11.83 5,12.15 5,12.5s0.09,0.67 0.27,0.96c1.87,2.95 5.07,4.77 8.73,4.77 1.35,0 2.63,-0.22 3.83,-0.61l-0.39,-0.39 2.5,2.5c0.39,0.39 1.02,0.39 1.41,0 0.4,-0.39 0.4,-1.02 0,-1.41l-1.41,-1.41zM5.06,4.5l2.18,2.18c1.09,-0.82 2.37,-1.42 3.76,-1.76L11,7.03c-0.63,0.23 -1.21,0.54 -1.73,0.92l1.4,1.4c0.64,-0.51 1.44,-0.81 2.33,-0.81 2.09,0 3.77,1.68 3.77,3.77 0,0.89 -0.31,1.69 -0.81,2.33l1.4,1.4c0.92,-0.74 1.73,-1.61 2.38,-2.57 0.18,-0.29 0.27,-0.61 0.27,-0.96s-0.09,-0.67 -0.27,-0.96C18.87,8.6 15.67,6.78 12,6.78c-1.35,0 -2.63,0.22 -3.83,0.61L5.06,4.27c-0.39,-0.39 -1.02,-0.39 -1.41,0s-0.39,1.02 0,1.41l1.41,1.41z"/>
|
||||
</vector>
|
||||
@@ -125,7 +125,7 @@
|
||||
<string name="dialog_edit">修改</string>
|
||||
<string name="dialog_positive">确定</string>
|
||||
<string name="dialog_negative">取消</string>
|
||||
<string name="dialog_paste">从剪贴板粘贴</string>
|
||||
<string name="dialog_paste">点我粘贴</string>
|
||||
<string name="dialog_config_hint">请输入接口…</string>
|
||||
<string name="dialog_config_name">请输入名称…</string>
|
||||
<string name="dialog_config_url">请输入地址…</string>
|
||||
|
||||
@@ -91,7 +91,7 @@
|
||||
<string name="setting_choose">Choose</string>
|
||||
<string name="setting_off">Off</string>
|
||||
<string name="setting_on">On</string>
|
||||
<string name="app_version">v3.0.3</string>
|
||||
<string name="app_version">v3.0.6</string>
|
||||
<string name="about_github">View on GitHub</string>
|
||||
|
||||
<!-- Backup & Restore -->
|
||||
@@ -126,7 +126,7 @@
|
||||
<string name="dialog_edit">Edit</string>
|
||||
<string name="dialog_positive">OK</string>
|
||||
<string name="dialog_negative">Cancel</string>
|
||||
<string name="dialog_paste">Paste from clipboard</string>
|
||||
<string name="dialog_paste">Click to paste</string>
|
||||
<string name="dialog_config_hint">Please enter the config…</string>
|
||||
<string name="dialog_config_name">Please enter the name…</string>
|
||||
<string name="dialog_config_url">Please enter the url…</string>
|
||||
|
||||
@@ -32,6 +32,7 @@ public class Updater implements Download.Callback {
|
||||
private AlertDialog dialog;
|
||||
private boolean dev;
|
||||
private String downloadUrl;
|
||||
private boolean forceCheck; // 标记是否是用户主动检查更新
|
||||
|
||||
private File getFile() {
|
||||
return Path.cache("update.apk");
|
||||
@@ -60,6 +61,7 @@ public class Updater implements Download.Callback {
|
||||
public Updater force() {
|
||||
Notify.show(R.string.update_check);
|
||||
Setting.putUpdate(true);
|
||||
this.forceCheck = true; // 标记为用户主动检查更新
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -160,7 +162,10 @@ public class Updater implements Download.Callback {
|
||||
Logger.d("Already latest version: " + tagName);
|
||||
} else {
|
||||
// 未找到对应的APK文件
|
||||
App.post(() -> Notify.show("检查更新完成,未找到适合此设备的安装包"));
|
||||
// 只在用户主动检查更新时显示提示
|
||||
if (forceCheck) {
|
||||
App.post(() -> Notify.show("检查更新完成,未找到适合此设备的安装包"));
|
||||
}
|
||||
Logger.d("APK not found for this device");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -30,6 +30,7 @@ import android.view.WindowManager;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -1465,6 +1466,55 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
|
||||
this.rotate = rotate;
|
||||
if (fullscreen && rotate) noPadding(mBinding.control.getRoot());
|
||||
if (fullscreen && !rotate) setPadding(mBinding.control.getRoot());
|
||||
// 检测屏幕方向变化并处理
|
||||
onOrientationChanged();
|
||||
}
|
||||
|
||||
// 添加屏幕方向变化处理方法
|
||||
private void onOrientationChanged() {
|
||||
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
// 切换到横屏模式
|
||||
onLandscapeMode();
|
||||
} else {
|
||||
// 切换到竖屏模式
|
||||
onPortraitMode();
|
||||
}
|
||||
}
|
||||
|
||||
private void onLandscapeMode() {
|
||||
// 横屏模式下的特殊处理
|
||||
// 调整进度条的敏感度
|
||||
if (mPlayers != null) {
|
||||
long duration = mPlayers.getDuration();
|
||||
if (duration > TimeUnit.MINUTES.toMillis(30)) {
|
||||
mBinding.control.seek.setKeyTimeIncrement(TimeUnit.MINUTES.toMillis(1));
|
||||
} else if (duration > TimeUnit.MINUTES.toMillis(10)) {
|
||||
mBinding.control.seek.setKeyTimeIncrement(TimeUnit.SECONDS.toMillis(30));
|
||||
} else if (duration > 0) {
|
||||
mBinding.control.seek.setKeyTimeIncrement(TimeUnit.SECONDS.toMillis(15));
|
||||
}
|
||||
}
|
||||
|
||||
// 确保进度条状态正确
|
||||
if (mPlayers != null) {
|
||||
long position = mPlayers.getPosition();
|
||||
long duration = mPlayers.getDuration();
|
||||
if (position > 0 && duration > 0) {
|
||||
mBinding.control.seek.setPosition(position);
|
||||
mBinding.control.seek.setDuration(duration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void onPortraitMode() {
|
||||
// 竖屏模式下的处理
|
||||
// 恢复进度条的默认敏感度
|
||||
if (mPlayers != null) {
|
||||
long duration = mPlayers.getDuration();
|
||||
if (duration > 0) {
|
||||
mBinding.control.seek.setKeyTimeIncrement(duration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isStop() {
|
||||
@@ -1566,10 +1616,40 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
|
||||
|
||||
@Override
|
||||
public void onSeekEnd(long time) {
|
||||
mBinding.widget.seek.setVisibility(View.GONE);
|
||||
mPlayers.seek(time);
|
||||
showProgress();
|
||||
onPlay();
|
||||
handleLandscapeSeek(time);
|
||||
}
|
||||
|
||||
// 添加新的方法,处理横屏模式下的特殊逻辑
|
||||
private void handleLandscapeSeek(long time) {
|
||||
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
// 横屏模式下的特殊处理
|
||||
mBinding.widget.seek.setVisibility(View.GONE);
|
||||
mPlayers.pause();
|
||||
mPlayers.seek(time);
|
||||
showProgress();
|
||||
App.post(() -> {
|
||||
long actualPosition = mPlayers.getPosition();
|
||||
if (Math.abs(actualPosition - time) > 500) {
|
||||
mPlayers.seek(time);
|
||||
}
|
||||
onPlay();
|
||||
hideProgress();
|
||||
}, 150); // 横屏模式下延迟更长,确保跳转完成
|
||||
} else {
|
||||
// 竖屏模式使用原有逻辑
|
||||
mBinding.widget.seek.setVisibility(View.GONE);
|
||||
mPlayers.pause();
|
||||
mPlayers.seek(time);
|
||||
showProgress();
|
||||
App.post(() -> {
|
||||
long actualPosition = mPlayers.getPosition();
|
||||
if (Math.abs(actualPosition - time) > 500) {
|
||||
mPlayers.seek(time);
|
||||
}
|
||||
onPlay();
|
||||
hideProgress();
|
||||
}, 100); // 竖屏模式下延迟较短
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,6 +8,7 @@ import android.view.MotionEvent;
|
||||
import android.view.ScaleGestureDetector;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.content.res.Configuration;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
@@ -109,6 +110,17 @@ public class CustomKeyDownVod extends GestureDetector.SimpleOnGestureListener im
|
||||
if (isEdge(e1) || changeScale || lock || e1.getPointerCount() > 1) return true;
|
||||
float deltaX = e2.getX() - e1.getX();
|
||||
float deltaY = e1.getY() - e2.getY();
|
||||
|
||||
// 在横屏模式下,调整触摸事件的处理逻辑
|
||||
if (activity.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
// 横屏模式下,增加对水平滑动的敏感度
|
||||
if (Math.abs(deltaX) > Math.abs(deltaY) * 0.5f) {
|
||||
if (touch) checkFunc(distanceX, distanceY, e2);
|
||||
if (changeTime) listener.onSeek(time = (long) (deltaX * 50));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (touch) checkFunc(distanceX, distanceY, e2);
|
||||
if (changeTime) listener.onSeek(time = (long) (deltaX * 50));
|
||||
if (changeBright) setBright(deltaY);
|
||||
@@ -145,9 +157,32 @@ public class CustomKeyDownVod extends GestureDetector.SimpleOnGestureListener im
|
||||
|
||||
private void checkFunc(float distanceX, float distanceY, MotionEvent e2) {
|
||||
int four = ResUtil.getScreenWidth(activity) / 4;
|
||||
if (e2.getX() > four && e2.getX() < four * 3) center = true;
|
||||
else if (Math.abs(distanceX) < Math.abs(distanceY)) checkSide(e2);
|
||||
if (Math.abs(distanceX) >= Math.abs(distanceY)) changeTime = true;
|
||||
|
||||
// 在横屏模式下,调整中心区域的判断
|
||||
if (activity.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
// 横屏模式下,扩大中心区域,更容易触发进度条调整
|
||||
int centerStart = ResUtil.getScreenWidth(activity) / 3;
|
||||
int centerEnd = ResUtil.getScreenWidth(activity) * 2 / 3;
|
||||
if (e2.getX() > centerStart && e2.getX() < centerEnd) {
|
||||
center = true;
|
||||
} else if (Math.abs(distanceX) < Math.abs(distanceY)) {
|
||||
checkSide(e2);
|
||||
}
|
||||
// 横屏模式下,降低触发进度条调整的阈值
|
||||
if (Math.abs(distanceX) >= Math.abs(distanceY) * 0.7f) {
|
||||
changeTime = true;
|
||||
}
|
||||
} else {
|
||||
// 竖屏模式保持原有逻辑
|
||||
if (e2.getX() > four && e2.getX() < four * 3) {
|
||||
center = true;
|
||||
} else if (Math.abs(distanceX) < Math.abs(distanceY)) {
|
||||
checkSide(e2);
|
||||
}
|
||||
if (Math.abs(distanceX) >= Math.abs(distanceY)) {
|
||||
changeTime = true;
|
||||
}
|
||||
}
|
||||
touch = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.fongmi.android.tv.api.config.WallConfig;
|
||||
import com.fongmi.android.tv.bean.Config;
|
||||
import com.fongmi.android.tv.databinding.DialogConfigBinding;
|
||||
import com.fongmi.android.tv.impl.ConfigCallback;
|
||||
import com.fongmi.android.tv.impl.Callback;
|
||||
import com.fongmi.android.tv.ui.custom.CustomTextListener;
|
||||
import com.fongmi.android.tv.utils.FileChooser;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
@@ -156,7 +157,63 @@ public class ConfigDialog {
|
||||
}
|
||||
|
||||
// 只有URL不为空时,才设置配置
|
||||
// 保存原始URL,以便在添加失败时恢复
|
||||
String originalUrl = ori;
|
||||
callback.setConfig(Config.find(url, type));
|
||||
|
||||
// 添加一个延迟检查,如果配置没有成功加载,则恢复原始URL
|
||||
new android.os.Handler().postDelayed(() -> {
|
||||
// 检查配置是否成功加载
|
||||
Config currentConfig = getConfig();
|
||||
if (currentConfig == null || !currentConfig.getUrl().equals(url)) {
|
||||
// 配置加载失败,恢复原始URL
|
||||
if (!TextUtils.isEmpty(originalUrl)) {
|
||||
// 如果有原始URL,恢复原始URL
|
||||
callback.setConfig(Config.find(originalUrl, type));
|
||||
} else {
|
||||
// 如果没有原始URL,设置为空
|
||||
switch (type) {
|
||||
case 0:
|
||||
VodConfig.get().clear().config(Config.vod()).load(new Callback() {
|
||||
@Override
|
||||
public void success() {}
|
||||
|
||||
@Override
|
||||
public void success(String result) {}
|
||||
|
||||
@Override
|
||||
public void error(String msg) {}
|
||||
});
|
||||
break;
|
||||
case 1:
|
||||
LiveConfig.get().clear().config(Config.live()).load(new Callback() {
|
||||
@Override
|
||||
public void success() {}
|
||||
|
||||
@Override
|
||||
public void success(String result) {}
|
||||
|
||||
@Override
|
||||
public void error(String msg) {}
|
||||
});
|
||||
break;
|
||||
case 2:
|
||||
WallConfig.get().clear().config(Config.wall()).load(new Callback() {
|
||||
@Override
|
||||
public void success() {}
|
||||
|
||||
@Override
|
||||
public void success(String result) {}
|
||||
|
||||
@Override
|
||||
public void error(String msg) {}
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 2000); // 2秒后检查
|
||||
|
||||
dialog.dismiss();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user