Browse Source

adding validations in 2nd screen

PankajBranch
Hemant Khadase 2 years ago
parent
commit
c9d4f76611
3 changed files with 147 additions and 104 deletions
  1. +78
    -3
      app/src/main/java/com/nivesh/production/bajajfd/ui/fragment/StepTwoBajajFDFragment.kt
  2. +16
    -33
      app/src/main/java/com/nivesh/production/bajajfd/util/Common.kt
  3. +53
    -68
      app/src/main/res/layout/fragment_bajajfd_step_two.xml

+ 78
- 3
app/src/main/java/com/nivesh/production/bajajfd/ui/fragment/StepTwoBajajFDFragment.kt View File

@ -1,15 +1,23 @@
package com.nivesh.production.bajajfd.ui.fragment
import android.R.attr
import android.R.attr.phoneNumber
import android.os.Bundle
import android.text.InputFilter
import android.text.InputFilter.LengthFilter
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider
import com.nivesh.production.bajajfd.interfaces.BajajFDInterface
import com.nivesh.production.bajajfd.databinding.FragmentBajajfdStepTwoBinding
import com.nivesh.production.bajajfd.interfaces.BajajFDInterface
import com.nivesh.production.bajajfd.util.Common.Companion.isIndianMobileNo
import com.nivesh.production.bajajfd.util.Common.Companion.isValidEmail
import com.nivesh.production.bajajfd.util.Common.Companion.isValidName
import com.nivesh.production.bajajfd.util.Common.Companion.isValidPan
import com.nivesh.production.bajajfd.viewModel.StepTwoBajajFDViewModel
class StepTwoBajajFDFragment : Fragment() {
private var _binding: FragmentBajajfdStepTwoBinding? = null
@ -44,6 +52,10 @@ class StepTwoBajajFDFragment : Fragment() {
_binding = FragmentBajajfdStepTwoBinding.inflate(inflater,container,false)
val root = binding.root
binding.edtMobileNumber.filters = arrayOf<InputFilter>(LengthFilter(10))
binding.edtPANNumber.filters = arrayOf<InputFilter>(LengthFilter(10))
binding.tvPersonalDetails.setOnClickListener {
@ -56,10 +68,73 @@ class StepTwoBajajFDFragment : Fragment() {
binding.tvBankDetails.setOnClickListener {
}
// if ( validation())
return root
}
private fun validation(): Boolean {
if (binding.edtMobileNumber.text.toString().isEmpty()){
return false
}else if (binding.edtMobileNumber.text?.length != 10){
return false
}else if (binding.edtMobileNumber.text?.length == 10 && isIndianMobileNo(binding.edtMobileNumber.text.toString())){
return false
} else if (binding.edtDOB.text.toString().isEmpty()){
return false
}else if (binding.edtPANNumber.text.toString().isEmpty()){
return false
}else if (isValidPan(binding.edtPANNumber.text.toString())){
return false
}else if (binding.spTitle.text.isEmpty()){
return false
}else if (binding.edtFirstName.text.toString().isEmpty()){
return false
}else if (isValidName(binding.edtFirstName.text.toString())){
return false
}else if (binding.edtMiddleName.text.toString().isEmpty()){
return false
}else if (isValidName(binding.edtMiddleName.text.toString())){
return false
}else if (binding.edtLastName.text.toString().isEmpty()){
return false
}else if (isValidName(binding.edtLastName.text.toString())){
return false
}else if (binding.spGender.text.toString().isEmpty()){
return false
}else if (binding.edtEmail.text.toString().isEmpty()){
return false
}else if (isValidEmail(binding.edtEmail.text.toString())){
return false
}else if (binding.edtOccupation.text.toString().isEmpty()){
return false
}else if (binding.edtQualification.text.toString().isEmpty()){
return false
}else if (binding.spMarital.text.toString().isEmpty()){
return false
}else if (binding.spRelation.text.toString().isEmpty()){
return false
}else if (binding.edtRelationName.text.toString().isEmpty()){
return false
}else if (binding.edtAddressLine1.text.toString().isEmpty()){
return false
}else if (binding.edtAddressLine2.text.toString().isEmpty()){
return false
}else if (binding.edtState.text.toString().isEmpty()){
return false
}else if (binding.edtCity.text.toString().isEmpty()){
return false
}else if (binding.edtPinCode.text.toString().isEmpty()){
return false
}else if (binding.edtIFSC.text.toString().isEmpty()){
return false
}else if (binding.edtAccountNumber.text.toString().isEmpty()){
return false
}else if (binding.edtBankName.text.toString().isEmpty()){
return false
}else return !binding.edtbankBranch.text.toString().isEmpty()
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null


+ 16
- 33
app/src/main/java/com/nivesh/production/bajajfd/util/Common.kt View File

@ -12,6 +12,7 @@ import com.nivesh.production.bajajfd.BajajApplication
import java.util.regex.Matcher
import java.util.regex.Pattern
class Common {
companion object{
@ -49,52 +50,34 @@ class Common {
}
return false
}
//valid email check
private fun isValidEmail(emailText:String?): String? {
if(!emailText?.let { Patterns.EMAIL_ADDRESS.matcher(it).matches() }!!)
{
return "Invalid Email Address"
}
return null
//valid email check
fun isValidEmail(target: String?): Boolean {
return Patterns.EMAIL_ADDRESS.matcher(target.toString()).matches()
}
//valid Name Check
private fun isValidName(nameText: String?): String {
fun isValidName(nameText: String?): Boolean {
val pattern = Pattern.compile(("^[a-zA-Z\\s]{2,70}$"))
val matcher = pattern.matcher(nameText)
if (!matcher.matches()) {
return "Enter Valid Name"
}
return ""
val matcher = pattern.matcher(nameText.toString())
return matcher.matches()
}
//validPanCard
private fun isValidPanCardNo(panCardNo: String?): Boolean {
// Regex to check valid PAN Card number.
val regex = "[A-Z]{5}[0-9]{4}[A-Z]{1}"
// Compile the ReGex
val p = Pattern.compile(regex)
// If the PAN Card number
// is empty return false
if (panCardNo == null) {
return false
}
// Pattern class contains matcher() method
// to find matching between given
// PAN Card number using regular expression.
val m = p.matcher(panCardNo)
// Return if the PAN Card number
// matched the ReGex
return m.matches()
fun isValidPan(pan: String?): Boolean {
val mPattern = Pattern.compile("[A-Z]{5}[0-9]{4}[A-Z]{1}")
val mMatcher = mPattern.matcher(pan.toString())
return mMatcher.matches()
}
//is Indian mobile Number
private fun isIndianMobileNo(mobileNumber: String?): Boolean {
fun isIndianMobileNo(mobileNumber: String?): Boolean {
//(0/91): number starts with (0/91)
//[7-9]: starting of the number may contain a digit between 0 to 9
//[0-9]: then contains digits 0 to 9
val pattern: Pattern = Pattern.compile("^[6-9]\\d{9}$")
//the matcher() method creates a matcher that will match the given input against this pattern
val match: Matcher = pattern.matcher(mobileNumber)
val match: Matcher = pattern.matcher(mobileNumber.toString())
//returns a boolean value
return match.matches()
}


+ 53
- 68
app/src/main/res/layout/fragment_bajajfd_step_two.xml View File

@ -18,11 +18,10 @@
android:background="@color/Nivesh_color_AppBg"
android:fillViewport="true"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/btnNext">
app:layout_constraintBottom_toTopOf="@+id/btnNext">
<com.google.android.material.card.MaterialCardView
style="@style/CustomCardViewStyle"
android:layout_width="match_parent"
@ -86,7 +85,6 @@
android:paddingStart="@dimen/margin_18"
android:paddingEnd="@dimen/margin_10"
android:background="@color/grey_bg"
android:padding="@dimen/margin_1"
android:text="Personal Details"
android:textColor="@color/black"
app:layout_constraintTop_toBottomOf="@+id/tvFdRating"
@ -152,18 +150,6 @@
</com.google.android.material.textfield.TextInputLayout>
<!-- <Spinner-->
<!-- android:id="@+id/spDuration"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_margin="@dimen/margin_5"-->
<!-- android:layout_marginTop="@dimen/margin_5"-->
<!-- android:background="@drawable/rounded_corner_with_line"-->
<!-- android:minHeight="@dimen/margin_48"-->
<!-- android:paddingStart="@dimen/margin_10"-->
<!-- android:paddingEnd="0dp"-->
<!-- android:entries="@array/title"/>-->
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/tlTitle"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
@ -546,35 +532,48 @@
</LinearLayout>
<RelativeLayout
<TextView
android:id="@+id/tvNomineeDetails"
style="@style/semiBoldStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/margin_5"
android:paddingBottom="@dimen/margin_5"
android:paddingStart="@dimen/margin_15"
android:paddingEnd="@dimen/margin_15"
android:background="@color/grey_bg">
<TextView
android:id="@+id/tvNomineeDetails"
style="@style/semiBoldStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/margin_3"
android:layout_centerVertical="true"
android:textSize="@dimen/text_size_14"
android:text="Nominee Details"
android:textColor="@color/black" />
android:paddingStart="@dimen/margin_18"
android:paddingEnd="@dimen/margin_10"
android:textSize="@dimen/text_size_14"
android:background="@color/grey_bg"
android:text="Nominee Details (Optional)"
app:drawableEndCompat="@drawable/svg_down_arrow"
android:textColor="@color/black" />
<!-- <RelativeLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:paddingTop="@dimen/margin_5"-->
<!-- android:paddingBottom="@dimen/margin_5"-->
<!-- android:paddingStart="@dimen/margin_15"-->
<!-- android:paddingEnd="@dimen/margin_15"-->
<!-- android:background="@color/grey_bg">-->
<!-- <TextView-->
<!-- android:id="@+id/tvNomineeDetails"-->
<!-- style="@style/semiBoldStyle"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:padding="@dimen/margin_3"-->
<!-- android:layout_centerVertical="true"-->
<!-- android:textSize="@dimen/text_size_14"-->
<!-- android:text="Nominee Details (Optional)"-->
<!-- android:textColor="@color/black" />-->
<androidx.appcompat.widget.SwitchCompat
android:theme="@style/SCBSwitch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:textSize="@dimen/text_size_14"
android:layout_marginEnd="@dimen/margin_5"/>
<!-- <androidx.appcompat.widget.SwitchCompat-->
<!-- android:theme="@style/SCBSwitch"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_alignParentEnd="true"-->
<!-- android:textSize="@dimen/text_size_14"-->
<!-- android:layout_marginEnd="@dimen/margin_5"/>-->
</RelativeLayout>
<!-- </RelativeLayout>-->
<LinearLayout
android:id="@+id/llNomineeDetail"
@ -688,16 +687,6 @@
</com.google.android.material.textfield.TextInputLayout>
<!-- <Spinner-->
<!-- android:id="@+id/spNomineeRelation"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginTop="@dimen/margin_5"-->
<!-- android:background="@drawable/rounded_corner_with_line"-->
<!-- android:minHeight="@dimen/margin_48"-->
<!-- android:textSize="@dimen/text_size_14"-->
<!-- android:entries="@array/interestPayoutList" />-->
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/tlNomineeRelation"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
@ -766,17 +755,6 @@
</com.google.android.material.textfield.TextInputLayout>
<!-- <Spinner-->
<!-- android:id="@+id/spGuardianRelation"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginTop="@dimen/margin_5"-->
<!-- android:background="@drawable/rounded_corner_with_line"-->
<!-- android:minHeight="@dimen/margin_48"-->
<!-- android:textSize="@dimen/text_size_14"-->
<!-- android:entries="@array/interestPayoutList" />-->
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/tlGuardianRelation"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
@ -879,12 +857,15 @@
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:buttonTint="@color/black"
android:text="Savings account" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="50dp"
android:buttonTint="@color/black"
android:text="Current account" />
</RadioGroup>
@ -897,6 +878,7 @@
android:hint="Enter IFSC Code">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/edtIFSC"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="@dimen/text_size_14"/>
@ -913,6 +895,7 @@
android:hint="Enter Account Number">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/edtAccountNumber"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
@ -928,6 +911,7 @@
android:hint="Enter Bank Name">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/edtBankName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="@dimen/text_size_14"/>
@ -944,6 +928,7 @@
android:hint="Enter Branch Name">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/edtbankBranch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="@dimen/text_size_14"/>
@ -993,6 +978,8 @@
android:orientation="horizontal">
<RadioButton
android:checked="true"
android:buttonTint="@color/black"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="UPI" />
@ -1001,6 +988,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="50dp"
android:buttonTint="@color/black"
android:text="NetBanking" />
</RadioGroup>
@ -1047,23 +1035,20 @@
android:textSize="@dimen/text_size_14"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/btnNext"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/scrollView" />
app:layout_constraintStart_toStartOf="parent" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btnNext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginTop="@dimen/margin_20"
android:layout_marginBottom="@dimen/margin_15"
android:backgroundTint="@color/colorPrimary"
android:text="@string/next"
android:textSize="@dimen/text_size_14"
android:textColor="@color/white"
android:textSize="@dimen/text_size_14"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/btnBack"
app:layout_constraintTop_toBottomOf="@+id/scrollView"/>
app:layout_constraintStart_toEndOf="@+id/btnBack" />
</androidx.constraintlayout.widget.ConstraintLayout>

Loading…
Cancel
Save

Powered by TurnKey Linux.