Example usage for android.view.animation Animation ABSOLUTE

List of usage examples for android.view.animation Animation ABSOLUTE

Introduction

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

Prototype

int ABSOLUTE

To view the source code for android.view.animation Animation ABSOLUTE.

Click Source Link

Document

The specified dimension is an absolute number of pixels.

Usage

From source file:com.juick.android.ThreadFragment.java

private void resetMainMenuButton(boolean animate) {
    if (navMenu != null) {
        TranslateAnimation immediate = new TranslateAnimation(Animation.ABSOLUTE,
                animate ? initNavMenuTranslationX + 100 : initNavMenuTranslationX, Animation.ABSOLUTE,
                initNavMenuTranslationX, Animation.ABSOLUTE, 0, Animation.ABSOLUTE, 0);
        immediate.setDuration(500);/*from   w w  w  .  j ava2s  .  c  om*/
        immediate.setFillEnabled(true);
        immediate.setFillBefore(true);
        immediate.setFillAfter(true);
        navMenu.startAnimation(immediate);
    }
    //navMenu.startAnimation(immediate);
}

From source file:com.juick.android.ThreadFragment.java

private void closeNavigationMenu() {
    navigationMenuShown = false;//  ww w  .  jav  a2 s  .  c o m
    for (int i = 0; i < flyingItems.length; i++) {
        final FlyingItem item = flyingItems[i];
        item.setVisibility(View.VISIBLE);
        item.ani = new TranslateAnimation(Animation.ABSOLUTE, 0, Animation.ABSOLUTE,
                -item.designedX + item.widget.getWidth() * 1.5f, Animation.ABSOLUTE, 0, Animation.ABSOLUTE,
                -item.designedY);
        item.ani.setDuration(500);
        item.ani.setInterpolator(new AccelerateInterpolator(1));

        item.ani.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
                //To change body of implemented methods use File | Settings | File Templates.
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                item.setVisibility(View.GONE);
                item.widget.clearAnimation();
                item.widget.disableReposition = false;
                item.widget.layout(item.originalHitRect.left, item.originalHitRect.top,
                        item.originalHitRect.right, item.originalHitRect.bottom);
                if (item == flyingItems[0]) {
                    TranslateAnimation aniIn = new TranslateAnimation(Animation.ABSOLUTE, 600,
                            Animation.ABSOLUTE, initNavMenuTranslationX, Animation.ABSOLUTE, 0,
                            Animation.ABSOLUTE, 0);
                    aniIn.setInterpolator(new DecelerateInterpolator(1));
                    item.ani.setDuration(500);
                    aniIn.setFillAfter(true);
                    navMenu.startAnimation(aniIn);
                }
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
                //To change body of implemented methods use File | Settings | File Templates.
            }
        });
        item.ani.setFillAfter(true);
        item.widget.startAnimation(item.ani);
    }
}

From source file:com.juick.android.ThreadFragment.java

