use of android.view.animation.AccelerateInterpolator in project LookLook by xinghongfei.
the class ZhihuDescribeActivity method expandImageAndFinish.
private void expandImageAndFinish() {
if (mShot.getOffset() != 0f) {
Animator expandImage = ObjectAnimator.ofFloat(mShot, ParallaxScrimageView.OFFSET, 0f);
expandImage.setDuration(80);
expandImage.setInterpolator(new AccelerateInterpolator());
expandImage.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
finishAfterTransition();
} else {
finish();
}
}
});
expandImage.start();
} else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
finishAfterTransition();
} else {
finish();
}
}
}
use of android.view.animation.AccelerateInterpolator in project LookLook by xinghongfei.
the class MeiziAdapter method bindViewHolderNormal.
private void bindViewHolderNormal(final MeiziViewHolder holder, final int position) {
final Meizi meizi = meiziItemes.get(holder.getAdapterPosition());
holder.imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startDescribeActivity(meizi, holder);
}
});
// holder.textView.setText("视频");
// holder.textView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View view) {
// startDescribeActivity(meizi,holder);
// }
// });
Glide.with(mContext).load(meizi.getUrl()).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) {
if (!meizi.hasFadedIn) {
holder.imageView.setHasTransientState(true);
final ObservableColorMatrix cm = new ObservableColorMatrix();
final ObjectAnimator animator = ObjectAnimator.ofFloat(cm, ObservableColorMatrix.SATURATION, 0f, 1f);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
holder.imageView.setColorFilter(new ColorMatrixColorFilter(cm));
}
});
animator.setDuration(2000L);
animator.setInterpolator(new AccelerateInterpolator());
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
holder.imageView.clearColorFilter();
holder.imageView.setHasTransientState(false);
animator.start();
meizi.hasFadedIn = true;
}
});
}
return false;
}
}).diskCacheStrategy(DiskCacheStrategy.SOURCE).centerCrop().into(new DribbbleTarget(holder.imageView, false));
}
use of android.view.animation.AccelerateInterpolator in project LookLook by xinghongfei.
the class TopNewsAdapter method bindViewHolderNormal.
private void bindViewHolderNormal(final TopNewsViewHolder holder, final int position) {
final NewsBean newsBeanItem = topNewitems.get(holder.getAdapterPosition());
if (DBUtils.getDB(mContext).isRead(Config.TOPNEWS, newsBeanItem.getTitle(), 1)) {
holder.textView.setTextColor(Color.GRAY);
holder.sourceTextview.setTextColor(Color.GRAY);
} else {
holder.textView.setTextColor(Color.BLACK);
holder.sourceTextview.setTextColor(Color.BLACK);
}
holder.imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
DBUtils.getDB(mContext).insertHasRead(Config.ZHIHU, newsBeanItem.getTitle(), 1);
holder.textView.setTextColor(Color.GRAY);
holder.sourceTextview.setTextColor(Color.GRAY);
startTopnewsActivity(newsBeanItem, holder);
}
});
holder.textView.setText(newsBeanItem.getTitle());
holder.sourceTextview.setText(newsBeanItem.getSource());
holder.linearLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startTopnewsActivity(newsBeanItem, holder);
}
});
Glide.with(mContext).load(newsBeanItem.getImgsrc()).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) {
if (!newsBeanItem.hasFadedIn) {
holder.imageView.setHasTransientState(true);
final ObservableColorMatrix cm = new ObservableColorMatrix();
final ObjectAnimator animator = ObjectAnimator.ofFloat(cm, ObservableColorMatrix.SATURATION, 0f, 1f);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
holder.imageView.setColorFilter(new ColorMatrixColorFilter(cm));
}
});
animator.setDuration(2000L);
animator.setInterpolator(new AccelerateInterpolator());
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
holder.imageView.clearColorFilter();
holder.imageView.setHasTransientState(false);
animator.start();
newsBeanItem.hasFadedIn = true;
}
});
}
return false;
}
}).diskCacheStrategy(DiskCacheStrategy.SOURCE).centerCrop().override(widthPx, heighPx).into(new DribbbleTarget(holder.imageView, false));
}
use of android.view.animation.AccelerateInterpolator in project WordPress-Android by wordpress-mobile.
the class AniUtils method animateBar.
private static void animateBar(View view, boolean show, boolean isTopBar, Duration duration) {
int newVisibility = (show ? View.VISIBLE : View.GONE);
if (view == null || view.getVisibility() == newVisibility) {
return;
}
float fromY;
float toY;
if (isTopBar) {
fromY = (show ? -1f : 0f);
toY = (show ? 0f : -1f);
} else {
fromY = (show ? 1f : 0f);
toY = (show ? 0f : 1f);
}
Animation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, fromY, Animation.RELATIVE_TO_SELF, toY);
long durationMillis = duration.toMillis(view.getContext());
animation.setDuration(durationMillis);
if (show) {
animation.setInterpolator(new DecelerateInterpolator());
} else {
animation.setInterpolator(new AccelerateInterpolator());
}
view.clearAnimation();
view.startAnimation(animation);
view.setVisibility(newVisibility);
}
use of android.view.animation.AccelerateInterpolator in project WordPress-Android by wordpress-mobile.
the class AniUtils method showFab.
/*
* in/out animation for floating action button
*/
public static void showFab(final View view, final boolean show) {
if (view == null)
return;
Context context = view.getContext();
int fabHeight = context.getResources().getDimensionPixelSize(android.support.design.R.dimen.design_fab_size_normal);
int fabMargin = context.getResources().getDimensionPixelSize(R.dimen.fab_margin);
int max = (fabHeight + fabMargin) * 2;
float fromY = (show ? max : 0f);
float toY = (show ? 0f : max);
ObjectAnimator anim = ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, fromY, toY);
if (show) {
anim.setInterpolator(new DecelerateInterpolator());
} else {
anim.setInterpolator(new AccelerateInterpolator());
}
anim.setDuration(show ? Duration.LONG.toMillis(context) : Duration.SHORT.toMillis(context));
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
super.onAnimationStart(animation);
if (view.getVisibility() != View.VISIBLE) {
view.setVisibility(View.VISIBLE);
}
}
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
if (!show) {
view.setVisibility(View.GONE);
}
}
});
anim.start();
}
Aggregations