Example usage for android.view.animation AccelerateInterpolator AccelerateInterpolator

List of usage examples for android.view.animation AccelerateInterpolator AccelerateInterpolator

Introduction

In this page you can find the example usage for android.view.animation AccelerateInterpolator AccelerateInterpolator.

Prototype

public AccelerateInterpolator() 

Source Link

Usage

From source file:org.torproject.android.OrbotMainActivity.java

public void spinOrbot(float direction) {
    sendIntentToService(TorServiceConstants.CMD_NEWNYM);

    Toast.makeText(this, R.string.newnym, Toast.LENGTH_SHORT).show();

    //    Rotate3dAnimation rotation = new Rotate3dAnimation(ROTATE_FROM, ROTATE_TO*direction, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    Rotate3dAnimation rotation = new Rotate3dAnimation(ROTATE_FROM, ROTATE_TO * direction,
            imgStatus.getWidth() / 2f, imgStatus.getWidth() / 2f, 20f, false);
    rotation.setFillAfter(true);/*from w w w  .j  a v a 2  s  .c o m*/
    rotation.setInterpolator(new AccelerateInterpolator());
    rotation.setDuration((long) 2 * 1000);
    rotation.setRepeatCount(0);
    imgStatus.startAnimation(rotation);

}

From source file:org.telegram.ui.SettingsActivity.java

private void needLayout() {
    FrameLayout.LayoutParams layoutParams;
    int newTop = (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0)
            + ActionBar.getCurrentActionBarHeight();
    if (listView != null) {
        layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
        if (layoutParams.topMargin != newTop) {
            layoutParams.topMargin = newTop;
            listView.setLayoutParams(layoutParams);
            extraHeightView.setTranslationY(newTop);
        }/*www .  j  av a  2s .co m*/
    }

    if (avatarContainer != null) {
        float diff = extraHeight / (float) AndroidUtilities.dp(88);
        extraHeightView.setScaleY(diff);
        shadowView.setTranslationY(newTop + extraHeight);

        writeButton.setTranslationY((actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0)
                + ActionBar.getCurrentActionBarHeight() + extraHeight - AndroidUtilities.dp(29.5f));

        final boolean setVisible = diff > 0.2f;
        boolean currentVisible = writeButton.getTag() == null;
        if (setVisible != currentVisible) {
            if (setVisible) {
                writeButton.setTag(null);
                writeButton.setVisibility(View.VISIBLE);
            } else {
                writeButton.setTag(0);
            }
            if (writeButtonAnimation != null) {
                AnimatorSet old = writeButtonAnimation;
                writeButtonAnimation = null;
                old.cancel();
            }
            writeButtonAnimation = new AnimatorSet();
            if (setVisible) {
                writeButtonAnimation.setInterpolator(new DecelerateInterpolator());
                writeButtonAnimation.playTogether(ObjectAnimator.ofFloat(writeButton, "scaleX", 1.0f),
                        ObjectAnimator.ofFloat(writeButton, "scaleY", 1.0f),
                        ObjectAnimator.ofFloat(writeButton, "alpha", 1.0f));
            } else {
                writeButtonAnimation.setInterpolator(new AccelerateInterpolator());
                writeButtonAnimation.playTogether(ObjectAnimator.ofFloat(writeButton, "scaleX", 0.2f),
                        ObjectAnimator.ofFloat(writeButton, "scaleY", 0.2f),
                        ObjectAnimator.ofFloat(writeButton, "alpha", 0.0f));
            }
            writeButtonAnimation.setDuration(150);
            writeButtonAnimation.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    if (writeButtonAnimation != null && writeButtonAnimation.equals(animation)) {
                        writeButton.setVisibility(setVisible ? View.VISIBLE : View.GONE);
                        writeButtonAnimation = null;
                    }
                }
            });
            writeButtonAnimation.start();
        }

        avatarContainer.setScaleX((42 + 18 * diff) / 42.0f);
        avatarContainer.setScaleY((42 + 18 * diff) / 42.0f);
        avatarProgressView.setSize(AndroidUtilities.dp(26 / avatarContainer.getScaleX()));
        avatarProgressView.setStrokeWidth(3 / avatarContainer.getScaleX());
        float avatarY = (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0)
                + ActionBar.getCurrentActionBarHeight() / 2.0f * (1.0f + diff) - 21 * AndroidUtilities.density
                + 27 * AndroidUtilities.density * diff;
        avatarContainer.setTranslationY((float) Math.ceil(avatarY));
        nameTextView.setTranslationY((float) Math.floor(avatarY) - (float) Math.ceil(AndroidUtilities.density)
                + (float) Math.floor(7 * AndroidUtilities.density * diff));
        onlineTextView.setTranslationY((float) Math.floor(avatarY) + AndroidUtilities.dp(22)
                + (float) Math.floor(11 * AndroidUtilities.density) * diff);
        nameTextView.setScaleX(1.0f + 0.12f * diff);
        nameTextView.setScaleY(1.0f + 0.12f * diff);

        if (LocaleController.isRTL) {
            avatarContainer.setTranslationX(AndroidUtilities.dp(47) * diff);
            nameTextView.setTranslationX(21 * AndroidUtilities.density * diff);
            onlineTextView.setTranslationX(21 * AndroidUtilities.density * diff);
        } else {
            avatarContainer.setTranslationX(-AndroidUtilities.dp(47) * diff);
            nameTextView.setTranslationX(-21 * AndroidUtilities.density * diff);
            onlineTextView.setTranslationX(-21 * AndroidUtilities.density * diff);
        }
    }
}

