List of usage examples for android.view.animation AccelerateInterpolator AccelerateInterpolator
public AccelerateInterpolator()
From source file:org.fossasia.phimpme.leafpic.activities.PlayerActivity.java
private void hideSystemBars() { toolbar.animate().translationY(-toolbar.getHeight()).setInterpolator(new AccelerateInterpolator()) .setDuration(200).start();/* w w w. j a v a2s. com*/ getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar | View.SYSTEM_UI_FLAG_IMMERSIVE); }
From source file:com.sinyuk.jianyimaterial.widgets.FloatingToolbar.java
@TargetApi(21) private void showLollipopImpl() { int rootWidth = mRoot.getWidth(); float endFabX; float controlX; if (mFabOriginalX > rootWidth / 2f) { endFabX = rootWidth / 2f + (mFabOriginalX - rootWidth / 2f) / 4f; controlX = mFabOriginalX * 0.98f; } else {/*from www .j a v a 2 s. co m*/ endFabX = rootWidth / 2f - (mFabOriginalX - rootWidth / 2f) / 4f; controlX = mFabOriginalX * 1.02f; } /** * Animate FAB movement */ final Path path = new Path(); path.moveTo(mFab.getX(), mFab.getY()); final float x2 = controlX; final float y2 = getY(); path.quadTo(x2, y2, endFabX, getY()); ObjectAnimator anim = ObjectAnimator.ofFloat(mFab, View.X, View.Y, path); anim.setInterpolator(new AccelerateDecelerateInterpolator()); anim.setDuration(FAB_MORPH_DURATION); anim.start(); /** * Fade FAB drawable */ Drawable drawable = mFab.getDrawable(); if (drawable != null) { anim = ObjectAnimator.ofPropertyValuesHolder(drawable, PropertyValuesHolder.ofInt("alpha", 0)); anim.setInterpolator(new AccelerateDecelerateInterpolator()); anim.setDuration((long) (FAB_MORPH_DURATION / 3f)); anim.start(); } /** * Animate FAB elevation to 8dp */ anim = ObjectAnimator.ofFloat(mFab, View.TRANSLATION_Z, dpToPixels(2)); anim.setInterpolator(new AccelerateDecelerateInterpolator()); anim.setDuration(FAB_MORPH_DURATION); anim.start(); /** * Create circular reveal */ Animator toolbarReveal = ViewAnimationUtils.createCircularReveal(this, getWidth() / 2, getHeight() / 2, (float) mFab.getWidth() / 2f, (float) (Math.hypot(getWidth() / 2, getHeight() / 2))); toolbarReveal.setDuration(CIRCULAR_REVEAL_DURATION); toolbarReveal.setTarget(this); toolbarReveal.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); mFab.setVisibility(View.INVISIBLE); setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); mMorphing = false; } }); toolbarReveal.setInterpolator(new AccelerateInterpolator()); toolbarReveal.setStartDelay(CIRCULAR_REVEAL_DELAY); toolbarReveal.start(); /** * Animate FloatingToolbar elevation to 8dp */ anim = ObjectAnimator.ofFloat(this, View.TRANSLATION_Z, dpToPixels(2)); anim.setDuration(CIRCULAR_REVEAL_DURATION); anim.setStartDelay(CIRCULAR_REVEAL_DELAY); anim.start(); }
From source file:com.evandroid.musica.fragment.LocalLyricsFragment.java
public void animateUndo(Lyrics[] lyricsArray) { final HashMap<Long, Integer> itemIdTopMap = new HashMap<>(); int firstVisiblePosition = megaListView.getFirstVisiblePosition(); for (int i = 0; i < megaListView.getChildCount(); ++i) { View child = megaListView.getChildAt(i); int position = firstVisiblePosition + i; long itemId = megaListView.getAdapter().getItemId(position); itemIdTopMap.put(itemId, child.getTop()); }//from w w w . j a v a 2 s.c o m final boolean[] firstAnimation = { true }; // Delete the item from the adapter final int groupPosition = ((LocalAdapter) getExpandableListAdapter()).add(lyricsArray[0]); megaListView.setAdapter(getExpandableListAdapter()); megaListView.post(new Runnable() { @Override public void run() { megaListView.expandGroupWithAnimation(groupPosition); } }); new WriteToDatabaseTask(LocalLyricsFragment.this).execute(LocalLyricsFragment.this, null, lyricsArray); final ViewTreeObserver[] observer = { megaListView.getViewTreeObserver() }; observer[0].addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { public boolean onPreDraw() { observer[0].removeOnPreDrawListener(this); firstAnimation[0] = true; int firstVisiblePosition = megaListView.getFirstVisiblePosition(); for (int i = 0; i < megaListView.getChildCount(); ++i) { final View child = megaListView.getChildAt(i); int position = firstVisiblePosition + i; long itemId = getListView().getAdapter().getItemId(position); Integer formerTop = itemIdTopMap.get(itemId); int newTop = child.getTop(); if (formerTop != null) { if (formerTop != newTop) { int delta = formerTop - newTop; child.setTranslationY(delta); int MOVE_DURATION = 500; child.animate().setDuration(MOVE_DURATION).translationY(0); if (firstAnimation[0]) { child.animate().setListener(new AnimatorActionListener(new Runnable() { public void run() { mBackgroundContainer.hideBackground(); mSwiping = false; getListView().setEnabled(true); } }, AnimatorActionListener.ActionType.END)); firstAnimation[0] = false; } } } else { // Animate new views along with the others. The catch is that they did not // exist in the start state, so we must calculate their starting position // based on neighboring views. int childHeight = child.getHeight() + megaListView.getDividerHeight(); formerTop = newTop - childHeight; int delta = formerTop - newTop; final float z = ((CardView) child).getCardElevation(); ((CardView) child).setCardElevation(0f); child.setTranslationY(delta); final int MOVE_DURATION = 500; child.animate().setDuration(MOVE_DURATION).translationY(0); child.animate().setListener(new AnimatorActionListener(new Runnable() { public void run() { mBackgroundContainer.hideBackground(); mSwiping = false; getListView().setEnabled(true); ObjectAnimator anim = ObjectAnimator.ofFloat(child, "cardElevation", 0f, z); anim.setDuration(200); anim.setInterpolator(new AccelerateInterpolator()); anim.start(); } }, AnimatorActionListener.ActionType.END)); firstAnimation[0] = false; } } if (firstAnimation[0]) { mBackgroundContainer.hideBackground(); mSwiping = false; getListView().setEnabled(true); firstAnimation[0] = false; } itemIdTopMap.clear(); return true; } }); }
From source file:orbin.deskclock.timer.TimerFragment.java
/** * @param timerToRemove the timer to be removed during the animation *///from w w w. ja va2 s. c o m private void animateTimerRemove(final Timer timerToRemove) { final long duration = UiDataModel.getUiDataModel().getShortAnimationDuration(); final Animator fadeOut = ObjectAnimator.ofFloat(mViewPager, ALPHA, 1, 0); fadeOut.setDuration(duration); fadeOut.setInterpolator(new DecelerateInterpolator()); fadeOut.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { DataModel.getDataModel().removeTimer(timerToRemove); Events.sendTimerEvent(R.string.action_delete, R.string.label_deskclock); } }); final Animator fadeIn = ObjectAnimator.ofFloat(mViewPager, ALPHA, 0, 1); fadeIn.setDuration(duration); fadeIn.setInterpolator(new AccelerateInterpolator()); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(fadeOut).before(fadeIn); animatorSet.start(); }
From source file:com.horaapps.leafpic.PlayerActivity.java
private void hideControls() { mediaController.hide();/* w w w .j a va 2 s . c o m*/ toolbar.animate().translationY(-toolbar.getHeight()).setInterpolator(new AccelerateInterpolator()) .setDuration(200).start(); getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar | View.SYSTEM_UI_FLAG_IMMERSIVE); fullscreen = true; }
From source file:com.android.deskclock.timer.TimerFragment.java
/** * @param toView one of {@link #mTimersView} or {@link #mCreateTimerView} * @param timerToRemove the timer to be removed during the animation; {@code null} if no timer * should be removed/*from w w w . j a v a 2 s . c o m*/ */ private void animateToView(View toView, final Timer timerToRemove) { if (mCurrentView == toView) { throw new IllegalStateException("toView is already the current view"); } final boolean toTimers = toView == mTimersView; // Avoid double-taps by enabling/disabling the set of buttons active on the new view. mLeftButton.setEnabled(toTimers); mRightButton.setEnabled(toTimers); mCancelCreateButton.setEnabled(!toTimers); final Animator rotateFrom = ObjectAnimator.ofFloat(mCurrentView, SCALE_X, 1, 0); rotateFrom.setDuration(mShortAnimationDuration); rotateFrom.setInterpolator(new DecelerateInterpolator()); rotateFrom.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (timerToRemove != null) { DataModel.getDataModel().removeTimer(timerToRemove); Events.sendTimerEvent(R.string.action_delete, R.string.label_deskclock); } mCurrentView.setScaleX(1); if (toTimers) { showTimersView(); } else { showCreateTimerView(); } } }); final Animator rotateTo = ObjectAnimator.ofFloat(toView, SCALE_X, 0, 1); rotateTo.setDuration(mShortAnimationDuration); rotateTo.setInterpolator(new AccelerateInterpolator()); final float preScale = toTimers ? 0 : 1; final float postScale = toTimers ? 1 : 0; final Animator fabAnimator = getScaleAnimator(mFab, preScale, postScale); final Animator leftButtonAnimator = getScaleAnimator(mLeftButton, preScale, postScale); final Animator rightButtonAnimator = getScaleAnimator(mRightButton, preScale, postScale); final AnimatorSet buttons = new AnimatorSet(); buttons.setDuration(toTimers ? mMediumAnimationDuration : mShortAnimationDuration); buttons.play(leftButtonAnimator).with(rightButtonAnimator).with(fabAnimator); buttons.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mLeftButton.setVisibility(toTimers ? VISIBLE : INVISIBLE); mRightButton.setVisibility(toTimers ? VISIBLE : INVISIBLE); mFab.setScaleX(1); mFab.setScaleY(1); mLeftButton.setScaleX(1); mLeftButton.setScaleY(1); mRightButton.setScaleX(1); mRightButton.setScaleY(1); } }); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(rotateFrom).before(rotateTo).with(buttons); animatorSet.start(); }
From source file:com.songcode.materialnotes.ui.NoteEditActivity.java
private void animateRevealShow(View targetview, View startView) { if (isActionInsertOrEdit()) { final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); int cx = startView.getLeft() + (startView.getWidth() / 2); //middle of button int cy = startView.getTop() + (startView.getHeight() / 2); //middle of button int radius = (int) Math.sqrt(Math.pow(cx, 2) + Math.pow(cy, 2)); //hypotenuse to top left Animator anim = ViewAnimationUtils.createCircularReveal(targetview, cx, cy, 0, radius); targetview.setVisibility(View.VISIBLE); anim.setInterpolator(new DecelerateInterpolator()); anim.addListener(new Animator.AnimatorListener() { @Override//from www . ja va 2 s .com public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { mNoteEditor.requestFocus(); imm.showSoftInput(mNoteEditor, 0); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); anim.setDuration(ANIM_DURATION); anim.start(); } else if (isActionActionView()) { mAnimBackGroudView.animate().scaleX(.92f).scaleY(.92f).alpha(.6f).setDuration(ANIM_DURATION) .setInterpolator(new AccelerateInterpolator()).start(); mNoteEditor.animate().alpha(1).setStartDelay(400).setDuration(ANIM_DURATION); ViewCompat.setTransitionName(mAnimTargetView, "target_anim_view"); } }
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.// ww w . j a va 2s. com */ 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:com.wizardsofm.deskclock.timer.TimerFragment.java
/** * @param timerToRemove the timer to be removed during the animation *//*from ww w . j a v a 2s .c o m*/ private void animateTimerRemove(final Timer timerToRemove) { final long duration = UiDataModel.getUiDataModel().getShortAnimationDuration(); final Animator fadeOut = ObjectAnimator.ofFloat(mViewPager, ALPHA, 1, 0); fadeOut.setDuration(duration); fadeOut.setInterpolator(new DecelerateInterpolator()); fadeOut.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { DataModel.getDataModel().removeTimer(timerToRemove); Events.sendTimerEvent(com.wizardsofm.deskclock.R.string.action_delete, com.wizardsofm.deskclock.R.string.label_deskclock); } }); final Animator fadeIn = ObjectAnimator.ofFloat(mViewPager, ALPHA, 0, 1); fadeIn.setDuration(duration); fadeIn.setInterpolator(new AccelerateInterpolator()); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(fadeOut).before(fadeIn); animatorSet.start(); }
From source file:com.stasbar.knowyourself.timer.TimerFragment.java
/** * @param timerToRemove the timer to be removed during the animation */// ww w .j a va 2 s .com private void animateTimerRemove(final Timer timerToRemove) { final long duration = UiDataModel.getUiDataModel().getShortAnimationDuration(); final Animator fadeOut = ObjectAnimator.ofFloat(mViewPager, ALPHA, 1, 0); fadeOut.setDuration(duration); fadeOut.setInterpolator(new DecelerateInterpolator()); fadeOut.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { LogUtils.d("animateTimerRemove"); DataModel.getDataModel().removeTimer(timerToRemove); } }); final Animator fadeIn = ObjectAnimator.ofFloat(mViewPager, ALPHA, 0, 1); fadeIn.setDuration(duration); fadeIn.setInterpolator(new AccelerateInterpolator()); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(fadeOut).before(fadeIn); animatorSet.start(); }