Search in sources :

Example 6 with LinearOutSlowInInterpolator

use of androidx.interpolator.view.animation.LinearOutSlowInInterpolator in project Carbon by ZieIony.

the class AnimUtils method getSlideInAnimator.

public static ValueAnimator getSlideInAnimator() {
    ViewAnimator animator = new ViewAnimator();
    animator.setInterpolator(new LinearOutSlowInInterpolator());
    animator.setOnSetupValuesListener(() -> {
        View view = animator.getTarget();
        animator.setFloatValues(view.getTranslationY(), 0);
        int height = view.getMeasuredHeight();
        ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
        if (layoutParams != null && layoutParams instanceof ViewGroup.MarginLayoutParams)
            height += ((ViewGroup.MarginLayoutParams) layoutParams).bottomMargin;
        long duration = (long) (SHORT_ANIMATION_DURATION * Math.abs(view.getTranslationY() / height));
        animator.setDuration(duration);
    });
    animator.addUpdateListener(valueAnimator -> {
        View view = animator.getTarget();
        view.setTranslationY((Float) valueAnimator.getAnimatedValue());
    });
    return animator;
}
Also used : LinearOutSlowInInterpolator(androidx.interpolator.view.animation.LinearOutSlowInInterpolator) ViewGroup(android.view.ViewGroup) ImageView(android.widget.ImageView) ProgressView(carbon.widget.ProgressView) ShadowView(carbon.view.ShadowView) View(android.view.View)

Example 7 with LinearOutSlowInInterpolator

use of androidx.interpolator.view.animation.LinearOutSlowInInterpolator in project Carbon by ZieIony.

the class AnimUtils method getProgressWidthInAnimator.

public static ValueAnimator getProgressWidthInAnimator() {
    ViewAnimator animator = new ViewAnimator();
    animator.setInterpolator(new LinearOutSlowInInterpolator());
    animator.setOnSetupValuesListener(() -> {
        ProgressView circularProgress = (ProgressView) animator.getTarget();
        final float arcWidth = circularProgress.getBarPadding() + circularProgress.getBarWidth();
        float start = circularProgress.getBarWidth();
        animator.setFloatValues(circularProgress.getBarWidth(), arcWidth);
        animator.setDuration((long) (100 * (arcWidth - start)));
    });
    animator.addUpdateListener(valueAnimator -> {
        ProgressView circularProgress = (ProgressView) animator.getTarget();
        final float arcWidth = circularProgress.getBarPadding() + circularProgress.getBarWidth();
        float value = (Float) valueAnimator.getAnimatedValue();
        circularProgress.setBarWidth(value);
        circularProgress.setBarPadding(arcWidth - value);
    });
    return animator;
}
Also used : LinearOutSlowInInterpolator(androidx.interpolator.view.animation.LinearOutSlowInInterpolator) ProgressView(carbon.widget.ProgressView)

Example 8 with LinearOutSlowInInterpolator

use of androidx.interpolator.view.animation.LinearOutSlowInInterpolator in project Carbon by ZieIony.

the class AnimUtils method getFlyInAnimator.

public static ValueAnimator getFlyInAnimator() {
    ViewAnimator animator = new ViewAnimator();
    animator.setInterpolator(new LinearOutSlowInInterpolator());
    animator.setOnSetupValuesListener(() -> {
        View view = animator.getTarget();
        if (view.getVisibility() != View.VISIBLE)
            view.setAlpha(0);
        float start = view.getAlpha();
        animator.setFloatValues(start, 1);
        animator.setDuration((long) (SHORT_ANIMATION_DURATION * (1 - start)));
    });
    animator.addUpdateListener(valueAnimator -> {
        View view = animator.getTarget();
        view.setAlpha((Float) valueAnimator.getAnimatedValue());
        view.setTranslationY(Math.min(view.getHeight() / 2, view.getResources().getDimension(R.dimen.carbon_1dip) * 50.0f) * (1 - (Float) valueAnimator.getAnimatedValue()));
    });
    return animator;
}
Also used : LinearOutSlowInInterpolator(androidx.interpolator.view.animation.LinearOutSlowInInterpolator) ImageView(android.widget.ImageView) ProgressView(carbon.widget.ProgressView) ShadowView(carbon.view.ShadowView) View(android.view.View)

