Skip to content

Commit

Permalink
Null guards
Browse files Browse the repository at this point in the history
Fixes #3055
Fixes #3364
  • Loading branch information
TranceLove committed Oct 25, 2023
1 parent 6783e4d commit f9764f0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,11 @@ class FileHandler(
!mainFragmentViewModel.isList
)
} else {
val itemList = main.elementsList ?: listOf()
// we already have some elements in list view, invalidate the adapter
(listView.adapter as RecyclerAdapter).setItems(listView, itemList)
listView.adapter?.let {
val itemList = main.elementsList ?: listOf()
// we already have some elements in list view, invalidate the adapter
(listView.adapter as RecyclerAdapter).setItems(listView, itemList)
}
}
} else {
// there was no list view, means the directory was empty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,25 +536,29 @@ public void returnIntentResults(HybridFileParcelable baseFile) {

requireMainActivity().mReturnIntent = false;

Uri mediaStoreUri = Utils.getUriForBaseFile(requireActivity(), baseFile);
LOG.debug(
mediaStoreUri.toString()
+ "\t"
+ MimeTypes.getMimeType(baseFile.getPath(), baseFile.isDirectory()));
Intent intent = new Intent();
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setAction(Intent.ACTION_SEND);

if (requireMainActivity().mRingtonePickerIntent) {
intent.setDataAndType(
mediaStoreUri, MimeTypes.getMimeType(baseFile.getPath(), baseFile.isDirectory()));
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI, mediaStoreUri);
@Nullable Uri mediaStoreUri = Utils.getUriForBaseFile(requireActivity(), baseFile);
if(mediaStoreUri != null) {
LOG.debug(
mediaStoreUri.toString()
+ "\t"
+ MimeTypes.getMimeType(baseFile.getPath(), baseFile.isDirectory()));
Intent intent = new Intent();
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setAction(Intent.ACTION_SEND);

if (requireMainActivity().mRingtonePickerIntent) {
intent.setDataAndType(
mediaStoreUri, MimeTypes.getMimeType(baseFile.getPath(), baseFile.isDirectory()));
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI, mediaStoreUri);
} else {
LOG.debug("pickup file");
intent.setDataAndType(mediaStoreUri, MimeTypes.getExtension(baseFile.getPath()));
}
requireActivity().setResult(FragmentActivity.RESULT_OK, intent);
} else {
LOG.debug("pickup file");
intent.setDataAndType(mediaStoreUri, MimeTypes.getExtension(baseFile.getPath()));
LOG.warn("Unable to get URI from baseFile [{}]", baseFile.getPath());
}
getActivity().setResult(FragmentActivity.RESULT_OK, intent);
getActivity().finish();
requireActivity().finish();
}

LoadFilesListTask loadFilesListTask;
Expand Down

0 comments on commit f9764f0

Please sign in to comment.