Example usage for android.view ViewGroup FOCUS_BLOCK_DESCENDANTS

List of usage examples for android.view ViewGroup FOCUS_BLOCK_DESCENDANTS

Introduction

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

Prototype

int FOCUS_BLOCK_DESCENDANTS

To view the source code for android.view ViewGroup FOCUS_BLOCK_DESCENDANTS.

Click Source Link

Document

This view will block any of its descendants from getting focus, even if they are focusable.

Usage

From source file:com.huewu.pla.lib.internal.PLAListView.java

/**
 * Indicates that the views created by the ListAdapter can contain focusable
 * items./*from www .j  a  va2 s  .  co m*/
 * 
 * @param itemsCanFocus true if items can get focus, false otherwise
 */
public void setItemsCanFocus(final boolean itemsCanFocus) {
    mItemsCanFocus = itemsCanFocus;
    if (!itemsCanFocus) {
        setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
    }
}

From source file:android.car.ui.provider.CarDrawerLayout.java

/**
 * Open the drawer view by animating it into view.
 *///from  www . j  a v  a  2s  .c  o m
public void openDrawer() {
    ViewGroup drawerView = (ViewGroup) findDrawerView();
    mStartedOpen = false;

    if (hasWindowFocus()) {
        int left;
        LayoutParams drawerLp = (LayoutParams) drawerView.getLayoutParams();
        if (checkDrawerViewAbsoluteGravity(drawerView, Gravity.LEFT)) {
            left = drawerLp.getMarginStart();
        } else {
            left = drawerLp.getMarginStart() + getWidth() - drawerView.getWidth();
        }
        mDragger.smoothSlideViewTo(drawerView, left, drawerView.getTop());
        dispatchOnDrawerOpening(drawerView);
    } else {
        final LayoutParams lp = (LayoutParams) drawerView.getLayoutParams();
        lp.onScreen = 1.f;
        dispatchOnDrawerOpened(drawerView);
    }

    ViewGroup contentView = (ViewGroup) findContentView();
    contentView.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
    drawerView.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);

    View focusable = drawerView.getChildAt(0);
    if (focusable != null) {
        focusable.requestFocus();
    }
    invalidate();
}

From source file:android.car.ui.provider.CarDrawerLayout.java

/**
 * Close the specified drawer view by animating it into view.
 *//*w  w  w  . ja  v  a  2 s. c  om*/
public void closeDrawer() {
    ViewGroup drawerView = (ViewGroup) findDrawerView();
    if (!isDrawerView(drawerView)) {
        throw new IllegalArgumentException("View " + drawerView + " is not a sliding drawer");
    }
    mStartedOpen = true;

    // Don't trigger the close drawer animation if drawer is not open.
    if (hasWindowFocus() && isDrawerOpen()) {
        int left;
        LayoutParams drawerLp = (LayoutParams) drawerView.getLayoutParams();
        if (checkDrawerViewAbsoluteGravity(drawerView, Gravity.LEFT)) {
            left = drawerLp.getMarginStart() - drawerView.getWidth();
        } else {
            left = drawerLp.getMarginStart() + getWidth();
        }
        mDragger.smoothSlideViewTo(drawerView, left, drawerView.getTop());
        dispatchOnDrawerClosing(drawerView);
    } else {
        final LayoutParams lp = (LayoutParams) drawerView.getLayoutParams();
        lp.onScreen = 0.f;
        dispatchOnDrawerClosed(drawerView);
    }

    ViewGroup contentView = (ViewGroup) findContentView();
    drawerView.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
    contentView.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);

    if (!isInTouchMode()) {
        List<View> focusables = contentView.getFocusables(FOCUS_DOWN);
        if (focusables.size() > 0) {
            View candidate = focusables.get(0);
            candidate.requestFocus();
        }
    }
    invalidate();
}

From source file:cc.flydev.launcher.Workspace.java

@Override
public int getDescendantFocusability() {
    if (isSmall()) {
        return ViewGroup.FOCUS_BLOCK_DESCENDANTS;
    }//from   w  ww .  j av  a2 s . c o m
    return super.getDescendantFocusability();
}

From source file:com.android.launcher3.Workspace.java

@Override
public int getDescendantFocusability() {
    if (workspaceInModalState()) {
        return ViewGroup.FOCUS_BLOCK_DESCENDANTS;
    }//from   ww w.j a  v a2 s. c  om
    return super.getDescendantFocusability();
}

From source file:org.mozilla.gecko.BrowserApp.java

@Override
public void onPropertyAnimationEnd() {
    if (!areTabsShown()) {
        mTabsPanel.setVisibility(View.INVISIBLE);
        mTabsPanel.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
        mRootLayout.setClosed();//  w w w. j a v a 2 s. c om
        mBrowserToolbar.setContextMenuEnabled(true);
    } else {
        // Cancel editing mode to return to page content when the TabsPanel closes. We cancel
        // it here because there are graphical glitches if it's canceled while it's visible.
        mBrowserToolbar.cancelEdit();
        mRootLayout.setOpen();
    }

    mTabsPanel.finishTabsAnimation();

    mMainLayoutAnimator = null;
}

From source file:org.bangbang.support.v4.widget.HListView.java

/**
     * Indicates that the views created by the ListAdapter can contain focusable
     * items./* ww w  . ja va 2  s. co m*/
     *
     * @param itemsCanFocus true if items can get focus, false otherwise
     */
    public void setItemsCanFocus(boolean itemsCanFocus) {
        mItemsCanFocus = itemsCanFocus;
        if (!itemsCanFocus) {
            setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
        }
    }