Skip to content

Commit

Permalink
fix : changes preload module
Browse files Browse the repository at this point in the history
  • Loading branch information
FenilInfy0m authored and FenilInfy0m committed Jan 12, 2023
1 parent 57cb5ed commit 3debdbc
Show file tree
Hide file tree
Showing 32 changed files with 239 additions and 173 deletions.
Binary file modified .gradle/7.4/executionHistory/executionHistory.bin
Binary file not shown.
Binary file modified .gradle/7.4/executionHistory/executionHistory.lock
Binary file not shown.
Binary file modified .gradle/7.4/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified .gradle/7.4/fileHashes/fileHashes.lock
Binary file not shown.
Binary file modified .gradle/7.4/fileHashes/resourceHashesCache.bin
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/outputFiles.bin
Binary file not shown.
Binary file modified .gradle/file-system.probe
Binary file not shown.
16 changes: 9 additions & 7 deletions adsSdk/src/main/java/com/infyom/adssdk/InfyOmAds.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,22 @@ public static void showInterstitial(int admob, Context context, Interstitial lis

if ((myPref.getAdsType().equals("admob") && !adsType.equals("facebook")) || adsType.equals("admob")) {
InterstitialUtils interstitialUtils = new InterstitialUtils(context, listener, admob);
interstitialUtils.show_interstitial(Constants.interAdmob);
interstitialUtils.load_interstitial(true);
} else if ((myPref.getAdsType().equals("facebook") || adsType.equals("facebook"))) {
InterstitialUtilsFb.loadInterstitial(context, listener);
} else if (myPref.getAdsType().equals("Quereca") || adsType.equals("Quereca")) {
InterstitialQuereca.showInterstitial(context,listener);
}else {
listener.onAdClose(false);
}

} else {
listener.onAdClose(true);
}
}

