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;
}
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;
}
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;
}
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);
}
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;
}
Aggregations