修复leanback版本更新提示和视频源选中状态问题
This commit is contained in:
@@ -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