Java Code Examples for android.support.design.widget.FloatingActionButton#clearAnimation()

The following examples show how to use android.support.design.widget.FloatingActionButton#clearAnimation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DataBindingAdapter.java    From Android-App-Architecture-MVVM-Databinding with Apache License 2.0 6 votes vote down vote up
/**
 * Binding FAB's icon to the "state".
 *
 * @param fab the FAB
 * @param state state
 */
@BindingAdapter({"state"})
public static void setFavoriteState(final FloatingActionButton fab, final MovieDetailsViewModel.State state) {
    if (state == null) {
        return;
    }

    switch (state) {
        case LOADING:
            changeToLoadingState(fab);
            break;
        case NON_FAVORITE:
            fab.clearAnimation();
            fab.setImageResource(R.drawable.ic_favorite_border);
            break;
        case FAVORITE:
            fab.clearAnimation();
            fab.setImageResource(R.drawable.ic_favorite);
            break;
        default:
            break;
    }
}
 
Example 2
Source File: ScrollAwareFABBehavior.java    From ForPDA with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) {
    super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);

    if (dyConsumed > 0 && child.getAlpha() == 1.0f) {
        child.clearAnimation();
        child.animate()
                .scaleX(0.0f)
                .scaleY(0.0f)
                .alpha(0.0f)
                .setInterpolator(interpolator)
                .start();
    } else if (dyConsumed < 0 && child.getAlpha() == 0.0f) {
        child.clearAnimation();
        child.animate()
                .scaleX(1.0f)
                .scaleY(1.0f)
                .alpha(1.0f)
                .setInterpolator(interpolator)
                .start();
    }
}
 
Example 3
Source File: FabOnScroll.java    From ForPDA with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child, View target, int dx, int dy, int[] consumed) {
    super.onNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed);
    //Log.d("SUKA", "FabOnScroll onNestedPreScroll" + consumed[1] + " : " + dy);
    if (child.getAlpha() == 0.0f && Math.abs(dy) > App.px24) {
        child.setImageDrawable(App.getVecDrawable(child.getContext(), dy > 0 ? R.drawable.ic_arrow_down : R.drawable.ic_arrow_up));
        child.clearAnimation();
        child.animate()
                .scaleX(1.0f)
                .scaleY(1.0f)
                .alpha(1.0f)
                .setInterpolator(interpolator)
                .start();
        child.setClickable(true);
    }
}
 
Example 4
Source File: FabOnScroll.java    From ForPDA with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onStopNestedScroll(@NonNull CoordinatorLayout coordinatorLayout, @NonNull FloatingActionButton child, @NonNull View target) {
    super.onStopNestedScroll(coordinatorLayout, child, target);
    if (currentRunnable != null) {
        handler.removeCallbacks(currentRunnable);
    }
    currentRunnable = () -> {
        child.clearAnimation();
        child.animate()
                .scaleX(0.0f)
                .scaleY(0.0f)
                .alpha(0.0f)
                .setInterpolator(interpolator)
                .start();
        child.setClickable(false);
    };
    handler.postDelayed(currentRunnable, 1000);
}
 
Example 5
Source File: FabOnScroll.java    From ForPDA with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) {
    super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);
    //Log.d("SUKA", "FabOnScroll onNestedScroll " + dyConsumed + " : " + dyUnconsumed + " : " + App.px24);
    if (child.getAlpha() == 0.0f && Math.abs(dyUnconsumed) > App.px24) {
        child.clearAnimation();
        child.animate()
                .scaleX(1.0f)
                .scaleY(1.0f)
                .alpha(1.0f)
                .setInterpolator(interpolator)
                .start();
        child.setClickable(true);
    }
}