diff --git a/android/src/main/java/org/fossasia/badgemagic/ui/fragments/SettingsFragment.kt b/android/src/main/java/org/fossasia/badgemagic/ui/fragments/SettingsFragment.kt index 882ecd96e..f1381db62 100644 --- a/android/src/main/java/org/fossasia/badgemagic/ui/fragments/SettingsFragment.kt +++ b/android/src/main/java/org/fossasia/badgemagic/ui/fragments/SettingsFragment.kt @@ -40,8 +40,11 @@ class SettingsFragment : BaseFragment() { Snackbar .make(view, requireContext().getString(R.string.change_language), Snackbar.LENGTH_INDEFINITE) .setAction("RESTART") { - requireActivity().finishAffinity() - startActivity(requireActivity().intent) + + activity?.let { + it.finishAffinity() + startActivity(requireActivity().intent) + } } .show() }) diff --git a/android/src/main/java/org/fossasia/badgemagic/viewmodels/SavedClipartViewModel.kt b/android/src/main/java/org/fossasia/badgemagic/viewmodels/SavedClipartViewModel.kt index 80adfd79f..572bc6412 100644 --- a/android/src/main/java/org/fossasia/badgemagic/viewmodels/SavedClipartViewModel.kt +++ b/android/src/main/java/org/fossasia/badgemagic/viewmodels/SavedClipartViewModel.kt @@ -15,7 +15,8 @@ class SavedClipartViewModel( fun getStorageClipartLiveData() = clipArtService.getClipsFromStorage() fun deleteClipart(position: Int) { - clipArtService.deleteClipart(cliparts[position].fileName) + if (cliparts.isNotEmpty() && position < cliparts.size) + clipArtService.deleteClipart(cliparts[position].fileName) } fun setList(list: List) {