public static void showBanner(Context context, RelativeLayout bannerContainer, int admob) {

AdsAccountProvider myPref = new AdsAccountProvider(context);
int preloadId;

Expand All @@ -113,7 +115,7 @@ public static void showBanner(Context context, RelativeLayout bannerContainer, i
}

if ((myPref.getAdsType().equals("admob") && !adsType.equals("facebook")) || adsType.equals("admob")) {
BannerUtils.show_banner(context, bannerContainer, admob, preloadId);
BannerUtils.load_ads(context, bannerContainer, admob, true);
} else if (myPref.getAdsType().equals("facebook") || adsType.equals("facebook")) {
BannerUtilsFb.show_banner(context, bannerContainer);
} else if (myPref.getAdsType().equals("Quereca") || adsType.equals("Quereca")) {
Expand All @@ -140,13 +142,13 @@ public static void showNative(Context context, RelativeLayout nativeContainer, V
if ((myPref.getAdsType().equals("admob") && !adsType.equals("facebook")) || adsType.equals("admob")) {

if (adTemplate.equals(AdTemplate.NATIVE_300)) {
NativeUtils.showNative(context, nativeContainer, space, admob, true, preloadId);
NativeUtils.load_native(context, nativeContainer, space, admob, true,preloadId);
} else if (adTemplate.equals(AdTemplate.NATIVE_100)){
NativeUtils.showNative(context, nativeContainer, space, admob, false, preloadId);
NativeUtils.load_native(context, nativeContainer, space, admob, false,preloadId);
} else if (adTemplate.equals(AdTemplate.NATIVE_50)){
NativeUtils50.showNative(context, nativeContainer, space, admob, preloadId);
NativeUtils50.load_native(context, nativeContainer, space, admob);
} else {
NativeUtils40.showNative(context, nativeContainer, space, admob, preloadId);
NativeUtils40.load_native(context, nativeContainer, space, admob);
}

} else if (myPref.getAdsType().equals("facebook") || adsType.equals("facebook")) {
Expand Down Expand Up @@ -178,7 +180,7 @@ public static void enableTestMode(Context context) {
myPref.setFbBannerAds("IMG_16_9_APP_INSTALL#YOUR_PLACEMENT_ID");
myPref.setFbNativeAds("IMG_16_9_APP_INSTALL#YOUR_PLACEMENT_ID");
myPref.setFbInterAds("IMG_16_9_APP_INSTALL#YOUR_PLACEMENT_ID");
myPref.setAdsTime(5);
myPref.setAdsTime(1);
myPref.setSplashAds(1);
myPref.setAdsType("admob");
myPref.setFirstAdsType("admob");
Expand Down
6 changes: 3 additions & 3 deletions adsSdk/src/main/java/com/infyom/adssdk/adModel/Google.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class Google {
private String appOpenThird;
@SerializedName("display_time")
@Expose
private Object displayTime;
private Integer displayTime;
@SerializedName("place_add")
@Expose
private Integer placeAdd;
Expand Down Expand Up @@ -211,11 +211,11 @@ public void setAppOpenThird(String appOpenThird) {
}


public Object getDisplayTime() {
public Integer getDisplayTime() {
return displayTime;
}

public void setDisplayTime(Object displayTime) {
public void setDisplayTime(Integer displayTime) {
this.displayTime = displayTime;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,13 @@ public void onAdLoaded() {
e.printStackTrace();
}


Constants.adView = adView;
load_ads(context, bannerView, adMobId,false);

} else {

Constants.adView = adView;

}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ public class InterstitialUtils {
AdsAccountProvider myPref;
Interstitial listener;
int adMobId;

private int failedCount = 0;
public InterstitialUtils(Context mContext,Interstitial listener,int adMobId) {
this.mContext = mContext;
this.listener = listener;
this.adMobId = adMobId;
}

void load_interstitial(boolean isFailed) {
public void load_interstitial(boolean isFailed) {

myPref = new AdsAccountProvider(mContext);

Expand All @@ -48,7 +48,9 @@ void load_interstitial(boolean isFailed) {
adMobId = 1;
}
} else {
dialog = AdProgressDialog.show(mContext);
if (dialog == null) {
dialog = AdProgressDialog.show(mContext);
}
}

if (adMobId == 1) {
Expand All @@ -63,27 +65,34 @@ void load_interstitial(boolean isFailed) {
@Override
public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
super.onAdFailedToLoad(loadAdError);
if (dialog != null && dialog.isShowing()) {
dialog.dismiss();
}

Constants.isTimeFinish = false;
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Constants.isTimeFinish = true;
if (failedCount == 2) {
failedCount = 0;
if (dialog != null && dialog.isShowing()) {
dialog.dismiss();
}
}, myPref.getAdsTime() * 1000);

if (isFailed) {
if (InfyOmAds.isConnectingToInternet(mContext)) {
listener.onAdClose(true);
} else {
listener.onAdClose(true);
Toast.makeText(mContext, "Please check your internet connection", Toast.LENGTH_SHORT).show();
Constants.isTimeFinish = false;
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Constants.isTimeFinish = true;
}
}, myPref.getAdsTime() * 1000);

if (isFailed) {
if (InfyOmAds.isConnectingToInternet(mContext)) {
listener.onAdClose(true);
} else {
listener.onAdClose(true);
Toast.makeText(mContext, "Please check your internet connection", Toast.LENGTH_SHORT).show();
}
}
}
} else {
failedCount++;
load_interstitial(true);


}
}

@Override
Expand All @@ -92,7 +101,7 @@ public void onAdLoaded(@NonNull InterstitialAd interstitialAd) {
if (dialog != null && dialog.isShowing()) {
dialog.dismiss();
}
setCountDown();
// setCountDown();
if (isFailed) {
show_interstitial(interstitialAd);
} else {
Expand Down Expand Up @@ -132,7 +141,6 @@ static void dismissCount() {
}
}


public void show_interstitial(InterstitialAd mInterstitialAd) {

if ( mInterstitialAd != null) {
Expand Down
51 changes: 26 additions & 25 deletions adsSdk/src/main/java/com/infyom/adssdk/adUtils/NativeUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
public class NativeUtils {

static String mUnitId;
static void load_native(Context context,RelativeLayout rlNative, View space,int admob,boolean isBigNative,int preAdmobId) {
public static void load_native(Context context,RelativeLayout rlNative, View space,int admob,boolean isBigNative,int preAdmobId) {

AdsAccountProvider accountProvider = new AdsAccountProvider(context);

Expand All @@ -40,34 +40,35 @@ static void load_native(Context context,RelativeLayout rlNative, View space,int
AdLoader adLoader = new AdLoader.Builder(context, mUnitId).forNativeAd(new NativeAd.OnNativeAdLoadedListener() {
@Override
public void onNativeAdLoaded(@NonNull NativeAd nativeAd) {
if (!Constants.isPreloadedNative) {
Constants.isPreloadedNative = true;

try {
if (rlNative.getChildCount() > 0) {
rlNative.removeAllViews();
}

View view;
if (isBigNative) {
view = LayoutInflater.from(context).inflate(R.layout.ad_300, null);
populate300AppInstallAdViewMedia(nativeAd, (NativeAdView) view.findViewById(R.id.unified));
} else {
view = LayoutInflater.from(context).inflate(R.layout.ad_100, null);
populateAppInstallAdViewMedia(nativeAd, (NativeAdView) view.findViewById(R.id.unified));
}
space.setVisibility(View.GONE);
rlNative.setVisibility(View.VISIBLE);
try {
if (rlNative.getChildCount() > 0) {
rlNative.removeAllViews();
rlNative.addView(view);
} catch (Exception e) {
e.printStackTrace();
}

load_native(context,rlNative,space,preAdmobId,isBigNative,preAdmobId);
} else {
Constants.nativeAds = nativeAd;
View view;
if (isBigNative) {
view = LayoutInflater.from(context).inflate(R.layout.ad_300, null);
populate300AppInstallAdViewMedia(nativeAd, (NativeAdView) view.findViewById(R.id.unified));
} else {
view = LayoutInflater.from(context).inflate(R.layout.ad_100, null);
populateAppInstallAdViewMedia(nativeAd, (NativeAdView) view.findViewById(R.id.unified));
}
space.setVisibility(View.GONE);
rlNative.setVisibility(View.VISIBLE);
rlNative.removeAllViews();
rlNative.addView(view);
} catch (Exception e) {
e.printStackTrace();
}

// if (!Constants.isPreloadedNative) {
// Constants.isPreloadedNative = true;
//
//
// load_native(context,rlNative,space,preAdmobId,isBigNative,preAdmobId);
// } else {
// Constants.nativeAds = nativeAd;
// }
}
}).withAdListener(new AdListener() {
@Override
Expand Down
41 changes: 21 additions & 20 deletions adsSdk/src/main/java/com/infyom/adssdk/adUtils/NativeUtils40.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,30 +44,31 @@ public static void load_native(Context context, RelativeLayout rlNative, View sp
@Override
public void onNativeAdLoaded(@NonNull NativeAd nativeAd) {
// && !(context instanceof SplashScreen)
if (!Constants.isPreloadedNative ) {
Constants.isPreloadedNative = true;

try {
if (rlNative.getChildCount() > 0) {
rlNative.removeAllViews();
}

View view = LayoutInflater.from(context).inflate( R.layout.ad_40, null);
populateNative40(nativeAd, (NativeAdView) view.findViewById(R.id.unified));
space.setVisibility(View.GONE);
rlNative.setVisibility(View.VISIBLE);
// if (!Constants.isPreloadedNative ) {
// Constants.isPreloadedNative = true;
//
//
//
//
// load_native(context, rlNative, space, admob);
// } else {
// Constants.nativeAds = nativeAd;
// }
try {
if (rlNative.getChildCount() > 0) {
rlNative.removeAllViews();
rlNative.addView(view);
} catch (Exception e) {
e.printStackTrace();
}



load_native(context, rlNative, space, admob);
} else {
Constants.nativeAds = nativeAd;
View view = LayoutInflater.from(context).inflate( R.layout.ad_40, null);
populateNative40(nativeAd, (NativeAdView) view.findViewById(R.id.unified));
space.setVisibility(View.GONE);
rlNative.setVisibility(View.VISIBLE);
rlNative.removeAllViews();
rlNative.addView(view);
} catch (Exception e) {
e.printStackTrace();
}

}
}).withAdListener(new AdListener() {
@Override
Expand Down
39 changes: 20 additions & 19 deletions adsSdk/src/main/java/com/infyom/adssdk/adUtils/NativeUtils50.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,29 +43,30 @@ public static void load_native(Context context, RelativeLayout rlNative, View sp
@Override
public void onNativeAdLoaded(@NonNull NativeAd nativeAd) {
// && !(context instanceof SplashScreen)
if (!Constants.isPreloadedNative ) {
Constants.isPreloadedNative = true;

try {
if (rlNative.getChildCount() > 0) {
rlNative.removeAllViews();
}

View view = LayoutInflater.from(context).inflate( R.layout.ad_50, null);
populateNative50(nativeAd, (NativeAdView) view.findViewById(R.id.unified));
space.setVisibility(View.GONE);
rlNative.setVisibility(View.VISIBLE);
try {
if (rlNative.getChildCount() > 0) {
rlNative.removeAllViews();
rlNative.addView(view);
} catch (Exception e) {
e.printStackTrace();
}


load_native(context, rlNative, space, admob);
} else {
Constants.nativeAds = nativeAd;
View view = LayoutInflater.from(context).inflate( R.layout.ad_50, null);
populateNative50(nativeAd, (NativeAdView) view.findViewById(R.id.unified));
space.setVisibility(View.GONE);
rlNative.setVisibility(View.VISIBLE);
rlNative.removeAllViews();
rlNative.addView(view);
} catch (Exception e) {
e.printStackTrace();
}
// if (!Constants.isPreloadedNative ) {
// Constants.isPreloadedNative = true;
//
//
//
//
// load_native(context, rlNative, space, admob);
// } else {
// Constants.nativeAds = nativeAd;
// }
}
}).withAdListener(new AdListener() {
@Override
Expand Down
16 changes: 0 additions & 16 deletions adsSdk/src/main/java/com/infyom/adssdk/apiService/ApiClient.java

This file was deleted.

Loading

0 comments on commit 3debdbc

Please sign in to comment.