From 3397ac67b611708d071bf3a6576651f2701e46f1 Mon Sep 17 00:00:00 2001 From: Gideon Okuro Date: Mon, 16 Dec 2024 19:37:31 +0300 Subject: [PATCH 1/7] survey in teams --- .../myplanet/ui/exam/BaseExamFragment.kt | 9 ++++++++ .../ui/exam/UserInformationFragment.kt | 13 +++-------- .../myplanet/ui/team/TeamPagerAdapter.kt | 22 +++++++++++++++---- 3 files changed, 30 insertions(+), 14 deletions(-) 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..f9ce0c471b 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,8 @@ abstract class BaseExamFragment : Fragment(), ImageCaptureCallback { var date = Date().toString() private var photoPath: String? = "" var submitId = "" + private var isTeam: Boolean = false + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) db = DatabaseService(requireActivity()) @@ -60,6 +63,8 @@ abstract class BaseExamFragment : Fragment(), ImageCaptureCallback { stepId = requireArguments().getString("stepId") stepNumber = requireArguments().getInt("stepNum") isMySurvey = requireArguments().getBoolean("isMySurvey") + isTeam = requireArguments().getBoolean("isTeam", false) + Log.d("okuro", "${requireArguments().getBoolean("isTeam", false)}") checkId() checkType() } @@ -106,8 +111,12 @@ abstract class BaseExamFragment : Fragment(), ImageCaptureCallback { } private fun continueExam() { + Log.d("BaseExamFragment", "isTeam: $isTeam") + Log.d("BaseExamFragment", "type: $type") if (currentIndex < (questions?.size ?: 0)) { startExam(questions?.get(currentIndex)) + } else if (isTeam == true && type?.startsWith("survey") == true) { + showUserInfoDialog() } else { saveCourseProgress() AlertDialog.Builder(requireActivity(), R.style.AlertDialogTheme) 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..a86b49b301 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 @@ -31,6 +31,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 +46,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 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..a337fa667f 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 @@ -2,6 +2,7 @@ package org.ole.planet.myplanet.ui.team import android.os.Bundle import android.text.TextUtils +import android.util.Log import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentActivity import androidx.viewpager2.adapter.FragmentStateAdapter @@ -12,6 +13,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 @@ -23,14 +25,19 @@ class TeamPagerAdapter(fm: FragmentActivity, team: RealmMyTeam?, isInMyTeam: Boo private val teamId: String? = team?._id private val list: MutableList = ArrayList() private val isEnterprise: Boolean = TextUtils.equals(team?.type, "enterprise") + private val isTeam: Boolean = TextUtils.equals(team?.type, "team") init { + Log.d("TeamPagerAdapter", "createFragment: ${team?.type}") 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(R.string.tasks)) list.add(context.getString(R.string.calendar)) + if (!isEnterprise) { + 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)) list.add(context.getString(if (isEnterprise) R.string.documents else R.string.resources)) @@ -56,6 +63,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 { + Log.d("TeamPagerAdapter", "SurveyFragment: $isTeam") + arguments = Bundle().apply { + putBoolean("isTeam", isTeam) + } + } context.getString(R.string.courses) -> TeamCourseFragment() context.getString(R.string.finances) -> FinanceFragment() context.getString(R.string.reports) -> ReportsFragment() @@ -63,10 +76,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) { + val bundle = Bundle() + bundle.putString("id", teamId) + fragment.arguments = bundle + } return fragment } From ba955cc3a6e5e5d95a4d852594ce5c7540b5f5c9 Mon Sep 17 00:00:00 2001 From: Gideon Okuro Date: Mon, 16 Dec 2024 20:18:49 +0300 Subject: [PATCH 2/7] show user dialog in teams --- .../ole/planet/myplanet/base/BaseResourceFragment.kt | 2 +- .../planet/myplanet/ui/courses/CourseStepFragment.kt | 7 ++++++- .../myplanet/ui/dashboard/BellDashboardFragment.kt | 2 +- .../dashboard/notification/NotificationsFragment.kt | 7 ++++++- .../myplanet/ui/exam/UserInformationFragment.kt | 12 ++++++------ .../myplanet/ui/submission/AdapterMySubmission.kt | 10 ++++++++-- .../ole/planet/myplanet/ui/survey/AdapterSurvey.kt | 9 +++++++-- .../ole/planet/myplanet/ui/survey/SurveyFragment.kt | 4 +++- 8 files changed, 38 insertions(+), 15 deletions(-) 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 b934afc84f..63e7086ad9 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 @@ -164,7 +164,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/ui/courses/CourseStepFragment.kt b/app/src/main/java/org/ole/planet/myplanet/ui/courses/CourseStepFragment.kt index 2bd0edf5e2..4dffc7bb32 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,12 @@ 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/BellDashboardFragment.kt b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/BellDashboardFragment.kt index 2af41dabbe..9343485e50 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..3205e717a7 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 @@ -108,7 +108,12 @@ class NotificationsFragment : Fragment() { val currentStepExam = mRealm.where(RealmStepExam::class.java).equalTo("name", notification.relatedId) .findFirst() if(context is OnHomeItemClickListener) { - AdapterMySubmission.openSurvey(context as OnHomeItemClickListener, currentStepExam?.id, false) + AdapterMySubmission.openSurvey( + context as OnHomeItemClickListener, + currentStepExam?.id, + false, + false + ) } } "task" -> { 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 a86b49b301..b4dbc2cd6e 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 @@ -60,12 +60,12 @@ 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.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.btnSubmit.setOnClickListener(this) fragmentUserInformationBinding.txtDob.setOnClickListener(this) 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..5b61312a2a 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 +) : RecyclerView.Adapter() { private var examList: List = emptyList() private var listener: OnHomeItemClickListener? = null private var user: RealmUserModel? = null @@ -63,7 +68,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) } val questions = mRealm.where(RealmExamQuestion::class.java) 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..dede666615 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,7 @@ class SurveyFragment : BaseRecyclerFragment() { private lateinit var spn: CustomSpinner private var isTitleAscending = true private lateinit var adapter: AdapterSurvey + private var isTeam: Boolean = false override fun getLayout(): Int { return R.layout.fragment_survey @@ -24,7 +25,8 @@ class SurveyFragment : BaseRecyclerFragment() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - adapter = AdapterSurvey(requireActivity(), mRealm, model?.id ?: "") + isTeam = arguments?.getBoolean("isTeam", false) ?: false + adapter = AdapterSurvey(requireActivity(), mRealm, model?.id ?: "", isTeam) } override fun getAdapter(): RecyclerView.Adapter<*> { From bbfe5a51057ee2a622a0b22c769ec34d1d3fb73e Mon Sep 17 00:00:00 2001 From: Gideon Okuro Date: Mon, 16 Dec 2024 20:48:46 +0300 Subject: [PATCH 3/7] clean up logs --- .../ole/planet/myplanet/ui/courses/CourseStepFragment.kt | 7 +------ .../ui/dashboard/notification/NotificationsFragment.kt | 9 ++------- .../org/ole/planet/myplanet/ui/exam/BaseExamFragment.kt | 4 ---- .../planet/myplanet/ui/submission/AdapterMySubmission.kt | 7 +------ .../org/ole/planet/myplanet/ui/survey/AdapterSurvey.kt | 7 +------ .../org/ole/planet/myplanet/ui/team/TeamPagerAdapter.kt | 3 --- 6 files changed, 5 insertions(+), 32 deletions(-) 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 4dffc7bb32..ac90c1a04e 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,12 +184,7 @@ class CourseStepFragment : BaseContainerFragment(), ImageCaptureCallback { fragmentCourseStepBinding.btnTakeSurvey.setOnClickListener { if (stepSurvey.isNotEmpty()) { - AdapterMySubmission.openSurvey( - homeItemClickListener, - stepSurvey[0].id, - false, - 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/notification/NotificationsFragment.kt b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/notification/NotificationsFragment.kt index 3205e717a7..aa37da4118 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,13 +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, - 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 f9ce0c471b..48942a740a 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,7 +5,6 @@ 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 @@ -64,7 +63,6 @@ abstract class BaseExamFragment : Fragment(), ImageCaptureCallback { stepNumber = requireArguments().getInt("stepNum") isMySurvey = requireArguments().getBoolean("isMySurvey") isTeam = requireArguments().getBoolean("isTeam", false) - Log.d("okuro", "${requireArguments().getBoolean("isTeam", false)}") checkId() checkType() } @@ -111,8 +109,6 @@ abstract class BaseExamFragment : Fragment(), ImageCaptureCallback { } private fun continueExam() { - Log.d("BaseExamFragment", "isTeam: $isTeam") - Log.d("BaseExamFragment", "type: $type") if (currentIndex < (questions?.size ?: 0)) { startExam(questions?.get(currentIndex)) } else if (isTeam == true && type?.startsWith("survey") == true) { 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 5b61312a2a..72362fce52 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 @@ -98,12 +98,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) : RecyclerView.Adapter() { private var examList: List = emptyList() private var listener: OnHomeItemClickListener? = null private var user: RealmUserModel? = null 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 a337fa667f..f9a7f67ff2 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 @@ -2,7 +2,6 @@ package org.ole.planet.myplanet.ui.team import android.os.Bundle import android.text.TextUtils -import android.util.Log import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentActivity import androidx.viewpager2.adapter.FragmentStateAdapter @@ -28,7 +27,6 @@ class TeamPagerAdapter(fm: FragmentActivity, team: RealmMyTeam?, isInMyTeam: Boo private val isTeam: Boolean = TextUtils.equals(team?.type, "team") init { - Log.d("TeamPagerAdapter", "createFragment: ${team?.type}") 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) { @@ -64,7 +62,6 @@ class TeamPagerAdapter(fm: FragmentActivity, team: RealmMyTeam?, isInMyTeam: Boo context.getString(R.string.tasks) -> TeamTaskFragment() context.getString(R.string.calendar) -> EnterpriseCalendarFragment() context.getString(R.string.survey) -> SurveyFragment().apply { - Log.d("TeamPagerAdapter", "SurveyFragment: $isTeam") arguments = Bundle().apply { putBoolean("isTeam", isTeam) } From ad88fe56efb5a2bb5e9b3b0348a11e8d62592a70 Mon Sep 17 00:00:00 2001 From: Gideon Okuro Date: Mon, 6 Jan 2025 01:22:58 +0300 Subject: [PATCH 4/7] Update TeamPagerAdapter.kt --- .../myplanet/ui/team/TeamPagerAdapter.kt | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) 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 f9a7f67ff2..e7f8379de4 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 @@ -27,23 +27,24 @@ class TeamPagerAdapter(fm: FragmentActivity, team: RealmMyTeam?, isInMyTeam: Boo private val isTeam: Boolean = TextUtils.equals(team?.type, "team") 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)) if (!isEnterprise) { 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)) } } @@ -74,9 +75,9 @@ class TeamPagerAdapter(fm: FragmentActivity, team: RealmMyTeam?, isInMyTeam: Boo else -> throw IllegalArgumentException("Invalid fragment type for position: $position") } if (fragment.arguments == null) { - val bundle = Bundle() - bundle.putString("id", teamId) - fragment.arguments = bundle + fragment.arguments = Bundle().apply { + putString("id", teamId) + } } return fragment } From 00fd77a7d089b00a71daddaa9ea61cf7a221e711 Mon Sep 17 00:00:00 2001 From: Gideon Okuro Date: Tue, 7 Jan 2025 18:30:37 +0300 Subject: [PATCH 5/7] show surveys in enterprise --- .../java/org/ole/planet/myplanet/ui/team/TeamPagerAdapter.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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 e7f8379de4..fd0cda6d58 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 @@ -33,9 +33,7 @@ class TeamPagerAdapter(fm: FragmentActivity, team: RealmMyTeam?, isInMyTeam: Boo 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)) - if (!isEnterprise) { - list.add(context.getString(R.string.survey)) - } + 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)) From 1257f640543e912ad705c6042b799b5af2d97399 Mon Sep 17 00:00:00 2001 From: Gideon Okuro Date: Wed, 8 Jan 2025 18:14:44 +0300 Subject: [PATCH 6/7] filter surveys --- .../planet/myplanet/model/RealmStepExam.kt | 8 ++++++-- .../myplanet/ui/survey/AdapterSurvey.kt | 8 +++----- .../myplanet/ui/survey/SurveyFragment.kt | 19 ++++++++++++++++--- .../myplanet/ui/team/TeamPagerAdapter.kt | 5 +++-- 4 files changed, 28 insertions(+), 12 deletions(-) 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/survey/AdapterSurvey.kt b/app/src/main/java/org/ole/planet/myplanet/ui/survey/AdapterSurvey.kt index 2dec73d2bb..4125f41698 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/survey/AdapterSurvey.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/survey/AdapterSurvey.kt @@ -22,13 +22,11 @@ import org.ole.planet.myplanet.utilities.TimeUtils.formatDate class AdapterSurvey(private val context: Context, private val mRealm: Realm, private val userId: String, private val isTeam: Boolean) : 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) { @@ -81,12 +79,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 dede666615..92f5381c62 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 @@ -18,6 +18,7 @@ class SurveyFragment : BaseRecyclerFragment() { 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 @@ -25,7 +26,8 @@ class SurveyFragment : BaseRecyclerFragment() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - isTeam = arguments?.getBoolean("isTeam", false) ?: false + isTeam = arguments?.getBoolean("isTeam", false) == true + teamId = arguments?.getString("teamId", null) adapter = AdapterSurvey(requireActivity(), mRealm, model?.id ?: "", isTeam) } @@ -80,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() } @@ -97,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 fd0cda6d58..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 @@ -24,7 +24,7 @@ class TeamPagerAdapter(fm: FragmentActivity, team: RealmMyTeam?, isInMyTeam: Boo private val teamId: String? = team?._id private val list: MutableList = ArrayList() private val isEnterprise: Boolean = TextUtils.equals(team?.type, "enterprise") - private val isTeam: Boolean = TextUtils.equals(team?.type, "team") + init { if (isInMyTeam || team?.isPublic == true) { @@ -62,7 +62,8 @@ class TeamPagerAdapter(fm: FragmentActivity, team: RealmMyTeam?, isInMyTeam: Boo context.getString(R.string.calendar) -> EnterpriseCalendarFragment() context.getString(R.string.survey) -> SurveyFragment().apply { arguments = Bundle().apply { - putBoolean("isTeam", isTeam) + putBoolean("isTeam", true) + putString("teamId", teamId) } } context.getString(R.string.courses) -> TeamCourseFragment() From e8d6e24948bfa3e5a5f6a8326bda7549666d3a85 Mon Sep 17 00:00:00 2001 From: Gideon Okuro Date: Wed, 8 Jan 2025 22:24:30 +0300 Subject: [PATCH 7/7] show user data form --- .../myplanet/base/BaseDialogFragment.kt | 2 ++ .../myplanet/base/BaseResourceFragment.kt | 2 +- .../myplanet/ui/courses/CourseStepFragment.kt | 2 +- .../ui/dashboard/BaseDashboardFragment.kt | 2 +- .../ui/dashboard/BellDashboardFragment.kt | 2 +- .../notification/NotificationsFragment.kt | 2 +- .../myplanet/ui/exam/BaseExamFragment.kt | 7 ++++- .../ui/exam/UserInformationFragment.kt | 30 +++++++++++++++---- .../ui/submission/AdapterMySubmission.kt | 5 ++-- .../myplanet/ui/survey/AdapterSurvey.kt | 6 ++-- .../myplanet/ui/survey/SurveyFragment.kt | 2 +- 11 files changed, 44 insertions(+), 18 deletions(-) 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 59808a916e..ff3cb6f0f7 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 @@ -166,7 +166,7 @@ abstract class BaseResourceFragment : Fragment() { } AlertDialog.Builder(requireActivity()).setTitle("Pending Surveys") .setAdapter(arrayAdapter) { _: DialogInterface?, i: Int -> - AdapterMySubmission.openSurvey(homeItemClickListener, list[i].id, true, false) + 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/ui/courses/CourseStepFragment.kt b/app/src/main/java/org/ole/planet/myplanet/ui/courses/CourseStepFragment.kt index ac90c1a04e..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, 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 9343485e50..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, false) + 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 aa37da4118..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 @@ -108,7 +108,7 @@ class NotificationsFragment : Fragment() { val currentStepExam = mRealm.where(RealmStepExam::class.java).equalTo("name", notification.relatedId) .findFirst() if (context is OnHomeItemClickListener) { - AdapterMySubmission.openSurvey(context as OnHomeItemClickListener, currentStepExam?.id, false, false) + 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 48942a740a..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 @@ -53,6 +54,7 @@ abstract class BaseExamFragment : Fragment(), ImageCaptureCallback { private var photoPath: String? = "" var submitId = "" private var isTeam: Boolean = false + private var teamId: String? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -63,6 +65,7 @@ abstract class BaseExamFragment : Fragment(), ImageCaptureCallback { stepNumber = requireArguments().getInt("stepNum") isMySurvey = requireArguments().getBoolean("isMySurvey") isTeam = requireArguments().getBoolean("isTeam", false) + teamId = requireArguments().getString("teamId") checkId() checkType() } @@ -112,6 +115,7 @@ abstract class BaseExamFragment : Fragment(), ImageCaptureCallback { if (currentIndex < (questions?.size ?: 0)) { startExam(questions?.get(currentIndex)) } else if (isTeam == true && type?.startsWith("survey") == true) { + Log.d("okuro", "$teamId") showUserInfoDialog() } else { saveCourseProgress() @@ -136,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 b4dbc2cd6e..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 @@ -66,7 +68,12 @@ class UserInformationFragment : BaseDialogFragment(), View.OnClickListener { // 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) + if (teamId != null) { + fragmentUserInformationBinding.btnCancel.visibility = View.GONE + } else { + fragmentUserInformationBinding.btnCancel.setOnClickListener(this) + } + fragmentUserInformationBinding.btnSubmit.setOnClickListener(this) fragmentUserInformationBinding.txtDob.setOnClickListener(this) } @@ -150,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() { @@ -166,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 72362fce52..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 @@ -61,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, isTeam) + AdapterMySubmission.openSurvey(listener, exam.id, false, isTeam, teamId) } val questions = mRealm.where(RealmExamQuestion::class.java) 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 92f5381c62..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 @@ -28,7 +28,7 @@ class SurveyFragment : BaseRecyclerFragment() { super.onCreate(savedInstanceState) isTeam = arguments?.getBoolean("isTeam", false) == true teamId = arguments?.getString("teamId", null) - adapter = AdapterSurvey(requireActivity(), mRealm, model?.id ?: "", isTeam) + adapter = AdapterSurvey(requireActivity(), mRealm, model?.id ?: "", isTeam, teamId) } override fun getAdapter(): RecyclerView.Adapter<*> {