diff --git a/app/src/main/java/com/d4rk/androidtutorials/java/ads/managers/NativeAdLoader.java b/app/src/main/java/com/d4rk/androidtutorials/java/ads/managers/NativeAdLoader.java
index 808856d6..177435a6 100644
--- a/app/src/main/java/com/d4rk/androidtutorials/java/ads/managers/NativeAdLoader.java
+++ b/app/src/main/java/com/d4rk/androidtutorials/java/ads/managers/NativeAdLoader.java
@@ -77,7 +77,9 @@ private static void populateNativeAdView(@NonNull NativeAd nativeAd, @NonNull Na
ImageView iconView = adView.findViewById(R.id.ad_app_icon);
TextView attributionView = adView.findViewById(R.id.ad_attribution);
- adView.setMediaView(mediaView);
+ if (mediaView != null) {
+ adView.setMediaView(mediaView);
+ }
adView.setHeadlineView(headlineView);
adView.setBodyView(bodyView);
adView.setCallToActionView(callToActionView);
diff --git a/app/src/main/res/layout/ad_lesson_code.xml b/app/src/main/res/layout/ad_lesson_code.xml
new file mode 100644
index 00000000..9946d104
--- /dev/null
+++ b/app/src/main/res/layout/ad_lesson_code.xml
@@ -0,0 +1,67 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/fragment_buttons_layout.xml b/app/src/main/res/layout/fragment_buttons_layout.xml
index 8332681c..ae4cff75 100644
--- a/app/src/main/res/layout/fragment_buttons_layout.xml
+++ b/app/src/main/res/layout/fragment_buttons_layout.xml
@@ -5,11 +5,13 @@
android:layout_height="match_parent">
@@ -266,6 +268,12 @@
android:id="@+id/ad_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_margin="24dp"
- app:layout_constraintBottom_toBottomOf="parent" />
+ android:layout_marginStart="24dp"
+ android:layout_marginTop="0dp"
+ android:layout_marginEnd="24dp"
+ android:layout_marginBottom="24dp"
+ app:nativeAdLayout="@layout/ad_lesson_code"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent" />
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_clock_layout.xml b/app/src/main/res/layout/fragment_clock_layout.xml
index 3ddb2e8e..ea22bd73 100644
--- a/app/src/main/res/layout/fragment_clock_layout.xml
+++ b/app/src/main/res/layout/fragment_clock_layout.xml
@@ -5,11 +5,14 @@
android:layout_height="match_parent">
@@ -73,6 +76,12 @@
android:id="@+id/ad_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_margin="24dp"
- app:layout_constraintBottom_toBottomOf="parent" />
+ android:layout_marginStart="24dp"
+ android:layout_marginTop="0dp"
+ android:layout_marginEnd="24dp"
+ android:layout_marginBottom="24dp"
+ app:nativeAdLayout="@layout/ad_lesson_code"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent" />
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_code.xml b/app/src/main/res/layout/fragment_code.xml
index 2427f2e3..2576feca 100644
--- a/app/src/main/res/layout/fragment_code.xml
+++ b/app/src/main/res/layout/fragment_code.xml
@@ -5,11 +5,13 @@
android:layout_height="match_parent">
@@ -30,7 +32,11 @@
android:id="@+id/ad_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_margin="24dp"
+ android:layout_marginStart="24dp"
+ android:layout_marginTop="0dp"
+ android:layout_marginEnd="24dp"
+ android:layout_marginBottom="24dp"
+ app:nativeAdLayout="@layout/ad_lesson_code"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
diff --git a/app/src/main/res/layout/fragment_layout.xml b/app/src/main/res/layout/fragment_layout.xml
index 2427f2e3..2576feca 100644
--- a/app/src/main/res/layout/fragment_layout.xml
+++ b/app/src/main/res/layout/fragment_layout.xml
@@ -5,11 +5,13 @@
android:layout_height="match_parent">
@@ -30,7 +32,11 @@
android:id="@+id/ad_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_margin="24dp"
+ android:layout_marginStart="24dp"
+ android:layout_marginTop="0dp"
+ android:layout_marginEnd="24dp"
+ android:layout_marginBottom="24dp"
+ app:nativeAdLayout="@layout/ad_lesson_code"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
diff --git a/app/src/main/res/layout/fragment_linear_layout_layout.xml b/app/src/main/res/layout/fragment_linear_layout_layout.xml
index 28714acd..7408925b 100644
--- a/app/src/main/res/layout/fragment_linear_layout_layout.xml
+++ b/app/src/main/res/layout/fragment_linear_layout_layout.xml
@@ -5,11 +5,13 @@
android:layout_height="match_parent">
@@ -56,6 +58,12 @@
android:id="@+id/ad_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_margin="24dp"
- app:layout_constraintBottom_toBottomOf="parent" />
+ android:layout_marginStart="24dp"
+ android:layout_marginTop="0dp"
+ android:layout_marginEnd="24dp"
+ android:layout_marginBottom="24dp"
+ app:nativeAdLayout="@layout/ad_lesson_code"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent" />
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_no_code.xml b/app/src/main/res/layout/fragment_no_code.xml
index 0ce2b350..1ca31f1d 100644
--- a/app/src/main/res/layout/fragment_no_code.xml
+++ b/app/src/main/res/layout/fragment_no_code.xml
@@ -5,11 +5,13 @@
android:layout_height="match_parent">
@@ -27,6 +29,12 @@
android:id="@+id/ad_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_margin="24dp"
- app:layout_constraintBottom_toBottomOf="parent" />
+ android:layout_marginStart="24dp"
+ android:layout_marginTop="0dp"
+ android:layout_marginEnd="24dp"
+ android:layout_marginBottom="24dp"
+ app:nativeAdLayout="@layout/ad_lesson_code"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent" />
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_same_code.xml b/app/src/main/res/layout/fragment_same_code.xml
index 6fc2e22c..d57182a5 100644
--- a/app/src/main/res/layout/fragment_same_code.xml
+++ b/app/src/main/res/layout/fragment_same_code.xml
@@ -5,11 +5,13 @@
android:layout_height="match_parent">
@@ -52,6 +54,12 @@
android:id="@+id/ad_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_margin="24dp"
- app:layout_constraintBottom_toBottomOf="parent" />
+ android:layout_marginStart="24dp"
+ android:layout_marginTop="0dp"
+ android:layout_marginEnd="24dp"
+ android:layout_marginBottom="24dp"
+ app:nativeAdLayout="@layout/ad_lesson_code"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent" />
\ No newline at end of file