@24jieqi/react-native-brayant-ad 0.1.10 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -40,6 +40,7 @@ public class BannerAdView extends RelativeLayout {
40
40
  super(context);
41
41
  mContext = context.getCurrentActivity();
42
42
  reactContext = context;
43
+ Log.d(TAG, "[DEBUG] BannerAdView constructor - inflating feed_view.xml");
43
44
  inflate(context, R.layout.feed_view, this);
44
45
  Utils.setupLayoutHack(this);
45
46
 
@@ -47,22 +48,23 @@ public class BannerAdView extends RelativeLayout {
47
48
  RelativeLayout.LayoutParams.MATCH_PARENT,
48
49
  RelativeLayout.LayoutParams.WRAP_CONTENT
49
50
  ));
51
+ Log.d(TAG, "[DEBUG] BannerAdView constructor completed - LayoutParams set");
50
52
  }
51
53
 
52
54
  public void setWidth(int width) {
53
- Log.d(TAG, "setCodeId = " + _codeid + ", setWidth:" + width);
55
+ Log.d(TAG, "[DEBUG] setWidth called - codeid=" + _codeid + ", width=" + width + ", current height=" + _expectedHeight);
54
56
  _expectedWidth = width;
55
57
  showAd();
56
58
  }
57
59
 
58
60
  public void setHeight(int height) {
59
- Log.d(TAG, "setCodeId = " + _codeid + ", setHeight:" + height);
61
+ Log.d(TAG, "[DEBUG] setHeight called - codeid=" + _codeid + ", height=" + height + ", current width=" + _expectedWidth);
60
62
  _expectedHeight = height;
61
63
  showAd();
62
64
  }
63
65
 
64
66
  public void setCodeId(String codeId) {
65
- Log.d(TAG, "setCodeId: " + codeId + ", _expectedWidth:" + _expectedWidth);
67
+ Log.d(TAG, "[DEBUG] setCodeId called - codeid=" + codeId + ", _expectedWidth=" + _expectedWidth + ", _expectedHeight=" + _expectedHeight);
66
68
  _codeid = codeId;
67
69
  showAd();
68
70
  }
