Skip to content

Commit a96cfcb

Browse files
authored
Merge pull request #830 from WurstMitDurst/setPanelStateBugfix
Fixed Bug: SlidingUpPanelLayout ignores setPanelState()
2 parents 23cbb33 + 4f2f5ee commit a96cfcb

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

library/src/main/java/com/sothree/slidinguppanel/SlidingUpPanelLayout.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import android.support.v4.view.MotionEventCompat;
1414
import android.support.v4.view.ViewCompat;
1515
import android.util.AttributeSet;
16+
import android.util.Log;
1617
import android.view.Gravity;
1718
import android.view.MotionEvent;
1819
import android.view.View;
@@ -1096,6 +1097,13 @@ public PanelState getPanelState() {
10961097
* @param state - new panel state
10971098
*/
10981099
public void setPanelState(PanelState state) {
1100+
1101+
// Abort any running animation, to allow state change
1102+
if(mDragHelper.getViewDragState() == ViewDragHelper.STATE_SETTLING){
1103+
Log.d(TAG, "View is settling. Aborting animation.");
1104+
mDragHelper.abort();
1105+
}
1106+
10991107
if (state == null || state == PanelState.DRAGGING) {
11001108
throw new IllegalArgumentException("Panel state cannot be null or DRAGGING.");
11011109
}
@@ -1226,6 +1234,7 @@ boolean smoothSlideTo(float slideOffset, int velocity) {
12261234
}
12271235

12281236
int panelTop = computePanelTopPosition(slideOffset);
1237+
12291238
if (mDragHelper.smoothSlideViewTo(mSlideableView, mSlideableView.getLeft(), panelTop)) {
12301239
setAllChildrenVisible();
12311240
ViewCompat.postInvalidateOnAnimation(this);

0 commit comments

Comments
 (0)