Commit 4623fbe9 authored by wanglei's avatar wanglei

...

parent 521bcfc3
......@@ -21,13 +21,14 @@ object AdMaxEvent {
obj.put(
"creativeId",
ad?.creativeId
)
obj.put("req_id", reqId)
obj.put("status", if (ad == null) "0" else "1")
obj.put("networkname", ad?.networkName)
obj.put("placement", ad?.placement)
obj.put("networkplacement", ad?.networkPlacement)
obj.put("requestLatencyMillis", ad?.requestLatencyMillis)
obj.put("latency", ad?.requestLatencyMillis)
obj.put("valueMicros", ad?.revenue?.times(1000000))
if (error == null) {
obj.put("status", "1")
......@@ -50,7 +51,7 @@ object AdMaxEvent {
obj.put("networkname", ad?.networkName)
obj.put("placement", ad?.placement)
obj.put("networkplacement", ad?.networkPlacement)
obj.put("requestLatencyMillis", ad?.requestLatencyMillis)
obj.put("latency", ad?.requestLatencyMillis)
obj.put("valueMicros", ad?.revenue)
if(!adUnit.equals("NativeAd")){
EventUtils.event("ad_click", ext = obj)
......@@ -71,7 +72,7 @@ object AdMaxEvent {
obj.put("networkname", ad?.networkName)
obj.put("placement", ad?.placement)
obj.put("networkplacement", ad?.networkPlacement)
obj.put("requestLatencyMillis", ad?.requestLatencyMillis)
obj.put("latency", ad?.requestLatencyMillis)
obj.put("valueMicros", ad?.revenue)
EventUtils.event("ad_show", ext = obj)
......
......@@ -52,11 +52,12 @@ object AdMaxNativeUtils {
}
override fun onNativeAdClicked(p0: MaxAd) {
LogEx.logDebug(TAG, "onNativeAdClicked")
super.onNativeAdClicked(p0)
AdDisplayUtils.getInstance().incrementAdClickCount()
nativeAd?.let { AdMaxEvent.clickAd(it, "nativeAd") }
AdmobCommonUtils.isMultiClick(nativeAd)
AdMaxEvent.clickAd(p0,"NativeAd")
AdMaxEvent.clickAd(p0, "NativeAd")
}
override fun onNativeAdExpired(p0: MaxAd) {
......@@ -78,15 +79,27 @@ object AdMaxNativeUtils {
}
private fun createNativeAdView(context: Context): MaxNativeAdView {
val binder: MaxNativeAdViewBinder = MaxNativeAdViewBinder.Builder(R.layout.layout_max_native_custom)
.setTitleTextViewId(R.id.title_text_view)
.setBodyTextViewId(R.id.body_text_view)
.setAdvertiserTextViewId(R.id.advertiser_text_view)
.setIconImageViewId(R.id.icon_image_view)
.setMediaContentViewGroupId(R.id.media_view_container)
.setOptionsContentViewGroupId(R.id.options_view)
.setStarRatingContentViewGroupId(R.id.star_rating_view)
.setCallToActionButtonId(R.id.cta_button)
// val binder: MaxNativeAdViewBinder = MaxNativeAdViewBinder.Builder(R.layout.layout_max_native_custom)
// .setTitleTextViewId(R.id.title_text_view)
// .setBodyTextViewId(R.id.body_text_view)
// .setAdvertiserTextViewId(R.id.advertiser_text_view)
// .setIconImageViewId(R.id.icon_image_view)
// .setMediaContentViewGroupId(R.id.media_view_container)
// .setOptionsContentViewGroupId(R.id.options_view)
// .setStarRatingContentViewGroupId(R.id.star_rating_view)
// .setCallToActionButtonId(R.id.cta_button)
// .build()
// return MaxNativeAdView(binder, context)
R.layout.layout_max_native_custom
val binder: MaxNativeAdViewBinder = MaxNativeAdViewBinder.Builder(R.layout.layout_max_native_small)
.setTitleTextViewId(R.id.ad_headline)
.setBodyTextViewId(R.id.ad_body)
// .setAdvertiserTextViewId(R.id.advertiser_text_view)
.setIconImageViewId(R.id.ad_app_icon)
.setMediaContentViewGroupId(R.id.ad_media)
// .setOptionsContentViewGroupId(R.id.options_view)
// .setStarRatingContentViewGroupId(R.id.star_rating_view)
.setCallToActionButtonId(R.id.ad_call_to_action)
.build()
return MaxNativeAdView(binder, context)
}
......@@ -112,6 +125,7 @@ object AdMaxNativeUtils {
} else {
//展示广告
val adView = createNativeAdView(activity)
parent.removeAllViews()
parent.isVisible = true
nativeAdLoader.render(adView, nativeAd)
parent.addView(adView)
......
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#D9D9D9"
android:baselineAligned="false"
android:minHeight="40dp"
android:orientation="horizontal"
android:paddingHorizontal="5dp"
android:paddingVertical="2dp"
tools:ignore="UselessParent">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical">
<FrameLayout
android:id="@+id/ad_media"
android:layout_width="80dp"
android:layout_height="60dp"
android:layout_gravity="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:background="@color/black"
android:padding="2dp"
android:text="Ad"
android:textColor="@color/white"
android:textSize="8sp"
tools:ignore="HardcodedText,SmallSp" />
</FrameLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginHorizontal="5dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/ad_headline"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:includeFontPadding="false"
android:maxLines="2"
android:textColor="@color/black"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="@+id/ad_body"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="2"
android:textColor="@color/black"
android:textSize="14sp"
tools:ignore="SmallSp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical">
<ImageView
android:id="@+id/ad_app_icon"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center_horizontal"
tools:ignore="ContentDescription" />
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/ad_call_to_action"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="center_vertical"
android:layout_marginHorizontal="8dp"
android:layout_marginVertical="5dp"
android:background="@drawable/bg_355bea_10"
android:gravity="center"
android:textColor="@color/white"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment