static float getAlpha(View view) { return view.getAlpha(); }
public float getTransitionAlpha(@NonNull View v) { return v.getAlpha(); }
private static void unsetAlpha(View view, NodeInfo nodeInfo) { if (Build.VERSION.SDK_INT >= 11) { if (nodeInfo.isAlphaSet() && view.getAlpha() != 1) { view.setAlpha(1); } } }
@Override public void captureStartValues(@NonNull TransitionValues transitionValues) { super.captureStartValues(transitionValues); transitionValues.values.put(PROPNAME_ALPHA, transitionValues.view.getAlpha()); }
@Override public float get(Object mountContent) { if (mountContent instanceof View) { return ((View) mountContent).getAlpha(); } else if (!ComponentsConfiguration.allowAnimatingDrawables) { throw new UnsupportedOperationException( "Tried to get alpha of unsupported mount content: " + mountContent); } else if (mountContent instanceof Drawable) { return AlphaHelper.getAlpha((Drawable) mountContent); } else { throw new UnsupportedOperationException( "Tried to get alpha of unsupported mount content: " + mountContent); } }
public static AlphaAnimExpectation sameAlphaAs(View otherView) { return new AlphaAnimExpectationValue(otherView.getAlpha()); }
@Override @NonNull protected Animator getAnimator(@NonNull ViewGroup container, @Nullable View from, @Nullable View to, boolean isPush, boolean toAddedToContainer) { AnimatorSet animator = new AnimatorSet(); if (to != null) { float start = toAddedToContainer ? 0 : to.getAlpha(); animator.play(ObjectAnimator.ofFloat(to, View.ALPHA, start, 1)); } if (from != null && (!isPush || removesFromViewOnPush())) { animator.play(ObjectAnimator.ofFloat(from, View.ALPHA, 0)); } return animator; }
/** * @return true if the given view is visible to user, false otherwise. The logic is leveraged from * {@link View#isVisibleToUser()}. */ private static boolean isVisibleToUser(View view) { if (view.getWindowVisibility() != View.VISIBLE) { return false; } Object current = view; while (current instanceof View) { final View currentView = (View) current; if (currentView.getAlpha() <= 0 || currentView.getVisibility() != View.VISIBLE) { return false; } current = currentView.getParent(); } return view.getGlobalVisibleRect(sDummyRect); }
@Override @NonNull protected Animator getAnimator(@NonNull ViewGroup container, View from, View to, boolean isPush, boolean toAddedToContainer) { AnimatorSet animator = new AnimatorSet(); if (to != null) { float start = toAddedToContainer ? 0 : to.getAlpha(); animator.play(ObjectAnimator.ofFloat(to, View.ALPHA, start, 1)); } if (from != null) { animator.play(ObjectAnimator.ofFloat(from, View.ALPHA, 0)); animator.play(ObjectAnimator.ofFloat(from, View.SCALE_X, 0.8f)); animator.play(ObjectAnimator.ofFloat(from, View.SCALE_Y, 0.8f)); } return animator; }
private void traverse(View view) { if (UETool.getInstance().getFilterClasses().contains(view.getClass().getName())) return; if (view.getAlpha() == 0 || view.getVisibility() != View.VISIBLE) return; if (getResources().getString(R.string.uet_disable).equals(view.getTag())) return; if (view instanceof ViewGroup) { elements.add(0, new Element(view)); ViewGroup parent = (ViewGroup) view; for (int i = 0; i < parent.getChildCount(); i++) { traverse(parent.getChildAt(i)); } } else { elements.add(new Element(view)); } }
@TargetApi(HONEYCOMB) public S hasAlpha(float alpha) { isNotNull(); float actualAlpha = actual.getAlpha(); assertThat(actualAlpha) // .overridingErrorMessage("Expected alpha <%s> but was <%s>", alpha, actualAlpha) // .isEqualTo(alpha); return myself; }
@Override public void onStartAnimator(@NonNull RefreshLayout layout, int height, int maxDragHeight) { super.onStartAnimator(layout, height, maxDragHeight); final View topView = mMaskViewTop; final View shadowView = mShadowView; final View bottomView = mMaskViewBottom; final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(ObjectAnimator.ofFloat(topView, "translationY", topView.getTranslationY(), -mHalfHeaderHeight)) .with(ObjectAnimator.ofFloat(bottomView, "translationY", bottomView.getTranslationY(), mHalfHeaderHeight)) .with(ObjectAnimator.ofFloat(shadowView, "alpha", shadowView.getAlpha(), 0)); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { topView.setVisibility(View.GONE); bottomView.setVisibility(View.GONE); shadowView.setVisibility(View.GONE); postStatus(FunGameView.STATUS_GAME_PLAY); } }); animatorSet.setDuration(800); animatorSet.setStartDelay(200); animatorSet.start(); }
private void hideViewWhenNotCanceled() { if (!mCanceled) { if (mIsForcedVisibility) { mView.setTag(R.id.transitionAlpha, mView.getAlpha()); mView.setAlpha(0); } else if (!mFinalVisibilitySet) { // Recreate the parent's display list in case it includes mView. ViewUtils.setTransitionVisibility(mView, mFinalVisibility); if (mParent != null) { mParent.invalidate(); } mFinalVisibilitySet = true; } } // Layout is allowed now that the View is in its final state suppressLayout(false); }
if (refreshHeader.getView().getAlpha() == 0 && refreshHeader.getView() != this) { refreshHeader.getView().setAlpha(1);
@Test public void actionsAppliedToView() { View view = new View(context); assertThat(view.isEnabled()).isTrue(); assertThat(view.getAlpha()).isEqualTo(1f); ViewCollections.run(view, ACTION_DISABLE, ACTION_ZERO_ALPHA); assertThat(view.isEnabled()).isFalse(); assertThat(view.getAlpha()).isEqualTo(0f); }
@Test public void testAlphaIsSet() throws Exception { View mediaView = inflate(layout.main); assertThat(mediaView.findViewById(R.id.time).getAlpha()).isEqualTo(.3f); }
@Test public void actionsAppliedToEveryViewInList() { View view1 = new View(context); View view2 = new View(context); View view3 = new View(context); assertThat(view1.isEnabled()).isTrue(); assertThat(view2.isEnabled()).isTrue(); assertThat(view3.isEnabled()).isTrue(); assertThat(view1.getAlpha()).isEqualTo(1f); assertThat(view2.getAlpha()).isEqualTo(1f); assertThat(view3.getAlpha()).isEqualTo(1f); List<View> views = asList(view1, view2, view3); ViewCollections.run(views, ACTION_DISABLE, ACTION_ZERO_ALPHA); assertThat(view1.isEnabled()).isFalse(); assertThat(view2.isEnabled()).isFalse(); assertThat(view3.isEnabled()).isFalse(); assertThat(view1.getAlpha()).isEqualTo(0f); assertThat(view2.getAlpha()).isEqualTo(0f); assertThat(view3.getAlpha()).isEqualTo(0f); }
@Test public void actionsAppliedToEveryViewInArray() { View view1 = new View(context); View view2 = new View(context); View view3 = new View(context); assertThat(view1.isEnabled()).isTrue(); assertThat(view2.isEnabled()).isTrue(); assertThat(view3.isEnabled()).isTrue(); assertThat(view1.getAlpha()).isEqualTo(1f); assertThat(view2.getAlpha()).isEqualTo(1f); assertThat(view3.getAlpha()).isEqualTo(1f); View[] views = new View[] { view1, view2, view3 }; ViewCollections.run(views, ACTION_DISABLE, ACTION_ZERO_ALPHA); assertThat(view1.isEnabled()).isFalse(); assertThat(view2.isEnabled()).isFalse(); assertThat(view3.isEnabled()).isFalse(); assertThat(view1.getAlpha()).isEqualTo(0f); assertThat(view2.getAlpha()).isEqualTo(0f); assertThat(view3.getAlpha()).isEqualTo(0f); }
public static ValueAnimator getFadeOutAnimator() { ViewAnimator animator = new ViewAnimator(); animator.setInterpolator(new DecelerateInterpolator()); animator.setOnSetupValuesListener(() -> { View view = animator.getTarget(); float start = view.getAlpha(); animator.setFloatValues(start, 0); animator.setDuration((long) (200 * start)); }); animator.addUpdateListener(valueAnimator -> { View view = animator.getTarget(); view.setAlpha((Float) valueAnimator.getAnimatedValue()); }); return animator; }
@Test public void shouldGetAndSetAlpha() throws Exception { view = new TestView(buildActivity(Activity.class).create().get()); view.setAlpha(9.1f); assertThat(view.getAlpha()).isEqualTo(9.1f); }