Optimize UX

pull/123/head
FongMi 3 years ago
parent d97b3d2e15
commit bcc0d95116
  1. 25
      app/src/leanback/java/com/fongmi/android/tv/ui/activity/DetailActivity.java
  2. 37
      app/src/leanback/java/com/fongmi/android/tv/ui/custom/CustomKeyDownVod.java

@ -1,5 +1,6 @@
package com.fongmi.android.tv.ui.activity;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.text.Html;
@ -178,12 +179,12 @@ public class DetailActivity extends BaseActivity implements CustomKeyDownVod.Lis
}
@Override
@SuppressLint("ClickableViewAccessibility")
protected void initEvent() {
mBinding.control.seek.setListener(mPlayers);
mBinding.desc.setOnClickListener(view -> onDesc());
mBinding.keep.setOnClickListener(view -> onKeep());
mBinding.video.setOnClickListener(view -> onVideo());
mBinding.video.setOnLongClickListener(view -> onLong());
mBinding.control.text.setOnClickListener(this::onTrack);
mBinding.control.audio.setOnClickListener(this::onTrack);
mBinding.control.next.setOnClickListener(view -> checkNext());
@ -199,6 +200,7 @@ public class DetailActivity extends BaseActivity implements CustomKeyDownVod.Lis
mBinding.control.replay.setOnLongClickListener(view -> onReplayLong());
mBinding.control.ending.setOnLongClickListener(view -> onEndingReset());
mBinding.control.opening.setOnLongClickListener(view -> onOpeningReset());
mBinding.video.setOnTouchListener((view, event) -> mKeyDown.onTouchEvent(event));
mBinding.flag.addOnChildViewHolderSelectedListener(new OnChildViewHolderSelectedListener() {
@Override
public void onChildViewHolderSelected(@NonNull RecyclerView parent, @Nullable RecyclerView.ViewHolder child, int position, int subposition) {
@ -462,7 +464,7 @@ public class DetailActivity extends BaseActivity implements CustomKeyDownVod.Lis
getIjk().getSubtitleView().setTextSize(TypedValue.COMPLEX_UNIT_SP, 24);
mBinding.video.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT));
mBinding.flag.setSelectedPosition(mCurrent);
mFullscreen = true;
App.post(() -> mFullscreen = true, 500);
onPlay(0);
}
@ -489,14 +491,7 @@ public class DetailActivity extends BaseActivity implements CustomKeyDownVod.Lis
}
private void onVideo() {
if (isVisible(mBinding.control.getRoot())) hideControl();
else if (mFullscreen) onKeyCenter();
else enterFullscreen();
}
private boolean onLong() {
if (mFullscreen) onKeyDown();
return true;
if (!mFullscreen) enterFullscreen();
}
private void checkNext() {
@ -857,6 +852,16 @@ public class DetailActivity extends BaseActivity implements CustomKeyDownVod.Lis
hideControl();
}
@Override
public void onSingleTap() {
if (mFullscreen) onToggle();
}
@Override
public void onDoubleTap() {
if (mFullscreen) onKeyCenter();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);

@ -1,20 +1,31 @@
package com.fongmi.android.tv.ui.custom;
import android.content.Context;
import android.view.GestureDetector;
import android.view.KeyEvent;
import android.view.MotionEvent;
import androidx.annotation.NonNull;
import com.fongmi.android.tv.utils.Utils;
public class CustomKeyDownVod {
public class CustomKeyDownVod extends GestureDetector.SimpleOnGestureListener {
private final GestureDetector detector;
private final Listener listener;
private int holdTime;
public static CustomKeyDownVod create(Listener listener) {
return new CustomKeyDownVod(listener);
public static CustomKeyDownVod create(Context context) {
return new CustomKeyDownVod(context);
}
private CustomKeyDownVod(Context context) {
this.listener = (Listener) context;
this.detector = new GestureDetector(context, this);
}
private CustomKeyDownVod(Listener listener) {
this.listener = listener;
public boolean onTouchEvent(MotionEvent e) {
return detector.onTouchEvent(e);
}
public boolean onKeyDown(KeyEvent event) {
@ -34,6 +45,18 @@ public class CustomKeyDownVod {
return true;
}
@Override
public boolean onDoubleTap(@NonNull MotionEvent e) {
listener.onDoubleTap();
return true;
}
@Override
public boolean onSingleTapConfirmed(@NonNull MotionEvent e) {
listener.onSingleTap();
return true;
}
public boolean hasEvent(KeyEvent event) {
return Utils.isEnterKey(event) || Utils.isUpKey(event) || Utils.isDownKey(event) || Utils.isLeftKey(event) || Utils.isRightKey(event);
}
@ -61,5 +84,9 @@ public class CustomKeyDownVod {
void onKeyDown();
void onKeyCenter();
void onSingleTap();
void onDoubleTap();
}
}

Loading…
Cancel
Save