Skip to content

Commit a5be0f7

Browse files
imhappidsn5ft
authored andcommitted
[Lists] Fix issue where the first drag may have not clamped to the end properly since originalContentLeft is 0
PiperOrigin-RevId: 820474927
1 parent ce092fa commit a5be0f7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/java/com/google/android/material/listitem/ListItemLayout.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ private void ensureContentViewIfRevealLayoutExists() {
160160
"Only one SwipeableListItem view is allowed in a ListItemLayout.");
161161
}
162162
contentView = getChildAt(i);
163+
originalContentViewLeft = contentView.getLeft();
163164
}
164165
}
165166
}
@@ -215,6 +216,7 @@ private boolean ensureSwipeToRevealSetupIfNeeded() {
215216
new ViewDragHelper.Callback() {
216217
@Override
217218
public boolean tryCaptureView(@NonNull View child, int pointerId) {
219+
ensureContentViewIfRevealLayoutExists();
218220
if (swipeToRevealLayout != null && contentView != null) {
219221
viewDragHelper.captureChildView(contentView, pointerId);
220222
}
@@ -257,7 +259,8 @@ public void onViewPositionChanged(
257259
- contentViewLp.rightMargin // only end margin matters here
258260
- revealViewLp.leftMargin
259261
- revealViewLp.rightMargin);
260-
((RevealableListItem) swipeToRevealLayout).setRevealedWidth(revealViewDesiredWidth);
262+
((RevealableListItem) swipeToRevealLayout)
263+
.setRevealedWidth(revealViewDesiredWidth);
261264
}
262265
});
263266

0 commit comments

Comments
 (0)