Example usage for android.view.animation DecelerateInterpolator DecelerateInterpolator

List of usage examples for android.view.animation DecelerateInterpolator DecelerateInterpolator

Introduction

In this page you can find the example usage for android.view.animation DecelerateInterpolator DecelerateInterpolator.

Prototype

public DecelerateInterpolator() 

Source Link

Usage

From source file:net.nym.napply.library.behavior.HeadScrollShowHideBehavior.java

private void hide(final View child) {
    if (child == null) {
        return;/* w ww.  j  a  v  a 2 s  .c o  m*/
    }
    final float translationY = child.getTranslationY();
    //show -> hide
    if (translationY < 0 || isAnimate) {
        return;
    }
    ViewPropertyAnimatorCompat animator = ViewCompat.animate(child);
    animator.translationY(-child.getHeight()).setDuration(500).setInterpolator(new DecelerateInterpolator())
            .setListener(new ViewPropertyAnimatorListener() {
                @Override
                public void onAnimationStart(View view) {
                    isAnimate = true;
                }

                @Override
                public void onAnimationEnd(View view) {
                    child.setVisibility(View.GONE);
                    isAnimate = false;
                }

                @Override
                public void onAnimationCancel(View view) {
                    show(child);
                }
            }).start();
}

From source file:com.savvasdalkitsis.betwixt.Interpolators.java

/**
 * <strong>ANDROID INTERPOLATOR</strong><br/><br/>
 * An interpolator where the rate of change starts out quickly and and then decelerates.
 *//*from w ww  .ja  v a 2 s  .com*/
@NonNull
public static Interpolator decelerate() {
    return new DecelerateInterpolator();
}

From source file:arun.com.chromer.browsing.article.util.ArticleScrollListener.java

@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
    super.onScrolled(recyclerView, dx, dy);

    int minDistance = toolbar.getContext().getResources()
            .getDimensionPixelSize(R.dimen.article_minToolbarScroll);
    if (Math.abs(dy) < minDistance) {
        return;/* w w w .ja  va2  s .  c o  m*/
    }
    if (dy > 0 && toolbar.getTranslationY() == 0) {
        Interpolator interpolator = new AccelerateInterpolator();

        if (!isUpdatingTranslation) {
            animateTranslation(-1 * toolbar.getHeight(), interpolator);
        }

        if (transparentBackground && !isUpdatingBackground) {
            animateBackgroundColor(transparentColor, primaryColor, interpolator);
            transparentBackground = false;
        }
    } else if (dy < 0 && toolbar.getTranslationY() != 0) {
        Interpolator interpolator = new DecelerateInterpolator();

        if (!isUpdatingTranslation) {
            animateTranslation(0, interpolator);
        }

        LinearLayoutManager manager = (LinearLayoutManager) recyclerView.getLayoutManager();
        int firstItem = manager.findFirstVisibleItemPosition();
        if (!transparentBackground && firstItem == 0 && !isUpdatingBackground) {
            animateBackgroundColor(primaryColor, transparentColor, interpolator);
            transparentBackground = true;
        }
    }
}

From source file:org.videolan.vlc.gui.AboutFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle("VLC " + BuildConfig.VERSION_NAME);
    View v = inflater.inflate(R.layout.about, container, false);

    View aboutMain = v.findViewById(R.id.about_main);
    WebView t = (WebView) v.findViewById(R.id.webview);
    String revision = getString(R.string.build_revision);
    t.loadData(Util.readAsset("licence.htm", "").replace("!COMMITID!", revision), "text/html", "UTF8");

    TextView link = (TextView) v.findViewById(R.id.main_link);
    link.setText(Html.fromHtml(this.getString(R.string.about_link)));

    String builddate = getString(R.string.build_time);
    String builder = getString(R.string.build_host);

    TextView compiled = (TextView) v.findViewById(R.id.main_compiled);
    compiled.setText(builder + " (" + builddate + ")");
    TextView textview_rev = (TextView) v.findViewById(R.id.main_revision);
    textview_rev.setText(getResources().getString(R.string.revision) + " " + revision + " (" + builddate + ")");

    final ImageView logo = (ImageView) v.findViewById(R.id.logo);
    logo.setOnClickListener(new OnClickListener() {
        @Override// w w w. j av  a  2  s  . com
        public void onClick(View v) {
            AnimationSet anim = new AnimationSet(true);
            RotateAnimation rotate = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f,
                    Animation.RELATIVE_TO_SELF, 0.5f);
            rotate.setDuration(800);
            rotate.setInterpolator(new DecelerateInterpolator());
            anim.addAnimation(rotate);
            logo.startAnimation(anim);
        }
    });

    List<View> lists = Arrays.asList(aboutMain, t);
    String[] titles = new String[] { getString(R.string.about), getString(R.string.licence) };
    mViewPager = (ViewPager) v.findViewById(R.id.pager);
    mViewPager.setOffscreenPageLimit(MODE_TOTAL - 1);
    mViewPager.setAdapter(new AudioPagerAdapter(lists, titles));

    mTabLayout = (TabLayout) v.findViewById(R.id.sliding_tabs);
    mTabLayout.setupWithViewPager(mViewPager);

    return v;
}

