Commit 81959caf authored by mengcuiguang's avatar mengcuiguang

添加gromore开屏广告,添加权限弹窗

parent e2efe09d
...@@ -23,10 +23,10 @@ object CsjGroMoreManager { ...@@ -23,10 +23,10 @@ object CsjGroMoreManager {
private var sInit: Boolean = false private var sInit: Boolean = false
// gromore // gromore
var AD_UNIT_SPLASH_ID = "" // 开屏 var AD_UNIT_SPLASH_ID = "887523427" // 开屏
// 穿山甲id // 穿山甲id
var AD_CSJ_SPLASH_ID = "" // 开屏 var AD_CSJ_SPLASH_ID = "887523426" // 开屏
fun init(context: Context) { fun init(context: Context) {
if (!sInit) { if (!sInit) {
......
...@@ -12,6 +12,7 @@ import com.mints.street.databinding.ActivityLoginBinding ...@@ -12,6 +12,7 @@ import com.mints.street.databinding.ActivityLoginBinding
import com.mints.street.main.MainActivity import com.mints.street.main.MainActivity
import com.mints.street.manager.UserManager import com.mints.street.manager.UserManager
import com.mints.street.utils.BackInputUtil import com.mints.street.utils.BackInputUtil
import com.mints.street.widget.dialog.DialogUtils
import com.tbruyelle.rxpermissions2.RxPermissions import com.tbruyelle.rxpermissions2.RxPermissions
import kotlinx.android.synthetic.main.activity_bindmobile.* import kotlinx.android.synthetic.main.activity_bindmobile.*
import kotlinx.android.synthetic.main.activity_login.* import kotlinx.android.synthetic.main.activity_login.*
...@@ -83,7 +84,7 @@ class LoginActivity : BaseActivity<ActivityLoginBinding, LoginViewModel>(), View ...@@ -83,7 +84,7 @@ class LoginActivity : BaseActivity<ActivityLoginBinding, LoginViewModel>(), View
// 登录 // 登录
viewModel.mobilelogin(mobile, code) viewModel.mobilelogin(mobile, code)
} else { } else {
// showMissingPermissionDialog("设备") DialogUtils.showPermissionDialog(this@LoginActivity,"设备")
} }
} }
......
...@@ -12,6 +12,7 @@ import com.mints.street.bean.UserBean ...@@ -12,6 +12,7 @@ import com.mints.street.bean.UserBean
import com.mints.street.databinding.ActivityBindmobileBinding import com.mints.street.databinding.ActivityBindmobileBinding
import com.mints.street.main.MainActivity import com.mints.street.main.MainActivity
import com.mints.street.utils.BackInputUtil import com.mints.street.utils.BackInputUtil
import com.mints.street.widget.dialog.DialogUtils
import com.tbruyelle.rxpermissions2.RxPermissions import com.tbruyelle.rxpermissions2.RxPermissions
import kotlinx.android.synthetic.main.activity_bindmobile.* import kotlinx.android.synthetic.main.activity_bindmobile.*
import kotlinx.android.synthetic.main.include_header.* import kotlinx.android.synthetic.main.include_header.*
...@@ -91,7 +92,7 @@ class BindMobileActivity : BaseActivity<ActivityBindmobileBinding, BindMobileVie ...@@ -91,7 +92,7 @@ class BindMobileActivity : BaseActivity<ActivityBindmobileBinding, BindMobileVie
mobile = mobile.replace(" ".toRegex(), "") mobile = mobile.replace(" ".toRegex(), "")
viewModel.bindingMobile(mobile, code) viewModel.bindingMobile(mobile, code)
} else { } else {
// showMissingPermissionDialog("设备") DialogUtils.showPermissionDialog(this@BindMobileActivity,"设备")
} }
} }
} }
......
...@@ -98,7 +98,7 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList ...@@ -98,7 +98,7 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList
startActivity(MoresettingsActivity::class.java) startActivity(MoresettingsActivity::class.java)
} }
loginDialog.setListener(object:WxLoginDialog.WxLoginListener{ loginDialog.setListener(object : WxLoginDialog.WxLoginListener {
override fun loginSuc(wxInfo: String) { override fun loginSuc(wxInfo: String) {
if (!isHidden) {//当前fragment正在显示调用微信登陆接口 if (!isHidden) {//当前fragment正在显示调用微信登陆接口
viewModel.wechatlogin(JsonUtil.toJson(wxInfo)) viewModel.wechatlogin(JsonUtil.toJson(wxInfo))
...@@ -108,7 +108,6 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList ...@@ -108,7 +108,6 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList
} }
override fun initViewObservable() { override fun initViewObservable() {
super.initViewObservable() super.initViewObservable()
viewModel.myInfodata.observe(this, Observer<UserBean> { viewModel.myInfodata.observe(this, Observer<UserBean> {
...@@ -130,18 +129,18 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList ...@@ -130,18 +129,18 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList
Glide.with(requireContext()).load(userManager.getWxHeader()).into(item_title_avatar) Glide.with(requireContext()).load(userManager.getWxHeader()).into(item_title_avatar)
// 是否会员 // 是否会员
if(userManager.getVipFlag()){ if (userManager.getVipFlag()) {
tv_tips.text = "恭喜您,已经成为全球会员啦~" tv_tips.text = "恭喜您,已经成为全球会员啦~"
bt_try.visibility=View.INVISIBLE bt_try.visibility = View.INVISIBLE
}else{ } else {
tv_tips.text = "恭喜你被全球会员卡砸中~" tv_tips.text = "恭喜你被全球会员卡砸中~"
bt_try.visibility=View.VISIBLE bt_try.visibility = View.VISIBLE
} }
} else { } else {
// 未登录 // 未登录
item_title_id.text = "未登录" item_title_id.text = "未登录"
tv_tips.text = "恭喜你被全球会员卡砸中~" tv_tips.text = "恭喜你被全球会员卡砸中~"
bt_try.visibility=View.VISIBLE bt_try.visibility = View.VISIBLE
item_title_avatar.setImageResource(R.mipmap.ic_my) item_title_avatar.setImageResource(R.mipmap.ic_my)
} }
} }
...@@ -175,7 +174,7 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList ...@@ -175,7 +174,7 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList
moresettings.findViewById<TextView>(R.id.tv_right).visibility = View.GONE moresettings.findViewById<TextView>(R.id.tv_right).visibility = View.GONE
moresettings.findViewById<ImageView>(R.id.iv_right).visibility = View.VISIBLE moresettings.findViewById<ImageView>(R.id.iv_right).visibility = View.VISIBLE
ic_theme.findViewById<TextView>(R.id.tv_theme_name).text="享8大特权" ic_theme.findViewById<TextView>(R.id.tv_theme_name).text = "享8大特权"
ic_theme.findViewById<TextView>(R.id.tv_me1).text = "无线缩放" ic_theme.findViewById<TextView>(R.id.tv_me1).text = "无线缩放"
ic_theme.findViewById<TextView>(R.id.tv_me2).text = "国内外街景" ic_theme.findViewById<TextView>(R.id.tv_me2).text = "国内外街景"
ic_theme.findViewById<TextView>(R.id.tv_me3).text = "VR全景" ic_theme.findViewById<TextView>(R.id.tv_me3).text = "VR全景"
......
package com.mints.street.widget.dialog package com.mints.street.widget.dialog
import android.app.AlertDialog
import android.content.Context import android.content.Context
import android.content.DialogInterface
import android.content.Intent
import android.net.Uri
import android.provider.Settings
import java.lang.ref.WeakReference import java.lang.ref.WeakReference
object DialogUtils{ object DialogUtils {
/** /**
* 公众号请求弹框 * 公众号请求弹框
*/ */
...@@ -14,4 +19,28 @@ object DialogUtils{ ...@@ -14,4 +19,28 @@ object DialogUtils{
dialogListener.setDialog(bonusDialog) dialogListener.setDialog(bonusDialog)
} }
/**
* 权限设置弹框
*/
fun showPermissionDialog(ctx: Context, msg: String) {
val weakReference = WeakReference<Context>(ctx)
val builder = AlertDialog.Builder(weakReference.get())
builder.setTitle("提示")
builder.setMessage("当前应用缺少 " + msg + "授权\n\n请点击 设置-权限-打开所需权限")
// 拒绝, 退出应用
builder.setNegativeButton("取消",
DialogInterface.OnClickListener { dialog, which ->
})
builder.setPositiveButton("确定",
DialogInterface.OnClickListener { dialog, which ->
val intent = Intent(
Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
intent.data = Uri.parse("package:" + weakReference.get()?.getPackageName())
weakReference.get()?.startActivity(intent)
})
builder.setCancelable(false)
builder.show()
}
} }
\ No newline at end of file
...@@ -35,19 +35,19 @@ class WxLoginDialog(context: FragmentActivity) : OnLoginListener { ...@@ -35,19 +35,19 @@ class WxLoginDialog(context: FragmentActivity) : OnLoginListener {
var wxLoginListener: WxLoginListener? = null var wxLoginListener: WxLoginListener? = null
private var mBottomSheetDialog: BottomSheetDialog? = null private var mBottomSheetDialog: BottomSheetDialog? = null
private var context:FragmentActivity private var context: FragmentActivity
private val loginApi by lazy { LoginApi() } private val loginApi by lazy { LoginApi() }
init { init {
this.context=context this.context = context
} }
/** /**
* 初始化 * 初始化
*/ */
fun init():WxLoginDialog{ fun init(): WxLoginDialog {
//创建弹窗 //创建弹窗
if(mBottomSheetDialog!=null) return this if (mBottomSheetDialog != null) return this
mBottomSheetDialog = BottomSheetDialog(context) mBottomSheetDialog = BottomSheetDialog(context)
val view1: View = LayoutInflater.from(context).inflate(R.layout.layout_popupwindow, null) val view1: View = LayoutInflater.from(context).inflate(R.layout.layout_popupwindow, null)
...@@ -60,13 +60,13 @@ class WxLoginDialog(context: FragmentActivity) : OnLoginListener { ...@@ -60,13 +60,13 @@ class WxLoginDialog(context: FragmentActivity) : OnLoginListener {
val tv_private: TextView = view1.findViewById(R.id.tv_private) val tv_private: TextView = view1.findViewById(R.id.tv_private)
val tv_regist: TextView = view1.findViewById(R.id.tv_regist) val tv_regist: TextView = view1.findViewById(R.id.tv_regist)
tv_regist.setOnClickListener{ tv_regist.setOnClickListener {
MintsWebViewActivity.startWebView(name = "用户协议", url = Constant.REGISTER_URL) MintsWebViewActivity.startWebView(name = "用户协议", url = Constant.REGISTER_URL)
} }
tv_private.setOnClickListener{ tv_private.setOnClickListener {
MintsWebViewActivity.startWebView(name = "隐私协议", url = Constant.PRIVACY_URL) MintsWebViewActivity.startWebView(name = "隐私协议", url = Constant.PRIVACY_URL)
} }
iv_weixin.setOnClickListener{ iv_weixin.setOnClickListener {
if (cb_checked!!.isChecked) { if (cb_checked!!.isChecked) {
val wechat = ShareSDK.getPlatform(Wechat.NAME) val wechat = ShareSDK.getPlatform(Wechat.NAME)
if (!wechat.isClientValid) { if (!wechat.isClientValid) {
...@@ -81,7 +81,7 @@ class WxLoginDialog(context: FragmentActivity) : OnLoginListener { ...@@ -81,7 +81,7 @@ class WxLoginDialog(context: FragmentActivity) : OnLoginListener {
loginApi.setPlatform(Wechat.NAME) loginApi.setPlatform(Wechat.NAME)
loginApi.login(context) loginApi.login(context)
} else { } else {
// showMissingPermissionDialog("设备") DialogUtils.showPermissionDialog(context,"设备")
} }
} }
mBottomSheetDialog!!.dismiss() mBottomSheetDialog!!.dismiss()
...@@ -105,13 +105,13 @@ class WxLoginDialog(context: FragmentActivity) : OnLoginListener { ...@@ -105,13 +105,13 @@ class WxLoginDialog(context: FragmentActivity) : OnLoginListener {
/** /**
* 展示 * 展示
*/ */
fun show(){ fun show() {
mBottomSheetDialog?.show() mBottomSheetDialog?.show()
} }
override fun onLogin(platform: String?, res: HashMap<String, Any>?): Boolean { override fun onLogin(platform: String?, res: HashMap<String, Any>?): Boolean {
try { try {
val wxInfo = WXInfo() val wxInfo = WXInfo()
wxInfo?.let { wxInfo?.let {
it.unionid = res?.get("unionid").toString() + "" it.unionid = res?.get("unionid").toString() + ""
it.openid = res?.get("openid").toString() + "" it.openid = res?.get("openid").toString() + ""
...@@ -122,10 +122,6 @@ class WxLoginDialog(context: FragmentActivity) : OnLoginListener { ...@@ -122,10 +122,6 @@ class WxLoginDialog(context: FragmentActivity) : OnLoginListener {
it.nickname = res?.get("nickname").toString() + "" it.nickname = res?.get("nickname").toString() + ""
it.sex = (res?.get("sex").toString() + "").toInt() it.sex = (res?.get("sex").toString() + "").toInt()
} }
// if (!isHidden) {//当前fragment正在显示调用微信登陆接口
// viewModel.wechatlogin(JsonUtil.toJson(wxInfo))
// }
wxLoginListener?.loginSuc(JsonUtil.toJson(wxInfo)) wxLoginListener?.loginSuc(JsonUtil.toJson(wxInfo))
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printStackTrace()
...@@ -133,9 +129,9 @@ class WxLoginDialog(context: FragmentActivity) : OnLoginListener { ...@@ -133,9 +129,9 @@ class WxLoginDialog(context: FragmentActivity) : OnLoginListener {
return false return false
} }
fun onDestroy(){ fun onDestroy() {
loginApi.setOnLoginListener(null) loginApi.setOnLoginListener(null)
mBottomSheetDialog=null mBottomSheetDialog = null
} }
fun setListener(listener: WxLoginListener?) { fun setListener(listener: WxLoginListener?) {
......
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