use of android.animation.Animator.AnimatorListener in project UltimateAndroid by cymcsg.
the class DefaultLayoutAnimator method animateChanges.
@Override
public void animateChanges(LayoutChangeset changeSet, final FreeFlowContainer callback) {
this.changeSet = changeSet;
this.callback = callback;
cancel();
mIsRunning = true;
disappearingSet = null;
appearingSet = null;
movingSet = null;
Comparator<FreeFlowItem> cmp = new Comparator<FreeFlowItem>() {
@Override
public int compare(FreeFlowItem lhs, FreeFlowItem rhs) {
return (lhs.itemSection * 1000 + lhs.itemIndex) - (rhs.itemSection * 1000 + rhs.itemIndex);
}
};
List<FreeFlowItem> removed = changeSet.getRemoved();
if (removed.size() > 0) {
Collections.sort(removed, cmp);
disappearingSet = getItemsRemovedAnimation(changeSet.getRemoved());
}
List<FreeFlowItem> added = changeSet.getAdded();
if (added.size() > 0) {
Collections.sort(added, cmp);
appearingSet = getItemsAddedAnimation(added);
}
if (changeSet.getMoved().size() > 0) {
movingSet = getItemsMovedAnimation(changeSet.getMoved());
}
AnimatorSet all = getAnimationSequence();
if (all == null) {
mIsRunning = false;
callback.onLayoutChangeAnimationsCompleted(this);
} else {
all.addListener(new AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
mIsRunning = false;
callback.onLayoutChangeAnimationsCompleted(DefaultLayoutAnimator.this);
}
@Override
public void onAnimationCancel(Animator animation) {
}
});
all.start();
}
}
use of android.animation.Animator.AnimatorListener in project android_frameworks_base by DirtyUnicorns.
the class SettingsButton method startAccelSpin.
protected void startAccelSpin() {
cancelAnimation();
mAnimator = ObjectAnimator.ofFloat(this, View.ROTATION, 0, 360);
mAnimator.setInterpolator(AnimationUtils.loadInterpolator(mContext, android.R.interpolator.accelerate_quad));
mAnimator.setDuration(ACCEL_LENGTH);
mAnimator.addListener(new AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
startContinuousSpin();
}
@Override
public void onAnimationCancel(Animator animation) {
}
});
mAnimator.start();
}
use of android.animation.Animator.AnimatorListener in project android_frameworks_base by ResurrectionRemix.
the class QSDetail method handleShowingDetail.
private void handleShowingDetail(final QSTile.DetailAdapter adapter, int x, int y) {
final boolean showingDetail = adapter != null;
setClickable(showingDetail);
if (showingDetail) {
mQsDetailHeaderTitle.setText(adapter.getTitle());
final Boolean toggleState = adapter.getToggleState();
if (toggleState == null) {
mQsDetailHeaderSwitch.setVisibility(INVISIBLE);
mQsDetailHeader.setClickable(false);
} else {
mQsDetailHeaderSwitch.setVisibility(VISIBLE);
handleToggleStateChanged(toggleState, adapter.getToggleEnabled());
mQsDetailHeader.setClickable(true);
mQsDetailHeader.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
boolean checked = !mQsDetailHeaderSwitch.isChecked();
mQsDetailHeaderSwitch.setChecked(checked);
adapter.setToggleState(checked);
}
});
}
if (!mFullyExpanded) {
mTriggeredExpand = true;
mHost.animateToggleQSExpansion();
} else {
mTriggeredExpand = false;
}
mOpenX = x;
mOpenY = y;
} else {
// Ensure we collapse into the same point we opened from.
x = mOpenX;
y = mOpenY;
if (mTriggeredExpand) {
mHost.animateToggleQSExpansion();
mTriggeredExpand = false;
}
}
boolean visibleDiff = (mDetailAdapter != null) != (adapter != null);
// already in right state
if (!visibleDiff && mDetailAdapter == adapter)
return;
AnimatorListener listener = null;
if (adapter != null) {
int viewCacheIndex = adapter.getMetricsCategory();
View detailView = adapter.createDetailView(mContext, mDetailViews.get(viewCacheIndex), mDetailContent);
if (detailView == null)
throw new IllegalStateException("Must return detail view");
final Intent settingsIntent = adapter.getSettingsIntent();
mDetailSettingsButton.setVisibility(settingsIntent != null ? VISIBLE : GONE);
mDetailSettingsButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mHost.startActivityDismissingKeyguard(settingsIntent);
}
});
mDetailContent.removeAllViews();
mDetailContent.addView(detailView);
mDetailViews.put(viewCacheIndex, detailView);
MetricsLogger.visible(mContext, adapter.getMetricsCategory());
announceForAccessibility(mContext.getString(R.string.accessibility_quick_settings_detail, adapter.getTitle()));
mDetailAdapter = adapter;
listener = mHideGridContentWhenDone;
setVisibility(View.VISIBLE);
} else {
if (mDetailAdapter != null) {
MetricsLogger.hidden(mContext, mDetailAdapter.getMetricsCategory());
}
mClosingDetail = true;
mDetailAdapter = null;
listener = mTeardownDetailWhenDone;
mHeader.setVisibility(View.VISIBLE);
mQsPanel.setGridContentVisibility(true);
mQsPanelCallback.onScanStateChanged(false);
}
sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
if (visibleDiff) {
mAnimatingOpen = adapter != null;
if (mFullyExpanded || mDetailAdapter != null) {
setAlpha(1);
mClipper.animateCircularClip(x, y, mDetailAdapter != null, listener);
} else {
animate().alpha(0).setDuration(FADE_DURATION).setListener(listener).start();
}
}
}
use of android.animation.Animator.AnimatorListener in project android_frameworks_base by ResurrectionRemix.
the class SettingsButton method startAccelSpin.
protected void startAccelSpin() {
cancelAnimation();
mAnimator = ObjectAnimator.ofFloat(this, View.ROTATION, 0, 360);
mAnimator.setInterpolator(AnimationUtils.loadInterpolator(mContext, android.R.interpolator.accelerate_quad));
mAnimator.setDuration(ACCEL_LENGTH);
mAnimator.addListener(new AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
startContinuousSpin();
}
@Override
public void onAnimationCancel(Animator animation) {
}
});
mAnimator.start();
}
use of android.animation.Animator.AnimatorListener in project RecyclerViewAnimator by dkmeteor.
the class HingeOut method startAnimation.
@Override
public void startAnimation(final ViewHolder holder, long duration, final BaseItemAnimator animator) {
ViewCompat.animate(holder.itemView).cancel();
AnimatorSet set = new AnimatorSet();
View target = holder.itemView;
int abs = Math.random() > 0.5 ? -1 : 1;
float x, y;
if (abs > 0) {
x = target.getPaddingLeft();
y = target.getPaddingTop();
} else {
x = target.getWidth();
y = target.getPaddingTop();
}
set.setDuration(animator.getRemoveDuration());
set.addListener(new AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
animator.dispatchAddFinished(holder);
animator.mAddAnimations.remove(holder);
animator.dispatchFinishedWhenDone();
}
@Override
public void onAnimationCancel(Animator animation) {
}
});
set.playTogether(ObjectAnimator.ofFloat(target, "rotation", 0, abs * 80, abs * 60, abs * 80, abs * 60, abs * 60), ObjectAnimator.ofFloat(target, "translationY", 0, 0, 0, 0, 0, 700), ObjectAnimator.ofFloat(target, "alpha", 1, 1, 1, 1, 1, 0), ObjectAnimator.ofFloat(target, "pivotX", x, x, x, x, x, x), ObjectAnimator.ofFloat(target, "pivotY", y, y, y, y, y, y));
set.setStartDelay(mDelay * mDelayCount);
set.setDuration(animator.getAddDuration());
set.start();
animator.mAddAnimations.add(holder);
}
Aggregations