diff --git a/app/src/main/java/org/ole/planet/myplanet/base/BaseDialogFragment.kt b/app/src/main/java/org/ole/planet/myplanet/base/BaseDialogFragment.kt index 298697e04f..76ea2a2eba 100644 --- a/app/src/main/java/org/ole/planet/myplanet/base/BaseDialogFragment.kt +++ b/app/src/main/java/org/ole/planet/myplanet/base/BaseDialogFragment.kt @@ -7,11 +7,13 @@ import androidx.fragment.app.DialogFragment abstract class BaseDialogFragment : DialogFragment() { @JvmField var id: String? = null + var teamId: String? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setStyle(STYLE_NO_TITLE, R.style.AppTheme_Dialog_NoActionBar_MinWidth) if (arguments != null) { id = requireArguments().getString(key) + teamId = requireArguments().getString("teamId") } } diff --git a/app/src/main/java/org/ole/planet/myplanet/base/BaseResourceFragment.kt b/app/src/main/java/org/ole/planet/myplanet/base/BaseResourceFragment.kt index bf9c5e2fc5..9cd57e0149 100644 --- a/app/src/main/java/org/ole/planet/myplanet/base/BaseResourceFragment.kt +++ b/app/src/main/java/org/ole/planet/myplanet/base/BaseResourceFragment.kt @@ -171,7 +171,7 @@ abstract class BaseResourceFragment : Fragment() { } AlertDialog.Builder(requireActivity()).setTitle("Pending Surveys") .setAdapter(arrayAdapter) { _: DialogInterface?, i: Int -> - AdapterMySubmission.openSurvey(homeItemClickListener, list[i].id, true) + AdapterMySubmission.openSurvey(homeItemClickListener, list[i].id, true, false, "") }.setPositiveButton(R.string.dismiss, null).show() } diff --git a/app/src/main/java/org/ole/planet/myplanet/model/RealmStepExam.kt b/app/src/main/java/org/ole/planet/myplanet/model/RealmStepExam.kt index 54bf32ae29..f35413787e 100644 --- a/app/src/main/java/org/ole/planet/myplanet/model/RealmStepExam.kt +++ b/app/src/main/java/org/ole/planet/myplanet/model/RealmStepExam.kt @@ -29,6 +29,7 @@ open class RealmStepExam : RealmObject() { var passingPercentage: String? = null var noOfQuestions = 0 var isFromNation = false + var teamId: String? = null companion object { val examDataList: MutableList> = mutableListOf() @@ -66,6 +67,7 @@ open class RealmStepExam : RealmObject() { myExam?.totalMarks = JsonUtils.getInt("totalMarks", exam) myExam?.noOfQuestions = JsonUtils.getJsonArray("questions", exam).size() myExam?.isFromNation = !TextUtils.isEmpty(parentId) + myExam.teamId = JsonUtils.getString("teamId", exam) val oldQuestions: RealmResults<*>? = mRealm.where(RealmExamQuestion::class.java).equalTo("examId", JsonUtils.getString("_id", exam)).findAll() if (oldQuestions == null || oldQuestions.isEmpty()) { RealmExamQuestion.insertExamQuestions(JsonUtils.getJsonArray("questions", exam), JsonUtils.getString("_id", exam), mRealm) @@ -84,8 +86,10 @@ open class RealmStepExam : RealmObject() { JsonUtils.getString("updatedDate", exam), JsonUtils.getString("totalMarks", exam), JsonUtils.getString("noOfQuestions", exam), - JsonUtils.getString("isFromNation", exam) + JsonUtils.getString("isFromNation", exam), + JsonUtils.getString("teamId", exam) ) + examDataList.add(csvRow) } @@ -94,7 +98,7 @@ open class RealmStepExam : RealmObject() { val file = File(filePath) file.parentFile?.mkdirs() val writer = CSVWriter(FileWriter(file)) - writer.writeNext(arrayOf("_id", "_rev", "name", "passingPercentage", "type", "createdBy", "sourcePlanet", "createdDate", "updatedDate", "totalMarks", "noOfQuestions", "isFromNation")) + writer.writeNext(arrayOf("_id", "_rev", "name", "passingPercentage", "type", "createdBy", "sourcePlanet", "createdDate", "updatedDate", "totalMarks", "noOfQuestions", "isFromNation", "teamId")) for (row in data) { writer.writeNext(row) } diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/courses/CourseStepFragment.kt b/app/src/main/java/org/ole/planet/myplanet/ui/courses/CourseStepFragment.kt index 2bd0edf5e2..2a9d992d01 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/courses/CourseStepFragment.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/courses/CourseStepFragment.kt @@ -184,7 +184,7 @@ class CourseStepFragment : BaseContainerFragment(), ImageCaptureCallback { fragmentCourseStepBinding.btnTakeSurvey.setOnClickListener { if (stepSurvey.isNotEmpty()) { - AdapterMySubmission.openSurvey(homeItemClickListener, stepSurvey[0].id, false) + AdapterMySubmission.openSurvey(homeItemClickListener, stepSurvey[0].id, false, false, "") } } val downloadedResources: List = cRealm.where(RealmMyLibrary::class.java).equalTo("stepId", stepId).equalTo("resourceOffline", true).isNotNull("resourceLocalAddress").findAll() diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/BaseDashboardFragment.kt b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/BaseDashboardFragment.kt index a098a68874..27898343f9 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/BaseDashboardFragment.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/BaseDashboardFragment.kt @@ -73,7 +73,7 @@ open class BaseDashboardFragment : BaseDashboardFragmentPlugin(), NotificationCa v.findViewById(R.id.ll_prompt).visibility = View.VISIBLE v.findViewById(R.id.ll_prompt).setOnClickListener { if (!childFragmentManager.isStateSaved) { - UserInformationFragment.getInstance("").show(childFragmentManager, "") + UserInformationFragment.getInstance("", "").show(childFragmentManager, "") } } } else { diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/BellDashboardFragment.kt b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/BellDashboardFragment.kt index 2af41dabbe..98a5494f69 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/BellDashboardFragment.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/BellDashboardFragment.kt @@ -132,7 +132,7 @@ class BellDashboardFragment : BaseDashboardFragment() { val adapter = SurveyAdapter(surveyTitles, { position -> val selectedSurvey = pendingSurveys[position].id - AdapterMySubmission.openSurvey(homeItemClickListener, selectedSurvey, true) + AdapterMySubmission.openSurvey(homeItemClickListener, selectedSurvey, true, false, "") }, alertDialog) recyclerView.adapter = adapter diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/notification/NotificationsFragment.kt b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/notification/NotificationsFragment.kt index b642cd3b88..7990f7adc3 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/notification/NotificationsFragment.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/notification/NotificationsFragment.kt @@ -107,8 +107,8 @@ class NotificationsFragment : Fragment() { "survey" -> { val currentStepExam = mRealm.where(RealmStepExam::class.java).equalTo("name", notification.relatedId) .findFirst() - if(context is OnHomeItemClickListener) { - AdapterMySubmission.openSurvey(context as OnHomeItemClickListener, currentStepExam?.id, false) + if (context is OnHomeItemClickListener) { + AdapterMySubmission.openSurvey(context as OnHomeItemClickListener, currentStepExam?.id, false, false, "") } } "task" -> { diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/exam/BaseExamFragment.kt b/app/src/main/java/org/ole/planet/myplanet/ui/exam/BaseExamFragment.kt index 5a7a0402be..c37300865e 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/exam/BaseExamFragment.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/exam/BaseExamFragment.kt @@ -5,6 +5,7 @@ import android.os.Bundle import android.text.Editable import android.text.TextUtils import android.text.TextWatcher +import android.util.Log import android.view.View import android.widget.CompoundButton import android.widget.EditText @@ -52,6 +53,9 @@ abstract class BaseExamFragment : Fragment(), ImageCaptureCallback { var date = Date().toString() private var photoPath: String? = "" var submitId = "" + private var isTeam: Boolean = false + private var teamId: String? = null + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) db = DatabaseService(requireActivity()) @@ -60,6 +64,8 @@ abstract class BaseExamFragment : Fragment(), ImageCaptureCallback { stepId = requireArguments().getString("stepId") stepNumber = requireArguments().getInt("stepNum") isMySurvey = requireArguments().getBoolean("isMySurvey") + isTeam = requireArguments().getBoolean("isTeam", false) + teamId = requireArguments().getString("teamId") checkId() checkType() } @@ -108,6 +114,9 @@ abstract class BaseExamFragment : Fragment(), ImageCaptureCallback { private fun continueExam() { if (currentIndex < (questions?.size ?: 0)) { startExam(questions?.get(currentIndex)) + } else if (isTeam == true && type?.startsWith("survey") == true) { + Log.d("okuro", "$teamId") + showUserInfoDialog() } else { saveCourseProgress() AlertDialog.Builder(requireActivity(), R.style.AlertDialogTheme) @@ -131,7 +140,8 @@ abstract class BaseExamFragment : Fragment(), ImageCaptureCallback { private fun showUserInfoDialog() { if (!isMySurvey && !exam?.isFromNation!!) { - UserInformationFragment.getInstance(sub?.id).show(childFragmentManager, "") + Log.d("called1", "exam called") + UserInformationFragment.getInstance(sub?.id, teamId).show(childFragmentManager, "") } else { if (!mRealm.isInTransaction) mRealm.beginTransaction() sub?.status = "complete" diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/exam/UserInformationFragment.kt b/app/src/main/java/org/ole/planet/myplanet/ui/exam/UserInformationFragment.kt index 6fa96ca8b4..ddc5621e92 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/exam/UserInformationFragment.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/exam/UserInformationFragment.kt @@ -16,11 +16,13 @@ import io.realm.Realm import org.ole.planet.myplanet.MainApplication import org.ole.planet.myplanet.R import org.ole.planet.myplanet.base.BaseDialogFragment +import org.ole.planet.myplanet.callback.OnHomeItemClickListener import org.ole.planet.myplanet.databinding.FragmentUserInformationBinding import org.ole.planet.myplanet.datamanager.DatabaseService import org.ole.planet.myplanet.model.RealmSubmission import org.ole.planet.myplanet.model.RealmUserModel import org.ole.planet.myplanet.service.UserProfileDbHandler +import org.ole.planet.myplanet.ui.team.TeamDetailFragment import org.ole.planet.myplanet.utilities.Utilities import java.util.Calendar import java.util.Locale @@ -31,6 +33,7 @@ class UserInformationFragment : BaseDialogFragment(), View.OnClickListener { lateinit var mRealm: Realm private var submissions: RealmSubmission? = null var userModel: RealmUserModel? = null + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { fragmentUserInformationBinding = FragmentUserInformationBinding.inflate(inflater, container, false) mRealm = DatabaseService(requireActivity()).realmInstance @@ -45,16 +48,8 @@ class UserInformationFragment : BaseDialogFragment(), View.OnClickListener { private fun initViews() { val langArray = resources.getStringArray(R.array.language).toMutableList() val levelArray = resources.getStringArray(R.array.level).toMutableList() - val adapterLang = ArrayAdapter( - requireContext(), - R.layout.spinner_item_white, - langArray - ) - val adapterLevel = ArrayAdapter( - requireContext(), - R.layout.spinner_item_white, - levelArray - ) + val adapterLang = ArrayAdapter(requireContext(), R.layout.spinner_item_white, langArray) + val adapterLevel = ArrayAdapter(requireContext(), R.layout.spinner_item_white, levelArray) adapterLang.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) adapterLevel.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) fragmentUserInformationBinding.spnLang.adapter = adapterLang @@ -67,13 +62,18 @@ class UserInformationFragment : BaseDialogFragment(), View.OnClickListener { val selectedView = fragmentUserInformationBinding.spnLevel.selectedView as? TextView selectedView?.setTextColor(ContextCompat.getColor(requireContext(), R.color.daynight_textColor)) } - fragmentUserInformationBinding.etEmail.setText(getString(R.string.message_placeholder, userModel?.email)) - fragmentUserInformationBinding.etFname.setText(getString(R.string.message_placeholder, userModel?.firstName)) - fragmentUserInformationBinding.etLname.setText(getString(R.string.message_placeholder, userModel?.lastName)) - fragmentUserInformationBinding.etPhone.setText(getString(R.string.message_placeholder, userModel?.phoneNumber)) - fragmentUserInformationBinding.txtDob.text = getString(R.string.message_placeholder, userModel?.dob) - dob = userModel?.dob - fragmentUserInformationBinding.btnCancel.setOnClickListener(this) +// fragmentUserInformationBinding.etEmail.setText(getString(R.string.message_placeholder, userModel?.email)) +// fragmentUserInformationBinding.etFname.setText(getString(R.string.message_placeholder, userModel?.firstName)) +// fragmentUserInformationBinding.etLname.setText(getString(R.string.message_placeholder, userModel?.lastName)) +// fragmentUserInformationBinding.etPhone.setText(getString(R.string.message_placeholder, userModel?.phoneNumber)) +// fragmentUserInformationBinding.txtDob.text = getString(R.string.message_placeholder, userModel?.dob) +// dob = userModel?.dob + if (teamId != null) { + fragmentUserInformationBinding.btnCancel.visibility = View.GONE + } else { + fragmentUserInformationBinding.btnCancel.setOnClickListener(this) + } + fragmentUserInformationBinding.btnSubmit.setOnClickListener(this) fragmentUserInformationBinding.txtDob.setOnClickListener(this) } @@ -157,7 +157,19 @@ class UserInformationFragment : BaseDialogFragment(), View.OnClickListener { override fun onDismiss(dialog: DialogInterface) { super.onDismiss(dialog) Utilities.toast(activity, getString(R.string.thank_you_for_taking_this_survey)) - BaseExamFragment.navigateToSurveyList(requireActivity()) + if (teamId == null) { + BaseExamFragment.navigateToSurveyList(requireActivity()) + } else { + if (context is OnHomeItemClickListener) { + val f = TeamDetailFragment() + val b = Bundle() + b.putString("id", teamId) + b.putBoolean("isMyTeam", true) + b.putInt("navigateToPage", 6) + f.arguments = b + (context as OnHomeItemClickListener).openCallFragment(f) + } + } } private fun showDatePickerDialog() { @@ -173,15 +185,16 @@ class UserInformationFragment : BaseDialogFragment(), View.OnClickListener { get() = "sub_id" companion object { - fun getInstance(id: String?): UserInformationFragment { + fun getInstance(id: String?, teamId: String?): UserInformationFragment { val f = UserInformationFragment() - setArgs(f, id) + setArgs(f, id, teamId) return f } - private fun setArgs(f: UserInformationFragment, id: String?) { + private fun setArgs(f: UserInformationFragment, id: String?, teamId: String?) { val b = Bundle() b.putString("sub_id", id) + b.putString("teamId", teamId) f.arguments = b } } diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/submission/AdapterMySubmission.kt b/app/src/main/java/org/ole/planet/myplanet/ui/submission/AdapterMySubmission.kt index 32bea6baf2..19d8e38c49 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/submission/AdapterMySubmission.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/submission/AdapterMySubmission.kt @@ -54,7 +54,7 @@ class AdapterMySubmission(private val context: Context, private val list: List() { +class AdapterSurvey(private val context: Context, private val mRealm: Realm, private val userId: String, private val isTeam: Boolean, val teamId: String?) : RecyclerView.Adapter() { private var examList: List = emptyList() private var listener: OnHomeItemClickListener? = null - private var user: RealmUserModel? = null init { if (context is OnHomeItemClickListener) { listener = context } - user = UserProfileDbHandler(context).userModel } fun updateData(newList: List) { @@ -63,7 +59,7 @@ class AdapterSurvey(private val context: Context, private val mRealm: Realm, pri binding.apply { tvTitle.text = exam.name startSurvey.setOnClickListener { - AdapterMySubmission.openSurvey(listener, exam.id, false) + AdapterMySubmission.openSurvey(listener, exam.id, false, isTeam, teamId) } val questions = mRealm.where(RealmExamQuestion::class.java) @@ -81,12 +77,12 @@ class AdapterSurvey(private val context: Context, private val mRealm: Realm, pri context.getString(R.string.record_survey) } - if (user?.id?.startsWith("guest") == true) { + if (userId.startsWith("guest") == true) { startSurvey.visibility = View.GONE } - tvNoSubmissions.text = getNoOfSubmissionByUser(exam.id, exam.courseId, user?.id, mRealm) - tvDateCompleted.text = getRecentSubmissionDate(exam.id, exam.courseId, user?.id, mRealm) + tvNoSubmissions.text = getNoOfSubmissionByUser(exam.id, exam.courseId, userId, mRealm) + tvDateCompleted.text = getRecentSubmissionDate(exam.id, exam.courseId, userId, mRealm) tvDate.text = formatDate(RealmStepExam.getSurveyCreationTime(exam.id!!, mRealm)!!, "MMM dd, yyyy") } } diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/survey/SurveyFragment.kt b/app/src/main/java/org/ole/planet/myplanet/ui/survey/SurveyFragment.kt index 3d935e0dae..c79a5fc767 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/survey/SurveyFragment.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/survey/SurveyFragment.kt @@ -17,6 +17,8 @@ class SurveyFragment : BaseRecyclerFragment() { private lateinit var spn: CustomSpinner private var isTitleAscending = true private lateinit var adapter: AdapterSurvey + private var isTeam: Boolean = false + private var teamId: String? = null override fun getLayout(): Int { return R.layout.fragment_survey @@ -24,7 +26,9 @@ class SurveyFragment : BaseRecyclerFragment() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - adapter = AdapterSurvey(requireActivity(), mRealm, model?.id ?: "") + isTeam = arguments?.getBoolean("isTeam", false) == true + teamId = arguments?.getString("teamId", null) + adapter = AdapterSurvey(requireActivity(), mRealm, model?.id ?: "", isTeam, teamId) } override fun getAdapter(): RecyclerView.Adapter<*> { @@ -78,8 +82,18 @@ class SurveyFragment : BaseRecyclerFragment() { } private fun updateAdapterData(sort: Sort = Sort.ASCENDING, field: String = "name") { - val newList = getList(RealmStepExam::class.java, field, sort) - adapter.updateData(safeCastList(newList, RealmStepExam::class.java)) + val query = mRealm.where(RealmStepExam::class.java) + + val surveys = if (teamId != null && isTeam) { + query.equalTo("teamId", teamId) + .sort(field, sort) + .findAll() + } else { + query.sort(field, sort) + .findAll() + } + + adapter.updateData(safeCastList(surveys, RealmStepExam::class.java)) updateUIState() } @@ -95,6 +109,7 @@ class SurveyFragment : BaseRecyclerFragment() { updateAdapterData(sort, "name") } + private fun safeCastList(items: List, clazz: Class): List { return items.mapNotNull { it?.takeIf(clazz::isInstance)?.let(clazz::cast) } } diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/team/TeamPagerAdapter.kt b/app/src/main/java/org/ole/planet/myplanet/ui/team/TeamPagerAdapter.kt index fe671d9457..671c258063 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/team/TeamPagerAdapter.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/team/TeamPagerAdapter.kt @@ -12,6 +12,7 @@ import org.ole.planet.myplanet.model.RealmMyTeam import org.ole.planet.myplanet.ui.enterprises.EnterpriseCalendarFragment import org.ole.planet.myplanet.ui.enterprises.FinanceFragment import org.ole.planet.myplanet.ui.enterprises.ReportsFragment +import org.ole.planet.myplanet.ui.survey.SurveyFragment import org.ole.planet.myplanet.ui.team.teamCourse.TeamCourseFragment import org.ole.planet.myplanet.ui.team.teamDiscussion.DiscussionListFragment import org.ole.planet.myplanet.ui.team.teamMember.JoinedMemberFragment @@ -24,21 +25,24 @@ class TeamPagerAdapter(fm: FragmentActivity, team: RealmMyTeam?, isInMyTeam: Boo private val list: MutableList = ArrayList() private val isEnterprise: Boolean = TextUtils.equals(team?.type, "enterprise") + init { - list.add(context.getString(if (isEnterprise) R.string.mission else R.string.plan)) - list.add(context.getString(if (isEnterprise) R.string.team else R.string.members)) if (isInMyTeam || team?.isPublic == true) { list.add(context.getString(R.string.chat)) + list.add(context.getString(if (isEnterprise) R.string.mission else R.string.plan)) + list.add(context.getString(if (isEnterprise) R.string.team else R.string.members)) list.add(context.getString(R.string.tasks)) list.add(context.getString(R.string.calendar)) + list.add(context.getString(R.string.survey)) list.add(context.getString(if (isEnterprise) R.string.finances else R.string.courses)) - if (isEnterprise) list.add(context.getString(R.string.reports)) + if (isEnterprise) { + list.add(context.getString(R.string.reports)) + } list.add(context.getString(if (isEnterprise) R.string.documents else R.string.resources)) list.add(context.getString(if (isEnterprise) R.string.applicants else R.string.join_requests)) - list.removeAt(0) - list.removeAt(0) - list.add(1, context.getString(if (isEnterprise) R.string.mission else R.string.plan)) - list.add(2, context.getString(if (isEnterprise) R.string.team else R.string.members)) + } else { + list.add(context.getString(if (isEnterprise) R.string.mission else R.string.plan)) + list.add(context.getString(if (isEnterprise) R.string.team else R.string.members)) } } @@ -56,6 +60,12 @@ class TeamPagerAdapter(fm: FragmentActivity, team: RealmMyTeam?, isInMyTeam: Boo context.getString(R.string.members), context.getString(R.string.team) -> JoinedMemberFragment() context.getString(R.string.tasks) -> TeamTaskFragment() context.getString(R.string.calendar) -> EnterpriseCalendarFragment() + context.getString(R.string.survey) -> SurveyFragment().apply { + arguments = Bundle().apply { + putBoolean("isTeam", true) + putString("teamId", teamId) + } + } context.getString(R.string.courses) -> TeamCourseFragment() context.getString(R.string.finances) -> FinanceFragment() context.getString(R.string.reports) -> ReportsFragment() @@ -63,10 +73,11 @@ class TeamPagerAdapter(fm: FragmentActivity, team: RealmMyTeam?, isInMyTeam: Boo context.getString(R.string.join_requests), context.getString(R.string.applicants) -> MembersFragment() else -> throw IllegalArgumentException("Invalid fragment type for position: $position") } - - val bundle = Bundle() - bundle.putString("id", teamId) - fragment.arguments = bundle + if (fragment.arguments == null) { + fragment.arguments = Bundle().apply { + putString("id", teamId) + } + } return fragment }