Commit f984f623 by Paktalin

Fixed bug with fragments being added twice

parent 51570a31
...@@ -10,8 +10,8 @@ android { ...@@ -10,8 +10,8 @@ android {
applicationId "com.paktalin.vocabularynotebook" applicationId "com.paktalin.vocabularynotebook"
minSdkVersion 15 minSdkVersion 15
targetSdkVersion 28 targetSdkVersion 28
versionCode 2 versionCode 3
versionName "1.1" versionName "1.2"
multiDexEnabled true multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables { vectorDrawables {
......
...@@ -15,6 +15,9 @@ val progressFragment: Fragment = ProgressFragment() ...@@ -15,6 +15,9 @@ val progressFragment: Fragment = ProgressFragment()
fun addFragment(fragmentManager: FragmentManager, fragment: Fragment, containerId: Int, arguments: Bundle?) { fun addFragment(fragmentManager: FragmentManager, fragment: Fragment, containerId: Int, arguments: Bundle?) {
fragment.arguments = arguments fragment.arguments = arguments
// remove progressFragment if it exists
if(fragmentManager.findFragmentById(fragment.id) != null)
removeFragment(fragmentManager, fragment)
fragmentManager.beginTransaction().add(containerId, fragment).commitAllowingStateLoss() fragmentManager.beginTransaction().add(containerId, fragment).commitAllowingStateLoss()
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment