Java 类android.view.ViewParent 实例源码

项目:CodeCompilerApp    文件:ViewUtils.java   
/**
 * 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);
    }
}
项目:HeroVideo-master    文件:BannerAdapter.java   
@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;
}
项目:ClouldReader    文件:PhotoViewAttacher.java   
@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);
        }
    }
}
项目:boohee_v5.6    文件:ExploreByTouchHelper.java   
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);
}
项目:q-mail    文件:NonLockingScrollView.java   
@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);
    }
}
项目:RNLearn_Project1    文件:NativeViewHierarchyManager.java   
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());
}
项目:letv    文件:ExploreByTouchHelper.java   
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);
}
项目:switchbutton    文件:FTouchHelper.java   
/**
 * 是否请求当前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);
}
项目:Blockly    文件:WorkspaceHelper.java   
/**
 * 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;
}
项目:boohee_v5.6    文件:SlidingPaneLayout.java   
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);
        }
    }
}
项目:boohee_v5.6    文件:PullToRefreshAdapterViewBase.java   
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;
}
项目:LiveNotes    文件:SeeScoreView.java   
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);
                }
            }
        }
    }
}
项目:frogment    文件:KeepingFragmentStateTest.java   
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));
        }
    };
}
项目:weex-uikit    文件:WXEditText.java   
@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;
}
项目:MathView    文件:MainActivityTest.java   
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));
    }
  };
}
项目:letv    文件:DrawerLayout.java   
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);
}
项目:TitleBarView    文件:ViewUtil.java   
/**
 * 设置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);
    }
}
项目:Discover    文件:JZVideoPlayer.java   
@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() + "] ");
}
项目:BilibiliClient    文件:BannerAdapter.java   
@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;
}
项目:BilibiliClient    文件:BannerAdapter.java   
@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;
}
项目:SimpleUILauncher    文件:BubbleTextView.java   
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();
}
项目:Sega    文件:SearchView.java   
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();
    }
}
项目:AndroidSkinAnimator    文件:SkinCompatDelegate.java   
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();
    }
}
项目:SimpleUILauncher    文件:UserEventDispatcher.java   
/**
 * 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;
}
项目:TurboChat    文件:MessageActivityWriteMessageTest.java   
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));
        }
    };
}
项目:Froggy    文件:HolderPresenter.java   
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);
        }

    }

}
项目:TestChat    文件:ShareMessageFragment.java   
@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);
}
项目:aos-MediaLib    文件:OrientableSeekBar.java   
public boolean isInScrollingContainer() {
    ViewParent p = getParent();
    while (p != null && p instanceof ViewGroup) {
        if (((ViewGroup) p).shouldDelayChildPressedState()) {
            return true;
        }
        p = p.getParent();
    }
    return false;
}
项目:https-github.com-hyb1996-NoRootScriptDroid    文件:ViewUtils.java   
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);
}
项目:diycode    文件:PositionAnimExpectationRightOfParent.java   
@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;
}
项目:AutoRecycleView    文件:SuperSwipeRefreshLayout.java   
private void requestParentDisallowInterceptTouchEvent(boolean disallowIntercept) {
    Log.i(LOG_TAG, "requestParentDisallowInterceptTouchEvent");
    final ViewParent parent = getParent();
    if (parent != null) {
        parent.requestDisallowInterceptTouchEvent(disallowIntercept);
    }
}
项目:Views    文件:SwipeLayout.java   
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;
}
项目:EosCommander    文件:TextInputAutoCompleteTextView.java   
@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;
}
项目:superglue    文件:DebugDrawerLayout.java   
@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);
}
项目:CoordinatorLayoutExample-master    文件:ViewOffsetHelper.java   
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);
        }
    }
}
项目:GitHub    文件:ContentScrollView.java   
@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();
    }
}
项目:boohee_v5.6    文件:SwipeDismissBehavior.java   
public void onViewCaptured(View capturedChild, int activePointerId) {
    this.mOriginalCapturedViewLeft = capturedChild.getLeft();
    ViewParent parent = capturedChild.getParent();
    if (parent != null) {
        parent.requestDisallowInterceptTouchEvent(true);
    }
}
项目:boohee_v5.6    文件:NestedScrollView.java   
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;
}
项目:YCUtils    文件:MaterialRippleLayout.java   
private boolean isInScrollingContainer() {
    ViewParent p = getParent();
    while (p != null && p instanceof ViewGroup) {
        if (((ViewGroup) p).shouldDelayChildPressedState()) {
            return true;
        }
        p = p.getParent();
    }
    return false;
}
项目:PicShow-zhaipin    文件:JCVideoPlayer.java   
@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();
    }
}