android.view.ViewDebug#trace ( )源码实例Demo

下面列出了android.view.ViewDebug#trace ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: SimplifyReader   文件: PLAListView.java
/**
 * Obtain the view and add it to our list of children. The view can be made
 * fresh, converted from an unused view, or used as is if it was in the
 * recycle bin.
 *
 * @param position Logical position in the list
 * @param childrenBottomOrTop Top or bottom edge of the view to add
 * @param flow If flow is true, align top edge to y. If false, align bottom
 *        edge to y.
 * @param selected Is this position selected?
 * @return View that was added
 */
@SuppressWarnings("deprecation")
private View makeAndAddView(int position, int childrenBottomOrTop, boolean flow,
        boolean selected) {
    View child;

    int childrenLeft;
    if (!mDataChanged) {
        // Try to use an exsiting view for this position
        child = mRecycler.getActiveView(position);
        if (child != null) {

            if (ViewDebug.TRACE_RECYCLER) {
                ViewDebug.trace(child, ViewDebug.RecyclerTraceType.RECYCLE_FROM_ACTIVE_HEAP,
                        position, getChildCount());
            }

            // Found it -- we're using an existing child
            // This just needs to be positioned
            childrenLeft = getItemLeft(position);
            setupChild(child, position, childrenBottomOrTop, flow, childrenLeft, selected, true);
            return child;
        }
    }

    //Notify new item is added to view.

    onItemAddedToList( position, flow );
    childrenLeft = getItemLeft( position );

    // Make a new view for this position, or convert an unused view if possible
    child = obtainView(position, mIsScrap);

    // This needs to be positioned and measured
    setupChild(child, position, childrenBottomOrTop, flow, childrenLeft, selected, mIsScrap[0]);

    return child;
}
 
源代码2 项目: Lay-s   文件: PLAListView.java
/**
 * Obtain the view and add it to our list of children. The view can be made
 * fresh, converted from an unused view, or used as is if it was in the
 * recycle bin.
 *
 * @param position Logical position in the list
 * @param childrenBottomOrTop Top or bottom edge of the view to add
 * @param flow If flow is true, align top edge to y. If false, align bottom
 *        edge to y.
 * @param selected Is this position selected?
 * @return View that was added
 */
@SuppressWarnings("deprecation")
private View makeAndAddView(int position, int childrenBottomOrTop, boolean flow,
        boolean selected) {
    View child;

    int childrenLeft;
    if (!mDataChanged) {
        // Try to use an exsiting view for this position
        child = mRecycler.getActiveView(position);
        if (child != null) {

            if (ViewDebug.TRACE_RECYCLER) {
                ViewDebug.trace(child, ViewDebug.RecyclerTraceType.RECYCLE_FROM_ACTIVE_HEAP,
                        position, getChildCount());
            }

            // Found it -- we're using an existing child
            // This just needs to be positioned
            childrenLeft = getItemLeft(position);
            setupChild(child, position, childrenBottomOrTop, flow, childrenLeft, selected, true);
            return child;
        }
    }

    //Notify new item is added to view.

    onItemAddedToList( position, flow );
    childrenLeft = getItemLeft( position );

    // Make a new view for this position, or convert an unused view if possible
    child = obtainView(position, mIsScrap);

    // This needs to be positioned and measured
    setupChild(child, position, childrenBottomOrTop, flow, childrenLeft, selected, mIsScrap[0]);

    return child;
}
 
源代码3 项目: EverMemo   文件: PLA_ListView.java
/**
 * Obtain the view and add it to our list of children. The view can be made
 * fresh, converted from an unused view, or used as is if it was in the
 * recycle bin.
 *
 * @param position Logical position in the list
 * @param childrenBottomOrTop Top or bottom edge of the view to add
 * @param flow If flow is true, align top edge to y. If false, align bottom
 *        edge to y.
 * @param childrenLeft Left edge where children should be positioned
 * @param selected Is this position selected?
 * @return View that was added
 */
