Java Code Examples for android.view.View#clearAnimation()

The following examples show how to use android.view.View#clearAnimation() . 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: RecyclerView.java    From kripton with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 2
Source File: DraggableGridViewPager.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
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);
	}
}
 
Example 3
Source File: ViewAnimator.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
        }
    }
}
 
Example 4
Source File: CityWeatherActivity.java    From LittleFreshWeather with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 5
Source File: Instrument.java    From CloudReader with Apache License 2.0 5 votes vote down vote up
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();
    }
}
 
Example 6
Source File: RayMenu.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 7
Source File: AnimHelper.java    From mvvm-template with GNU General Public License v3.0 5 votes vote down vote up
@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);
    }
}
 
Example 8
Source File: ICSRevealAnimatorImpl.java    From ViewRevealAnimator with Apache License 2.0 5 votes vote down vote up
@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();
        }
    }
}
 
Example 9
Source File: OrdersAdapter.java    From Pharmacy-Android with GNU General Public License v3.0 5 votes vote down vote up
private void clearAnimation(View View) {
    View.clearAnimation();
    if (View.getAnimation() != null) {
        View.getAnimation().cancel();
    }

}
 
Example 10
Source File: ItemBaseListAdapter.java    From ListView-Swipe-to-Delete with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 11
Source File: Instrument.java    From styT with Apache License 2.0 5 votes vote down vote up
public void slidingToY(View view, float y) {
    if (view == null) {
        return;
    }
    view.clearAnimation();
    view.setY(y);
}
 
Example 12
Source File: Instrument.java    From styT with Apache License 2.0 5 votes vote down vote up
public void slidingByDelta(View view, float delta) {
    if (view == null) {
        return;
    }
    view.clearAnimation();
    view.setTranslationY(delta);
}
 
Example 13
Source File: AnimHelper.java    From FastAccess with GNU General Public License v3.0 5 votes vote down vote up
@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);
    }
}
 
Example 14
Source File: Instrument.java    From stynico with MIT License 5 votes vote down vote up
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);
    }
}
 
Example 15
Source File: ItemBaseExpListAdapter.java    From ListView-Swipe-to-Delete with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 16
Source File: ViewUtils.java    From actor-platform with GNU Affero General Public License v3.0 5 votes vote down vote up
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);
}
 
Example 17
Source File: ViewUtil.java    From Silence with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example 18
Source File: Main.java    From iZhihu with GNU General Public License v2.0 4 votes vote down vote up
@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;
    }
}
 
Example 19
Source File: GridFragment.java    From Klyph with MIT License 4 votes vote down vote up
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);
	}
}
 
Example 20
Source File: SpanVariableGridView.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
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;
    }