Example usage for android.view.animation TranslateAnimation setDuration

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

Introduction

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

Prototype

public void setDuration(long durationMillis) 

Source Link

Document

How long this animation should last.

Usage

From source file:com.turingtechnologies.materialscrollbar.MaterialScrollBar.java

/**
 * Animates the bar out of view/* ww w. j av a 2  s.  c  o  m*/
 */
private void fadeOut() {
    if (!hidden) {
        TranslateAnimation anim = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f,
                Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_PARENT, 0.0f,
                Animation.RELATIVE_TO_PARENT, 0.0f);
        anim.setDuration(500);
        anim.setFillAfter(true);
        hidden = true;
        startAnimation(anim);
    }
}

From source file:com.cachirulop.moneybox.fragment.MoneyboxFragment.java

/**
 * Create dynamically an android animation for a coin or a bill getting from
 * the moneybox./*from w  ww .j av  a2  s  .  co m*/
 * 
 * @param img
 *            ImageView to receive the animation
 * @param layout
 *            Layout that paint the image
 * @return Set of animations to apply to the image
 */
private AnimationSet createGetAnimation(ImageView img, View layout) {
    AnimationSet result;

    result = new AnimationSet(false);
    result.setFillAfter(true);

    // get
    TranslateAnimation get;
    int bottom;

    bottom = Math.abs(layout.getHeight() - img.getLayoutParams().height);
    get = new TranslateAnimation(1.0f, 1.0f, bottom, 1.0f);
    get.setDuration(1500);
    result.addAnimation(get);

    // Fade out
    AlphaAnimation fadeOut;

    fadeOut = new AlphaAnimation(1.0f, 0.0f);
    fadeOut.setDuration(300);
    fadeOut.setStartOffset(1500);

    result.addAnimation(fadeOut);

    return result;
}

From source file:com.mappn.gfan.ui.HomeTabActivity.java

@Override
public void onTabChanged(String tabId) {

    // ?//from w  w  w . ja v  a 2 s .c  om
    if (TAB_APP.equals(tabId)) {
        Utils.trackEvent(getApplicationContext(), Constants.GROUP_4, Constants.CLICK_MANAGER_TAB);
    } else if (TAB_CATEGORY.equals(tabId)) {
        Utils.trackEvent(getApplicationContext(), Constants.GROUP_4, Constants.CLICK_CATEGORY_TAB);
    } else if (TAB_RANK.equals(tabId)) {
        Utils.trackEvent(getApplicationContext(), Constants.GROUP_4, Constants.CLICK_RANK_TAB);
    } else if (TAB_HOME.equals(tabId)) {
        Utils.trackEvent(getApplicationContext(), Constants.GROUP_4, Constants.CLICK_HOME_TAB);
    }
    final View tab = getTabHost().getCurrentTabView();
    final int endX = tab.getLeft();

    final TranslateAnimation animation = new TranslateAnimation(mStartX, endX, 0, 0);
    animation.setDuration(200);
    animation.setFillAfter(true);
    if (mMover == null) {
        initTabAnimationParameter();
    }
    mMover.startAnimation(animation);
    mStartX = endX;
}

From source file:org.mariotaku.gallery3d.ImageViewerGLActivity.java

private void hideBars() {
    if (!mShowBars || isSwiping())
        return;/*from  w  w w  .j a v  a2  s . co  m*/
    mShowBars = false;
    mActionBar.hide();
    final TranslateAnimation anim = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0,
            Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 1);
    anim.setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime));
    anim.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationEnd(final Animation animation) {
            mMenuBar.setVisibility(View.GONE);
        }

        @Override
        public void onAnimationRepeat(final Animation animation) {

        }

        @Override
        public void onAnimationStart(final Animation animation) {

        }
    });
    mMenuBar.startAnimation(anim);
    mHandler.removeMessages(MSG_HIDE_BARS);
}

From source file:net.xisberto.work_schedule.alarm.AlarmMessageActivity.java

