Java Code Examples for android.view.ViewParent

The following are top voted examples for showing how to use android.view.ViewParent. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: CodeCompilerApp   File: ViewUtils.java   Source Code and License 7 votes vote down vote up
/**
 * Recursive helper method that applies transformations in post-order.
 *
 * @param ev the on-screen motion event
 */
private static void transformMotionEventToLocal(@NonNull View view, @NonNull MotionEvent ev) {
    final ViewParent parent = view.getParent();
    if (parent instanceof View) {
        final View vp = (View) parent;
        transformMotionEventToLocal(vp, ev);
        ev.offsetLocation(vp.getScrollX(), vp.getScrollY());
    } // TODO: Use reflections to access ViewRootImpl
    // else if (parent instanceof ViewRootImpl) {
    //    final ViewRootImpl vr = (ViewRootImpl) parent;
    //    ev.offsetLocation(0, vr.mCurScrollY);
    // }

    ev.offsetLocation(-view.getLeft(), -view.getTop());

    Matrix matrix = view.getMatrix();
    if (matrix != null) {
        ev.transform(matrix);
    }
}
 
Example 2
Project: switchbutton   File: FTouchHelper.java   Source Code and License 7 votes vote down vote up
/**
 * 是否请求当前view的父view不要拦截事件
 *
 * @param view
 * @param disallowIntercept true-请求父view不要拦截,false-父view可以拦截
 */
public static void requestDisallowInterceptTouchEvent(View view, boolean disallowIntercept)
{
    ViewParent parent = view.getParent();
    if (parent == null)
    {
        return;
    }
    parent.requestDisallowInterceptTouchEvent(disallowIntercept);
}
 
Example 3
Project: HeroVideo-master   File: BannerAdapter.java   Source Code and License 6 votes vote down vote up
@Override
public Object instantiateItem(ViewGroup container, int position)
{

    //对ViewPager页号求模取出View列表中要显示的项
    position %= mList.size();
    if (position < 0)
    {
        position = mList.size() + position;
    }
    ImageView v = mList.get(position);
    pos = position;
    v.setScaleType(ImageView.ScaleType.CENTER);
    //如果View已经在之前添加到了一个父组件,则必须先remove,否则会抛出IllegalStateException。
    ViewParent vp = v.getParent();
    if (vp != null)
    {
        ViewGroup parent = (ViewGroup) vp;
        parent.removeView(v);
    }
    v.setOnClickListener(v1 -> {

        if (mViewPagerOnItemClickListener != null)
        {
            mViewPagerOnItemClickListener.onItemClick();
        }
    });


    container.addView(v);
    return v;
}
 
Example 4
Project: ClouldReader   File: PhotoViewAttacher.java   Source Code and License 6 votes vote down vote up
@Override
public void onDrag(float dx, float dy) {
    if (mScaleDragDetector.isScaling()) {
        return; // Do not drag if we are already scaling
    }

    if (DEBUG) {
        LogManager.getLogger().d(LOG_TAG,
                String.format("onDrag: dx: %.2f. dy: %.2f", dx, dy));
    }

    ImageView imageView = getImageView();
    mSuppMatrix.postTranslate(dx, dy);
    checkAndDisplayMatrix();

    /**
     * Here we decide whether to let the ImageView's parent to start taking
     * over the touch event.
     *
     * First we check whether this function is enabled. We never want the
     * parent to take over if we're scaling. We then check the edge we're
     * on, and the direction of the scroll (i.e. if we're pulling against
     * the edge, aka 'overscrolling', let the parent take over).
     */
    ViewParent parent = imageView.getParent();
    if (mAllowParentInterceptOnEdge && !mScaleDragDetector.isScaling() && !mBlockParentIntercept) {
        if (mScrollEdge == EDGE_BOTH
                || (mScrollEdge == EDGE_LEFT && dx >= 1f)
                || (mScrollEdge == EDGE_RIGHT && dx <= -1f)) {
            if (null != parent) {
                parent.requestDisallowInterceptTouchEvent(false);
            }
        }
    } else {
        if (null != parent) {
            parent.requestDisallowInterceptTouchEvent(true);
        }
    }
}
 
Example 5
Project: boohee_v5.6   File: ExploreByTouchHelper.java   Source Code and License 6 votes vote down vote up
private boolean intersectVisibleToUser(Rect localRect) {
    if (localRect == null || localRect.isEmpty() || this.mView.getWindowVisibility() != 0) {
        return false;
    }
    ViewParent viewParent = this.mView.getParent();
    while (viewParent instanceof View) {
        View view = (View) viewParent;
        if (ViewCompat.getAlpha(view) <= 0.0f || view.getVisibility() != 0) {
            return false;
        }
        viewParent = view.getParent();
    }
    if (viewParent == null || !this.mView.getLocalVisibleRect(this.mTempVisibleRect)) {
        return false;
    }
    return localRect.intersect(this.mTempVisibleRect);
}
 
Example 6
Project: q-mail   File: NonLockingScrollView.java   Source Code and License 6 votes vote down vote up
@Override
public void requestChildFocus(View child, View focused) {
    /*
     * Normally a ScrollView will scroll the child into view.
     * Prevent this when a MessageWebView is first touched,
     * assuming it already is at least partially in view.
     * 
     */
    if (mSkipWebViewScroll  &&
            focused instanceof MessageWebView &&
            focused.getGlobalVisibleRect(new Rect())) {
        mSkipWebViewScroll = false;
        super.requestChildFocus(child, child);
        ViewParent parent = getParent();
        if (parent != null) {
            parent.requestChildFocus(this, focused);
        }
    } else {
        super.requestChildFocus(child, focused);
    }
}
 
Example 7
Project: RNLearn_Project1   File: NativeViewHierarchyManager.java   Source Code and License 6 votes vote down vote up
public void setJSResponder(int reactTag, int initialReactTag, boolean blockNativeResponder) {
  if (!blockNativeResponder) {
    mJSResponderHandler.setJSResponder(initialReactTag, null);
    return;
  }

  View view = mTagsToViews.get(reactTag);
  if (initialReactTag != reactTag && view instanceof ViewParent) {
    // In this case, initialReactTag corresponds to a virtual/layout-only View, and we already
    // have a parent of that View in reactTag, so we can use it.
    mJSResponderHandler.setJSResponder(initialReactTag, (ViewParent) view);
    return;
  }

  if (mRootTags.get(reactTag)) {
    SoftAssertions.assertUnreachable(
        "Cannot block native responder on " + reactTag + " that is a root view");
  }
  mJSResponderHandler
      .setJSResponder(initialReactTag, view.getParent());
}
 
Example 8
Project: letv   File: ExploreByTouchHelper.java   Source Code and License 6 votes vote down vote up
private boolean intersectVisibleToUser(Rect localRect) {
    if (localRect == null || localRect.isEmpty() || this.mView.getWindowVisibility() != 0) {
        return false;
    }
    ViewParent viewParent = this.mView.getParent();
    while (viewParent instanceof View) {
        View view = (View) viewParent;
        if (ViewCompat.getAlpha(view) <= 0.0f || view.getVisibility() != 0) {
            return false;
        }
        viewParent = view.getParent();
    }
    if (viewParent == null || !this.mView.getLocalVisibleRect(this.mTempVisibleRect)) {
        return false;
    }
    return localRect.intersect(this.mTempVisibleRect);
}
 
Example 9
Project: Blockly   File: WorkspaceHelper.java   Source Code and License 6 votes vote down vote up
/**
 * Get virtual view coordinates of a given {@link View}.
 * <p/>
 * This function always returns the coordinate of the top-left corner of the given view,
 * regardless of left-to-right (LTR) vs. right-to-left (RTL) mode. Note that in RTL mode, this
 * is not the corner that corresponds to the block's workspace coordinates. Use
 * {@link #getWorkspaceCoordinates(View, WorkspacePoint)} to obtain  the workspace coordinates
 * of a block from its view, adjusted for RTL mode if necessary.
 *
 * @param view The view to find the position of.
 * @param viewPosition The Point to store the results in.
 */
