use of android.support.v4.view.ViewPropertyAnimatorUpdateListener in project Android-MaterialRefreshLayout by android-cjj.
the class MaterialRefreshLayout method createAnimatorTranslationY.
// public void setProgressValue(int progressValue) {
// this.progressValue = progressValue;
// mMaterialHeaderView.setProgressValue(progressValue);
// }
public void createAnimatorTranslationY(final View v, final float h, final FrameLayout fl) {
ViewPropertyAnimatorCompat viewPropertyAnimatorCompat = ViewCompat.animate(v);
viewPropertyAnimatorCompat.setDuration(250);
viewPropertyAnimatorCompat.setInterpolator(new DecelerateInterpolator());
viewPropertyAnimatorCompat.translationY(h);
viewPropertyAnimatorCompat.start();
viewPropertyAnimatorCompat.setUpdateListener(new ViewPropertyAnimatorUpdateListener() {
@Override
public void onAnimationUpdate(View view) {
float height = ViewCompat.getTranslationY(v);
fl.getLayoutParams().height = (int) height;
fl.requestLayout();
}
});
}
use of android.support.v4.view.ViewPropertyAnimatorUpdateListener in project floatingsearchview by arimorty.
the class FloatingSearchView method updateSuggestionsSectionHeight.
private void updateSuggestionsSectionHeight(List<? extends SearchSuggestion> newSearchSuggestions, boolean withAnim) {
final int cardTopBottomShadowPadding = Util.dpToPx(CARD_VIEW_CORNERS_AND_TOP_BOTTOM_SHADOW_HEIGHT);
final int cardRadiusSize = Util.dpToPx(CARD_VIEW_TOP_BOTTOM_SHADOW_HEIGHT);
int visibleSuggestionHeight = calculateSuggestionItemsHeight(newSearchSuggestions, mSuggestionListContainer.getHeight());
int diff = mSuggestionListContainer.getHeight() - visibleSuggestionHeight;
int addedTranslationYForShadowOffsets = (diff <= cardTopBottomShadowPadding) ? -(cardTopBottomShadowPadding - diff) : diff < (mSuggestionListContainer.getHeight() - cardTopBottomShadowPadding) ? cardRadiusSize : 0;
final float newTranslationY = -mSuggestionListContainer.getHeight() + visibleSuggestionHeight + addedTranslationYForShadowOffsets;
final boolean animateAtEnd = newTranslationY >= mSuggestionListContainer.getTranslationY();
//todo go over
final float fullyInvisibleTranslationY = -mSuggestionListContainer.getHeight() + cardRadiusSize;
ViewCompat.animate(mSuggestionListContainer).cancel();
if (withAnim) {
ViewCompat.animate(mSuggestionListContainer).setInterpolator(SUGGEST_ITEM_ADD_ANIM_INTERPOLATOR).setDuration(mSuggestionSectionAnimDuration).translationY(newTranslationY).setUpdateListener(new ViewPropertyAnimatorUpdateListener() {
@Override
public void onAnimationUpdate(View view) {
if (mOnSuggestionsListHeightChanged != null) {
float newSuggestionsHeight = Math.abs(view.getTranslationY() - fullyInvisibleTranslationY);
mOnSuggestionsListHeightChanged.onSuggestionsListHeightChanged(newSuggestionsHeight);
}
}
}).setListener(new ViewPropertyAnimatorListenerAdapter() {
@Override
public void onAnimationCancel(View view) {
mSuggestionListContainer.setTranslationY(newTranslationY);
}
@Override
public void onAnimationStart(View view) {
if (!animateAtEnd) {
mSuggestionsList.smoothScrollToPosition(0);
}
}
@Override
public void onAnimationEnd(View view) {
if (animateAtEnd) {
int lastPos = mSuggestionsList.getAdapter().getItemCount() - 1;
if (lastPos > -1) {
mSuggestionsList.smoothScrollToPosition(lastPos);
}
}
}
}).start();
} else {
mSuggestionListContainer.setTranslationY(newTranslationY);
if (mOnSuggestionsListHeightChanged != null) {
float newSuggestionsHeight = Math.abs(mSuggestionListContainer.getTranslationY() - fullyInvisibleTranslationY);
mOnSuggestionsListHeightChanged.onSuggestionsListHeightChanged(newSuggestionsHeight);
}
}
}
use of android.support.v4.view.ViewPropertyAnimatorUpdateListener in project NavigationTabBar by Devlight.
the class NavigationTabBarBehavior method ensureOrCancelAnimator.
// Manage animation for Android >= KITKAT
private void ensureOrCancelAnimator(final NavigationTabBar child, boolean withAnimation) {
if (mTranslationAnimator == null) {
mTranslationAnimator = ViewCompat.animate(child);
mTranslationAnimator.setDuration(withAnimation ? ANIMATION_DURATION : 0);
mTranslationAnimator.setUpdateListener(new ViewPropertyAnimatorUpdateListener() {
@Override
public void onAnimationUpdate(View view) {
// Animate snack bar
if (mSnackBarLayout != null && mSnackBarLayout.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
mTargetOffset = child.getBarHeight() - view.getTranslationY();
final ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) mSnackBarLayout.getLayoutParams();
p.setMargins(p.leftMargin, p.topMargin, p.rightMargin, (int) mTargetOffset);
mSnackBarLayout.requestLayout();
}
// Animate Floating Action Button
if (mFloatingActionButton != null && mFloatingActionButton.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
final ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) mFloatingActionButton.getLayoutParams();
mFabTargetOffset = mFabDefaultBottomMargin - view.getTranslationY();
p.setMargins(p.leftMargin, p.topMargin, p.rightMargin, (int) mFabTargetOffset);
mFloatingActionButton.requestLayout();
}
}
});
mTranslationAnimator.setInterpolator(INTERPOLATOR);
} else {
mTranslationAnimator.setDuration(withAnimation ? ANIMATION_DURATION : 0);
mTranslationAnimator.cancel();
}
}
use of android.support.v4.view.ViewPropertyAnimatorUpdateListener in project ahbottomnavigation by aurelhubert.
the class AHBottomNavigationBehavior method ensureOrCancelAnimator.
/**
* Manage animation for Android >= KITKAT
*
* @param child
*/
private void ensureOrCancelAnimator(V child, boolean withAnimation) {
if (translationAnimator == null) {
translationAnimator = ViewCompat.animate(child);
translationAnimator.setDuration(withAnimation ? ANIM_DURATION : 0);
translationAnimator.setUpdateListener(new ViewPropertyAnimatorUpdateListener() {
@Override
public void onAnimationUpdate(View view) {
if (navigationPositionListener != null) {
navigationPositionListener.onPositionChange((int) (view.getMeasuredHeight() - view.getTranslationY() + snackBarY));
}
}
});
translationAnimator.setInterpolator(INTERPOLATOR);
} else {
translationAnimator.setDuration(withAnimation ? ANIM_DURATION : 0);
translationAnimator.cancel();
}
}
Aggregations