AdView now is shown only after the loading is done

This commit is contained in:
serso 2015-01-26 22:42:36 +01:00
parent a6577a70b7
commit 477e99eec6

View File

@ -50,11 +50,10 @@ public class AdView extends FrameLayout {
return; return;
} }
setVisibility(VISIBLE);
LayoutInflater.from(getContext()).inflate(R.layout.admob, this); LayoutInflater.from(getContext()).inflate(R.layout.admob, this);
admobView = (com.google.android.gms.ads.AdView) findViewById(R.id.admob); admobView = (com.google.android.gms.ads.AdView) findViewById(R.id.admob);
admobView.setVisibility(View.VISIBLE); if (admobView == null) throw new AssertionError();
admobView.setAdListener(new AdListener() { admobView.setAdListener(new AdListener() {
@Override @Override
public void onAdFailedToLoad(int errorCode) { public void onAdFailedToLoad(int errorCode) {
@ -63,6 +62,10 @@ public class AdView extends FrameLayout {
@Override @Override
public void onAdLoaded() { public void onAdLoaded() {
if (admobView != null) {
admobView.setVisibility(View.VISIBLE);
}
setVisibility(VISIBLE);
} }
}); });