public void getVirtualViewCoordinates(View view, ViewPoint viewPosition) {
    int leftRelativeToWorkspace = view.getLeft();
    int topRelativeToWorkspace = view.getTop();

    // Move up the parent hierarchy and add parent-relative view coordinates.
    ViewParent viewParent = view.getParent();
    while (viewParent != null) {
        if (viewParent instanceof WorkspaceView || viewParent instanceof RecyclerView) {
            break;
        }

        leftRelativeToWorkspace += ((View) viewParent).getLeft();
        topRelativeToWorkspace += ((View) viewParent).getTop();

        viewParent = viewParent.getParent();
    }

    if (viewParent == null) {
        throw new IllegalStateException(
                "No WorkspaceView or RecyclerView found among view's parents.");
    }

    viewPosition.x = leftRelativeToWorkspace;
    viewPosition.y = topRelativeToWorkspace;
}
 
Example 10
Project: boohee_v5.6   File: SlidingPaneLayout.java   Source Code and License 6 votes vote down vote up
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
    AccessibilityNodeInfoCompat superNode = AccessibilityNodeInfoCompat.obtain(info);
    super.onInitializeAccessibilityNodeInfo(host, superNode);
    copyNodeInfoNoChildren(info, superNode);
    superNode.recycle();
    info.setClassName(SlidingPaneLayout.class.getName());
    info.setSource(host);
    ViewParent parent = ViewCompat.getParentForAccessibility(host);
    if (parent instanceof View) {
        info.setParent((View) parent);
    }
    int childCount = SlidingPaneLayout.this.getChildCount();
    for (int i = 0; i < childCount; i++) {
        View child = SlidingPaneLayout.this.getChildAt(i);
        if (!filter(child) && child.getVisibility() == 0) {
            ViewCompat.setImportantForAccessibility(child, 1);
            info.addChild(child);
        }
    }
}
 
Example 11
Project: boohee_v5.6   File: PullToRefreshAdapterViewBase.java   Source Code and License 6 votes vote down vote up
public final void setEmptyView(View newEmptyView) {
    FrameLayout refreshableViewWrapper = getRefreshableViewWrapper();
    if (newEmptyView != null) {
        newEmptyView.setClickable(true);
        ViewParent newEmptyViewParent = newEmptyView.getParent();
        if (newEmptyViewParent != null && (newEmptyViewParent instanceof ViewGroup)) {
            ((ViewGroup) newEmptyViewParent).removeView(newEmptyView);
        }
        LayoutParams lp = convertEmptyViewLayoutParams(newEmptyView.getLayoutParams());
        if (lp != null) {
            refreshableViewWrapper.addView(newEmptyView, lp);
        } else {
            refreshableViewWrapper.addView(newEmptyView);
        }
    }
    if (this.mRefreshableView instanceof EmptyViewMethodAccessor) {
        ((EmptyViewMethodAccessor) this.mRefreshableView).setEmptyViewInternal(newEmptyView);
    } else {
        ((AbsListView) this.mRefreshableView).setEmptyView(newEmptyView);
    }
    this.mEmptyView = newEmptyView;
}
 
Example 12
Project: LiveNotes   File: SeeScoreView.java   Source Code and License 6 votes vote down vote up
private void scrollToBar(int barIndex, int autoScrollAnimationTime) {
    ViewParent parentView = getParent();
    if (parentView instanceof ScrollView) {
        final ScrollView parentScrollView = (ScrollView) parentView;
        for (View view : views) {
            if (view instanceof SystemView
                    && view.isShown()) {
                SystemView systemView = (SystemView) view;
                if (systemView.containsBar(barIndex)) {
                    int scroll_max = getBottom() - parentScrollView.getHeight();
                    int scroll_min = 0;
                    float windowHeight = parentScrollView.getHeight();
                    float windowPlayingCentre = kWindowPlayingCentreFractionFromTop * windowHeight;
                    float sysFrac = systemView.fractionalScroll(barIndex);
                    float playingCentre = view.getTop() + view.getHeight() * sysFrac;
                    float scroll_y = playingCentre - windowPlayingCentre;

                    if (scroll_y < scroll_min)
                        scroll_y = scroll_min;
                    else if (scroll_y > scroll_max)
                        scroll_y = scroll_max;
                    slowSmoothScrollTo(parentScrollView, (int) scroll_y, autoScrollAnimationTime);
                }
            }
        }
    }
}
 
