Added textbox for caste if the "OTHER" option is selected from dropdown, Added textbox for gender if the "OTHER" option is selected from gender
This commit is contained in:
@@ -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,9 +252,12 @@ 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 if (caste == "OTHER" && tilOthercaste.isVisible) {
|
||||
userData.caste = othercaste
|
||||
} else {
|
||||
userData.caste = caste
|
||||
}
|
||||
@@ -285,6 +328,8 @@ class UserDetailsRegistrationFragment : Fragment() {
|
||||
|
||||
return true
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 @@
|
||||
</RadioGroup>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/til_mobile"
|
||||
android:visibility="gone"
|
||||
android:id="@+id/til_othergender"
|
||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -93,6 +93,28 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/gender">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/et_othergender"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="Enter Other"
|
||||
android:inputType="text"
|
||||
android:maxLength="10" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/til_mobile"
|
||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="24dp"
|
||||
android:layout_marginTop="20dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/til_othergender">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/et_mobile"
|
||||
android:layout_width="match_parent"
|
||||
@@ -207,7 +229,27 @@
|
||||
app:simpleItems="@array/caste" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:visibility="gone"
|
||||
android:id="@+id/til_othercaste"
|
||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="24dp"
|
||||
android:layout_marginTop="20dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/til_caste">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/et_othercaste"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="Enter Other Caste"
|
||||
android:inputType="text"
|
||||
android:maxLength="10" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/til_subCaste"
|
||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||
@@ -217,7 +259,7 @@
|
||||
android:layout_marginTop="16dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/til_caste">
|
||||
app:layout_constraintTop_toBottomOf="@id/til_othercaste">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/et_subCaste"
|
||||
|
||||
Reference in New Issue
Block a user