List of usage examples for android.view View getParent
public final ViewParent getParent()
From source file:Main.java
public static Activity findActivity(View view) { if (view == null) { return null; }//from ww w .jav a 2 s . c o m View targetView = view; while (true) { if (targetView.getContext() instanceof Activity) { return (Activity) targetView.getContext(); } if (!(targetView.getParent() instanceof View)) { return null; } targetView = (View) targetView.getParent(); } }
From source file:Main.java
public static void invalidateGlobalRegion(View view, RectF childBounds) { //childBounds.offset(view.getTranslationX(), view.getTranslationY()); if (DEBUG_INVALIDATE) Log.v(TAG, "-------------"); while (view.getParent() != null && view.getParent() instanceof View) { view = (View) view.getParent(); view.getMatrix().mapRect(childBounds); view.invalidate((int) Math.floor(childBounds.left), (int) Math.floor(childBounds.top), (int) Math.ceil(childBounds.right), (int) Math.ceil(childBounds.bottom)); if (DEBUG_INVALIDATE) { Log.v(TAG,/* w w w. jav a 2 s . c om*/ "INVALIDATE(" + (int) Math.floor(childBounds.left) + "," + (int) Math.floor(childBounds.top) + "," + (int) Math.ceil(childBounds.right) + "," + (int) Math.ceil(childBounds.bottom)); } } }
From source file:Main.java
public static void restoreAncestralClipping(@NonNull View view, List<Boolean> was) { if (view instanceof ViewGroup) { ViewGroup group = (ViewGroup) view; group.setClipChildren(was.remove(0)); }/*from w w w. j av a2s .c o m*/ ViewParent parent = view.getParent(); if (parent != null && parent instanceof ViewGroup) { restoreAncestralClipping((ViewGroup) parent, was); } }
From source file:Main.java
public static int getRelativeLeft(View myView) { // if (myView.getParent() == myView.getRootView()) if (myView.getId() == android.R.id.content) { return myView.getLeft(); } else {/*from w w w.j av a2 s. c om*/ return myView.getLeft() + getRelativeLeft((View) myView.getParent()); } }
From source file:com.jaspersoft.android.jaspermobile.test.utils.espresso.JasperMatcher.java
public static Matcher<View> childForPositionOf(final int position, final Matcher<View> parentMatcher) { return new TypeSafeMatcher<View>() { @Override/* w w w.j av a2 s.c om*/ public void describeTo(Description description) { description.appendText( "with child on position " + position + " of parent " + parentMatcher.toString()); } @Override public boolean matchesSafely(View view) { if (!(view.getParent() instanceof ViewGroup)) { return parentMatcher.matches(view.getParent()); } ViewGroup group = (ViewGroup) view.getParent(); if (parentMatcher.matches(view.getParent())) { int childCount = group.getChildCount(); if (position >= childCount) { throw new RuntimeException("Position '" + position + "' should be lower than child count '" + childCount + "'"); } return group.getChildAt(position).equals(view); } else { return false; } } }; }
From source file:com.grottworkshop.gwscirclereveal.animation.ViewAnimationUtils.java
/** * Returns an Animator which can animate a clipping circle. * <p>/*from w ww.ja v a 2 s .co m*/ * Any shadow cast by the View will respect the circular clip from this animator. * <p> * Only a single non-rectangular clip can be applied on a View at any time. * Views clipped by a circular reveal animation take priority over * {@link android.view.View#setClipToOutline(boolean) View Outline clipping}. * <p> * Note that the animation returned here is a one-shot animation. It cannot * be re-used, and once started it cannot be paused or resumed. * * @param view The View will be clipped to the animating circle. * @param centerX The x coordinate of the center of the animating circle. * @param centerY The y coordinate of the center of the animating circle. * @param startRadius The starting radius of the animating circle. * @param endRadius The ending radius of the animating circle. */ @TargetApi(Build.VERSION_CODES.LOLLIPOP) public static SupportAnimator createCircularReveal(View view, int centerX, int centerY, float startRadius, float endRadius) { if (!(view.getParent() instanceof RevealAnimator)) { throw new IllegalArgumentException("View must be inside RevealFrameLayout or RevealLinearLayout."); } RevealAnimator revealLayout = (RevealAnimator) view.getParent(); revealLayout.attachRevealInfo( new RevealAnimator.RevealInfo(centerX, centerY, startRadius, endRadius, new WeakReference<>(view))); if (LOLLIPOP_PLUS) { return new SupportAnimatorLollipop(android.view.ViewAnimationUtils.createCircularReveal(view, centerX, centerY, startRadius, endRadius), revealLayout); } ObjectAnimator reveal = ObjectAnimator.ofFloat(revealLayout, CLIP_RADIUS, startRadius, endRadius); reveal.addListener(getRevealFinishListener(revealLayout)); return new SupportAnimatorPreL(reveal, revealLayout); }
From source file:Main.java
public static void makeListViewWorkableInScollView(ListView lv) { lv.setOnTouchListener(new ListView.OnTouchListener() { @Override/*from www.j ava2s .c om*/ public boolean onTouch(View v, MotionEvent event) { int action = event.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: // Disallow ScrollView to intercept touch events. v.getParent().requestDisallowInterceptTouchEvent(true); break; case MotionEvent.ACTION_UP: // Allow ScrollView to intercept touch events. v.getParent().requestDisallowInterceptTouchEvent(false); break; } // Handle ListView touch events. v.onTouchEvent(event); return true; } }); }
From source file:com.agenmate.lollipop.util.ViewUtils.java
public static int getRelativeTop(View myView) { if (myView.getParent() == myView.getRootView()) { return myView.getTop(); } else {/*from ww w. ja v a 2s.c o m*/ return myView.getTop() + getRelativeTop((View) myView.getParent()); } }
From source file:Main.java
private static List<Boolean> setAncestralClipping(@NonNull View view, boolean clipChildren, List<Boolean> was) { if (view instanceof ViewGroup) { ViewGroup group = (ViewGroup) view; was.add(group.getClipChildren()); group.setClipChildren(clipChildren); }// w w w . j a va2s .c o m ViewParent parent = view.getParent(); if (parent != null && parent instanceof ViewGroup) { setAncestralClipping((ViewGroup) parent, clipChildren, was); } return was; }
From source file:cn.bingoogolapple.refreshlayout.util.BGARefreshScrollingUtil.java
public static BGAStickyNavLayout getStickyNavLayout(View view) { ViewParent viewParent = view.getParent(); while (viewParent != null) { if (viewParent instanceof BGAStickyNavLayout) { return (BGAStickyNavLayout) viewParent; }// ww w . j av a2 s .com viewParent = viewParent.getParent(); } return null; }