Skip to content

Commit

Permalink
fix : banner code fixing and upgrade project
Browse files Browse the repository at this point in the history
  • Loading branch information
FenilInfy0m authored and FenilInfy0m committed Mar 15, 2024
1 parent 96a5147 commit de18280
Show file tree
Hide file tree
Showing 48 changed files with 75 additions and 224 deletions.
Binary file modified .gradle/7.5/checksums/checksums.lock
Binary file not shown.
Binary file modified .gradle/7.5/checksums/sha1-checksums.bin
Binary file not shown.
Binary file modified .gradle/7.5/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified .gradle/7.5/fileHashes/fileHashes.lock
Binary file not shown.
Binary file removed .gradle/8.0/checksums/checksums.lock
Binary file not shown.
Binary file removed .gradle/8.0/checksums/sha1-checksums.bin
Binary file not shown.
Binary file not shown.
Binary file removed .gradle/8.0/executionHistory/executionHistory.bin
Binary file not shown.
Binary file removed .gradle/8.0/executionHistory/executionHistory.lock
Binary file not shown.
Binary file removed .gradle/8.0/fileHashes/fileHashes.bin
Binary file not shown.
Binary file removed .gradle/8.0/fileHashes/fileHashes.lock
Binary file not shown.
Binary file removed .gradle/8.0/fileHashes/resourceHashesCache.bin
Binary file not shown.
Binary file removed .gradle/8.2/checksums/checksums.lock
Binary file not shown.
Binary file removed .gradle/8.2/checksums/md5-checksums.bin
Binary file not shown.
Binary file removed .gradle/8.2/checksums/sha1-checksums.bin
Binary file not shown.
Binary file not shown.
Empty file.
Binary file removed .gradle/8.2/executionHistory/executionHistory.bin
Binary file not shown.
Binary file removed .gradle/8.2/executionHistory/executionHistory.lock
Binary file not shown.
Binary file removed .gradle/8.2/fileChanges/last-build.bin
Binary file not shown.
Binary file removed .gradle/8.2/fileHashes/fileHashes.bin
Binary file not shown.
Binary file removed .gradle/8.2/fileHashes/fileHashes.lock
Binary file not shown.
Empty file removed .gradle/8.2/gc.properties
Empty file.
Binary file added .gradle/8.4/checksums/checksums.lock
Binary file not shown.
Binary file not shown.
Binary file added .gradle/8.4/checksums/sha1-checksums.bin
Binary file not shown.
Binary file not shown.
Binary file added .gradle/8.4/executionHistory/executionHistory.bin
Binary file not shown.
Binary file added .gradle/8.4/executionHistory/executionHistory.lock
Binary file not shown.
File renamed without changes.
Binary file added .gradle/8.4/fileHashes/fileHashes.bin
Binary file not shown.
Binary file added .gradle/8.4/fileHashes/fileHashes.lock
Binary file not shown.
Binary file not shown.
File renamed without changes.
Binary file modified .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
4 changes: 2 additions & 2 deletions .gradle/buildOutputCleanup/cache.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#Thu Jan 04 10:53:45 IST 2024
gradle.version=7.5
#Fri Mar 15 12:40:11 IST 2024
gradle.version=8.4
Binary file modified .gradle/buildOutputCleanup/outputFiles.bin
Binary file not shown.
4 changes: 2 additions & 2 deletions .gradle/config.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#Wed Mar 13 15:34:53 IST 2024
java.home=/Users/mac/Library/Java/JavaVirtualMachines/temurin-17.0.9/Contents/Home
#Fri Mar 15 12:35:47 IST 2024
java.home=/Applications/Android Studio.app/Contents/jbr/Contents/Home
Binary file modified .gradle/file-system.probe
Binary file not shown.
3 changes: 2 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions adsSdk/src/main/java/com/infyom/adssdk/InfyOmAds.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ public static void enableTestMode(Context context) {
myPref.setFbNativeAds("IMG_16_9_LINK#YOUR_PLACEMENT_ID");
myPref.setFbInterAds("IMG_16_9_LINK#YOUR_PLACEMENT_ID");
myPref.setAdsTime(0);
myPref.setBannerAdsTime(30);
myPref.setNativeAdsTime(30);
myPref.setBannerAdsTime(0);
myPref.setNativeAdsTime(0);
myPref.setSplashAds(1);
myPref.setAdsType(ADMOB);
myPref.setFirstAdsType(ADMOB);
Expand Down
196 changes: 55 additions & 141 deletions adsSdk/src/main/java/com/infyom/adssdk/adUtils/banner/AdBanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,168 +18,108 @@
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.LoadAdError;
import com.google.android.gms.ads.admanager.AdManagerAdView;
import com.infyom.adssdk.AdsAccountProvider;
import com.infyom.adssdk.Constants;

public class AdBanner {
static AdView mAdView = null;
static String mUnitId = null;
static Context context = null;
static View mSpace;
static RelativeLayout rlBanner;
static int adMobId = 1;
static AdsAccountProvider accountProvider;
static boolean isInitBanner = false;
static AdRequest adRequest;

public static void showBanner(Context mContext, RelativeLayout mRlBanner, View space, int mAdMobId,boolean isCollaps) {


context = null;
initAdView();

context = mContext;
mSpace = space;
rlBanner = mRlBanner;
adMobId = mAdMobId;
accountProvider = new AdsAccountProvider(context);

isInitBanner = true;

load_ads(isCollaps);
}

static void initAdView() {
mAdView = null;
}

static AdView getAdView() {
return mAdView;
}

static void setAdView(AdView adView) {
mAdView = adView;
loadBannerAd(isCollaps);
}

public static void load_ads(boolean isCollaps) {

if (getAdView() == null) {
if (adMobId == 1) {
mUnitId = accountProvider.getBannerAds1();
} else if (adMobId == 2) {
mUnitId = accountProvider.getBannerAds2();
} else {
mUnitId = accountProvider.getBannerAds3();
}
AdView adView = new AdView(context);
AdView finalAdView = adView;
adView.setAdUnitId(mUnitId);
adView.setAdListener( new AdListener() {
@Override
public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
super.onAdFailedToLoad(loadAdError);
BannerUtilsFb.loadFbBanner(context, rlBanner,mSpace);
}
public static void loadBannerAd(boolean isCollaps) {

@Override
public void onAdLoaded() {
super.onAdLoaded();
Log.e("AD-BANNER", "load_ads : success call" );
// loadFailed = 0;
setAdView( finalAdView );
try {
if (rlBanner.getChildCount() > 0) {
rlBanner.removeAllViews();
}

rlBanner.setVisibility(View.VISIBLE);
mSpace.setVisibility(View.GONE);

rlBanner.addView( finalAdView );
} catch (Exception e) {
e.printStackTrace();
}

}

@Override
public void onAdClicked() {
super.onAdClicked();

Constants.isBannerClicked = true;
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Constants.isBannerClicked = false;
}
},accountProvider.getBannerAdsTime() * 1000);
}
});
AdRequest adRequest;
if(!isCollaps){
adRequest=getAdRequest();
adView.setAdSize(AdSize.BANNER);
}else {
AdSize adSize = getAdSize(context,rlBanner);
adView.setAdSize(adSize);
Bundle extras = new Bundle();
extras.putString("collapsible", "bottom");
adRequest = new AdRequest.Builder()
.addNetworkExtrasBundle( AdMobAdapter.class, extras)
.build();

}
adView.loadAd(adRequest);
// AdSize adSize = getAdSize(context, rlBanner);
// adView.setAdSize(AdSize.BANNER);
// adView.loadAd(getAdRequest());
if (adMobId == 1) {
mUnitId = accountProvider.getBannerAds1();
} else if (adMobId == 2) {
mUnitId = accountProvider.getBannerAds2();
} else {
Log.e("AD-BANNER", "load_ads : already loaded call" );
mUnitId = accountProvider.getBannerAds3();
}
}

static void loadAfterFail() {
AdView adView = new AdView(context);
adView.setAdUnitId(mUnitId);
adView.setAdListener(new AdListener() {
adView.setAdListener( new AdListener() {
@Override
public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
super.onAdFailedToLoad(loadAdError);
Log.e("AD-BANNER", "onAdFailedToLoad: " + loadAdError);
initAdView();
// if (loadFailed != 3) {
// Log.e("AD-BANNER", "onAdFailedToLoad: " + loadFailed);
// loadFailed++;
// loadAfterFail();
// }
Log.e("AD-BANNER", "failed : " +loadAdError.toString());
// BannerUtilsFb.loadFbBanner(context, rlBanner,mSpace);
}

@Override
public void onAdLoaded() {
super.onAdLoaded();
Log.e("AD-BANNER", "load_ads : success call" );
// loadFailed = 0;
setAdView(adView);
// loadFailed = 0;
// setAdView( finalAdView );
try {
if (rlBanner.getChildCount() > 0) {
rlBanner.removeAllViews();
}

rlBanner.setVisibility(View.VISIBLE);
mSpace.setVisibility(View.GONE);

rlBanner.addView(adView);
} catch (Exception e) {
e.printStackTrace();
}

}
});

try {
if (rlBanner.getChildCount() > 0) {
rlBanner.removeAllViews();
@Override
public void onAdClicked() {
super.onAdClicked();

Constants.isBannerClicked = true;
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Constants.isBannerClicked = false;
}
},accountProvider.getBannerAdsTime() * 1000);
}
rlBanner.addView(adView);
} catch (Exception e) {
e.printStackTrace();
}
});


