|
@ -1,12 +1,20 @@ |
|
|
package com.nivesh.production.bajajfd.ui.activity |
|
|
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.graphics.drawable.Drawable |
|
|
import android.os.Bundle |
|
|
import android.os.Bundle |
|
|
import android.util.Log |
|
|
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.fragment.app.Fragment |
|
|
import androidx.lifecycle.ViewModelProvider |
|
|
import androidx.lifecycle.ViewModelProvider |
|
|
import androidx.viewpager.widget.ViewPager |
|
|
import androidx.viewpager.widget.ViewPager |
|
|
import com.google.gson.Gson |
|
|
import com.google.gson.Gson |
|
|
|
|
|
import com.nivesh.production.bajajfd.R |
|
|
import com.nivesh.production.bajajfd.adapter.SectionsPagerAdapter |
|
|
import com.nivesh.production.bajajfd.adapter.SectionsPagerAdapter |
|
|
import com.nivesh.production.bajajfd.api.ApiClient |
|
|
import com.nivesh.production.bajajfd.api.ApiClient |
|
|
import com.nivesh.production.bajajfd.databinding.ActivityBajajFdBinding |
|
|
import com.nivesh.production.bajajfd.databinding.ActivityBajajFdBinding |
|
@ -46,7 +54,7 @@ class BajajFdMainActivity : BaseActivity(), BajajFDInterface { |
|
|
var getClientDetailsResponse: getClientDetailsResponse |
|
|
var getClientDetailsResponse: getClientDetailsResponse |
|
|
|
|
|
|
|
|
private var stepCount: Int = 0 |
|
|
private var stepCount: Int = 0 |
|
|
private lateinit var sectionsPagerAdapter : SectionsPagerAdapter |
|
|
|
|
|
|
|
|
private lateinit var sectionsPagerAdapter: SectionsPagerAdapter |
|
|
private lateinit var fragments: Array<Fragment> |
|
|
private lateinit var fragments: Array<Fragment> |
|
|
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) { |
|
|
override fun onCreate(savedInstanceState: Bundle?) { |
|
@ -108,53 +116,51 @@ class BajajFdMainActivity : BaseActivity(), BajajFDInterface { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private fun getStepsCountApi() { |
|
|
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) { |
|
|
private fun refreshToken(fdStepsCount: FDStepsCountRequest) { |
|
|
if (Common.isNetworkAvailable(this@BajajFdMainActivity)) { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -162,20 +168,20 @@ class BajajFdMainActivity : BaseActivity(), BajajFDInterface { |
|
|
if (Common.isNetworkAvailable(this@BajajFdMainActivity)) { |
|
|
if (Common.isNetworkAvailable(this@BajajFdMainActivity)) { |
|
|
val getClientDetailsRequest = getClientDetailsRequest() |
|
|
val getClientDetailsRequest = getClientDetailsRequest() |
|
|
getClientDetailsRequest.client_code = "8872" |
|
|
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" |
|
|
getClientDetailsRequest.sub_broker_code = "1038" |
|
|
|
|
|
|
|
|
val userRequest = UserRequest() |
|
|
val userRequest = UserRequest() |
|
|
userRequest.UID = 19060 |
|
|
userRequest.UID = 19060 |
|
|
userRequest.IPAddress = "" |
|
|
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 |
|
|
userRequest.LoggedInRoleId = 5 |
|
|
|
|
|
|
|
|
val deviceInfo = DeviceInfo() |
|
|
val deviceInfo = DeviceInfo() |
|
|
deviceInfo.device_id = "" |
|
|
deviceInfo.device_id = "" |
|
|
deviceInfo.device_id_for_UMSId = "" |
|
|
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_model = "" |
|
|
deviceInfo.device_token = "" |
|
|
deviceInfo.device_token = "" |
|
|
deviceInfo.device_name = "" |
|
|
deviceInfo.device_name = "" |
|
@ -388,29 +394,23 @@ class BajajFdMainActivity : BaseActivity(), BajajFDInterface { |
|
|
|
|
|
|
|
|
// step 2 response |
|
|
// step 2 response |
|
|
override fun stepTwoApi(data: CreateFDRequest) { |
|
|
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 |
|
|
// step 3 response |
|
|
override fun stepThreeApi(data: CreateFDRequest) { |
|
|
override fun stepThreeApi(data: CreateFDRequest) { |
|
|
Log.e("stepThreeApi", " response ---> $data") |
|
|
|
|
|
|
|
|
Log.e("stepThreeApi", " response --->" + Gson().toJson(data)) |
|
|
// call create fd api |
|
|
// call create fd api |
|
|
createFDApi(data, 3, "3") |
|
|
createFDApi(data, 3, "3") |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// step 4 response |
|
|
// 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) { |
|
|
private fun createFDApi(data: CreateFDRequest, currentItem: Int, step: String) { |
|
@ -430,16 +430,19 @@ class BajajFdMainActivity : BaseActivity(), BajajFDInterface { |
|
|
when (code) { |
|
|
when (code) { |
|
|
200 -> { |
|
|
200 -> { |
|
|
binding.viewPager.currentItem = currentItem |
|
|
binding.viewPager.currentItem = currentItem |
|
|
if (step == "2"){ |
|
|
|
|
|
|
|
|
if (step == "2") { |
|
|
val stepThreeBajajFDFragment: StepThreeBajajFDFragment = |
|
|
val stepThreeBajajFDFragment: StepThreeBajajFDFragment = |
|
|
sectionsPagerAdapter.getRegisteredFragment(currentItem) as 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() |
|
|
// 650 -> refreshToken() |
|
|
else -> { |
|
|
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<TextView>(R.id.tvCancel) |
|
|
|
|
|
tvCancel.setOnClickListener { |
|
|
|
|
|
dialogWebView.dismiss() |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
val lp = WindowManager.LayoutParams() |
|
|
|
|
|
lp.copyFrom(dialogWebView.window?.attributes) |
|
|
|
|
|
lp.width = WindowManager.LayoutParams.MATCH_PARENT |
|
|
|
|
|
lp.height = WindowManager.LayoutParams.MATCH_PARENT |
|
|
|
|
|
dialogWebView.window?.attributes = lp |
|
|
|
|
|
val wVPay = dialogWebView.findViewById<WebView>(R.id.wVPay) |
|
|
|
|
|
wVPay.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) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |