Skip to content

Commit

Permalink
myhealth: smoohter members add (fixes #4994)
Browse files Browse the repository at this point in the history
  • Loading branch information
Avinash-Codes committed Jan 10, 2025
1 parent 08e4079 commit 787088c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,24 +102,30 @@ class MyHealthFragment : Fragment() {

private fun selectPatient() {
userModelList = mRealm.where(RealmUserModel::class.java).sort("joinDate", Sort.DESCENDING).findAll()
adapter = UserListArrayAdapter(requireActivity(), android.R.layout.simple_list_item_1, userModelList)
adapter = UserListArrayAdapter(requireActivity(), R.layout.list_item, userModelList)
alertHealthListBinding = AlertHealthListBinding.inflate(LayoutInflater.from(context))
alertHealthListBinding.btnAddMember.setOnClickListener {
startActivity(Intent(requireContext(), BecomeMemberActivity::class.java))
}

setTextWatcher(alertHealthListBinding.etSearch, alertHealthListBinding.btnAddMember, alertHealthListBinding.list)
alertHealthListBinding.list.adapter = adapter
alertHealthListBinding.list.onItemClickListener = OnItemClickListener { _: AdapterView<*>?, _: View, i: Int, _: Long ->
alertHealthListBinding.list.choiceMode = ListView.CHOICE_MODE_SINGLE
alertHealthListBinding.list.onItemClickListener = OnItemClickListener { _: AdapterView<*>?, view: 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)
view.isActivated = true
dialog?.dismiss()
}
sortList(alertHealthListBinding.spnSort, alertHealthListBinding.list)
dialog = AlertDialog.Builder(requireActivity())
.setTitle(getString(R.string.select_health_member)).setView(alertHealthListBinding.root)
.setCancelable(false).setNegativeButton(R.string.dismiss, null).create()

dialog!!.setOnShowListener{
dialog!!.window?.setBackgroundDrawableResource(R.color.secondary_bg)
}
dialog?.show()
}

Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/list_item_selector.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_activated="true" android:drawable="@color/secondary_bg" />
<item android:drawable="@android:color/transparent" />
</selector>
11 changes: 10 additions & 1 deletion app/src/main/res/layout/alert_health_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,33 @@
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:background="@color/secondary_bg"
android:orientation="vertical">

<LinearLayout
android:background="@color/secondary_bg"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<androidx.appcompat.widget.AppCompatSpinner
android:id="@+id/spn_sort"
android:background="@color/secondary_bg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:entries="@array/sort_member"
android:minWidth="150dp"
android:padding="8dp" />
android:padding="8dp"
android:popupBackground="@color/secondary_bg"
android:theme="@style/CustomAlertDialog"/>

<Button
android:id="@+id/btn_add_member"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:textColor="@color/daynight_textColor"
android:background="@color/secondary_bg"
android:minWidth="150dp"
android:padding="8dp"
android:text="@string/add_member"
Expand All @@ -36,7 +43,9 @@
android:id="@+id/et_search"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColorHint="@color/daynight_textColor"
android:hint="@string/search_dots"
android:textColor="@color/daynight_textColor"
android:inputType="text"
android:maxLines="1" />

Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/layout/list_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:background="@drawable/list_item_selector"
android:textColor="@color/daynight_textColor"
android:textSize="16sp" />

0 comments on commit 787088c

Please sign in to comment.