feat(ad): add data to onReceiveAdEvent (#3378)

* feat(ad): add adData to onReceiveAdEvent
* fix: remove adData from response if empty
* fix: add getAdData to stub file
* chore: fix build without IMA
* fix: rename `adData` to `data`

---------

Co-authored-by: olivier <olivier.bouillet@ifeelsmart.com>
This commit is contained in:
Axel Vencatareddy
2023-11-27 21:43:30 +01:00
committed by GitHub
parent de4159f0c2
commit d05231d76b
9 changed files with 50 additions and 15 deletions

View File

@@ -18,6 +18,7 @@ import java.io.StringWriter;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Map;
public class VideoEventEmitter {
@@ -413,6 +414,19 @@ public class VideoEventEmitter {
receiveEvent(EVENT_AUDIO_BECOMING_NOISY, null);
}
public void receiveAdEvent(String event, Map<String, String> data) {
WritableMap map = Arguments.createMap();
map.putString("event", event);
WritableMap dataMap = Arguments.createMap();
for (Map.Entry<String, String> entry : data.entrySet()) {
dataMap.putString(entry.getKey(), entry.getValue());
}
map.putMap("data", dataMap);
receiveEvent(EVENT_ON_RECEIVE_AD_EVENT, map);
}
public void receiveAdEvent(String event) {
WritableMap map = Arguments.createMap();
map.putString("event", event);

View File

@@ -2100,6 +2100,10 @@ public class ReactExoplayerView extends FrameLayout implements
@Override
public void onAdEvent(AdEvent adEvent) {
eventEmitter.receiveAdEvent(adEvent.getType().name());
if (adEvent.getAdData() != null) {
eventEmitter.receiveAdEvent(adEvent.getType().name(), adEvent.getAdData());
} else {
eventEmitter.receiveAdEvent(adEvent.getType().name());
}
}
}

View File

@@ -2,8 +2,11 @@ package com.google.ads.interactivemedia.v3.api;
import androidx.annotation.InspectableProperty;
import java.util.Map;
public abstract class AdEvent {
public abstract InspectableProperty getType();
public abstract Map<String, String> getAdData();
public interface AdEventListener {
public void onAdEvent(AdEvent adEvent);