Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix npes #4344

Draft
wants to merge 4 commits into
base: release/4.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ public void toggleInverse(String path) {
notifyItemChanged(i);
}
}
invalidateSelection();
invalidateActionMode();
}

public void toggleSameTypes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -300,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 @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Loading