Example 9 with LinearOutSlowInInterpolator

use of androidx.interpolator.view.animation.LinearOutSlowInInterpolator in project ahbottomnavigation by aurelhubert.

the class DemoActivity method initUI.

/**
 * Init UI
 */
private void initUI() {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    }
    bottomNavigation = findViewById(R.id.bottom_navigation);
    viewPager = findViewById(R.id.view_pager);
    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);
            if (currentFragment == null) {
                return true;
            }
            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(androidx.interpolator.view.animation.LinearOutSlowInInterpolator) Animator(android.animation.Animator) AHNotification(com.aurelhubert.ahbottomnavigation.notification.AHNotification) AHBottomNavigationAdapter(com.aurelhubert.ahbottomnavigation.AHBottomNavigationAdapter) AHBottomNavigationItem(com.aurelhubert.ahbottomnavigation.AHBottomNavigationItem)

Example 10 with LinearOutSlowInInterpolator

use of androidx.interpolator.view.animation.LinearOutSlowInInterpolator in project Transitions-Everywhere by andkulikov.

the class ScaleSample method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_scale, container, false);
    final ViewGroup transitionsContainer = view.findViewById(R.id.transitions_container);
    final TextView text1 = transitionsContainer.findViewById(R.id.text1);
    transitionsContainer.findViewById(R.id.button1).setOnClickListener(new VisibleToggleClickListener() {

        @Override
        protected void changeVisibility(boolean visible) {
            TransitionManager.beginDelayedTransition(transitionsContainer, new Scale());
            text1.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
        }
    });
    final TextView text2 = transitionsContainer.findViewById(R.id.text2);
    transitionsContainer.findViewById(R.id.button2).setOnClickListener(new VisibleToggleClickListener() {

        @Override
        protected void changeVisibility(boolean visible) {
            TransitionSet set = new TransitionSet().addTransition(new Scale(0.7f)).addTransition(new Fade()).setInterpolator(visible ? new LinearOutSlowInInterpolator() : new FastOutLinearInInterpolator());
            TransitionManager.beginDelayedTransition(transitionsContainer, set);
            text2.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
        }
    });
    return view;
}
Also used : LinearOutSlowInInterpolator(androidx.interpolator.view.animation.LinearOutSlowInInterpolator) TransitionSet(androidx.transition.TransitionSet) ViewGroup(android.view.ViewGroup) FastOutLinearInInterpolator(androidx.interpolator.view.animation.FastOutLinearInInterpolator) TextView(android.widget.TextView) Scale(com.transitionseverywhere.extra.Scale) TextView(android.widget.TextView) View(android.view.View) Fade(androidx.transition.Fade) Nullable(androidx.annotation.Nullable)

Aggregations

LinearOutSlowInInterpolator (androidx.interpolator.view.animation.LinearOutSlowInInterpolator)16 View (android.view.View)8 SlideUpAlphaAnimator (com.mikepenz.itemanimators.SlideUpAlphaAnimator)7 AlphaInAnimator (com.mikepenz.itemanimators.AlphaInAnimator)5 OfflineSubreddit (me.ccrama.redditslide.OfflineSubreddit)5 Submission (net.dean.jraw.models.Submission)5 ViewGroup (android.view.ViewGroup)4 RecyclerView (androidx.recyclerview.widget.RecyclerView)4 Context (android.content.Context)3 Intent (android.content.Intent)3 RelativeLayout (android.widget.RelativeLayout)3 AlertDialog (androidx.appcompat.app.AlertDialog)3 ContextThemeWrapper (androidx.appcompat.view.ContextThemeWrapper)3 ProgressView (carbon.widget.ProgressView)3 Snackbar (com.google.android.material.snackbar.Snackbar)3 Submit (me.ccrama.redditslide.Activities.Submit)3 ColorPreferences (me.ccrama.redditslide.Visuals.ColorPreferences)3 Animator (android.animation.Animator)2 ObjectAnimator (android.animation.ObjectAnimator)2 TargetApi (android.annotation.TargetApi)2