Example usage for android.os Debug startMethodTracing

List of usage examples for android.os Debug startMethodTracing

Introduction

In this page you can find the example usage for android.os Debug startMethodTracing.

Prototype

public static void startMethodTracing(String tracePath) 

Source Link

Document

Start method tracing, specifying the trace log file path.

Usage

From source file:com.example.libwidgettv.bak.AbsListView.java

private void scrollIfNeeded(int y) {
    final int rawDeltaY = y - mMotionY;
    final int deltaY = rawDeltaY - mMotionCorrection;
    int incrementalDeltaY = mLastY != Integer.MIN_VALUE ? y - mLastY : deltaY;

    if (mTouchMode == TOUCH_MODE_SCROLL) {
        if (PROFILE_SCROLLING) {
            if (!mScrollProfilingStarted) {
                Debug.startMethodTracing("AbsListViewScroll");
                mScrollProfilingStarted = true;
            }//  w  w  w . java 2 s  .  co m
        }

        if (y != mLastY) {
            // We may be here after stopping a fling and continuing to
            // scroll.
            // If so, we haven't disallowed intercepting touch events yet.
            // Make sure that we do so in case we're in a parent that can
            // intercept.
            // if ((mGroupFlags & FLAG_DISALLOW_INTERCEPT) == 0 &&
            // Math.abs(rawDeltaY) > mTouchSlop) {
            // final ViewParent parent = getParent();
            // if (parent != null) {
            // parent.requestDisallowInterceptTouchEvent(true);
            // }
            // }

            final int motionIndex;
            if (mMotionPosition >= 0) {
                motionIndex = mMotionPosition - mFirstPosition;
            } else {
                // If we don't have a motion position that we can reliably
                // track,
                // pick something in the middle to make a best guess at
                // things below.
                motionIndex = getChildCount() / 2;
            }

            int motionViewPrevTop = 0;
            View motionView = this.getChildAt(motionIndex);
            if (motionView != null) {
                motionViewPrevTop = motionView.getTop();
            }

            // No need to do all this work if we're not going to move anyway
            boolean atEdge = false;
            if (incrementalDeltaY != 0) {
                atEdge = trackMotionScroll(deltaY, incrementalDeltaY);
            }

            // Check to see if we have bumped into the scroll limit
            motionView = this.getChildAt(motionIndex);
            if (motionView != null) {
                // Check if the top of the motion view is where it is
                // supposed to be
                final int motionViewRealTop = motionView.getTop();
                if (atEdge) {
                    // Apply overscroll

                    int overscroll = -incrementalDeltaY - (motionViewRealTop - motionViewPrevTop);
                    overScrollBy(0, overscroll, 0, getScrollY(), 0, 0, 0, mOverscrollDistance, true);
                    if (Math.abs(mOverscrollDistance) == Math.abs(getScrollY())) {
                        // Don't allow overfling if we're at the edge.
                        if (mVelocityTracker != null) {
                            mVelocityTracker.clear();
                        }
                    }

                    final int overscrollMode = getOverScrollMode();
                    if (overscrollMode == OVER_SCROLL_ALWAYS
                            || (overscrollMode == OVER_SCROLL_IF_CONTENT_SCROLLS && !contentFits())) {
                        mDirection = 0; // Reset when entering overscroll.
                        mTouchMode = TOUCH_MODE_OVERSCROLL;
                    }
                }
                mMotionY = y;
                invalidate();
            }
            mLastY = y;
        }
    } else if (mTouchMode == TOUCH_MODE_OVERSCROLL) {
        if (y != mLastY) {
            final int oldScroll = getScrollY();
            final int newScroll = oldScroll - incrementalDeltaY;
            int newDirection = y > mLastY ? 1 : -1;

            if (mDirection == 0) {
                mDirection = newDirection;
            }

            int overScrollDistance = -incrementalDeltaY;
            if ((newScroll < 0 && oldScroll >= 0) || (newScroll > 0 && oldScroll <= 0)) {
                overScrollDistance = -oldScroll;
                incrementalDeltaY += overScrollDistance;
            } else {
                incrementalDeltaY = 0;
            }

            if (overScrollDistance != 0) {
                overScrollBy(0, overScrollDistance, 0, getScrollY(), 0, 0, 0, mOverscrollDistance, true);
                final int overscrollMode = getOverScrollMode();
                if (overscrollMode == OVER_SCROLL_ALWAYS
                        || (overscrollMode == OVER_SCROLL_IF_CONTENT_SCROLLS && !contentFits())) {
                    invalidate();
                }
            }

            if (incrementalDeltaY != 0) {
                // Coming back to 'real' list scrolling
                // mScrollY = 0;
                // invalidateParentIfNeeded();
                scrollTo(getScrollX(), 0);

                // No need to do all this work if we're not going to move
                // anyway
                if (incrementalDeltaY != 0) {
                    trackMotionScroll(incrementalDeltaY, incrementalDeltaY);
                }

                mTouchMode = TOUCH_MODE_SCROLL;

                // We did not scroll the full amount. Treat this essentially
                // like the
                // start of a new touch scroll
                final int motionPosition = findClosestMotionRow(y);

                mMotionCorrection = 0;
                View motionView = getChildAt(motionPosition - mFirstPosition);
                mMotionViewOriginalTop = motionView != null ? motionView.getTop() : 0;
                mMotionY = y;
                mMotionPosition = motionPosition;
            }
            mLastY = y;
            mDirection = newDirection;
        }
    }
}

