Search in sources :

Example 86 with Animation

use of android.view.animation.Animation in project wire-android by wireapp.

the class ParticipantBodyFragment method onCreateAnimation.

@Override
public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) {
    final Fragment parent = getParentFragment();
    // is being removed.
    if (!enter && parent != null && parent.isRemoving()) {
        // This is a workaround for the bug where child fragments disappear when
        // the parent is removed (as all children are first removed from the parent)
        // See https://code.google.com/p/android/issues/detail?id=55228
        Animation doNothingAnim = new AlphaAnimation(1, 1);
        doNothingAnim.setDuration(ViewUtils.getNextAnimationDuration(parent));
        return doNothingAnim;
    } else {
        return super.onCreateAnimation(transit, enter, nextAnim);
    }
}
Also used : Animation(android.view.animation.Animation) AlphaAnimation(android.view.animation.AlphaAnimation) Fragment(android.support.v4.app.Fragment) BaseFragment(com.waz.zclient.pages.BaseFragment) AlphaAnimation(android.view.animation.AlphaAnimation)

Example 87 with Animation

use of android.view.animation.Animation in project HumaneApp by Ganesh1010.

the class LandingPage method onCreate.

/*    @Bind(R.id.fragmentLayout)FrameLayout frameLayout;
    @Bind(R.id.donarActivity) Button donor;
    @Bind(R.id.orgActivity) Button org;
    @Bind(R.id.viewLine) View viewLine;*/
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_landing_page);
    // ButterKnife.bind(this);
    frameLayout = (FrameLayout) findViewById(R.id.fragmentLayout);
    donor = (Button) findViewById(R.id.donarActivity);
    org = (Button) findViewById(R.id.orgActivity);
    viewLine = findViewById(R.id.viewLine);
    SharedPreferences preferences = getSharedPreferences(Connectivity.MyPREFERENCES, Context.MODE_PRIVATE);
    Boolean isfirsttme = preferences.getBoolean(Connectivity.Is_First_Time, true);
    if (!isfirsttme) {
        SharedPreferences.Editor editor = getSharedPreferences(Connectivity.MyPREFERENCES, Context.MODE_PRIVATE).edit();
    }
    final Animation myAnim = AnimationUtils.loadAnimation(this, R.anim.bounce);
    BounceInterpolator interpolator = new BounceInterpolator(0.2, 20);
    myAnim.setInterpolator(interpolator);
    myAnim.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
        // LandingPage.this.startActivity(new Intent(LandingPage.this,LoginPageFragment.class));
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });
    // Use bounce interpolator with amplitude 0.2 and frequency 20
    donor.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // Toast.makeText(LandingPage.this,"Donor Clicked",Toast.LENGTH_LONG).show();
            // v.startAnimation(myAnim);
            user = "DONOR";
            org.setVisibility(View.INVISIBLE);
            donor.setVisibility(View.INVISIBLE);
            viewLine.setVisibility(View.INVISIBLE);
            Bundle bundle = new Bundle();
            bundle.putString(USER_KEY_TYPE, USER_TYPE_SELECTION_DONOR);
            fragment = new LoginPageFragment();
            fragment.setArguments(bundle);
            fragmentManager = getFragmentManager();
            fragmentManager.beginTransaction().replace(R.id.fragmentLayout, fragment).commit();
            Toast.makeText(LandingPage.this, "Donor Clicked", Toast.LENGTH_LONG).show();
        }
    });
    org.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            //  view.setAnimation(myAnim);
            user = "COORDINATOR";
            org.setVisibility(View.INVISIBLE);
            donor.setVisibility(View.INVISIBLE);
            viewLine.setVisibility(View.INVISIBLE);
            Bundle bundle = new Bundle();
            bundle.putString(USER_KEY_TYPE, USER_TYPE_SELECTION_ORG);
            fragment = new LoginPageFragment();
            fragment.setArguments(bundle);
            fragmentManager = getFragmentManager();
            fragmentManager.beginTransaction().replace(R.id.fragmentLayout, fragment).commit();
            Toast.makeText(LandingPage.this, "Organisation Clicked", Toast.LENGTH_LONG).show();
        }
    });
}
Also used : SharedPreferences(android.content.SharedPreferences) Bundle(android.os.Bundle) Animation(android.view.animation.Animation) View(android.view.View)

Example 88 with Animation

use of android.view.animation.Animation in project WaveSwipeRefreshLayout by recruit-lifestyle.

the class MaterialProgressDrawable method setupAnimators.

private void setupAnimators() {
    final Ring ring = mRing;
    final Animation animation = new Animation() {

        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            if (mFinishing) {
                applyFinishTranslation(interpolatedTime, ring);
            } else {
                // The minProgressArc is calculated from 0 to create an
                // angle that
                // matches the stroke width.
                final float minProgressArc = (float) Math.toRadians(ring.getStrokeWidth() / (2 * Math.PI * ring.getCenterRadius()));
                final float startingEndTrim = ring.getStartingEndTrim();
                final float startingTrim = ring.getStartingStartTrim();
                final float startingRotation = ring.getStartingRotation();
                // Offset the minProgressArc to where the endTrim is
                // located.
                final float minArc = MAX_PROGRESS_ARC - minProgressArc;
                final float endTrim = startingEndTrim + (minArc * START_CURVE_INTERPOLATOR.getInterpolation(interpolatedTime));
                ring.setEndTrim(endTrim);
                final float startTrim = startingTrim + (MAX_PROGRESS_ARC * END_CURVE_INTERPOLATOR.getInterpolation(interpolatedTime));
                ring.setStartTrim(startTrim);
                final float rotation = startingRotation + (0.25f * interpolatedTime);
                ring.setRotation(rotation);
                float groupRotation = ((720.0f / NUM_POINTS) * interpolatedTime) + (720.0f * (mRotationCount / NUM_POINTS));
                setRotation(groupRotation);
            }
        }
    };
    animation.setRepeatCount(Animation.INFINITE);
    animation.setRepeatMode(Animation.RESTART);
    animation.setInterpolator(LINEAR_INTERPOLATOR);
    animation.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
            mRotationCount = 0;
        }

        @Override
        public void onAnimationEnd(Animation animation) {
        // do nothing
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
            ring.storeOriginals();
            ring.goToNextColor();
            ring.setStartTrim(ring.getEndTrim());
            if (mFinishing) {
                // finished closing the last ring from the swipe gesture; go
                // into progress mode
                mFinishing = false;
                animation.setDuration(ANIMATION_DURATION);
                ring.setShowArrow(false);
            } else {
                mRotationCount = (mRotationCount + 1) % (NUM_POINTS);
            }
        }
    });
    mAnimation = animation;
}
Also used : Transformation(android.view.animation.Transformation) Animation(android.view.animation.Animation)

Example 89 with Animation

use of android.view.animation.Animation in project WaveSwipeRefreshLayout by recruit-lifestyle.

the class MaterialProgressDrawable method isRunning.

@Override
public boolean isRunning() {
    final ArrayList<Animation> animators = mAnimators;
    final int N = animators.size();
    for (int i = 0; i < N; i++) {
        final Animation animator = animators.get(i);
        if (animator.hasStarted() && !animator.hasEnded()) {
            return true;
        }
    }
    return false;
}
Also used : Animation(android.view.animation.Animation) Paint(android.graphics.Paint)

Example 90 with Animation

use of android.view.animation.Animation in project TwinklingRefreshLayout by lcodecorex.

the class MaterialProgressDrawable method setupAnimators.

