mirror of
https://gitee.com/houstudio/Cdroid.git
synced 2024-11-30 03:08:12 +08:00
fix some memleak of itemtouchhelper
This commit is contained in:
parent
c5ebaa5009
commit
1a95f27a9a
@ -18,9 +18,9 @@ bool ItemTouchHelper::onInterceptTouchEvent(RecyclerView& recyclerView,MotionEve
|
|||||||
mInitialTouchX -= animation->mX;
|
mInitialTouchX -= animation->mX;
|
||||||
mInitialTouchY -= animation->mY;
|
mInitialTouchY -= animation->mY;
|
||||||
endRecoverAnimation(*animation->mViewHolder, true);
|
endRecoverAnimation(*animation->mViewHolder, true);
|
||||||
auto it=std::find(mPendingCleanup.begin(),mPendingCleanup.end(),animation->mViewHolder->itemView);
|
auto it=std::find(mPendingCleanup.begin(),mPendingCleanup.end(),animation->mViewHolder->itemView);
|
||||||
if (it!=mPendingCleanup.end()){//remove(animation->mViewHolder->itemView)) {
|
if (it!=mPendingCleanup.end()){//remove(animation->mViewHolder->itemView)) {
|
||||||
mPendingCleanup.erase(it);
|
mPendingCleanup.erase(it);
|
||||||
mCallback->clearView(*mRecyclerView, *animation->mViewHolder);
|
mCallback->clearView(*mRecyclerView, *animation->mViewHolder);
|
||||||
}
|
}
|
||||||
select(animation->mViewHolder, animation->mActionState);
|
select(animation->mViewHolder, animation->mActionState);
|
||||||
@ -165,6 +165,7 @@ void ItemTouchHelper::destroyCallbacks() {
|
|||||||
for (int i = recoverAnimSize - 1; i >= 0; i--) {
|
for (int i = recoverAnimSize - 1; i >= 0; i--) {
|
||||||
RecoverAnimation* recoverAnimation = mRecoverAnimations.at(0);
|
RecoverAnimation* recoverAnimation = mRecoverAnimations.at(0);
|
||||||
mCallback->clearView(*mRecyclerView, *recoverAnimation->mViewHolder);
|
mCallback->clearView(*mRecyclerView, *recoverAnimation->mViewHolder);
|
||||||
|
delete recoverAnimation;
|
||||||
}
|
}
|
||||||
mRecoverAnimations.clear();
|
mRecoverAnimations.clear();
|
||||||
mOverdrawChild = nullptr;
|
mOverdrawChild = nullptr;
|
||||||
@ -250,7 +251,7 @@ void ItemTouchHelper::select(RecyclerView::ViewHolder* selected, int actionState
|
|||||||
bool preventLayout = false;
|
bool preventLayout = false;
|
||||||
|
|
||||||
if (mSelected != nullptr) {
|
if (mSelected != nullptr) {
|
||||||
RecyclerView::ViewHolder* prevSelected = mSelected;
|
RecyclerView::ViewHolder* prevSelected = mSelected;
|
||||||
if (prevSelected->itemView->getParent()) {
|
if (prevSelected->itemView->getParent()) {
|
||||||
const int swipeDir = prevActionState == ACTION_STATE_DRAG ? 0
|
const int swipeDir = prevActionState == ACTION_STATE_DRAG ? 0
|
||||||
: swipeIfNecessary(*prevSelected);
|
: swipeIfNecessary(*prevSelected);
|
||||||
@ -557,6 +558,7 @@ void ItemTouchHelper::endRecoverAnimation(RecyclerView::ViewHolder& viewHolder,
|
|||||||
anim->cancel();
|
anim->cancel();
|
||||||
}
|
}
|
||||||
mRecoverAnimations.erase(mRecoverAnimations.begin()+i);//remove(i);
|
mRecoverAnimations.erase(mRecoverAnimations.begin()+i);//remove(i);
|
||||||
|
delete anim;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,7 @@ public:
|
|||||||
int viewSize, int viewSizeOutOfBounds,int totalSize, long msSinceStartScroll);
|
int viewSize, int viewSizeOutOfBounds,int totalSize, long msSinceStartScroll);
|
||||||
};
|
};
|
||||||
|
|
||||||
class ItemTouchHelper::SimpleCallback:public ItemTouchHelper::Callback{// ItemTouchHelper::Callback {
|
class ItemTouchHelper::SimpleCallback:public ItemTouchHelper::Callback{
|
||||||
private:
|
private:
|
||||||
friend ItemTouchHelper;
|
friend ItemTouchHelper;
|
||||||
int mDefaultSwipeDirs;
|
int mDefaultSwipeDirs;
|
||||||
@ -232,5 +232,3 @@ public:
|
|||||||
};
|
};
|
||||||
}/*endof namespace*/
|
}/*endof namespace*/
|
||||||
#endif/*__ITEMTOUCH_HELPER_H__*/
|
#endif/*__ITEMTOUCH_HELPER_H__*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,15 +3,15 @@ namespace cdroid{
|
|||||||
|
|
||||||
LinearSmoothScroller::LinearSmoothScroller(Context* context) {
|
LinearSmoothScroller::LinearSmoothScroller(Context* context) {
|
||||||
mDisplayMetrics = context->getDisplayMetrics();
|
mDisplayMetrics = context->getDisplayMetrics();
|
||||||
mLinearInterpolator = new LinearInterpolator();
|
mLinearInterpolator = LinearInterpolator::gLinearInterpolator.get();
|
||||||
mDecelerateInterpolator = new DecelerateInterpolator();
|
mDecelerateInterpolator = DecelerateInterpolator::gDecelerateInterpolator.get();
|
||||||
mTargetVectorUsable = false;
|
mTargetVectorUsable = false;
|
||||||
mHasCalculatedMillisPerPixel = false;
|
mHasCalculatedMillisPerPixel = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
LinearSmoothScroller::~LinearSmoothScroller(){
|
LinearSmoothScroller::~LinearSmoothScroller(){
|
||||||
delete mLinearInterpolator;
|
//delete mLinearInterpolator;
|
||||||
delete mDecelerateInterpolator;
|
//delete mDecelerateInterpolator;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LinearSmoothScroller::onStart() {
|
void LinearSmoothScroller::onStart() {
|
||||||
|
Loading…
Reference in New Issue
Block a user