Example 13
Project: frogment   File: KeepingFragmentStateTest.java   Source Code and License 6 votes vote down vote up
private static Matcher<View> childAtPosition(
        final Matcher<View> parentMatcher, final int position) {

    return new TypeSafeMatcher<View>() {
        @Override
        public void describeTo(Description description) {
            description.appendText("Child at position " + position + " in parent ");
            parentMatcher.describeTo(description);
        }

        @Override
        public boolean matchesSafely(View view) {
            ViewParent parent = view.getParent();
            return parent instanceof ViewGroup && parentMatcher.matches(parent)
                    && view.equals(((ViewGroup) parent).getChildAt(position));
        }
    };
}
 
Example 14
Project: weex-uikit   File: WXEditText.java   Source Code and License 6 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent event) {
  boolean result = super.onTouchEvent(event);
  if (wxGesture != null) {
    result |= wxGesture.onTouch(this, event);
  }

  ViewParent parent = getParent();
  if(parent != null){
    switch (event.getAction() & MotionEvent.ACTION_MASK){
      case MotionEvent.ACTION_DOWN:
        if(mLines < getLineCount()) {
          //scrollable
          parent.requestDisallowInterceptTouchEvent(true);
        }
        break;
      case MotionEvent.ACTION_UP:
      case MotionEvent.ACTION_CANCEL:
        parent.requestDisallowInterceptTouchEvent(false);
        break;
    }
  }
  return result;
}
 
Example 15
Project: MathView   File: MainActivityTest.java   Source Code and License 6 votes vote down vote up
private static Matcher<View> childAtPosition(
  final Matcher<View> parentMatcher, final int position
) {

  return new TypeSafeMatcher<View>() {
    @Override
    public void describeTo(Description description) {
      description.appendText("Child at position " + position + " in parent ");
      parentMatcher.describeTo(description);
    }

    @Override
    public boolean matchesSafely(View view) {
      ViewParent parent = view.getParent();
      return parent instanceof ViewGroup && parentMatcher.matches(parent)
        && view.equals(((ViewGroup) parent).getChildAt(position));
    }
  };
}
 
Example 16
Project: letv   File: DrawerLayout.java   Source Code and License 6 votes vote down vote up
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
    if (DrawerLayout.CAN_HIDE_DESCENDANTS) {
        super.onInitializeAccessibilityNodeInfo(host, info);
    } else {
        AccessibilityNodeInfoCompat superNode = AccessibilityNodeInfoCompat.obtain(info);
        super.onInitializeAccessibilityNodeInfo(host, superNode);
        info.setSource(host);
        ViewParent parent = ViewCompat.getParentForAccessibility(host);
        if (parent instanceof View) {
            info.setParent((View) parent);
        }
        copyNodeInfoNoChildren(info, superNode);
        superNode.recycle();
        addChildrenForAccessibility(info, (ViewGroup) host);
    }
    info.setClassName(DrawerLayout.class.getName());
    info.setFocusable(false);
    info.setFocused(false);
    info.removeAction(AccessibilityActionCompat.ACTION_FOCUS);
    info.removeAction(AccessibilityActionCompat.ACTION_CLEAR_FOCUS);
}
 
Example 17
Project: TitleBarView   File: ViewUtil.java   Source Code and License 6 votes vote down vote up
/**
 * 设置View的Margin
 *
 * @param view
 * @param left
 * @param top
 * @param right
 * @param bottom
 * @param width
 * @param height
 */