@SuppressWarnings("deprecation")
private View makeAndAddView(int position, int childrenBottomOrTop, boolean flow,
		boolean selected) {
	View child;

	int childrenLeft;
	if (!mDataChanged) {
		// Try to use an exsiting view for this position
		child = mRecycler.getActiveView(position);
		if (child != null) {

			if (ViewDebug.TRACE_RECYCLER) {
				ViewDebug.trace(child, ViewDebug.RecyclerTraceType.RECYCLE_FROM_ACTIVE_HEAP,
						position, getChildCount());
			}

			// Found it -- we're using an existing child
			// This just needs to be positioned
			childrenLeft = getItemLeft(position);
			setupChild(child, position, childrenBottomOrTop, flow, childrenLeft, selected, true);
			return child;
		}
	}

	//Notify new item is added to view.
	
	onItemAddedToList( position, flow );
	childrenLeft = getItemLeft( position );

	// Make a new view for this position, or convert an unused view if possible
	child = obtainView(position, mIsScrap);

	// This needs to be positioned and measured
	setupChild(child, position, childrenBottomOrTop, flow, childrenLeft, selected, mIsScrap[0]);

	return child;
}
 
源代码4 项目: recent-images   文件: TwoWayAbsListView.java
/**
 * Get a view and have it show the data associated with the specified
 * position. This is called when we have already discovered that the view is
 * not available for reuse in the recycle bin. The only choices left are
 * converting an old view or making a new one.
 *
 * @param position The position to display
 * @param isScrap Array of at least 1 boolean, the first entry will become true if
 *                the returned view was taken from the scrap heap, false if otherwise.
 * 
 * @return A view displaying the data associated with the specified position
 */
View obtainView(int position, boolean[] isScrap) {
	isScrap[0] = false;
	View scrapView;

	scrapView = mRecycler.getScrapView(position);

	View child;
	if (scrapView != null) {
		if (ViewDebug.TRACE_RECYCLER) {
			ViewDebug.trace(scrapView, ViewDebug.RecyclerTraceType.RECYCLE_FROM_SCRAP_HEAP,
					position, -1);
		}

		child = mAdapter.getView(position, scrapView, this);

		if (ViewDebug.TRACE_RECYCLER) {
			ViewDebug.trace(child, ViewDebug.RecyclerTraceType.BIND_VIEW,
					position, getChildCount());
		}

		if (child != scrapView) {
			mRecycler.addScrapView(scrapView);
			if (mCacheColorHint != 0) {
				child.setDrawingCacheBackgroundColor(mCacheColorHint);
			}
			if (ViewDebug.TRACE_RECYCLER) {
				ViewDebug.trace(scrapView, ViewDebug.RecyclerTraceType.MOVE_TO_SCRAP_HEAP,
						position, -1);
			}
		} else {
			isScrap[0] = true;
			child.onFinishTemporaryDetach();
		}
	} else {
		child = mAdapter.getView(position, null, this);
		if (mCacheColorHint != 0) {
			child.setDrawingCacheBackgroundColor(mCacheColorHint);
		}
		if (ViewDebug.TRACE_RECYCLER) {
			ViewDebug.trace(child, ViewDebug.RecyclerTraceType.NEW_VIEW,
					position, getChildCount());
		}
	}

	return child;
}
 
源代码5 项目: recent-images   文件: TwoWayAbsListView.java
/**
 * Move all views remaining in mActiveViews to mScrapViews.
 */
void scrapActiveViews() {
	final View[] activeViews = mActiveViews;
	final boolean hasListener = mRecyclerListener != null;
	final boolean multipleScraps = mViewTypeCount > 1;

	ArrayList<View> scrapViews = mCurrentScrap;
	final int count = activeViews.length;
	for (int i = count - 1; i >= 0; i--) {
		final View victim = activeViews[i];
		if (victim != null) {
			int whichScrap = ((TwoWayAbsListView.LayoutParams) victim.getLayoutParams()).viewType;

			activeViews[i] = null;

			if (!shouldRecycleViewType(whichScrap)) {
				// Do not move views that should be ignored
				if (whichScrap != ITEM_VIEW_TYPE_HEADER_OR_FOOTER) {
					removeDetachedView(victim, false);
				}
				continue;
			}

			if (multipleScraps) {
				scrapViews = mScrapViews[whichScrap];
			}
			victim.onStartTemporaryDetach();
			scrapViews.add(victim);

			if (hasListener) {
				mRecyclerListener.onMovedToScrapHeap(victim);
			}

			if (ViewDebug.TRACE_RECYCLER) {
				ViewDebug.trace(victim,
						ViewDebug.RecyclerTraceType.MOVE_FROM_ACTIVE_TO_SCRAP_HEAP,
						mFirstActivePosition + i, -1);
			}
		}
	}

	pruneScrapViews();
}
 
