Example usage for android.view.animation TranslateAnimation setInterpolator

List of usage examples for android.view.animation TranslateAnimation setInterpolator

Introduction

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

Prototype

public void setInterpolator(Interpolator i) 

Source Link

Document

Sets the acceleration curve for this animation.

Usage

From source file:net.bither.fragment.hot.MarketFragment.java

public void showPriceAlertAnimTo(int fromX, int fromY, Market toMarket) {
    int[] containerOffset = new int[2];
    v.getLocationInWindow(containerOffset);
    containerOffset[0] += v.getPaddingLeft();
    containerOffset[1] += v.getPaddingTop();
    ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) ivMarketPriceAnimIcon.getLayoutParams();
    lp.topMargin = fromY - containerOffset[1];
    lp.leftMargin = fromX - containerOffset[0];
    int marketIndex = markets.indexOf(toMarket);
    if (marketIndex < lv.getFirstVisiblePosition() || marketIndex > lv.getLastVisiblePosition()) {
        lv.setSelection(marketIndex);/*from  w  ww.  ja v  a 2  s .c o m*/
    }
    View marketView = lv.getChildAt(marketIndex - lv.getFirstVisiblePosition());
    View toIconView = marketView.findViewById(R.id.iv_price_alert);
    int[] toLocation = new int[2];
    toIconView.getLocationInWindow(toLocation);
    TranslateAnimation anim = new TranslateAnimation(0, toLocation[0] - fromX, 0, toLocation[1] - fromY);
    anim.setDuration(300);
    anim.setInterpolator(new AccelerateDecelerateInterpolator());
    anim.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            doRefresh();
            ivMarketPriceAnimIcon.setVisibility(View.INVISIBLE);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });
    ivMarketPriceAnimIcon.setVisibility(View.VISIBLE);
    ivMarketPriceAnimIcon.startAnimation(anim);
}

From source file:ezy.ui.view.NoticeView.java

private Animation anim(float from, float to) {
    final TranslateAnimation anim = new TranslateAnimation(0, 0f, 0, 0f, Animation.RELATIVE_TO_PARENT, from,
            Animation.RELATIVE_TO_PARENT, to);
    anim.setDuration(mDuration);//from   ww  w  .ja v a  2  s. c  om
    anim.setFillAfter(false);
    anim.setInterpolator(new LinearInterpolator());
    return anim;
}

From source file:com.changhong.mscreensynergy.mainui.fragment.ViewPageFragment.java

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    //mInflater = inflater;
    View mView = inflater.inflate(R.layout.view_pager, null);
    showLeft = (Button) mView.findViewById(R.id.showLeft);
    mPager = (ViewPager) mView.findViewById(R.id.pager);
    PageFragment1 page1 = new PageFragment1();
    PageFragment2 page2 = new PageFragment2();
    PageFragment3 page3 = new PageFragment3();
    //      PageFragment4 page4 = new PageFragment4();
    //      PageFragment5 page5 = new PageFragment5();
    pagerItemList.add(page1);/* ww w.j ava  2s  .  com*/
    pagerItemList.add(page2);
    pagerItemList.add(page3);
    //      pagerItemList.add(page4);
    //      pagerItemList.add(page5);
    mAdapter = new MyAdapter(getFragmentManager());
    mPager.setAdapter(mAdapter);
    mPager.setOffscreenPageLimit(3); //3
    mPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {

            if (myPageChangeListener != null)
                myPageChangeListener.onPageSelected(position);

            if (rg_nav_content != null && rg_nav_content.getChildCount() > position) {
                ((RadioButton) rg_nav_content.getChildAt(position)).performClick();
            }

        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {

        }

        @Override
        public void onPageScrollStateChanged(int position) {

        }
    });

    /*
     * ?
     */
    rl_nav = (RelativeLayout) mView.findViewById(R.id.rl_nav);

    mHsv = (SyncHorizontalScrollView) mView.findViewById(R.id.mHsv);

    rg_nav_content = (RadioGroup) mView.findViewById(R.id.rg_nav_content);

    rg_nav_content.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {

            if (rg_nav_content.getChildAt(checkedId) != null) {

                TranslateAnimation animation = new TranslateAnimation(currentIndicatorLeft,
                        ((RadioButton) rg_nav_content.getChildAt(checkedId)).getLeft(), 0f, 0f);
                animation.setInterpolator(new LinearInterpolator());
                animation.setDuration(100);
                animation.setFillAfter(true);

                //?
                iv_nav_indicator.startAnimation(animation);

                mPager.setCurrentItem(checkedId); //ViewPager ? ?

                //? ? ?
                currentIndicatorLeft = ((RadioButton) rg_nav_content.getChildAt(checkedId)).getLeft();

                mHsv.smoothScrollTo(
                        (checkedId > 1 ? ((RadioButton) rg_nav_content.getChildAt(checkedId)).getLeft() : 0)
                                - ((RadioButton) rg_nav_content.getChildAt(2)).getLeft(),
                        0);
            }
        }
    });

    iv_nav_indicator = (ImageView) mView.findViewById(R.id.iv_nav_indicator);
    iv_nav_left = (ImageView) mView.findViewById(R.id.iv_nav_left);
    iv_nav_right = (ImageView) mView.findViewById(R.id.iv_nav_right);

    LayoutParams cursor_Params = iv_nav_indicator.getLayoutParams();
    cursor_Params.width = indicatorWidth;// ?
    iv_nav_indicator.setLayoutParams(cursor_Params);

    mHsv.setSomeParam(rl_nav, iv_nav_left, iv_nav_right, SlidingActivity.scontext);

    mInflater = (LayoutInflater) SlidingActivity.scontext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    indicatorWidth = SlidingMenu.screenWidth / 4;

    initNavigationHSV();

    return mView;
}

From source file:com.example.fragment.ScreenSlidePageFragment.java

public void startAnimation() {
    // SELECT LAYER
    ScrollView relate = (ScrollView) mRootView.findViewById(R.id.content);
    //       relate.setVisibility(View.VISIBLE);

    AnimationSet set = new AnimationSet(true);
    set.setAnimationListener(this);

    TranslateAnimation translate;
    float toX = -8.0f / 100.0f;//0.0f;
    float fromX = 0.0f;//-8.0f / 100.0f;
    float toY = 0.0f;
    float fromY = 29.0f / 100.0f;
    translate = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, fromX, Animation.RELATIVE_TO_PARENT, toX,
            Animation.RELATIVE_TO_PARENT, fromY, Animation.RELATIVE_TO_PARENT, toY);
    translate.setDuration(2000);/*from   w ww . j  a v a 2 s .  c  o m*/
    translate.setInterpolator(new AccelerateInterpolator());

    set.addAnimation(translate);
    set.setFillBefore(true);
    //          set.setFillBefore(false);
    //         set.setFillAfter(false);
    set.setFillAfter(true);

    relate.startAnimation(set);
}

From source file:com.plusub.lib.example.view.TabView.java

/**
 * ?/*w  w w  . j  ava  2s  . c  o  m*/
 * @param arg0
 */
private void moveCursor(int arg0) {
    TranslateAnimation animation = new TranslateAnimation(mCursorCurPosition, arg0 * mScreenWidth / tabCount,
            Animation.RELATIVE_TO_SELF, Animation.RELATIVE_TO_SELF);
    mCursorCurPosition = arg0 * mScreenWidth / tabCount;
    animation.setDuration(200);
    animation.setInterpolator(new LinearInterpolator());
    animation.setFillAfter(true);
    mIvCursor.startAnimation(animation);
}

From source file:com.breadwallet.presenter.activities.IntroActivity.java

private void animateSlide(final Fragment from, final Fragment to, int direction) {
    if (to instanceof IntroRecoverWalletFragment) {
        if (Utils.isUsingCustomInputMethod(to.getActivity()))
            ((IntroRecoverWalletFragment) to).disableEditText();
    }/*  w  w  w  . j  a v  a2s .  c  om*/
    int screenWidth = screenParametersPoint.x;
    int screenHeigth = screenParametersPoint.y;

    showHideFragments(from, to);
    TranslateAnimation transFrom = direction == RIGHT ? new TranslateAnimation(0, -screenWidth, 0, 0)
            : new TranslateAnimation(0, screenWidth, 0, 0);
    transFrom.setDuration(BRAnimator.horizontalSlideDuration);
    transFrom.setInterpolator(new DecelerateOvershootInterpolator(1f, 0.5f));
    View fromView = from.getView();
    if (fromView != null)
        fromView.startAnimation(transFrom);
    TranslateAnimation transTo = direction == RIGHT ? new TranslateAnimation(screenWidth, 0, 0, 0)
            : new TranslateAnimation(-screenWidth, 0, 0, 0);
    transTo.setDuration(BRAnimator.horizontalSlideDuration);
    transTo.setInterpolator(new DecelerateOvershootInterpolator(1f, 0.5f));
    transTo.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            showHideFragments(to);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });
    View toView = to.getView();
    if (toView != null)
        toView.startAnimation(transTo);
}

From source file:com.aniruddhc.acemusic.player.ListViewFragment.ListViewFragment.java

/**
 * Displays the search field./* w  w w.  ja  va  2s.c o m*/
 */
