Example usage for android.view ViewGroup getVisibility

List of usage examples for android.view ViewGroup getVisibility

Introduction

In this page you can find the example usage for android.view ViewGroup getVisibility.

Prototype

@ViewDebug.ExportedProperty(mapping = { @ViewDebug.IntToString(from = VISIBLE, to = "VISIBLE"),
        @ViewDebug.IntToString(from = INVISIBLE, to = "INVISIBLE"),
        @ViewDebug.IntToString(from = GONE, to = "GONE") })
@Visibility
public int getVisibility() 

Source Link

Document

Returns the visibility status for this view.

Usage

From source file:Main.java

public static void hideProgress(ViewGroup mCover) {
    if (null == mCover)
        return;//w w  w .j  a v a 2 s.  com

    if (mCover.getVisibility() == View.VISIBLE) {
        mCover.setVisibility(View.GONE);
    }
}

From source file:org.solovyev.android.messenger.ListViewFilter.java

public void toggleView() {
    final View view = fragment.getView();
    final FragmentActivity activity = fragment.getActivity();

    if (view != null && activity != null && filterEditText != null) {
        final ViewGroup filterBox = (ViewGroup) view.findViewById(R.id.mpp_list_filter);
        if (filterBox != null) {
            int visibility = filterBox.getVisibility();

            final InputMethodManager manager = (InputMethodManager) activity
                    .getSystemService(Context.INPUT_METHOD_SERVICE);

            if (visibility != View.VISIBLE) {
                filterBox.setVisibility(View.VISIBLE);
                filterEditText.requestFocus();

                manager.showSoftInput(filterEditText, InputMethodManager.SHOW_IMPLICIT);

            } else if (visibility != View.GONE) {
                // if filter box is visible before hiding it clear filter query
                filterEditText.getText().clear();
                filterEditText.clearFocus();

                manager.hideSoftInputFromWindow(filterEditText.getWindowToken(),
                        InputMethodManager.HIDE_IMPLICIT_ONLY);

                filterBox.setVisibility(View.GONE);
            }/* w w  w.j  a v a2  s .  com*/
        }
    } else {
        Log.e(TAG, "toggleView() is called when view or activity is detached from fragment!");
    }
}

From source file:com.tmall.wireless.tangram.ext.SwipeItemTouchListener.java

private View findCanScrollView(View v) {
    if (v instanceof ViewGroup) {
        ViewGroup target = (ViewGroup) v;
        if ((target instanceof UltraViewPager || target instanceof RecyclerView)
                && target.getVisibility() == View.VISIBLE) {
            return target;
        } else {/* www . j  a v a  2  s . c  o m*/
            for (int i = 0; i < target.getChildCount(); ++i) {
                View view = findCanScrollView(target.getChildAt(i));
                if (view != null) {
                    return view;
                }
            }
            return null;
        }
    } else {
        return null;
    }
}

From source file:com.grottworkshop.gwsswipelayout.SwipeLayout.java

/**
 * prevent bottom view get any touch event. Especially in LayDown mode.
 *///from  w  ww .  j a v  a2  s .  c  o  m
private void safeBottomView() {
    Status status = getOpenStatus();
    ViewGroup bottom = getBottomView();

    if (status == Status.Close) {
        if (bottom.getVisibility() != INVISIBLE)
            bottom.setVisibility(INVISIBLE);
    } else {
        if (bottom.getVisibility() != VISIBLE)
            bottom.setVisibility(VISIBLE);
    }
}

From source file:com.wellsandwhistles.android.redditsp.fragments.CommentListingFragment.java

