Commit e974d479 authored by mengcuiguang's avatar mengcuiguang

代码优化

parent f52f437f
......@@ -33,6 +33,7 @@ import com.duben.miniplaylet.login.LoginApi
import com.duben.miniplaylet.login.OnLoginListener
import com.duben.miniplaylet.manager.UserManager
import com.duben.miniplaylet.mvp.model.WXInfo
import com.duben.miniplaylet.utils.MateUtils
import kotlinx.android.synthetic.main.fragment_draw.*
/**
......@@ -212,8 +213,7 @@ class DrawCashFragment : LazyLoadBaseFragment(), OnLoginListener, DrawCashView,
if (TextUtils.equals(payChannel, WEIXIN_PAY)) {
// 微信授权
if (!weixinStatus) {
val wechat = ShareSDK.getPlatform(Wechat.NAME)
if (!wechat.isClientValid) {
if (!MateUtils.checkPackageName(requireContext(),"com.tencent.mm")) {
showToast("请先安装微信")
return
}
......
package com.duben.miniplaylet.utils
import android.content.Context
import android.content.pm.PackageInfo
import android.content.pm.PackageManager
import android.text.TextUtils
......@@ -31,4 +32,14 @@ object MateUtils {
}
return resultData
}
fun checkPackageName(ctx: Context, pkg: String): Boolean {
var packageInfo: PackageInfo? = null
try {
packageInfo = ctx.packageManager.getPackageInfo(pkg, 0)
} catch (e: PackageManager.NameNotFoundException) {
e.printStackTrace()
}
return packageInfo != null
}
}
\ No newline at end of file
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