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
de4562fd
Commit
de4562fd
authored
Aug 04, 2023
by
mengcuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码优化
parent
e4fdc1e3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
164 additions
and
1 deletion
+164
-1
AndroidManifest.xml
video/app/src/main/AndroidManifest.xml
+4
-0
SplashForeAdActivity.kt
.../duben/miaoquplaylet/ui/activitys/SplashForeAdActivity.kt
+117
-0
ForegroundOrBackground.java
...com/duben/miaoquplaylet/utils/ForegroundOrBackground.java
+34
-1
activity_gromore_fore.xml
video/app/src/main/res/layout/activity_gromore_fore.xml
+9
-0
No files found.
video/app/src/main/AndroidManifest.xml
View file @
de4562fd
...
...
@@ -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/duben/miaoquplaylet/ui/activitys/SplashForeAdActivity.kt
0 → 100644
View file @
de4562fd
package
com.duben.miaoquplaylet.ui.activitys
import
android.os.Handler
import
android.os.Looper
import
android.view.KeyEvent
import
com.duben.miaoquplaylet.R
import
com.duben.miaoquplaylet.ad.AdStatusListener
import
com.duben.miaoquplaylet.ad.splash.SplashManager
import
com.duben.miaoquplaylet.ui.activitys.base.BaseActivity
import
com.duben.miaoquplaylet.ui.widgets.countdowntimer.CountDownTimerSupport
import
com.duben.miaoquplaylet.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/duben/miaoquplaylet/utils/ForegroundOrBackground.java
View file @
de4562fd
...
...
@@ -6,10 +6,12 @@ import android.content.Intent;
import
android.os.Bundle
;
import
android.text.TextUtils
;
import
com.duben.miaoquplaylet.ad.splash.SplashManager
;
import
com.duben.miaoquplaylet.common.AppConfig
;
import
com.duben.miaoquplaylet.manager.ActivityPageManager
;
import
com.duben.miaoquplaylet.manager.TrackManager
;
import
com.duben.miaoquplaylet.mvp.presenters.VersionUpdatePresenter
;
import
com.duben.miaoquplaylet.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,41 @@ 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
)
{
count
=
0
;
}
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 @
de4562fd
<?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