List of usage examples for android.animation AnimatorSet setDuration
@Override public AnimatorSet setDuration(long duration)
From source file:com.dk.animation.effect.out.HingeOut.java
@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;//from ww w .ja v a2 s . co m 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); }
From source file:com.evilduck.animtest.DraggedPanelLayout.java
public void animatePanel(final boolean opening, float distY, long duration) { ObjectAnimator slidingPanelAnimator = ObjectAnimator.ofFloat(slidingPanel, View.TRANSLATION_Y, slidingPanel.getTranslationY(), slidingPanel.getTranslationY() + distY); ObjectAnimator bottomPanelAnimator = ObjectAnimator.ofFloat(bottomPanel, View.TRANSLATION_Y, bottomPanel.getTranslationY(), bottomPanel.getTranslationY() + (float) (distY * parallaxFactor)); AnimatorSet set = new AnimatorSet(); set.playTogether(slidingPanelAnimator, bottomPanelAnimator); set.setDuration(duration); set.setInterpolator(sDecelerator);/*from ww w. ja va 2 s .c o m*/ set.addListener(new MyAnimListener(opening)); set.start(); }
From source file:com.gudong.appkit.ui.helper.AppItemAnimator.java
private void animateAddImpl(final RecyclerView.ViewHolder viewHolder) { final View target = viewHolder.itemView; mAddAnimations.add(viewHolder);/*from w w w .j a va 2 s .com*/ final AnimatorSet animator = new AnimatorSet(); animator.playTogether(ObjectAnimator.ofFloat(target, "translationX", -target.getMeasuredWidth(), 0, 0f), ObjectAnimator.ofFloat(target, "alpha", 0.5f, 1.0f)); animator.setTarget(target); animator.setDuration(KEY_DURATION_TIME); animator.setInterpolator(new AccelerateInterpolator()); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); dispatchAddStarting(viewHolder); } @Override public void onAnimationCancel(Animator animation) { super.onAnimationCancel(animation); ViewCompat.setAlpha(target, 1); } @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); animator.removeAllListeners(); dispatchAddFinished(viewHolder); mAddAnimations.remove(viewHolder); dispatchFinishedWhenDone(); } }); animator.start(); }
From source file:com.viewpagerindicator.TabMovablePageIndicator.java
private void animateScrollWithIndicator(TabView tabView) { int scrollPos = tabView.getLeft() - (getWidth() - tabView.getWidth()) / 2; AnimatorSet as = new AnimatorSet(); as.setDuration(300); ArrayList<Animator> animations = new ArrayList<Animator>(); // scroll/*w w w . j a v a 2 s . c o m*/ ObjectAnimator animScrollX = ObjectAnimator.ofInt(TabMovablePageIndicator.this, "scrollX", scrollPos); animScrollX.setInterpolator(new AccelerateDecelerateInterpolator()); animations.add(animScrollX); // indicator position int left = tabView.getLeft(); // int width = tabView.getWidth(); int textWidth = tabView.wordWidth; // int x = left + (width - textWidth) / 2 - mExtendWidth * 2; // x = x < 0 ? 0 : x; ObjectAnimator translateXAnim = ObjectAnimator.ofFloat(mIndicator, "translationX", left); translateXAnim.setInterpolator(new OvershootInterpolator(0.8f)); animations.add(translateXAnim); // indicator width ValueAnimator animWidth = ValueAnimator.ofInt(mIndicator.getLayoutParams().width, textWidth + mExtendWidth * 2); animWidth.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) mIndicator.getLayoutParams(); lp.width = (Integer) animation.getAnimatedValue(); mIndicator.setLayoutParams(lp); requestLayout(); } }); animations.add(animWidth); as.playTogether(animations); as.start(); }
From source file:io.romain.passport.ui.AddCityActivity.java
private void hideLoadingSpinner() { ObjectAnimator a = ObjectAnimator.ofFloat(mLoading, View.ALPHA, 1, 0); a.addListener(new SimpleAnimatorListener() { @Override/*from www . j a v a 2 s. com*/ public void onAnimationEnd(Animator animation) { mLoading.setVisibility(View.GONE); } }); ObjectAnimator b = ObjectAnimator.ofFloat(mContainer, View.ALPHA, 0, 1); b.addListener(new SimpleAnimatorListener() { @Override public void onAnimationStart(Animator animation) { mContainer.setAlpha(0); mContainer.setVisibility(View.VISIBLE); mEditText.requestFocus(); mEditText.setError(getString(R.string.add_city_error)); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0); } }); AnimatorSet transition = new AnimatorSet(); transition.playTogether(a, b); transition.setDuration(300); transition.setInterpolator(AnimUtils.getFastOutSlowInInterpolator(this)); transition.start(); }
From source file:io.romain.passport.ui.AddCityActivity.java
private void showLoadingSpinner() { View view = getCurrentFocus(); if (view != null) { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); }// w ww . j a v a 2 s . co m ObjectAnimator a = ObjectAnimator.ofFloat(mLoading, View.ALPHA, 0, 1); a.addListener(new SimpleAnimatorListener() { @Override public void onAnimationStart(Animator animation) { mLoading.setAlpha(0); mLoading.setVisibility(View.VISIBLE); } }); ObjectAnimator b = ObjectAnimator.ofFloat(mContainer, View.ALPHA, 1, 0); b.addListener(new SimpleAnimatorListener() { @Override public void onAnimationEnd(Animator animation) { mContainer.setVisibility(View.INVISIBLE); } }); AnimatorSet transition = new AnimatorSet(); transition.playTogether(a, b); transition.setDuration(300); transition.setInterpolator(AnimUtils.getFastOutSlowInInterpolator(this)); transition.start(); }
From source file:com.gudong.appkit.ui.fragment.AppListFragment.java
@Override public void onClickListItemIcon(View iconView, AppEntity entity) { ObjectAnimator animatorRotation = ObjectAnimator.ofFloat(iconView, "rotation", 0, 360); ObjectAnimator scaleRotationX = ObjectAnimator.ofFloat(iconView, "scaleX", 0, 1F); ObjectAnimator scaleRotationY = ObjectAnimator.ofFloat(iconView, "scaleY", 0, 1F); AnimatorSet animationSet = new AnimatorSet(); animationSet.playTogether(animatorRotation, scaleRotationY, scaleRotationX); animationSet.setDuration(500); animationSet.start();/*from w w w.jav a 2 s . c om*/ }
From source file:com.waz.zclient.views.menus.ConfirmationMenu.java
public void animateToShow(boolean show) { if (show) {/*from w w w . j a va 2 s .co m*/ confirmed = false; cancelled = false; // Init views and post animations to get measured height of message container backgroundView.setAlpha(0); messageContainerView.setVisibility(INVISIBLE); setVisibility(VISIBLE); messageContainerView.post(new Runnable() { @Override public void run() { ObjectAnimator showBackgroundAnimator = ObjectAnimator.ofFloat(backgroundView, View.ALPHA, 0, 1); showBackgroundAnimator.setInterpolator(new Quart.EaseOut()); showBackgroundAnimator .setDuration(getResources().getInteger(R.integer.framework_animation_duration_short)); ObjectAnimator showMessageAnimator = ObjectAnimator.ofFloat(messageContainerView, View.TRANSLATION_Y, messageContainerView.getMeasuredHeight(), 0); showMessageAnimator.setInterpolator(new Expo.EaseOut()); showMessageAnimator .setDuration(getResources().getInteger(R.integer.framework_animation_duration_medium)); showMessageAnimator.setStartDelay(getResources() .getInteger(R.integer.framework_animation__confirmation_menu__show_message_delay)); showMessageAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { messageContainerView.setVisibility(VISIBLE); } }); AnimatorSet showSet = new AnimatorSet(); showSet.playTogether(showBackgroundAnimator, showMessageAnimator); showSet.setDuration(getResources() .getInteger(R.integer.background_accent_color_transition_animation_duration)); showSet.start(); } }); } else { ObjectAnimator hideBackgroundAnimator = ObjectAnimator.ofFloat(backgroundView, View.ALPHA, 1, 0); hideBackgroundAnimator.setInterpolator(new Quart.EaseOut()); hideBackgroundAnimator .setDuration(getResources().getInteger(R.integer.framework_animation_duration_short)); hideBackgroundAnimator.setStartDelay(getResources() .getInteger(R.integer.framework_animation__confirmation_menu__hide_background_delay)); hideBackgroundAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { setVisibility(GONE); boolean checkboxIsSelected = checkBoxView.getVisibility() == VISIBLE && checkBoxView.isSelected(); if (callback != null) { callback.onHideAnimationEnd(confirmed, cancelled, checkboxIsSelected); } } }); ObjectAnimator hideMessageAnimator = ObjectAnimator.ofFloat(messageContainerView, View.TRANSLATION_Y, 0, messageContainerView.getMeasuredHeight()); hideMessageAnimator.setInterpolator(new Expo.EaseIn()); hideMessageAnimator .setDuration(getResources().getInteger(R.integer.framework_animation_duration_medium)); AnimatorSet hideSet = new AnimatorSet(); hideSet.playTogether(hideMessageAnimator, hideBackgroundAnimator); hideSet.start(); } }
From source file:MainActivity.java
private void zoomFromThumbnail(final ImageView imageViewThumb) { if (mCurrentAnimator != null) { mCurrentAnimator.cancel();/*from w ww. j ava 2 s .co m*/ } final Rect startBounds = new Rect(); final Rect finalBounds = new Rect(); final Point globalOffset = new Point(); imageViewThumb.getGlobalVisibleRect(startBounds); findViewById(R.id.frameLayout).getGlobalVisibleRect(finalBounds, globalOffset); mImageViewExpanded .setImageBitmap(loadSampledResource(R.drawable.image, finalBounds.height(), finalBounds.width())); startBounds.offset(-globalOffset.x, -globalOffset.y); finalBounds.offset(-globalOffset.x, -globalOffset.y); float startScale; if ((float) finalBounds.width() / finalBounds.height() > (float) startBounds.width() / startBounds.height()) { startScale = (float) startBounds.height() / finalBounds.height(); float startWidth = startScale * finalBounds.width(); float deltaWidth = (startWidth - startBounds.width()) / 2; startBounds.left -= deltaWidth; startBounds.right += deltaWidth; } else { startScale = (float) startBounds.width() / finalBounds.width(); float startHeight = startScale * finalBounds.height(); float deltaHeight = (startHeight - startBounds.height()) / 2; startBounds.top -= deltaHeight; startBounds.bottom += deltaHeight; } imageViewThumb.setVisibility(View.GONE); mImageViewExpanded.setVisibility(View.VISIBLE); mImageViewExpanded.setPivotX(0f); mImageViewExpanded.setPivotY(0f); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(ObjectAnimator.ofFloat(mImageViewExpanded, View.X, startBounds.left, finalBounds.left)) .with(ObjectAnimator.ofFloat(mImageViewExpanded, View.Y, startBounds.top, finalBounds.top)) .with(ObjectAnimator.ofFloat(mImageViewExpanded, View.SCALE_X, startScale, 1f)) .with(ObjectAnimator.ofFloat(mImageViewExpanded, View.SCALE_Y, startScale, 1f)); animatorSet.setDuration(1000); animatorSet.setInterpolator(new AccelerateInterpolator()); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mCurrentAnimator = null; } @Override public void onAnimationCancel(Animator animation) { mCurrentAnimator = null; } }); animatorSet.start(); mCurrentAnimator = animatorSet; }
From source file:me.hammarstrom.imagerecognition.activities.MainActivity.java
private void convertResponseToString(BatchAnnotateImagesResponse response) { Log.d(TAG, ":: " + response.getResponses().toString()); List<FaceAnnotation> faces = response.getResponses().get(0).getFaceAnnotations(); List<EntityAnnotation> labels = response.getResponses().get(0).getLabelAnnotations(); // Label string to be populated with data for TextToSpeech String label = ""; if (labels != null && labels.size() > 0) { label = "The image may contain "; List<Animator> scoreViewAnimations = new ArrayList<>(); List<Animator> scoreAlphaAnimations = new ArrayList<>(); List<Animator> showScoreAnimations = new ArrayList<>(); for (EntityAnnotation l : labels) { if (l.getScore() < 0.6f) { continue; }//from ww w.j a v a2s. c om // Add label description (ex. laptop, desk, person, etc.) label += l.getDescription() + ", "; /** * Create a new {@link ScoreView} and populate it with label description and score */ ScoreView scoreView = new ScoreView(MainActivity.this); int padding = (int) DeviceDimensionsHelper.convertDpToPixel(8, this); scoreView.setPadding(padding, padding, padding, padding); scoreView.setScore(l.getScore()); scoreView.setLabelPosition(ScoreView.LABEL_POSITION_RIGHT); scoreView.setLabelText(l.getDescription()); scoreView.setAlpha(0f); scoreView.setTranslationX((DeviceDimensionsHelper.getDisplayWidth(this) / 2) * -1); // Add ScoreView to result layout mScoreResultLayout.addView(scoreView); // Create animations to used to show the ScoreView in a nice way ObjectAnimator animator = ObjectAnimator.ofFloat(scoreView, "translationX", (DeviceDimensionsHelper.getDisplayWidth(this) / 2) * -1, 0f); animator.setInterpolator(new OvershootInterpolator()); scoreViewAnimations.add(animator); ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(scoreView, "alpha", 0f, 1f); scoreAlphaAnimations.add(alphaAnimator); // Get the animation to show the actual score from ScoreView object showScoreAnimations.addAll(scoreView.getShowScoreAnimationsList()); } // Set reset button visibility to visible mButtonReset.setVisibility(View.VISIBLE); // Setup and play the animations AnimatorSet translationSet = new AnimatorSet(); translationSet.playSequentially(scoreViewAnimations); translationSet.setDuration(300); AnimatorSet alphaSet = new AnimatorSet(); alphaSet.playSequentially(scoreAlphaAnimations); alphaSet.setDuration(300); AnimatorSet showScoreSet = new AnimatorSet(); showScoreSet.playTogether(showScoreAnimations); showLoading(false); AnimatorSet set = new AnimatorSet(); set.play(translationSet).with(alphaSet).before(showScoreSet); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); mButtonReset.animate().alpha(1f).start(); } }); set.start(); } else { // Set reset button visibility to visible mButtonReset.setVisibility(View.VISIBLE); mButtonReset.setAlpha(1f); } // Handle detected faces String facesFound = ""; if (faces != null && faces.size() > 0) { FaceGraphicOverlay faceGraphicOverlay = new FaceGraphicOverlay(MainActivity.this); faceGraphicOverlay.addFaces(faces); faceGraphicOverlay.setTag("faceOverlay"); mCameraPreviewLayout.addView(faceGraphicOverlay); facesFound = FaceFoundHelper.getFacesFoundString(this, faces); } // Add the detected image data to TTS engine mTts.speak(label, TextToSpeech.QUEUE_FLUSH, null); mTts.speak(facesFound, TextToSpeech.QUEUE_ADD, null); }