android.view.View#clearAnimation ( )源码实例Demo

下面列出了android.view.View#clearAnimation ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: android_9.0.0_r45   文件: ViewAnimator.java
/**
 * Shows only the specified child. The other displays Views exit the screen,
 * optionally with the with the {@link #getOutAnimation() out animation} and
 * the specified child enters the screen, optionally with the
 * {@link #getInAnimation() in animation}.
 *
 * @param childIndex The index of the child to be shown.
 * @param animate Whether or not to use the in and out animations, defaults
 *            to true.
 */
void showOnly(int childIndex, boolean animate) {
    final int count = getChildCount();
    for (int i = 0; i < count; i++) {
        final View child = getChildAt(i);
        if (i == childIndex) {
            if (animate && mInAnimation != null) {
                child.startAnimation(mInAnimation);
            }
            child.setVisibility(View.VISIBLE);
            mFirstTime = false;
        } else {
            if (animate && mOutAnimation != null && child.getVisibility() == View.VISIBLE) {
                child.startAnimation(mOutAnimation);
            } else if (child.getAnimation() == mInAnimation)
                child.clearAnimation();
            child.setVisibility(View.GONE);
        }
    }
}
 
源代码2 项目: LittleFreshWeather   文件: CityWeatherActivity.java
private void stopAnimation() {
    mHandler.removeCallbacks(rainProc);
    mHandler.removeCallbacks(snowProc);
    mHandler.removeCallbacks(cloudProc);
    mHandler.removeCallbacks(lightningProc);
    mHandler.removeCallbacks(sunshaineProc);
    for (int i = 0; i != rlBackgroundView.getChildCount(); ++i) {
        View view = rlBackgroundView.getChildAt(i);
        if (view != null) {
            view.clearAnimation();
        }
    }
    rlBackgroundView.removeAllViews();
    mSpecialWeatherNumRain = 0;
    mSpecialWeatherNumCloud = 0;
    mSpecialWeatherNumSnow = 0;
    mSpecialWeatherNumLightning = 0;
}
 
源代码3 项目: UltimateAndroid   文件: DraggableGridViewPager.java
private void animateDragged() {
	if (mLastDragged >= 0) {
		final View v = getChildAt(mLastDragged);

		final Rect r = new Rect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
		r.inset(-r.width() / 20, -r.height() / 20);
		v.measure(MeasureSpec.makeMeasureSpec(r.width(), MeasureSpec.EXACTLY),
				MeasureSpec.makeMeasureSpec(r.height(), MeasureSpec.EXACTLY));
		v.layout(r.left, r.top, r.right, r.bottom);

		AnimationSet animSet = new AnimationSet(true);
		ScaleAnimation scale = new ScaleAnimation(0.9091f, 1, 0.9091f, 1, v.getWidth() / 2, v.getHeight() / 2);
		scale.setDuration(ANIMATION_DURATION);
		AlphaAnimation alpha = new AlphaAnimation(1, .5f);
		alpha.setDuration(ANIMATION_DURATION);

		animSet.addAnimation(scale);
		animSet.addAnimation(alpha);
		animSet.setFillEnabled(true);
		animSet.setFillAfter(true);

		v.clearAnimation();
		v.startAnimation(animSet);
	}
}
 
源代码4 项目: kripton   文件: RecyclerView.java
@Override
protected void removeDetachedView(View child, boolean animate) {
    ViewHolder vh = getChildViewHolderInt(child);
    if (vh != null) {
        if (vh.isTmpDetached()) {
            vh.clearTmpDetachFlag();
        } else if (!vh.shouldIgnore()) {
            throw new IllegalArgumentException("Called removeDetachedView with a view which"
                    + " is not flagged as tmp detached." + vh + exceptionLabel());
        }
    }
    // Clear any android.view.animation.Animation that may prevent the item from
    // detaching when being removed. If a child is re-added before the
    // lazy detach occurs, it will receive invalid attach/detach sequencing.
    child.clearAnimation();
    dispatchChildDetached(child);
    super.removeDetachedView(child, animate);
}
 
源代码5 项目: Silence   文件: ViewUtil.java
public static void animateIn(final @NonNull View view, final @NonNull Animation animation) {
  if (view.getVisibility() == View.VISIBLE) return;

  view.clearAnimation();
  animation.reset();
  animation.setStartTime(0);
  view.setVisibility(View.VISIBLE);
  view.startAnimation(animation);
}
 
