use of android.support.v4.view.ViewPropertyAnimatorListenerAdapter 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.ViewPropertyAnimatorListenerAdapter in project Space-Navigation-View by armcha.
the class BadgeHelper method showBadge.
/**
* Show badge
*
* @param view target badge
* @param badgeItem BadgeItem object
*/
static void showBadge(RelativeLayout view, BadgeItem badgeItem, boolean shouldShowBadgeWithNinePlus) {
Utils.changeViewVisibilityVisible(view);
TextView badgeTextView = (TextView) view.findViewById(R.id.badge_text_view);
if (shouldShowBadgeWithNinePlus)
badgeTextView.setText(badgeItem.getBadgeText());
else
badgeTextView.setText(badgeItem.getFullBadgeText());
view.setScaleX(0);
view.setScaleY(0);
ViewCompat.animate(view).setDuration(200).scaleX(1).scaleY(1).setListener(new ViewPropertyAnimatorListenerAdapter() {
@Override
public void onAnimationEnd(View view) {
Utils.changeViewVisibilityVisible(view);
}
}).start();
}
use of android.support.v4.view.ViewPropertyAnimatorListenerAdapter in project android-topeka by googlesamples.
the class QuizActivity method revealFragmentContainerLollipop.
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void revealFragmentContainerLollipop(final View clickedView, final FrameLayout fragmentContainer) {
prepareCircularReveal(clickedView, fragmentContainer);
ViewCompat.animate(clickedView).scaleX(0).scaleY(0).alpha(0).setInterpolator(mInterpolator).setListener(new ViewPropertyAnimatorListenerAdapter() {
@Override
public void onAnimationEnd(View view) {
fragmentContainer.setVisibility(View.VISIBLE);
clickedView.setVisibility(View.GONE);
}
}).start();
fragmentContainer.setVisibility(View.VISIBLE);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.play(mCircularReveal).with(mColorChange);
animatorSet.start();
}
use of android.support.v4.view.ViewPropertyAnimatorListenerAdapter in project easy by MehdiBenmesa.
the class MaterialViewPagerImageHelper method setImageUrl.
/**
* change the image with a fade
*
* @param urlImage
* @param fadeDuration TODO : remove Picasso
*/
public static void setImageUrl(final ImageView imageView, final String urlImage, final int fadeDuration) {
final float alpha = ViewCompat.getAlpha(imageView);
final ImageView viewToAnimate = imageView;
//fade to alpha=0
fadeOut(viewToAnimate, fadeDuration, new ViewPropertyAnimatorListenerAdapter() {
@Override
public void onAnimationEnd(View view) {
super.onAnimationEnd(view);
//change the image when alpha=0
Glide.with(imageView.getContext()).load(urlImage).centerCrop().listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
//then fade to alpha=1
fadeIn(viewToAnimate, alpha, fadeDuration, new ViewPropertyAnimatorListenerAdapter());
if (imageLoadListener != null) {
imageLoadListener.OnImageLoad(imageView, ((BitmapDrawable) imageView.getDrawable()).getBitmap());
}
return false;
}
}).into(viewToAnimate);
}
});
}
use of android.support.v4.view.ViewPropertyAnimatorListenerAdapter in project AndroidChromium by JackyAndroid.
the class FloatLabelLayout method hideLabel.
/**
* Hide the label
*/
private void hideLabel(boolean animate) {
if (animate) {
float scale = mEditText.getTextSize() / mLabel.getTextSize();
ViewCompat.setScaleX(mLabel, 1f);
ViewCompat.setScaleY(mLabel, 1f);
ViewCompat.setTranslationY(mLabel, 0f);
ViewCompat.animate(mLabel).translationY(mLabel.getHeight()).setDuration(ANIMATION_DURATION).scaleX(scale).scaleY(scale).setListener(new ViewPropertyAnimatorListenerAdapter() {
@Override
public void onAnimationEnd(View view) {
mLabel.setVisibility(INVISIBLE);
mEditText.setHint(mHint);
}
}).setInterpolator(mInterpolator).start();
} else {
mLabel.setVisibility(INVISIBLE);
mEditText.setHint(mHint);
}
}
Aggregations