List of usage examples for android.animation ObjectAnimator setDuration
@Override @NonNull public ObjectAnimator setDuration(long duration)
From source file:com.waz.zclient.pages.main.conversation.SingleImageFragment.java
private AnimatorSet getSaveImageAnimation(final ImageAsset image) { int totalAnimationDuration = getResources().getInteger(R.integer.framework_animation_duration_long); ObjectAnimator fadeOutAnimator = ObjectAnimator.ofFloat(saveImageViewContainer, View.ALPHA, 1, 0); fadeOutAnimator.setDuration(totalAnimationDuration); ObjectAnimator scaleDownXAnimator = ObjectAnimator.ofFloat(saveImageViewContainer, View.SCALE_X, 0f); ObjectAnimator scaleDownYAnimator = ObjectAnimator.ofFloat(saveImageViewContainer, View.SCALE_Y, 0f); scaleDownXAnimator.setDuration(totalAnimationDuration); scaleDownYAnimator.setDuration(totalAnimationDuration); int moveY = ViewUtils.getOrientationIndependentDisplayHeight(getActivity()) / 2; int moveX;/*from w w w.j ava2s . c o m*/ if (ViewUtils.isInLandscape(getActivity())) { moveX = ViewUtils.getOrientationIndependentDisplayWidth(getActivity()); } else { moveX = ViewUtils.getOrientationIndependentDisplayWidth(getActivity()) / 2; } ObjectAnimator moveXAnimator = ObjectAnimator.ofFloat(saveImageViewContainer, View.TRANSLATION_X, -moveX); ObjectAnimator moveYAnimator = ObjectAnimator.ofFloat(saveImageViewContainer, View.TRANSLATION_Y, moveY); moveXAnimator.setDuration(totalAnimationDuration); moveYAnimator.setDuration(totalAnimationDuration); // Fade out top image view for blur effect ObjectAnimator fadeToBlurredAnimator = ObjectAnimator.ofFloat(saveImageView, View.ALPHA, 1, 0); fadeToBlurredAnimator.setDuration(getResources().getInteger(R.integer.framework_animation_duration_medium)); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.setInterpolator(new Expo.EaseIn()); animatorSet.playTogether(fadeOutAnimator, scaleDownXAnimator, scaleDownYAnimator, moveXAnimator, moveYAnimator, fadeToBlurredAnimator); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (getStoreFactory() == null || getStoreFactory().isTornDown()) { return; } resetSaveImageView(); // Image saving is called here, as an image save triggers a notification which contains a bitmap; // currently that bitmap is quite large, android.app.Notification writes the bitmap to a parcel // on the main thread, dropping a large number of frames and breaking the save animation image.saveImageToGallery(SingleImageFragment.this); enableSaveImageButton(true); } }); return animatorSet; }
From source file:com.hannesdorfmann.search.SearchActivity.java
@OnClick(R.id.fab) protected void save() { // show the save confirmation bubble fab.setVisibility(View.INVISIBLE); confirmSaveContainer.setVisibility(View.VISIBLE); resultsScrim.setVisibility(View.VISIBLE); // expand it once it's been measured and show a scrim over the search results confirmSaveContainer.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override/* ww w. j a v a 2 s . c o m*/ public boolean onPreDraw() { // expand the confirmation confirmSaveContainer.getViewTreeObserver().removeOnPreDrawListener(this); Animator reveal = ViewAnimationUtils.createCircularReveal(confirmSaveContainer, confirmSaveContainer.getWidth() / 2, confirmSaveContainer.getHeight() / 2, fab.getWidth() / 2, confirmSaveContainer.getWidth() / 2); reveal.setDuration(250L); reveal.setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.fast_out_slow_in)); reveal.start(); // show the scrim int centerX = (fab.getLeft() + fab.getRight()) / 2; int centerY = (fab.getTop() + fab.getBottom()) / 2; Animator revealScrim = ViewAnimationUtils.createCircularReveal(resultsScrim, centerX, centerY, 0, (float) Math.hypot(centerX, centerY)); revealScrim.setDuration(400L); revealScrim.setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.linear_out_slow_in)); revealScrim.start(); ObjectAnimator fadeInScrim = ObjectAnimator.ofArgb(resultsScrim, ViewUtils.BACKGROUND_COLOR, Color.TRANSPARENT, ContextCompat.getColor(SearchActivity.this, R.color.scrim)); fadeInScrim.setDuration(800L); fadeInScrim.setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.linear_out_slow_in)); fadeInScrim.start(); // ease in the checkboxes saveDribbble.setAlpha(0.6f); saveDribbble.setTranslationY(saveDribbble.getHeight() * 0.4f); saveDribbble.animate().alpha(1f).translationY(0f).setDuration(200L).setInterpolator(AnimationUtils .loadInterpolator(SearchActivity.this, android.R.interpolator.linear_out_slow_in)); saveDesignerNews.setAlpha(0.6f); saveDesignerNews.setTranslationY(saveDesignerNews.getHeight() * 0.5f); saveDesignerNews.animate().alpha(1f).translationY(0f).setDuration(200L) .setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.linear_out_slow_in)); return false; } }); }
From source file:com.projecttango.examples.java.greenscreen.GreenScreenActivity.java
/** * Here is where you would set up your rendering logic. We're replacing it with a minimalistic, * dummy example, using a standard GLSurfaceView and a basic renderer, for illustration purposes * only.//w w w.jav a 2 s.c om */ private void setupRenderer() { mSurfaceView.setEGLContextClientVersion(2); mRenderer = new GreenScreenRenderer(this, new GreenScreenRenderer.RenderCallback() { @Override public void preRender() { // This is the work that you would do on your main OpenGL render thread. // We need to be careful to not run any Tango-dependent code in the // OpenGL thread unless we know the Tango Service to be properly set up // and connected. if (!mIsConnected) { return; } // Synchronize against concurrently disconnecting the service triggered // from the UI thread. synchronized (GreenScreenActivity.this) { // Connect the Tango SDK to the OpenGL texture ID where we are // going to render the camera. // NOTE: This must be done after both the texture is generated // and the Tango Service is connected. if (mConnectedTextureIdGlThread != mRenderer.getTextureId()) { mTango.connectTextureId(TangoCameraIntrinsics.TANGO_CAMERA_COLOR, mRenderer.getTextureId()); mConnectedTextureIdGlThread = mRenderer.getTextureId(); Log.d(TAG, "connected to texture id: " + mRenderer.getTextureId()); // Set up scene camera projection to match RGB camera intrinsics. mRenderer.setProjectionMatrix(projectionMatrixFromCameraIntrinsics(mIntrinsics)); mRenderer.setCameraIntrinsics(mIntrinsics); } // If there is a new RGB camera frame available, update the texture and // scene camera pose. if (mIsFrameAvailableTangoThread.compareAndSet(true, false)) { double depthTimestamp = 0; TangoPointCloudData pointCloud = mPointCloudManager.getLatestPointCloud(); if (pointCloud != null) { mRenderer.updatePointCloud(pointCloud); depthTimestamp = pointCloud.timestamp; } try { // {@code mRgbTimestampGlThread} contains the exact timestamp at // which the rendered RGB frame was acquired. mRgbTimestampGlThread = mTango.updateTexture(TangoCameraIntrinsics.TANGO_CAMERA_COLOR); // In the following code, we define t0 as the depth timestamp // and t1 as the color camera timestamp. // Calculate the relative pose between color camera frame at // timestamp color_timestamp t1 and depth. TangoPoseData poseColort1Tdeptht0; poseColort1Tdeptht0 = TangoSupport.calculateRelativePose(mRgbTimestampGlThread, TangoPoseData.COORDINATE_FRAME_CAMERA_COLOR, depthTimestamp, TangoPoseData.COORDINATE_FRAME_CAMERA_DEPTH); if (poseColort1Tdeptht0.statusCode == TangoPoseData.POSE_VALID) { float[] colort1Tdeptht0 = poseToMatrix(poseColort1Tdeptht0); mRenderer.updateModelMatrix(colort1Tdeptht0); } else { Log.w(TAG, "Could not get relative pose from camera depth" + " " + "at " + depthTimestamp + " to camera color at " + mRgbTimestampGlThread); } } catch (Exception e) { Log.e(TAG, "Exception on the OpenGL thread", e); } } } } /** * This method is called by the renderer when the screenshot has been taken. */ @Override public void onScreenshotTaken(final Bitmap screenshotBitmap) { // Give immediate feedback to the user. MediaActionSound sound = new MediaActionSound(); sound.play(MediaActionSound.SHUTTER_CLICK); runOnUiThread(new Runnable() { @Override public void run() { mPanelFlash.setVisibility(View.VISIBLE); // Run a fade in and out animation of a white screen. ObjectAnimator fadeIn = ObjectAnimator.ofFloat(mPanelFlash, View.ALPHA, 0, 1); fadeIn.setDuration(100); fadeIn.setInterpolator(new DecelerateInterpolator()); ObjectAnimator fadeOut = ObjectAnimator.ofFloat(mPanelFlash, View.ALPHA, 1, 0); fadeOut.setInterpolator(new AccelerateInterpolator()); fadeOut.setDuration(100); AnimatorSet animation = new AnimatorSet(); animation.playSequentially(fadeIn, fadeOut); animation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mPanelFlash.setVisibility(View.GONE); } }); animation.start(); } }); // Save bitmap to gallery in background. new BitmapSaverTask(screenshotBitmap).execute(); } }); mSurfaceView.setRenderer(mRenderer); }
From source file:io.vit.vitio.Fragments.Today.TodayFragment.java
private void animateView() { PowerManager powerManager = (PowerManager) getActivity().getSystemService(Context.POWER_SERVICE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && powerManager.isPowerSaveMode()) { return;/* w w w . ja v a 2s . com*/ } //float dimension = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 200, getResources().getDisplayMetrics()); ObjectAnimator objectAnimatorX = ObjectAnimator.ofFloat(ocassionImage, "scaleX", 1f, 0.8f); ObjectAnimator objectAnimatorY = ObjectAnimator.ofFloat(ocassionImage, "scaleY", 1f, 0.8f); objectAnimatorX.setDuration(6000); objectAnimatorY.setDuration(6000); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(objectAnimatorX, objectAnimatorY); animatorSet.setInterpolator(new LinearInterpolator()); objectAnimatorX.setRepeatCount(ObjectAnimator.INFINITE); objectAnimatorX.setRepeatMode(ObjectAnimator.REVERSE); objectAnimatorY.setRepeatCount(ObjectAnimator.INFINITE); objectAnimatorY.setRepeatMode(ObjectAnimator.REVERSE); animatorSet.start(); objectAnimatorX.start(); }
From source file:com.justplay1.shoppist.features.search.widget.FloatingSearchView.java
private void fadeIn(boolean enter) { ValueAnimator backgroundAnim;/*from w w w . j av a2s. c o m*/ if (Build.VERSION.SDK_INT >= 19) { backgroundAnim = ObjectAnimator.ofInt(backgroundDrawable, "alpha", enter ? 255 : 0); } else { backgroundAnim = ValueAnimator.ofInt(enter ? 0 : 255, enter ? 255 : 0); backgroundAnim.addUpdateListener(animation -> { int value = (Integer) animation.getAnimatedValue(); backgroundDrawable.setAlpha(value); }); } backgroundAnim.setDuration(enter ? DEFAULT_DURATION_ENTER : DEFAULT_DURATION_EXIT); backgroundAnim.setInterpolator(enter ? DECELERATE : ACCELERATE); backgroundAnim.start(); Drawable icon = unwrap(getIcon()); if (icon != null) { ObjectAnimator iconAnim = ObjectAnimator.ofFloat(icon, "progress", enter ? 1 : 0); iconAnim.setDuration(backgroundAnim.getDuration()); iconAnim.setInterpolator(backgroundAnim.getInterpolator()); iconAnim.start(); } }
From source file:com.ae.apps.tripmeter.fragments.expenses.TripDetailsFragment.java
private void initViews(View inflatedView) { mExpenseManager = ExpenseManager.newInstance(getContext()); mTrip = mExpenseManager.getTripByTripId(String.valueOf(mTripId)); // Update the trip with the ContactVos from member ids mTrip.getMembers().addAll(mExpenseManager.getContactsFromIds(mTrip.getMemberIds())); TextView tripName = (TextView) inflatedView.findViewById(R.id.txtTripName); mTripTotalExpenses = (TextView) inflatedView.findViewById(R.id.txtTripTotalAmount); mTripMembersContainer = (LinearLayout) inflatedView.findViewById(R.id.tripMembersContainer); addTripMembersToContainer();/*from w w w . j a v a2 s. c om*/ tripName.setText(mTrip.getName()); updateTripTotalExpenses(); FloatingActionButton floatingActionButton = (FloatingActionButton) inflatedView.findViewById(R.id.fab); floatingActionButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showAddExpenseDialog(); } }); final ImageButton btnShowHideExpenseMembers = (ImageButton) inflatedView .findViewById(R.id.btnShowHideExpenseMembers); btnShowHideExpenseMembers.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ObjectAnimator btnAnimation; if (isMembersContainerDisplayed) { mTripMembersContainer.setVisibility(View.GONE); isMembersContainerDisplayed = false; btnAnimation = ObjectAnimator.ofFloat(btnShowHideExpenseMembers, "rotation", 180, 0); } else { mTripMembersContainer.setVisibility(View.VISIBLE); isMembersContainerDisplayed = true; btnAnimation = ObjectAnimator.ofFloat(btnShowHideExpenseMembers, "rotation", 0, 180); } btnAnimation.setDuration(200).start(); } }); mViewPager = (ViewPager) inflatedView.findViewById(R.id.viewpager); setUpViewPager(); TabLayout mTabLayout = (TabLayout) inflatedView.findViewById(R.id.tabs); mTabLayout.setupWithViewPager(mViewPager); // Bundle args = new Bundle(); // args.putString(AppConstants.KEY_TRIP_ID, mTripId); // Fragment fragment = TripExpenseFragment.newInstance(args); // FragmentTransaction transaction = getChildFragmentManager().beginTransaction(); // transaction.replace(R.id.frag, fragment).commit(); }
From source file:com.android.tv.menu.MenuLayoutManager.java
private ObjectAnimator createAlphaAnimator(View view, float from, float to, TimeInterpolator interpolator) { ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.ALPHA, from, to); animator.setDuration(mRowAnimationDuration); animator.setInterpolator(interpolator); return animator; }
From source file:com.android.tv.menu.MenuLayoutManager.java
private ObjectAnimator createAlphaAnimator(View view, float from, float to, float end, TimeInterpolator interpolator) { ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.ALPHA, from, to); animator.setDuration(mRowAnimationDuration); animator.setInterpolator(interpolator); mPropertyValuesAfterAnimation.add(new ViewPropertyValueHolder(View.ALPHA, view, end)); return animator; }
From source file:com.android.tv.menu.MenuLayoutManager.java
private ObjectAnimator createScaleXAnimator(View view, float from, float to) { ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.SCALE_X, from, to); animator.setDuration(mRowAnimationDuration); animator.setInterpolator(mFastOutSlowIn); return animator; }
From source file:com.android.tv.menu.MenuLayoutManager.java
private ObjectAnimator createScaleYAnimator(View view, float from, float to) { ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.SCALE_Y, from, to); animator.setDuration(mRowAnimationDuration); animator.setInterpolator(mFastOutSlowIn); return animator; }