private void openNavigationMenu(float currentTranslation) {
    try {//from   ww  w. jav a2s  . c o m
        navigationMenuShown = true;
        for (final FlyingItem item : flyingItems) {
            item.setVisibility(View.VISIBLE);
            item.ani = new TranslateAnimation(Animation.ABSOLUTE, 300, Animation.ABSOLUTE, item.designedX,
                    Animation.ABSOLUTE, 0, Animation.ABSOLUTE, item.designedY);

            item.ani.setInterpolator(new OvershootInterpolator(2));
            item.ani.setDuration(500);
            item.ani.setFillAfter(true);
            item.ani.setAnimationListener(new Animation.AnimationListener() {
                @Override
                public void onAnimationStart(Animation animation) {
                    //To change body of implemented methods use File | Settings | File Templates.
                }

                @Override
                public void onAnimationEnd(Animation animation) {
                    // this code is very ugly because it's all android 2.3 animations.
                    item.widget.getHitRect(item.originalHitRect);
                    item.widget.clearAnimation();
                    item.widget.layout(item.originalHitRect.left + (int) item.widget.initialTranslationX,
                            item.originalHitRect.top + (int) item.widget.initialTranslationY,
                            item.originalHitRect.right + (int) item.widget.initialTranslationX,
                            item.originalHitRect.bottom + (int) item.widget.initialTranslationY);
                    item.widget.disableReposition = true;
                }

                @Override
                public void onAnimationRepeat(Animation animation) {
                    //To change body of implemented methods use File | Settings | File Templates.
                }
            });
            item.widget.startAnimation(item.ani);
        }
        TranslateAnimation aniOut = new TranslateAnimation(Animation.ABSOLUTE, currentTranslation,
                Animation.ABSOLUTE, -1.2f * getActivity().getWindowManager().getDefaultDisplay().getWidth(),
                Animation.ABSOLUTE, 0, Animation.ABSOLUTE, 0);
        aniOut.setInterpolator(new DecelerateInterpolator(1));
        aniOut.setDuration(700);
        aniOut.setFillAfter(true);
        navMenu.startAnimation(aniOut);

        getListView().performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    } catch (Throwable e) {
        e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
    }
}

From source file:de.tum.in.tumcampus.auxiliary.calendar.DayView.java

private View switchViews(boolean forward, float xOffSet, float width, float velocity) {
    mAnimationDistance = width - xOffSet;

    float progress = Math.abs(xOffSet) / width;
    if (progress > 1.0f) {
        progress = 1.0f;/*from w  w w .j  a  v  a2  s  . c om*/
    }

    float inFromXValue, inToXValue;
    float outFromXValue, outToXValue;
    if (forward) {
        inFromXValue = 1.0f - progress;
        inToXValue = 0.0f;
        outFromXValue = -progress;
        outToXValue = -1.0f;
    } else {
        inFromXValue = progress - 1.0f;
        inToXValue = 0.0f;
        outFromXValue = progress;
        outToXValue = 1.0f;
    }

    final Time start = new Time(mBaseDate.timezone);
    start.set(mController.getTime());
    if (forward) {
        start.monthDay += mNumDays;
    } else {
        start.monthDay -= mNumDays;
    }
    mController.setTime(start.normalize(true));

    Time newSelected = start;

    if (mNumDays == 7) {
        newSelected = new Time(start);
        adjustToBeginningOfWeek(start);
    }

    final Time end = new Time(start);
    end.monthDay += mNumDays - 1;

    // We have to allocate these animation objects each time we switch views
    // because that is the only way to set the animation parameters.
    TranslateAnimation inAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, inFromXValue,
            Animation.RELATIVE_TO_SELF, inToXValue, Animation.ABSOLUTE, 0.0f, Animation.ABSOLUTE, 0.0f);

    TranslateAnimation outAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, outFromXValue,
            Animation.RELATIVE_TO_SELF, outToXValue, Animation.ABSOLUTE, 0.0f, Animation.ABSOLUTE, 0.0f);

    long duration = calculateDuration(width - Math.abs(xOffSet), width, velocity);
    inAnimation.setDuration(duration);
    inAnimation.setInterpolator(mHScrollInterpolator);
    outAnimation.setInterpolator(mHScrollInterpolator);
    outAnimation.setDuration(duration);
    outAnimation.setAnimationListener(new GotoBroadcaster(start, end));

    mViewSwitcher.setInAnimation(inAnimation);
    mViewSwitcher.setOutAnimation(outAnimation);

    DayView view = (DayView) mViewSwitcher.getCurrentView();
    view.cleanup();
    mViewSwitcher.showNext();
    view = (DayView) mViewSwitcher.getCurrentView();
    view.setSelected(newSelected, true, false);
    view.requestFocus();
    view.reloadEvents();
    view.updateTitle();
    view.restartCurrentTimeUpdates();

    return view;
}