Example usage for android.view View getVisibility

List of usage examples for android.view View getVisibility

Introduction

In this page you can find the example usage for android.view View 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:com.facebook.litho.ViewCompatComponent.java

@Override
protected void onMeasure(ComponentContext c, ComponentLayout layout, int widthSpec, int heightSpec, Size size,
        Component<?> component) {
    final ViewCompatComponentImpl impl = (ViewCompatComponentImpl) component;
    final ViewBinder viewBinder = impl.mViewBinder;

    final boolean isSafeToAllocatePool = getValidActivityForContext(c) != null;

    View toMeasure = (View) ComponentsPools.acquireMountContent(c, getId(), isSafeToAllocatePool);
    if (toMeasure == null) {
        toMeasure = mViewCompatCreator.createView(c);
    }// ww  w . j a  v  a  2 s  .co m

    ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(size.width, size.height);
    toMeasure.setLayoutParams(layoutParams);

    viewBinder.bind(toMeasure);

    if (toMeasure.getVisibility() == View.GONE) {
        // No need to measure the view if binding it caused its visibility to become GONE.
        size.width = 0;
        size.height = 0;
    } else {
        toMeasure.measure(widthSpec, heightSpec);
        size.width = toMeasure.getMeasuredWidth();
        size.height = toMeasure.getMeasuredHeight();
    }

    viewBinder.unbind(toMeasure);

    ComponentsPools.release(c, this, toMeasure);
}

From source file:com.abcvoipsip.ui.account.AccountsEditListFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    //getListView().setSelector(R.drawable.transparent);
    getListView().setCacheColorHint(Color.TRANSPARENT);

    // View management
    View detailsFrame = getActivity().findViewById(R.id.details);
    dualPane = detailsFrame != null && detailsFrame.getVisibility() == View.VISIBLE;

    if (savedInstanceState != null) {
        // Restore last state for checked position.
        curCheckPosition = savedInstanceState.getLong(CURRENT_CHOICE, SipProfile.INVALID_ID);
        //curCheckWizard = savedInstanceState.getString(CURRENT_WIZARD);
    }/*from  www .  ja  v  a2  s  .com*/

    AccountsEditListAdapter adapter = new AccountsEditListAdapter(getActivity(), null);
    adapter.setOnCheckedRowListener(this);
    //getListView().setEmptyView(getActivity().findViewById(R.id.progress_container));
    //getActivity().findViewById(android.R.id.empty).setVisibility(View.GONE);
    setListAdapter(adapter);
    registerForContextMenu(getListView());

    // Prepare the loader.  Either re-connect with an existing one,
    // or start a new one.
    getLoaderManager().initLoader(0, null, this);

    getListView().setVerticalFadingEdgeEnabled(true);

    if (dualPane) {
        // In dual-pane mode, the list view highlights the selected item.
        Log.d("lp", "dual pane mode");
        getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        //getListView().setVerticalScrollbarPosition(View.SCROLLBAR_POSITION_LEFT);
        getListView().setVerticalScrollBarEnabled(false);
        getListView().setFadingEdgeLength(50);

        updateCheckedItem();
        // Make sure our UI is in the correct state.
        //showDetails(curCheckPosition, curCheckWizard);
    } else {
        //getListView().setVerticalScrollbarPosition(View.SCROLLBAR_POSITION_RIGHT);
        getListView().setVerticalScrollBarEnabled(true);
        getListView().setFadingEdgeLength(100);
    }
}

From source file:com.cicada.yuanxiaobao.common.BaseAdapterHelper.java

/**
 * Get a view visibility ./*from w  w  w  .j  a v a2 s.  c  o m*/
 * 
 * @param viewId
 *            The view id.
 *            True for VISIBLE, false for GONE.
 * @return The BaseAdapterHelper for chaining.
 */
public boolean getVisible(int viewId) {
    View view = retrieveView(viewId);

    return view.getVisibility() == View.VISIBLE ? true : false;
}

From source file:arefin.dialogs.core.BaseDialogFragment.java

/**
 * Button divider should be shown only if the content is scrollable.
 *///from w w w  .j av  a2  s  .c o  m
