Browse Source

Fixed unessesary drop inrdicators

pull/71/head
babaliaris 4 years ago
parent
commit
44d2d85177
  1. 21
      app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksFragment.java

21
app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksFragment.java

@ -129,16 +129,19 @@ public class BookmarksFragment extends Fragment {
Bookmark indicator = new Bookmark("Drop Here", "-1", true); Bookmark indicator = new Bookmark("Drop Here", "-1", true);
//Add the indicator followed by the current actual bookmark. //Add the indicator followed by the current actual bookmark.
new_bookmarks.add(indicator); if (position != i-1 && position != i)
new_bookmarks.add(indicator);
new_bookmarks.add(bookmarks.get(i)); new_bookmarks.add(bookmarks.get(i));
} }
//Add one last indicator.
if (position != bookmarks.size() - 1)
new_bookmarks.add(new Bookmark("Drop Here", "-1", true));
//Replace the bookmarks with the new bookmarks that contains the indicators. //Replace the bookmarks with the new bookmarks that contains the indicators.
bookmarks = new_bookmarks; bookmarks = new_bookmarks;
//Add one last indicator.
bookmarks.add(new Bookmark("Drop Here", "-1", true));
//Notify the adapter that the bookmarks array has changed! //Notify the adapter that the bookmarks array has changed!
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
} }
@ -152,12 +155,12 @@ public class BookmarksFragment extends Fragment {
@Override @Override
public void onItemDragEnded(int fromPosition, int toPosition) public void onItemDragEnded(int fromPosition, int toPosition)
{ {
//It's hard to explain what this does.
int actualPos = fromPosition;
//This is VERY IMPORTANT: Because I added indicator boxes //It's hard to explain what this does.
//in the onItemDragStarted, I need to recalculate the actual position if (fromPosition != 0)
//of the started item (fromPosition) because it has changed!!! actualPos = 2 * fromPosition;
int offset = fromPosition + 1;
int actualPos = fromPosition + offset;
//If the drag and drop is not the same item. //If the drag and drop is not the same item.
if (actualPos != toPosition) if (actualPos != toPosition)

Loading…
Cancel
Save