release^2
jhengazuki 2 months ago
parent 3d4274f6e4
commit 72baf2c8d7
  1. 2
      app/src/leanback/java/com/fongmi/android/tv/ui/activity/CastActivity.java
  2. 2
      app/src/leanback/java/com/fongmi/android/tv/ui/activity/LiveActivity.java
  3. 2
      app/src/leanback/java/com/fongmi/android/tv/ui/activity/VideoActivity.java
  4. 30
      app/src/main/java/com/fongmi/android/tv/ui/custom/CustomSeekView.java
  5. 2
      app/src/mobile/java/com/fongmi/android/tv/ui/activity/LiveActivity.java
  6. 2
      app/src/mobile/java/com/fongmi/android/tv/ui/activity/VideoActivity.java

@ -103,7 +103,7 @@ public class CastActivity extends BaseActivity implements CustomKeyDownVod.Liste
@Override @Override
@SuppressLint("ClickableViewAccessibility") @SuppressLint("ClickableViewAccessibility")
protected void initEvent() { protected void initEvent() {
mBinding.control.seek.setListener(mPlayers); mBinding.control.seek.setPlayer(mPlayers);
mBinding.control.speed.setUpListener(this::onSpeedAdd); mBinding.control.speed.setUpListener(this::onSpeedAdd);
mBinding.control.speed.setDownListener(this::onSpeedSub); mBinding.control.speed.setDownListener(this::onSpeedSub);
mBinding.control.text.setUpListener(this::onSubtitleClick); mBinding.control.text.setUpListener(this::onSubtitleClick);

@ -153,7 +153,7 @@ public class LiveActivity extends BaseActivity implements GroupPresenter.OnClick
mBinding.group.setListener(this); mBinding.group.setListener(this);
mBinding.channel.setListener(this); mBinding.channel.setListener(this);
mBinding.epgData.setListener(this); mBinding.epgData.setListener(this);
mBinding.control.seek.setListener(mPlayers); mBinding.control.seek.setPlayer(mPlayers);
mBinding.control.text.setOnClickListener(this::onTrack); mBinding.control.text.setOnClickListener(this::onTrack);
mBinding.control.audio.setOnClickListener(this::onTrack); mBinding.control.audio.setOnClickListener(this::onTrack);
mBinding.control.video.setOnClickListener(this::onTrack); mBinding.control.video.setOnClickListener(this::onTrack);

@ -290,7 +290,7 @@ public class VideoActivity extends BaseActivity implements CustomKeyDownVod.List
@Override @Override
@SuppressLint("ClickableViewAccessibility") @SuppressLint("ClickableViewAccessibility")
protected void initEvent() { protected void initEvent() {
mBinding.control.seek.setListener(mPlayers); mBinding.control.seek.setPlayer(mPlayers);
mBinding.desc.setOnClickListener(view -> onDesc()); mBinding.desc.setOnClickListener(view -> onDesc());
mBinding.keep.setOnClickListener(view -> onKeep()); mBinding.keep.setOnClickListener(view -> onKeep());
mBinding.video.setOnClickListener(view -> onVideo()); mBinding.video.setOnClickListener(view -> onVideo());

@ -22,17 +22,16 @@ public class CustomSeekView extends FrameLayout implements TimeBar.OnScrubListen
private static final int MAX_UPDATE_INTERVAL_MS = 1000; private static final int MAX_UPDATE_INTERVAL_MS = 1000;
private static final int MIN_UPDATE_INTERVAL_MS = 200; private static final int MIN_UPDATE_INTERVAL_MS = 200;
private TextView positionView; private final TextView positionView;
private TextView durationView; private final TextView durationView;
private DefaultTimeBar timeBar; private final DefaultTimeBar timeBar;
private final Runnable refresh;
private Runnable refresh;
private Players player;
private long currentDuration; private long currentDuration;
private long currentPosition; private long currentPosition;
private long currentBuffered; private long currentBuffered;
private boolean scrubbing; private boolean scrubbing;
private Players player;
public CustomSeekView(Context context) { public CustomSeekView(Context context) {
this(context, null); this(context, null);
@ -45,11 +44,6 @@ public class CustomSeekView extends FrameLayout implements TimeBar.OnScrubListen
public CustomSeekView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { public CustomSeekView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr); super(context, attrs, defStyleAttr);
LayoutInflater.from(context).inflate(R.layout.view_control_seek, this); LayoutInflater.from(context).inflate(R.layout.view_control_seek, this);
init();
start();
}
private void init() {
positionView = findViewById(R.id.position); positionView = findViewById(R.id.position);
durationView = findViewById(R.id.duration); durationView = findViewById(R.id.duration);
timeBar = findViewById(R.id.timeBar); timeBar = findViewById(R.id.timeBar);
@ -57,12 +51,9 @@ public class CustomSeekView extends FrameLayout implements TimeBar.OnScrubListen
refresh = this::refresh; refresh = this::refresh;
} }
public void setListener(Players player) { public void setPlayer(Players player) {
this.player = player;
}
private void start() {
removeCallbacks(refresh); removeCallbacks(refresh);
this.player = player;
post(refresh); post(refresh);
} }
@ -73,17 +64,17 @@ public class CustomSeekView extends FrameLayout implements TimeBar.OnScrubListen
boolean positionChanged = position != currentPosition; boolean positionChanged = position != currentPosition;
boolean durationChanged = duration != currentDuration; boolean durationChanged = duration != currentDuration;
boolean bufferedChanged = buffered != currentBuffered; boolean bufferedChanged = buffered != currentBuffered;
currentDuration = duration;
currentPosition = position; currentPosition = position;
currentDuration = duration;
currentBuffered = buffered; currentBuffered = buffered;
if (durationChanged) { if (durationChanged) {
setKeyTimeIncrement(duration); setKeyTimeIncrement(duration);
timeBar.setDuration(duration); timeBar.setDuration(duration);
durationView.setText(player.stringToTime(duration < 0 ? 0 : duration)); durationView.setText(player.stringToTime(Math.max(0, duration)));
} }
if (positionChanged && !scrubbing) { if (positionChanged && !scrubbing) {
timeBar.setPosition(position); timeBar.setPosition(position);
positionView.setText(player.stringToTime(position < 0 ? 0 : position)); positionView.setText(player.stringToTime(Math.max(0, position)));
} }
if (bufferedChanged) { if (bufferedChanged) {
timeBar.setBufferedPosition(buffered); timeBar.setBufferedPosition(buffered);
@ -94,6 +85,7 @@ public class CustomSeekView extends FrameLayout implements TimeBar.OnScrubListen
durationView.setText("00:00"); durationView.setText("00:00");
timeBar.setPosition(currentPosition = 0); timeBar.setPosition(currentPosition = 0);
timeBar.setDuration(currentDuration = 0); timeBar.setDuration(currentDuration = 0);
timeBar.setBufferedPosition(currentBuffered = 0);
postDelayed(refresh, MIN_UPDATE_INTERVAL_MS); postDelayed(refresh, MIN_UPDATE_INTERVAL_MS);
} else if (player.isPlaying()) { } else if (player.isPlaying()) {
postDelayed(refresh, delayMs(position)); postDelayed(refresh, delayMs(position));

@ -161,7 +161,7 @@ public class LiveActivity extends BaseActivity implements CustomKeyDown.Listener
@Override @Override
@SuppressLint("ClickableViewAccessibility") @SuppressLint("ClickableViewAccessibility")
protected void initEvent() { protected void initEvent() {
mBinding.control.seek.setListener(mPlayers); mBinding.control.seek.setPlayer(mPlayers);
mBinding.control.back.setOnClickListener(view -> onBack()); mBinding.control.back.setOnClickListener(view -> onBack());
mBinding.control.cast.setOnClickListener(view -> onCast()); mBinding.control.cast.setOnClickListener(view -> onCast());
mBinding.control.info.setOnClickListener(view -> onInfo()); mBinding.control.info.setOnClickListener(view -> onInfo());

@ -306,6 +306,7 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
@Override @Override
@SuppressLint("ClickableViewAccessibility") @SuppressLint("ClickableViewAccessibility")
protected void initEvent() { protected void initEvent() {
mBinding.control.seek.setPlayer(mPlayers);
mBinding.name.setOnClickListener(view -> onName()); mBinding.name.setOnClickListener(view -> onName());
mBinding.more.setOnClickListener(view -> onMore()); mBinding.more.setOnClickListener(view -> onMore());
mBinding.actor.setOnClickListener(view -> onActor()); mBinding.actor.setOnClickListener(view -> onActor());
@ -347,7 +348,6 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
mBinding.video.setOnTouchListener((view, event) -> mKeyDown.onTouchEvent(event)); mBinding.video.setOnTouchListener((view, event) -> mKeyDown.onTouchEvent(event));
mBinding.control.action.getRoot().setOnTouchListener(this::onActionTouch); mBinding.control.action.getRoot().setOnTouchListener(this::onActionTouch);
mBinding.swipeLayout.setOnRefreshListener(this::onSwipeRefresh); mBinding.swipeLayout.setOnRefreshListener(this::onSwipeRefresh);
mBinding.control.seek.setListener(mPlayers);
} }
private WindowInsetsCompat setStatusBar(WindowInsetsCompat insets) { private WindowInsetsCompat setStatusBar(WindowInsetsCompat insets) {

Loading…
Cancel
Save