Skip to content

Commit

Permalink
[#2722] use already referenced non-null variable mainFragmentViewModel
Browse files Browse the repository at this point in the history
  • Loading branch information
VishnuSanal committed Jan 1, 2025
1 parent 77f5ee6 commit 255f9f0
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,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);
Expand Down Expand Up @@ -301,13 +301,12 @@ private List<LayoutElementParcelable> getCachedMediaList(
}

private void postListCustomPathProcess(
@NonNull List<LayoutElementParcelable> list, @NonNull MainFragment mainFragment) {
@NonNull List<LayoutElementParcelable> 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;
}
Expand All @@ -322,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) {
Expand Down

0 comments on commit 255f9f0

Please sign in to comment.