|
|
@ -31,9 +31,6 @@ import com.nivesh.production.bajajfd.util.Common.Companion.showDialogValidation |
|
|
|
import com.nivesh.production.bajajfd.util.Constants.Companion.token |
|
|
|
import com.nivesh.production.bajajfd.util.Resource |
|
|
|
import com.nivesh.production.bajajfd.viewModel.* |
|
|
|
import java.io.BufferedReader |
|
|
|
import java.io.InputStream |
|
|
|
import java.io.InputStreamReader |
|
|
|
|
|
|
|
|
|
|
|
class BajajFdMainActivity : BaseActivity() { |
|
|
@ -55,12 +52,12 @@ class BajajFdMainActivity : BaseActivity() { |
|
|
|
var nomineeDetails: NomineeDetails = NomineeDetails() |
|
|
|
var nomineeGuardianDetails: NomineeGuardianDetails = NomineeGuardianDetails() |
|
|
|
var getClientDetailsResponse: getClientDetailsResponse = getClientDetailsResponse() |
|
|
|
|
|
|
|
var UniqueId: String = "" |
|
|
|
private var stepCount: Int = 0 |
|
|
|
private lateinit var sectionsPagerAdapter: SectionsPagerAdapter |
|
|
|
private lateinit var fragments: Array<Fragment> |
|
|
|
|
|
|
|
var valur:String="" |
|
|
|
var dialogWebView: Dialog? = null |
|
|
|
var LoginRole: Int = 0 |
|
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) { |
|
|
|
super.onCreate(savedInstanceState) |
|
|
@ -78,6 +75,7 @@ class BajajFdMainActivity : BaseActivity() { |
|
|
|
FDModelProviderFactory(MainRepository(ApiClient.getApiClient)) |
|
|
|
)[BajajFDViewModel::class.java] |
|
|
|
|
|
|
|
LoginRole = 5 |
|
|
|
if (Common.isNetworkAvailable(this)) { |
|
|
|
getStepsCountApi() |
|
|
|
} |
|
|
@ -92,8 +90,7 @@ class BajajFdMainActivity : BaseActivity() { |
|
|
|
val fdStepsCount = FDStepsCountRequest() |
|
|
|
fdStepsCount.FDProvider = getString(R.string.bajaj) |
|
|
|
fdStepsCount.NiveshClientCode = "8872" |
|
|
|
//hemant client code =8872 /60476 |
|
|
|
|
|
|
|
// client code =8872 /60476 |
|
|
|
viewModel.getStepsCount(fdStepsCount, token, this) |
|
|
|
viewModel.getStepsCountMutableData.observe(this) { response -> |
|
|
|
when (response) { |
|
|
@ -110,7 +107,7 @@ class BajajFdMainActivity : BaseActivity() { |
|
|
|
stepCount = stepsCountResponse.Response.StepsCount |
|
|
|
getClientDetailsApi(stepsCountResponse.Response.StepsCount) |
|
|
|
} |
|
|
|
650 -> refreshToken(fdStepsCount) |
|
|
|
650 -> refreshToken("") |
|
|
|
else -> { |
|
|
|
showDialogValidation( |
|
|
|
this@BajajFdMainActivity, |
|
|
@ -136,10 +133,10 @@ class BajajFdMainActivity : BaseActivity() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private fun refreshToken(fdStepsCount: FDStepsCountRequest) { |
|
|
|
|
|
|
|
} |
|
|
|
private fun refreshToken(fdStepsCount: String) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private fun getClientDetailsApi(stepsCount: Int) { |
|
|
|
if (Common.isNetworkAvailable(this@BajajFdMainActivity)) { |
|
|
@ -147,16 +144,13 @@ class BajajFdMainActivity : BaseActivity() { |
|
|
|
getClientDetailsRequest.client_code = "8872" |
|
|
|
getClientDetailsRequest.AppOrWeb = getString(R.string.app) |
|
|
|
getClientDetailsRequest.sub_broker_code = "1038" |
|
|
|
|
|
|
|
//hemant 8872/1038// |
|
|
|
|
|
|
|
|
|
|
|
// 8872/1038 |
|
|
|
val userRequest = UserRequest() |
|
|
|
userRequest.UID = 0 |
|
|
|
userRequest.IPAddress = "" |
|
|
|
userRequest.Source = getString(R.string.source) |
|
|
|
userRequest.AppOrWeb = getString(R.string.app) |
|
|
|
userRequest.LoggedInRoleId = 5 |
|
|
|
userRequest.LoggedInRoleId = LoginRole |
|
|
|
|
|
|
|
val deviceInfo = DeviceInfo() |
|
|
|
deviceInfo.device_id = "" |
|
|
@ -210,7 +204,6 @@ class BajajFdMainActivity : BaseActivity() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun setViewPager(stepsCount: Int) { |
|
|
|
// steps setting |
|
|
|
setBackground(selectedShape(), defaultShape(), defaultShape(), defaultShape()) |
|
|
@ -356,7 +349,6 @@ class BajajFdMainActivity : BaseActivity() { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// set background for selected/ default step |
|
|
|
private fun setBackground( |
|
|
|
drawable: Drawable?, |
|
|
@ -371,21 +363,20 @@ class BajajFdMainActivity : BaseActivity() { |
|
|
|
} |
|
|
|
|
|
|
|
// step 1 response |
|
|
|
fun stepOneApi(data: String?) { |
|
|
|
fun stepOneApi(data: String?) { |
|
|
|
Log.e("stepOneApi", " response ---> $data") |
|
|
|
binding.viewPager.currentItem = 1 |
|
|
|
} |
|
|
|
|
|
|
|
// step 2 response |
|
|
|
fun stepTwoApi(data: CreateFDApplicationResponse) { |
|
|
|
fun stepTwoApi(data: CreateFDApplicationResponse) { |
|
|
|
Log.e("stepTwoApi", " response ---> " + Gson().toJson(data)) |
|
|
|
binding.viewPager.currentItem = 2 |
|
|
|
stepThreeBajajFDFragment.displayReceivedData(data) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// step 3 response |
|
|
|
fun stepThreeApi(data: CreateFDApplicationResponse) { |
|
|
|
fun stepThreeApi(data: CreateFDApplicationResponse) { |
|
|
|
Log.e("stepThreeApi", " response --->" + Gson().toJson(data)) |
|
|
|
// call create fd api |
|
|
|
binding.viewPager.currentItem = 3 |
|
|
@ -393,10 +384,7 @@ class BajajFdMainActivity : BaseActivity() { |
|
|
|
} |
|
|
|
|
|
|
|
// step 4 response |
|
|
|
fun stepFourApi(payUrl: String, value: String) { |
|
|
|
|
|
|
|
valur=value |
|
|
|
|
|
|
|
fun stepFourApi(payUrl: String, value: String) { |
|
|
|
paymentDialog(payUrl, value) |
|
|
|
} |
|
|
|
|
|
|
@ -404,121 +392,92 @@ class BajajFdMainActivity : BaseActivity() { |
|
|
|
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) |
|
|
|
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() |
|
|
|
dialogWebView!!.dismiss() |
|
|
|
} |
|
|
|
|
|
|
|
val lp = WindowManager.LayoutParams() |
|
|
|
lp.copyFrom(dialogWebView.window?.attributes) |
|
|
|
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() |
|
|
|
dialogWebView!!.window?.attributes = lp |
|
|
|
val wVPay = dialogWebView!!.findViewById<WebView>(R.id.wVPay) |
|
|
|
wVPay.settings.javaScriptEnabled = true |
|
|
|
wVPay.settings.domStorageEnabled = true |
|
|
|
// val postData = "name=${URLEncoder.encode("msg", "UTF-8")}" + |
|
|
|
// "&value=${URLEncoder.encode(value, "UTF-8")}" |
|
|
|
// wVPay.postUrl(payUrl, postData.toByteArray()) |
|
|
|
|
|
|
|
// val webView = WebView(this@BajajFdMainActivity) |
|
|
|
// setContentView(webView) |
|
|
|
// val postData = "msg=${URLEncoder.encode(value, "UTF-8")}" |
|
|
|
// |
|
|
|
// Log.e("valueee", "-->$postData") |
|
|
|
// |
|
|
|
// |
|
|
|
// webView.postUrl(payUrl, postData.toByteArray()) |
|
|
|
// |
|
|
|
// |
|
|
|
// |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val iss: InputStream = assets.open("paymentpageform.html") |
|
|
|
val size: Int = iss.available() |
|
|
|
|
|
|
|
val buffer = ByteArray(size) |
|
|
|
iss.read(buffer) |
|
|
|
|
|
|
|
var str = String(buffer) |
|
|
|
str = str.replace("cus", value) |
|
|
|
|
|
|
|
|
|
|
|
// val br = BufferedReader( |
|
|
|
// InputStreamReader( |
|
|
|
// iss.getInputStream() |
|
|
|
// ) |
|
|
|
// ) |
|
|
|
// |
|
|
|
// while ((str = br.readLine()) != null) { |
|
|
|
// response += line; |
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
iss.close() |
|
|
|
|
|
|
|
wVPay.loadUrl("file:///android_asset/paymentpageform.html") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wVPay.setWebViewClient(object : WebViewClient() { |
|
|
|
wVPay.loadData( |
|
|
|
"<form name=\"frm\" action=\"$payUrl\" method=\"post\"> \n" + " <input type=\"hidden\" name=\"msg\" value=\"$value\"> \n" + " </form> \n" + |
|
|
|
"<script type=\"text/javascript\"> \n" + "document.forms[\"frm\"].submit(); \n" + "</script>", |
|
|
|
"text/html", |
|
|
|
"UTF-8" |
|
|
|
) |
|
|
|
wVPay.webViewClient = object : WebViewClient() { |
|
|
|
override fun onPageStarted(view: WebView, url: String, favicon: Bitmap?) { |
|
|
|
super.onPageStarted(view, url, favicon) |
|
|
|
Log.e("onPageStarted", "-->$url") |
|
|
|
|
|
|
|
|
|
|
|
wVPay.loadUrl("file:///android_asset/paymentpageform.html") |
|
|
|
|
|
|
|
val link1 = "pp" |
|
|
|
val link2 = valur |
|
|
|
view.loadUrl("javascript:(function(){document.body.innerHTML = document.body.innerHTML.replace('$link1', '$link2')})()") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (url.isNotEmpty() && url.contains("CustomerPaymentResponse")) { |
|
|
|
|
|
|
|
if (url.isNotEmpty() && url.contains("https://uat.nivesh.com/bajajFD/OrderStatus")) { |
|
|
|
if (dialogWebView != null && dialogWebView!!.isShowing) { |
|
|
|
dialogWebView!!.dismiss() |
|
|
|
paymentReQueryApi() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// wVPay.loadUrl("file:///android_asset/paymentpageform.html") |
|
|
|
|
|
|
|
// wVPay.loadDataWithBaseURL("file:///android_asset/", str,"text/html", "UTF-8",null); |
|
|
|
// wVPay.loadData(str, "text/html; charset=utf-8", "UTF-8"); |
|
|
|
// dialogWebView.show() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// class MyWebViewClient : WebViewClient() { |
|
|
|
// override fun onPageStarted(view: WebView, url: String, favicon: Bitmap?) { |
|
|
|
// super.onPageStarted(view, url, favicon) |
|
|
|
// Log.e("onPageStarted", "-->$url") |
|
|
|
// |
|
|
|
// val link1 = "pp" |
|
|
|
// val link2 = valur |
|
|
|
// view.loadUrl("javascript:(function(){document.body.innerHTML = document.body.innerHTML.replace('$link1', '$link2')})()") |
|
|
|
// |
|
|
|
// if (url.isNotEmpty() && url.contains("CustomerPaymentResponse")) { |
|
|
|
// |
|
|
|
// } |
|
|
|
// } |
|
|
|
// |
|
|
|
// override fun onPageFinished(view: WebView, url: String) { |
|
|
|
// super.onPageFinished(view, url) |
|
|
|
// } |
|
|
|
|
|
|
|
} |
|
|
|
dialogWebView!!.show() |
|
|
|
} |
|
|
|
|
|
|
|
fun paymentReQueryApi() { |
|
|
|
if (Common.isNetworkAvailable(this)) { |
|
|
|
val paymentReQueryRequest = PaymentReQueryRequest() |
|
|
|
paymentReQueryRequest.UniqueId = UniqueId |
|
|
|
paymentReQueryRequest.NiveshClientCode = |
|
|
|
getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_CODE |
|
|
|
viewModel.getPaymentReQuery(paymentReQueryRequest, token, this) |
|
|
|
viewModel.getPaymentReQueryMutableData.observe(this) { response -> |
|
|
|
when (response) { |
|
|
|
is Resource.Success -> { |
|
|
|
Log.e("response", "-->$response") |
|
|
|
val paymentReQueryResponse: PaymentReQueryResponse = |
|
|
|
Gson().fromJson( |
|
|
|
response.data?.toString(), |
|
|
|
PaymentReQueryResponse::class.java |
|
|
|
) |
|
|
|
paymentReQueryResponse.Response.StatusCode.let { code -> |
|
|
|
when (code) { |
|
|
|
200 -> { |
|
|
|
if (stepCount == 4) { |
|
|
|
binding.viewPager.currentItem = 4 |
|
|
|
} else { |
|
|
|
binding.viewPager.currentItem = 3 |
|
|
|
} |
|
|
|
stepFiveBajajFDFragment.getData(paymentReQueryResponse) |
|
|
|
} |
|
|
|
650 -> refreshToken("") |
|
|
|
else -> { |
|
|
|
showDialogValidation( |
|
|
|
this@BajajFdMainActivity, |
|
|
|
paymentReQueryResponse.Response.Errors[0].ErrorMessage |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
is Resource.Error -> { |
|
|
|
response.message?.let { message -> |
|
|
|
showDialogValidation(this@BajajFdMainActivity, message) |
|
|
|
} |
|
|
|
} |
|
|
|
is Resource.Loading -> { |
|
|
|
|
|
|
|
} |
|
|
|
is Resource.DataError -> { |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |