mirror of
https://gitee.com/houstudio/Cdroid.git
synced 2024-11-30 03:08:12 +08:00
uncomment gesture impl
This commit is contained in:
parent
cecac00cd4
commit
896fdb14f4
@ -1220,60 +1220,48 @@ int ItemTouchHelper::SimpleCallback::getMovementFlags(RecyclerView& recyclerView
|
||||
return makeMovementFlags(getDragDirs(recyclerView, viewHolder),
|
||||
getSwipeDirs(recyclerView, viewHolder));
|
||||
}
|
||||
#if 0
|
||||
private class ItemTouchHelperGestureListener extends GestureDetector.SimpleOnGestureListener {
|
||||
|
||||
private bool mShouldReactToLongPress = true;
|
||||
ItemTouchHelper::ItemTouchHelperGestureListener::ItemTouchHelperGestureListener(ItemTouchHelper*hlp):mItemTouchHelper(hlp) {
|
||||
}
|
||||
|
||||
ItemTouchHelperGestureListener() {
|
||||
void ItemTouchHelper::ItemTouchHelperGestureListener::doNotReactToLongPress() {
|
||||
mShouldReactToLongPress = false;
|
||||
}
|
||||
|
||||
bool ItemTouchHelper::ItemTouchHelperGestureListener::onDown(MotionEvent& e) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void ItemTouchHelper::ItemTouchHelperGestureListener::onLongPress(MotionEvent& e) {
|
||||
if (!mShouldReactToLongPress) {
|
||||
return;
|
||||
}
|
||||
|
||||
void doNotReactToLongPress() {
|
||||
mShouldReactToLongPress = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public bool onDown(MotionEvent e) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLongPress(MotionEvent e) {
|
||||
if (!mShouldReactToLongPress) {
|
||||
return;
|
||||
}
|
||||
View child = findChildView(e);
|
||||
if (child != null) {
|
||||
ViewHolder vh = mRecyclerView.getChildViewHolder(child);
|
||||
if (vh != null) {
|
||||
if (!mCallback->hasDragFlag(mRecyclerView, vh)) {
|
||||
return;
|
||||
}
|
||||
int pointerId = e.getPointerId(0);
|
||||
// Long press is deferred.
|
||||
// Check w/ active pointer id to avoid selecting after motion
|
||||
// event is canceled.
|
||||
if (pointerId == mActivePointerId) {
|
||||
final int index = e.findPointerIndex(mActivePointerId);
|
||||
final float x = e.getX(index);
|
||||
final float y = e.getY(index);
|
||||
mInitialTouchX = x;
|
||||
mInitialTouchY = y;
|
||||
mDx = mDy = 0f;
|
||||
if (DEBUG) {
|
||||
Log.d(TAG,
|
||||
"onlong press: x:" + mInitialTouchX + ",y:" + mInitialTouchY);
|
||||
}
|
||||
if (mCallback->isLongPressDragEnabled()) {
|
||||
select(vh, ACTION_STATE_DRAG);
|
||||
}
|
||||
View* child = mItemTouchHelper->findChildView(e);
|
||||
if (child != nullptr) {
|
||||
RecyclerView::ViewHolder* vh = mItemTouchHelper->mRecyclerView->getChildViewHolder(child);
|
||||
if (vh != nullptr) {
|
||||
if (!mItemTouchHelper->mCallback->hasDragFlag(*mItemTouchHelper->mRecyclerView,*vh)) {
|
||||
return;
|
||||
}
|
||||
int pointerId = e.getPointerId(0);
|
||||
// Long press is deferred.
|
||||
// Check w/ active pointer id to avoid selecting after motion
|
||||
// event is canceled.
|
||||
if (pointerId == mItemTouchHelper->mActivePointerId) {
|
||||
const int index = e.findPointerIndex(mItemTouchHelper->mActivePointerId);
|
||||
const float x = e.getX(index);
|
||||
const float y = e.getY(index);
|
||||
mItemTouchHelper->mInitialTouchX = x;
|
||||
mItemTouchHelper->mInitialTouchY = y;
|
||||
mItemTouchHelper->mDx = mItemTouchHelper->mDy = 0.f;
|
||||
LOGD_IF(_DEBUG,"onlong press: x:%.f ,y:%.f",x,y);
|
||||
if (mItemTouchHelper->mCallback->isLongPressDragEnabled()) {
|
||||
mItemTouchHelper->select(vh, ACTION_STATE_DRAG);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//private static class RecoverAnimation:public Animator::AnimatorListener {
|
||||
|
||||
ItemTouchHelper::RecoverAnimation::RecoverAnimation(RecyclerView::ViewHolder* viewHolder, int animationType,
|
||||
int actionState, float startDx, float startDy, float targetX, float targetY) {
|
||||
|
@ -36,6 +36,7 @@ public:
|
||||
class RecoverAnimation;
|
||||
class ItemTouchHelperGestureListener;
|
||||
protected:
|
||||
friend ItemTouchHelperGestureListener;
|
||||
std::vector<View*> mPendingCleanup;
|
||||
std::vector<RecoverAnimation*> mRecoverAnimations;
|
||||
RecyclerView* mRecyclerView;
|
||||
@ -187,17 +188,16 @@ public:
|
||||
int getMovementFlags(RecyclerView& recyclerView,RecyclerView::ViewHolder& viewHolder)override;
|
||||
};
|
||||
|
||||
#if 0
|
||||
class ItemTouchHelper::ItemTouchHelperGestureListener:public GestureDetector.SimpleOnGestureListener {
|
||||
class ItemTouchHelper::ItemTouchHelperGestureListener/*:public GestureDetector::SimpleOnGestureListener*/{
|
||||
private:
|
||||
bool mShouldReactToLongPress = true;
|
||||
ItemTouchHelper*mItemTouchHelper;
|
||||
public:
|
||||
ItemTouchHelperGestureListener();
|
||||
ItemTouchHelperGestureListener(ItemTouchHelper*);
|
||||
void doNotReactToLongPress();
|
||||
bool onDown(MotionEvent& e);
|
||||
void onLongPress(MotionEvent& e);
|
||||
};
|
||||
#endif
|
||||
|
||||
class ItemTouchHelper::RecoverAnimation{
|
||||
protected:
|
||||
|
Loading…
Reference in New Issue
Block a user