private void modifyButtonsBasedOnScrollableContent(boolean scrollable) {
    if (getView() == null) {
        return;
    }
    View vButtonDivider = getView().findViewById(R.id.sdl_button_divider);
    View vButtonsBottomSpace = getView().findViewById(R.id.sdl_buttons_bottom_space);
    View vDefaultButtons = getView().findViewById(R.id.sdl_buttons_default);
    View vStackedButtons = getView().findViewById(R.id.sdl_buttons_stacked);
    if (vDefaultButtons.getVisibility() == View.GONE && vStackedButtons.getVisibility() == View.GONE) {
        // no buttons
        vButtonDivider.setVisibility(View.GONE);
        vButtonsBottomSpace.setVisibility(View.GONE);
    } else if (scrollable) {
        vButtonDivider.setVisibility(View.VISIBLE);
        vButtonsBottomSpace.setVisibility(View.GONE);
    } else {
        vButtonDivider.setVisibility(View.GONE);
        vButtonsBottomSpace.setVisibility(View.VISIBLE);
    }
}

From source file:com.appeaser.sublimepickerlibrary.datepicker.DayPickerViewPager.java

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    //populate();
    // Use reflection
    callPopulate();//  w ww.ja  v a2  s  .c o  m

    // Everything below is mostly copied from FrameLayout.
    int count = getChildCount();

    final boolean measureMatchParentChildren = MeasureSpec.getMode(widthMeasureSpec) != MeasureSpec.EXACTLY
            || MeasureSpec.getMode(heightMeasureSpec) != MeasureSpec.EXACTLY;

    int maxHeight = 0;
    int maxWidth = 0;
    int childState = 0;

    for (int i = 0; i < count; i++) {
        final View child = getChildAt(i);
        if (child.getVisibility() != GONE) {
            measureChild(child, widthMeasureSpec, heightMeasureSpec);
            final LayoutParams lp = (LayoutParams) child.getLayoutParams();
            maxWidth = Math.max(maxWidth, child.getMeasuredWidth());
            maxHeight = Math.max(maxHeight, child.getMeasuredHeight());
            childState = combineMeasuredStates(childState, child.getMeasuredState());
            if (measureMatchParentChildren) {
                if (lp.width == LayoutParams.MATCH_PARENT || lp.height == LayoutParams.MATCH_PARENT) {
                    mMatchParentChildren.add(child);
                }
            }
        }
    }

    // Account for padding too
    maxWidth += getPaddingLeft() + getPaddingRight();
    maxHeight += getPaddingTop() + getPaddingBottom();

    // Check against our minimum height and width
    maxHeight = Math.max(maxHeight, getSuggestedMinimumHeight());
    maxWidth = Math.max(maxWidth, getSuggestedMinimumWidth());

    // Check against our foreground's minimum height and width
    if (SUtils.isApi_23_OrHigher()) {
        final Drawable drawable = getForeground();
        if (drawable != null) {
            maxHeight = Math.max(maxHeight, drawable.getMinimumHeight());
            maxWidth = Math.max(maxWidth, drawable.getMinimumWidth());
        }
    }

    setMeasuredDimension(resolveSizeAndState(maxWidth, widthMeasureSpec, childState),
            resolveSizeAndState(maxHeight, heightMeasureSpec, childState << MEASURED_HEIGHT_STATE_SHIFT));

    count = mMatchParentChildren.size();
    if (count > 1) {
        for (int i = 0; i < count; i++) {
            final View child = mMatchParentChildren.get(i);

            final LayoutParams lp = (LayoutParams) child.getLayoutParams();
            final int childWidthMeasureSpec;
            final int childHeightMeasureSpec;

            if (lp.width == LayoutParams.MATCH_PARENT) {
                childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(
                        getMeasuredWidth() - getPaddingLeft() - getPaddingRight(), MeasureSpec.EXACTLY);
            } else {
                childWidthMeasureSpec = getChildMeasureSpec(widthMeasureSpec,
                        getPaddingLeft() + getPaddingRight(), lp.width);
            }

            if (lp.height == LayoutParams.MATCH_PARENT) {
                childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(
                        getMeasuredHeight() - getPaddingTop() - getPaddingBottom(), MeasureSpec.EXACTLY);
            } else {
                childHeightMeasureSpec = getChildMeasureSpec(heightMeasureSpec,
                        getPaddingTop() + getPaddingBottom(), lp.height);
            }

            child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
        }
    }

    mMatchParentChildren.clear();
}

From source file:io.selendroid.server.model.AndroidNativeElement.java

