commit 2c2a417245fc491a8978dce8625e28dcd76e8325 Author: akashgori Date: Tue Jan 10 18:05:07 2023 +0530 asd diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d740922 --- /dev/null +++ b/.gitignore @@ -0,0 +1,39 @@ +#built application files +*.apk +*.ap_ + +# files for the dex VM +*.dex + +# Java class files +*.class + +# generated files +bin/ +gen/ + +# Local configuration file (sdk path, etc) +local.properties + +# Windows thumbnail db +Thumbs.db + +# OSX files +.DS_Store + +# Android Studio +*.iml +.idea +#.idea/workspace.xml - remove # and delete .idea if it better suit your needs. +.gradle +build/ +.navigation +captures/ +output.json + +#NDK +obj/ +.externalNativeBuild + + + diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..5727a72 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,93 @@ +plugins { + id 'com.android.application' + id 'org.jetbrains.kotlin.android' + id 'kotlin-parcelize' + id 'maven-publish' +} + +publishing { + publications { + mavenJava(MavenPublication) { + groupId = 'com.nivesh.production.bajajfd.Manoj.Singh' + artifactId = 'library' + version = '1.0' + } + } +} + +android { + namespace 'com.nivesh.production.bajajfd' + compileSdk 33 + + defaultConfig { + applicationId "com.nivesh.production.bajajfd" + minSdk 21 + targetSdk 33 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + consumerProguardFiles 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = '1.8' + } + + buildFeatures { + viewBinding true + } +} + +ext{ + roomVersion="2.4.3" + glideVersion="4.11.0" +} + +dependencies { + + implementation 'androidx.core:core-ktx:1.9.0' + implementation 'androidx.appcompat:appcompat:1.5.1' + implementation 'com.google.android.material:material:1.7.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' + implementation 'androidx.legacy:legacy-support-v4:1.0.0' + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.5.1' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + + // Architectural Components + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1" + + // Coroutines + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + + // Coroutine Lifecycle Scopes + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1" + implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.5.1" + //test + + // Retrofit + implementation 'com.squareup.retrofit2:retrofit:2.9.0' + implementation 'com.squareup.retrofit2:converter-gson:2.9.0' + implementation "com.squareup.okhttp3:logging-interceptor:4.7.2" + + // Navigation Components + implementation "androidx.navigation:navigation-fragment-ktx:2.5.3" + implementation "androidx.navigation:navigation-ui-ktx:2.5.3" + + //Preference + implementation 'androidx.preference:preference:1.2.0' + +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/app/src/androidTest/java/com/nivesh/production/bajajfd/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/nivesh/production/bajajfd/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..5307e6e --- /dev/null +++ b/app/src/androidTest/java/com/nivesh/production/bajajfd/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.nivesh.production.bajajfd + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.nivesh.production.bajajfd", appContext.packageName) + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..8bcec28 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/BajajApplication.kt b/app/src/main/java/com/nivesh/production/bajajfd/BajajApplication.kt new file mode 100644 index 0000000..d7f71fe --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/BajajApplication.kt @@ -0,0 +1,17 @@ +package com.nivesh.production.bajajfd + +import android.app.Application +import android.content.Context + +class BajajApplication : Application() { + private var mInstance: BajajApplication? = null + companion object { + var appContext: Context? = null + } + override fun onCreate() { + super.onCreate() + mInstance = this + appContext = applicationContext + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/adapter/BankListAdapter.kt b/app/src/main/java/com/nivesh/production/bajajfd/adapter/BankListAdapter.kt new file mode 100644 index 0000000..ee521eb --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/adapter/BankListAdapter.kt @@ -0,0 +1,83 @@ +package com.nivesh.production.bajajfd.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.bajajfd.R +import com.nivesh.production.bajajfd.model.ClientBanklist + +class BankListAdapter( + private val bankList: List?, + private val selectedAccount: String? = null, + private val width: Double? +) : RecyclerView.Adapter() { + 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 + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/adapter/CustomerListAdapter.kt b/app/src/main/java/com/nivesh/production/bajajfd/adapter/CustomerListAdapter.kt new file mode 100644 index 0000000..40e48d5 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/adapter/CustomerListAdapter.kt @@ -0,0 +1,47 @@ +package com.nivesh.production.bajajfd.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.bajajfd.R +import com.nivesh.production.bajajfd.model.GetCodes + +class CustomerListAdapter( + private val customerList: MutableList? +) : RecyclerView.Adapter() { + 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 + holder.tvCustomerName.setOnCheckedChangeListener { _, isChecked -> + cList.isSelected = isChecked + } + } + } + + override fun getItemCount(): Int { + return customerList?.size!! + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/adapter/DisableAdapter.kt b/app/src/main/java/com/nivesh/production/bajajfd/adapter/DisableAdapter.kt new file mode 100644 index 0000000..d900477 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/adapter/DisableAdapter.kt @@ -0,0 +1,24 @@ +package com.nivesh.production.bajajfd.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 + } +} diff --git a/app/src/main/java/com/nivesh/production/bajajfd/adapter/HorizontalRecyclerViewAdapter.kt b/app/src/main/java/com/nivesh/production/bajajfd/adapter/HorizontalRecyclerViewAdapter.kt new file mode 100644 index 0000000..311fdf1 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/adapter/HorizontalRecyclerViewAdapter.kt @@ -0,0 +1,124 @@ +package com.nivesh.production.bajajfd.adapter + +import 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.bajajfd.R +import com.nivesh.production.bajajfd.adapter.HorizontalRecyclerViewAdapter.HistoryAdapterViewHolder2 +import com.nivesh.production.bajajfd.interfaces.OnClickListener + + +class HorizontalRecyclerViewAdapter( + private val activity: Activity, + dropdownList: MutableList, + onClickListener: OnClickListener +) : RecyclerView.Adapter() { + private var dropdownList: MutableList + 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_line, + 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() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/adapter/PaymentModeAdapter.kt b/app/src/main/java/com/nivesh/production/bajajfd/adapter/PaymentModeAdapter.kt new file mode 100644 index 0000000..bde88fd --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/adapter/PaymentModeAdapter.kt @@ -0,0 +1,94 @@ +package com.nivesh.production.bajajfd.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.bajajfd.R +import com.nivesh.production.bajajfd.model.GetCodes + +class PaymentModeAdapter( + private val bankList: List?, + private val selectedAccount: String? = null +) : RecyclerView.Adapter() { + 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 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 bankList = bankList?.get(position) + if (bankList != null) { + holder.itemView.apply { + holder.tvBankName.text = bankList.Value + if (bankList.Value.equals("UPI")){ + holder.tvUpiMsg.text = context.getString(R.string.upto1LakhOnly) + }else{ + holder.tvUpiMsg.text = "" + } + + if (selectedAccount == bankList.Value && 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) + } + + setOnClickListener { + onItemClickListener?.let { + it(bankList) + + 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: ((GetCodes) -> Unit)? = null + + fun setOnItemClickListener(listener: (GetCodes) -> Unit) { + onItemClickListener = listener + } + + + fun getSelected(): GetCodes? { + return if (checkedPosition != -1) { + bankList?.get(checkedPosition) + } else null + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/adapter/RecommendedBankListAdapter.kt b/app/src/main/java/com/nivesh/production/bajajfd/adapter/RecommendedBankListAdapter.kt new file mode 100644 index 0000000..4b12412 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/adapter/RecommendedBankListAdapter.kt @@ -0,0 +1,39 @@ +package com.nivesh.production.bajajfd.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.bajajfd.R +import com.nivesh.production.bajajfd.model.Bank + +class RecommendedBankListAdapter( + private val bankList: List +) : RecyclerView.Adapter() { + + class MyViewHolder(view: View) : RecyclerView.ViewHolder(view) { + val txtYear: TextView + + init { + txtYear = 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 + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/adapter/SectionsPagerAdapter.kt b/app/src/main/java/com/nivesh/production/bajajfd/adapter/SectionsPagerAdapter.kt new file mode 100644 index 0000000..b795476 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/adapter/SectionsPagerAdapter.kt @@ -0,0 +1,18 @@ +package com.nivesh.production.bajajfd.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter + + +class SectionsPagerAdapter(manager: FragmentManager,private val fragments: Array) : FragmentPagerAdapter(manager, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { + + private val titles = ArrayList() + + override fun getItem(position: Int): Fragment = fragments[position] + + override fun getCount(): Int = fragments.size + + override fun getPageTitle(position: Int): CharSequence = titles[position] + +} \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/api/ApiCallback.kt b/app/src/main/java/com/nivesh/production/bajajfd/api/ApiCallback.kt new file mode 100644 index 0000000..308a41f --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/api/ApiCallback.kt @@ -0,0 +1,35 @@ +package com.nivesh.production.bajajfd.api + +import com.nivesh.production.bajajfd.util.Resource +import retrofit2.Call +import retrofit2.Callback +import retrofit2.Response + +abstract class ApiCallback : Callback> { + + abstract fun onSuccess(response: Resource) + + abstract fun onFailure(response: Resource) + + override fun onResponse(call: Call>, response: Response>) { + if (response.isSuccessful && response.body() != null && response.code() == 200) { + onSuccess(response.body()!!) + } else { + // handle 4xx & 5xx error codes here +// val resp = Resource() +// resp.status = false +// resp.message = response.message() +// onFailure(resp) + + + + } + } + + override fun onFailure(call: Call>, t: Throwable) { +// val response = Resource() +// response.status = false +// response.message = t.message.toString() +// onFailure(response) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/api/ApiClient.kt b/app/src/main/java/com/nivesh/production/bajajfd/api/ApiClient.kt new file mode 100644 index 0000000..0d70dc4 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/api/ApiClient.kt @@ -0,0 +1,65 @@ +package com.nivesh.production.bajajfd.api + +import com.nivesh.production.bajajfd.BajajApplication +import com.nivesh.production.bajajfd.interfaces.ApiInterface +import com.nivesh.production.bajajfd.util.Constants.Companion.BASE_URL +import okhttp3.OkHttpClient +import okhttp3.logging.HttpLoggingInterceptor +import retrofit2.Retrofit +import retrofit2.converter.gson.GsonConverterFactory +import java.security.KeyStore +import java.util.* +import java.util.concurrent.TimeUnit +import javax.net.ssl.* + +class ApiClient { + val context = BajajApplication.appContext + + companion object { + private val client by lazy { + //lazy means we only initialize this here once + val logging = HttpLoggingInterceptor() + //loggingInterceptor use for see making request and for see what responses are + logging.setLevel(HttpLoggingInterceptor.Level.BODY) + //see the body of response + //create client for retrofit + + val trustManagerFactory: TrustManagerFactory = + TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()) + trustManagerFactory.init(null as KeyStore?) + val trustManagers: Array = trustManagerFactory.getTrustManagers() + check(!(trustManagers.size != 1 || trustManagers[0] !is X509TrustManager)) { + "Unexpected default trust managers:" + Arrays.toString( + trustManagers + ) + } + val trustManager: X509TrustManager = trustManagers[0] as X509TrustManager + val sslContext = SSLContext.getInstance("SSL") + sslContext.init(null, arrayOf(trustManager), null) + val sslSocketFactory: SSLSocketFactory = sslContext.socketFactory + + val client = OkHttpClient.Builder() + .addInterceptor(logging) + .sslSocketFactory(sslSocketFactory, trustManager) + .retryOnConnectionFailure(true) + .callTimeout(2, TimeUnit.MINUTES) + .connectTimeout(20, TimeUnit.SECONDS) + .readTimeout(30, TimeUnit.SECONDS) + .writeTimeout(30, TimeUnit.SECONDS) + .build() + + Retrofit.Builder() + .baseUrl(BASE_URL) + .addConverterFactory(GsonConverterFactory.create()) + .client(client) + .build() + } + val getApiClient: ApiInterface by lazy { + client.create(ApiInterface::class.java) + } + } +} + + + + diff --git a/app/src/main/java/com/nivesh/production/bajajfd/api/TokenAuthenticator.kt b/app/src/main/java/com/nivesh/production/bajajfd/api/TokenAuthenticator.kt new file mode 100644 index 0000000..204cf9d --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/api/TokenAuthenticator.kt @@ -0,0 +1,19 @@ +package com.nivesh.production.bajajfd.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(); +// +// +// } +} \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/interfaces/ApiInterface.kt b/app/src/main/java/com/nivesh/production/bajajfd/interfaces/ApiInterface.kt new file mode 100644 index 0000000..b066f1e --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/interfaces/ApiInterface.kt @@ -0,0 +1,180 @@ +package com.nivesh.production.bajajfd.interfaces + +import com.google.gson.JsonObject +import com.nivesh.production.bajajfd.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 + + @POST("CheckFDCKYC") + suspend fun checkFDKYC( + @Body checkFDKYCRequest: CheckFDKYCRequest, + @Header("token") token: String + ): Response + + @POST("CreateFDApplication") + suspend fun createFDApp( + @Body createFDRequest: CreateFDRequest, + @Header("token") token: String + ): Response + + @POST("DocumentsUpload") + suspend fun documentsUpload( + @Body requestBody: DocumentUpload, + @Header("token") token: String + ): Response + + @POST("SaveFDOtherData") + suspend fun saveFDOtherData( + @Body requestBody: SaveFDOtherDataRequest, + @Header("token") token: String + ): Response + + @POST("GetFDDetails") + suspend fun getFDDetails( + @Body requestBody: GetFDDetailsRequest, + @Header("token") token: String + ): Response + + @POST("UpdateFDPaymentStatus") + suspend fun updateFDPaymentStatus( + @Body requestBody: RequestBody, + @Header("token") token: String + ): Response + + @POST("FinaliseFD") + suspend fun finaliseFD( + @Body requestBody: FinalizeFDRequest, + @Header("token") token: String + ): Response + + @POST("FinaliseKYC") + suspend fun finaliseKYC( + @Body requestBody: FinalizeKYCRequest, + @Header("token") token: String + ): Response + + @POST("PaymentRequery") + suspend fun paymentReQuery( + @Body requestBody: PaymentReQueryRequest, + @Header("token") token: String + ): Response + + // @FormUrlEncoded + @POST("GetCodes") + suspend fun getCodes( + @Body requestBody: GetCodeRequest, + @Header("token") token: String + ): Response + + @POST("CalculateFDMaturityAmount") + suspend fun getCalculateFDMaturityAmount( + @Body requestBody: GetMaturityAmountRequest, + @Header("token") token: String + ): Response + + @POST("PanCheck_S") + suspend fun panCheckApi( + @Body panCheck: PanCheckRequest, + @Header("token") token: String + ): Response + + @POST("getFDStepsCount") + suspend fun getFDStepsCount( + @Body fdStepsCountRequest: FDStepsCountRequest, + @Header("token") token: String + ): Response + + @POST("GetClientDetailV2_S") + suspend fun getClientDetails( + @Body getClientDetailsRequest: getClientDetailsRequest, + @Header("token") token: String + ): Response + + + @POST("GetCodes") + suspend fun titleApi( + @Body getCodeRequest: GetCodeRequest, + @Header("token") token: String + ): Response + + @POST("GetCodes") + suspend fun genderApi( + @Body getCodeRequest: GetCodeRequest, + @Header("token") token: String + ): Response + + @POST("GetCodes") + suspend fun annualIncomeApi( + @Body getCodeRequest: GetCodeRequest, + @Header("token") token: String + ): Response + + @POST("GetCodes") + suspend fun relationShipApi( + @Body getCodeRequest: GetCodeRequest, + @Header("token") token: String + ): Response + + @POST("GetCodes") + suspend fun maritalStatusApi( + @Body getCodeRequest: GetCodeRequest, + @Header("token") token: String + ): Response + + @POST("GetCodes") + suspend fun occupationApi( + @Body getCodeRequest: GetCodeRequest, + @Header("token") token: String + ): Response + + @POST("GetStateMaster") + suspend fun stateApi(@Header("token") token: String): Response + + @POST("GetCity") + suspend fun cityApi( + @Body cityRequest: CityRequest, + @Header("token") token: String + ): Response + + @GET("GetFDBankList?FDProvider=Bajaj") + suspend fun bankListApi(@Header("token") token: String, @Query("Language") language : String): Response + + @GET("GetIFSC_Autofill?") + suspend fun getIFSCApi(@Query("prefix") ifsc : String): Response + + @GET("GetbankNames") + suspend fun getIFSCBankDetailsApi(@Query( "bankname") ifsc : String, @Header("token") token: String): Response + + @POST("GetCodes") + suspend fun payModeApi( + @Body getCodeRequest: GetCodeRequest, + @Header("token") token: String + ): Response + + @POST("GetCodes") + suspend fun customerListApi( + @Body getCodeRequest: GetCodeRequest, + @Header("token") token: String + ): Response + + @POST("BankValidationAPI_S") + suspend fun bankValidationApi( + @Body bankValidationApiRequest: BankValidationApiRequest, + @Header("token") token: String + ): Response + + @POST("GetToken_V2") + suspend fun freshToken( + @Body requestBody: RequestBody + ):Response + +} \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/interfaces/OnClickListener.java b/app/src/main/java/com/nivesh/production/bajajfd/interfaces/OnClickListener.java new file mode 100644 index 0000000..2ca2e60 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/interfaces/OnClickListener.java @@ -0,0 +1,5 @@ +package com.nivesh.production.bajajfd.interfaces; + +public interface OnClickListener { + void onclickCategory(int position); +} diff --git a/app/src/main/java/com/nivesh/production/bajajfd/interfaces/SendData.kt b/app/src/main/java/com/nivesh/production/bajajfd/interfaces/SendData.kt new file mode 100644 index 0000000..13fecab --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/interfaces/SendData.kt @@ -0,0 +1,8 @@ +package com.nivesh.production.bajajfd.interfaces + +import com.nivesh.production.bajajfd.model.CreateFDApplicationResponse + +interface SendData { + fun sendDataFragment(message: CreateFDApplicationResponse) + fun sendDataFragmentStepFour(message: CreateFDApplicationResponse) +} \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/ApplicantDetails.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/ApplicantDetails.kt new file mode 100644 index 0000000..3d28613 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/ApplicantDetails.kt @@ -0,0 +1,24 @@ +package com.nivesh.production.bajajfd.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 +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/ApplicantRelationDetails.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/ApplicantRelationDetails.kt new file mode 100644 index 0000000..91eff1b --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/ApplicantRelationDetails.kt @@ -0,0 +1,10 @@ +package com.nivesh.production.bajajfd.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 +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/Bank.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/Bank.kt new file mode 100644 index 0000000..b0a0931 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/Bank.kt @@ -0,0 +1,6 @@ +package com.nivesh.production.bajajfd.model + +data class Bank( + val BankName: String, + val IFSC4Mapping: String +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/BankList.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/BankList.kt new file mode 100644 index 0000000..ea6bfe9 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/BankList.kt @@ -0,0 +1,15 @@ +package com.nivesh.production.bajajfd.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 + + diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/BankValidationApiRequest.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/BankValidationApiRequest.kt new file mode 100644 index 0000000..0b6ae56 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/BankValidationApiRequest.kt @@ -0,0 +1,10 @@ +package com.nivesh.production.bajajfd.model + +data class BankValidationApiRequest( + var BankAccountNo: String?="", + var BankNo: Int?= 0, + var IFSC: String?= "", + var Name: String? = "", + var PhoneNo: String? = "", + var RoleId: Int? = 0 +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/BankValidationApiResponse.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/BankValidationApiResponse.kt new file mode 100644 index 0000000..ef516a9 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/BankValidationApiResponse.kt @@ -0,0 +1,8 @@ +package com.nivesh.production.bajajfd.model + +data class BankValidationApiResponse( + val DataObject: Any, + val Message: String, + val ObjectResponse: Any, + val response: ResponseXXXXXXXXXXXXXX +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/CheckFDKYCRequest.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/CheckFDKYCRequest.kt new file mode 100644 index 0000000..ad4924a --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/CheckFDKYCRequest.kt @@ -0,0 +1,8 @@ +package com.nivesh.production.bajajfd.model + +data class CheckFDKYCRequest( + var DOB: String? ="", + var Mobile: String? = "", + var NiveshClientCode: String? = "", + var PAN: String?= "" +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/CityListResponse.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/CityListResponse.kt new file mode 100644 index 0000000..c14725a --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/CityListResponse.kt @@ -0,0 +1,6 @@ +package com.nivesh.production.bajajfd.model + +data class CityListResponse( + val DataObject: List, + val response: ResponseXXXXXX +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/CityRequest.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/CityRequest.kt new file mode 100644 index 0000000..9c20f7a --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/CityRequest.kt @@ -0,0 +1,15 @@ +package com.nivesh.production.bajajfd.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 +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/ClientBanklist.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/ClientBanklist.kt new file mode 100644 index 0000000..04a1ed1 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/ClientBanklist.kt @@ -0,0 +1,11 @@ +package com.nivesh.production.bajajfd.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 +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/ClientDetails.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/ClientDetails.kt new file mode 100644 index 0000000..38c73cd --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/ClientDetails.kt @@ -0,0 +1,22 @@ +package com.nivesh.production.bajajfd.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 +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/ClientMasterMFD.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/ClientMasterMFD.kt new file mode 100644 index 0000000..dfcfec8 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/ClientMasterMFD.kt @@ -0,0 +1,40 @@ +package com.nivesh.production.bajajfd.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, + val ParentName: String, + val ums_id: String +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/CreateFDApplicationRequest.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/CreateFDApplicationRequest.kt new file mode 100644 index 0000000..a5c8d1e --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/CreateFDApplicationRequest.kt @@ -0,0 +1,10 @@ +package com.nivesh.production.bajajfd.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 +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/CreateFDApplicationResponse.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/CreateFDApplicationResponse.kt new file mode 100644 index 0000000..3465640 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/CreateFDApplicationResponse.kt @@ -0,0 +1,5 @@ +package com.nivesh.production.bajajfd.model + +data class CreateFDApplicationResponse( + val Response: ResponseXXXXXXXXXXX +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/CreateFDRequest.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/CreateFDRequest.kt new file mode 100644 index 0000000..3921974 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/CreateFDRequest.kt @@ -0,0 +1,5 @@ +package com.nivesh.production.bajajfd.model + +data class CreateFDRequest( + var CreateFDApplicationRequest: CreateFDApplicationRequest? = null +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/DataObject.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/DataObject.kt new file mode 100644 index 0000000..bdf0cbb --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/DataObject.kt @@ -0,0 +1,17 @@ +package com.nivesh.production.bajajfd.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() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/DataObjectX.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/DataObjectX.kt new file mode 100644 index 0000000..7599a9d --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/DataObjectX.kt @@ -0,0 +1,10 @@ +package com.nivesh.production.bajajfd.model + +data class DataObjectX( + val city_id: Int, + val city_name: String +) { + override fun toString(): String { + return city_name + } +} \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/DeviceInfo.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/DeviceInfo.kt new file mode 100644 index 0000000..d7b0b88 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/DeviceInfo.kt @@ -0,0 +1,12 @@ +package com.nivesh.production.bajajfd.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? = "" +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/DocumentUpload.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/DocumentUpload.kt new file mode 100644 index 0000000..e0f8154 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/DocumentUpload.kt @@ -0,0 +1,10 @@ +package com.nivesh.production.bajajfd.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 +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/Errors.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/Errors.kt new file mode 100644 index 0000000..a2c80e2 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/Errors.kt @@ -0,0 +1,6 @@ +package com.nivesh.production.bajajfd.model + +data class Errors( + val ErrorCode: Int, + val ErrorMessage: String +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/FDCreationDetailsResponse.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/FDCreationDetailsResponse.kt new file mode 100644 index 0000000..2d4524c --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/FDCreationDetailsResponse.kt @@ -0,0 +1,7 @@ +package com.nivesh.production.bajajfd.model + +data class FDCreationDetailsResponse( + val DocumentUploadFlag: Int, + val UniqueId: String, + val kycFlag: Int +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/FDDataResponse.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/FDDataResponse.kt new file mode 100644 index 0000000..325e7e6 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/FDDataResponse.kt @@ -0,0 +1,12 @@ +package com.nivesh.production.bajajfd.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 +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/FDInvestmentDetails.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/FDInvestmentDetails.kt new file mode 100644 index 0000000..276ca56 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/FDInvestmentDetails.kt @@ -0,0 +1,18 @@ +package com.nivesh.production.bajajfd.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? = "" + +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/FDStepsCountRequest.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/FDStepsCountRequest.kt new file mode 100644 index 0000000..79a9e1d --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/FDStepsCountRequest.kt @@ -0,0 +1,6 @@ +package com.nivesh.production.bajajfd.model + +data class FDStepsCountRequest( + var FDProvider: String? = "", + var NiveshClientCode: String? = "" +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/FdBankDetails.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/FdBankDetails.kt new file mode 100644 index 0000000..f292a4c --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/FdBankDetails.kt @@ -0,0 +1,10 @@ +package com.nivesh.production.bajajfd.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 +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/FinaliseFD.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/FinaliseFD.kt new file mode 100644 index 0000000..b487f60 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/FinaliseFD.kt @@ -0,0 +1,7 @@ +package com.nivesh.production.bajajfd.model + +data class FinaliseFD( + var FDProvider: String? = "", + var NiveshClientCode: String? = "", + var UniqueId: String? = "" +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/FinalizeFDRequest.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/FinalizeFDRequest.kt new file mode 100644 index 0000000..e77b6bf --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/FinalizeFDRequest.kt @@ -0,0 +1,5 @@ +package com.nivesh.production.bajajfd.model + +data class FinalizeFDRequest( + var FinaliseFD: FinaliseFD? = null +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/FinalizeFDResponse.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/FinalizeFDResponse.kt new file mode 100644 index 0000000..ea2554c --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/FinalizeFDResponse.kt @@ -0,0 +1,5 @@ +package com.nivesh.production.bajajfd.model + +data class FinalizeFDResponse( + val Response: ResponseXXXXXXXXXXXXXXXX +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/FinalizeKYCRequest.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/FinalizeKYCRequest.kt new file mode 100644 index 0000000..cb1e51e --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/FinalizeKYCRequest.kt @@ -0,0 +1,7 @@ +package com.nivesh.production.bajajfd.model + +data class FinalizeKYCRequest( + var FDProvider: String? = "", + var NiveshClientCode: String? = "", + var UniqueId: String? = "" +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/GetCalculateMaturityAmountResponse.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/GetCalculateMaturityAmountResponse.kt new file mode 100644 index 0000000..9f98c13 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/GetCalculateMaturityAmountResponse.kt @@ -0,0 +1,5 @@ +package com.nivesh.production.bajajfd.model + +data class GetCalculateMaturityAmountResponse( + val Response: ResponseXX +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/GetCodeRequest.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/GetCodeRequest.kt new file mode 100644 index 0000000..7a890aa --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/GetCodeRequest.kt @@ -0,0 +1,8 @@ +package com.nivesh.production.bajajfd.model + +data class GetCodeRequest( + var Category: String ? = null, + var InputValue: String? = null, + var Language: String ? = null, + var ProductName: String? = null +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/GetCodeResponse.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/GetCodeResponse.kt new file mode 100644 index 0000000..ea8687d --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/GetCodeResponse.kt @@ -0,0 +1,5 @@ +package com.nivesh.production.bajajfd.model + +data class GetCodeResponse( + val Response: ResponseX +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/GetCodes.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/GetCodes.kt new file mode 100644 index 0000000..8e4df4c --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/GetCodes.kt @@ -0,0 +1,11 @@ +package com.nivesh.production.bajajfd.model + +data class GetCodes( + val Label: String, + var Value: String, + var isSelected : Boolean +) { + override fun toString(): String { + return Label + } +} \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/GetFDBankListResponse.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/GetFDBankListResponse.kt new file mode 100644 index 0000000..cebf1e3 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/GetFDBankListResponse.kt @@ -0,0 +1,5 @@ +package com.nivesh.production.bajajfd.model + +data class GetFDBankListResponse( + val Response: ResponseXXXXXXXX +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/GetFDDetailsRequest.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/GetFDDetailsRequest.kt new file mode 100644 index 0000000..7cde245 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/GetFDDetailsRequest.kt @@ -0,0 +1,7 @@ +package com.nivesh.production.bajajfd.model + +data class GetFDDetailsRequest( + var FDProvider: String? = "", + var NiveshClientCode: String? = "", + var UniqueId: String? = "" +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/GetFDDetailsResponse.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/GetFDDetailsResponse.kt new file mode 100644 index 0000000..15f4af7 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/GetFDDetailsResponse.kt @@ -0,0 +1,5 @@ +package com.nivesh.production.bajajfd.model + +data class GetFDDetailsResponse( + val Response: ResponseXXXXXXXXXXXX +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/GetIFSCCodeListResponse.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/GetIFSCCodeListResponse.kt new file mode 100644 index 0000000..7e31899 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/GetIFSCCodeListResponse.kt @@ -0,0 +1,6 @@ +package com.nivesh.production.bajajfd.model + +data class GetIFSCCodeListResponse( + val IFSCCodes: MutableList, + val Response: ResponseXXXXXXXXXX +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/GetIFSCCodeResponse.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/GetIFSCCodeResponse.kt new file mode 100644 index 0000000..21338dd --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/GetIFSCCodeResponse.kt @@ -0,0 +1,5 @@ +package com.nivesh.production.bajajfd.model + +data class GetIFSCCodeResponse( + val IFSCCODEServiceResult: List +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/GetMaturityAmountRequest.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/GetMaturityAmountRequest.kt new file mode 100644 index 0000000..9d0112f --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/GetMaturityAmountRequest.kt @@ -0,0 +1,9 @@ +package com.nivesh.production.bajajfd.model + +data class GetMaturityAmountRequest( + var FDAmount: Int? = 0, + var FDProvider: String? = "", + var Frequency: String? = "", + var Interest: Double? = 0.0, + var Tenure: Int? = 0 +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/GetRatesRequest.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/GetRatesRequest.kt new file mode 100644 index 0000000..6553a5e --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/GetRatesRequest.kt @@ -0,0 +1,9 @@ +package com.nivesh.production.bajajfd.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 +) diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/GetRatesResponse.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/GetRatesResponse.kt new file mode 100644 index 0000000..2db5422 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/GetRatesResponse.kt @@ -0,0 +1,3 @@ +data class GetRatesResponse( + val Response: Response +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/IFSCCODEServiceResult.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/IFSCCODEServiceResult.kt new file mode 100644 index 0000000..717ce5f --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/IFSCCODEServiceResult.kt @@ -0,0 +1,10 @@ +package com.nivesh.production.bajajfd.model + +data class IFSCCODEServiceResult( + val BankBranch: String, + val BnkDescr: String, + val BnkShrtDescr: String, + val Code: String, + val IfscCode: String, + val intCustbnk_pk: String +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/Nominee.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/Nominee.kt new file mode 100644 index 0000000..31c1ae6 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/Nominee.kt @@ -0,0 +1,12 @@ +package com.nivesh.production.bajajfd.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 +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/NomineeDetails.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/NomineeDetails.kt new file mode 100644 index 0000000..456e518 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/NomineeDetails.kt @@ -0,0 +1,18 @@ +package com.nivesh.production.bajajfd.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 +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/NomineeGuardianDetails.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/NomineeGuardianDetails.kt new file mode 100644 index 0000000..9416a47 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/NomineeGuardianDetails.kt @@ -0,0 +1,14 @@ +package com.nivesh.production.bajajfd.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 +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/ObjectResponse.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/ObjectResponse.kt new file mode 100644 index 0000000..ae043f7 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/ObjectResponse.kt @@ -0,0 +1,9 @@ +package com.nivesh.production.bajajfd.model + +data class ObjectResponse( + val TransactionCount: Int, + val clientDetails: ClientDetails, + val languageid: Int, + val membersList: List, + val ClientBanklist : List +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/PanCheckRequest.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/PanCheckRequest.kt new file mode 100644 index 0000000..6a823eb --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/PanCheckRequest.kt @@ -0,0 +1,14 @@ +package com.nivesh.production.bajajfd.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 +) diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/PanCheckResponse.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/PanCheckResponse.kt new file mode 100644 index 0000000..5cae1b6 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/PanCheckResponse.kt @@ -0,0 +1,5 @@ +package com.nivesh.production.bajajfd.model + +data class PanCheckResponse( + val response: ResponseXXX +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/PaymentReQueryRequest.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/PaymentReQueryRequest.kt new file mode 100644 index 0000000..b7391d7 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/PaymentReQueryRequest.kt @@ -0,0 +1,6 @@ +package com.nivesh.production.bajajfd.model + +data class PaymentReQueryRequest( + var NiveshClientCode: String? = "", + var UniqueId: String? = "" +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/PaymentReQueryResponse.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/PaymentReQueryResponse.kt new file mode 100644 index 0000000..82d78d9 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/PaymentReQueryResponse.kt @@ -0,0 +1,5 @@ +package com.nivesh.production.bajajfd.model + +data class PaymentReQueryResponse( + val Response: ResponseXXXXXXXXXXXXXXX +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/ROIDataList.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/ROIDataList.kt new file mode 100644 index 0000000..c568b3c --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/ROIDataList.kt @@ -0,0 +1,11 @@ +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("%") + } +} \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/Response.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/Response.kt new file mode 100644 index 0000000..c479c7f --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/Response.kt @@ -0,0 +1,9 @@ +import com.nivesh.production.bajajfd.model.Errors + +data class Response( + val Errors: List, + val Message: String, + var ROIDatalist: MutableList, + val Status: String, + val StatusCode: Int +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseX.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseX.kt new file mode 100644 index 0000000..06a1cde --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseX.kt @@ -0,0 +1,9 @@ +package com.nivesh.production.bajajfd.model + +data class ResponseX( + val Errors: List, + val GetCodesList: MutableList, + val Message: String, + val Status: String, + val StatusCode: Int +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXX.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXX.kt new file mode 100644 index 0000000..1ec3e62 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXX.kt @@ -0,0 +1,9 @@ +package com.nivesh.production.bajajfd.model + +data class ResponseXX( + val Errors: List, + val MaturityAmount: Double, + val Message: String, + val Status: String, + val StatusCode: Int +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXX.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXX.kt new file mode 100644 index 0000000..3420420 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXX.kt @@ -0,0 +1,7 @@ +package com.nivesh.production.bajajfd.model + +data class ResponseXXX( + val message: String, + val status: String, + val status_code: Int +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXX.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXX.kt new file mode 100644 index 0000000..0c37922 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXX.kt @@ -0,0 +1,9 @@ +package com.nivesh.production.bajajfd.model + +data class ResponseXXXX( + val Errors: List, + val Message: String, + val Status: String, + val StatusCode: Int, + val StepsCount: Int +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXXX.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXXX.kt new file mode 100644 index 0000000..3b668b5 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXXX.kt @@ -0,0 +1,7 @@ +package com.nivesh.production.bajajfd.model + +data class ResponseXXXXX( + val message: String, + val status: String, + val status_code: Int +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXXXX.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXXXX.kt new file mode 100644 index 0000000..cce2013 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXXXX.kt @@ -0,0 +1,7 @@ +package com.nivesh.production.bajajfd.model + +data class ResponseXXXXXX( + val message: String, + val status: String, + val status_code: Int +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXXXXX.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXXXXX.kt new file mode 100644 index 0000000..1adec00 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXXXXX.kt @@ -0,0 +1,7 @@ +package com.nivesh.production.bajajfd.model + +data class ResponseXXXXXXX( + val message: String, + val status: String, + val status_code: Int +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXXXXXX.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXXXXXX.kt new file mode 100644 index 0000000..a48dfa5 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXXXXXX.kt @@ -0,0 +1,9 @@ +package com.nivesh.production.bajajfd.model + +data class ResponseXXXXXXXX( + val BankList: List, + val Errors: List, + val Message: String, + val Status: String, + val StatusCode: Int +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXXXXXXX.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXXXXXXX.kt new file mode 100644 index 0000000..128fad0 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXXXXXXX.kt @@ -0,0 +1,7 @@ +package com.nivesh.production.bajajfd.model + +data class ResponseXXXXXXXXX( + val message: String, + val status: String, + val status_code: Int +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXXXXXXXX.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXXXXXXXX.kt new file mode 100644 index 0000000..092b2f9 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXXXXXXXX.kt @@ -0,0 +1,7 @@ +package com.nivesh.production.bajajfd.model + +data class ResponseXXXXXXXXXX( + val message: String, + val status: String, + val status_code: Int +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXXXXXXXXX.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXXXXXXXXX.kt new file mode 100644 index 0000000..cf7ddc5 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXXXXXXXXX.kt @@ -0,0 +1,9 @@ +package com.nivesh.production.bajajfd.model + +data class ResponseXXXXXXXXXXX( + val Errors: List, + val FDCreationDetailsResponse: FDCreationDetailsResponse, + val Message: String, + val Status: String, + val StatusCode: Int +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXXXXXXXXXX.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXXXXXXXXXX.kt new file mode 100644 index 0000000..187adc4 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXXXXXXXXXX.kt @@ -0,0 +1,11 @@ +package com.nivesh.production.bajajfd.model + +import com.nivesh.production.bajajfd.util.Resource + +data class ResponseXXXXXXXXXXXX( + val Errors: List, + val FDDataResponse: FDDataResponse, + val Message: String, + val Status: String, + val StatusCode: Int +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXXXXXXXXXXX.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXXXXXXXXXXX.kt new file mode 100644 index 0000000..d140607 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXXXXXXXXXXX.kt @@ -0,0 +1,8 @@ +package com.nivesh.production.bajajfd.model + +data class ResponseXXXXXXXXXXXXX( + val Errors: List, + val Message: String, + val Status: String, + val StatusCode: Int +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXXXXXXXXXXXX.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXXXXXXXXXXXX.kt new file mode 100644 index 0000000..e470814 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXXXXXXXXXXXX.kt @@ -0,0 +1,7 @@ +package com.nivesh.production.bajajfd.model + +data class ResponseXXXXXXXXXXXXXX( + val message: String, + val status: String, + val status_code: Int +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXXXXXXXXXXXXX.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXXXXXXXXXXXXX.kt new file mode 100644 index 0000000..02339b2 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXXXXXXXXXXXXX.kt @@ -0,0 +1,8 @@ +package com.nivesh.production.bajajfd.model + +data class ResponseXXXXXXXXXXXXXXX( + val Errors: List, + val Message: String, + val Status: String, + val StatusCode: Int +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXXXXXXXXXXXXXX.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXXXXXXXXXXXXXX.kt new file mode 100644 index 0000000..c16ac00 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXXXXXXXXXXXXXX.kt @@ -0,0 +1,9 @@ +package com.nivesh.production.bajajfd.model + +data class ResponseXXXXXXXXXXXXXXXX( + val Errors: List, + val Message: String, + val Status: String, + val StatusCode: Int, + val UniqueId: String +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/SaveFDOtherDataRequest.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/SaveFDOtherDataRequest.kt new file mode 100644 index 0000000..5558f83 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/SaveFDOtherDataRequest.kt @@ -0,0 +1,8 @@ +package com.nivesh.production.bajajfd.model + +data class SaveFDOtherDataRequest( + var FDProvider: String?= "", + var NiveshClientCode: String? = "", + var UniqueId: String? = "", + var Values: String? = "" +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/SaveFDOtherDataResponse.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/SaveFDOtherDataResponse.kt new file mode 100644 index 0000000..d1cd6f4 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/SaveFDOtherDataResponse.kt @@ -0,0 +1,5 @@ +package com.nivesh.production.bajajfd.model + +data class SaveFDOtherDataResponse( + val Response: ResponseXXXXXXXXXXXXX +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/StateListResponse.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/StateListResponse.kt new file mode 100644 index 0000000..8ed273c --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/StateListResponse.kt @@ -0,0 +1,8 @@ +package com.nivesh.production.bajajfd.model + +data class StateListResponse( + val DataObject: List, + val Message: Any, + val ObjectResponse: Any, + val response: ResponseXXXXX +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/StepsCountResponse.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/StepsCountResponse.kt new file mode 100644 index 0000000..b0266d1 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/StepsCountResponse.kt @@ -0,0 +1,5 @@ +package com.nivesh.production.bajajfd.model + +data class StepsCountResponse( + val Response: ResponseXXXX +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/UploadResponse.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/UploadResponse.kt new file mode 100644 index 0000000..a9a1560 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/UploadResponse.kt @@ -0,0 +1,5 @@ +package com.nivesh.production.bajajfd.model + +data class UploadResponse( + val Response: ResponseXXXXXXXXXXXX +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/UserRequest.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/UserRequest.kt new file mode 100644 index 0000000..b6a37e6 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/UserRequest.kt @@ -0,0 +1,10 @@ +package com.nivesh.production.bajajfd.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 +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/getClientDetailsRequest.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/getClientDetailsRequest.kt new file mode 100644 index 0000000..e140749 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/getClientDetailsRequest.kt @@ -0,0 +1,8 @@ +package com.nivesh.production.bajajfd.model + +data class getClientDetailsRequest( + var AppOrWeb: String? = "", + var UserRequest: UserRequest? = null, + var client_code: String? = "", + var sub_broker_code: String? = "" +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/model/getClientDetailsResponse.kt b/app/src/main/java/com/nivesh/production/bajajfd/model/getClientDetailsResponse.kt new file mode 100644 index 0000000..a60896a --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/model/getClientDetailsResponse.kt @@ -0,0 +1,8 @@ +package com.nivesh.production.bajajfd.model + +data class getClientDetailsResponse( +// val DataObject: Any ?, +// val Message: Any, + val ObjectResponse: ObjectResponse? = null, + val response: ResponseXXXXXXX? = null +) \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/repositories/MainRepository.kt b/app/src/main/java/com/nivesh/production/bajajfd/repositories/MainRepository.kt new file mode 100644 index 0000000..23eef56 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/repositories/MainRepository.kt @@ -0,0 +1,110 @@ +package com.nivesh.production.bajajfd.repositories + +import com.nivesh.production.bajajfd.interfaces.ApiInterface +import com.nivesh.production.bajajfd.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) +} \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/ui/activity/BajajFdMainActivity.kt b/app/src/main/java/com/nivesh/production/bajajfd/ui/activity/BajajFdMainActivity.kt new file mode 100644 index 0000000..af50bde --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/ui/activity/BajajFdMainActivity.kt @@ -0,0 +1,489 @@ +package com.nivesh.production.bajajfd.ui.activity + +import android.annotation.SuppressLint +import android.app.Dialog +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.bajajfd.R +import com.nivesh.production.bajajfd.adapter.DisableAdapter +import com.nivesh.production.bajajfd.adapter.SectionsPagerAdapter +import com.nivesh.production.bajajfd.api.ApiClient +import com.nivesh.production.bajajfd.databinding.ActivityBajajFdBinding +import com.nivesh.production.bajajfd.model.* +import com.nivesh.production.bajajfd.repositories.MainRepository +import com.nivesh.production.bajajfd.ui.fragment.* +import com.nivesh.production.bajajfd.ui.providerfactory.* +import com.nivesh.production.bajajfd.util.Common +import com.nivesh.production.bajajfd.util.Common.Companion.defaultShape +import com.nivesh.production.bajajfd.util.Common.Companion.getDate +import com.nivesh.production.bajajfd.util.Common.Companion.selectedShape +import com.nivesh.production.bajajfd.util.Common.Companion.showDialogValidation +import com.nivesh.production.bajajfd.util.Constants.Companion.token +import com.nivesh.production.bajajfd.util.ProgressUtil +import com.nivesh.production.bajajfd.util.ProgressUtil.hideLoading +import com.nivesh.production.bajajfd.util.ProgressUtil.showLoading +import com.nivesh.production.bajajfd.util.Resource +import com.nivesh.production.bajajfd.viewModel.* + + +class BajajFdMainActivity : BaseActivity() { + lateinit var binding: ActivityBajajFdBinding + lateinit var viewModel: BajajFDViewModel + + private val stepOneBajajFDFragment = StepOneBajajFDFragment() + private val stepTwoBajajFDFragment = StepTwoBajajFDFragment() + private val stepThreeBajajFDFragment = StepThreeBajajFDFragment() + private val stepFourBajajFDFragment = StepFourBajajFDFragment() + private val stepFiveBajajFDFragment = StepFiveBajajFDFragment() + + 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() + var uniqueId: String = "" + var stepCount: Int = 0 + private lateinit var sectionsPagerAdapter: SectionsPagerAdapter + private lateinit var fragments: Array + var dialogWebView: Dialog? = null + var loginRole: Int = 0 + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + init() + } + + private fun init() { + //start Repository + viewModel = ViewModelProvider( + this@BajajFdMainActivity, + FDModelProviderFactory(MainRepository(ApiClient.getApiClient)) + )[BajajFDViewModel::class.java] + binding = ActivityBajajFdBinding.inflate(layoutInflater) + binding.apply { + setContentView(this.root) + } + + loginRole = 5 + 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 = "8872" // 60476 + viewModel.getStepsCount(fdStepsCount, token, 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 -> { + showDialogValidation( + this@BajajFdMainActivity, + stepsCountResponse.Response.Errors[0].ErrorMessage + ) + } + } + } + } + is Resource.Error -> { + response.message?.let { message -> + showDialogValidation(this@BajajFdMainActivity, message) + } + } + is Resource.Loading -> { + + } + is Resource.DataError -> { + + } + } + } + } + } + + private fun getClientDetailsApi(stepsCount: Int) { + if (Common.isNetworkAvailable(this@BajajFdMainActivity)) { + val getClientDetailsRequest = getClientDetailsRequest() + getClientDetailsRequest.client_code = "8872" + getClientDetailsRequest.AppOrWeb = getString(R.string.app) + getClientDetailsRequest.sub_broker_code = "1038" + val userRequest = UserRequest() + userRequest.UID = 0 + userRequest.IPAddress = "" + userRequest.Source = getString(R.string.source) + userRequest.AppOrWeb = getString(R.string.app) + userRequest.LoggedInRoleId = loginRole + + 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@BajajFdMainActivity) + viewModel.getClientDetails(getClientDetailsRequest, token, 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) + checkFDCKYCApi() + } + // 650 -> refreshToken() + else -> { + showDialogValidation(this@BajajFdMainActivity, response.message) + } + } + } + } + + is Resource.Error -> { + response.message?.let { message -> + showDialogValidation(this@BajajFdMainActivity, message) + } + } + is Resource.Loading -> { + hideLoading() + } + is Resource.DataError -> { + + } + } + } + } + } + + private fun setViewPager(stepsCount: Int) { + // steps setting + setBackground(selectedShape(), defaultShape(), defaultShape(), defaultShape(), stepsCount) + + if (stepCount == 3) { + fragments = arrayOf( + stepOneBajajFDFragment, + stepTwoBajajFDFragment, + stepFourBajajFDFragment, + stepFiveBajajFDFragment + ) + } else if (stepCount == 4) { + fragments = arrayOf( + stepOneBajajFDFragment, + stepTwoBajajFDFragment, + stepThreeBajajFDFragment, + stepFourBajajFDFragment, + stepFiveBajajFDFragment + ) + } + + // 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) { + + } + }) + + } + + private fun checkFDCKYCApi() { + if (Common.isNetworkAvailable(this@BajajFdMainActivity)) { + if (getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CM_MOBILE?.isNotEmpty()!! && getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_DOB?.isNotEmpty()!! && getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_PAN?.isNotEmpty()!! && getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_CODE?.isNotEmpty()!!) { + val checkFDKYCRequest = CheckFDKYCRequest() + checkFDKYCRequest.Mobile = + getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CM_MOBILE + checkFDKYCRequest.DOB = + getDate(getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_DOB!!) + checkFDKYCRequest.PAN = + getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_PAN + checkFDKYCRequest.NiveshClientCode = + getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_CODE.toString() + viewModel.checkFDKYC(checkFDKYCRequest, token, this) + viewModel.getFDKYCMutableData.observe(this) { response -> + when (response) { + is Resource.Success -> { + Log.e("response", "-->${response.data.toString()}") + val getCodeResponse: GetCodeResponse = + Gson().fromJson( + response.data?.toString(), + GetCodeResponse::class.java + ) + getCodeResponse.Response.StatusCode.let { code -> + when (code) { + 200 -> { + + fdInvestmentDetails.CustomerType = "" + } + // 650 -> refreshToken() + else -> { + showDialogValidation( + this@BajajFdMainActivity, + getCodeResponse.Response.Errors[0].ErrorMessage + ) + } + } + } + } + + is Resource.Error -> { + response.message?.let { message -> + showDialogValidation(this@BajajFdMainActivity, message) + } + } + is Resource.Loading -> { + + } + is Resource.DataError -> { + + } + } + } + } + } + + } + + // 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@BajajFdMainActivity) + dialogWebView!!.setContentView(R.layout.row_fd_pay) + dialogWebView!!.setCancelable(true) + val tvCancel = dialogWebView!!.findViewById(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(R.id.wVPay) + wVPay.settings.javaScriptEnabled = true + wVPay.settings.domStorageEnabled = true + wVPay.loadData( + "
\n" + " \n" + "
\n" + + "", + "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 != null && 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 + ProgressUtil.showLoading(this@BajajFdMainActivity) + viewModel.getPaymentReQuery(paymentReQueryRequest, token, 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 + } + stepFiveBajajFDFragment.getData(paymentReQueryResponse) + } + } + } + } + is Resource.Error -> { + response.message?.let { message -> + showDialogValidation(this@BajajFdMainActivity, message) + } + } + is Resource.Loading -> { + hideLoading() + } + is Resource.DataError -> { + + } + } + } + } + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/ui/activity/BaseActivity.kt b/app/src/main/java/com/nivesh/production/bajajfd/ui/activity/BaseActivity.kt new file mode 100644 index 0000000..fc035c6 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/ui/activity/BaseActivity.kt @@ -0,0 +1,14 @@ +package com.nivesh.production.bajajfd.ui.activity + +import android.app.Activity +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity + +open class BaseActivity : AppCompatActivity() { + private lateinit var mActivity: Activity + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + mActivity = this + } +} \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/ui/fragment/StepFiveBajajFDFragment.kt b/app/src/main/java/com/nivesh/production/bajajfd/ui/fragment/StepFiveBajajFDFragment.kt new file mode 100644 index 0000000..224961c --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/ui/fragment/StepFiveBajajFDFragment.kt @@ -0,0 +1,173 @@ +package com.nivesh.production.bajajfd.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.ContextCompat +import androidx.fragment.app.Fragment +import com.google.gson.Gson +import com.nivesh.production.bajajfd.R +import com.nivesh.production.bajajfd.databinding.FragmentBajajfdStepFiveBinding +import com.nivesh.production.bajajfd.model.* +import com.nivesh.production.bajajfd.ui.activity.BajajFdMainActivity +import com.nivesh.production.bajajfd.util.Common +import com.nivesh.production.bajajfd.util.Constants +import com.nivesh.production.bajajfd.util.Resource + +class StepFiveBajajFDFragment : Fragment() { + + private var _binding: FragmentBajajfdStepFiveBinding? = null + private val binding get() = _binding!! + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + + _binding = FragmentBajajfdStepFiveBinding.inflate(inflater, container, false) + return binding.root + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + binding.tvCongrats.text = "" + binding.tvSuccessMessage.text = "" + binding.btnViewOrder.setOnClickListener { + + } + } + + fun getData(paymentReQueryResponse: PaymentReQueryResponse) { + if (paymentReQueryResponse.Response.StatusCode == 200) { + if (paymentReQueryResponse.Response.Message.isNotEmpty()) { + val arrOfStr: List = paymentReQueryResponse.Response.Message.split(" ", limit = 2) + binding.tvCongrats.text = arrOfStr[0] + binding.tvCongrats.setTextColor( + ContextCompat.getColor( + activity as BajajFdMainActivity, + R.color.green + ) + ) + binding.tvSuccessMessage.text = arrOfStr[1] + } + }else{ + if (paymentReQueryResponse.Response.Message.isNotEmpty()) { + val arrOfStr: List = paymentReQueryResponse.Response.Message.split(" ", limit = 2) + binding.tvCongrats.text = arrOfStr[0] + binding.tvCongrats.setTextColor( + ContextCompat.getColor( + activity as BajajFdMainActivity, + R.color.red + ) + ) + binding.tvSuccessMessage.text = arrOfStr[1] + } + } + finalizeFDApi() + finalizeKYCApi() + } + + private fun finalizeFDApi() { + val finalizeFDRequest = FinalizeFDRequest() + val finaliseFD = FinaliseFD() + finaliseFD.FDProvider = getString(R.string.bajaj) + finaliseFD.NiveshClientCode = (activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_CODE + finaliseFD.UniqueId = (activity as BajajFdMainActivity).uniqueId + finalizeFDRequest.FinaliseFD = finaliseFD + + (activity as BajajFdMainActivity).viewModel.finaliseFD( + finalizeFDRequest, Constants.token, activity as BajajFdMainActivity + ) + (activity as BajajFdMainActivity).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 -> { + + } + 650 -> "" + else -> { + Common.showDialogValidation( + activity as BajajFdMainActivity, + finalizeFDResponse.Response.Errors[0].ErrorMessage + ) + } + } + } + } + + is Resource.Error -> { + response.message?.let { message -> + Common.showDialogValidation(activity as BajajFdMainActivity, message) + } + } + is Resource.Loading -> { + + } + is Resource.DataError -> { + + } + } + } + } + + private fun finalizeKYCApi() { + val finalizeKYCRequest = FinalizeKYCRequest() + finalizeKYCRequest.FDProvider = getString(R.string.bajaj) + finalizeKYCRequest.NiveshClientCode = (activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_CODE + finalizeKYCRequest.UniqueId = (activity as BajajFdMainActivity).uniqueId + (activity as BajajFdMainActivity).viewModel.finaliseKYC( + finalizeKYCRequest, Constants.token, activity as BajajFdMainActivity + ) + (activity as BajajFdMainActivity).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 -> { + Common.showDialogValidation( + activity as BajajFdMainActivity, + finalizeFDResponse.Response.Errors[0].ErrorMessage + ) + } + } + } + } + + is Resource.Error -> { + response.message?.let { message -> + Common.showDialogValidation(activity as BajajFdMainActivity, message) + } + } + is Resource.Loading -> { + + } + is Resource.DataError -> { + + } + } + } + + } + + + + override fun onDestroyView() { + super.onDestroyView() + _binding = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/ui/fragment/StepFourBajajFDFragment.kt b/app/src/main/java/com/nivesh/production/bajajfd/ui/fragment/StepFourBajajFDFragment.kt new file mode 100644 index 0000000..8918585 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/ui/fragment/StepFourBajajFDFragment.kt @@ -0,0 +1,303 @@ +package com.nivesh.production.bajajfd.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.bajajfd.R +import com.nivesh.production.bajajfd.adapter.CustomerListAdapter +import com.nivesh.production.bajajfd.databinding.FragmentBajajfdStepFourBinding +import com.nivesh.production.bajajfd.model.* +import com.nivesh.production.bajajfd.ui.activity.BajajFdMainActivity +import com.nivesh.production.bajajfd.util.Common +import com.nivesh.production.bajajfd.util.Common.Companion.showDialogValidation +import com.nivesh.production.bajajfd.util.Constants.Companion.token +import com.nivesh.production.bajajfd.util.ProgressUtil +import com.nivesh.production.bajajfd.util.Resource + +class StepFourBajajFDFragment : Fragment() { + + private var _binding: FragmentBajajfdStepFourBinding? = null + private val binding get() = _binding!! + + private lateinit var listOfCustomer: MutableList + private var selectedList: String = "" + private var payUrl: String = "" + private var value: String = "" + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + + _binding = FragmentBajajfdStepFourBinding.inflate(inflater, container, false) + return binding.root + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + if ((activity as BajajFdMainActivity).loginRole == 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 + ) + ) + } + + binding.btnNext.setOnClickListener { + selectedList = "" + for (getCodes in listOfCustomer) { + if (getCodes.isSelected) { + selectedList = if (selectedList.isEmpty()) { + getCodes.Value + } else { + selectedList.plus(",").plus(getCodes.Value) + } + } + } + if (validated()) { + if ((activity as BajajFdMainActivity).loginRole == 5) { + val saveFDOtherDataRequest = SaveFDOtherDataRequest() + saveFDOtherDataRequest.FDProvider = getString(R.string.bajaj) + saveFDOtherDataRequest.UniqueId = (activity as BajajFdMainActivity).uniqueId + saveFDOtherDataRequest.Values = selectedList + saveFDOtherDataRequest.NiveshClientCode = + (activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_CODE + saveFDOtherData(saveFDOtherDataRequest, payUrl, value) + } else { + // go to view order + } + } + } + + binding.btnBack.setOnClickListener { + if ((activity as BajajFdMainActivity).stepCount == 4) { + (activity as BajajFdMainActivity).binding.viewPager.currentItem = 2 + } else { + (activity as BajajFdMainActivity).binding.viewPager.currentItem = 1 + } + } + } + + private fun validated(): Boolean { + if (selectedList.isEmpty()) { + showDialogValidation( + activity as BajajFdMainActivity, + getString(R.string.validTermsCondition) + ) + return false + } else if (!binding.checkBox.isChecked) { + showDialogValidation( + activity as BajajFdMainActivity, + resources.getString(R.string.validTermsConditions) + ) + return false + } else { + return true + } + } + + private fun saveFDOtherData(data: SaveFDOtherDataRequest, payUrl: String, value: String) { + ProgressUtil.showLoading(activity as BajajFdMainActivity) + (activity as BajajFdMainActivity).viewModel.saveFDOtherData( + data, + token, + activity as BajajFdMainActivity + ) + (activity as BajajFdMainActivity).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 BajajFdMainActivity).stepFourApi(payUrl, value) + } + // 650 -> refreshToken() + else -> { + showDialogValidation( + activity as BajajFdMainActivity, + saveFDOtherDataResponse.Response.Errors[0].ErrorMessage + ) + } + } + } + } + + is Resource.Error -> { + response.message?.let { message -> + showDialogValidation(activity as BajajFdMainActivity, message) + } + } + is Resource.Loading -> { + ProgressUtil.hideLoading() + } + is Resource.DataError -> { + + } + } + } + } + + fun displayReceivedData() { + getFDDetailsApi() + 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 BajajFdMainActivity).viewModel.customerListApi( + getCodeRequest, + token, + activity as BajajFdMainActivity + ) + (activity as BajajFdMainActivity).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 -> { + showDialogValidation( + activity as BajajFdMainActivity, + getCodeResponse.Response.Message + ) + } + } + } + } + + is Resource.Error -> { + response.message?.let { message -> + showDialogValidation(activity as BajajFdMainActivity, message) + } + } + is Resource.Loading -> { + + } + is Resource.DataError -> { + + } + } + } + } + + private fun setUpRecyclerView(getCustomerList: MutableList) { + binding.rvTerms.layoutManager = + LinearLayoutManager(activity as BajajFdMainActivity) + val customerListAdapter = CustomerListAdapter(getCustomerList) + binding.rvTerms.adapter = customerListAdapter + + } + + private fun getFDDetailsApi() { + if (Common.isNetworkAvailable(activity as BajajFdMainActivity)) { + val getFDDetailsRequest = GetFDDetailsRequest() + getFDDetailsRequest.FDProvider = getString(R.string.bajaj) + getFDDetailsRequest.NiveshClientCode = + (activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_CODE + getFDDetailsRequest.UniqueId = (activity as BajajFdMainActivity).uniqueId + ProgressUtil.showLoading(activity as BajajFdMainActivity) + (activity as BajajFdMainActivity).viewModel.getFDDetails( + getFDDetailsRequest, + token, + activity as BajajFdMainActivity + ) + (activity as BajajFdMainActivity).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 -> { + showDialogValidation( + activity as BajajFdMainActivity, + getFDDetailsResponse.Response.Errors[0].ErrorMessage + ) + } + } + } + } + + is Resource.Error -> { + response.message?.let { message -> + showDialogValidation(activity as BajajFdMainActivity, message) + } + } + is Resource.Loading -> { + ProgressUtil.hideLoading() + } + is Resource.DataError -> { + + } + } + } + } + } + + + override fun onDestroyView() { + super.onDestroyView() + _binding = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/ui/fragment/StepOneBajajFDFragment.kt b/app/src/main/java/com/nivesh/production/bajajfd/ui/fragment/StepOneBajajFDFragment.kt new file mode 100644 index 0000000..c5700bb --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/ui/fragment/StepOneBajajFDFragment.kt @@ -0,0 +1,541 @@ +package com.nivesh.production.bajajfd.ui.fragment + +import GetRatesResponse +import ROIDataList +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.recyclerview.widget.DefaultItemAnimator +import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView.LayoutManager +import com.google.gson.Gson +import com.nivesh.production.bajajfd.R +import com.nivesh.production.bajajfd.adapter.HorizontalRecyclerViewAdapter +import com.nivesh.production.bajajfd.databinding.FragmentBajajfdStepOneBinding +import com.nivesh.production.bajajfd.model.* +import com.nivesh.production.bajajfd.ui.activity.BajajFdMainActivity +import com.nivesh.production.bajajfd.util.Common +import com.nivesh.production.bajajfd.util.Common.Companion.commonErrorMethod +import com.nivesh.production.bajajfd.util.Common.Companion.removeError +import com.nivesh.production.bajajfd.util.Constants.Companion.token +import com.nivesh.production.bajajfd.util.Resource + + +class StepOneBajajFDFragment : Fragment() { + private var _binding: FragmentBajajfdStepOneBinding? = null + private val binding get() = _binding!! + + private lateinit var rgMaturity: RadioButton + private lateinit var listOfTenure: MutableList + private lateinit var recyclerViewDropDownAdapter: HorizontalRecyclerViewAdapter + private lateinit var listOfMinAmount: List + private lateinit var listOfMaxAmount: List + private lateinit var listOfFrequency: List + + private var tenure: Int = 0 + private var interest: Double = 0.0 + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + _binding = FragmentBajajfdStepOneBinding.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 BajajFdMainActivity) + binding.edtAmount.filters = arrayOf(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 + rgMaturity.text = getString(R.string.additionalDetailOne) + binding.radioGroup.setOnCheckedChangeListener { group, checkedId -> + rgMaturity = group.findViewById(checkedId) + Log.e("Maturity", "-->" + rgMaturity.text) + } + + // Next Button + binding.btnNext.setOnClickListener { + if (validation()) { + (activity as BajajFdMainActivity).fdInvestmentDetails.FDAmount = + binding.edtAmount.text.toString().toDouble() + (activity as BajajFdMainActivity).fdInvestmentDetails.Frequency = + binding.spInterestPayout.text.toString() + (activity as BajajFdMainActivity).fdInvestmentDetails.Tenure = tenure + (activity as BajajFdMainActivity).fdInvestmentDetails.Interest = interest + (activity as BajajFdMainActivity).fdInvestmentDetails.NiveshClientCode = + (activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_CODE + (activity as BajajFdMainActivity).fdInvestmentDetails.Provider = + getString(R.string.bajaj) + (activity as BajajFdMainActivity).fdInvestmentDetails.IPAddress = "192.168.1.23" + (activity as BajajFdMainActivity).fdInvestmentDetails.Device = + getString(R.string.app) + (activity as BajajFdMainActivity).fdInvestmentDetails.Source = + getString(R.string.source) + if (binding.swSeniorCitizen.isChecked) { + (activity as BajajFdMainActivity).fdInvestmentDetails.CitizenType = + getString(R.string.seniorCitizen) + } else { + (activity as BajajFdMainActivity).fdInvestmentDetails.CitizenType = + getString(R.string.nonSeniorCitizen) + } + (activity as BajajFdMainActivity).fdInvestmentDetails.CustomerType = "" + (activity as BajajFdMainActivity).fdInvestmentDetails.CKYCNumber = "" + (activity as BajajFdMainActivity).fdInvestmentDetails.UniqueId = + (activity as BajajFdMainActivity).uniqueId + + (activity as BajajFdMainActivity).createFDApplicantRequest.FDInvestmentDetails = + (activity as BajajFdMainActivity).fdInvestmentDetails + Log.e( + "StepOneData", + "-->" + Gson().toJson((activity as BajajFdMainActivity).fdInvestmentDetails) + ) + (activity as BajajFdMainActivity).stepOneApi() + } + } + + minAmountApi() + interestPayoutApi() + } + + private fun interestPayoutApi() { + val getCodeRequest = GetCodeRequest() + getCodeRequest.ProductName = getString(R.string.bajajFD) + getCodeRequest.Category = getString(R.string.category) + getCodeRequest.Language = getString(R.string.language) + getCodeRequest.InputValue = "" + (activity as BajajFdMainActivity).viewModel.getCode( + getCodeRequest, + token, + activity as BajajFdMainActivity + ) + (activity as BajajFdMainActivity).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 BajajFdMainActivity, + 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 BajajFdMainActivity, + "Interest Payout Frequency Data Is Missing." + ) + } + } + 650 -> "" + else -> { + Common.showDialogValidation( + activity as BajajFdMainActivity, + getCodeResponse.Response.Errors[0].ErrorMessage + ) + } + } + } + } + + is Resource.Error -> { + response.message?.let { message -> + Common.showDialogValidation(activity as BajajFdMainActivity, 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 BajajFdMainActivity).viewModel.getMinAmount( + getCodeRequest, + token, + activity as BajajFdMainActivity + ) + (activity as BajajFdMainActivity).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 -> { + Common.showDialogValidation( + activity as BajajFdMainActivity, + getCodeResponse.Response.Errors[0].ErrorMessage + ) + } + } + } + } + + is Resource.Error -> { + response.message?.let { message -> + Common.showDialogValidation(activity as BajajFdMainActivity, 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 BajajFdMainActivity).viewModel.getMaxAmount( + getCodeRequest, + token, + activity as BajajFdMainActivity + ) + (activity as BajajFdMainActivity).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 -> { + Common.showDialogValidation( + activity as BajajFdMainActivity, + getCodeResponse.Response.Errors[0].ErrorMessage + ) + } + } + } + } + + is Resource.Error -> { + response.message?.let { message -> + Common.showDialogValidation(activity as BajajFdMainActivity, message) + } + } + is Resource.Loading -> { + + } + is Resource.DataError -> { + + } + } + } + } + + private fun setUpRecyclerView() { + + recyclerViewDropDownAdapter = HorizontalRecyclerViewAdapter( + activity as BajajFdMainActivity, + 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 BajajFdMainActivity).viewModel.getMaturityAmount( + maturityAmountRequest, + activity as BajajFdMainActivity + ) + (activity as BajajFdMainActivity).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 -> { + Common.showDialogValidation( + activity as BajajFdMainActivity, + getMaturityAmountResponse.Response.Errors[0].ErrorMessage + ) + } + } + } + } + + is Resource.Error -> { + response.message?.let { message -> + Common.showDialogValidation( + activity as BajajFdMainActivity, + 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() + .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 BajajFdMainActivity).viewModel.getRates( + getRatesRequest, + token, + activity as BajajFdMainActivity + ) + (activity as BajajFdMainActivity).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 BajajFdMainActivity, + 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 -> { + Common.showDialogValidation( + activity as BajajFdMainActivity, + getRatesResponse.Response.Errors[0].ErrorMessage + ) + } + } + } + } + + is Resource.Error -> { + response.message?.let { message -> + Common.showDialogValidation(activity as BajajFdMainActivity, message) + } + } + is Resource.Loading -> { + + } + is Resource.DataError -> { + + } + } + } + } + + override fun onDestroyView() { + super.onDestroyView() + _binding = null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/ui/fragment/StepThreeBajajFDFragment.kt b/app/src/main/java/com/nivesh/production/bajajfd/ui/fragment/StepThreeBajajFDFragment.kt new file mode 100644 index 0000000..384c5e4 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/ui/fragment/StepThreeBajajFDFragment.kt @@ -0,0 +1,700 @@ +package com.nivesh.production.bajajfd.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.bajajfd.BuildConfig +import com.nivesh.production.bajajfd.R +import com.nivesh.production.bajajfd.databinding.FragmentBajajfdStepThreeBinding +import com.nivesh.production.bajajfd.model.* +import com.nivesh.production.bajajfd.ui.activity.BajajFdMainActivity +import com.nivesh.production.bajajfd.util.Common +import com.nivesh.production.bajajfd.util.Common.Companion.getFileExtension +import com.nivesh.production.bajajfd.util.Common.Companion.showDialogWithTwoButtons +import com.nivesh.production.bajajfd.util.Constants +import com.nivesh.production.bajajfd.util.ImageUtil +import com.nivesh.production.bajajfd.util.Resource +import java.io.* +import java.util.* + +class StepThreeBajajFDFragment : Fragment() { + + private var _binding: FragmentBajajfdStepThreeBinding? = null + private val binding get() = _binding!! + + private var takeImageResult: ActivityResultLauncher? = null + private var selectImageIntent: ActivityResultLauncher? = null + private var bitmap: Bitmap? = null + private var latestTmpUri: Uri? = null + + private val mapImage: HashMap = HashMap() + private lateinit var listOfDocType: List + + 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 BajajFdMainActivity), 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 BajajFdMainActivity), getString(R.string.galleryPermission), getString( + R.string.permissionsRequired + ) + ) + } + } + + + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + + _binding = FragmentBajajfdStepThreeBinding.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 BajajFdMainActivity).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 BajajFdMainActivity + ) + 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 BajajFdMainActivity, + Manifest.permission.CAMERA + ) + ) { + takeImage() + } else { + onClickRequestPermission() + } + dialog.dismiss() + } + 1 -> { + if (hasPermissions(activity as BajajFdMainActivity, *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 BajajFdMainActivity, + Manifest.permission.CAMERA + ) == PackageManager.PERMISSION_GRANTED -> { + + } + + ActivityCompat.shouldShowRequestPermissionRationale( + activity as BajajFdMainActivity, + 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 BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_CODE + du.UniqueId = (activity as BajajFdMainActivity).uniqueId + (activity as BajajFdMainActivity).viewModel.documentsUpload( + du, + Constants.token, + activity as BajajFdMainActivity + ) + (activity as BajajFdMainActivity).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 BajajFdMainActivity).createFDRequest) + } + } + // 650 -> refreshToken() + else -> { + Common.showDialogValidation( + activity as BajajFdMainActivity, + getUploadResponse.Response.Errors[0].ErrorMessage + ) + } + } + } + } + + is Resource.Error -> { + response.message?.let { message -> + Common.showDialogValidation(activity as BajajFdMainActivity, message) + } + } + is Resource.Loading -> { + + } + is Resource.DataError -> { + + } + } + } + } + + private fun createFDApi(data: CreateFDRequest) { + (activity as BajajFdMainActivity).viewModel.createFDApi( + data, + Constants.token, + activity as BajajFdMainActivity + ) + (activity as BajajFdMainActivity).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 BajajFdMainActivity).stepThreeApi() + } + // 650 -> refreshToken() + else -> { + Common.showDialogValidation( + activity as BajajFdMainActivity, + createFDApplicationResponse.Response.Errors[0].ErrorMessage + ) + } + } + } + } + + is Resource.Error -> { + response.message?.let { message -> + Common.showDialogValidation(activity as BajajFdMainActivity, 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 BajajFdMainActivity).viewModel.docTypeApi( + getCodeRequest, + Constants.token, + activity as BajajFdMainActivity + ) + (activity as BajajFdMainActivity).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 BajajFdMainActivity, + 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 -> { + Common.showDialogValidation( + activity as BajajFdMainActivity, + getCodeResponse.Response.Message + ) + } + } + } + } + + is Resource.Error -> { + response.message?.let { message -> + Common.showDialogValidation(activity as BajajFdMainActivity, message) + } + } + is Resource.Loading -> { + + } + + is Resource.DataError -> { + + } + } + } + } + + private fun validate(): Boolean { + if (panString.isEmpty()) { + Common.showDialogValidation( + activity as BajajFdMainActivity, + getString(R.string.uploadPanDoc) + ) + return false + } else if (photoString.isEmpty()) { + Common.showDialogValidation( + activity as BajajFdMainActivity, + getString(R.string.uploadPhotoDoc) + ) + return false + } else if (docString.isEmpty()) { + Common.showDialogValidation( + activity as BajajFdMainActivity, + "Upload $docValue Document" + ) + return false + } else if (docValue == "Aadhar" && docString2.isEmpty()) { + Common.showDialogValidation( + activity as BajajFdMainActivity, + 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", requireActivity().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 + } +} \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/ui/fragment/StepTwoBajajFDFragment.kt b/app/src/main/java/com/nivesh/production/bajajfd/ui/fragment/StepTwoBajajFDFragment.kt new file mode 100644 index 0000000..f552c44 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/ui/fragment/StepTwoBajajFDFragment.kt @@ -0,0 +1,2015 @@ +package com.nivesh.production.bajajfd.ui.fragment + +import android.app.DatePickerDialog +import android.app.Dialog +import android.os.Bundle +import android.text.Editable +import android.text.InputFilter +import android.text.InputFilter.LengthFilter +import android.text.TextWatcher +import android.util.DisplayMetrics +import android.util.Log +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.view.WindowManager +import android.widget.ArrayAdapter +import android.widget.RadioButton +import android.widget.TextView +import androidx.core.content.ContextCompat +import androidx.fragment.app.Fragment +import androidx.recyclerview.widget.GridLayoutManager +import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView +import com.google.android.material.textfield.TextInputEditText +import com.google.gson.Gson +import com.nivesh.production.bajajfd.R +import com.nivesh.production.bajajfd.adapter.BankListAdapter +import com.nivesh.production.bajajfd.adapter.PaymentModeAdapter +import com.nivesh.production.bajajfd.adapter.RecommendedBankListAdapter +import com.nivesh.production.bajajfd.databinding.FragmentBajajfdStepTwoBinding +import com.nivesh.production.bajajfd.model.* +import com.nivesh.production.bajajfd.ui.activity.BajajFdMainActivity +import com.nivesh.production.bajajfd.util.Common.Companion.commonErrorAutoCompleteMethod +import com.nivesh.production.bajajfd.util.Common.Companion.commonErrorMethod +import com.nivesh.production.bajajfd.util.Common.Companion.commonSpinnerErrorMethod +import com.nivesh.production.bajajfd.util.Common.Companion.getDate +import com.nivesh.production.bajajfd.util.Common.Companion.isIndianMobileNo +import com.nivesh.production.bajajfd.util.Common.Companion.isMinor +import com.nivesh.production.bajajfd.util.Common.Companion.isValidEmail +import com.nivesh.production.bajajfd.util.Common.Companion.isValidName +import com.nivesh.production.bajajfd.util.Common.Companion.isValidPan +import com.nivesh.production.bajajfd.util.Common.Companion.removeError +import com.nivesh.production.bajajfd.util.Common.Companion.showDialogValidation +import com.nivesh.production.bajajfd.util.Constants.Companion.token +import com.nivesh.production.bajajfd.util.ProgressUtil +import com.nivesh.production.bajajfd.util.Resource +import java.util.* + + +class StepTwoBajajFDFragment : Fragment() { + + private var _binding: FragmentBajajfdStepTwoBinding? = null + private val binding get() = _binding!! + + private lateinit var listOfTitle: List + private lateinit var listOfGender: List + private lateinit var listOfAnnualIncome: List + private lateinit var listOfRelationShip: List + private lateinit var listOfMaritalStatus: List + private lateinit var listOfOccupation: List + private lateinit var listOfPayMode: List + private lateinit var listOfStates: List + private lateinit var listOfCities: List + private lateinit var listOfIFSC: MutableList + + private lateinit var bankListAdapter: BankListAdapter + private lateinit var paymentModeAdapter: PaymentModeAdapter + private lateinit var stateObject: DataObject + private val listOfBanks: MutableList = mutableListOf() + + private lateinit var rbBank: RadioButton + private lateinit var rbPaymentMode: RadioButton + private var cal = Calendar.getInstance() + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + _binding = FragmentBajajfdStepTwoBinding.inflate(inflater, container, false) + return binding.root + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + listOfTitle = ArrayList() + listOfGender = ArrayList() + listOfAnnualIncome = ArrayList() + listOfRelationShip = ArrayList() + listOfMaritalStatus = ArrayList() + listOfOccupation = ArrayList() + listOfStates = ArrayList() + listOfIFSC = ArrayList() + listOfPayMode = ArrayList() + stateObject = DataObject() + rbPaymentMode = RadioButton(activity as BajajFdMainActivity) + + // Personal Details + binding.edtMobileNumber.filters = arrayOf(LengthFilter(10)) + binding.edtPANNumber.filters = arrayOf(LengthFilter(10)) + binding.edtPinCode.filters = arrayOf(LengthFilter(6)) + binding.edtIFSC.filters = arrayOf(LengthFilter(11)) + + binding.edtMobileNumber.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.tlMobileNumber) + } + }) + binding.edtMobileNumber.setText((activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.mobile) + binding.edtMobileNumber.setSelection(binding.edtMobileNumber.text.toString().length) + // create an OnDateSetListener + if (!(activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_DOB.isNullOrEmpty()) { + binding.edtDOB.setText(getDate((activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_DOB.toString())) + } + binding.edtDOB.setOnClickListener { + removeError(binding.tlDOB) + datePicker(binding.edtDOB, 1) + } + + + binding.edtPANNumber.setText((activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_PAN) + binding.edtPANNumber.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.tlPanNumber) + if (s.toString().trim().length == 10) { + panCheckApi() + } + } + }) + + binding.spTitle.setOnItemClickListener { _, _, _, _ -> + removeError(binding.tlTitle) + } + + binding.edtFirstName.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.tlFirstName) + } + }) + binding.edtMiddleName.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.tlMiddleName) + } + }) + binding.edtLastName.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.tlLastName) + } + }) + + val splitStringName = + (activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_APPNAME1?.split( + "\\s".toRegex() + )?.toTypedArray() + when (splitStringName?.size) { + 1 -> { + binding.edtFirstName.setText(splitStringName[0]) + } + 2 -> { + binding.edtFirstName.setText(splitStringName[0]) + binding.edtLastName.setText(splitStringName[1]) + } + 3 -> { + binding.edtFirstName.setText(splitStringName[0]) + binding.edtMiddleName.setText(splitStringName[1]) + binding.edtLastName.setText(splitStringName[2]) + } + } + + binding.spGender.setOnItemClickListener { _, _, _, _ -> + removeError(binding.tlGender) + } + + binding.edtEmail.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.tlEmail) + } + }) + binding.edtEmail.setText((activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_EMAIL) + + binding.spOccupation.setOnItemClickListener { _, _, _, _ -> + removeError(binding.tlOccupation) + } + + binding.edtQualification.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.tlQualification) + } + }) + + binding.spMarital.setOnItemClickListener { _, _, _, _ -> + removeError(binding.tlMarital) + } + + binding.edtAddressLine1.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.tlAddressLine1) + } + }) + binding.edtAddressLine1.setText((activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_ADD1) + binding.edtAddressLine2.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.tlAddressLine2) + } + }) + binding.edtAddressLine2.setText((activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_ADD2) + binding.edtAddressLine3.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.tlAddressLine3) + } + }) + binding.edtAddressLine3.setText((activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_ADD3) + + binding.spState.setOnItemClickListener { parent, _, position, _ -> + removeError(binding.tlState) + stateObject = parent.getItemAtPosition(position) as DataObject + } + binding.spCity.setOnItemClickListener { _, _, _, _ -> + removeError(binding.tlCity) + } + binding.edtPinCode.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.tlPinCode) + } + }) + binding.edtPinCode.setText((activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_PINCODE) + + // Nominee Details + binding.spNomineeTitle.setOnItemClickListener { _, _, _, _ -> + binding.tlNomineeTitle.error = null + } + + binding.edtNomineeFirstName.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.tlNomineeFirstName) + } + }) + binding.edtNomineeMiddleName.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.tlNomineeMiddleName) + } + }) + binding.edtNomineeLastName.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.tlNomineeLastName) + } + }) + + val splitNomineeName = + (activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.Nominees?.get( + 0 + )?.NomineeName?.split( + "\\s".toRegex() + )?.toTypedArray() + when (splitNomineeName?.size) { + 1 -> { + binding.edtNomineeFirstName.setText(splitNomineeName[0]) + } + 2 -> { + binding.edtNomineeFirstName.setText(splitNomineeName[0]) + binding.edtNomineeLastName.setText(splitNomineeName[1]) + } + 3 -> { + binding.edtNomineeFirstName.setText(splitNomineeName[0]) + binding.edtNomineeMiddleName.setText(splitNomineeName[1]) + binding.edtNomineeLastName.setText(splitNomineeName[2]) + } + } + + if (!(activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.Nominees?.get( + 0 + )?.NomineeDOB.isNullOrEmpty() + ) { + binding.edtNomineeDOB.setText( + getDate( + (activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.Nominees?.get( + 0 + )?.NomineeDOB.toString() + ) + ) + } + binding.edtNomineeDOB.setOnClickListener { + removeError(binding.tlNomineeDOB) + datePicker(binding.edtNomineeDOB, 2) + } + + binding.spNomineeRelation.setText( + (activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.Nominees?.get( + 0 + )?.NomineeRelationship + ) + binding.spNomineeRelation.setOnItemClickListener { _, _, _, _ -> + removeError(binding.tlNomineeRelation) + } + + // Guardian Details + binding.edtGuardianName.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.tlGuardianName) + } + }) + binding.edtGuardianName.setText( + (activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.Nominees?.get( + 0 + )?.NomineeGuardian + ) + + binding.edtGuardianAge.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.tlGuardianAge) + } + }) + + binding.spGuardianRelation.setOnItemClickListener { _, _, _, _ -> + removeError(binding.tlGuardianRelation) + } + + binding.edtGuardianAddress.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.tlGuardianAddress) + } + }) + binding.edtGuardianPinCode.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.tlGuardianPinCode) + } + }) + + binding.rgBank.setOnCheckedChangeListener { group, checkedId -> + rbBank = group.findViewById(checkedId) + Log.e("BankType", "-->" + rbBank.text) + } + + + // Bank Details + binding.edtIFSC.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.tlIFSC) + ifscCodeCheckApi(s.toString()) + } + }) + binding.edtAccountNumber.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.tlAccountNumber) + } + }) + binding.edtBankName.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.tlBankName) + } + }) + binding.edtBankBranch.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.tlBankBranchName) + } + }) + + binding.btnAddBank.setOnClickListener { + if (validateBank()) { + verifyAccountNo( + binding.edtAccountNumber.text.toString(), + binding.edtIFSC.text.toString(), + binding.edtFirstName.text.toString().plus(" ") + .plus(binding.edtMiddleName.text.toString()).plus(" ") + .plus(binding.edtLastName.text.toString()), + binding.edtMobileNumber.text.toString() + , (activity as BajajFdMainActivity).loginRole) + } + } + + binding.tvEligibleBankOption.setOnClickListener { + apiForEligibleBankList() + } + + if ((activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.ClientBanklist?.isEmpty()!!) { + binding.llBankDetails.visibility = View.VISIBLE + } else { + binding.llBankDetails.visibility = View.GONE + } + + binding.addBankDetail.setOnClickListener { + if (bankListAdapter.itemCount == 5) { + showDialogValidation(activity as BajajFdMainActivity, getString(R.string.fiveAccountValidation)) + } else { + showHideBankDetail() + } + } + + titleApi() + setUpRecyclerView( + (activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.ClientBanklist, + (activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_ACCNO1 + ) + + binding.tvPersonalDetails.setOnClickListener { + if (binding.llPersonalDetail.visibility == View.VISIBLE) { + binding.llPersonalDetail.visibility = View.GONE + } else { + binding.llPersonalDetail.visibility = View.VISIBLE + } + } + binding.tvNomineeDetails.setOnClickListener { + if (binding.llNomineeDetail.visibility == View.VISIBLE) { + binding.llNomineeDetail.visibility = View.GONE + } else { + binding.llNomineeDetail.visibility = View.VISIBLE + } + } + binding.tvBankDetails.setOnClickListener { + if (binding.llBankDetails.visibility == View.VISIBLE) { + binding.llBankDetails.visibility = View.GONE + } else { + binding.llBankDetails.visibility = View.VISIBLE + } + } + + binding.btnNext.setOnClickListener { + if (validation()) { + // Applicant Details + (activity as BajajFdMainActivity).applicantDetails.ApplicantSalutation = + binding.spTitle.text.toString() + (activity as BajajFdMainActivity).applicantDetails.ApplicantGender = + binding.spGender.text.toString() + (activity as BajajFdMainActivity).applicantDetails.ApplicantFirstName = + binding.edtFirstName.text.toString() + (activity as BajajFdMainActivity).applicantDetails.ApplicantMiddleName = + binding.edtMiddleName.text.toString() + (activity as BajajFdMainActivity).applicantDetails.ApplicantLastName = + binding.edtLastName.text.toString() + (activity as BajajFdMainActivity).applicantDetails.ApplicantDOB = + binding.edtDOB.text.toString() + (activity as BajajFdMainActivity).applicantDetails.ApplicantPAN = + binding.edtPANNumber.text.toString() + (activity as BajajFdMainActivity).applicantDetails.ApplicantMobile = + binding.edtMobileNumber.text.toString() + (activity as BajajFdMainActivity).applicantDetails.ApplicantOccupation = + binding.spOccupation.text.toString() + (activity as BajajFdMainActivity).applicantDetails.ApplicantQualification = + binding.edtQualification.text.toString() + (activity as BajajFdMainActivity).applicantDetails.ApplicantMaritalStatus = + binding.spMarital.text.toString() + (activity as BajajFdMainActivity).applicantDetails.ApplicantEmail = + binding.edtEmail.text.toString() + (activity as BajajFdMainActivity).applicantDetails.ApplicantAddress1 = + binding.edtAddressLine1.text.toString() + (activity as BajajFdMainActivity).applicantDetails.ApplicantAddress2 = + binding.edtAddressLine2.text.toString() + (activity as BajajFdMainActivity).applicantDetails.ApplicantAddress3 = + binding.edtAddressLine3.text.toString() + (activity as BajajFdMainActivity).applicantDetails.ApplicantCity = + binding.spCity.text.toString() + (activity as BajajFdMainActivity).applicantDetails.ApplicantState = + stateObject.State_Code + (activity as BajajFdMainActivity).applicantDetails.ApplicantCountry = "India" + (activity as BajajFdMainActivity).applicantDetails.ApplicantPincode = + binding.edtPinCode.text.toString().toInt() + (activity as BajajFdMainActivity).applicantDetails.AnnualIncome = + binding.spIncome.text.toString() + + // Applicant Relation Details + (activity as BajajFdMainActivity).applicantRelationDetails.ApplicantRelation = "" + (activity as BajajFdMainActivity).applicantRelationDetails.ApplicantRelationSalutation = + "" + (activity as BajajFdMainActivity).applicantRelationDetails.ApplicantRelationFirstName = + "" + (activity as BajajFdMainActivity).applicantRelationDetails.ApplicantRelationLastName = + "" + (activity as BajajFdMainActivity).applicantRelationDetails.ApplicantMotherFirstName = + "" + (activity as BajajFdMainActivity).applicantRelationDetails.ApplicantMotherLastName = + "" + + // Applicant Nominee Details + (activity as BajajFdMainActivity).nomineeDetails.NomineeSalutation = + binding.spNomineeTitle.text.toString() + (activity as BajajFdMainActivity).nomineeDetails.NomineeGender = + binding.spGender.text.toString() + (activity as BajajFdMainActivity).nomineeDetails.NomineeFirstName = + binding.edtNomineeFirstName.text.toString() + (activity as BajajFdMainActivity).nomineeDetails.NomineeMiddleName = + binding.edtNomineeMiddleName.text.toString() + (activity as BajajFdMainActivity).nomineeDetails.NomineeLastName = + binding.edtNomineeLastName.text.toString() + (activity as BajajFdMainActivity).nomineeDetails.NomineeDOB = + binding.edtNomineeDOB.text.toString() + (activity as BajajFdMainActivity).nomineeDetails.NomineeRelation = + binding.spNomineeRelation.text.toString() + (activity as BajajFdMainActivity).nomineeDetails.NomineeAddress1 = "" + (activity as BajajFdMainActivity).nomineeDetails.NomineeAddress2 = "" + (activity as BajajFdMainActivity).nomineeDetails.NomineeAddress3 = "" + (activity as BajajFdMainActivity).nomineeDetails.NomineeCity = "" + (activity as BajajFdMainActivity).nomineeDetails.NomineeState = "" + (activity as BajajFdMainActivity).nomineeDetails.NomineeCountry = "India" + (activity as BajajFdMainActivity).nomineeDetails.NomineePincode = 0 + + // Applicant Nominee Guardian Details + (activity as BajajFdMainActivity).nomineeGuardianDetails.GuardianSalutation = binding.spGuardianRelation.text.toString() + (activity as BajajFdMainActivity).nomineeGuardianDetails.GuardianName = + binding.edtGuardianName.text.toString() + if (binding.edtGuardianAge.text.toString().isEmpty()) { + (activity as BajajFdMainActivity).nomineeGuardianDetails.GuardianAge = 0 + } else { + (activity as BajajFdMainActivity).nomineeGuardianDetails.GuardianAge = + binding.edtGuardianAge.text.toString().toInt() + } + (activity as BajajFdMainActivity).nomineeGuardianDetails.GuardianCountry = "India" + (activity as BajajFdMainActivity).nomineeGuardianDetails.GuardianCity = "" + (activity as BajajFdMainActivity).nomineeGuardianDetails.GuardianState = "" + if (binding.edtGuardianPinCode.text.toString().isEmpty()) { + (activity as BajajFdMainActivity).nomineeGuardianDetails.GuardianPincode = 0 + } else { + (activity as BajajFdMainActivity).nomineeGuardianDetails.GuardianPincode = + binding.edtGuardianPinCode.text.toString().toInt() + } + + (activity as BajajFdMainActivity).nomineeGuardianDetails.GuardianAddress1 = + binding.edtGuardianAddress.text.toString() + (activity as BajajFdMainActivity).nomineeGuardianDetails.GuardianAddress2 = "" + (activity as BajajFdMainActivity).nomineeGuardianDetails.GuardianAddress3 = "" + + // Applicant Bank Details + (activity as BajajFdMainActivity).fdBankDetails.AccountType = + bankListAdapter.getSelected()?.AccountType + (activity as BajajFdMainActivity).fdBankDetails.BankBranch = + bankListAdapter.getSelected()?.BranchName + (activity as BajajFdMainActivity).fdBankDetails.IFSCCode = + bankListAdapter.getSelected()?.IFSCCode + (activity as BajajFdMainActivity).fdBankDetails.AccountNumber = + bankListAdapter.getSelected()?.AccountNumber + (activity as BajajFdMainActivity).fdBankDetails.BankName = + bankListAdapter.getSelected()?.BankName + (activity as BajajFdMainActivity).fdBankDetails.PaymentMode = + rbPaymentMode.text.toString() + + (activity as BajajFdMainActivity).createFDApplicantRequest.ApplicantDetails = + (activity as BajajFdMainActivity).applicantDetails + (activity as BajajFdMainActivity).createFDApplicantRequest.ApplicantRelationDetails = + (activity as BajajFdMainActivity).applicantRelationDetails + (activity as BajajFdMainActivity).createFDApplicantRequest.FdBankDetails = + (activity as BajajFdMainActivity).fdBankDetails + (activity as BajajFdMainActivity).createFDApplicantRequest.NomineeDetails = + (activity as BajajFdMainActivity).nomineeDetails + (activity as BajajFdMainActivity).createFDApplicantRequest.NomineeGuardianDetails = + (activity as BajajFdMainActivity).nomineeGuardianDetails + + + (activity as BajajFdMainActivity).createFDRequest.CreateFDApplicationRequest = + (activity as BajajFdMainActivity).createFDApplicantRequest + Log.e( + "StepTwoResponse", + "-->" + Gson().toJson((activity as BajajFdMainActivity).createFDRequest) + ) + createFDApi((activity as BajajFdMainActivity).createFDRequest) + } + } + + binding.btnBack.setOnClickListener { + (activity as BajajFdMainActivity).binding.viewPager.currentItem = 0 + } + + } + + private fun createFDApi(data: CreateFDRequest) { + ProgressUtil.showLoading(activity as BajajFdMainActivity) + (activity as BajajFdMainActivity).viewModel.createFDApi(data, token, activity as BajajFdMainActivity) + (activity as BajajFdMainActivity).viewModel.getFDResponseMutableData.observe(viewLifecycleOwner) { response -> + when (response) { + is Resource.Success -> { + Log.e("createFDApi ", " response -->$response") + val createFDApplicationResponse: CreateFDApplicationResponse = + Gson().fromJson( + response.data?.toString(), + CreateFDApplicationResponse::class.java + ) + createFDApplicationResponse.Response.StatusCode.let { code -> + when (code) { + 200 -> { + (activity as BajajFdMainActivity).uniqueId = createFDApplicationResponse.Response.FDCreationDetailsResponse.UniqueId + (activity as BajajFdMainActivity).stepTwoApi() + + } + // 650 -> refreshToken() + else -> { + showDialogValidation( + activity as BajajFdMainActivity, + createFDApplicationResponse.Response.Errors[0].ErrorMessage + ) + } + } + } + } + + is Resource.Error -> { + response.message?.let { message -> + showDialogValidation(activity as BajajFdMainActivity, message) + } + } + is Resource.Loading -> { + ProgressUtil.hideLoading() + } + is Resource.DataError -> { + + } + } + } + } + + private fun ifscCodeCheckApi(ifsc: String) { + if (ifsc.length >= 10) { + (activity as BajajFdMainActivity).viewModel.ifscCodeApi(ifsc, activity as BajajFdMainActivity) + (activity as BajajFdMainActivity).viewModel.getIfscCodeCheckMutableData.observe(viewLifecycleOwner) { response -> + when (response) { + is Resource.Success -> { + Log.e("ifscCodeCheckApi ", " response -->$response") + val getIFSCCodeListResponse = + Gson().fromJson( + response.data?.toString(), + GetIFSCCodeListResponse::class.java + ) + getIFSCCodeListResponse.Response.status_code.let { code -> + when (code) { + 200 -> { + if (listOfIFSC.size > 0) { + listOfIFSC.clear() + } + listOfIFSC = getIFSCCodeListResponse.IFSCCodes + if (listOfIFSC.size > 0) { + val adapter = ArrayAdapter( + activity as BajajFdMainActivity, + R.layout.spinner_dropdown, + listOfIFSC + ) + binding.edtIFSC.setAdapter(adapter) + binding.edtIFSC.setOnItemClickListener { _, _, position, _ -> + if (listOfIFSC.size > 0) { + binding.edtIFSC.setText( + adapter.getItem(position).toString() + ) + binding.edtIFSC.setSelection(binding.edtIFSC.text.toString().length) + getIFSCDetailsApi(binding.edtIFSC.text.toString()) + } + } + } + } + // 650 -> refreshToken() + else -> { + showDialogValidation( + activity as BajajFdMainActivity, + getIFSCCodeListResponse.Response.message + ) + } + } + } + } + + is Resource.Error -> { + response.message?.let { message -> + showDialogValidation( + activity as BajajFdMainActivity, + message + ) + } + } + is Resource.Loading -> { + + } + is Resource.DataError -> { + + } + } + } + } + } + + private fun getIFSCDetailsApi(ifscCode: String) { + + (activity as BajajFdMainActivity).viewModel.ifscCodeDetailsApi( + ifscCode, + activity as BajajFdMainActivity + ) + (activity as BajajFdMainActivity).viewModel.getIfscCodeDetailsCheckMutableData.observe(viewLifecycleOwner) { response -> + when (response) { + is Resource.Success -> { + if (response.data.toString().isNotEmpty()) { + Log.e("getIFSCDetailsApi ", " response -->$response") + val getIFSCCodeResponse = Gson().fromJson( + response.data.toString(), + GetIFSCCodeResponse::class.java + ) + binding.edtBankName.setText(getIFSCCodeResponse.IFSCCODEServiceResult[0].BnkDescr) + binding.edtBankName.setSelection(binding.edtBankName.text.toString().length) + binding.edtBankBranch.setText(getIFSCCodeResponse.IFSCCODEServiceResult[0].BankBranch) + binding.edtBankBranch.setSelection( binding.edtBankBranch.text.toString().length) + } + } + is Resource.Error -> { + response.message?.let { message -> + showDialogValidation(activity as BajajFdMainActivity, message) + } + } + is Resource.Loading -> { + + } + is Resource.DataError -> { + + } + + } + + } + } + + private fun verifyAccountNo( + bankAccount: String, Ifsc: String, name: String, phoneNumber: String + ,loginRole : Int) { + + val bankValidationApiRequest = BankValidationApiRequest() + bankValidationApiRequest.BankAccountNo = bankAccount + bankValidationApiRequest.IFSC = Ifsc + bankValidationApiRequest.Name = name + bankValidationApiRequest.PhoneNo = phoneNumber + bankValidationApiRequest.RoleId = loginRole + bankValidationApiRequest.BankNo = 1 + ProgressUtil.showLoading(activity as BajajFdMainActivity) + (activity as BajajFdMainActivity).viewModel.bankValidationApi( + bankValidationApiRequest, + token, + activity as BajajFdMainActivity + ) + (activity as BajajFdMainActivity).viewModel.bankValidationApiMutableData.observe(viewLifecycleOwner) { response -> + when (response) { + is Resource.Success -> { + Log.e("verifyAccountNo ", " response -->$response") + val getBankValidationApiResponse = + Gson().fromJson( + response.data?.toString(), + BankValidationApiResponse::class.java + ) + getBankValidationApiResponse.response.status_code.let { code -> + if (binding.tvAcVerify.visibility == View.GONE) { + binding.tvAcVerify.visibility = View.VISIBLE + } + when (code) { + 200 -> { + if (getBankValidationApiResponse.Message == getString(R.string.accountVerified)) { + val clientBankList = ClientBanklist() + clientBankList.AccountNumber = bankAccount + clientBankList.AccountType = "sb" + clientBankList.BankName = + binding.edtBankName.text.toString() + clientBankList.BranchName = + binding.edtBankBranch.text.toString() + clientBankList.IFSCCode = Ifsc + clientBankList.IsValBank = 1 + (activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.ClientBanklist?.let { + listOfBanks.addAll( + it + ) + } + listOfBanks.add(clientBankList) + setUpRecyclerView( + listOfBanks, + clientBankList.AccountNumber.toString() + ) + showHideBankDetail() + + } else { + showDialogValidation( + activity as BajajFdMainActivity, + getBankValidationApiResponse.Message + ) + showHideBankDetail() + } + } + else -> { + showDialogValidation( + activity as BajajFdMainActivity, + getBankValidationApiResponse.Message + ) + showHideBankDetail() + } + } + } + } + + is Resource.Error -> { + response.message?.let { message -> + showDialogValidation(activity as BajajFdMainActivity, message) + } + } + is Resource.Loading -> { + ProgressUtil.hideLoading() + } + is Resource.DataError -> { + + } + } + } + } + + private fun validateBank(): Boolean { + return if (binding.edtIFSC.text.toString().isEmpty()) { // EditText + commonErrorAutoCompleteMethod( + binding.edtIFSC, + binding.tlIFSC, + getString(R.string.emptyIFSCCode) + ) + } else if (binding.edtIFSC.text.toString().length != 11) { // EditText + commonErrorAutoCompleteMethod( + binding.edtIFSC, + binding.tlIFSC, + getString(R.string.validIFSCCode) + ) + } else if (binding.edtAccountNumber.text.toString().isEmpty()) { // EditText + commonErrorMethod( + binding.edtAccountNumber, + binding.tlAccountNumber, + getString(R.string.emptyAccNo) + ) + } else if (binding.edtBankName.text.toString().isEmpty()) { // EditText + commonErrorMethod( + binding.edtBankName, + binding.tlBankName, + getString(R.string.emptyBankName) + ) + } else if (binding.edtBankBranch.text.toString().isEmpty()) { // EditText + commonErrorMethod( + binding.edtBankBranch, + binding.tlBankBranchName, + getString(R.string.emptyBranchName) + ) + } else { + return true + } + } + + private fun setUpRecyclerView( + bankList: List?, + selectedAccount: String? = null + ) { + val displayMetrics = DisplayMetrics() + requireActivity().windowManager.defaultDisplay.getMetrics(displayMetrics) + val width = displayMetrics.widthPixels.toDouble() + binding.rvClientBankList.layoutManager = LinearLayoutManager( + activity as BajajFdMainActivity, + LinearLayoutManager.HORIZONTAL, + false + ) + bankListAdapter = BankListAdapter(bankList, selectedAccount, width) + binding.rvClientBankList.adapter = bankListAdapter + } + + private fun datePicker(edtDOB: TextInputEditText, number : Int) { + val year = cal.get(Calendar.YEAR) + val month = cal.get(Calendar.MONTH) + val day = cal.get(Calendar.DAY_OF_MONTH) + val datePickerDialog = DatePickerDialog( + activity as BajajFdMainActivity, { _, years, monthOfYear, dayOfMonth -> + if (monthOfYear.toString().length == 1) { + "0".plus(monthOfYear) + } + edtDOB.setText( + years.toString().plus("-").plus(monthOfYear + 1).plus("-") + .plus(dayOfMonth.toString()) + ) + edtDOB.setSelection(edtDOB.text.toString().length) + if (number == 2){ + if (isMinor(years.toString().plus("-").plus(monthOfYear + 1).plus("-") + .plus(dayOfMonth.toString())) + ){ + guardianCodeVisibility(View.VISIBLE) + }else{ + guardianCodeVisibility(View.GONE) + } + } + }, year, month, day + ) + datePickerDialog.datePicker.maxDate = cal.timeInMillis + val c = Calendar.getInstance() + c.add(Calendar.YEAR, -140) + datePickerDialog.datePicker.minDate = c.timeInMillis + datePickerDialog.show() + } + + private fun guardianCodeVisibility(visibility: Int) { + binding.tlGuardianName.visibility = visibility + binding.tlGuardianName.visibility = visibility + binding.tlGuardianName.visibility = visibility + binding.tlGuardianName.visibility = visibility + binding.tlGuardianName.visibility = visibility + + } + + private fun panCheckApi() { + val panCheck = PanCheckRequest() + panCheck.clientCode = + (activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_CODE + panCheck.subBrokerCode = + (activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.sub_broker_code + panCheck.panNumber = binding.edtPANNumber.text.toString() + panCheck.mobileNumber = "" + (activity as BajajFdMainActivity).viewModel.panCheck(panCheck, token, activity as BajajFdMainActivity) + (activity as BajajFdMainActivity).viewModel.getPanCheckMutableData.observe(viewLifecycleOwner) { response -> + when (response) { + is Resource.Success -> { + Log.e("panCheckApi ", " response -->$response") + val panCheckResponse = + Gson().fromJson( + response.data?.toString(), + PanCheckResponse::class.java + ) + panCheckResponse.response.status_code.let { code -> + if (binding.tvPANVerify.visibility == View.GONE) { + binding.tvPANVerify.visibility = View.VISIBLE + } + when (code) { + 200 -> { + binding.tvPANVerify.text = getString(R.string.verifiedText) + binding.tvPANVerify.setTextColor( + ContextCompat.getColor( + activity as BajajFdMainActivity, + R.color.green + ) + ) + } + // 650 -> refreshToken() + else -> { + binding.tvPANVerify.text = getString(R.string.notVerifiedText) + binding.tvPANVerify.setTextColor( + ContextCompat.getColor( + activity as BajajFdMainActivity, + R.color.red + ) + ) + } + } + } + } + + is Resource.Error -> { + response.message?.let { message -> + showDialogValidation(activity as BajajFdMainActivity, message) + } + } + is Resource.Loading -> { + + } + is Resource.DataError -> { + + } + } + } + } + + private fun titleApi() { + val getCodeRequest = GetCodeRequest() + getCodeRequest.ProductName = getString(R.string.bajajFD) + getCodeRequest.Category = getString(R.string.salutationCategory) + getCodeRequest.Language = getString(R.string.language) + getCodeRequest.InputValue = "" + (activity as BajajFdMainActivity).viewModel.titleApi(getCodeRequest, token, activity as BajajFdMainActivity) + (activity as BajajFdMainActivity).viewModel.getTitleMutableData.observe(viewLifecycleOwner) { response -> + when (response) { + is Resource.Success -> { + Log.e("titleApi ", " response -->$response") + val getCodeResponse: GetCodeResponse = + Gson().fromJson(response.data?.toString(), GetCodeResponse::class.java) + getCodeResponse.Response.StatusCode.let { code -> + when (code) { + 200 -> { + listOfTitle = getCodeResponse.Response.GetCodesList + if (listOfTitle.isNotEmpty()) { + val adapter = ArrayAdapter( + activity as BajajFdMainActivity, + R.layout.spinner_dropdown, + listOfTitle + ) + binding.spTitle.setAdapter(adapter) + + val titleText = + (activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.Client_Title + val newTitleText = "$titleText." + + if (titleText.isNullOrEmpty()) { + binding.spTitle.setText( + adapter.getItem(0)?.Value, + false + ) + } else { + for (title in listOfTitle) { + if (title.Value == newTitleText) { + binding.spTitle.setText(title.Value, false) + break + } + } + } + binding.spNomineeTitle.setAdapter(adapter) + binding.spNomineeTitle.setText( + adapter.getItem(0)?.Value, + false + ) + } + genderApi() + relationShipApi() + maritalStatusApi() + occupationApi() + annualIncomeApi() + stateListApi() + paymentModeApi() + + } + // 650 -> refreshToken() + else -> { + showDialogValidation( + activity as BajajFdMainActivity, + getCodeResponse.Response.Errors[0].ErrorMessage + ) + } + } + } + } + + is Resource.Error -> { + response.message?.let { message -> + showDialogValidation(activity as BajajFdMainActivity, message) + } + } + is Resource.Loading -> { + + } + is Resource.DataError -> { + + } + } + } + } + + private fun paymentModeApi() { + val getCodeRequest = GetCodeRequest() + getCodeRequest.ProductName = getString(R.string.bajajFD) + getCodeRequest.Category = getString(R.string.paymentModeCategory) + getCodeRequest.Language = getString(R.string.language) + getCodeRequest.InputValue = "" + (activity as BajajFdMainActivity).viewModel.paymentModeApi( + getCodeRequest, + token, + activity as BajajFdMainActivity + ) + (activity as BajajFdMainActivity).viewModel.getPaymentModeMutableData.observe(viewLifecycleOwner) { response -> + when (response) { + is Resource.Success -> { + Log.e("paymentModeApi ", " response -->$response") + val getCodeResponse: GetCodeResponse = + Gson().fromJson(response.data?.toString(), GetCodeResponse::class.java) + getCodeResponse.Response.StatusCode.let { code -> + when (code) { + 200 -> { + if (getCodeResponse.Response.GetCodesList.isNotEmpty()) { + listOfPayMode = getCodeResponse.Response.GetCodesList + setUpRecyclerViewPaymentMode(listOfPayMode) + } + } + // 650 -> refreshToken() + else -> { + showDialogValidation( + activity as BajajFdMainActivity, + getCodeResponse.Response.Errors[0].ErrorMessage + ) + } + } + } + } + + is Resource.Error -> { + response.message?.let { message -> + showDialogValidation(activity as BajajFdMainActivity, message) + } + } + is Resource.Loading -> { + + } + is Resource.DataError -> { + + } + } + } + } + + private fun setUpRecyclerViewPaymentMode(listOfPayMode: List) { + + binding.rvPaymentMode.layoutManager = + GridLayoutManager(activity as BajajFdMainActivity, 2) + paymentModeAdapter = PaymentModeAdapter( + listOfPayMode, + listOfPayMode[0].Value + ) + binding.rvPaymentMode.adapter = paymentModeAdapter + } + + private fun genderApi() { + val getCodeRequest = GetCodeRequest() + getCodeRequest.ProductName = getString(R.string.bajajFD) + getCodeRequest.Category = getString(R.string.genderCategory) + getCodeRequest.Language = getString(R.string.language) + getCodeRequest.InputValue = "" + (activity as BajajFdMainActivity).viewModel.genderApi( + getCodeRequest, + token, + activity as BajajFdMainActivity + ) + (activity as BajajFdMainActivity).viewModel.getGenderMutableData.observe(viewLifecycleOwner) { response -> + when (response) { + is Resource.Success -> { + Log.e("genderApi ", " response -->$response") + val getCodeResponse: GetCodeResponse = + Gson().fromJson(response.data?.toString(), GetCodeResponse::class.java) + getCodeResponse.Response.StatusCode.let { code -> + when (code) { + 200 -> { + listOfGender = getCodeResponse.Response.GetCodesList + if (listOfGender.isNotEmpty()) { + val adapter = ArrayAdapter( + activity as BajajFdMainActivity, + R.layout.spinner_dropdown, + listOfGender + ) + binding.spGender.setAdapter(adapter) + binding.spGender.setText( + adapter.getItem(0)?.Value, + false + ) + } + } + // 650 -> refreshToken() + else -> { + showDialogValidation( + activity as BajajFdMainActivity, + getCodeResponse.Response.Errors[0].ErrorMessage + ) + } + } + } + } + + is Resource.Error -> { + response.message?.let { message -> + showDialogValidation(activity as BajajFdMainActivity, message) + } + } + is Resource.Loading -> { + + } + is Resource.DataError -> { + + } + } + } + } + + private fun relationShipApi() { + val getCodeRequest = GetCodeRequest() + getCodeRequest.ProductName = getString(R.string.bajajFD) + getCodeRequest.Category = getString(R.string.relationshipCategory) + getCodeRequest.Language = getString(R.string.language) + getCodeRequest.InputValue = "" + (activity as BajajFdMainActivity).viewModel.relationShipApi( + getCodeRequest, + token, + activity as BajajFdMainActivity + ) + (activity as BajajFdMainActivity).viewModel.getRelationShipMutableData.observe(viewLifecycleOwner) { response -> + when (response) { + is Resource.Success -> { + Log.e("relationShipApi ", " response -->$response") + val getCodeResponse: GetCodeResponse = + Gson().fromJson(response.data?.toString(), GetCodeResponse::class.java) + getCodeResponse.Response.StatusCode.let { code -> + when (code) { + 200 -> { + listOfRelationShip = getCodeResponse.Response.GetCodesList + if (listOfGender.isNotEmpty()) { + val adapter = ArrayAdapter( + activity as BajajFdMainActivity, + R.layout.spinner_dropdown, + listOfRelationShip + ) + + binding.spNomineeRelation.setAdapter(adapter) + binding.spNomineeRelation.setText( + adapter.getItem(0)?.Value, + false + ) + + binding.spGuardianRelation.setAdapter(adapter) + binding.spGuardianRelation.setText( + adapter.getItem(0)?.Value, + false + ) + } + } + // 650 -> refreshToken() + else -> { + showDialogValidation( + activity as BajajFdMainActivity, + getCodeResponse.Response.Errors[0].ErrorMessage + ) + } + } + } + } + + is Resource.Error -> { + response.message?.let { message -> + showDialogValidation(activity as BajajFdMainActivity, message) + } + } + is Resource.Loading -> { + + } + + is Resource.DataError -> { + + } + } + } + } + + private fun maritalStatusApi() { + val getCodeRequest = GetCodeRequest() + getCodeRequest.ProductName = getString(R.string.bajajFD) + getCodeRequest.Category = getString(R.string.maritalCategory) + getCodeRequest.Language = getString(R.string.language) + getCodeRequest.InputValue = "" + (activity as BajajFdMainActivity).viewModel.maritalStatusApi( + getCodeRequest, + token, + activity as BajajFdMainActivity + ) + (activity as BajajFdMainActivity).viewModel.getMaritalStatusMutableData.observe(viewLifecycleOwner) { response -> + when (response) { + is Resource.Success -> { + Log.e("maritalStatusApi ", " response -->$response") + val getCodeResponse: GetCodeResponse = + Gson().fromJson(response.data?.toString(), GetCodeResponse::class.java) + getCodeResponse.Response.StatusCode.let { code -> + when (code) { + 200 -> { + listOfMaritalStatus = getCodeResponse.Response.GetCodesList + if (listOfMaritalStatus.isNotEmpty()) { + val adapter = ArrayAdapter( + activity as BajajFdMainActivity, + R.layout.spinner_dropdown, + listOfMaritalStatus + ) + binding.spMarital.setAdapter(adapter) + binding.spMarital.setText( + adapter.getItem(0)?.Value, + false + ) + } + } + // 650 -> refreshToken() + else -> { + showDialogValidation( + activity as BajajFdMainActivity, + getCodeResponse.Response.Errors[0].ErrorMessage + ) + } + } + } + } + + is Resource.Error -> { + response.message?.let { message -> + showDialogValidation(activity as BajajFdMainActivity, message) + } + } + is Resource.Loading -> { + + } + is Resource.DataError -> { + + } + } + } + } + + private fun occupationApi() { + val getCodeRequest = GetCodeRequest() + getCodeRequest.ProductName = getString(R.string.bajajFD) + getCodeRequest.Category = getString(R.string.occupationCategory) + getCodeRequest.Language = getString(R.string.language) + getCodeRequest.InputValue = "" + (activity as BajajFdMainActivity).viewModel.occupationApi( + getCodeRequest, + token, + activity as BajajFdMainActivity + ) + (activity as BajajFdMainActivity).viewModel.getOccupationMutableData.observe(viewLifecycleOwner) { response -> + when (response) { + is Resource.Success -> { + Log.e("occupationApi ", " response -->$response") + val getCodeResponse: GetCodeResponse = + Gson().fromJson(response.data?.toString(), GetCodeResponse::class.java) + getCodeResponse.Response.StatusCode.let { code -> + when (code) { + 200 -> { + listOfOccupation = getCodeResponse.Response.GetCodesList + if (listOfOccupation.isNotEmpty()) { + val adapter = ArrayAdapter( + activity as BajajFdMainActivity, + R.layout.spinner_dropdown, + listOfOccupation + ) + binding.spOccupation.setAdapter(adapter) + binding.spOccupation.setText( + adapter.getItem(0)?.Label, + false + ) + } + } + // 650 -> refreshToken() + else -> { + showDialogValidation( + activity as BajajFdMainActivity, + getCodeResponse.Response.Errors[0].ErrorMessage + ) + } + } + } + } + + is Resource.Error -> { + response.message?.let { message -> + showDialogValidation(activity as BajajFdMainActivity, message) + } + } + is Resource.Loading -> { + + } + is Resource.DataError -> { + + } + } + } + } + + private fun annualIncomeApi() { + val getCodeRequest = GetCodeRequest() + getCodeRequest.ProductName = getString(R.string.bajajFD) + getCodeRequest.Category = getString(R.string.annualIncome) + getCodeRequest.Language = getString(R.string.language) + getCodeRequest.InputValue = "" + (activity as BajajFdMainActivity).viewModel.annualIncomeApi( + getCodeRequest, + token, + activity as BajajFdMainActivity + ) + (activity as BajajFdMainActivity).viewModel.getAnnualIncomeMutableData.observe(viewLifecycleOwner) { response -> + when (response) { + is Resource.Success -> { + Log.e("annualIncomeApi ", " response -->$response") + val getCodeResponse: GetCodeResponse = + Gson().fromJson(response.data?.toString(), GetCodeResponse::class.java) + getCodeResponse.Response.StatusCode.let { code -> + when (code) { + 200 -> { + listOfAnnualIncome = getCodeResponse.Response.GetCodesList + if (listOfAnnualIncome.isNotEmpty()) { + val adapter = ArrayAdapter( + activity as BajajFdMainActivity, + R.layout.spinner_dropdown, + listOfAnnualIncome + ) + binding.spIncome.setAdapter(adapter) + binding.spIncome.setText( + adapter.getItem(0)?.Value, + false + ) + } + } + // 650 -> refreshToken() + else -> { + showDialogValidation( + activity as BajajFdMainActivity, + getCodeResponse.Response.Errors[0].ErrorMessage + ) + } + } + } + } + + is Resource.Error -> { + response.message?.let { message -> + showDialogValidation(activity as BajajFdMainActivity, message) + } + } + is Resource.Loading -> { + + } + is Resource.DataError -> { + + } + } + } + } + + private fun stateListApi() { + (activity as BajajFdMainActivity).viewModel.stateApi(token, activity as BajajFdMainActivity) + (activity as BajajFdMainActivity).viewModel.getStateMasterMutableData.observe(viewLifecycleOwner) { response -> + when (response) { + is Resource.Success -> { + Log.e("stateListApi ", " response -->$response") + val stateListResponse: StateListResponse = + Gson().fromJson( + response.data?.toString(), + StateListResponse::class.java + ) + stateListResponse.response.status_code.let { code -> + when (code) { + 200 -> { + listOfStates = stateListResponse.DataObject + if (listOfStates.isNotEmpty()) { + val adapter = ArrayAdapter( + activity as BajajFdMainActivity, + R.layout.spinner_dropdown, + listOfStates + ) + binding.spState.setAdapter(adapter) + val newTitleText = + (activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_STATE + if (newTitleText?.isEmpty()!!) { + binding.spState.setText( + adapter.getItem(0)?.State_Name, + false + ) + cityListApi(adapter.getItem(0)?.State_Id) + + stateObject = adapter.getItem(0) as DataObject + Log.e("if", " -->" + stateObject.State_Code) + } else { + for (title in listOfStates) { + if (title.State_Code == newTitleText) { + binding.spState.setText(title.State_Name, false) + cityListApi(title.State_Id) + stateObject = title + Log.e("else", " -->" + stateObject.State_Code) + break + } + } + } + } + } + // 650 -> refreshToken() + else -> { + showDialogValidation( + activity as BajajFdMainActivity, + stateListResponse.response.message + ) + } + } + } + } + + is Resource.Error -> { + response.message?.let { message -> + showDialogValidation(activity as BajajFdMainActivity, message) + } + } + is Resource.Loading -> { + + } + is Resource.DataError -> { + + } + } + } + } + + private fun cityListApi(stateCode: Int?) { + + val cityRequest = CityRequest() + cityRequest.StateCode = stateCode + cityRequest.Type = "" + cityRequest.ClientCode = + (activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_CODE + cityRequest.RoleID = (activity as BajajFdMainActivity).loginRole + cityRequest.APIName = "" + cityRequest.UID = 0 + cityRequest.Subbroker_Code = + (activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.sub_broker_code + cityRequest.RMCode = "" + cityRequest.HOCode = "" + cityRequest.Source = getString(R.string.source) + cityRequest.APP_Web = getString(R.string.app) + (activity as BajajFdMainActivity).viewModel.cityListApi(cityRequest, token, activity as BajajFdMainActivity) + (activity as BajajFdMainActivity).viewModel.getCityListMutableData.observe(viewLifecycleOwner) { response -> + when (response) { + is Resource.Success -> { + Log.e("cityListApi ", " response -->$response") + val cityListResponse: CityListResponse = + Gson().fromJson(response.data?.toString(), CityListResponse::class.java) + cityListResponse.response.status_code.let { code -> + when (code) { + 200 -> { + listOfCities = cityListResponse.DataObject + if (listOfCities.isNotEmpty()) { + val adapter = ArrayAdapter( + activity as BajajFdMainActivity, + R.layout.spinner_dropdown, + listOfCities + ) + binding.spCity.setAdapter(adapter) + + val newTitleText = + (activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_CITY + if (newTitleText?.isEmpty()!!) { + binding.spCity.setText( + adapter.getItem(0)?.city_name, + false + ) + } else { + for (title in listOfCities) { + if (title.city_name == newTitleText) { + binding.spCity.setText(title.city_name, false) + break + } + } + } + } + } + // 650 -> refreshToken() + else -> { + showDialogValidation( + activity as BajajFdMainActivity, + cityListResponse.response.message + ) + } + } + } + } + + is Resource.Error -> { + response.message?.let { message -> + showDialogValidation(activity as BajajFdMainActivity, message) + } + } + is Resource.Loading -> { + + } + is Resource.DataError -> { + + } + } + } + } + + private fun apiForEligibleBankList() { + ProgressUtil.showLoading(activity as BajajFdMainActivity) + (activity as BajajFdMainActivity).viewModel.bankListApi(token,getString(R.string.language), activity as BajajFdMainActivity) + (activity as BajajFdMainActivity).viewModel.getFDBankListMutableData.observe(viewLifecycleOwner) { response -> + when (response) { + is Resource.Success -> { + Log.e("apiForEligibleBankList ", " response -->$response") + val getFDBankListResponse: GetFDBankListResponse = + Gson().fromJson( + response.data?.toString(), + GetFDBankListResponse::class.java + ) + getFDBankListResponse.Response.StatusCode.let { code -> + when (code) { + 200 -> { + if (getFDBankListResponse.Response.BankList.isNotEmpty()) { + dialogForBankList(getFDBankListResponse.Response.BankList) + } + } + 650 -> refreshToken() + else -> { + showDialogValidation( + activity as BajajFdMainActivity, + getFDBankListResponse.Response.Errors[0].ErrorMessage + ) + } + } + } + } + + is Resource.Error -> { + response.message?.let { message -> + showDialogValidation(activity as BajajFdMainActivity, message) + } + } + is Resource.Loading -> { + ProgressUtil.hideLoading() + } + is Resource.DataError -> { + + } + } + } + } + + private fun refreshToken() { + + } + + private fun dialogForBankList(bankList: List) { + val dialog = Dialog(activity as BajajFdMainActivity) + dialog.setContentView(R.layout.layout_bank_list) + dialog.setCancelable(true) + dialog.window!! + .setLayout( + WindowManager.LayoutParams.MATCH_PARENT, + WindowManager.LayoutParams.MATCH_PARENT + ) + val rvClientList = dialog.findViewById(R.id.rvBankList) + rvClientList.layoutManager = LinearLayoutManager(activity as BajajFdMainActivity) + val tvCancel = dialog.findViewById(R.id.tvCancel) + tvCancel.setOnClickListener { + dialog.dismiss() + } + + if (bankList.isNotEmpty()) { + val bankListAdapter = RecommendedBankListAdapter(bankList) + rvClientList.adapter = bankListAdapter + } + dialog.show() + } + + // validations + private fun validation(): Boolean { + return if (binding.edtMobileNumber.text.toString().isEmpty()) { // EditText + commonErrorMethod( + binding.edtMobileNumber, + binding.tlMobileNumber, + getString(R.string.emptyMobileNumber) + ) + } else if (!isIndianMobileNo(binding.edtMobileNumber.text.toString())) { // EditText + commonErrorMethod( + binding.edtMobileNumber, + binding.tlMobileNumber, + getString(R.string.inValidIndianMobileNumber) + ) + } else if (binding.edtMobileNumber.text?.length != 10) { // EditText + commonErrorMethod( + binding.edtMobileNumber, + binding.tlMobileNumber, + getString(R.string.inValidMobileNumber) + ) + } else if (binding.edtDOB.text.toString().isEmpty()) { // EditText + commonErrorMethod(binding.edtDOB, binding.tlDOB, getString(R.string.emptyDOB)) + } else if (binding.edtPANNumber.text.toString().isEmpty()) { // EditText + commonErrorMethod( + binding.edtPANNumber, + binding.tlPanNumber, + getString(R.string.emptyPAN) + ) + } else if (!isValidPan(binding.edtPANNumber.text.toString())) { // EditText + commonErrorMethod( + binding.edtPANNumber, + binding.tlPanNumber, + getString(R.string.invalidPAN) + ) + } else if (binding.spTitle.text.isEmpty()) { // Spinner + commonSpinnerErrorMethod( + binding.spTitle, + binding.tlTitle, + getString(R.string.emptyTitle) + ) + } else if (binding.spGender.text.toString().isEmpty()) { // Spinner + commonSpinnerErrorMethod( + binding.spGender, + binding.tlGender, + getString(R.string.emptyGender) + ) + } else if (binding.edtFirstName.text.toString().isEmpty()) { // EditText + commonErrorMethod( + binding.edtFirstName, + binding.tlFirstName, + getString(R.string.emptyFirstName) + ) + } else if (!isValidName(binding.edtFirstName.text.toString())) { // EditText + commonErrorMethod( + binding.edtFirstName, + binding.tlFirstName, + getString(R.string.validFirstName) + ) + } else if (binding.edtMiddleName.text.toString().isEmpty()) { // EditText + commonErrorMethod( + binding.edtMiddleName, + binding.tlMiddleName, + getString(R.string.emptyMiddleName) + ) + } else if (!isValidName(binding.edtMiddleName.text.toString())) { // EditText + commonErrorMethod( + binding.edtMiddleName, + binding.tlMiddleName, + getString(R.string.validMiddleName) + ) + } else if (binding.edtLastName.text.toString().isEmpty()) { // EditText + commonErrorMethod( + binding.edtLastName, + binding.tlLastName, + getString(R.string.emptyLastName) + ) + } else if (!isValidName(binding.edtLastName.text.toString())) { // EditText + commonErrorMethod( + binding.edtLastName, + binding.tlLastName, + getString(R.string.validLastName) + ) + } else if (binding.spOccupation.text.toString().isEmpty()) { // EditText + commonSpinnerErrorMethod( + binding.spOccupation, + binding.tlOccupation, + getString(R.string.emptyOccupation) + ) + } else if (binding.spIncome.text.toString().isEmpty()) { // EditText + commonSpinnerErrorMethod( + binding.spIncome, + binding.tlIncome, + getString(R.string.emptyIncome) + ) + } else if (binding.edtQualification.text.toString().isEmpty()) { // EditText + commonErrorMethod( + binding.edtQualification, + binding.tlQualification, + getString(R.string.emptyQualification) + ) + } else if (binding.spMarital.text.toString().isEmpty()) { // Spinner + commonSpinnerErrorMethod( + binding.spMarital, + binding.tlMarital, + getString(R.string.emptyMaritalStatus) + ) + } else if (binding.edtEmail.text.toString().isEmpty()) { // EditText + commonErrorMethod(binding.edtEmail, binding.tlEmail, getString(R.string.emptyEmail)) + } else if (!isValidEmail(binding.edtEmail.text.toString())) { // EditText + commonErrorMethod(binding.edtEmail, binding.tlEmail, getString(R.string.validEmail)) + } else if (binding.edtAddressLine1.text.toString().isEmpty()) { // EditText + commonErrorMethod( + binding.edtAddressLine1, + binding.tlAddressLine1, + getString(R.string.emptyAddressLine1) + ) + } else if (binding.edtAddressLine2.text.toString().isEmpty()) { // EditText + commonErrorMethod( + binding.edtAddressLine2, + binding.tlAddressLine2, + getString(R.string.emptyAddressLine2) + ) + } else if (binding.edtAddressLine3.text.toString().isEmpty()) { // EditText + commonErrorMethod( + binding.edtAddressLine3, + binding.tlAddressLine3, + getString(R.string.emptyAddressLine3) + ) + } else if (binding.spState.text.toString().isEmpty()) { // EditText + commonSpinnerErrorMethod( + binding.spState, + binding.tlState, + getString(R.string.emptyState) + ) + } else if (binding.spCity.text.toString().isEmpty()) { // EditText + commonSpinnerErrorMethod( + binding.spCity, + binding.tlCity, + getString(R.string.emptyCity) + ) + } else if (binding.edtPinCode.text.toString().isEmpty()) { // EditText + commonErrorMethod( + binding.edtPinCode, + binding.tlPinCode, + getString(R.string.emptyPinCode) + ) + } else if (binding.edtPinCode.text.toString().length != 6) { // EditText + commonErrorMethod( + binding.edtPinCode, + binding.tlPinCode, + getString(R.string.validPinCode) + ) + } else if (binding.edtNomineeDOB.text.toString() + .isNotEmpty() && isMinor(binding.edtNomineeDOB.text.toString()) + ) { + commonErrorMethod( + binding.edtGuardianName, + binding.tlGuardianName, + getString(R.string.validGuardianDetails) + ) + } else if ((activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.ClientBanklist?.isEmpty()!! && binding.edtIFSC.text.toString() + .isEmpty() + ) { // EditText + commonErrorAutoCompleteMethod( + binding.edtIFSC, + binding.tlIFSC, + getString(R.string.emptyIFSCCode) + ) + } else if ((activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.ClientBanklist?.isEmpty()!! && binding.edtIFSC.text.toString() + .length != 11 + ) { // EditText + commonErrorAutoCompleteMethod( + binding.edtIFSC, + binding.tlIFSC, + getString(R.string.validIFSCCode) + ) + } else if ((activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.ClientBanklist?.isEmpty()!! && binding.edtAccountNumber.text.toString() + .isEmpty() + ) { // EditText + commonErrorMethod( + binding.edtAccountNumber, + binding.tlAccountNumber, + getString(R.string.emptyAccNo) + ) + } else if ((activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.ClientBanklist?.isEmpty()!! && binding.edtBankName.text.toString() + .isEmpty() + ) { // EditText + commonErrorMethod( + binding.edtBankName, + binding.tlBankName, + getString(R.string.emptyBankName) + ) + } else if ((activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.ClientBanklist?.isEmpty()!! && binding.edtBankBranch.text.toString() + .isEmpty() + ) { // EditText + commonErrorMethod( + binding.edtBankBranch, + binding.tlBankBranchName, + getString(R.string.emptyBranchName) + ) + } else { + return true + } + } + + private fun showHideBankDetail() { + if (binding.llBankDetails.visibility == View.GONE) { + binding.llBankDetails.visibility = View.VISIBLE + binding.addBankDetail.setCompoundDrawablesWithIntrinsicBounds( + 0, + 0, + R.drawable.ic_minus, + 0 + ) + + } else { + binding.llBankDetails.visibility = View.GONE + binding.addBankDetail.setCompoundDrawablesWithIntrinsicBounds( + 0, + 0, + R.drawable.ic_add_icon, + 0 + ) + } + } + + override fun onDestroyView() { + super.onDestroyView() + _binding = null + } +} + + diff --git a/app/src/main/java/com/nivesh/production/bajajfd/ui/providerfactory/FDModelProviderFactory.kt b/app/src/main/java/com/nivesh/production/bajajfd/ui/providerfactory/FDModelProviderFactory.kt new file mode 100644 index 0000000..3f68938 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/ui/providerfactory/FDModelProviderFactory.kt @@ -0,0 +1,15 @@ +package com.nivesh.production.bajajfd.ui.providerfactory + +import androidx.lifecycle.ViewModel +import androidx.lifecycle.ViewModelProvider +import com.nivesh.production.bajajfd.repositories.MainRepository +import com.nivesh.production.bajajfd.viewModel.BajajFDViewModel + +class FDModelProviderFactory(private val mainRepository: MainRepository) : + ViewModelProvider.Factory { + + override fun create(modelClass: Class): T { + return BajajFDViewModel(mainRepository) as T + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/util/Colors.kt b/app/src/main/java/com/nivesh/production/bajajfd/util/Colors.kt new file mode 100644 index 0000000..168a28a --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/util/Colors.kt @@ -0,0 +1,5 @@ +package com.nivesh.production.bajajfd.util + +object Colors { + const val colorDefault: String = "#17A31D" +} \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/util/Common.kt b/app/src/main/java/com/nivesh/production/bajajfd/util/Common.kt new file mode 100644 index 0000000..09aef07 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/util/Common.kt @@ -0,0 +1,285 @@ +package com.nivesh.production.bajajfd.util + +import android.Manifest +import android.app.Activity +import android.app.AlertDialog +import android.content.Context +import android.content.Intent +import android.content.pm.PackageManager +import android.graphics.Color +import android.graphics.drawable.GradientDrawable +import android.net.ConnectivityManager +import android.net.NetworkCapabilities +import android.net.Uri +import android.os.Build +import android.provider.Settings +import android.text.format.DateFormat +import android.util.Log +import android.util.Patterns +import androidx.activity.result.contract.ActivityResultContracts +import androidx.core.app.ActivityCompat +import androidx.core.content.ContextCompat +import androidx.core.content.ContextCompat.startActivity +import com.google.android.material.textfield.MaterialAutoCompleteTextView +import com.google.android.material.textfield.TextInputEditText +import com.google.android.material.textfield.TextInputLayout +import com.google.gson.JsonObject +import com.nivesh.production.bajajfd.R +import com.nivesh.production.bajajfd.ui.activity.BajajFdMainActivity +import kotlinx.coroutines.CoroutineExceptionHandler +import org.json.JSONObject +import retrofit2.HttpException +import retrofit2.Response +import java.io.IOException +import java.text.SimpleDateFormat +import java.util.* +import java.util.regex.Matcher +import java.util.regex.Pattern + + +class Common { + + companion object { + /** + *Before use this method write following code in model class + app:Application(in activity and model) + changes in hasInternetConnection + val connectivityManager = getApplication().getSystemService(.... + **/ + //internet check + fun isNetworkAvailable(activity: Activity): Boolean { + val connectivityManager = activity.getSystemService( + Context.CONNECTIVITY_SERVICE + ) as ConnectivityManager + + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + + val activeNetwork = connectivityManager.activeNetwork ?: return false + val capabilities = + connectivityManager.getNetworkCapabilities(activeNetwork) ?: return false + return when { + capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> true + capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> true + capabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) -> true + else -> false + } + } else { + connectivityManager.activeNetworkInfo?.run { + return when (type) { + ConnectivityManager.TYPE_WIFI -> true + ConnectivityManager.TYPE_MOBILE -> true + ConnectivityManager.TYPE_ETHERNET -> true + else -> false + } + } + } + return false + } + + //valid email check + fun isValidEmail(target: String?): Boolean { + return Patterns.EMAIL_ADDRESS.matcher(target.toString()).matches() + } + + //valid Name Check + fun isValidName(nameText: String?): Boolean { + val pattern = Pattern.compile(("^[a-zA-Z\\s]{2,70}$")) + val matcher = pattern.matcher(nameText.toString()) + return matcher.matches() + } + + //validPanCard + fun isValidPan(pan: String?): Boolean { + val mPattern = Pattern.compile("[A-Z]{5}[0-9]{4}[A-Z]") + val mMatcher = mPattern.matcher(pan.toString()) + return mMatcher.matches() + } + + //is Indian mobile Number + fun isIndianMobileNo(mobileNumber: String?): Boolean { + //(0/91): number starts with (0/91) + //[7-9]: starting of the number may contain a digit between 0 to 9 + //[0-9]: then contains digits 0 to 9 + val pattern: Pattern = Pattern.compile("^[6-9]\\d{9}$") + //the matcher() method creates a matcher that will match the given input against this pattern + val match: Matcher = pattern.matcher(mobileNumber.toString()) + //returns a boolean value + return match.matches() + } + + fun removeError(textInputLayout: TextInputLayout) { + if (textInputLayout.error != null) { + textInputLayout.error = null + if (textInputLayout.isErrorEnabled) { + textInputLayout.isErrorEnabled = false + } + } + } + + fun showDialogValidation(activity: Activity?, message: CharSequence?) { + val builder = AlertDialog.Builder(activity) + builder.setMessage(message) + builder.setCancelable(false) + if (activity != null) { + builder.setPositiveButton(activity.getString(R.string.Ok)) { dialogInterface, _ -> + dialogInterface.dismiss() + } + } + builder.show() + } + + fun showDialogWithTwoButtons(activity: Activity?, message: CharSequence?, title: String) { + val builder = AlertDialog.Builder(activity) + builder.setTitle(title) + builder.setMessage(message) + if (activity != null) { + builder.setPositiveButton(activity.getString(R.string.Ok)) { dialogInterface, _ -> + val intent = Intent( + Settings.ACTION_APPLICATION_DETAILS_SETTINGS, + Uri.fromParts("package", (activity as BajajFdMainActivity).packageName, null) + ) + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + activity.startActivity(intent) + dialogInterface.dismiss() + } + builder.setNegativeButton(activity.getString(R.string.cancel)) { dialogInterface, _ -> + dialogInterface.dismiss() + } + } + builder.show() + } + + // set Default Step + fun defaultShape(): GradientDrawable { + val shape = GradientDrawable() + shape.shape = GradientDrawable.OVAL + shape.setColor(Color.WHITE) + shape.setStroke(6, Color.parseColor(Colors.colorDefault)) + return shape + } + + // set Selected Step + fun selectedShape(): GradientDrawable { + val shape = GradientDrawable() + shape.shape = GradientDrawable.OVAL + shape.setColor(Color.parseColor(Colors.colorDefault)) + shape.setStroke(6, Color.parseColor(Colors.colorDefault)) + return shape + } + + fun commonErrorMethod( + inputText: TextInputEditText, + inputError: TextInputLayout, + strMessage: String + ): Boolean { + inputText.requestFocus() + inputError.error = strMessage + return false + } + + fun commonErrorAutoCompleteMethod( + inputText: MaterialAutoCompleteTextView, + inputError: TextInputLayout, + strMessage: String + ): Boolean { + inputText.requestFocus() + inputError.error = strMessage + return false + } + + fun commonSpinnerErrorMethod( + inputText: MaterialAutoCompleteTextView, + inputError: TextInputLayout, + strMessage: String + ): Boolean { + inputText.requestFocus() + inputError.error = strMessage + return false + } + + fun getDate(string: String): String { + val input = SimpleDateFormat("dd/MM/yyyy", Locale.US) + val mDate: Date? = input.parse(string) + val simpleDateFormat = SimpleDateFormat("yyyy-MM-dd", Locale.US) + return simpleDateFormat.format(mDate as Date) + } + + fun handleResponse(response: Response): Resource { + if (response.isSuccessful && response.body() != null) { + response.body()?.let { resultResponse -> + return Resource.Success(resultResponse) + } + } + return Resource.Error(response.message()) + } + + fun handleResponse1(response: Response): Resource { + if (response.isSuccessful && response.body() != null) { + return if (response.body().toString().isNotEmpty()) { + Log.e("response", "-->$response") + val str: String = response.body().toString().replace("\r\n", "") + Log.e("str", "-->$str") + val jsonObject = JSONObject(str) + Log.e("jsonObject", "-->$jsonObject") + Resource.Success(jsonObject.toString()) + }else { + Resource.Error(response.message()) + } + } + return Resource.Error(response.message()) + + } + + fun handleError(activity: Activity): CoroutineExceptionHandler { + val handler = CoroutineExceptionHandler { _, exception -> + if (exception is IOException || exception is HttpException) { + showDialogValidation( + activity, + "Response : ".plus(exception.message).plus(" Cause: ").plus(exception.cause) + ) + } else { + showDialogValidation( + activity, + "Response : ".plus(exception.localizedMessage?.toString()) + ) + } + } + return handler + } + + fun isMinor(date: String): Boolean { + val simpleDateFormat = SimpleDateFormat("yyyy-MM-dd", Locale.US) + val dt1: Date = simpleDateFormat.parse(date) as Date + val year: Int = DateFormat.format("yyyy", dt1).toString().toInt() + val month: Int = DateFormat.format("mm", dt1).toString().toInt() + val day = DateFormat.format("dd", dt1).toString().toInt() + val userAge: Calendar = GregorianCalendar(year, month, day) + val minAdultAge: Calendar = GregorianCalendar() + minAdultAge.add(Calendar.YEAR, -18) + return minAdultAge.before(userAge) + } + + /* this function is used for file size in readable format(End)*/ + fun getFileSizeInMB(length: Long): Double { + // Get length of file in bytes + val fileSizeInBytes = length.toDouble() + // Convert the bytes to Kilobytes (1 KB = 1024 Bytes) + val fileSizeInKB = fileSizeInBytes / 1024 + // Convert the KB to MegaBytes (1 MB = 1024 KBytes) + return fileSizeInKB / 1024 + } + + fun getFileExtension(name: String): String { + val index = name.lastIndexOf('.') + return if (index > 0) { + name.substring(index + 1) + } else { + "" + } + } + + + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/util/Constants.kt b/app/src/main/java/com/nivesh/production/bajajfd/util/Constants.kt new file mode 100644 index 0000000..8c89cd8 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/util/Constants.kt @@ -0,0 +1,19 @@ +package com.nivesh.production.bajajfd.util + +class Constants() { + + companion object { + const val BASE_URL = "https://providential.in/WebApi_Bajaj/api/" + const val token = "636F8F63-06C4-4D95-8562-392B34025FB0" + + const val passphrase = "bml2ZXNo" + const val KEY_LOGIN_EMAIL = "LOGIN_EMAIL" + const val KEY_LOGINUSER_CODE = "LOGINUSER_CODE" + const val KEY_LOGIN_SOCIALID = "KEY_LOGIN_SOCIALID" + const val KEY_LOGIN_PASSWORD = "LOGIN_PASSWORD" + const val KEY_LOGINTYPE = "LOGINTYPE" + const val KEY_VERSION_CODE = "Version Code" + const val KEY_GCM_APP_ID = "Gcm App Id" + val GetFreshToken_V2_Encrypt: String = BASE_URL + "GetToken_V2" + } +} \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/util/EncryptionDecryption.kt b/app/src/main/java/com/nivesh/production/bajajfd/util/EncryptionDecryption.kt new file mode 100644 index 0000000..db69d69 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/util/EncryptionDecryption.kt @@ -0,0 +1,141 @@ +package com.nivesh.production.bajajfd.util + +import android.annotation.SuppressLint +import android.util.Base64 +import android.util.Log +import com.nivesh.production.bajajfd.util.Constants.Companion.passphrase +import java.security.InvalidAlgorithmParameterException +import java.security.InvalidKeyException +import java.security.MessageDigest +import java.security.NoSuchAlgorithmException +import java.text.SimpleDateFormat +import java.util.* +import javax.crypto.* +import javax.crypto.spec.IvParameterSpec +import javax.crypto.spec.SecretKeySpec + +class EncryptionDecryption { + val TAG = "Crypto" + + + private var aesCipher: Cipher? = null + private var secretKey: SecretKey? = null + + private var ivParameterSpec: IvParameterSpec? = null + + private val CIPHER_TRANSFORMATION = "AES/CBC/PKCS5Padding" + private val CIPHER_ALGORITHM = "AES" + + // Replace me with a 16-byte key, share between Java and C# + private val rawSecretKey = byteArrayOf( + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + ) + + private val MESSAGEDIGEST_ALGORITHM = "MD5" + + @SuppressLint("NotConstructor") + fun EncryptionDecryption() { + val passwordKey = + encodeDigest(passphrase) //new NativeClass().localName(KeyConstant.passphrase)); + try { + aesCipher = Cipher.getInstance(CIPHER_TRANSFORMATION) + } catch (e: NoSuchAlgorithmException) { + Log.e(TAG, "No such algorithm $CIPHER_ALGORITHM", e) + } catch (e: NoSuchPaddingException) { + Log.e(TAG, "No such padding PKCS5", e) + } + secretKey = SecretKeySpec(passwordKey, CIPHER_ALGORITHM) + ivParameterSpec = IvParameterSpec(rawSecretKey) + } + + fun encryptAsBase64(dataToEncrypt: String): String? { + var dataToEncrypt = dataToEncrypt + val dateFormat = SimpleDateFormat("SSS", Locale.US) + dataToEncrypt = dataToEncrypt + dateFormat.format(Date()) + val encryptedData = encrypt(dataToEncrypt.toByteArray()) + return Base64.encodeToString(encryptedData, Base64.DEFAULT) + } + +// public String decrypt(String textToDecrypt) throws Exception { +// +// +// //SecretKeySpec skeySpec = new SecretKeySpec(getRaw(plainText, AESSalt), "AES"); +// //Cipher cipher = Cipher.getInstance(cypherInstance); +// //cipher.init(Cipher.DECRYPT_MODE, skeySpec, new IvParameterSpec(initializationVector.getBytes())); +// byte[] decrypted = aesCipher.doFinal(encryted_bytes); +// return new String(decrypted, "UTF-8"); +// } + + // public String decrypt(String textToDecrypt) throws Exception { + // + // + // //SecretKeySpec skeySpec = new SecretKeySpec(getRaw(plainText, AESSalt), "AES"); + // //Cipher cipher = Cipher.getInstance(cypherInstance); + // //cipher.init(Cipher.DECRYPT_MODE, skeySpec, new IvParameterSpec(initializationVector.getBytes())); + // byte[] decrypted = aesCipher.doFinal(encryted_bytes); + // return new String(decrypted, "UTF-8"); + // } + fun decrypt(encryptString: String?): String? { + var decryptedData = "" + try { + aesCipher!!.init(Cipher.DECRYPT_MODE, secretKey, ivParameterSpec) + } catch (e: InvalidKeyException) { + Log.e(TAG, "Invalid key", e) + return null + } catch (e: InvalidAlgorithmParameterException) { + Log.e(TAG, "Invalid algorithm $CIPHER_ALGORITHM", e) + return null + } + val decryptBytes: ByteArray + try { + val encryted_bytes = Base64.decode(encryptString, Base64.DEFAULT) + decryptBytes = aesCipher!!.doFinal(encryted_bytes) + decryptedData = String(decryptBytes) + decryptedData = decryptedData.substring(0, decryptedData.length - 3) + } catch (e: IllegalBlockSizeException) { + Log.e(TAG, "Illegal block size", e) + return null + } catch (e: BadPaddingException) { + Log.e(TAG, "Bad padding", e) + return null + } catch (e: Exception) { + e.printStackTrace() + } + return decryptedData + } + + fun encrypt(clearData: ByteArray?): ByteArray? { + try { + aesCipher!!.init(Cipher.ENCRYPT_MODE, secretKey, ivParameterSpec) + } catch (e: InvalidKeyException) { + Log.e(TAG, "Invalid key", e) + return null + } catch (e: InvalidAlgorithmParameterException) { + Log.e(TAG, "Invalid algorithm $CIPHER_ALGORITHM", e) + return null + } + val encryptedData: ByteArray + encryptedData = try { + aesCipher!!.doFinal(clearData) + } catch (e: IllegalBlockSizeException) { + Log.e(TAG, "Illegal block size", e) + return null + } catch (e: BadPaddingException) { + Log.e(TAG, "Bad padding", e) + return null + } + return encryptedData + } + + private fun encodeDigest(text: String): ByteArray? { + val digest: MessageDigest + try { + digest = MessageDigest.getInstance(MESSAGEDIGEST_ALGORITHM) + return digest.digest(text.toByteArray()) + } catch (e: NoSuchAlgorithmException) { + Log.e(TAG, "No such algorithm $MESSAGEDIGEST_ALGORITHM", e) + } + return null + } +} \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/util/ImageUtil.kt b/app/src/main/java/com/nivesh/production/bajajfd/util/ImageUtil.kt new file mode 100644 index 0000000..0d1340f --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/util/ImageUtil.kt @@ -0,0 +1,27 @@ +package com.nivesh.production.bajajfd.util + +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.util.Base64; +import java.io.ByteArrayOutputStream; + + +class ImageUtil { + + @Throws(IllegalArgumentException::class) + fun convert(base64Str: String): Bitmap? { + val decodedBytes: ByteArray = Base64.decode( + base64Str.substring(base64Str.indexOf(",") + 1), + Base64.DEFAULT + ) + return BitmapFactory.decodeByteArray(decodedBytes, 0, decodedBytes.size) + } + + companion object { + fun convert(bitmap: Bitmap): String? { + val outputStream = ByteArrayOutputStream() + bitmap.compress(Bitmap.CompressFormat.PNG, 100, outputStream) + return Base64.encodeToString(outputStream.toByteArray(), Base64.DEFAULT) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/util/ProgressUtil.kt b/app/src/main/java/com/nivesh/production/bajajfd/util/ProgressUtil.kt new file mode 100644 index 0000000..847f6c5 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/util/ProgressUtil.kt @@ -0,0 +1,49 @@ +package com.nivesh.production.bajajfd.util + +import android.annotation.SuppressLint +import android.app.AlertDialog +import android.content.Context +import android.graphics.Color +import android.graphics.drawable.ColorDrawable +import android.util.Log +import android.view.Window +import android.widget.ProgressBar + +@SuppressLint("StaticFieldLeak") +object ProgressUtil{ + + private lateinit var dialogBuilder: AlertDialog.Builder + private lateinit var alertDialog: AlertDialog + private lateinit var pDialog: ProgressBar + + fun showLoading(ctx: Context){ + // instantiating the lateInit objects + dialogBuilder= AlertDialog.Builder(ctx) + pDialog= ProgressBar(ctx) + + // setting up the dialog + dialogBuilder.setCancelable(false) + dialogBuilder.setView(pDialog) + alertDialog=dialogBuilder.create() + + // magic of transparent background goes here + alertDialog.requestWindowFeature(Window.FEATURE_NO_TITLE) + // setting the alertDialog's BackgroundDrawable as the color resource of any color with 1% opacity + alertDialog.window?.setBackgroundDrawable(ColorDrawable(Color.parseColor("#00141414"))) + + // finally displaying the Alertdialog containing the ProgressBar + alertDialog.show() + + } + + + fun hideLoading(){ + try { + if(alertDialog.isShowing){ + alertDialog.dismiss() + } + } catch (e: UninitializedPropertyAccessException) { + Log.e("TAG","AlertDialog UninitializedPropertyAccessException") + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/util/Resource.kt b/app/src/main/java/com/nivesh/production/bajajfd/util/Resource.kt new file mode 100644 index 0000000..69fe7d9 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/util/Resource.kt @@ -0,0 +1,16 @@ +package com.nivesh.production.bajajfd.util + +sealed class Resource( + val data: T? = null, + var message: String? = null, + val errorCode: Int? = null, + var status: Boolean = true + +) { + class Success(data: T) : Resource(data) + class Error(message: String, data: T? = null) : Resource(data, message) + class Loading : Resource() + class DataError(errorCode: Int, message: String) : + Resource(null, message, errorCode) + +} \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/util/SharedPrefrenceDataMethods.kt b/app/src/main/java/com/nivesh/production/bajajfd/util/SharedPrefrenceDataMethods.kt new file mode 100644 index 0000000..2085276 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/util/SharedPrefrenceDataMethods.kt @@ -0,0 +1,65 @@ +package com.nivesh.production.bajajfd.util + +import android.content.Context +import androidx.preference.PreferenceManager + +class SharedPrefrenceDataMethods { + + companion object { + + fun getLoginEmail(Name: String?, context: Context?): String? { + val preferences = context?.let { + PreferenceManager.getDefaultSharedPreferences( + it + ) + } + + return preferences?.getString(Name, "") + + } + + fun getLoginUserCode(Name: String?, context: Context?): String? { + val preferences = context?.let { PreferenceManager.getDefaultSharedPreferences(it) } + return preferences?.getString(Name, "") + } + + fun setLogin_SOCIALID(json: String?, context: Context?, Name: String?) { + val preferences = context?.let { PreferenceManager.getDefaultSharedPreferences(it) } + val editor = preferences?.edit() + editor?.putString(Name, json) + editor?.apply() + } + + fun getLoginSOCIALID(Name: String?, context: Context?): String? { + val preferences = context?.let { PreferenceManager.getDefaultSharedPreferences(it) } + return preferences?.getString(Name, "") + } + + fun getLoginPassword(Name: String?, context: Context?): String? { + val preferences = context?.let { PreferenceManager.getDefaultSharedPreferences(it) } + return preferences?.getString(Name, "") + } + + fun getLogin_Type(Name: String?, context: Context?): String? { + val preferences = context?.let { PreferenceManager.getDefaultSharedPreferences(it) } + return preferences?.getString(Name, "") + } + + fun getVersionCode(Name: String?, context: Context?): String? { + val preferences = context?.let { PreferenceManager.getDefaultSharedPreferences(it) } + return preferences?.getString(Name, "") + } + + fun getGcmAppId(Name: String?, context: Context?): String? { + val preferences = context?.let { PreferenceManager.getDefaultSharedPreferences(it) } + return preferences?.getString(Name, "") + } + + fun setToken(context: Context?, token: String?) { + val preferences = context?.let { PreferenceManager.getDefaultSharedPreferences(it) } + val editor = preferences?.edit() + editor?.putString("token", token) + editor?.apply() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/util/Utility.kt b/app/src/main/java/com/nivesh/production/bajajfd/util/Utility.kt new file mode 100644 index 0000000..e8597de --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/util/Utility.kt @@ -0,0 +1,169 @@ +package com.nivesh.production.bajajfd.util + +import android.Manifest +import android.annotation.SuppressLint +import android.content.Context +import android.content.pm.PackageManager +import android.os.Build +import android.provider.Settings +import android.telephony.TelephonyManager +import android.text.TextUtils +import android.util.Log +import androidx.core.app.ActivityCompat +import com.nivesh.production.bajajfd.model.DeviceInfo +import java.nio.charset.StandardCharsets +import java.security.MessageDigest +import java.util.* + +class Utility { + + companion object{ + + fun convert_sha256(rawString: String): String { + return try { + val digest = MessageDigest.getInstance("SHA-256") + var hash = ByteArray(0) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + hash = digest.digest(rawString.toByteArray(StandardCharsets.UTF_8)) + } + val hexString = StringBuilder() + for (i in hash.indices) { + val hex = Integer.toHexString(0xff and hash[i].toInt()) + if (hex.length == 1) hexString.append('0') + hexString.append(hex) + } + hexString.toString().uppercase(Locale.getDefault()) + } catch (ex: Exception) { + throw RuntimeException(ex) + } + } + + fun convert_sha256_2X(rawString: String): String { + return try { + val digest = MessageDigest.getInstance("SHA-256") + var hash = ByteArray(0) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + hash = digest.digest(rawString.toByteArray(StandardCharsets.UTF_8)) + } + val hexString = java.lang.StringBuilder() + for (i in hash.indices) { + val hex = Integer.toHexString(0xff and hash[i].toInt()) + if (hex.length == 1) hexString.append('0') + hexString.append(hex) + } + hexString.toString() + } catch (ex: java.lang.Exception) { + throw java.lang.RuntimeException(ex) + } + } + + @SuppressLint("HardwareIds") + fun getDeviceInfo(mContext: Context): DeviceInfo { + val deviceInfo = DeviceInfo() + var device_id: String? = "" + try { + val telephonyManager = + mContext.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager + deviceInfo.app_version = ( + SharedPrefrenceDataMethods.getVersionCode( + Constants.KEY_VERSION_CODE, + mContext + ) + ) + + deviceInfo.device_model = (if (TextUtils.isEmpty(Build.DEVICE)) "" else Build.DEVICE) + deviceInfo.device_os_version = (if (TextUtils.isEmpty(Build.VERSION.RELEASE)) "" else Build.VERSION.RELEASE) + deviceInfo.device_name = (if (TextUtils.isEmpty(Build.PRODUCT)) "" else Build.PRODUCT) + deviceInfo.device_token = ( + if (TextUtils.isEmpty( + SharedPrefrenceDataMethods.getGcmAppId( + Constants.KEY_GCM_APP_ID, + mContext + ) + ) + ) "" else SharedPrefrenceDataMethods.getGcmAppId( + Constants.KEY_GCM_APP_ID, + mContext + ) + ) + deviceInfo.device_type = ("Android") + + // Hemant Code Added start 28-10-2020 + if (ActivityCompat.checkSelfPermission( + mContext, + Manifest.permission.READ_PHONE_STATE + ) != PackageManager.PERMISSION_GRANTED + ) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + device_id = telephonyManager.imei + if (device_id == null) { + device_id = + if (TextUtils.isEmpty(Build.getSerial())) "" else Build.getSerial() + } + } else { + device_id = telephonyManager.deviceId + if (device_id == null) { + device_id = + if (TextUtils.isEmpty(Build.SERIAL)) "" else Build.SERIAL + } + } + } else { + device_id = telephonyManager.deviceId + if (device_id == null) { + device_id = if (TextUtils.isEmpty(Build.SERIAL)) "" else Build.SERIAL + } + } + if (device_id == null || device_id.isEmpty() || device_id.equals( + "unknown", + ignoreCase = true + ) + ) { + device_id = if (TextUtils.isEmpty( + Settings.Secure.getString( + mContext.contentResolver, + Settings.Secure.ANDROID_ID + ) + ) + ) "" else Settings.Secure.getString( + mContext.contentResolver, + Settings.Secure.ANDROID_ID + ) + } + Log.e("device_id", "-> $device_id") + // Hemant changes 07-11-2019 start commented and Added 12-12-2019 +// deviceInfo.device_id = (device_id + "#" + com.nivesh.production.util.Utility.getFlavor()) + // Hemant changes 07-11-2019 end commented and Added 12-12-2019 + + + // Hemant changes 07-11-2019 start added and commented 12-12-2019 + deviceInfo.device_id_for_UMSId = (device_id) + // deviceInfo.setDeviceId(device_id); + // Hemant changes 07-11-2019 end added and commented 12-12-2019 + } catch (e: java.lang.Exception) { + e.printStackTrace() + // Hemant changes 07-11-2019 start Added 28-10-2020 + if (device_id == null || device_id.isEmpty() || device_id.equals( + "unknown", + ignoreCase = true + ) + ) { + device_id = if (TextUtils.isEmpty( + Settings.Secure.getString( + mContext.contentResolver, + Settings.Secure.ANDROID_ID + ) + ) + ) "" else Settings.Secure.getString( + mContext.contentResolver, + Settings.Secure.ANDROID_ID + ) + } + Log.e("device_id", "-> $device_id") +// deviceInfo.setDeviceId(device_id + "#" + com.nivesh.production.util.Utility.getFlavor()) + deviceInfo.device_id_for_UMSId = (device_id) + // Hemant changes 07-11-2019 end Added 28-10-2020 + } + return deviceInfo + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/util/Utils_Functions.kt b/app/src/main/java/com/nivesh/production/bajajfd/util/Utils_Functions.kt new file mode 100644 index 0000000..e2664f1 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/util/Utils_Functions.kt @@ -0,0 +1,21 @@ +package com.nivesh.production.bajajfd.util + +import android.annotation.SuppressLint +import java.text.SimpleDateFormat +import java.util.* + +class Utils_Functions { + + companion object{ + + fun getCurrentDateStamp(): String? { + val d = Date() + @SuppressLint("SimpleDateFormat") val simpleDateFormat = + SimpleDateFormat("yyyy-MM-dd HH:mm:ss") + val dateStr = simpleDateFormat.format(d) + val output = d.time / 1000L + val str = java.lang.Long.toString(output) + return d.time.toString() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/viewModel/BajajFDViewModel.kt b/app/src/main/java/com/nivesh/production/bajajfd/viewModel/BajajFDViewModel.kt new file mode 100644 index 0000000..c323cb7 --- /dev/null +++ b/app/src/main/java/com/nivesh/production/bajajfd/viewModel/BajajFDViewModel.kt @@ -0,0 +1,380 @@ +package com.nivesh.production.bajajfd.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.bajajfd.model.* +import com.nivesh.production.bajajfd.repositories.MainRepository +import com.nivesh.production.bajajfd.util.Common +import com.nivesh.production.bajajfd.util.Common.Companion.handleError +import com.nivesh.production.bajajfd.util.Common.Companion.handleResponse +import com.nivesh.production.bajajfd.util.Constants +import com.nivesh.production.bajajfd.util.Resource +import kotlinx.coroutines.launch + +open class BajajFDViewModel(private val mainRepository: MainRepository) : ViewModel() { + + val getStepsCountMutableData: MutableLiveData> = 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> = 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 getFDKYCMutableData: MutableLiveData> = 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 getPaymentReQueryMutableData: MutableLiveData> = 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> = 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> = 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> = MutableLiveData() + fun getMaturityAmount(requestBody: GetMaturityAmountRequest, activity: Activity) = + viewModelScope.launch( + handleError(activity) + ) { + if (Common.isNetworkAvailable(activity)) { + getMaturityAmountMutableData.postValue(Resource.Loading()) + val response = mainRepository.createCalculateFDMaturityAmount(requestBody, + Constants.token + ) + getMaturityAmountMutableData.postValue(handleResponse(response)) + } + } + + val getRatesMutableData: MutableLiveData> = 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> = 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 getPanCheckMutableData: MutableLiveData> = MutableLiveData() + fun panCheck(panCheck: PanCheckRequest, token: String, activity : Activity) = viewModelScope.launch( + handleError(activity) + ) { + if (Common.isNetworkAvailable(activity)) { + getPanCheckMutableData.postValue(Resource.Loading()) + val response = mainRepository.panCheck(panCheck, token) + getPanCheckMutableData.postValue(handleResponse(response)) + } + } + + val getTitleMutableData: MutableLiveData> = 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> = 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> = 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> = 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> = 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> = 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> = 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> = 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> = 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> = 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> = MutableLiveData() + fun ifscCodeDetailsApi(ifsc : String,activity : Activity) = viewModelScope.launch( + handleError(activity) + ) { + if (Common.isNetworkAvailable(activity)) { + getIfscCodeDetailsCheckMutableData.postValue(Resource.Loading()) + val response = mainRepository.ifscCodeBankDetailsCheck(ifsc, Constants.token) + getIfscCodeDetailsCheckMutableData.postValue(Common.handleResponse1(response)) + } + } + + val getPaymentModeMutableData: MutableLiveData> = 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> = 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> = 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> = 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> = 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> = 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> = 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> = 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> = 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> = 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)) + } + } + +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bajaj_logo.png b/app/src/main/res/drawable/bajaj_logo.png new file mode 100644 index 0000000..906f1fc Binary files /dev/null and b/app/src/main/res/drawable/bajaj_logo.png differ diff --git a/app/src/main/res/drawable/camera.png b/app/src/main/res/drawable/camera.png new file mode 100644 index 0000000..6ea6bca Binary files /dev/null and b/app/src/main/res/drawable/camera.png differ diff --git a/app/src/main/res/drawable/card_bg.xml b/app/src/main/res/drawable/card_bg.xml new file mode 100644 index 0000000..3e643f0 --- /dev/null +++ b/app/src/main/res/drawable/card_bg.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/cursor_color.xml b/app/src/main/res/drawable/cursor_color.xml new file mode 100644 index 0000000..0ec4a7a --- /dev/null +++ b/app/src/main/res/drawable/cursor_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_add_icon.xml b/app/src/main/res/drawable/ic_add_icon.xml new file mode 100644 index 0000000..a6bdf84 --- /dev/null +++ b/app/src/main/res/drawable/ic_add_icon.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_arrow_down.xml b/app/src/main/res/drawable/ic_arrow_down.xml new file mode 100644 index 0000000..bf94fc1 --- /dev/null +++ b/app/src/main/res/drawable/ic_arrow_down.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_baseline_check_24.xml b/app/src/main/res/drawable/ic_baseline_check_24.xml new file mode 100644 index 0000000..eb14651 --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_check_24.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_minus.xml b/app/src/main/res/drawable/ic_minus.xml new file mode 100644 index 0000000..f465978 --- /dev/null +++ b/app/src/main/res/drawable/ic_minus.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_select_green.xml b/app/src/main/res/drawable/ic_select_green.xml new file mode 100644 index 0000000..c3bb144 --- /dev/null +++ b/app/src/main/res/drawable/ic_select_green.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_select_outline.xml b/app/src/main/res/drawable/ic_select_outline.xml new file mode 100644 index 0000000..35bec46 --- /dev/null +++ b/app/src/main/res/drawable/ic_select_outline.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/rounded_corner_green_fill.xml b/app/src/main/res/drawable/rounded_corner_green_fill.xml new file mode 100644 index 0000000..0f43eb7 --- /dev/null +++ b/app/src/main/res/drawable/rounded_corner_green_fill.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/rounded_corner_with_line.xml b/app/src/main/res/drawable/rounded_corner_with_line.xml new file mode 100644 index 0000000..e922c05 --- /dev/null +++ b/app/src/main/res/drawable/rounded_corner_with_line.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/rounded_corner_with_line_blue.xml b/app/src/main/res/drawable/rounded_corner_with_line_blue.xml new file mode 100644 index 0000000..7b54a02 --- /dev/null +++ b/app/src/main/res/drawable/rounded_corner_with_line_blue.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/sp_bg.xml b/app/src/main/res/drawable/sp_bg.xml new file mode 100644 index 0000000..1a4b686 --- /dev/null +++ b/app/src/main/res/drawable/sp_bg.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/svg_back.xml b/app/src/main/res/drawable/svg_back.xml new file mode 100644 index 0000000..13ba1de --- /dev/null +++ b/app/src/main/res/drawable/svg_back.xml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/svg_cal.xml b/app/src/main/res/drawable/svg_cal.xml new file mode 100644 index 0000000..3773633 --- /dev/null +++ b/app/src/main/res/drawable/svg_cal.xml @@ -0,0 +1,36 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/svg_camera.xml b/app/src/main/res/drawable/svg_camera.xml new file mode 100644 index 0000000..48a8a01 --- /dev/null +++ b/app/src/main/res/drawable/svg_camera.xml @@ -0,0 +1,6 @@ + + + + diff --git a/app/src/main/res/drawable/svg_close.xml b/app/src/main/res/drawable/svg_close.xml new file mode 100644 index 0000000..844b6b6 --- /dev/null +++ b/app/src/main/res/drawable/svg_close.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/svg_down_arrow.xml b/app/src/main/res/drawable/svg_down_arrow.xml new file mode 100644 index 0000000..9e345b8 --- /dev/null +++ b/app/src/main/res/drawable/svg_down_arrow.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/svg_grey_bullet.xml b/app/src/main/res/drawable/svg_grey_bullet.xml new file mode 100644 index 0000000..214aae6 --- /dev/null +++ b/app/src/main/res/drawable/svg_grey_bullet.xml @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/svg_image.xml b/app/src/main/res/drawable/svg_image.xml new file mode 100644 index 0000000..3ffb603 --- /dev/null +++ b/app/src/main/res/drawable/svg_image.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/svg_rs.xml b/app/src/main/res/drawable/svg_rs.xml new file mode 100644 index 0000000..83c522d --- /dev/null +++ b/app/src/main/res/drawable/svg_rs.xml @@ -0,0 +1,17 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/svg_star.xml b/app/src/main/res/drawable/svg_star.xml new file mode 100644 index 0000000..8218c21 --- /dev/null +++ b/app/src/main/res/drawable/svg_star.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/svg_step_process.xml b/app/src/main/res/drawable/svg_step_process.xml new file mode 100644 index 0000000..53c595f --- /dev/null +++ b/app/src/main/res/drawable/svg_step_process.xml @@ -0,0 +1,13 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/font/font.xml b/app/src/main/res/font/font.xml new file mode 100644 index 0000000..4ce9314 --- /dev/null +++ b/app/src/main/res/font/font.xml @@ -0,0 +1,23 @@ + + + + + + + + diff --git a/app/src/main/res/font/roboto_black.ttf b/app/src/main/res/font/roboto_black.ttf new file mode 100644 index 0000000..fbde625 Binary files /dev/null and b/app/src/main/res/font/roboto_black.ttf differ diff --git a/app/src/main/res/font/roboto_bold.ttf b/app/src/main/res/font/roboto_bold.ttf new file mode 100644 index 0000000..a355c27 Binary files /dev/null and b/app/src/main/res/font/roboto_bold.ttf differ diff --git a/app/src/main/res/font/roboto_light.ttf b/app/src/main/res/font/roboto_light.ttf new file mode 100644 index 0000000..94c6bcc Binary files /dev/null and b/app/src/main/res/font/roboto_light.ttf differ diff --git a/app/src/main/res/font/roboto_medium.ttf b/app/src/main/res/font/roboto_medium.ttf new file mode 100644 index 0000000..39c63d7 Binary files /dev/null and b/app/src/main/res/font/roboto_medium.ttf differ diff --git a/app/src/main/res/font/roboto_regular.ttf b/app/src/main/res/font/roboto_regular.ttf new file mode 100644 index 0000000..8c082c8 Binary files /dev/null and b/app/src/main/res/font/roboto_regular.ttf differ diff --git a/app/src/main/res/font/roboto_thin.ttf b/app/src/main/res/font/roboto_thin.ttf new file mode 100644 index 0000000..d695550 Binary files /dev/null and b/app/src/main/res/font/roboto_thin.ttf differ diff --git a/app/src/main/res/layout/activity_bajaj_fd.xml b/app/src/main/res/layout/activity_bajaj_fd.xml new file mode 100644 index 0000000..c890513 --- /dev/null +++ b/app/src/main/res/layout/activity_bajaj_fd.xml @@ -0,0 +1,154 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/bank_detail_select.xml b/app/src/main/res/layout/bank_detail_select.xml new file mode 100644 index 0000000..864b267 --- /dev/null +++ b/app/src/main/res/layout/bank_detail_select.xml @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/camera_gallery_layout.xml b/app/src/main/res/layout/camera_gallery_layout.xml new file mode 100644 index 0000000..eda34a7 --- /dev/null +++ b/app/src/main/res/layout/camera_gallery_layout.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_bajajfd_step_five.xml b/app/src/main/res/layout/fragment_bajajfd_step_five.xml new file mode 100644 index 0000000..9acdd82 --- /dev/null +++ b/app/src/main/res/layout/fragment_bajajfd_step_five.xml @@ -0,0 +1,163 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_bajajfd_step_four.xml b/app/src/main/res/layout/fragment_bajajfd_step_four.xml new file mode 100644 index 0000000..c49c958 --- /dev/null +++ b/app/src/main/res/layout/fragment_bajajfd_step_four.xml @@ -0,0 +1,301 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_bajajfd_step_one.xml b/app/src/main/res/layout/fragment_bajajfd_step_one.xml new file mode 100644 index 0000000..194cff4 --- /dev/null +++ b/app/src/main/res/layout/fragment_bajajfd_step_one.xml @@ -0,0 +1,395 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +