use of android.view.animation.DecelerateInterpolator in project JamsMusicPlayer by psaravan.
the class QueueDrawerFragment method animatePlayToPause.
/**
* Animates the play button to a pause button.
*/
private void animatePlayToPause() {
//Check to make sure the current icon is the play icon.
if (mPlayPauseButton.getId() != R.drawable.play_light)
return;
//Fade out the play button.
final ScaleAnimation scaleOut = new ScaleAnimation(1.0f, 0.0f, 1.0f, 0.0f, mPlayPauseButton.getWidth() / 2, mPlayPauseButton.getHeight() / 2);
scaleOut.setDuration(150);
scaleOut.setInterpolator(new AccelerateInterpolator());
//Scale in the pause button.
final ScaleAnimation scaleIn = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f, mPlayPauseButton.getWidth() / 2, mPlayPauseButton.getHeight() / 2);
scaleIn.setDuration(150);
scaleIn.setInterpolator(new DecelerateInterpolator());
scaleOut.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
mPlayPauseButton.setImageResource(R.drawable.pause_light);
mPlayPauseButton.setPadding(0, 0, 0, 0);
mPlayPauseButton.startAnimation(scaleIn);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
scaleIn.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
mPlayPauseButton.setScaleX(1.0f);
mPlayPauseButton.setScaleY(1.0f);
mPlayPauseButton.setId(R.drawable.pause_light);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
mPlayPauseButton.startAnimation(scaleOut);
}
use of android.view.animation.DecelerateInterpolator in project JamsMusicPlayer by psaravan.
the class PlaylistPagerFragment method hideLyrics.
/**
* Slides down the album art to hide lyrics.
*/
private void hideLyrics() {
TranslateAnimation slideDownAnimation = new TranslateAnimation(coverArt, 400, new DecelerateInterpolator(2.0f), View.VISIBLE, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, -2.0f, Animation.RELATIVE_TO_SELF, 0.0f);
slideDownAnimation.animate();
}
use of android.view.animation.DecelerateInterpolator in project weiciyuan by qii.
the class FriendsTimeLineFragment method addNewDataAndRememberPositionAutoRefresh.
private void addNewDataAndRememberPositionAutoRefresh(final MessageListBean newValue) {
int initSize = getList().getSize();
if (getActivity() != null && newValue.getSize() > 0) {
if (hasActionMode()) {
AppLogger.v("ListView have ActionMode, skip notifyDataSetChanged");
return;
}
final HeaderListView headerListView = (HeaderListView) getListView();
View firstChildView = getListView().getChildAt(0);
boolean isFirstViewHeader = headerListView.isThisViewHeader(firstChildView);
if (isFirstViewHeader && !headerListView.isInTouchByUser()) {
// //Overlay is Android 4.3 method
if (!Utility.isJB2()) {
getList().addNewData(newValue);
getAdapter().notifyDataSetChanged();
Utility.setListViewItemPosition(getListView(), 0, 0, null);
return;
}
//animate add item
final ListView listView = getListView();
final ArrayList<Pair<Long, Bitmap>> previousViewsBitmap = new ArrayList<Pair<Long, Bitmap>>();
final HashMap<Long, Integer> previousViewsTop = new HashMap<Long, Integer>();
final HashMap<Long, View> previousViews = new HashMap<Long, View>();
int childCount = listView.getChildCount();
for (int i = 0; i < childCount; i++) {
View childView = listView.getChildAt(i);
if (headerListView.isThisViewHeader(childView)) {
continue;
}
int firstAdapterItemPosition = listView.getFirstVisiblePosition();
int currentAdapterItemPosition = firstAdapterItemPosition + i - listView.getHeaderViewsCount();
long currentAdapterItemId = getAdapter().getItemId(currentAdapterItemPosition);
int childViewTop = childView.getTop();
Bitmap bitmap = Utility.getBitmapFromView(childView);
Pair<Long, Bitmap> pair = new Pair<Long, Bitmap>(currentAdapterItemId, bitmap);
previousViewsBitmap.add(pair);
previousViewsTop.put(currentAdapterItemId, childViewTop);
childView.setHasTransientState(true);
previousViews.put(currentAdapterItemId, childView);
}
getList().addNewData(newValue);
getAdapter().notifyDataSetChanged();
getListView().getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
listView.getViewTreeObserver().removeOnPreDrawListener(this);
DecelerateInterpolator decelerateInterpolator = new DecelerateInterpolator();
final ViewGroupOverlay overlay = listView.getOverlay();
Set<Long> previousViewsId = previousViews.keySet();
boolean somePreviousViewsAreStillInScreen = false;
ArrayList<View> newAddedItemViews = new ArrayList<View>();
int deltaY = 0;
int childCount = listView.getChildCount();
for (int i = 0; i < childCount; i++) {
View childView = listView.getChildAt(i);
if (headerListView.isThisViewHeader(childView)) {
continue;
}
int firstAdapterItemPosition = listView.getFirstVisiblePosition();
int currentAdapterItemPosition = firstAdapterItemPosition + i - listView.getHeaderViewsCount();
long currentAdapterItemId = getAdapter().getItemId(currentAdapterItemPosition);
if (previousViewsId.contains(currentAdapterItemId)) {
somePreviousViewsAreStillInScreen = true;
deltaY = childView.getTop() - previousViewsTop.get(currentAdapterItemId);
} else {
newAddedItemViews.add(childView);
}
}
if (!somePreviousViewsAreStillInScreen) {
deltaY = listView.getHeight();
}
for (View view : newAddedItemViews) {
view.setTranslationY(-deltaY);
view.animate().translationY(0).setInterpolator(decelerateInterpolator);
}
for (Pair<Long, Bitmap> pair : previousViewsBitmap) {
long id = pair.first;
int top = previousViewsTop.get(id);
final View view = previousViews.get(id);
final Bitmap bitmap = pair.second;
final ImageView imageView = new ImageView(getActivity());
imageView.setImageBitmap(bitmap);
imageView.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
imageView.layout(0, 0, imageView.getMeasuredWidth(), imageView.getMeasuredHeight());
overlay.add(imageView);
imageView.setTranslationY(top);
view.setAlpha(0);
imageView.animate().translationY(top + deltaY).setInterpolator(decelerateInterpolator).withEndAction(new Runnable() {
@Override
public void run() {
overlay.remove(imageView);
bitmap.recycle();
view.setAlpha(1.0f);
view.setHasTransientState(false);
}
});
}
return true;
}
});
return;
}
getList().addNewData(newValue);
Runnable endAction = new Runnable() {
@Override
public void run() {
newMsgTipBar.setValue(newValue, false);
newMsgTipBar.setType(TopTipBar.Type.ALWAYS);
}
};
//keep current read position when user touch listview
if (isFirstViewHeader && headerListView.isInTouchByUser()) {
int index = getListView().getFirstVisiblePosition();
getAdapter().notifyDataSetChanged();
int finalSize = getList().getSize();
final int positionAfterRefresh = index + finalSize - initSize + getListView().getHeaderViewsCount();
//use 1 px to show newMsgTipBar
Utility.setListViewItemPosition(getListView(), positionAfterRefresh, 1, endAction);
return;
}
//need to calc the first child view's top distance
int index = getListView().getFirstVisiblePosition();
View firstAdapterItemView = Utility.getListViewFirstAdapterItemView(getListView());
final int top = (firstAdapterItemView == null) ? 0 : firstAdapterItemView.getTop();
getAdapter().notifyDataSetChanged();
int finalSize = getList().getSize();
final int positionAfterRefresh = index + finalSize - initSize;
Utility.setListViewItemPosition(getListView(), positionAfterRefresh, top, endAction);
}
}
use of android.view.animation.DecelerateInterpolator in project weiciyuan by qii.
the class UserInfoFragment method displayCoverPicture.
private void displayCoverPicture() {
if (cover.getDrawable() != null) {
return;
}
// final int height = viewPager.getHeight();
final int height = Utility.dip2px(200);
final int width = Utility.getMaxLeftWidthOrHeightImageViewCanRead(height);
final String picPath = userBean.getCover_image();
blur.setAlpha(0f);
blur.setOriImageUrl(picPath);
ArrayList<ImageView> imageViewArrayList = new ArrayList<ImageView>();
imageViewArrayList.add(cover);
imageViewArrayList.add(blur);
TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, -100f, Animation.RELATIVE_TO_SELF, 0f);
animation.setDuration(3000);
animation.setInterpolator(new DecelerateInterpolator());
ArrayList<Animation> animationArray = new ArrayList<Animation>();
animationArray.add(animation);
TimeLineBitmapDownloader.getInstance().display(imageViewArrayList, width, height, picPath, FileLocationMethod.cover, animationArray);
}
use of android.view.animation.DecelerateInterpolator in project FlyRefresh by race604.
the class FlyRefreshLayout method startRefresh.
@Override
public void startRefresh() {
if (mFlyAnimator != null) {
mFlyAnimator.end();
}
final View iconView = getIconView();
UIUtils.clearAnimator(iconView);
AnimatorSet flyUpAnim = new AnimatorSet();
flyUpAnim.setDuration(800);
ObjectAnimator transX = ObjectAnimator.ofFloat(iconView, "translationX", 0, getWidth());
ObjectAnimator transY = ObjectAnimator.ofFloat(iconView, "translationY", 0, -mHeaderController.getHeight());
transY.setInterpolator(PathInterpolatorCompat.create(0.7f, 1f));
ObjectAnimator rotation = ObjectAnimator.ofFloat(iconView, "rotation", -45, 0);
rotation.setInterpolator(new DecelerateInterpolator());
ObjectAnimator rotationX = ObjectAnimator.ofFloat(iconView, "rotationX", 0, 60);
rotationX.setInterpolator(new DecelerateInterpolator());
flyUpAnim.playTogether(transX, transY, rotationX, ObjectAnimator.ofFloat(iconView, "scaleX", 1, 0.5f), ObjectAnimator.ofFloat(iconView, "scaleY", 1, 0.5f), rotation);
mFlyAnimator = flyUpAnim;
mFlyAnimator.start();
if (mListener != null) {
mListener.onRefresh(FlyRefreshLayout.this);
}
}
Aggregations