From 9974ebc543ce1f24a677a62cf000caf7c61c07b0 Mon Sep 17 00:00:00 2001 From: Aditya Gupta Date: Sun, 9 Feb 2020 15:13:46 +0000 Subject: [PATCH] fix: app launch issues --- .../fossasia/badgemagic/ui/fragments/SettingsFragment.kt | 7 +++++-- .../badgemagic/viewmodels/SavedClipartViewModel.kt | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) 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) {