If you think the Android project wally listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/*
* Copyright (C) 2014 Freddie (Musenkishi) Lust-Hed
*//fromwww.java2s.com
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/package com.musenkishi.wally.anim;
import android.support.v4.view.ViewCompat;
import android.support.v7.widget.RecyclerView;
import android.view.View;
/**
* @author Gabriele Mariotti (gabri.mariotti@gmail.com)
*/publicclass ScaleInOutItemAnimator extends BaseItemAnimator {
privatefloat DEFAULT_SCALE_INITIAL = 0.6f;
privatefloat mInitialScaleX = DEFAULT_SCALE_INITIAL;
privatefloat mInitialScaleY = DEFAULT_SCALE_INITIAL;
privatefloat mEndScaleX = DEFAULT_SCALE_INITIAL;
privatefloat mEndScaleY = DEFAULT_SCALE_INITIAL;
privatefloat mOriginalScaleX;
privatefloat mOriginalScaleY;
public ScaleInOutItemAnimator(RecyclerView recyclerView) {
super(recyclerView);
}
protectedvoid animateRemoveImpl(final RecyclerView.ViewHolder holder) {
final View view = holder.itemView;
ViewCompat.animate(view).cancel();
ViewCompat.animate(view).setDuration(getRemoveDuration()).
scaleX(mEndScaleX).scaleY(mEndScaleY).setListener(new VpaListenerAdapter() {
@Override
publicvoid onAnimationEnd(View view) {
ViewCompat.setScaleX(view, mEndScaleX);
ViewCompat.setScaleY(view, mEndScaleY);
dispatchRemoveFinished(holder);
mRemoveAnimations.remove(holder);
dispatchFinishedWhenDone();
}
}).start();
mRemoveAnimations.add(holder);
}
@Override
protectedvoid prepareAnimateAdd(RecyclerView.ViewHolder holder) {
retrieveOriginalScale(holder);
ViewCompat.setScaleX(holder.itemView, mInitialScaleX);
ViewCompat.setScaleY(holder.itemView, mInitialScaleY);
}
@Override
publicboolean animateAdd(RecyclerView.ViewHolder holder) {
return super.animateAdd(holder);
}
protectedvoid animateAddImpl(final RecyclerView.ViewHolder holder) {
final View view = holder.itemView;
ViewCompat.animate(view).cancel();
ViewCompat.animate(view).scaleX(mOriginalScaleX).scaleY(mOriginalScaleY)
.setDuration(getAddDuration()).
setListener(new VpaListenerAdapter() {
@Override
publicvoid onAnimationCancel(View view) {
ViewCompat.setScaleX(view, mOriginalScaleX);
ViewCompat.setScaleY(view, mOriginalScaleY);
}
@Override
publicvoid onAnimationEnd(View view) {
dispatchAddFinished(holder);
mAddAnimations.remove(holder);
dispatchFinishedWhenDone();
}
}).start();
mAddAnimations.add(holder);
}
publicvoid setInitialScale(float scaleXY){
setInitialScale(scaleXY, scaleXY);
}
publicvoid setInitialScale(float scaleX, float scaleY){
mInitialScaleX = scaleX;
mInitialScaleY = scaleY;
mEndScaleX = scaleX;
mEndScaleY = scaleY;
}
publicvoid setEndScale(float scaleXY){
setEndScale(scaleXY, scaleXY);
}
publicvoid setEndScale(float scaleX, float scaleY){
mEndScaleX = scaleX;
mEndScaleY = scaleY;
}
privatevoid retrieveOriginalScale(RecyclerView.ViewHolder holder) {
mOriginalScaleX = holder.itemView.getScaleX();
mOriginalScaleY = holder.itemView.getScaleY();
}
@Override
publicboolean animateChange(RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder viewHolder2, int i, int i2, int i3, int i4) {
return false;
}
}