public void setViewMargin(View view, int left, int top, int right, int bottom, int width, int height) {
    if (view == null) {
        return;
    }
    ViewParent parent = view.getParent();
    if (parent == null) {
        return;
    }
    ViewGroup.MarginLayoutParams lp;
    if (parent instanceof LinearLayout) {
        lp = new LinearLayout.LayoutParams(width, height);
    } else if (parent instanceof RelativeLayout) {
        lp = new RelativeLayout.LayoutParams(width, height);
    } else if (parent instanceof FrameLayout) {
        lp = new FrameLayout.LayoutParams(width, height);
    } else {
        lp = new TableLayout.LayoutParams(width, height);
    }
    if (lp != null) {
        lp.setMargins(left, top, right, bottom);
        view.setLayoutParams(lp);
    }
}
 
Example 18
Project: Discover   File: JZVideoPlayer.java   Source Code and License 6 votes vote down vote up
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
    Log.i(TAG, "bottomProgress onStopTrackingTouch [" + this.hashCode() + "] ");
    onEvent(JZUserAction.ON_SEEK_POSITION);
    startProgressTimer();
    ViewParent vpup = getParent();
    while (vpup != null) {
        vpup.requestDisallowInterceptTouchEvent(false);
        vpup = vpup.getParent();
    }
    if (currentState != CURRENT_STATE_PLAYING &&
            currentState != CURRENT_STATE_PAUSE) return;
    long time = seekBar.getProgress() * getDuration() / 100;
    JZMediaManager.seekTo(time);
    Log.i(TAG, "seekTo " + time + " [" + this.hashCode() + "] ");
}
 
Example 19
Project: BilibiliClient   File: BannerAdapter.java   Source Code and License 6 votes vote down vote up
@Override
public Object instantiateItem(ViewGroup container, int position) {

  //对ViewPager页号求模取出View列表中要显示的项
  position %= mList.size();
  if (position < 0) {
    position = mList.size() + position;
  }
  ImageView v = mList.get(position);
  pos = position;
  v.setScaleType(ImageView.ScaleType.CENTER);
  //如果View已经在之前添加到了一个父组件,则必须先remove,否则会抛出IllegalStateException。
  ViewParent vp = v.getParent();
  if (vp != null) {
    ViewGroup parent = (ViewGroup) vp;
    parent.removeView(v);
  }
  v.setOnClickListener(v1 -> {

    if (mViewPagerOnItemClickListener != null) {
      mViewPagerOnItemClickListener.onItemClick();
    }
  });

  container.addView(v);
  return v;
}
 
Example 20
Project: BilibiliClient   File: BannerAdapter.java   Source Code and License 6 votes vote down vote up
@Override
public Object instantiateItem(ViewGroup container, int position) {

  //对ViewPager页号求模取出View列表中要显示的项
  position %= mList.size();
  if (position < 0) {
    position = mList.size() + position;
  }
  ImageView v = mList.get(position);
  pos = position;
  v.setScaleType(ImageView.ScaleType.CENTER);
  //如果View已经在之前添加到了一个父组件,则必须先remove,否则会抛出IllegalStateException。
  ViewParent vp = v.getParent();
  if (vp != null) {
    ViewGroup parent = (ViewGroup) vp;
    parent.removeView(v);
  }
  v.setOnClickListener(v1 -> {

    if (mViewPagerOnItemClickListener != null) {
      mViewPagerOnItemClickListener.onItemClick();
    }
  });

  container.addView(v);
  return v;
}
 
Example 21
Project: SimpleUILauncher   File: BubbleTextView.java   Source Code and License 6 votes vote down vote up
void setStayPressed(boolean stayPressed) {
    mStayPressed = stayPressed;
    if (!stayPressed) {
        HolographicOutlineHelper.obtain(getContext()).recycleShadowBitmap(mPressedBackground);
        mPressedBackground = null;
    } else {
        if (mPressedBackground == null) {
            mPressedBackground = mOutlineHelper.createMediumDropShadow(this);
        }
    }

    // Only show the shadow effect when persistent pressed state is set.
    ViewParent parent = getParent();
    if (parent != null && parent.getParent() instanceof BubbleTextShadowHandler) {
        ((BubbleTextShadowHandler) parent.getParent()).setPressedIcon(
                this, mPressedBackground);
    }

    updateIconState();
}
 
