Java Code Examples for android.view.View.getVisibility()

The following are Jave code examples for showing how to use getVisibility() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: Renrentou   File: XCCycleViewPager.java   Source Code and License Vote up 6 votes
@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
    if (!checkLayoutParams(params)) {
        params = generateLayoutParams(params);
    }
    final LayoutParams lp = (LayoutParams) params;
    lp.isDecor |= child instanceof Decor;
    if (mInLayout) {
        if (lp != null && lp.isDecor) {
            throw new IllegalStateException("Cannot add pager decor view during layout");
        }
        lp.needsMeasure = true;
        addViewInLayout(child, index, params);
    } else {
        super.addView(child, index, params);
    }

    if (USE_CACHE) {
        if (child.getVisibility() != GONE) {
            child.setDrawingCacheEnabled(mScrollingCacheEnabled);
        } else {
            child.setDrawingCacheEnabled(false);
        }
    }
}
 
Example 2
Project: Sega   File: ViewPagerEx.java   Source Code and License Vote up 6 votes
@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
    if (!checkLayoutParams(params)) {
        params = generateLayoutParams(params);
    }
    final LayoutParams lp = (LayoutParams) params;
    lp.isDecor |= child instanceof Decor;
    if (mInLayout) {
        if (lp != null && lp.isDecor) {
            throw new IllegalStateException("Cannot add pager decor view during layout");
        }
        lp.needsMeasure = true;
        addViewInLayout(child, index, params);
    } else {
        super.addView(child, index, params);
    }

    if (USE_CACHE) {
        if (child.getVisibility() != GONE) {
            child.setDrawingCacheEnabled(mScrollingCacheEnabled);
        } else {
            child.setDrawingCacheEnabled(false);
        }
    }
}
 
Example 3
Project: chromium-for-android-56-debug-video   File: ContextMenuHelper.java   Source Code and License Vote up 6 votes
/**
 * Starts showing a context menu for {@code view} based on {@code params}.
 * @param contentViewCore The {@link ContentViewCore} to show the menu to.
 * @param params          The {@link ContextMenuParams} that indicate what menu items to show.
 */
@CalledByNative
private void showContextMenu(ContentViewCore contentViewCore, ContextMenuParams params) {
    final View view = contentViewCore.getContainerView();

    if (view == null
            || view.getVisibility() != View.VISIBLE
            || view.getParent() == null) {
        return;
    }

    mCurrentContextMenuParams = params;

    view.setOnCreateContextMenuListener(this);
    if (view.showContextMenu()) {
        WebContents webContents = contentViewCore.getWebContents();
        RecordHistogram.recordBooleanHistogram(
                "ContextMenu.Shown", webContents != null);
    }
}
 
Example 4
Project: richeditor   File: LuBottomMenu.java   Source Code and License Vote up 6 votes
private int getAllChildrenHeightSum(boolean withPadding, boolean withMargin) {
    final int childCount = getChildCount();
    int height = 0;
    for (int i = 0; i < childCount; i++) {
        View child = getChildAt(i);
        if (child.getVisibility() == GONE)
            continue;

        int margin = ((MarginLayoutParams) child.getLayoutParams()).topMargin +
                ((MarginLayoutParams) child.getLayoutParams()).bottomMargin;

        height += child.getMeasuredHeight() +
                (withPadding ? child.getPaddingTop() + child.getPaddingBottom() : 0) +
                (withMargin ? margin : 0);
    }
    return Math.max(height, 0);
}
 
Example 5
Project: GitHub   File: VerticalViewPager.java   Source Code and License Vote up 6 votes
@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
    if (!checkLayoutParams(params)) {
        params = generateLayoutParams(params);
    }
    final LayoutParams lp = (LayoutParams) params;
    lp.isDecor |= child instanceof Decor;
    if (mInLayout) {
        if (lp != null && lp.isDecor) {
            throw new IllegalStateException("Cannot add pager decor view during layout");
        }
        lp.needsMeasure = true;
        addViewInLayout(child, index, params);
    } else {
        super.addView(child, index, params);
    }

    if (USE_CACHE) {
        if (child.getVisibility() != GONE) {
            child.setDrawingCacheEnabled(mScrollingCacheEnabled);
        } else {
            child.setDrawingCacheEnabled(false);
        }
    }
}
 
Example 6
Project: airgram   File: EmptyTextProgressView.java   Source Code and License Vote up 6 votes
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    inLayout = true;
    int width = r - l;
    int height = b - t;
    int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        View child = getChildAt(i);

        if (child.getVisibility() == GONE) {
            continue;
        }

        int x = (width - child.getMeasuredWidth()) / 2;
        int y;
        if (showAtCenter) {
            y = (height / 2 - child.getMeasuredHeight()) / 2;
        } else {
            y = (height - child.getMeasuredHeight()) / 2;
        }
        child.layout(x, y, x + child.getMeasuredWidth(), y + child.getMeasuredHeight());
    }
    inLayout = false;
}
 