/**
 * If view.isShown() == false, logs why exactly this evaluates to false.
 * Copied from Android's implementation of View.isShown().
 *///from  w w  w  .  j  ava  2s  . co m
private void logIsShownCheckFailure(View view) {
    try {
        SelendroidLogger.debug("Display check failed because View.isShown() == false");
        View current = view;
        do {
            if ((current.getVisibility()) != View.VISIBLE) {
                SelendroidLogger.debug(String.format(
                        "isShown: View %s is not visible because its ancestor %s has visibility %d", view,
                        current, current.getVisibility()));
                break;
            }
            ViewParent parent = current.getParent();
            if (parent == null) {
                SelendroidLogger.debug(
                        String.format("isShown: View %s is not visible because its ancestor %s has no parent "
                                + "(it is not attached to view root): ", view, current));
                break;
            }
            if (!(parent instanceof View)) {
                // The only case where View.isShown() returns true:
                // The view needs to have an ancestor that is not a View and all ancestors on the way up have to
                // be visible.
                break;
            }
            current = (View) parent;
        } while (current != null);
        SelendroidLogger.debug(String.format("View %s is not visible", view));
    } catch (Exception e) {
        // Don't let an exception in debug printing crash the caller
        SelendroidLogger.error("isShown() debug printing failed", e);
    }
}

From source file:com.android.yijiang.kzx.widget.betterpickers.TouchExplorationHelper.java

/**
 * Computes whether the specified {@link android.graphics.Rect} intersects with the visible portion of its parent
 * {@link android.view.View}. Modifies {@code localRect} to contain only the visible portion.
 *
 * @param localRect A rectangle in local (parent) coordinates.
 * @return Whether the specified {@link android.graphics.Rect} is visible on the screen.
 *//*from   ww w. j ava 2s  .c o m*/
private boolean intersectVisibleToUser(Rect localRect) {
    // Missing or empty bounds mean this view is not visible.
    if ((localRect == null) || localRect.isEmpty()) {
        return false;
    }

    // Attached to invisible window means this view is not visible.
    if (mParentView.getWindowVisibility() != View.VISIBLE) {
        return false;
    }

    // An invisible predecessor or one with alpha zero means
    // that this view is not visible to the user.
    Object current = this;
    while (current instanceof View) {
        final View view = (View) current;
        // We have attach info so this view is attached and there is no
        // need to check whether we reach to ViewRootImpl on the way up.
        if ((view.getAlpha() <= 0) || (view.getVisibility() != View.VISIBLE)) {
            return false;
        }
        current = view.getParent();
    }

    // If no portion of the parent is visible, this view is not visible.
    if (!mParentView.getLocalVisibleRect(mTempVisibleRect)) {
        return false;
    }

    // Check if the view intersects the visible portion of the parent.
    return localRect.intersect(mTempVisibleRect);
}

From source file:com.csipsimple.ui.account.AccountsEditListFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    ListView lv = getListView();//  w w  w  .  j  av  a 2s  .  c o m

    //getListView().setSelector(R.drawable.transparent);
    lv.setCacheColorHint(Color.TRANSPARENT);

    // View management
    View detailsFrame = getActivity().findViewById(R.id.details);
    dualPane = detailsFrame != null && detailsFrame.getVisibility() == View.VISIBLE;

    if (savedInstanceState != null) {
        // Restore last state for checked position.
        curCheckPosition = savedInstanceState.getLong(CURRENT_CHOICE, SipProfile.INVALID_ID);
        //curCheckWizard = savedInstanceState.getString(CURRENT_WIZARD);
    }
    setListShown(false);
    if (mAdapter == null) {
        if (mHeaderView != null) {
            lv.addHeaderView(mHeaderView, null, true);
        }
        mAdapter = new AccountsEditListAdapter(getActivity(), null);
        mAdapter.setOnCheckedRowListener(this);
        //getListView().setEmptyView(getActivity().findViewById(R.id.progress_container));
        //getActivity().findViewById(android.R.id.empty).setVisibility(View.GONE);
        setListAdapter(mAdapter);
        registerForContextMenu(lv);

        // Prepare the loader.  Either re-connect with an existing one,
        // or start a new one.
        getLoaderManager().initLoader(0, null, this);

        lv.setVerticalFadingEdgeEnabled(true);
    }

    if (dualPane) {
        // In dual-pane mode, the list view highlights the selected item.
        Log.d("lp", "dual pane mode");
        lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        //lv.setVerticalScrollbarPosition(View.SCROLLBAR_POSITION_LEFT);
        lv.setVerticalScrollBarEnabled(false);
        lv.setFadingEdgeLength(50);

        updateCheckedItem();
        // Make sure our UI is in the correct state.
        //showDetails(curCheckPosition, curCheckWizard);
    } else {
        //getListView().setVerticalScrollbarPosition(View.SCROLLBAR_POSITION_RIGHT);
        lv.setVerticalScrollBarEnabled(true);
        lv.setFadingEdgeLength(100);
    }
}