Example 22
Project: Sega   File: SearchView.java   Source Code and License 6 votes vote down vote up
private void getMenuItemPosition(int menuItemId) {
    if (mMenuItemView != null) {
        mMenuItemCx = getCenterX(mMenuItemView);
    }
    ViewParent viewParent = getParent();
    while (viewParent != null && viewParent instanceof View) {
        View parent = (View) viewParent;
        View view = parent.findViewById(menuItemId);
        if (view != null) {
            mMenuItemView = view;
            mMenuItemCx = getCenterX(mMenuItemView);
            break;
        }
        viewParent = viewParent.getParent();
    }
}
 
Example 23
Project: AndroidSkinAnimator   File: SkinCompatDelegate.java   Source Code and License 6 votes vote down vote up
private boolean shouldInheritContext(ViewParent parent) {
    if (parent == null) {
        // The initial parent is null so just return false
        return false;
    }
    final View windowDecor = mAppCompatActivity.getWindow().getDecorView();
    while (true) {
        if (parent == null) {
            // Bingo. We've hit a view which has a null parent before being terminated from
            // the loop. This is (most probably) because it's the root view in an inflation
            // call, therefore we should inherit. This works as the inflated layout is only
            // added to the hierarchy at the end of the inflate() call.
            return true;
        } else if (parent == windowDecor || !(parent instanceof View)
                || ViewCompat.isAttachedToWindow((View) parent)) {
            // We have either hit the window's decor view, a parent which isn't a View
            // (i.e. ViewRootImpl), or an attached view, so we know that the original parent
            // is currently added to the view hierarchy. This means that it has not be
            // inflated in the current inflate() call and we should not inherit the context.
            return false;
        }
        parent = parent.getParent();
    }
}
 
Example 24
Project: SimpleUILauncher   File: UserEventDispatcher.java   Source Code and License 6 votes vote down vote up
/**
 * Recursively finds the parent of the given child which implements IconLogInfoProvider
 */
public static LaunchSourceProvider getLaunchProviderRecursive(View v) {
    ViewParent parent = null;

    if (v != null) {
        parent = v.getParent();
    } else {
        return null;
    }

    // Optimization to only check up to 5 parents.
    int count = MAXIMUM_VIEW_HIERARCHY_LEVEL;
    while (parent != null && count-- > 0) {
        if (parent instanceof LaunchSourceProvider) {
            return (LaunchSourceProvider) parent;
        } else {
            parent = parent.getParent();
        }
    }
    return null;
}
 
Example 25
Project: TurboChat   File: MessageActivityWriteMessageTest.java   Source Code and License 6 votes vote down vote up
private static Matcher<View> childAtPosition(
        final Matcher<View> parentMatcher, final int position) {

    return new TypeSafeMatcher<View>() {
        @Override
        public void describeTo(Description description) {
            description.appendText("Child at position " + position + " in parent ");
            parentMatcher.describeTo(description);
        }

        @Override
        public boolean matchesSafely(View view) {
            ViewParent parent = view.getParent();
            return parent instanceof ViewGroup && parentMatcher.matches(parent)
                    && view.equals(((ViewGroup) parent).getChildAt(position));
        }
    };
}
 
Example 26
Project: Froggy   File: HolderPresenter.java   Source Code and License 6 votes vote down vote up
public void onClick(View v){
    ViewParent parent = v.getParent();
    if (parent instanceof RecyclerView){
        Context context = ((RecyclerView) parent).getContext();

        String text = "onClick: " + model().getPosition() + " position\n" +
                "Position: " + model().getPosition() + "\n" +
                "Presenter hash code: " + this.hashCode() + "\n" +
                "ViewHolder hash code: " + view().hashCode();
        if(context instanceof MainActivity){
            ((MainActivity) context).updateText(text);
        }

    }

}
 
