Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve accuracy of danmaku click #307

Open
wants to merge 1 commit into
base: master
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
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package master.flame.danmaku.ui.widget;

import android.graphics.RectF;
import android.nfc.Tag;
import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
Expand All @@ -18,6 +16,7 @@
public class DanmakuTouchHelper {
private final GestureDetector mTouchDelegate;
private IDanmakuView danmakuView;
private IDanmakus clickDanmakus;
private RectF mDanmakuBounds;
private float mXOff;
private float mYOff;
Expand All @@ -38,7 +37,6 @@ public boolean onDown(MotionEvent event) {

@Override
public boolean onSingleTapConfirmed(MotionEvent event) {
IDanmakus clickDanmakus = touchHitDanmaku(event.getX(), event.getY());
boolean isEventConsumed = false;
if (null != clickDanmakus && !clickDanmakus.isEmpty()) {
isEventConsumed = performDanmakuClick(clickDanmakus, false);
Expand All @@ -57,7 +55,6 @@ public void onLongPress(MotionEvent event) {
}
mXOff = danmakuView.getXOff();
mYOff = danmakuView.getYOff();
IDanmakus clickDanmakus = touchHitDanmaku(event.getX(), event.getY());
if (null != clickDanmakus && !clickDanmakus.isEmpty()) {
performDanmakuClick(clickDanmakus, true);
}
Expand All @@ -75,6 +72,9 @@ public static synchronized DanmakuTouchHelper instance(IDanmakuView danmakuView)
}

public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
clickDanmakus = touchHitDanmaku(event.getX(), event.getY());
}
return mTouchDelegate.onTouchEvent(event);
}

Expand Down