mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-27 19:38:22 +01:00
Modify the behaviour of ItemTouchHelper.
This commit is contained in:
parent
fd63dba91b
commit
c2360ca59a
@ -177,6 +177,7 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
|
||||
@Override
|
||||
public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) {
|
||||
if (touchHelper != null) {
|
||||
exceedThreshold = false;
|
||||
touchHelper.attachToRecyclerView(null);
|
||||
touchHelper.attachToRecyclerView(mCommentRecyclerView);
|
||||
if (mAdapter != null) {
|
||||
@ -189,6 +190,7 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
|
||||
public void onChildDraw(@NonNull Canvas c, @NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
|
||||
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
|
||||
|
||||
if (isCurrentlyActive) {
|
||||
View itemView = viewHolder.itemView;
|
||||
int horizontalOffset = (int) Utils.convertDpToPixel(16, mActivity);
|
||||
if (dX > 0) {
|
||||
@ -233,11 +235,17 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
|
||||
backgroundSwipeLeft.draw(c);
|
||||
drawableSwipeLeft.draw(c);
|
||||
}
|
||||
} else {
|
||||
if (exceedThreshold) {
|
||||
mAdapter.onItemSwipe(viewHolder, dX > 0 ? ItemTouchHelper.END : ItemTouchHelper.START, swipeLeftAction, swipeRightAction);
|
||||
exceedThreshold = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSwipeThreshold(@NonNull RecyclerView.ViewHolder viewHolder) {
|
||||
return swipeActionThreshold;
|
||||
return 100;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -488,6 +488,7 @@ public class HistoryPostFragment extends Fragment implements FragmentCommunicato
|
||||
@Override
|
||||
public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) {
|
||||
if (touchHelper != null) {
|
||||
exceedThreshold = false;
|
||||
touchHelper.attachToRecyclerView(null);
|
||||
touchHelper.attachToRecyclerView(mPostRecyclerView);
|
||||
if (mAdapter != null) {
|
||||
@ -500,6 +501,7 @@ public class HistoryPostFragment extends Fragment implements FragmentCommunicato
|
||||
public void onChildDraw(@NonNull Canvas c, @NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
|
||||
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
|
||||
|
||||
if (isCurrentlyActive) {
|
||||
View itemView = viewHolder.itemView;
|
||||
int horizontalOffset = (int) Utils.convertDpToPixel(16, activity);
|
||||
if (dX > 0) {
|
||||
@ -544,11 +546,17 @@ public class HistoryPostFragment extends Fragment implements FragmentCommunicato
|
||||
backgroundSwipeLeft.draw(c);
|
||||
drawableSwipeLeft.draw(c);
|
||||
}
|
||||
} else {
|
||||
if (exceedThreshold) {
|
||||
mAdapter.onItemSwipe(viewHolder, dX > 0 ? ItemTouchHelper.END : ItemTouchHelper.START, swipeLeftAction, swipeRightAction);
|
||||
exceedThreshold = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSwipeThreshold(@NonNull RecyclerView.ViewHolder viewHolder) {
|
||||
return swipeActionThreshold;
|
||||
return 100;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1075,6 +1075,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
@Override
|
||||
public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) {
|
||||
if (touchHelper != null) {
|
||||
exceedThreshold = false;
|
||||
touchHelper.attachToRecyclerView(null);
|
||||
touchHelper.attachToRecyclerView(mPostRecyclerView);
|
||||
if (mAdapter != null) {
|
||||
@ -1087,6 +1088,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
public void onChildDraw(@NonNull Canvas c, @NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
|
||||
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
|
||||
|
||||
if (isCurrentlyActive) {
|
||||
View itemView = viewHolder.itemView;
|
||||
int horizontalOffset = (int) Utils.convertDpToPixel(16, activity);
|
||||
if (dX > 0) {
|
||||
@ -1131,11 +1133,19 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
backgroundSwipeLeft.draw(c);
|
||||
drawableSwipeLeft.draw(c);
|
||||
}
|
||||
} else {
|
||||
if (exceedThreshold) {
|
||||
mAdapter.onItemSwipe(viewHolder, dX > 0 ? ItemTouchHelper.END : ItemTouchHelper.START, swipeLeftAction, swipeRightAction);
|
||||
exceedThreshold = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSwipeThreshold(@NonNull RecyclerView.ViewHolder viewHolder) {
|
||||
return swipeActionThreshold;
|
||||
return 100;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -458,6 +458,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
@Override
|
||||
public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) {
|
||||
if (touchHelper != null) {
|
||||
exceedThreshold = false;
|
||||
touchHelper.attachToRecyclerView(null);
|
||||
touchHelper.attachToRecyclerView((mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView));
|
||||
if (mCommentsAdapter != null) {
|
||||
@ -470,6 +471,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
public void onChildDraw(@NonNull Canvas c, @NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
|
||||
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
|
||||
|
||||
if (isCurrentlyActive) {
|
||||
View itemView = viewHolder.itemView;
|
||||
int horizontalOffset = (int) Utils.convertDpToPixel(16, activity);
|
||||
if (dX > 0) {
|
||||
@ -514,11 +516,19 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
backgroundSwipeLeft.draw(c);
|
||||
drawableSwipeLeft.draw(c);
|
||||
}
|
||||
} else {
|
||||
if (exceedThreshold) {
|
||||
if (mCommentsAdapter != null) {
|
||||
mCommentsAdapter.onItemSwipe(viewHolder, dX > 0 ? ItemTouchHelper.END : ItemTouchHelper.START, swipeLeftAction, swipeRightAction);
|
||||
}
|
||||
exceedThreshold = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSwipeThreshold(@NonNull RecyclerView.ViewHolder viewHolder) {
|
||||
return swipeActionThreshold;
|
||||
return 100;
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user