diff --git a/app/src/main/java/com/amaze/filemanager/adapters/RecyclerAdapter.java b/app/src/main/java/com/amaze/filemanager/adapters/RecyclerAdapter.java index ace6284542..0d98940798 100644 --- a/app/src/main/java/com/amaze/filemanager/adapters/RecyclerAdapter.java +++ b/app/src/main/java/com/amaze/filemanager/adapters/RecyclerAdapter.java @@ -329,6 +329,8 @@ public void toggleInverse(String path) { notifyItemChanged(i); } } + invalidateSelection(); + invalidateActionMode(); } public void toggleSameTypes() { diff --git a/app/src/main/java/com/amaze/filemanager/asynchronous/asynctasks/LoadFilesListTask.java b/app/src/main/java/com/amaze/filemanager/asynchronous/asynctasks/LoadFilesListTask.java index 6de0985902..ecc7cd0d65 100644 --- a/app/src/main/java/com/amaze/filemanager/asynchronous/asynctasks/LoadFilesListTask.java +++ b/app/src/main/java/com/amaze/filemanager/asynchronous/asynctasks/LoadFilesListTask.java @@ -130,7 +130,8 @@ public LoadFilesListTask( if (mainFragment == null || context == null || mainFragment.getMainFragmentViewModel() == null - || mainFragment.getMainActivityViewModel() == null) { + || mainFragment.getMainActivityViewModel() == null + || path == null) { cancel(true); return null; } @@ -201,7 +202,7 @@ public LoadFilesListTask( if (list != null && !(openmode == OpenMode.CUSTOM && (("5").equals(path) || ("6").equals(path) || ("7").equals(path)))) { - postListCustomPathProcess(list, mainFragment); + postListCustomPathProcess(list, mainFragmentViewModel); } return new Pair<>(openmode, list); @@ -300,13 +301,12 @@ private List getCachedMediaList( } private void postListCustomPathProcess( - @NonNull List list, @NonNull MainFragment mainFragment) { + @NonNull List list, + @NonNull MainFragmentViewModel mainFragmentViewModel) { SortType sortType = SortHandler.getSortType(context.get(), path); - MainFragmentViewModel viewModel = mainFragment.getMainFragmentViewModel(); - - if (viewModel == null) { + if (mainFragmentViewModel == null) { LOG.error("MainFragmentViewModel is null, this is a bug"); return; } @@ -321,13 +321,13 @@ private void postListCustomPathProcess( } if (layoutElementParcelable.isDirectory) { - viewModel.incrementFolderCount(); + mainFragmentViewModel.incrementFolderCount(); } else { - viewModel.incrementFileCount(); + mainFragmentViewModel.incrementFileCount(); } } - Collections.sort(list, new FileListSorter(viewModel.getDsort(), sortType)); + Collections.sort(list, new FileListSorter(mainFragmentViewModel.getDsort(), sortType)); } private @Nullable LayoutElementParcelable createListParcelables(HybridFileParcelable baseFile) { diff --git a/app/src/main/java/com/amaze/filemanager/ui/views/appbar/BottomBar.java b/app/src/main/java/com/amaze/filemanager/ui/views/appbar/BottomBar.java index 4385a620e6..41e2de943c 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/views/appbar/BottomBar.java +++ b/app/src/main/java/com/amaze/filemanager/ui/views/appbar/BottomBar.java @@ -197,9 +197,8 @@ public boolean onSingleTapConfirmed(MotionEvent e) { @Override public void onLongPress(MotionEvent e) { final MainFragment mainFragment = mainActivity.getCurrentMainFragment(); - Objects.requireNonNull(mainFragment); if (mainActivity.getBoolean(PREFERENCE_CHANGEPATHS) - && (mainFragment.getMainFragmentViewModel() != null + && (mainFragment != null && mainFragment.getMainFragmentViewModel() != null || buttons.getVisibility() == View.VISIBLE)) { GeneralDialogCreation.showChangePathsDialog( mainActivity, mainActivity.getPrefs());