Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
android_goodmoney
Project
Project
Details
Activity
Releases
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
android
android_goodmoney
Commits
7096cfc1
Commit
7096cfc1
authored
Feb 26, 2021
by
mengcuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码优化
parent
2abf2287
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
78 additions
and
74 deletions
+78
-74
CsjDrawAdManager.kt
...main/java/com/mints/goodmoney/ad/draw/CsjDrawAdManager.kt
+59
-4
PreLoadExpressManager.kt
...a/com/mints/goodmoney/ad/express/PreLoadExpressManager.kt
+1
-2
DrawNativeVideoActivity.kt
...m/mints/goodmoney/ui/activitys/DrawNativeVideoActivity.kt
+13
-65
DrawVideoAdapter.kt
...n/java/com/mints/goodmoney/ui/adapter/DrawVideoAdapter.kt
+4
-2
ForegroundOrBackground.java
...ava/com/mints/goodmoney/utils/ForegroundOrBackground.java
+1
-1
No files found.
GoodMoney/app/src/main/java/com/mints/goodmoney/ad/draw/CsjDrawAdManager.kt
View file @
7096cfc1
package
com.mints.goodmoney.ad.draw
import
android.app.Activity
import
android.view.View
import
com.bytedance.sdk.openadsdk.AdSlot
import
com.bytedance.sdk.openadsdk.TTAdNative
import
com.bytedance.sdk.openadsdk.TTNativeExpressAd
import
com.bytedance.sdk.openadsdk.TTRewardVideoAd
import
com.mints.goodmoney.manager.TTNativeExpressManager
import
com.mints.goodmoney.manager.TtCsjAdManager
import
com.mints.goodmoney.mvp.model.DrawVideoBean
import
com.mints.goodmoney.ui.activitys.DrawNativeVideoActivity
import
com.mints.goodmoney.utils.LogUtil
import
com.mints.goodmoney.utils.ToastUtil
import
com.mints.goodmoney.utils.UIUtils
class
CsjDrawAdManager
private
constructor
(
activity
:
Activity
)
{
...
...
@@ -60,15 +64,66 @@ class CsjDrawAdManager private constructor(activity: Activity) {
this
@CsjDrawAdManager
.
csjDrawAdListener
?.
csjDrawAdFail
()
}
override
fun
onNativeExpressAdLoad
(
p0
:
MutableList
<
TTNativeExpressAd
>?)
{
if
(
p0
==
null
||
p0
.
isEmpty
())
{
override
fun
onNativeExpressAdLoad
(
ads
:
MutableList
<
TTNativeExpressAd
>?)
{
if
(
ads
==
null
||
ads
.
isEmpty
())
{
// ToastUtil.show(activity, "未请求到广告")
this
@CsjDrawAdManager
.
csjDrawAdListener
?.
csjDrawAdFail
()
LogUtil
.
d
(
"未请求到广告"
)
return
}
this
@CsjDrawAdManager
.
csjDrawAdListener
?.
csjDrawAdSuccess
(
p0
)
for
(
ad
in
ads
)
{
//点击监听器必须在getAdView之前调
ad
.
setVideoAdListener
(
object
:
TTNativeExpressAd
.
ExpressVideoAdListener
{
override
fun
onVideoLoad
()
{
}
override
fun
onVideoError
(
p0
:
Int
,
p1
:
Int
)
{
}
override
fun
onVideoAdStartPlay
()
{
}
override
fun
onVideoAdPaused
()
{
}
override
fun
onVideoAdContinuePlay
()
{
}
override
fun
onProgressUpdate
(
p0
:
Long
,
p1
:
Long
)
{
}
override
fun
onVideoAdComplete
()
{
}
override
fun
onClickRetry
()
{
}
})
ad
.
setCanInterruptVideoPlay
(
true
)
ad
.
setExpressInteractionListener
(
object
:
TTNativeExpressAd
.
ExpressAdInteractionListener
{
override
fun
onAdClicked
(
p0
:
View
?,
p1
:
Int
)
{
}
override
fun
onAdShow
(
p0
:
View
?,
p1
:
Int
)
{
}
override
fun
onRenderFail
(
p0
:
View
?,
p1
:
String
?,
p2
:
Int
)
{
this
@CsjDrawAdManager
.
csjDrawAdListener
?.
csjDrawAdFail
()
}
override
fun
onRenderSuccess
(
p0
:
View
?,
p1
:
Float
,
p2
:
Float
)
{
this
@CsjDrawAdManager
.
csjDrawAdListener
?.
csjDrawAdSuccess
(
ad
)
}
})
ad
.
render
()
}
}
})
...
...
@@ -80,7 +135,7 @@ class CsjDrawAdManager private constructor(activity: Activity) {
interface
CsjDrawAdListener
{
fun
csjDrawAdFail
()
fun
csjDrawAdSuccess
(
data
:
MutableList
<
TTNativeExpressAd
>?
)
fun
csjDrawAdSuccess
(
data
:
TTNativeExpressAd
)
}
fun
onDestroy
()
{
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/ad/express/PreLoadExpressManager.kt
View file @
7096cfc1
...
...
@@ -19,7 +19,6 @@ object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener
private
val
TAG
=
PreLoadExpressManager
::
class
.
java
.
simpleName
// 是否是穿山甲信息流
@Volatile
private
var
currentIndex
=
0
...
...
@@ -99,7 +98,7 @@ object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener
var
randomWeight
=
r
.
nextInt
(
weight
)
+
1
LogUtil
.
d
(
TAG
,
"2、权重随机值EXPRESS:$randomWeight"
)
ToastUtil
.
show
(
MintsApplication
.
getContext
(),
"权重随机值EXPRESS:"
+
randomWeight
);
//
ToastUtil.show(MintsApplication.getContext(), "权重随机值EXPRESS:" + randomWeight);
for
(
weightBean
in
weightList
)
{
randomWeight
-=
weightBean
.
weight
if
(
randomWeight
<=
0
)
{
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/activitys/DrawNativeVideoActivity.kt
View file @
7096cfc1
...
...
@@ -120,7 +120,8 @@ class DrawNativeVideoActivity : BaseActivity(),
mCsjDrawAdManager
?.
setCsjDrawAdListener
(
this
)
mLayoutManager
=
ViewPagerLayoutManager
(
this
,
OrientationHelper
.
VERTICAL
)
mDrawVideoAdapter
=
DrawVideoAdapter
(
this
,
drawDatas
)
// mDrawVideoAdapter = DrawVideoAdapter(this, drawDatas)
mDrawVideoAdapter
=
DrawVideoAdapter
(
drawDatas
)
recy_draw_native
.
setItemViewCacheSize
(
1
)
recy_draw_native
.
layoutManager
=
mLayoutManager
recy_draw_native
.
adapter
=
mDrawVideoAdapter
...
...
@@ -388,59 +389,11 @@ class DrawNativeVideoActivity : BaseActivity(),
}
override
fun
csjDrawAdFail
()
{
showToast
(
"加载失败,请稍候再试"
)
finish
()
}
override
fun
csjDrawAdSuccess
(
ads
:
MutableList
<
TTNativeExpressAd
>?)
{
if
(
ads
==
null
||
ads
.
isEmpty
())
{
ToastUtil
.
show
(
this
,
"请求广告为空"
)
return
}
for
(
ad
in
ads
)
{
//点击监听器必须在getAdView之前调
ad
.
setVideoAdListener
(
object
:
TTNativeExpressAd
.
ExpressVideoAdListener
{
override
fun
onVideoLoad
()
{
}
override
fun
onVideoError
(
p0
:
Int
,
p1
:
Int
)
{
// showToast("当前视频加载失败")
// finish()
}
override
fun
onVideoAdStartPlay
()
{
}
override
fun
onVideoAdPaused
()
{
}
override
fun
onVideoAdContinuePlay
()
{
}
override
fun
onProgressUpdate
(
p0
:
Long
,
p1
:
Long
)
{
}
override
fun
onVideoAdComplete
()
{
}
override
fun
onClickRetry
()
{
}
})
ad
.
setCanInterruptVideoPlay
(
true
)
ad
.
setExpressInteractionListener
(
object
:
TTNativeExpressAd
.
ExpressAdInteractionListener
{
override
fun
onAdClicked
(
p0
:
View
?,
p1
:
Int
)
{
}
override
fun
onAdShow
(
p0
:
View
?,
p1
:
Int
)
{
}
override
fun
onRenderFail
(
p0
:
View
?,
p1
:
String
?,
p2
:
Int
)
{
}
override
fun
onRenderSuccess
(
p0
:
View
?,
p1
:
Float
,
p2
:
Float
)
{
override
fun
csjDrawAdSuccess
(
ad
:
TTNativeExpressAd
)
{
// 数据源每次刷新添加3个视频加1个广告 则需+1
var
index
=
drawDatas
.
size
/
(
AD_INSERT_INDEX
+
1
)
+
mAdPage
*
AD_INSERT_INDEX
if
(
index
==
0
)
{
...
...
@@ -454,11 +407,6 @@ class DrawNativeVideoActivity : BaseActivity(),
mAdPage
++
}
})
ad
.
render
()
}
}
override
fun
getXfPageMsgSuc
(
data
:
KylBean
)
{
for
(
data
in
data
.
data
)
{
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/adapter/DrawVideoAdapter.kt
View file @
7096cfc1
...
...
@@ -14,14 +14,16 @@ import com.mints.goodmoney.ui.activitys.DrawNativeVideoActivity
import
com.mints.goodmoney.ui.adapter.listener.OnItemClickListener
import
com.mints.library.utils.GlideUtils
class
DrawVideoAdapter
(
context
:
Context
,
datas
:
List
<
DrawVideoBean
>)
:
RecyclerView
.
Adapter
<
RecyclerView
.
ViewHolder
>()
{
//class DrawVideoAdapter(context: Context, datas: List<DrawVideoBean>) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
class
DrawVideoAdapter
(
datas
:
List
<
DrawVideoBean
>)
:
RecyclerView
.
Adapter
<
RecyclerView
.
ViewHolder
>()
{
private
var
mContext
:
Context
=
context
private
var
mContext
:
Context
?=
null
private
var
mDrawVideoData
:
List
<
DrawVideoBean
>
=
datas
private
var
mOnItemClickListener
:
OnItemClickListener
?
=
null
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
RecyclerView
.
ViewHolder
{
mContext
=
parent
.
context
val
view
=
LayoutInflater
.
from
(
mContext
).
inflate
(
R
.
layout
.
item_view_pager
,
parent
,
false
)
return
ViewHolder
(
view
)
}
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/utils/ForegroundOrBackground.java
View file @
7096cfc1
...
...
@@ -103,7 +103,7 @@ public class ForegroundOrBackground implements Application.ActivityLifecycleCall
if
(
count
==
0
)
{
// LogUtil.d("ForegroundOrBackground", System.currentTimeMillis() - leaveTime + " onActivityStarted");
// 60秒后打开应用 显示开屏广告
if
(
System
.
currentTimeMillis
()
-
leaveTime
>=
3
000
)
{
if
(
System
.
currentTimeMillis
()
-
leaveTime
>=
60
000
)
{
if
(
isYlhSplash
)
{
isYlhSplash
=
false
;
...
...
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