Commit 231cba09 authored by 赵鹏翔's avatar 赵鹏翔

kotlin非空处理

parent 090e977c
...@@ -36,11 +36,11 @@ class SystemParameterDialog(context: Context) : Dialog(context, R.style.CommonDi ...@@ -36,11 +36,11 @@ class SystemParameterDialog(context: Context) : Dialog(context, R.style.CommonDi
private fun init() { private fun init() {
val accountInfo = getAccountInfo() val accountInfo = getAccountInfo()
setInfo(viewBinding.tvVersion, getVersion(context)) setInfo(viewBinding.tvVersion, getVersion(context))
setInfo(viewBinding.tvStoreName, accountInfo!!.shopInfo.storeName) setInfo(viewBinding.tvStoreName, accountInfo!!.shopInfo?.storeName)
setInfo(viewBinding.tvStoreNum, accountInfo.shopInfo.storeId) setInfo(viewBinding.tvStoreNum, accountInfo.shopInfo?.storeId)
setInfo(viewBinding.tvMerchantNum, accountInfo.shopInfo.hhMerchant) setInfo(viewBinding.tvMerchantNum, accountInfo.shopInfo?.hhMerchant)
setInfo(viewBinding.tvPos, accountInfo.shopInfo.posId) setInfo(viewBinding.tvPos, accountInfo.shopInfo?.posId)
setInfo(viewBinding.tvCashier, accountInfo.shopInfo.operatorId) setInfo(viewBinding.tvCashier, accountInfo.shopInfo?.operatorId)
setInfo(viewBinding.tvVersionType, "fastCashier_" + BuildConfig.appType) setInfo(viewBinding.tvVersionType, "fastCashier_" + BuildConfig.appType)
setInfo(viewBinding.tvEquipment, "sunmi_v2pro") setInfo(viewBinding.tvEquipment, "sunmi_v2pro")
setInfo(viewBinding.tvServerUrl, baseUrl) setInfo(viewBinding.tvServerUrl, baseUrl)
......
...@@ -23,10 +23,12 @@ class RequestSignInterceptor : Interceptor { ...@@ -23,10 +23,12 @@ class RequestSignInterceptor : Interceptor {
val requestBuilder: Request.Builder = original.newBuilder() val requestBuilder: Request.Builder = original.newBuilder()
val accountInfo = getAccountInfo() val accountInfo = getAccountInfo()
if (accountInfo != null && accountInfo.accessToken != null) { if (accountInfo != null && accountInfo.accessToken != null) {
requestBuilder.addHeader( accountInfo.accessToken!!.accessToken?.let { getAuthorization(it) }?.let {
AUTHORIZATION, requestBuilder.addHeader(
getAuthorization(accountInfo.accessToken.accessToken) AUTHORIZATION,
) it
)
}
} }
val request: Request = requestBuilder.build() val request: Request = requestBuilder.build()
return chain.proceed(request) return chain.proceed(request)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment