Commit 072dc40d authored by mengcuiguang2's avatar mengcuiguang2

添加广告,联调微信登录

parent 81959caf
...@@ -101,7 +101,7 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList ...@@ -101,7 +101,7 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList
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(wxInfo)
} }
} }
}) })
......
package com.mints.street.main.my package com.mints.street.main.my
import android.annotation.SuppressLint
import android.app.Dialog import android.app.Dialog
import android.graphics.Color import android.graphics.Color
import android.os.Bundle import android.os.Bundle
...@@ -80,11 +81,12 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>() ...@@ -80,11 +81,12 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
loginDialog.setListener(object:WxLoginDialog.WxLoginListener{ loginDialog.setListener(object:WxLoginDialog.WxLoginListener{
override fun loginSuc(wxInfo: String) { override fun loginSuc(wxInfo: String) {
viewModel.wechatlogin(JsonUtil.toJson(wxInfo)) viewModel.wechatlogin(wxInfo)
} }
}) })
} }
@SuppressLint("InflateParams")
private fun initView() { private fun initView() {
val layoutInflater = layoutInflater val layoutInflater = layoutInflater
......
...@@ -38,7 +38,6 @@ class SplashActivity : BaseActivity<ActivitySplashBinding, SplashViewModel>() { ...@@ -38,7 +38,6 @@ class SplashActivity : BaseActivity<ActivitySplashBinding, SplashViewModel>() {
private var msplash: FrameLayout? = null private var msplash: FrameLayout? = null
private var mTTSplashAd: TTSplashAd? = null private var mTTSplashAd: TTSplashAd? = null
private val AD_TIME_OUT = 4000 private val AD_TIME_OUT = 4000
private var onPaused = false
//是否强制跳转到主页面 //是否强制跳转到主页面
private var mForceGoMain = false private var mForceGoMain = false
...@@ -49,6 +48,8 @@ class SplashActivity : BaseActivity<ActivitySplashBinding, SplashViewModel>() { ...@@ -49,6 +48,8 @@ class SplashActivity : BaseActivity<ActivitySplashBinding, SplashViewModel>() {
override fun initVariableId() = BR.viewModel override fun initVariableId() = BR.viewModel
override fun getStatusBarHeightView()=binding.rlSplashRoot
override fun initData() { override fun initData() {
super.initData() super.initData()
//点击Home键后再点击App图标,会回到原来的界面。今天重新打包后,但是在Debug模式下,一切正常, //点击Home键后再点击App图标,会回到原来的界面。今天重新打包后,但是在Debug模式下,一切正常,
...@@ -58,7 +59,7 @@ class SplashActivity : BaseActivity<ActivitySplashBinding, SplashViewModel>() { ...@@ -58,7 +59,7 @@ class SplashActivity : BaseActivity<ActivitySplashBinding, SplashViewModel>() {
return return
} }
StatusBarUtil.immersive(this) // StatusBarUtil.immersive(this)
//校验App签名 //校验App签名
checkAppSign() checkAppSign()
...@@ -70,10 +71,6 @@ class SplashActivity : BaseActivity<ActivitySplashBinding, SplashViewModel>() { ...@@ -70,10 +71,6 @@ class SplashActivity : BaseActivity<ActivitySplashBinding, SplashViewModel>() {
if (mForceGoMain) { if (mForceGoMain) {
goToMainActivity() goToMainActivity()
} }
if (onPaused) {
// 这种情况下,百度开屏广告不能在onAdDismiss中跳转,需要自己在onResume中跳转主页。
goToMainActivity()
}
} }
super.onResume() super.onResume()
...@@ -81,7 +78,6 @@ class SplashActivity : BaseActivity<ActivitySplashBinding, SplashViewModel>() { ...@@ -81,7 +78,6 @@ class SplashActivity : BaseActivity<ActivitySplashBinding, SplashViewModel>() {
override fun onPause() { override fun onPause() {
super.onPause() super.onPause()
onPaused = true
} }
override fun onStop() { override fun onStop() {
...@@ -106,7 +102,16 @@ class SplashActivity : BaseActivity<ActivitySplashBinding, SplashViewModel>() { ...@@ -106,7 +102,16 @@ class SplashActivity : BaseActivity<ActivitySplashBinding, SplashViewModel>() {
if (!deviceInfo.signInfo) { if (!deviceInfo.signInfo) {
finish() finish()
} else { } else {
showPowerDialog() // showPowerDialog()
isClickAgree = true
try {
msplash = findViewById(R.id.fl_splash)
//加载开屏广告
loadSplashAd()
// goToMainActivity()
} catch (e: Exception) {
goToMainActivity()
}
} }
} }
...@@ -130,8 +135,6 @@ class SplashActivity : BaseActivity<ActivitySplashBinding, SplashViewModel>() { ...@@ -130,8 +135,6 @@ class SplashActivity : BaseActivity<ActivitySplashBinding, SplashViewModel>() {
val ttNetworkRequestInfo: TTNetworkRequestInfo val ttNetworkRequestInfo: TTNetworkRequestInfo
//穿山甲兜底 //穿山甲兜底
ttNetworkRequestInfo = PangleNetworkRequestInfo(CsjGroMoreManager.TT_AD_APPID, CsjGroMoreManager.AD_CSJ_SPLASH_ID) ttNetworkRequestInfo = PangleNetworkRequestInfo(CsjGroMoreManager.TT_AD_APPID, CsjGroMoreManager.AD_CSJ_SPLASH_ID)
//step4:请求广告,调用开屏广告异步请求接口,对请求回调的广告作渲染处理 //step4:请求广告,调用开屏广告异步请求接口,对请求回调的广告作渲染处理
mTTSplashAd?.loadAd(adSlot, ttNetworkRequestInfo, object : TTSplashAdLoadCallback { mTTSplashAd?.loadAd(adSlot, ttNetworkRequestInfo, object : TTSplashAdLoadCallback {
// mTTSplashAd.loadAd(adSlot, new TTSplashAdLoadCallback() { // mTTSplashAd.loadAd(adSlot, new TTSplashAdLoadCallback() {
...@@ -161,10 +164,6 @@ class SplashActivity : BaseActivity<ActivitySplashBinding, SplashViewModel>() { ...@@ -161,10 +164,6 @@ class SplashActivity : BaseActivity<ActivitySplashBinding, SplashViewModel>() {
} }
override fun onAdDismiss() { override fun onAdDismiss() {
if (onPaused) {
// 这种情况下,百度开屏广告不能在onAdDismiss中跳转,需要在onResume中跳转主页。
return
}
goToMainActivity() goToMainActivity()
} }
} }
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item > <item>
<shape android:shape="rectangle">
<solid android:color="@color/white" />
</shape>
</item>
<item android:bottom="20dp">
<bitmap <bitmap
android:src="@drawable/bg_splash" /> android:gravity="bottom|center_horizontal"
android:src="@mipmap/ic_launcher_main" />
</item> </item>
</layer-list> </layer-list>
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"> <layout xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout
android:id="@+id/rl_splash_root"
android:layout_width="match_parent"
android:background="#061b45"
android:layout_height="match_parent">
<ImageView
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/bg_splash"/>
<FrameLayout <FrameLayout
android:id="@+id/fl_splash" android:id="@+id/fl_splash"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
</FrameLayout> </FrameLayout>
<data> </RelativeLayout>
<data>
<variable <variable
name="viewModel" name="viewModel"
type="com.mints.street.splash.SplashViewModel" /> type="com.mints.street.splash.SplashViewModel" />
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
<style name="NormalSplash" parent="Theme.AppCompat.NoActionBar"> <style name="NormalSplash" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/splash_bg</item> <item name="android:windowBackground">@drawable/splash_bg</item>
<item name="android:windowNoTitle">true</item> <item name="android:windowNoTitle">true</item>
<item name="android:colorPrimaryDark">@color/white</item>
<item name="android:windowContentOverlay">@null</item> <item name="android:windowContentOverlay">@null</item>
</style> </style>
<style name="AppTheme.NoneTranslucent" parent="AppTheme.Base"> <style name="AppTheme.NoneTranslucent" parent="AppTheme.Base">
......
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