Example usage for android.view View addFocusables

List of usage examples for android.view View addFocusables

Introduction

In this page you can find the example usage for android.view View addFocusables.

Prototype

public void addFocusables(ArrayList<View> views, @FocusDirection int direction,
        @FocusableMode int focusableMode) 

Source Link

Document

Adds any focusable views that are descendants of this view (possibly including this view if it is focusable itself) to views.

Usage

From source file:com.aincc.libtest.activity.flip.FlipViewGroup.java

/**
 * We only want the current page that is being shown to be focusable.
 *//* ww  w .  j a v  a  2s  .co m*/
@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) {
                ItemInfo ii = infoForChild(child);
                if (ii != null && ii.position == currentItem) {
                    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 ||
    // No focusable descendants
            (focusableCount == views.size())) {
        // 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);
        }
    }
}

From source file:com.xiaosu.lib.base.widget.drawerLayout.DrawerLayout.java

@Override
public void addFocusables(ArrayList<View> views, int direction, int focusableMode) {
    if (getDescendantFocusability() == FOCUS_BLOCK_DESCENDANTS) {
        return;//from  w  w  w .j a  v a2  s  .  co  m
    }

    // Only the views in the open drawers are focusables. Add normal child views when
    // no drawers are opened.
    final int childCount = getChildCount();
    boolean isDrawerOpen = false;
    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);
        if (isDrawerView(child)) {
            if (isDrawerOpen()) {
                isDrawerOpen = true;
                child.addFocusables(views, direction, focusableMode);
            }
        } else {
            mNonDrawerViews.add(child);
        }
    }

    if (!isDrawerOpen) {
        final int nonDrawerViewsCount = mNonDrawerViews.size();
        for (int i = 0; i < nonDrawerViewsCount; ++i) {
            final View child = mNonDrawerViews.get(i);
            if (child.getVisibility() == View.VISIBLE) {
                child.addFocusables(views, direction, focusableMode);
            }
        }
    }

    mNonDrawerViews.clear();
}

From source file:com.jzh.stuapp.view.MyViewPager.java

/**
 * We only want the current page that is being shown to be focusable.
 *///from w w w.  j a v a 2s.c  om
@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) {
                ItemInfo ii = infoForChild(child);
                if (ii != null && ii.position == mCurItem) {
                    child.addFocusables(views, direction, focusableMode);
                }
            }
        }
    }

    if (descendantFocusability != FOCUS_AFTER_DESCENDANTS || (focusableCount == views.size())) {
        if (!isFocusable()) {
            return;
        }
        if ((focusableMode & FOCUSABLES_TOUCH_MODE) == FOCUSABLES_TOUCH_MODE && isInTouchMode()
                && !isFocusableInTouchMode()) {
            return;
        }
        if (views != null) {
            views.add(this);
        }
    }
}

From source file:com.yimeng.babymom.view.LazyViewPager.java

/**
 * We only want the current page that is being shown to be focusable.
 *//* w w  w  .j  a  v a  2  s.  com*/
@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) {
                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 ||
    // No focusable descendants
            (focusableCount == views.size())) {
        // 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;
        }
        views.add(this);
    }
}

From source file:tech.niuchuang.xzlibrary.ui.widget.LazyViewPager.java

/**
 * We only want the current page that is being shown to be focusable.
 *//*from  ww w.j  av a 2  s  .c  o m*/
@Override
public void addFocusables(ArrayList<View> views, int direction, int focusableMode) {
    if (views == null)
        return;
    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) {
                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 ||
    // No focusable descendants
            (focusableCount == views.size())) {
        // 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);
        }
    }
}

From source file:com.cnpeng.cnpeng_mydemosfrom2016_12.a_12_GetLocalFiles_VP_FM.CustomNoPreLoadViewPager.java

/**
 * We only want the current page that is being shown to be focusable.
 *///  w  ww .j  a va2 s  . c  o m
@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) {
                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 ||
    // No focusable descendants  
            (focusableCount == views.size())) {
        // 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);
        }
    }
}

From source file:com.oguzbabaoglu.cardpager.CardPager.java

/**
 * We only want the current page that is being shown to be focusable.
 *//* ww w.  jav a 2  s .  c  o m*/
@Override
public void addFocusables(@NonNull 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) {
                ItemInfo ii = infoForChild(child);
                if (ii != null && ii.position == currentItem) {
                    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())) {
        // 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;
        }
        views.add(this);
    }
}

From source file:com.chenglong.muscle.ui.LazyViewPager.java

/**
 * We only want the current page that is being shown to be focusable.
 *///from  www  . j  av  a 2  s .com
@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) {
                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 ||
    // No focusable descendants
            (focusableCount == views.size())) {
        // 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);
        }
    }
}

From source file:beichen.douban.ui.view.LazyViewPager.java

/**
 * We only want the current page that is being shown to be focusable.
 *//*from  w ww .  j a  va2  s  .c o  m*/
@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) {
                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 ||
    // No focusable descendants
            (focusableCount == views.size())) {
        // 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);
        }
    }
}

From source file:com.huangj.huangjlibrary.widget.drawerlayout.DrawerLayout.java

@Override
public void addFocusables(ArrayList<View> views, int direction, int focusableMode) {
    if (getDescendantFocusability() == FOCUS_BLOCK_DESCENDANTS) {
        return;//from   w ww . j  a v  a  2  s .co  m
    }

    // Only the views in the open drawers are focusables. Add normal child views when
    // no drawers are opened.
    final int childCount = getChildCount();
    boolean isDrawerOpen = false;
    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);
        if (isDrawerView(child)) {
            if (isDrawerOpen(child)) {
                isDrawerOpen = true;
                child.addFocusables(views, direction, focusableMode);
            }
        } else {
            mNonDrawerViews.add(child);
        }
    }

    if (!isDrawerOpen) {
        final int nonDrawerViewsCount = mNonDrawerViews.size();
        for (int i = 0; i < nonDrawerViewsCount; ++i) {
            final View child = mNonDrawerViews.get(i);
            if (child.getVisibility() == View.VISIBLE) {
                child.addFocusables(views, direction, focusableMode);
            }
        }
    }

    mNonDrawerViews.clear();
}