Search in sources :

Example 46 with TranslateAnimation

use of android.view.animation.TranslateAnimation in project android_packages_apps_OmniClock by omnirom.

the class StopwatchFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    ViewGroup v = (ViewGroup) inflater.inflate(org.omnirom.deskclock.R.layout.stopwatch_fragment, container, false);
    mTime = (CircleTimerView) v.findViewById(org.omnirom.deskclock.R.id.stopwatch_time);
    mTime.setBackgroundResource(Utils.getCircleViewBackgroundResourceId(getActivity()));
    mTimeText = (CountingTimerView) v.findViewById(org.omnirom.deskclock.R.id.stopwatch_time_text);
    mLapsList = (ListView) v.findViewById(org.omnirom.deskclock.R.id.laps_list);
    mLapsList.setDividerHeight(0);
    mLapsAdapter = new LapsListAdapter(getActivity());
    mLapsList.setAdapter(mLapsAdapter);
    View footerView = inflater.inflate(org.omnirom.deskclock.R.layout.blank_footer_view, mLapsList, false);
    mLapsList.addFooterView(footerView, null, false);
    mTimeText.registerVirtualButtonAction(new Runnable() {

        @Override
        public void run() {
            toggleStopwatchState();
        }
    });
    mCircleLayout = (CircleButtonsLayout) v.findViewById(org.omnirom.deskclock.R.id.stopwatch_circle);
    mCircleLayout.setCircleTimerViewIds(org.omnirom.deskclock.R.id.stopwatch_time, 0, /* stopwatchId */
    0, /* labelId */
    0);
    // Animation setup
    mLayoutTransition = new LayoutTransition();
    mCircleLayoutTransition = new LayoutTransition();
    // The CircleButtonsLayout only needs to undertake location changes
    mCircleLayoutTransition.enableTransitionType(LayoutTransition.CHANGING);
    mCircleLayoutTransition.disableTransitionType(LayoutTransition.APPEARING);
    mCircleLayoutTransition.disableTransitionType(LayoutTransition.DISAPPEARING);
    mCircleLayoutTransition.disableTransitionType(LayoutTransition.CHANGE_APPEARING);
    mCircleLayoutTransition.disableTransitionType(LayoutTransition.CHANGE_DISAPPEARING);
    mCircleLayoutTransition.setAnimateParentHierarchy(false);
    // These spacers assist in keeping the size of CircleButtonsLayout constant
    mStartSpace = v.findViewById(org.omnirom.deskclock.R.id.start_space);
    mEndSpace = v.findViewById(org.omnirom.deskclock.R.id.end_space);
    mSpacersUsed = mStartSpace != null || mEndSpace != null;
    // Listener to invoke extra animation within the laps-list
    mLayoutTransition.addTransitionListener(new LayoutTransition.TransitionListener() {

        @Override
        public void startTransition(LayoutTransition transition, ViewGroup container, View view, int transitionType) {
            if (view == mLapsList) {
                if (transitionType == LayoutTransition.DISAPPEARING) {
                    if (DEBUG)
                        LogUtils.v("StopwatchFragment.start laps-list disappearing");
                    boolean shiftX = view.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
                    int first = mLapsList.getFirstVisiblePosition();
                    int last = mLapsList.getLastVisiblePosition();
                    // Ensure index range will not cause a divide by zero
                    if (last < first) {
                        last = first;
                    }
                    long duration = transition.getDuration(LayoutTransition.DISAPPEARING);
                    long offset = duration / (last - first + 1) / 5;
                    for (int visibleIndex = first; visibleIndex <= last; visibleIndex++) {
                        View lapView = mLapsList.getChildAt(visibleIndex - first);
                        if (lapView != null) {
                            float toXValue = shiftX ? 1.0f * (visibleIndex - first + 1) : 0;
                            float toYValue = shiftX ? 0 : 4.0f * (visibleIndex - first + 1);
                            TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, toXValue, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, toYValue);
                            animation.setStartOffset((last - visibleIndex) * offset);
                            animation.setDuration(duration);
                            lapView.startAnimation(animation);
                        }
                    }
                }
            }
        }

        @Override
        public void endTransition(LayoutTransition transition, ViewGroup container, View view, int transitionType) {
            if (transitionType == LayoutTransition.DISAPPEARING) {
                if (DEBUG)
                    LogUtils.v("StopwatchFragment.end laps-list disappearing");
                int last = mLapsList.getLastVisiblePosition();
                for (int visibleIndex = mLapsList.getFirstVisiblePosition(); visibleIndex <= last; visibleIndex++) {
                    View lapView = mLapsList.getChildAt(visibleIndex);
                    if (lapView != null) {
                        Animation animation = lapView.getAnimation();
                        if (animation != null) {
                            animation.cancel();
                        }
                    }
                }
            }
        }
    });
    return v;
}
Also used : ViewGroup(android.view.ViewGroup) TranslateAnimation(android.view.animation.TranslateAnimation) TranslateAnimation(android.view.animation.TranslateAnimation) Animation(android.view.animation.Animation) LayoutTransition(android.animation.LayoutTransition) CountingTimerView(org.omnirom.deskclock.timer.CountingTimerView) View(android.view.View) CircleTimerView(org.omnirom.deskclock.CircleTimerView) TextView(android.widget.TextView) ListView(android.widget.ListView)

