misp-bump/app/src/main/java/lu/circl/mispbump/customViews/ExtendedBottomSheetBehavior...

64 lines
1.6 KiB
Java
Raw Normal View History

2019-06-19 20:01:49 +02:00
package lu.circl.mispbump.customViews;
2019-07-24 12:16:51 +02:00
2019-06-19 20:01:49 +02:00
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
2019-06-19 20:01:49 +02:00
2019-06-19 17:24:00 +02:00
/**
* Can disable touch input on bottom sheet.
2019-06-19 20:01:49 +02:00
*
2019-06-19 17:24:00 +02:00
* @param <V>
*/
public class ExtendedBottomSheetBehavior<V extends View> extends BottomSheetBehavior<V> {
private boolean swipeable = false;
2019-06-19 20:01:49 +02:00
public ExtendedBottomSheetBehavior() {
super();
}
public ExtendedBottomSheetBehavior(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
}
@Override
public boolean onInterceptTouchEvent(CoordinatorLayout parent, V child, MotionEvent event) {
if (swipeable) {
return super.onInterceptTouchEvent(parent, child, event);
}
return false;
}
@Override
public boolean onTouchEvent(CoordinatorLayout parent, V child, MotionEvent event) {
if (swipeable) {
return super.onTouchEvent(parent, child, event);
}
return false;
}
@Override
public boolean onNestedPreFling(CoordinatorLayout parent, V child, View target, float velocityX, float velocityY) {
if (swipeable) {
return super.onNestedPreFling(parent, child, target, velocityX, velocityY);
}
return false;
}
2019-06-19 17:24:00 +02:00
public void setSwipeable(boolean swipeable) {
this.swipeable = swipeable;
}
public boolean isSwipeable() {
return swipeable;
}
}