-
Notifications
You must be signed in to change notification settings - Fork 17
/
TestActivity.kt
119 lines (103 loc) · 3.29 KB
/
TestActivity.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package com.tjhello.demo.adeasy
import android.os.Bundle
import android.view.ViewGroup
import android.widget.Toast
import com.tjhello.adeasy.base.info.ADInfo
import kotlinx.android.synthetic.main.test_activity_layout.*
/**
* 作者:天镜baobao
* 时间:2019/12/4 17:51
* 说明:允许使用,但请遵循Apache License 2.0
* 使用:
* Copyright 2019/12/4 天镜baobao
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class TestActivity : AppActivity() {
override fun onInitValue(savedInstanceState: Bundle?) {
adEasy.isAutoShowBanner(true)
}
override fun onInitView() {
setContentView(R.layout.test_activity_layout)
refreshBtVideo()
refreshBtIns()
refreshBtInsVideo()
refreshBtBanner()
btShowVideo.setOnClickListener {
adEasy.showVideo{adInfo, isReward ->
refreshBtVideo()
Toast.makeText(this,"Close Video :$isReward", Toast.LENGTH_LONG).show()
}
}
btShowInterstitialVideo.setOnClickListener {
adEasy.showInterstitialVideo {
refreshBtIns()
Toast.makeText(this,"Close InterstitialVideo",Toast.LENGTH_LONG).show()
}
}
btShowInterstitial.setOnClickListener {
adEasy.showInterstitial {
refreshBtInsVideo()
Toast.makeText(this,"Close Interstitial",Toast.LENGTH_LONG).show()
}
}
btShowBanner.setOnClickListener {
refreshBtBanner()
adEasy.showBanner()
}
btHideBanner.setOnClickListener {
adEasy.hideBanner()
}
}
override fun onLoadData() {
}
private fun refreshBtVideo(){
if(adEasy.hasVideo()){
btShowVideo.alpha = 1f
}else{
btShowVideo.alpha = 0.5f
}
}
private fun refreshBtIns(){
if(adEasy.hasInterstitial()){
btShowInterstitial.alpha = 1f
}else{
btShowInterstitial.alpha = 0.5f
}
}
private fun refreshBtInsVideo(){
if(adEasy.hasInterstitialVideo()){
btShowInterstitialVideo.alpha = 1f
}else{
btShowInterstitialVideo.alpha = 0.5f
}
}
private fun refreshBtBanner(){
if(adEasy.hasBanner()){
btShowBanner.alpha = 1f
}else{
btShowBanner.alpha = 0.5f
}
}
override fun onAdLoad(adInfo: ADInfo, isSelf: Boolean) {
when(adInfo.type){
ADInfo.TYPE_VIDEO->refreshBtVideo()
ADInfo.TYPE_INTERSTITIAL->refreshBtIns()
ADInfo.TYPE_INTERSTITIAL_VIDEO->refreshBtInsVideo()
ADInfo.TYPE_BANNER->refreshBtBanner()
}
}
override fun onCreateBanner(): ViewGroup? {
return bannerLayout
}
}