From source file:com.gigabytedevelopersinc.app.calculator.Calculator.java

private Cling initCling(int clingId, int[] positionData, float revealRadius, boolean showHand,
        boolean animate) {
    setPagingEnabled(false);/*from  ww w  .  jav  a  2s  .co m*/
    clingActive = true;

    Cling cling = findViewById(clingId);
    if (cling != null) {
        //getActionBar().hide();
        if (getActionBar() != null) {
            getActionBar().hide();
        }
        cling.init(this, positionData, revealRadius, showHand);
        cling.setVisibility(View.VISIBLE);
        cling.setLayerType(View.LAYER_TYPE_HARDWARE, null);
        if (animate) {
            cling.buildLayer();
            cling.setAlpha(0f);
            cling.animate().alpha(1f).setInterpolator(new AccelerateInterpolator())
                    .setDuration(Cling.SHOW_CLING_DURATION).setStartDelay(0).start();
        } else {
            cling.setAlpha(1f);
        }
    }
    return cling;
}

From source file:com.achep.acdisplay.ui.fragments.AcDisplayFragment.java

/**
 * Updates the visibility of divider between
 * the scene and icons.//  w w w  .ja  va2  s  .c o m
 */
@SuppressLint("NewApi")
private void updateDividerVisibility(boolean animate) {
    final View view = mDividerView;

    final boolean visible = view.getVisibility() == View.VISIBLE;
    final boolean visibleNow = !mWidgetsMap.isEmpty();

    if (animate && isAnimatable()) {
        int visibleInt = MathUtils.bool(visible);
        int visibleNowInt = MathUtils.bool(visibleNow);
        float[] values = { 1.0f, 0.1f, 1.0f, 0.5f };

        ViewUtils.setVisible(view, true);
        view.setScaleX(values[1 - visibleInt]);
        view.setAlpha(values[3 - visibleInt]);
        view.animate().scaleX(values[1 - visibleNowInt]).alpha(values[3 - visibleNowInt])
                .setInterpolator(new AccelerateInterpolator()).setListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        super.onAnimationEnd(animation);
                        ViewUtils.setVisible(view, visibleNow, View.INVISIBLE);
                        view.setAlpha(1);
                        view.setScaleX(1);
                    }
                });
    } else {
        ViewUtils.setVisible(view, visibleNow, View.INVISIBLE);
    }
}

