|
51 | 51 |
|
52 | 52 | public class ItemsFragment extends android.support.v4.app.Fragment |
53 | 53 | implements AdapterView.OnItemClickListener, SwipeRefreshLayout.OnRefreshListener, ListView.MultiChoiceModeListener, |
54 | | - ListView.OnTouchListener, CopyMoveTask.CopyMoveListener { |
| 54 | + ListView.OnTouchListener { |
55 | 55 | @BindView(R.id.items_list) ListView mListView; |
56 | 56 | @BindView(R.id.items_swipe_refresh) SwipeRefreshLayout mSwipeRefreshLayout; |
57 | 57 | @BindView(R.id.items_holder) CoordinatorLayout mCoordinatorLayout; |
@@ -358,17 +358,34 @@ public void onSuccess() { |
358 | 358 | } |
359 | 359 |
|
360 | 360 | private void displayCopyDialog() { |
361 | | - final List<Integer> itemIndexes = getSelectedItemIndexes(); |
362 | | - if (itemIndexes.isEmpty()) |
| 361 | + final List<Integer> fileIndexes = getSelectedItemIndexes(); |
| 362 | + if (fileIndexes.isEmpty()) |
363 | 363 | return; |
364 | 364 |
|
365 | | - final ArrayList<File> itemsToCopy = new ArrayList<>(itemIndexes.size()); |
366 | | - for (Integer i : itemIndexes) { |
| 365 | + final ArrayList<File> files = new ArrayList<>(fileIndexes.size()); |
| 366 | + for (Integer i : fileIndexes) { |
367 | 367 | FileDirItem item = mItems.get(i); |
368 | | - itemsToCopy.add(new File(item.getPath())); |
| 368 | + files.add(new File(item.getPath())); |
369 | 369 | } |
370 | 370 |
|
371 | | - new CopyDialog((SimpleActivity) getActivity(), itemsToCopy, this); |
| 371 | + new CopyDialog((SimpleActivity) getActivity(), files, new CopyMoveTask.CopyMoveListener() { |
| 372 | + @Override |
| 373 | + public void copySucceeded(boolean deleted, boolean copiedAll) { |
| 374 | + int msgId; |
| 375 | + if (deleted) { |
| 376 | + fillItems(); |
| 377 | + msgId = copiedAll ? R.string.moving_success : R.string.moving_success_partial; |
| 378 | + } else { |
| 379 | + msgId = copiedAll? R.string.copying_success : R.string.copying_success_partial; |
| 380 | + } |
| 381 | + Utils.Companion.showToast(getContext(), msgId); |
| 382 | + } |
| 383 | + |
| 384 | + @Override |
| 385 | + public void copyFailed() { |
| 386 | + Utils.Companion.showToast(getContext(), R.string.copy_move_failed); |
| 387 | + } |
| 388 | + }); |
372 | 389 | } |
373 | 390 |
|
374 | 391 | private FileDirItem getSelectedItem() { |
@@ -476,17 +493,6 @@ public void onDestroyActionMode(ActionMode mode) { |
476 | 493 | mSelectedItemsCnt = 0; |
477 | 494 | } |
478 | 495 |
|
479 | | - @Override |
480 | | - public void copySucceeded(boolean deleted) { |
481 | | - fillItems(); |
482 | | - Utils.Companion.showToast(getContext(), deleted ? R.string.moving_success : R.string.copying_success); |
483 | | - } |
484 | | - |
485 | | - @Override |
486 | | - public void copyFailed() { |
487 | | - Utils.Companion.showToast(getContext(), R.string.copy_move_failed); |
488 | | - } |
489 | | - |
490 | 496 | public interface ItemInteractionListener { |
491 | 497 | void itemClicked(FileDirItem item); |
492 | 498 | } |
|
0 commit comments