diff --git a/app/build.gradle b/app/build.gradle index b577d31069..9d4bf6203c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,8 +9,8 @@ android { applicationId "org.ole.planet.myplanet" minSdkVersion 21 targetSdkVersion 34 - versionCode 1182 - versionName "0.11.82" + versionCode 1183 + versionName "0.11.83" ndkVersion '21.3.6528147' testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true diff --git a/app/src/main/java/org/ole/planet/myplanet/base/BaseResourceFragment.java b/app/src/main/java/org/ole/planet/myplanet/base/BaseResourceFragment.java index ea3f7169ff..52d8076963 100644 --- a/app/src/main/java/org/ole/planet/myplanet/base/BaseResourceFragment.java +++ b/app/src/main/java/org/ole/planet/myplanet/base/BaseResourceFragment.java @@ -102,15 +102,17 @@ protected void showDownloadDialog(final List db_myLibrary) { @Override public void isAvailable() { if (!db_myLibrary.isEmpty()) { - LayoutInflater inflater = getLayoutInflater(); - convertView = inflater.inflate(R.layout.my_library_alertdialog, null); - AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity()); - alertDialogBuilder.setView(convertView).setTitle(R.string.download_suggestion); - alertDialogBuilder.setPositiveButton(R.string.download_selected, (dialogInterface, i) -> startDownload(DownloadUtils.downloadFiles(db_myLibrary, lv.getSelectedItemsList(), settings))).setNeutralButton(R.string.download_all, (dialogInterface, i) -> startDownload(DownloadUtils.downloadAllFiles(db_myLibrary, settings))).setNegativeButton(R.string.txt_cancel, null); - AlertDialog alertDialog = alertDialogBuilder.create(); - createListView(db_myLibrary, alertDialog); - alertDialog.show(); - (alertDialog).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(lv.getSelectedItemsList().size() > 0); + if (isAdded() && getActivity() != null) { + LayoutInflater inflater = getActivity().getLayoutInflater(); + convertView = inflater.inflate(R.layout.my_library_alertdialog, null); + AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity()); + alertDialogBuilder.setView(convertView).setTitle(R.string.download_suggestion); + alertDialogBuilder.setPositiveButton(R.string.download_selected, (dialogInterface, i) -> startDownload(DownloadUtils.downloadFiles(db_myLibrary, lv.getSelectedItemsList(), settings))).setNeutralButton(R.string.download_all, (dialogInterface, i) -> startDownload(DownloadUtils.downloadAllFiles(db_myLibrary, settings))).setNegativeButton(R.string.txt_cancel, null); + AlertDialog alertDialog = alertDialogBuilder.create(); + createListView(db_myLibrary, alertDialog); + alertDialog.show(); + (alertDialog).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(lv.getSelectedItemsList().size() > 0); + } } else { Utilities.toast(requireContext(), getString(R.string.no_resources_to_download)); }