Skip to content

Commit

Permalink
Fix issue where the app crashes on first run after emulator restarts.
Browse files Browse the repository at this point in the history
  • Loading branch information
meiron03 committed Jan 6, 2024
1 parent c645054 commit d370cd1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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? {
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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"
}
}
}
3 changes: 2 additions & 1 deletion PennMobile/src/main/res/layout/fragment_about.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">

<LinearLayout
android:layout_width="match_parent"
Expand Down

0 comments on commit d370cd1

Please sign in to comment.