|
|
@ -1,12 +1,15 @@ |
|
|
|
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 |
|
|
@ -28,7 +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.net.URLEncoder |
|
|
|
|
|
|
|
|
|
|
|
class BajajFdMainActivity : BaseActivity() { |
|
|
@ -50,10 +52,12 @@ class BajajFdMainActivity : BaseActivity() { |
|
|
|
var nomineeDetails: NomineeDetails = NomineeDetails() |
|
|
|
var nomineeGuardianDetails: NomineeGuardianDetails = NomineeGuardianDetails() |
|
|
|
var getClientDetailsResponse: getClientDetailsResponse = getClientDetailsResponse() |
|
|
|
var UniqueId :String = "" |
|
|
|
var UniqueId: String = "" |
|
|
|
private var stepCount: Int = 0 |
|
|
|
private lateinit var sectionsPagerAdapter: SectionsPagerAdapter |
|
|
|
private lateinit var fragments: Array<Fragment> |
|
|
|
var dialogWebView: Dialog? = null |
|
|
|
var LoginRole: Int = 0 |
|
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) { |
|
|
|
super.onCreate(savedInstanceState) |
|
|
@ -71,6 +75,7 @@ class BajajFdMainActivity : BaseActivity() { |
|
|
|
FDModelProviderFactory(MainRepository(ApiClient.getApiClient)) |
|
|
|
)[BajajFDViewModel::class.java] |
|
|
|
|
|
|
|
LoginRole = 5 |
|
|
|
if (Common.isNetworkAvailable(this)) { |
|
|
|
getStepsCountApi() |
|
|
|
} |
|
|
@ -145,7 +150,7 @@ class BajajFdMainActivity : BaseActivity() { |
|
|
|
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 = "" |
|
|
@ -370,7 +375,6 @@ class BajajFdMainActivity : BaseActivity() { |
|
|
|
stepThreeBajajFDFragment.displayReceivedData(data) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// step 3 response |
|
|
|
fun stepThreeApi(data: CreateFDApplicationResponse) { |
|
|
|
Log.e("stepThreeApi", " response --->" + Gson().toJson(data)) |
|
|
@ -388,52 +392,48 @@ 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) |
|
|
|
// 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 |
|
|
|
// val postData = "name=${URLEncoder.encode("msg", "UTF-8")}" + |
|
|
|
// "&value=${URLEncoder.encode(value, "UTF-8")}" |
|
|
|
// wVPay.postUrl(payUrl, postData.toByteArray()) |
|
|
|
// dialogWebView.show() |
|
|
|
|
|
|
|
val webView = WebView(this@BajajFdMainActivity) |
|
|
|
setContentView(webView) |
|
|
|
val postData = "name=${URLEncoder.encode("msg", "UTF-8")}" + |
|
|
|
"&value=${URLEncoder.encode(value, "UTF-8")}" |
|
|
|
webView.postUrl(payUrl, postData.toByteArray()) |
|
|
|
} |
|
|
|
|
|
|
|
class MyWebViewClient : WebViewClient() { |
|
|
|
override fun onPageStarted(view: WebView, url: String, favicon: Bitmap?) { |
|
|
|
super.onPageStarted(view, url, favicon) |
|
|
|
Log.e("onPageStarted", "-->$url") |
|
|
|
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() |
|
|
|
} |
|
|
|
|
|
|
|
override fun onPageFinished(view: WebView, url: String) { |
|
|
|
super.onPageFinished(view, url) |
|
|
|
val lp = WindowManager.LayoutParams() |
|
|
|
lp.copyFrom(dialogWebView!!.window?.attributes) |
|
|
|
lp.width = WindowManager.LayoutParams.MATCH_PARENT |
|
|
|
lp.height = WindowManager.LayoutParams.MATCH_PARENT |
|
|
|
dialogWebView!!.window?.attributes = lp |
|
|
|
val wVPay = dialogWebView!!.findViewById<WebView>(R.id.wVPay) |
|
|
|
wVPay.settings.javaScriptEnabled = true |
|
|
|
wVPay.settings.domStorageEnabled = true |
|
|
|
wVPay.loadData( |
|
|
|
"<form name=\"frm\" action=\"$payUrl\" method=\"post\"> \n" + " <input type=\"hidden\" name=\"msg\" value=\"$value\"> \n" + " </form> \n" + |
|
|
|
"<script type=\"text/javascript\"> \n" + "document.forms[\"frm\"].submit(); \n" + "</script>", |
|
|
|
"text/html", |
|
|
|
"UTF-8" |
|
|
|
) |
|
|
|
wVPay.webViewClient = object : WebViewClient() { |
|
|
|
override fun onPageStarted(view: WebView, url: String, favicon: Bitmap?) { |
|
|
|
super.onPageStarted(view, url, favicon) |
|
|
|
Log.e("onPageStarted", "-->$url") |
|
|
|
if (url.isNotEmpty() && url.contains("https://uat.nivesh.com/bajajFD/OrderStatus")) { |
|
|
|
if (dialogWebView != null && dialogWebView!!.isShowing) { |
|
|
|
dialogWebView!!.dismiss() |
|
|
|
paymentReQueryApi() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
dialogWebView!!.show() |
|
|
|
} |
|
|
|
|
|
|
|
private fun paymentReQueryApi() { |
|
|
|
fun paymentReQueryApi() { |
|
|
|
if (Common.isNetworkAvailable(this)) { |
|
|
|
val paymentReQueryRequest = PaymentReQueryRequest() |
|
|
|
paymentReQueryRequest.UniqueId = UniqueId |
|
|
|
paymentReQueryRequest.NiveshClientCode = getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_CODE |
|
|
|
paymentReQueryRequest.NiveshClientCode = |
|
|
|
getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_CODE |
|
|
|
viewModel.getPaymentReQuery(paymentReQueryRequest, token, this) |
|
|
|
viewModel.getPaymentReQueryMutableData.observe(this) { response -> |
|
|
|
when (response) { |
|
|
@ -452,7 +452,7 @@ class BajajFdMainActivity : BaseActivity() { |
|
|
|
} else { |
|
|
|
binding.viewPager.currentItem = 3 |
|
|
|
} |
|
|
|
stepFiveBajajFDFragment.getData() |
|
|
|
stepFiveBajajFDFragment.getData(paymentReQueryResponse) |
|
|
|
} |
|
|
|
650 -> refreshToken("") |
|
|
|
else -> { |
|
|
|