Example usage for android.view ViewGroup setVisibility

List of usage examples for android.view ViewGroup setVisibility

Introduction

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

Prototype

@RemotableViewMethod
public void setVisibility(@Visibility int visibility) 

Source Link

Document

Set the visibility state of this view.

Usage

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 .c  o  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 setupContent(ViewGroup contentPanel) {
    mScrollView = (NestedScrollView) mWindow.findViewById(R.id.scrollView);
    mScrollView.setFocusable(false);/*from  www.j  a va2  s  .c  om*/
    mScrollView.setNestedScrollingEnabled(false);

    // Special case for users that only want to display a String
    mMessageView = (TextView) contentPanel.findViewById(android.R.id.message);
    if (mMessageView == null) {
        return;
    }

    if (mMessage != null) {
        mMessageView.setText(mMessage);
    } else {
        mMessageView.setVisibility(View.GONE);
        mScrollView.removeView(mMessageView);

        if (mListView != null) {
            final ViewGroup scrollParent = (ViewGroup) mScrollView.getParent();
            final int childIndex = scrollParent.indexOfChild(mScrollView);
            scrollParent.removeViewAt(childIndex);
            scrollParent.addView(mListView, childIndex, new LayoutParams(MATCH_PARENT, MATCH_PARENT));
        } else {
            contentPanel.setVisibility(View.GONE);
        }
    }
}

From source file:com.juick.android.MainActivity.java

public void openNavigationMenu(boolean animate) {
    if (isNavigationMenuShown())
        return;//  ww w .j av  a2 s  .  c  o  m
    navigationMenuShown = true;
    final ViewGroup navigationPanel = (ViewGroup) findViewById(R.id.navigation_panel);
    navigationPanel.setVisibility(View.VISIBLE);
    final View frag = (ViewGroup) findViewById(R.id.messagesfragment);
    if (animate) {
        AnimationSet set = new AnimationSet(true);
        TranslateAnimation translate = new TranslateAnimation(0, navigationPanel.getWidth(), 0, 0);
        translate.setFillAfter(false);
        translate.setFillEnabled(true);
        translate.setDuration(400);
        set.addAnimation(translate);
        set.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
                //To change body of implemented methods use File | Settings | File Templates.
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                frag.clearAnimation();
                layoutNavigationPane();
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
                //To change body of implemented methods use File | Settings | File Templates.
            }
        });
        frag.startAnimation(set);
    } else {
        layoutNavigationPane();
    }
}

From source file:de.sourcestream.movieDB.MainActivity.java

/**
 * This method is used in MovieDetails, CastDetails and TVDetails.
 *
 * @param layout the layout which we hide.
 *//*  ww w  .j  a  va2  s . c o m*/
public void hideLayout(final ViewGroup layout) {
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            layout.setVisibility(View.GONE);
        }
    });
}

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

private void setupCustomContent(ViewGroup customPanel) {
    final View customView;
    if (mView != null) {
        customView = mView;/*from   ww  w  . jav  a2 s  . c o m*/
    } else if (mViewLayoutResId != 0) {
        final LayoutInflater inflater = LayoutInflater.from(mContext);
        customView = inflater.inflate(mViewLayoutResId, customPanel, false);
    } else {
        customView = null;
    }

    final boolean hasCustomView = customView != null;
    if (!hasCustomView || !canTextInput(customView)) {
        mWindow.setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
                WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
    }

    if (hasCustomView) {
        final FrameLayout custom = (FrameLayout) mWindow.findViewById(R.id.custom);
        custom.addView(customView, new LayoutParams(MATCH_PARENT, MATCH_PARENT));

        if (mViewSpacingSpecified) {
            custom.setPadding(mViewSpacingLeft, mViewSpacingTop, mViewSpacingRight, mViewSpacingBottom);
        }

        if (mListView != null) {
            ((LinearLayout.LayoutParams) customPanel.getLayoutParams()).weight = 0;
        }
    } else {
        customPanel.setVisibility(View.GONE);
    }
}

From source file:com.goliathonline.android.kegbot.ui.DrinkDetailFragment.java

private void onUsersQueryComplete(Cursor cursor) {
    try {//ww  w . j av a 2s.  c  om
        mSpeakersCursor = true;
        // TODO: remove any existing speakers from layout, since this cursor
        // might be from a data change notification.
        final ViewGroup speakersGroup = (ViewGroup) mRootView.findViewById(R.id.drink_user_block);
        final LayoutInflater inflater = getActivity().getLayoutInflater();

        boolean hasSpeakers = false;

        while (cursor.moveToNext()) {
            final String userName = cursor.getString(UserQuery.USER_ID);
            if (TextUtils.isEmpty(userName)) {
                continue;
            }

            final String speakerImageUrl = cursor.getString(UserQuery.USER_IMAGE_URL);

            String speakerHeader = userName;

            final View speakerView = inflater.inflate(R.layout.user_detail, speakersGroup, false);
            final TextView speakerHeaderView = (TextView) speakerView.findViewById(R.id.user_header);
            final ImageView speakerImgView = (ImageView) speakerView.findViewById(R.id.user_image);

            if (!TextUtils.isEmpty(speakerImageUrl)) {
                BitmapUtils.fetchImage(getActivity(), speakerImageUrl, null, null,
                        new BitmapUtils.OnFetchCompleteListener() {
                            public void onFetchComplete(Object cookie, Bitmap result) {
                                if (result != null) {
                                    speakerImgView.setImageBitmap(result);
                                }
                            }
                        });
            }

            speakerHeaderView.setText(speakerHeader);

            speakersGroup.addView(speakerView);
            hasSpeakers = true;
            mHasSummaryContent = true;
        }

        speakersGroup.setVisibility(hasSpeakers ? View.VISIBLE : View.GONE);

        // Show empty message when all data is loaded, and nothing to show
        if (mSessionCursor && !mHasSummaryContent) {
            mRootView.findViewById(android.R.id.empty).setVisibility(View.VISIBLE);
        }
    } finally {
        if (null != cursor) {
            cursor.close();
        }
    }
}

From source file:group.pals.android.lib.ui.filechooser.FragmentFiles.java

/**
 * Setup:/* w  ww. j  a v  a2 s. com*/
 * <p/>
 * <ul>
 * <li>button Cancel;</li>
 * <li>text field "save as" filename;</li>
 * <li>button OK;</li>
 * </ul>
 */
private void setupFooter() {
    /*
     * By default, view group footer and all its child views are hidden.
     */

    ViewGroup viewGroupFooterContainer = (ViewGroup) getView()
            .findViewById(R.id.afc_viewgroup_footer_container);
    ViewGroup viewGroupFooter = (ViewGroup) getView().findViewById(R.id.afc_viewgroup_footer);

    if (mIsSaveDialog) {
        viewGroupFooterContainer.setVisibility(View.VISIBLE);
        viewGroupFooter.setVisibility(View.VISIBLE);

        mTextSaveas.setVisibility(View.VISIBLE);
        mTextSaveas.setText(getArguments().getString(FileChooserActivity.EXTRA_DEFAULT_FILENAME));
        mTextSaveas.setOnEditorActionListener(new TextView.OnEditorActionListener() {

            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (actionId == EditorInfo.IME_ACTION_DONE) {
                    Ui.showSoftKeyboard(v, false);
                    mBtnOk.performClick();
                    return true;
                }
                return false;
            }// onEditorAction()
        });
        mTextSaveas.addTextChangedListener(new TextWatcher() {

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                /*
                 * Do nothing.
                 */
            }// onTextChanged()

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
                /*
                 * Do nothing.
                 */
            }// beforeTextChanged()

            @Override
            public void afterTextChanged(Editable s) {
                /*
                 * If the user taps a file, the tag is set to that file's
                 * URI. But if the user types the file name, we remove the
                 * tag.
                 */
                mTextSaveas.setTag(null);
            }// afterTextChanged()
        });

        mBtnOk.setVisibility(View.VISIBLE);
        mBtnOk.setOnClickListener(mBtnOk_SaveDialog_OnClickListener);
        mBtnOk.setBackgroundResource(Ui.resolveAttribute(getActivity(), R.attr.afc_selector_button_ok_saveas));

        int size = getResources().getDimensionPixelSize(R.dimen.afc_button_ok_saveas_size);
        LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) mBtnOk.getLayoutParams();
        lp.width = size;
        lp.height = size;
        mBtnOk.setLayoutParams(lp);
    } // this is in save mode
    else {
        if (mIsMultiSelection) {
            viewGroupFooterContainer.setVisibility(View.VISIBLE);
            viewGroupFooter.setVisibility(View.VISIBLE);

            ViewGroup.LayoutParams lp = viewGroupFooter.getLayoutParams();
            lp.width = ViewGroup.LayoutParams.WRAP_CONTENT;
            viewGroupFooter.setLayoutParams(lp);

            mBtnOk.setMinWidth(getResources().getDimensionPixelSize(R.dimen.afc_single_button_min_width));
            mBtnOk.setText(android.R.string.ok);
            mBtnOk.setVisibility(View.VISIBLE);
            mBtnOk.setOnClickListener(mBtnOk_OpenDialog_OnClickListener);
        }
    } // this is in open mode
}

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

private void setupButtons(ViewGroup buttonPanel) {
    int BIT_BUTTON_POSITIVE = 1;
    int BIT_BUTTON_NEGATIVE = 2;
    int BIT_BUTTON_NEUTRAL = 4;
    int whichButtons = 0;
    mButtonPositive = (Button) buttonPanel.findViewById(android.R.id.button1);
    mButtonPositive.setOnClickListener(mButtonHandler);

    if (TextUtils.isEmpty(mButtonPositiveText)) {
        mButtonPositive.setVisibility(View.GONE);
    } else {// w  w  w  . j a  v a2 s  .  co  m
        mButtonPositive.setText(mButtonPositiveText);
        mButtonPositive.setVisibility(View.VISIBLE);
        whichButtons = whichButtons | BIT_BUTTON_POSITIVE;
    }

    mButtonNegative = (Button) buttonPanel.findViewById(android.R.id.button2);
    mButtonNegative.setOnClickListener(mButtonHandler);

    if (TextUtils.isEmpty(mButtonNegativeText)) {
        mButtonNegative.setVisibility(View.GONE);
    } else {
        mButtonNegative.setText(mButtonNegativeText);
        mButtonNegative.setVisibility(View.VISIBLE);

        whichButtons = whichButtons | BIT_BUTTON_NEGATIVE;
    }

    mButtonNeutral = (Button) buttonPanel.findViewById(android.R.id.button3);
    mButtonNeutral.setOnClickListener(mButtonHandler);

    if (TextUtils.isEmpty(mButtonNeutralText)) {
        mButtonNeutral.setVisibility(View.GONE);
    } else {
        mButtonNeutral.setText(mButtonNeutralText);
        mButtonNeutral.setVisibility(View.VISIBLE);

        whichButtons = whichButtons | BIT_BUTTON_NEUTRAL;
    }

    final boolean hasButtons = whichButtons != 0;
    if (!hasButtons) {
        buttonPanel.setVisibility(View.GONE);
    }
}

From source file:com.haibison.android.anhuu.FragmentFiles.java

/**
 * Setup:/*from   w w  w  . j av  a2  s .com*/
 * <p/>
 * <ul>
 * <li>button Cancel;</li>
 * <li>text field "save as" filename;</li>
 * <li>button OK;</li>
 * </ul>
 */
