- CompoundButton 源码分析
- LinearLayout 源码分析
- SearchView 源码解析
- LruCache 源码解析
- ViewDragHelper 源码解析
- BottomSheets 源码解析
- Media Player 源码分析
- NavigationView 源码解析
- Service 源码解析
- Binder 源码分析
- Android 应用 Preference 相关及源码浅析 SharePreferences 篇
- ScrollView 源码解析
- Handler 源码解析
- NestedScrollView 源码解析
- SQLiteOpenHelper/SQLiteDatabase/Cursor 源码解析
- Bundle 源码解析
- LocalBroadcastManager 源码解析
- Toast 源码解析
- TextInputLayout
- LayoutInflater 和 LayoutInflaterCompat 源码解析
- TextView 源码解析
- NestedScrolling 事件机制源码解析
- ViewGroup 源码解析
- StaticLayout 源码分析
- AtomicFile 源码解析
- AtomicFile 源码解析
- Spannable 源码分析
- Notification 之 Android 5.0 实现原理
- CoordinatorLayout 源码分析
- Scroller 源码解析
- SwipeRefreshLayout 源码分析
- FloatingActionButton 源码解析
- AsyncTask 源码分析
- TabLayout 源码解析
文章来源于网络收集而来,版权归原创者所有,如有侵权请及时联系!
4.7. tryCaptureViewForDrag() 方法
boolean tryCaptureViewForDrag(View toCapture, int pointerId) {
//如果已经捕获该 View 直接返回 true
if (toCapture == mCapturedView && mActivePointerId == pointerId) {
// Already done!
return true;
}
//根据 mCallback.tryCaptureView() 方法来最终决定是否可以捕获 View
if (toCapture != null && mCallback.tryCaptureView(toCapture, pointerId)) {
mActivePointerId = pointerId;
//如果可以则调用 captureChildView(),并返回 true
captureChildView(toCapture, pointerId);
return true;
}
return false;
}
可以看到如果可以捕获 View 则调用了 captureChildView() 方法:
public void captureChildView(View childView, int activePointerId) {
if (childView.getParent() != mParentView) {
throw new IllegalArgumentException("captureChildView: parameter must be a descendant " +
"of the ViewDragHelper's tracked parent view (" + mParentView + ")");
}
//赋值 mCapturedView
mCapturedView = childView;
mActivePointerId = activePointerId;
//回调 callback
mCallback.onViewCaptured(childView, activePointerId);
//设定 mDragState 的状态为 STATE_DRAGGING
setDragState(STATE_DRAGGING);
}
如果程序执行到这里,就证明 View 已经处于拖拽状态了,后续的触摸操作,将直接根据 mDragState 为 STATE_DRAGGING 的状态处理。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论