Remove Ads from Game
This commit is contained in:
parent
d6c23ae835
commit
6143e9edb8
@ -40,6 +40,5 @@ dependencies {
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
testImplementation 'junit:junit:4.12'
|
||||
implementation 'com.android.support:appcompat-v7:26.1.0'
|
||||
implementation 'com.google.android.gms:play-services-ads:15.0.1'
|
||||
implementation files('libs/simple-xml-2.7.1.jar')
|
||||
}
|
||||
|
@ -18,8 +18,6 @@ import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import com.google.android.gms.ads.MobileAds;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -84,7 +82,6 @@ public class GameActivity extends Activity implements ExceptionHandler, User.LvU
|
||||
super.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
|
||||
MobileAds.initialize(this, "ca-app-pub-7069685539417779~2685294395");
|
||||
if (!hasGLES20())
|
||||
throw new Exception("OpenGL ES 2.0 not supported");
|
||||
|
||||
|
@ -1,16 +0,0 @@
|
||||
/*
|
||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||
* Copyright (c) 2018. All rights reserved.
|
||||
* Last modified 7/10/18 3:54 PM
|
||||
*
|
||||
*/
|
||||
|
||||
package de.frajul.endlessroll.main.ads;
|
||||
|
||||
public interface AdLoadingListener {
|
||||
|
||||
void onAdLoaded();
|
||||
|
||||
void onAdFailedToLoad(int errorCode);
|
||||
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||
* Copyright (c) 2018. All rights reserved.
|
||||
* Last modified 7/10/18 3:54 PM
|
||||
*
|
||||
*/
|
||||
|
||||
package de.frajul.endlessroll.main.ads;
|
||||
|
||||
import com.google.android.gms.ads.AdListener;
|
||||
|
||||
public class CustomAdListener extends AdListener {
|
||||
|
||||
private AdLoadingListener adLoadingListener;
|
||||
|
||||
public CustomAdListener(AdLoadingListener adLoadingListener) {
|
||||
super();
|
||||
this.adLoadingListener = adLoadingListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdLoaded() {
|
||||
adLoadingListener.onAdLoaded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdFailedToLoad(int i) {
|
||||
adLoadingListener.onAdFailedToLoad(i);
|
||||
}
|
||||
}
|
@ -10,9 +10,6 @@ package de.frajul.endlessroll.main.screens;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.google.android.gms.ads.AdRequest;
|
||||
import com.google.android.gms.ads.AdView;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import de.frajul.endlessroll.R;
|
||||
@ -20,8 +17,6 @@ import de.frajul.endlessroll.levels.Level;
|
||||
import de.frajul.endlessroll.levels.LevelPack;
|
||||
import de.frajul.endlessroll.main.GameActivity;
|
||||
import de.frajul.endlessroll.main.GameLog;
|
||||
import de.frajul.endlessroll.main.ads.AdLoadingListener;
|
||||
import de.frajul.endlessroll.main.ads.CustomAdListener;
|
||||
import de.frajul.endlessroll.views.LevelButton;
|
||||
import de.frajul.endlessroll.views.LevelButtonOnClickListener;
|
||||
import de.frajul.endlessroll.views.TopBar;
|
||||
@ -29,29 +24,19 @@ import de.frajul.endlessroll.views.TopBar;
|
||||
/**
|
||||
* Created by Julian on 23.04.2016.
|
||||
*/
|
||||
public class LevelsScreen extends Screen<LinearLayout> implements LevelButtonOnClickListener, AdLoadingListener {
|
||||
public class LevelsScreen extends Screen<LinearLayout> implements LevelButtonOnClickListener {
|
||||
|
||||
private LevelPack levelPack;
|
||||
|
||||
private TopBar topBar;
|
||||
private LinearLayout topRow;
|
||||
private LinearLayout bottomRow;
|
||||
private AdView adView;
|
||||
private AtomicBoolean waitingForAdResponse;
|
||||
private AtomicBoolean adLoaded;
|
||||
|
||||
public LevelsScreen(GameActivity gameActivity) {
|
||||
super(ScreenType.LEVELS, gameActivity, R.layout.levels);
|
||||
topBar = super.createTopBar(R.id.levels_topbar);
|
||||
topRow = layout.findViewById(R.id.levels_top_row);
|
||||
bottomRow = layout.findViewById(R.id.levels_bottom_row);
|
||||
adView = layout.findViewById(R.id.levels_ad_view);
|
||||
adView.setAdListener(new CustomAdListener(this));
|
||||
adView.setVisibility(View.GONE);
|
||||
|
||||
waitingForAdResponse = new AtomicBoolean(false);
|
||||
adLoaded = new AtomicBoolean(false);
|
||||
loadAd();
|
||||
}
|
||||
|
||||
public void onLevelPackSelected(LevelPack levelPack) {
|
||||
@ -85,19 +70,10 @@ public class LevelsScreen extends Screen<LinearLayout> implements LevelButtonOnC
|
||||
bottomRow.addView(button.getView(), params);
|
||||
}
|
||||
|
||||
private void loadAd() {
|
||||
waitingForAdResponse.set(true);
|
||||
AdRequest adRequest = new AdRequest.Builder().build();
|
||||
adView.loadAd(adRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepareToBeShown() {
|
||||
gameActivity.getSoundManager().menuMusic.start();
|
||||
|
||||
if (!adLoaded.get() && !waitingForAdResponse.get())
|
||||
loadAd();
|
||||
|
||||
topBar.update();
|
||||
build();
|
||||
}
|
||||
@ -114,18 +90,4 @@ public class LevelsScreen extends Screen<LinearLayout> implements LevelButtonOnC
|
||||
gameActivity.startGame(levelPack, level);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdLoaded() {
|
||||
adLoaded.set(true);
|
||||
waitingForAdResponse.set(false);
|
||||
adView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdFailedToLoad(int errorCode) {
|
||||
adLoaded.set(false);
|
||||
waitingForAdResponse.set(false);
|
||||
GameLog.i("LevelsScreen-Ad failed to load. ErrorCode=" + errorCode);
|
||||
adView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
@ -22,19 +22,9 @@
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/backgrounds_menu_grasslands">
|
||||
|
||||
<com.google.android.gms.ads.AdView
|
||||
xmlns:ads="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/levels_ad_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
ads:adSize="SMART_BANNER"
|
||||
ads:adUnitId="@string/ad_unit_id_levels"/>
|
||||
|
||||
<HorizontalScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_above="@id/levels_ad_view"
|
||||
android:overScrollMode="never"
|
||||
android:scrollbars="none">
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user