@Override
public boolean onTouch(View view, MotionEvent event) {
    if (event.getPointerCount() > 1) {
        return super.onTouchEvent(event);
    }/*from   w  ww  . j  a v  a 2s  .c o  m*/

    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) view.getLayoutParams();

    int action = MotionEventCompat.getActionMasked(event);
    if (view.getId() == R.id.frame_bottom || view.getId() == R.id.frame_top) {
        switch (action) {
        case MotionEvent.ACTION_DOWN:
            initialPoint = event.getRawY();
            moving = true;
            break;
        case MotionEvent.ACTION_MOVE:
            if (moving) {
                hinter.interrupt();
                currentPoint = event.getRawY();

                DisplayMetrics displayMetrics = new DisplayMetrics();
                getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
                int screenHeight = displayMetrics.heightPixels;

                if (view.getId() == R.id.frame_top) {
                    int new_margin = (int) (currentPoint - initialPoint);
                    params.topMargin = (new_margin > 0) ? new_margin : 0;
                    if ((new_margin > (screenHeight / 3)) && (!isFinishing())) {
                        snoozeAlarm();
                        break;
                    }
                } else {
                    int new_margin = (int) (initialPoint - currentPoint);
                    params.bottomMargin = (new_margin > 0) ? new_margin : 0;
                    if ((new_margin > (screenHeight / 3)) && (!isFinishing())) {
                        cancelAlarm();
                        break;
                    }
                }
                view.setLayoutParams(params);
                view.invalidate();
            }
            break;
        case MotionEvent.ACTION_UP:
            initialPoint = 0;
            TranslateAnimation ta;
            if (view.getId() == R.id.frame_top) {
                ta = new TranslateAnimation(0, 0, params.topMargin, 0);
                params.topMargin = 0;
            } else {
                ta = new TranslateAnimation(0, 0, -params.bottomMargin, 0);
                params.bottomMargin = 0;
            }
            ta.setDuration(100);
            view.setLayoutParams(params);
            view.startAnimation(ta);
            moving = false;
            startHinter();
            break;
        default:
            return super.onTouchEvent(event);
        }
    }
    return true;
}

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);/*from www  .j av  a 2 s . com*/
    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 w  w .  j av  a 2s.  c o m*/
    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.dtr.zxing.activity.CaptureActivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    Window window = getWindow();/*from  w  ww. ja  v  a2s. c o  m*/
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setContentView(R.layout.activity_qr_scan);

    scanPreview = (SurfaceView) findViewById(R.id.capture_preview);
    scanContainer = (RelativeLayout) findViewById(R.id.capture_container);
    scanCropView = (RelativeLayout) findViewById(R.id.capture_crop_view);
    scanLine = (ImageView) findViewById(R.id.capture_scan_line);
    mFlash = (ImageView) findViewById(R.id.capture_flash);
    mFlash.setOnClickListener(this);

    inactivityTimer = new InactivityTimer(this);
    beepManager = new BeepManager(this);

    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_PARENT, 0.9f);
    animation.setDuration(4500);
    animation.setRepeatCount(-1);
    animation.setRepeatMode(Animation.RESTART);
    scanLine.startAnimation(animation);
}

From source file:com.cachirulop.moneybox.fragment.MoneyboxFragment.java

/**
 * Create dynamically an android animation for a coin or a bill droping into
 * the moneybox.//from w w  w.  j av  a2  s . c o m
 * 
 * @param img
 *            ImageView to receive the animation
 * @param layout
 *            Layout that paint the image
 * @param curr
 *            Currency value of the image
 * @return Set of animations to apply to the image
 */
private AnimationSet createDropAnimation(ImageView img, View layout, CurrencyValueDef curr) {
    AnimationSet result;

    result = new AnimationSet(false);
    result.setFillAfter(true);

    // Fade in
    AlphaAnimation fadeIn;

    fadeIn = new AlphaAnimation(0.0f, 1.0f);
    fadeIn.setDuration(300);
    result.addAnimation(fadeIn);

    // drop
    TranslateAnimation drop;
    int bottom;

    bottom = Math.abs(layout.getHeight() - img.getLayoutParams().height);
    drop = new TranslateAnimation(1.0f, 1.0f, 1.0f, bottom);
    drop.setStartOffset(300);
    drop.setDuration(1500);

    if (curr.getType() == CurrencyValueDef.MoneyType.COIN) {
        drop.setInterpolator(new BounceInterpolator());
    } else {
        // drop.setInterpolator(new DecelerateInterpolator(0.7f));
        drop.setInterpolator(new AnticipateOvershootInterpolator());
    }

    result.addAnimation(drop);

    return result;
}

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

/**
 * Slides away the GridView./*from ww  w . ja  v a2  s  .  c  om*/
 */
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);
}