Example 27
Project: TestChat   File: ShareMessageFragment.java   Source Code and License 6 votes vote down vote up
@Override
public void onCommentItemClick(View view, String id, int shareMessagePosition, int position, String replyUser) {
        LogUtil.e("位置" + shareMessagePosition);
        currentPosition = shareMessagePosition;
        currentCommentPosition = position;
        ViewParent viewParent = view.getParent();
        if (viewParent != null) {
                ViewGroup parent = (ViewGroup) viewParent;
                commentItemOffset += parent.getHeight() - view.getBottom();
                if (parent.getParent() != null) {
                        ViewGroup rootParent = (ViewGroup) parent.getParent();
                        commentItemOffset += rootParent.getHeight() + parent.getBottom();
                }
        }
        this.replyUid = replyUser;
        dealBottomView(true);
}
 
Example 28
Project: aos-MediaLib   File: OrientableSeekBar.java   Source Code and License 5 votes vote down vote up
public boolean isInScrollingContainer() {
    ViewParent p = getParent();
    while (p != null && p instanceof ViewGroup) {
        if (((ViewGroup) p).shouldDelayChildPressedState()) {
            return true;
        }
        p = p.getParent();
    }
    return false;
}
 
Example 29
Project: https-github.com-hyb1996-NoRootScriptDroid   File: ViewUtils.java   Source Code and License 5 votes vote down vote up
public static View findParentById(View view, int id) {
    ViewParent parent = view.getParent();
    if (parent == null || !(parent instanceof View))
        return null;
    View viewParent = (View) parent;
    if (viewParent.getId() == id) {
        return viewParent;
    }
    return findParentById(viewParent, id);
}
 
Example 30
Project: diycode   File: PositionAnimExpectationRightOfParent.java   Source Code and License 5 votes vote down vote up
@Override
public Float getCalculatedValueX(View viewToMove) {
    final ViewParent viewParent = viewToMove.getParent();
    if((viewParent instanceof View)){
        final View parentView = (View)viewParent;
        return parentView.getWidth() - getMargin(viewToMove) - viewCalculator.finalWidthOfView(viewToMove);
    }
    return null;
}
 
Example 31
Project: AutoRecycleView   File: SuperSwipeRefreshLayout.java   Source Code and License 5 votes vote down vote up
private void requestParentDisallowInterceptTouchEvent(boolean disallowIntercept) {
    Log.i(LOG_TAG, "requestParentDisallowInterceptTouchEvent");
    final ViewParent parent = getParent();
    if (parent != null) {
        parent.requestDisallowInterceptTouchEvent(disallowIntercept);
    }
}
 
Example 32
Project: Views   File: SwipeLayout.java   Source Code and License 5 votes vote down vote up
private boolean performAdapterViewItemLongClick() {
    if (getOpenStatus() != Status.Close) return false;
    ViewParent t = getParent();
    if (t instanceof AdapterView) {
        AdapterView view = (AdapterView) t;
        int p = view.getPositionForView(SwipeLayout.this);
        if (p == AdapterView.INVALID_POSITION) return false;
        long vId = view.getItemIdAtPosition(p);
        boolean handled = false;
        try {
            Method m = AbsListView.class.getDeclaredMethod("performLongPress", View.class, int.class, long.class);
            m.setAccessible(true);
            handled = (boolean) m.invoke(view, SwipeLayout.this, p, vId);

        } catch (Exception e) {
            e.printStackTrace();

            if (view.getOnItemLongClickListener() != null) {
                handled = view.getOnItemLongClickListener().onItemLongClick(view, SwipeLayout.this, p, vId);
            }
            if (handled) {
                view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
            }
        }
        return handled;
    }
    return false;
}
 
Example 33
Project: EosCommander   File: TextInputAutoCompleteTextView.java   Source Code and License 5 votes vote down vote up
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
    final InputConnection ic = super.onCreateInputConnection(outAttrs);
    if (ic != null && outAttrs.hintText == null) {
        // If we don't have a hint and our parent is a TextInputLayout, use it's hint for the
        // EditorInfo. This allows us to display a hint in 'extract mode'.
        final ViewParent parent = getParent();
        if (parent instanceof TextInputLayout) {
            outAttrs.hintText = ((TextInputLayout) parent).getHint();
        }
    }
    return ic;
}
 
