From de14815a29d8a2b909ef81f210b9671fe51c13c6 Mon Sep 17 00:00:00 2001 From: Tobrun Van Nuland Date: Tue, 25 Jul 2017 09:31:23 +0200 Subject: [PATCH] [android] - use custom viewpager to allow horizontal swiping --- .../activity/fragment/ViewPagerActivity.java | 4 ++-- .../mapboxsdk/testapp/view/MapViewPager.java | 20 +++++++++++++++++++ .../main/res/layout/activity_viewpager.xml | 4 ++-- 3 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/view/MapViewPager.java diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/ViewPagerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/ViewPagerActivity.java index 80258324297..bbdf450505a 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/ViewPagerActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/ViewPagerActivity.java @@ -31,11 +31,11 @@ protected void onCreate(Bundle savedInstanceState) { } } - public static class MapFragmentAdapter extends FragmentPagerAdapter { + static class MapFragmentAdapter extends FragmentPagerAdapter { private static int NUM_ITEMS = 3; - public MapFragmentAdapter(FragmentManager fragmentManager) { + MapFragmentAdapter(FragmentManager fragmentManager) { super(fragmentManager); } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/view/MapViewPager.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/view/MapViewPager.java new file mode 100644 index 00000000000..92c28d7ed42 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/view/MapViewPager.java @@ -0,0 +1,20 @@ +package com.mapbox.mapboxsdk.testapp.view; + +import android.content.Context; +import android.support.v4.view.PagerTabStrip; +import android.support.v4.view.ViewPager; +import android.util.AttributeSet; +import android.view.SurfaceView; +import android.view.View; + +public class MapViewPager extends ViewPager { + + public MapViewPager(Context context, AttributeSet attrs) { + super(context, attrs); + } + + @Override + protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) { + return v instanceof SurfaceView || v instanceof PagerTabStrip || (super.canScroll(v, checkV, dx, x, y)); + } +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_viewpager.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_viewpager.xml index d931cb3643e..3b96277d237 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_viewpager.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_viewpager.xml @@ -4,7 +4,7 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - @@ -17,6 +17,6 @@ android:paddingBottom="4dp" android:paddingTop="4dp"/> - +