Java Code Examples for android.view.View#getAnimation()
The following examples show how to use
android.view.View#getAnimation() .
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: ViewUtil.java From sa-sdk-android with Apache License 2.0 | 6 votes |
@SuppressLint("NewApi") public static boolean isViewSelfVisible(View view) { if (view == null || view.getWindowVisibility() == View.GONE) { return false; } if (WindowHelper.isDecorView(view.getClass())) { return true; } if (view.getWidth() <= 0 || view.getHeight() <= 0 || view.getAlpha() <= 0.0f || !view.getLocalVisibleRect(new Rect())) { return false; } if ((view.getVisibility() == View.VISIBLE || view.getAnimation() == null || !view.getAnimation().getFillAfter()) && view.getVisibility() != View.VISIBLE) { return false; } return true; }
Example 2
Source File: EBrowserWindow.java From appcan-android with GNU Lesser General Public License v3.0 | 6 votes |
public void removeViewFromCurrentWindow(View child) { // Message msg = mWindLoop.obtainMessage(); // msg.what = F_WHANDLER_REMOVE_VIEW; // msg.obj = child; // mWindLoop.sendMessage(msg); // Animation removeAnim = child.getAnimation(); // if (null != removeAnim) { // removeAnim.start(); // } // removeView(child); // View children = (View) msg.obj; Animation removeAnim = child.getAnimation(); if (null != removeAnim) { removeAnim.start(); } removeViewList(child); // msg.obj = null; }
Example 3
Source File: AnimHelper.java From mvvm-template with GNU General Public License v3.0 | 5 votes |
@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 4
Source File: ViewUtil.java From sa-sdk-android with Apache License 2.0 | 5 votes |
/** * View 自身是否可见 * * @return View 宽、高、透明度 有一个 < 0 时,或 getLocalVisibleRect 为 false 时;返回 false 。 * View getVisibility 不可见,且有 Animation getFillAfter 为 false 时;返回 false 。 * View 无 Animation 时 getVisibility 不可见时返回 false 。 */ @RequiresApi(api = 11) public static boolean isViewSelfVisible(View view) { if (view == null) { return false; } if (view.getWidth() <= 0 || view.getHeight() <= 0 || view.getAlpha() <= 0.0f || !view.getLocalVisibleRect(new Rect())) { return false; } return (view.getVisibility() != VISIBLE && view.getAnimation() != null && view.getAnimation().getFillAfter()) || view.getVisibility() == VISIBLE; }
Example 5
Source File: AnimatorProxy.java From android-project-wo2b with Apache License 2.0 | 5 votes |
/** * Create a proxy to allow for modifying post-3.0 view properties on all * pre-3.0 platforms. <strong>DO NOT</strong> wrap your views if you are * using {@code ObjectAnimator} as it will handle that itself. * * @param view View to wrap. * @return Proxy to post-3.0 properties. */ public static AnimatorProxy wrap(View view) { AnimatorProxy proxy = PROXIES.get(view); // This checks if the proxy already exists and whether it still is the animation of the given view if (proxy == null || proxy != view.getAnimation()) { proxy = new AnimatorProxy(view); PROXIES.put(view, proxy); } return proxy; }
Example 6
Source File: AnimatorProxy.java From Mover with Apache License 2.0 | 5 votes |
/** * Create a proxy to allow for modifying post-3.0 view properties on all * pre-3.0 platforms. <strong>DO NOT</strong> wrap your views if you are * using {@code ObjectAnimator} as it will handle that itself. * * @param view View to wrap. * @return Proxy to post-3.0 properties. */ public static AnimatorProxy wrap(View view) { AnimatorProxy proxy = PROXIES.get(view); // This checks if the proxy already exists and whether it still is the animation of the given view if (proxy == null || proxy != view.getAnimation()) { proxy = new AnimatorProxy(view); PROXIES.put(view, proxy); } return proxy; }
Example 7
Source File: OrdersAdapter.java From Pharmacy-Android with GNU General Public License v3.0 | 5 votes |
private void clearAnimation(View View) { View.clearAnimation(); if (View.getAnimation() != null) { View.getAnimation().cancel(); } }
Example 8
Source File: AnimatorProxy.java From AndroidLinkup with GNU General Public License v2.0 | 5 votes |
/** * Create a proxy to allow for modifying post-3.0 view properties on all pre-3.0 platforms. <strong>DO NOT</strong> wrap your views if you are using * {@code ObjectAnimator} as it will handle that itself. * * @param view * View to wrap. * @return Proxy to post-3.0 properties. */ public static AnimatorProxy wrap(View view) { AnimatorProxy proxy = PROXIES.get(view); // This checks if the proxy already exists and whether it still is the animation of the given view if (proxy == null || proxy != view.getAnimation()) { proxy = new AnimatorProxy(view); PROXIES.put(view, proxy); } return proxy; }
Example 9
Source File: AnimatorProxy.java From KJFrameForAndroid with Apache License 2.0 | 5 votes |
/** * Create a proxy to allow for modifying post-3.0 view properties on all * pre-3.0 platforms. <strong>DO NOT</strong> wrap your views if you are * using {@code ObjectAnimator} as it will handle that itself. * * @param view * View to wrap. * @return Proxy to post-3.0 properties. */ public static AnimatorProxy wrap(View view) { AnimatorProxy proxy = PROXIES.get(view); // This checks if the proxy already exists and whether it still is the // animation of the given view if (proxy == null || proxy != view.getAnimation()) { proxy = new AnimatorProxy(view); PROXIES.put(view, proxy); } return proxy; }
Example 10
Source File: AnimatorProxy.java From UltimateAndroid with Apache License 2.0 | 5 votes |
/** * Create a proxy to allow for modifying post-3.0 view properties on all * pre-3.0 platforms. <strong>DO NOT</strong> wrap your views if you are * using {@code ObjectAnimator} as it will handle that itself. * * @param view View to wrap. * @return Proxy to post-3.0 properties. */ public static AnimatorProxy wrap(View view) { AnimatorProxy proxy = PROXIES.get(view); // This checks if the proxy already exists and whether it still is the animation of the given view if (proxy == null || proxy != view.getAnimation()) { proxy = new AnimatorProxy(view); PROXIES.put(view, proxy); } return proxy; }
Example 11
Source File: AnimationHelpers.java From ripple with GNU General Public License v3.0 | 5 votes |
static void addAnimation(View view, Animation animation, boolean first) { Animation previousAnimation = view.getAnimation(); if (previousAnimation == null || previousAnimation.getClass() == animation.getClass()) { if (animation.getStartTime() == Animation.START_ON_FIRST_FRAME) view.startAnimation(animation); else view.setAnimation(animation); return; } if (!(previousAnimation instanceof AnimationSet)) { AnimationSet newSet = new AnimationSet(false); newSet.addAnimation(previousAnimation); previousAnimation = newSet; } // Remove old of same type // AnimationSet set = (AnimationSet) previousAnimation; for (int i = 0; i < set.getAnimations().size(); i++) { Animation anim = set.getAnimations().get(i); if (anim.getClass() == animation.getClass()) { set.getAnimations().remove(i); break; } } // Add this (first if it is a scale animation ,else at end) if (animation instanceof ScaleAnimation || first) { set.getAnimations().add(0, animation); } else { set.getAnimations().add(animation); } animation.startNow(); view.setAnimation(set); }
Example 12
Source File: SmoothRefreshLayout.java From SmoothRefreshLayout with MIT License | 5 votes |
protected View ensureScrollTargetView(View target, boolean noTransform, float x, float y) { if (target instanceof IRefreshView || target.getVisibility() != VISIBLE || target.getAnimation() != null) { return null; } if (isScrollingView(target)) { return target; } if (target instanceof ViewGroup) { ViewGroup group = (ViewGroup) target; final int count = group.getChildCount(); for (int i = count - 1; i >= 0; i--) { View child = group.getChildAt(i); if (noTransform || isTransformedTouchPointInView(x, y, group, child)) { View view = ensureScrollTargetView( child, noTransform, x + mCachedFloatPoint[0], y + mCachedFloatPoint[1]); if (view != null) { return view; } } } } return null; }
Example 13
Source File: ICSRevealAnimatorImpl.java From ViewRevealAnimator with Apache License 2.0 | 5 votes |
@Override public void showOnly(final int previousChild, final int childIndex, @Nullable final Point origin) { if (DBG) { Log.i(TAG, "showOnly: " + previousChild + " >> " + childIndex); } parent.mInAnimation.setAnimationListener(new MyAnimationListener(previousChild, childIndex)); final int count = parent.getChildCount(); for (int i = 0; i < count; i++) { final View child = parent.getChildAt(i); if (i == childIndex) { if (parent.mInAnimation != null) { child.startAnimation(parent.mInAnimation); } child.setVisibility(View.VISIBLE); parent.mFirstTime = false; } else { if (parent.mOutAnimation != null && child.getVisibility() == View.VISIBLE) { child.startAnimation(parent.mOutAnimation); } else if (child.getAnimation() == parent.mInAnimation) { parent.mInAnimation.setAnimationListener(null); child.clearAnimation(); } child.setVisibility(View.GONE); } } }
Example 14
Source File: ICSRevealAnimatorImpl.java From ViewRevealAnimator with Apache License 2.0 | 5 votes |
@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 15
Source File: SwipeBackLayout.java From AndroidNavigation with MIT License | 5 votes |
@Override public boolean tryCaptureView(@NonNull View view, int pointerId) { if (view.getAnimation() != null) { return false; } boolean ret = mDragHelper.isEdgeTouched(ViewDragHelper.EDGE_LEFT, pointerId); boolean directionCheck = !mDragHelper.checkTouchSlop(ViewDragHelper.DIRECTION_VERTICAL, pointerId); return mDragHelper.getViewDragState() != ViewDragHelper.STATE_SETTLING && (ret & directionCheck); }
Example 16
Source File: FadeOutAnimation.java From Popeens-DSub with GNU General Public License v3.0 | 5 votes |
/** * Creates and starts the fade out animation. * * @param view The view to fade out (or display). * @param fadeOut If true, the view is faded out. Otherwise it is immediately made visible. * @param durationMillis Fade duration. */ public static void createAndStart(View view, boolean fadeOut, long durationMillis) { if (fadeOut) { view.clearAnimation(); view.startAnimation(new FadeOutAnimation(view, durationMillis)); } else { Animation animation = view.getAnimation(); if (animation instanceof FadeOutAnimation) { ((FadeOutAnimation) animation).cancelFadeOut(); } view.clearAnimation(); view.setVisibility(View.VISIBLE); } }
Example 17
Source File: AnimatorProxy.java From imsdk-android with MIT License | 5 votes |
/** * Create a proxy to allow for modifying post-3.0 view properties on all * pre-3.0 platforms. <strong>DO NOT</strong> wrap your views if you are * using {@code ObjectAnimator} as it will handle that itself. * * @param view View to wrap. * @return Proxy to post-3.0 properties. */ public static AnimatorProxy wrap(View view) { AnimatorProxy proxy = PROXIES.get(view); // This checks if the proxy already exists and whether it still is the animation of the given view if (proxy == null || proxy != view.getAnimation()) { proxy = new AnimatorProxy(view); PROXIES.put(view, proxy); } return proxy; }
Example 18
Source File: EmptyLayout.java From AndroidEmptyLayout with Apache License 2.0 | 4 votes |
private void changeEmptyType() { setDefaultValues(); refreshMessages(); // insert views in the root view if (!mViewsAdded) { RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); lp.addRule(RelativeLayout.CENTER_IN_PARENT); mEmptyRelativeLayout = new RelativeLayout(getContext()); mEmptyRelativeLayout.setGravity(Gravity.CENTER); mEmptyRelativeLayout.setLayoutParams(lp); if (mEmptyView!=null) mEmptyRelativeLayout.addView(mEmptyView); if (mLoadingView!=null) mEmptyRelativeLayout.addView(mLoadingView); if (mErrorView!=null) mEmptyRelativeLayout.addView(mErrorView); mViewsAdded = true; mEmptyRelativeLayout.setVisibility(VISIBLE); addView(mEmptyRelativeLayout); } // change empty type View loadingAnimationView = null; if (mLoadingAnimationViewId > 0) loadingAnimationView = findViewById(mLoadingAnimationViewId); switch (mEmptyType) { case TYPE_EMPTY: if (mEmptyView!=null) mEmptyView.setVisibility(View.VISIBLE); if (mErrorView!=null) mErrorView.setVisibility(View.GONE); if (mLoadingView!=null) { mLoadingView.setVisibility(View.GONE); if (loadingAnimationView!=null && loadingAnimationView.getAnimation()!=null) loadingAnimationView.getAnimation().cancel(); } break; case TYPE_ERROR: if (mEmptyView!=null) mEmptyView.setVisibility(View.GONE); if (mErrorView!=null) mErrorView.setVisibility(View.VISIBLE); if (mLoadingView!=null) { mLoadingView.setVisibility(View.GONE); if (loadingAnimationView!=null && loadingAnimationView.getAnimation()!=null) loadingAnimationView.getAnimation().cancel(); } break; case TYPE_LOADING: if (mEmptyView!=null) mEmptyView.setVisibility(View.GONE); if (mErrorView!=null) mErrorView.setVisibility(View.GONE); if (mLoadingView!=null) { mLoadingView.setVisibility(View.VISIBLE); if (mLoadingAnimation != null && loadingAnimationView!=null) { loadingAnimationView.startAnimation(mLoadingAnimation); } else if (loadingAnimationView!=null) { loadingAnimationView.startAnimation(getRotateAnimation()); } } break; default: break; } }
Example 19
Source File: ViewUtils.java From px-android with MIT License | 4 votes |
public static void cancelAnimation(@NonNull final View targetView) { final Animation animation = targetView.getAnimation(); if (animation != null) { animation.cancel(); } }
Example 20
Source File: EmptyLayout.java From android-empty-layout with Apache License 2.0 | 4 votes |
private void changeEmptyType() { setDefaultValues(); refreshMessages(); // insert views in the root view if (!mViewsAdded) { RelativeLayout.LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lp.addRule(RelativeLayout.CENTER_HORIZONTAL); lp.addRule(RelativeLayout.CENTER_VERTICAL); RelativeLayout rl = new RelativeLayout(mContext); rl.setLayoutParams(lp); if (mEmptyView!=null) rl.addView(mEmptyView); if (mLoadingView!=null) rl.addView(mLoadingView); if (mErrorView!=null) rl.addView(mErrorView); mViewsAdded = true; ViewGroup parent = (ViewGroup) mListView.getParent(); parent.addView(rl); mListView.setEmptyView(rl); } // change empty type if (mListView!=null) { View loadingAnimationView = null; if (mLoadingAnimationViewId > 0) loadingAnimationView = ((Activity) mContext).findViewById(mLoadingAnimationViewId); switch (mEmptyType) { case TYPE_EMPTY: if (mEmptyView!=null) mEmptyView.setVisibility(View.VISIBLE); if (mErrorView!=null) mErrorView.setVisibility(View.GONE); if (mLoadingView!=null) { mLoadingView.setVisibility(View.GONE); if (loadingAnimationView!=null && loadingAnimationView.getAnimation()!=null) loadingAnimationView.getAnimation().cancel(); } break; case TYPE_ERROR: if (mEmptyView!=null) mEmptyView.setVisibility(View.GONE); if (mErrorView!=null) mErrorView.setVisibility(View.VISIBLE); if (mLoadingView!=null) { mLoadingView.setVisibility(View.GONE); if (loadingAnimationView!=null && loadingAnimationView.getAnimation()!=null) loadingAnimationView.getAnimation().cancel(); } break; case TYPE_LOADING: if (mEmptyView!=null) mEmptyView.setVisibility(View.GONE); if (mErrorView!=null) mErrorView.setVisibility(View.GONE); if (mLoadingView!=null) { mLoadingView.setVisibility(View.VISIBLE); if (mLoadingAnimation != null && loadingAnimationView!=null) { loadingAnimationView.startAnimation(mLoadingAnimation); } else if (loadingAnimationView!=null) { loadingAnimationView.startAnimation(getRotateAnimation()); } } break; default: break; } } }