Skip to content

Commit

Permalink
healthsection: smoother update (fixes #4932)
Browse files Browse the repository at this point in the history
  • Loading branch information
Avinash-Codes committed Jan 2, 2025
1 parent ad144be commit 075e91d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,8 @@ import org.ole.planet.myplanet.ui.userprofile.BecomeMemberActivity
import org.ole.planet.myplanet.utilities.AndroidDecrypter
import org.ole.planet.myplanet.utilities.Utilities

/**
* A simple [Fragment] subclass.
*/
class MyHealthFragment : Fragment() {
private lateinit var fragmentVitalSignBinding : FragmentVitalSignBinding
private lateinit var fragmentVitalSignBinding: FragmentVitalSignBinding
private lateinit var alertMyPersonalBinding: AlertMyPersonalBinding
private lateinit var alertHealthListBinding: AlertHealthListBinding
var profileDbHandler: UserProfileDbHandler? = null
Expand All @@ -49,6 +46,7 @@ class MyHealthFragment : Fragment() {
lateinit var userModelList: List<RealmUserModel>
lateinit var adapter: UserListArrayAdapter
var dialog: AlertDialog? = null

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
fragmentVitalSignBinding = FragmentVitalSignBinding.inflate(inflater, container, false)
mRealm = DatabaseService(requireContext()).realmInstance
Expand All @@ -65,18 +63,12 @@ class MyHealthFragment : Fragment() {
userId = if (TextUtils.isEmpty(profileDbHandler?.userModel?._id)) profileDbHandler?.userModel?.id else profileDbHandler?.userModel?._id
getHealthRecords(userId)

if (profileDbHandler?.userModel?.getRoleAsString()?.contains("health", true) == true) {
fragmentVitalSignBinding.btnnewPatient.visibility = View.VISIBLE
fragmentVitalSignBinding.btnnewPatient.setOnClickListener { selectPatient() }
fragmentVitalSignBinding.fabAddMember.show(true)
fragmentVitalSignBinding.fabAddMember.visibility = View.VISIBLE
} else {
fragmentVitalSignBinding.btnnewPatient.visibility = View.GONE
fragmentVitalSignBinding.fabAddMember.hide(true)
fragmentVitalSignBinding.fabAddMember.visibility = View.GONE
}
fragmentVitalSignBinding.fabAddMember.setOnClickListener {
startActivity(Intent(activity, BecomeMemberActivity::class.java))
fragmentVitalSignBinding.btnnewPatient.visibility = View.VISIBLE
fragmentVitalSignBinding.btnnewPatient.setOnClickListener { selectPatient() }
fragmentVitalSignBinding.updateHealth.visibility = View.VISIBLE

fragmentVitalSignBinding.updateHealth.setOnClickListener {
startActivity(Intent(activity, AddMyHealthActivity::class.java).putExtra("userId", userId))
}
}

Expand All @@ -103,8 +95,7 @@ class MyHealthFragment : Fragment() {

setTextWatcher(alertHealthListBinding.etSearch, alertHealthListBinding.btnAddMember, alertHealthListBinding.list)
alertHealthListBinding.list.adapter = adapter
alertHealthListBinding.list.onItemClickListener = OnItemClickListener {
_: AdapterView<*>?, _: View, i: Int, _: Long ->
alertHealthListBinding.list.onItemClickListener = OnItemClickListener { _: AdapterView<*>?, _: View, i: Int, _: Long ->
val selected = alertHealthListBinding.list.adapter.getItem(i) as RealmUserModel
userId = if (selected._id.isNullOrEmpty()) selected.id else selected._id
getHealthRecords(userId)
Expand Down Expand Up @@ -203,7 +194,7 @@ class MyHealthFragment : Fragment() {
fragmentVitalSignBinding.txtSpecialNeeds.text = Utilities.checkNA(myHealths.specialNeeds)
fragmentVitalSignBinding.txtBirthPlace.text = Utilities.checkNA(userModel?.birthPlace!!)
fragmentVitalSignBinding.txtEmergencyContact.text = getString(R.string.emergency_contact_details, Utilities.checkNA(myHealths.emergencyContactName),
Utilities.checkNA(myHealths.emergencyContactName), Utilities.checkNA(myHealths.emergencyContact)).trimIndent()
Utilities.checkNA(myHealths.emergencyContactName), Utilities.checkNA(myHealths.emergencyContact)).trimIndent()
val list = getExaminations(mm)

val adap = AdapterHealthExamination(requireActivity(), list, mh, userModel)
Expand All @@ -220,7 +211,7 @@ class MyHealthFragment : Fragment() {
fragmentVitalSignBinding.txtOtherNeed.text = getString(R.string.empty_text)
fragmentVitalSignBinding.txtSpecialNeeds.text = getString(R.string.empty_text)
fragmentVitalSignBinding.txtBirthPlace.text = getString(R.string.empty_text)
fragmentVitalSignBinding.txtEmergencyContact.text= getString(R.string.empty_text)
fragmentVitalSignBinding.txtEmergencyContact.text = getString(R.string.empty_text)
fragmentVitalSignBinding.rvRecords.adapter = null
}
}
Expand All @@ -243,4 +234,4 @@ class MyHealthFragment : Fragment() {
}
}
}
}
}
21 changes: 0 additions & 21 deletions app/src/main/res/layout/fragment_vital_sign.xml
Original file line number Diff line number Diff line change
Expand Up @@ -327,17 +327,6 @@
android:textColor="@color/daynight_textColor" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>

<com.github.clans.fab.FloatingActionMenu
android:id="@+id/fab_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/padding_large"
app:menu_icon="@drawable/ic_add"
app:menu_open="arc_left"
app:menu_scr="@drawable/ic_add">

<com.github.clans.fab.FloatingActionButton
android:id="@+id/update_health"
android:layout_width="wrap_content"
Expand All @@ -348,14 +337,4 @@
android:text="@string/update_health_record"
android:tint="@color/md_white_1000"
app:fab_label="@string/update_health_record" />
<com.github.clans.fab.FloatingActionButton
android:id="@+id/fab_add_member"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/padding_large"
android:src="@drawable/ic_add_member"
android:tint="@color/md_white_1000"
app:fab_label="@string/add_member" />
</com.github.clans.fab.FloatingActionMenu>
</FrameLayout>

0 comments on commit 075e91d

Please sign in to comment.