@Override public boolean apply(final View input) { return input.getVisibility() == View.VISIBLE; } };
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { int width = getMeasuredWidth(); int connectorRight = rowMargins + connector.getMeasuredWidth(); connector.layout(rowMargins, 0, connectorRight, connector.getMeasuredHeight()); moreButton.layout(width - rowMargins - moreSize, moreMarginTop, width - rowMargins, moreMarginTop + moreSize); int titleLeft = connectorRight + rowMargins; int titleBottom = titleMarginTop + title.getMeasuredHeight(); title.layout(titleLeft, titleMarginTop, titleLeft + title.getMeasuredWidth(), titleBottom); if (details.getVisibility() != GONE) { details.layout(titleLeft, titleBottom, width - rowMargins, titleBottom + details.getMeasuredHeight()); } } }
@Override public void onStartAnimator(@NonNull RefreshLayout refreshLayout, int height, int maxDragHeight) { final View progressView = mProgressView; if (progressView.getVisibility() != VISIBLE) { progressView.setVisibility(VISIBLE); Drawable drawable = mProgressView.getDrawable(); if (drawable instanceof Animatable) { ((Animatable) drawable).start(); } else { progressView.animate().rotation(36000).setDuration(100000); } } }
@Override public String apply(View input) { int id = input.getId(); return String.format( "View with id \"%s=%d\" is %s.", ViewTreeUtil.getResourceName(id), id, getVisibilityString(input.getVisibility())); } };
public static boolean isTransformedTouchPointInView(@NonNull View group,@NonNull View child, float x, float y,PointF outLocalPoint) { if (child.getVisibility() != View.VISIBLE) { return false; } final float[] point = new float[2]; point[0] = x; point[1] = y; // transformPointToViewLocal(group, child, point); point[0] += group.getScrollX() - child.getLeft(); point[1] += group.getScrollY() - child.getTop(); // final boolean isInView = pointInView(child, point[0], point[1], 0); final boolean isInView = point[0] >= 0 && point[1] >= 0 && point[0] < (child.getWidth()) && point[1] < ((child.getHeight())); if (isInView && outLocalPoint != null) { outLocalPoint.set(point[0]-x, point[1]-y); } return isInView; }
public static boolean isTransformedTouchPointInView(@NonNull View group,@NonNull View child, float x, float y,PointF outLocalPoint) { if (child.getVisibility() != View.VISIBLE) { return false; } final float[] point = new float[2]; point[0] = x; point[1] = y; // transformPointToViewLocal(group, child, point); point[0] += group.getScrollX() - child.getLeft(); point[1] += group.getScrollY() - child.getTop(); // final boolean isInView = pointInView(child, point[0], point[1], 0); final boolean isInView = point[0] >= 0 && point[1] >= 0 && point[0] < (child.getWidth()) && point[1] < ((child.getHeight())); if (isInView && outLocalPoint != null) { outLocalPoint.set(point[0]-x, point[1]-y); } return isInView; }
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int availableWidth = MeasureSpec.getSize(widthMeasureSpec); int titleWidth = availableWidth - connectorWidth - moreSize - 4 * rowMargins; int titleWidthSpec = MeasureSpec.makeMeasureSpec(titleWidth, MeasureSpec.AT_MOST); int titleHeightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); title.measure(titleWidthSpec, titleHeightSpec); int moreSizeSpec = MeasureSpec.makeMeasureSpec(moreSize, MeasureSpec.EXACTLY); moreButton.measure(moreSizeSpec, moreSizeSpec); int totalHeight = titleMarginTop + title.getMeasuredHeight(); int detailsWidth = availableWidth - connectorWidth - 3 * rowMargins; int detailsWidthSpec = MeasureSpec.makeMeasureSpec(detailsWidth, MeasureSpec.AT_MOST); int detailsHeightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); details.measure(detailsWidthSpec, detailsHeightSpec); if (details.getVisibility() != GONE) { totalHeight += details.getMeasuredHeight(); } totalHeight = Math.max(totalHeight, minHeight); int connectorWidthSpec = MeasureSpec.makeMeasureSpec(connectorWidth, MeasureSpec.EXACTLY); int connectorHeightSpec = MeasureSpec.makeMeasureSpec(totalHeight, MeasureSpec.EXACTLY); connector.measure(connectorWidthSpec, connectorHeightSpec); setMeasuredDimension(availableWidth, totalHeight); }
void setAllChildrenVisible() { for (int i = 0, childCount = getChildCount(); i < childCount; i++) { final View child = getChildAt(i); if (child.getVisibility() == INVISIBLE) { child.setVisibility(VISIBLE); } } }
void setAllChildrenVisible() { for (int i = 0, childCount = getChildCount(); i < childCount; i++) { final View child = getChildAt(i); if (child.getVisibility() == INVISIBLE) { child.setVisibility(VISIBLE); } } }
@Override public boolean onBackPressed() { if (suggestionsPanel.getVisibility() == View.VISIBLE && infoListAdapter.getItemsList().size() > 0 && !isLoading.get()) { hideSuggestionsPanel(); hideKeyboardSearch(); searchEditText.setText(lastSearchedString); return true; } return false; }
public boolean isWhenShown() { return RuntimeEnvironment.getApiLevel() >= Build.VERSION_CODES.N ? realNotification.extras.getBoolean(Notification.EXTRA_SHOW_WHEN) : findView(applyContentView(), "chronometer").getVisibility() == View.VISIBLE || findView(applyContentView(), "time").getVisibility() == View.VISIBLE; }
public boolean usesChronometer() { return RuntimeEnvironment.getApiLevel() >= Build.VERSION_CODES.N ? realNotification.extras.getBoolean(Notification.EXTRA_SHOW_CHRONOMETER) : findView(applyContentView(), "chronometer").getVisibility() == View.VISIBLE; }
@Test public void testViewVisibilityIsSet() throws Exception { View mediaView = inflate(layout.media); assertThat(mediaView.findViewById(R.id.title).getVisibility()).isEqualTo(View.VISIBLE); assertThat(mediaView.findViewById(R.id.subtitle).getVisibility()).isEqualTo(View.GONE); }
@Test public void testIncludeShouldRetainAttributes() throws Exception { ViewGroup mediaView = inflate(R.layout.media); assertThat(mediaView.findViewById(R.id.include_id).getVisibility()).isEqualTo(View.GONE); }
@Test public void testIncludeShouldOverrideAttributesOfIncludedRootNode() throws Exception { ViewGroup overrideIncludeView = inflate(R.layout.override_include); assertThat(overrideIncludeView.findViewById(R.id.snippet_text).getVisibility()) .isEqualTo(View.INVISIBLE); }
@Test public void testSetEmptyView_ShouldHideAdapterViewIfAdapterIsNull() throws Exception { adapterView.setAdapter(null); View emptyView = new View(adapterView.getContext()); adapterView.setEmptyView(emptyView); assertThat(adapterView.getVisibility()).isEqualTo(View.GONE); assertThat(emptyView.getVisibility()).isEqualTo(View.VISIBLE); }
@Test public void testSetEmptyView_ShouldHideEmptyViewWhenAdapterGetsNewItem() throws Exception { ShadowCountingAdapter adapter = new ShadowCountingAdapter(0); adapterView.setAdapter(adapter); View emptyView = new View(adapterView.getContext()); adapterView.setEmptyView(emptyView); assertThat(adapterView.getVisibility()).isEqualTo(View.GONE); assertThat(emptyView.getVisibility()).isEqualTo(View.VISIBLE); adapter.setCount(1); ShadowLooper.idleMainLooper(); assertThat(adapterView.getVisibility()).isEqualTo(View.VISIBLE); assertThat(emptyView.getVisibility()).isEqualTo(View.GONE); }
@Test public void testSetEmptyView_ShouldHideAdapterViewWhenAdapterBecomesEmpty() throws Exception { ShadowCountingAdapter adapter = new ShadowCountingAdapter(1); adapterView.setAdapter(adapter); View emptyView = new View(adapterView.getContext()); adapterView.setEmptyView(emptyView); assertThat(adapterView.getVisibility()).isEqualTo(View.VISIBLE); assertThat(emptyView.getVisibility()).isEqualTo(View.GONE); adapter.setCount(0); ShadowLooper.idleMainLooper(); assertThat(adapterView.getVisibility()).isEqualTo(View.GONE); assertThat(emptyView.getVisibility()).isEqualTo(View.VISIBLE); } }
@Test public void testSetEmptyView_ShouldHideAdapterViewIfAdapterViewIsEmpty() throws Exception { adapterView.setAdapter(new ShadowCountingAdapter(0)); View emptyView = new View(adapterView.getContext()); adapterView.setEmptyView(emptyView); assertThat(adapterView.getVisibility()).isEqualTo(View.GONE); assertThat(emptyView.getVisibility()).isEqualTo(View.VISIBLE); }
@Test public void testSetEmptyView_ShouldHideEmptyViewIfAdapterViewIsNotEmpty() throws Exception { adapterView.setAdapter(new ShadowCountingAdapter(1)); View emptyView = new View(adapterView.getContext()); adapterView.setEmptyView(emptyView); assertThat(adapterView.getVisibility()).isEqualTo(View.VISIBLE); assertThat(emptyView.getVisibility()).isEqualTo(View.GONE); }