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

Change to customeViewPager to catch error

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
tobiasKaminsky 6 жил өмнө
parent
commit
a9a42c8507

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

@@ -0,0 +1,40 @@
+package com.owncloud.android.ui.components;
+
+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;
+
+import com.owncloud.android.lib.common.utils.Log_OC;
+
+public class CustomViewPager extends ViewPager {
+    public CustomViewPager(@NonNull Context context) {
+        super(context);
+    }
+
+    public CustomViewPager(@NonNull Context context, @Nullable AttributeSet attrs) {
+        super(context, attrs);
+    }
+
+    @Override
+    public boolean onTouchEvent(MotionEvent ev) {
+        try {
+            return super.onTouchEvent(ev);
+        } catch (IllegalArgumentException ex) {
+            Log_OC.e("CustomViewPager", "crash", ex);
+        }
+        return false;
+    }
+
+    @Override
+    public boolean onInterceptTouchEvent(MotionEvent ev) {
+        try {
+            return super.onInterceptTouchEvent(ev);
+        } catch (IllegalArgumentException ex) {
+            Log_OC.e("CustomViewPager", "crash", ex);
+        }
+        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>