2019-06-19 20:01:49 +02:00
|
|
|
package lu.circl.mispbump.customViews;
|
2019-06-17 09:49:09 +02:00
|
|
|
|
2019-07-24 12:16:51 +02:00
|
|
|
|
2019-06-19 20:01:49 +02:00
|
|
|
import android.content.Context;
|
|
|
|
import android.util.AttributeSet;
|
2019-06-17 09:49:09 +02:00
|
|
|
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>
|
|
|
|
*/
|
2019-06-17 09:49:09 +02:00
|
|
|
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);
|
|
|
|
}
|
2019-06-17 09:49:09 +02:00
|
|
|
|
|
|
|
@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
|
|
|
|
2019-06-17 09:49:09 +02:00
|
|
|
public void setSwipeable(boolean swipeable) {
|
|
|
|
this.swipeable = swipeable;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isSwipeable() {
|
|
|
|
return swipeable;
|
|
|
|
}
|
|
|
|
}
|