diff --git a/app/src/mobile/java/com/fongmi/android/tv/ui/activity/DetailActivity.java b/app/src/mobile/java/com/fongmi/android/tv/ui/activity/DetailActivity.java
index d8c66c97b..db37d7566 100644
--- a/app/src/mobile/java/com/fongmi/android/tv/ui/activity/DetailActivity.java
+++ b/app/src/mobile/java/com/fongmi/android/tv/ui/activity/DetailActivity.java
@@ -881,7 +881,9 @@ public class DetailActivity extends BaseActivity implements CustomKeyDownVod.Lis
@Override
public void onSeeking(int time) {
- if (!isLock()) showState(time > 0 ? R.drawable.ic_widget_forward : R.drawable.ic_widget_rewind, time);
+ if (isLock()) return;
+ showState(time > 0 ? R.drawable.ic_widget_forward : R.drawable.ic_widget_rewind, time);
+ hideProgress();
}
@Override
@@ -899,24 +901,24 @@ public class DetailActivity extends BaseActivity implements CustomKeyDownVod.Lis
}
@Override
+ public void onDoubleTap() {
+ if (mPlayers.isPlaying()) onPause(true);
+ else onPlay();
+ hideControl();
+ }
+
public void onDoubleTapLeft() {
mPlayers.seekTo(-15 * 1000);
showState(R.drawable.ic_widget_rewind);
App.post(mR4, 500);
+ hideProgress();
}
- @Override
public void onDoubleTapRight() {
mPlayers.seekTo(15 * 1000);
showState(R.drawable.ic_widget_forward);
App.post(mR4, 500);
- }
-
- @Override
- public void onDoubleTapCenter() {
- if (mPlayers.isPlaying()) onPause(true);
- else onPlay();
- hideControl();
+ hideProgress();
}
@Override
diff --git a/app/src/mobile/java/com/fongmi/android/tv/ui/custom/CustomKeyDownVod.java b/app/src/mobile/java/com/fongmi/android/tv/ui/custom/CustomKeyDownVod.java
index 54726e83c..968ff3a7f 100644
--- a/app/src/mobile/java/com/fongmi/android/tv/ui/custom/CustomKeyDownVod.java
+++ b/app/src/mobile/java/com/fongmi/android/tv/ui/custom/CustomKeyDownVod.java
@@ -6,12 +6,15 @@ import android.view.MotionEvent;
import androidx.annotation.NonNull;
+import com.fongmi.android.tv.App;
+import com.fongmi.android.tv.Constant;
import com.fongmi.android.tv.utils.ResUtil;
public class CustomKeyDownVod extends GestureDetector.SimpleOnGestureListener {
private final GestureDetector detector;
private final Listener listener;
+ private Runnable runnable;
private boolean touch;
private boolean seek;
private int time;
@@ -26,7 +29,7 @@ public class CustomKeyDownVod extends GestureDetector.SimpleOnGestureListener {
}
public boolean onTouchEvent(MotionEvent e) {
- if (seek && e.getAction() == MotionEvent.ACTION_UP) listener.onSeekTo(time);
+ if (seek && e.getAction() == MotionEvent.ACTION_UP) seekDone();
return detector.onTouchEvent(e);
}
@@ -39,6 +42,16 @@ public class CustomKeyDownVod extends GestureDetector.SimpleOnGestureListener {
return true;
}
+ @Override
+ public void onLongPress(@NonNull MotionEvent e) {
+ int base = ResUtil.getScreenWidthPx() / 3;
+ boolean left = e.getX() > 0 && e.getX() < base;
+ boolean right = e.getX() > base * 2 && e.getX() < base * 3;
+ if (left) App.post(runnable = this::subTime, 0);
+ if (right) App.post(runnable = this::addTime, 0);
+ seek = left || right;
+ }
+
@Override
public boolean onScroll(@NonNull MotionEvent e1, @NonNull MotionEvent e2, float distanceX, float distanceY) {
int deltaX = (int) (e2.getX() - e1.getX());
@@ -54,13 +67,7 @@ public class CustomKeyDownVod extends GestureDetector.SimpleOnGestureListener {
@Override
public boolean onDoubleTap(@NonNull MotionEvent e) {
- int base = ResUtil.getScreenWidthPx() / 3;
- boolean left = e.getX() > 0 && e.getX() < base;
- boolean center = e.getX() > base && e.getX() < base * 2;
- boolean right = e.getX() > base * 2 && e.getX() < base * 3;
- if (left) listener.onDoubleTapLeft();
- if (right) listener.onDoubleTapRight();
- if (center) listener.onDoubleTapCenter();
+ listener.onDoubleTap();
return true;
}
@@ -70,6 +77,31 @@ public class CustomKeyDownVod extends GestureDetector.SimpleOnGestureListener {
return true;
}
+ private void addTime() {
+ listener.onSeeking(time = time + Constant.INTERVAL_SEEK);
+ App.post(runnable, getDelay());
+ }
+
+ private void subTime() {
+ listener.onSeeking(time = time - Constant.INTERVAL_SEEK);
+ App.post(runnable, getDelay());
+ }
+
+ private int getDelay() {
+ int count = Math.abs(time) / Constant.INTERVAL_SEEK;
+ if (count < 5) return 500;
+ else if (count < 10) return 250;
+ else if (count < 15) return 100;
+ else return 50;
+ }
+
+ private void seekDone() {
+ App.removeCallbacks(runnable);
+ listener.onSeekTo(time);
+ seek = false;
+ time = 0;
+ }
+
public interface Listener {
void onSeeking(int time);
@@ -78,10 +110,6 @@ public class CustomKeyDownVod extends GestureDetector.SimpleOnGestureListener {
void onSingleTap();
- void onDoubleTapLeft();
-
- void onDoubleTapRight();
-
- void onDoubleTapCenter();
+ void onDoubleTap();
}
}
\ No newline at end of file
diff --git a/app/src/mobile/res/drawable/shape_widget.xml b/app/src/mobile/res/drawable/shape_widget.xml
new file mode 100644
index 000000000..1533e5dcb
--- /dev/null
+++ b/app/src/mobile/res/drawable/shape_widget.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/mobile/res/layout/view_widget_vod.xml b/app/src/mobile/res/layout/view_widget_vod.xml
index 0587bfa1a..e0789afb6 100644
--- a/app/src/mobile/res/layout/view_widget_vod.xml
+++ b/app/src/mobile/res/layout/view_widget_vod.xml
@@ -59,8 +59,8 @@
android:id="@+id/state"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="end|top"
- android:layout_margin="16dp"
+ android:layout_gravity="center"
+ android:background="@drawable/shape_widget"
android:gravity="center"
android:orientation="horizontal"
android:visibility="gone"
@@ -70,7 +70,7 @@
android:id="@+id/action"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginEnd="4dp"
+ android:layout_marginEnd="8dp"
android:src="@drawable/ic_widget_rewind" />