Skip to content

Commit 11b3463

Browse files
committed
fix #20
1 parent 4367ce0 commit 11b3463

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

library/src/main/java/github/chenupt/dragtoplayout/DragTopLayout.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,20 @@ private void calculateRatio(float top) {
242242
}
243243
}
244244

245+
private void updatePanelState(){
246+
if (contentTop <= getPaddingTop() + collapseOffset) {
247+
panelState = PanelState.COLLAPSED;
248+
} else if(contentTop >= topView.getHeight()){
249+
panelState = PanelState.EXPANDED;
250+
} else {
251+
panelState = PanelState.SLIDING;
252+
}
253+
254+
if (panelListener != null) {
255+
panelListener.onPanelStateChanged(panelState);
256+
}
257+
}
258+
245259
@Override
246260
protected Parcelable onSaveInstanceState() {
247261

@@ -288,6 +302,7 @@ public void onViewPositionChanged(View changedView, int left, int top, int dx, i
288302
contentTop = top;
289303
requestLayout();
290304
calculateRatio(contentTop);
305+
updatePanelState();
291306
}
292307

293308
@Override
@@ -321,20 +336,6 @@ public void onViewReleased(View releasedChild, float xvel, float yvel) {
321336

322337
@Override
323338
public void onViewDragStateChanged(int state) {
324-
// 1 -> 2 -> 0
325-
if (state == ViewDragHelper.STATE_IDLE) {
326-
// Change the panel state while the drag content view is idle.
327-
if (contentTop > getPaddingTop() + collapseOffset) {
328-
panelState = PanelState.EXPANDED;
329-
} else {
330-
panelState = PanelState.COLLAPSED;
331-
}
332-
} else {
333-
panelState = PanelState.SLIDING;
334-
}
335-
if (panelListener != null) {
336-
panelListener.onPanelStateChanged(panelState);
337-
}
338339
super.onViewDragStateChanged(state);
339340
}
340341
};

0 commit comments

Comments
 (0)