@@ -72,7 +74,7 @@ public class BannerAdView extends RelativeLayout {
72
74
  * @param visible true: 可见,false: 不可见
73
75
  */
74
76
  public void setVisibility(boolean visible) {
75
- Log.d(TAG, "setVisibility: " + visible);
77
+ Log.d(TAG, "[DEBUG] setVisibility called - visible=" + visible + ", current codeid=" + _codeid + ", SDK initialized=" + (DyADCore.TTAdSdk != null));
76
78
  if (visible) {
77
79
  super.setVisibility(View.VISIBLE);
78
80
  // 可见时尝试加载广告
@@ -83,10 +85,11 @@ public class BannerAdView extends RelativeLayout {
83
85
  }
84
86
 
85
87
  public void showAd() {
86
- Log.d(TAG, "showAd: width:" + _expectedWidth + " height:" + _expectedHeight + " codeid:" + _codeid);
88
+ Log.d(TAG, "[DEBUG] showAd called - width=" + _expectedWidth + ", height=" + _expectedHeight + ", codeid=" + _codeid + ", SDK initialized=" + (DyADCore.TTAdSdk != null));
87
89
 
88
90
  // 显示广告
89
91
  if (_expectedWidth <= 0 || _expectedHeight <= 0 || _codeid.isEmpty()) {
92
+ Log.w(TAG, "[DEBUG] showAd aborted - width=" + _expectedWidth + " (must >0), height=" + _expectedHeight + " (must >0), codeid=" + _codeid + " (must not be empty)");
90
93
  // 广告宽高未设置或 code id 未设置,停止显示广告
91
94
  return;
92
95
  }
@@ -94,6 +97,7 @@ public class BannerAdView extends RelativeLayout {
94
97
  // 在UI线程加载广告
95
98
  runOnUiThread(
96
99
  () -> {
100
+ Log.d(TAG, "[DEBUG] showAd - calling loadBannerAd on UI thread");
97
101
  loadBannerAd();
98
102
  }
99
103
  );
@@ -101,13 +105,16 @@ public class BannerAdView extends RelativeLayout {
101
105
 
102
106
  // 显示Banner广告
103
107
  public void loadBannerAd() {
108
+ Log.d(TAG, "[DEBUG] loadBannerAd called - SDK initialized=" + (DyADCore.TTAdSdk != null) + ", codeid=" + _codeid);
109
+
104
110
  if (DyADCore.TTAdSdk == null) {
105
- Log.e(TAG, "TTAdSdk 还没初始化");
111
+ Log.e(TAG, "[DEBUG] loadBannerAd aborted - TTAdSdk not initialized yet");
106
112
  return;
107
113
  }
108
114
 
109
115
  // 如果已有广告,先销毁
110
116
  if (mBannerAd != null) {
117
+ Log.d(TAG, "[DEBUG] loadBannerAd - destroying previous ad");
111
118
  mBannerAd.destroy();
112
119
  }
113
120
 
@@ -120,6 +127,8 @@ public class BannerAdView extends RelativeLayout {
120
127
  .setExpressViewAcceptedSize(_expectedWidth, _expectedHeight) // 期望模板广告view的size,单位dp
121
128
  .build();
122
129
 
130
+ Log.d(TAG, "[DEBUG] loadBannerAd - requesting ad with AdSlot: codeid=" + _codeid + ", width=" + _expectedWidth + ", height=" + _expectedHeight);
131
+
123
132
  // 请求广告
124
133
  final BannerAdView _this = this;
125
134
  DyADCore.TTAdSdk.loadBannerExpressAd(
@@ -128,6 +137,7 @@ public class BannerAdView extends RelativeLayout {
128
137
 
129
138
  @Override
130
139
  public void onError(int code, String message) {
140
+ Log.e(TAG, "[DEBUG] onError - code=" + code + ", message=" + message);
131
141
  message =
132
142
  "Banner ad error: " + code + ", " + message;
133
143
  Log.e(TAG, message);
@@ -136,13 +146,15 @@ public class BannerAdView extends RelativeLayout {
136
146
 
137
147
  @Override
138
148
  public void onNativeExpressAdLoad(java.util.List<TTNativeExpressAd> ads) {
139
- Log.d(TAG, "onNativeExpressAdLoad: Banner ad loaded!");
149
+ Log.d(TAG, "[DEBUG] onNativeExpressAdLoad - ads received=" + (ads != null ? ads.size() : "null"));
140
150
  if (ads == null || ads.isEmpty()) {
151
+ Log.e(TAG, "[DEBUG] onNativeExpressAdLoad - ads is null or empty");
141
152
  onAdError("Banner ad loaded but no content");
142
153
  return;
143
154
  }
144
155
 
145
156
  mBannerAd = ads.get(0);
157
+ Log.d(TAG, "[DEBUG] onNativeExpressAdLoad - calling _showBannerAd");
146
158
  _showBannerAd(mBannerAd);
147
159
  }
148
160
  }
@@ -185,16 +197,38 @@ public class BannerAdView extends RelativeLayout {
185
197
 
186
198
  @Override
187
199
  public void onRenderSuccess(View view, float width, float height) {
188
- Log.d(TAG, "Banner onRenderSuccess: " + width + ", " + height);
200
+ Log.d(TAG, "[DEBUG] onRenderSuccess - adView width=" + width + ", adView height=" + height);
201
+
189
202
  RelativeLayout mExpressContainer = findViewById(R.id.feed_container);
190
- if (mExpressContainer != null) {
191
- mExpressContainer.removeAllViews();
192
- RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
193
- RelativeLayout.LayoutParams.MATCH_PARENT,
194
- RelativeLayout.LayoutParams.WRAP_CONTENT
195
- );
196
- mExpressContainer.addView(view, params);
203
+
204
+ if (mExpressContainer == null) {
205
+ Log.e(TAG, "[DEBUG] onRenderSuccess - feed_container is null!");
206
+ onAdError("feed_container not found");
207
+ return;
197
208
  }
209
+
210
+ Log.d(TAG, "[DEBUG] onRenderSuccess - feed_container found, removing old views");
211
+ mExpressContainer.removeAllViews();
212
+
213
+ RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
214
+ RelativeLayout.LayoutParams.MATCH_PARENT,
215
+ RelativeLayout.LayoutParams.WRAP_CONTENT
216
+ );
217
+ mExpressContainer.addView(view, params);
218
+
219
+ Log.d(TAG, "[DEBUG] onRenderSuccess - adView added to feed_container");
220
+ Log.d(TAG, "[DEBUG] onRenderSuccess - BannerAdView size: width=" + BannerAdView.this.getWidth() + ", height=" + BannerAdView.this.getHeight());
221
+ Log.d(TAG, "[DEBUG] onRenderSuccess - feed_container size: width=" + mExpressContainer.getWidth() + ", height=" + mExpressContainer.getHeight());
222
+
223
+ view.setVisibility(View.VISIBLE);
224
+ mExpressContainer.setVisibility(View.VISIBLE);
225
+ BannerAdView.this.setVisibility(View.VISIBLE);
226
+
227
+ mExpressContainer.requestLayout();
228
+ BannerAdView.this.requestLayout();
229
+
230
+ Log.d(TAG, "[DEBUG] onRenderSuccess - layout requested, sending onAdRenderSuccess event");
231
+
198
232
  onAdRenderSuccess((int) width, (int) height);
199
233
  }
200
234
  }
@@ -2,8 +2,8 @@
2
2
  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
3
  android:id="@+id/feed_container"
4
4
  android:layout_width="match_parent"
5
- android:layout_height="wrap_content"
6
- android:background="@drawable/shape_corner"
5
+ android:layout_height="280dp"
6
+ android:background="#FFFFFF"
7
7
  android:orientation="vertical"
8
8
  android:layout_gravity="center"
9
9
  >
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@24jieqi/react-native-brayant-ad",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "国内广告联盟sdk封装",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",