From a9187fb484c4d12137c7919a2a53339d67cab0cb Mon Sep 17 00:00:00 2001 From: Leigh Douglas Date: Mon, 21 Oct 2024 16:17:28 -0400 Subject: [PATCH] [no-jira] hotfix for 3.26.0 release - crashes in discovery fragment when context is null (#2154) --- app/external_version_code.txt | 2 +- app/external_version_name.txt | 2 +- app/internal_version_code.txt | 2 +- app/internal_version_name.txt | 2 +- .../ui/fragments/DiscoveryFragment.kt | 51 ++++++++++++------- 5 files changed, 38 insertions(+), 21 deletions(-) diff --git a/app/external_version_code.txt b/app/external_version_code.txt index b62c943b06..c4ad1364f5 100644 --- a/app/external_version_code.txt +++ b/app/external_version_code.txt @@ -1 +1 @@ -2014150918 +2014150919 diff --git a/app/external_version_name.txt b/app/external_version_name.txt index 427f3464e5..419ede3b9c 100644 --- a/app/external_version_name.txt +++ b/app/external_version_name.txt @@ -1 +1 @@ -3.25.2 +3.26.0 diff --git a/app/internal_version_code.txt b/app/internal_version_code.txt index b62c943b06..c4ad1364f5 100644 --- a/app/internal_version_code.txt +++ b/app/internal_version_code.txt @@ -1 +1 @@ -2014150918 +2014150919 diff --git a/app/internal_version_name.txt b/app/internal_version_name.txt index a6b31b4483..1c92f6b11a 100644 --- a/app/internal_version_name.txt +++ b/app/internal_version_name.txt @@ -1 +1 @@ -3.25.2 \ No newline at end of file +3.26.0 \ No newline at end of file diff --git a/app/src/main/java/com/kickstarter/ui/fragments/DiscoveryFragment.kt b/app/src/main/java/com/kickstarter/ui/fragments/DiscoveryFragment.kt index 737cf96cfb..ed1adf2c2c 100644 --- a/app/src/main/java/com/kickstarter/ui/fragments/DiscoveryFragment.kt +++ b/app/src/main/java/com/kickstarter/ui/fragments/DiscoveryFragment.kt @@ -262,17 +262,28 @@ class DiscoveryFragment : Fragment() { } private fun startActivityFeedActivity() { - startActivity(Intent(activity, ActivityFeedActivity::class.java)) + context?.let { + startActivity(Intent(context, ActivityFeedActivity::class.java)) + } } private fun startSetPasswordActivity(email: String) { - val intent = Intent().getSetPasswordActivity(requireContext(), email) - startActivityForResult(intent, ActivityRequestCodes.LOGIN_FLOW) - TransitionUtils.transition(requireContext(), TransitionUtils.fadeIn()) + context?.let { + val intent = Intent().getSetPasswordActivity(requireContext(), email) + startActivityForResult(intent, ActivityRequestCodes.LOGIN_FLOW) + TransitionUtils.transition(requireContext(), TransitionUtils.fadeIn()) + } } private fun showStarToast() { - ViewUtils.showToastFromTop(requireContext(), getString(this.projectStarConfirmationString), 0, resources.getDimensionPixelSize(R.dimen.grid_8)) + context?.let { + ViewUtils.showToastFromTop( + requireContext(), + getString(this.projectStarConfirmationString), + 0, + resources.getDimensionPixelSize(R.dimen.grid_8) + ) + } } private fun startEditorialActivity(editorial: Editorial) { @@ -288,21 +299,27 @@ class DiscoveryFragment : Fragment() { } private fun startLoginToutActivity() { - val intent = Intent(activity, LoginToutActivity::class.java) - .putExtra(IntentKey.LOGIN_REASON, LoginReason.DEFAULT) - startActivityForResult(intent, ActivityRequestCodes.LOGIN_FLOW) context?.let { + val intent = Intent(context, LoginToutActivity::class.java) + .putExtra(IntentKey.LOGIN_REASON, LoginReason.DEFAULT) + startActivityForResult(intent, ActivityRequestCodes.LOGIN_FLOW) TransitionUtils.transition(it, TransitionUtils.fadeIn()) } } private fun startPreLaunchProjectActivity(project: Project, refTag: RefTag) { - val intent = Intent().getPreLaunchProjectActivity(requireContext(), project.slug()) - .putExtra(IntentKey.REF_TAG, refTag) - .putExtra(IntentKey.PREVIOUS_SCREEN, ThirdPartyEventValues.ScreenName.DISCOVERY.value) - startActivity(intent) - TransitionUtils.transition(requireContext(), TransitionUtils.slideInFromRight()) + context?.let { + val intent = Intent().getPreLaunchProjectActivity(requireContext(), project.slug()) + .putExtra(IntentKey.REF_TAG, refTag) + .putExtra( + IntentKey.PREVIOUS_SCREEN, + ThirdPartyEventValues.ScreenName.DISCOVERY.value + ) + startActivity(intent) + TransitionUtils.transition(requireContext(), TransitionUtils.slideInFromRight()) + } } + private fun startProjectActivity(project: Project, refTag: RefTag) { context?.let { val intent = Intent().getProjectIntent(it) @@ -315,11 +332,11 @@ class DiscoveryFragment : Fragment() { } private fun startUpdateActivity(activity: Activity) { - val intent = Intent(getActivity(), UpdateActivity::class.java) - .putExtra(IntentKey.PROJECT, activity.project()) - .putExtra(IntentKey.UPDATE, activity.update()) - startActivity(intent) context?.let { + val intent = Intent(context, UpdateActivity::class.java) + .putExtra(IntentKey.PROJECT, activity.project()) + .putExtra(IntentKey.UPDATE, activity.update()) + startActivity(intent) TransitionUtils.transition(it, TransitionUtils.slideInFromRight()) } }