/** * Update the progress the user has made toward triggering the swipe * gesture. and use this value to update the percentage of the trigger that * is shown. */ void setTriggerPercentage(float triggerPercentage) { mTriggerPercentage = triggerPercentage; mStartTime = 0; ViewCompat.postInvalidateOnAnimation(mParent); }
public boolean canChildScrollUp() { return ViewCompat.canScrollVertically(scrollChild, -1); }
private boolean canChildScrollLeft() { return ViewCompat.canScrollHorizontally(scrollChild, 1); }
@Override public void handleLeftPage(View view, float position) { ViewCompat.setAlpha(view, 1); ViewCompat.setTranslationX(view, 0); ViewCompat.setScaleX(view, 1); ViewCompat.setScaleY(view, 1); }
return checkV && (ViewCompat.canScrollHorizontally(v, -dx) || ViewCompat.canScrollVertically(v, -dy));
@Override public boolean animateChange(RecyclerView.ViewHolder oldHolder, RecyclerView.ViewHolder newHolder, int fromX, int fromY, int toX, int toY) { if (oldHolder == newHolder) { // Don't know how to run change animations when the same view holder is re-used. // run a move animation to handle position changes. return animateMove(oldHolder, fromX, fromY, toX, toY); } final float prevTranslationX = ViewCompat.getTranslationX(oldHolder.itemView); final float prevTranslationY = ViewCompat.getTranslationY(oldHolder.itemView); final float prevAlpha = ViewCompat.getAlpha(oldHolder.itemView); resetAnimation(oldHolder); int deltaX = (int) (toX - fromX - prevTranslationX); int deltaY = (int) (toY - fromY - prevTranslationY); // recover prev translation state after ending animation ViewCompat.setTranslationX(oldHolder.itemView, prevTranslationX); ViewCompat.setTranslationY(oldHolder.itemView, prevTranslationY); ViewCompat.setAlpha(oldHolder.itemView, prevAlpha); if (newHolder != null) { // carry over translation values resetAnimation(newHolder); ViewCompat.setTranslationX(newHolder.itemView, -deltaX); ViewCompat.setTranslationY(newHolder.itemView, -deltaY); ViewCompat.setAlpha(newHolder.itemView, 0); } mPendingChanges.add(new ChangeInfo(oldHolder, newHolder, fromX, fromY, toX, toY)); return true; }
@Override public void handleLeftPage(View view, float position) { ViewCompat.setTranslationX(view, -view.getWidth() * position); ViewCompat.setPivotX(view, view.getWidth() * 0.5f); ViewCompat.setPivotY(view, view.getHeight() * 0.5f); ViewCompat.setScaleX(view, 1 + position); ViewCompat.setScaleY(view, 1 + position); ViewCompat.setAlpha(view, 1 + position); }
private void _showTapText() { _tapEventTxtShow.setVisibility(View.VISIBLE); _tapEventTxtShow.setAlpha(1f); ViewCompat.animate(_tapEventTxtShow).alphaBy(-1f).setDuration(400); } }
@Override public void onAnimationCancel(View view) { ViewCompat.setAlpha(view, 1); ViewCompat.setTranslationY(view, 0); }
@Override public boolean animateMove(final RecyclerView.ViewHolder holder, int fromX, int fromY, int toX, int toY) { final View view = holder.itemView; fromX += ViewCompat.getTranslationX(holder.itemView); fromY += ViewCompat.getTranslationY(holder.itemView); resetAnimation(holder); int deltaX = toX - fromX; int deltaY = toY - fromY; if (deltaX == 0 && deltaY == 0) { dispatchMoveFinished(holder); return false; } if (deltaX != 0) { ViewCompat.setTranslationX(view, -deltaX); } if (deltaY != 0) { ViewCompat.setTranslationY(view, -deltaY); } mPendingMoves.add(new MoveInfo(holder, fromX, fromY, toX, toY)); return true; }
final float currentTransY = ViewCompat.getTranslationY(child); final float dy = currentTransY - targetTransY; ViewCompat.animate(child) .translationY(targetTransY) .scaleX(1f) } else { ViewCompat.animate(child).cancel(); ViewCompat.setTranslationY(child, targetTransY);
private static void setShadowElevation(View view, float shadowElevation) { if (shadowElevation != 0) { ViewCompat.setElevation(view, shadowElevation); } }
@Override public void onAnimationEnd(View view) { oldViewAnim.setListener(null); ViewCompat.setAlpha(view, 1); ViewCompat.setTranslationX(view, 0); ViewCompat.setTranslationY(view, 0); dispatchChangeFinished(changeInfo.oldHolder, true); mChangeAnimations.remove(changeInfo.oldHolder); dispatchFinishedWhenDone(); } }).start();
public void finishRefreshing() { if (mChildView != null) { ViewPropertyAnimatorCompat viewPropertyAnimatorCompat = ViewCompat.animate(mChildView); viewPropertyAnimatorCompat.setDuration(200); viewPropertyAnimatorCompat.y(ViewCompat.getTranslationY(mChildView)); viewPropertyAnimatorCompat.translationY(0); viewPropertyAnimatorCompat.setInterpolator(new DecelerateInterpolator()); viewPropertyAnimatorCompat.start(); if (mMaterialHeaderView != null) { mMaterialHeaderView.onComlete(MaterialRefreshLayout.this); } else if (mSunLayout != null) { mSunLayout.onComlete(MaterialRefreshLayout.this); } if (refreshListener != null) { refreshListener.onfinish(); } } isRefreshing = false; progressValue = 0; }
public View findHeaderViewUnder(float x, float y) { for (RecyclerView.ViewHolder holder : mHeaderCache.values()) { final View child = holder.itemView; final float translationX = ViewCompat.getTranslationX(child); final float translationY = ViewCompat.getTranslationY(child); if (x >= child.getLeft() + translationX && x <= child.getRight() + translationX && y >= child.getTop() + translationY && y <= child.getBottom() + translationY) { return child; } } return null; }
final float currentTransY = ViewCompat.getTranslationY(child); } else { ViewCompat.setTranslationY(child, targetTransY);
public CircleImageView(Context context, int color, final float radius) { super(context); final float density = getContext().getResources().getDisplayMetrics().density; final int diameter = (int) (radius * density * 2); final int shadowYOffset = (int) (density * Y_OFFSET); final int shadowXOffset = (int) (density * X_OFFSET); mShadowRadius = (int) (density * SHADOW_RADIUS); ShapeDrawable circle; if (elevationSupported()) { circle = new ShapeDrawable(new OvalShape()); ViewCompat.setElevation(this, SHADOW_ELEVATION * density); } else { OvalShape oval = new OvalShadow(mShadowRadius, diameter); circle = new ShapeDrawable(oval); ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, circle.getPaint()); circle.getPaint().setShadowLayer(mShadowRadius, shadowXOffset, shadowYOffset, KEY_SHADOW_COLOR); final int padding = mShadowRadius; // set padding so the inner image sits correctly within the shadow. setPadding(padding, padding, padding, padding); } circle.getPaint().setColor(color); setBackgroundDrawable(circle); }