Skip to content

Commit 4af78df

Browse files
authored
Merge pull request #4344 from TeamAmaze/fix-npes
fix npes
2 parents 265803a + 8ddeae5 commit 4af78df

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

app/src/main/java/com/amaze/filemanager/adapters/RecyclerAdapter.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,8 @@ public void toggleInverse(String path) {
329329
notifyItemChanged(i);
330330
}
331331
}
332+
invalidateSelection();
333+
invalidateActionMode();
332334
}
333335

334336
public void toggleSameTypes() {

app/src/main/java/com/amaze/filemanager/asynchronous/asynctasks/LoadFilesListTask.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ public LoadFilesListTask(
130130
if (mainFragment == null
131131
|| context == null
132132
|| mainFragment.getMainFragmentViewModel() == null
133-
|| mainFragment.getMainActivityViewModel() == null) {
133+
|| mainFragment.getMainActivityViewModel() == null
134+
|| path == null) {
134135
cancel(true);
135136
return null;
136137
}
@@ -201,7 +202,7 @@ public LoadFilesListTask(
201202
if (list != null
202203
&& !(openmode == OpenMode.CUSTOM
203204
&& (("5").equals(path) || ("6").equals(path) || ("7").equals(path)))) {
204-
postListCustomPathProcess(list, mainFragment);
205+
postListCustomPathProcess(list, mainFragmentViewModel);
205206
}
206207

207208
return new Pair<>(openmode, list);
@@ -300,13 +301,12 @@ private List<LayoutElementParcelable> getCachedMediaList(
300301
}
301302

302303
private void postListCustomPathProcess(
303-
@NonNull List<LayoutElementParcelable> list, @NonNull MainFragment mainFragment) {
304+
@NonNull List<LayoutElementParcelable> list,
305+
@NonNull MainFragmentViewModel mainFragmentViewModel) {
304306

305307
SortType sortType = SortHandler.getSortType(context.get(), path);
306308

307-
MainFragmentViewModel viewModel = mainFragment.getMainFragmentViewModel();
308-
309-
if (viewModel == null) {
309+
if (mainFragmentViewModel == null) {
310310
LOG.error("MainFragmentViewModel is null, this is a bug");
311311
return;
312312
}
@@ -321,13 +321,13 @@ private void postListCustomPathProcess(
321321
}
322322

323323
if (layoutElementParcelable.isDirectory) {
324-
viewModel.incrementFolderCount();
324+
mainFragmentViewModel.incrementFolderCount();
325325
} else {
326-
viewModel.incrementFileCount();
326+
mainFragmentViewModel.incrementFileCount();
327327
}
328328
}
329329

330-
Collections.sort(list, new FileListSorter(viewModel.getDsort(), sortType));
330+
Collections.sort(list, new FileListSorter(mainFragmentViewModel.getDsort(), sortType));
331331
}
332332

333333
private @Nullable LayoutElementParcelable createListParcelables(HybridFileParcelable baseFile) {

app/src/main/java/com/amaze/filemanager/ui/views/appbar/BottomBar.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,8 @@ public boolean onSingleTapConfirmed(MotionEvent e) {
197197
@Override
198198
public void onLongPress(MotionEvent e) {
199199
final MainFragment mainFragment = mainActivity.getCurrentMainFragment();
200-
Objects.requireNonNull(mainFragment);
201200
if (mainActivity.getBoolean(PREFERENCE_CHANGEPATHS)
202-
&& (mainFragment.getMainFragmentViewModel() != null
201+
&& (mainFragment != null && mainFragment.getMainFragmentViewModel() != null
203202
|| buttons.getVisibility() == View.VISIBLE)) {
204203
GeneralDialogCreation.showChangePathsDialog(
205204
mainActivity, mainActivity.getPrefs());

0 commit comments

Comments
 (0)