Search in sources :

Example 71 with OvershootInterpolator

use of android.view.animation.OvershootInterpolator in project recyclerview-animators by wasabeef.

the class AdapterSampleActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_adapter_sample);
    Toolbar toolbar = (Toolbar) findViewById(R.id.tool_bar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list);
    if (getIntent().getBooleanExtra("GRID", true)) {
        recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
    } else {
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
    }
    Spinner spinner = (Spinner) findViewById(R.id.spinner);
    ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1);
    for (Type type : Type.values()) {
        spinnerAdapter.add(type.name());
    }
    spinner.setAdapter(spinnerAdapter);
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            AnimationAdapter adapter = Type.values()[position].get(AdapterSampleActivity.this);
            adapter.setFirstOnly(true);
            adapter.setDuration(500);
            adapter.setInterpolator(new OvershootInterpolator(.5f));
            recyclerView.setAdapter(adapter);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    recyclerView.setItemAnimator(new FadeInAnimator());
    MainAdapter adapter = new MainAdapter(this, new ArrayList<>(Arrays.asList(data)));
    AlphaInAnimationAdapter alphaAdapter = new AlphaInAnimationAdapter(adapter);
    alphaAdapter.setFirstOnly(true);
    alphaAdapter.setDuration(500);
    alphaAdapter.setInterpolator(new OvershootInterpolator(.5f));
    recyclerView.setAdapter(alphaAdapter);
}
Also used : OvershootInterpolator(android.view.animation.OvershootInterpolator) Spinner(android.widget.Spinner) AlphaInAnimationAdapter(jp.wasabeef.recyclerview.adapters.AlphaInAnimationAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) AdapterView(android.widget.AdapterView) GridLayoutManager(android.support.v7.widget.GridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) AdapterView(android.widget.AdapterView) ArrayAdapter(android.widget.ArrayAdapter) SlideInRightAnimationAdapter(jp.wasabeef.recyclerview.adapters.SlideInRightAnimationAdapter) AnimationAdapter(jp.wasabeef.recyclerview.adapters.AnimationAdapter) ScaleInAnimationAdapter(jp.wasabeef.recyclerview.adapters.ScaleInAnimationAdapter) SlideInBottomAnimationAdapter(jp.wasabeef.recyclerview.adapters.SlideInBottomAnimationAdapter) SlideInLeftAnimationAdapter(jp.wasabeef.recyclerview.adapters.SlideInLeftAnimationAdapter) AlphaInAnimationAdapter(jp.wasabeef.recyclerview.adapters.AlphaInAnimationAdapter) Toolbar(android.support.v7.widget.Toolbar) FadeInAnimator(jp.wasabeef.recyclerview.animators.FadeInAnimator)

Example 72 with OvershootInterpolator

use of android.view.animation.OvershootInterpolator in project UltimateAndroid by cymcsg.

the class DefaultAnimationHandler method animateMenuOpening.

@Override
public void animateMenuOpening(Point center) {
    super.animateMenuOpening(center);
    setAnimating(true);
    Animator lastAnimation = null;
    for (int i = 0; i < menu.getSubActionItems().size(); i++) {
        menu.getSubActionItems().get(i).view.setScaleX(0);
        menu.getSubActionItems().get(i).view.setScaleY(0);
        menu.getSubActionItems().get(i).view.setAlpha(0);
        PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat(View.TRANSLATION_X, menu.getSubActionItems().get(i).x - center.x + menu.getSubActionItems().get(i).width / 2);
        PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, menu.getSubActionItems().get(i).y - center.y + menu.getSubActionItems().get(i).height / 2);
        PropertyValuesHolder pvhR = PropertyValuesHolder.ofFloat(View.ROTATION, 720);
        PropertyValuesHolder pvhsX = PropertyValuesHolder.ofFloat(View.SCALE_X, 1);
        PropertyValuesHolder pvhsY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 1);
        PropertyValuesHolder pvhA = PropertyValuesHolder.ofFloat(View.ALPHA, 1);
        final ObjectAnimator animation = ObjectAnimator.ofPropertyValuesHolder(menu.getSubActionItems().get(i).view, pvhX, pvhY, pvhR, pvhsX, pvhsY, pvhA);
        animation.setDuration(DURATION);
        animation.setInterpolator(new OvershootInterpolator(0.9f));
        animation.addListener(new SubActionItemAnimationListener(menu.getSubActionItems().get(i), ActionType.OPENING));
        if (i == 0) {
            lastAnimation = animation;
        }
        // Put a slight lag between each of the menu items to make it asymmetric
        animation.setStartDelay((menu.getSubActionItems().size() - i) * LAG_BETWEEN_ITEMS);
        animation.start();
    }
    if (lastAnimation != null) {
        lastAnimation.addListener(new LastAnimationListener());
    }
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) OvershootInterpolator(android.view.animation.OvershootInterpolator) ObjectAnimator(android.animation.ObjectAnimator) PropertyValuesHolder(android.animation.PropertyValuesHolder) Point(android.graphics.Point)

Example 73 with OvershootInterpolator

use of android.view.animation.OvershootInterpolator in project android_packages_apps_DUI by DirtyUnicorns.

the class SmartBarEditor method switchId.

/**
     * Switches positions of two views and updates their mButtonViews entry
     * 
     * @param targetView - view to be replaced animate out
     * @param view - view being dragged
     */
