Эх сурвалжийг харах

Merge pull request #2890 from nextcloud/fixViewPager

Change to customeViewPager to catch error
Andy Scherzinger 6 жил өмнө
parent
commit
3e66d16498

+ 40 - 0
src/main/java/com/owncloud/android/ui/components/CustomViewPager.java

@@ -0,0 +1,40 @@
+package com.owncloud.android.ui.components;
+
+import android.annotation.SuppressLint;
+import android.content.Context;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.v4.view.ViewPager;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+
+public class CustomViewPager extends ViewPager {
+    public CustomViewPager(@NonNull Context context) {
+        super(context);
+    }
+
+    public CustomViewPager(@NonNull Context context, @Nullable AttributeSet attrs) {
+        super(context, attrs);
+    }
+
+    @SuppressLint("ClickableViewAccessibility")
+    @Override
+    public boolean onTouchEvent(MotionEvent ev) {
+        try {
+            return super.onTouchEvent(ev);
+        } catch (IllegalArgumentException ex) {
+            // no logging as this might flood log and we cannot do anything
+        }
+        return false;
+    }
+
+    @Override
+    public boolean onInterceptTouchEvent(MotionEvent ev) {
+        try {
+            return super.onInterceptTouchEvent(ev);
+        } catch (IllegalArgumentException ex) {
+            // no logging as this might flood log and we cannot do anything
+        }
+        return false;
+    }
+}

+ 2 - 2
src/main/res/layout/preview_image_activity.xml

@@ -23,7 +23,7 @@
     android:layout_height="match_parent"
     android:clickable="true" >
 
-    <android.support.v4.view.ViewPager
+    <com.owncloud.android.ui.components.CustomViewPager
         android:id="@+id/fragmentPager"
 		android:layout_width="match_parent"
 		android:layout_height="match_parent" 
@@ -42,4 +42,4 @@
             <!- - Preview: layout=@layout/preview_image_fragment - ->
     </LinearLayout -->
 
-</android.support.v4.widget.DrawerLayout>
+</android.support.v4.widget.DrawerLayout>