Skip to content

Commit 4b31bad

Browse files
committed
setup Ads
1 parent 8a1a318 commit 4b31bad

File tree

2 files changed

+3
-38
lines changed

2 files changed

+3
-38
lines changed

app/src/main/java/com/ahmadabuhasan/qrbarcode/MainActivity.java

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
public class MainActivity extends AppCompatActivity implements ZXingScannerView.ResultHandler {
3131

3232
private static final int PERMISSION_CODE = 100;
33-
//private static final String TAG = "ConfigCat";
3433
private static final String FLASH_STATE = "FLASH_STATE";
3534
private static long pressedTime;
3635
private boolean flashlight;
@@ -50,7 +49,6 @@ protected void onCreate(Bundle savedInstanceState) {
5049
MobileAds.initialize(this, initializationStatus -> {
5150

5251
});
53-
new Utils().interstitialAdsShow(this);
5452
AdRequest adRequest = new AdRequest.Builder().build();
5553
binding.adView.loadAd(adRequest);
5654

@@ -59,8 +57,6 @@ protected void onCreate(Bundle savedInstanceState) {
5957

6058
flashOn();
6159
flashOff();
62-
63-
//ConfigCat();
6460
}
6561

6662
private void flashOn() {
@@ -151,30 +147,9 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) {
151147
public void onBackPressed() {
152148
if (pressedTime + 2000 > System.currentTimeMillis()) {
153149
finishAndRemoveTask();
154-
if (Utils.interstitialAd.isLoaded()) {
155-
Utils.interstitialAd.show();
156-
} else {
157-
super.onBackPressed();
158-
finish();
159-
}
160-
finishAndRemoveTask();
161150
} else {
162151
Toast.makeText(this, "Press once again to exit", Toast.LENGTH_SHORT).show();
163152
}
164153
pressedTime = System.currentTimeMillis();
165154
}
166-
167-
/*private void ConfigCat() {
168-
String SDK = BuildConfig.SDK;
169-
ConfigCatClient client = ConfigCatClient.newBuilder()
170-
.logLevel(LogLevel.INFO)
171-
.logLevel(LogLevel.DEBUG)
172-
.build(SDK);
173-
174-
User user = User.newBuilder()
175-
.email("example@email.com")
176-
.build(SDK);
177-
178-
Log.d(TAG, "ConfigCat: " + client + user);
179-
}*/
180155
}

app/src/main/java/com/ahmadabuhasan/qrbarcode/Utils.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import android.content.Context;
44
import android.os.Handler;
5-
import android.util.Log;
65

76
import com.google.android.gms.ads.AdListener;
87
import com.google.android.gms.ads.AdRequest;
@@ -19,19 +18,10 @@ public void interstitialAdsShow(Context context) {
1918
interstitialAd.setAdListener(new AdListener() {
2019
@Override
2120
public void onAdLoaded() {
22-
AdsDelay();
23-
Log.d("interstitialAd", "Show");
21+
if (interstitialAd.isLoaded()) {
22+
interstitialAd.show();
23+
}
2424
}
2525
});
2626
}
27-
28-
public void AdsDelay() {
29-
Handler handler = new Handler();
30-
handler.postDelayed(() -> {
31-
if (interstitialAd == null || !interstitialAd.isLoaded()) {
32-
return;
33-
}
34-
interstitialAd.show();
35-
}, 30000);
36-
}
3727
}

0 commit comments

Comments
 (0)