除了workspace进入springload之外,其他模块也会进入springload,
主要是folder、allapp、widget,这三个模块
先看folder,从onlongclick开始。
public boolean onLongClick(View v) {
if (!mLauncher.isDraggingEnabled()) return true;
return startDrag(v, new DragOptions());
}
public boolean startDrag(View v, DragOptions options) {
Object tag = v.getTag();
if (tag instanceof ShortcutInfo) {
ShortcutInfo item = (ShortcutInfo) tag;
if (!v.isInTouchMode()) {
return false;
}
mEmptyCellRank = item.rank;
mCurrentDragView = v;
//绑定listener,在 callOnDragStart()的时候,会调用onDragStart方法。
mDragController.addDragListener(this);
而后进入workspace的beginDragShared
mLauncher.getWorkspace().beginDragShared(v, this, options);
}
return true;
}
Allapp的drag流程。
@Override
public boolean onLongClick(final View v) {
//首先进行一些普通判断,确保当前能够进行drag的模式。
if (!v.isInTouchMode()) return false;
if (!mLauncher.isAppsViewVisible() ||
mLauncher.getWorkspace().isSwitchingState()) return false;
if (!mLauncher.isDraggingEnabled()) return false;
if (mLauncher.getDragController().isDragging()) return false;
// 首先是绑定addDragListener,并且这次在绑定时就直接重写了onDr

本文详细介绍了Android Launcher中拖拽操作的实现,涉及Folder、AllApp和Widget的长按拖动流程。从onLongClick开始,分析了开始拖动、添加DragListener以及进入SpringLoaded模式的过程,揭示了不同组件拖拽进入SpringLoad的细节。
最低0.47元/天 解锁文章
662

被折叠的 条评论
为什么被折叠?



