From 0f6c54fe7aa17b5b1dd4894b7e6f108348e94f79 Mon Sep 17 00:00:00 2001 From: Hemant Khadase Date: Wed, 4 Jan 2023 15:39:55 +0530 Subject: [PATCH] changes done --- .../production/bajajfd/api/ApiClient.kt | 48 ++-- .../bajajfd/interfaces/ApiInterface.kt | 2 +- .../bajajfd/interfaces/BajajFDInterface.kt | 2 +- .../bajajfd/model/ResponseXXXXXXXXXXXXX.kt | 8 + .../bajajfd/model/SaveFDOtherDataResponse.kt | 5 + .../bajajfd/repositories/MainRepository.kt | 4 +- .../ui/activity/BajajFdMainActivity.kt | 222 ++++++++++++------ .../ui/fragment/StepFiveBajajFDFragment.kt | 16 +- .../ui/fragment/StepFourBajajFDFragment.kt | 16 +- .../ui/fragment/StepOneBajajFDFragment.kt | 2 +- .../ui/fragment/StepTwoBajajFDFragment.kt | 12 +- .../nivesh/production/bajajfd/util/Common.kt | 13 + .../bajajfd/viewModel/BajajFDViewModel.kt | 26 +- .../viewModel/StepFiveBajajFDViewModel.kt | 10 + .../viewModel/StepFourBajajFDViewModel.kt | 8 +- app/src/main/res/layout/row_fd_pay.xml | 43 ++++ app/src/main/res/values-hi-rIN/strings.xml | 2 + app/src/main/res/values/strings.xml | 2 + 18 files changed, 302 insertions(+), 139 deletions(-) create mode 100644 app/src/main/java/com/nivesh/production/bajajfd/model/ResponseXXXXXXXXXXXXX.kt create mode 100644 app/src/main/java/com/nivesh/production/bajajfd/model/SaveFDOtherDataResponse.kt create mode 100644 app/src/main/res/layout/row_fd_pay.xml 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 index 14f4d89..a537cf0 100644 --- a/app/src/main/java/com/nivesh/production/bajajfd/api/ApiClient.kt +++ b/app/src/main/java/com/nivesh/production/bajajfd/api/ApiClient.kt @@ -1,21 +1,20 @@ package com.nivesh.production.bajajfd.api -import android.content.Context -import android.net.ConnectivityManager import com.nivesh.production.bajajfd.BajajApplication -import com.nivesh.production.bajajfd.api.ApiClient.Companion.isNetworkAvailablee import com.nivesh.production.bajajfd.interfaces.ApiInterface import com.nivesh.production.bajajfd.util.Constants.Companion.BASE_URL -import okhttp3.Interceptor import okhttp3.OkHttpClient -import okhttp3.Response import okhttp3.logging.HttpLoggingInterceptor import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory -import java.io.IOException +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 @@ -24,10 +23,31 @@ class ApiClient { 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(ConnectVerifierInterceptor()) + .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()) @@ -37,24 +57,10 @@ class ApiClient { val getApiClient: ApiInterface by lazy { client.create(ApiInterface::class.java) } - fun isNetworkAvailablee(): Boolean { - val connectivityManager = - BajajApplication.appContext?.getSystemService(Context.CONNECTIVITY_SERVICE) as? ConnectivityManager - return connectivityManager?.activeNetworkInfo?.isConnected == true - } } } -class ConnectVerifierInterceptor : Interceptor { - override fun intercept(chain: Interceptor.Chain): okhttp3.Response { -// if (!isNetworkAvailablee()) { -// throw IOException("No Network Available!") -// } - val request = chain.request() - return chain.proceed(request) - } -} 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 index dc65119..c253c17 100644 --- a/app/src/main/java/com/nivesh/production/bajajfd/interfaces/ApiInterface.kt +++ b/app/src/main/java/com/nivesh/production/bajajfd/interfaces/ApiInterface.kt @@ -34,7 +34,7 @@ interface ApiInterface { @POST("WebApi_Bajaj/api/SaveFDOtherData") suspend fun saveFDOtherData( - @Body requestBody: RequestBody, + @Body requestBody: SaveFDOtherDataRequest, @Header("token") token: String ): Response diff --git a/app/src/main/java/com/nivesh/production/bajajfd/interfaces/BajajFDInterface.kt b/app/src/main/java/com/nivesh/production/bajajfd/interfaces/BajajFDInterface.kt index d827306..2238ef6 100644 --- a/app/src/main/java/com/nivesh/production/bajajfd/interfaces/BajajFDInterface.kt +++ b/app/src/main/java/com/nivesh/production/bajajfd/interfaces/BajajFDInterface.kt @@ -7,5 +7,5 @@ interface BajajFDInterface { fun stepOneApi(data: String?) fun stepTwoApi(data: CreateFDRequest) fun stepThreeApi(data: CreateFDRequest) - fun stepFourApi(data: SaveFDOtherDataRequest) + fun stepFourApi(data: SaveFDOtherDataRequest, payUrl: String, value: String) } \ 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/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/repositories/MainRepository.kt b/app/src/main/java/com/nivesh/production/bajajfd/repositories/MainRepository.kt index 8550104..0b1ba2c 100644 --- a/app/src/main/java/com/nivesh/production/bajajfd/repositories/MainRepository.kt +++ b/app/src/main/java/com/nivesh/production/bajajfd/repositories/MainRepository.kt @@ -29,8 +29,8 @@ class MainRepository constructor(private val apiInterface: ApiInterface) { suspend fun documentsUploadResponse(getRatesRequest: DocumentUpload, token: String) = apiInterface.documentsUpload(getRatesRequest, token) - suspend fun saveFDOtherDataResponse(getRatesRequest: GetRatesRequest, token: String) = - apiInterface.getRates(getRatesRequest, token) + suspend fun saveFDOtherDataResponse(getRatesRequest: SaveFDOtherDataRequest, token: String) = + apiInterface.saveFDOtherData(getRatesRequest, token) suspend fun getFDDetailsResponse(getRatesRequest: GetFDDetailsRequest, token: String) = apiInterface.getFDDetails(getRatesRequest, token) 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 index 9bb0340..2982565 100644 --- 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 @@ -1,12 +1,20 @@ 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.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.SectionsPagerAdapter import com.nivesh.production.bajajfd.api.ApiClient import com.nivesh.production.bajajfd.databinding.ActivityBajajFdBinding @@ -46,7 +54,7 @@ class BajajFdMainActivity : BaseActivity(), BajajFDInterface { var getClientDetailsResponse: getClientDetailsResponse private var stepCount: Int = 0 - private lateinit var sectionsPagerAdapter : SectionsPagerAdapter + private lateinit var sectionsPagerAdapter: SectionsPagerAdapter private lateinit var fragments: Array override fun onCreate(savedInstanceState: Bundle?) { @@ -108,53 +116,51 @@ class BajajFdMainActivity : BaseActivity(), BajajFDInterface { } private fun getStepsCountApi() { - if (Common.isNetworkAvailable(this)) { - val fdStepsCount = FDStepsCountRequest() - fdStepsCount.FDProvider = getString(com.nivesh.production.bajajfd.R.string.bajaj) - fdStepsCount.NiveshClientCode = "8872" - viewModel.getStepsCount(fdStepsCount, token) - viewModel.getStepsCountMutableData.observe(this) { response -> - when (response) { - is Resource.Success -> { - Log.e("response", "-->$response") - val stepsCountResponse: StepsCountResponse = - Gson().fromJson( - response.data?.toString(), - StepsCountResponse::class.java - ) - stepsCountResponse.Response.StatusCode.let { code -> - when (code) { - 200 -> { - stepCount = stepsCountResponse.Response.StepsCount - getClientDetailsApi(stepsCountResponse.Response.StepsCount) - } - 650 -> refreshToken(fdStepsCount) - else -> { - showDialogValidation( - this@BajajFdMainActivity, - stepsCountResponse.Response.Errors[0].ErrorMessage - ) - } - } - } - } - is Resource.Error -> { - response.message?.let { message -> - showDialogValidation(this@BajajFdMainActivity, message) - } - } - is Resource.Loading -> { - - } - } - } - } + if (Common.isNetworkAvailable(this)) { + val fdStepsCount = FDStepsCountRequest() + fdStepsCount.FDProvider = getString(R.string.bajaj) + fdStepsCount.NiveshClientCode = "8872" + viewModel.getStepsCount(fdStepsCount, token) + viewModel.getStepsCountMutableData.observe(this) { response -> + when (response) { + is Resource.Success -> { + Log.e("response", "-->$response") + val stepsCountResponse: StepsCountResponse = + Gson().fromJson( + response.data?.toString(), + StepsCountResponse::class.java + ) + stepsCountResponse.Response.StatusCode.let { code -> + when (code) { + 200 -> { + stepCount = stepsCountResponse.Response.StepsCount + getClientDetailsApi(stepsCountResponse.Response.StepsCount) + } + 650 -> refreshToken(fdStepsCount) + else -> { + showDialogValidation( + this@BajajFdMainActivity, + stepsCountResponse.Response.Errors[0].ErrorMessage + ) + } + } + } + } + is Resource.Error -> { + response.message?.let { message -> + showDialogValidation(this@BajajFdMainActivity, message) + } + } + is Resource.Loading -> { + + } + } + } + } } private fun refreshToken(fdStepsCount: FDStepsCountRequest) { - if (Common.isNetworkAvailable(this@BajajFdMainActivity)) { - } } @@ -162,20 +168,20 @@ class BajajFdMainActivity : BaseActivity(), BajajFDInterface { if (Common.isNetworkAvailable(this@BajajFdMainActivity)) { val getClientDetailsRequest = getClientDetailsRequest() getClientDetailsRequest.client_code = "8872" - getClientDetailsRequest.AppOrWeb = getString(com.nivesh.production.bajajfd.R.string.app) + getClientDetailsRequest.AppOrWeb = getString(R.string.app) getClientDetailsRequest.sub_broker_code = "1038" val userRequest = UserRequest() userRequest.UID = 19060 userRequest.IPAddress = "" - userRequest.Source = getString(com.nivesh.production.bajajfd.R.string.source) - userRequest.AppOrWeb = getString(com.nivesh.production.bajajfd.R.string.app) + userRequest.Source = getString(R.string.source) + userRequest.AppOrWeb = getString(R.string.app) userRequest.LoggedInRoleId = 5 val deviceInfo = DeviceInfo() deviceInfo.device_id = "" deviceInfo.device_id_for_UMSId = "" - deviceInfo.device_type = getString(com.nivesh.production.bajajfd.R.string.app) + deviceInfo.device_type = getString(R.string.app) deviceInfo.device_model = "" deviceInfo.device_token = "" deviceInfo.device_name = "" @@ -388,29 +394,23 @@ class BajajFdMainActivity : BaseActivity(), BajajFDInterface { // step 2 response override fun stepTwoApi(data: CreateFDRequest) { - Log.e("stepTwoApi", " response ---> $data") - // if (stepCount == 4) { - // go to step 3 image Upload - // binding.viewPager.currentItem = 2 - // } else { - // call create fd api bypass step 3 - createFDApi(data, 2, "2") - // } + Log.e("stepTwoApi", " response ---> " + Gson().toJson(data)) + createFDApi(data, 2, "2") } // step 3 response override fun stepThreeApi(data: CreateFDRequest) { - Log.e("stepThreeApi", " response ---> $data") + Log.e("stepThreeApi", " response --->" + Gson().toJson(data)) // call create fd api createFDApi(data, 3, "3") } // step 4 response - override fun stepFourApi(data: SaveFDOtherDataRequest) { - Log.e("stepFourApi", " response ---> $data") - // binding.viewPager.currentItem = 4 - + override fun stepFourApi(data: SaveFDOtherDataRequest, payUrl: String, value: String) { + Log.e("stepFourApi", " response ---> " + Gson().toJson(data)) + // binding.viewPager.currentItem = 4 + saveFDOtherData(data, payUrl, value) } private fun createFDApi(data: CreateFDRequest, currentItem: Int, step: String) { @@ -430,16 +430,19 @@ class BajajFdMainActivity : BaseActivity(), BajajFDInterface { when (code) { 200 -> { binding.viewPager.currentItem = currentItem - if (step == "2"){ + if (step == "2") { val stepThreeBajajFDFragment: StepThreeBajajFDFragment = sectionsPagerAdapter.getRegisteredFragment(currentItem) as StepThreeBajajFDFragment - stepThreeBajajFDFragment.displayReceivedData(createFDApplicationResponse) + stepThreeBajajFDFragment.displayReceivedData( + createFDApplicationResponse + ) + } else { + val stepFourFDFragment: StepFourBajajFDFragment = + sectionsPagerAdapter.getRegisteredFragment(currentItem) as StepFourBajajFDFragment + stepFourFDFragment.displayReceivedData( + createFDApplicationResponse + ) } - else{ - val stepFourFDFragment: StepFourBajajFDFragment = - sectionsPagerAdapter.getRegisteredFragment(currentItem) as StepFourBajajFDFragment - stepFourFDFragment.displayReceivedData(createFDApplicationResponse) - } } // 650 -> refreshToken() else -> { @@ -464,4 +467,87 @@ class BajajFdMainActivity : BaseActivity(), BajajFDInterface { } } } + + private fun saveFDOtherData(data: SaveFDOtherDataRequest, payUrl: String, value: String) { + if (Common.isNetworkAvailable(this)) { + viewModel.saveFDOtherData(data, token) + viewModel.getFDOtherMutableData.observe(this) { response -> + when (response) { + is Resource.Success -> { + Log.e("response", "-->" + response.data.toString()) + val saveFDOtherDataResponse: SaveFDOtherDataResponse = + Gson().fromJson( + response.data?.toString(), + SaveFDOtherDataResponse::class.java + ) + saveFDOtherDataResponse.Response.StatusCode.let { code -> + when (code) { + 200 -> { + paymentDialog(payUrl, value) + } + // 650 -> refreshToken() + else -> { + showDialogValidation( + this@BajajFdMainActivity, + saveFDOtherDataResponse.Response.Errors[0].ErrorMessage + ) + } + } + } + } + + is Resource.Error -> { + response.message?.let { message -> + showDialogValidation(this@BajajFdMainActivity, message) + } + } + is Resource.Loading -> { + + } + } + } + } + } + + @SuppressLint("SetJavaScriptEnabled") + fun paymentDialog(payUrl: String, value: String) { + Log.e("payUrl", "-->$payUrl") + Log.e("value", "-->$value") + val 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.webViewClient = MyWebViewClient() + wVPay.settings.javaScriptEnabled = true + wVPay.settings.domStorageEnabled = true + wVPay.loadUrl(payUrl) + dialogWebView.show() + } + + class MyWebViewClient : WebViewClient() { + override fun onPageStarted(view: WebView, url: String, favicon: Bitmap?) { + super.onPageStarted(view, url, favicon) + Log.e("onPageStarted", "-->$url") + if (url.isNotEmpty() && url.contains("CustomerPaymentResponse")) { + + } + } + + override fun onPageFinished(view: WebView, url: String) { + super.onPageFinished(view, url) + } + + } + } \ 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 index 654ce7d..4186ee3 100644 --- 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 @@ -8,30 +8,27 @@ import androidx.fragment.app.Fragment import androidx.lifecycle.ViewModelProvider import com.nivesh.production.bajajfd.interfaces.BajajFDInterface import com.nivesh.production.bajajfd.databinding.FragmentBajajfdStepFiveBinding +import com.nivesh.production.bajajfd.ui.activity.BajajFdMainActivity import com.nivesh.production.bajajfd.viewModel.StepFiveBajajFDViewModel class StepFiveBajajFDFragment : Fragment() { - private lateinit var stepFourViewModel: StepFiveBajajFDViewModel + private lateinit var stepFiveBajajFDViewModel: StepFiveBajajFDViewModel private var _binding: FragmentBajajfdStepFiveBinding? = null private val binding get() = _binding!! private lateinit var bajajFDInterface: BajajFDInterface companion object { fun getInstance(fdInterface: BajajFDInterface): StepFiveBajajFDFragment { - val stepFourFragment = StepFiveBajajFDFragment() - stepFourFragment.setApi(fdInterface) - return stepFourFragment + val stepFiveFragment = StepFiveBajajFDFragment() + stepFiveFragment.setApi(fdInterface) + return stepFiveFragment } } - private fun setApi(bajajFDInterfaces: BajajFDInterface) { + fun setApi(bajajFDInterfaces: BajajFDInterface) { bajajFDInterface = bajajFDInterfaces } - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - - } override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, @@ -40,6 +37,7 @@ class StepFiveBajajFDFragment : Fragment() { _binding = FragmentBajajfdStepFiveBinding.inflate(inflater, container, false) val root = binding.root + stepFiveBajajFDViewModel= (activity as BajajFdMainActivity).stepFiveBajajFDViewModel // val textView: TextView = binding.sectionLabel // stepFourViewModel.text.observe(viewLifecycleOwner) { 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 index 8735f74..60a5e1d 100644 --- 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 @@ -26,7 +26,9 @@ class StepFourBajajFDFragment : BaseFragment() { private val binding get() = _binding!! private lateinit var listOfCustomer: MutableList private var selectedList: String = "" - private var uniqueId: String? = "" + private var uniqueId: String = "" + private var payUrl : String = "" + private var Value : String = "" private lateinit var bajajFDInterface: BajajFDInterface @@ -75,7 +77,7 @@ class StepFourBajajFDFragment : BaseFragment() { saveFDOtherDataRequest.Values = selectedList saveFDOtherDataRequest.NiveshClientCode = (activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_CODE - bajajFDInterface.stepFourApi(saveFDOtherDataRequest) + bajajFDInterface.stepFourApi(saveFDOtherDataRequest, payUrl, Value) } else { showDialogValidation( activity as BajajFdMainActivity, @@ -92,10 +94,6 @@ class StepFourBajajFDFragment : BaseFragment() { fun displayReceivedData(createFDApplicationResponse: CreateFDApplicationResponse) { - Log.e( - "createFDApplication", - "Response-->" + createFDApplicationResponse.Response.FDCreationDetailsResponse.UniqueId - ) uniqueId = createFDApplicationResponse.Response.FDCreationDetailsResponse.UniqueId getFDDetailsApi(createFDApplicationResponse.Response.FDCreationDetailsResponse.UniqueId) customerListApi() @@ -188,12 +186,14 @@ class StepFourBajajFDFragment : BaseFragment() { 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.Message + getFDDetailsResponse.Response.Errors[0].ErrorMessage ) } } @@ -216,6 +216,6 @@ class StepFourBajajFDFragment : BaseFragment() { override fun onDestroyView() { super.onDestroyView() - _binding = null + // _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 index b6e6484..d902315 100644 --- 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 @@ -505,6 +505,6 @@ class StepOneBajajFDFragment : BaseFragment() { override fun onDestroyView() { super.onDestroyView() - _binding = null + // _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 index 8218885..4637d23 100644 --- 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 @@ -35,6 +35,7 @@ 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 @@ -1784,7 +1785,14 @@ class StepTwoBajajFDFragment : BaseFragment() { binding.tlPinCode, getString(R.string.validPinCode) ) - } else if ((activity as BajajFdMainActivity).getClientDetailsResponse.ObjectResponse?.ClientBanklist?.isEmpty()!! && binding.edtIFSC.text.toString() + }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( @@ -1831,7 +1839,7 @@ class StepTwoBajajFDFragment : BaseFragment() { override fun onDestroyView() { super.onDestroyView() - _binding = null + // _binding = null } } 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 index 2616268..9e980ec 100644 --- a/app/src/main/java/com/nivesh/production/bajajfd/util/Common.kt +++ b/app/src/main/java/com/nivesh/production/bajajfd/util/Common.kt @@ -9,6 +9,7 @@ import android.net.ConnectivityManager import android.net.NetworkCapabilities import android.os.Build import android.provider.ContactsContract +import android.text.format.DateFormat import android.util.Patterns import com.google.android.material.textfield.MaterialAutoCompleteTextView import com.google.android.material.textfield.TextInputEditText @@ -203,5 +204,17 @@ class Common { } return Resource.Error(response.message()) } + + fun isMinor(date: String): Boolean { + val simpleDateFormat = SimpleDateFormat("yyyy-mm-dd") + val dt1: Date = simpleDateFormat.parse(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) + } } } \ 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 index 1b703fb..a659e8c 100644 --- a/app/src/main/java/com/nivesh/production/bajajfd/viewModel/BajajFDViewModel.kt +++ b/app/src/main/java/com/nivesh/production/bajajfd/viewModel/BajajFDViewModel.kt @@ -5,9 +5,7 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.google.gson.JsonObject -import com.nivesh.production.bajajfd.model.CreateFDRequest -import com.nivesh.production.bajajfd.model.FDStepsCountRequest -import com.nivesh.production.bajajfd.model.getClientDetailsRequest +import com.nivesh.production.bajajfd.model.* import com.nivesh.production.bajajfd.repositories.MainRepository import com.nivesh.production.bajajfd.util.Common.Companion.handleRatesResponse import com.nivesh.production.bajajfd.util.Resource @@ -38,21 +36,11 @@ class BajajFDViewModel(private val mainRepository: MainRepository) : ViewModel() getFDResponseMutableData.postValue(handleRatesResponse(response)) } -// private fun handleRatesResponse(response: retrofit2.Response): Resource { -// try { -// if ( response.isSuccessful && response.body() != null) { -// response.body()?.let { resultResponse -> -// return Resource.Success(resultResponse) -// } -// } -// } catch (t: Throwable) { -// return when (t) { -// is IOException -> Resource.Error("Response : "+t.message.plus(" Cause: "+t.cause)) -// is HttpException -> Resource.Error("Response : "+t.message.plus(" Cause: "+t.cause)) -// else -> Resource.Error(t.localizedMessage?.toString() ?: "") -// } -// } -// return Resource.Error(response.message()) -// } + val getFDOtherMutableData: MutableLiveData> = MutableLiveData() + fun saveFDOtherData(getRatesRequest: SaveFDOtherDataRequest, token: String) = viewModelScope.launch { + getFDOtherMutableData.postValue(Resource.Loading()) + val response = mainRepository.saveFDOtherDataResponse(getRatesRequest, token) + getFDOtherMutableData.postValue(handleRatesResponse(response)) + } } \ No newline at end of file diff --git a/app/src/main/java/com/nivesh/production/bajajfd/viewModel/StepFiveBajajFDViewModel.kt b/app/src/main/java/com/nivesh/production/bajajfd/viewModel/StepFiveBajajFDViewModel.kt index 509c598..0484681 100644 --- a/app/src/main/java/com/nivesh/production/bajajfd/viewModel/StepFiveBajajFDViewModel.kt +++ b/app/src/main/java/com/nivesh/production/bajajfd/viewModel/StepFiveBajajFDViewModel.kt @@ -1,7 +1,17 @@ package com.nivesh.production.bajajfd.viewModel +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup import androidx.lifecycle.ViewModel +import com.nivesh.production.bajajfd.databinding.FragmentBajajfdStepFiveBinding +import com.nivesh.production.bajajfd.databinding.FragmentBajajfdStepFourBinding +import com.nivesh.production.bajajfd.interfaces.BajajFDInterface import com.nivesh.production.bajajfd.repositories.MainRepository +import com.nivesh.production.bajajfd.ui.activity.BajajFdMainActivity +import com.nivesh.production.bajajfd.ui.fragment.StepFiveBajajFDFragment +import com.nivesh.production.bajajfd.ui.fragment.StepFourBajajFDFragment class StepFiveBajajFDViewModel (private val mainRepository: MainRepository) : ViewModel() { diff --git a/app/src/main/java/com/nivesh/production/bajajfd/viewModel/StepFourBajajFDViewModel.kt b/app/src/main/java/com/nivesh/production/bajajfd/viewModel/StepFourBajajFDViewModel.kt index e68bff9..f7acd5b 100644 --- a/app/src/main/java/com/nivesh/production/bajajfd/viewModel/StepFourBajajFDViewModel.kt +++ b/app/src/main/java/com/nivesh/production/bajajfd/viewModel/StepFourBajajFDViewModel.kt @@ -28,13 +28,7 @@ class StepFourBajajFDViewModel(private val mainRepository: MainRepository) : Vie getFDDetailsMutableData.postValue(handleRatesResponse(response)) } - private val getRatesMutableData: MutableLiveData> = MutableLiveData() - fun saveFDOtherData(getRatesRequest: GetRatesRequest, token: String) = viewModelScope.launch { - getRatesMutableData.postValue(Resource.Loading()) - val response = mainRepository.saveFDOtherDataResponse(getRatesRequest, token) - getRatesMutableData.postValue(handleRatesResponse(response)) - } - + val getRatesMutableData: MutableLiveData> = MutableLiveData() fun updateFDPaymentStatus(getRatesRequest: GetRatesRequest, token: String) = viewModelScope.launch { getRatesMutableData.postValue(Resource.Loading()) diff --git a/app/src/main/res/layout/row_fd_pay.xml b/app/src/main/res/layout/row_fd_pay.xml new file mode 100644 index 0000000..a255157 --- /dev/null +++ b/app/src/main/res/layout/row_fd_pay.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values-hi-rIN/strings.xml b/app/src/main/res/values-hi-rIN/strings.xml index 53064ea..86039fa 100644 --- a/app/src/main/res/values-hi-rIN/strings.xml +++ b/app/src/main/res/values-hi-rIN/strings.xml @@ -247,5 +247,7 @@ PaymentMode CustomerCategory PAY + Payment + Please enter Guardian Details \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0027640..7311f62 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -247,6 +247,8 @@ PaymentMode CustomerCategory PAY + Payment + Please enter Guardian Details Aadhaar Card