Java Code Examples for android.view.animation.Animation#setStartOffset()

The following examples show how to use android.view.animation.Animation#setStartOffset() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnimationUtils.java    From Lay-s with MIT License 6 votes vote down vote up
public static void clickCurtain(View v) {
    AnimationSet set = new AnimationSet(false);
    Animation anim1 = getTranslateAnimation(0, 0, 0, -50, 110);
    Animation anim2 = getTranslateAnimation(0, 0, -50, 0, 80);
    Animation anim3 = getTranslateAnimation(0, 0, 0, -25, 25);
    Animation anim4 = getTranslateAnimation(0, 0, -25, 0, 25);
    anim1.setStartOffset(20);
    anim2.setStartOffset(230);
    anim3.setStartOffset(360);
    anim4.setStartOffset(400);
    set.addAnimation(anim1);
    set.addAnimation(anim2);
    set.addAnimation(anim3);
    set.addAnimation(anim4);
    v.startAnimation(set);
}
 
Example 2
Source File: RayLayout.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
private static Animation createShrinkAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta,
		long startOffset, long duration, Interpolator interpolator) {
	AnimationSet animationSet = new AnimationSet(false);
	animationSet.setFillAfter(true);

	final long preDuration = duration / 2;
	Animation rotateAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f,
			Animation.RELATIVE_TO_SELF, 0.5f);
	rotateAnimation.setStartOffset(startOffset);
	rotateAnimation.setDuration(preDuration);
	rotateAnimation.setInterpolator(new LinearInterpolator());
	rotateAnimation.setFillAfter(true);

	animationSet.addAnimation(rotateAnimation);

	Animation translateAnimation = new RotateAndTranslateAnimation(0, toXDelta, 0, toYDelta, 360, 720);
	translateAnimation.setStartOffset(startOffset + preDuration);
	translateAnimation.setDuration(duration - preDuration);
	translateAnimation.setInterpolator(interpolator);
	translateAnimation.setFillAfter(true);

	animationSet.addAnimation(translateAnimation);

	return animationSet;
}
 
Example 3
Source File: CreateLiveDialog.java    From MeiBaseModule with Apache License 2.0 6 votes vote down vote up
@Override
protected void initData() {
    Animation animation = AnimationUtils.loadAnimation(getActivity(), R.anim.live_btn_bottom_in);
    animation.setStartOffset(80);
    mTvLive.startAnimation(animation);
    animation = AnimationUtils.loadAnimation(getActivity(), R.anim.live_btn_bottom_in);
    animation.setStartOffset(160);
    mTvVideo.startAnimation(animation);
    animation = AnimationUtils.loadAnimation(getActivity(), R.anim.live_btn_bottom_in);
    animation.setStartOffset(200);
    mIvClose.startAnimation(animation);

    mIvClose.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            dismiss();
        }
    });
}
 
Example 4
Source File: FwUpgradeActivity.java    From MiBandDecompiled with Apache License 2.0 6 votes vote down vote up
public void enterAnimation()
{
    Animation animation = AnimationUtils.loadAnimation(this, 0x7f040001);
    Animation animation1 = AnimationUtils.loadAnimation(this, 0x7f040001);
    Animation animation2 = AnimationUtils.loadAnimation(this, 0x7f040001);
    Animation animation3 = AnimationUtils.loadAnimation(this, 0x7f040001);
    animation.setStartOffset(0L);
    animation1.setStartOffset(100L);
    animation2.setStartOffset(150L);
    animation3.setStartOffset(200L);
    animation3.setAnimationListener(new an(this));
    DecelerateInterpolator decelerateinterpolator = new DecelerateInterpolator(2.0F);
    animation.setInterpolator(decelerateinterpolator);
    animation1.setInterpolator(decelerateinterpolator);
    animation2.setInterpolator(decelerateinterpolator);
    animation3.setInterpolator(decelerateinterpolator);
    i.startAnimation(animation);
    j.startAnimation(animation1);
    k.startAnimation(animation2);
    h.startAnimation(animation3);
}
 
Example 5
Source File: AwesomeTextView.java    From Android-Bootstrap with MIT License 6 votes vote down vote up
/**
 * Starts a Flashing Animation on the AwesomeTextView
 *
 * @param forever whether the animation should be infinite or play once
 * @param speed   how fast the item should flash
 */
public void startFlashing(boolean forever, AnimationSpeed speed) {
    Animation fadeIn = new AlphaAnimation(0, 1);

    //set up extra variables
    fadeIn.setDuration(50);
    fadeIn.setRepeatMode(Animation.REVERSE);

    //default repeat count is 0, however if user wants, set it up to be infinite
    fadeIn.setRepeatCount(0);
    if (forever) {
        fadeIn.setRepeatCount(Animation.INFINITE);
    }

    fadeIn.setStartOffset(speed.getFlashDuration());
    startAnimation(fadeIn);
}
 
Example 6
Source File: PlayVoiceView.java    From imsdk-android with MIT License 6 votes vote down vote up
public void startBlinking() {
    Animation fadeIn = new AlphaAnimation(0.2f, 1f);
    fadeIn.setInterpolator(new DecelerateInterpolator()); //add this
    fadeIn.setDuration(1000);

    Animation fadeOut = new AlphaAnimation(1f, 0.2f);
    fadeOut.setInterpolator(new AccelerateInterpolator()); //and this
    fadeOut.setStartOffset(1000);
    fadeOut.setDuration(1000);

    final AnimationSet animationSet = new AnimationSet(false);
    animationSet.addAnimation(fadeIn);
    animationSet.addAnimation(fadeOut);
    animationSet.setRepeatCount(AnimationSet.INFINITE);
    animationSet.setRepeatMode(Animation.REVERSE);
    setAnimation(animationSet);
    animationSet.start();

}
 
Example 7
Source File: AnimationUtils.java    From Lay-s with MIT License 6 votes vote down vote up
public static void shakeCurtain(View v) {
    AnimationSet set = new AnimationSet(false);
    Animation anim1 = getTranslateAnimation(0, 0, 0, -200, 110);
    Animation anim2 = getTranslateAnimation(0, 0, -200, 0, 80);
    Animation anim3 = getTranslateAnimation(0, 0, 0, -50, 25);
    Animation anim4 = getTranslateAnimation(0, 0, -50, 0, 25);
    anim1.setStartOffset(20);
    anim2.setStartOffset(230);
    anim3.setStartOffset(360);
    anim4.setStartOffset(400);
    set.addAnimation(anim1);
    set.addAnimation(anim2);
    set.addAnimation(anim3);
    set.addAnimation(anim4);
    v.startAnimation(set);
}
 
Example 8
Source File: KJAnimations.java    From KJFrameForAndroid with Apache License 2.0 6 votes vote down vote up
public static void clickCurtain(View v) {
    AnimationSet set = new AnimationSet(false);
    Animation anim1 = getTranslateAnimation(0, 0, 0, -50, 110);
    Animation anim2 = getTranslateAnimation(0, 0, -50, 0, 80);
    Animation anim3 = getTranslateAnimation(0, 0, 0, -25, 25);
    Animation anim4 = getTranslateAnimation(0, 0, -25, 0, 25);
    anim1.setStartOffset(20);
    anim2.setStartOffset(230);
    anim3.setStartOffset(360);
    anim4.setStartOffset(400);
    set.addAnimation(anim1);
    set.addAnimation(anim2);
    set.addAnimation(anim3);
    set.addAnimation(anim4);
    v.startAnimation(set);
}
 
Example 9
Source File: KJAnimations.java    From CoreModule with Apache License 2.0 6 votes vote down vote up
public static void shakeCurtain(View v) {
    AnimationSet set = new AnimationSet(false);
    Animation anim1 = getTranslateAnimation(0, 0, 0, -200, 110);
    Animation anim2 = getTranslateAnimation(0, 0, -200, 0, 80);
    Animation anim3 = getTranslateAnimation(0, 0, 0, -50, 25);
    Animation anim4 = getTranslateAnimation(0, 0, -50, 0, 25);
    anim1.setStartOffset(20);
    anim2.setStartOffset(230);
    anim3.setStartOffset(360);
    anim4.setStartOffset(400);
    set.addAnimation(anim1);
    set.addAnimation(anim2);
    set.addAnimation(anim3);
    set.addAnimation(anim4);
    v.startAnimation(set);
}
 
Example 10
Source File: RayLayout.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
private static Animation createShrinkAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta,
		long startOffset, long duration, Interpolator interpolator) {
	AnimationSet animationSet = new AnimationSet(false);
	animationSet.setFillAfter(true);

	final long preDuration = duration / 2;
	Animation rotateAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f,
			Animation.RELATIVE_TO_SELF, 0.5f);
	rotateAnimation.setStartOffset(startOffset);
	rotateAnimation.setDuration(preDuration);
	rotateAnimation.setInterpolator(new LinearInterpolator());
	rotateAnimation.setFillAfter(true);

	animationSet.addAnimation(rotateAnimation);

	Animation translateAnimation = new RotateAndTranslateAnimation(0, toXDelta, 0, toYDelta, 360, 720);
	translateAnimation.setStartOffset(startOffset + preDuration);
	translateAnimation.setDuration(duration - preDuration);
	translateAnimation.setInterpolator(interpolator);
	translateAnimation.setFillAfter(true);

	animationSet.addAnimation(translateAnimation);

	return animationSet;
}
 
Example 11
Source File: MainActivity.java    From privacy-friendly-dicer with GNU General Public License v3.0 5 votes vote down vote up
public static void flashResult(ImageView imageView) {
    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(500);
    animation.setStartOffset(20);
    animation.setRepeatMode(Animation.REVERSE);
    imageView.startAnimation(animation);
}
 
Example 12
Source File: ArcMenu.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
private static Animation createHintSwitchAnimation(final boolean expanded) {
    Animation animation = new RotateAnimation(expanded ? 45 : 0, expanded ? 0 : 45, Animation.RELATIVE_TO_SELF,
            0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    animation.setStartOffset(0);
    animation.setDuration(100);
    animation.setInterpolator(new DecelerateInterpolator());
    animation.setFillAfter(true);

    return animation;
}
 
Example 13
Source File: ArcMenu.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
private static Animation createHintSwitchAnimation(final boolean expanded) {
    Animation animation = new RotateAnimation(expanded ? 45 : 0, expanded ? 0 : 45, Animation.RELATIVE_TO_SELF,
            0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    animation.setStartOffset(0);
    animation.setDuration(100);
    animation.setInterpolator(new DecelerateInterpolator());
    animation.setFillAfter(true);

    return animation;
}
 
Example 14
Source File: NowPlayingFragment.java    From Jockey with Apache License 2.0 5 votes vote down vote up
private void animateOutSleepTimerCounter() {
    TimeView sleepTimerCounter = mBinding.nowPlayingSleepTimer;

    Animation transition = AnimationUtils.loadAnimation(getContext(), R.anim.tooltip_out_down);
    transition.setStartOffset(250);
    transition.setDuration(300);
    transition.setInterpolator(getContext(), android.R.interpolator.accelerate_quint);

    sleepTimerCounter.startAnimation(transition);

    new Handler().postDelayed(() -> sleepTimerCounter.setVisibility(View.GONE), 550);
}
 
Example 15
Source File: ArcLayout.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
private static Animation createExpandAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta,
        long startOffset, long duration, Interpolator interpolator) {
    Animation animation = new RotateAndTranslateAnimation(0, toXDelta, 0, toYDelta, 0, 720);
    animation.setStartOffset(startOffset);
    animation.setDuration(duration);
    animation.setInterpolator(interpolator);
    animation.setFillAfter(true);

    return animation;
}
 
Example 16
Source File: SensorTagBarometerTableRow.java    From SensorTag-CC2650 with Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(View v) {
	if (v.equals(this.calibrateButton)) {
		this.calibrationButtonTouched();
		return;
	}
	this.config = !this.config;
	Animation fadeOut = new AlphaAnimation(1.0f, 0.0f);
	fadeOut.setAnimationListener(this);
	fadeOut.setDuration(500);
	fadeOut.setStartOffset(0);
	Animation fadeIn = new AlphaAnimation(0.0f, 1.0f);
	fadeIn.setAnimationListener(this);
	fadeIn.setDuration(500);
	fadeIn.setStartOffset(250);
	if (this.config == true) {
		this.sl1.startAnimation(fadeOut);
		if ((this.sl2.isEnabled()))this.sl2.startAnimation(fadeOut);
		if ((this.sl3.isEnabled()))this.sl3.startAnimation(fadeOut);
		this.value.startAnimation(fadeOut);
		this.onOffLegend.startAnimation(fadeIn);
		this.onOff.startAnimation(fadeIn);
		this.periodLegend.startAnimation(fadeIn);
		this.periodBar.startAnimation(fadeIn);
		this.calibrateButton.startAnimation(fadeIn);
	}
	else {
		this.sl1.startAnimation(fadeIn);
		if ((this.sl2.isEnabled()))this.sl2.startAnimation(fadeIn);
		if ((this.sl3.isEnabled()))this.sl3.startAnimation(fadeIn);
		this.value.startAnimation(fadeIn);
		this.onOffLegend.startAnimation(fadeOut);
		this.onOff.startAnimation(fadeOut);
		this.periodLegend.startAnimation(fadeOut);
		this.periodBar.startAnimation(fadeOut);
		this.calibrateButton.startAnimation(fadeOut);
	}
	
	
}
 
Example 17
Source File: MessageBox.java    From always-on-amoled with GNU General Public License v3.0 5 votes vote down vote up
public void showNotification(NotificationListener.NotificationHolder notification) {
    if (notification != null)
        if (!notification.getTitle().equals("null")) {
            this.notification = notification;
            //Clear previous animation
            if (messageBox.getAnimation() != null)
                messageBox.clearAnimation();
            //Fade in animation
            Animation fadeIn = new AlphaAnimation(0, 1);
            fadeIn.setInterpolator(new DecelerateInterpolator());
            fadeIn.setDuration(1000);
            //Fade out animation
            Animation fadeOut = new AlphaAnimation(1, 0);
            fadeOut.setInterpolator(new AccelerateInterpolator());
            fadeOut.setStartOffset(40000);
            fadeOut.setDuration(1000);
            //Set the notification text and icon
            ((TextView) messageBox.findViewById(R.id.message_box_title)).setText(notification.getTitle());
            ((TextView) messageBox.findViewById(R.id.message_box_message)).setText(notification.getMessage());
            ((ImageView) messageBox.findViewById(R.id.message_box_icon)).setImageDrawable(notification.getIcon(context));
            ((TextView) messageBox.findViewById(R.id.message_app_name)).setText(notification.getAppName());
            //Run animations
            AnimationSet animation = new AnimationSet(false);
            animation.addAnimation(fadeIn);
            animation.addAnimation(fadeOut);
            messageBox.setAnimation(animation);
        }
}
 
Example 18
Source File: SuccessTickView.java    From pe-protector-moe with GNU General Public License v3.0 5 votes vote down vote up
public void startTickAnim () {
    // hide tick
    mLeftRectWidth = 0;
    mRightRectWidth = 0;
    invalidate();
    Animation tickAnim = new Animation() {
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            super.applyTransformation(interpolatedTime, t);
            if (0.54 < interpolatedTime && 0.7 >= interpolatedTime) {  // grow left and right rect to right
                mLeftRectGrowMode = true;
                mLeftRectWidth = mMaxLeftRectWidth * ((interpolatedTime - 0.54f) / 0.16f);
                if (0.65 < interpolatedTime) {
                    mRightRectWidth = MAX_RIGHT_RECT_W * ((interpolatedTime - 0.65f) / 0.19f);
                }
                invalidate();
            } else if (0.7 < interpolatedTime && 0.84 >= interpolatedTime) { // shorten left rect from right, still grow right rect
                mLeftRectGrowMode = false;
                mLeftRectWidth = mMaxLeftRectWidth * (1 - ((interpolatedTime - 0.7f) / 0.14f));
                mLeftRectWidth = mLeftRectWidth < MIN_LEFT_RECT_W ? MIN_LEFT_RECT_W : mLeftRectWidth;
                mRightRectWidth = MAX_RIGHT_RECT_W * ((interpolatedTime - 0.65f) / 0.19f);
                invalidate();
            } else if (0.84 < interpolatedTime && 1 >= interpolatedTime) { // restore left rect width, shorten right rect to const
                mLeftRectGrowMode = false;
                mLeftRectWidth = MIN_LEFT_RECT_W + (CONST_LEFT_RECT_W - MIN_LEFT_RECT_W) * ((interpolatedTime - 0.84f) / 0.16f);
                mRightRectWidth = CONST_RIGHT_RECT_W + (MAX_RIGHT_RECT_W - CONST_RIGHT_RECT_W) * (1 - ((interpolatedTime - 0.84f) / 0.16f));
                invalidate();
            }
        }
    };
    tickAnim.setDuration(750);
    tickAnim.setStartOffset(100);
    startAnimation(tickAnim);
}
 