@Override
public void onCommentListingRequestPostDownloaded(final RedditPreparedPost post) {

    final Context context = getActivity();

    if (mPost == null) {

        final SRThemeAttributes attr = new SRThemeAttributes(context);

        mPost = post;/*  www . j  a  v  a 2s . com*/
        isArchived = post.isArchived;

        final RedditPostHeaderView postHeader = new RedditPostHeaderView(getActivity(), this.mPost);

        mCommentListingManager.addPostHeader(postHeader);
        ((LinearLayoutManager) mRecyclerView.getLayoutManager()).scrollToPositionWithOffset(0, 0);

        if (post.src.getSelfText() != null) {
            final ViewGroup selfText = post.src.getSelfText().buildView(getActivity(), attr.srMainTextCol,
                    14f * mCommentFontScale, mShowLinkButtons);
            selfText.setFocusable(false);
            selfText.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);

            final int paddingPx = General.dpToPixels(context, 10);
            final FrameLayout paddingLayout = new FrameLayout(context);
            final TextView collapsedView = new TextView(context);
            collapsedView.setText("[ + ]  " + getActivity().getString(R.string.collapsed_self_post));
            collapsedView.setVisibility(View.GONE);
            collapsedView.setPadding(paddingPx, paddingPx, paddingPx, paddingPx);
            paddingLayout.addView(selfText);
            paddingLayout.addView(collapsedView);
            paddingLayout.setPadding(paddingPx, paddingPx, paddingPx, paddingPx);

            paddingLayout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (selfText.getVisibility() == View.GONE) {
                        selfText.setVisibility(View.VISIBLE);
                        collapsedView.setVisibility(View.GONE);
                    } else {
                        selfText.setVisibility(View.GONE);
                        collapsedView.setVisibility(View.VISIBLE);
                    }

                }
            });
            // TODO mListHeaderNotifications.setBackgroundColor(Color.argb(35, 128, 128, 128));

            mCommentListingManager.addPostSelfText(paddingLayout);
        }

        if (!General.isTablet(context, PreferenceManager.getDefaultSharedPreferences(context))) {
            getActivity().setTitle(post.src.getTitle());
        }

        if (mCommentListingManager.isSearchListing()) {
            final CommentSubThreadView searchCommentThreadView = new CommentSubThreadView(getActivity(),
                    mAllUrls.get(0).asPostCommentListURL(), R.string.comment_header_search_thread_title);

            mCommentListingManager.addNotification(searchCommentThreadView);
        } else if (!mAllUrls.isEmpty() && mAllUrls.get(0).pathType() == RedditURLParser.POST_COMMENT_LISTING_URL
                && mAllUrls.get(0).asPostCommentListURL().commentId != null) {

            final CommentSubThreadView specificCommentThreadView = new CommentSubThreadView(getActivity(),
                    mAllUrls.get(0).asPostCommentListURL(), R.string.comment_header_specific_thread_title);

            mCommentListingManager.addNotification(specificCommentThreadView);
        }

        // TODO pref (currently 10 mins)
        if (mCachedTimestamp != null && SRTime.since(mCachedTimestamp) > 10 * 60 * 1000) {

            final TextView cacheNotif = (TextView) LayoutInflater.from(getActivity())
                    .inflate(R.layout.cached_header, null, false);
            cacheNotif.setText(getActivity().getString(R.string.listing_cached,
                    SRTime.formatDateTime(mCachedTimestamp, getActivity())));
            mCommentListingManager.addNotification(cacheNotif);
        }
    }
}

From source file:org.quantumbadger.redreader.fragments.CommentListingFragment.java

@Override
public void onCommentListingRequestPostDownloaded(final RedditPreparedPost post) {

    final Context context = getActivity();

    if (mPost == null) {

        final RRThemeAttributes attr = new RRThemeAttributes(context);

        mPost = post;//from  w w w  . j a va2 s  . co m
        isArchived = post.isArchived;

        final RedditPostHeaderView postHeader = new RedditPostHeaderView(getActivity(), this.mPost);

        mCommentListingManager.addPostHeader(postHeader);
        ((LinearLayoutManager) mRecyclerView.getLayoutManager()).scrollToPositionWithOffset(0, 0);

        if (post.src.getSelfText() != null) {
            final ViewGroup selfText = post.src.getSelfText().buildView(getActivity(), attr.rrMainTextCol,
                    14f * mCommentFontScale, mShowLinkButtons);
            selfText.setFocusable(false);
            selfText.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);

            final int paddingPx = General.dpToPixels(context, 10);
            final FrameLayout paddingLayout = new FrameLayout(context);
            final TextView collapsedView = new TextView(context);
            collapsedView.setText("[ + ]  " + getActivity().getString(R.string.collapsed_self_post));
            collapsedView.setVisibility(View.GONE);
            collapsedView.setPadding(paddingPx, paddingPx, paddingPx, paddingPx);
            paddingLayout.addView(selfText);
            paddingLayout.addView(collapsedView);
            paddingLayout.setPadding(paddingPx, paddingPx, paddingPx, paddingPx);

            paddingLayout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (selfText.getVisibility() == View.GONE) {
                        selfText.setVisibility(View.VISIBLE);
                        collapsedView.setVisibility(View.GONE);
                    } else {
                        selfText.setVisibility(View.GONE);
                        collapsedView.setVisibility(View.VISIBLE);
                    }

                }
            });
            // TODO mListHeaderNotifications.setBackgroundColor(Color.argb(35, 128, 128, 128));

            mCommentListingManager.addPostSelfText(paddingLayout);
        }

        if (!General.isTablet(context, PreferenceManager.getDefaultSharedPreferences(context))) {
            getActivity().setTitle(post.src.getTitle());
        }

        if (mCommentListingManager.isSearchListing()) {
            final CommentSubThreadView searchCommentThreadView = new CommentSubThreadView(getActivity(),
                    mAllUrls.get(0).asPostCommentListURL(), R.string.comment_header_search_thread_title);

            mCommentListingManager.addNotification(searchCommentThreadView);
        } else if (!mAllUrls.isEmpty() && mAllUrls.get(0).pathType() == RedditURLParser.POST_COMMENT_LISTING_URL
                && mAllUrls.get(0).asPostCommentListURL().commentId != null) {

            final CommentSubThreadView specificCommentThreadView = new CommentSubThreadView(getActivity(),
                    mAllUrls.get(0).asPostCommentListURL(), R.string.comment_header_specific_thread_title);

            mCommentListingManager.addNotification(specificCommentThreadView);
        }

        // TODO pref (currently 10 mins)
        if (mCachedTimestamp != null && RRTime.since(mCachedTimestamp) > 10 * 60 * 1000) {

            final TextView cacheNotif = (TextView) LayoutInflater.from(getActivity())
                    .inflate(R.layout.cached_header, null, false);
            cacheNotif.setText(getActivity().getString(R.string.listing_cached,
                    RRTime.formatDateTime(mCachedTimestamp, getActivity())));
            mCommentListingManager.addNotification(cacheNotif);
        }
    }
}

