Search in sources :

Example 51 with Transformation

use of android.view.animation.Transformation in project Lightning-Browser by anthonycr.

the class BrowserActivity method changeToolbarBackground.

/**
     * Animates the color of the toolbar from one color to another. Optionally animates
     * the color of the tab background, for use when the tabs are displayed on the top
     * of the screen.
     *
     * @param favicon       the Bitmap to extract the color from
     * @param tabBackground the optional LinearLayout to color
     */
@Override
public void changeToolbarBackground(@NonNull Bitmap favicon, @Nullable final Drawable tabBackground) {
    final int defaultColor = ContextCompat.getColor(this, R.color.primary_color);
    if (mCurrentUiColor == Color.BLACK) {
        mCurrentUiColor = defaultColor;
    }
    Palette.from(favicon).generate(new Palette.PaletteAsyncListener() {

        @Override
        public void onGenerated(Palette palette) {
            // OR with opaque black to remove transparency glitches
            int color = 0xff000000 | palette.getVibrantColor(defaultColor);
            // Lighten up the dark color if it is
            final int finalColor;
            // too dark
            if (!mShowTabsInDrawer || Utils.isColorTooDark(color)) {
                finalColor = Utils.mixTwoColors(defaultColor, color, 0.25f);
            } else {
                finalColor = color;
            }
            final Window window = getWindow();
            if (!mShowTabsInDrawer) {
                window.setBackgroundDrawable(new ColorDrawable(Color.BLACK));
            }
            final int startSearchColor = getSearchBarColor(mCurrentUiColor, defaultColor);
            final int finalSearchColor = getSearchBarColor(finalColor, defaultColor);
            Animation animation = new Animation() {

                @Override
                protected void applyTransformation(float interpolatedTime, Transformation t) {
                    final int color = DrawableUtils.mixColor(interpolatedTime, mCurrentUiColor, finalColor);
                    if (mShowTabsInDrawer) {
                        mBackground.setColor(color);
                        Handlers.MAIN.post(new Runnable() {

                            @Override
                            public void run() {
                                window.setBackgroundDrawable(mBackground);
                            }
                        });
                    } else if (tabBackground != null) {
                        tabBackground.setColorFilter(color, PorterDuff.Mode.SRC_IN);
                    }
                    mCurrentUiColor = color;
                    mToolbarLayout.setBackgroundColor(color);
                    mSearchBackground.getBackground().setColorFilter(DrawableUtils.mixColor(interpolatedTime, startSearchColor, finalSearchColor), PorterDuff.Mode.SRC_IN);
                }
            };
            animation.setDuration(300);
            mToolbarLayout.startAnimation(animation);
        }
    });
}
Also used : Window(android.view.Window) Palette(android.support.v7.graphics.Palette) Transformation(android.view.animation.Transformation) ColorDrawable(android.graphics.drawable.ColorDrawable) Animation(android.view.animation.Animation)

Example 52 with Transformation

use of android.view.animation.Transformation in project teaTime by ancfdy.

the class SunRefreshView method setupAnimations.

private void setupAnimations() {
    mAnimation = new Animation() {

        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            setRotate(interpolatedTime);
        }
    };
    mAnimation.setRepeatCount(Animation.INFINITE);
    mAnimation.setRepeatMode(Animation.RESTART);
    mAnimation.setInterpolator(LINEAR_INTERPOLATOR);
    mAnimation.setDuration(ANIMATION_DURATION);
}
Also used : Transformation(android.view.animation.Transformation) Animation(android.view.animation.Animation)

Example 53 with Transformation

use of android.view.animation.Transformation in project BookReader by JustWayward.

the class MaterialProgressDrawable method setupAnimators.

private void setupAnimators() {
    final Ring ring = mRing;
    final Animation animation = new Animation() {

        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            if (mFinishing) {
                applyFinishTranslation(interpolatedTime, ring);
            } else {
                // The minProgressArc is calculated from 0 to create an
                // angle that matches the stroke width.
                final float minProgressArc = getMinProgressArc(ring);
                final float startingEndTrim = ring.getStartingEndTrim();
                final float startingTrim = ring.getStartingStartTrim();
                final float startingRotation = ring.getStartingRotation();
                updateRingColor(interpolatedTime, ring);
                // single ring animation
                if (interpolatedTime <= START_TRIM_DURATION_OFFSET) {
                    // scale the interpolatedTime so that the full
                    // transformation from 0 - 1 takes place in the
                    // remaining time
                    final float scaledTime = (interpolatedTime) / (1.0f - START_TRIM_DURATION_OFFSET);
                    final float startTrim = startingTrim + ((MAX_PROGRESS_ARC - minProgressArc) * MATERIAL_INTERPOLATOR.getInterpolation(scaledTime));
                    ring.setStartTrim(startTrim);
                }
                // animation completes
                if (interpolatedTime > END_TRIM_START_DELAY_OFFSET) {
                    // scale the interpolatedTime so that the full
                    // transformation from 0 - 1 takes place in the
                    // remaining time
                    final float minArc = MAX_PROGRESS_ARC - minProgressArc;
                    float scaledTime = (interpolatedTime - START_TRIM_DURATION_OFFSET) / (1.0f - START_TRIM_DURATION_OFFSET);
                    final float endTrim = startingEndTrim + (minArc * MATERIAL_INTERPOLATOR.getInterpolation(scaledTime));
                    ring.setEndTrim(endTrim);
                }
                final float rotation = startingRotation + (0.25f * interpolatedTime);
                ring.setRotation(rotation);
                float groupRotation = ((FULL_ROTATION / NUM_POINTS) * interpolatedTime) + (FULL_ROTATION * (mRotationCount / NUM_POINTS));
                setRotation(groupRotation);
            }
        }
    };
    animation.setRepeatCount(Animation.INFINITE);
    animation.setRepeatMode(Animation.RESTART);
    animation.setInterpolator(LINEAR_INTERPOLATOR);
    animation.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
            mRotationCount = 0;
        }

        @Override
        public void onAnimationEnd(Animation animation) {
        // do nothing
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
            ring.storeOriginals();
            ring.goToNextColor();
            ring.setStartTrim(ring.getEndTrim());
            if (mFinishing) {
                // finished closing the last ring from the swipe gesture; go
                // into progress mode
                mFinishing = false;
                animation.setDuration(ANIMATION_DURATION);
                ring.setShowArrow(false);
            } else {
                mRotationCount = (mRotationCount + 1) % (NUM_POINTS);
            }
        }
    });
    mAnimation = animation;
}
Also used : Transformation(android.view.animation.Transformation) Animation(android.view.animation.Animation)

