DragPreviewProvider.java 文件源码

java
阅读 23 收藏 0 点赞 0 评论 0

项目:SimpleUILauncher 作者:
/**
 * Draws the {@link #mView} into the given {@param destCanvas}.
 */
private void drawDragView(Canvas destCanvas) {
    destCanvas.save();
    if (mView instanceof TextView) {
        Drawable d = Workspace.getTextViewIcon((TextView) mView);
        Rect bounds = getDrawableBounds(d);
        destCanvas.translate(DRAG_BITMAP_PADDING / 2 - bounds.left,
                DRAG_BITMAP_PADDING / 2 - bounds.top);
        d.draw(destCanvas);
    } else {
        final Rect clipRect = mTempRect;
        mView.getDrawingRect(clipRect);

        boolean textVisible = false;
        if (mView instanceof FolderIcon) {
            // For FolderIcons the text can bleed into the icon area, and so we need to
            // hide the text completely (which can't be achieved by clipping).
            if (((FolderIcon) mView).getTextVisible()) {
                ((FolderIcon) mView).setTextVisible(false);
                textVisible = true;
            }
        }
        destCanvas.translate(-mView.getScrollX() + DRAG_BITMAP_PADDING / 2,
                -mView.getScrollY() + DRAG_BITMAP_PADDING / 2);
        destCanvas.clipRect(clipRect, Op.REPLACE);
        mView.draw(destCanvas);

        // Restore text visibility of FolderIcon if necessary
        if (textVisible) {
            ((FolderIcon) mView).setTextVisible(true);
        }
    }
    destCanvas.restore();
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号