From source file:org.videolan.vlc2.gui.AboutFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ((ActionBarActivity) getActivity()).getSupportActionBar().setTitle("VLC " + getVersion(getActivity()));

    View v = inflater.inflate(R.layout.about, container, false);

    mTabHost = (TabHost) v.findViewById(android.R.id.tabhost);
    mFlingViewGroup = (FlingViewGroup) v.findViewById(R.id.fling_view_group);

    WebView t = (WebView) v.findViewById(R.id.webview);
    String revision = Util.readAsset("revision.txt", "Unknown revision");
    t.loadData(Util.readAsset("licence.htm", "").replace("!COMMITID!", revision), "text/html", "UTF8");

    TextView link = (TextView) v.findViewById(R.id.main_link);
    link.setText(Html.fromHtml(this.getString(R.string.about_link)));

    String builddate = Util.readAsset("builddate.txt", "Unknown");
    String builder = Util.readAsset("builder.txt", "unknown");

    TextView compiled = (TextView) v.findViewById(R.id.main_compiled);
    compiled.setText(builder + " (" + builddate + ")");
    TextView textview_rev = (TextView) v.findViewById(R.id.main_revision);
    textview_rev.setText(getResources().getString(R.string.revision) + " " + revision + " (" + builddate + ")");

    final ImageView logo = (ImageView) v.findViewById(R.id.logo);
    logo.setOnClickListener(new OnClickListener() {
        @Override/*from ww w .java  2  s  . co  m*/
        public void onClick(View v) {
            AnimationSet anim = new AnimationSet(true);
            RotateAnimation rotate = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f,
                    Animation.RELATIVE_TO_SELF, 0.5f);
            rotate.setDuration(800);
            rotate.setInterpolator(new DecelerateInterpolator());
            anim.addAnimation(rotate);
            logo.startAnimation(anim);
        }
    });

    mTabHost.setup();

    addNewTab(mTabHost, "about", getResources().getString(R.string.about));
    addNewTab(mTabHost, "licence", getResources().getString(R.string.licence));

    mTabHost.setCurrentTab(mCurrentTab);
    mFlingViewGroup.snapToScreen(mCurrentTab);

    mTabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
        @Override
        public void onTabChanged(String tabId) {
            mCurrentTab = mTabHost.getCurrentTab();
            mFlingViewGroup.smoothScrollTo(mCurrentTab);
        }
    });

    mFlingViewGroup.setOnViewSwitchedListener(new FlingViewGroup.ViewSwitchListener() {
        @Override
        public void onSwitching(float progress) {
        }

        @Override
        public void onSwitched(int position) {
            mTabHost.setCurrentTab(position);
        }

        @Override
        public void onTouchDown() {
        }

        @Override
        public void onTouchUp() {
        }

        @Override
        public void onTouchClick() {
        }

        @Override
        public void onBackSwitched() {
            MainActivity activity = (MainActivity) getActivity();
            activity.popSecondaryFragment();
        }
    });

    return v;
}

From source file:com.philliphsu.bottomsheetpickers.time.numberpad.NumberPadTimePicker.java

public NumberPadTimePicker(Context context, AttributeSet attrs) {
    super(context, attrs);
    mAltButtons[0] = (Button) findViewById(R.id.bsp_leftAlt);
    mAltButtons[1] = (Button) findViewById(R.id.bsp_rightAlt);
    mFab = (FloatingActionButton) findViewById(R.id.bsp_fab);
    mBackspace = (ImageButton) findViewById(R.id.bsp_backspace);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        mElevationAnimator = ObjectAnimator
                .ofFloat(mFab, "elevation", getResources().getDimension(R.dimen.bsp_fab_elevation))
                .setDuration(200);//from  ww w .j ava  2s.com
        mElevationAnimator.setInterpolator(new DecelerateInterpolator());
    } else {
        // Only animate the elevation for 21+ because changing elevation on pre-21
        // shifts the FAB slightly up/down. For that reason, pre-21 has elevation
        // permanently set to 0 (in XML).
        mElevationAnimator = null;
    }

    mFabDisabledColorDark = ContextCompat.getColor(context, R.color.bsp_fab_disabled_dark);
    mFabDisabledColorLight = ContextCompat.getColor(context, R.color.bsp_fab_disabled_light);

    setIs24HourMode(DateFormat.is24HourFormat(context));
}

From source file:com.microsoft.mimickeralarm.mimics.ProgressButton.java