Example 7
Project: ChatExchange-old   File: CustomViewAbove.java   Source Code and License Vote up 6 votes
private void setScrollingCacheEnabled(boolean enabled)
{
    if (mScrollingCacheEnabled != enabled)
    {
        mScrollingCacheEnabled = enabled;
        if (USE_CACHE)
        {
            final int size = getChildCount();
            for (int i = 0; i < size; ++i)
            {
                final View child = getChildAt(i);
                if (child.getVisibility() != GONE)
                {
                    child.setDrawingCacheEnabled(enabled);
                }
            }
        }
    }
}
 
Example 8
Project: ImitateZHRB   File: SimpleViewSwitcher.java   Source Code and License Vote up 5 votes
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    final int count = getChildCount();
    for (int i = 0; i < count; i++) {
        final View child = getChildAt(i);
        if (child.getVisibility() != View.GONE) {
            child.layout(0, 0,  r - l,  b - t);

        }
    }
}
 
Example 9
Project: ClouldReader   File: XRecyclerView.java   Source Code and License Vote up 5 votes
@Override
public boolean onTouchEvent(MotionEvent ev) {
    if (mLastY == -1) {
        mLastY = ev.getRawY();
    }
    switch (ev.getAction()) {
        case MotionEvent.ACTION_DOWN:
            mLastY = ev.getRawY();
            break;
        case MotionEvent.ACTION_MOVE:
            final float deltaY = ev.getRawY() - mLastY;
            mLastY = ev.getRawY();
            if (isOnTop() && pullRefreshEnabled) {
                mRefreshHeader.onMove(deltaY / DRAG_RATE);
                if (mRefreshHeader.getVisiableHeight() > 0 && mRefreshHeader.getState() < YunRefreshHeader.STATE_REFRESHING) {
                    return false;
                }
            }
            break;
        default:
            mLastY = -1; // reset
            if (isOnTop() && pullRefreshEnabled) {
                if (mRefreshHeader.releaseAction()) {
                    if (mLoadingListener != null) {
                        mLoadingListener.onRefresh();
                        isnomore = false;
                        previousTotal = 0;
                        final View footView = mFootViews.get(0);
                        if (footView instanceof LoadingMoreFooter) {
                            if (footView.getVisibility() != View.GONE) {
                                footView.setVisibility(View.GONE);
                            }
                        }
                    }
                }
            }
            break;
    }
    return super.onTouchEvent(ev);
}
 
Example 10
Project: RLibrary   File: RFlowLayout.java   Source Code and License Vote up 5 votes
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    int top = getPaddingTop();//开始布局子view的 top距离
    int left = getPaddingLeft();//开始布局子view的 left距离

    int lineNum = mAllViews.size();//行数
    List<View> lineView;
    int lineHeight;
    for (int i = 0; i < lineNum; i++) {
        lineView = mAllViews.get(i);
        lineHeight = mLineHeight.get(i);

        for (int j = 0; j < lineView.size(); j++) {
            View child = lineView.get(j);
            if (child.getVisibility() == View.GONE) {
                continue;
            }

            LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) child.getLayoutParams();
            int ld = left + params.leftMargin;
            int td = top + params.topMargin;
            int rd = ld + child.getMeasuredWidth();//不需要加上 params.rightMargin,
            int bd = td + child.getMeasuredHeight();//不需要加上 params.bottomMargin, 因为在 onMeasure , 中已经加在了 lineHeight 中
            child.layout(ld, td, rd, bd);

            left += child.getMeasuredWidth() + params.leftMargin + params.rightMargin;//因为在 这里添加了;
        }

        left = getPaddingLeft();
        top += lineHeight;
    }
}
 
Example 11
Project: GitHub   File: BaseLayoutHelper.java   Source Code and License Vote up 5 votes
@Override
public void adjustLayout(int startPosition, int endPosition, LayoutManagerHelper helper) {
    if (requireLayoutView()) {
        View refer = null;
        Rect tempRect = new Rect();
        final OrientationHelperEx orientationHelper = helper.getMainOrientationHelper();
        for (int i = 0; i < helper.getChildCount(); i++) {
            refer = helper.getChildAt(i);
            int anchorPos = helper.getPosition(refer);
            if (getRange().contains(anchorPos)) {
                if (refer.getVisibility() == View.GONE) {
                    tempRect.setEmpty();
                } else {
                    final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams)
                        refer.getLayoutParams();
                    if (helper.getOrientation() == VirtualLayoutManager.VERTICAL) {
                        tempRect.union(helper.getDecoratedLeft(refer) - params.leftMargin,
                            orientationHelper.getDecoratedStart(refer),
                            helper.getDecoratedRight(refer) + params.rightMargin,
                            orientationHelper.getDecoratedEnd(refer));
                    } else {
                        tempRect.union(orientationHelper.getDecoratedStart(refer),
                            helper.getDecoratedTop(refer) - params.topMargin, orientationHelper.getDecoratedEnd(refer),
                            helper.getDecoratedBottom(refer) + params.bottomMargin);
                    }
                }
            }
        }
        if (!tempRect.isEmpty()) {
            mLayoutRegion.set(tempRect.left - mPaddingLeft, tempRect.top - mPaddingTop,
                tempRect.right + mPaddingRight, tempRect.bottom + mPaddingBottom);
        } else {
            mLayoutRegion.setEmpty();
        }
        if (mLayoutView != null) {
            mLayoutView.layout(mLayoutRegion.left, mLayoutRegion.top, mLayoutRegion.right, mLayoutRegion.bottom);
        }
    }
}
 
Example 12
Project: hypertrack-live-android   File: AnimationUtils.java   Source Code and License Vote up 5 votes
public static Animation expand(final View v, int duration, boolean startAnim) {
    if (v.getVisibility() == View.VISIBLE)
        return null;

    v.measure(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    final int targetHeight = v.getMeasuredHeight();

    v.getLayoutParams().height = 0;
    v.setVisibility(View.VISIBLE);
    Animation a = new Animation() {
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            v.getLayoutParams().height = interpolatedTime == 1
                    ? ViewGroup.LayoutParams.WRAP_CONTENT
                    : (int) (targetHeight * interpolatedTime);
            v.requestLayout();
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }

    };

    a.setDuration(duration);
    if (startAnim)
        v.startAnimation(a);
    return a;
}
 
Example 13
Project: JewelryUI   File: ViewPager.java   Source Code and License Vote up 5 votes
/**
 * We only want the current page that is being shown to be focusable.
 */
@Override
public void addFocusables(ArrayList<View> views, int direction, int focusableMode) {
    final int focusableCount = views.size();

    final int descendantFocusability = getDescendantFocusability();

    if (descendantFocusability != FOCUS_BLOCK_DESCENDANTS) {
        for (int i = 0; i < getChildCount(); i++) {
            final View child = getChildAt(i);
            if (child.getVisibility() == VISIBLE) {
                ViewPager.ItemInfo ii = infoForChild(child);
                if (ii != null && ii.position == mCurItem) {
                    child.addFocusables(views, direction, focusableMode);
                }
            }
        }
    }

    // we add ourselves (if focusable) in all cases except for when we are
    // FOCUS_AFTER_DESCENDANTS and there are some descendants focusable.  this is
    // to avoid the focus search finding layouts when a more precise search
    // among the focusable children would be more interesting.
    if (descendantFocusability != FOCUS_AFTER_DESCENDANTS
            || (focusableCount == views.size())) { // No focusable descendants
        // Note that we can't call the superclass here, because it will
        // add all views in.  So we need to do the same thing View does.
        if (!isFocusable()) {
            return;
        }
        if ((focusableMode & FOCUSABLES_TOUCH_MODE) == FOCUSABLES_TOUCH_MODE
                && isInTouchMode() && !isFocusableInTouchMode()) {
            return;
        }
        if (views != null) {
            views.add(this);
        }
    }
}
 
Example 14
Project: GitHub   File: TagGroup.java   Source Code and License Vote up 5 votes
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    final int parentLeft = getPaddingLeft();
    final int parentRight = r - l - getPaddingRight();
    final int parentTop = getPaddingTop();
    final int parentBottom = b - t - getPaddingBottom();

    int childLeft = parentLeft;
    int childTop = parentTop;

    int rowMaxHeight = 0;

    final int count = getChildCount();
    for (int i = 0; i < count; i++) {
        final View child = getChildAt(i);
        final int width = child.getMeasuredWidth();
        final int height = child.getMeasuredHeight();

        if (child.getVisibility() != GONE) {
            if (childLeft + width > parentRight) { // Next line
                childLeft = parentLeft;
                childTop += rowMaxHeight + verticalSpacing;
                rowMaxHeight = height;
            } else {
                rowMaxHeight = Math.max(rowMaxHeight, height);
            }
            child.layout(childLeft, childTop, childLeft + width, childTop + height);

            childLeft += width + horizontalSpacing;
        }
    }
}
 
Example 15
Project: DMS   File: CalendarView.java   Source Code and License Vote up 5 votes
private void setScrollingCacheEnabled(boolean enabled) {
    if (mScrollingCacheEnabled != enabled) {
        mScrollingCacheEnabled = enabled;
        if (USE_CACHE) {
            final int size = getChildCount();
            for (int i = 0; i < size; ++i) {
                final View child = getChildAt(i);
                if (child.getVisibility() != GONE) {
                    child.setDrawingCacheEnabled(enabled);
                }
            }
        }
    }
}
 