From source file:android.support.v7.app.AlertController.java

private void setupView() {
    final View parentPanel = mWindow.findViewById(R.id.parentPanel);
    final View defaultTopPanel = parentPanel.findViewById(R.id.topPanel);
    final View defaultContentPanel = parentPanel.findViewById(R.id.contentPanel);
    final View defaultButtonPanel = parentPanel.findViewById(R.id.buttonPanel);

    // Install custom content before setting up the title or buttons so
    // that we can handle panel overrides.
    final ViewGroup customPanel = (ViewGroup) parentPanel.findViewById(R.id.customPanel);
    setupCustomContent(customPanel);//from  w w w.  j a v  a2  s .c  o  m

    final View customTopPanel = customPanel.findViewById(R.id.topPanel);
    final View customContentPanel = customPanel.findViewById(R.id.contentPanel);
    final View customButtonPanel = customPanel.findViewById(R.id.buttonPanel);

    // Resolve the correct panels and remove the defaults, if needed.
    final ViewGroup topPanel = resolvePanel(customTopPanel, defaultTopPanel);
    final ViewGroup contentPanel = resolvePanel(customContentPanel, defaultContentPanel);
    final ViewGroup buttonPanel = resolvePanel(customButtonPanel, defaultButtonPanel);

    setupContent(contentPanel);
    setupButtons(buttonPanel);
    setupTitle(topPanel);

    final boolean hasCustomPanel = customPanel != null && customPanel.getVisibility() != View.GONE;
    final boolean hasTopPanel = topPanel != null && topPanel.getVisibility() != View.GONE;
    final boolean hasButtonPanel = buttonPanel != null && buttonPanel.getVisibility() != View.GONE;

    // Only display the text spacer if we don't have buttons.
    if (!hasButtonPanel) {
        if (contentPanel != null) {
            final View spacer = contentPanel.findViewById(R.id.textSpacerNoButtons);
            if (spacer != null) {
                spacer.setVisibility(View.VISIBLE);
            }
        }
    }

    if (hasTopPanel) {
        // Only clip scrolling content to padding if we have a title.
        if (mScrollView != null) {
            mScrollView.setClipToPadding(true);
        }
    }

    // Update scroll indicators as needed.
    if (!hasCustomPanel) {
        final View content = mListView != null ? mListView : mScrollView;
        if (content != null) {
            final int indicators = (hasTopPanel ? ViewCompat.SCROLL_INDICATOR_TOP : 0)
                    | (hasButtonPanel ? ViewCompat.SCROLL_INDICATOR_BOTTOM : 0);
            setScrollIndicators(contentPanel, content, indicators,
                    ViewCompat.SCROLL_INDICATOR_TOP | ViewCompat.SCROLL_INDICATOR_BOTTOM);
        }
    }

    final ListView listView = mListView;
    if (listView != null && mAdapter != null) {
        listView.setAdapter(mAdapter);
        final int checkedItem = mCheckedItem;
        if (checkedItem > -1) {
            listView.setItemChecked(checkedItem, true);
            listView.setSelection(checkedItem);
        }
    }
}