Example 54 with Transformation

use of android.view.animation.Transformation in project BookReader by JustWayward.

the class SwipeRefreshLayout method startScaleDownAnimation.

private void startScaleDownAnimation(AnimationListener listener) {
    mScaleDownAnimation = new Animation() {

        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            setAnimationProgress(1 - interpolatedTime);
        }
    };
    mScaleDownAnimation.setDuration(SCALE_DOWN_DURATION);
    mCircleView.setAnimationListener(listener);
    mCircleView.clearAnimation();
    mCircleView.startAnimation(mScaleDownAnimation);
}
Also used : Transformation(android.view.animation.Transformation) Animation(android.view.animation.Animation)

Example 55 with Transformation

use of android.view.animation.Transformation in project XposedInstaller by rovo89.

the class WelcomeActivity method navigate.

private void navigate(final int itemId) {
    final View elevation = findViewById(R.id.elevation);
    Fragment navFragment = null;
    switch(itemId) {
        case R.id.nav_item_framework:
            mPrevSelectedId = itemId;
            setTitle(R.string.app_name);
            navFragment = new StatusInstallerFragment();
            break;
        case R.id.nav_item_modules:
            mPrevSelectedId = itemId;
            setTitle(R.string.nav_item_modules);
            navFragment = new ModulesFragment();
            break;
        case R.id.nav_item_downloads:
            mPrevSelectedId = itemId;
            setTitle(R.string.nav_item_download);
            navFragment = new DownloadFragment();
            break;
        case R.id.nav_item_logs:
            mPrevSelectedId = itemId;
            setTitle(R.string.nav_item_logs);
            navFragment = new LogsFragment();
            break;
        case R.id.nav_item_settings:
            startActivity(new Intent(this, SettingsActivity.class));
            mNavigationView.getMenu().findItem(mPrevSelectedId).setChecked(true);
            return;
        case R.id.nav_item_support:
            startActivity(new Intent(this, SupportActivity.class));
            mNavigationView.getMenu().findItem(mPrevSelectedId).setChecked(true);
            return;
        case R.id.nav_item_about:
            startActivity(new Intent(this, AboutActivity.class));
            mNavigationView.getMenu().findItem(mPrevSelectedId).setChecked(true);
            return;
    }
    final LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp(4));
    if (navFragment != null) {
        FragmentTransaction transaction = getFragmentManager().beginTransaction();
        transaction.setCustomAnimations(R.animator.fade_in, R.animator.fade_out);
        try {
            transaction.replace(R.id.content_frame, navFragment).commit();
            if (elevation != null) {
                Animation a = new Animation() {

                    @Override
                    protected void applyTransformation(float interpolatedTime, Transformation t) {
                        elevation.setLayoutParams(params);
                    }
                };
                a.setDuration(150);
                elevation.startAnimation(a);
            }
        } catch (IllegalStateException ignored) {
        }
    }
}
Also used : Transformation(android.view.animation.Transformation) StatusInstallerFragment(de.robv.android.xposed.installer.installation.StatusInstallerFragment) Intent(android.content.Intent) NavigationView(android.support.design.widget.NavigationView) View(android.view.View) StatusInstallerFragment(de.robv.android.xposed.installer.installation.StatusInstallerFragment) Fragment(android.app.Fragment) FragmentTransaction(android.app.FragmentTransaction) Animation(android.view.animation.Animation) LinearLayout(android.widget.LinearLayout)

Aggregations

Transformation (android.view.animation.Transformation)108 Animation (android.view.animation.Animation)61 Point (android.graphics.Point)24 Paint (android.graphics.Paint)22 AlphaAnimation (android.view.animation.AlphaAnimation)18 Animatable (android.graphics.drawable.Animatable)17 LinearInterpolator (android.view.animation.LinearInterpolator)17 Matrix (android.graphics.Matrix)15 RectF (android.graphics.RectF)13 Rect (android.graphics.Rect)7 Bitmap (android.graphics.Bitmap)6 MagnificationSpec (android.view.MagnificationSpec)5 View (android.view.View)3 BezierDecelerateInterpolator (acr.browser.lightning.interpolator.BezierDecelerateInterpolator)2 CoordinatorLayout (android.support.design.widget.CoordinatorLayout)2 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)2 WindowPanel (com.android.server.wm.WindowManagerService.WindowPanel)2 Fragment (android.app.Fragment)1 FragmentTransaction (android.app.FragmentTransaction)1 Intent (android.content.Intent)1