Search in sources :

Example 36 with OvershootInterpolator

use of android.view.animation.OvershootInterpolator in project Tapad by berict.

the class AnimateHelper method scaleInOverShoot.

public void scaleInOverShoot(final int view_id, final int delay, final long duration, String handlerName, final Activity activity) {
    final ScaleAnimation scaleInOverShoot = new ScaleAnimation(0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    scaleInOverShoot.setInterpolator(new OvershootInterpolator());
    Map<String, Handler> handlerCreator = new HashMap<>();
    handlerCreator.put(handlerName, new Handler());
    handlerCreator.get(handlerName).postDelayed(new Runnable() {

        @Override
        public void run() {
            View view = activity.findViewById(view_id);
            scaleInOverShoot.setDuration(duration);
            view.startAnimation(scaleInOverShoot);
            view.setVisibility(View.VISIBLE);
            Log.i("AnimateHelper", "scale IN OVERSHOOT effect for " + String.valueOf(duration) + "ms with " + String.valueOf(delay) + "ms delay");
        }
    }, delay);
}
Also used : OvershootInterpolator(android.view.animation.OvershootInterpolator) HashMap(java.util.HashMap) Handler(android.os.Handler) View(android.view.View) ScaleAnimation(android.view.animation.ScaleAnimation)

Example 37 with OvershootInterpolator

use of android.view.animation.OvershootInterpolator in project LeafPic by HoraApps.

the class AlbumsFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_albums, container, false);
    ButterKnife.bind(this, v);
    int spanCount = columnsCount();
    spacingDecoration = new GridSpacingItemDecoration(spanCount, Measure.pxToDp(3, getContext()), true);
    rv.setHasFixedSize(true);
    rv.addItemDecoration(spacingDecoration);
    rv.setLayoutManager(new GridLayoutManager(getContext(), spanCount));
    if (Prefs.animationsEnabled()) {
        rv.setItemAnimator(AnimationUtils.getItemAnimator(new LandingAnimator(new OvershootInterpolator(1f))));
    }
    adapter = new AlbumsAdapter(getContext(), this);
    refresh.setOnRefreshListener(this::displayAlbums);
    rv.setAdapter(adapter);
    return v;
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) OvershootInterpolator(android.view.animation.OvershootInterpolator) AlbumsAdapter(org.horaapps.leafpic.adapters.AlbumsAdapter) LandingAnimator(jp.wasabeef.recyclerview.animators.LandingAnimator) BindView(butterknife.BindView) View(android.view.View) CardView(android.support.v7.widget.CardView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) GridSpacingItemDecoration(org.horaapps.leafpic.views.GridSpacingItemDecoration) Nullable(android.support.annotation.Nullable)

Example 38 with OvershootInterpolator

use of android.view.animation.OvershootInterpolator in project MaterialLibrary by DeveloperPaul123.

the class MaterialFloatingActionButton method init.

/**
 * Initialize various things for this view.
 * @param context the context passed from the constructor.
 * @param attributeSet attributeSet passed from the constructor.
 */
