Open mtyy opened 8 years ago
I also got this error while scrolling a listview. I set a timer to auto-expand the panel after a fixed time. But when the timer end while I'm scrolling the listview, the Panel is not expanded and gets the same state as you showed. @mtyy can you show me your temporality solution?
Thank in advance.
I had the same issue because I was disabling the user from interacting with the panel and setting the state programmatically. If the user clicked anywhere on the root layout while the panel was moving, the panel would get stuck and stop expanding or collapsing.
I was able to use @mtyy's suggestion and override the dispatchTouchEvent(MotionEvent ev)
and only returning the super if the panel state was dragging.
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
return this.getPanelState() == PanelState.DRAGGING || super.dispatchTouchEvent(ev);
}
In my case, when drawer is collapsing or expanding, a tap on the screen will stop the animation. My workaround, put a view (visibility:gone) above the sliding layout and apply the following actions:
`slidingLayout.addPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() { @Override public void onPanelSlide(View panel, float slideOffset) {
}
@Override
public void onPanelStateChanged(View panel, SlidingUpPanelLayout.PanelState prevState, SlidingUpPanelLayout.PanelState newState) {
if( ( prevState == SlidingUpPanelLayout.PanelState.COLLAPSED || prevState == SlidingUpPanelLayout.PanelState.EXPANDED ) && newState == SlidingUpPanelLayout.PanelState.DRAGGING ) {
clickInterceptor.setVisibility(View.VISIBLE);
}
else if( prevState == SlidingUpPanelLayout.PanelState.DRAGGING && ( newState == SlidingUpPanelLayout.PanelState.COLLAPSED || newState == SlidingUpPanelLayout.PanelState.EXPANDED ) ) {
clickInterceptor.setVisibility(View.GONE);
}
}
});`
Anyone with a knowledge of a nicer solution - let me know.
We encountered this issue today. I was able to fix it by modifying SlidingUpPanelLayout#dispatchTouchEvent() to only call ViewDragHelper#abort() if ViewDragHelper is in STATE_IDLE.
I've created PR #917 to fix this issue.
I also ran into this issue. This happens when we tap outside the panel (non-panel area) when the panel is sliding. Here, the newState is set to ANCHORED. So we can force it to slide down to COLLAPSED.
This would be natural for the user as he had already tapped outside the panel which means that he wanted to touch the area behind it.
@Override public void onPanelStateChanged(View panel, SlidingUpPanelLayout.PanelState previousState, SlidingUpPanelLayout.PanelState newState) {
switch (newState) {
case EXPANDED:
// your logic
break;
case COLLAPSED:
// your logic
break;
case ANCHORED:
// this is when we tap outside the panel when it is sliding. Here, we will force it to slide down to COLLAPSED.
slidingUpPanelLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
break;
}
}
To escape the aftermath of these unintended touches on objects (buttons, etc) while you are not ready to act on those touches, use setFadeOnClickListener so all the touches are forwarded to our SlidingUpPanelLayout where we will not do anything about these touches.
I want to be 100% sure that panel slides to EXPANDED state no matter what. However when user is in middle of a listview/viewpager scroll and possibly other touch interactions, the panel does not appear.
this is basically what happens:
starts dragging and collapses instantly.
I can work around this with disabling touch events. By overriding
dispatchTouchEvent(MotionEvent ev)
to return true (without calling super) before settingsetPanelState(Panelstate.EXPANDED)
and untilonPanelStateChanged()
newState is EXPANDED.however this seems super hacky and unreliable. Maybe you guys have more ideas how to tackle it?