Example 47 with TranslateAnimation

use of android.view.animation.TranslateAnimation in project BaseProject by feer921.

the class CanDragScrollView method animation.

public void animation() {
    TranslateAnimation ta = new TranslateAnimation(0, 0, inner.getTop(), normal.top);
    ta.setDuration(200);
    inner.startAnimation(ta);
    inner.layout(normal.left, normal.top, normal.right, normal.bottom);
    normal.setEmpty();
}
Also used : TranslateAnimation(android.view.animation.TranslateAnimation)

Example 48 with TranslateAnimation

use of android.view.animation.TranslateAnimation in project Signal-Android by signalapp.

the class VerificationPinKeyboard method displayFailure.

public ListenableFuture<Boolean> displayFailure() {
    SettableFuture<Boolean> result = new SettableFuture<>();
    this.keyboardView.setVisibility(View.INVISIBLE);
    this.progressBar.setVisibility(View.GONE);
    this.failureView.setVisibility(View.GONE);
    this.lockedView.setVisibility(View.GONE);
    this.failureView.getBackground().setColorFilter(getResources().getColor(R.color.red_500), PorterDuff.Mode.SRC_IN);
    this.failureView.setVisibility(View.VISIBLE);
    TranslateAnimation shake = new TranslateAnimation(0, 30, 0, 0);
    shake.setDuration(50);
    shake.setRepeatCount(7);
    shake.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            result.set(true);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });
    this.failureView.startAnimation(shake);
    return result;
}
Also used : SettableFuture(org.thoughtcrime.securesms.util.concurrent.SettableFuture) TranslateAnimation(android.view.animation.TranslateAnimation) ScaleAnimation(android.view.animation.ScaleAnimation) TranslateAnimation(android.view.animation.TranslateAnimation) Animation(android.view.animation.Animation)

Example 49 with TranslateAnimation

use of android.view.animation.TranslateAnimation in project Signal-Android by signalapp.

the class AttachmentTypeSelector method animateWindowInTranslate.

private void animateWindowInTranslate(@NonNull View contentView) {
    Animation animation = new TranslateAnimation(0, 0, contentView.getHeight(), 0);
    animation.setDuration(ANIMATION_DURATION);
    getContentView().startAnimation(animation);
}
Also used : ScaleAnimation(android.view.animation.ScaleAnimation) TranslateAnimation(android.view.animation.TranslateAnimation) Animation(android.view.animation.Animation) TranslateAnimation(android.view.animation.TranslateAnimation)

Example 50 with TranslateAnimation

use of android.view.animation.TranslateAnimation in project Signal-Android by signalapp.

the class AttachmentTypeSelector method animateWindowOutTranslate.

private void animateWindowOutTranslate(@NonNull View contentView) {
    Animation animation = new TranslateAnimation(0, 0, 0, contentView.getTop() + contentView.getHeight());
    animation.setDuration(ANIMATION_DURATION);
    animation.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            AttachmentTypeSelector.super.dismiss();
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });
    getContentView().startAnimation(animation);
}
Also used : ScaleAnimation(android.view.animation.ScaleAnimation) TranslateAnimation(android.view.animation.TranslateAnimation) Animation(android.view.animation.Animation) TranslateAnimation(android.view.animation.TranslateAnimation)

Aggregations

TranslateAnimation (android.view.animation.TranslateAnimation)229 Animation (android.view.animation.Animation)109 AlphaAnimation (android.view.animation.AlphaAnimation)90 AnimationSet (android.view.animation.AnimationSet)69 ScaleAnimation (android.view.animation.ScaleAnimation)44 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)30 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)27 View (android.view.View)22 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)22 TextView (android.widget.TextView)18 AnimationListener (android.view.animation.Animation.AnimationListener)17 LinearInterpolator (android.view.animation.LinearInterpolator)13 RotateAnimation (android.view.animation.RotateAnimation)13 ClipRectAnimation (android.view.animation.ClipRectAnimation)12 ListView (android.widget.ListView)12 CurvedTranslateAnimation (com.android.server.wm.animation.CurvedTranslateAnimation)12 ImageView (android.widget.ImageView)11 LayoutAnimationController (android.view.animation.LayoutAnimationController)8 WindowAnimation_activityCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseEnterAnimation)8 WindowAnimation_activityCloseExitAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseExitAnimation)8