diff --git a/app/src/main/java/com/example/hposregistration/ui/fragments/registration/UserDetailsRegistrationFragment.kt b/app/src/main/java/com/example/hposregistration/ui/fragments/registration/UserDetailsRegistrationFragment.kt
index e58cf16..e0583d5 100644
--- a/app/src/main/java/com/example/hposregistration/ui/fragments/registration/UserDetailsRegistrationFragment.kt
+++ b/app/src/main/java/com/example/hposregistration/ui/fragments/registration/UserDetailsRegistrationFragment.kt
@@ -53,7 +53,15 @@ class UserDetailsRegistrationFragment : Fragment() {
}
}
+ binding.etCaste.setOnItemClickListener { parent, view, position, id ->
+ if (parent.getItemAtPosition(position).toString().equals("OTHER", ignoreCase = true)) {
+ binding.tilOthercaste.visibility = View.VISIBLE
+ } else {
+ binding.tilOthercaste.visibility = View.GONE
+ }
+
+ }
}
private fun setupViewModel() {
@@ -71,21 +79,21 @@ class UserDetailsRegistrationFragment : Fragment() {
when (it) {
"Male" -> {
male.isChecked = true
+ binding.tilOthergender.visibility = View.GONE
}
"Female" -> {
female.isChecked = true
+ binding.tilOthergender.visibility = View.GONE
}
else -> {
other.isChecked = true
+ binding.tilOthergender.visibility = View.VISIBLE
}
}
}
user.phoneNumber.let { etMobile.setText(it) }
user.careOf.let { etCareof.setText(it) }
user.maritalStatus.let { etIsMarried.setText(it, false) }
- user.caste.let {
- etCaste.setText(it, false)
- }
user.subCaste.let { etSubCaste.setText(it) }
user.house.let { etHouse.setText(it) }
user.city.let { etCity.setText(it) }
@@ -110,8 +118,9 @@ class UserDetailsRegistrationFragment : Fragment() {
user.category.let {
etCategory.setText(it, false)
}
-
-
+ user.caste.let {
+ etCaste.setText(it, false)
+ }
if (yes1history.isChecked) {
if (binding.yes1history.isChecked) View.VISIBLE else View.GONE
@@ -130,6 +139,22 @@ class UserDetailsRegistrationFragment : Fragment() {
if (binding.no1history.isChecked) View.GONE else View.VISIBLE
}
+ if(other.isChecked){
+ user.gender.let { etOthergender.setText(it) }
+ }
+
+ binding.male.setOnClickListener {
+ binding.tilOthergender.visibility = View.GONE
+ }
+
+ binding.female.setOnClickListener {
+ binding.tilOthergender.visibility = View.GONE
+ }
+
+ binding.other.setOnClickListener {
+ binding.tilOthergender.visibility = View.VISIBLE
+ }
+
if (binding.etCategory.text.toString().equals("OTHER", ignoreCase = true)) {
binding.tilOther.visibility = View.VISIBLE
binding.etOther.visibility = View.VISIBLE
@@ -137,6 +162,13 @@ class UserDetailsRegistrationFragment : Fragment() {
binding.tilOther.visibility = View.GONE
}
+ if (binding.etCaste.text.toString().equals("OTHER", ignoreCase = true)) {
+ binding.tilOthercaste.visibility = View.VISIBLE
+ binding.etOthercaste.visibility = View.VISIBLE
+ } else {
+ binding.tilOthercaste.visibility = View.GONE
+ }
+
}
}
@@ -169,11 +201,19 @@ class UserDetailsRegistrationFragment : Fragment() {
}
if (male.isChecked) {
+ binding.tilOthergender.visibility = View.GONE
userData.gender = "Male"
} else if (female.isChecked) {
+ binding.tilOthergender.visibility = View.GONE
userData.gender = "Female"
- } else {
- userData.gender = "Other"
+ } else if(other.isChecked) {
+ binding.tilOthergender.visibility = View.VISIBLE
+ val genderother= binding.etOthergender.text.toString()
+ userData.gender = genderother
+ if (genderother.isEmpty()) {
+ etOthergender.error = "Please fill the field"
+ return false
+ }
}
val mobile = etMobile.text.toString()
@@ -212,10 +252,13 @@ class UserDetailsRegistrationFragment : Fragment() {
}
val caste = etCaste.text.toString()
+ val othercaste = etOthercaste.text.toString()
if (caste.isEmpty()) {
etCaste.error = "Please enter your caste"
return false
- }else{
+ } else if (caste == "OTHER" && tilOthercaste.isVisible) {
+ userData.caste = othercaste
+ } else {
userData.caste = caste
}
@@ -285,6 +328,8 @@ class UserDetailsRegistrationFragment : Fragment() {
return true
+
+
}
}
diff --git a/app/src/main/res/layout/fragment_user_details_registration.xml b/app/src/main/res/layout/fragment_user_details_registration.xml
index 1c3b502..7f06efc 100644
--- a/app/src/main/res/layout/fragment_user_details_registration.xml
+++ b/app/src/main/res/layout/fragment_user_details_registration.xml
@@ -63,7 +63,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
- android:checked="true"
android:text="@string/male"
android:textSize="16sp" />
@@ -83,7 +82,8 @@
+
+
+
+
+
+
+
+
+
+
+
+ app:layout_constraintTop_toBottomOf="@id/til_othercaste">