private void showSearch() {
    mSearchLayout.setVisibility(View.VISIBLE);
    final TranslateAnimation searchAnim = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0f,
            Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, -2f, Animation.RELATIVE_TO_SELF, 0f);
    searchAnim.setDuration(500l);
    searchAnim.setInterpolator(new AccelerateDecelerateInterpolator());

    final TranslateAnimation gridListAnim = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0f,
            Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 2f);

    gridListAnim.setDuration(500l);
    gridListAnim.setInterpolator(new LinearInterpolator());

    gridListAnim.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationEnd(Animation animation) {
            mListView.setAdapter(null);

        }

        @Override
        public void onAnimationRepeat(Animation animation) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onAnimationStart(Animation animation) {
            mSearchLayout.startAnimation(searchAnim);
            mSearchLayout.setVisibility(View.VISIBLE);

        }

    });

    searchAnim.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationEnd(Animation animation) {
            if (mSearchEditText.requestFocus()) {
                mFragment.getActivity().getWindow()
                        .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
            }

        }

        @Override
        public void onAnimationRepeat(Animation animation) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onAnimationStart(Animation animation) {
            // TODO Auto-generated method stub

        }

    });

    mListView.startAnimation(gridListAnim);

}

From source file:com.example.fragment.PrimitiveFragment.java

public void testAnimation(float destX, float destY) {
    this.mDestX = Factory.getAdjustedX(destX);
    this.mDestY = Factory.getAdjustedY(destY);
    // SELECT LAYER
    FrameLayout relate = (FrameLayout) mRootView.findViewById(R.id.FLBackLayer);
    //       ScrollView relate = (ScrollView)mRootView.findViewById(R.id.content);
    //       relate.setVisibility(View.VISIBLE);

    AnimationSet set = new AnimationSet(true);
    set.setAnimationListener(this);

    TranslateAnimation translate;
    float toX = this.mDestX;
    float fromX = this.mSrcX;
    float toY = this.mDestY;
    float fromY = this.mSrcY;
    translate = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, fromX, Animation.RELATIVE_TO_PARENT, toX,
            Animation.RELATIVE_TO_PARENT, fromY, Animation.RELATIVE_TO_PARENT, toY);
    translate.setDuration(Constants.Animation.IPF_START);
    translate.setInterpolator(new AccelerateInterpolator());

    set.addAnimation(translate);//  w w w  .j ava 2  s . c  o  m
    set.setFillBefore(true);
    //          set.setFillBefore(false);
    //         set.setFillAfter(false);
    set.setFillAfter(true);

    relate.startAnimation(set);
}

From source file:com.example.fragment.PrimitiveFragment.java

public void move(float destX, float destY) {
    if (!this.mIsAlive)
        return;/*from  w  ww .  j av  a2  s  . com*/
    if (this.mIsMoving) {
        return;// ADD Array
    }
    this.mDestX = Factory.getAdjustedX(destX - this.mPaddingW);
    this.mDestY = Factory.getAdjustedY(destY - this.mPaddingH);
    // SELECT LAYER 
    FrameLayout relate = (FrameLayout) mRootView.findViewById(R.id.FLBackLayer);
    //       ScrollView relate = (ScrollView)mRootView.findViewById(R.id.content);
    //       relate.setVisibility(View.VISIBLE);

    AnimationSet set = new AnimationSet(true);
    set.setAnimationListener(this);

    TranslateAnimation translate;
    float toX = this.mDestX;
    float fromX = this.mSrcX;
    float toY = this.mDestY;
    float fromY = this.mSrcY;
    translate = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, fromX, Animation.RELATIVE_TO_PARENT, toX,
            Animation.RELATIVE_TO_PARENT, fromY, Animation.RELATIVE_TO_PARENT, toY);
    translate.setDuration(Constants.Animation.IPF);
    translate.setInterpolator(new AccelerateInterpolator());

    set.addAnimation(translate);
    set.setFillBefore(true);
    //          set.setFillBefore(false);
    //         set.setFillAfter(false);
    set.setFillAfter(true);

    relate.startAnimation(set);
    this.mIsMoving = true;
    this.mIsMove = true;
}

From source file:com.aniruddhc.acemusic.player.BrowserSubListActivity.BrowserSubListActivity.java

/**
 * Slides away the GridView./*from ww  w.  j  a  v a 2  s  .  co m*/
 */
private void slideAwayGridView() {
    android.view.animation.TranslateAnimation animation = new android.view.animation.TranslateAnimation(
            Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
            0.0f, Animation.RELATIVE_TO_SELF, 2.0f);

    animation.setDuration(400);
    animation.setInterpolator(new AccelerateInterpolator(2.0f));
    animation.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationEnd(Animation arg0) {
            mListView.setVisibility(View.INVISIBLE);
            BrowserSubListActivity.super.onBackPressed();

        }

        @Override
        public void onAnimationRepeat(Animation arg0) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onAnimationStart(Animation arg0) {

        }

    });

    mListView.startAnimation(animation);
}