private void setupAnimators() {
    final Ring ring = mRing;
    final Animation animation = new Animation() {

        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            if (mFinishing) {
                applyFinishTranslation(interpolatedTime, ring);
            } else {
                // The minProgressArc is calculated from 0 to create an
                // angle that matches the stroke width.
                final float minProgressArc = getMinProgressArc(ring);
                final float startingEndTrim = ring.getStartingEndTrim();
                final float startingTrim = ring.getStartingStartTrim();
                final float startingRotation = ring.getStartingRotation();
                updateRingColor(interpolatedTime, ring);
                // single ring animation
                if (interpolatedTime <= START_TRIM_DURATION_OFFSET) {
                    // scale the interpolatedTime so that the full
                    // transformation from 0 - 1 takes place in the
                    // remaining time
                    final float scaledTime = (interpolatedTime) / (1.0f - START_TRIM_DURATION_OFFSET);
                    final float startTrim = startingTrim + ((MAX_PROGRESS_ARC - minProgressArc) * MATERIAL_INTERPOLATOR.getInterpolation(scaledTime));
                    ring.setStartTrim(startTrim);
                }
                // animation completes
                if (interpolatedTime > END_TRIM_START_DELAY_OFFSET) {
                    // scale the interpolatedTime so that the full
                    // transformation from 0 - 1 takes place in the
                    // remaining time
                    final float minArc = MAX_PROGRESS_ARC - minProgressArc;
                    float scaledTime = (interpolatedTime - START_TRIM_DURATION_OFFSET) / (1.0f - START_TRIM_DURATION_OFFSET);
                    final float endTrim = startingEndTrim + (minArc * MATERIAL_INTERPOLATOR.getInterpolation(scaledTime));
                    ring.setEndTrim(endTrim);
                }
                final float rotation = startingRotation + (0.25f * interpolatedTime);
                ring.setRotation(rotation);
                float groupRotation = ((FULL_ROTATION / NUM_POINTS) * interpolatedTime) + (FULL_ROTATION * (mRotationCount / NUM_POINTS));
                setRotation(groupRotation);
            }
        }
    };
    animation.setRepeatCount(Animation.INFINITE);
    animation.setRepeatMode(Animation.RESTART);
    animation.setInterpolator(LINEAR_INTERPOLATOR);
    animation.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
            mRotationCount = 0;
        }

        @Override
        public void onAnimationEnd(Animation animation) {
        // do nothing
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
            ring.storeOriginals();
            ring.goToNextColor();
            ring.setStartTrim(ring.getEndTrim());
            if (mFinishing) {
                // finished closing the last ring from the swipe gesture; go
                // into progress mode
                mFinishing = false;
                animation.setDuration(ANIMATION_DURATION);
                ring.setShowArrow(false);
            } else {
                mRotationCount = (mRotationCount + 1) % (NUM_POINTS);
            }
        }
    });
    mAnimation = animation;
}
Also used : Transformation(android.view.animation.Transformation) Animation(android.view.animation.Animation)

Aggregations

Animation (android.view.animation.Animation)943 AlphaAnimation (android.view.animation.AlphaAnimation)241 TranslateAnimation (android.view.animation.TranslateAnimation)190 ScaleAnimation (android.view.animation.ScaleAnimation)146 Transformation (android.view.animation.Transformation)114 View (android.view.View)104 AnimationListener (android.view.animation.Animation.AnimationListener)98 AnimationSet (android.view.animation.AnimationSet)94 RotateAnimation (android.view.animation.RotateAnimation)63 ImageView (android.widget.ImageView)48 TextView (android.widget.TextView)47 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)43 Point (android.graphics.Point)40 WindowAnimation_activityCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseEnterAnimation)35 WindowAnimation_activityCloseExitAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseExitAnimation)35 WindowAnimation_activityOpenEnterAnimation (com.android.internal.R.styleable.WindowAnimation_activityOpenEnterAnimation)35 WindowAnimation_activityOpenExitAnimation (com.android.internal.R.styleable.WindowAnimation_activityOpenExitAnimation)35 WindowAnimation_taskCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskCloseEnterAnimation)35 WindowAnimation_taskCloseExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskCloseExitAnimation)35 WindowAnimation_taskOpenEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskOpenEnterAnimation)35