Skip to content
This repository has been archived by the owner on Aug 9, 2022. It is now read-only.

1.添加简单小窗口跟随手指移动 #2190

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion jiaozivideoplayer/src/main/java/cn/jzvd/JzvdStd.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.content.IntentFilter;
import android.graphics.Color;
import android.util.AttributeSet;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
Expand Down Expand Up @@ -225,10 +226,25 @@ public void onStateAutoComplete() {
public boolean onTouch(View v, MotionEvent event) {
int id = v.getId();
if (id == R.id.surface_container) {
float x = event.getX();
float y = event.getY();
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
break;
case MotionEvent.ACTION_MOVE:
if (JzvdMgr.getCurrentJzvd() != null &&
JzvdMgr.getCurrentJzvd().currentScreen == Jzvd.SCREEN_WINDOW_TINY) {
Log.e("拖动", "x:" + event.getRawX() + ",y:" + event.getRawY());
// 计算偏移量
int offsetX = (int) (event.getX() - mDownX);
int offsetY = (int) (event.getY() - mDownY);
// 在当前left、top、right、bottom的基础上加上偏移量

layout(getLeft() + offsetX,
getTop() + offsetY,
getRight() + offsetX,
getBottom() + offsetY);
}
break;
case MotionEvent.ACTION_UP:
startDismissControlViewTimer();
Expand All @@ -237,7 +253,10 @@ public boolean onTouch(View v, MotionEvent event) {
int progress = (int) (mSeekTimePosition * 100 / (duration == 0 ? 1 : duration));
bottomProgressBar.setProgress(progress);
}
if (!mChangePosition && !mChangeVolume) {
float offsetX = Math.abs(x - mDownX);
float offsetY = Math.abs(y - mDownY);
Log.e(TAG, "onTouch: offsetX->" + offsetX + ",offsetY->" + offsetY);
if (!mChangePosition && !mChangeVolume && offsetX <= 0 && offsetY <= 0) {
onEvent(JZUserActionStd.ON_CLICK_BLANK);
onClickUiToggle();
}
Expand Down