private void setupFooter() {
    /*
     * By default, view group footer and all its child views are hidden.
     */

    ViewGroup viewGroupFooterContainer = (ViewGroup) getView()
            .findViewById(R.id.anhuu_f5be488d_viewgroup_footer_container);
    ViewGroup viewGroupFooter = (ViewGroup) getView().findViewById(R.id.anhuu_f5be488d_viewgroup_footer);

    if (mIsSaveDialog) {
        viewGroupFooterContainer.setVisibility(View.VISIBLE);
        viewGroupFooter.setVisibility(View.VISIBLE);

        mTextSaveas.setVisibility(View.VISIBLE);
        mTextSaveas.setText(getArguments().getString(FileChooserActivity.EXTRA_DEFAULT_FILENAME));
        mTextSaveas.setOnEditorActionListener(new TextView.OnEditorActionListener() {

            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (actionId == EditorInfo.IME_ACTION_DONE) {
                    UI.showSoftKeyboard(v, false);
                    mBtnOk.performClick();
                    return true;
                }
                return false;
            }// onEditorAction()
        });
        mTextSaveas.addTextChangedListener(new TextWatcher() {

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                /*
                 * Do nothing.
                 */
            }// onTextChanged()

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
                /*
                 * Do nothing.
                 */
            }// beforeTextChanged()

            @Override
            public void afterTextChanged(Editable s) {
                /*
                 * If the user taps a file, the tag is set to that file's
                 * URI. But if the user types the file name, we remove the
                 * tag.
                 */
                mTextSaveas.setTag(null);
            }// afterTextChanged()
        });

        mBtnOk.setVisibility(View.VISIBLE);
        mBtnOk.setOnClickListener(mBtnOk_SaveDialog_OnClickListener);
        mBtnOk.setBackgroundResource(
                UI.resolveAttribute(getActivity(), R.attr.anhuu_f5be488d_selector_button_ok_saveas));

        int size = getResources().getDimensionPixelSize(R.dimen.anhuu_f5be488d_button_ok_saveas_size);
        LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) mBtnOk.getLayoutParams();
        lp.width = size;
        lp.height = size;
        mBtnOk.setLayoutParams(lp);
    } // this is in save mode
    else {
        if (mIsMultiSelection) {
            viewGroupFooterContainer.setVisibility(View.VISIBLE);
            viewGroupFooter.setVisibility(View.VISIBLE);

            ViewGroup.LayoutParams lp = viewGroupFooter.getLayoutParams();
            lp.width = ViewGroup.LayoutParams.WRAP_CONTENT;
            viewGroupFooter.setLayoutParams(lp);

            mBtnOk.setMinWidth(
                    getResources().getDimensionPixelSize(R.dimen.anhuu_f5be488d_single_button_min_width));
            mBtnOk.setText(android.R.string.ok);
            mBtnOk.setVisibility(View.VISIBLE);
            mBtnOk.setOnClickListener(mBtnOk_OpenDialog_OnClickListener);
        }
    } // this is in open mode
}

From source file:com.cw.litenote.note.Note_adapter.java

