Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
X
xxsq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王雪伟
xxsq
Commits
3e03ef9c
Commit
3e03ef9c
authored
Sep 21, 2022
by
maxiaoliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加广告daima
parent
e8d95a07
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
586 additions
and
10 deletions
+586
-10
Appli.kt
app/src/main/java/com/zxhl/shop/Appli.kt
+103
-1
MainActivity.java
app/src/main/java/com/zxhl/shop/activity/MainActivity.java
+0
-1
Constant.java
cms/src/main/java/com/zxhl/cms/common/Constant.java
+8
-0
BaseActivity.java
cms/src/main/java/com/zxhl/cms/common/base/BaseActivity.java
+8
-0
RounterApi.kt
cms/src/main/java/com/zxhl/cms/router/RounterApi.kt
+4
-0
JumpUtils.java
cms/src/main/java/com/zxhl/cms/utils/JumpUtils.java
+10
-0
AndroidManifest.xml
moduleMain/src/main/AndroidManifest.xml
+24
-5
RechargeActivity.kt
...ain/java/com/zxbw/modulemain/activity/RechargeActivity.kt
+18
-0
RightsDetailActivity.kt
...java/com/zxbw/modulemain/activity/RightsDetailActivity.kt
+18
-0
SplashBackgroundActivity.kt
.../com/zxbw/modulemain/activity/SplashBackgroundActivity.kt
+95
-0
UserCenterFragment.kt
...n/java/com/zxbw/modulemain/fragment/UserCenterFragment.kt
+108
-1
fragment_layout_user_center.xml
...eMain/src/main/res/layout/fragment_layout_user_center.xml
+9
-0
AdManager.kt
moduleZxAd/src/main/java/com/zx/ad/AdManager.kt
+74
-1
InterertionAdListener.kt
...src/main/java/com/zx/ad/callback/InterertionAdListener.kt
+10
-0
ADType.kt
moduleZxAd/src/main/java/com/zx/ad/platform/ADType.kt
+1
-0
CSJAdManager.kt
...ZxAd/src/main/java/com/zx/ad/platform/csj/CSJAdManager.kt
+96
-1
No files found.
app/src/main/java/com/zxhl/shop/Appli.kt
View file @
3e03ef9c
package
com.zxhl.shop
package
com.zxhl.shop
import
android.app.Activity
import
android.app.ActivityManager
import
android.app.Application
import
android.app.Application
import
android.content.Context
import
android.content.Intent
import
android.os.Bundle
import
android.text.TextUtils
import
android.text.TextUtils
import
android.util.Log
import
android.util.Log
import
com.tencent.bugly.crashreport.CrashReport
import
com.tencent.bugly.crashreport.CrashReport
import
com.umeng.commonsdk.UMConfigure
import
com.umeng.commonsdk.UMConfigure
import
com.umeng.socialize.PlatformConfig
import
com.umeng.socialize.PlatformConfig
import
com.zx.ad.modulecommon.AdNetConfig
import
com.zx.ad.modulecommon.AdNetConfig
import
com.zxbw.modulemain.activity.SplashBackgroundActivity
import
com.zxhl.cms.AppContext
import
com.zxhl.cms.AppContext
import
com.zxhl.cms.common.ApplicationAsLibrary
import
com.zxhl.cms.common.ApplicationAsLibrary
import
com.zxhl.cms.common.Config
import
com.zxhl.cms.common.Config
import
com.zxhl.cms.common.Constant
import
com.zxhl.cms.common.Constant
import
com.zxhl.cms.net.SettingPreference
import
com.zxhl.cms.net.SettingPreference
import
com.zxhl.cms.utils.EventUtils.onEvent
import
com.zxhl.cms.utils.EventUtils.onEvent
import
com.zxhl.cms.utils.JumpUtils
import
com.zxhl.cms.utils.MiitHelper
import
com.zxhl.cms.utils.MiitHelper
import
com.zxhl.cms.utils.Utils
import
com.zxhl.cms.utils.Utils
import
java.util.*
import
java.util.*
...
@@ -23,7 +30,29 @@ import java.util.*
...
@@ -23,7 +30,29 @@ import java.util.*
*/
*/
class
Appli
:
Application
()
{
class
Appli
:
Application
()
{
private
val
mChildApplicationList
=
ArrayList
<
ApplicationAsLibrary
>()
private
val
mChildApplicationList
=
ArrayList
<
ApplicationAsLibrary
>()
// 正常状态
val
STATE_NORMAL
=
0
// 从后台回到前台
val
STATE_BACK_TO_FRONT
=
1
// 从前台进入后台
val
STATE_FRONT_TO_BACK
=
2
// APP状态
private
var
sAppState
=
STATE_NORMAL
// 标记程序是否已进入后台(依据onStop回调)
private
var
flag
=
false
// 标记程序是否已进入后台(依据onTrimMemory回调)
private
var
background
=
false
// 从前台进入后台的时间
private
var
frontToBackTime
:
Long
=
0
// 从后台返回前台的时间
private
var
backToFrontTime
:
Long
=
0
override
fun
onCreate
()
{
override
fun
onCreate
()
{
super
.
onCreate
()
super
.
onCreate
()
AppContext
.
init
(
applicationContext
)
AppContext
.
init
(
applicationContext
)
...
@@ -31,8 +60,9 @@ class Appli : Application() {
...
@@ -31,8 +60,9 @@ class Appli : Application() {
if
(!
SettingPreference
.
getFirstApp
())
{
if
(!
SettingPreference
.
getFirstApp
())
{
initAppConfig
()
initAppConfig
()
}
}
registerActivityLifecycleCallbacks
(
activityLifecycleCallbacks
)
val
helper
=
AppFrontBackHelper
()
val
helper
=
AppFrontBackHelper
()
helper
.
register
(
this
,
object
:
AppFrontBackHelper
.
OnAppStatusListener
{
helper
.
register
(
this
,
object
:
AppFrontBackHelper
.
OnAppStatusListener
{
override
fun
onFront
()
{
override
fun
onFront
()
{
//应用切到前台处理
//应用切到前台处理
...
@@ -90,4 +120,76 @@ class Appli : Application() {
...
@@ -90,4 +120,76 @@ class Appli : Application() {
CrashReport
.
initCrashReport
(
AppContext
.
get
(),
"f9fb9a9ef5"
,
false
);
CrashReport
.
initCrashReport
(
AppContext
.
get
(),
"f9fb9a9ef5"
,
false
);
getOaid
()
getOaid
()
}
}
/**
* 当前Activity个数
*/
private
var
activityCount
=
0
var
activityLifecycleCallbacks
:
Application
.
ActivityLifecycleCallbacks
=
object
:
Application
.
ActivityLifecycleCallbacks
{
override
fun
onActivityCreated
(
activity
:
Activity
,
savedInstanceState
:
Bundle
?)
{}
override
fun
onActivityStarted
(
activity
:
Activity
)
{
if
(
activityCount
===
0
)
{
//从后台进入前台
Constant
.
Utils
.
isTimingReport
=
true
}
activityCount
++
if
(
background
||
flag
)
{
background
=
false
flag
=
false
sAppState
=
STATE_BACK_TO_FRONT
backToFrontTime
=
System
.
currentTimeMillis
()
if
(
canShowAd
()){
Log
.
e
(
"MXL"
,
"加载开屏"
)
var
intent
=
Intent
()
intent
.
setClass
(
applicationContext
,
SplashBackgroundActivity
::
class
.
java
)
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
)
AppContext
.
get
().
startActivity
(
intent
)
}
}
else
{
sAppState
=
STATE_NORMAL
}
}
override
fun
onActivityResumed
(
activity
:
Activity
)
{}
override
fun
onActivityPaused
(
activity
:
Activity
)
{}
override
fun
onActivityStopped
(
activity
:
Activity
)
{
activityCount
--
if
(
activityCount
===
0
)
{
//进入后台
Constant
.
Utils
.
isTimingReport
=
false
}
if
(!
isCurAppTop
(
activity
))
{
// 从前台进入后台
sAppState
=
STATE_FRONT_TO_BACK
;
frontToBackTime
=
System
.
currentTimeMillis
();
flag
=
true
;
}
else
{
// 否则是正常状态
sAppState
=
STATE_NORMAL
;
}
}
override
fun
onActivitySaveInstanceState
(
activity
:
Activity
,
outState
:
Bundle
)
{}
override
fun
onActivityDestroyed
(
activity
:
Activity
)
{}
}
fun
canShowAd
():
Boolean
{
return
sAppState
===
STATE_BACK_TO_FRONT
&&
backToFrontTime
-
frontToBackTime
>
10000
}
fun
isCurAppTop
(
context
:
Context
?):
Boolean
{
if
(
context
==
null
)
{
return
false
}
val
curPackageName
=
context
.
packageName
val
am
:
ActivityManager
=
context
.
getSystemService
(
Context
.
ACTIVITY_SERVICE
)
as
ActivityManager
val
list
:
List
<
ActivityManager
.
RunningTaskInfo
>
=
am
.
getRunningTasks
(
1
)
if
(
list
!=
null
&&
list
.
size
>
0
)
{
val
info
:
ActivityManager
.
RunningTaskInfo
=
list
[
0
]
val
topPackageName
:
String
=
info
?.
topActivity
?.
packageName
!!
val
basePackageName
:
String
=
info
.
baseActivity
?.
packageName
!!
if
(
topPackageName
==
curPackageName
&&
basePackageName
==
curPackageName
)
{
return
true
}
}
return
false
}
}
}
\ No newline at end of file
app/src/main/java/com/zxhl/shop/activity/MainActivity.java
View file @
3e03ef9c
...
@@ -246,7 +246,6 @@ public class MainActivity extends BaseActivity implements NavigationBottomView.N
...
@@ -246,7 +246,6 @@ public class MainActivity extends BaseActivity implements NavigationBottomView.N
ApiClient
.
INSTANCE
.
getHomeApi
().
closeApp
().
compose
(
RxSchedulers
.
observableIO2Main
()).
subscribe
(
new
BaseObserver
<
Object
>()
{
ApiClient
.
INSTANCE
.
getHomeApi
().
closeApp
().
compose
(
RxSchedulers
.
observableIO2Main
()).
subscribe
(
new
BaseObserver
<
Object
>()
{
@Override
@Override
public
void
onSuccess
(
Object
result
)
{
public
void
onSuccess
(
Object
result
)
{
Log
.
e
(
"MXL"
,
"退出app上报"
);
exitActivity
();
exitActivity
();
}
}
...
...
cms/src/main/java/com/zxhl/cms/common/Constant.java
View file @
3e03ef9c
...
@@ -338,5 +338,13 @@ public class Constant {
...
@@ -338,5 +338,13 @@ public class Constant {
public
static
final
String
flowTag
=
"flowTag"
;
public
static
final
String
flowTag
=
"flowTag"
;
}
}
public
static
class
Utils
{
public
static
String
userId
=
""
;
public
static
String
ReportSessionId
=
""
;
public
static
boolean
isReportXiaoman
=
true
;
public
static
boolean
isTimingReport
=
true
;
public
static
boolean
isOpenSound
=
true
;
public
static
boolean
isOpenVibrate
=
true
;
}
}
}
cms/src/main/java/com/zxhl/cms/common/base/BaseActivity.java
View file @
3e03ef9c
...
@@ -8,6 +8,7 @@ import android.os.Bundle;
...
@@ -8,6 +8,7 @@ import android.os.Bundle;
import
android.os.Handler
;
import
android.os.Handler
;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.view.View
;
import
android.view.View
;
import
android.view.Window
;
import
android.view.Window
;
import
android.view.WindowManager
;
import
android.view.WindowManager
;
...
@@ -22,6 +23,7 @@ import com.zxhl.cms.AppContext;
...
@@ -22,6 +23,7 @@ import com.zxhl.cms.AppContext;
import
com.zxhl.cms.R
;
import
com.zxhl.cms.R
;
import
com.zxhl.cms.utils.ActivityManager
;
import
com.zxhl.cms.utils.ActivityManager
;
import
com.zxhl.cms.utils.ClipboardManagerUtil
;
import
com.zxhl.cms.utils.ClipboardManagerUtil
;
import
com.zxhl.cms.utils.JumpUtils
;
import
com.zxhl.cms.utils.LogUtils
;
import
com.zxhl.cms.utils.LogUtils
;
import
com.zxhl.cms.utils.StatusBarUtils
;
import
com.zxhl.cms.utils.StatusBarUtils
;
import
com.zxhl.cms.utils.Utils
;
import
com.zxhl.cms.utils.Utils
;
...
@@ -351,4 +353,10 @@ public abstract class BaseActivity extends RxAppCompatActivity implements View.O
...
@@ -351,4 +353,10 @@ public abstract class BaseActivity extends RxAppCompatActivity implements View.O
overridePendingTransition
(
0
,
0
);
overridePendingTransition
(
0
,
0
);
}
}
@Override
protected
void
onStart
()
{
super
.
onStart
();
}
}
}
cms/src/main/java/com/zxhl/cms/router/RounterApi.kt
View file @
3e03ef9c
...
@@ -305,4 +305,8 @@ interface RounterApi {
...
@@ -305,4 +305,8 @@ interface RounterApi {
fun
getIntentSearchReslut
(
fun
getIntentSearchReslut
(
@RounterParam
(
"keyword"
)
keyword
:
String
@RounterParam
(
"keyword"
)
keyword
:
String
):
Intent
):
Intent
@RounterUri
(
Constant
.
scheme
+
"://splash_background"
)
fun
getIntentSplashBack
(
):
Intent
}
}
\ No newline at end of file
cms/src/main/java/com/zxhl/cms/utils/JumpUtils.java
View file @
3e03ef9c
...
@@ -543,4 +543,14 @@ public class JumpUtils {
...
@@ -543,4 +543,14 @@ public class JumpUtils {
Utils
.
showToast
(
AppContext
.
get
(),
"该版本暂不支持,请更新版本!"
);
Utils
.
showToast
(
AppContext
.
get
(),
"该版本暂不支持,请更新版本!"
);
}
}
}
}
public
static
void
SplashBackJumo
()
{
try
{
Intent
intent
=
RounterBus
.
getRounter
(
RounterApi
.
class
).
getIntentSplashBack
();
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
AppContext
.
get
().
startActivity
(
intent
);
}
catch
(
Exception
e
)
{
Utils
.
showToast
(
AppContext
.
get
(),
"该版本暂不支持,请更新版本!"
);
}
}
}
}
moduleMain/src/main/AndroidManifest.xml
View file @
3e03ef9c
...
@@ -55,7 +55,8 @@
...
@@ -55,7 +55,8 @@
<activity
android:name=
".activity.CardDetailActivity"
>
<activity
android:name=
".activity.CardDetailActivity"
>
<intent-filter>
<intent-filter>
<action
android:name=
"android.intent.action.VIEW"
/>
<action
android:name=
"android.intent.action.VIEW"
/>
<category
android:name=
"android.intent.category.BROWSABLE"
/>
<category
android:name=
"android.intent.category.BROWSABLE"
/>
<category
android:name=
"android.intent.category.DEFAULT"
/>
<category
android:name=
"android.intent.category.DEFAULT"
/>
<data
<data
...
@@ -133,9 +134,11 @@
...
@@ -133,9 +134,11 @@
android:name=
".activity.RightsDetailActivity"
android:name=
".activity.RightsDetailActivity"
android:launchMode=
"singleTop"
>
android:launchMode=
"singleTop"
>
<intent-filter>
<intent-filter>
<action
android:name=
"android.intent.action.VIEW"
/>
<action
android:name=
"android.intent.action.VIEW"
/>
<category
android:name=
"android.intent.category.DEFAULT"
/>
<category
android:name=
"android.intent.category.BROWSABLE"
/>
<category
android:name=
"android.intent.category.DEFAULT"
/>
<category
android:name=
"android.intent.category.BROWSABLE"
/>
<data
<data
android:host=
"rights_detail"
android:host=
"rights_detail"
android:scheme=
"xxsqshop"
/>
android:scheme=
"xxsqshop"
/>
...
@@ -171,7 +174,8 @@
...
@@ -171,7 +174,8 @@
<activity
android:name=
".box.activity.NewBoxGoodsDetailActivity"
>
<activity
android:name=
".box.activity.NewBoxGoodsDetailActivity"
>
<intent-filter>
<intent-filter>
<action
android:name=
"android.intent.action.VIEW"
/>
<action
android:name=
"android.intent.action.VIEW"
/>
<category
android:name=
"android.intent.category.BROWSABLE"
/>
<category
android:name=
"android.intent.category.BROWSABLE"
/>
<category
android:name=
"android.intent.category.DEFAULT"
/>
<category
android:name=
"android.intent.category.DEFAULT"
/>
<data
<data
...
@@ -391,6 +395,21 @@
...
@@ -391,6 +395,21 @@
android:scheme=
"xxsqshop"
/>
android:scheme=
"xxsqshop"
/>
</intent-filter>
</intent-filter>
</activity>
</activity>
<activity
android:name=
".activity.SplashBackgroundActivity"
android:launchMode=
"singleTop"
>
<intent-filter>
<action
android:name=
"android.intent.action.VIEW"
/>
<category
android:name=
"android.intent.category.DEFAULT"
/>
<data
android:host=
"splash_background"
android:scheme=
"xxsqshop"
/>
</intent-filter>
</activity>
</application>
</application>
</manifest>
</manifest>
\ No newline at end of file
moduleMain/src/main/java/com/zxbw/modulemain/activity/RechargeActivity.kt
View file @
3e03ef9c
...
@@ -13,6 +13,8 @@ import androidx.recyclerview.widget.LinearLayoutManager
...
@@ -13,6 +13,8 @@ import androidx.recyclerview.widget.LinearLayoutManager
import
com.pay.paytypelibrary.base.OnPayResultListener
import
com.pay.paytypelibrary.base.OnPayResultListener
import
com.pay.paytypelibrary.base.OrderInfo
import
com.pay.paytypelibrary.base.OrderInfo
import
com.pay.paytypelibrary.base.PayUtil
import
com.pay.paytypelibrary.base.PayUtil
import
com.zx.ad.AdManager
import
com.zx.ad.callback.InterertionAdListener
import
com.zxbw.modulemain.R
import
com.zxbw.modulemain.R
import
com.zxbw.modulemain.adapter.OperatorAdapter
import
com.zxbw.modulemain.adapter.OperatorAdapter
import
com.zxbw.modulemain.adapter.RechargeAdapter
import
com.zxbw.modulemain.adapter.RechargeAdapter
...
@@ -88,8 +90,24 @@ class RechargeActivity : BaseActivity(), OnRecycleItemClickListener<MemberEntity
...
@@ -88,8 +90,24 @@ class RechargeActivity : BaseActivity(), OnRecycleItemClickListener<MemberEntity
override
fun
layoutID
():
Int
{
override
fun
layoutID
():
Int
{
return
R
.
layout
.
activity_layout_recharge
return
R
.
layout
.
activity_layout_recharge
}
}
fun
showIntriAd
(){
AdManager
.
loadInterAd
(
this
!!
,
object
:
InterertionAdListener
{
override
fun
onAdShow
()
{
}
override
fun
onAdError
(
errorMsg
:
String
?)
{
Log
.
e
(
"MXL"
,
"onAdError"
+
errorMsg
)
}
override
fun
onAdClose
()
{
}
})
}
override
fun
init
()
{
override
fun
init
()
{
showIntriAd
()
id_img_back
?.
setOnClickListener
{
id_img_back
?.
setOnClickListener
{
finish
()
finish
()
}
}
...
...
moduleMain/src/main/java/com/zxbw/modulemain/activity/RightsDetailActivity.kt
View file @
3e03ef9c
...
@@ -12,6 +12,8 @@ import com.bumptech.glide.request.RequestOptions
...
@@ -12,6 +12,8 @@ import com.bumptech.glide.request.RequestOptions
import
com.pay.paytypelibrary.base.OnPayResultListener
import
com.pay.paytypelibrary.base.OnPayResultListener
import
com.pay.paytypelibrary.base.OrderInfo
import
com.pay.paytypelibrary.base.OrderInfo
import
com.pay.paytypelibrary.base.PayUtil
import
com.pay.paytypelibrary.base.PayUtil
import
com.zx.ad.AdManager
import
com.zx.ad.callback.InterertionAdListener
import
com.zxbw.modulemain.R
import
com.zxbw.modulemain.R
import
com.zxbw.modulemain.adapter.RightsDetailListAdapter
import
com.zxbw.modulemain.adapter.RightsDetailListAdapter
import
com.zxbw.modulemain.contract.RightsDetailContract
import
com.zxbw.modulemain.contract.RightsDetailContract
...
@@ -63,6 +65,7 @@ class RightsDetailActivity : BaseActivity(), RightsDetailContract.View, RightsPa
...
@@ -63,6 +65,7 @@ class RightsDetailActivity : BaseActivity(), RightsDetailContract.View, RightsPa
}
}
override
fun
init
()
{
override
fun
init
()
{
showIntriAd
()
var
statusBarHeight
=
ScreenUtils
.
getStatusBarHeight
()
var
statusBarHeight
=
ScreenUtils
.
getStatusBarHeight
()
if
(
statusBarHeight
<=
0
)
{
if
(
statusBarHeight
<=
0
)
{
statusBarHeight
=
40
;
statusBarHeight
=
40
;
...
@@ -98,7 +101,22 @@ class RightsDetailActivity : BaseActivity(), RightsDetailContract.View, RightsPa
...
@@ -98,7 +101,22 @@ class RightsDetailActivity : BaseActivity(), RightsDetailContract.View, RightsPa
mPresenter
?.
geRightsDetail
(
brandName
)
mPresenter
?.
geRightsDetail
(
brandName
)
}
}
fun
showIntriAd
(){
AdManager
.
loadInterAd
(
this
!!
,
object
:
InterertionAdListener
{
override
fun
onAdShow
()
{
}
override
fun
onAdError
(
errorMsg
:
String
?)
{
Log
.
e
(
"MXL"
,
"onAdError"
+
errorMsg
)
}
override
fun
onAdClose
()
{
}
})
}
override
fun
onClick
(
v
:
View
?)
{
override
fun
onClick
(
v
:
View
?)
{
when
(
v
)
{
when
(
v
)
{
...
...
moduleMain/src/main/java/com/zxbw/modulemain/activity/SplashBackgroundActivity.kt
0 → 100644
View file @
3e03ef9c
package
com.zxbw.modulemain.activity
import
android.text.TextUtils
import
android.util.Log
import
android.view.View
import
com.umeng.analytics.MobclickAgent
import
com.zx.ad.AdManager
import
com.zx.ad.callback.SplashAdListener
import
com.zxbw.modulemain.R
import
com.zxbw.modulemain.contract.SplashContract
import
com.zxbw.modulemain.presenter.SplashPresenter
import
com.zxhl.cms.common.Constant
import
com.zxhl.cms.common.NetConfig
import
com.zxhl.cms.common.base.BaseActivity
import
com.zxhl.cms.net.ApiClient
import
com.zxhl.cms.net.RxSchedulers
import
com.zxhl.cms.net.SettingPreference
import
com.zxhl.cms.net.callback.BaseObserver
import
com.zxhl.cms.net.model.box.AppInEntity
import
com.zxhl.cms.router.RounterApi
import
com.zxhl.cms.router.RounterBus
import
com.zxhl.cms.utils.EventUtils
import
com.zxhl.cms.utils.JumpUtils
import
com.zxhl.cms.widget.CenterDialog
import
kotlinx.android.synthetic.main.activity_splash.*
class
SplashBackgroundActivity
:
BaseActivity
()
{
override
fun
onClick
(
v
:
View
?)
{
}
override
fun
layoutID
():
Int
=
R
.
layout
.
activity_splash
private
var
mPresenter
:
SplashContract
.
Presenter
?
=
null
override
fun
init
()
{
if
(!
isTaskRoot
)
{
finish
()
return
}
initSplashAd
()
}
private
fun
initSplashAd
()
{
AdManager
.
loadSplashAd
(
this
,
id_splash_view
,
object
:
SplashAdListener
{
override
fun
onAdShow
()
{
}
override
fun
onAdSkip
()
{
}
override
fun
onError
(
errorMsg
:
String
?)
{
Log
.
e
(
"MXL"
,
"MSG:"
+
errorMsg
)
jumpMainPage
()
}
})
}
fun
jumpMainPage
()
{
val
user
=
SettingPreference
.
getUserInfoData
()
val
token
=
SettingPreference
.
getUserToken
()
if
(
user
==
null
&&
TextUtils
.
isEmpty
(
token
))
{
JumpUtils
.
loginJump
()
}
else
{
JumpUtils
.
activityJump
(
RounterBus
.
getRounter
(
RounterApi
::
class
.
java
).
getIntentActivityMain
()
)
}
finish
()
}
private
var
isPause
=
false
override
fun
onResume
()
{
super
.
onResume
()
MobclickAgent
.
onResume
(
this
)
}
override
fun
onPause
()
{
super
.
onPause
()
MobclickAgent
.
onPause
(
this
)
}
}
\ No newline at end of file
moduleMain/src/main/java/com/zxbw/modulemain/fragment/UserCenterFragment.kt
View file @
3e03ef9c
...
@@ -8,10 +8,16 @@ import android.view.View
...
@@ -8,10 +8,16 @@ import android.view.View
import
com.bumptech.glide.Glide
import
com.bumptech.glide.Glide
import
com.bumptech.glide.load.resource.bitmap.CircleCrop
import
com.bumptech.glide.load.resource.bitmap.CircleCrop
import
com.bumptech.glide.request.RequestOptions
import
com.bumptech.glide.request.RequestOptions
import
com.bytedance.sdk.openadsdk.TTAdNative
import
com.bytedance.sdk.openadsdk.TTNativeExpressAd
import
com.zx.ad.AdManager
import
com.zx.ad.AdManager
import
com.zx.ad.callback.InterertionAdListener
import
com.zx.ad.callback.RewardVideoAdListener
import
com.zx.ad.callback.RewardVideoAdListener
import
com.zx.ad.platform.csj.CSJAdManager
import
com.zxbw.modulemain.R
import
com.zxbw.modulemain.R
import
com.zxbw.modulemain.view.DialogUtils
import
com.zxbw.modulemain.view.DialogUtils
import
com.zxhl.cms.ad.upload.Utils.AdUpload
import
com.zxhl.cms.ad.upload.model.NewsEntity
import
com.zxhl.cms.common.NetConfig
import
com.zxhl.cms.common.NetConfig
import
com.zxhl.cms.common.base.BaseFragment
import
com.zxhl.cms.common.base.BaseFragment
import
com.zxhl.cms.net.ApiClient
import
com.zxhl.cms.net.ApiClient
...
@@ -77,6 +83,23 @@ class UserCenterFragment : BaseFragment(), AdCallback<String> {
...
@@ -77,6 +83,23 @@ class UserCenterFragment : BaseFragment(), AdCallback<String> {
}
}
private
fun
showIntriAd
()
{
AdManager
.
loadInterAd
(
activity
!!
,
object
:
InterertionAdListener
{
override
fun
onAdShow
()
{
}
override
fun
onAdError
(
errorMsg
:
String
?)
{
Log
.
e
(
"MXL"
,
"onAdError"
+
errorMsg
)
}
override
fun
onAdClose
()
{
}
})
}
private
fun
loadRewardAd
()
{
private
fun
loadRewardAd
()
{
AdManager
.
loadRewardAd
(
activity
!!
,
object
:
RewardVideoAdListener
{
AdManager
.
loadRewardAd
(
activity
!!
,
object
:
RewardVideoAdListener
{
override
fun
onRewardVideoAdClose
()
{
override
fun
onRewardVideoAdClose
()
{
...
@@ -99,13 +122,15 @@ class UserCenterFragment : BaseFragment(), AdCallback<String> {
...
@@ -99,13 +122,15 @@ class UserCenterFragment : BaseFragment(), AdCallback<String> {
override
fun
data
()
{
override
fun
data
()
{
super
.
data
()
super
.
data
()
userVisibleHint
=
true
//
userVisibleHint = true
}
}
override
fun
lazyLoad
()
{
override
fun
lazyLoad
()
{
super
.
lazyLoad
()
super
.
lazyLoad
()
if
(
isInitial
&&
isVisible
)
{
if
(
isInitial
&&
isVisible
)
{
UserDataUtils
.
updateUserInfo
(
this
)
UserDataUtils
.
updateUserInfo
(
this
)
getAds
()
// showIntriAd()
}
}
}
}
...
@@ -174,4 +199,86 @@ class UserCenterFragment : BaseFragment(), AdCallback<String> {
...
@@ -174,4 +199,86 @@ class UserCenterFragment : BaseFragment(), AdCallback<String> {
}
}
})
})
}
}
private
fun
getAds
()
{
var
slotId
=
"bigimage"
Log
.
d
(
"MXL"
,
"getAds "
)
ApiClient
.
adApi
.
getAds
(
slotId
)
.
compose
(
RxSchedulers
.
observableIO2Main
())
.
subscribe
(
object
:
BaseObserver
<
List
<
NewsEntity
>>()
{
override
fun
onSuccess
(
result
:
List
<
NewsEntity
>)
{
if
(
result
!=
null
&&
result
?.
isNotEmpty
())
{
if
(
result
?.
isNotEmpty
())
{
updataAdView
(
slotId
,
result
?.
get
(
0
),
0
)
}
else
{
updataAdView
(
slotId
,
null
,
0
)
}
}
else
{
updataAdView
(
slotId
,
null
,
0
)
}
}
override
fun
onFailure
(
e
:
Throwable
?,
code
:
String
?,
errorMsg
:
String
?)
{
updataAdView
(
slotId
,
null
,
0
)
}
})
}
var
mTTAd
:
TTNativeExpressAd
?
=
null
private
fun
updataAdView
(
slotId
:
String
,
data
:
NewsEntity
?,
count
:
Int
)
{
if
(
data
==
null
)
{
id_fragment_user_ad_layout
?.
visibility
=
View
.
GONE
return
}
if
(
TextUtils
.
equals
(
data
.
adPlatform
,
"chuanshanjia"
))
{
var
expressViewWidth
=
(
Utils
.
px2dip
(
context
,
PhoneUtils
.
getScreenWidth
(
context
).
toFloat
())
-
32
).
toFloat
()
var
expressViewHeight
=
0f
CSJAdManager
.
requestByteDailyActiveBigImgFeed
(
data
?.
codeId
?:
""
,
expressViewWidth
,
expressViewHeight
,
object
:
TTAdNative
.
NativeExpressAdListener
{
override
fun
onError
(
p0
:
Int
,
p1
:
String
?)
{
id_fragment_user_ad_layout
?.
removeAllViews
()
// retryAds(slotId, data, count)
}
override
fun
onNativeExpressAdLoad
(
p0
:
MutableList
<
TTNativeExpressAd
>?)
{
Log
.
d
(
"qbs"
,
"onNativeExpressAdLoad"
)
if
(
p0
?.
isNotEmpty
()
==
true
)
{
id_fragment_user_ad_layout
?.
visibility
=
View
.
VISIBLE
mTTAd
=
p0
.
get
(
0
)
mTTAd
?.
setExpressInteractionListener
(
object
:
TTNativeExpressAd
.
ExpressAdInteractionListener
{
override
fun
onAdClicked
(
p0
:
View
?,
p1
:
Int
)
{
//广告被点击
AdUpload
.
onAdClick
(
data
)
}
override
fun
onAdShow
(
view
:
View
,
type
:
Int
)
{
//广告展示
AdUpload
.
onAdImpression
(
data
)
}
override
fun
onRenderFail
(
p0
:
View
?,
p1
:
String
?,
p2
:
Int
)
{
// }
}
override
fun
onRenderSuccess
(
p0
:
View
?,
p1
:
Float
,
p2
:
Float
)
{
Log
.
d
(
"qbs"
,
"onRenderSuccess:"
+
p1
+
"------"
+
p2
)
id_fragment_user_ad_layout
?.
removeAllViews
()
id_fragment_user_ad_layout
?.
addView
(
p0
)
// }
}
})
mTTAd
?.
render
()
//调用render开始渲染广告
}
}
})
}
}
}
}
\ No newline at end of file
moduleMain/src/main/res/layout/fragment_layout_user_center.xml
View file @
3e03ef9c
...
@@ -569,4 +569,13 @@
...
@@ -569,4 +569,13 @@
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:id=
"@+id/id_fragment_user_ad_layout"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"10dp"
android:layout_marginBottom=
"20dp"
android:background=
"@color/white"
android:gravity=
"center"
android:visibility=
"gone"
/>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
moduleZxAd/src/main/java/com/zx/ad/AdManager.kt
View file @
3e03ef9c
...
@@ -7,6 +7,7 @@ import android.util.Log
...
@@ -7,6 +7,7 @@ import android.util.Log
import
android.widget.FrameLayout
import
android.widget.FrameLayout
import
com.bytedance.sdk.openadsdk.TTAdSdk
import
com.bytedance.sdk.openadsdk.TTAdSdk
import
com.zx.ad.callback.AdLoadCallBack
import
com.zx.ad.callback.AdLoadCallBack
import
com.zx.ad.callback.InterertionAdListener
import
com.zx.ad.callback.RewardVideoAdListener
import
com.zx.ad.callback.RewardVideoAdListener
import
com.zx.ad.callback.SplashAdListener
import
com.zx.ad.callback.SplashAdListener
import
com.zx.ad.modulecommon.AdConstant
import
com.zx.ad.modulecommon.AdConstant
...
@@ -33,6 +34,7 @@ object AdManager {
...
@@ -33,6 +34,7 @@ object AdManager {
private
var
TAG
=
"AdManager"
private
var
TAG
=
"AdManager"
private
var
isLoadReward
=
false
private
var
isLoadReward
=
false
private
var
isLoadSplash
=
false
private
var
isLoadSplash
=
false
private
var
isInterAd
=
false
private
var
mLoading
:
LoadingDialog
?
=
null
private
var
mLoading
:
LoadingDialog
?
=
null
private
fun
showLoadIng
(
activity
:
Activity
)
{
private
fun
showLoadIng
(
activity
:
Activity
)
{
activity
.
runOnUiThread
{
activity
.
runOnUiThread
{
...
@@ -189,6 +191,75 @@ object AdManager {
...
@@ -189,6 +191,75 @@ object AdManager {
loadAdPlatform
(
context
,
entity
,
ADType
.
AD_SPLASH
,
callBack
)
loadAdPlatform
(
context
,
entity
,
ADType
.
AD_SPLASH
,
callBack
)
}
}
fun
loadInterAd
(
context
:
Activity
,
listener
:
InterertionAdListener
)
{
if
(
context
.
isFinishing
)
{
return
}
if
(
isInterAd
)
{
Log
.
d
(
"AdManager"
,
"正在加载.."
)
return
}
else
{
isInterAd
=
true
}
ZXADClient
.
adApi
.
getAds
(
ADType
.
AD_INTERSTITAL
)
.
compose
(
RxSchedulers
.
observableIO2Main
())
.
subscribe
(
object
:
BaseObserver
<
List
<
NewsEntity
>?>()
{
override
fun
onSuccess
(
result
:
List
<
NewsEntity
>?)
{
isInterAd
=
false
if
(
result
.
isNullOrEmpty
())
{
listener
.
onAdError
(
"loadInterAd Config IS NULL"
)
}
else
{
LogUtils
.
d
(
"loadInterAd result:${result.size}"
)
loadingInterAd
(
context
,
result
,
listener
)
}
}
override
fun
onFailure
(
e
:
Throwable
?,
code
:
String
?,
errorMsg
:
String
?)
{
isInterAd
=
false
LogUtils
.
e
(
"loadSplashAd Error code:${code} errorMsg:${errorMsg}"
)
listener
.
onAdError
(
"loadRewardVideoAd Error code:${code} errorMsg:${errorMsg}"
)
}
})
}
private
fun
loadingInterAd
(
context
:
Activity
,
result
:
List
<
NewsEntity
>,
listener
:
InterertionAdListener
)
{
var
totalEntity
=
ArrayList
<
NewsEntity
>()
totalEntity
.
add
(
result
[
0
])
totalEntity
.
addAll
(
result
[
0
].
backups
)
var
callBack
=
object
:
AdLoadCallBack
{
override
fun
OnAdLoadSuccess
(
platform
:
String
?,
entity
:
NewsEntity
)
{
dismissLoading
()
when
(
platform
)
{
ADType
.
PLATFORM_AD_TT
->
{
CSJAdManager
.
showIntereiAd
(
context
,
entity
,
listener
)
}
}
}
override
fun
OnAdLoadFail
(
errorMsg
:
String
?)
{
LogUtils
.
e
(
"errorMsg:${errorMsg}"
)
if
(
totalEntity
.
isNullOrEmpty
())
{
dismissLoading
()
listener
.
onAdError
(
"interAd loadFail end"
)
}
else
{
var
entity
=
totalEntity
[
0
];
totalEntity
.
removeAt
(
0
)
loadAdPlatform
(
context
,
entity
,
ADType
.
AD_INTERSTITAL
,
this
)
}
}
}
var
entity
=
totalEntity
[
0
]
totalEntity
.
removeAt
(
0
)
loadAdPlatform
(
context
,
entity
,
ADType
.
AD_INTERSTITAL
,
callBack
)
}
fun
loadRewardAd
(
context
:
Activity
,
listener
:
RewardVideoAdListener
)
{
fun
loadRewardAd
(
context
:
Activity
,
listener
:
RewardVideoAdListener
)
{
if
(
context
.
isFinishing
)
{
if
(
context
.
isFinishing
)
{
return
return
...
@@ -289,7 +360,9 @@ object AdManager {
...
@@ -289,7 +360,9 @@ object AdManager {
ADType
.
AD_SPLASH
->
{
ADType
.
AD_SPLASH
->
{
CSJAdManager
.
loadSplashAd
(
context
,
data
,
callBack
)
CSJAdManager
.
loadSplashAd
(
context
,
data
,
callBack
)
}
}
ADType
.
AD_INTERSTITAL
->
{
CSJAdManager
.
loadIntertialAd
(
context
,
data
,
callBack
)
}
ADType
.
AD_REWARD_VIDEO
->
{
ADType
.
AD_REWARD_VIDEO
->
{
CSJAdManager
.
loadRewardVideoAd
(
context
,
data
,
callBack
)
CSJAdManager
.
loadRewardVideoAd
(
context
,
data
,
callBack
)
}
}
...
...
moduleZxAd/src/main/java/com/zx/ad/callback/InterertionAdListener.kt
0 → 100644
View file @
3e03ef9c
package
com.zx.ad.callback
interface
InterertionAdListener
{
//获取广告展示
fun
onAdShow
()
//获取广告错误
fun
onAdError
(
errorMsg
:
String
?)
fun
onAdClose
()
}
\ No newline at end of file
moduleZxAd/src/main/java/com/zx/ad/platform/ADType.kt
View file @
3e03ef9c
...
@@ -28,6 +28,7 @@ object ADType {
...
@@ -28,6 +28,7 @@ object ADType {
const
val
AD_SPLASH
=
"splash"
//开屏广告
const
val
AD_SPLASH
=
"splash"
//开屏广告
const
val
AD_REWARD_VIDEO
=
"video"
//激励视频广告
const
val
AD_REWARD_VIDEO
=
"video"
//激励视频广告
const
val
AD_BIG_IMAGE
=
"bigimage"
//大图广告
const
val
AD_BIG_IMAGE
=
"bigimage"
//大图广告
const
val
AD_INTERSTITAL
=
"Interstitial"
//大图广告
const
val
AD_FULL_VIDEO
=
"fullvideo"
//全屏视频广告
const
val
AD_FULL_VIDEO
=
"fullvideo"
//全屏视频广告
...
...
moduleZxAd/src/main/java/com/zx/ad/platform/csj/CSJAdManager.kt
View file @
3e03ef9c
...
@@ -7,8 +7,8 @@ import android.util.Log
...
@@ -7,8 +7,8 @@ import android.util.Log
import
android.view.View
import
android.view.View
import
android.widget.FrameLayout
import
android.widget.FrameLayout
import
com.bytedance.sdk.openadsdk.*
import
com.bytedance.sdk.openadsdk.*
import
com.zx.ad.AdManager
import
com.zx.ad.callback.AdLoadCallBack
import
com.zx.ad.callback.AdLoadCallBack
import
com.zx.ad.callback.InterertionAdListener
import
com.zx.ad.callback.RewardVideoAdListener
import
com.zx.ad.callback.RewardVideoAdListener
import
com.zx.ad.callback.SplashAdListener
import
com.zx.ad.callback.SplashAdListener
import
com.zx.ad.modulecommon.module.NewsEntity
import
com.zx.ad.modulecommon.module.NewsEntity
...
@@ -24,7 +24,15 @@ import com.zx.ad.utils.UIUtils
...
@@ -24,7 +24,15 @@ import com.zx.ad.utils.UIUtils
* @detail :穿山甲广告平台
* @detail :穿山甲广告平台
*/
*/
object
CSJAdManager
{
object
CSJAdManager
{
private
var
mTTAdNative
:
TTAdNative
?
=
null
private
var
mTTAdNative
:
TTAdNative
?
=
null
private
var
context
:
Context
?
=
null
fun
init
(
context
:
Context
)
{
this
.
context
=
context
mTTAdNative
=
TTAdSdk
.
getAdManager
().
createAdNative
(
context
)
//baseContext建议为activity
}
fun
adInit
(
context
:
Context
,
appId
:
String
,
initCallback
:
TTAdSdk
.
InitCallback
?)
{
fun
adInit
(
context
:
Context
,
appId
:
String
,
initCallback
:
TTAdSdk
.
InitCallback
?)
{
TTAdManagerHolder
.
init
(
context
,
appId
,
initCallback
)
TTAdManagerHolder
.
init
(
context
,
appId
,
initCallback
)
// TTAdManagerHolder.init(context, "5001121")
// TTAdManagerHolder.init(context, "5001121")
...
@@ -135,7 +143,61 @@ object CSJAdManager {
...
@@ -135,7 +143,61 @@ object CSJAdManager {
})
})
}
}
private
var
innterstitialAd
:
TTInteractionAd
?
=
null
//加载插屏广告
fun
loadIntertialAd
(
context
:
Context
,
entity
:
NewsEntity
,
loadCallBack
:
AdLoadCallBack
)
{
mTTAdNative
=
TTAdManagerHolder
.
get
().
createAdNative
(
context
)
val
adSlot
=
AdSlot
.
Builder
()
.
setCodeId
(
entity
.
codeId
)
.
setSupportDeepLink
(
true
)
.
setAdCount
(
1
)
//请求广告数量为1到3条
//.setExpressViewAcceptedSize(300f, 300f) //期望模板广告view的size,单位dp
// .setAdLoadType(TTAdLoadType.LOAD) //推荐使用,用于标注此次的广告请求用途为预加载(当做缓存)还是实时加载,方便后续为开发者优化相关策略
.
build
()
mTTAdNative
?.
loadFullScreenVideoAd
(
adSlot
,
object
:
TTAdNative
.
FullScreenVideoAdListener
{
override
fun
onError
(
p0
:
Int
,
p1
:
String
?)
{
AdEventUtils
.
onEventPullFail
(
entity
)
loadCallBack
.
OnAdLoadFail
(
"CSJ Interaction error p0:${p0} p1:${p1}"
)
}
override
fun
onFullScreenVideoAdLoad
(
p0
:
TTFullScreenVideoAd
?)
{
AdEventUtils
.
onEventPullSuccess
(
entity
)
// innterstitialAd=p0
loadCallBack
.
OnAdLoadSuccess
(
ADType
.
PLATFORM_AD_TT
,
entity
)
}
override
fun
onFullScreenVideoCached
()
{
}
override
fun
onFullScreenVideoCached
(
p0
:
TTFullScreenVideoAd
?)
{
}
})
}
fun
showIntereiAd
(
context
:
Activity
,
entity
:
NewsEntity
,
listener
:
InterertionAdListener
){
if
(
innterstitialAd
==
null
){
listener
.
onAdError
(
"CSJ innterstitialAd Is Null"
)
return
}
if
(!
context
.
isFinishing
)
{
innterstitialAd
?.
setAdInteractionListener
(
object
:
TTInteractionAd
.
AdInteractionListener
{
override
fun
onAdClicked
()
{
}
override
fun
onAdShow
()
{
listener
.
onAdShow
()
}
override
fun
onAdDismiss
()
{
listener
.
onAdClose
()
}
})
}
}
private
var
rewardVideoAd
:
TTRewardVideoAd
?
=
null
private
var
rewardVideoAd
:
TTRewardVideoAd
?
=
null
/**
/**
...
@@ -247,4 +309,37 @@ object CSJAdManager {
...
@@ -247,4 +309,37 @@ object CSJAdManager {
splashAd
=
null
splashAd
=
null
rewardVideoAd
=
null
rewardVideoAd
=
null
}
}
fun
requestByteDailyActiveBigImgFeed
(
codeId
:
String
,
expressViewWidth
:
Float
,
expressViewHeight
:
Float
,
callBack
:
TTAdNative
.
NativeExpressAdListener
)
{
val
adSlot
=
AdSlot
.
Builder
()
.
setCodeId
(
codeId
)
.
setSupportDeepLink
(
false
)
.
setExpressViewAcceptedSize
(
expressViewWidth
,
expressViewHeight
)
// .setImageAcceptedSize(640, 0)
// .setAdLoadType(TTAdLoadType.PRELOAD)
.
setAdCount
(
1
)
.
build
()
//调用feed广告异步请求接口
// mTTAdNative?.loadFeedAd(adSlot,callBack)
mTTAdNative
?.
loadNativeExpressAd
(
adSlot
,
object
:
TTAdNative
.
NativeExpressAdListener
{
override
fun
onNativeExpressAdLoad
(
p0
:
MutableList
<
TTNativeExpressAd
>?)
{
if
(
p0
!=
null
&&
p0
.
size
>
0
)
{
callBack
.
onNativeExpressAdLoad
(
p0
)
}
else
{
callBack
?.
onError
(
1000
,
"没有拉取到广告"
)
}
}
override
fun
onError
(
p0
:
Int
,
p1
:
String
?)
{
Log
.
e
(
"MXL"
,
"loadNativeExpressAdonError"
+
p1
)
callBack
?.
onError
(
p0
,
p1
)
}
})
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment