|
|
@ -2,13 +2,11 @@ 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 |
|
|
@ -31,7 +29,9 @@ 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 |
|
|
|
import java.io.BufferedReader |
|
|
|
import java.io.InputStream |
|
|
|
import java.io.InputStreamReader |
|
|
|
|
|
|
|
|
|
|
|
class BajajFdMainActivity : BaseActivity() { |
|
|
@ -58,6 +58,8 @@ class BajajFdMainActivity : BaseActivity() { |
|
|
|
private lateinit var sectionsPagerAdapter: SectionsPagerAdapter |
|
|
|
private lateinit var fragments: Array<Fragment> |
|
|
|
|
|
|
|
var valur:String="" |
|
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) { |
|
|
|
super.onCreate(savedInstanceState) |
|
|
|
init() |
|
|
@ -87,7 +89,7 @@ class BajajFdMainActivity : BaseActivity() { |
|
|
|
if (Common.isNetworkAvailable(this)) { |
|
|
|
val fdStepsCount = FDStepsCountRequest() |
|
|
|
fdStepsCount.FDProvider = getString(R.string.bajaj) |
|
|
|
fdStepsCount.NiveshClientCode = "60476" |
|
|
|
fdStepsCount.NiveshClientCode = "8872" |
|
|
|
//hemant client code =8872 /60476 |
|
|
|
|
|
|
|
viewModel.getStepsCount(fdStepsCount, token, this) |
|
|
@ -140,9 +142,9 @@ class BajajFdMainActivity : BaseActivity() { |
|
|
|
private fun getClientDetailsApi(stepsCount: Int) { |
|
|
|
if (Common.isNetworkAvailable(this@BajajFdMainActivity)) { |
|
|
|
val getClientDetailsRequest = getClientDetailsRequest() |
|
|
|
getClientDetailsRequest.client_code = "60476" |
|
|
|
getClientDetailsRequest.client_code = "8872" |
|
|
|
getClientDetailsRequest.AppOrWeb = getString(R.string.app) |
|
|
|
getClientDetailsRequest.sub_broker_code = "4761" |
|
|
|
getClientDetailsRequest.sub_broker_code = "1038" |
|
|
|
|
|
|
|
//hemant 8872/1038// |
|
|
|
|
|
|
@ -390,6 +392,9 @@ class BajajFdMainActivity : BaseActivity() { |
|
|
|
|
|
|
|
// step 4 response |
|
|
|
fun stepFourApi(payUrl: String, value: String) { |
|
|
|
|
|
|
|
valur=value |
|
|
|
|
|
|
|
paymentDialog(payUrl, value) |
|
|
|
} |
|
|
|
|
|
|
@ -397,49 +402,121 @@ 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 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()) |
|
|
|
} |
|
|
|
// val webView = WebView(this@BajajFdMainActivity) |
|
|
|
// setContentView(webView) |
|
|
|
// val postData = "msg=${URLEncoder.encode(value, "UTF-8")}" |
|
|
|
// |
|
|
|
// Log.e("valueee", "-->$postData") |
|
|
|
// |
|
|
|
// |
|
|
|
// 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") |
|
|
|
if (url.isNotEmpty() && url.contains("CustomerPaymentResponse")) { |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
override fun onPageFinished(view: WebView, url: String) { |
|
|
|
super.onPageFinished(view, url) |
|
|
|
} |
|
|
|
|
|
|
|
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() { |
|
|
|
// 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")) { |
|
|
|
// |
|
|
|
// } |
|
|
|
// } |
|
|
|
// |
|
|
|
// }) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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) |
|
|
|
// } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|