在我的应用程序中,我在Fresco上使用GestureDetector来获取onSingleTapConfirmed。但它没有被称为。在日志中,我只获得onTouch
。这是来自我的片段的代码,它填充了我的ViewPager。
DraweeView draweeImageView = (DraweeView) rootView.findViewById(R.id.drawee_view);
final GestureDetector gestureDetector = new GestureDetector(App.getContext(), new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
((MediaViewActivity) getActivity()).onSingleTapConfirmed();
Log.d(TAG, "onSingleTapConfirmed");
return super.onSingleTapConfirmed(e);
}
});
DraweeController controller = Fresco.newDraweeControllerBuilder()
.setImageRequest(ImageRequest.fromUri(ThumbUrl)
.build();
draweeImageView.setController(controller);
draweeImageView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
Log.d(TAG, "onTouch");
return gestureDetector.onTouchEvent(motionEvent);
}
});
答案 0 :(得分:0)
通过在GestureDetector中返回onDown
覆盖true
解决了我的问题。
final GestureDetector gestureDetector = new GestureDetector(App.getContext(), new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
((MediaViewActivity) getActivity()).onSingleTapConfirmed();
return super.onSingleTapConfirmed(e);
}
@Override
public boolean onDown(MotionEvent e) {
return true;
}
});