Example 16
Project: Android-UtilCode   File: BarUtils.java   Source Code and License Vote up 5 votes
/**
 * 添加半透明矩形条
 *
 * @param activity       需要设置的 activity
 * @param statusBarAlpha 透明值
 */
private static void addTranslucentView(Activity activity, @IntRange(from = 0, to = 255) int statusBarAlpha) {
    ViewGroup contentView = (ViewGroup) activity.findViewById(android.R.id.content);
    View fakeTranslucentView = contentView.findViewWithTag(FAKE_TRANSLUCENT_VIEW_TAG);
    if (fakeTranslucentView != null) {
        if (fakeTranslucentView.getVisibility() == View.GONE) {
            fakeTranslucentView.setVisibility(View.VISIBLE);
        }
        fakeTranslucentView.setBackgroundColor(Color.argb(statusBarAlpha, 0, 0, 0));
    } else {
        contentView.addView(createTranslucentStatusBarView(activity, statusBarAlpha));
    }
}
 
Example 17
Project: WechatChatroomHelper   File: BGASwipeBackLayout2.java   Source Code and License Vote up 5 votes
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
    final AccessibilityNodeInfoCompat superNode = AccessibilityNodeInfoCompat.obtain(info);
    super.onInitializeAccessibilityNodeInfo(host, superNode);
    copyNodeInfoNoChildren(info, superNode);
    superNode.recycle();

    info.setClassName(BGASwipeBackLayout2.class.getName());
    info.setSource(host);

    final ViewParent parent = ViewCompat.getParentForAccessibility(host);
    if (parent instanceof View) {
        info.setParent((View) parent);
    }

    // This is a best-approximation of addChildrenForAccessibility()
    // that accounts for filtering.
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);
        if (!filter(child) && (child.getVisibility() == View.VISIBLE)) {
            // Force importance to "yes" since we can't read the value.
            ViewCompat.setImportantForAccessibility(
                    child, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
            info.addChild(child);
        }
    }
}
 
Example 18
Project: PageScrollView   File: BaseViewGroup.java   Source Code and License Vote up 4 votes
protected boolean isChildNotGone(View child) {
    return child != null && child.getVisibility() != View.GONE && child.getParent() == BaseViewGroup.this;
}
 
Example 19
Project: IslamicLibraryAndroid   File: FadeAnimationController.java   Source Code and License Vote up 4 votes
public FadeAnimationController(View view, int invisibleValue, float visibleAlpha) {
    this.mView = view;
    this.mVisibility = view.getVisibility();
    this.mInvisibleValue = invisibleValue;
    this.mVisibleAlpha = visibleAlpha;
}
 
Example 20
Project: GitHub   File: TagGroup.java   Source Code and License Vote up 4 votes
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
    final int heightMode = MeasureSpec.getMode(heightMeasureSpec);
    final int widthSize = MeasureSpec.getSize(widthMeasureSpec);
    final int heightSize = MeasureSpec.getSize(heightMeasureSpec);

    measureChildren(widthMeasureSpec, heightMeasureSpec);

    int width = 0;
    int height = 0;

    int row = 0; // The row counter.
    int rowWidth = 0; // Calc the current row width.
    int rowMaxHeight = 0; // Calc the max tag height, in current row.

    final int count = getChildCount();
    for (int i = 0; i < count; i++) {
        final View child = getChildAt(i);
        final int childWidth = child.getMeasuredWidth();
        final int childHeight = child.getMeasuredHeight();

        if (child.getVisibility() != GONE) {
            rowWidth += childWidth;
            if (rowWidth > widthSize) { // Next line.
                rowWidth = childWidth; // The next row width.
                height += rowMaxHeight + verticalSpacing;
                rowMaxHeight = childHeight; // The next row max height.
                row++;
            } else { // This line.
                rowMaxHeight = Math.max(rowMaxHeight, childHeight);
            }
            rowWidth += horizontalSpacing;
        }
    }
    // Account for the last row height.
    height += rowMaxHeight;

    // Account for the padding too.
    height += getPaddingTop() + getPaddingBottom();

    // If the tags grouped in one row, set the width to wrap the tags.
    if (row == 0) {
        width = rowWidth;
        width += getPaddingLeft() + getPaddingRight();
    } else {// If the tags grouped exceed one line, set the width to match the parent.
        width = widthSize;
    }

    setMeasuredDimension(widthMode == MeasureSpec.EXACTLY ? widthSize : width,
            heightMode == MeasureSpec.EXACTLY ? heightSize : height);
}