|
@ -5,6 +5,7 @@ import android.app.Dialog |
|
|
import android.graphics.Bitmap |
|
|
import android.graphics.Bitmap |
|
|
import android.graphics.drawable.Drawable |
|
|
import android.graphics.drawable.Drawable |
|
|
import android.os.Bundle |
|
|
import android.os.Bundle |
|
|
|
|
|
import android.text.TextUtils |
|
|
import android.util.Log |
|
|
import android.util.Log |
|
|
import android.view.View |
|
|
import android.view.View |
|
|
import android.view.WindowManager |
|
|
import android.view.WindowManager |
|
@ -24,17 +25,26 @@ import com.nivesh.production.bajajfd.model.* |
|
|
import com.nivesh.production.bajajfd.repositories.MainRepository |
|
|
import com.nivesh.production.bajajfd.repositories.MainRepository |
|
|
import com.nivesh.production.bajajfd.ui.fragment.* |
|
|
import com.nivesh.production.bajajfd.ui.fragment.* |
|
|
import com.nivesh.production.bajajfd.ui.providerfactory.* |
|
|
import com.nivesh.production.bajajfd.ui.providerfactory.* |
|
|
import com.nivesh.production.bajajfd.util.Common |
|
|
|
|
|
|
|
|
import com.nivesh.production.bajajfd.util.* |
|
|
import com.nivesh.production.bajajfd.util.Common.Companion.defaultShape |
|
|
import com.nivesh.production.bajajfd.util.Common.Companion.defaultShape |
|
|
import com.nivesh.production.bajajfd.util.Common.Companion.getDate |
|
|
import com.nivesh.production.bajajfd.util.Common.Companion.getDate |
|
|
import com.nivesh.production.bajajfd.util.Common.Companion.selectedShape |
|
|
import com.nivesh.production.bajajfd.util.Common.Companion.selectedShape |
|
|
import com.nivesh.production.bajajfd.util.Common.Companion.showDialogValidation |
|
|
import com.nivesh.production.bajajfd.util.Common.Companion.showDialogValidation |
|
|
|
|
|
import com.nivesh.production.bajajfd.util.Constants.Companion.KEY_LOGINTYPE |
|
|
|
|
|
import com.nivesh.production.bajajfd.util.Constants.Companion.KEY_LOGIN_EMAIL |
|
|
|
|
|
import com.nivesh.production.bajajfd.util.Constants.Companion.KEY_LOGIN_PASSWORD |
|
|
|
|
|
import com.nivesh.production.bajajfd.util.Constants.Companion.KEY_LOGIN_SOCIALID |
|
|
import com.nivesh.production.bajajfd.util.Constants.Companion.token |
|
|
import com.nivesh.production.bajajfd.util.Constants.Companion.token |
|
|
import com.nivesh.production.bajajfd.util.ProgressUtil |
|
|
|
|
|
import com.nivesh.production.bajajfd.util.ProgressUtil.hideLoading |
|
|
import com.nivesh.production.bajajfd.util.ProgressUtil.hideLoading |
|
|
import com.nivesh.production.bajajfd.util.ProgressUtil.showLoading |
|
|
import com.nivesh.production.bajajfd.util.ProgressUtil.showLoading |
|
|
import com.nivesh.production.bajajfd.util.Resource |
|
|
|
|
|
|
|
|
import com.nivesh.production.bajajfd.util.Utility.Companion.convert_sha256 |
|
|
|
|
|
import com.nivesh.production.bajajfd.util.Utility.Companion.convert_sha256_2X |
|
|
|
|
|
import com.nivesh.production.bajajfd.util.Utility.Companion.getDeviceInfo |
|
|
|
|
|
import com.nivesh.production.bajajfd.util.Utils_Functions.Companion.getCurrentDateStamp |
|
|
import com.nivesh.production.bajajfd.viewModel.* |
|
|
import com.nivesh.production.bajajfd.viewModel.* |
|
|
|
|
|
import okhttp3.MediaType.Companion.toMediaType |
|
|
|
|
|
import okhttp3.RequestBody.Companion.toRequestBody |
|
|
|
|
|
import org.json.JSONObject |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BajajFdMainActivity : BaseActivity() { |
|
|
class BajajFdMainActivity : BaseActivity() { |
|
@ -181,7 +191,7 @@ class BajajFdMainActivity : BaseActivity() { |
|
|
setViewPager(stepsCount) |
|
|
setViewPager(stepsCount) |
|
|
checkFDCKYCApi() |
|
|
checkFDCKYCApi() |
|
|
} |
|
|
} |
|
|
// 650 -> refreshToken() |
|
|
|
|
|
|
|
|
650 -> refreshToken() |
|
|
else -> { |
|
|
else -> { |
|
|
showDialogValidation(this@BajajFdMainActivity, response.message) |
|
|
showDialogValidation(this@BajajFdMainActivity, response.message) |
|
|
} |
|
|
} |
|
@ -205,6 +215,112 @@ class BajajFdMainActivity : BaseActivity() { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun refreshToken() { |
|
|
|
|
|
if (!Common.isNetworkAvailable(this@BajajFdMainActivity)) { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
var jsonObject: JSONObject? = null |
|
|
|
|
|
val str2Hash: String? |
|
|
|
|
|
var strDeviceID = "" |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
jsonObject = JSONObject() |
|
|
|
|
|
jsonObject.put( |
|
|
|
|
|
"Email_Mob", SharedPrefrenceDataMethods.getLoginEmail( |
|
|
|
|
|
KEY_LOGIN_EMAIL, |
|
|
|
|
|
applicationContext |
|
|
|
|
|
) |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// jsonObject.put("Uid", SharedPrefrenceDataMethods.getLoginUser_Code(KEY_LOGINUSER_CODE, getApplicationContext())); |
|
|
|
|
|
jsonObject.put( |
|
|
|
|
|
"Uid", SharedPrefrenceDataMethods.getUserUid( |
|
|
|
|
|
Constants.KEY_GET_USER_UID, |
|
|
|
|
|
applicationContext |
|
|
|
|
|
) |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
jsonObject.put( |
|
|
|
|
|
"Soc_Id", SharedPrefrenceDataMethods.getLogin_SOCIALID( |
|
|
|
|
|
KEY_LOGIN_SOCIALID, |
|
|
|
|
|
applicationContext |
|
|
|
|
|
) |
|
|
|
|
|
) |
|
|
|
|
|
val ed = EncryptionDecryption() |
|
|
|
|
|
val decryptString = ed.decrypt( |
|
|
|
|
|
SharedPrefrenceDataMethods.getLoginPassword( |
|
|
|
|
|
KEY_LOGIN_PASSWORD, |
|
|
|
|
|
applicationContext |
|
|
|
|
|
) |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
val strTimeStamp = getCurrentDateStamp() |
|
|
|
|
|
|
|
|
|
|
|
if (SharedPrefrenceDataMethods.getLogin_Type(KEY_LOGINTYPE, applicationContext) |
|
|
|
|
|
.equals("EMAIL",true) |
|
|
|
|
|
) { |
|
|
|
|
|
val strsha256hex_password: String = convert_sha256(decryptString!!) |
|
|
|
|
|
|
|
|
|
|
|
str2Hash = convert_sha256_2X(strsha256hex_password + strTimeStamp) |
|
|
|
|
|
} else { |
|
|
|
|
|
str2Hash = "" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
val deviceInfo: DeviceInfo = getDeviceInfo(applicationContext) |
|
|
|
|
|
strDeviceID = java.lang.String.valueOf(deviceInfo.device_id) |
|
|
|
|
|
Log.e("strDeviceID", "-> $strDeviceID") |
|
|
|
|
|
jsonObject.put("DeviceId", strDeviceID) |
|
|
|
|
|
|
|
|
|
|
|
val mediaType = "application/json; charset=utf-8".toMediaType() |
|
|
|
|
|
val requestBody = jsonObject.toString().toRequestBody(mediaType) |
|
|
|
|
|
viewModel.getRefreshToken(requestBody, this@BajajFdMainActivity) |
|
|
|
|
|
|
|
|
|
|
|
(this@BajajFdMainActivity).viewModel.getFreshTokenMutableData.observe(this){ response -> |
|
|
|
|
|
when (response){ |
|
|
|
|
|
is Resource.Success -> { |
|
|
|
|
|
val refreshTokenResponse: RefreshTokenResponse = |
|
|
|
|
|
Gson().fromJson(response.data?.toString(),RefreshTokenResponse::class.java) |
|
|
|
|
|
|
|
|
|
|
|
if (!TextUtils.isEmpty( |
|
|
|
|
|
refreshTokenResponse.Token |
|
|
|
|
|
) |
|
|
|
|
|
) { |
|
|
|
|
|
SharedPrefrenceDataMethods.setToken( |
|
|
|
|
|
this, |
|
|
|
|
|
refreshTokenResponse.Token |
|
|
|
|
|
) |
|
|
|
|
|
} |
|
|
|
|
|
if (refreshTokenResponse.response.StatusCode == 200 |
|
|
|
|
|
) { |
|
|
|
|
|
// getSubBroker_Encrypt(LoginCode, Api.Subbroker) |
|
|
|
|
|
getClientDetailsApi(stepCount) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
is Resource.Error -> { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
is Resource.Loading -> { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
is Resource.DataError ->{ |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (e: Exception) { |
|
|
|
|
|
e.printStackTrace() |
|
|
|
|
|
// Utility.saveExceptionLog( |
|
|
|
|
|
// mActivity, |
|
|
|
|
|
// BaseActivity.TAG, |
|
|
|
|
|
// Throwable().stackTrace[0].lineNumber.toString(), |
|
|
|
|
|
// e |
|
|
|
|
|
// ) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private fun setViewPager(stepsCount: Int) { |
|
|
private fun setViewPager(stepsCount: Int) { |
|
|
// steps setting |
|
|
// steps setting |
|
|
setBackground(selectedShape(), defaultShape(), defaultShape(), defaultShape(), stepsCount) |
|
|
setBackground(selectedShape(), defaultShape(), defaultShape(), defaultShape(), stepsCount) |
|
@ -329,7 +445,7 @@ class BajajFdMainActivity : BaseActivity() { |
|
|
|
|
|
|
|
|
fdInvestmentDetails.CustomerType = "" |
|
|
fdInvestmentDetails.CustomerType = "" |
|
|
} |
|
|
} |
|
|
// 650 -> refreshToken() |
|
|
|
|
|
|
|
|
// 650 -> refreshToken() |
|
|
else -> { |
|
|
else -> { |
|
|
showDialogValidation( |
|
|
showDialogValidation( |
|
|
this@BajajFdMainActivity, |
|
|
this@BajajFdMainActivity, |
|
|