List of usage examples for android.animation AnimatorSet addListener
public void addListener(AnimatorListener listener)
From source file:ch.gianulli.flashcards.ui.Flashcard.java
public void turnCard() { if (mPreviousAnimation != null) { mPreviousAnimation.cancel();//from w ww. j a v a 2 s . c o m mPreviousAnimation = null; } AnimatorSet set = new AnimatorSet(); mQuestion.setLayerType(View.LAYER_TYPE_HARDWARE, null); mAnswer.setLayerType(View.LAYER_TYPE_HARDWARE, null); if (mQuestionShowing) { mQuestionShowing = false; mQuestion.setVisibility(View.VISIBLE); mQuestion.setAlpha(1.0f); mAnswer.setVisibility(View.VISIBLE); mAnswer.setAlpha(0.0f); ObjectAnimator questionAnim = ObjectAnimator.ofFloat(mQuestion, "alpha", 1.0f, 0.0f); questionAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mQuestion.setVisibility(View.GONE); } }); ObjectAnimator answerAnim = ObjectAnimator.ofFloat(mAnswer, "alpha", 0.0f, 1.0f); set.playTogether(questionAnim, answerAnim); // Show button bar if necessary if (!mButtonBarShowing) { expandButtonBar(); } } else { mQuestionShowing = true; mQuestion.setVisibility(View.VISIBLE); mQuestion.setAlpha(0.0f); mAnswer.setVisibility(View.VISIBLE); mAnswer.setAlpha(1.0f); ObjectAnimator questionAnim = ObjectAnimator.ofFloat(mQuestion, "alpha", 0.0f, 1.0f); ObjectAnimator answerAnim = ObjectAnimator.ofFloat(mAnswer, "alpha", 1.0f, 0.0f); answerAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mAnswer.setVisibility(View.GONE); } }); set.playTogether(questionAnim, answerAnim); } set.setDuration(400); mPreviousAnimation = set; set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mQuestion.setLayerType(View.LAYER_TYPE_SOFTWARE, null); mAnswer.setLayerType(View.LAYER_TYPE_SOFTWARE, null); mPreviousAnimation = null; } }); set.start(); }
From source file:org.telegram.ui.Components.ChatAttachAlert.java
@TargetApi(16) private void openCamera() { if (cameraView == null) { return;/*from w w w. ja v a 2 s .co m*/ } animateCameraValues[0] = 0; animateCameraValues[1] = AndroidUtilities.dp(80) - cameraViewOffsetX; animateCameraValues[2] = AndroidUtilities.dp(80) - cameraViewOffsetY; cameraAnimationInProgress = true; cameraPanel.setVisibility(View.VISIBLE); cameraPanel.setTag(null); ArrayList<Animator> animators = new ArrayList<>(); animators.add(ObjectAnimator.ofFloat(ChatAttachAlert.this, "cameraOpenProgress", 0.0f, 1.0f)); animators.add(ObjectAnimator.ofFloat(cameraPanel, "alpha", 1.0f)); for (int a = 0; a < 2; a++) { if (flashModeButton[a].getVisibility() == View.VISIBLE) { animators.add(ObjectAnimator.ofFloat(flashModeButton[a], "alpha", 1.0f)); break; } } AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(animators); animatorSet.setDuration(200); animatorSet.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Animator animator) { cameraAnimationInProgress = false; } }); animatorSet.start(); if (Build.VERSION.SDK_INT >= 21) { cameraView .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_FULLSCREEN); } cameraOpened = true; }
From source file:org.telegram.ui.Components.ChatAttachAlert.java
@TargetApi(16) public void closeCamera(boolean animated) { if (takingPhoto || cameraView == null) { return;// ww w . j a v a2 s. c om } animateCameraValues[1] = AndroidUtilities.dp(80) - cameraViewOffsetX; animateCameraValues[2] = AndroidUtilities.dp(80) - cameraViewOffsetY; if (animated) { FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) cameraView.getLayoutParams(); animateCameraValues[0] = layoutParams.topMargin = (int) cameraView.getTranslationY(); cameraView.setLayoutParams(layoutParams); cameraView.setTranslationY(0); cameraAnimationInProgress = true; ArrayList<Animator> animators = new ArrayList<>(); animators.add(ObjectAnimator.ofFloat(ChatAttachAlert.this, "cameraOpenProgress", 0.0f)); animators.add(ObjectAnimator.ofFloat(cameraPanel, "alpha", 0.0f)); for (int a = 0; a < 2; a++) { if (flashModeButton[a].getVisibility() == View.VISIBLE) { animators.add(ObjectAnimator.ofFloat(flashModeButton[a], "alpha", 0.0f)); break; } } AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(animators); animatorSet.setDuration(200); animatorSet.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Animator animator) { cameraAnimationInProgress = false; cameraPanel.setVisibility(View.GONE); cameraOpened = false; if (Build.VERSION.SDK_INT >= 21) { cameraView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); } } }); animatorSet.start(); } else { animateCameraValues[0] = 0; setCameraOpenProgress(0); cameraPanel.setAlpha(0); cameraPanel.setVisibility(View.GONE); for (int a = 0; a < 2; a++) { if (flashModeButton[a].getVisibility() == View.VISIBLE) { flashModeButton[a].setAlpha(0.0f); break; } } cameraOpened = false; if (Build.VERSION.SDK_INT >= 21) { cameraView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); } } }
From source file:com.github.shareme.gwsmaterialdrawer.library.DrawerView.java
private void openProfileList() { Log.d(TAG, "openProfileList()"); if (!profileListOpen) { AnimatorSet set = new AnimatorSet(); set.playTogether(ObjectAnimator.ofFloat(linearListView, "alpha", 1, 0f, 0f, 0f), ObjectAnimator.ofFloat(linearListView, "translationY", 0, getResources().getDimensionPixelSize(R.dimen.md_list_item_height) / 4), ObjectAnimator.ofFloat(linearListViewProfileList, "alpha", 0, 1), ObjectAnimator.ofFloat(linearListViewProfileList, "translationY", -getResources().getDimensionPixelSize(R.dimen.md_list_item_height) / 2, 0), ObjectAnimator.ofInt(imageViewOpenProfileListIcon.getDrawable(), PROPERTY_LEVEL, 0, 10000), ObjectAnimator.ofInt(scrollView, PROPERTY_SCROLL_POSITION, 0)); set.setDuration(getResources().getInteger(R.integer.md_profile_list_open_anim_time)); set.addListener(new Animator.AnimatorListener() { @Override//w w w . j a va 2 s. c om public void onAnimationStart(Animator animation) { linearListViewProfileList.setVisibility(VISIBLE); imageViewOpenProfileListIcon.setClickable(false); } @Override public void onAnimationEnd(Animator animation) { imageViewOpenProfileListIcon.setClickable(true); profileListOpen = true; updateListVisibility(); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); set.start(); } else { updateListVisibility(); } }
From source file:com.github.shareme.gwsmaterialdrawer.library.DrawerView.java
private void closeProfileList() { Log.d(TAG, "closeProfileList()"); if (profileListOpen) { AnimatorSet set = new AnimatorSet(); set.playTogether(ObjectAnimator.ofFloat(linearListViewProfileList, "alpha", 1, 0f, 0f, 0f), ObjectAnimator.ofFloat(linearListViewProfileList, "translationY", 0, -getResources().getDimensionPixelSize(R.dimen.md_list_item_height) / 4), ObjectAnimator.ofFloat(linearListView, "alpha", 0f, 1), ObjectAnimator.ofFloat(linearListView, "translationY", getResources().getDimensionPixelSize(R.dimen.md_list_item_height) / 2, 0), ObjectAnimator.ofInt(imageViewOpenProfileListIcon.getDrawable(), PROPERTY_LEVEL, 10000, 0), ObjectAnimator.ofInt(scrollView, PROPERTY_SCROLL_POSITION, 0)); set.setDuration(getResources().getInteger(R.integer.md_profile_list_open_anim_time)); set.addListener(new Animator.AnimatorListener() { @Override//from ww w . j a va 2s.c om public void onAnimationStart(Animator animation) { linearListView.setVisibility(VISIBLE); imageViewOpenProfileListIcon.setClickable(false); } @Override public void onAnimationEnd(Animator animation) { imageViewOpenProfileListIcon.setClickable(true); profileListOpen = false; updateListVisibility(); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); set.start(); } else { updateListVisibility(); } }
From source file:trendoidtechnologies.com.navigationdrawerlibrary.DrawerView.java
private void openProfileList() { if (loggingEnabled) Log.d(TAG, "openProfileList()"); if (!profileListOpen) { AnimatorSet set = new AnimatorSet(); set.playTogether(ObjectAnimator.ofFloat(linearListView, "alpha", 1, 0f, 0f, 0f), ObjectAnimator.ofFloat(linearListView, "translationY", 0, getResources().getDimensionPixelSize(R.dimen.md_list_item_height) / 4), ObjectAnimator.ofFloat(linearListViewProfileList, "alpha", 0, 1), ObjectAnimator.ofFloat(linearListViewProfileList, "translationY", -getResources().getDimensionPixelSize(R.dimen.md_list_item_height) / 2, 0), ObjectAnimator.ofInt(imageViewOpenProfileListIcon.getDrawable(), PROPERTY_LEVEL, 0, 10000), ObjectAnimator.ofInt(scrollView, PROPERTY_SCROLL_POSITION, 0)); set.setDuration(getResources().getInteger(R.integer.md_profile_list_open_anim_time)); set.addListener(new Animator.AnimatorListener() { @Override/* w ww. j a v a 2s .com*/ public void onAnimationStart(Animator animation) { linearListViewProfileList.setVisibility(VISIBLE); imageViewOpenProfileListIcon.setClickable(false); } @Override public void onAnimationEnd(Animator animation) { imageViewOpenProfileListIcon.setClickable(true); profileListOpen = true; updateListVisibility(); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); set.start(); } else { updateListVisibility(); } }
From source file:trendoidtechnologies.com.navigationdrawerlibrary.DrawerView.java
private void closeProfileList() { if (loggingEnabled) Log.d(TAG, "closeProfileList()"); if (profileListOpen) { AnimatorSet set = new AnimatorSet(); set.playTogether(ObjectAnimator.ofFloat(linearListViewProfileList, "alpha", 1, 0f, 0f, 0f), ObjectAnimator.ofFloat(linearListViewProfileList, "translationY", 0, -getResources().getDimensionPixelSize(R.dimen.md_list_item_height) / 4), ObjectAnimator.ofFloat(linearListView, "alpha", 0f, 1), ObjectAnimator.ofFloat(linearListView, "translationY", getResources().getDimensionPixelSize(R.dimen.md_list_item_height) / 2, 0), ObjectAnimator.ofInt(imageViewOpenProfileListIcon.getDrawable(), PROPERTY_LEVEL, 10000, 0), ObjectAnimator.ofInt(scrollView, PROPERTY_SCROLL_POSITION, 0)); set.setDuration(getResources().getInteger(R.integer.md_profile_list_open_anim_time)); set.addListener(new Animator.AnimatorListener() { @Override//w ww .j a va 2s.com public void onAnimationStart(Animator animation) { linearListView.setVisibility(VISIBLE); imageViewOpenProfileListIcon.setClickable(false); } @Override public void onAnimationEnd(Animator animation) { imageViewOpenProfileListIcon.setClickable(true); profileListOpen = false; updateListVisibility(); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); set.start(); } else { updateListVisibility(); } }
From source file:org.telegram.ui.ActionBar.ActionBarLayout.java
public boolean onTouchEvent(MotionEvent ev) { if (!checkTransitionAnimation() && !inActionMode && !animationInProgress) { if (fragmentsStack.size() > 1) { if (ev != null && ev.getAction() == MotionEvent.ACTION_DOWN && !startedTracking && !maybeStartTracking) { BaseFragment currentFragment = fragmentsStack.get(fragmentsStack.size() - 1); if (!currentFragment.swipeBackEnabled) { return false; }/*from ww w. j ava 2 s . com*/ startedTrackingPointerId = ev.getPointerId(0); maybeStartTracking = true; startedTrackingX = (int) ev.getX(); startedTrackingY = (int) ev.getY(); if (velocityTracker != null) { velocityTracker.clear(); } } else if (ev != null && ev.getAction() == MotionEvent.ACTION_MOVE && ev.getPointerId(0) == startedTrackingPointerId) { if (velocityTracker == null) { velocityTracker = VelocityTracker.obtain(); } int dx = Math.max(0, (int) (ev.getX() - startedTrackingX)); int dy = Math.abs((int) ev.getY() - startedTrackingY); velocityTracker.addMovement(ev); if (maybeStartTracking && !startedTracking && dx >= AndroidUtilities.getPixelsInCM(0.4f, true) && Math.abs(dx) / 3 > dy) { prepareForMoving(ev); } else if (startedTracking) { if (!beginTrackingSent) { if (parentActivity.getCurrentFocus() != null) { AndroidUtilities.hideKeyboard(parentActivity.getCurrentFocus()); } BaseFragment currentFragment = fragmentsStack.get(fragmentsStack.size() - 1); currentFragment.onBeginSlide(); beginTrackingSent = true; } containerView.setTranslationX(dx); setInnerTranslationX(dx); } } else if (ev != null && ev.getPointerId(0) == startedTrackingPointerId && (ev.getAction() == MotionEvent.ACTION_CANCEL || ev.getAction() == MotionEvent.ACTION_UP || ev.getAction() == MotionEvent.ACTION_POINTER_UP)) { if (velocityTracker == null) { velocityTracker = VelocityTracker.obtain(); } velocityTracker.computeCurrentVelocity(1000); if (!startedTracking && fragmentsStack.get(fragmentsStack.size() - 1).swipeBackEnabled) { float velX = velocityTracker.getXVelocity(); float velY = velocityTracker.getYVelocity(); if (velX >= 3500 && velX > Math.abs(velY)) { prepareForMoving(ev); if (!beginTrackingSent) { if (((Activity) getContext()).getCurrentFocus() != null) { AndroidUtilities.hideKeyboard(((Activity) getContext()).getCurrentFocus()); } beginTrackingSent = true; } } } if (startedTracking) { float x = containerView.getX(); AnimatorSet animatorSet = new AnimatorSet(); float velX = velocityTracker.getXVelocity(); float velY = velocityTracker.getYVelocity(); final boolean backAnimation = x < containerView.getMeasuredWidth() / 3.0f && (velX < 3500 || velX < velY); float distToMove; if (!backAnimation) { distToMove = containerView.getMeasuredWidth() - x; animatorSet.playTogether( ObjectAnimator.ofFloat(containerView, "translationX", containerView.getMeasuredWidth()), ObjectAnimator.ofFloat(this, "innerTranslationX", (float) containerView.getMeasuredWidth())); } else { distToMove = x; animatorSet.playTogether(ObjectAnimator.ofFloat(containerView, "translationX", 0), ObjectAnimator.ofFloat(this, "innerTranslationX", 0.0f)); } animatorSet.setDuration( Math.max((int) (200.0f / containerView.getMeasuredWidth() * distToMove), 50)); animatorSet.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Animator animator) { onSlideAnimationEnd(backAnimation); } }); animatorSet.start(); animationInProgress = true; } else { maybeStartTracking = false; startedTracking = false; } if (velocityTracker != null) { velocityTracker.recycle(); velocityTracker = null; } } else if (ev == null) { maybeStartTracking = false; startedTracking = false; if (velocityTracker != null) { velocityTracker.recycle(); velocityTracker = null; } } } return startedTracking; } return false; }
From source file:io.plaidapp.core.ui.transitions.ReflowText.java
@Override public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) { if (startValues == null || endValues == null) return null; final View view = endValues.view; AnimatorSet transition = new AnimatorSet(); ReflowData startData = (ReflowData) startValues.values.get(PROPNAME_DATA); ReflowData endData = (ReflowData) endValues.values.get(PROPNAME_DATA); duration = calculateDuration(startData.bounds, endData.bounds); // create layouts & capture a bitmaps of the text in both states // (with max lines variants where needed) Layout startLayout = createLayout(startData, sceneRoot.getContext(), false); Layout endLayout = createLayout(endData, sceneRoot.getContext(), false); Layout startLayoutMaxLines = null;//from w w w.j a va2s. c o m Layout endLayoutMaxLines = null; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { // StaticLayout maxLines support if (startData.maxLines != -1) { startLayoutMaxLines = createLayout(startData, sceneRoot.getContext(), true); } if (endData.maxLines != -1) { endLayoutMaxLines = createLayout(endData, sceneRoot.getContext(), true); } } final Bitmap startText = createBitmap(startData, startLayoutMaxLines != null ? startLayoutMaxLines : startLayout); final Bitmap endText = createBitmap(endData, endLayoutMaxLines != null ? endLayoutMaxLines : endLayout); // temporarily turn off clipping so we can draw outside of our bounds don't draw view.setWillNotDraw(true); ((ViewGroup) view.getParent()).setClipChildren(false); // calculate the runs of text to move together List<Run> runs = getRuns(startData, startLayout, startLayoutMaxLines, endData, endLayout, endLayoutMaxLines); // create animators for moving, scaling and fading each run of text transition.playTogether(createRunAnimators(view, startData, endData, startText, endText, runs)); if (!freezeFrame) { transition.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { // clean up view.setWillNotDraw(false); view.getOverlay().clear(); ((ViewGroup) view.getParent()).setClipChildren(true); startText.recycle(); endText.recycle(); } }); } return transition; }
From source file:com.aliyun.homeshell.Folder.java
public void backFromSelectApps() { if (mRunningAnimatorSet != null) { if (mRunningIsShow) { mRunningAnimatorSet.end();//w w w . jav a2s. com } else { return; } } ObjectAnimator invisToVis = ObjectAnimator.ofFloat(this, "alpha", 0, 1); invisToVis.setDuration(mAnimatorDuration); ObjectAnimator visToInvisX = ObjectAnimator.ofFloat(mAppsSelectView, "scaleX", 1, 0); visToInvisX.setDuration(mAnimatorDuration); ObjectAnimator visToInvisY = ObjectAnimator.ofFloat(mAppsSelectView, "scaleY", 1, 0); visToInvisY.setDuration(mAnimatorDuration); List<Animator> animList = new ArrayList<Animator>(); animList.add(invisToVis); animList.add(visToInvisX); animList.add(visToInvisY); final AnimatorSet as = new AnimatorSet(); as.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animator) { Folder.this.setVisibility(View.VISIBLE); mRunningAnimatorSet = as; mRunningIsShow = false; /*YUNOS BEGIN*/ //##date:2014/06/27 ##author:yangshan.ys@alibaba-inc.com##BugID:132255 //when back to folder from folderappsselectview ,prevent the mFolderName from getting focus mFolderName.setFocusable(false); /* YUNOS END */ } @Override public void onAnimationEnd(Animator animator) { mRunningAnimatorSet = null; mRunningIsShow = false; mAppsSelectView.setVisibility(View.INVISIBLE); Folder.this.setVisibility(View.VISIBLE); /*YUNOS BEGIN*/ //##date:2014/06/27 ##author:yangshan.ys@alibaba-inc.com##BugID:132255 //when back to folder from folderappsselectview ,prevent the mFolderName from getting focus mFolderName.setFocusable(true); /*YUNOS BEGIN*/ //##date:2014/06/27 ##author:yangshan.ys@alibaba-inc.com##BugID:133680 //when back to folder from folderappsselectview, the folderName cannot be changed mFolderName.setFocusableInTouchMode(true); /* YUNOS END */ /* YUNOS END */ mIsEditingName = false; } }); as.playTogether(animList); as.start(); }