From source file:com.appunite.list.AbsHorizontalListView.java

private void scrollIfNeeded(int x) {
    final int rawDeltaX = x - mMotionX;
    final int deltaX = rawDeltaX - mMotionCorrection;
    int incrementalDeltaX = mLastX != Integer.MIN_VALUE ? x - mLastX : deltaX;

    if (mTouchMode == TOUCH_MODE_SCROLL) {
        if (PROFILE_SCROLLING) {
            if (!mScrollProfilingStarted) {
                Debug.startMethodTracing("AbsListViewScroll");
                mScrollProfilingStarted = true;
            }//w w  w  .  j a v a2s  .co m
        }

        // TODO removed strict span in backport (j. m.)
        //if (mScrollStrictSpan == null) {
        //    // If it's non-null, we're already in a scroll.
        //    mScrollStrictSpan = StrictMode.enterCriticalSpan("AbsListView-scroll");
        //}

        if (x != mLastX) {
            // We may be here after stopping a fling and continuing to scroll.
            // If so, we haven't disallowed intercepting touch events yet.
            // Make sure that we do so in case we're in a parent that can intercept.
            if (!mDisallowIntercept && Math.abs(rawDeltaX) > mTouchSlop) {
                final ViewParent parent = getParent();
                if (parent != null) {
                    parent.requestDisallowInterceptTouchEvent(true);
                }
            }

            final int motionIndex;
            if (mMotionPosition >= 0) {
                motionIndex = mMotionPosition - mFirstPosition;
            } else {
                // If we don't have a motion position that we can reliably track,
                // pick something in the middle to make a best guess at things below.
                motionIndex = getChildCount() / 2;
            }

            int motionViewPrevLeft = 0;
            View motionView = this.getChildAt(motionIndex);
            if (motionView != null) {
                motionViewPrevLeft = motionView.getLeft();
            }

            // No need to do all this work if we're not going to move anyway
            boolean atEdge = false;
            if (incrementalDeltaX != 0) {
                atEdge = trackMotionScroll(deltaX, incrementalDeltaX);
            }

            // Check to see if we have bumped into the scroll limit
            motionView = this.getChildAt(motionIndex);
            if (motionView != null) {
                // Check if the top of the motion view is where it is
                // supposed to be
                final int motionViewRealLeft = motionView.getLeft();
                if (atEdge) {
                    // Apply overscroll
                    final int scrollX = getScrollX();

                    int overscroll = -incrementalDeltaX - (motionViewRealLeft - motionViewPrevLeft);

                    overScrollBy(overscroll, 0, scrollX, 0, 0, 0, mOverscrollDistance, 0, true);
                    if (Math.abs(mOverscrollDistance) == Math.abs(scrollX)) {
                        // Don't allow overfling if we're at the edge.
                        if (mVelocityTracker != null) {
                            mVelocityTracker.clear();
                        }
                    }

                    final int overscrollMode = getOverScrollMode();
                    if (overscrollMode == OVER_SCROLL_ALWAYS
                            || (overscrollMode == OVER_SCROLL_IF_CONTENT_SCROLLS && !contentFits())) {
                        mDirection = 0; // Reset when entering overscroll.
                        mTouchMode = TOUCH_MODE_OVERSCROLL;
                        if (rawDeltaX > 0) {
                            mEdgeGlowLeft.onPull((float) overscroll / getWidth());
                            if (!mEdgeGlowRight.isFinished()) {
                                mEdgeGlowRight.onRelease();
                            }
                        } else if (rawDeltaX < 0) {
                            mEdgeGlowRight.onPull((float) overscroll / getWidth());
                            if (!mEdgeGlowLeft.isFinished()) {
                                mEdgeGlowLeft.onRelease();
                            }
                        }
                        invalidate();
                    }
                }
                mMotionX = x;
            }
            mLastX = x;
        }
    } else if (mTouchMode == TOUCH_MODE_OVERSCROLL) {
        if (x != mLastX) {
            final int oldScroll = getScrollX();
            final int newScroll = oldScroll - incrementalDeltaX;
            int newDirection = x > mLastX ? 1 : -1;

            if (mDirection == 0) {
                mDirection = newDirection;
            }

            int overScrollDistance = -incrementalDeltaX;
            if ((newScroll < 0 && oldScroll >= 0) || (newScroll > 0 && oldScroll <= 0)) {
                overScrollDistance = -oldScroll;
                incrementalDeltaX += overScrollDistance;
            } else {
                incrementalDeltaX = 0;
            }

            if (overScrollDistance != 0) {
                final int scrollX = getScrollX();
                overScrollBy(overScrollDistance, 0, scrollX, 0, 0, 0, mOverscrollDistance, 0, true);
                final int overscrollMode = getOverScrollMode();
                if (overscrollMode == OVER_SCROLL_ALWAYS
                        || (overscrollMode == OVER_SCROLL_IF_CONTENT_SCROLLS && !contentFits())) {
                    if (rawDeltaX > 0) {
                        mEdgeGlowLeft.onPull((float) overScrollDistance / getWidth());
                        if (!mEdgeGlowRight.isFinished()) {
                            mEdgeGlowRight.onRelease();
                        }
                    } else if (rawDeltaX < 0) {
                        mEdgeGlowRight.onPull((float) overScrollDistance / getWidth());
                        if (!mEdgeGlowLeft.isFinished()) {
                            mEdgeGlowLeft.onRelease();
                        }
                    }
                    invalidate();
                }
            }

            if (incrementalDeltaX != 0) {
                // Coming back to 'real' list scrolling
                if (getScrollX() != 0) {
                    scrollTo(0, getScrollY());
                    invalidateParentIfNeededUnhide();
                }

                // FIXME fix this
                trackMotionScroll(incrementalDeltaX, incrementalDeltaX);

                mTouchMode = TOUCH_MODE_SCROLL;

                // We did not scroll the full amount. Treat this essentially like the
                // start of a new touch scroll
                final int motionPosition = findClosestMotionCol(x);

                mMotionCorrection = 0;
                View motionView = getChildAt(motionPosition - mFirstPosition);
                mMotionViewOriginalLeft = motionView != null ? motionView.getLeft() : 0;
                mMotionX = x;
                mMotionPosition = motionPosition;
            }
            mLastX = x;
            mDirection = newDirection;
        }
    }
}