Example 34
Project: superglue   File: DebugDrawerLayout.java   Source Code and License 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
  if (CAN_HIDE_DESCENDANTS) {
    super.onInitializeAccessibilityNodeInfo(host, info);
  } else {
    // Obtain a node for the host, then manually generate the list
    // of children to only include non-obscured views.
    final AccessibilityNodeInfoCompat superNode =
        AccessibilityNodeInfoCompat.obtain(info);
    super.onInitializeAccessibilityNodeInfo(host, superNode);

    info.setSource(host);
    final ViewParent parent = ViewCompat.getParentForAccessibility(host);
    if (parent instanceof View) {
      info.setParent((View) parent);
    }
    copyNodeInfoNoChildren(info, superNode);
    superNode.recycle();

    addChildrenForAccessibility(info, (ViewGroup) host);
  }

  info.setClassName(DebugDrawerLayout.class.getName());

  // This view reports itself as focusable so that it can intercept
  // the back button, but we should prevent this view from reporting
  // itself as focusable to accessibility services.
  info.setFocusable(false);
  info.setFocused(false);
}
 
Example 35
Project: CoordinatorLayoutExample-master   File: ViewOffsetHelper.java   Source Code and License 5 votes vote down vote up
private void updateOffsets() {
    ViewCompat.offsetTopAndBottom(mView, mOffsetTop - (mView.getTop() - mLayoutTop));
    ViewCompat.offsetLeftAndRight(mView, mOffsetLeft - (mView.getLeft() - mLayoutLeft));

    // Manually invalidate the view and parent to make sure we get drawn pre-M
    if (Build.VERSION.SDK_INT < 23) {
        tickleInvalidationFlag(mView);
        final ViewParent vp = mView.getParent();
        if (vp instanceof View) {
            tickleInvalidationFlag((View) vp);
        }
    }
}
 
Example 36
Project: GitHub   File: ContentScrollView.java   Source Code and License 5 votes vote down vote up
@Override
protected void onAttachedToWindow() {
    super.onAttachedToWindow();
    ViewParent parent = this.getParent();
    while (parent != null) {
        if (parent instanceof ScrollLayout) {
            ((ScrollLayout) parent).setAssociatedScrollView(this);
            break;
        }
        parent = parent.getParent();
    }
}
 
Example 37
Project: boohee_v5.6   File: SwipeDismissBehavior.java   Source Code and License 5 votes vote down vote up
public void onViewCaptured(View capturedChild, int activePointerId) {
    this.mOriginalCapturedViewLeft = capturedChild.getLeft();
    ViewParent parent = capturedChild.getParent();
    if (parent != null) {
        parent.requestDisallowInterceptTouchEvent(true);
    }
}
 
Example 38
Project: boohee_v5.6   File: NestedScrollView.java   Source Code and License 5 votes vote down vote up
private static boolean isViewDescendantOf(View child, View parent) {
    if (child == parent) {
        return true;
    }
    ViewParent theParent = child.getParent();
    if ((theParent instanceof ViewGroup) && isViewDescendantOf((View) theParent, parent)) {
        return true;
    }
    return false;
}
 
Example 39
Project: YCUtils   File: MaterialRippleLayout.java   Source Code and License 5 votes vote down vote up
private boolean isInScrollingContainer() {
    ViewParent p = getParent();
    while (p != null && p instanceof ViewGroup) {
        if (((ViewGroup) p).shouldDelayChildPressedState()) {
            return true;
        }
        p = p.getParent();
    }
    return false;
}
 
Example 40
Project: PicShow-zhaipin   File: JCVideoPlayer.java   Source Code and License 5 votes vote down vote up
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
    Log.i(TAG, "bottomProgress onStartTrackingTouch [" + this.hashCode() + "] ");
    cancelProgressTimer();
    ViewParent vpdown = getParent();
    while (vpdown != null) {
        vpdown.requestDisallowInterceptTouchEvent(true);
        vpdown = vpdown.getParent();
    }
}