[3.2.0] bus乘客屏,修复地图和视频滑动bug

This commit is contained in:
wangmingjun
2023-05-15 16:21:12 +08:00
parent fac0757836
commit 766b8b5577
4 changed files with 45 additions and 71 deletions

View File

@@ -56,6 +56,9 @@ class MapAndLiveVideoView @JvmOverloads constructor(
}
fun changeToSecondView(){
if (viewPager?.currentItem == 0){
startPosition = 0
}
viewPager?.currentItem = 1
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 555 KiB

After

Width:  |  Height:  |  Size: 354 KiB

View File

@@ -8,12 +8,13 @@
android:layout_marginBottom="@dimen/dp_40"
app:roundLayoutRadius="@dimen/dp_40">
<View
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="@dimen/bus_p_route_info_panel_width"
android:layout_height="match_parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:background="@drawable/bus_p_route_bg"/>
android:src="@drawable/bus_p_route_bg"
android:scaleType="fitXY"/>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="@dimen/bus_p_route_info_panel_width"

View File

@@ -21,19 +21,19 @@ import com.mogo.och.common.module.R;
* desc :
* version: 1.0
*/
public class OCHRoundConstraintLayout extends ConstraintLayout implements GestureDetector.OnGestureListener {
public class OCHRoundConstraintLayout extends ConstraintLayout {
private float roundLayoutRadius = 14f;
private Path roundPath;
private RectF rectF;
// 上次滑动的坐标
private int mLastXIntercept;
private int mLastYIntercept;
// private int mLastXIntercept;
// private int mLastYIntercept;
private IScrollListener mScrollListener;
private GestureDetector mDetector;
// private GestureDetector mDetector;
public OCHRoundConstraintLayout(Context context) {
this(context, null);
@@ -57,7 +57,7 @@ public class OCHRoundConstraintLayout extends ConstraintLayout implements Gestur
setWillNotDraw(false);//如果你继承的是ViewGroup,注意此行,否则draw方法是不会回调的;
roundPath = new Path();
rectF = new RectF();
mDetector = new GestureDetector(getContext(), this);
// mDetector = new GestureDetector(getContext(), this);
}
private void setRoundPath() {
@@ -92,72 +92,42 @@ public class OCHRoundConstraintLayout extends ConstraintLayout implements Gestur
super.draw(canvas);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
boolean intercepted = false;
int x = (int) ev.getX();
int y = (int) ev.getY();
switch (ev.getAction()) {
case MotionEvent.ACTION_MOVE:
int deltaX = x - mLastXIntercept;
int deltaY = y - mLastYIntercept;
if (Math.abs(deltaX) > Math.abs(deltaY)) {
intercepted = true;
}
break;
default:
break;
}
mLastXIntercept = x;
mLastYIntercept = y;
return intercepted;
}
// @Override
// public boolean onDown(MotionEvent e) {
// return true;
// }
//
// @Override
// public void onShowPress(MotionEvent e) {
// }
@Override
public boolean onTouchEvent(MotionEvent event) {
if (mDetector != null) {
return mDetector.onTouchEvent(event);
} else {
return super.onTouchEvent(event);
}
}
// @Override
// public boolean onSingleTapUp(MotionEvent e) {
// return true;
// }
//
// @Override
// public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
// return true;
// }
@Override
public boolean onDown(MotionEvent e) {
return true;
}
@Override
public void onShowPress(MotionEvent e) {
}
@Override
public boolean onSingleTapUp(MotionEvent e) {
return true;
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
return true;
}
@Override
public void onLongPress(MotionEvent e) {
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
if (e2 != null) {
float deltaX = e2.getX() - (e1 != null ? e1.getX() : 0f);
float deltaY = e2.getY() - (e1 != null ? e1.getY() : 0f);
if (Math.abs(deltaX) > Math.abs(deltaY)) {
if (mScrollListener != null) {
mScrollListener.onScroll(velocityX < 0);
}
}
}
return true;
}
// @Override
// public void onLongPress(MotionEvent e) {
// }
//
// @Override
// public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
// if (e2 != null) {
// float deltaX = e2.getX() - (e1 != null ? e1.getX() : 0f);
// float deltaY = e2.getY() - (e1 != null ? e1.getY() : 0f);
// if (Math.abs(deltaX) > Math.abs(deltaY)) {
// if (mScrollListener != null) {
// mScrollListener.onScroll(velocityX < 0);
// }
// }
// }
// return true;
// }
public interface IScrollListener {
void onScroll(boolean isNextPage);