无法从Android中的Fresco Drawee获得单点贴图确认

时间:2016-03-14 05:00:50

标签: android fresco

在我的应用程序中,我在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);
            }
        });

1 个答案:

答案 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;
            }
        });