From 2d1c5985be7b29a8ae98582620533925eb415d18 Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 17 Nov 2016 19:00:19 +0100 Subject: [PATCH] convert MyViewPager to kotlin --- .../calendar/views/MyViewPager.java | 38 ------------------- .../calendar/views/MyViewPager.kt | 36 ++++++++++++++++++ 2 files changed, 36 insertions(+), 38 deletions(-) delete mode 100644 app/src/main/java/com/simplemobiletools/calendar/views/MyViewPager.java create mode 100644 app/src/main/kotlin/com/simplemobiletools/calendar/views/MyViewPager.kt diff --git a/app/src/main/java/com/simplemobiletools/calendar/views/MyViewPager.java b/app/src/main/java/com/simplemobiletools/calendar/views/MyViewPager.java deleted file mode 100644 index 3918f5253..000000000 --- a/app/src/main/java/com/simplemobiletools/calendar/views/MyViewPager.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.simplemobiletools.calendar.views; - -import android.content.Context; -import android.support.v4.view.ViewPager; -import android.util.AttributeSet; -import android.view.MotionEvent; - -// we are creating a custom viewpager just to fix "pointerIndex out of range" exception at onInterceptTouchEvent -public class MyViewPager extends ViewPager { - - public MyViewPager(Context context) { - super(context); - } - - public MyViewPager(Context context, AttributeSet attrs) { - super(context, attrs); - } - - @Override - public boolean onInterceptTouchEvent(MotionEvent ev) { - try { - return super.onInterceptTouchEvent(ev); - } catch (IllegalArgumentException ex) { - ex.printStackTrace(); - } - return false; - } - - @Override - public boolean onTouchEvent(MotionEvent ev) { - try { - return super.onTouchEvent(ev); - } catch (IllegalArgumentException ex) { - ex.printStackTrace(); - } - return false; - } -} diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/views/MyViewPager.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/views/MyViewPager.kt new file mode 100644 index 000000000..741ccedf6 --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/views/MyViewPager.kt @@ -0,0 +1,36 @@ +package com.simplemobiletools.calendar.views + +import android.content.Context +import android.support.v4.view.ViewPager +import android.util.AttributeSet +import android.view.MotionEvent + +// we are creating a custom viewpager just to fix "pointerIndex out of range" exception at onInterceptTouchEvent +class MyViewPager : ViewPager { + + constructor(context: Context) : super(context) { + } + + constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { + } + + override fun onInterceptTouchEvent(ev: MotionEvent): Boolean { + try { + return super.onInterceptTouchEvent(ev) + } catch (ex: IllegalArgumentException) { + ex.printStackTrace() + } + + return false + } + + override fun onTouchEvent(ev: MotionEvent): Boolean { + try { + return super.onTouchEvent(ev) + } catch (ex: IllegalArgumentException) { + ex.printStackTrace() + } + + return false + } +}