diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 4920c19..939a831 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -18,8 +18,8 @@ android { applicationId = "com.hd.phone.mico.wallpaper" minSdk = 23 targetSdk = 34 - versionCode = 2 - versionName = "1.0.1" + versionCode = 3 + versionName = "1.0.2" setProperty("archivesBaseName", "Mico Wallpaper_V" + versionName + "(${versionCode})_$timestamp") testInstrumentationRunner = "androidx.live.runner.AndroidJUnitRunner" @@ -66,4 +66,95 @@ dependencies { implementation("com.google.firebase:firebase-analytics") implementation("com.google.firebase:firebase-config") + + + + //-----------------------------------------------TopOn(Mintegral、Pangle、UnitAds、Digital Turbine(Fyber)、Chartboost&Helium、Ironsource、Liftoff(Vungle)、Inmobi、Start.io、Appnext、Bigo) + + //Anythink (Necessary) + implementation("com.anythink.sdk:core-tpn:6.4.07") + implementation("com.anythink.sdk:nativead-tpn:6.4.07") + implementation("com.anythink.sdk:banner-tpn:6.4.07") + implementation("com.anythink.sdk:interstitial-tpn:6.4.07") + implementation("com.anythink.sdk:rewardedvideo-tpn:6.4.07") + implementation("com.anythink.sdk:splash-tpn:6.4.07") + + //Androidx (Necessary) + implementation("androidx.appcompat:appcompat:1.1.0") + implementation("androidx.browser:browser:1.4.0") + + //StartApp + implementation("com.anythink.sdk:adapter-tpn-startapp:6.4.07") + implementation("com.startapp:inapp-sdk:5.0.2") + + //Appnext + implementation("com.anythink.sdk:adapter-tpn-appnext:6.4.07") + implementation("com.appnext.sdk:ads:2.7.1.473") + implementation("com.appnext.sdk:banners:2.7.1.473") + implementation("com.appnext.sdk:native-ads2:2.7.1.473") + implementation("com.appnext.sdk:actions:2.4.6.472") + implementation("androidx.constraintlayout:constraintlayout:2.0.4") + + //Vungle + implementation("com.anythink.sdk:adapter-tpn-vungle:6.4.07") + implementation("com.vungle:vungle-ads:7.4.0") + implementation("com.google.android.gms:play-services-basement:18.1.0") + implementation("com.google.android.gms:play-services-ads-identifier:18.0.1") + + //UnityAds + implementation("com.anythink.sdk:adapter-tpn-unityads:6.4.07") + implementation("com.unity3d.ads:unity-ads:4.12.2") + + //Ironsource + implementation("com.anythink.sdk:adapter-tpn-ironsource:6.4.07") + implementation("com.ironsource.sdk:mediationsdk:8.2.1") + implementation("com.google.android.gms:play-services-appset:16.0.2") + implementation("com.google.android.gms:play-services-ads-identifier:18.0.1") + implementation("com.google.android.gms:play-services-basement:18.1.0") + + //Bigo + implementation("com.anythink.sdk:adapter-tpn-bigo:6.4.07") + implementation("com.bigossp:bigo-ads:4.9.0") + + //Pangle + implementation("com.anythink.sdk:adapter-tpn-pangle-nonchina:6.4.07") + implementation("com.pangle.global:ads-sdk:6.1.0.9") + implementation("com.google.android.gms:play-services-ads-identifier:18.0.1") + + //Inmobi + implementation("com.anythink.sdk:adapter-tpn-inmobi:6.4.07") + implementation("com.inmobi.monetization:inmobi-ads-kotlin:10.7.5") + + //Mintegral + implementation("com.anythink.sdk:adapter-tpn-mintegral-nonchina:6.4.07") + implementation("com.mbridge.msdk.oversea:reward:16.8.11") + implementation("com.mbridge.msdk.oversea:newinterstitial:16.8.11") + implementation("com.mbridge.msdk.oversea:mbnative:16.8.11") + implementation("com.mbridge.msdk.oversea:mbnativeadvanced:16.8.11") + implementation("com.mbridge.msdk.oversea:mbsplash:16.8.11") + implementation("com.mbridge.msdk.oversea:mbbanner:16.8.11") + implementation("com.mbridge.msdk.oversea:mbbid:16.8.11") + implementation("androidx.recyclerview:recyclerview:1.1.0") + + //Chartboost + implementation("com.anythink.sdk:adapter-tpn-chartboost:6.4.07") + implementation("com.chartboost:chartboost-sdk:9.7.0") + implementation("com.chartboost:chartboost-mediation-sdk:4.9.1") + implementation("com.chartboost:chartboost-mediation-adapter-chartboost:4.9.7.0.0") + implementation("com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:1.0.0") + implementation("com.squareup.okhttp3:logging-interceptor:4.10.0") + implementation("com.squareup.okhttp3:okhttp:4.10.0") + implementation("com.squareup.retrofit2:converter-scalars:2.9.0") + implementation("com.squareup.retrofit2:retrofit:2.9.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1") + + //Fyber + implementation("com.anythink.sdk:adapter-tpn-fyber:6.4.07") + implementation("com.fyber:marketplace-sdk:8.3.0") + implementation("com.google.android.gms:play-services-ads-identifier:18.0.1") + + // Debugger UI Tools + implementation ("com.anythink.sdk:debugger-ui:1.0.7") + } \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 706d30b..5570670 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -22,4 +22,133 @@ -keep class com.hd.phone.fresh.walls.json.** { *; } -keep class com.google.gson.** { *; } -keepattributes Signature --keepattributes AnnotationDefault,RuntimeVisibleAnnotations \ No newline at end of file +-keepattributes AnnotationDefault,RuntimeVisibleAnnotations + + + +#---------------------------------------------Topon + -keep class com.startapp.** { + *; + } + + -keep class com.truenet.** { + *; + } + + -keepattributes Exceptions, InnerClasses, Signature, Deprecated, SourceFile, + LineNumberTable, *Annotation*, EnclosingMethod + -dontwarn android.webkit.JavascriptInterface + -dontwarn com.startapp.** + + -dontwarn org.jetbrains.annotations.** + -keep class com.appnext.** { *; } + -dontwarn com.appnext.** + # Vungle + -dontwarn com.vungle.ads.** + -keepclassmembers class com.vungle.ads.** { + *; + } + -keep class com.vungle.ads.** + + + + # Google + -keep class com.google.android.gms.** { *; } + -dontwarn com.google.android.gms.** + + + + + # START OkHttp + Okio + # JSR 305 annotations are for embedding nullability information. + -dontwarn javax.annotation.** + + + # A resource is loaded with a relative path so the package of this class must be preserved. + -adaptresourcefilenames okhttp3/internal/publicsuffix/PublicSuffixDatabase.gz + + + # Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java. + -dontwarn org.codehaus.mojo.animal_sniffer.* + + + # OkHttp platform used only on JVM and when Conscrypt and other security providers are available. + -dontwarn okhttp3.internal.platform.** + -dontwarn org.conscrypt.** + -dontwarn org.bouncycastle.** + -dontwarn org.openjsse.** + + + # Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java. + -dontwarn org.codehaus.mojo.animal_sniffer.* + + + # END OkHttp + Okio + + + # START Protobuf + -dontwarn com.google.protobuf.** + -keepclassmembers class com.google.protobuf.** { + *; + } + -keep class * extends com.google.protobuf.GeneratedMessageLite { *; } + + + # END Protobuf + -keepclassmembers class com.ironsource.sdk.controller.IronSourceWebView$JSInterface { + public *; + } + -keepclassmembers class * implements android.os.Parcelable { + public static final android.os.Parcelable$Creator *; + } + -keep public class com.google.android.gms.ads.** { + public *; + } + -keep class com.ironsource.adapters.** { *; + } + -dontwarn com.ironsource.mediationsdk.** + -dontwarn com.ironsource.adapters.** + -keepattributes JavascriptInterface + -keepclassmembers class * { + @android.webkit.JavascriptInterface ; + } + -keep class com.bytedance.sdk.** { *; } + -keep class com.inmobi.** { *; } + -keep public class com.google.android.gms.** + -dontwarn com.google.android.gms.** + -dontwarn com.squareup.picasso.** + -keep class com.google.android.gms.ads.identifier.AdvertisingIdClient{ + public *; + } + -keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info{ + public *; + } + # skip the Picasso library classes + -keep class com.squareup.picasso.** {*;} + -dontwarn com.squareup.okhttp.** + # skip Moat classes + -keep class com.moat.** {*;} + -dontwarn com.moat.** + # skip IAB classes + -keep class com.iab.** {*;} + -dontwarn com.iab.** + -keepattributes Signature + -keepattributes *Annotation* + -keep class com.mbridge.** {*; } + -keep interface com.mbridge.** {*; } + -keep class android.support.v4.** { *; } + -dontwarn com.mbridge.** + -keep class **.R$* { public static final int mbridge*; } + -keep public class com.mbridge.* extends androidx.** { *; } + -keep public class androidx.viewpager.widget.PagerAdapter{ *; } + -keep public class androidx.viewpager.widget.ViewPager.OnPageChangeListener{ *; } + -keep interface androidx.annotation.IntDef{ *; } + -keep interface androidx.annotation.Nullable{ *; } + -keep interface androidx.annotation.CheckResult{ *; } + -keep interface androidx.annotation.NonNull{ *; } + -keep public class androidx.fragment.app.Fragment{ *; } + -keep public class androidx.core.content.FileProvider{ *; } + -keep public class androidx.core.app.NotificationCompat{ *; } + -keep public class androidx.appcompat.widget.AppCompatImageView { *; } + -keep public class androidx.recyclerview.*{ *; } + -keep class com.chartboost.** { *; } \ No newline at end of file diff --git a/app/src/main/java/com/hd/phone/fresh/walls/MyApp.java b/app/src/main/java/com/hd/phone/fresh/walls/MyApp.java index e4bfb55..3583a8c 100644 --- a/app/src/main/java/com/hd/phone/fresh/walls/MyApp.java +++ b/app/src/main/java/com/hd/phone/fresh/walls/MyApp.java @@ -4,11 +4,15 @@ import android.app.Application; import android.content.Context; import android.util.Log; +import com.anythink.core.api.ATSDK; +import com.anythink.core.api.NetTrafficeCallback; +import com.anythink.debug.api.ATDebuggerUITest; import com.google.firebase.FirebaseApp; import com.hd.phone.fresh.walls.file.Common; import com.hd.phone.fresh.walls.file.CommonKt; import com.hd.phone.fresh.walls.file.DbManager; import com.hd.phone.fresh.walls.json.Data; +import com.hd.phone.fresh.walls.topon.AdManager; import java.io.IOException; import java.io.InputStream; @@ -22,15 +26,20 @@ public class MyApp extends Application { private static List animalsList; public static String TAG = "-------MyApp---------"; + private String APPId="h673ddf8ae8467"; + private String AppKey="a17cd7a62720b00498a8dc5c538c92303"; + private String debug_Key=""; + @Override public void onCreate() { super.onCreate(); mAppContext = this; + initTop(); DbManager.init(this); if (!FirebaseApp.getApps(this).isEmpty()) { - Log.d("TAG", "Firebase 初始化成功"); +// Log.d("TAG", "Firebase 初始化成功"); } else { - Log.e("TAG", "Firebase 初始化失败"); +// Log.e("TAG", "Firebase 初始化失败"); } try { InputStream open = getAssets().open("Nature.json"); @@ -60,4 +69,29 @@ public class MyApp extends Application { Collections.shuffle(animalsList); return animalsList; } + + private void initTop(){ + ATSDK.checkIsEuTraffic(this, new NetTrafficeCallback() { + + @Override + public void onResultCallback(boolean isEU) { + Log.e(TAG, "onResultCallback:" + isEU); + if (isEU && ATSDK.getGDPRDataLevel( MyApp.mAppContext) == ATSDK.UNKNOWN) { + ATSDK.showGdprAuth(MyApp.mAppContext); + } + + } + + @Override + public void onErrorCallback(String errorMsg) { + Log.e(TAG, "onErrorCallback:" + errorMsg); + } + }); + + ATSDK.init( this, APPId, AppKey); + //测试工具 +// ATDebuggerUITest.showDebuggerUI(this,debug_Key); + AdManager.loadAllAd(); + + } } diff --git a/app/src/main/java/com/hd/phone/fresh/walls/act/DetailActivity.java b/app/src/main/java/com/hd/phone/fresh/walls/act/DetailActivity.java index 6ca504b..2d6407d 100644 --- a/app/src/main/java/com/hd/phone/fresh/walls/act/DetailActivity.java +++ b/app/src/main/java/com/hd/phone/fresh/walls/act/DetailActivity.java @@ -35,6 +35,8 @@ import com.hd.phone.fresh.walls.file.CommonValue; import com.hd.phone.fresh.walls.file.DbManager; import com.hd.phone.fresh.walls.frag.DialogSelectType; import com.hd.phone.fresh.walls.json.Data; +import com.hd.phone.fresh.walls.topon.AdManager; +import com.hd.phone.fresh.walls.topon.onActionListener; import java.io.File; import java.io.FileInputStream; @@ -68,6 +70,13 @@ public class DetailActivity extends AppCompatActivity implements OnSelectTypeLis vb = ActivityDetailBinding.inflate(getLayoutInflater()); Common.initFull(this, true); setContentView(vb.getRoot()); + AdManager.showTopOn(this, new onActionListener() { + @Override + public void onAction() { + + } + }); + AdManager.loadAllAd(); data = (Data) getIntent().getSerializableExtra(CommonValue.key_info); if (data == null) { return; @@ -137,13 +146,19 @@ public class DetailActivity extends AppCompatActivity implements OnSelectTypeLis }); vb.buttonSet.setOnClickListener(v -> { - if (dialogSelectType == null) { - dialogSelectType = new DialogSelectType(); - dialogSelectType.setListener(this); - } - if(!dialogSelectType.isAdded()){ - dialogSelectType.show(getSupportFragmentManager(), ""); - } + AdManager.showTopOn(DetailActivity.this, new onActionListener() { + @Override + public void onAction() { + if (dialogSelectType == null) { + dialogSelectType = new DialogSelectType(); + dialogSelectType.setListener(DetailActivity.this); + } + if(!dialogSelectType.isAdded()){ + dialogSelectType.show(getSupportFragmentManager(), ""); + } + } + }); + }); vb.imageFavorite.setOnClickListener(new View.OnClickListener() { @@ -162,53 +177,59 @@ public class DetailActivity extends AppCompatActivity implements OnSelectTypeLis vb.layoutDownload.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - showDownloadLoading(true); - File file = new File(mSavePath); - if (file.exists()) { - Log.d(MyApp.TAG, "-----------Download 1"); - startSave(file); - return; - } - if (downloadFile != null && downloadFile.exists()) { - Log.d(MyApp.TAG, "-----------Download 2"); - startSave(downloadFile); - return; - } - if (fullDrawable == null) { - Log.d(MyApp.TAG, "-----------Download 3"); - CommonKt.INSTANCE.downloadFile(fullUrl, mSavePath, new Function2() { - @Override - public Unit invoke(Boolean aBoolean, InputStream inputStream) { - File file = new File(mSavePath); - if (aBoolean && file.exists()) { - downloadFile = file; - runOnUiThread(new Runnable() { - @Override - public void run() { - Glide.with(DetailActivity.this) - .load(downloadFile) - .into(vb.imageviewPreview); - } - }); - startSave(downloadFile); - } else { - runOnUiThread(new Runnable() { - @Override - public void run() { - showDownloadLoading(false); - Toast.makeText(DetailActivity.this, getString(R.string.download_fail), Toast.LENGTH_SHORT).show(); - } - }); - - } - return null; + AdManager.showTopOn(DetailActivity.this, new onActionListener() { + @Override + public void onAction() { + showDownloadLoading(true); + File file = new File(mSavePath); + if (file.exists()) { + Log.d(MyApp.TAG, "-----------Download 1"); + startSave(file); + return; } - }); - return; - } - Log.d(MyApp.TAG, "-----------Download 4"); - Common.saveDrawableToFile(fullDrawable, mSavePath); - startSave(file); + if (downloadFile != null && downloadFile.exists()) { + Log.d(MyApp.TAG, "-----------Download 2"); + startSave(downloadFile); + return; + } + if (fullDrawable == null) { + Log.d(MyApp.TAG, "-----------Download 3"); + CommonKt.INSTANCE.downloadFile(fullUrl, mSavePath, new Function2() { + @Override + public Unit invoke(Boolean aBoolean, InputStream inputStream) { + File file = new File(mSavePath); + if (aBoolean && file.exists()) { + downloadFile = file; + runOnUiThread(new Runnable() { + @Override + public void run() { + Glide.with(DetailActivity.this) + .load(downloadFile) + .into(vb.imageviewPreview); + } + }); + startSave(downloadFile); + } else { + runOnUiThread(new Runnable() { + @Override + public void run() { + showDownloadLoading(false); + Toast.makeText(DetailActivity.this, getString(R.string.download_fail), Toast.LENGTH_SHORT).show(); + } + }); + + } + return null; + } + }); + return; + } + Log.d(MyApp.TAG, "-----------Download 4"); + Common.saveDrawableToFile(fullDrawable, mSavePath); + startSave(file); + } + }); + } }); diff --git a/app/src/main/java/com/hd/phone/fresh/walls/act/WElActivity.java b/app/src/main/java/com/hd/phone/fresh/walls/act/WElActivity.java index 60fce9d..9782310 100644 --- a/app/src/main/java/com/hd/phone/fresh/walls/act/WElActivity.java +++ b/app/src/main/java/com/hd/phone/fresh/walls/act/WElActivity.java @@ -12,13 +12,16 @@ import com.hd.phone.fresh.walls.R; import com.hd.phone.fresh.walls.databinding.ActivityWelcomeBinding; import com.hd.phone.fresh.walls.file.Common; +import com.hd.phone.fresh.walls.topon.AdManager; +import com.hd.phone.fresh.walls.topon.CountAction; +import com.hd.phone.fresh.walls.topon.GoMainAction; public class WElActivity extends AppCompatActivity { private TextView textViewWallpaper; private CountDownTimer countDownTimer; private ActivityWelcomeBinding vb; - private long totalTime = 2000; + private long totalTime = 12000; @SuppressLint("MissingInflatedId") @Override @@ -28,35 +31,30 @@ public class WElActivity extends AppCompatActivity { Common.initFull(this,false); setContentView(vb.getRoot()); - - countDownTimer = new CountDownTimer(totalTime, 100) { + countDownTimer = AdManager.showWelcomeAd(this, totalTime, new CountAction() { @Override - public void onTick(long millisUntilFinished) { + public void onCount(long millisUntilFinished) { int progressPercentage = (int) ((100 * millisUntilFinished) / totalTime); - // 或者从 100% 到 0% 的倒计时 int countdownPercentage = 100 - progressPercentage; vb.progressbar.setProgress(countdownPercentage); } - + }, new GoMainAction() { @Override - public void onFinish() { + public void onGo() { vb.progressbar.setProgress(100); Intent intent = new Intent(WElActivity.this, HomeActivity.class); startActivity(intent); finish(); - } - }; - - goCount(); - } - - private void goCount() { + }); countDownTimer.start(); + } + + @Override protected void onDestroy() { super.onDestroy(); diff --git a/app/src/main/java/com/hd/phone/fresh/walls/file/DbManager.java b/app/src/main/java/com/hd/phone/fresh/walls/file/DbManager.java index a1ee323..b9fbafe 100644 --- a/app/src/main/java/com/hd/phone/fresh/walls/file/DbManager.java +++ b/app/src/main/java/com/hd/phone/fresh/walls/file/DbManager.java @@ -75,7 +75,7 @@ public class DbManager { .build() .findFirst(); if (first == null) { - Log.d(MyApp.TAG, "-----------添加11 isLike=" + imId); +// Log.d(MyApp.TAG, "-----------添加11 isLike=" + imId); objectBoxLike.put(boxLike); for(OnAddOrRemoveListener listener:list){ listener.onAdd(boxLike); @@ -83,7 +83,7 @@ public class DbManager { } else { - Log.d(MyApp.TAG, "-----------已经存在添加22 isLike=" + imId); +// Log.d(MyApp.TAG, "-----------已经存在添加22 isLike=" + imId); } } diff --git a/app/src/main/java/com/hd/phone/fresh/walls/topon/AdListener.java b/app/src/main/java/com/hd/phone/fresh/walls/topon/AdListener.java new file mode 100644 index 0000000..b09af89 --- /dev/null +++ b/app/src/main/java/com/hd/phone/fresh/walls/topon/AdListener.java @@ -0,0 +1,10 @@ +package com.hd.phone.fresh.walls.topon; + +public interface AdListener { + void loadFail(String placeId); + void showSuccess(); + + void showFail(); + + void showClose(); +} diff --git a/app/src/main/java/com/hd/phone/fresh/walls/topon/AdManager.java b/app/src/main/java/com/hd/phone/fresh/walls/topon/AdManager.java new file mode 100644 index 0000000..521d097 --- /dev/null +++ b/app/src/main/java/com/hd/phone/fresh/walls/topon/AdManager.java @@ -0,0 +1,245 @@ +package com.hd.phone.fresh.walls.topon; + +import android.app.Activity; +import android.os.CountDownTimer; +import android.util.Log; + +import androidx.annotation.NonNull; + +import com.anythink.core.api.ATAdInfo; +import com.anythink.core.api.AdError; +import com.anythink.interstitial.api.ATInterstitial; +import com.anythink.interstitial.api.ATInterstitialListener; +import com.hd.phone.fresh.walls.MyApp; + + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class AdManager { + + private static final int type_no_cache = 0; + private static final int type_has_cache = 1; + private static final int type_show_success = 2; + private static final int type_show_close = 3; + private static final int type_show_fail = 4; + + + + private static final String place1Id = "n673ddfba1e51f"; + private static final String place2Id = "n673ddfb9df182"; + private static final String place3Id = "n673ddfb9a9f64"; + + + private static boolean place1LoadFail = false; + private static boolean place2LoadFail = false; + private static boolean place3LoadFail = false; + + private static boolean alreadyShow = false; + + private static List list = new ArrayList<>(); + + + public static void loadAllAd() { + if (list.size() == 0) { + ATInterstitial mInterstitialAd1 = new ATInterstitial(MyApp.mAppContext, place1Id); + ATInterstitial mInterstitialAd2 = new ATInterstitial(MyApp.mAppContext, place2Id); + ATInterstitial mInterstitialAd3 = new ATInterstitial(MyApp.mAppContext, place3Id); + list.add(mInterstitialAd1); + list.add(mInterstitialAd2); + list.add(mInterstitialAd3); + } + for (ATInterstitial ad : list) { + if (!ad.isAdReady()) { + setCallBack(ad, new AdListener() { + @Override + public void loadFail(@NonNull String placeId) { + if (placeId.equals(place1Id)) { + place1LoadFail = true; + } + if (placeId.equals(place2Id)) { + place2LoadFail = true; + } + if (placeId.equals(place3Id)) { + place3LoadFail = true; + } + } + + @Override + public void showSuccess() { + + } + + @Override + public void showFail() { + + } + + @Override + public void showClose() { + + } + }); + ad.load(); + } + } + + + } + + private static ATInterstitial getReadyAd() { + Collections.shuffle(list); + for (ATInterstitial ad : list) { + if (ad.isAdReady()) { + Log.d(MyApp.TAG, "-has Cache------------"); + return ad; + } + } + Log.d(MyApp.TAG, "-No Cache------------"); + return null; + } + + private static void setCallBack(ATInterstitial ad, AdListener listener) { + ad.setAdListener(new ATInterstitialListener() { + + + @Override + public void onInterstitialAdLoaded() { + Log.d(MyApp.TAG, "LoadLoaded " + ad.mPlacementId); + } + + @Override + public void onInterstitialAdLoadFail(AdError adError) { + listener.loadFail(ad.mPlacementId); + Log.d(MyApp.TAG, "LoadFail:--" + ad.mPlacementId + "--" + adError.getCode() + "---" + adError.getDesc()); + } + + @Override + public void onInterstitialAdClicked(ATAdInfo atAdInfo) { + + } + + @Override + public void onInterstitialAdShow(ATAdInfo atAdInfo) { + Log.d(MyApp.TAG, "AdShow " + atAdInfo.getPlacementId()); + listener.showSuccess(); + ad.load(); + } + + @Override + public void onInterstitialAdClose(ATAdInfo atAdInfo) { + listener.showClose(); + } + + @Override + public void onInterstitialAdVideoStart(ATAdInfo atAdInfo) { + + } + + @Override + public void onInterstitialAdVideoEnd(ATAdInfo atAdInfo) { + + } + + @Override + public void onInterstitialAdVideoError(AdError adError) { + + } + }); + } + + + + + public static CountDownTimer showWelcomeAd( + Activity activity, + Long totalTim, + CountAction countAction, + GoMainAction goMain + ) { + + CountDownTimer timer = new CountDownTimer(totalTim, 100) { + @Override + public void onTick(long millisUntilFinished) { + countAction.onCount(millisUntilFinished); + if (!alreadyShow) { + showAD(activity, new AdStatusAction() { + @Override + public void onStatus(int adType) { + if (adType == type_has_cache) { + alreadyShow = true; + } + if (adType == type_show_close || adType == type_show_fail) { + goMain.onGo(); + } + + } + }); + } + } + + @Override + public void onFinish() { + if (!alreadyShow) { + showTopOn(activity, new onActionListener() { + @Override + public void onAction() { + goMain.onGo(); + } + }); + } + } + }; + + + return timer; + } + + + + private static void showAD(Activity activity, AdStatusAction action) { + ATInterstitial readyAd = getReadyAd(); + if (readyAd != null) { + action.onStatus(type_has_cache); + setCallBack(readyAd, new AdListener() { + @Override + public void loadFail(@NonNull String placeId) { + + } + + @Override + public void showSuccess() { + action.onStatus(type_show_success); + } + + @Override + public void showFail() { + action.onStatus(type_show_fail); + } + + @Override + public void showClose() { + action.onStatus(type_show_close); + } + }); + readyAd.show(activity); + } else { + action.onStatus(type_no_cache); + + } + } + + + public static void showTopOn(Activity activity, onActionListener listener) { + showAD(activity, new AdStatusAction() { + @Override + public void onStatus(int adType) { + if (adType == type_no_cache || adType == type_show_close || adType == type_show_fail) { + listener.onAction(); + } + } + }); + + } +} diff --git a/app/src/main/java/com/hd/phone/fresh/walls/topon/AdStatusAction.java b/app/src/main/java/com/hd/phone/fresh/walls/topon/AdStatusAction.java new file mode 100644 index 0000000..c57c012 --- /dev/null +++ b/app/src/main/java/com/hd/phone/fresh/walls/topon/AdStatusAction.java @@ -0,0 +1,5 @@ +package com.hd.phone.fresh.walls.topon; + +public interface AdStatusAction { + void onStatus(int adType); +} diff --git a/app/src/main/java/com/hd/phone/fresh/walls/topon/CountAction.java b/app/src/main/java/com/hd/phone/fresh/walls/topon/CountAction.java new file mode 100644 index 0000000..6364d65 --- /dev/null +++ b/app/src/main/java/com/hd/phone/fresh/walls/topon/CountAction.java @@ -0,0 +1,5 @@ +package com.hd.phone.fresh.walls.topon; + +public interface CountAction { + void onCount(long millisUntilFinished); +} diff --git a/app/src/main/java/com/hd/phone/fresh/walls/topon/GoMainAction.java b/app/src/main/java/com/hd/phone/fresh/walls/topon/GoMainAction.java new file mode 100644 index 0000000..d61dda9 --- /dev/null +++ b/app/src/main/java/com/hd/phone/fresh/walls/topon/GoMainAction.java @@ -0,0 +1,5 @@ +package com.hd.phone.fresh.walls.topon; + +public interface GoMainAction { + void onGo(); +} diff --git a/app/src/main/java/com/hd/phone/fresh/walls/topon/onActionListener.java b/app/src/main/java/com/hd/phone/fresh/walls/topon/onActionListener.java new file mode 100644 index 0000000..923eaaf --- /dev/null +++ b/app/src/main/java/com/hd/phone/fresh/walls/topon/onActionListener.java @@ -0,0 +1,6 @@ +package com.hd.phone.fresh.walls.topon; + +public interface onActionListener { + + void onAction(); +} diff --git a/gradle.properties b/gradle.properties index 3e927b1..d703cac 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 +org.gradle.jvmargs=-Xmx4096m -Dfile.encoding=UTF-8 # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects diff --git a/settings.gradle.kts b/settings.gradle.kts index d248c44..9d4f759 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -10,6 +10,29 @@ dependencyResolutionManagement { repositories { google() mavenCentral() + + + //Anythink(Core) + maven ("https://jfrog.anythinktech.com/artifactory/overseas_sdk") + + //Appnext + maven ("https://dl.appnext.com") + + //Ironsource + maven ("https://android-sdk.is.com/") + + //Pangle + maven ("https://artifact.bytedance.com/repository/pangle") + + //Mintegral + maven ("https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea") + + //Chartboost + maven ("https://cboost.jfrog.io/artifactory/chartboost-ads") + maven ("https://cboost.jfrog.io/artifactory/chartboost-mediation") + + //TopOn集成测试工具 + maven ( "https://jfrog.anythinktech.com/artifactory/debugger") } }