private void switchId(View replaceView, View dragView) {
    final OpaLayout squatter = (OpaLayout) replaceView;
    final OpaLayout dragger = (OpaLayout) dragView;
    final boolean vertical = mHost.isVertical();
    ViewGroup parent = (ViewGroup) replaceView.getParent();
    float slideTo = vertical ? mDragOrigin - parent.getTop() : mDragOrigin - parent.getLeft();
    replaceView.getLocationOnScreen(sLocation);
    mDragOrigin = sLocation[vertical ? 1 : 0];
    final int targetIndex = mHost.getCurrentSequence().indexOf(squatter.getButton().getTag());
    final int draggedIndex = mHost.getCurrentSequence().indexOf(dragger.getButton().getTag());
    Collections.swap(mHost.getCurrentSequence(), draggedIndex, targetIndex);
    SmartButtonView hidden1 = (SmartButtonView) getHiddenNavButtons().findViewWithTag(squatter.getButton().getTag());
    SmartButtonView hidden2 = (SmartButtonView) getHiddenNavButtons().findViewWithTag(dragger.getButton().getTag());
    OpaLayout hidden1Opa = (OpaLayout) hidden1.getParent();
    OpaLayout hidden2Opa = (OpaLayout) hidden2.getParent();
    swapConfigs(hidden1Opa, hidden2Opa);
    Animator anim = getButtonSlideAnimator(squatter, vertical, slideTo);
    anim.setInterpolator(new OvershootInterpolator());
    anim.setDuration(250);
    anim.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            mSquatters.remove(squatter);
        }
    });
    anim.start();
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) OpaLayout(com.android.systemui.navigation.OpaLayout) OvershootInterpolator(android.view.animation.OvershootInterpolator) ViewGroup(android.view.ViewGroup) SmartButtonView(com.android.systemui.navigation.smartbar.SmartButtonView) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) Point(android.graphics.Point)

Example 74 with OvershootInterpolator

use of android.view.animation.OvershootInterpolator in project android_packages_apps_DUI by DirtyUnicorns.

the class SmartButtonView method checkAndDoFlipAnim.

private void checkAndDoFlipAnim() {
    if (mAnimStyle == ANIM_STYLE_FLIP) {
        mFlipAnim = ObjectAnimator.ofFloat(this, "rotationY", 0f, 360f);
        mFlipAnim.setDuration(1500);
        mFlipAnim.setInterpolator(new OvershootInterpolator());
        mFlipAnim.start();
    }
}
Also used : OvershootInterpolator(android.view.animation.OvershootInterpolator)

Example 75 with OvershootInterpolator

use of android.view.animation.OvershootInterpolator in project android_frameworks_base by ResurrectionRemix.

the class QSPanel method setAnimationTile.

private void setAnimationTile(TileRecord r) {
    ObjectAnimator animTile = null;
    int animStyle = Settings.System.getIntForUser(mContext.getContentResolver(), Settings.System.ANIM_TILE_STYLE, 0, UserHandle.USER_CURRENT);
    int animDuration = Settings.System.getIntForUser(mContext.getContentResolver(), Settings.System.ANIM_TILE_DURATION, 2000, UserHandle.USER_CURRENT);
    int interpolatorType = Settings.System.getIntForUser(mContext.getContentResolver(), Settings.System.ANIM_TILE_INTERPOLATOR, 0, UserHandle.USER_CURRENT);
    if (animStyle == 0) {
    //No animation
    }
    if (animStyle == 1) {
        animTile = ObjectAnimator.ofFloat(r.tileView, "rotationY", 0f, 360f);
    }
    if (animStyle == 2) {
        animTile = ObjectAnimator.ofFloat(r.tileView, "rotation", 0f, 360f);
    }
    if (animTile != null) {
        switch(interpolatorType) {
            case 0:
                animTile.setInterpolator(new LinearInterpolator());
                break;
            case 1:
                animTile.setInterpolator(new AccelerateInterpolator());
                break;
            case 2:
                animTile.setInterpolator(new DecelerateInterpolator());
                break;
            case 3:
                animTile.setInterpolator(new AccelerateDecelerateInterpolator());
                break;
            case 4:
                animTile.setInterpolator(new BounceInterpolator());
                break;
            case 5:
                animTile.setInterpolator(new OvershootInterpolator());
                break;
            case 6:
                animTile.setInterpolator(new AnticipateInterpolator());
                break;
            case 7:
                animTile.setInterpolator(new AnticipateOvershootInterpolator());
                break;
            default:
                break;
        }
        animTile.setDuration(animDuration);
        animTile.start();
    }
}
Also used : AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) AnticipateOvershootInterpolator(android.view.animation.AnticipateOvershootInterpolator) OvershootInterpolator(android.view.animation.OvershootInterpolator) LinearInterpolator(android.view.animation.LinearInterpolator) ObjectAnimator(android.animation.ObjectAnimator) BounceInterpolator(android.view.animation.BounceInterpolator) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) AnticipateOvershootInterpolator(android.view.animation.AnticipateOvershootInterpolator) AnticipateInterpolator(android.view.animation.AnticipateInterpolator)

Aggregations

OvershootInterpolator (android.view.animation.OvershootInterpolator)85 ObjectAnimator (android.animation.ObjectAnimator)32 Animator (android.animation.Animator)21 View (android.view.View)21 AnimatorSet (android.animation.AnimatorSet)15 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)14 TextView (android.widget.TextView)14 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)13 Handler (android.os.Handler)12 ValueAnimator (android.animation.ValueAnimator)10 LinearInterpolator (android.view.animation.LinearInterpolator)10 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)8 Drawable (android.graphics.drawable.Drawable)7 RecyclerView (android.support.v7.widget.RecyclerView)7 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)7 LayerDrawable (android.graphics.drawable.LayerDrawable)6 PropertyValuesHolder (android.animation.PropertyValuesHolder)5 Rect (android.graphics.Rect)5 Interpolator (android.view.animation.Interpolator)5 Point (android.graphics.Point)4