From source file:com.appunite.list.AbsListView.java

private void scrollIfNeeded(int y) {
    final int rawDeltaY = y - mMotionY;
    final int deltaY = rawDeltaY - mMotionCorrection;
    int incrementalDeltaY = mLastY != Integer.MIN_VALUE ? y - mLastY : deltaY;

    if (mTouchMode == TOUCH_MODE_SCROLL) {
        if (PROFILE_SCROLLING) {
            if (!mScrollProfilingStarted) {
                Debug.startMethodTracing("AbsListViewScroll");
                mScrollProfilingStarted = true;
            }/*from  w  w  w.j  a  v a  2 s .c o m*/
        }

        // TODO removed strict span in backport (j. m.)
        //if (mScrollStrictSpan == null) {
        //    // If it's non-null, we're already in a scroll.
        //    mScrollStrictSpan = StrictMode.enterCriticalSpan("AbsListView-scroll");
        //}

        if (y != mLastY) {
            // We may be here after stopping a fling and continuing to scroll.
            // If so, we haven't disallowed intercepting touch events yet.
            // Make sure that we do so in case we're in a parent that can intercept.
            if (!mDisallowIntercept && Math.abs(rawDeltaY) > mTouchSlop) {
                final ViewParent parent = getParent();
                if (parent != null) {
                    parent.requestDisallowInterceptTouchEvent(true);
                }
            }

            final int motionIndex;
            if (mMotionPosition >= 0) {
                motionIndex = mMotionPosition - mFirstPosition;
            } else {
                // If we don't have a motion position that we can reliably track,
                // pick something in the middle to make a best guess at things below.
                motionIndex = getChildCount() / 2;
            }

            int motionViewPrevTop = 0;
            View motionView = this.getChildAt(motionIndex);
            if (motionView != null) {
                motionViewPrevTop = motionView.getTop();
            }

            // No need to do all this work if we're not going to move anyway
            boolean atEdge = false;
            if (incrementalDeltaY != 0) {
                atEdge = trackMotionScroll(deltaY, incrementalDeltaY);
            }

            // Check to see if we have bumped into the scroll limit
            motionView = this.getChildAt(motionIndex);
            if (motionView != null) {
                // Check if the top of the motion view is where it is
                // supposed to be
                final int motionViewRealTop = motionView.getTop();
                if (atEdge) {
                    // Apply overscroll
                    final int scrollY = getScrollY();

                    int overscroll = -incrementalDeltaY - (motionViewRealTop - motionViewPrevTop);
                    overScrollBy(0, overscroll, 0, scrollY, 0, 0, 0, mOverscrollDistance, true);
                    if (Math.abs(mOverscrollDistance) == Math.abs(scrollY)) {
                        // Don't allow overfling if we're at the edge.
                        if (mVelocityTracker != null) {
                            mVelocityTracker.clear();
                        }
                    }

                    final int overscrollMode = getOverScrollMode();
                    if (overscrollMode == OVER_SCROLL_ALWAYS
                            || (overscrollMode == OVER_SCROLL_IF_CONTENT_SCROLLS && !contentFits())) {
                        mDirection = 0; // Reset when entering overscroll.
                        mTouchMode = TOUCH_MODE_OVERSCROLL;
                        if (rawDeltaY > 0) {
                            mEdgeGlowTop.onPull((float) overscroll / getHeight());
                            if (!mEdgeGlowBottom.isFinished()) {
                                mEdgeGlowBottom.onRelease();
                            }
                        } else if (rawDeltaY < 0) {
                            mEdgeGlowBottom.onPull((float) overscroll / getHeight());
                            if (!mEdgeGlowTop.isFinished()) {
                                mEdgeGlowTop.onRelease();
                            }
                        }
                        invalidate();
                    }
                }
                mMotionY = y;
            }
            mLastY = y;
        }
    } else if (mTouchMode == TOUCH_MODE_OVERSCROLL) {
        if (y != mLastY) {
            final int oldScroll = getScrollY();
            final int newScroll = oldScroll - incrementalDeltaY;
            int newDirection = y > mLastY ? 1 : -1;

            if (mDirection == 0) {
                mDirection = newDirection;
            }

            int overScrollDistance = -incrementalDeltaY;
            if ((newScroll < 0 && oldScroll >= 0) || (newScroll > 0 && oldScroll <= 0)) {
                overScrollDistance = -oldScroll;
                incrementalDeltaY += overScrollDistance;
            } else {
                incrementalDeltaY = 0;
            }

            if (overScrollDistance != 0) {
                final int scrollY = getScrollY();
                overScrollBy(0, overScrollDistance, 0, scrollY, 0, 0, 0, mOverscrollDistance, true);
                final int overscrollMode = getOverScrollMode();
                if (overscrollMode == OVER_SCROLL_ALWAYS
                        || (overscrollMode == OVER_SCROLL_IF_CONTENT_SCROLLS && !contentFits())) {
                    if (rawDeltaY > 0) {
                        mEdgeGlowTop.onPull((float) overScrollDistance / getHeight());
                        if (!mEdgeGlowBottom.isFinished()) {
                            mEdgeGlowBottom.onRelease();
                        }
                    } else if (rawDeltaY < 0) {
                        mEdgeGlowBottom.onPull((float) overScrollDistance / getHeight());
                        if (!mEdgeGlowTop.isFinished()) {
                            mEdgeGlowTop.onRelease();
                        }
                    }
                    invalidate();
                }
            }

            if (incrementalDeltaY != 0) {
                // Coming back to 'real' list scrolling
                if (getScrollY() != 0) {
                    scrollTo(getScrollX(), 0);
                    invalidateParentIfNeededUnhide();
                }

                trackMotionScroll(incrementalDeltaY, incrementalDeltaY);

                mTouchMode = TOUCH_MODE_SCROLL;

                // We did not scroll the full amount. Treat this essentially like the
                // start of a new touch scroll
                final int motionPosition = findClosestMotionRow(y);

                mMotionCorrection = 0;
                View motionView = getChildAt(motionPosition - mFirstPosition);
                mMotionViewOriginalTop = motionView != null ? motionView.getTop() : 0;
                mMotionY = y;
                mMotionPosition = motionPosition;
            }
            mLastY = y;
            mDirection = newDirection;
        }
    }
}