Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
android_vedio
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_vedio
Commits
b69136af
Commit
b69136af
authored
Aug 04, 2023
by
mengcuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加后台返回应用超10秒 弹出开屏广告
parent
94cabbbf
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
166 additions
and
7 deletions
+166
-7
build.gradle
video/app/build.gradle
+2
-2
AndroidManifest.xml
video/app/src/main/AndroidManifest.xml
+4
-0
SplashManager.kt
.../main/java/com/mints/helivideo/ad/splash/SplashManager.kt
+0
-3
SplashAdActivity.kt
...java/com/mints/helivideo/ui/activitys/SplashAdActivity.kt
+0
-1
SplashForeAdActivity.kt
.../com/mints/helivideo/ui/activitys/SplashForeAdActivity.kt
+117
-0
MovieFragment.kt
...ain/java/com/mints/helivideo/ui/fragment/MovieFragment.kt
+3
-0
ForegroundOrBackground.java
...ava/com/mints/helivideo/utils/ForegroundOrBackground.java
+31
-1
activity_gromore_fore.xml
video/app/src/main/res/layout/activity_gromore_fore.xml
+9
-0
No files found.
video/app/build.gradle
View file @
b69136af
...
...
@@ -12,8 +12,8 @@ android {
applicationId
"com.mints.helivideo"
minSdkVersion
rootProject
.
ext
.
androidMinSdkVersion
targetSdkVersion
rootProject
.
ext
.
androidTargetSdkVersion
versionCode
5
versionName
"1.0.
4
"
versionCode
6
versionName
"1.0.
5
"
flavorDimensions
"default"
// dex突破65535的限制
...
...
video/app/src/main/AndroidManifest.xml
View file @
b69136af
...
...
@@ -93,6 +93,10 @@
android:name=
".ui.activitys.SplashAdActivity"
android:exported=
"false"
android:screenOrientation=
"portrait"
/>
<activity
android:name=
".ui.activitys.SplashForeAdActivity"
android:exported=
"false"
android:screenOrientation=
"portrait"
/>
<activity
android:name=
".ui.activitys.MobileLoginActivity"
android:configChanges=
"orientation|screenSize|keyboardHidden"
...
...
video/app/src/main/java/com/mints/helivideo/ad/splash/SplashManager.kt
View file @
b69136af
...
...
@@ -180,7 +180,4 @@ object SplashManager {
*/
fun
getAdStatus
()
=
isShowAd
fun
onDestroy
()
{
isLoadSuccess
=
0
}
}
\ No newline at end of file
video/app/src/main/java/com/mints/helivideo/ui/activitys/SplashAdActivity.kt
View file @
b69136af
...
...
@@ -83,7 +83,6 @@ class SplashAdActivity : BaseActivity() {
override
fun
onDestroy
()
{
super
.
onDestroy
()
onDestroyTimer
()
SplashManager
.
onDestroy
()
}
override
fun
onKeyDown
(
keyCode
:
Int
,
event
:
KeyEvent
?):
Boolean
{
...
...
video/app/src/main/java/com/mints/helivideo/ui/activitys/SplashForeAdActivity.kt
0 → 100644
View file @
b69136af
package
com.mints.helivideo.ui.activitys
import
android.os.Handler
import
android.os.Looper
import
android.view.KeyEvent
import
com.mints.helivideo.R
import
com.mints.helivideo.ad.AdStatusListener
import
com.mints.helivideo.ad.splash.SplashManager
import
com.mints.helivideo.ui.activitys.base.BaseActivity
import
com.mints.helivideo.ui.widgets.countdowntimer.CountDownTimerSupport
import
com.mints.helivideo.ui.widgets.countdowntimer.OnCountDownTimerListener
import
kotlinx.android.synthetic.main.activity_gromore.*
/**
* 描述:gromore后台返回广告
* 作者:孟崔广
* 时间:2023/8/04 13:52
*/
class
SplashForeAdActivity
:
BaseActivity
()
{
//是否强制跳转到主页面
private
var
onPaused
=
false
var
mTimer
:
CountDownTimerSupport
?
=
null
private
val
mMainHandler
=
Handler
(
Looper
.
getMainLooper
())
override
fun
getContentViewLayoutID
()
=
R
.
layout
.
activity_gromore_fore
override
fun
isApplyKitKatTranslucency
()
=
false
override
fun
initViewsAndEvents
()
{
var
timeout
=
200L
mMainHandler
.
postDelayed
({
SplashManager
.
showAd
(
this
@SplashForeAdActivity
,
fl_gromore_root
,
object
:
AdStatusListener
{
override
fun
adSuccess
()
{
}
override
fun
adFail
()
{
goToMainActivity
()
}
override
fun
adClose
(
vo
:
HashMap
<
String
,
Any
>?)
{
goToMainActivity
()
}
})
// 防止广告展示异常,界面卡住
startTime
()
},
timeout
)
}
override
fun
onResume
()
{
super
.
onResume
()
//判断是否该跳转到主页面
if
(
onPaused
)
{
goToMainActivity
()
}
}
override
fun
onPause
()
{
super
.
onPause
()
onPaused
=
true
}
override
fun
onDestroy
()
{
super
.
onDestroy
()
onDestroyTimer
()
}
override
fun
onKeyDown
(
keyCode
:
Int
,
event
:
KeyEvent
?):
Boolean
{
return
if
(
keyCode
==
KeyEvent
.
KEYCODE_BACK
)
{
true
}
else
super
.
onKeyDown
(
keyCode
,
event
)
}
/**
* 跳转到主页面
*/
private
fun
goToMainActivity
()
{
finish
()
}
/**
* 防止广告展示异常,界面卡住
*/
private
fun
startTime
()
{
onDestroyTimer
()
mTimer
=
CountDownTimerSupport
(
3000L
,
1000L
)
mTimer
?.
setOnCountDownTimerListener
(
object
:
OnCountDownTimerListener
{
override
fun
onTick
(
millisUntilFinished
:
Long
)
{
}
override
fun
onFinish
()
{
if
(!
isFinishing
)
{
// 3秒广告都没有展示 则进入首页
if
(!
SplashManager
.
getAdStatus
())
{
onDestroyTimer
()
goToMainActivity
()
}
}
}
})
mTimer
?.
start
()
}
private
fun
onDestroyTimer
()
{
mTimer
?.
stop
()
mTimer
=
null
}
}
video/app/src/main/java/com/mints/helivideo/ui/fragment/MovieFragment.kt
View file @
b69136af
...
...
@@ -16,6 +16,7 @@ import com.mints.helivideo.ui.fragment.base.LazyLoadBaseFragment
import
com.scwang.smartrefresh.layout.api.RefreshLayout
import
com.scwang.smartrefresh.layout.listener.OnLoadMoreListener
import
com.mints.helivideo.common.AppConfig
import
com.mints.helivideo.manager.UserManager
import
com.mints.helivideo.ui.adapter.NewHotStyle2Adapter
import
com.mints.helivideo.ui.widgets.MyGridLayoutManager
import
com.mints.helivideo.utils.LogUtil
...
...
@@ -145,6 +146,8 @@ class MovieFragment : LazyLoadBaseFragment(), PicContentView, OnLoadMoreListener
}
private
fun
loadAd
()
{
if
(
UserManager
.
getInstance
().
vipFlag
)
return
MainExpressManager
.
instance
.
loadAd
(
object
:
ExpressAdCallback
{
override
fun
loadSuccess
(
adView
:
FrameLayout
?)
{
...
...
video/app/src/main/java/com/mints/helivideo/utils/ForegroundOrBackground.java
View file @
b69136af
...
...
@@ -6,10 +6,12 @@ import android.content.Intent;
import
android.os.Bundle
;
import
android.text.TextUtils
;
import
com.mints.helivideo.ad.splash.SplashManager
;
import
com.mints.helivideo.common.AppConfig
;
import
com.mints.helivideo.manager.ActivityPageManager
;
import
com.mints.helivideo.manager.TrackManager
;
import
com.mints.helivideo.mvp.presenters.VersionUpdatePresenter
;
import
com.mints.helivideo.ui.activitys.SplashForeAdActivity
;
import
java.lang.ref.WeakReference
;
...
...
@@ -19,7 +21,8 @@ import java.lang.ref.WeakReference;
*/
public
class
ForegroundOrBackground
implements
Application
.
ActivityLifecycleCallbacks
{
private
static
ForegroundOrBackground
instance
;
public
int
count
=
0
;
private
int
count
=
0
;
private
long
activityStoppedTime
=
0
;
//获取当前最上层的activity
private
static
WeakReference
<
Activity
>
app_activity
;
...
...
@@ -66,11 +69,38 @@ public class ForegroundOrBackground implements Application.ActivityLifecycleCall
@Override
public
void
onActivityStarted
(
Activity
activity
)
{
if
(
activity
==
null
)
return
;
String
simpleName
=
activity
.
getClass
().
getSimpleName
();
if
(
TextUtils
.
equals
(
simpleName
,
"SplashActivity"
)
||
TextUtils
.
equals
(
simpleName
,
"SplashAdActivity"
)
||
TextUtils
.
equals
(
simpleName
,
"SplashForeAdActivity"
)
||
TextUtils
.
equals
(
simpleName
,
"VipActivity"
))
{
count
++;
return
;
}
if
(
count
==
0
)
{
long
currentTimeMillis
=
System
.
currentTimeMillis
();
long
diff
=
currentTimeMillis
-
activityStoppedTime
;
long
diffInSeconds
=
diff
/
1000
;
System
.
out
.
println
(
"mcg -->>>>>:: diffInSeconds="
+
diffInSeconds
+
" adSuccessStatus="
+
SplashManager
.
INSTANCE
.
isSuccessStatus
());
if
(
diffInSeconds
>=
10
&&
SplashManager
.
INSTANCE
.
isSuccessStatus
())
{
activity
.
startActivity
(
new
Intent
(
activity
,
SplashForeAdActivity
.
class
));
}
}
count
++;
}
@Override
public
void
onActivityStopped
(
Activity
activity
)
{
count
--;
if
(
count
==
0
)
{
System
.
out
.
println
(
"mcg -->>>>>:: onActivityStopped"
);
activityStoppedTime
=
System
.
currentTimeMillis
();
SplashManager
.
INSTANCE
.
preLoadAd
(
activity
);
}
}
@Override
...
...
video/app/src/main/res/layout/activity_gromore_fore.xml
0 → 100644
View file @
b69136af
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/fl_gromore_root"
android:layout_width=
"match_parent"
android:background=
"@color/graya"
android:layout_height=
"match_parent"
>
</FrameLayout>
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