@ -1,83 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.adapter | |||
import android.view.LayoutInflater | |||
import android.view.View | |||
import android.view.ViewGroup | |||
import android.widget.ImageView | |||
import android.widget.TextView | |||
import androidx.recyclerview.widget.RecyclerView | |||
import com.nivesh.production.niveshfd.R | |||
import com.nivesh.production.niveshfd.fd.model.ClientBanklist | |||
class BankListAdapter( | |||
private val bankList: List<ClientBanklist>?, | |||
private val selectedAccount: String? = null, | |||
private val width: Double? | |||
) : RecyclerView.Adapter<BankListAdapter.BankListViewHolder>() { | |||
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 tvBankAccountNumber: TextView = itemView.findViewById(R.id.tvBankAccountNumber) | |||
val tvBankIFSC: TextView = itemView.findViewById(R.id.tvBankIFSC) | |||
} | |||
private var checkedPosition: Int = -2 | |||
override fun onCreateViewHolder( | |||
parent: ViewGroup, | |||
viewType: Int | |||
): BankListViewHolder { | |||
val view = LayoutInflater.from(parent.context) | |||
.inflate(R.layout.item_bank_list_preview, parent, false); | |||
view.layoutParams = width?.div(1.35) | |||
?.let { ViewGroup.LayoutParams(it.toInt(), ViewGroup.LayoutParams.WRAP_CONTENT) } | |||
return BankListViewHolder(view) | |||
} | |||
override fun onBindViewHolder(holder: BankListViewHolder, position: Int) { | |||
val bankList = bankList?.get(position) | |||
if (bankList != null) { | |||
holder.itemView.apply { | |||
holder.tvBankName.text = bankList.BankName | |||
holder.tvBankIFSC.text = bankList.IFSCCode | |||
holder.tvBankAccountNumber.text = bankList.AccountNumber | |||
if (selectedAccount == bankList.AccountNumber && (checkedPosition == -2)) { | |||
holder.bankSelector.setBackgroundResource(R.drawable.ic_select_green) | |||
checkedPosition = holder.adapterPosition | |||
} else if (checkedPosition == -1) { | |||
holder.bankSelector.setBackgroundResource(R.drawable.ic_select_outline) | |||
} else if (checkedPosition == holder.adapterPosition) { | |||
holder.bankSelector.setBackgroundResource(R.drawable.ic_select_green) | |||
} else { | |||
holder.bankSelector.setBackgroundResource(R.drawable.ic_select_outline) | |||
} | |||
holder.itemView.setOnClickListener { | |||
holder.bankSelector.setBackgroundResource(R.drawable.ic_select_green) | |||
if (checkedPosition != holder.adapterPosition) { | |||
notifyItemChanged(checkedPosition) | |||
checkedPosition = holder.adapterPosition | |||
} | |||
} | |||
} | |||
} | |||
} | |||
override fun getItemCount(): Int { | |||
return bankList?.size!! | |||
} | |||
private var onItemClickListener: ((ClientBanklist) -> Unit)? = null | |||
fun setOnItemClickListener(listener: (ClientBanklist) -> Unit) { | |||
onItemClickListener = listener | |||
} | |||
fun getSelected(): ClientBanklist? { | |||
return if (checkedPosition != -1) { | |||
bankList?.get(checkedPosition) | |||
} else null | |||
} | |||
} |
@ -1,54 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.adapter | |||
import android.view.LayoutInflater | |||
import android.view.View | |||
import android.view.ViewGroup | |||
import android.widget.TextView | |||
import androidx.recyclerview.widget.RecyclerView | |||
import com.google.android.material.switchmaterial.SwitchMaterial | |||
import com.nivesh.production.niveshfd.R | |||
import com.nivesh.production.niveshfd.fd.model.GetCodes | |||
class CustomerListAdapter( | |||
private val customerList: MutableList<GetCodes>? | |||
) : RecyclerView.Adapter<CustomerListAdapter.BankListViewHolder>() { | |||
inner class BankListViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { | |||
val tvCustomerName: SwitchMaterial = itemView.findViewById(R.id.tvCustomerName) | |||
val txtLabel: TextView = itemView.findViewById(R.id.txtLabel) | |||
} | |||
override fun onCreateViewHolder( | |||
parent: ViewGroup, | |||
viewType: Int | |||
): BankListViewHolder { | |||
return BankListViewHolder( | |||
LayoutInflater.from(parent.context).inflate( | |||
R.layout.item_customer_list_preview, | |||
parent, | |||
false | |||
) | |||
) | |||
} | |||
override fun onBindViewHolder(holder: BankListViewHolder, position: Int) { | |||
val cList = customerList?.get(position) | |||
if (cList != null) { | |||
holder.txtLabel.text = cList.Label | |||
if(holder.txtLabel.text.contains("outside of india",true) ) { | |||
holder.tvCustomerName.isChecked = true | |||
holder.tvCustomerName.setOnCheckedChangeListener { _, isChecked -> | |||
cList.isSelected = isChecked | |||
} | |||
}else { | |||
holder.tvCustomerName.setOnCheckedChangeListener { _, isChecked -> | |||
cList.isSelected = isChecked | |||
} | |||
} | |||
} | |||
} | |||
override fun getItemCount(): Int { | |||
return customerList?.size!! | |||
} | |||
} |
@ -1,24 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.adapter | |||
import android.annotation.SuppressLint | |||
import android.content.Context | |||
import android.util.AttributeSet | |||
import android.view.MotionEvent | |||
import androidx.viewpager.widget.ViewPager | |||
class DisableAdapter (context: Context, attrs: AttributeSet) : ViewPager(context, attrs) { | |||
private var isPagingEnabled = true // change this value for enable and disable the viewpager swipe | |||
@SuppressLint("ClickableViewAccessibility") | |||
override fun onTouchEvent(event: MotionEvent?): Boolean { | |||
return this.isPagingEnabled && super.onTouchEvent(event) | |||
} | |||
override fun onInterceptTouchEvent(event: MotionEvent?): Boolean { | |||
return this.isPagingEnabled && super.onInterceptTouchEvent(event) | |||
} | |||
fun setPagingEnabled(b: Boolean) { isPagingEnabled = b | |||
} | |||
} |
@ -1,124 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.adapter | |||
import com.nivesh.production.niveshfd.fd.model.ROIDataList | |||
import android.annotation.SuppressLint | |||
import android.app.Activity | |||
import android.view.LayoutInflater | |||
import android.view.View | |||
import android.view.ViewGroup | |||
import android.widget.LinearLayout | |||
import android.widget.TextView | |||
import androidx.core.content.ContextCompat | |||
import androidx.core.content.res.ResourcesCompat | |||
import androidx.recyclerview.widget.RecyclerView | |||
import com.nivesh.production.niveshfd.R | |||
import com.nivesh.production.niveshfd.fd.adapter.HorizontalRecyclerViewAdapter.HistoryAdapterViewHolder2 | |||
import com.nivesh.production.niveshfd.fd.interfaces.OnClickListener | |||
class HorizontalRecyclerViewAdapter( | |||
private val activity: Activity, | |||
dropdownList: MutableList<ROIDataList>, | |||
onClickListener: OnClickListener | |||
) : RecyclerView.Adapter<HistoryAdapterViewHolder2>() { | |||
private var dropdownList: MutableList<ROIDataList> | |||
private var rowIndex = -1 | |||
private var onClickListener: OnClickListener | |||
inner class HistoryAdapterViewHolder2(view: View?) : RecyclerView.ViewHolder( | |||
view!! | |||
) { | |||
var txtYear: TextView = itemView.findViewById(R.id.txtYear) | |||
var txtInterestRate: TextView = itemView.findViewById(R.id.txtInterestRate) | |||
var rlParent: LinearLayout = itemView.findViewById(R.id.rlParent) | |||
} | |||
init { | |||
this.dropdownList = dropdownList | |||
this.onClickListener = onClickListener | |||
} | |||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): HistoryAdapterViewHolder2 { | |||
val itemView = | |||
LayoutInflater.from(parent.context).inflate(R.layout.row_dropdown, parent, false) | |||
return HistoryAdapterViewHolder2(itemView) | |||
} | |||
override fun onBindViewHolder( | |||
holder: HistoryAdapterViewHolder2, | |||
@SuppressLint("RecyclerView") position: Int | |||
) { | |||
if (dropdownList.isNotEmpty()) { | |||
val roiDataList: ROIDataList = dropdownList[position] | |||
getYear(holder.txtYear, roiDataList, holder) | |||
holder.txtInterestRate.text = roiDataList.ROI.toString().plus(" % ") | |||
holder.rlParent.setOnClickListener { | |||
rowIndex = position | |||
notifyDataSetChanged() | |||
} | |||
if (rowIndex == position) { | |||
onClickListener.onclickCategory(position) | |||
holder.txtYear.background = | |||
ResourcesCompat.getDrawable( | |||
activity.resources, | |||
R.drawable.rounded_corner_green_fill, | |||
null | |||
) | |||
holder.txtYear.setTextColor(ContextCompat.getColor(activity, R.color.white)) | |||
} else { | |||
holder.txtYear.background = | |||
ResourcesCompat.getDrawable( | |||
activity.resources, | |||
R.drawable.rounded_corner_with_line1, | |||
null | |||
) | |||
holder.txtYear.setTextColor( | |||
ContextCompat.getColor(activity, R.color.black) | |||
) | |||
} | |||
} | |||
} | |||
private fun getYear(txtYear: TextView, option: ROIDataList, holder: HistoryAdapterViewHolder2) { | |||
when (option.Tenure) { | |||
"12" -> { | |||
holder.rlParent.visibility = View.VISIBLE | |||
txtYear.text = activity.getString(R.string.OneYear) | |||
} | |||
"24" -> { | |||
holder.rlParent.visibility = View.VISIBLE | |||
txtYear.text = activity.getString(R.string.TwoYears) | |||
} | |||
"36" -> { | |||
holder.rlParent.visibility = View.VISIBLE | |||
txtYear.text = activity.getString(R.string.ThreeYears) | |||
} | |||
"48" -> { | |||
holder.rlParent.visibility = View.VISIBLE | |||
txtYear.text = activity.getString(R.string.FourYears) | |||
} | |||
"60" -> { | |||
holder.rlParent.visibility = View.VISIBLE | |||
txtYear.text = activity.getString(R.string.FiveYears) | |||
} | |||
else -> { | |||
holder.rlParent.visibility = View.GONE | |||
} | |||
} | |||
} | |||
override fun getItemCount(): Int { | |||
return dropdownList.size | |||
} | |||
override fun getItemViewType(position: Int): Int { | |||
return position | |||
} | |||
fun refresh() { | |||
rowIndex = -1 | |||
notifyDataSetChanged() | |||
} | |||
} |
@ -1,90 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.adapter | |||
import android.view.LayoutInflater | |||
import android.view.View | |||
import android.view.ViewGroup | |||
import android.widget.ImageView | |||
import android.widget.TextView | |||
import androidx.recyclerview.widget.RecyclerView | |||
import com.nivesh.production.niveshfd.R | |||
import com.nivesh.production.niveshfd.fd.model.GetCodes | |||
class PaymentModeAdapter( | |||
private val listOfPayMode: MutableList<GetCodes>, | |||
private var selectedAmount: String? = null | |||
) : RecyclerView.Adapter<PaymentModeAdapter.BankListViewHolder>() { | |||
inner class BankListViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { | |||
val paymentSelector: ImageView = itemView.findViewById(R.id.paymentSelector) | |||
val paymentMethod: TextView = itemView.findViewById(R.id.paymentMethod) | |||
val tvUpiMsg: TextView = itemView.findViewById(R.id.tvUpiMsg) | |||
} | |||
private var checkedPosition: Int = -2 | |||
override fun onCreateViewHolder( | |||
parent: ViewGroup, | |||
viewType: Int | |||
): BankListViewHolder { | |||
return BankListViewHolder( | |||
LayoutInflater.from(parent.context).inflate( | |||
R.layout.item_payment_list_preview, | |||
parent, | |||
false | |||
) | |||
) | |||
} | |||
override fun onBindViewHolder(holder: BankListViewHolder, position: Int) { | |||
val listOfPayMode = listOfPayMode[position] | |||
holder.itemView.apply { | |||
holder.paymentMethod.text = listOfPayMode.Value | |||
if (listOfPayMode.Value == "UPI") { | |||
holder.tvUpiMsg.text = context.getString(R.string.upto1LakhOnly) | |||
} else { | |||
holder.tvUpiMsg.text = "" | |||
} | |||
if (selectedAmount != null && (checkedPosition == -2)) { | |||
holder.paymentSelector.setBackgroundResource(R.drawable.ic_select_green) | |||
checkedPosition = holder.adapterPosition | |||
} else if (checkedPosition == -1) { | |||
holder.paymentSelector.setBackgroundResource(R.drawable.ic_select_outline) | |||
} else if (checkedPosition == holder.adapterPosition) { | |||
holder.paymentSelector.setBackgroundResource(R.drawable.ic_select_green) | |||
} else { | |||
holder.paymentSelector.setBackgroundResource(R.drawable.ic_select_outline) | |||
} | |||
holder.itemView.setOnClickListener { | |||
holder.paymentSelector.setBackgroundResource(R.drawable.ic_select_green) | |||
if (checkedPosition != holder.adapterPosition) { | |||
notifyItemChanged(checkedPosition) | |||
checkedPosition = holder.adapterPosition | |||
} | |||
} | |||
} | |||
} | |||
override fun getItemCount(): Int { | |||
return listOfPayMode.size | |||
} | |||
private var onItemClickListener: ((GetCodes) -> Unit)? = null | |||
fun setOnItemClickListener(listener: (GetCodes) -> Unit) { | |||
onItemClickListener = listener | |||
} | |||
fun getSelected(): GetCodes? { | |||
return if (checkedPosition != -1) { | |||
listOfPayMode[checkedPosition] | |||
} else null | |||
} | |||
} |
@ -1,35 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.adapter | |||
import android.view.LayoutInflater | |||
import android.view.View | |||
import android.view.ViewGroup | |||
import android.widget.TextView | |||
import androidx.recyclerview.widget.RecyclerView | |||
import com.nivesh.production.niveshfd.R | |||
import com.nivesh.production.niveshfd.fd.model.Bank | |||
class RecommendedBankListAdapter( | |||
private val bankList: List<Bank> | |||
) : RecyclerView.Adapter<RecommendedBankListAdapter.MyViewHolder>() { | |||
class MyViewHolder(view: View) : RecyclerView.ViewHolder(view) { | |||
val txtYear :TextView = view.findViewById(R.id.txtYear) | |||
} | |||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder { | |||
val itemView: View = LayoutInflater.from(parent.context) | |||
.inflate(R.layout.row_bank_list, parent, false) | |||
return MyViewHolder(itemView) | |||
} | |||
override fun onBindViewHolder(holder: MyViewHolder, position: Int) { | |||
val bank: Bank = bankList[position] | |||
holder.txtYear.text = bank.BankName | |||
} | |||
override fun getItemCount(): Int { | |||
return bankList.size | |||
} | |||
} |
@ -1,18 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.adapter | |||
import androidx.fragment.app.Fragment | |||
import androidx.fragment.app.FragmentManager | |||
import androidx.fragment.app.FragmentPagerAdapter | |||
class SectionsPagerAdapter(manager: FragmentManager,private val fragments: Array<Fragment>) : FragmentPagerAdapter(manager, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { | |||
private val titles = ArrayList<String>() | |||
override fun getItem(position: Int): Fragment = fragments[position] | |||
override fun getCount(): Int = fragments.size | |||
override fun getPageTitle(position: Int): CharSequence = titles[position] | |||
} |
@ -1,19 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.api | |||
import okhttp3.Authenticator | |||
import okhttp3.Request | |||
import okhttp3.Response | |||
import okhttp3.Route | |||
class TokenAuthenticator { | |||
// override fun authenticate(route: Route?, response: Response): Request? { | |||
//// newAccessToken = service.refreshToken(); | |||
//// | |||
//// // Add new header to rejected request and retry it | |||
//// return response.request().newBuilder() | |||
//// .header(AUTHORIZATION, newAccessToken) | |||
//// .build(); | |||
// | |||
// | |||
// } | |||
} |
@ -1,175 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.interfaces | |||
import com.google.gson.JsonObject | |||
import com.nivesh.production.niveshfd.fd.model.* | |||
import okhttp3.RequestBody | |||
import retrofit2.Response | |||
import retrofit2.http.* | |||
interface ApiInterface { | |||
@POST("GetRates") | |||
suspend fun getRates( | |||
@Body getRatesRequest: GetRatesRequest, | |||
@Header("token") token: String | |||
): Response<JsonObject> | |||
@POST("CheckFDCKYC") | |||
suspend fun checkFDKYC( | |||
@Body checkFDKYCRequest: CheckFDKYCRequest, | |||
@Header("token") token: String | |||
): Response<JsonObject> | |||
@POST("CreateFDApplication") | |||
suspend fun createFDApp( | |||
@Body createFDRequest: CreateFDRequest, | |||
@Header("token") token: String | |||
): Response<JsonObject> | |||
@POST("DocumentsUpload") | |||
suspend fun documentsUpload( | |||
@Body requestBody: DocumentUpload, | |||
@Header("token") token: String | |||
): Response<JsonObject> | |||
@POST("SaveFDOtherData") | |||
suspend fun saveFDOtherData( | |||
@Body requestBody: SaveFDOtherDataRequest, | |||
@Header("token") token: String | |||
): Response<JsonObject> | |||
@POST("GetFDDetails") | |||
suspend fun getFDDetails( | |||
@Body requestBody: GetFDDetailsRequest, | |||
@Header("token") token: String | |||
): Response<JsonObject> | |||
@POST("FinaliseFD") | |||
suspend fun finaliseFD( | |||
@Body requestBody: FinalizeFDRequest, | |||
@Header("token") token: String | |||
): Response<JsonObject> | |||
@POST("FinaliseKYC") | |||
suspend fun finaliseKYC( | |||
@Body requestBody: FinalizeKYCRequest, | |||
@Header("token") token: String | |||
): Response<JsonObject> | |||
@POST("PaymentRequery") | |||
suspend fun paymentReQuery( | |||
@Body requestBody: PaymentReQueryRequest, | |||
@Header("token") token: String | |||
): Response<JsonObject> | |||
// @FormUrlEncoded | |||
@POST("GetCodes") | |||
suspend fun getCodes( | |||
@Body requestBody: GetCodeRequest, | |||
@Header("token") token: String | |||
): Response<JsonObject> | |||
@POST("CalculateFDMaturityAmount") | |||
suspend fun getCalculateFDMaturityAmount( | |||
@Body requestBody: GetMaturityAmountRequest, | |||
@Header("token") token: String | |||
): Response<JsonObject> | |||
@POST("PanCheck_S") | |||
suspend fun panCheckApi( | |||
@Body panCheck: PanCheckRequest, | |||
@Header("token") token: String | |||
): Response<JsonObject> | |||
@POST("getFDStepsCount") | |||
suspend fun getFDStepsCount( | |||
@Body fdStepsCountRequest: FDStepsCountRequest, | |||
@Header("token") token: String | |||
): Response<JsonObject> | |||
@POST("GetClientDetailV2_S") | |||
suspend fun getClientDetails( | |||
@Body getClientDetailsRequest: getClientDetailsRequest, | |||
@Header("token") token: String | |||
): Response<JsonObject> | |||
@POST("GetCodes") | |||
suspend fun titleApi( | |||
@Body getCodeRequest: GetCodeRequest, | |||
@Header("token") token: String | |||
): Response<JsonObject> | |||
@POST("GetCodes") | |||
suspend fun genderApi( | |||
@Body getCodeRequest: GetCodeRequest, | |||
@Header("token") token: String | |||
): Response<JsonObject> | |||
@POST("GetCodes") | |||
suspend fun annualIncomeApi( | |||
@Body getCodeRequest: GetCodeRequest, | |||
@Header("token") token: String | |||
): Response<JsonObject> | |||
@POST("GetCodes") | |||
suspend fun relationShipApi( | |||
@Body getCodeRequest: GetCodeRequest, | |||
@Header("token") token: String | |||
): Response<JsonObject> | |||
@POST("GetCodes") | |||
suspend fun maritalStatusApi( | |||
@Body getCodeRequest: GetCodeRequest, | |||
@Header("token") token: String | |||
): Response<JsonObject> | |||
@POST("GetCodes") | |||
suspend fun occupationApi( | |||
@Body getCodeRequest: GetCodeRequest, | |||
@Header("token") token: String | |||
): Response<JsonObject> | |||
@POST("GetStateMaster") | |||
suspend fun stateApi(@Header("token") token: String): Response<JsonObject> | |||
@POST("GetCity") | |||
suspend fun cityApi( | |||
@Body cityRequest: CityRequest, | |||
@Header("token") token: String | |||
): Response<JsonObject> | |||
@GET("GetFDBankList?FDProvider=Bajaj") | |||
suspend fun bankListApi(@Header("token") token: String, @Query("Language") language : String): Response<JsonObject> | |||
@GET("GetIFSC_Autofill?") | |||
suspend fun getIFSCApi(@Query("prefix") ifsc : String): Response<JsonObject> | |||
@GET("GetbankNames") | |||
suspend fun getIFSCBankDetailsApi(@Query( "bankname") ifsc : String, @Header("token") token: String): Response<String> | |||
@POST("GetCodes") | |||
suspend fun payModeApi( | |||
@Body getCodeRequest: GetCodeRequest, | |||
@Header("token") token: String | |||
): Response<JsonObject> | |||
@POST("GetCodes") | |||
suspend fun customerListApi( | |||
@Body getCodeRequest: GetCodeRequest, | |||
@Header("token") token: String | |||
): Response<JsonObject> | |||
@POST("BankValidationAPI_S") | |||
suspend fun bankValidationApi( | |||
@Body bankValidationApiRequest: BankValidationApiRequest, | |||
@Header("token") token: String | |||
): Response<JsonObject> | |||
@POST("BankValidationAPI_S") | |||
suspend fun getToken( | |||
@Body bankValidationApiRequest: BankValidationApiRequest, | |||
@Header("token") token: String | |||
): Response<JsonObject> | |||
} |
@ -1,5 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.interfaces; | |||
public interface OnClickListener { | |||
void onclickCategory(int position); | |||
} |
@ -1,8 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.interfaces | |||
import com.nivesh.production.niveshfd.fd.model.CreateFDApplicationResponse | |||
interface SendData { | |||
fun sendDataFragment(message: CreateFDApplicationResponse) | |||
fun sendDataFragmentStepFour(message: CreateFDApplicationResponse) | |||
} |
@ -1,24 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class ApplicantDetails( | |||
var AnnualIncome: String?= null, | |||
var ApplicantAddress1: String?= null, | |||
var ApplicantAddress2: String?= null, | |||
var ApplicantAddress3: String?= null, | |||
var ApplicantCity: String?= null, | |||
var ApplicantCountry: String?= null, | |||
var ApplicantDOB: String?= null, | |||
var ApplicantEmail: String?= null, | |||
var ApplicantFirstName: String?= null, | |||
var ApplicantGender: String?= null, | |||
var ApplicantLastName: String?= null, | |||
var ApplicantMaritalStatus: String?= null, | |||
var ApplicantMiddleName: String?= null, | |||
var ApplicantMobile: String?= null, | |||
var ApplicantOccupation: String?= null, | |||
var ApplicantPAN: String?= null, | |||
var ApplicantPincode: Int?= 0, | |||
var ApplicantQualification: String?= null, | |||
var ApplicantSalutation: String?= null, | |||
var ApplicantState: String?= null | |||
) |
@ -1,10 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class ApplicantRelationDetails( | |||
var ApplicantMotherFirstName: String? = null, | |||
var ApplicantMotherLastName: String? = null, | |||
var ApplicantRelation: String? = null, | |||
var ApplicantRelationFirstName: String? = null, | |||
var ApplicantRelationLastName: String? = null, | |||
var ApplicantRelationSalutation: String? = null | |||
) |
@ -1,6 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class Bank( | |||
val BankName: String, | |||
val IFSCInitials: String | |||
) |
@ -1,15 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
import java.io.Serializable | |||
data class BankList( | |||
val BankName: String?, | |||
val IFSCCode: String?, | |||
val AccountNumber: String?, | |||
val BranchName: String?, | |||
val DefaultBankFlag: String?, | |||
val IsValBank: String?, | |||
val AccountType: String? | |||
): Serializable | |||
@ -1,10 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class BankValidationApiRequest( | |||
var BankAccountNo: String?="", | |||
var BankNo: Int?= 0, | |||
var IFSC: String?= "", | |||
var Name: String? = "", | |||
var PhoneNo: String? = "", | |||
var RoleId: Int? = 0 | |||
) |
@ -1,8 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class BankValidationApiResponse( | |||
val DataObject: Any, | |||
val Message: String, | |||
val ObjectResponse: Any, | |||
val response: ResponseXXXXXXXXXXXXXX | |||
) |
@ -1,8 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class CheckFDKYCRequest( | |||
var DOB: String? ="", | |||
var Mobile: String? = "", | |||
var NiveshClientCode: String? = "", | |||
var PAN: String?= "" | |||
) |
@ -1,6 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class CityListResponse( | |||
val DataObject: List<DataObjectX>, | |||
val response: ResponseXXXXXX | |||
) |
@ -1,15 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class CityRequest( | |||
var APIName: String? = "", | |||
var APP_Web: String?="", | |||
var ClientCode: String?="", | |||
var HOCode: String?="", | |||
var RMCode: String?="", | |||
var RoleID: Int = 0, | |||
var Source: String? = "", | |||
var StateCode: Int? = 0, | |||
var Subbroker_Code: String? = "", | |||
var Type: String?= "", | |||
var UID: Int = 0 | |||
) |
@ -1,11 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class ClientBanklist( | |||
var AccountNumber: String?="", | |||
var AccountType: String?="", | |||
var BankName: String?="", | |||
var BranchName: String?="", | |||
val DefaultBankFlag: String?="", | |||
var IFSCCode: String?="", | |||
var IsValBank: Int? = 0 | |||
) |
@ -1,22 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class ClientDetails( | |||
val ARNexpiredFlag: Boolean, | |||
val EditProfileMessage: String, | |||
val IsPartiallyFilled: Boolean, | |||
val KYCstatus: String, | |||
val ProfileMessage: String, | |||
val ProfileStatus: String, | |||
val UnifiedMessage: String, | |||
val appliaction1_image_name: String, | |||
val city_of_birth: String, | |||
val clientMasterMFD: ClientMasterMFD, | |||
val country_of_birth: String, | |||
val created_by: String, | |||
val created_date: String, | |||
val email: String, | |||
val mobile: String, | |||
val modified_by: String, | |||
val modified_date: String, | |||
val sub_broker_code: String | |||
) |
@ -1,40 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class ClientMasterMFD( | |||
val CLIENT_ACCNO1: String, | |||
val CLIENT_ACCTYPE1: String, | |||
val CLIENT_ADD1: String, | |||
val CLIENT_ADD2: String, | |||
val CLIENT_ADD3: String, | |||
val CLIENT_APPNAME1: String, | |||
val CLIENT_CITY: String, | |||
val CLIENT_CODE: String, | |||
val CLIENT_COMMMODE: String, | |||
val CLIENT_COUNTRY: String, | |||
val CLIENT_DIVPAYMODE: String, | |||
val CLIENT_DOB: String, | |||
val CLIENT_EMAIL: String, | |||
val CLIENT_FATHER_HUSBAND_GUARDIAN: String, | |||
val CLIENT_GENDER: String, | |||
val CLIENT_GUARDIANPAN: String, | |||
val CLIENT_HOLDING: String, | |||
val CLIENT_NEFT_IFSCCODE1: String, | |||
val CLIENT_OCCUPATION_CODE: String, | |||
val CLIENT_PAN: String, | |||
val CLIENT_PINCODE: String, | |||
val CLIENT_STATE: String, | |||
val CLIENT_TAXSTATUS: String, | |||
val CLIENT_TYPE: String, | |||
val CM_MOBILE: String, | |||
val Client_Title: String, | |||
val DEFAULT_BLANK_FLAG1: String, | |||
val Filler1: String, | |||
val Filler2: String, | |||
val Filler3: Any, | |||
val NominationAuthMode: String, | |||
val NominationOptFlag: String, | |||
val Nominee_Title: String, | |||
val Nominees: List<Nominee>, | |||
val ParentName: String, | |||
val ums_id: String | |||
) |
@ -1,10 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class CreateFDApplicationRequest( | |||
var ApplicantDetails: ApplicantDetails ? = null, | |||
var ApplicantRelationDetails: ApplicantRelationDetails? = null, | |||
var FDInvestmentDetails: FDInvestmentDetails? = null, | |||
var FdBankDetails: FdBankDetails? = null, | |||
var NomineeDetails: NomineeDetails? = null, | |||
var NomineeGuardianDetails: NomineeGuardianDetails ? = null | |||
) |
@ -1,5 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class CreateFDApplicationResponse( | |||
val Response: ResponseXXXXXXXXXXX | |||
) |
@ -1,5 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class CreateFDRequest( | |||
var CreateFDApplicationRequest: CreateFDApplicationRequest? = null | |||
) |
@ -1,17 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
import java.io.Serializable | |||
data class DataObject( | |||
var BSE_State_Code: String? = "", | |||
var CAMS_statecode: String? = "", | |||
var Country_Id: Int? = 0, | |||
var State_Code: String?= "", | |||
var State_Id: Int? = 0, | |||
var State_Name: String? = "", | |||
var signzyCode: String? = "" | |||
): Serializable { | |||
override fun toString(): String { | |||
return State_Name.toString() | |||
} | |||
} |
@ -1,10 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class DataObjectX( | |||
val city_id: Int, | |||
val city_name: String | |||
) { | |||
override fun toString(): String { | |||
return city_name | |||
} | |||
} |
@ -1,12 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class DeviceInfo( | |||
var app_version: String? = "", | |||
var device_id: String? = "", | |||
var device_model: String? = "", | |||
var device_name: String? ="", | |||
var device_os_version: String? = "", | |||
var device_token: String? = "", | |||
var device_type: String? = "", | |||
var device_id_for_UMSId : String? = "" | |||
) |
@ -1,10 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class DocumentUpload( | |||
var Description: String? = null, | |||
var DocumentType: String? = null, | |||
var FDProvider: String? = null, | |||
var ImageEncodeToBase64: String? = null, | |||
var NiveshClientCode: String? = null, | |||
var UniqueId: String? = null | |||
) |
@ -1,6 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class Errors( | |||
val ErrorCode: Int, | |||
val ErrorMessage: String | |||
) |
@ -1,7 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class FDCreationDetailsResponse( | |||
val DocumentUploadFlag: Int, | |||
val UniqueId: String, | |||
val kycFlag: Int | |||
) |
@ -1,12 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class FDDataResponse( | |||
val FDAmount: Double, | |||
val Frequency: String, | |||
val ParameterName: String, | |||
val PaymentUrl: String, | |||
val RateOfInterest: Double, | |||
val Tenure: Int, | |||
val UniqueId: String, | |||
val Value: String | |||
) |
@ -1,19 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class FDInvestmentDetails( | |||
var CKYCNumber: String? = null, | |||
var CitizenType: String? = null, | |||
var CustomerType: String? = null, | |||
var Device: String? = null, | |||
var FDAmount: Double? = 0.0, | |||
var Frequency: String? = null, | |||
var IPAddress: String? = null, | |||
var Interest: Double? = 0.0, | |||
var NiveshClientCode: String? = null, | |||
var Provider: String? = null, | |||
var Source: String? = null, | |||
var Tenure: Int? = 0, | |||
var UniqueId: String? = "", | |||
var RenewOption : String = "" | |||
) |
@ -1,6 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class FDStepsCountRequest( | |||
var FDProvider: String? = "", | |||
var NiveshClientCode: String? = "" | |||
) |
@ -1,10 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class FdBankDetails( | |||
var AccountNumber: String?= null, | |||
var AccountType: String?= null, | |||
var BankBranch: String?= null, | |||
var BankName: String?= null, | |||
var IFSCCode: String?= null, | |||
var PaymentMode: String?= null | |||
) |
@ -1,7 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class FinaliseFD( | |||
var FDProvider: String? = "", | |||
var NiveshClientCode: String? = "", | |||
var UniqueId: String? = "" | |||
) |
@ -1,5 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class FinalizeFDRequest( | |||
var FinaliseFD: FinaliseFD? = null | |||
) |
@ -1,5 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class FinalizeFDResponse( | |||
val Response: ResponseXXXXXXXXXXXXXXXX | |||
) |
@ -1,7 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class FinalizeKYCRequest( | |||
var FDProvider: String? = "", | |||
var NiveshClientCode: String? = "", | |||
var UniqueId: String? = "" | |||
) |
@ -1,5 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class GetCalculateMaturityAmountResponse( | |||
val Response: ResponseXX | |||
) |
@ -1,8 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class GetCodeRequest( | |||
var Category: String ? = null, | |||
var InputValue: String? = null, | |||
var Language: String ? = null, | |||
var ProductName: String? = null | |||
) |
@ -1,5 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class GetCodeResponse( | |||
val Response: ResponseX | |||
) |
@ -1,11 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class GetCodes( | |||
val Label: String, | |||
var Value: String, | |||
var isSelected : Boolean | |||
) { | |||
override fun toString(): String { | |||
return Label | |||
} | |||
} |
@ -1,5 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class GetFDBankListResponse( | |||
val Response: ResponseXXXXXXXX | |||
) |
@ -1,7 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class GetFDDetailsRequest( | |||
var FDProvider: String? = "", | |||
var NiveshClientCode: String? = "", | |||
var UniqueId: String? = "" | |||
) |
@ -1,5 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class GetFDDetailsResponse( | |||
val Response: ResponseXXXXXXXXXXXX | |||
) |
@ -1,6 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class GetIFSCCodeListResponse( | |||
val IFSCCodes: MutableList<String>, | |||
val Response: ResponseXXXXXXXXXX | |||
) |
@ -1,5 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class GetIFSCCodeResponse( | |||
val IFSCCODEServiceResult: List<IFSCCODEServiceResult> | |||
) |
@ -1,9 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class GetMaturityAmountRequest( | |||
var FDAmount: Int? = 0, | |||
var FDProvider: String? = "", | |||
var Frequency: String? = "", | |||
var Interest: Double? = 0.0, | |||
var Tenure: Int? = 0 | |||
) |
@ -1,9 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
import com.google.gson.annotations.SerializedName | |||
data class GetRatesRequest( | |||
@SerializedName("FDProvider") var fdProvider: String? = null, | |||
@SerializedName("Frequency") var frequency: String? = null, | |||
@SerializedName("Type") var type: String? = null | |||
) |
@ -1,5 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class GetRatesResponse( | |||
val Response: Response | |||
) |
@ -1,10 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class IFSCCODEServiceResult( | |||
val BankBranch: String, | |||
val BnkDescr: String, | |||
val BnkShrtDescr: String, | |||
val Code: String, | |||
val IfscCode: String, | |||
val intCustbnk_pk: String | |||
) |
@ -1,12 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class Nominee( | |||
val NomineeApplicablePercent: Double, | |||
val NomineeDOB: String, | |||
val NomineeGuardian: String, | |||
val NomineeGuardianPAN: String, | |||
val NomineeMinorFlag: String, | |||
val NomineeName: String, | |||
val NomineePAN: String, | |||
val NomineeRelationship: String | |||
) |
@ -1,18 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class NomineeDetails( | |||
var NomineeAddress1: String?= null, | |||
var NomineeAddress2: String?= null, | |||
var NomineeAddress3: String?= null, | |||
var NomineeCity: String?= null, | |||
var NomineeCountry: String?= null, | |||
var NomineeDOB: String?= null, | |||
var NomineeFirstName: String?= null, | |||
var NomineeGender: String?= null, | |||
var NomineeLastName: String?= null, | |||
var NomineeMiddleName: String?= null, | |||
var NomineePincode: Int?= 0, | |||
var NomineeRelation: String?= null, | |||
var NomineeSalutation: String?= null, | |||
var NomineeState: String?= null | |||
) |
@ -1,14 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class NomineeGuardianDetails( | |||
var GuardianAddress1: String?= null, | |||
var GuardianAddress2: String?= null, | |||
var GuardianAddress3: String?= null, | |||
var GuardianAge: Int?= 0, | |||
var GuardianCity: String?= null, | |||
var GuardianCountry: String?= null, | |||
var GuardianName: String?= null, | |||
var GuardianPincode: Int?= 0, | |||
var GuardianSalutation: String?= null, | |||
var GuardianState: String?= null | |||
) |
@ -1,9 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class ObjectResponse( | |||
val TransactionCount: Int, | |||
val clientDetails: ClientDetails, | |||
val languageid: Int, | |||
val membersList: List<Any>, | |||
val ClientBanklist : List<ClientBanklist> | |||
) |
@ -1,14 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
import com.google.gson.annotations.SerializedName | |||
data class PanCheckRequest( | |||
@SerializedName("client_code") | |||
var clientCode: String? = null, | |||
@SerializedName("sub_broker_code") | |||
var subBrokerCode: String? = null, | |||
@SerializedName("pan_number") | |||
var panNumber: String? = null, | |||
@SerializedName("mobile_number") | |||
var mobileNumber: String? = null | |||
) |
@ -1,5 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class PanCheckResponse( | |||
val response: ResponseXXX | |||
) |
@ -1,6 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class PaymentReQueryRequest( | |||
var NiveshClientCode: String? = "", | |||
var UniqueId: String? = "" | |||
) |
@ -1,5 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class PaymentReQueryResponse( | |||
val Response: ResponseXXXXXXXXXXXXXXX | |||
) |
@ -1,13 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class ROIDataList( | |||
val Frequency: String, | |||
val Provider: String, | |||
val ROI: Double, | |||
val Tenure: String, | |||
val Type: String | |||
) { | |||
override fun toString(): String { | |||
return Tenure.plus(" Months ").plus(" | ").plus(ROI).plus("%") | |||
} | |||
} |
@ -1,11 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
import com.nivesh.production.niveshfd.fd.model.Errors | |||
data class Response( | |||
val Errors: List<Errors>, | |||
val Message: String, | |||
var ROIDatalist: MutableList<ROIDataList>, | |||
val Status: String, | |||
val StatusCode: Int | |||
) |
@ -1,9 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class ResponseX( | |||
val Errors: List<Errors>, | |||
val GetCodesList: MutableList<GetCodes>, | |||
val Message: String, | |||
val Status: String, | |||
val StatusCode: Int | |||
) |
@ -1,9 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class ResponseXX( | |||
val Errors: List<Errors>, | |||
val MaturityAmount: Double, | |||
val Message: String, | |||
val Status: String, | |||
val StatusCode: Int | |||
) |
@ -1,7 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class ResponseXXX( | |||
val message: String, | |||
val status: String, | |||
val status_code: Int | |||
) |
@ -1,9 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class ResponseXXXX( | |||
val Errors: List<Errors>, | |||
val Message: String, | |||
val Status: String, | |||
val StatusCode: Int, | |||
val StepsCount: Int | |||
) |
@ -1,7 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class ResponseXXXXX( | |||
val message: String, | |||
val status: String, | |||
val status_code: Int | |||
) |
@ -1,7 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class ResponseXXXXXX( | |||
val message: String, | |||
val status: String, | |||
val status_code: Int | |||
) |
@ -1,7 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class ResponseXXXXXXX( | |||
val message: String, | |||
val status: String, | |||
val status_code: Int | |||
) |
@ -1,9 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class ResponseXXXXXXXX( | |||
val BankList: List<Bank>, | |||
val Errors: List<Errors>, | |||
val Message: String, | |||
val Status: String, | |||
val StatusCode: Int | |||
) |
@ -1,7 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class ResponseXXXXXXXXX( | |||
val message: String, | |||
val status: String, | |||
val status_code: Int | |||
) |
@ -1,7 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class ResponseXXXXXXXXXX( | |||
val message: String, | |||
val status: String, | |||
val status_code: Int | |||
) |
@ -1,9 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class ResponseXXXXXXXXXXX( | |||
val Errors: List<Errors>, | |||
val FDCreationDetailsResponse: FDCreationDetailsResponse, | |||
val Message: String, | |||
val Status: String, | |||
val StatusCode: Int | |||
) |
@ -1,11 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
import com.nivesh.production.niveshfd.fd.util.Resource | |||
data class ResponseXXXXXXXXXXXX( | |||
val Errors: List<Errors>, | |||
val FDDataResponse: FDDataResponse, | |||
val Message: String, | |||
val Status: String, | |||
val StatusCode: Int | |||
) |
@ -1,8 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class ResponseXXXXXXXXXXXXX( | |||
val Errors: List<Errors>, | |||
val Message: String, | |||
val Status: String, | |||
val StatusCode: Int | |||
) |
@ -1,7 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class ResponseXXXXXXXXXXXXXX( | |||
val message: String, | |||
val status: String, | |||
val status_code: Int | |||
) |
@ -1,8 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class ResponseXXXXXXXXXXXXXXX( | |||
val Errors: List<Errors>, | |||
val Message: String, | |||
val Status: String, | |||
val StatusCode: Int | |||
) |
@ -1,10 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class ResponseXXXXXXXXXXXXXXXX( | |||
val Errors: List<Errors>, | |||
val Message: String, | |||
val Status: String, | |||
val StatusCode: Int, | |||
val UniqueId: String, | |||
val KYCFlag: Int | |||
) |
@ -1,8 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class SaveFDOtherDataRequest( | |||
var FDProvider: String?= "", | |||
var NiveshClientCode: String? = "", | |||
var UniqueId: String? = "", | |||
var Values: String? = "" | |||
) |
@ -1,5 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class SaveFDOtherDataResponse( | |||
val Response: ResponseXXXXXXXXXXXXX | |||
) |
@ -1,8 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class StateListResponse( | |||
val DataObject: List<DataObject>, | |||
val Message: Any, | |||
val ObjectResponse: Any, | |||
val response: ResponseXXXXX | |||
) |
@ -1,5 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class StepsCountResponse( | |||
val Response: ResponseXXXX | |||
) |
@ -1,5 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class UploadResponse( | |||
val Response: ResponseXXXXXXXXXXXX | |||
) |
@ -1,10 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class UserRequest( | |||
var AppOrWeb: String? = "", | |||
var IPAddress: String? = "", | |||
var LoggedInRoleId: Int = 0, | |||
var Source: String? = "", | |||
var UID: Int? = 0, | |||
var deviceInfo: DeviceInfo? = null | |||
) |
@ -1,8 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class getClientDetailsRequest( | |||
var AppOrWeb: String? = "", | |||
var UserRequest: UserRequest? = null, | |||
var client_code: String? = "", | |||
var sub_broker_code: String? = "" | |||
) |
@ -1,8 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.model | |||
data class getClientDetailsResponse( | |||
// val DataObject: Any ?, | |||
// val Message: Any, | |||
val ObjectResponse: ObjectResponse? = null, | |||
val response: ResponseXXXXXXX? = null | |||
) |
@ -1,111 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.repositories | |||
import com.nivesh.production.niveshfd.fd.interfaces.ApiInterface | |||
import com.nivesh.production.niveshfd.fd.model.* | |||
class MainRepository constructor(private val apiInterface: ApiInterface) { | |||
// MainActivity | |||
suspend fun getStepsCountResponse(requestBody: FDStepsCountRequest, token: String) = | |||
apiInterface.getFDStepsCount(requestBody, token) | |||
suspend fun getClientDetailsResponse(getClientDetails: getClientDetailsRequest, token: String) = | |||
apiInterface.getClientDetails(getClientDetails, token) | |||
// Step One | |||
suspend fun getRatesResponse(getRatesRequest: GetRatesRequest, token: String) = | |||
apiInterface.getRates(getRatesRequest, token) | |||
suspend fun getCodesResponse(requestBody: GetCodeRequest, token: String) = | |||
apiInterface.getCodes(requestBody, token) | |||
suspend fun createCalculateFDMaturityAmount( | |||
requestBody: GetMaturityAmountRequest, | |||
token: String | |||
) = | |||
apiInterface.getCalculateFDMaturityAmount(requestBody, token) | |||
// Step Two | |||
suspend fun createFDKYCResponse(createFDRequest: CreateFDRequest, token: String) = | |||
apiInterface.createFDApp(createFDRequest, token) | |||
suspend fun panCheck(panCheck: PanCheckRequest, token: String) = | |||
apiInterface.panCheckApi(panCheck, token) | |||
suspend fun titleCheck(getCodeRequest: GetCodeRequest, token: String) = | |||
apiInterface.titleApi(getCodeRequest, token) | |||
suspend fun genderCheck(getCodeRequest: GetCodeRequest, token: String) = | |||
apiInterface.genderApi(getCodeRequest, token) | |||
suspend fun annualIncomeCheck(getCodeRequest: GetCodeRequest, token: String) = | |||
apiInterface.annualIncomeApi(getCodeRequest, token) | |||
suspend fun relationShipCheck(getCodeRequest: GetCodeRequest, token: String) = | |||
apiInterface.relationShipApi(getCodeRequest, token) | |||
suspend fun maritalStatusCheck(getCodeRequest: GetCodeRequest, token: String) = | |||
apiInterface.maritalStatusApi(getCodeRequest, token) | |||
suspend fun occupationCheck(getCodeRequest: GetCodeRequest, token: String) = | |||
apiInterface.occupationApi(getCodeRequest, token) | |||
suspend fun stateCheck(token: String) = | |||
apiInterface.stateApi(token) | |||
suspend fun cityCheck(cityRequest: CityRequest, token: String) = | |||
apiInterface.cityApi(cityRequest, token) | |||
suspend fun bankListCheck(token: String, language: String) = | |||
apiInterface.bankListApi(token, language) | |||
suspend fun ifscCodeCheck(str: String) = | |||
apiInterface.getIFSCApi(str) | |||
suspend fun ifscCodeBankDetailsCheck(str: String, token: String) = | |||
apiInterface.getIFSCBankDetailsApi(str, token) | |||
suspend fun payModeCheck(getCodeRequest: GetCodeRequest, token: String) = | |||
apiInterface.payModeApi(getCodeRequest, token) | |||
suspend fun bankValidationApiRequest(bankValidationApiRequest: BankValidationApiRequest, token: String) = | |||
apiInterface.bankValidationApi(bankValidationApiRequest, token) | |||
// Step Three | |||
suspend fun documentsUploadResponse(getRatesRequest: DocumentUpload, token: String) = | |||
apiInterface.documentsUpload(getRatesRequest, token) | |||
suspend fun saveFDOtherDataResponse(getRatesRequest: SaveFDOtherDataRequest, token: String) = | |||
apiInterface.saveFDOtherData(getRatesRequest, token) | |||
suspend fun getFDDetailsResponse(getRatesRequest: GetFDDetailsRequest, token: String) = | |||
apiInterface.getFDDetails(getRatesRequest, token) | |||
suspend fun updateFDPaymentStatusResponse(getRatesRequest: GetRatesRequest, token: String) = | |||
apiInterface.getRates(getRatesRequest, token) | |||
// Step 4 | |||
suspend fun customerListCheck(getCodeRequest: GetCodeRequest, token: String) = | |||
apiInterface.customerListApi(getCodeRequest, token) | |||
suspend fun checkFDKYCRequest(checkFDKYCRequest: CheckFDKYCRequest, token: String) = | |||
apiInterface.checkFDKYC(checkFDKYCRequest, token) | |||
// Step 5 | |||
suspend fun finaliseFDResponse(getRatesRequest: FinalizeFDRequest, token: String) = | |||
apiInterface.finaliseFD(getRatesRequest, token) | |||
suspend fun finaliseKYCResponse(getRatesRequest: FinalizeKYCRequest, token: String) = | |||
apiInterface.finaliseKYC(getRatesRequest, token) | |||
suspend fun paymentReQueryResponse(getRatesRequest: PaymentReQueryRequest, token: String) = | |||
apiInterface.paymentReQuery(getRatesRequest, token) | |||
} |
@ -1,481 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.ui.activity | |||
import android.annotation.SuppressLint | |||
import android.app.Dialog | |||
import android.content.Intent | |||
import android.graphics.Bitmap | |||
import android.graphics.drawable.Drawable | |||
import android.os.Bundle | |||
import android.util.Log | |||
import android.view.View | |||
import android.view.WindowManager | |||
import android.webkit.WebView | |||
import android.webkit.WebViewClient | |||
import android.widget.TextView | |||
import androidx.fragment.app.Fragment | |||
import androidx.lifecycle.ViewModelProvider | |||
import androidx.viewpager.widget.ViewPager | |||
import com.google.gson.Gson | |||
import com.nivesh.production.niveshfd.R | |||
import com.nivesh.production.niveshfd.databinding.ActivityNiveshFdBinding | |||
import com.nivesh.production.niveshfd.fd.adapter.DisableAdapter | |||
import com.nivesh.production.niveshfd.fd.adapter.SectionsPagerAdapter | |||
import com.nivesh.production.niveshfd.fd.api.ApiClient | |||
import com.nivesh.production.niveshfd.fd.db.PreferenceManager | |||
import com.nivesh.production.niveshfd.fd.model.CreateFDRequest | |||
import com.nivesh.production.niveshfd.fd.model.FdBankDetails | |||
import com.nivesh.production.niveshfd.fd.model.NomineeDetails | |||
import com.nivesh.production.niveshfd.fd.model.* | |||
import com.nivesh.production.niveshfd.fd.repositories.MainRepository | |||
import com.nivesh.production.niveshfd.fd.ui.fragment.* | |||
import com.nivesh.production.niveshfd.fd.ui.providerfactory.* | |||
import com.nivesh.production.niveshfd.fd.util.Common | |||
import com.nivesh.production.niveshfd.fd.util.Common.Companion.defaultShape | |||
import com.nivesh.production.niveshfd.fd.util.Common.Companion.selectedShape | |||
import com.nivesh.production.niveshfd.fd.util.Common.Companion.showDialogValidation | |||
import com.nivesh.production.niveshfd.fd.util.ProgressUtil.hideLoading | |||
import com.nivesh.production.niveshfd.fd.util.ProgressUtil.showLoading | |||
import com.nivesh.production.niveshfd.fd.util.Resource | |||
import com.nivesh.production.niveshfd.fd.viewModel.* | |||
import com.nivesh.production.niveshfd.fd.ui.fragment.StepThreeNiveshFDFragment | |||
class NiveshFdMainActivity : BaseActivity() { | |||
lateinit var binding: ActivityNiveshFdBinding | |||
lateinit var viewModel: BajajFDViewModel | |||
private val stepOneNiveshFDFragment = StepOneNiveshFDFragment() | |||
private val stepTwoNiveshFDFragment = StepTwoNiveshFDFragment() | |||
private val stepThreeNiveshFDFragment = StepThreeNiveshFDFragment() | |||
private val stepFourBajajFDFragment = StepFourNiveshFDFragment() | |||
private val stepFiveNiveshFDFragment = StepFiveNiveshFDFragment() | |||
var createFDRequest: CreateFDRequest = CreateFDRequest() | |||
var createFDApplicantRequest: CreateFDApplicationRequest = CreateFDApplicationRequest() | |||
var applicantDetails: ApplicantDetails = ApplicantDetails() | |||
var fdInvestmentDetails: FDInvestmentDetails = FDInvestmentDetails() | |||
var applicantRelationDetails: ApplicantRelationDetails = ApplicantRelationDetails() | |||
var fdBankDetails: FdBankDetails = FdBankDetails() | |||
var nomineeDetails: NomineeDetails = NomineeDetails() | |||
var nomineeGuardianDetails: NomineeGuardianDetails = NomineeGuardianDetails() | |||
var getClientDetailsResponse: getClientDetailsResponse = getClientDetailsResponse() | |||
private lateinit var sectionsPagerAdapter: SectionsPagerAdapter | |||
private lateinit var fragments: Array<Fragment> | |||
var dialogWebView: Dialog? = null | |||
var stepCount: Int = 0 | |||
var uniqueId: String = "" | |||
override fun onCreate(savedInstanceState: Bundle?) { | |||
super.onCreate(savedInstanceState) | |||
init() | |||
} | |||
private fun init() { | |||
//start Repository | |||
viewModel = ViewModelProvider( | |||
this@NiveshFdMainActivity, | |||
FDModelProviderFactory(MainRepository(ApiClient.getApiClient)) | |||
)[BajajFDViewModel::class.java] | |||
binding = ActivityNiveshFdBinding.inflate(layoutInflater) | |||
binding.apply { | |||
setContentView(this.root) | |||
} | |||
PreferenceManager(this@NiveshFdMainActivity).setLoginRole(5) | |||
PreferenceManager(this@NiveshFdMainActivity).setClientCode("8872") | |||
PreferenceManager(this@NiveshFdMainActivity).setSubBrokerID("1038") | |||
PreferenceManager(this@NiveshFdMainActivity).setToken("636F8F63-06C4-4D95-8562-392B34025FB0") | |||
if (Common.isNetworkAvailable(this)) { | |||
getStepsCountApi() | |||
} | |||
binding.imgBack.setOnClickListener { | |||
finish() | |||
} | |||
} | |||
private fun getStepsCountApi() { | |||
if (Common.isNetworkAvailable(this)) { | |||
val fdStepsCount = FDStepsCountRequest() | |||
fdStepsCount.FDProvider = getString(R.string.bajaj) | |||
fdStepsCount.NiveshClientCode = | |||
PreferenceManager(this@NiveshFdMainActivity).getClientCode() | |||
viewModel.getStepsCount( | |||
fdStepsCount, | |||
PreferenceManager(this@NiveshFdMainActivity).getToken(), | |||
this | |||
) | |||
viewModel.getStepsCountMutableData.observe(this) { response -> | |||
when (response) { | |||
is Resource.Success -> { | |||
Log.e("response", "-->${response.data.toString()}") | |||
val stepsCountResponse: StepsCountResponse = | |||
Gson().fromJson( | |||
response.data?.toString(), | |||
StepsCountResponse::class.java | |||
) | |||
stepsCountResponse.Response.StatusCode.let { code -> | |||
when (code) { | |||
200 -> { | |||
stepCount = stepsCountResponse.Response.StepsCount | |||
if (stepCount == 3) { | |||
binding.llStep4.visibility = View.GONE | |||
} | |||
getClientDetailsApi(stepsCountResponse.Response.StepsCount) | |||
} | |||
650 -> "" | |||
else -> { | |||
if (stepsCountResponse.Response.Errors.isNotEmpty()) { | |||
showDialogValidation( | |||
this@NiveshFdMainActivity, | |||
stepsCountResponse.Response.Errors[0].ErrorMessage | |||
) | |||
}else{ | |||
showDialogValidation( | |||
this@NiveshFdMainActivity, | |||
"".plus(stepsCountResponse.Response.Message) | |||
) | |||
} | |||
} | |||
} | |||
} | |||
} | |||
is Resource.Error -> { | |||
response.message?.let { message -> | |||
showDialogValidation(this@NiveshFdMainActivity, message) | |||
} | |||
} | |||
is Resource.Loading -> { | |||
} | |||
is Resource.DataError -> { | |||
} | |||
else -> { | |||
showDialogValidation(this@NiveshFdMainActivity, response.message) | |||
} | |||
} | |||
} | |||
} | |||
} | |||
private fun getClientDetailsApi(stepsCount: Int) { | |||
if (Common.isNetworkAvailable(this@NiveshFdMainActivity)) { | |||
val getClientDetailsRequest = getClientDetailsRequest() | |||
getClientDetailsRequest.client_code = | |||
PreferenceManager(this@NiveshFdMainActivity).getClientCode() | |||
getClientDetailsRequest.AppOrWeb = getString(R.string.app) | |||
getClientDetailsRequest.sub_broker_code = | |||
PreferenceManager(this@NiveshFdMainActivity).getSubBrokerID() | |||
val userRequest = UserRequest() | |||
userRequest.UID = 0 | |||
userRequest.IPAddress = "" | |||
userRequest.Source = getString(R.string.source) | |||
userRequest.AppOrWeb = getString(R.string.app) | |||
userRequest.LoggedInRoleId = PreferenceManager(this@NiveshFdMainActivity).getLoginRole() | |||
val deviceInfo = DeviceInfo() | |||
deviceInfo.device_id = "" | |||
deviceInfo.device_id_for_UMSId = "" | |||
deviceInfo.device_type = getString(R.string.app) | |||
deviceInfo.device_model = "" | |||
deviceInfo.device_token = "" | |||
deviceInfo.device_name = "" | |||
deviceInfo.app_version = "" | |||
deviceInfo.device_os_version = "" | |||
userRequest.deviceInfo = deviceInfo | |||
getClientDetailsRequest.UserRequest = userRequest | |||
Log.e("getClientDetail ", " Request -->" + Gson().toJson(getClientDetailsRequest)) | |||
showLoading(this@NiveshFdMainActivity) | |||
viewModel.getClientDetails( | |||
getClientDetailsRequest, | |||
PreferenceManager(this@NiveshFdMainActivity).getToken(), | |||
this | |||
) | |||
viewModel.getClientDetailsMutableData.observe(this) { response -> | |||
when (response) { | |||
is Resource.Success -> { | |||
Log.e("getClientDetail ", " response -->${response.data.toString()}") | |||
getClientDetailsResponse = | |||
Gson().fromJson( | |||
response.data?.toString(), | |||
getClientDetailsResponse::class.java | |||
) | |||
getClientDetailsResponse.response?.status_code.let { code -> | |||
when (code) { | |||
200 -> { | |||
setViewPager(stepsCount) | |||
} | |||
650 -> "" | |||
else -> { | |||
showDialogValidation( | |||
this@NiveshFdMainActivity, | |||
response.message | |||
) | |||
} | |||
} | |||
} | |||
} | |||
is Resource.Error -> { | |||
response.message?.let { message -> | |||
showDialogValidation(this@NiveshFdMainActivity, message) | |||
} | |||
} | |||
is Resource.Loading -> { | |||
hideLoading() | |||
} | |||
is Resource.DataError -> { | |||
} | |||
else -> { | |||
showDialogValidation(this@NiveshFdMainActivity, response.message) | |||
} | |||
} | |||
} | |||
} | |||
} | |||
private fun setViewPager(stepsCount: Int) { | |||
// steps setting | |||
setBackground(selectedShape(), defaultShape(), defaultShape(), defaultShape(), stepsCount) | |||
if (stepCount == 3) { | |||
fragments = arrayOf( | |||
stepOneNiveshFDFragment, | |||
stepTwoNiveshFDFragment, | |||
stepFourBajajFDFragment, | |||
stepFiveNiveshFDFragment | |||
) | |||
} else if (stepCount == 4) { | |||
fragments = arrayOf( | |||
stepOneNiveshFDFragment, | |||
stepTwoNiveshFDFragment, | |||
stepThreeNiveshFDFragment, | |||
stepFourBajajFDFragment, | |||
stepFiveNiveshFDFragment | |||
) | |||
} | |||
// set viewPager | |||
sectionsPagerAdapter = SectionsPagerAdapter(supportFragmentManager, fragments) | |||
val viewPager: DisableAdapter = binding.viewPager | |||
viewPager.adapter = sectionsPagerAdapter | |||
viewPager.setPagingEnabled(false) | |||
// if (sectionsPagerAdapter.count > 1) { | |||
viewPager.offscreenPageLimit = stepCount | |||
// } else { | |||
// viewPager.offscreenPageLimit = 1 | |||
// } | |||
viewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { | |||
override fun onPageScrolled( | |||
position: Int, | |||
positionOffset: Float, | |||
positionOffsetPixels: Int | |||
) { | |||
} | |||
override fun onPageSelected(position: Int) { | |||
when (position) { | |||
0 -> { | |||
setBackground( | |||
defaultShape(), | |||
defaultShape(), | |||
defaultShape(), | |||
defaultShape(), | |||
stepsCount | |||
) | |||
} | |||
1 -> { | |||
setBackground( | |||
selectedShape(), | |||
defaultShape(), | |||
defaultShape(), | |||
defaultShape(), | |||
stepsCount | |||
) | |||
} | |||
2 -> { | |||
setBackground( | |||
selectedShape(), | |||
selectedShape(), | |||
defaultShape(), | |||
defaultShape(), | |||
stepsCount | |||
) | |||
} | |||
3 -> { | |||
setBackground( | |||
selectedShape(), | |||
selectedShape(), | |||
selectedShape(), | |||
defaultShape(), | |||
stepsCount | |||
) | |||
} | |||
4 -> { | |||
setBackground( | |||
selectedShape(), | |||
selectedShape(), | |||
selectedShape(), | |||
selectedShape(), | |||
stepsCount | |||
) | |||
} | |||
} | |||
} | |||
override fun onPageScrollStateChanged(state: Int) { | |||
} | |||
}) | |||
} | |||
// set background for selected/ default step | |||
private fun setBackground( | |||
drawable: Drawable?, | |||
drawable1: Drawable?, | |||
drawable2: Drawable?, | |||
drawable3: Drawable?, | |||
stepsCount: Int | |||
) { | |||
binding.stepOne.background = drawable | |||
binding.stepTwo.background = drawable1 | |||
binding.stepThree.background = drawable2 | |||
if (stepsCount == 4) { | |||
binding.stepFour.background = drawable3 | |||
} | |||
} | |||
// step 1 response | |||
fun stepOneApi() { | |||
binding.viewPager.currentItem = 1 | |||
} | |||
// step 2 response | |||
fun stepTwoApi() { | |||
binding.viewPager.currentItem = 2 | |||
if (stepCount == 3) { | |||
stepFourBajajFDFragment.displayReceivedData() | |||
} | |||
} | |||
// step 3 response | |||
fun stepThreeApi() { | |||
binding.viewPager.currentItem = 3 | |||
stepFourBajajFDFragment.displayReceivedData() | |||
} | |||
// step 4 response | |||
fun stepFourApi(payUrl: String, value: String) { | |||
paymentDialog(payUrl, value) | |||
} | |||
@SuppressLint("SetJavaScriptEnabled") | |||
fun paymentDialog(payUrl: String, value: String) { | |||
Log.e("payUrl", "-->$payUrl") | |||
Log.e("value", "-->$value") | |||
dialogWebView = Dialog(this@NiveshFdMainActivity) | |||
dialogWebView!!.setContentView(R.layout.row_fd_pay1) | |||
dialogWebView!!.setCancelable(true) | |||
val tvCancel = dialogWebView!!.findViewById<TextView>(R.id.tvCancel) | |||
tvCancel.setOnClickListener { | |||
dialogWebView!!.dismiss() | |||
} | |||
val lp = WindowManager.LayoutParams() | |||
lp.copyFrom(dialogWebView!!.window?.attributes) | |||
lp.width = WindowManager.LayoutParams.MATCH_PARENT | |||
lp.height = WindowManager.LayoutParams.MATCH_PARENT | |||
dialogWebView!!.window?.attributes = lp | |||
val wVPay = dialogWebView!!.findViewById<WebView>(R.id.wVPay) | |||
wVPay.settings.javaScriptEnabled = true | |||
wVPay.settings.domStorageEnabled = true | |||
wVPay.loadData( | |||
"<form name=\"frm\" action=\"$payUrl\" method=\"post\"> \n" + " <input type=\"hidden\" name=\"msg\" value=\"$value\"> \n" + " </form> \n" + | |||
"<script type=\"text/javascript\"> \n" + "document.forms[\"frm\"].submit(); \n" + "</script>", | |||
"text/html", | |||
"UTF-8" | |||
) | |||
wVPay.webViewClient = object : WebViewClient() { | |||
override fun onPageStarted(view: WebView, url: String, favicon: Bitmap?) { | |||
super.onPageStarted(view, url, favicon) | |||
Log.e("onPageStarted", "-->$url") | |||
if (url.isNotEmpty() && url.contains("https://uat.nivesh.com/bajajFD/OrderStatus")) { | |||
if (dialogWebView!!.isShowing) { | |||
dialogWebView!!.dismiss() | |||
paymentReQueryApi() | |||
} | |||
} | |||
} | |||
} | |||
dialogWebView!!.show() | |||
} | |||
fun paymentReQueryApi() { | |||
if (Common.isNetworkAvailable(this)) { | |||
val paymentReQueryRequest = PaymentReQueryRequest() | |||
paymentReQueryRequest.UniqueId = uniqueId | |||
paymentReQueryRequest.NiveshClientCode = | |||
getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_CODE | |||
showLoading(this@NiveshFdMainActivity) | |||
viewModel.getPaymentReQuery( | |||
paymentReQueryRequest, | |||
PreferenceManager(this@NiveshFdMainActivity).getToken(), | |||
this | |||
) | |||
viewModel.getPaymentReQueryMutableData.observe(this) { response -> | |||
when (response) { | |||
is Resource.Success -> { | |||
Log.e("paymentReQueryApi ", "response -->$response") | |||
val paymentReQueryResponse: PaymentReQueryResponse = | |||
Gson().fromJson( | |||
response.data?.toString(), | |||
PaymentReQueryResponse::class.java | |||
) | |||
paymentReQueryResponse.Response.StatusCode.let { code -> | |||
when (code) { | |||
650 -> "" | |||
else -> { | |||
if (stepCount == 4) { | |||
binding.viewPager.currentItem = 4 | |||
} else { | |||
binding.viewPager.currentItem = 3 | |||
} | |||
stepFiveNiveshFDFragment.getData(paymentReQueryResponse) | |||
} | |||
} | |||
} | |||
} | |||
is Resource.Error -> { | |||
response.message?.let { message -> | |||
showDialogValidation(this@NiveshFdMainActivity, message) | |||
} | |||
} | |||
is Resource.Loading -> { | |||
hideLoading() | |||
} | |||
is Resource.DataError -> { | |||
} | |||
else -> { | |||
showDialogValidation(this@NiveshFdMainActivity, response.message) | |||
} | |||
} | |||
} | |||
} | |||
} | |||
fun retryMethod() { | |||
val intent: Intent = intent | |||
finish() | |||
startActivity(intent) | |||
} | |||
} |
@ -1,187 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.ui.activity | |||
import android.app.Dialog | |||
import android.graphics.Bitmap | |||
import android.os.Bundle | |||
import android.util.Log | |||
import android.view.View | |||
import android.view.WindowManager | |||
import android.webkit.WebView | |||
import android.webkit.WebViewClient | |||
import android.widget.TextView | |||
import androidx.core.content.ContextCompat | |||
import androidx.lifecycle.ViewModelProvider | |||
import com.google.gson.Gson | |||
import com.nivesh.production.niveshfd.R | |||
import com.nivesh.production.niveshfd.databinding.FragmentNiveshfdStepFiveBinding | |||
import com.nivesh.production.niveshfd.fd.api.ApiClient | |||
import com.nivesh.production.niveshfd.fd.db.PreferenceManager | |||
import com.nivesh.production.niveshfd.fd.model.PaymentReQueryRequest | |||
import com.nivesh.production.niveshfd.fd.model.PaymentReQueryResponse | |||
import com.nivesh.production.niveshfd.fd.repositories.MainRepository | |||
import com.nivesh.production.niveshfd.fd.ui.providerfactory.FDModelProviderFactory | |||
import com.nivesh.production.niveshfd.fd.util.Common | |||
import com.nivesh.production.niveshfd.fd.util.Constants | |||
import com.nivesh.production.niveshfd.fd.util.ProgressUtil | |||
import com.nivesh.production.niveshfd.fd.util.Resource | |||
import com.nivesh.production.niveshfd.fd.viewModel.BajajFDViewModel | |||
class PaymentActivity : BaseActivity() { | |||
private lateinit var binding: FragmentNiveshfdStepFiveBinding | |||
var dialogWebView: Dialog? = null | |||
lateinit var viewModel: BajajFDViewModel | |||
private var clientCode : String = "" | |||
var uniqueId : String = "" | |||
override fun onCreate(savedInstanceState: Bundle?) { | |||
super.onCreate(savedInstanceState) | |||
viewModel = ViewModelProvider( | |||
this@PaymentActivity, | |||
FDModelProviderFactory(MainRepository(ApiClient.getApiClient)) | |||
)[BajajFDViewModel::class.java] | |||
binding = FragmentNiveshfdStepFiveBinding.inflate(layoutInflater) | |||
binding.btnViewOrder.setOnClickListener { | |||
(this@PaymentActivity).setResult(RESULT_OK) | |||
(this@PaymentActivity).finish() | |||
} | |||
binding.tvRetry.setOnClickListener { | |||
(this@PaymentActivity).setResult(RESULT_OK) | |||
(this@PaymentActivity).finish() | |||
} | |||
if (intent != null){ | |||
clientCode = intent.getStringExtra("clientCode").toString() | |||
paymentDialog(intent.getStringExtra("url").toString(), intent.getStringExtra("value").toString()) | |||
} | |||
} | |||
private fun paymentDialog(payUrl: String, value: String) { | |||
Log.e("payUrl", "-->$payUrl") | |||
Log.e("value", "-->$value") | |||
dialogWebView = Dialog(this@PaymentActivity) | |||
dialogWebView!!.setContentView(R.layout.row_fd_pay1) | |||
dialogWebView!!.setCancelable(true) | |||
val tvCancel = dialogWebView!!.findViewById<TextView>(R.id.tvCancel) | |||
tvCancel.setOnClickListener { | |||
dialogWebView!!.dismiss() | |||
(this@PaymentActivity).setResult(RESULT_OK) | |||
(this@PaymentActivity).finish() | |||
} | |||
val lp = WindowManager.LayoutParams() | |||
lp.copyFrom(dialogWebView!!.window?.attributes) | |||
lp.width = WindowManager.LayoutParams.MATCH_PARENT | |||
lp.height = WindowManager.LayoutParams.MATCH_PARENT | |||
dialogWebView!!.window?.attributes = lp | |||
val wVPay = dialogWebView!!.findViewById<WebView>(R.id.wVPay) | |||
wVPay.settings.javaScriptEnabled = true | |||
wVPay.settings.domStorageEnabled = true | |||
wVPay.loadData( | |||
"<form name=\"frm\" action=\"$payUrl\" method=\"post\"> \n" + " <input type=\"hidden\" name=\"msg\" value=\"$value\"> \n" + " </form> \n" + | |||
"<script type=\"text/javascript\"> \n" + "document.forms[\"frm\"].submit(); \n" + "</script>", | |||
"text/html", | |||
"UTF-8" | |||
) | |||
wVPay.webViewClient = object : WebViewClient() { | |||
override fun onPageStarted(view: WebView, url: String, favicon: Bitmap?) { | |||
super.onPageStarted(view, url, favicon) | |||
Log.e("onPageStarted", "-->$url") | |||
if (url.isNotEmpty() && url.contains(Constants.paymentUrl)) { | |||
if (dialogWebView!!.isShowing) { | |||
dialogWebView!!.dismiss() | |||
paymentReQueryApi() | |||
} | |||
} | |||
} | |||
} | |||
dialogWebView!!.show() | |||
} | |||
fun paymentReQueryApi() { | |||
if (Common.isNetworkAvailable(this)) { | |||
val paymentReQueryRequest = PaymentReQueryRequest() | |||
paymentReQueryRequest.UniqueId = uniqueId | |||
paymentReQueryRequest.NiveshClientCode = clientCode | |||
ProgressUtil.showLoading(this@PaymentActivity) | |||
viewModel.getPaymentReQuery( | |||
paymentReQueryRequest, | |||
PreferenceManager(this@PaymentActivity).getToken(), | |||
this | |||
) | |||
viewModel.getPaymentReQueryMutableData.observe(this) { response -> | |||
when (response) { | |||
is Resource.Success -> { | |||
Log.e("paymentReQueryApi ", "response -->$response") | |||
val paymentReQueryResponse: PaymentReQueryResponse = | |||
Gson().fromJson( | |||
response.data?.toString(), | |||
PaymentReQueryResponse::class.java | |||
) | |||
paymentReQueryResponse.Response.StatusCode.let { code -> | |||
when (code) { | |||
650 -> "" | |||
else -> { | |||
getData(paymentReQueryResponse) | |||
} | |||
} | |||
} | |||
} | |||
is Resource.Error -> { | |||
response.message?.let { message -> | |||
Common.showDialogValidation(this@PaymentActivity, message) | |||
} | |||
} | |||
is Resource.Loading -> { | |||
ProgressUtil.hideLoading() | |||
} | |||
is Resource.DataError -> { | |||
} | |||
else -> { | |||
Common.showDialogValidation(this@PaymentActivity, response.message) | |||
} | |||
} | |||
} | |||
} | |||
} | |||
private fun getData(paymentReQueryResponse: PaymentReQueryResponse) { | |||
if (paymentReQueryResponse.Response.StatusCode == 200) { | |||
if (paymentReQueryResponse.Response.Message.isNotEmpty()) { | |||
val arrOfStr: List<String> = | |||
paymentReQueryResponse.Response.Message.split(" ", limit = 2) | |||
binding.tvCongrats.text = arrOfStr[0] | |||
binding.tvCongrats.setTextColor( | |||
ContextCompat.getColor( | |||
this@PaymentActivity, | |||
R.color.green | |||
) | |||
) | |||
binding.tvSuccessMessage.text = arrOfStr[1] | |||
} | |||
} else { | |||
if (paymentReQueryResponse.Response.Message.isNotEmpty()) { | |||
if (paymentReQueryResponse.Response.Message.isNotEmpty()) { | |||
binding.tvCongrats.text = paymentReQueryResponse.Response.Status | |||
binding.tvCongrats.setTextColor( | |||
ContextCompat.getColor( | |||
this@PaymentActivity, | |||
R.color.red | |||
) | |||
) | |||
binding.tvSuccessMessage.text = paymentReQueryResponse.Response.Message | |||
} | |||
} | |||
binding.tvRetry.visibility = View.VISIBLE | |||
binding.btnViewOrder.visibility = View.GONE | |||
} | |||
} | |||
} |
@ -1,208 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.ui.fragment | |||
import android.app.Activity | |||
import android.os.Bundle | |||
import android.util.Log | |||
import android.view.LayoutInflater | |||
import android.view.View | |||
import android.view.ViewGroup | |||
import androidx.core.content.ContextCompat | |||
import androidx.fragment.app.Fragment | |||
import com.google.gson.Gson | |||
import com.nivesh.production.niveshfd.R | |||
import com.nivesh.production.niveshfd.databinding.FragmentNiveshfdStepFiveBinding | |||
import com.nivesh.production.niveshfd.fd.db.PreferenceManager | |||
import com.nivesh.production.niveshfd.fd.model.* | |||
import com.nivesh.production.niveshfd.fd.ui.activity.NiveshFdMainActivity | |||
import com.nivesh.production.niveshfd.fd.util.Common | |||
import com.nivesh.production.niveshfd.fd.util.Resource | |||
class StepFiveNiveshFDFragment : Fragment() { | |||
private var _binding: FragmentNiveshfdStepFiveBinding? = null | |||
private val binding get() = _binding!! | |||
override fun onCreateView( | |||
inflater: LayoutInflater, container: ViewGroup?, | |||
savedInstanceState: Bundle? | |||
): View { | |||
_binding = FragmentNiveshfdStepFiveBinding.inflate(inflater, container, false) | |||
return binding.root | |||
} | |||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |||
super.onViewCreated(view, savedInstanceState) | |||
binding.btnViewOrder.setOnClickListener { | |||
(activity as NiveshFdMainActivity).setResult(Activity.RESULT_OK) | |||
(activity as NiveshFdMainActivity).finish() | |||
} | |||
binding.tvRetry.setOnClickListener { | |||
(activity as NiveshFdMainActivity).retryMethod() | |||
} | |||
} | |||
fun getData(paymentReQueryResponse: PaymentReQueryResponse) { | |||
if (paymentReQueryResponse.Response.StatusCode == 200) { | |||
if (paymentReQueryResponse.Response.Message.isNotEmpty()) { | |||
val arrOfStr: List<String> = | |||
paymentReQueryResponse.Response.Message.split(" ", limit = 2) | |||
binding.tvCongrats.text = arrOfStr[0] | |||
binding.tvCongrats.setTextColor( | |||
ContextCompat.getColor( | |||
activity as NiveshFdMainActivity, | |||
R.color.green | |||
) | |||
) | |||
binding.tvSuccessMessage.text = arrOfStr[1] | |||
} | |||
finalizeFDApi() | |||
} else { | |||
if (paymentReQueryResponse.Response.Message.isNotEmpty()) { | |||
if (paymentReQueryResponse.Response.Message.isNotEmpty()) { | |||
binding.tvCongrats.text = paymentReQueryResponse.Response.Status | |||
binding.tvCongrats.setTextColor( | |||
ContextCompat.getColor( | |||
activity as NiveshFdMainActivity, | |||
R.color.red | |||
) | |||
) | |||
binding.tvSuccessMessage.text = paymentReQueryResponse.Response.Message | |||
} | |||
} | |||
binding.tvRetry.visibility = View.VISIBLE | |||
binding.btnViewOrder.visibility = View.GONE | |||
} | |||
} | |||
private fun finalizeFDApi() { | |||
val finalizeFDRequest = FinalizeFDRequest() | |||
val finaliseFD = FinaliseFD() | |||
finaliseFD.FDProvider = getString(R.string.bajaj) | |||
finaliseFD.NiveshClientCode = | |||
(activity as NiveshFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_CODE | |||
finaliseFD.UniqueId = (activity as NiveshFdMainActivity).uniqueId | |||
finalizeFDRequest.FinaliseFD = finaliseFD | |||
(activity as NiveshFdMainActivity).viewModel.finaliseFD( | |||
finalizeFDRequest, | |||
PreferenceManager(activity as NiveshFdMainActivity).getToken(), | |||
activity as NiveshFdMainActivity | |||
) | |||
(activity as NiveshFdMainActivity).viewModel.getFinalizeFDMutableData.observe( | |||
viewLifecycleOwner | |||
) { response -> | |||
when (response) { | |||
is Resource.Success -> { | |||
Log.e("finalizeKYC ", " response-->${response.data.toString()}") | |||
val finalizeFDResponse: FinalizeFDResponse = | |||
Gson().fromJson(response.data?.toString(), FinalizeFDResponse::class.java) | |||
finalizeFDResponse.Response.StatusCode.let { code -> | |||
when (code) { | |||
200 -> { | |||
if ( finalizeFDResponse.Response.KYCFlag == 0){ | |||
finalizeKYCApi() | |||
} else { | |||
} | |||
} | |||
650 -> "" | |||
else -> { | |||
if (finalizeFDResponse.Response.Errors.isNotEmpty()) { | |||
Common.showDialogValidation( | |||
activity as NiveshFdMainActivity, | |||
finalizeFDResponse.Response.Errors[0].ErrorMessage | |||
) | |||
}else{ | |||
Common.showDialogValidation( | |||
activity as NiveshFdMainActivity, | |||
"".plus(finalizeFDResponse.Response.Message) | |||
) | |||
} | |||
} | |||
} | |||
} | |||
} | |||
is Resource.Error -> { | |||
response.message?.let { message -> | |||
Common.showDialogValidation(activity as NiveshFdMainActivity, message) | |||
} | |||
} | |||
is Resource.Loading -> { | |||
} | |||
is Resource.DataError -> { | |||
} | |||
} | |||
} | |||
} | |||
private fun finalizeKYCApi() { | |||
val finalizeKYCRequest = FinalizeKYCRequest() | |||
finalizeKYCRequest.FDProvider = getString(R.string.bajaj) | |||
finalizeKYCRequest.NiveshClientCode = | |||
(activity as NiveshFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_CODE | |||
finalizeKYCRequest.UniqueId = (activity as NiveshFdMainActivity).uniqueId | |||
(activity as NiveshFdMainActivity).viewModel.finaliseKYC( | |||
finalizeKYCRequest, | |||
PreferenceManager(activity as NiveshFdMainActivity).getToken(), | |||
activity as NiveshFdMainActivity | |||
) | |||
(activity as NiveshFdMainActivity).viewModel.getFinalizeKYCMutableData.observe( | |||
viewLifecycleOwner | |||
) { response -> | |||
when (response) { | |||
is Resource.Success -> { | |||
Log.e("finalizeKYC ", " response-->${response.data.toString()}") | |||
val finalizeFDResponse: FinalizeFDResponse = | |||
Gson().fromJson(response.data?.toString(), FinalizeFDResponse::class.java) | |||
finalizeFDResponse.Response.StatusCode.let { code -> | |||
when (code) { | |||
200 -> { | |||
} | |||
650 -> "" | |||
else -> { | |||
if (finalizeFDResponse.Response.Errors.isNotEmpty()) { | |||
Common.showDialogValidation( | |||
activity as NiveshFdMainActivity, | |||
finalizeFDResponse.Response.Errors[0].ErrorMessage | |||
) | |||
}else{ | |||
Common.showDialogValidation( | |||
activity as NiveshFdMainActivity, | |||
"".plus(finalizeFDResponse.Response.Message) | |||
) | |||
} | |||
} | |||
} | |||
} | |||
} | |||
is Resource.Error -> { | |||
response.message?.let { message -> | |||
Common.showDialogValidation(activity as NiveshFdMainActivity, message) | |||
} | |||
} | |||
is Resource.Loading -> { | |||
} | |||
is Resource.DataError -> { | |||
} | |||
} | |||
} | |||
} | |||
override fun onDestroyView() { | |||
super.onDestroyView() | |||
_binding = null | |||
} | |||
} |
@ -1,329 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.ui.fragment | |||
import android.os.Bundle | |||
import android.util.Log | |||
import android.view.LayoutInflater | |||
import android.view.View | |||
import android.view.ViewGroup | |||
import androidx.core.content.res.ResourcesCompat | |||
import androidx.fragment.app.Fragment | |||
import androidx.recyclerview.widget.LinearLayoutManager | |||
import com.google.gson.Gson | |||
import com.nivesh.production.niveshfd.R | |||
import com.nivesh.production.niveshfd.databinding.FragmentNiveshfdStepFourBinding | |||
import com.nivesh.production.niveshfd.fd.adapter.CustomerListAdapter | |||
import com.nivesh.production.niveshfd.fd.db.PreferenceManager | |||
import com.nivesh.production.niveshfd.fd.model.* | |||
import com.nivesh.production.niveshfd.fd.ui.activity.NiveshFdMainActivity | |||
import com.nivesh.production.niveshfd.fd.util.Common | |||
import com.nivesh.production.niveshfd.fd.util.Common.Companion.showDialogValidation | |||
import com.nivesh.production.niveshfd.fd.util.Resource | |||
class StepFourNiveshFDFragment : Fragment() { | |||
private var _binding: FragmentNiveshfdStepFourBinding? = null | |||
private val binding get() = _binding!! | |||
private lateinit var listOfCustomer: MutableList<GetCodes> | |||
private var selectedList: String = "" | |||
private var payUrl: String = "" | |||
private var value: String = "" | |||
private var checkNRI: Boolean = false | |||
override fun onCreateView( | |||
inflater: LayoutInflater, container: ViewGroup?, | |||
savedInstanceState: Bundle? | |||
): View { | |||
_binding = FragmentNiveshfdStepFourBinding.inflate(inflater, container, false) | |||
return binding.root | |||
} | |||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |||
super.onViewCreated(view, savedInstanceState) | |||
if (PreferenceManager(activity as NiveshFdMainActivity).getLoginRole() == 5) { | |||
binding.btnNext.text = getString(R.string.pay) | |||
binding.btnNext.setBackgroundColor( | |||
ResourcesCompat.getColor( | |||
resources, | |||
R.color.green, | |||
null | |||
) | |||
) | |||
} else { | |||
binding.btnNext.text = getString(R.string.viewOrder) | |||
binding.btnNext.setBackgroundColor( | |||
ResourcesCompat.getColor( | |||
resources, | |||
R.color.red, | |||
null | |||
) | |||
) | |||
} | |||
checkNRI = true | |||
binding.btnNext.setOnClickListener { | |||
selectedList = "" | |||
for (getCodes in listOfCustomer) { | |||
if (getCodes.isSelected) { | |||
selectedList = if (selectedList.isEmpty()) { | |||
getCodes.Value | |||
} else { | |||
if (getCodes.Value.contains("outside of india", true)) { | |||
checkNRI = getCodes.isSelected | |||
} | |||
selectedList.plus(",").plus(getCodes.Value) | |||
} | |||
} | |||
} | |||
if (validated()) { | |||
if (PreferenceManager(activity as NiveshFdMainActivity).getLoginRole() == 5) { | |||
val saveFDOtherDataRequest = SaveFDOtherDataRequest() | |||
saveFDOtherDataRequest.FDProvider = getString(R.string.bajaj) | |||
saveFDOtherDataRequest.UniqueId = (activity as NiveshFdMainActivity).uniqueId | |||
saveFDOtherDataRequest.Values = selectedList | |||
saveFDOtherDataRequest.NiveshClientCode = | |||
(activity as NiveshFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_CODE | |||
saveFDOtherData(saveFDOtherDataRequest, payUrl, value) | |||
} else { | |||
// go to view order | |||
} | |||
} | |||
} | |||
binding.btnBack.setOnClickListener { | |||
if ((activity as NiveshFdMainActivity).stepCount == 4) { | |||
(activity as NiveshFdMainActivity).binding.viewPager.currentItem = 2 | |||
} else { | |||
(activity as NiveshFdMainActivity).binding.viewPager.currentItem = 1 | |||
} | |||
} | |||
customerListApi() | |||
} | |||
private fun customerListApi() { | |||
val getCodeRequest = GetCodeRequest() | |||
getCodeRequest.ProductName = getString(R.string.bajajFD) | |||
getCodeRequest.Category = getString(R.string.customerCategory) | |||
getCodeRequest.Language = getString(R.string.language) | |||
getCodeRequest.InputValue = "" | |||
(activity as NiveshFdMainActivity).viewModel.customerListApi( | |||
getCodeRequest, | |||
PreferenceManager(activity as NiveshFdMainActivity).getToken(), | |||
activity as NiveshFdMainActivity | |||
) | |||
(activity as NiveshFdMainActivity).viewModel.customerListMutableData.observe( | |||
viewLifecycleOwner | |||
) { response -> | |||
when (response) { | |||
is Resource.Success -> { | |||
Log.e("customerListApi", " response -->${response.data.toString()}") | |||
val getCodeResponse: GetCodeResponse = | |||
Gson().fromJson(response.data?.toString(), GetCodeResponse::class.java) | |||
getCodeResponse.Response.StatusCode.let { code -> | |||
when (code) { | |||
200 -> { | |||
if (getCodeResponse.Response.GetCodesList.isNotEmpty()) { | |||
listOfCustomer = getCodeResponse.Response.GetCodesList | |||
setUpRecyclerView(listOfCustomer) | |||
} | |||
} | |||
// 650 -> refreshToken() | |||
else -> { | |||
if (getCodeResponse.Response.Errors.isNotEmpty()) { | |||
showDialogValidation( | |||
activity as NiveshFdMainActivity, | |||
getCodeResponse.Response.Errors[0].ErrorMessage | |||
) | |||
} else { | |||
showDialogValidation( | |||
activity as NiveshFdMainActivity, | |||
"".plus(getCodeResponse.Response.Message) | |||
) | |||
} | |||
} | |||
} | |||
} | |||
} | |||
is Resource.Error -> { | |||
response.message?.let { message -> | |||
showDialogValidation(activity as NiveshFdMainActivity, message) | |||
} | |||
} | |||
is Resource.Loading -> { | |||
} | |||
is Resource.DataError -> { | |||
} | |||
} | |||
} | |||
} | |||
private fun validated(): Boolean { | |||
return if (!checkNRI) { | |||
showDialogValidation( | |||
activity as NiveshFdMainActivity, | |||
getString(R.string.validNRI) | |||
) | |||
false | |||
} else if (!binding.checkBox.isChecked) { | |||
showDialogValidation( | |||
activity as NiveshFdMainActivity, | |||
resources.getString(R.string.validTermsConditions) | |||
) | |||
false | |||
} else { | |||
true | |||
} | |||
} | |||
private fun saveFDOtherData(data: SaveFDOtherDataRequest, payUrl: String, value: String) { | |||
// ProgressUtil.showLoading(activity as NiveshFdMainActivity) | |||
(activity as NiveshFdMainActivity).viewModel.saveFDOtherData( | |||
data, | |||
PreferenceManager(activity as NiveshFdMainActivity).getToken(), | |||
activity as NiveshFdMainActivity | |||
) | |||
(activity as NiveshFdMainActivity).viewModel.getFDOtherMutableData.observe( | |||
viewLifecycleOwner | |||
) { response -> | |||
when (response) { | |||
is Resource.Success -> { | |||
Log.e("saveFDOtherData", " response -->${response.data.toString()}") | |||
val saveFDOtherDataResponse: SaveFDOtherDataResponse = | |||
Gson().fromJson( | |||
response.data?.toString(), | |||
SaveFDOtherDataResponse::class.java | |||
) | |||
saveFDOtherDataResponse.Response.StatusCode.let { code -> | |||
when (code) { | |||
200 -> { | |||
(activity as NiveshFdMainActivity).stepFourApi(payUrl, value) | |||
} | |||
// 650 -> refreshToken() | |||
else -> { | |||
if (saveFDOtherDataResponse.Response.Errors.isNotEmpty()) { | |||
showDialogValidation( | |||
activity as NiveshFdMainActivity, | |||
saveFDOtherDataResponse.Response.Errors[0].ErrorMessage | |||
) | |||
} else { | |||
showDialogValidation( | |||
activity as NiveshFdMainActivity, | |||
"".plus(saveFDOtherDataResponse.Response.Message) | |||
) | |||
} | |||
} | |||
} | |||
} | |||
} | |||
is Resource.Error -> { | |||
response.message?.let { message -> | |||
showDialogValidation(activity as NiveshFdMainActivity, message) | |||
} | |||
} | |||
is Resource.Loading -> { | |||
// ProgressUtil.hideLoading() | |||
} | |||
is Resource.DataError -> { | |||
} | |||
} | |||
} | |||
} | |||
private fun setUpRecyclerView(getCustomerList: MutableList<GetCodes>) { | |||
binding.rvTerms.layoutManager = | |||
LinearLayoutManager(activity as NiveshFdMainActivity) | |||
val customerListAdapter = CustomerListAdapter(getCustomerList) | |||
binding.rvTerms.adapter = customerListAdapter | |||
} | |||
fun displayReceivedData() { | |||
getFDDetailsApi() | |||
} | |||
private fun getFDDetailsApi() { | |||
if (Common.isNetworkAvailable(activity as NiveshFdMainActivity)) { | |||
val getFDDetailsRequest = GetFDDetailsRequest() | |||
getFDDetailsRequest.FDProvider = getString(R.string.bajaj) | |||
getFDDetailsRequest.NiveshClientCode = | |||
(activity as NiveshFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_CODE | |||
getFDDetailsRequest.UniqueId = (activity as NiveshFdMainActivity).uniqueId | |||
(activity as NiveshFdMainActivity).viewModel.getFDDetails( | |||
getFDDetailsRequest, | |||
PreferenceManager(activity as NiveshFdMainActivity).getToken(), | |||
activity as NiveshFdMainActivity | |||
) | |||
(activity as NiveshFdMainActivity).viewModel.getFDDetailsMutableData.observe( | |||
viewLifecycleOwner | |||
) { response -> | |||
when (response) { | |||
is Resource.Success -> { | |||
Log.e("getFDDetailsApi", " response -->${response.data.toString()}") | |||
val getFDDetailsResponse: GetFDDetailsResponse = | |||
Gson().fromJson( | |||
response.data?.toString(), | |||
GetFDDetailsResponse::class.java | |||
) | |||
getFDDetailsResponse.Response.StatusCode.let { code -> | |||
when (code) { | |||
200 -> { | |||
binding.tvInvestedAmount.text = | |||
getString(R.string.rs).plus(getFDDetailsResponse.Response.FDDataResponse.FDAmount.toString()) | |||
binding.tvTenure.text = | |||
getFDDetailsResponse.Response.FDDataResponse.Tenure.toString() | |||
.plus(" Months") | |||
binding.tvInterestPayout.text = | |||
getFDDetailsResponse.Response.FDDataResponse.Frequency | |||
binding.tvRateOfInterest.text = | |||
getFDDetailsResponse.Response.FDDataResponse.RateOfInterest.toString() | |||
.plus(" % p.a.") | |||
payUrl = getFDDetailsResponse.Response.FDDataResponse.PaymentUrl | |||
value = getFDDetailsResponse.Response.FDDataResponse.Value | |||
} | |||
// 650 -> refreshToken() | |||
else -> { | |||
if (getFDDetailsResponse.Response.Errors.isNotEmpty()) { | |||
showDialogValidation( | |||
activity as NiveshFdMainActivity, | |||
getFDDetailsResponse.Response.Errors[0].ErrorMessage | |||
) | |||
} else { | |||
showDialogValidation( | |||
activity as NiveshFdMainActivity, | |||
"".plus(getFDDetailsResponse.Response.Message) | |||
) | |||
} | |||
} | |||
} | |||
} | |||
} | |||
is Resource.Error -> { | |||
response.message?.let { message -> | |||
showDialogValidation(activity as NiveshFdMainActivity, message) | |||
} | |||
} | |||
is Resource.Loading -> { | |||
} | |||
is Resource.DataError -> { | |||
} | |||
} | |||
} | |||
} | |||
} | |||
override fun onDestroyView() { | |||
super.onDestroyView() | |||
_binding = null | |||
} | |||
} |
@ -1,592 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.ui.fragment | |||
import android.os.Bundle | |||
import android.text.Editable | |||
import android.text.InputFilter | |||
import android.text.TextWatcher | |||
import android.util.Log | |||
import android.view.LayoutInflater | |||
import android.view.View | |||
import android.view.ViewGroup | |||
import android.widget.ArrayAdapter | |||
import android.widget.RadioButton | |||
import androidx.fragment.app.Fragment | |||
import androidx.fragment.app.activityViewModels | |||
import androidx.recyclerview.widget.DefaultItemAnimator | |||
import androidx.recyclerview.widget.LinearLayoutManager | |||
import androidx.recyclerview.widget.RecyclerView.LayoutManager | |||
import com.google.gson.Gson | |||
import com.nivesh.production.niveshfd.R | |||
import com.nivesh.production.niveshfd.databinding.FragmentNiveshfdStepOneBinding | |||
import com.nivesh.production.niveshfd.fd.adapter.HorizontalRecyclerViewAdapter | |||
import com.nivesh.production.niveshfd.fd.db.PreferenceManager | |||
import com.nivesh.production.niveshfd.fd.model.* | |||
import com.nivesh.production.niveshfd.fd.ui.activity.NiveshFdMainActivity | |||
import com.nivesh.production.niveshfd.fd.util.Common | |||
import com.nivesh.production.niveshfd.fd.util.Common.Companion.commonErrorMethod | |||
import com.nivesh.production.niveshfd.fd.util.Common.Companion.removeError | |||
import com.nivesh.production.niveshfd.fd.util.Resource | |||
import com.nivesh.production.niveshfd.fd.viewModel.MyObseravble | |||
class StepOneNiveshFDFragment : Fragment() { | |||
private var _binding: FragmentNiveshfdStepOneBinding? = null | |||
private val binding get() = _binding!! | |||
private val observerViewModel: MyObseravble by activityViewModels() | |||
private lateinit var rgMaturity: RadioButton | |||
private lateinit var listOfTenure: MutableList<ROIDataList> | |||
private lateinit var recyclerViewDropDownAdapter: HorizontalRecyclerViewAdapter | |||
private lateinit var listOfMinAmount: List<GetCodes> | |||
private lateinit var listOfMaxAmount: List<GetCodes> | |||
private lateinit var listOfFrequency: List<GetCodes> | |||
private var tenure: Int = 0 | |||
private var interest: Double = 0.0 | |||
private var maturityText: String = "" | |||
override fun onCreateView( | |||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? | |||
): View { | |||
_binding = FragmentNiveshfdStepOneBinding.inflate(inflater, container, false) | |||
return binding.root | |||
} | |||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |||
super.onViewCreated(view, savedInstanceState) | |||
listOfTenure = ArrayList() | |||
listOfMinAmount = ArrayList() | |||
listOfMaxAmount = ArrayList() | |||
listOfFrequency = ArrayList() | |||
rgMaturity = RadioButton(activity as NiveshFdMainActivity) | |||
binding.edtAmount.filters = arrayOf<InputFilter>(InputFilter.LengthFilter(8)) // upto 1 Cr | |||
// Amount | |||
binding.edtAmount.addTextChangedListener(object : TextWatcher { | |||
override fun afterTextChanged(s: Editable?) {} | |||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {} | |||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) { | |||
removeError(binding.tlDepositAmount) | |||
if (s.toString().trim().length >= 4) { | |||
maturityAmountApi(tenure, interest) | |||
} | |||
} | |||
}) | |||
// Frequency | |||
binding.spInterestPayout.setOnItemClickListener { _, _, position, _ -> | |||
removeError(binding.tlInterestPayout) | |||
if (listOfFrequency.isNotEmpty()) { | |||
binding.tvFrequency.text = listOfFrequency[position].Value | |||
if (!binding.tvFrequency.text.equals(getString(R.string.cumulativeText))) { | |||
binding.txtCumulativeNon.text = getString(R.string.nonCumulativeROI) | |||
} else { | |||
binding.txtCumulativeNon.text = getString(R.string.cumulativeROI) | |||
} | |||
if (binding.edtAmount.text.toString().trim().isNotEmpty()) { | |||
maturityAmountApi(tenure, interest) | |||
} | |||
} | |||
} | |||
// Tenure | |||
binding.spTenure.setOnItemClickListener { _, _, position, _ -> | |||
removeError(binding.tlInterestTenure) | |||
if (listOfTenure.isNotEmpty()) { | |||
tenure = listOfTenure[position].Tenure.toInt() | |||
interest = listOfTenure[position].ROI | |||
binding.tvROI.text = interest.toString().plus(" %") | |||
maturityAmountApi(tenure, interest) | |||
recyclerViewDropDownAdapter.refresh() | |||
} | |||
} | |||
// Senior / Non Senior Citizen | |||
binding.swSeniorCitizen.setOnCheckedChangeListener { _, _ -> | |||
getRatesApi() | |||
} | |||
// Maturity Options | |||
maturityText = getString(R.string.totalDeduction) | |||
rgMaturity.text = getString(R.string.additionalDetailOne) | |||
binding.radioGroup.setOnCheckedChangeListener { group, checkedId -> | |||
rgMaturity = group.findViewById(checkedId) | |||
Log.e("Maturity", "-->" + rgMaturity.text) | |||
maturityText = if (rgMaturity.text.contains("credit")) { | |||
getString(R.string.totalDeduction) | |||
} else { | |||
getString(R.string.principalDeduction) | |||
} | |||
} | |||
// Next Button | |||
binding.btnNext.setOnClickListener { | |||
if (validation()) { | |||
(activity as NiveshFdMainActivity).fdInvestmentDetails.FDAmount = | |||
binding.edtAmount.text.toString().toDouble() | |||
observerViewModel.data.value = binding.edtAmount.text.toString() | |||
(activity as NiveshFdMainActivity).fdInvestmentDetails.Frequency = | |||
binding.spInterestPayout.text.toString() | |||
(activity as NiveshFdMainActivity).fdInvestmentDetails.Tenure = tenure | |||
(activity as NiveshFdMainActivity).fdInvestmentDetails.Interest = interest | |||
(activity as NiveshFdMainActivity).fdInvestmentDetails.NiveshClientCode = | |||
(activity as NiveshFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_CODE | |||
(activity as NiveshFdMainActivity).fdInvestmentDetails.Provider = | |||
getString(R.string.bajaj) | |||
(activity as NiveshFdMainActivity).fdInvestmentDetails.IPAddress = "192.168.1.23" | |||
(activity as NiveshFdMainActivity).fdInvestmentDetails.Device = | |||
getString(R.string.app) | |||
(activity as NiveshFdMainActivity).fdInvestmentDetails.Source = | |||
getString(R.string.source) | |||
if (binding.swSeniorCitizen.isChecked) { | |||
(activity as NiveshFdMainActivity).fdInvestmentDetails.CitizenType = | |||
getString(R.string.seniorCitizen) | |||
} else { | |||
(activity as NiveshFdMainActivity).fdInvestmentDetails.CitizenType = | |||
getString(R.string.nonSeniorCitizen) | |||
} | |||
(activity as NiveshFdMainActivity).fdInvestmentDetails.CustomerType = "" | |||
(activity as NiveshFdMainActivity).fdInvestmentDetails.CKYCNumber = "" | |||
(activity as NiveshFdMainActivity).fdInvestmentDetails.UniqueId = | |||
(activity as NiveshFdMainActivity).uniqueId | |||
(activity as NiveshFdMainActivity).fdInvestmentDetails.RenewOption = maturityText | |||
(activity as NiveshFdMainActivity).createFDApplicantRequest.FDInvestmentDetails = | |||
(activity as NiveshFdMainActivity).fdInvestmentDetails | |||
Log.e( | |||
"StepOneData", | |||
"-->" + Gson().toJson((activity as NiveshFdMainActivity).fdInvestmentDetails) | |||
) | |||
(activity as NiveshFdMainActivity).stepOneApi() | |||
} | |||
} | |||
minAmountApi() | |||
interestPayoutApi() | |||
} | |||
private fun interestPayoutApi() { | |||
val getCodeRequest = GetCodeRequest() | |||
getCodeRequest.ProductName = getString(R.string.bajajFD) | |||
getCodeRequest.Category = getString(R.string.niveshCategory) | |||
getCodeRequest.Language = getString(R.string.language) | |||
getCodeRequest.InputValue = "" | |||
(activity as NiveshFdMainActivity).viewModel.getCode( | |||
getCodeRequest, | |||
PreferenceManager(activity as NiveshFdMainActivity).getToken(), | |||
activity as NiveshFdMainActivity | |||
) | |||
(activity as NiveshFdMainActivity).viewModel.getCodeMutableData.observe(viewLifecycleOwner) { response -> | |||
when (response) { | |||
is Resource.Success -> { | |||
Log.e("interestPayoutApi", " response -->${response.data.toString()}") | |||
val getCodeResponse: GetCodeResponse = | |||
Gson().fromJson(response.data?.toString(), GetCodeResponse::class.java) | |||
getCodeResponse.Response.StatusCode.let { code -> | |||
when (code) { | |||
200 -> { | |||
listOfFrequency = getCodeResponse.Response.GetCodesList | |||
if (listOfFrequency.isNotEmpty()) { | |||
val adapter = ArrayAdapter( | |||
activity as NiveshFdMainActivity, | |||
R.layout.spinner_dropdown, | |||
listOfFrequency | |||
) | |||
binding.spInterestPayout.setAdapter(adapter) | |||
binding.spInterestPayout.setText( | |||
adapter.getItem(listOfFrequency.size - 1)?.Value, | |||
false | |||
) | |||
binding.tvFrequency.text = | |||
adapter.getItem(listOfFrequency.size - 1)?.Value | |||
getRatesApi() | |||
} else { | |||
Common.showDialogValidation( | |||
activity as NiveshFdMainActivity, | |||
"Interest Payout Frequency Data Is Missing." | |||
) | |||
} | |||
} | |||
650 -> "" | |||
else -> { | |||
if (getCodeResponse.Response.Errors.isNotEmpty()) { | |||
Common.showDialogValidation( | |||
activity as NiveshFdMainActivity, | |||
getCodeResponse.Response.Errors[0].ErrorMessage | |||
) | |||
}else{ | |||
Common.showDialogValidation( | |||
activity as NiveshFdMainActivity, | |||
"".plus(getCodeResponse.Response.Message) | |||
) | |||
} | |||
} | |||
} | |||
} | |||
} | |||
is Resource.Error -> { | |||
response.message?.let { message -> | |||
Common.showDialogValidation(activity as NiveshFdMainActivity, message) | |||
} | |||
} | |||
is Resource.Loading -> { | |||
} | |||
is Resource.DataError -> { | |||
} | |||
} | |||
} | |||
} | |||
private fun minAmountApi() { | |||
val getCodeRequest = GetCodeRequest() | |||
getCodeRequest.ProductName = getString(R.string.bajajFD) | |||
getCodeRequest.Category = getString(R.string.minAmountCategory) | |||
getCodeRequest.Language = getString(R.string.language) | |||
getCodeRequest.InputValue = "" | |||
(activity as NiveshFdMainActivity).viewModel.getMinAmount( | |||
getCodeRequest, | |||
PreferenceManager(activity as NiveshFdMainActivity).getToken(), | |||
activity as NiveshFdMainActivity | |||
) | |||
(activity as NiveshFdMainActivity).viewModel.getMinAmountMutableData.observe( | |||
viewLifecycleOwner | |||
) { response -> | |||
when (response) { | |||
is Resource.Success -> { | |||
Log.e("minAmountApi ", " response-->${response.data.toString()}") | |||
val getCodeResponse: GetCodeResponse = | |||
Gson().fromJson(response.data?.toString(), GetCodeResponse::class.java) | |||
getCodeResponse.Response.StatusCode.let { code -> | |||
when (code) { | |||
200 -> { | |||
listOfMinAmount = getCodeResponse.Response.GetCodesList | |||
// if (listOfMinAmount.isNotEmpty()) { | |||
// binding.txtMinAmount.text = getString(R.string.minAmount).plus(listOfMinAmount[0].Value) | |||
// } | |||
maxAmountApi() | |||
} | |||
650 -> "" | |||
else -> { | |||
if (getCodeResponse.Response.Errors.isNotEmpty()) { | |||
Common.showDialogValidation( | |||
activity as NiveshFdMainActivity, | |||
getCodeResponse.Response.Errors[0].ErrorMessage | |||
) | |||
}else{ | |||
Common.showDialogValidation( | |||
activity as NiveshFdMainActivity, | |||
"".plus(getCodeResponse.Response.Message) | |||
) | |||
} | |||
} | |||
} | |||
} | |||
} | |||
is Resource.Error -> { | |||
response.message?.let { message -> | |||
Common.showDialogValidation(activity as NiveshFdMainActivity, message) | |||
} | |||
} | |||
is Resource.Loading -> { | |||
} | |||
is Resource.DataError -> { | |||
} | |||
} | |||
} | |||
} | |||
private fun maxAmountApi() { | |||
val getCodeRequest = GetCodeRequest() | |||
getCodeRequest.ProductName = getString(R.string.bajajFD) | |||
getCodeRequest.Category = getString(R.string.MaxAmountCategory) | |||
getCodeRequest.Language = getString(R.string.language) | |||
getCodeRequest.InputValue = "" | |||
(activity as NiveshFdMainActivity).viewModel.getMaxAmount( | |||
getCodeRequest, | |||
PreferenceManager(activity as NiveshFdMainActivity).getToken(), | |||
activity as NiveshFdMainActivity | |||
) | |||
(activity as NiveshFdMainActivity).viewModel.getMaxAmountMutableData.observe( | |||
viewLifecycleOwner | |||
) { response -> | |||
when (response) { | |||
is Resource.Success -> { | |||
Log.e("maxAmountApi ", " response-->${response.data.toString()}") | |||
val getCodeResponse: GetCodeResponse = | |||
Gson().fromJson(response.data?.toString(), GetCodeResponse::class.java) | |||
getCodeResponse.Response.StatusCode.let { code -> | |||
when (code) { | |||
200 -> { | |||
listOfMaxAmount = getCodeResponse.Response.GetCodesList | |||
} | |||
650 -> "" | |||
else -> { | |||
if (getCodeResponse.Response.Errors.isNotEmpty()) { | |||
Common.showDialogValidation( | |||
activity as NiveshFdMainActivity, | |||
getCodeResponse.Response.Errors[0].ErrorMessage | |||
) | |||
}else{ | |||
Common.showDialogValidation( | |||
activity as NiveshFdMainActivity, | |||
"".plus(getCodeResponse.Response.Message) | |||
) | |||
} | |||
} | |||
} | |||
} | |||
} | |||
is Resource.Error -> { | |||
response.message?.let { message -> | |||
Common.showDialogValidation(activity as NiveshFdMainActivity, message) | |||
} | |||
} | |||
is Resource.Loading -> { | |||
} | |||
is Resource.DataError -> { | |||
} | |||
} | |||
} | |||
} | |||
private fun setUpRecyclerView() { | |||
recyclerViewDropDownAdapter = HorizontalRecyclerViewAdapter( | |||
activity as NiveshFdMainActivity, | |||
listOfTenure | |||
) { position -> | |||
tenure = listOfTenure[position].Tenure.toInt() | |||
interest = listOfTenure[position].ROI | |||
binding.tvROI.text = interest.toString().plus(" %") | |||
maturityAmountApi(tenure, interest) | |||
} | |||
val mLayoutManager: LayoutManager = | |||
LinearLayoutManager(activity, LinearLayoutManager.HORIZONTAL, true) | |||
binding.rvTenure.layoutManager = mLayoutManager | |||
binding.rvTenure.setHasFixedSize(true) | |||
binding.rvTenure.itemAnimator = DefaultItemAnimator() | |||
binding.rvTenure.adapter = recyclerViewDropDownAdapter | |||
} | |||
private fun maturityAmountApi(tenure: Int, interest: Double) { | |||
if (binding.edtAmount.text.toString().length >= 4 && interest != 0.0 && tenure != 0 && binding.spInterestPayout.text.toString() | |||
.isNotEmpty() | |||
) { | |||
val maturityAmountRequest = GetMaturityAmountRequest() | |||
maturityAmountRequest.FDProvider = getString(R.string.bajaj) | |||
maturityAmountRequest.FDAmount = binding.edtAmount.text.toString().toInt() | |||
maturityAmountRequest.Frequency = binding.spInterestPayout.text.toString() | |||
maturityAmountRequest.Tenure = tenure | |||
maturityAmountRequest.Interest = interest | |||
(activity as NiveshFdMainActivity).viewModel.getMaturityAmount( | |||
maturityAmountRequest, | |||
activity as NiveshFdMainActivity, | |||
PreferenceManager(activity as NiveshFdMainActivity).getToken() | |||
) | |||
(activity as NiveshFdMainActivity).viewModel.getMaturityAmountMutableData.observe( | |||
viewLifecycleOwner | |||
) { response -> | |||
when (response) { | |||
is Resource.Success -> { | |||
Log.e("maturityAmountApi ", " response-->${response.data.toString()}") | |||
val getMaturityAmountResponse = | |||
Gson().fromJson( | |||
response.data?.toString(), | |||
GetCalculateMaturityAmountResponse::class.java | |||
) | |||
getMaturityAmountResponse.Response.StatusCode.let { code -> | |||
when (code) { | |||
200 -> { | |||
binding.tvMaturityAmount.text = | |||
getString(R.string.rs).plus(" ").plus( | |||
getMaturityAmountResponse.Response.MaturityAmount.toString() | |||
) | |||
} | |||
// 650 -> refreshToken() | |||
else -> { | |||
if (getMaturityAmountResponse.Response.Errors.isNotEmpty()) { | |||
Common.showDialogValidation( | |||
activity as NiveshFdMainActivity, | |||
getMaturityAmountResponse.Response.Errors[0].ErrorMessage | |||
) | |||
}else{ | |||
Common.showDialogValidation( | |||
activity as NiveshFdMainActivity, | |||
"".plus(getMaturityAmountResponse.Response.Message) | |||
) | |||
} | |||
} | |||
} | |||
} | |||
} | |||
is Resource.Error -> { | |||
response.message?.let { message -> | |||
Common.showDialogValidation( | |||
activity as NiveshFdMainActivity, | |||
message | |||
) | |||
} | |||
} | |||
is Resource.Loading -> { | |||
} | |||
is Resource.DataError -> { | |||
} | |||
} | |||
} | |||
} | |||
} | |||
private fun validation(): Boolean { | |||
return if (binding.edtAmount.text.toString().isEmpty()) { | |||
commonErrorMethod( | |||
binding.edtAmount, | |||
binding.tlDepositAmount, | |||
getString(R.string.emptyAmount) | |||
) | |||
} else if (binding.edtAmount.text.toString() | |||
.toDouble() < listOfMinAmount[0].Value.toDouble() | |||
) { | |||
commonErrorMethod( | |||
binding.edtAmount, | |||
binding.tlDepositAmount, | |||
getString(R.string.validMinAmount) | |||
) | |||
} else if (binding.edtAmount.text.toString().toInt() % 1000 != 0) { | |||
commonErrorMethod( | |||
binding.edtAmount, | |||
binding.tlDepositAmount, | |||
getString(R.string.validMultipleAmount) | |||
) | |||
} else if (binding.edtAmount.text.toString() | |||
.toDouble() > listOfMaxAmount[0].Value.toDouble() | |||
) { | |||
commonErrorMethod( | |||
binding.edtAmount, | |||
binding.tlDepositAmount, | |||
getString(R.string.validMaxAmount) | |||
) | |||
} else if (binding.spInterestPayout.text.isEmpty()) { | |||
Common.commonSpinnerErrorMethod( | |||
binding.spInterestPayout, | |||
binding.tlInterestPayout, | |||
getString(R.string.emptyInterestPayout) | |||
) | |||
} else if (binding.spTenure.text.isEmpty()) { | |||
Common.commonSpinnerErrorMethod( | |||
binding.spTenure, | |||
binding.tlInterestTenure, | |||
getString(R.string.emptyInterestTenure) | |||
) | |||
} else { | |||
true | |||
} | |||
} | |||
private fun getRatesApi() { | |||
val getRatesRequest = GetRatesRequest() | |||
getRatesRequest.fdProvider = getString(R.string.bajaj) | |||
getRatesRequest.frequency = binding.spInterestPayout.text.toString() | |||
if (binding.swSeniorCitizen.isChecked) { | |||
getRatesRequest.type = getString(R.string.seniorCitizen) | |||
} else { | |||
getRatesRequest.type = getString(R.string.nonSeniorCitizen) | |||
} | |||
(activity as NiveshFdMainActivity).viewModel.getRates( | |||
getRatesRequest, | |||
PreferenceManager(activity as NiveshFdMainActivity).getToken(), | |||
activity as NiveshFdMainActivity | |||
) | |||
(activity as NiveshFdMainActivity).viewModel.getRatesMutableData.observe(viewLifecycleOwner) { response -> | |||
when (response) { | |||
is Resource.Success -> { | |||
val getRatesResponse: GetRatesResponse = | |||
Gson().fromJson(response.data?.toString(), GetRatesResponse::class.java) | |||
getRatesResponse.Response.StatusCode.let { code -> | |||
when (code) { | |||
200 -> { | |||
if (listOfTenure.isNotEmpty()) { | |||
listOfTenure.clear() | |||
} | |||
listOfTenure = getRatesResponse.Response.ROIDatalist | |||
// Tenure | |||
if (listOfTenure.isNotEmpty()) { | |||
listOfTenure.sortWith { lhs: ROIDataList, rhs: ROIDataList -> | |||
rhs.Tenure.compareTo( | |||
lhs.Tenure | |||
) | |||
} | |||
binding.ORLayout.visibility = View.VISIBLE | |||
val tenureAdapter = | |||
ArrayAdapter( | |||
activity as NiveshFdMainActivity, | |||
R.layout.spinner_dropdown, | |||
listOfTenure | |||
) | |||
binding.spTenure.setAdapter(tenureAdapter) | |||
binding.spTenure.setText( | |||
tenureAdapter.getItem(0)?.Tenure.plus( | |||
" Months | " | |||
).plus(tenureAdapter.getItem(0)?.ROI).plus(" %"), false | |||
) | |||
tenure = tenureAdapter.getItem(0)?.Tenure.toString().toInt() | |||
interest = tenureAdapter.getItem(0)?.ROI ?: 0.0 | |||
binding.tvROI.text = | |||
tenureAdapter.getItem(0)?.ROI.toString().plus(" %") | |||
setUpRecyclerView() | |||
} else { | |||
binding.ORLayout.visibility = View.GONE | |||
} | |||
} | |||
// 650 -> refreshToken() | |||
else -> { | |||
if (getRatesResponse.Response.Errors.isNotEmpty()) { | |||
Common.showDialogValidation( | |||
activity as NiveshFdMainActivity, | |||
getRatesResponse.Response.Errors[0].ErrorMessage | |||
) | |||
}else{ | |||
Common.showDialogValidation( | |||
activity as NiveshFdMainActivity, | |||
"".plus(getRatesResponse.Response.Message) | |||
) | |||
} | |||
} | |||
} | |||
} | |||
} | |||
is Resource.Error -> { | |||
response.message?.let { message -> | |||
Common.showDialogValidation(activity as NiveshFdMainActivity, message) | |||
} | |||
} | |||
is Resource.Loading -> { | |||
} | |||
is Resource.DataError -> { | |||
} | |||
} | |||
} | |||
} | |||
override fun onDestroyView() { | |||
super.onDestroyView() | |||
_binding = null | |||
} | |||
} |
@ -1,725 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.ui.fragment | |||
import android.Manifest | |||
import android.annotation.SuppressLint | |||
import android.app.Activity | |||
import android.content.DialogInterface | |||
import android.content.pm.PackageManager | |||
import android.database.Cursor | |||
import android.graphics.Bitmap | |||
import android.graphics.BitmapFactory | |||
import android.net.Uri | |||
import android.os.Build | |||
import android.os.Bundle | |||
import android.provider.OpenableColumns | |||
import android.util.Base64 | |||
import android.util.Log | |||
import android.view.LayoutInflater | |||
import android.view.View | |||
import android.view.ViewGroup | |||
import android.widget.* | |||
import androidx.activity.result.ActivityResultLauncher | |||
import androidx.activity.result.contract.ActivityResultContracts | |||
import androidx.appcompat.app.AlertDialog | |||
import androidx.core.app.ActivityCompat | |||
import androidx.core.content.ContextCompat | |||
import androidx.core.content.FileProvider | |||
import androidx.fragment.app.Fragment | |||
import androidx.lifecycle.lifecycleScope | |||
import com.google.gson.Gson | |||
import com.nivesh.production.niveshfd.BuildConfig | |||
import com.nivesh.production.niveshfd.R | |||
import com.nivesh.production.niveshfd.databinding.FragmentNiveshfdStepThreeBinding | |||
import com.nivesh.production.niveshfd.fd.db.PreferenceManager | |||
import com.nivesh.production.niveshfd.fd.model.* | |||
import com.nivesh.production.niveshfd.fd.ui.activity.NiveshFdMainActivity | |||
import com.nivesh.production.niveshfd.fd.util.Common | |||
import com.nivesh.production.niveshfd.fd.util.Common.Companion.getFileExtension | |||
import com.nivesh.production.niveshfd.fd.util.Common.Companion.showDialogWithTwoButtons | |||
import com.nivesh.production.niveshfd.fd.util.ImageUtil | |||
import com.nivesh.production.niveshfd.fd.util.Resource | |||
import java.io.* | |||
import java.util.* | |||
class StepThreeNiveshFDFragment : Fragment() { | |||
// private var _binding: FragmentNiveshfdStepThreeBinding? = null | |||
private var _binding: FragmentNiveshfdStepThreeBinding? = null | |||
private val binding get() = _binding!! | |||
private var takeImageResult: ActivityResultLauncher<Uri>? = null | |||
private var selectImageIntent: ActivityResultLauncher<String>? = null | |||
private var bitmap: Bitmap? = null | |||
private var latestTmpUri: Uri? = null | |||
private val mapImage: HashMap<String, String> = HashMap() | |||
private lateinit var listOfDocType: List<GetCodes> | |||
private var panString: String = "" | |||
private var photoString: String = "" | |||
private var docString: String = "" | |||
private var docString2: String = "" | |||
private var panFileExt: String? = "" | |||
private var photoFileExt: String? = "" | |||
private var doc1FileExt: String? = "" | |||
private var doc2fileExt: String? = "" | |||
private var docValue: String = "" | |||
private val mainPANUpload: Int = 1 | |||
private val mainPhotoUpload: Int = 2 | |||
private val firstDocUpload: Int = 3 | |||
private val secondDocUpload: Int = 4 | |||
private var actionType: Int = -1 | |||
private val permissions = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { | |||
arrayOf( | |||
Manifest.permission.READ_EXTERNAL_STORAGE, | |||
Manifest.permission.WRITE_EXTERNAL_STORAGE, | |||
Manifest.permission.READ_MEDIA_IMAGES | |||
) | |||
} else { | |||
arrayOf( | |||
Manifest.permission.READ_EXTERNAL_STORAGE, | |||
Manifest.permission.WRITE_EXTERNAL_STORAGE | |||
) | |||
} | |||
private val requestCameraPermission = registerForActivityResult( | |||
ActivityResultContracts.RequestPermission() | |||
) { isGranted: Boolean -> | |||
if (isGranted) { | |||
takeImage() | |||
} else { | |||
showDialogWithTwoButtons( | |||
(activity as NiveshFdMainActivity), getString(R.string.cameraPermission), getString( | |||
R.string.permissionRequired | |||
) | |||
) | |||
} | |||
} | |||
private val requestGalleryPermission = registerForActivityResult( | |||
ActivityResultContracts.RequestMultiplePermissions() | |||
) { permission -> | |||
if (!permission.containsValue(false)) { | |||
selectImageIntent?.launch("image/*") | |||
} else { | |||
showDialogWithTwoButtons( | |||
(activity as NiveshFdMainActivity), | |||
getString(R.string.galleryPermission), | |||
getString( | |||
R.string.permissionsRequired | |||
) | |||
) | |||
} | |||
} | |||
override fun onCreateView( | |||
inflater: LayoutInflater, container: ViewGroup?, | |||
savedInstanceState: Bundle? | |||
): View { | |||
_binding = FragmentNiveshfdStepThreeBinding.inflate(inflater, container, false) | |||
return binding.root | |||
} | |||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |||
super.onViewCreated(view, savedInstanceState) | |||
selectImageIntent = registerForActivityResult(ActivityResultContracts.GetContent()) | |||
{ uri: Uri? -> | |||
if (uri != null) { | |||
bitmap = uriToBitmap(uri) | |||
uploadDocument(uri, "g") | |||
} | |||
} | |||
takeImageResult = | |||
registerForActivityResult(ActivityResultContracts.TakePicture()) { isSuccess -> | |||
if (isSuccess) { | |||
latestTmpUri?.let { uri -> | |||
uploadDocument(uri, "c") | |||
} | |||
} | |||
} | |||
binding.btnNext.setOnClickListener { | |||
if (validate()) { | |||
if (panString.isNotEmpty()) { | |||
mapImage["PAN"] = "data:image/".plus(panFileExt) | |||
.plus(";base64, ").plus(panString) | |||
} | |||
if (photoString.isNotEmpty()) { | |||
mapImage["Photograph"] = "data:image/".plus(photoFileExt) | |||
.plus(";base64, ").plus(photoString) | |||
} | |||
if (docString.isNotEmpty()) { | |||
mapImage["docValue"] = "data:image/".plus(doc1FileExt) | |||
.plus(";base64, ").plus(docString) | |||
} | |||
if (docString2.isNotEmpty()) { | |||
mapImage["Aadhar"] = "data:image/".plus(doc2fileExt) | |||
.plus(";base64, ").plus(docString2) | |||
} | |||
var uploadPosition = 0 | |||
for (entry in mapImage.iterator()) { | |||
uploadPosition++ | |||
uploadDocApi(entry.key, entry.value, uploadPosition) | |||
} | |||
} | |||
} | |||
binding.btnBack.setOnClickListener { | |||
(activity as NiveshFdMainActivity).binding.viewPager.currentItem = 1 | |||
} | |||
binding.btnPANUpload.setOnClickListener { | |||
actionType = mainPANUpload | |||
selectImage() | |||
} | |||
binding.btnPhotoUpload.setOnClickListener { | |||
actionType = mainPhotoUpload | |||
selectImage() | |||
} | |||
binding.btnAadhaarFrontUpload.setOnClickListener { | |||
actionType = firstDocUpload | |||
selectImage() | |||
} | |||
binding.btnAadhaarBackUpload.setOnClickListener { | |||
actionType = secondDocUpload | |||
selectImage() | |||
} | |||
binding.spDocType.onItemClickListener = | |||
AdapterView.OnItemClickListener { parent, _, position, _ -> | |||
val getCodes: GetCodes = parent.getItemAtPosition(position) as GetCodes | |||
docValue = getCodes.Value | |||
docString = "" | |||
docString2 = "" | |||
when (getCodes.Label) { | |||
resources.getString(R.string.aadhar) -> | |||
setAadhaarUploadLayout() | |||
else -> { | |||
setOtherUploadLayout(getCodes.Value) | |||
} | |||
} | |||
} | |||
docTypeApi() | |||
} | |||
@SuppressLint("Range") | |||
fun getFileName(uri: Uri): String { | |||
var result = "" | |||
if (uri.scheme == "content") { | |||
val cursor: Cursor = | |||
requireActivity().contentResolver.query(uri, null, null, null, null)!! | |||
cursor.use { cursor1 -> | |||
if (cursor1.moveToFirst()) { | |||
result = cursor1.getString(cursor1.getColumnIndex(OpenableColumns.DISPLAY_NAME)) | |||
} | |||
} | |||
} | |||
if (result.isEmpty()) { | |||
result = uri.path!! | |||
val cut = result.lastIndexOf('/') | |||
if (cut != -1) { | |||
result = result.substring(cut + 1) | |||
} | |||
} | |||
return result | |||
} | |||
private fun selectImage() { | |||
val builder = AlertDialog.Builder( | |||
activity as NiveshFdMainActivity | |||
) | |||
builder.setTitle(getString(R.string.addPhoto)) | |||
builder.setItems( | |||
arrayOf( | |||
getString(R.string.takePhoto), | |||
getString(R.string.chooseFromGallery), | |||
getString(R.string.cancel) | |||
) | |||
) { dialog: DialogInterface, pos -> | |||
when (pos) { | |||
0 -> { | |||
if (hasPermissions( | |||
activity as NiveshFdMainActivity, | |||
Manifest.permission.CAMERA | |||
) | |||
) { | |||
takeImage() | |||
} else { | |||
onClickRequestPermission() | |||
} | |||
dialog.dismiss() | |||
} | |||
1 -> { | |||
if (hasPermissions(activity as NiveshFdMainActivity, *permissions)) { | |||
selectImageIntent?.launch("image/*") | |||
} else { | |||
requestGalleryPermission.launch(permissions) | |||
} | |||
dialog.dismiss() | |||
} | |||
else -> { | |||
dialog.dismiss() | |||
} | |||
} | |||
} | |||
builder.show() | |||
} | |||
private fun hasPermissions(activity: Activity, vararg permissions: String?): Boolean { | |||
for (permission in permissions) { | |||
if (ActivityCompat.checkSelfPermission( | |||
activity, | |||
permission!! | |||
) != PackageManager.PERMISSION_GRANTED | |||
) { | |||
return false | |||
} | |||
} | |||
return true | |||
} | |||
private fun onClickRequestPermission() { | |||
when { | |||
ContextCompat.checkSelfPermission( | |||
activity as NiveshFdMainActivity, | |||
Manifest.permission.CAMERA | |||
) == PackageManager.PERMISSION_GRANTED -> { | |||
} | |||
ActivityCompat.shouldShowRequestPermissionRationale( | |||
activity as NiveshFdMainActivity, | |||
Manifest.permission.CAMERA | |||
) -> { | |||
requestCameraPermission.launch( | |||
Manifest.permission.CAMERA | |||
) | |||
} | |||
else -> { | |||
requestCameraPermission.launch( | |||
Manifest.permission.CAMERA | |||
) | |||
} | |||
} | |||
} | |||
private fun setOtherUploadLayout(itemName: String?) { | |||
binding.tvAadhaarFront.text = itemName.plus(" Front *") | |||
if (binding.tvAadhaarBack.visibility == View.VISIBLE) binding.tvAadhaarBack.visibility = | |||
View.INVISIBLE | |||
if (binding.btnAadhaarBackUpload.visibility == View.VISIBLE) binding.btnAadhaarBackUpload.visibility = | |||
View.INVISIBLE | |||
} | |||
private fun setAadhaarUploadLayout() { | |||
binding.tvAadhaarFront.text = resources.getString(R.string.aadhaarFront) | |||
binding.tvAadhaarBack.text = resources.getString(R.string.aadhaarBack) | |||
binding.tvAadhaarBack.visibility = View.VISIBLE | |||
binding.btnAadhaarBackUpload.visibility = View.VISIBLE | |||
binding.tvAadhaarFront.visibility = View.VISIBLE | |||
binding.btnAadhaarFrontUpload.visibility = View.VISIBLE | |||
} | |||
private fun uploadDocument(uri: Uri, type: String) { | |||
when (actionType) { | |||
mainPANUpload -> { | |||
binding.ivPan.visibility = View.VISIBLE | |||
val fileDir: File = requireActivity().cacheDir | |||
val fileExtension = File(fileDir.toString().plus("/").plus(getFileName(uri))) | |||
panFileExt = getFileExtension(getFileName(uri)) | |||
val size: Double = Common.getFileSizeInMB(fileExtension.length()) | |||
if (size < 5) { | |||
if (type == "c") encodedPANBase64(fileExtension) | |||
else panString = bitmap?.let { ImageUtil.convert(it) }.toString() | |||
} else { | |||
panString = "" | |||
panFileExt = "" | |||
} | |||
} | |||
mainPhotoUpload -> { | |||
binding.ivPhotograph.visibility = View.VISIBLE | |||
binding.ivPan.visibility = View.VISIBLE | |||
val fileDir: File = requireActivity().cacheDir | |||
val fileExtension = File(fileDir.toString().plus("/").plus(getFileName(uri))) | |||
photoFileExt = getFileExtension(getFileName(uri)) | |||
val size: Double = Common.getFileSizeInMB(fileExtension.length()) | |||
if (size < 5) { | |||
if (type == "c") encodedPhotoBase64(fileExtension) | |||
else photoString = bitmap?.let { ImageUtil.convert(it) }.toString() | |||
} else { | |||
photoString = "" | |||
photoFileExt = "" | |||
} | |||
} | |||
firstDocUpload -> { | |||
binding.ivAadharFront.visibility = View.VISIBLE | |||
val fileDir: File = requireActivity().cacheDir | |||
val fileExtension = File(fileDir.toString().plus("/").plus(getFileName(uri))) | |||
doc1FileExt = getFileExtension(getFileName(uri)) | |||
val size: Double = Common.getFileSizeInMB(fileExtension.length()) | |||
if (size < 5) { | |||
if (type == "c") encodedUpload1Base64(fileExtension) | |||
else docString = bitmap?.let { ImageUtil.convert(it) }.toString() | |||
} else { | |||
docString = "" | |||
doc1FileExt = "" | |||
} | |||
} | |||
else -> { | |||
binding.ivAadharBack.visibility = View.VISIBLE | |||
val fileDir: File = requireActivity().cacheDir | |||
val fileExtension = File(fileDir.toString().plus("/").plus(getFileName(uri))) | |||
doc2fileExt = getFileExtension(getFileName(uri)) | |||
val size: Double = Common.getFileSizeInMB(fileExtension.length()) | |||
if (size < 5) { | |||
if (type == "c") encodedFileToBase64(fileExtension) | |||
else docString2 = bitmap?.let { ImageUtil.convert(it) }.toString() | |||
} else { | |||
docString2 = "" | |||
doc2fileExt = "" | |||
} | |||
} | |||
} | |||
} | |||
private fun encodedPANBase64(fileName: File) { | |||
panString = try { | |||
val bytes: ByteArray = loadFile(fileName) | |||
Base64.encodeToString(bytes, Base64.DEFAULT).trim().replace("\n", "") | |||
.replace("\\s+", "") | |||
} catch (e: Exception) { | |||
e.printStackTrace() | |||
"" | |||
} | |||
} | |||
private fun encodedPhotoBase64(fileName: File) { | |||
photoString = try { | |||
val bytes: ByteArray = loadFile(fileName) | |||
Base64.encodeToString(bytes, Base64.DEFAULT).trim().replace("\n", "") | |||
.replace("\\s+", "") | |||
} catch (e: Exception) { | |||
e.printStackTrace() | |||
"" | |||
} | |||
} | |||
private fun encodedUpload1Base64(fileName: File) { | |||
docString = try { | |||
val bytes: ByteArray = loadFile(fileName) | |||
Base64.encodeToString(bytes, Base64.DEFAULT).trim().replace("\n", "") | |||
.replace("\\s+", "") | |||
} catch (e: Exception) { | |||
e.printStackTrace() | |||
"" | |||
} | |||
} | |||
private fun encodedFileToBase64(fileName: File) { | |||
docString2 = try { | |||
val bytes: ByteArray = loadFile(fileName) | |||
Base64.encodeToString(bytes, Base64.DEFAULT).trim().replace("\n", "") | |||
.replace("\\s+", "") | |||
} catch (e: Exception) { | |||
e.printStackTrace() | |||
"" | |||
} | |||
} | |||
@Throws(IOException::class) | |||
private fun loadFile(file: File): ByteArray { | |||
val inputStream: InputStream = FileInputStream(file) | |||
val length = file.length() | |||
val bytes = ByteArray(length.toInt()) | |||
var offset = 0 | |||
var numRead = 0 | |||
while (offset < bytes.size && inputStream.read(bytes, offset, bytes.size - offset).also { | |||
numRead = it | |||
} >= 0) { | |||
offset += numRead | |||
} | |||
if (offset < bytes.size) { | |||
throw IOException("Could not completely read file " + file.name) | |||
} | |||
inputStream.close() | |||
return bytes | |||
} | |||
private fun uploadDocApi(key: String, imageBase64: String, uploadPosition: Int) { | |||
val du = DocumentUpload() | |||
du.Description = key | |||
du.DocumentType = key | |||
du.FDProvider = getString(R.string.bajaj) | |||
du.ImageEncodeToBase64 = imageBase64 | |||
du.NiveshClientCode = | |||
(activity as NiveshFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_CODE | |||
du.UniqueId = (activity as NiveshFdMainActivity).uniqueId | |||
(activity as NiveshFdMainActivity).viewModel.documentsUpload( | |||
du, | |||
PreferenceManager(activity as NiveshFdMainActivity).getToken(), | |||
activity as NiveshFdMainActivity | |||
) | |||
(activity as NiveshFdMainActivity).viewModel.getDocumentUploadMutableData.observe( | |||
viewLifecycleOwner | |||
) { response -> | |||
when (response) { | |||
is Resource.Success -> { | |||
Log.e("UploadImage", "Response-->" + response.data.toString()) | |||
val getUploadResponse: UploadResponse = | |||
Gson().fromJson(response.data?.toString(), UploadResponse::class.java) | |||
getUploadResponse.Response.StatusCode.let { code -> | |||
when (code) { | |||
200 -> { | |||
Log.e("check_upload_res", response.message.toString()) | |||
if (uploadPosition == mapImage.size) { | |||
Toast.makeText( | |||
requireActivity(), | |||
"Documents Uploaded Successfully", | |||
Toast.LENGTH_SHORT | |||
).show() | |||
createFDApi((activity as NiveshFdMainActivity).createFDRequest) | |||
} | |||
} | |||
// 650 -> refreshToken() | |||
else -> { | |||
if (getUploadResponse.Response.Errors.isNotEmpty()) { | |||
Common.showDialogValidation( | |||
activity as NiveshFdMainActivity, | |||
getUploadResponse.Response.Errors[0].ErrorMessage | |||
) | |||
}else{ | |||
Common.showDialogValidation( | |||
activity as NiveshFdMainActivity, | |||
"".plus(getUploadResponse.Response.Message) | |||
) | |||
} | |||
} | |||
} | |||
} | |||
} | |||
is Resource.Error -> { | |||
response.message?.let { message -> | |||
Common.showDialogValidation(activity as NiveshFdMainActivity, message) | |||
} | |||
} | |||
is Resource.Loading -> { | |||
} | |||
is Resource.DataError -> { | |||
} | |||
} | |||
} | |||
} | |||
private fun createFDApi(data: CreateFDRequest) { | |||
(activity as NiveshFdMainActivity).viewModel.createFDApi( | |||
data, | |||
PreferenceManager(activity as NiveshFdMainActivity).getToken(), | |||
activity as NiveshFdMainActivity | |||
) | |||
(activity as NiveshFdMainActivity).viewModel.getFDResponseMutableData.observe( | |||
viewLifecycleOwner | |||
) { response -> | |||
when (response) { | |||
is Resource.Success -> { | |||
Log.e("createFDApi", "response--> " + response.data.toString()) | |||
val createFDApplicationResponse: CreateFDApplicationResponse = | |||
Gson().fromJson( | |||
response.data?.toString(), | |||
CreateFDApplicationResponse::class.java | |||
) | |||
createFDApplicationResponse.Response.StatusCode.let { code -> | |||
when (code) { | |||
200 -> { | |||
(activity as NiveshFdMainActivity).stepThreeApi() | |||
} | |||
// 650 -> refreshToken() | |||
else -> { | |||
if (createFDApplicationResponse.Response.Errors.isNotEmpty()) { | |||
Common.showDialogValidation( | |||
activity as NiveshFdMainActivity, | |||
createFDApplicationResponse.Response.Errors[0].ErrorMessage | |||
) | |||
}else{ | |||
Common.showDialogValidation( | |||
activity as NiveshFdMainActivity, | |||
"".plus(createFDApplicationResponse.Response.Message) | |||
) | |||
} | |||
} | |||
} | |||
} | |||
} | |||
is Resource.Error -> { | |||
response.message?.let { message -> | |||
Common.showDialogValidation(activity as NiveshFdMainActivity, message) | |||
} | |||
} | |||
is Resource.Loading -> { | |||
} | |||
is Resource.DataError -> { | |||
} | |||
} | |||
} | |||
} | |||
private fun docTypeApi() { | |||
val getCodeRequest = GetCodeRequest() | |||
getCodeRequest.ProductName = getString(R.string.bajajFD) | |||
getCodeRequest.Category = getString(R.string.docType) | |||
getCodeRequest.Language = getString(R.string.language) | |||
getCodeRequest.InputValue = "" | |||
(activity as NiveshFdMainActivity).viewModel.docTypeApi( | |||
getCodeRequest, | |||
PreferenceManager(activity as NiveshFdMainActivity).getToken(), | |||
activity as NiveshFdMainActivity | |||
) | |||
(activity as NiveshFdMainActivity).viewModel.getDocTypeMutableData.observe( | |||
viewLifecycleOwner | |||
) { response -> | |||
when (response) { | |||
is Resource.Success -> { | |||
Log.e("response", "-->$response") | |||
val getCodeResponse: GetCodeResponse = | |||
Gson().fromJson(response.data?.toString(), GetCodeResponse::class.java) | |||
getCodeResponse.Response.StatusCode.let { code -> | |||
when (code) { | |||
200 -> { | |||
listOfDocType = getCodeResponse.Response.GetCodesList | |||
if (listOfDocType.isNotEmpty()) { | |||
val adapter = ArrayAdapter( | |||
activity as NiveshFdMainActivity, | |||
R.layout.spinner_dropdown, | |||
listOfDocType | |||
) | |||
binding.spDocType.setAdapter(adapter) | |||
binding.spDocType.setText( | |||
adapter.getItem(0)?.Label, | |||
false | |||
) | |||
setOtherUploadLayout(adapter.getItem(0)?.Label) | |||
docValue = adapter.getItem(0)?.Label.toString() | |||
} | |||
} | |||
// 650 -> refreshToken() | |||
else -> { | |||
if (getCodeResponse.Response.Errors.isNotEmpty()) { | |||
Common.showDialogValidation( | |||
activity as NiveshFdMainActivity, | |||
getCodeResponse.Response.Errors[0].ErrorMessage | |||
) | |||
}else{ | |||
Common.showDialogValidation( | |||
activity as NiveshFdMainActivity, | |||
"".plus(getCodeResponse.Response.Message) | |||
) | |||
} | |||
} | |||
} | |||
} | |||
} | |||
is Resource.Error -> { | |||
response.message?.let { message -> | |||
Common.showDialogValidation(activity as NiveshFdMainActivity, message) | |||
} | |||
} | |||
is Resource.Loading -> { | |||
} | |||
is Resource.DataError -> { | |||
} | |||
} | |||
} | |||
} | |||
private fun validate(): Boolean { | |||
if (panString.isEmpty()) { | |||
Common.showDialogValidation( | |||
activity as NiveshFdMainActivity, | |||
getString(R.string.uploadPanDoc) | |||
) | |||
return false | |||
} else if (photoString.isEmpty()) { | |||
Common.showDialogValidation( | |||
activity as NiveshFdMainActivity, | |||
getString(R.string.uploadPhotoDoc) | |||
) | |||
return false | |||
} else if (docString.isEmpty()) { | |||
Common.showDialogValidation( | |||
activity as NiveshFdMainActivity, | |||
"Upload $docValue Document" | |||
) | |||
return false | |||
} else if (docValue == "Aadhar" && docString2.isEmpty()) { | |||
Common.showDialogValidation( | |||
activity as NiveshFdMainActivity, | |||
getString(R.string.uploadAadharBackDoc) | |||
) | |||
return false | |||
} | |||
return true | |||
} | |||
private fun takeImage() { | |||
lifecycleScope.launchWhenStarted { | |||
getTmpFileUri().let { uri -> | |||
latestTmpUri = uri | |||
takeImageResult?.launch(uri) | |||
} | |||
} | |||
} | |||
private fun getTmpFileUri(): Uri { | |||
val tmpFile = | |||
File.createTempFile("tmp_image_file", ".png", (activity as NiveshFdMainActivity).cacheDir).apply { | |||
createNewFile() | |||
deleteOnExit() | |||
} | |||
return FileProvider.getUriForFile( | |||
requireActivity(), | |||
"${BuildConfig.APPLICATION_ID}.provider", | |||
tmpFile | |||
) | |||
} | |||
private fun uriToBitmap(selectedFileUri: Uri): Bitmap? { | |||
try { | |||
val parcelFileDescriptor = | |||
requireActivity().contentResolver.openFileDescriptor(selectedFileUri, "r") | |||
val fileDescriptor: FileDescriptor = parcelFileDescriptor!!.fileDescriptor | |||
val image = BitmapFactory.decodeFileDescriptor(fileDescriptor) | |||
parcelFileDescriptor.close() | |||
return image | |||
} catch (e: IOException) { | |||
e.printStackTrace() | |||
} | |||
return null | |||
} | |||
override fun onDestroyView() { | |||
super.onDestroyView() | |||
_binding = null | |||
} | |||
} |
@ -1,15 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.ui.providerfactory | |||
import androidx.lifecycle.ViewModel | |||
import androidx.lifecycle.ViewModelProvider | |||
import com.nivesh.production.niveshfd.fd.repositories.MainRepository | |||
import com.nivesh.production.niveshfd.fd.viewModel.BajajFDViewModel | |||
class FDModelProviderFactory(private val mainRepository: MainRepository) : | |||
ViewModelProvider.Factory { | |||
override fun <T : ViewModel> create(modelClass: Class<T>): T { | |||
return BajajFDViewModel(mainRepository) as T | |||
} | |||
} |
@ -1,369 +0,0 @@ | |||
package com.nivesh.production.niveshfd.fd.viewModel | |||
import android.app.Activity | |||
import androidx.lifecycle.MutableLiveData | |||
import androidx.lifecycle.ViewModel | |||
import androidx.lifecycle.viewModelScope | |||
import com.google.gson.JsonObject | |||
import com.nivesh.production.niveshfd.fd.model.* | |||
import com.nivesh.production.niveshfd.fd.repositories.MainRepository | |||
import com.nivesh.production.niveshfd.fd.util.Common | |||
import com.nivesh.production.niveshfd.fd.util.Common.Companion.handleError | |||
import com.nivesh.production.niveshfd.fd.util.Common.Companion.handleResponse | |||
import com.nivesh.production.niveshfd.fd.util.Constants | |||
import com.nivesh.production.niveshfd.fd.util.Resource | |||
import kotlinx.coroutines.launch | |||
open class BajajFDViewModel(private val mainRepository: MainRepository) : ViewModel() { | |||
val getStepsCountMutableData: MutableLiveData<Resource<JsonObject>> = MutableLiveData() | |||
fun getStepsCount( | |||
requestBody: FDStepsCountRequest, | |||
token: String, | |||
activity: Activity | |||
) = viewModelScope.launch(handleError(activity)) { | |||
if (Common.isNetworkAvailable(activity)) { | |||
getStepsCountMutableData.postValue(Resource.Loading()) | |||
val response = mainRepository.getStepsCountResponse(requestBody, token) | |||
getStepsCountMutableData.postValue(handleResponse(response)) | |||
} | |||
} | |||
val getClientDetailsMutableData: MutableLiveData<Resource<JsonObject>> = MutableLiveData() | |||
fun getClientDetails(getClientDetailsRequest: getClientDetailsRequest, token: String, activity: Activity) = | |||
viewModelScope.launch(handleError(activity)) { | |||
if (Common.isNetworkAvailable(activity)) { | |||
getClientDetailsMutableData.postValue(Resource.Loading()) | |||
val response = | |||
mainRepository.getClientDetailsResponse(getClientDetailsRequest, token) | |||
getClientDetailsMutableData.postValue(handleResponse(response)) | |||
} | |||
} | |||
val getPaymentReQueryMutableData: MutableLiveData<Resource<JsonObject>> = MutableLiveData() | |||
fun getPaymentReQuery(requestBody: PaymentReQueryRequest, token : String, activity: Activity) = viewModelScope.launch(handleError(activity)) { | |||
if (Common.isNetworkAvailable(activity)) { | |||
getPaymentReQueryMutableData.postValue(Resource.Loading()) | |||
val response = mainRepository.paymentReQueryResponse(requestBody, token) | |||
getPaymentReQueryMutableData.postValue(handleResponse(response)) | |||
} | |||
} | |||
// Step 1 Api | |||
val getMinAmountMutableData: MutableLiveData<Resource<JsonObject>> = MutableLiveData() | |||
fun getMinAmount(requestBody: GetCodeRequest, token: String, activity: Activity) = | |||
viewModelScope.launch( | |||
handleError(activity) | |||
) { | |||
if (Common.isNetworkAvailable(activity)) { | |||
getMinAmountMutableData.postValue(Resource.Loading()) | |||
val response = mainRepository.getCodesResponse(requestBody, token) | |||
getMinAmountMutableData.postValue(handleResponse(response)) | |||
} | |||
} | |||
val getMaxAmountMutableData: MutableLiveData<Resource<JsonObject>> = MutableLiveData() | |||
fun getMaxAmount(requestBody: GetCodeRequest, token: String, activity: Activity) = | |||
viewModelScope.launch( | |||
handleError(activity) | |||
) { | |||
if (Common.isNetworkAvailable(activity)) { | |||
getMaxAmountMutableData.postValue(Resource.Loading()) | |||
val response = mainRepository.getCodesResponse(requestBody, token) | |||
getMaxAmountMutableData.postValue(handleResponse(response)) | |||
} | |||
} | |||
val getMaturityAmountMutableData: MutableLiveData<Resource<JsonObject>> = MutableLiveData() | |||
fun getMaturityAmount(requestBody: GetMaturityAmountRequest, activity: Activity, token: String) = | |||
viewModelScope.launch( | |||
handleError(activity) | |||
) { | |||
if (Common.isNetworkAvailable(activity)) { | |||
getMaturityAmountMutableData.postValue(Resource.Loading()) | |||
val response = mainRepository.createCalculateFDMaturityAmount(requestBody, token) | |||
getMaturityAmountMutableData.postValue(handleResponse(response)) | |||
} | |||
} | |||
val getRatesMutableData: MutableLiveData<Resource<JsonObject>> = MutableLiveData() | |||
fun getRates(getRatesRequest: GetRatesRequest, token: String, activity: Activity) = | |||
viewModelScope.launch( | |||
handleError(activity) | |||
) { | |||
if (Common.isNetworkAvailable(activity)) { | |||
getRatesMutableData.postValue(Resource.Loading()) | |||
val response = mainRepository.getRatesResponse(getRatesRequest, token) | |||
getRatesMutableData.postValue(handleResponse(response)) | |||
} | |||
} | |||
val getCodeMutableData: MutableLiveData<Resource<JsonObject>> = MutableLiveData() | |||
fun getCode(requestBody: GetCodeRequest, token: String, activity: Activity) = | |||
viewModelScope.launch( | |||
handleError(activity) | |||
) { | |||
if (Common.isNetworkAvailable(activity)) { | |||
getCodeMutableData.postValue(Resource.Loading()) | |||
val response = mainRepository.getCodesResponse(requestBody, token) | |||
getCodeMutableData.postValue(handleResponse(response)) | |||
} | |||
} | |||
// Step 2 | |||
val getFDKYCMutableData: MutableLiveData<Resource<JsonObject>> = MutableLiveData() | |||
fun checkFDKYC(requestBody: CheckFDKYCRequest, token : String, activity: Activity) = viewModelScope.launch(handleError(activity)) { | |||
if (Common.isNetworkAvailable(activity)) { | |||
getFDKYCMutableData.postValue(Resource.Loading()) | |||
val response = mainRepository.checkFDKYCRequest(requestBody, token) | |||
getFDKYCMutableData.postValue(handleResponse(response)) | |||
} | |||
} | |||
val getTitleMutableData: MutableLiveData<Resource<JsonObject>> = MutableLiveData() | |||
fun titleApi(getCodeRequest: GetCodeRequest, token: String, activity : Activity) = viewModelScope.launch( | |||
handleError(activity) | |||
) { | |||
if (Common.isNetworkAvailable(activity)) { | |||
getTitleMutableData.postValue(Resource.Loading()) | |||
val response = mainRepository.titleCheck(getCodeRequest, token) | |||
getTitleMutableData.postValue(handleResponse(response)) | |||
} | |||
} | |||
val getGenderMutableData: MutableLiveData<Resource<JsonObject>> = MutableLiveData() | |||
fun genderApi(getCodeRequest: GetCodeRequest, token: String,activity : Activity) = viewModelScope.launch( | |||
handleError(activity) | |||
) { | |||
if (Common.isNetworkAvailable(activity)) { | |||
getGenderMutableData.postValue(Resource.Loading()) | |||
val response = mainRepository.genderCheck(getCodeRequest, token) | |||
getGenderMutableData.postValue(handleResponse(response)) | |||
} | |||
} | |||
val getAnnualIncomeMutableData: MutableLiveData<Resource<JsonObject>> = MutableLiveData() | |||
fun annualIncomeApi(getCodeRequest: GetCodeRequest, token: String,activity : Activity) = viewModelScope.launch( | |||
handleError(activity) | |||
) { | |||
if (Common.isNetworkAvailable(activity)) { | |||
getAnnualIncomeMutableData.postValue(Resource.Loading()) | |||
val response = mainRepository.annualIncomeCheck(getCodeRequest, token) | |||
getAnnualIncomeMutableData.postValue(handleResponse(response)) | |||
} | |||
} | |||
val getRelationShipMutableData: MutableLiveData<Resource<JsonObject>> = MutableLiveData() | |||
fun relationShipApi(getCodeRequest: GetCodeRequest, token: String,activity : Activity) = viewModelScope.launch( | |||
handleError(activity) | |||
) { | |||
if (Common.isNetworkAvailable(activity)) { | |||
getRelationShipMutableData.postValue(Resource.Loading()) | |||
val response = mainRepository.relationShipCheck(getCodeRequest, token) | |||
getRelationShipMutableData.postValue(handleResponse(response)) | |||
} | |||
} | |||
val getMaritalStatusMutableData: MutableLiveData<Resource<JsonObject>> = MutableLiveData() | |||
fun maritalStatusApi(getCodeRequest: GetCodeRequest, token: String,activity : Activity) = viewModelScope.launch( | |||
handleError(activity) | |||
) { | |||
if (Common.isNetworkAvailable(activity)) { | |||
getMaritalStatusMutableData.postValue(Resource.Loading()) | |||
val response = mainRepository.maritalStatusCheck(getCodeRequest, token) | |||
getMaritalStatusMutableData.postValue(handleResponse(response)) | |||
} | |||
} | |||
val getOccupationMutableData: MutableLiveData<Resource<JsonObject>> = MutableLiveData() | |||
fun occupationApi(getCodeRequest: GetCodeRequest, token: String,activity : Activity) = viewModelScope.launch( | |||
handleError(activity) | |||
) { | |||
if (Common.isNetworkAvailable(activity)) { | |||
getOccupationMutableData.postValue(Resource.Loading()) | |||
val response = mainRepository.occupationCheck(getCodeRequest, token) | |||
getOccupationMutableData.postValue(handleResponse(response)) | |||
} | |||
} | |||
val getStateMasterMutableData: MutableLiveData<Resource<JsonObject>> = MutableLiveData() | |||
fun stateApi(token: String,activity : Activity) = viewModelScope.launch( | |||
handleError(activity) | |||
) { | |||
if (Common.isNetworkAvailable(activity)) { | |||
getStateMasterMutableData.postValue(Resource.Loading()) | |||
val response = mainRepository.stateCheck(token) | |||
getStateMasterMutableData.postValue(handleResponse(response)) | |||
} | |||
} | |||
val getCityListMutableData: MutableLiveData<Resource<JsonObject>> = MutableLiveData() | |||
fun cityListApi(cityRequest: CityRequest, token: String,activity : Activity) = viewModelScope.launch( | |||
handleError(activity) | |||
) { | |||
if (Common.isNetworkAvailable(activity)) { | |||
getCityListMutableData.postValue(Resource.Loading()) | |||
val response = mainRepository.cityCheck(cityRequest, token) | |||
getCityListMutableData.postValue(handleResponse(response)) | |||
} | |||
} | |||
val getFDBankListMutableData: MutableLiveData<Resource<JsonObject>> = MutableLiveData() | |||
fun bankListApi( token: String,language: String, activity : Activity) = viewModelScope.launch( | |||
handleError(activity) | |||
) { | |||
if (Common.isNetworkAvailable(activity)) { | |||
getFDBankListMutableData.postValue(Resource.Loading()) | |||
val response = mainRepository.bankListCheck(token, language) | |||
getFDBankListMutableData.postValue(handleResponse(response)) | |||
} | |||
} | |||
val getIfscCodeCheckMutableData: MutableLiveData<Resource<JsonObject>> = MutableLiveData() | |||
fun ifscCodeApi(ifsc : String,activity : Activity) = viewModelScope.launch( | |||
handleError(activity) | |||
) { | |||
if (Common.isNetworkAvailable(activity)) { | |||
getIfscCodeCheckMutableData.postValue(Resource.Loading()) | |||
val response = mainRepository.ifscCodeCheck(ifsc) | |||
getIfscCodeCheckMutableData.postValue(handleResponse(response)) | |||
} | |||
} | |||
val getIfscCodeDetailsCheckMutableData: MutableLiveData<Resource<String>> = MutableLiveData() | |||
fun ifscCodeDetailsApi(ifsc : String,activity : Activity, token:String) = viewModelScope.launch( | |||
handleError(activity) | |||
) { | |||
if (Common.isNetworkAvailable(activity)) { | |||
getIfscCodeDetailsCheckMutableData.postValue(Resource.Loading()) | |||
val response = mainRepository.ifscCodeBankDetailsCheck(ifsc, token) | |||
getIfscCodeDetailsCheckMutableData.postValue(Common.handleResponse1(response)) | |||
} | |||
} | |||
val getPaymentModeMutableData: MutableLiveData<Resource<JsonObject>> = MutableLiveData() | |||
fun paymentModeApi(getCodeRequest: GetCodeRequest, token: String,activity : Activity) = viewModelScope.launch( | |||
handleError(activity) | |||
) { | |||
if (Common.isNetworkAvailable(activity)) { | |||
getPaymentModeMutableData.postValue(Resource.Loading()) | |||
val response = mainRepository.payModeCheck(getCodeRequest, token) | |||
getPaymentModeMutableData.postValue(handleResponse(response)) | |||
} | |||
} | |||
val getFDResponseMutableData: MutableLiveData<Resource<JsonObject>> = MutableLiveData() | |||
fun createFDApi(getRatesRequest: CreateFDRequest, token: String,activity : Activity) = viewModelScope.launch( | |||
handleError(activity) | |||
) { | |||
if (Common.isNetworkAvailable(activity)) { | |||
getFDResponseMutableData.postValue(Resource.Loading()) | |||
val response = mainRepository.createFDKYCResponse(getRatesRequest, token) | |||
getFDResponseMutableData.postValue(handleResponse(response)) | |||
} | |||
} | |||
val bankValidationApiMutableData: MutableLiveData<Resource<JsonObject>> = MutableLiveData() | |||
fun bankValidationApi(bankValidationApiRequest : BankValidationApiRequest,token:String,activity : Activity) = viewModelScope.launch( | |||
handleError(activity) | |||
) { | |||
if (Common.isNetworkAvailable(activity)) { | |||
bankValidationApiMutableData.postValue(Resource.Loading()) | |||
val response = mainRepository.bankValidationApiRequest(bankValidationApiRequest,token) | |||
bankValidationApiMutableData.postValue(handleResponse(response)) | |||
} | |||
} | |||
// Step 3 | |||
val getDocTypeMutableData: MutableLiveData<Resource<JsonObject>> = MutableLiveData() | |||
fun docTypeApi(getCodeRequest: GetCodeRequest, token: String, activity : Activity) = viewModelScope.launch( | |||
handleError(activity) | |||
) { | |||
if (Common.isNetworkAvailable(activity)) { | |||
getDocTypeMutableData.postValue(Resource.Loading()) | |||
val response = mainRepository.titleCheck(getCodeRequest, token) | |||
getDocTypeMutableData.postValue(handleResponse(response)) | |||
} | |||
} | |||
val getDocumentUploadMutableData: MutableLiveData<Resource<JsonObject>> = MutableLiveData() | |||
fun documentsUpload(documentUpload: DocumentUpload, token: String, activity: Activity) = viewModelScope.launch( | |||
handleError(activity) | |||
) { | |||
if (Common.isNetworkAvailable(activity)) { | |||
getDocumentUploadMutableData.postValue(Resource.Loading()) | |||
val response = mainRepository.documentsUploadResponse(documentUpload, token) | |||
getDocumentUploadMutableData.postValue(handleResponse(response)) | |||
} | |||
} | |||
// Step 4 | |||
val getFDDetailsMutableData: MutableLiveData<Resource<JsonObject>> = MutableLiveData() | |||
fun getFDDetails(getRatesRequest: GetFDDetailsRequest, token: String, | |||
activity: Activity) = viewModelScope.launch(handleError(activity)) { | |||
if (Common.isNetworkAvailable(activity)) { | |||
getFDDetailsMutableData.postValue(Resource.Loading()) | |||
val response = mainRepository.getFDDetailsResponse(getRatesRequest, token) | |||
getFDDetailsMutableData.postValue(handleResponse(response)) | |||
} | |||
} | |||
val getFDOtherMutableData: MutableLiveData<Resource<JsonObject>> = MutableLiveData() | |||
fun saveFDOtherData(getRatesRequest: SaveFDOtherDataRequest, token: String, | |||
activity: Activity) = viewModelScope.launch(handleError(activity)) { | |||
if (Common.isNetworkAvailable(activity)) { | |||
getFDOtherMutableData.postValue(Resource.Loading()) | |||
val response = mainRepository.saveFDOtherDataResponse(getRatesRequest, token) | |||
getFDOtherMutableData.postValue(handleResponse(response)) | |||
} | |||
} | |||
val customerListMutableData: MutableLiveData<Resource<JsonObject>> = MutableLiveData() | |||
fun customerListApi(getCodeRequest: GetCodeRequest, token: String,activity : Activity) = viewModelScope.launch( | |||
handleError(activity) | |||
) { | |||
if (Common.isNetworkAvailable(activity)) { | |||
customerListMutableData.postValue(Resource.Loading()) | |||
val response = mainRepository.customerListCheck(getCodeRequest, token) | |||
customerListMutableData.postValue(handleResponse(response)) | |||
} | |||
} | |||
fun updateFDPaymentStatus(getRatesRequest: GetRatesRequest, token: String, | |||
activity: Activity | |||
) = | |||
viewModelScope.launch(handleError(activity)) { | |||
if (Common.isNetworkAvailable(activity)) { | |||
getRatesMutableData.postValue(Resource.Loading()) | |||
val response = mainRepository.updateFDPaymentStatusResponse(getRatesRequest, token) | |||
getRatesMutableData.postValue(handleResponse(response)) | |||
} | |||
} | |||
val getFinalizeFDMutableData: MutableLiveData<Resource<JsonObject>> = MutableLiveData() | |||
fun finaliseFD(finalizeFDRequest: FinalizeFDRequest, token: String, | |||
activity: Activity) = viewModelScope.launch(handleError(activity)) { | |||
if (Common.isNetworkAvailable(activity)) { | |||
getFinalizeFDMutableData.postValue(Resource.Loading()) | |||
val response = mainRepository.finaliseFDResponse(finalizeFDRequest, token) | |||
getFinalizeFDMutableData.postValue(handleResponse(response)) | |||
} | |||
} | |||
val getFinalizeKYCMutableData: MutableLiveData<Resource<JsonObject>> = MutableLiveData() | |||
fun finaliseKYC(getRatesRequest: FinalizeKYCRequest, token: String, | |||
activity: Activity) = viewModelScope.launch(handleError(activity)) { | |||
if (Common.isNetworkAvailable(activity)) { | |||
getFinalizeKYCMutableData.postValue(Resource.Loading()) | |||
val response = mainRepository.finaliseKYCResponse(getRatesRequest, token) | |||
getFinalizeKYCMutableData.postValue(handleResponse(response)) | |||
} | |||
} | |||
} |
Powered by TurnKey Linux.