private void init(Context context, AttributeSet attributeSet) {
    int size = 0;
    // try to first deduce the accent color.
    int accentColor = -1;
    TypedArray a = null;
    try {
        TypedValue typedValue = new TypedValue();
        a = context.obtainStyledAttributes(typedValue.data, new int[] { R.attr.colorAccent });
        accentColor = a.getColor(0, -1);
    } catch (Resources.NotFoundException e) {
        e.printStackTrace();
    } finally {
        if (a != null) {
            a.recycle();
        }
    }
    // read the attributes.
    TypedArray attr = context.obtainStyledAttributes(attributeSet, R.styleable.MaterialFloatingActionButton, 0, 0);
    mButtonColor = attr.getColor(R.styleable.MaterialFloatingActionButton_mat_fab_colorNormal, accentColor == -1 ? getColor(android.R.color.holo_blue_dark) : accentColor);
    mButtonPressedColor = attr.getColor(R.styleable.MaterialFloatingActionButton_mat_fab_colorPressed, ColorUtils.getDarkerColor(mButtonColor));
    mIcon = attr.getResourceId(R.styleable.MaterialFloatingActionButton_mat_fab_icon, 0);
    useSelector = attr.getBoolean(R.styleable.MaterialFloatingActionButton_mat_fab_use_selector, false);
    size = attr.getInt(R.styleable.MaterialFloatingActionButton_mat_fab_size, 0);
    attr.recycle();
    iconSize = getDimension(R.dimen.mat_fab_icon_size);
    if (mIcon != 0) {
        iconBitmap = BitmapFactory.decodeResource(getResources(), mIcon);
        drawable = new BitmapDrawable(getResources(), iconBitmap);
        drawable.setAntiAlias(true);
        bitmapRect = new Rect(0, 0, iconBitmap.getWidth(), iconBitmap.getHeight());
        bitmapDrawRect = new RectF(0.0f, 0.0f, iconSize, iconSize);
    } else {
        iconBitmap = getDefaulBitmap();
        bitmapRect = new Rect(0, 0, iconBitmap.getWidth(), iconBitmap.getHeight());
        bitmapDrawRect = new RectF(0.0f, 0.0f, iconSize, iconSize);
    }
    float maxShadowOffset = getDimension(R.dimen.mat_fab_shadow_offset) * 1.5f;
    float minShadowOffset = maxShadowOffset / 1.5f;
    float maxShadowSize = getDimension(R.dimen.mat_fab_shadow_max_radius);
    float minShawdowSize = getDimension(R.dimen.mat_fab_shadow_min_radius) / 2;
    buttonSize = size == 0 ? getDimension(R.dimen.mat_fab_normal_size) : getDimension(R.dimen.mat_fab_mini_size);
    mSize = buttonSize + maxShadowSize * 4 + maxShadowOffset * 3;
    cx = mSize / 2;
    cy = mSize / 2;
    rotation = 0;
    rotationAnimator = ObjectAnimator.ofFloat(this, "rotation", MAX_ROTATION);
    rotationAnimator.setDuration(200);
    rotationAnimator.setInterpolator(new OvershootInterpolator());
    float halfsize = buttonSize / 2;
    float halfBitmapSize = iconSize / 2;
    bitmapDrawRect.set(cx - halfBitmapSize, cy - halfBitmapSize, cx + halfBitmapSize, cy + halfBitmapSize);
    mButtonPaint.setStyle(Paint.Style.FILL);
    mButtonPaint.setColor(mButtonColor);
    bitmapPaint = new Paint();
    bitmapPaint.setAntiAlias(true);
    bitmapPaint.setFilterBitmap(true);
    bitmapPaint.setDither(true);
    shadowRippleGenerator = new ShadowRippleGenerator(this, mButtonPaint);
    shadowRippleGenerator.setRippleColor(ColorUtils.getDarkerColor(mButtonColor));
    shadowRippleGenerator.setClipRadius((int) buttonSize / 2);
    shadowRippleGenerator.setAnimationDuration(200);
    shadowRippleGenerator.setMaxRippleRadius((int) (0.75f * buttonSize / 2));
    shadowRippleGenerator.setBoundingRect(new RectF(cx - halfsize, cy - halfsize, cx + halfsize, cy + halfsize));
    shadowSelectorGenerator = new ShadowSelectorGenerator(this, mButtonPaint);
    shadowSelectorGenerator.setNormalColor(mButtonColor);
    shadowSelectorGenerator.setPressedColor(mButtonPressedColor);
    shadowSelectorGenerator.setAnimationDuration(200);
    shadowSelectorGenerator.setShadowLimits(minShadowOffset, maxShadowOffset, minShawdowSize, maxShadowSize);
    invalidate();
}
Also used : Rect(android.graphics.Rect) OvershootInterpolator(android.view.animation.OvershootInterpolator) ShadowRippleGenerator(com.devpaul.materiallibrary.utils.ShadowRippleGenerator) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) Paint(android.graphics.Paint) RectF(android.graphics.RectF) TypedArray(android.content.res.TypedArray) Resources(android.content.res.Resources) TypedValue(android.util.TypedValue) ShadowSelectorGenerator(com.devpaul.materiallibrary.utils.ShadowSelectorGenerator)

