ResultInterstitialActivity.java
4.6 KB
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
package com.lotus.town.clean;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.ad.lib.AdInfo;
import com.ad.lib.AdManager;
import com.ad.lib.AdPlacement;
import com.ad.lib.IAdCallback;
import com.ad.lib.RequestInfo;
import com.bumptech.glide.Glide;
import com.bytedance.sdk.openadsdk.AdSlot;
import com.umeng.analytics.MobclickAgent;
import java.util.ArrayList;
import java.util.List;
public class ResultInterstitialActivity extends Activity implements View.OnClickListener {
ImageView mAdFrom = null;
ImageView mAdInfoIcon = null;
TextView mAdInfoName = null;
TextView mAdInfoSubName = null;
ImageView mAdInfoImage = null;
Button mAdInfoBottom = null;
RelativeLayout AdLayout = null;
ImageView close = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(com.ad.lib.R.layout.activity_interstitial);
initView();
initInfo();
initListener();
}
@Override
protected void onResume() {
super.onResume();
MobclickAgent.onResume(this);
}
@Override
protected void onPause() {
super.onPause();
MobclickAgent.onPause(this);
}
@Override
protected void onDestroy() {
super.onDestroy();
}
private void initListener() {
close.setOnClickListener(this);
}
private void initInfo() {
int adType = 0;
RequestInfo info = new RequestInfo();
info.setId(AdPlacement.getResultInsertPageId());
info.setWidth(1080);
info.setHeight(1920);
info.setType(AdSlot.TYPE_INTERACTION_AD);
AdManager.getInstance().getAdController(this,adType).loadNativeAd(info, new IAdCallback() {
@Override
public void onADLoaded(AdInfo info) {
InitAd(info);
}
@Override
public void onADError() {
finish();
}
@Override
public void onClicked() {
finish();
}
});
}
private void InitAd(final AdInfo ad){
int adType = 0;
if(ad.getAdIcon() != null)
mAdFrom.setImageBitmap(ad.getAdIcon());
Glide.with(this)
.load(ad.getIconUrl())
.into(mAdInfoIcon);
if (ad.getImageList() != null && !ad.getImageList().isEmpty()) {
Glide.with(this)
.load(ad.getImageList().get(0))
.into(mAdInfoImage);
}
mAdInfoName.setText(ad.getTitle());
mAdInfoSubName.setText(ad.getSubtitle());
mAdInfoBottom.setText(ad.getButtonLabel());
if(adType == 0){
List<View> clickViewList = new ArrayList<>();
clickViewList.add(AdLayout);
clickViewList.add(mAdInfoBottom);
ad.getReporter().impress(AdLayout,clickViewList,"i_s_a_d","i_s_c");
} else if(adType == 1 || adType == 2){
ad.getReporter().impress(AdLayout,"i_s_a_d");
ad.getReporter().impress(mAdInfoBottom,"i_s_a_d");
AdLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ad.getReporter().click(view,"i_s_c"); // 点击接口
}
});
mAdInfoBottom.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ad.getReporter().click(view,"i_s_c"); // 点击接口
}
});
}
}
private void initView() {
AdLayout = (RelativeLayout) findViewById(com.ad.lib.R.id.ad_layout1);
close = findViewById(com.ad.lib.R.id.close);
// mAdLogo = findViewById(R.id.ad_logo);
mAdFrom = findViewById(com.ad.lib.R.id.ad_from);
mAdInfoIcon = findViewById(com.ad.lib.R.id.ad_info_icon);
mAdInfoName = findViewById(com.ad.lib.R.id.ad_info_name);
mAdInfoSubName = findViewById(com.ad.lib.R.id.ad_info_sub_name);
mAdInfoImage = findViewById(com.ad.lib.R.id.ad_info_image);
mAdInfoBottom = findViewById(com.ad.lib.R.id.ad_info_buttom);
}
@Override
public void onBackPressed() {
// setResult(0);
// finish();
}
@Override
public void onClick(View v) {
if(v.getId() == com.ad.lib.R.id.close){
setResult(0);
finish();
}
}
}