Example 19
Source File: ExpressPaymentFragment.java    From px-android with MIT License 4 votes vote down vote up
@Nullable
@Override
public Animation onCreateAnimation(final int transit, final boolean enter, final int nextAnim) {
    final FragmentManager fragmentManager = getFragmentManager();
    if (fragmentManager != null && fragmentManager.findFragmentByTag(CardFormWithFragment.TAG) != null) {
        final int duration = getResources().getInteger(R.integer.cf_anim_duration);
        final int offset = getResources().getInteger(R.integer.px_card_form_animation_offset);
        if (enter) {
            final Animation slideUp = AnimationUtils.loadAnimation(getContext(), R.anim.px_summary_slide_up_in);
            slideUp.setStartOffset(offset);
            paymentMethodPager
                .startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.px_summary_slide_up_in));

            final Animation fadeIn = AnimationUtils.loadAnimation(getContext(), R.anim.px_fade_in);
            fadeIn.setDuration(duration);
            fadeIn.setStartOffset(offset);

            paymentMethodHeaderView.startAnimation(fadeIn);
            splitPaymentView.startAnimation(fadeIn);
            indicator.startAnimation(fadeIn);
            payButtonContainer.startAnimation(slideUp);

            summaryView.animateEnter(duration);
        } else {
            final Animation slideDown =
                AnimationUtils.loadAnimation(getContext(), R.anim.px_summary_slide_down_out);
            paymentMethodPager.startAnimation(slideDown);

            final Animation fadeOut = AnimationUtils.loadAnimation(getContext(), R.anim.px_fade_out);
            fadeOut.setDuration(duration);

            paymentMethodHeaderView.startAnimation(fadeOut);
            indicator.startAnimation(fadeOut);
            payButtonContainer.startAnimation(slideDown);
            if (splitPaymentView.getVisibility() == VISIBLE) {
                splitPaymentView.startAnimation(fadeOut);
            }

            summaryView.animateExit(offset);
        }
    }
    return super.onCreateAnimation(transit, enter, nextAnim);
}
 
Example 20
Source File: MainListAdapter.java    From Passbook with Apache License 2.0 4 votes vote down vote up
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    View view = convertView;
    ViewHolder holder;
    AccountManager.Account account = mEntries.get(position);
    boolean checked = mChecked.get(position);
    if (convertView == null) {
        view = inflate(parent);
    }
    else {
        holder = (ViewHolder) view.getTag();
        if(holder.mInflate) {
            view = inflate(parent);
        }
    }
    if (mDeleted.get(position)) {
        final View deletedView = view;
        view.post(() -> animateDeletion(deletedView, position));
    }
    holder = (ViewHolder) view.getTag();
    holder.mTextView.setText(account.getAccountName());
    holder.mIconView.setPressed(checked);
    holder.mIconView.setTag(position);
    int srcId = checked ? R.drawable.checkmark : mIcons.get(position);
    String iconUrl = checked ? null : account.getIconUrl();
    if (!checked) {
        holder.mIconView.setColorFilter(COLORS[account.getCategoryId() & 0x0f]);
    } else {
        holder.mIconView.clearColorFilter();
    }
    final ImageView iconView = holder.mIconView;
    Picasso.get().load(iconUrl).placeholder(srcId)
            .transform(new CircleTransform())
            .fit().into(holder.mIconView, new Callback() {
        @Override
        public void onSuccess() {
            iconView.clearColorFilter();
        }

        @Override
        public void onError(Exception e) {

        }
    });
    final View currentView = view;
    holder.mIconView.setOnClickListener(v -> {
        v.clearAnimation();
        v.setAnimation(FLIP1);
        v.startAnimation(FLIP1);
        AnimationListener listener = getAnimListener(currentView, (ImageButton) v,
                Integer.parseInt(v.getTag().toString()), FLIP1, FLIP2);
        FLIP1.setAnimationListener(listener);
        FLIP2.setAnimationListener(listener);
    });
    if(mAnimationEnabled) {
        long timestamp = System.currentTimeMillis();
        long delta = timestamp - mLastTimestamp;
        mLastTimestamp = timestamp;

        Animation animation = AnimationUtils.loadAnimation(mContext,
                position < mLastPosition ? R.anim.down_from_top : R.anim.up_from_bottom);
        if(delta > TIME_INTERVAL) {
            animation.setStartOffset(0);
            mAdjustment = 0;
        }
        else{
            mAdjustment += TIME_INTERVAL - delta;
            if(mAdjustment > 100) {
                mAdjustment = 100;
            }
            animation.setStartOffset(mAdjustment);
        }
        view.startAnimation(animation);
    }
    view.setActivated(checked);
    mLastPosition = position;
    return view;
}