@SuppressLint("SetJavaScriptEnabled")
@Override//from  www. j a  va2  s .c o  m
public Object instantiateItem(ViewGroup container, final int position) {
    System.out.println("Note_adapter / instantiateItem / position = " + position);
    // Inflate the layout containing 
    // 1. picture group: image,video, thumb nail, control buttons
    // 2. text group: title, body, time 
    View pagerView = inflater.inflate(R.layout.note_view_adapter, container, false);
    int style = Note.getStyle();
    pagerView.setBackgroundColor(ColorSet.mBG_ColorArray[style]);

    // Picture group
    ViewGroup pictureGroup = (ViewGroup) pagerView.findViewById(R.id.pictureContent);
    String tagPictureStr = "current" + position + "pictureView";
    pictureGroup.setTag(tagPictureStr);

    // image view
    TouchImageView imageView = ((TouchImageView) pagerView.findViewById(R.id.image_view));
    String tagImageStr = "current" + position + "imageView";
    imageView.setTag(tagImageStr);

    // video view
    VideoViewCustom videoView = ((VideoViewCustom) pagerView.findViewById(R.id.video_view));
    String tagVideoStr = "current" + position + "videoView";
    videoView.setTag(tagVideoStr);

    ProgressBar spinner = (ProgressBar) pagerView.findViewById(R.id.loading);

    // link web view
    CustomWebView linkWebView = ((CustomWebView) pagerView.findViewById(R.id.link_web_view));
    String tagStr = "current" + position + "linkWebView";
    linkWebView.setTag(tagStr);

    // line view
    View line_view = pagerView.findViewById(R.id.line_view);

    // text group
    ViewGroup textGroup = (ViewGroup) pagerView.findViewById(R.id.textGroup);

    // Set tag for text web view
    CustomWebView textWebView = ((CustomWebView) textGroup.findViewById(R.id.textBody));

    // set accessibility
    textGroup.setContentDescription(act.getResources().getString(R.string.note_text));
    textWebView.getRootView().setContentDescription(act.getResources().getString(R.string.note_text));

    tagStr = "current" + position + "textWebView";
    textWebView.setTag(tagStr);

    // set text web view
    setWebView(textWebView, spinner, CustomWebView.TEXT_VIEW);

    String linkUri = db_page.getNoteLinkUri(position, true);
    String strTitle = db_page.getNoteTitle(position, true);
    String strBody = db_page.getNoteBody(position, true);

    // View mode
    // picture only
    if (Note.isPictureMode()) {
        System.out.println("Note_adapter / _instantiateItem / isPictureMode ");
        pictureGroup.setVisibility(View.VISIBLE);
        showPictureView(position, imageView, videoView, linkWebView, spinner);

        line_view.setVisibility(View.GONE);
        textGroup.setVisibility(View.GONE);
    }
    // text only
    else if (Note.isTextMode()) {
        System.out.println("Note_adapter / _instantiateItem / isTextMode ");
        pictureGroup.setVisibility(View.GONE);

        line_view.setVisibility(View.VISIBLE);
        textGroup.setVisibility(View.VISIBLE);

        if (Util.isYouTubeLink(linkUri) || !Util.isEmptyString(strTitle) || !Util.isEmptyString(strBody)
                || linkUri.startsWith("http")) {
            showTextWebView(position, textWebView);
        }
    }
    // picture and text
    else if (Note.isViewAllMode()) {
        System.out.println("Note_adapter / _instantiateItem / isViewAllMode ");

        // picture
        pictureGroup.setVisibility(View.VISIBLE);
        showPictureView(position, imageView, videoView, linkWebView, spinner);

        line_view.setVisibility(View.VISIBLE);
        textGroup.setVisibility(View.VISIBLE);

        // text
        if (!Util.isEmptyString(strTitle) || !Util.isEmptyString(strBody) || Util.isYouTubeLink(linkUri)
                || linkUri.startsWith("http")) {
            showTextWebView(position, textWebView);
        } else {
            textGroup.setVisibility(View.GONE);
        }
    }

    // footer of note view
    TextView footerText = (TextView) pagerView.findViewById(R.id.note_view_footer);
    if (!Note.isPictureMode()) {
        footerText.setVisibility(View.VISIBLE);
        footerText.setText(String.valueOf(position + 1) + "/" + pager.getAdapter().getCount());
        footerText.setTextColor(ColorSet.mText_ColorArray[Note.mStyle]);
        footerText.setBackgroundColor(ColorSet.mBG_ColorArray[Note.mStyle]);
    } else
        footerText.setVisibility(View.GONE);

    container.addView(pagerView, 0);

    return pagerView;
}