From source file:com.fututel.ui.account.AccountsEditListFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    ListView lv = getListView();/*from   w  ww. ja  va  2s.c  o  m*/

    //getListView().setSelector(R.drawable.transparent);
    lv.setCacheColorHint(Color.TRANSPARENT);

    // View management
    View detailsFrame = getActivity().findViewById(R.id.details);
    dualPane = detailsFrame != null && detailsFrame.getVisibility() == View.VISIBLE;

    if (savedInstanceState != null) {
        // Restore last state for checked position.
        curCheckPosition = savedInstanceState.getLong(CURRENT_CHOICE, SipProfile.INVALID_ID);
        //curCheckWizard = savedInstanceState.getString(CURRENT_WIZARD);
    }
    setListShown(false);
    if (mAdapter == null) {
        if (mHeaderView != null) {
            //  lv.addHeaderView(mHeaderView , null, true);//rangdong
        }
        mAdapter = new AccountsEditListAdapter(getActivity(), null);
        mAdapter.setOnCheckedRowListener(this);
        //getListView().setEmptyView(getActivity().findViewById(R.id.progress_container));
        //getActivity().findViewById(android.R.id.empty).setVisibility(View.GONE);
        setListAdapter(mAdapter);
        registerForContextMenu(lv);

        // Prepare the loader.  Either re-connect with an existing one,
        // or start a new one.
        getLoaderManager().initLoader(0, null, this);

        lv.setVerticalFadingEdgeEnabled(true);
    }

    if (dualPane) {
        // In dual-pane mode, the list view highlights the selected item.
        Log.d("lp", "dual pane mode");
        lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        //lv.setVerticalScrollbarPosition(View.SCROLLBAR_POSITION_LEFT);
        lv.setVerticalScrollBarEnabled(false);
        lv.setFadingEdgeLength(50);

        updateCheckedItem();
        // Make sure our UI is in the correct state.
        //showDetails(curCheckPosition, curCheckWizard);
    } else {
        //getListView().setVerticalScrollbarPosition(View.SCROLLBAR_POSITION_RIGHT);
        lv.setVerticalScrollBarEnabled(true);
        lv.setFadingEdgeLength(100);
    }

}

From source file:com.door43.translationstudio.RobotiumTests.java

public void test09ReadChapter() {
    act.waitForLoad();//from   w  w  w  .  j a  va 2 s  .c  om
    int title = R.id.translationNoteReferenceEditText;
    ArrayList<View> cvs;
    //ArrayList<EditText> etViews = solo.getCurrentViews(EditText.class);
    boolean isChapter = solo.waitForText("Chapter", 1, 30000);
    boolean isFrame = solo.waitForText("Frame", 1, 30000);
    boolean isTranslation = solo.waitForText("Afaraf: [Chapter 1]", 1, 30000);
    EditText et = (EditText) solo.getView(R.id.inputText);

    TextView tTitle = (TextView) solo.getView(R.id.translationTitleText);
    isTranslation = tTitle.getText().toString().endsWith("[Chapter 1]");

    assertTrue("Failed to find translation view.", isTranslation);
    assertNotNull("Could not find id.inputText", et);
    View pView = solo.getView(R.id.sourceTitleText);
    ArrayList<Button> btns = solo.getCurrentViews(Button.class);
    View cButton = solo.getView(R.id.contextual_menu_btn);
    assertTrue("Failed to find contextual menu button.", cButton.getVisibility() == View.VISIBLE);
    solo.clickOnView(cButton);
    solo.sleep(1000);
    solo.clickOnMenuItem("Read chapter");
    solo.sleep(1000);
    ArrayList<ListView> lvs = solo.getCurrentViews(ListView.class);
    TextView tv = solo.getText("Solomon was the father", true);
    assertNotNull("Unexpectedly found chapter", tv);
}