Example 39 with OvershootInterpolator

use of android.view.animation.OvershootInterpolator in project AndriodDesignPattern by Shimingli.

the class StrategyModelFragment method onActivityCreated.

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    FivePriceStrategy fivePriceStrategy = new FivePriceStrategy();
    ContextPrice contextPrice = new ContextPrice(fivePriceStrategy);
    int i = contextPrice.setNewPrice(10);
    SevenPriceStrategy sevenPriceStrategy = new SevenPriceStrategy();
    contextPrice.setNewStrategy(sevenPriceStrategy);
    int i1 = contextPrice.setNewPrice(20);
    mTextView = (TextView) getView().findViewById(R.id.tvdes);
    final TextView viewById1 = (TextView) getView().findViewById(R.id.tv_text);
    mTextView.setText("第一种策略模式实现的价格:\n原价是10 减半后" + i + "\n" + "第二种策略模式实现的价格\n原价是20 7折后" + i1);
    // 时间差值器,也是策略模式
    final Button viewById = (Button) getView().findViewById(R.id.btn);
    viewById.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(viewById1, View.ALPHA, 0, 1);
            // 这里就相当于策略模式实现的
            // 加速
            objectAnimator.setInterpolator(new AccelerateInterpolator());
            // huilai
            objectAnimator.setInterpolator(new OvershootInterpolator());
            objectAnimator.start();
        }
    });
}
Also used : ContextPrice(com.shiming.andrioddesignpattern.strategy_model.ContextPrice) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) OvershootInterpolator(android.view.animation.OvershootInterpolator) Button(android.widget.Button) ObjectAnimator(android.animation.ObjectAnimator) SevenPriceStrategy(com.shiming.andrioddesignpattern.strategy_model.SevenPriceStrategy) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View) FivePriceStrategy(com.shiming.andrioddesignpattern.strategy_model.FivePriceStrategy)

Example 40 with OvershootInterpolator

use of android.view.animation.OvershootInterpolator in project ahbottomnavigation by aurelhubert.

the class DemoActivity method initUI.

/**
	 * Init UI
	 */