if(!isCollaps){
adRequest = getAdRequest();
adView.setAdSize(AdSize.BANNER);
}else {
AdSize adSize = getAdSize(context,rlBanner);
adView.setAdSize(adSize);
Bundle extras = new Bundle();
extras.putString("collapsible", "bottom");
adRequest = new AdRequest.Builder()
.addNetworkExtrasBundle( AdMobAdapter.class, extras)
.build();

AdSize adSize = getAdSize(context, rlBanner);
adView.setAdSize(adSize);
adView.loadAd(getAdRequest());
}
adView.loadAd(adRequest);
}


static AdRequest getAdRequest() {
AdRequest adRequest = new AdRequest.Builder().build();
return adRequest;
return new AdRequest.Builder().build();
}

static AdSize getAdSize(Context context, RelativeLayout rlBanner) {
Expand All @@ -200,30 +140,4 @@ static AdSize getAdSize(Context context, RelativeLayout rlBanner) {
return AdSize.getCurrentOrientationInlineAdaptiveBannerAdSize(context, adWidth);
}

public static Activity getCurrentActivity() {
return (Activity) context;
}

public static void pauseAdView() {
if (getAdView() != null && isInitBanner) {
getAdView().pause();
Log.e("AD-BANNER", "pauseAdView: ");
}
}

public static void resumeAdView() {
if (getAdView() != null && isInitBanner) {
getAdView().resume();
Log.e("AD-BANNER", "resumeAdView: ");
}
}

public static void destroyAdView() {
if (getAdView() != null && isInitBanner) {
isInitBanner = false;
getAdView().destroy();
Log.e("AD-BANNER", "destroyAdView: ");
}
}

}
14 changes: 7 additions & 7 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@
<meta-data android:name="com.google.android.gms.ads.flag.NATIVE_AD_DEBUGGER_ENABLED"
android:value="true" />

<!-- <meta-data-->
<!-- android:name="com.google.android.gms.ads.AD_MANAGER_APP"-->
<!-- android:value="true" >-->
<!-- </meta-data>-->

<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~3347511713">
android:name="com.google.android.gms.ads.AD_MANAGER_APP"
android:value="true" >
</meta-data>

<!-- <meta-data-->
<!-- android:name="com.google.android.gms.ads.APPLICATION_ID"-->
<!-- android:value="ca-app-pub-3940256099942544~3347511713">-->
<!-- </meta-data>-->
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected void onCreate(Bundle savedInstanceState) {

InfyOmAds.enableTestMode(this);

InfyOmAds.showBanner(MainActivity.this,rlBanner,space,1,false);
InfyOmAds.showBanner(MainActivity.this,rlBanner,space,1,true);
InfyOmAds.showNative(MainActivity.this,rl_native,tv_space,3, InfyOmAds.AdTemplate.NATIVE_350);

showAds.setOnClickListener(v -> {
Expand Down Expand Up @@ -104,7 +104,7 @@ public void onConsentFormLoadSuccess(ConsentForm consentForm) {
public void onConsentFormDismissed(@Nullable FormError formError) {
if (consentInformation.getConsentStatus() == ConsentInformation.ConsentStatus.OBTAINED) {
// App can start requesting ads.
InfyOmAds.showBanner(MainActivity.this,rlBanner,space,1,false);
InfyOmAds.showBanner(MainActivity.this,rlBanner,space,1,true);
InfyOmAds.showNative(MainActivity.this,rl_native,tv_space,1, InfyOmAds.AdTemplate.NATIVE_50);
}

Expand Down
64 changes: 0 additions & 64 deletions app/src/main/java/com/example/infyomadssdkproj/MyApplication.java

This file was deleted.

Loading

0 comments on commit de18280

Please sign in to comment.