From d370cd17ecbd5b268603ea1d27ba7aebaae88d2c Mon Sep 17 00:00:00 2001 From: meiron03 Date: Sat, 6 Jan 2024 12:27:39 -0500 Subject: [PATCH] Fix issue where the app crashes on first run after emulator restarts. --- .../labs/pennmobile/more_fragments/MoreFragment.kt | 12 ++++++++---- .../pennmobile/more_fragments/PreferenceFragment.kt | 4 ++-- PennMobile/src/main/res/layout/fragment_about.xml | 3 ++- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/more_fragments/MoreFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/more_fragments/MoreFragment.kt index 74a6ce46..ad9a1bbc 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/more_fragments/MoreFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/more_fragments/MoreFragment.kt @@ -24,10 +24,6 @@ class MoreFragment : Fragment() { super.onCreate(savedInstanceState) mActivity = activity as MainActivity mActivity.closeKeyboard() - parentFragmentManager.beginTransaction() - .replace(R.id.more_frame, PreferenceFragment()) - .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN) - .commit() } override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { @@ -37,6 +33,14 @@ class MoreFragment : Fragment() { return view } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + childFragmentManager.beginTransaction() + .replace(R.id.more_frame, PreferenceFragment()) + .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN) + .commit() + } + private fun initAppBar(view: View) { view.date_view.text = Utils.getCurrentSystemTime() // Appbar behavior init diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/more_fragments/PreferenceFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/more_fragments/PreferenceFragment.kt index 3988b761..5fcafaa5 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/more_fragments/PreferenceFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/more_fragments/PreferenceFragment.kt @@ -113,7 +113,7 @@ class PreferenceFragment : PreferenceFragmentCompat() { val aboutFeaturePref: Preference? = findPreference("pref_about_feature") aboutFeaturePref?.setOnPreferenceClickListener { mActivity.supportFragmentManager.beginTransaction() - .replace(R.id.more_frame, AboutFragment()) + .replace(R.id.content_frame, AboutFragment()) .addToBackStack(null) .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN) .commit() @@ -254,4 +254,4 @@ class PreferenceFragment : PreferenceFragmentCompat() { private const val PathAtPenn = "https://path.at.upenn.edu/" private const val PennPortal = "https://portal.apps.upenn.edu/penn_portal" } -} \ No newline at end of file +} diff --git a/PennMobile/src/main/res/layout/fragment_about.xml b/PennMobile/src/main/res/layout/fragment_about.xml index 57f197d9..14a8cf07 100644 --- a/PennMobile/src/main/res/layout/fragment_about.xml +++ b/PennMobile/src/main/res/layout/fragment_about.xml @@ -4,7 +4,8 @@ xmlns:tools="http://schemas.android.com/tools" android:id="@+id/coordinator" android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_height="match_parent" + android:background="@color/white">