Browse Source

added missing code

PankajBranch
Hemant Khadase 2 years ago
parent
commit
8a70c1cdb8
7 changed files with 111 additions and 50 deletions
  1. +32
    -27
      app/src/main/java/com/nivesh/production/niveshfd/adapter/PaymentModeAdapter.kt
  2. +1
    -2
      app/src/main/java/com/nivesh/production/niveshfd/ui/fragment/StepFourNiveshFDFragment.kt
  3. +5
    -0
      app/src/main/java/com/nivesh/production/niveshfd/ui/fragment/StepOneNiveshFDFragment.kt
  4. +47
    -15
      app/src/main/java/com/nivesh/production/niveshfd/ui/fragment/StepTwoNiveshFDFragment.kt
  5. +9
    -2
      app/src/main/java/com/nivesh/production/niveshfd/util/ProgressUtil.kt
  6. +12
    -0
      app/src/main/java/com/nivesh/production/niveshfd/viewModel/MyObseravble.kt
  7. +5
    -4
      app/src/main/res/layout/item_payment_list_preview.xml

+ 32
- 27
app/src/main/java/com/nivesh/production/niveshfd/adapter/PaymentModeAdapter.kt View File

@ -5,17 +5,19 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.ImageView import android.widget.ImageView
import android.widget.TextView import android.widget.TextView
import androidx.cardview.widget.CardView
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.nivesh.production.niveshfd.R import com.nivesh.production.niveshfd.R
import com.nivesh.production.niveshfd.model.GetCodes import com.nivesh.production.niveshfd.model.GetCodes
class PaymentModeAdapter( class PaymentModeAdapter(
private val bankList: List<GetCodes>?,
private val selectedAccount: String? = null
private val listOfPayMode: MutableList<GetCodes>,
private var selectedAmount: String? = null
) : RecyclerView.Adapter<PaymentModeAdapter.BankListViewHolder>() { ) : RecyclerView.Adapter<PaymentModeAdapter.BankListViewHolder>() {
inner class BankListViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { inner class BankListViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val bankSelector: ImageView = itemView.findViewById(R.id.bankSelector)
val tvBankName: TextView = itemView.findViewById(R.id.tvBankName)
val paymentSelector: ImageView = itemView.findViewById(R.id.paymentSelector)
val paymentMethod: TextView = itemView.findViewById(R.id.paymentMethod)
val tvUpiMsg: TextView = itemView.findViewById(R.id.tvUpiMsg) val tvUpiMsg: TextView = itemView.findViewById(R.id.tvUpiMsg)
} }
@ -36,38 +38,35 @@ class PaymentModeAdapter(
} }
override fun onBindViewHolder(holder: BankListViewHolder, position: Int) { override fun onBindViewHolder(holder: BankListViewHolder, position: Int) {
val bankList = bankList?.get(position)
if (bankList != null) {
val listOfPayMode = listOfPayMode?.get(position)
if (listOfPayMode != null) {
holder.itemView.apply { holder.itemView.apply {
holder.tvBankName.text = bankList.Value
if (bankList.Value.equals("UPI")){
holder.paymentMethod.text = listOfPayMode.Value
if (listOfPayMode.Value.equals("UPI")) {
holder.tvUpiMsg.text = context.getString(R.string.upto1LakhOnly) holder.tvUpiMsg.text = context.getString(R.string.upto1LakhOnly)
}else{
} else {
holder.tvUpiMsg.text = "" holder.tvUpiMsg.text = ""
} }
if (selectedAccount == bankList.Value && checkedPosition == -2
) {
holder.bankSelector.setBackgroundResource(R.drawable.ic_select_green)
if (selectedAmount !=null && (checkedPosition == -2)) {
holder.paymentSelector.setBackgroundResource(R.drawable.ic_select_green)
checkedPosition = holder.adapterPosition checkedPosition = holder.adapterPosition
} else if (checkedPosition == -1) { } else if (checkedPosition == -1) {
holder.bankSelector.setBackgroundResource(R.drawable.ic_select_outline)
holder.paymentSelector.setBackgroundResource(R.drawable.ic_select_outline)
} else if (checkedPosition == holder.adapterPosition) { } else if (checkedPosition == holder.adapterPosition) {
holder.bankSelector.setBackgroundResource(R.drawable.ic_select_green)
holder.paymentSelector.setBackgroundResource(R.drawable.ic_select_green)
} else { } else {
holder.bankSelector.setBackgroundResource(R.drawable.ic_select_outline)
holder.paymentSelector.setBackgroundResource(R.drawable.ic_select_outline)
} }
setOnClickListener {
onItemClickListener?.let {
it(bankList)
holder.bankSelector.setBackgroundResource(R.drawable.ic_select_green)
if (checkedPosition != holder.adapterPosition) {
notifyItemChanged(checkedPosition)
checkedPosition = holder.adapterPosition
}
holder.itemView.setOnClickListener {
holder.paymentSelector.setBackgroundResource(R.drawable.ic_select_green)
if (checkedPosition != holder.adapterPosition) {
notifyItemChanged(checkedPosition)
checkedPosition = holder.adapterPosition
} }
} }
} }
@ -75,7 +74,7 @@ class PaymentModeAdapter(
} }
override fun getItemCount(): Int { override fun getItemCount(): Int {
return bankList?.size!!
return listOfPayMode?.size!!
} }
private var onItemClickListener: ((GetCodes) -> Unit)? = null private var onItemClickListener: ((GetCodes) -> Unit)? = null
@ -87,8 +86,14 @@ class PaymentModeAdapter(
fun getSelected(): GetCodes? { fun getSelected(): GetCodes? {
return if (checkedPosition != -1) { return if (checkedPosition != -1) {
bankList?.get(checkedPosition)
listOfPayMode?.get(checkedPosition)
} else null } else null
} }
private fun removeItem(position: Int) {
listOfPayMode?.removeAt(position)
notifyItemRemoved(position)
listOfPayMode?.let { notifyItemRangeChanged(position, it.size) }
}
} }

+ 1
- 2
app/src/main/java/com/nivesh/production/niveshfd/ui/fragment/StepFourNiveshFDFragment.kt View File

@ -235,7 +235,6 @@ class StepFourNiveshFDFragment : Fragment() {
getFDDetailsRequest.NiveshClientCode = getFDDetailsRequest.NiveshClientCode =
(activity as NiveshFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_CODE (activity as NiveshFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_CODE
getFDDetailsRequest.UniqueId = (activity as NiveshFdMainActivity).uniqueId getFDDetailsRequest.UniqueId = (activity as NiveshFdMainActivity).uniqueId
ProgressUtil.showLoading(activity as NiveshFdMainActivity)
(activity as NiveshFdMainActivity).viewModel.getFDDetails( (activity as NiveshFdMainActivity).viewModel.getFDDetails(
getFDDetailsRequest, getFDDetailsRequest,
token, token,
@ -285,7 +284,7 @@ class StepFourNiveshFDFragment : Fragment() {
} }
} }
is Resource.Loading -> { is Resource.Loading -> {
ProgressUtil.hideLoading()
} }
is Resource.DataError -> { is Resource.DataError -> {


+ 5
- 0
app/src/main/java/com/nivesh/production/niveshfd/ui/fragment/StepOneNiveshFDFragment.kt View File

@ -13,6 +13,7 @@ import android.view.ViewGroup
import android.widget.ArrayAdapter import android.widget.ArrayAdapter
import android.widget.RadioButton import android.widget.RadioButton
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.recyclerview.widget.DefaultItemAnimator import androidx.recyclerview.widget.DefaultItemAnimator
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView.LayoutManager import androidx.recyclerview.widget.RecyclerView.LayoutManager
@ -27,12 +28,14 @@ import com.nivesh.production.niveshfd.util.Common.Companion.commonErrorMethod
import com.nivesh.production.niveshfd.util.Common.Companion.removeError import com.nivesh.production.niveshfd.util.Common.Companion.removeError
import com.nivesh.production.niveshfd.util.Constants.Companion.token import com.nivesh.production.niveshfd.util.Constants.Companion.token
import com.nivesh.production.niveshfd.util.Resource import com.nivesh.production.niveshfd.util.Resource
import com.nivesh.production.niveshfd.viewModel.MyObseravble
class StepOneNiveshFDFragment : Fragment() { class StepOneNiveshFDFragment : Fragment() {
private var _binding: FragmentNiveshfdStepOneBinding? = null private var _binding: FragmentNiveshfdStepOneBinding? = null
private val binding get() = _binding!! private val binding get() = _binding!!
private val observerViewModel: MyObseravble by activityViewModels()
private lateinit var rgMaturity: RadioButton private lateinit var rgMaturity: RadioButton
private lateinit var listOfTenure: MutableList<ROIDataList> private lateinit var listOfTenure: MutableList<ROIDataList>
private lateinit var recyclerViewDropDownAdapter: HorizontalRecyclerViewAdapter private lateinit var recyclerViewDropDownAdapter: HorizontalRecyclerViewAdapter
@ -115,8 +118,10 @@ class StepOneNiveshFDFragment : Fragment() {
// Next Button // Next Button
binding.btnNext.setOnClickListener { binding.btnNext.setOnClickListener {
if (validation()) { if (validation()) {
(activity as NiveshFdMainActivity).fdInvestmentDetails.FDAmount = (activity as NiveshFdMainActivity).fdInvestmentDetails.FDAmount =
binding.edtAmount.text.toString().toDouble() binding.edtAmount.text.toString().toDouble()
observerViewModel.data.value = binding.edtAmount.text.toString()
(activity as NiveshFdMainActivity).fdInvestmentDetails.Frequency = (activity as NiveshFdMainActivity).fdInvestmentDetails.Frequency =
binding.spInterestPayout.text.toString() binding.spInterestPayout.text.toString()
(activity as NiveshFdMainActivity).fdInvestmentDetails.Tenure = tenure (activity as NiveshFdMainActivity).fdInvestmentDetails.Tenure = tenure


+ 47
- 15
app/src/main/java/com/nivesh/production/niveshfd/ui/fragment/StepTwoNiveshFDFragment.kt View File

@ -18,6 +18,7 @@ import android.widget.RadioButton
import android.widget.TextView import android.widget.TextView
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
@ -44,6 +45,7 @@ import com.nivesh.production.niveshfd.util.Common.Companion.showDialogValidation
import com.nivesh.production.niveshfd.util.Constants.Companion.token import com.nivesh.production.niveshfd.util.Constants.Companion.token
import com.nivesh.production.niveshfd.util.ProgressUtil import com.nivesh.production.niveshfd.util.ProgressUtil
import com.nivesh.production.niveshfd.util.Resource import com.nivesh.production.niveshfd.util.Resource
import com.nivesh.production.niveshfd.viewModel.MyObseravble
import java.util.* import java.util.*
@ -52,6 +54,7 @@ class StepTwoNiveshFDFragment : Fragment() {
private var _binding: FragmentNiveshfdStepTwoBinding? = null private var _binding: FragmentNiveshfdStepTwoBinding? = null
private val binding get() = _binding!! private val binding get() = _binding!!
private val observerViewModel: MyObseravble by activityViewModels()
private lateinit var listOfTitle: List<GetCodes> private lateinit var listOfTitle: List<GetCodes>
private lateinit var listOfGender: List<GetCodes> private lateinit var listOfGender: List<GetCodes>
private lateinit var listOfAnnualIncome: List<GetCodes> private lateinit var listOfAnnualIncome: List<GetCodes>
@ -682,8 +685,7 @@ class StepTwoNiveshFDFragment : Fragment() {
bankListAdapter.getSelected()?.AccountNumber bankListAdapter.getSelected()?.AccountNumber
(activity as NiveshFdMainActivity).fdBankDetails.BankName = (activity as NiveshFdMainActivity).fdBankDetails.BankName =
bankListAdapter.getSelected()?.BankName bankListAdapter.getSelected()?.BankName
(activity as NiveshFdMainActivity).fdBankDetails.PaymentMode =
rbPaymentMode.text.toString()
(activity as NiveshFdMainActivity).fdBankDetails.PaymentMode = paymentModeAdapter.getSelected()?.Value
(activity as NiveshFdMainActivity).createFDApplicantRequest.ApplicantDetails = (activity as NiveshFdMainActivity).createFDApplicantRequest.ApplicantDetails =
(activity as NiveshFdMainActivity).applicantDetails (activity as NiveshFdMainActivity).applicantDetails
@ -898,7 +900,7 @@ class StepTwoNiveshFDFragment : Fragment() {
if (getBankValidationApiResponse.Message == getString(R.string.accountVerified)) { if (getBankValidationApiResponse.Message == getString(R.string.accountVerified)) {
val clientBankList = ClientBanklist() val clientBankList = ClientBanklist()
clientBankList.AccountNumber = bankAccount clientBankList.AccountNumber = bankAccount
clientBankList.AccountType = "sb"
clientBankList.AccountType = rbBank.text.toString()
clientBankList.BankName = clientBankList.BankName =
binding.edtBankName.text.toString() binding.edtBankName.text.toString()
clientBankList.BranchName = clientBankList.BranchName =
@ -1037,10 +1039,10 @@ class StepTwoNiveshFDFragment : Fragment() {
private fun guardianCodeVisibility(visibility: Int) { private fun guardianCodeVisibility(visibility: Int) {
binding.tlGuardianName.visibility = visibility binding.tlGuardianName.visibility = visibility
binding.tlGuardianName.visibility = visibility
binding.tlGuardianName.visibility = visibility
binding.tlGuardianName.visibility = visibility
binding.tlGuardianName.visibility = visibility
binding.tlGuardianAddress.visibility = visibility
binding.tlGuardianAge.visibility = visibility
binding.tlGuardianPinCode.visibility = visibility
binding.tlGuardianRelation.visibility = visibility
} }
@ -1210,7 +1212,7 @@ class StepTwoNiveshFDFragment : Fragment() {
200 -> { 200 -> {
if (getCodeResponse.Response.GetCodesList.isNotEmpty()) { if (getCodeResponse.Response.GetCodesList.isNotEmpty()) {
listOfPayMode = getCodeResponse.Response.GetCodesList listOfPayMode = getCodeResponse.Response.GetCodesList
setUpRecyclerViewPaymentMode(listOfPayMode)
setUpRecyclerViewPaymentMode(listOfPayMode as MutableList<GetCodes>)
} }
} }
// 650 -> refreshToken() // 650 -> refreshToken()
@ -1239,7 +1241,28 @@ class StepTwoNiveshFDFragment : Fragment() {
} }
} }
private fun setUpRecyclerViewPaymentMode(listOfPayMode: List<GetCodes>) {
private fun setUpRecyclerViewPaymentMode(listOfPayMode: MutableList<GetCodes>) {
observerViewModel.data.observe(viewLifecycleOwner) {
val tempList= mutableListOf<GetCodes>()
tempList.addAll(listOfPayMode)
val amountEntered:String = observerViewModel.data.value.toString()
if( amountEntered.toDouble()>100000.0) {
for (list in listOfPayMode) {
if (list.Value == "UPI") {
tempList.remove(list)
break
}
}
}
binding.rvPaymentMode.layoutManager =
GridLayoutManager(activity as NiveshFdMainActivity, 2)
paymentModeAdapter = PaymentModeAdapter(
tempList,
listOfPayMode[0].Value
)
binding.rvPaymentMode.adapter = paymentModeAdapter
}
binding.rvPaymentMode.layoutManager = binding.rvPaymentMode.layoutManager =
GridLayoutManager(activity as NiveshFdMainActivity, 2) GridLayoutManager(activity as NiveshFdMainActivity, 2)
@ -1337,16 +1360,25 @@ class StepTwoNiveshFDFragment : Fragment() {
R.layout.spinner_dropdown, R.layout.spinner_dropdown,
listOfRelationShip listOfRelationShip
) )
binding.spNomineeRelation.setAdapter(adapter) binding.spNomineeRelation.setAdapter(adapter)
binding.spNomineeRelation.setText(
adapter.getItem(0)?.Value,
false
)
val nomineeRelation = (activity as NiveshFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.Nominees?.get(0)?.NomineeRelationship
if (nomineeRelation.isNullOrEmpty()) {
binding.spNomineeRelation.setText(adapter.getItem(0)?.Label,
false)
}else{
for (title in listOfRelationShip) {
if (title.Label == nomineeRelation) {
binding.spNomineeRelation.setText(title.Label ,
false)
break
}
}
}
binding.spGuardianRelation.setAdapter(adapter) binding.spGuardianRelation.setAdapter(adapter)
binding.spGuardianRelation.setText( binding.spGuardianRelation.setText(
adapter.getItem(0)?.Value,
adapter.getItem(0)?.Label,
false false
) )
} }


+ 9
- 2
app/src/main/java/com/nivesh/production/niveshfd/util/ProgressUtil.kt View File

@ -8,6 +8,10 @@ import android.graphics.drawable.ColorDrawable
import android.util.Log import android.util.Log
import android.view.Window import android.view.Window
import android.widget.ProgressBar import android.widget.ProgressBar
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
@SuppressLint("StaticFieldLeak") @SuppressLint("StaticFieldLeak")
object ProgressUtil{ object ProgressUtil{
@ -41,8 +45,11 @@ object ProgressUtil{
fun hideLoading(){ fun hideLoading(){
try { try {
if(alertDialog.isShowing){
alertDialog.dismiss()
CoroutineScope(IO).launch {
delay(1000)
if(alertDialog.isShowing){
alertDialog.dismiss()
}
} }
} catch (e: UninitializedPropertyAccessException) { } catch (e: UninitializedPropertyAccessException) {
Log.e("TAG","AlertDialog UninitializedPropertyAccessException") Log.e("TAG","AlertDialog UninitializedPropertyAccessException")


+ 12
- 0
app/src/main/java/com/nivesh/production/niveshfd/viewModel/MyObseravble.kt View File

@ -0,0 +1,12 @@
package com.nivesh.production.niveshfd.viewModel
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
open class MyObseravble : ViewModel()
{
val data = MutableLiveData<String>()
fun data(item: String) {
data.value = item
}
}

+ 5
- 4
app/src/main/res/layout/item_payment_list_preview.xml View File

@ -8,7 +8,8 @@
app:cardElevation="2dp" app:cardElevation="2dp"
app:cardMaxElevation="1dp" app:cardMaxElevation="1dp"
app:cardPreventCornerOverlap="true" app:cardPreventCornerOverlap="true"
app:cardUseCompatPadding="true">
app:cardUseCompatPadding="true"
android:id="@+id/cardView">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -22,7 +23,7 @@
android:orientation="horizontal"> android:orientation="horizontal">
<ImageView <ImageView
android:id="@+id/bankSelector"
android:id="@+id/paymentSelector"
android:layout_width="@dimen/margin_25" android:layout_width="@dimen/margin_25"
android:layout_height="@dimen/margin_25" android:layout_height="@dimen/margin_25"
android:layout_marginStart="@dimen/margin_10" android:layout_marginStart="@dimen/margin_10"
@ -32,7 +33,7 @@
android:padding="@dimen/margin_5" /> android:padding="@dimen/margin_5" />
<TextView <TextView
android:id="@+id/tvBankName"
android:id="@+id/paymentMethod"
style="@style/BoldStyle" style="@style/BoldStyle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -52,4 +53,4 @@
android:textSize="@dimen/text_size_12" /> android:textSize="@dimen/text_size_12" />
</LinearLayout> </LinearLayout>
</com.google.android.material.card.MaterialCardView>
</com.google.android.material.card.MaterialCardView>

Loading…
Cancel
Save

Powered by TurnKey Linux.