Example usage for android.widget ScrollView requestDisallowInterceptTouchEvent

List of usage examples for android.widget ScrollView requestDisallowInterceptTouchEvent

Introduction

In this page you can find the example usage for android.widget ScrollView requestDisallowInterceptTouchEvent.

Prototype

@Override
    public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) 

Source Link

Usage

From source file:org.wheelmap.android.fragment.POIDetailFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = null;/*from  w  ww.j  ava 2  s.  com*/
    if (!UtilsMisc.isTablet(getActivity().getApplicationContext())) {

        v = inflater.inflate(R.layout.fragment_detail, container, false);
    }

    if (UtilsMisc.isTablet(getActivity().getApplicationContext())) {
        v = inflater.inflate(R.layout.fragment_detail_tablet, container, false);
    }

    initViews(v);

    ScrollView scrollView = (ScrollView) v.findViewById(R.id.scrollView);
    scrollView.requestDisallowInterceptTouchEvent(true);

    View closeButton = v.findViewById(R.id.titlebar_backbutton);

    closeButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mListener.dismissDetailView();
        }
    });

    mShowMenu = false;
    closeButton.setVisibility(View.GONE);

    if (!UtilsMisc.isTablet(getActivity().getApplicationContext())) {
        closeButton.setVisibility(View.GONE);
    }

    buttonTangoMeasure.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            startTangoMeasurement();
        }
    });

    buttonPhoto.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            startPickPhotoDialog();
        }
    });

    buttonEdit.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mListener != null) {
                mListener.onEdit(poiId, FOCUS_TO_NOTHING);
            }
        }
    });

    buttonRoute.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {

            startActivity(Intent.createChooser(intentSaved.get(ACTION_PROVIDER_DIRECTIONS),
                    getString(R.string.menu_directions)));
            return;
        }
    });

    buttonShare.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {

            startActivity(Intent.createChooser(intentSaved.get(ACTION_PROVIDER_SHARE),
                    getString(R.string.menu_share)));
            return;
        }
    });

    layoutComment.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mListener != null) {
                mListener.onEdit(poiId, FOCUS_TO_COMMENT);
            }
        }
    });
    layoutAdress.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mListener != null) {
                mListener.onEdit(poiId, FOCUS_TO_ADRESS);
            }
        }
    });

    layoutPhoto.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            startPickPhotoDialog();

        }
    });

    if (!UtilsMisc.isTablet(getActivity().getApplication())) {

        mMapView = (org.osmdroid.views.MapView) v.findViewById(R.id.map_detail);
        mBtnExpand = (ImageButton) v.findViewById(R.id.map_btn_expand);
        mBtnLocate = (ImageButton) v.findViewById(R.id.center_poi);

        mMapView.setTileSource(mMapBoxTileSource);
        mMapView.setBuiltInZoomControls(false);
        mMapView.setMultiTouchControls(true);
        setHardwareAccelerationOff();

        mMapView.setMapListener(this);

        mPoisItemizedOverlay = new POIsCursorOsmdroidOverlay(getActivity(), this);

        mMapView.getOverlays().add(mPoisItemizedOverlay);

        MyLocationNewOverlayFixed a = new MyLocationNewOverlayFixed(mMyLocationProvider, mMapView);
        a.disableFollowLocation();
        a.enableMyLocation();
        mMapView.getOverlays().add(a);

        mMapController = mMapView.getController();
        mMapController.setZoom(18);
        //mMapController.setCenter(new org.osmdroid.mapsforge.wrapper.GeoPoint(new GeoPoint(mCrrLatitude, mCrrLongitude)));

        mBtnExpand.setOnTouchListener(new PressSelector());
        mBtnExpand.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                if (mapFocus) {
                    mBtnExpand.setBackgroundDrawable(getResources().getDrawable(R.drawable.ic_detail_expand));
                    mapFocus = false;

                    HeightAnimation heightAnim = new HeightAnimation(layoutMapDetail,
                            layoutMapDetail.getHeight(), mHeightLayout);
                    heightAnim.setDuration(1000);
                    layoutMapDetail.startAnimation(heightAnim);

                } else if (!mapFocus) {
                    mBtnExpand.setBackgroundDrawable(getResources().getDrawable(R.drawable.ic_detail_collapse));
                    mapFocus = true;
                    if (mHeightLayout <= 0) {
                        mHeightLayout = layoutMapDetail.getHeight();
                    }
                    HeightAnimation heightAnim = new HeightAnimation(layoutMapDetail, mHeightLayout,
                            content.getHeight());
                    heightAnim.setDuration(1000);
                    layoutMapDetail.startAnimation(heightAnim);
                }
            }
        });

        mBtnLocate.setOnTouchListener(new PressSelector());
        mBtnLocate.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                org.osmdroid.util.GeoPoint geoPoint = new org.osmdroid.util.GeoPoint(mCrrLatitude,
                        mCrrLongitude);

                if (mMapView != null) {
                    centerMap(geoPoint, true, true);
                }
            }
        });

        v.findViewById(R.id.map_btn_locate).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mMapView != null && mMyLocationProvider.getLastKnownLocation() != null) {
                    Location location = mMyLocationProvider.getLastKnownLocation();
                    org.osmdroid.util.GeoPoint geoPoint = new org.osmdroid.util.GeoPoint(location.getLatitude(),
                            location.getLongitude());
                    centerMap(geoPoint, true, true);
                }
            }
        });
    }
    content = v;
    return v;
}

From source file:com.orbar.pxdemo.ImageView.FivePXImageFragment.java

private void setupMap(String latitude, String longitude, String imageName, String imageDescription) {

    map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();

    // get references to transparent image and ScrollView
    final ScrollView mainScrollView = (ScrollView) rootView.findViewById(R.id.image_details_scrollView);
    ImageView transparentImageView = (ImageView) rootView.findViewById(R.id.transparent_image);

    // allows scrolling on the map independently of the scrollView
    transparentImageView.setOnTouchListener(new View.OnTouchListener() {

        @Override/*from w  w  w.j  ava  2  s. c  o m*/
        public boolean onTouch(View v, MotionEvent event) {
            int action = event.getAction();

            switch (action) {
            case MotionEvent.ACTION_DOWN:
                // Disallow ScrollView to intercept touch events.
                mainScrollView.requestDisallowInterceptTouchEvent(true);
                // Disable touch on transparent view
                return false;

            case MotionEvent.ACTION_UP:
                // Allow ScrollView to intercept touch events.
                mainScrollView.requestDisallowInterceptTouchEvent(false);
                return true;

            case MotionEvent.ACTION_MOVE:
                mainScrollView.requestDisallowInterceptTouchEvent(true);
                return false;

            default:
                return true;
            }
        }

    });

    LatLng imageLocation = new LatLng(Double.valueOf(latitude), Double.valueOf(longitude));
    LatLng mapCenter = new LatLng(Double.valueOf(latitude) - 1, Double.valueOf(longitude));

    map.addMarker(new MarkerOptions().position(imageLocation).snippet(imageDescription).title(imageName));

    // Move the camera instantly to position with a zoom of 6.
    map.moveCamera(CameraUpdateFactory.newLatLngZoom(mapCenter, 6));

}