public ProgressButton(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setFocusable(true);/*  ww w.  j av  a  2  s  .  c o m*/
    setScaleType(ScaleType.CENTER_INSIDE);

    sYellow = ContextCompat.getColor(context, R.color.yellow3);
    sBlue = ContextCompat.getColor(context, R.color.blue);
    sGrey = ContextCompat.getColor(context, R.color.grey);
    sWhite = ContextCompat.getColor(context, R.color.white);
    mMicrophoneIcon = ((BitmapDrawable) ContextCompat.getDrawable(context, android.R.drawable.ic_btn_speak_now))
            .getBitmap();
    mCameraIcon = ((BitmapDrawable) ContextCompat.getDrawable(context, android.R.drawable.ic_menu_camera))
            .getBitmap();

    mBrush = new Paint(Paint.ANTI_ALIAS_FLAG);

    mLoadingAnimation = ObjectAnimator.ofFloat(this, "loadingAnimationProgress", 0f, 360f);
    mLoadingAnimation.setDuration(LOADING_ANIMATION_DURATION);
    mLoadingAnimation.setRepeatCount(ObjectAnimator.INFINITE);

    mPressedAnimation = ObjectAnimator.ofFloat(this, "radius", 0f, 0f);
    mPressedAnimation.setDuration(PRESSED_ANIMATION_DURATION);
    mPressedAnimation.setInterpolator(new DecelerateInterpolator());
}

From source file:com.liuguangqiang.ripplelayout.sample.TargetActivity.java

private void startIntoAnimation() {
    layoutTop.animate().translationY(0).setDuration(400).setInterpolator(new DecelerateInterpolator());
    layoutBottom.animate().translationY(0).setDuration(400).setInterpolator(new DecelerateInterpolator());
}

From source file:com.tanmay.blip.activities.ImageActivity.java

@SuppressLint("InlinedApi")
@Override//from  www .  j  a  v  a  2  s.c o m
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_image);
    if (BlipUtils.isLollopopUp()) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
    }
    databaseManager = new DatabaseManager(this);
    int num = getIntent().getExtras().getInt(EXTRA_NUM);
    final Comic comic = databaseManager.getComic(num);

    topBar = findViewById(R.id.topBar);
    close = findViewById(R.id.close);
    title = (TextView) findViewById(R.id.title);
    number = (TextView) findViewById(R.id.number);

    number.setText(String.valueOf(num));
    close.setOnClickListener(this);
    title.setText(comic.getTitle());
    photo = (ImageView) findViewById(R.id.img);
    topBar.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            topBar.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            if (BlipUtils.isLollopopUp()) {
                BlipUtils.setMargins(topBar, 0, getStatusBarHeight(), 0, 0);
                if (getResources().getBoolean(R.bool.landscape)) {
                    photo.setPadding(0, getStatusBarHeight() + topBar.getHeight(), 0, 0);
                } else {
                    photo.setPadding(0, getStatusBarHeight() + topBar.getHeight(), 0, getNavigationBarHeight());
                }
            } else {
                photo.setPadding(0, topBar.getHeight(), 0, 0);
            }
            Picasso.with(ImageActivity.this).load(comic.getImg()).into(photo);
            photoViewAttacher = new PhotoViewAttacher(photo);
            photoViewAttacher.setOnPhotoTapListener(ImageActivity.this);
            photoViewAttacher.setScaleType(ImageView.ScaleType.FIT_CENTER);
            topBar.setTranslationY(-(topBar.getHeight() + getStatusBarHeight()));
            topBar.animate().translationY(0).setDuration(500).setInterpolator(new DecelerateInterpolator())
                    .start();
        }
    });
}

From source file:de.interoberlin.lymbo.view.activities.SwipeRefreshBaseActivity.java

protected void onActionBarAutoShowOrHide(boolean shown) {
    for (View view : hideableHeaderViews) {
        if (shown) {
            view.animate().translationY(0).alpha(1).setDuration(HEADER_HIDE_ANIM_DURATION)
                    .setInterpolator(new DecelerateInterpolator());
        } else {//  w  w  w  .  java 2  s  . c o  m
            view.animate().translationY(-view.getBottom()).alpha(1).setDuration(HEADER_HIDE_ANIM_DURATION)
                    .setInterpolator(new DecelerateInterpolator());
        }
    }

    for (View view : hideableFooterViews) {
        if (shown) {
            view.animate().translationY(0).alpha(1).setDuration(HEADER_HIDE_ANIM_DURATION)
                    .setInterpolator(new DecelerateInterpolator());
        } else {
            view.animate()
                    .translationY(view.getHeight() + view.getPaddingBottom()
                            + getResources().getDimension(R.dimen.hide_cushion))
                    .alpha(1).setDuration(HEADER_HIDE_ANIM_DURATION)
                    .setInterpolator(new DecelerateInterpolator());
        }
    }
}