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

The following examples show how to use android.view.animation.Animation#setAnimationListener() . 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: MasterDialog.java    From android-dialog-builder with Apache License 2.0 6 votes vote down vote up
private void playDialogOutAnimation(Animation outAnimation) {
    if(isPlaying){
        return;
    }
    clearAnimation();
    outAnimation.setAnimationListener(new SimpleAnimationListener(){
        @Override
        public void onAnimationEnd(Animation animation) {
            isPlaying = false;
            detachedFromWindow();
        }
    });
    isPlaying = true;
    mContentView.startAnimation(outAnimation);
    if(isShowShadow()){
        AlphaAnimation alphaAnimation = new AlphaAnimation(1.0f,0.0f);
        alphaAnimation.setDuration(outAnimation.getDuration());
        mShadowView.startAnimation(alphaAnimation);
    }
}
 
Example 2
Source File: SensorTagSimpleKeysTableRow.java    From SensorTag-CC2650 with Apache License 2.0 6 votes vote down vote up
@Override
public void onClick(View v) {
	super.onClick(v);
	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.leftKeyPressStateImage.startAnimation(fadeOut);
		this.rightKeyPressStateImage.startAnimation(fadeOut);
		this.reedStateImage.startAnimation(fadeOut);
	}
	else {
		this.leftKeyPressStateImage.startAnimation(fadeIn);
		this.rightKeyPressStateImage.startAnimation(fadeIn);
		this.reedStateImage.startAnimation(fadeIn);
	}
}
 
Example 3
Source File: FwUpgradeActivity.java    From MiBandDecompiled with Apache License 2.0 6 votes vote down vote up
public void finishAnimation()
{
    Animation animation = AnimationUtils.loadAnimation(this, 0x7f040002);
    Animation animation1 = AnimationUtils.loadAnimation(this, 0x7f040002);
    Animation animation2 = AnimationUtils.loadAnimation(this, 0x7f040002);
    Animation animation3 = AnimationUtils.loadAnimation(this, 0x7f040002);
    animation.setStartOffset(0L);
    animation3.setStartOffset(100L);
    animation2.setStartOffset(150L);
    animation1.setStartOffset(200L);
    animation.setAnimationListener(new ao(this));
    animation1.setAnimationListener(new ap(this));
    animation2.setAnimationListener(new aq(this));
    animation3.setAnimationListener(new ar(this));
    AccelerateInterpolator accelerateinterpolator = new AccelerateInterpolator(2.0F);
    animation.setInterpolator(accelerateinterpolator);
    animation1.setInterpolator(accelerateinterpolator);
    animation2.setInterpolator(accelerateinterpolator);
    animation3.setInterpolator(accelerateinterpolator);
    i.startAnimation(animation);
    j.startAnimation(animation1);
    k.startAnimation(animation2);
    h.startAnimation(animation3);
}
 
Example 4
Source File: AnimationUtil.java    From bither-android with Apache License 2.0 5 votes vote down vote up
public static void fadeOut(final View view, AnimationListener animationListener, int duration) {
    view.setVisibility(View.VISIBLE);
    Animation alphaAnimation = new AlphaAnimation(0.0f, 1.0f);
    alphaAnimation.setDuration(duration);
    alphaAnimation.setAnimationListener(animationListener);
    view.startAnimation(alphaAnimation);
}
 
Example 5
Source File: EBrowserWindow.java    From appcan-android with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void closeWindowByAnimation(Animation anim) {

        if (anim != null) {
            startAnimation(anim);
            anim.setAnimationListener(this);
        } else {
            setVisibility(GONE);
            if (null != mBroWidget) {
                mBroWidget.destoryWindow(this);
            }
        }

    }
 
Example 6
Source File: GenericCharacteristicTableRow.java    From SensorTag-CC2650 with Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(View v) {
	this.config = !this.config;
	Log.d("onClick","Row ID" + v.getId());
	//Toast.makeText(this.context, "Found row with title : " + this.title.getText(), Toast.LENGTH_SHORT).show();
	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);
	}
	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);
	}
}
 
Example 7
Source File: _Rigger.java    From FragmentRigger with MIT License 5 votes vote down vote up
/**
 * Sets the to be animated view on hardware layer during the animation.Note
 * that calling this will replace any existing animation listener on the animation
 * with a new one, as animations do not support more than one listeners. Therefore,
 * animations that already have listeners should do the layer change operations
 * in their existing listeners, rather than calling this function.
 */
void setHWLayerAnimListenerIfAlpha(View v, Animation anim) {
    if (v == null || anim == null) {
        return;
    }
    if (shouldRunOnHWLayer(v, anim)) {
        anim.setAnimationListener(new AnimateOnHWLayerIfNeededListener(v, anim));
    }
}
 
Example 8
Source File: ViewMover.java    From viewmover with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the moving animation
 * <p>
 * Configures the moving animation based on moving params
 *
 * @param params params, which is used to configure the moving animation
 * @return moving animation
 */
private Animation createAnimation(MovingParams params) {
	Animation animation = new TranslateAnimation(0, params.getXAxisDelta(), 0, params.getYAxisDelta());
	animation.setFillEnabled(true);
	animation.setFillBefore(false);
	animation.setDuration(params.getAnimationDuration());
	Interpolator interpolator = params.getAnimationInterpolator();
	if (interpolator != null) {
		animation.setInterpolator(interpolator);
	}
	animation.setAnimationListener(new MoveAnimationListener(params));
	return animation;
}
 
Example 9
Source File: MyRecyclerView.java    From IdeaTrackerPlus with MIT License 5 votes vote down vote up
/**
 * Animate the view to shrink vertically
 *
 * @param v
 * @param al
 */
private void collapse(final View v, Animation.AnimationListener al) {

    final int initialHeight = v.getMeasuredHeight();

    Animation anim = new Animation() {
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            if (interpolatedTime == 1) {
                v.getLayoutParams().height = initialHeight;
            } else {
                v.getLayoutParams().height = initialHeight - (int) (initialHeight * interpolatedTime);
                v.requestLayout();
            }
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };

    if (al != null) {
        anim.setAnimationListener(al);
    }
    anim.setDuration(ANIMATION_DURATION);
    v.startAnimation(anim);
}
 
Example 10
Source File: PluginPayTip.java    From SimplifyReader with Apache License 2.0 5 votes vote down vote up
public void close(AnimationListener listener) {
	Animation animation = AnimationUtils.loadAnimation(mActivity,
			R.anim.paytip_right_out);
	if (listener != null)
		animation.setAnimationListener(listener);
	mContainerView.startAnimation(animation);
	mContainerView.setVisibility(View.INVISIBLE);
}
 
Example 11
Source File: MapWidget.java    From mappwidget with Apache License 2.0 5 votes vote down vote up
protected void animateZoomIn(AnimationListener listener, float pivotX,
		float pivotY) {
	Animation zoomInAnimation = getZoomInAnimation(pivotX, pivotY);

	if (listener != null) {
		zoomInAnimation.setAnimationListener(listener);
	}

	this.startAnimation(zoomInAnimation);
}
 
Example 12
Source File: PullToRefreshView.java    From Taurus with Apache License 2.0 5 votes vote down vote up
private void animateOffsetToPosition(Animation animation) {
    mFrom = mCurrentOffsetTop;
    mFromDragPercent = mCurrentDragPercent;
    long animationDuration = (long) Math.abs(MAX_OFFSET_ANIMATION_DURATION * mFromDragPercent);

    animation.reset();
    animation.setDuration(animationDuration);
    animation.setInterpolator(mDecelerateInterpolator);
    animation.setAnimationListener(mToStartListener);
    mRefreshImageView.clearAnimation();
    mRefreshImageView.startAnimation(animation);
}
 
