Example usage for android.view ViewParent getParent

List of usage examples for android.view ViewParent getParent

Introduction

In this page you can find the example usage for android.view ViewParent getParent.

Prototype

public ViewParent getParent();

Source Link

Document

Returns the parent if it exists, or null.

Usage

From source file:au.org.ala.fielddata.mobile.CollectSurveyData.java

public void scrollTo(final Attribute attribute) {
    pager.post(new Runnable() {
        public void run() {

            Binder binder = (Binder) surveyViewModel.getAttributeListener(attribute);
            View boundView = binder.getView();
            ViewParent parent = boundView.getParent();
            while (parent != null && !(parent instanceof ScrollView)) {
                parent = parent.getParent();
            }/*from   w  w  w . j  a  v  a2 s. co  m*/

            if (parent != null) {
                final ScrollView view = (ScrollView) parent;
                final Rect r = new Rect();

                view.offsetDescendantRectToMyCoords((View) boundView.getParent(), r);
                view.post(new Runnable() {
                    public void run() {
                        view.scrollTo(0, r.bottom);
                    }
                });

            }
        }
    });
}

From source file:com.github.shareme.gwsmaterialuikit.library.mscrollbar.MaterialScrollBar.java

void identifySwipeRefreshParents() {
    boolean cycle = true;
    ViewParent parent = getParent();
    while (cycle) {
        if (parent instanceof SwipeRefreshLayout) {
            swipeRefreshLayout = (SwipeRefreshLayout) parent;
            cycle = false;/* w ww  .  j  av  a 2  s  .c o  m*/
        } else {
            if (parent.getParent() == null) {
                cycle = false;
            } else {
                parent = parent.getParent();
            }
        }
    }
}

From source file:ti.modules.titanium.ui.widget.tableview.TiTableView.java

private TiBaseTableViewItem getParentTableViewItem(View view) {
    ViewParent parent = view.getParent();
    while (parent != null) {
        if (parent instanceof TiBaseTableViewItem) {
            return (TiBaseTableViewItem) parent;
        }//from   w  w  w  . j  a  v a  2  s  .c om
        parent = parent.getParent();
    }
    return null;
}

From source file:com.vuze.android.remote.fragment.TorrentListFragment.java

public static boolean isChildOf(View child, ViewGroup vg) {
    if (child == null || vg == null) {
        return false;
    }/*w  w w  .jav a  2 s  .  com*/
    ViewParent parent = child.getParent();
    while (parent != null) {
        if (parent == vg) {
            return true;
        }
        parent = parent.getParent();
    }
    return false;
}

From source file:net.qiujuer.genius.ui.widget.GeniusAbsSeekBar.java

private boolean isInScrollingContainer() {
    ViewParent p = getParent();
    while (p != null && p instanceof ViewGroup) {
        if (((ViewGroup) p).shouldDelayChildPressedState()) {
            return true;
        }/*w  ww  .jav  a 2  s  . co  m*/
        p = p.getParent();
    }
    return false;
}

From source file:com.nachiket.titan.LibraryActivity.java

private void setSearchBoxVisible(boolean visible) {
    mSearchBoxVisible = visible;//from  w  w  w .  ja  v a2 s . c o  m
    mSearchBox.setVisibility(visible ? View.VISIBLE : View.GONE);
    if (mControls != null) {
        mControls.setVisibility(
                visible || (mState & PlaybackService.FLAG_NO_MEDIA) != 0 ? View.GONE : View.VISIBLE);
    } else if (mActionControls != null) {
        // try to hide the bottom action bar
        ViewParent parent = mActionControls.getParent();
        if (parent != null)
            parent = parent.getParent();
        if (parent != null && parent instanceof ViewGroup) {
            ViewGroup ab = (ViewGroup) parent;
            if (ab.getChildCount() == 1) {
                ab.setVisibility(visible ? View.GONE : View.VISIBLE);
            }
        }
    }

    if (visible) {
        mTextFilter.requestFocus();
        ((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE)).showSoftInput(mTextFilter, 0);
    }
}

From source file:com.vuze.android.remote.fragment.TorrentListFragment.java

public static boolean childOrParentHasTag(View child, String tag) {
    if (child == null || tag == null) {
        return false;
    }//from  ww w  .  j  ava2s .  c om
    if (tag.equals(child.getTag())) {
        return true;
    }
    ViewParent parent = child.getParent();
    while (parent != null) {

        if ((parent instanceof View) && tag.equals(((View) parent).getTag())) {
            return true;
        }
        parent = parent.getParent();
    }
    return false;

}

From source file:org.catrobat.catroid.uitest.util.UiTestUtils.java

private static View greatGreatGrandParent(View view) {
    ViewParent parent = view.getParent();
    int i = 0;//from   w w  w  . jav  a2s . c  o m
    while (i < 3 && parent != null) {
        parent = parent.getParent();
        i++;
    }

    return (parent != null && parent instanceof View ? ((View) parent) : null);
}

From source file:com.facebook.litho.ComponentHost.java

@Override
public void requestLayout() {
    // Don't request a layout if it will be blocked by any parent. Requesting a layout that is
    // then ignored by an ancestor means that this host will remain in a state where it thinks that
    // it has requested layout, and will therefore ignore future layout requests. This will lead to
    // problems if a child (e.g. a ViewPager) requests a layout later on, since the request will be
    // wrongly ignored by this host.
    ViewParent parent = this;
    while (parent instanceof ComponentHost) {
        final ComponentHost host = (ComponentHost) parent;
        if (!host.shouldRequestLayout()) {
            return;
        }/*  w w w . j  a v  a2s.c o m*/

        parent = parent.getParent();
    }

    super.requestLayout();
}

From source file:com.zcolin.gui.zrecyclerview.swiperefreshlayout.SwipeRefreshLayout.java

@Override
protected void onAttachedToWindow() {
    super.onAttachedToWindow();
    //CollapsingToolbarLayout?
    AppBarLayout appBarLayout = null;/*from w w w.  j ava2 s  . co  m*/
    ViewParent p = getParent();
    while (p != null) {
        if (p instanceof CoordinatorLayout) {
            break;
        }
        p = p.getParent();
    }

    if (p != null) {
        CoordinatorLayout coordinatorLayout = (CoordinatorLayout) p;
        final int childCount = coordinatorLayout.getChildCount();
        for (int i = childCount - 1; i >= 0; i--) {
            final View child = coordinatorLayout.getChildAt(i);
            if (child instanceof AppBarLayout) {
                appBarLayout = (AppBarLayout) child;
                break;
            }
        }
        if (appBarLayout != null) {
            appBarLayout.addOnOffsetChangedListener(new AppBarStateChangeListener() {
                @Override
                public void onStateChanged(AppBarLayout appBarLayout, State state) {
                    appbarState = state;
                }
            });
        }
    }
}