Skip to content

Commit

Permalink
setup Ads
Browse files Browse the repository at this point in the history
  • Loading branch information
eby8zevin committed Mar 11, 2023
1 parent 8a1a318 commit 4b31bad
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 38 deletions.
25 changes: 0 additions & 25 deletions app/src/main/java/com/ahmadabuhasan/qrbarcode/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
public class MainActivity extends AppCompatActivity implements ZXingScannerView.ResultHandler {

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

});
new Utils().interstitialAdsShow(this);
AdRequest adRequest = new AdRequest.Builder().build();
binding.adView.loadAd(adRequest);

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

flashOn();
flashOff();

//ConfigCat();
}

private void flashOn() {
Expand Down Expand Up @@ -151,30 +147,9 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) {
public void onBackPressed() {
if (pressedTime + 2000 > System.currentTimeMillis()) {
finishAndRemoveTask();
if (Utils.interstitialAd.isLoaded()) {
Utils.interstitialAd.show();
} else {
super.onBackPressed();
finish();
}
finishAndRemoveTask();
} else {
Toast.makeText(this, "Press once again to exit", Toast.LENGTH_SHORT).show();
}
pressedTime = System.currentTimeMillis();
}

/*private void ConfigCat() {
String SDK = BuildConfig.SDK;
ConfigCatClient client = ConfigCatClient.newBuilder()
.logLevel(LogLevel.INFO)
.logLevel(LogLevel.DEBUG)
.build(SDK);
User user = User.newBuilder()
.email("[email protected]")
.build(SDK);
Log.d(TAG, "ConfigCat: " + client + user);
}*/
}
16 changes: 3 additions & 13 deletions app/src/main/java/com/ahmadabuhasan/qrbarcode/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.content.Context;
import android.os.Handler;
import android.util.Log;

import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.AdRequest;
Expand All @@ -19,19 +18,10 @@ public void interstitialAdsShow(Context context) {
interstitialAd.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
AdsDelay();
Log.d("interstitialAd", "Show");
if (interstitialAd.isLoaded()) {
interstitialAd.show();
}
}
});
}

public void AdsDelay() {
Handler handler = new Handler();
handler.postDelayed(() -> {
if (interstitialAd == null || !interstitialAd.isLoaded()) {
return;
}
interstitialAd.show();
}, 30000);
}
}

0 comments on commit 4b31bad

Please sign in to comment.