源代码6 项目: SimplifyReader   文件: PLAAbsListView.java
/**
 * Get a view and have it show the data associated with the specified
 * position. This is called when we have already discovered that the view is
 * not available for reuse in the recycle bin. The only choices left are
 * converting an old view or making a new one.
 *
 * @param position The position to display
 * @param isScrap Array of at least 1 boolean, the first entry will become true if
 *                the returned view was taken from the scrap heap, false if otherwise.
 *
 * @return A view displaying the data associated with the specified position
 */
@SuppressWarnings("deprecation")
View obtainView(int position, boolean[] isScrap) {
    isScrap[0] = false;
    View scrapView;

    scrapView = mRecycler.getScrapView(position);

    View child;
    if (scrapView != null) {
        if (ViewDebug.TRACE_RECYCLER) {
            ViewDebug.trace(scrapView, ViewDebug.RecyclerTraceType.RECYCLE_FROM_SCRAP_HEAP,
                    position, -1);
        }

        child = mAdapter.getView(position, scrapView, this);

        if (ViewDebug.TRACE_RECYCLER) {
            ViewDebug.trace(child, ViewDebug.RecyclerTraceType.BIND_VIEW,
                    position, getChildCount());
        }

        if (child != scrapView) {
            mRecycler.addScrapView(scrapView);
            if (mCacheColorHint != 0) {
                child.setDrawingCacheBackgroundColor(mCacheColorHint);
            }
            if (ViewDebug.TRACE_RECYCLER) {
                ViewDebug.trace(scrapView, ViewDebug.RecyclerTraceType.MOVE_TO_SCRAP_HEAP,
                        position, -1);
            }
        } else {
            isScrap[0] = true;
            //child.dispatchFinishTemporaryDetach();
            dispatchFinishTemporaryDetach(child);
        }
    } else {
        child = mAdapter.getView(position, null, this);
        if (mCacheColorHint != 0) {
            child.setDrawingCacheBackgroundColor(mCacheColorHint);
        }
        if (ViewDebug.TRACE_RECYCLER) {
            ViewDebug.trace(child, ViewDebug.RecyclerTraceType.NEW_VIEW,
                    position, getChildCount());
        }
    }

    return child;
}
 
源代码7 项目: SimplifyReader   文件: PLAAbsListView.java
/**
 * Move all views remaining in mActiveViews to mScrapViews.
 */
@SuppressWarnings("deprecation")
void scrapActiveViews() {
    final View[] activeViews = mActiveViews;
    final boolean hasListener = mRecyclerListener != null;
    final boolean multipleScraps = mViewTypeCount > 1;

    Stack<View> scrapViews = mCurrentScrap;
    final int count = activeViews.length;
    for (int i = count - 1; i >= 0; i--) {
        final View victim = activeViews[i];
        if (victim != null) {
            int whichScrap = ((LayoutParams) victim.getLayoutParams()).viewType;

            activeViews[i] = null;

            if (!shouldRecycleViewType(whichScrap)) {
                // Do not move views that should be ignored
                if (whichScrap != ITEM_VIEW_TYPE_HEADER_OR_FOOTER) {
                    removeDetachedView(victim, false);
                }
                continue;
            }

            if (multipleScraps) {
                scrapViews = mScrapViews[whichScrap];
            }
            //victim.dispatchStartTemporaryDetach();
            dispatchFinishTemporaryDetach(victim);
            scrapViews.add(victim);

            if (hasListener) {
                mRecyclerListener.onMovedToScrapHeap(victim);
            }

            if (ViewDebug.TRACE_RECYCLER) {
                ViewDebug.trace(victim,
                        ViewDebug.RecyclerTraceType.MOVE_FROM_ACTIVE_TO_SCRAP_HEAP,
                        mFirstActivePosition + i, -1);
            }
        }
    }

    pruneScrapViews();
}
 