From source file:com.xmobileapp.rockplayer.RockPlayer.java

/*******************************************
 * // w  w w.  j  av a2  s  .  c  o  m
 * initializeAnimations
 * 
 *******************************************/
private void initializeAnimations() {
    /*
     * Puts the left panel in perspective
     */
    if (this.display.getOrientation() == 0)
        perspectiveLeft = new Rotate3dAnimation(0, 0, // X-axis rotation
                30, 30, // Y-axis rotation
                0, 0, // Z-axis rotation
                100, 100, // rotation center
                0.0f, // Z-depth
                false); //reverse movement
    else
        perspectiveLeft = new Rotate3dAnimation(0, 0, // X-axis rotation
                15, 15, // Y-axis rotation
                0, 0, // Z-axis rotation
                100, 100, // rotation center
                0.0f, // Z-depth
                false); //reverse movement
    perspectiveLeft.setDuration(1);
    perspectiveLeft.setFillAfter(true);

    /*
     * Puts the right panel in perspective
     */
    if (this.display.getOrientation() == 0)
        perspectiveRight = new Rotate3dAnimation(0, 0, // X-axis rotation
                -30, -30, // Y-axis rotation
                0, 0, // Z-axis rotation
                100, 100, // rotation center
                0.0f, // Z-depth
                false); //reverse movement
    else
        perspectiveRight = new Rotate3dAnimation(0, 0, // X-axis rotation
                -15, -15, // Y-axis rotation
                0, 0, // Z-axis rotation
                100, 100, // rotation center
                0.0f, // Z-depth
                false); //reverse movement
    perspectiveRight.setDuration(1);
    perspectiveRight.setFillAfter(true);
    //perspectiveLeftAnim.setDuration(500);
    //perspectiveLeftAnim.setInterpolator(new AccelerateInterpolator());

    /*
     * Hides a panel left
     */
    hideLeft = new Rotate3dAnimationY(30, 90, // Y-axis rotation
            100, 100, // rotation center
            0.0f, // Z-depth
            false); //reverse movement
    hideLeft.setDuration(300);
    hideLeft.setFillAfter(true);
    hideLeft.setInterpolator(new DecelerateInterpolator());
    hideLeft.setAnimationListener(this.hideAlbumAnimationListener);

    /*
     * Shows a panel hidden to the left
     */
    showLeft = new Rotate3dAnimationY(270, 390, // Y-axis rotation
            100, 100, // rotation center
            0.0f, // Z-depth
            false); //reverse movement
    showLeft.setDuration(600); // double of the angle
    showLeft.setFillAfter(true);
    showLeft.setInterpolator(new AccelerateInterpolator());
    showLeft.setAnimationListener(this.showAlbumAnimationListener);

    /*
     * Fades an Album out
     */
    /*fadeAlbumOut = new AlphaAnimation((float) 1.0, 0);
    fadeAlbumOut.setDuration(250);
    fadeAlbumOut.setFillAfter(true);
    fadeAlbumOut.setAnimationListener(this.hideAlbumAnimationListener);       
    */
    //      fadeAlbumOut = new TranslateAnimation(-display.getWidth(),-display.getWidth(), 0, 0);
    fadeAlbumOut = new AlphaAnimation(1.0f, 0.0f);
    fadeAlbumOut.setDuration(200);
    fadeAlbumOut.setFillAfter(true);
    //fadeAlbumOut.setInterpolator(new AccelerateInterpolator());
    fadeAlbumOut.setAnimationListener(this.hideAlbumAnimationListener);

    /*
     * Fades an Album in
     */
    /*fadeAlbumIn = new AlphaAnimation(0, 1);
    fadeAlbumIn.setDuration(250);
    fadeAlbumIn.setFillAfter(true);
    fadeAlbumIn.setAnimationListener(this.showAlbumAnimationListener);
    */
    //      fadeAlbumIn = new TranslateAnimation(-display.getWidth(),0, 0, 0);
    fadeAlbumIn = new AlphaAnimation(0.0f, 1.0f);
    fadeAlbumIn.setDuration(200);
    fadeAlbumIn.setFillAfter(true);
    //fadeAlbumIn.setInterpolator(new AccelerateInterpolator());
    fadeAlbumIn.setAnimationListener(this.showAlbumAnimationListener);
}

From source file:org.telegram.ui.ProfileActivity.java

private void needLayout() {
    FrameLayout.LayoutParams layoutParams;
    int newTop = (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0)
            + ActionBar.getCurrentActionBarHeight();
    if (listView != null && !openAnimationInProgress) {
        layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
        if (layoutParams.topMargin != newTop) {
            layoutParams.topMargin = newTop;
            listView.setLayoutParams(layoutParams);
        }//from www . java2  s  .  c  o m
    }

    if (avatarImage != null) {
        float diff = extraHeight / (float) AndroidUtilities.dp(88);
        listView.setTopGlowOffset(extraHeight);

        if (writeButton != null) {
            writeButton.setTranslationY((actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0)
                    + ActionBar.getCurrentActionBarHeight() + extraHeight - AndroidUtilities.dp(29.5f));

            if (!openAnimationInProgress) {
                final boolean setVisible = diff > 0.2f;
                boolean currentVisible = writeButton.getTag() == null;
                if (setVisible != currentVisible) {
                    if (setVisible) {
                        writeButton.setTag(null);
                    } else {
                        writeButton.setTag(0);
                    }
                    if (writeButtonAnimation != null) {
                        AnimatorSet old = writeButtonAnimation;
                        writeButtonAnimation = null;
                        old.cancel();
                    }
                    writeButtonAnimation = new AnimatorSet();
                    if (setVisible) {
                        writeButtonAnimation.setInterpolator(new DecelerateInterpolator());
                        writeButtonAnimation.playTogether(ObjectAnimator.ofFloat(writeButton, "scaleX", 1.0f),
                                ObjectAnimator.ofFloat(writeButton, "scaleY", 1.0f),
                                ObjectAnimator.ofFloat(writeButton, "alpha", 1.0f));
                    } else {
                        writeButtonAnimation.setInterpolator(new AccelerateInterpolator());
                        writeButtonAnimation.playTogether(ObjectAnimator.ofFloat(writeButton, "scaleX", 0.2f),
                                ObjectAnimator.ofFloat(writeButton, "scaleY", 0.2f),
                                ObjectAnimator.ofFloat(writeButton, "alpha", 0.0f));
                    }
                    writeButtonAnimation.setDuration(150);
                    writeButtonAnimation.addListener(new AnimatorListenerAdapterProxy() {
                        @Override
                        public void onAnimationEnd(Animator animation) {
                            if (writeButtonAnimation != null && writeButtonAnimation.equals(animation)) {
                                writeButtonAnimation = null;
                            }
                        }
                    });
                    writeButtonAnimation.start();
                }
            }
        }

        float avatarY = (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0)
                + ActionBar.getCurrentActionBarHeight() / 2.0f * (1.0f + diff) - 21 * AndroidUtilities.density
                + 27 * AndroidUtilities.density * diff;
        avatarImage.setScaleX((42 + 18 * diff) / 42.0f);
        avatarImage.setScaleY((42 + 18 * diff) / 42.0f);
        avatarImage.setTranslationX(-AndroidUtilities.dp(47) * diff);
        avatarImage.setTranslationY((float) Math.ceil(avatarY));
        for (int a = 0; a < 2; a++) {
            if (nameTextView[a] == null) {
                continue;
            }
            nameTextView[a].setTranslationX(-21 * AndroidUtilities.density * diff);
            nameTextView[a].setTranslationY(
                    (float) Math.floor(avatarY) + AndroidUtilities.dp(1.3f) + AndroidUtilities.dp(7) * diff);
            onlineTextView[a].setTranslationX(-21 * AndroidUtilities.density * diff);
            onlineTextView[a].setTranslationY((float) Math.floor(avatarY) + AndroidUtilities.dp(24)
                    + (float) Math.floor(11 * AndroidUtilities.density) * diff);
            nameTextView[a].setScaleX(1.0f + 0.12f * diff);
            nameTextView[a].setScaleY(1.0f + 0.12f * diff);
            if (a == 1 && !openAnimationInProgress) {
                int width;
                if (AndroidUtilities.isTablet()) {
                    width = AndroidUtilities.dp(490);
                } else {
                    width = AndroidUtilities.displaySize.x;
                }
                width = (int) (width - AndroidUtilities.dp(118 + 8 + 40 * (1.0f - diff))
                        - nameTextView[a].getTranslationX());
                float width2 = nameTextView[a].getPaint().measureText(nameTextView[a].getText().toString())
                        * nameTextView[a].getScaleX() + getSideDrawablesSize(nameTextView[a]);
                layoutParams = (FrameLayout.LayoutParams) nameTextView[a].getLayoutParams();
                if (width < width2) {
                    layoutParams.width = (int) Math.ceil(width / nameTextView[a].getScaleX());
                } else {
                    layoutParams.width = LayoutHelper.WRAP_CONTENT;
                }
                nameTextView[a].setLayoutParams(layoutParams);

                layoutParams = (FrameLayout.LayoutParams) onlineTextView[a].getLayoutParams();
                layoutParams.rightMargin = (int) Math.ceil(onlineTextView[a].getTranslationX()
                        + AndroidUtilities.dp(8) + AndroidUtilities.dp(40) * (1.0f - diff));
                onlineTextView[a].setLayoutParams(layoutParams);
            }
        }
    }
}

From source file:org.telegram.ui.Components.ChatActivityEnterView.java

private void updateRecordIntefrace() {
    if (recordingAudioVideo) {
        if (recordInterfaceState == 1) {
            return;
        }/*from ww  w  .  j av  a 2s.co m*/
        recordInterfaceState = 1;
        try {
            if (wakeLock == null) {
                PowerManager pm = (PowerManager) ApplicationLoader.applicationContext
                        .getSystemService(Context.POWER_SERVICE);
                wakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE,
                        "audio record lock");
                wakeLock.acquire();
            }
        } catch (Exception e) {
            FileLog.e(e);
        }
        AndroidUtilities.lockOrientation(parentActivity);

        recordPanel.setVisibility(VISIBLE);
        recordCircle.setVisibility(VISIBLE);
        recordCircle.setAmplitude(0);
        recordTimeText.setText("00:00");
        recordDot.resetAlpha();
        lastTimeString = null;

        FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) slideText.getLayoutParams();
        params.leftMargin = AndroidUtilities.dp(30);
        slideText.setLayoutParams(params);
        slideText.setAlpha(1);
        recordPanel.setX(AndroidUtilities.displaySize.x);
        recordCircle.setTranslationX(0);
        if (runningAnimationAudio != null) {
            runningAnimationAudio.cancel();
        }
        runningAnimationAudio = new AnimatorSet();
        runningAnimationAudio.playTogether(ObjectAnimator.ofFloat(recordPanel, "translationX", 0),
                ObjectAnimator.ofFloat(recordCircle, "scale", 1),
                ObjectAnimator.ofFloat(audioVideoButtonContainer, "alpha", 0));
        runningAnimationAudio.setDuration(300);
        runningAnimationAudio.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animator) {
                if (runningAnimationAudio != null && runningAnimationAudio.equals(animator)) {
                    recordPanel.setX(0);
                    runningAnimationAudio = null;
                }
            }
        });
        runningAnimationAudio.setInterpolator(new DecelerateInterpolator());
        runningAnimationAudio.start();
    } else {
        if (wakeLock != null) {
            try {
                wakeLock.release();
                wakeLock = null;
            } catch (Exception e) {
                FileLog.e(e);
            }
        }
        AndroidUtilities.unlockOrientation(parentActivity);
        if (recordInterfaceState == 0) {
            return;
        }
        recordInterfaceState = 0;

        if (runningAnimationAudio != null) {
            runningAnimationAudio.cancel();
        }
        runningAnimationAudio = new AnimatorSet();
        runningAnimationAudio.playTogether(
                ObjectAnimator.ofFloat(recordPanel, "translationX", AndroidUtilities.displaySize.x),
                ObjectAnimator.ofFloat(recordCircle, "scale", 0.0f),
                ObjectAnimator.ofFloat(audioVideoButtonContainer, "alpha", 1.0f));
        runningAnimationAudio.setDuration(300);
        runningAnimationAudio.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animator) {
                if (runningAnimationAudio != null && runningAnimationAudio.equals(animator)) {
                    FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) slideText.getLayoutParams();
                    params.leftMargin = AndroidUtilities.dp(30);
                    slideText.setLayoutParams(params);
                    slideText.setAlpha(1);
                    recordPanel.setVisibility(GONE);
                    recordCircle.setVisibility(GONE);
                    runningAnimationAudio = null;
                }
            }
        });
        runningAnimationAudio.setInterpolator(new AccelerateInterpolator());
        runningAnimationAudio.start();
    }
}

From source file:com.ichi2.anki2.Reviewer.java

public void fillFlashcard(boolean flip) {
    if (!flip) {/*from   ww w .  j  a  va  2s  .  co  m*/
        Log.i(AnkiDroidApp.TAG, "base url = " + mBaseUrl);
        if (mCurrentSimpleInterface && mSimpleCard != null) {
            mSimpleCard.setText(mCardContent);
        } else if (mRefreshWebview && mCard != null && mNextCard != null) {
            mNextCard.setBackgroundColor(mCurrentBackgroundColor);
            mNextCard.loadDataWithBaseURL(mBaseUrl, mCardContent.toString(), "text/html", "utf-8", null);
            mNextCard.setVisibility(View.VISIBLE);
            mCardFrame.removeView(mCard);
            mCard.destroy();
            mCard = mNextCard;
            mNextCard = createWebView();
            mNextCard.setVisibility(View.GONE);
            mCardFrame.addView(mNextCard, 0);
            // hunt for input issue 720, like android issue 3341
            if (AnkiDroidApp.SDK_VERSION <= 7) {
                mCard.setFocusableInTouchMode(true);
            }
        } else if (mCard != null) {
            mCard.loadDataWithBaseURL(mBaseUrl, mCardContent.toString(), "text/html", "utf-8", null);
            mCard.setBackgroundColor(mCurrentBackgroundColor);
        }
        if (mChangeBorderStyle) {
            switch (mCurrentBackgroundColor) {
            case Color.WHITE:
                if (mInvertedColors) {
                    mInvertedColors = false;
                    invertColors(false);
                }
                break;
            case Color.BLACK:
                if (!mInvertedColors) {
                    mInvertedColors = true;
                    invertColors(true);
                }
                break;
            default:
                if (Themes.getTheme() != Themes.THEME_BLUE) {
                    mMainLayout.setBackgroundColor(mCurrentBackgroundColor);
                }
                if (mInvertedColors != mNightMode) {
                    mInvertedColors = mNightMode;
                    invertColors(mNightMode);
                }
            }
        }
        if (!mShowAnimations && mCardTimer.getVisibility() == View.INVISIBLE) {
            switchTopBarVisibility(View.VISIBLE);
        }
        if (!sDisplayAnswer) {
            updateForNewCard();
            if (mShowWhiteboard) {
                mWhiteboard.clear();
            }
            setNextCardAnimation(false);
        }
    } else {
        Animation3D rotation;
        boolean directionToLeft = true;
        switch (mNextAnimation) {
        case ANIMATION_TURN:
            rotation = new Animation3D(mCardContainer.getWidth(), mCardContainer.getHeight(), 9,
                    Animation3D.ANIMATION_TURN, true, true, this);
            rotation.setDuration(mAnimationDurationTurn);
            rotation.setInterpolator(new AccelerateDecelerateInterpolator());
            break;
        case ANIMATION_NEXT_CARD_FROM_LEFT:
            directionToLeft = false;
        case ANIMATION_NEXT_CARD_FROM_RIGHT:
            rotation = new Animation3D(mCardContainer.getWidth(), mCardContainer.getHeight(), 0,
                    Animation3D.ANIMATION_EXCHANGE_CARD, directionToLeft, true, this);
            rotation.setDuration(mAnimationDurationMove);
            rotation.setInterpolator(new AccelerateDecelerateInterpolator());
            break;
        case ANIMATION_SLIDE_OUT_TO_RIGHT:
            directionToLeft = false;
        case ANIMATION_SLIDE_OUT_TO_LEFT:
            fillFlashcard(false);
            rotation = new Animation3D(mCardContainer.getWidth(), mCardContainer.getHeight(), 0,
                    Animation3D.ANIMATION_SLIDE_OUT_CARD, directionToLeft, true, this);
            rotation.setDuration(mAnimationDurationMove);
            rotation.setInterpolator(new AccelerateInterpolator());
            switchTopBarVisibility(View.INVISIBLE);
            break;
        case ANIMATION_SLIDE_IN_FROM_LEFT:
            directionToLeft = false;
        case ANIMATION_SLIDE_IN_FROM_RIGHT:
            fillFlashcard(false);
            rotation = new Animation3D(mCardContainer.getWidth(), mCardContainer.getHeight(), 0,
                    Animation3D.ANIMATION_SLIDE_IN_CARD, directionToLeft, true, this);
            rotation.setDuration(mAnimationDurationMove);
            rotation.setInterpolator(new DecelerateInterpolator());
            switchTopBarVisibility(View.VISIBLE);
            break;
        case ANIMATION_NO_ANIMATION:
        default:
            return;
        }

        rotation.reset();
        mCardContainer.setDrawingCacheEnabled(true);
        mCardContainer.setDrawingCacheBackgroundColor(Themes.getBackgroundColor());
        mCardContainer.clearAnimation();
        mCardContainer.startAnimation(rotation);
    }
}

From source file:com.hichinaschool.flashcards.anki.Reviewer.java

public void fillFlashcard(boolean flip) {
    if (!flip) {// w w w.  j  a  v  a  2 s .com
        // Log.i(AnkiDroidApp.TAG, "base url = " + mBaseUrl);
        if (mCurrentSimpleInterface && mSimpleCard != null) {
            mSimpleCard.setText(mCardContent);
        } else if (!mUseQuickUpdate && mCard != null && mNextCard != null) {
            mNextCard.setBackgroundColor(mCurrentBackgroundColor);
            mNextCard.loadDataWithBaseURL(mBaseUrl, mCardContent.toString(), "text/html", "utf-8", null);
            mNextCard.setVisibility(View.VISIBLE);
            mCardFrame.removeView(mCard);
            mCard.destroy();
            mCard = mNextCard;
            mNextCard = createWebView();
            mNextCard.setVisibility(View.GONE);
            mCardFrame.addView(mNextCard, 0);
            // hunt for input issue 720, like android issue 3341
            if (AnkiDroidApp.SDK_VERSION <= 7) {
                mCard.setFocusableInTouchMode(true);
            }
        } else if (mCard != null) {
            mCard.loadDataWithBaseURL(mBaseUrl, mCardContent.toString(), "text/html", "utf-8", null);
            mCard.setBackgroundColor(mCurrentBackgroundColor);
        }
        if (mChangeBorderStyle) {
            switch (mCurrentBackgroundColor) {
            case Color.WHITE:
                if (mInvertedColors) {
                    mInvertedColors = false;
                    invertColors(false);
                }
                break;
            case Color.BLACK:
                if (!mInvertedColors) {
                    mInvertedColors = true;
                    invertColors(true);
                }
                break;
            default:
                if (Themes.getTheme() != Themes.THEME_BLUE) {
                    mMainLayout.setBackgroundColor(mCurrentBackgroundColor);
                }
                if (mInvertedColors != mNightMode) {
                    mInvertedColors = mNightMode;
                    invertColors(mNightMode);
                }
            }
        }
        if (!mShowAnimations && mShowTimer && mCardTimer.getVisibility() == View.INVISIBLE) {
            switchTopBarVisibility(View.VISIBLE);
        }
        if (!sDisplayAnswer) {
            updateForNewCard();
            if (mShowWhiteboard) {
                mWhiteboard.clear();
            }
            setNextCardAnimation(false);
        }
    } else {
        Animation3D rotation;
        boolean directionToLeft = true;
        switch (mNextAnimation) {
        case ANIMATION_TURN:
            rotation = new Animation3D(mCardContainer.getWidth(), mCardContainer.getHeight(), 9,
                    Animation3D.ANIMATION_TURN, true, true, this);
            rotation.setDuration(mAnimationDurationTurn);
            rotation.setInterpolator(new AccelerateDecelerateInterpolator());
            break;
        case ANIMATION_NEXT_CARD_FROM_LEFT:
            directionToLeft = false;
        case ANIMATION_NEXT_CARD_FROM_RIGHT:
            rotation = new Animation3D(mCardContainer.getWidth(), mCardContainer.getHeight(), 0,
                    Animation3D.ANIMATION_EXCHANGE_CARD, directionToLeft, true, this);
            rotation.setDuration(mAnimationDurationMove);
            rotation.setInterpolator(new AccelerateDecelerateInterpolator());
            break;
        case ANIMATION_SLIDE_OUT_TO_RIGHT:
            directionToLeft = false;
        case ANIMATION_SLIDE_OUT_TO_LEFT:
            fillFlashcard(false);
            rotation = new Animation3D(mCardContainer.getWidth(), mCardContainer.getHeight(), 0,
                    Animation3D.ANIMATION_SLIDE_OUT_CARD, directionToLeft, true, this);
            rotation.setDuration(mAnimationDurationMove);
            rotation.setInterpolator(new AccelerateInterpolator());
            switchTopBarVisibility(View.INVISIBLE);
            break;
        case ANIMATION_SLIDE_IN_FROM_LEFT:
            directionToLeft = false;
        case ANIMATION_SLIDE_IN_FROM_RIGHT:
            fillFlashcard(false);
            rotation = new Animation3D(mCardContainer.getWidth(), mCardContainer.getHeight(), 0,
                    Animation3D.ANIMATION_SLIDE_IN_CARD, directionToLeft, true, this);
            rotation.setDuration(mAnimationDurationMove);
            rotation.setInterpolator(new DecelerateInterpolator());
            switchTopBarVisibility(View.VISIBLE);
            break;
        case ANIMATION_NO_ANIMATION:
        default:
            return;
        }

        rotation.reset();
        mCardContainer.setDrawingCacheEnabled(true);
        mCardContainer.setDrawingCacheBackgroundColor(Themes.getBackgroundColor());
        mCardContainer.clearAnimation();
        mCardContainer.startAnimation(rotation);
    }
}

From source file:org.anurag.file.quest.TaskerActivity.java

/**
 * Creates the animation set for next ViewFlippers when loaded.
 * @return a customized animation for mViewFlippers
 *///from   ww w .  ja  va  2s  .co m
private static Animation nextAnim() {
    Animation anim = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, +1.0f, Animation.RELATIVE_TO_PARENT,
            0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f);
    anim.setDuration(100);
    anim.setInterpolator(new AccelerateInterpolator());
    return anim;
}