private void initUI() {
    bottomNavigation = (AHBottomNavigation) findViewById(R.id.bottom_navigation);
    viewPager = (AHBottomNavigationViewPager) findViewById(R.id.view_pager);
    floatingActionButton = (FloatingActionButton) findViewById(R.id.floating_action_button);
    if (useMenuResource) {
        tabColors = getApplicationContext().getResources().getIntArray(R.array.tab_colors);
        navigationAdapter = new AHBottomNavigationAdapter(this, R.menu.bottom_navigation_menu_3);
        navigationAdapter.setupWithBottomNavigation(bottomNavigation, tabColors);
    } else {
        AHBottomNavigationItem item1 = new AHBottomNavigationItem(R.string.tab_1, R.drawable.ic_apps_black_24dp, R.color.color_tab_1);
        AHBottomNavigationItem item2 = new AHBottomNavigationItem(R.string.tab_2, R.drawable.ic_maps_local_bar, R.color.color_tab_2);
        AHBottomNavigationItem item3 = new AHBottomNavigationItem(R.string.tab_3, R.drawable.ic_maps_local_restaurant, R.color.color_tab_3);
        bottomNavigationItems.add(item1);
        bottomNavigationItems.add(item2);
        bottomNavigationItems.add(item3);
        bottomNavigation.addItems(bottomNavigationItems);
    }
    bottomNavigation.manageFloatingActionButtonBehavior(floatingActionButton);
    bottomNavigation.setTranslucentNavigationEnabled(true);
    bottomNavigation.setOnTabSelectedListener(new AHBottomNavigation.OnTabSelectedListener() {

        @Override
        public boolean onTabSelected(int position, boolean wasSelected) {
            if (currentFragment == null) {
                currentFragment = adapter.getCurrentFragment();
            }
            if (wasSelected) {
                currentFragment.refresh();
                return true;
            }
            if (currentFragment != null) {
                currentFragment.willBeHidden();
            }
            viewPager.setCurrentItem(position, false);
            currentFragment = adapter.getCurrentFragment();
            currentFragment.willBeDisplayed();
            if (position == 1) {
                bottomNavigation.setNotification("", 1);
                floatingActionButton.setVisibility(View.VISIBLE);
                floatingActionButton.setAlpha(0f);
                floatingActionButton.setScaleX(0f);
                floatingActionButton.setScaleY(0f);
                floatingActionButton.animate().alpha(1).scaleX(1).scaleY(1).setDuration(300).setInterpolator(new OvershootInterpolator()).setListener(new Animator.AnimatorListener() {

                    @Override
                    public void onAnimationStart(Animator animation) {
                    }

                    @Override
                    public void onAnimationEnd(Animator animation) {
                        floatingActionButton.animate().setInterpolator(new LinearOutSlowInInterpolator()).start();
                    }

                    @Override
                    public void onAnimationCancel(Animator animation) {
                    }

                    @Override
                    public void onAnimationRepeat(Animator animation) {
                    }
                }).start();
            } else {
                if (floatingActionButton.getVisibility() == View.VISIBLE) {
                    floatingActionButton.animate().alpha(0).scaleX(0).scaleY(0).setDuration(300).setInterpolator(new LinearOutSlowInInterpolator()).setListener(new Animator.AnimatorListener() {

                        @Override
                        public void onAnimationStart(Animator animation) {
                        }

                        @Override
                        public void onAnimationEnd(Animator animation) {
                            floatingActionButton.setVisibility(View.GONE);
                        }

                        @Override
                        public void onAnimationCancel(Animator animation) {
                            floatingActionButton.setVisibility(View.GONE);
                        }

                        @Override
                        public void onAnimationRepeat(Animator animation) {
                        }
                    }).start();
                }
            }
            return true;
        }
    });
    /*
		bottomNavigation.setOnNavigationPositionListener(new AHBottomNavigation.OnNavigationPositionListener() {
			@Override public void onPositionChange(int y) {
				Log.d("DemoActivity", "BottomNavigation Position: " + y);
			}
		});
		*/
    viewPager.setOffscreenPageLimit(4);
    adapter = new DemoViewPagerAdapter(getSupportFragmentManager());
    viewPager.setAdapter(adapter);
    currentFragment = adapter.getCurrentFragment();
    handler.postDelayed(new Runnable() {

        @Override
        public void run() {
            // Setting custom colors for notification
            AHNotification notification = new AHNotification.Builder().setText(":)").setBackgroundColor(ContextCompat.getColor(DemoActivity.this, R.color.color_notification_back)).setTextColor(ContextCompat.getColor(DemoActivity.this, R.color.color_notification_text)).build();
            bottomNavigation.setNotification(notification, 1);
            Snackbar.make(bottomNavigation, "Snackbar with bottom navigation", Snackbar.LENGTH_SHORT).show();
        }
    }, 3000);
//bottomNavigation.setDefaultBackgroundResource(R.drawable.bottom_navigation_background);
}
Also used : OvershootInterpolator(android.view.animation.OvershootInterpolator) AHBottomNavigation(com.aurelhubert.ahbottomnavigation.AHBottomNavigation) LinearOutSlowInInterpolator(android.support.v4.view.animation.LinearOutSlowInInterpolator) Animator(android.animation.Animator) AHNotification(com.aurelhubert.ahbottomnavigation.notification.AHNotification) AHBottomNavigationAdapter(com.aurelhubert.ahbottomnavigation.AHBottomNavigationAdapter) AHBottomNavigationItem(com.aurelhubert.ahbottomnavigation.AHBottomNavigationItem)

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