源代码8 项目: Lay-s   文件: PLAAbsListView.java
/**
 * Get a view and have it show the data associated with the specified
 * position. This is called when we have already discovered that the view is
 * not available for reuse in the recycle bin. The only choices left are
 * converting an old view or making a new one.
 *
 * @param position The position to display
 * @param isScrap Array of at least 1 boolean, the first entry will become true if
 *                the returned view was taken from the scrap heap, false if otherwise.
 *
 * @return A view displaying the data associated with the specified position
 */
@SuppressWarnings("deprecation")
View obtainView(int position, boolean[] isScrap) {
    isScrap[0] = false;
    View scrapView;

    scrapView = mRecycler.getScrapView(position);

    View child;
    if (scrapView != null) {
        if (ViewDebug.TRACE_RECYCLER) {
            ViewDebug.trace(scrapView, ViewDebug.RecyclerTraceType.RECYCLE_FROM_SCRAP_HEAP,
                    position, -1);
        }

        child = mAdapter.getView(position, scrapView, this);

        if (ViewDebug.TRACE_RECYCLER) {
            ViewDebug.trace(child, ViewDebug.RecyclerTraceType.BIND_VIEW,
                    position, getChildCount());
        }

        if (child != scrapView) {
            mRecycler.addScrapView(scrapView);
            if (mCacheColorHint != 0) {
                child.setDrawingCacheBackgroundColor(mCacheColorHint);
            }
            if (ViewDebug.TRACE_RECYCLER) {
                ViewDebug.trace(scrapView, ViewDebug.RecyclerTraceType.MOVE_TO_SCRAP_HEAP,
                        position, -1);
            }
        } else {
            isScrap[0] = true;
            //child.dispatchFinishTemporaryDetach();
            dispatchFinishTemporaryDetach(child);
        }
    } else {
        child = mAdapter.getView(position, null, this);
        if (mCacheColorHint != 0) {
            child.setDrawingCacheBackgroundColor(mCacheColorHint);
        }
        if (ViewDebug.TRACE_RECYCLER) {
            ViewDebug.trace(child, ViewDebug.RecyclerTraceType.NEW_VIEW,
                    position, getChildCount());
        }
    }

    return child;
}
 
源代码9 项目: Lay-s   文件: PLAAbsListView.java
/**
 * Move all views remaining in mActiveViews to mScrapViews.
 */
@SuppressWarnings("deprecation")
void scrapActiveViews() {
    final View[] activeViews = mActiveViews;
    final boolean hasListener = mRecyclerListener != null;
    final boolean multipleScraps = mViewTypeCount > 1;

    Stack<View> scrapViews = mCurrentScrap;
    final int count = activeViews.length;
    for (int i = count - 1; i >= 0; i--) {
        final View victim = activeViews[i];
        if (victim != null) {
            int whichScrap = ((LayoutParams) victim.getLayoutParams()).viewType;

            activeViews[i] = null;

            if (!shouldRecycleViewType(whichScrap)) {
                // Do not move views that should be ignored
                if (whichScrap != ITEM_VIEW_TYPE_HEADER_OR_FOOTER) {
                    removeDetachedView(victim, false);
                }
                continue;
            }

            if (multipleScraps) {
                scrapViews = mScrapViews[whichScrap];
            }
            //victim.dispatchStartTemporaryDetach();
            dispatchFinishTemporaryDetach(victim);
            scrapViews.add(victim);

            if (hasListener) {
                mRecyclerListener.onMovedToScrapHeap(victim);
            }

            if (ViewDebug.TRACE_RECYCLER) {
                ViewDebug.trace(victim,
                        ViewDebug.RecyclerTraceType.MOVE_FROM_ACTIVE_TO_SCRAP_HEAP,
                        mFirstActivePosition + i, -1);
            }
        }
    }

    pruneScrapViews();
}
 
