Convert DisableableViewPager to Kotlin
This commit is contained in:
parent
4e04f9993d
commit
cd884cd24b
2 changed files with 28 additions and 37 deletions
|
@ -1,37 +0,0 @@
|
|||
package com.wbrawner.simplemarkdown.view;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
public class DisableableViewPager extends ViewPager {
|
||||
private boolean isSwipeLocked = false;
|
||||
|
||||
public DisableableViewPager(@NonNull Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public DisableableViewPager(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
return !isSwipeLocked && super.onInterceptTouchEvent(ev);
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent ev) {
|
||||
return !isSwipeLocked && super.onTouchEvent(ev);
|
||||
}
|
||||
|
||||
public void setSwipeLocked(boolean locked) {
|
||||
this.isSwipeLocked = locked;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package com.wbrawner.simplemarkdown.view
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.MotionEvent
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
|
||||
class DisableableViewPager : ViewPager {
|
||||
private var isSwipeLocked = false
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
|
||||
override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
|
||||
return !isSwipeLocked && super.onInterceptTouchEvent(ev)
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
override fun onTouchEvent(ev: MotionEvent): Boolean {
|
||||
return !isSwipeLocked && super.onTouchEvent(ev)
|
||||
}
|
||||
|
||||
fun setSwipeLocked(locked: Boolean) {
|
||||
this.isSwipeLocked = locked
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue