-
-
Save hyuni/268d69cd8bae4c35e954 to your computer and use it in GitHub Desktop.
A fix for Daniel Olshansky's DevByte example "ListView Expanding Cells Animation"- collapsing part, when last item is visible from top
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int offset = computeVerticalScrollOffset(); | |
int range = computeVerticalScrollRange(); | |
int extent = computeVerticalScrollExtent(); | |
int leftoverExtent = range - offset - extent; | |
// In Case Items does not fill the screen (More accurate, if last | |
// Item is reachable from offset 0 | |
boolean isfillingScreen = getBottom() - height +yDelta< getHeight(); | |
// added line | |
if (!isfillingScreen && leftoverExtent < 0) | |
leftoverExtent *= -1; | |
boolean isCollapsingBelowBottom = (yTranslateBottom > leftoverExtent); | |
boolean isCellCompletelyDisappearing = bottom - yTranslateBottom < 0; | |
boolean isExtentBeyondRange = leftoverExtent < 0; // fix | |
// added line | |
if (!isfillingScreen) | |
isCollapsingBelowBottom = (yTranslateTop + yTranslateBottom > range) ? false | |
: isCollapsingBelowBottom; | |
if (isCollapsingBelowBottom && !isExtentBeyondRange) { | |
yTranslateTop = yTranslateBottom - leftoverExtent; | |
// added line - problematic- last item jumps | |
if (!isfillingScreen) | |
yTranslateTop = yTranslateTop < range ? 0 : yTranslateTop; | |
yTranslateBottom = yDelta - yTranslateTop; | |
} else if (isCellCompletelyDisappearing && !isExtentBeyondRange) { | |
yTranslateBottom = bottom; | |
yTranslateTop = yDelta - yTranslateBottom; | |
} | |
//added line- jumping when last item is seen from offset 0 | |
if(offset==0 && !isfillingScreen) { | |
yTranslateBottom+=yTranslateTop; | |
yTranslateTop = 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment