Example usage for android.view.animation AnimationSet AnimationSet

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

Introduction

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

Prototype

public AnimationSet(boolean shareInterpolator) 

Source Link

Document

Constructor to use when building an AnimationSet from code

Usage

From source file:com.sonvp.tooltip.Tooltip.java

/**
 * Removes the tool tip view from the view hierarchy.
 *///from w  ww. j  av  a  2s  .  c o m
@UiThread
public void remove() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
        container.setPivotX(pivotX);
        container.setPivotY(pivotY);
        container.animate().setDuration(ANIMATION_DURATION).alpha(0.0F).scaleX(0.0F).scaleY(0.0F)
                .setListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        popupWindow.dismiss();

                    }
                });
    } else {
        AnimationSet animationSet = new AnimationSet(true);
        animationSet.setDuration(ANIMATION_DURATION);
        animationSet.addAnimation(new AlphaAnimation(1.0F, 0.0F));
        animationSet.addAnimation(new ScaleAnimation(1.0F, 0.0F, 1.0F, 0.0F, pivotX, pivotY));
        animationSet.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
                // do nothing
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                popupWindow.dismiss();
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
                // do nothing
            }
        });
        container.startAnimation(animationSet);
    }
}

From source file:com.example.testtab.fragment.TwitEyesPageFragment.java

public synchronized void endImgLoad(ImgFileIO status, String resMessage, final Bitmap bitmap, final int index,
        final int fresh) {
    showErrorLog("endImageLoad : index : " + index + " ---- //");
    boolean isContinue = true;
    switch (status) {
    case InterruptError:
        toastFormThread(Table.ERROR_INTERRUPTED + " while loading image.");
        isContinue = false;/*from w ww  .j a  v a  2  s .c o  m*/
        break;
    case HttpCodeError:
        toastFormThread(Table.ERROR_HTTP_CODE + " while loading image. Http Response: " + resMessage);
        isContinue = false;
        break;
    case FileMalformedError:
        toastFormThread(Table.ERROR_MALFORMED_URL + " while loading image.");
        isContinue = false;
        break;
    case ClientProtocolError:
        toastFormThread(Table.ERROR_CLIENT_PROTOCOL + " while loading image.");
        isContinue = false;
        break;
    case FileIOError:
        toastFormThread(Table.ERROR_IO + " while loading image.");
        isContinue = false;
        break;
    case FileCloserror:
        toastFormThread(Table.ERROR_FILE_CLOSE + " while loading image.");
        isContinue = false;
    }
    if (!isContinue)
        return;
    if (bitmap == null) {
        toastFormThread(Table.ERROR_IMAGE_NULL + " while loading image. Http Response: " + resMessage + " (No. "
                + index + ")");
        //return;
    }

    // CONTINUE
    this.handler.post(new Runnable() {
        public void run() {
            ImageButton image = (ImageButton) mRootView.findViewById(imageViews[index]);
            image.setImageBitmap(bitmap);

            if (bitmap != null) {
                AnimationSet set = new AnimationSet(true);

                AlphaAnimation alpha;
                switch (fresh) {
                case 1:
                case 2:
                    alpha = new AlphaAnimation(0.0f, 0.8f);
                    break;
                case 3:
                case 4:
                    alpha = new AlphaAnimation(0.0f, 0.6f);
                    break;
                case 5:
                case 6:
                    alpha = new AlphaAnimation(0.0f, 0.4f);
                    break;
                case 7:
                    alpha = new AlphaAnimation(0.0f, 0.2f);
                    break;
                default:
                    alpha = new AlphaAnimation(0.0f, 1.0f);
                }
                set.addAnimation(alpha);
                set.setDuration(500);
                set.setFillAfter(true);

                image.startAnimation(set);
            }
        }
    });
}

From source file:com.example.fragment.PrimitiveFragment.java

public void move(float destX, float destY) {
    if (!this.mIsAlive)
        return;//from www  .  j a  v a 2  s  . c  o  m
    if (this.mIsMoving) {
        return;// ADD Array
    }
    this.mDestX = Factory.getAdjustedX(destX - this.mPaddingW);
    this.mDestY = Factory.getAdjustedY(destY - this.mPaddingH);
    // SELECT LAYER 
    FrameLayout relate = (FrameLayout) mRootView.findViewById(R.id.FLBackLayer);
    //       ScrollView relate = (ScrollView)mRootView.findViewById(R.id.content);
    //       relate.setVisibility(View.VISIBLE);

    AnimationSet set = new AnimationSet(true);
    set.setAnimationListener(this);

    TranslateAnimation translate;
    float toX = this.mDestX;
    float fromX = this.mSrcX;
    float toY = this.mDestY;
    float fromY = this.mSrcY;
    translate = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, fromX, Animation.RELATIVE_TO_PARENT, toX,
            Animation.RELATIVE_TO_PARENT, fromY, Animation.RELATIVE_TO_PARENT, toY);
    translate.setDuration(Constants.Animation.IPF);
    translate.setInterpolator(new AccelerateInterpolator());

    set.addAnimation(translate);
    set.setFillBefore(true);
    //          set.setFillBefore(false);
    //         set.setFillAfter(false);
    set.setFillAfter(true);

    relate.startAnimation(set);
    this.mIsMoving = true;
    this.mIsMove = true;
}

From source file:com.example.testtab.fragment.TwitEyesPageFragment.java

public void showProgressBar(int percent) {
    TextView textLayer = (TextView) this.mRootView.findViewById(R.id.progress_bar);
    AnimationSet set = new AnimationSet(true);

    // ALPHA// www. j  a  v  a2  s.com
    AlphaAnimation alpha;
    switch (percent) {
    case 100:
        alpha = new AlphaAnimation(1.0f, 0.0f);
        break;
    case 0:
        alpha = new AlphaAnimation(0.0f, 1.0f);
        break;
    default:
        alpha = new AlphaAnimation(0.8f, 1.0f);
    }
    alpha.setDuration(500);

    TranslateAnimation translate;
    float toX = ((float) percent - 100.0f) / 100.0f;
    float fromX = toX - 0.1f;
    translate = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, fromX, Animation.RELATIVE_TO_PARENT, toX,
            Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f);
    translate.setDuration(500);
    translate.setInterpolator(new BounceInterpolator());

    set.addAnimation(alpha);
    set.addAnimation(translate);
    //         set.setDuration(500);
    set.setFillBefore(true);
    set.setFillAfter(true);

    textLayer.startAnimation(set);
}

From source file:it.imwatch.nfclottery.dialogs.InsertContactDialog.java

/**
 * Hides the email error textview.//  w  w w  .j  av a2 s.  co m
 */
private void hideEmailError() {
    mEmailErrorState = 0;

    // Re-enable the positive button of the dialog iif the name is also valid
    setFormIsValidated(mNameErrorState == 0);

    if (mEmailErrorTextView.getVisibility() == View.GONE) {
        return; // No need to animate out the textview, it's already gone
    }

    AnimationSet fadeOutSet = new AnimationSet(true);
    fadeOutSet.addAnimation(new AlphaAnimation(1f, 0f));
    fadeOutSet.addAnimation(new TranslateAnimation(0f, 0f, 0f, -mErrorAnimTranslateY));
    fadeOutSet.setDuration(300);
    fadeOutSet.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
            // Don't care
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            mEmailErrorTextView.setVisibility(View.GONE);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
            // Don't care
        }
    });

    mEmailErrorTextView.startAnimation(fadeOutSet);
}

From source file:it.imwatch.nfclottery.dialogs.InsertContactDialog.java

/**
 * Hides the name error textview./*from ww  w.j a  va 2s  .  co  m*/
 */
private void hideNameError() {
    mNameErrorState = 0;

    // Re-enable the positive button of the dialog iif the name is also valid
    setFormIsValidated(mEmailErrorState == 0);

    if (mNameErrorTextView.getVisibility() == View.GONE) {
        return; // No need to animate out the textview, it's already gone
    }

    AnimationSet fadeOutSet = new AnimationSet(true);
    fadeOutSet.addAnimation(new AlphaAnimation(1f, 0f));
    fadeOutSet.addAnimation(new TranslateAnimation(0f, 0f, 0f, -mErrorAnimTranslateY));
    fadeOutSet.setDuration(300);
    fadeOutSet.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
            // Don't care
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            mNameErrorTextView.setVisibility(View.GONE);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
            // Don't care
        }
    });

    mNameErrorTextView.startAnimation(fadeOutSet);
}

From source file:com.google.android.apps.santatracker.games.matching.MemoryMatchFragment.java

/**
 * Load and initialise all animations required for the game.
 *//*from  w w w  .j  a v a2  s .com*/
private void loadAnimations() {
    mAnimationTimerAlpha = new AlphaAnimation(0.0f, 1.0f);
    mAnimationTimerAlpha.setDuration(1000);
    mAnimationTimerAlpha.setRepeatMode(Animation.REVERSE);
    mAnimationTimerAlpha.setRepeatCount(Animation.INFINITE);

    mAnimationPlayAgainBackground = AnimationUtils.loadAnimation(getActivity(), R.anim.play_again_bkgrd_anim);
    mAnimationPlayAgainBackground.setFillAfter(true);
    mAnimationPlayAgainBackground.setAnimationListener(this);
    mAnimationCardCover = AnimationUtils.loadAnimation(getActivity(), R.anim.card_answer_flash);
    mAnimationCardCover.setFillAfter(true);
    mAnimationPlayAgainMain = AnimationUtils.loadAnimation(getActivity(), R.anim.play_again_main_anim);
    mAnimationPlayAgainMain.setFillAfter(true);
    mAnimationPlayAgainMain.setAnimationListener(this);
    // Special bonus animation to play if the player is particularly awesome.
    mAnimationSetSnowman = new AnimationSet(true);
    mAnimationSnowman = new TranslateAnimation(150, 0, 150, 0);
    mAnimationSnowman.setDuration(1000);
    mAnimationSetSnowman.addAnimation(mAnimationSnowman);
    mAnimationSnowmanBack = new TranslateAnimation(0, 150, 0, 150);
    mAnimationSnowmanBack.setDuration(1000);
    mAnimationSnowmanBack.setStartOffset(1500);
    mAnimationSnowmanBack.setAnimationListener(this);
    mAnimationSetSnowman.addAnimation(mAnimationSnowmanBack);
    mAnimationSetSnowman.setAnimationListener(this);

    mAnimationRightPaneSlideOut = AnimationUtils.loadAnimation(getActivity(), android.R.anim.slide_out_right);
    mAnimationRightPaneSlideOut.setFillAfter(true);
    mAnimationLeftPaneSlideOut = AnimationUtils.loadAnimation(getActivity(), R.anim.left_pane_slide_out);
    mAnimationLeftPaneSlideOut.setFillAfter(true);
    mAnimationLeftPaneSlideIn = AnimationUtils.loadAnimation(getActivity(), android.R.anim.slide_in_left);
    mAnimationLeftPaneSlideIn.setFillAfter(true);
    mAnimationRightPaneSlideIn = AnimationUtils.loadAnimation(getActivity(), R.anim.right_pane_slide_in);
    mAnimationRightPaneSlideIn.setFillAfter(true);
    mAnimationScaleLevelDown = AnimationUtils.loadAnimation(getActivity(), R.anim.scale_level_anim_down);
    mAnimationScaleLevelDown.setAnimationListener(this);
    mAnimationLevelFadeOut = AnimationUtils.loadAnimation(getActivity(), R.anim.level_fade_out_anim);
    mAnimationLevelFadeOut.setAnimationListener(this);
    mAnimationLevelScaleUp = AnimationUtils.loadAnimation(getActivity(), R.anim.scale_up_level_anim);
    mAnimationLevelScaleUp.setAnimationListener(this);
    mAnimationRightPaneSlideOut.setAnimationListener(this);
    mAnimationLeftPaneSlideOut.setAnimationListener(this);
}

From source file:it.imwatch.nfclottery.dialogs.InsertContactDialog.java

/**
 * Shows the email error textfield with the appropriate
 * error message./*from  w w w .j  a va2 s .  co  m*/
 *
 * @param message The error message to show
 */
private void showEmailError(CharSequence message, int errState) {
    mEmailErrorTextView.setText(message);
    mEmailErrorState = errState;

    // Disable the positive button of the dialog
    setFormIsValidated(false);

    if (mEmailErrorTextView.getVisibility() == View.VISIBLE) {
        return; // No need to animate in the textview, it's already visible
    }

    mEmailErrorTextView.setVisibility(View.VISIBLE);

    AnimationSet fadeInSet = new AnimationSet(true);
    fadeInSet.addAnimation(new AlphaAnimation(0f, 1f));
    fadeInSet.addAnimation(new TranslateAnimation(0f, 0f, -mErrorAnimTranslateY, 0f));
    fadeInSet.setDuration(300);
    mEmailErrorTextView.startAnimation(fadeInSet);
}

From source file:com.sahildave.snackbar.SnackBar.java

private AnimationSet getEntryAnimation() {
    //In//from ww  w .  j a  va 2s  .c o  m
    mInAnimationSet = new AnimationSet(false);

    TranslateAnimation mSlideInAnimation = new TranslateAnimation(TranslateAnimation.RELATIVE_TO_PARENT, 0.0f,
            TranslateAnimation.RELATIVE_TO_PARENT, 0.0f, TranslateAnimation.RELATIVE_TO_SELF, 1.0f,
            TranslateAnimation.RELATIVE_TO_SELF, 0.0f);
    mSlideInAnimation.setFillAfter(true);

    AlphaAnimation mFadeInAnimation = new AlphaAnimation(0.0f, 1.0f);
    mFadeInAnimation.setFillAfter(true);

    mInAnimationSet.addAnimation(mSlideInAnimation);
    mInAnimationSet.addAnimation(mFadeInAnimation);

    mInAnimationSet.setDuration(IN_ANIMATION_DURATION);

    return mInAnimationSet;

}

From source file:it.imwatch.nfclottery.dialogs.InsertContactDialog.java

/**
 * Shows the name error textfield with the appropriate
 * error message./*  ww w . j  a  v  a  2  s. co m*/
 */
private void showNameError() {
    mNameErrorState = 1;

    // Disable the positive button of the dialog
    setFormIsValidated(false);

    if (mNameErrorTextView.getVisibility() == View.VISIBLE) {
        return; // No need to animate in the textview, it's already visible
    }

    mNameErrorTextView.setVisibility(View.VISIBLE);

    AnimationSet fadeInSet = new AnimationSet(true);
    fadeInSet.addAnimation(new AlphaAnimation(0f, 1f));
    fadeInSet.addAnimation(new TranslateAnimation(0f, 0f, -mErrorAnimTranslateY, 0f));
    fadeInSet.setDuration(300);
    mNameErrorTextView.startAnimation(fadeInSet);
}