Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8923911c authored by Ben Kwa's avatar Ben Kwa
Browse files

Fix a crash when deleting documents.

Deleting (and moving) documents invalidates previous selections, as
items change position.  Exit selection mode *before* actually deleting
anything, otherwise we end up trying to unselect potentially deleted
documents.

BUG=24338150

Change-Id: I79fb0c156142b78987be68560c78306f2678c521
parent ca309393
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -631,7 +631,6 @@ public class DirectoryFragment extends Fragment {

        @Override
        public void onItemStateChanged(int position, boolean selected) {

            final Cursor cursor = mModel.getItem(position);
            checkNotNull(cursor, "Cursor cannot be null.");

@@ -717,8 +716,9 @@ public class DirectoryFragment extends Fragment {
                return true;

            } else if (id == R.id.menu_delete) {
                deleteDocuments(selection);
                // Exit selection mode first, so we avoid deselecting deleted documents.
                mode.finish();
                deleteDocuments(selection);
                return true;

            } else if (id == R.id.menu_copy_to) {
@@ -727,8 +727,9 @@ public class DirectoryFragment extends Fragment {
                return true;

            } else if (id == R.id.menu_move_to) {
                transferDocuments(selection, CopyService.TRANSFER_MODE_MOVE);
                // Exit selection mode first, so we avoid deselecting deleted documents.
                mode.finish();
                transferDocuments(selection, CopyService.TRANSFER_MODE_MOVE);
                return true;

            } else if (id == R.id.menu_copy_to_clipboard) {