源代码6 项目: actor-platform   文件: ViewUtils.java
public static void wave(final View layer, float scale, int duration, float stepOffset) {
    final ScaleAnimation scaleAnimation = new ScaleAnimation(1.0f, scale, 1.0f, scale, Animation.RELATIVE_TO_SELF, (float) 0.5, Animation.RELATIVE_TO_SELF, (float) 0.5);
    scaleAnimation.setDuration(duration);

    scaleAnimation.setInterpolator(new OffsetCycleInterpolator(stepOffset));
    scaleAnimation.setRepeatCount(Animation.INFINITE);
    layer.clearAnimation();
    layer.startAnimation(scaleAnimation);
}
 
@Override
public View getChildView(final int groupPosition, final int childPosition, boolean isLastChild, View convertView, final ViewGroup parent) {
	View view = null;
	ItemBase dt = data.get(groupPosition).get(childPosition);
	
	if (dt.isMarkedToDelete()) {
		view = getItemMarkedView(groupPosition, childPosition, convertView, parent);
	}
	else {
		view = getItemWithMenuView(groupPosition, childPosition, convertView, parent);
	}
	
	view.clearAnimation();
	return view;
}
 
源代码8 项目: stynico   文件: Instrument.java
public void slidingByDelta(View view ,float delta){
    if(view == null){
        return;
    }
    view.clearAnimation();
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        view.setTranslationY(delta);
    }else{
       // ViewHelper.setTranslationY(view, delta);
    }
}
 
源代码9 项目: FastAccess   文件: AnimHelper.java
@UiThread public static void startBeatsAnimation(@NonNull View view) {
    view.clearAnimation();
    if (view.getAnimation() != null) {
        view.getAnimation().cancel();
    }
    List<ObjectAnimator> animators = getBeats(view);
    for (ObjectAnimator anim : animators) {
        anim.setDuration(300).start();
        anim.setInterpolator(interpolator);
    }
}
 
源代码10 项目: CloudReader   文件: Instrument.java
public void smoothTo(View view ,float y, long duration){
    if(view == null){
        return;
    }
    view.clearAnimation();
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        android.animation.ObjectAnimator.ofFloat(view, "translationY", y).setDuration(duration).start();
    }else{
        com.nineoldandroids.animation.ObjectAnimator.ofFloat(view, "translationY", y).setDuration(duration).start();
    }
}
 
源代码11 项目: styT   文件: Instrument.java
public void slidingByDelta(View view, float delta) {
    if (view == null) {
        return;
    }
    view.clearAnimation();
    view.setTranslationY(delta);
}
 
源代码12 项目: styT   文件: Instrument.java
public void slidingToY(View view, float y) {
    if (view == null) {
        return;
    }
    view.clearAnimation();
    view.setY(y);
}
 
@Override
public View getView(int position, View convertView, ViewGroup parent) {
	View view = null;
	ItemBase dt = data.get(position);
	
	if (dt.isMarkedToDelete()) {
		view = getItemMarkedView(position, convertView, parent);
	}
	else {
		view = getItemWithMenuView(position, convertView, parent);
	}
	
	view.clearAnimation();
	return view;
}
 
源代码14 项目: Pharmacy-Android   文件: OrdersAdapter.java
private void clearAnimation(View View) {
    View.clearAnimation();
    if (View.getAnimation() != null) {
        View.getAnimation().cancel();
    }

}
 
源代码15 项目: ViewRevealAnimator   文件: ICSRevealAnimatorImpl.java
@Override
public void showOnlyNoAnimation(final int previousIndex, final int childIndex) {
    for (int i = 0; i < parent.getChildCount(); i++) {
        View child = parent.getChildAt(i);
        child.setVisibility(i == childIndex ? View.VISIBLE : View.GONE);
        if (child.getAnimation() == parent.mInAnimation) {
            parent.mInAnimation.setAnimationListener(null);
            child.clearAnimation();
        } else if (child.getAnimation() == parent.mOutAnimation) {
            child.clearAnimation();
        }
    }
}
 
源代码16 项目: mvvm-template   文件: AnimHelper.java
@UiThread public static void startBeatsAnimation(@NonNull View view) {
    view.clearAnimation();
    if (view.getAnimation() != null) {
        view.getAnimation().cancel();
    }
    List<ObjectAnimator> animators = getBeats(view);
    for (ObjectAnimator anim : animators) {
        anim.setDuration(300).start();
        anim.setInterpolator(interpolator);
    }
}
 
源代码17 项目: UltimateAndroid   文件: RayMenu.java
private void itemDidDisappear() {
	final int itemCount = mRayLayout.getChildCount();
	for (int i = 0; i < itemCount; i++) {
		View item = mRayLayout.getChildAt(i);
		item.clearAnimation();
	}

	mRayLayout.switchState(false);
}
 
源代码18 项目: iZhihu   文件: Main.java
@Override
public void handleMessage(Message msg) {
    switch (msg.what) {
        case MESSAGE_UPDATE_LOADING:
            if (isFirstRun()) {
                progressDialog = ProgressDialog.show(
                        Main.this,
                        getString(R.string.app_name), getString(R.string.loading), false, false);
            }

            Animation rotation = AnimationUtils.loadAnimation(context, R.anim.refresh_rotate);
            RelativeLayout layout = new RelativeLayout(context);
            RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
                    RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);

            ImageView imageView = new ImageView(context);
            imageView.setLayoutParams(params);

            layout.setGravity(Gravity.CENTER_VERTICAL | Gravity.TOP);
            layout.addView(imageView);

            imageView.setImageDrawable(getResources().getDrawable(R.drawable.ic_action_refersh));
            imageView.startAnimation(rotation);

            if (mMenuRefersh != null) {
                mMenuRefersh.setActionView(layout);
            }
            break;

        case MESSAGE_UPDATE_COMPLETE:
            try {
                Fragment fragment = mScrollTabsFragment.getCurrentFragment();
                if (fragment instanceof QuestionsListFragment) {
                    ((QuestionsListFragment) fragment).updateQuestionsFromDatabase();
                }
            } catch (NullPointerException e) {
                e.printStackTrace();
            } finally {
                mScrollTabsFragment.notifyDatasetChanged();
            }

            if (mMenuRefersh != null) {
                View v = mMenuRefersh.getActionView();
                if (v != null) {
                    v.clearAnimation();
                }
                mMenuRefersh.setActionView(null);
            }

            if (progressDialog != null) {
                progressDialog.dismiss();
            }

            if (mFetchQuestionsTask.hasError()) {
                Helper.showShortToast(context, mFetchQuestionsTask.getErrorMessage());
            }

            break;

        case MESSAGE_UPDATE_SHOW_RESULT:
            if (mFetchQuestionsTask != null) {
                String message = getString(R.string.no_newer_questions);
                if (mFetchQuestionsTask.getAffectedRows() > 0) {
                    message = String.format(getString(R.string.affectRows), mFetchQuestionsTask.getAffectedRows());
                }

                Helper.showShortToast(context, message);
            }
            break;
    }
}
 
源代码19 项目: UltimateAndroid   文件: SpanVariableGridView.java
protected void performDragAndDropSwapping(int from, int to) {

        mPopulating = true;
        Logs.d("drag----" + from + "   " + to + "   " + mAdapter.getCount());
        if (from != to && isLastItemCouldDrag ? true : to != mAdapter.getCount() - 1) {

            final View removedChild = getChildAt(from);
            removedChild.clearAnimation();

            removeViewInLayout(removedChild);
            addViewInLayout(removedChild, to, removedChild.getLayoutParams());
        }

        mControlHeight = measureChildrens(false);

        layoutChildrens(to, true);

        mPopulating = false;
    }
 
源代码20 项目: Klyph   文件: GridFragment.java
private void setGridVisibility(boolean visible, boolean animate)
{
	if (gridVisible == visible)
	{
		return;
	}

	gridVisible = visible;

	View parent = (View) getGridView().getParent();

	if (visible)
	{
		if (animate)
		{
			loadingView.startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out));
			parent.startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in));
		}
		else
		{
			loadingView.clearAnimation();
			parent.clearAnimation();
		}
		loadingView.setVisibility(View.GONE);

		if (parent != null)
			parent.setVisibility(View.VISIBLE);
	}
	else
	{
		if (animate)
		{
			loadingView.startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in));
			parent.startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out));
		}
		else
		{
			loadingView.clearAnimation();
			parent.clearAnimation();
		}
		loadingView.setVisibility(View.VISIBLE);

		if (parent != null)
			parent.setVisibility(View.GONE);
	}
}
 
 方法所在类
 同类方法