Example 13
Source File: PhotoViewerActivity.java    From android-open-project-demo with Apache License 2.0 5 votes vote down vote up
public void onAnimationEnd(Animation animation) {
	mView.setVisibility(View.GONE);
	animation.setAnimationListener(null);

	if (!mController.hasSelections()) {
		finish();
	} else {
		View view = (View) mView.getParent();
		view.post(new Runnable() {
			public void run() {
				mAdapter.notifyDataSetChanged();
			}
		});
	}
}
 
Example 14
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 15
Source File: RCheckHeaderView.java    From bither-android with Apache License 2.0 5 votes vote down vote up
public void start() {
    flBottom.setVisibility(View.INVISIBLE);
    Animation scaleAnim = AnimationUtils.loadAnimation(getContext(),
            R.anim.check_points_scale_up);
    scaleAnim.setDuration(ScaleUpAnimDuraion);
    scaleAnim.setAnimationListener(scaleUpListener);
    llPoints.startAnimation(scaleAnim);
}
 
Example 16
Source File: TabBarFragment.java    From AndroidNavigation with MIT License 5 votes vote down vote up
void hideTabBarWhenPush(@AnimRes int anim) {
    if (tabBar != null) {
        tabBarHidden = true;
        setNeedsNavigationBarAppearanceUpdate();
        if (anim != R.anim.nav_none) {
            Animation animation = AnimationUtils.loadAnimation(getContext(), anim);
            animation.setAnimationListener(new TabBarAnimationListener(true));
            tabBar.startAnimation(animation);
        } else {
            tabBar.setVisibility(View.GONE);
            tabBar.setTranslationY(tabBar.getHeight());
        }
    }
}
 
Example 17
Source File: AnimationHandler.java    From CompactCalendarView with MIT License 5 votes vote down vote up
private void setUpAnimationLisForClose(Animation openAnimation) {
    openAnimation.setAnimationListener(new AnimationListener() {
        @Override
        public void onAnimationEnd(Animation animation) {
            super.onAnimationEnd(animation);
            onClose();
            isAnimating = false;
        }
    });
}
 
Example 18
Source File: ShowHideOnScroll.java    From floating-action-button with Apache License 2.0 5 votes vote down vote up
private void animate(int anim) {
    if (anim != 0) {
        Animation a = AnimationUtils.loadAnimation(mView.getContext(), anim);
        a.setAnimationListener(this);

        mView.startAnimation(a);
        setIgnore(true);
    }
}
 
Example 19
Source File: MainListAdapter.java    From Passbook with Apache License 2.0 5 votes vote down vote up
void markAll(ListView listView) {
    int firstVisible = listView.getFirstVisiblePosition();
    int lastVisible = listView.getLastVisiblePosition();
    int pos;
    for(pos = 0; pos < firstVisible; ++pos) {
        mChecked.set(pos, true);
    }
    for(pos = lastVisible + 1; pos < mChecked.size(); ++pos) {
        mChecked.set(pos, true);
    }
    mCheckCount += (mChecked.size() - lastVisible - 1);
    for(pos = firstVisible; pos <= lastVisible; ++pos) {
        View v = listView.getChildAt(pos);
        if(v!=null) {
            ViewHolder holder = (ViewHolder) v.getTag();
            Animation anim1 = AnimationUtils.loadAnimation(mContext, R.anim.shrink_to_middle);
            Animation anim2 = AnimationUtils.loadAnimation(mContext, R.anim.expand_from_middle);
            holder.mIconView.clearAnimation();
            holder.mIconView.setAnimation(anim1);
            holder.mIconView.startAnimation(anim1);

            AnimationListener listener = getAnimListener(v, holder.mIconView, pos, anim1, anim2);
            anim1.setAnimationListener(listener);
            anim2.setAnimationListener(listener);
        }
    }
}
 
Example 20
Source File: AnimationListener.java    From UPMiss with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onAnimationEnd(Animation animation) {
    animation.setAnimationListener(null);
}