Skip to content

Commit

Permalink
Merge pull request #6 from OpenCraft/feature-support-dafault-value
Browse files Browse the repository at this point in the history
initial value
  • Loading branch information
cleberhenriques authored Jan 25, 2018
2 parents 6e37dec + 04c89cf commit a1e8b32
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class MainActivity : AppCompatActivity() {

})

seekbar.post { seekbar.applyInitialAnimation(2500) }
seekbar.post { seekbar.applyInitialValue(1075, false) }
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,26 @@ private int calculatePixelToInteraction() {
return getHeight() / interations;
}

public void applyInitialAnimation(int wantedValue) {
public void applyInitialValue(int wantedValue, boolean withAnimation) {
int pixelNumberToInteractionWithoutMargin = calculatePixelToInteraction();

int interationsToGetWantedValue = wantedValue / step;
float wantedValueY = interationsToGetWantedValue * pixelNumberToInteractionWithoutMargin;
AnimatorSet animSetViews = new AnimatorSet();

if (withAnimation) {
applyAnimation(pixelNumberToInteractionWithoutMargin, wantedValueY);
} else {
calculateValueFromYPosition((int) wantedValueY, pixelNumberToInteractionWithoutMargin);
verticalSeekBarThumb.setY(wantedValueY + thumbMarginTop);
verticalSeekBarBackground.setY(wantedValueY);
addMarginToBackground(wantedValueY);
callOnValueChanged(calculatedValue);
listener.onYPositionChanged(wantedValueY + thumbMarginTop, wantedValueY);
}
}

private void applyAnimation(int pixelNumberToInteractionWithoutMargin, float wantedValueY) {
AnimatorSet animSetViews = new AnimatorSet();
for (int i = (int) verticalSeekBarBackground.getY(); i <= wantedValueY; i++) {
final int finalYPosition = i;
calculateValueFromYPosition(i, pixelNumberToInteractionWithoutMargin);
Expand Down

0 comments on commit a1e8b32

Please sign in to comment.