源代码10 项目: EverMemo   文件: PLA_AbsListView.java
/**
 * Get a view and have it show the data associated with the specified
 * position. This is called when we have already discovered that the view is
 * not available for reuse in the recycle bin. The only choices left are
 * converting an old view or making a new one.
 *
 * @param position The position to display
 * @param isScrap Array of at least 1 boolean, the first entry will become true if
 *                the returned view was taken from the scrap heap, false if otherwise.
 * 
 * @return A view displaying the data associated with the specified position
 */
@SuppressWarnings("deprecation")
View obtainView(int position, boolean[] isScrap) {
	isScrap[0] = false;
	View scrapView;

	scrapView = mRecycler.getScrapView(position);

	View child;
	if (scrapView != null) {
		if (ViewDebug.TRACE_RECYCLER) {
			ViewDebug.trace(scrapView, ViewDebug.RecyclerTraceType.RECYCLE_FROM_SCRAP_HEAP,
					position, -1);
		}

		child = mAdapter.getView(position, scrapView, this);

		if (ViewDebug.TRACE_RECYCLER) {
			ViewDebug.trace(child, ViewDebug.RecyclerTraceType.BIND_VIEW,
					position, getChildCount());
		}

		if (child != scrapView) {
			mRecycler.addScrapView(scrapView);
			if (mCacheColorHint != 0) {
				child.setDrawingCacheBackgroundColor(mCacheColorHint);
			}
			if (ViewDebug.TRACE_RECYCLER) {
				ViewDebug.trace(scrapView, ViewDebug.RecyclerTraceType.MOVE_TO_SCRAP_HEAP,
						position, -1);
			}
		} else {
			isScrap[0] = true;
			//child.dispatchFinishTemporaryDetach();
			dispatchFinishTemporaryDetach(child);
		}
	} else {
		child = mAdapter.getView(position, null, this);
		if (mCacheColorHint != 0) {
			child.setDrawingCacheBackgroundColor(mCacheColorHint);
		}
		if (ViewDebug.TRACE_RECYCLER) {
			ViewDebug.trace(child, ViewDebug.RecyclerTraceType.NEW_VIEW,
					position, getChildCount());
		}
	}

	return child;
}
 
源代码11 项目: EverMemo   文件: PLA_AbsListView.java
/**
 * Move all views remaining in mActiveViews to mScrapViews.
 */
@SuppressWarnings("deprecation")
void scrapActiveViews() {
	final View[] activeViews = mActiveViews;
	final boolean hasListener = mRecyclerListener != null;
	final boolean multipleScraps = mViewTypeCount > 1;

	ArrayList<View> scrapViews = mCurrentScrap;
	final int count = activeViews.length;
	for (int i = count - 1; i >= 0; i--) {
		final View victim = activeViews[i];
		if (victim != null) {
			int whichScrap = ((PLA_AbsListView.LayoutParams) victim.getLayoutParams()).viewType;

			activeViews[i] = null;

			if (!shouldRecycleViewType(whichScrap)) {
				// Do not move views that should be ignored
				if (whichScrap != ITEM_VIEW_TYPE_HEADER_OR_FOOTER) {
					removeDetachedView(victim, false);
				}
				continue;
			}

			if (multipleScraps) {
				scrapViews = mScrapViews[whichScrap];
			}
			//victim.dispatchStartTemporaryDetach();
			dispatchFinishTemporaryDetach(victim);
			scrapViews.add(victim);

			if (hasListener) {
				mRecyclerListener.onMovedToScrapHeap(victim);
			}

			if (ViewDebug.TRACE_RECYCLER) {
				ViewDebug.trace(victim,
						ViewDebug.RecyclerTraceType.MOVE_FROM_ACTIVE_TO_SCRAP_HEAP,
						mFirstActivePosition + i, -1);
			}
		}
	}

	pruneScrapViews();
}