]> git.ktnx.net Git - mobile-ledger.git/commitdiff
touch helper: avoid moving an item to its present position
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Mon, 8 Feb 2021 05:47:16 +0000 (05:47 +0000)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Thu, 18 Feb 2021 07:33:52 +0000 (07:33 +0000)
app/src/main/java/net/ktnx/mobileledger/ui/templates/TemplateDetailsAdapter.java

index a12c92b68d3daf955429deab274d9cdac512e61e..297fa73e3f012c7bd42b40cc6047d228b4c32cda 100644 (file)
@@ -166,6 +166,16 @@ class TemplateDetailsAdapter extends RecyclerView.Adapter<TemplateDetailsAdapter
 
                 final int fromPosition = viewHolder.getAdapterPosition();
                 final int toPosition = target.getAdapterPosition();
+                if (fromPosition == toPosition) {
+                    Logger.debug("drag", String.format(Locale.US,
+                            "Ignoring request to move an account from position %d to %d",
+                            fromPosition, toPosition));
+                    return false;
+                }
+
+                Logger.debug("drag",
+                        String.format(Locale.US, "Moving account from %d to %d", fromPosition,
+                                toPosition));
                 mModel.moveItem(fromPosition, toPosition);
 
                 return true;