Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fixed Bug: SlidingUpPanelLayout ignores setPanelState(), as long as a…
…nimated settling is in progress.
  • Loading branch information
Tobias Royé committed May 9, 2017
commit 4f2f5ee31a785853dc5a9ecc3847eaa54e54b86a
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import android.support.v4.view.MotionEventCompat;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
import android.util.Log;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
Expand Down Expand Up @@ -1089,6 +1090,13 @@ public PanelState getPanelState() {
* @param state - new panel state
*/
public void setPanelState(PanelState state) {

// Abort any running animation, to allow state change
if(mDragHelper.getViewDragState() == ViewDragHelper.STATE_SETTLING){
Log.d(TAG, "View is settling. Aborting animation.");
mDragHelper.abort();
}

if (state == null || state == PanelState.DRAGGING) {
throw new IllegalArgumentException("Panel state cannot be null or DRAGGING.");
}
Expand Down Expand Up @@ -1219,6 +1227,7 @@ boolean smoothSlideTo(float slideOffset, int velocity) {
}

int panelTop = computePanelTopPosition(slideOffset);

if (mDragHelper.smoothSlideViewTo(mSlideableView, mSlideableView.getLeft(), panelTop)) {
setAllChildrenVisible();
ViewCompat.postInvalidateOnAnimation(this);
Expand Down