List of usage examples for android.view View getAlpha
@ViewDebug.ExportedProperty(category = "drawing") public float getAlpha()
From source file:android.support.v17.leanback.widget.AbstractMediaItemPresenter.java
/** * Each media item row can have multiple focusable elements; the details on the left and a set * of optional custom actions on the right. * The selector is a highlight that moves to highlight to cover whichever views is in focus. * * @param selectorView the selector view used to highlight an individual element within a row. * @param focusChangedView The component within the media row whose focus got changed. * @param layoutAnimator the ValueAnimator producing animation frames for the selector's width * and x-translation, generated by this method and stored for the each * {@link ViewHolder}. * @param isDetails Whether the changed-focused view is for a media item details (true) or * an action (false).//w w w. jav a2 s . c o m */ private static ValueAnimator updateSelector(final View selectorView, View focusChangedView, ValueAnimator layoutAnimator, boolean isDetails) { int animationDuration = focusChangedView.getContext().getResources() .getInteger(android.R.integer.config_shortAnimTime); DecelerateInterpolator interpolator = new DecelerateInterpolator(); int layoutDirection = ViewCompat.getLayoutDirection(selectorView); if (!focusChangedView.hasFocus()) { // if neither of the details or action views are in focus (ie. another row is in focus), // animate the selector out. selectorView.animate().cancel(); selectorView.animate().alpha(0f).setDuration(animationDuration).setInterpolator(interpolator).start(); // keep existing layout animator return layoutAnimator; } else { // cancel existing layout animator if (layoutAnimator != null) { layoutAnimator.cancel(); layoutAnimator = null; } float currentAlpha = selectorView.getAlpha(); selectorView.animate().alpha(1f).setDuration(animationDuration).setInterpolator(interpolator).start(); final ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) selectorView.getLayoutParams(); ViewGroup rootView = (ViewGroup) selectorView.getParent(); sTempRect.set(0, 0, focusChangedView.getWidth(), focusChangedView.getHeight()); rootView.offsetDescendantRectToMyCoords(focusChangedView, sTempRect); if (isDetails) { if (layoutDirection == View.LAYOUT_DIRECTION_RTL) { sTempRect.right += rootView.getHeight(); sTempRect.left -= rootView.getHeight() / 2; } else { sTempRect.left -= rootView.getHeight(); sTempRect.right += rootView.getHeight() / 2; } } final int targetLeft = sTempRect.left; final int targetWidth = sTempRect.width(); final float deltaWidth = lp.width - targetWidth; final float deltaLeft = lp.leftMargin - targetLeft; if (deltaLeft == 0f && deltaWidth == 0f) { // no change needed } else if (currentAlpha == 0f) { // change selector to the proper width and marginLeft without animation. lp.width = targetWidth; lp.leftMargin = targetLeft; selectorView.requestLayout(); } else { // animate the selector to the proper width and marginLeft. layoutAnimator = ValueAnimator.ofFloat(0f, 1f); layoutAnimator.setDuration(animationDuration); layoutAnimator.setInterpolator(interpolator); layoutAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { // Set width to the proper width for this animation step. float fractionToEnd = 1f - valueAnimator.getAnimatedFraction(); lp.leftMargin = Math.round(targetLeft + deltaLeft * fractionToEnd); lp.width = Math.round(targetWidth + deltaWidth * fractionToEnd); selectorView.requestLayout(); } }); layoutAnimator.start(); } return layoutAnimator; } }
From source file:com.android.yijiang.kzx.widget.betterpickers.TouchExplorationHelper.java
/** * Computes whether the specified {@link android.graphics.Rect} intersects with the visible portion of its parent * {@link android.view.View}. Modifies {@code localRect} to contain only the visible portion. * * @param localRect A rectangle in local (parent) coordinates. * @return Whether the specified {@link android.graphics.Rect} is visible on the screen. */// w ww .ja v a 2 s. co m private boolean intersectVisibleToUser(Rect localRect) { // Missing or empty bounds mean this view is not visible. if ((localRect == null) || localRect.isEmpty()) { return false; } // Attached to invisible window means this view is not visible. if (mParentView.getWindowVisibility() != View.VISIBLE) { return false; } // An invisible predecessor or one with alpha zero means // that this view is not visible to the user. Object current = this; while (current instanceof View) { final View view = (View) current; // We have attach info so this view is attached and there is no // need to check whether we reach to ViewRootImpl on the way up. if ((view.getAlpha() <= 0) || (view.getVisibility() != View.VISIBLE)) { return false; } current = view.getParent(); } // If no portion of the parent is visible, this view is not visible. if (!mParentView.getLocalVisibleRect(mTempVisibleRect)) { return false; } // Check if the view intersects the visible portion of the parent. return localRect.intersect(mTempVisibleRect); }
From source file:com.taobao.weex.ui.component.WXSliderNeighbor.java
private void updateScaleAndAlpha(View view, float alpha, float scale) { if (null == view) { return;//from w w w . j a v a 2 s. co m } if (alpha >= 0 && view.getAlpha() != alpha) { view.setAlpha(alpha); } if (scale >= 0 && view.getScaleX() != scale) { view.setScaleX(scale); view.setScaleY(scale); } }
From source file:com.doomonafireball.betterpickers.TouchExplorationHelper.java
/** * Computes whether the specified {@link android.graphics.Rect} intersects * with the visible portion of its parent {@link android.view.View}. * Modifies {@code localRect} to contain only the visible portion. * //from www . ja v a 2s . c om * @param localRect * A rectangle in local (parent) coordinates. * @return Whether the specified {@link android.graphics.Rect} is visible on * the screen. */ @SuppressLint("NewApi") private boolean intersectVisibleToUser(Rect localRect) { // Missing or empty bounds mean this view is not visible. if ((localRect == null) || localRect.isEmpty()) { return false; } // Attached to invisible window means this view is not visible. if (mParentView.getWindowVisibility() != View.VISIBLE) { return false; } // An invisible predecessor or one with alpha zero means // that this view is not visible to the user. Object current = this; while (current instanceof View) { final View view = (View) current; // We have attach info so this view is attached and there is no // need to check whether we reach to ViewRootImpl on the way up. if ((view.getAlpha() <= 0) || (view.getVisibility() != View.VISIBLE)) { return false; } current = view.getParent(); } // If no portion of the parent is visible, this view is not visible. if (!mParentView.getLocalVisibleRect(mTempVisibleRect)) { return false; } // Check if the view intersects the visible portion of the parent. return localRect.intersect(mTempVisibleRect); }
From source file:com.rbware.github.androidcouchpotato.widget.AbstractMediaItemPresenter.java
/** * Each media item row can have multiple focusable elements; the details on the left and a set * of optional custom actions on the right. * The selector is a highlight that moves to highlight to cover whichever views is in focus. * * @param selectorView the selector view used to highlight an individual element within a row. * @param focusChangedView The component within the media row whose focus got changed. * @param layoutAnimator the ValueAnimator producing animation frames for the selector's width * and x-translation, generated by this method and stored for the each * {@link ViewHolder}. * @param isDetails Whether the changed-focused view is for a media item details (true) or * an action (false).//from w w w . j a v a 2 s . c o m */ static ValueAnimator updateSelector(final View selectorView, View focusChangedView, ValueAnimator layoutAnimator, boolean isDetails) { int animationDuration = focusChangedView.getContext().getResources() .getInteger(android.R.integer.config_shortAnimTime); DecelerateInterpolator interpolator = new DecelerateInterpolator(); int layoutDirection = ViewCompat.getLayoutDirection(selectorView); if (!focusChangedView.hasFocus()) { // if neither of the details or action views are in focus (ie. another row is in focus), // animate the selector out. selectorView.animate().cancel(); selectorView.animate().alpha(0f).setDuration(animationDuration).setInterpolator(interpolator).start(); // keep existing layout animator return layoutAnimator; } else { // cancel existing layout animator if (layoutAnimator != null) { layoutAnimator.cancel(); layoutAnimator = null; } float currentAlpha = selectorView.getAlpha(); selectorView.animate().alpha(1f).setDuration(animationDuration).setInterpolator(interpolator).start(); final ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) selectorView.getLayoutParams(); ViewGroup rootView = (ViewGroup) selectorView.getParent(); sTempRect.set(0, 0, focusChangedView.getWidth(), focusChangedView.getHeight()); rootView.offsetDescendantRectToMyCoords(focusChangedView, sTempRect); if (isDetails) { if (layoutDirection == View.LAYOUT_DIRECTION_RTL) { sTempRect.right += rootView.getHeight(); sTempRect.left -= rootView.getHeight() / 2; } else { sTempRect.left -= rootView.getHeight(); sTempRect.right += rootView.getHeight() / 2; } } final int targetLeft = sTempRect.left; final int targetWidth = sTempRect.width(); final float deltaWidth = lp.width - targetWidth; final float deltaLeft = lp.leftMargin - targetLeft; if (deltaLeft == 0f && deltaWidth == 0f) { // no change needed } else if (currentAlpha == 0f) { // change selector to the proper width and marginLeft without animation. lp.width = targetWidth; lp.leftMargin = targetLeft; selectorView.requestLayout(); } else { // animate the selector to the proper width and marginLeft. layoutAnimator = ValueAnimator.ofFloat(0f, 1f); layoutAnimator.setDuration(animationDuration); layoutAnimator.setInterpolator(interpolator); layoutAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { // Set width to the proper width for this animation step. float fractionToEnd = 1f - valueAnimator.getAnimatedFraction(); lp.leftMargin = Math.round(targetLeft + deltaLeft * fractionToEnd); lp.width = Math.round(targetWidth + deltaWidth * fractionToEnd); selectorView.requestLayout(); } }); layoutAnimator.start(); } return layoutAnimator; } }
From source file:com.android.utils.ExploreByTouchHelper.java
/** * Computes whether the specified {@link Rect} intersects with the visible * portion of its parent {@link View}. Modifies {@code localRect} to contain * only the visible portion./*from w w w .ja v a 2 s .c om*/ * * @param localRect A rectangle in local (parent) coordinates. * @return Whether the specified {@link Rect} is visible on the screen. */ private boolean intersectVisibleToUser(Rect localRect) { // Missing or empty bounds mean this view is not visible. if ((localRect == null) || localRect.isEmpty()) { return false; } // Attached to invisible window means this view is not visible. if (mHost.getWindowVisibility() != View.VISIBLE) { return false; } // An invisible predecessor or one with alpha zero means // that this view is not visible to the user. Object current = this; while (current instanceof View) { final View view = (View) current; // We have attach info so this view is attached and there is no // need to check whether we reach to ViewRootImpl on the way up. if ((view.getAlpha() <= 0) || (view.getVisibility() != View.VISIBLE)) { return false; } current = view.getParent(); } // If no portion of the parent is visible, this view is not visible. if (!mHost.getLocalVisibleRect(mTempVisibleRect)) { return false; } // Check if the view intersects the visible portion of the parent. return localRect.intersect(mTempVisibleRect); }
From source file:fr.shywim.antoinedaniel.ui.MainActivity.java
/** * Fade in main content view if view has been faded out. *//*from w w w . ja v a 2 s .c om*/ private void fadeIn() { View mainLayout = findViewById(R.id.content); if (mainLayout != null) { if (mainLayout.getAlpha() != 1.0f) { mainLayout.clearAnimation(); mainLayout.animate().alpha(1).setDuration(getResources().getInteger(R.integer.anim_duration_fast)); } } }
From source file:me.lizheng.deckview.helpers.DeckChildViewTransform.java
/** * Applies this transform to a view./*from w w w . j a v a2 s. c o m*/ */ public void applyToTaskView(View v, int duration, Interpolator interp, /*boolean allowLayers,*/ boolean allowShadows/*, ValueAnimator.AnimatorUpdateListener updateCallback*/) { // Check to see if any properties have changed, and update the task view if (duration > 0) { ViewPropertyAnimator anim = v.animate(); // boolean requiresLayers = false; // Animate to the final state if (hasTranslationYChangedFrom(v.getTranslationY())) { anim.translationY(translationY); } // if (allowShadows && hasTranslationZChangedFrom(v.getTranslationZ())) { // anim.translationZ(translationZ); // } if (hasScaleChangedFrom(v.getScaleX())) { anim.scaleX(scale).scaleY(scale); // requiresLayers = true; } if (hasAlphaChangedFrom(v.getAlpha())) { // Use layers if we animate alpha anim.alpha(alpha); // requiresLayers = true; } // if (requiresLayers && allowLayers) { // anim.withLayer(); // } // if (updateCallback != null) { // anim.setUpdateListener(updateCallback); // } else { // anim.setUpdateListener(null); // } anim.setStartDelay(startDelay).setDuration(duration).setInterpolator(interp).start(); } else { // Set the changed properties if (hasTranslationYChangedFrom(v.getTranslationY())) { v.setTranslationY(translationY); } if (allowShadows && hasTranslationZChangedFrom(ViewCompat.getTranslationZ(v))) { ViewCompat.setTranslationZ(v, translationZ); } if (hasScaleChangedFrom(v.getScaleX())) { v.setScaleX(scale); v.setScaleY(scale); } if (hasAlphaChangedFrom(v.getAlpha())) { v.setAlpha(alpha); } } }
From source file:com.android.tv.menu.MenuLayoutManager.java
/** * Move the current selection to the given {@code position} with animation. * The animation specification is included in http://b/21069476 *///from w w w. j a v a 2 s . c o m public void setSelectedPositionSmooth(final int position) { if (DEBUG) { Log.d(TAG, "setSelectedPositionSmooth(position=" + position + ") {previousPosition=" + mSelectedPosition + "}"); } if (mMenuView.getVisibility() != View.VISIBLE) { setSelectedPosition(position); return; } if (mSelectedPosition == position) { return; } boolean oldIndexValid = Utils.isIndexValid(mMenuRowViews, mSelectedPosition); SoftPreconditions.checkState(oldIndexValid, TAG, "No previous selection: " + mSelectedPosition); if (!oldIndexValid) { return; } boolean newIndexValid = Utils.isIndexValid(mMenuRowViews, position); SoftPreconditions.checkArgument(newIndexValid, TAG, "position " + position); if (!newIndexValid) { return; } MenuRow row = mMenuRows.get(position); if (!row.isVisible()) { Log.e(TAG, "Moving to the invisible row: " + position); return; } if (mAnimatorSet != null) { // Do not cancel the animation here. The property values should be set to the end values // when the animation finishes. mAnimatorSet.end(); } if (mTitleFadeOutAnimator != null) { // Cancel the animation instead of ending it in order that the title animation starts // again from the intermediate state. mTitleFadeOutAnimator.cancel(); } final int oldPosition = mSelectedPosition; mSelectedPosition = position; if (DEBUG) dumpChildren("startRowAnimation()"); MenuRowView currentView = mMenuRowViews.get(position); // Show the children of the next row. currentView.getTitleView().setVisibility(View.VISIBLE); currentView.getContentsView().setVisibility(View.VISIBLE); // Request focus after the new contents view shows up. mMenuView.requestFocus(); if (mTempTitleViewForOld == null) { // Initialize here because we don't know when the views are inflated. mTempTitleViewForOld = (TextView) mMenuView.findViewById(R.id.temp_title_for_old); mTempTitleViewForCurrent = (TextView) mMenuView.findViewById(R.id.temp_title_for_current); } // Animations. mPropertyValuesAfterAnimation.clear(); List<Animator> animators = new ArrayList<>(); boolean scrollDown = position > oldPosition; List<Rect> layouts = getViewLayouts(mMenuView.getLeft(), mMenuView.getTop(), mMenuView.getRight(), mMenuView.getBottom()); // Old row. MenuRow oldRow = mMenuRows.get(oldPosition); MenuRowView oldView = mMenuRowViews.get(oldPosition); View oldContentsView = oldView.getContentsView(); // Old contents view. animators.add(createAlphaAnimator(oldContentsView, 1.0f, 0.0f, 1.0f, mLinearOutSlowIn) .setDuration(mOldContentsFadeOutDuration)); final TextView oldTitleView = oldView.getTitleView(); setTempTitleView(mTempTitleViewForOld, oldTitleView); Rect oldLayoutRect = layouts.get(oldPosition); if (scrollDown) { // Old title view. if (oldRow.hideTitleWhenSelected() && oldTitleView.getVisibility() != View.VISIBLE) { // This case is not included in the animation specification. mTempTitleViewForOld.setScaleX(1.0f); mTempTitleViewForOld.setScaleY(1.0f); animators.add(createAlphaAnimator(mTempTitleViewForOld, 0.0f, oldView.getTitleViewAlphaDeselected(), mFastOutLinearIn)); int offset = oldLayoutRect.top - mTempTitleViewForOld.getTop(); animators.add(createTranslationYAnimator(mTempTitleViewForOld, offset + mRowScrollUpAnimationOffset, offset)); } else { animators .add(createScaleXAnimator(mTempTitleViewForOld, oldView.getTitleViewScaleSelected(), 1.0f)); animators .add(createScaleYAnimator(mTempTitleViewForOld, oldView.getTitleViewScaleSelected(), 1.0f)); animators.add(createAlphaAnimator(mTempTitleViewForOld, oldTitleView.getAlpha(), oldView.getTitleViewAlphaDeselected(), mLinearOutSlowIn)); animators.add(createTranslationYAnimator(mTempTitleViewForOld, 0, oldLayoutRect.top - mTempTitleViewForOld.getTop())); } oldTitleView.setAlpha(oldView.getTitleViewAlphaDeselected()); oldTitleView.setVisibility(View.INVISIBLE); } else { Rect currentLayoutRect = new Rect(layouts.get(position)); // Old title view. // The move distance in the specification is 32dp(mRowScrollUpAnimationOffset). // But if the height of the upper row is small, the upper row will move down a lot. In // this case, this row needs to move more than the specification to avoid the overlap of // the two titles. // The maximum is to the top of the start position of mTempTitleViewForOld. int distanceCurrentTitle = currentLayoutRect.top - currentView.getTop(); int distance = Math.max(mRowScrollUpAnimationOffset, distanceCurrentTitle); int distanceToTopOfSecondTitle = oldLayoutRect.top - mRowScrollUpAnimationOffset - oldView.getTop(); animators.add( createTranslationYAnimator(oldTitleView, 0.0f, Math.min(distance, distanceToTopOfSecondTitle))); animators.add(createAlphaAnimator(oldTitleView, 1.0f, 0.0f, 1.0f, mLinearOutSlowIn) .setDuration(mOldContentsFadeOutDuration)); animators.add(createScaleXAnimator(oldTitleView, oldView.getTitleViewScaleSelected(), 1.0f)); animators.add(createScaleYAnimator(oldTitleView, oldView.getTitleViewScaleSelected(), 1.0f)); mTempTitleViewForOld.setScaleX(1.0f); mTempTitleViewForOld.setScaleY(1.0f); animators.add(createAlphaAnimator(mTempTitleViewForOld, 0.0f, oldView.getTitleViewAlphaDeselected(), mFastOutLinearIn)); int offset = oldLayoutRect.top - mTempTitleViewForOld.getTop(); animators.add( createTranslationYAnimator(mTempTitleViewForOld, offset - mRowScrollUpAnimationOffset, offset)); } // Current row. Rect currentLayoutRect = new Rect(layouts.get(position)); TextView currentTitleView = currentView.getTitleView(); View currentContentsView = currentView.getContentsView(); currentContentsView.setAlpha(0.0f); if (scrollDown) { // Current title view. setTempTitleView(mTempTitleViewForCurrent, currentTitleView); // The move distance in the specification is 32dp(mRowScrollUpAnimationOffset). // But if the height of the upper row is small, the upper row will move up a lot. In // this case, this row needs to start the move from more than the specification to avoid // the overlap of the two titles. // The maximum is to the top of the end position of mTempTitleViewForCurrent. int distanceOldTitle = oldView.getTop() - oldLayoutRect.top; int distance = Math.max(mRowScrollUpAnimationOffset, distanceOldTitle); int distanceTopOfSecondTitle = currentView.getTop() - mRowScrollUpAnimationOffset - currentLayoutRect.top; animators.add(createTranslationYAnimator(currentTitleView, Math.min(distance, distanceTopOfSecondTitle), 0.0f)); currentView.setTop(currentLayoutRect.top); ObjectAnimator animator = createAlphaAnimator(currentTitleView, 0.0f, 1.0f, mFastOutLinearIn) .setDuration(mCurrentContentsFadeInDuration); animator.setStartDelay(mOldContentsFadeOutDuration); currentTitleView.setAlpha(0.0f); animators.add(animator); animators.add(createScaleXAnimator(currentTitleView, 1.0f, currentView.getTitleViewScaleSelected())); animators.add(createScaleYAnimator(currentTitleView, 1.0f, currentView.getTitleViewScaleSelected())); animators.add(createTranslationYAnimator(mTempTitleViewForCurrent, 0.0f, -mRowScrollUpAnimationOffset)); animators.add(createAlphaAnimator(mTempTitleViewForCurrent, currentView.getTitleViewAlphaDeselected(), 0, mLinearOutSlowIn)); // Current contents view. animators.add(createTranslationYAnimator(currentContentsView, mRowScrollUpAnimationOffset, 0.0f)); animator = createAlphaAnimator(currentContentsView, 0.0f, 1.0f, mFastOutLinearIn) .setDuration(mCurrentContentsFadeInDuration); animator.setStartDelay(mOldContentsFadeOutDuration); animators.add(animator); } else { currentView.setBottom(currentLayoutRect.bottom); // Current title view. int currentViewOffset = currentLayoutRect.top - currentView.getTop(); animators.add(createTranslationYAnimator(currentTitleView, 0, currentViewOffset)); animators.add(createAlphaAnimator(currentTitleView, currentView.getTitleViewAlphaDeselected(), 1.0f, mFastOutSlowIn)); animators.add(createScaleXAnimator(currentTitleView, 1.0f, currentView.getTitleViewScaleSelected())); animators.add(createScaleYAnimator(currentTitleView, 1.0f, currentView.getTitleViewScaleSelected())); // Current contents view. animators.add(createTranslationYAnimator(currentContentsView, currentViewOffset - mRowScrollUpAnimationOffset, currentViewOffset)); ObjectAnimator animator = createAlphaAnimator(currentContentsView, 0.0f, 1.0f, mFastOutLinearIn) .setDuration(mCurrentContentsFadeInDuration); animator.setStartDelay(mOldContentsFadeOutDuration); animators.add(animator); } // Next row. int nextPosition; if (scrollDown) { nextPosition = findNextVisiblePosition(position); if (nextPosition != -1) { MenuRowView nextView = mMenuRowViews.get(nextPosition); Rect nextLayoutRect = layouts.get(nextPosition); animators.add(createTranslationYAnimator(nextView, nextLayoutRect.top + mRowScrollUpAnimationOffset - nextView.getTop(), nextLayoutRect.top - nextView.getTop())); animators.add(createAlphaAnimator(nextView, 0.0f, 1.0f, mFastOutLinearIn)); } } else { nextPosition = findNextVisiblePosition(oldPosition); if (nextPosition != -1) { MenuRowView nextView = mMenuRowViews.get(nextPosition); animators.add(createTranslationYAnimator(nextView, 0, mRowScrollUpAnimationOffset)); animators.add(createAlphaAnimator(nextView, nextView.getTitleViewAlphaDeselected(), 0.0f, 1.0f, mLinearOutSlowIn)); } } // Other rows. int count = mMenuRowViews.size(); for (int i = 0; i < count; ++i) { MenuRowView view = mMenuRowViews.get(i); if (view.getVisibility() == View.VISIBLE && i != oldPosition && i != position && i != nextPosition) { Rect rect = layouts.get(i); animators.add(createTranslationYAnimator(view, 0, rect.top - view.getTop())); } } // Run animation. final List<ViewPropertyValueHolder> propertyValuesAfterAnimation = new ArrayList<>(); propertyValuesAfterAnimation.addAll(mPropertyValuesAfterAnimation); mAnimatorSet = new AnimatorSet(); mAnimatorSet.playTogether(animators); mAnimatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { if (DEBUG) dumpChildren("onRowAnimationEndBefore"); mAnimatorSet = null; // The property values which are different from the end values and need to be // changed after the animation are set here. // e.g. setting translationY to 0, alpha of the contents view to 1. for (ViewPropertyValueHolder holder : propertyValuesAfterAnimation) { holder.property.set(holder.view, holder.value); } oldTitleView.setVisibility(View.VISIBLE); mMenuRowViews.get(oldPosition).onDeselected(); mMenuRowViews.get(position).onSelected(true); mTempTitleViewForOld.setVisibility(View.GONE); mTempTitleViewForCurrent.setVisibility(View.GONE); layout(mMenuView.getLeft(), mMenuView.getTop(), mMenuView.getRight(), mMenuView.getBottom()); if (DEBUG) dumpChildren("onRowAnimationEndAfter"); MenuRow currentRow = mMenuRows.get(position); if (currentRow.hideTitleWhenSelected()) { View titleView = mMenuRowViews.get(position).getTitleView(); mTitleFadeOutAnimator = createAlphaAnimator(titleView, titleView.getAlpha(), 0.0f, mLinearOutSlowIn); mTitleFadeOutAnimator.setStartDelay(TITLE_SHOW_DURATION_BEFORE_HIDDEN_MS); mTitleFadeOutAnimator.addListener(new AnimatorListenerAdapter() { private boolean mCanceled; @Override public void onAnimationCancel(Animator animator) { mCanceled = true; } @Override public void onAnimationEnd(Animator animator) { mTitleFadeOutAnimator = null; if (!mCanceled) { mMenuRowViews.get(position).onSelected(false); } } }); mTitleFadeOutAnimator.start(); } } }); mAnimatorSet.start(); if (DEBUG) dumpChildren("startedRowAnimation()"); }
From source file:com.android.tv.menu.MenuLayoutManager.java
private void dumpChildren(String prefix) { int position = 0; for (MenuRowView view : mMenuRowViews) { View title = view.getChildAt(0); View contents = view.getChildAt(1); Log.d(TAG, prefix + " position=" + position++ + " rowView={visiblility=" + view.getVisibility() + ", alpha=" + view.getAlpha() + ", translationY=" + view.getTranslationY() + ", left=" + view.getLeft() + ", top=" + view.getTop() + ", right=" + view.getRight() + ", bottom=" + view.getBottom() + "}, title={visiblility=" + title.getVisibility() + ", alpha=" + title.getAlpha() + ", translationY=" + title.getTranslationY() + ", left=" + title.getLeft() + ", top=" + title.getTop() + ", right=" + title.getRight() + ", bottom=" + title.getBottom() + "}, contents={visiblility=" + contents.getVisibility() + ", alpha=" + contents.getAlpha() + ", translationY=" + contents.getTranslationY() + ", left=" + contents.getLeft() + ", top=" + contents.getTop() + ", right=" + contents.getRight() + ", bottom=" + contents.getBottom() + "}"); }/*from w w w. j a v a 2 s .co m*/ }