Banner doesn’t resize / reload when changing device orientation
Closed this issue · 1 comments
Banner doesn’t resize / reload when changing device orientation. Expected behaviour would be that the AdInlineView loads the banner which fits the new screen dimensions the best.
<?xml version="1.0" encoding="utf-8"?> <com.adform.sdk.pub.views.AdInline xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/adContainer" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerInParent="true" android:gravity="center" android:minHeight="@dimen/item_size_50" />
`import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.adform.sdk.interfaces.AdListener;
import com.adform.sdk.pub.views.AdInline;
import com.adform.sdk.utils.SmartAdSize;
/**
-
Abstract class to avoid code duplication
-
-
Extend this class in your fragment where you want to display an ad, add the
-
ad into your layout file and call {@link #initAdView(AdInline)} in
-
{@link #onCreateView(LayoutInflater, ViewGroup, Bundle)} if you want to
-
update your layout e.g. for resizing override {@link #onAdLoaded()} use
-
{@link #getMasterTagId()} to deliver the tag id for your page
-
-
in your xml file you can include:
*/
public abstract class AbstractAdFragment extends AbstractBaseFragment {public final static String TAG = "AdUpdate";
private AdInline mAdView;void initAdView(final AdInline adView) {
if (adView != null) {
Log.d(TAG, "init");
this.mAdView = adView;
this.mAdView.setAdSize(new SmartAdSize());
this.mAdView.addKeyValue("language", getString(R.string.lang));
this.mAdView.setListener(new AdListener() {
@OverRide
public void onAdLoadSuccess(final AdInline adInline) {
Log.d(TAG, "Success");
if (mAdView != null) {
mAdView.setVisibility(View.VISIBLE);
}
onAdLoaded();
}@Override public void onAdLoadFail(final AdInline adInline, final String s) { Log.d(TAG, "Fail"); if (mAdView != null) { mAdView.setVisibility(View.GONE); } onAdLoaded(); } }); this.loadAd(); }
}
private void loadAd() {
final int masterTagId = getMasterTagId();
if (masterTagId > 0) {
Log.d(TAG, "loadAd");
this.mAdView.setMasterTagId(masterTagId);
this.mAdView.loadAd();
} else {
this.mAdView.setVisibility(View.GONE);
}
}@OverRide
public void onResume() {
super.onResume();
if (this.mAdView != null) {
Log.d(TAG, "onResume");
this.mAdView.onResume();
}
}@OverRide
public void onPause() {
super.onPause();
if (this.mAdView != null) {
Log.d(TAG, "onPause");
this.mAdView.onPause();
}
}@OverRide
public void onDestroy() {
super.onDestroy();
if (this.mAdView != null) {
Log.d(TAG, "onDestroy");
this.mAdView.destroy();
}
}protected abstract int getMasterTagId();
protected void onAdLoaded() {
}
}`
Fixed in 2.17.1 version.
https://github.com/adform/adform-android-sdk/releases/tag/2.17.1