V1.0.3(11) max改为topon
This commit is contained in:
parent
02f5642536
commit
08ffb4b752
@ -4,13 +4,10 @@ import java.text.SimpleDateFormat
|
|||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
alias(libs.plugins.android.application)
|
alias(libs.plugins.android.application)
|
||||||
id("applovin-quality-service")
|
|
||||||
id("org.jetbrains.kotlin.android")
|
id("org.jetbrains.kotlin.android")
|
||||||
id ("kotlin-kapt")
|
id ("kotlin-kapt")
|
||||||
}
|
}
|
||||||
applovin{
|
|
||||||
apiKey = "y87o4e7vb5bbqzuGVTFyOIfZiyBG0Nf0Ksq8S3m2MJOHf_A5BcWGJnKuQqoxwxVvtdQdiTC4O3MPzFwy8rJ9Cc"
|
|
||||||
}
|
|
||||||
val timestamp = SimpleDateFormat("MM_dd_HH_mm").format(Date())
|
val timestamp = SimpleDateFormat("MM_dd_HH_mm").format(Date())
|
||||||
|
|
||||||
|
|
||||||
@ -26,8 +23,8 @@ android {
|
|||||||
applicationId = "com.sound.prankparty"
|
applicationId = "com.sound.prankparty"
|
||||||
minSdk = 23
|
minSdk = 23
|
||||||
targetSdk = 34
|
targetSdk = 34
|
||||||
versionCode = 10
|
versionCode = 11
|
||||||
versionName = "1.0.2"
|
versionName = "1.0.3"
|
||||||
|
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
@ -71,16 +68,94 @@ dependencies {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
//--------------------------MAX(Liftoff Monetize(vungle)、Mintegral、Pangle、Unity Ads、inmobi)
|
//-----------------------------------------------TopOn(Mintegral、Pangle、UnitAds、Digital Turbine(Fyber)、Chartboost&Helium、Ironsource、Liftoff(Vungle)、Inmobi、Start.io、Appnext、Bigo)
|
||||||
implementation("com.applovin:applovin-sdk:+")
|
|
||||||
implementation("com.applovin.mediation:vungle-adapter:+")
|
|
||||||
implementation("com.applovin.mediation:mintegral-adapter:+")
|
|
||||||
implementation("com.applovin.mediation:bytedance-adapter:+")
|
|
||||||
implementation("com.applovin.mediation:unityads-adapter:+")
|
|
||||||
|
|
||||||
implementation("com.applovin.mediation:inmobi-adapter:+")
|
//Anythink (Necessary)
|
||||||
implementation("com.squareup.picasso:picasso:2.71828")
|
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")
|
implementation("androidx.recyclerview:recyclerview:1.1.0")
|
||||||
//MAX
|
|
||||||
|
//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.1.0")
|
||||||
|
|
||||||
|
//----------------------------------------------TopOn
|
||||||
|
|
||||||
}
|
}
|
||||||
132
app/proguard-rules.pro
vendored
132
app/proguard-rules.pro
vendored
@ -39,3 +39,135 @@
|
|||||||
|
|
||||||
# 额外的保留规则,确保任何使用 Room 的地方都能正常工作
|
# 额外的保留规则,确保任何使用 Room 的地方都能正常工作
|
||||||
-keep class androidx.room.** { *; }
|
-keep class androidx.room.** { *; }
|
||||||
|
|
||||||
|
#---------------------------------------------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 <methods>;
|
||||||
|
}
|
||||||
|
-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.** { *; }
|
||||||
|
|
||||||
|
#---------------------------------------------Topon
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,14 +2,11 @@ package com.sound;
|
|||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
import com.anythink.core.api.ATSDK;
|
||||||
|
import com.anythink.core.api.NetTrafficeCallback;
|
||||||
import com.applovin.sdk.AppLovinMediationProvider;
|
import com.sound.prankparty.topon.AdManager;
|
||||||
import com.applovin.sdk.AppLovinSdk;
|
|
||||||
import com.applovin.sdk.AppLovinSdkConfiguration;
|
|
||||||
import com.applovin.sdk.AppLovinSdkInitializationConfiguration;
|
|
||||||
|
|
||||||
public class MainApplication extends Application {
|
public class MainApplication extends Application {
|
||||||
/**
|
/**
|
||||||
@ -17,11 +14,14 @@ public class MainApplication extends Application {
|
|||||||
*/
|
*/
|
||||||
private static Context mContext;
|
private static Context mContext;
|
||||||
|
|
||||||
public static final String TAG = "--------------";
|
|
||||||
public static final String AD_BROADCAST = "on_success_action";
|
public static final String AD_BROADCAST = "on_success_action";
|
||||||
private static final String MAX_SDK = "Kwbl2wDLdNgp3kE8gk7WW_CCEBAee8xOIUJZQtEdNZX1iwclqFHlbgrUJt_g4zzSHJosSKIN13gv5Lqoe0bPvg";
|
|
||||||
public static Boolean initSDK = false;
|
public static Boolean initSDK = false;
|
||||||
|
|
||||||
|
private static final String AppKey = "a26e024a9bca8b461e84fa4d8897106d1";
|
||||||
|
private static final String APPId = "h670f347749ff5";
|
||||||
|
|
||||||
|
public static String TAG = "-------Prank----------";
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
@ -51,19 +51,27 @@ public class MainApplication extends Application {
|
|||||||
|
|
||||||
private void initSdk() {
|
private void initSdk() {
|
||||||
|
|
||||||
AppLovinSdkInitializationConfiguration initConfig = AppLovinSdkInitializationConfiguration.builder(MAX_SDK, this)
|
ATSDK.checkIsEuTraffic(this, new NetTrafficeCallback() {
|
||||||
.setMediationProvider(AppLovinMediationProvider.MAX)
|
|
||||||
.build();
|
|
||||||
AppLovinSdk.getInstance(this).initialize(initConfig, new AppLovinSdk.SdkInitializationListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onSdkInitialized(final AppLovinSdkConfiguration sdkConfig) {
|
public void onResultCallback(boolean isEU) {
|
||||||
initSDK = true;
|
Log.e(TAG, "onResultCallback:" + isEU);
|
||||||
LocalBroadcastManager.getInstance(mContext).sendBroadcast(new Intent(AD_BROADCAST));
|
if (isEU && ATSDK.getGDPRDataLevel(MainApplication.this) == ATSDK.UNKNOWN) {
|
||||||
|
ATSDK.showGdprAuth(MainApplication.this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onErrorCallback(String errorMsg) {
|
||||||
|
Log.e(TAG, "onErrorCallback:" + errorMsg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
AppLovinSdk.getInstance(this).getSettings().setVerboseLogging(true);
|
|
||||||
//MAX广告测试
|
ATSDK.init(this, APPId, AppKey);
|
||||||
// AppLovinSdk.getInstance( this ).showMediationDebugger();
|
AdManager.loadAllAd();
|
||||||
|
//测试工具
|
||||||
|
// ATDebuggerUITest.showDebuggerUI(this,"a8dd4a3f1c38a5a3cadb4f39385fb682af63df07");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -12,8 +12,9 @@ import com.sound.prankparty.JSON.Category;
|
|||||||
import com.sound.prankparty.JSON.SoundItem;
|
import com.sound.prankparty.JSON.SoundItem;
|
||||||
import com.sound.prankparty.Utils.ItemDecoration;
|
import com.sound.prankparty.Utils.ItemDecoration;
|
||||||
import com.sound.prankparty.databinding.ActivityAirhonrBinding;
|
import com.sound.prankparty.databinding.ActivityAirhonrBinding;
|
||||||
import com.sound.prankparty.max.MaxManager;
|
import com.sound.prankparty.topon.AdManager;
|
||||||
import com.sound.prankparty.max.onAdAfterAction;
|
import com.sound.prankparty.topon.onActionListener;
|
||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -28,7 +29,7 @@ public class AirHornActivity extends AppCompatActivity {
|
|||||||
binding = ActivityAirhonrBinding.inflate(getLayoutInflater());
|
binding = ActivityAirhonrBinding.inflate(getLayoutInflater());
|
||||||
setContentView(binding.getRoot());
|
setContentView(binding.getRoot());
|
||||||
|
|
||||||
MaxManager.onLoadAd();
|
AdManager.loadAllAd();
|
||||||
|
|
||||||
binding.airHornRecyclerview.setLayoutManager(new GridLayoutManager(this, 3));
|
binding.airHornRecyclerview.setLayoutManager(new GridLayoutManager(this, 3));
|
||||||
|
|
||||||
@ -51,7 +52,7 @@ public class AirHornActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
showAd(new onAdAfterAction() {
|
AdManager.showTopOn(AirHornActivity.this,new onActionListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAction() {
|
public void onAction() {
|
||||||
@ -70,7 +71,7 @@ public class AirHornActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
showAd(new onAdAfterAction() {
|
AdManager.showTopOn(this, new onActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onAction() {
|
public void onAction() {
|
||||||
finish();
|
finish();
|
||||||
@ -78,14 +79,5 @@ public class AirHornActivity extends AppCompatActivity {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showAd(onAdAfterAction listener) {
|
|
||||||
MaxManager.startShowMaxAd(this, new onAdAfterAction() {
|
|
||||||
@Override
|
|
||||||
public void onAction() {
|
|
||||||
listener.onAction();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,8 +27,8 @@ import com.sound.prankparty.Room.AppDatabase;
|
|||||||
import com.sound.prankparty.Room.FavoriteSounds;
|
import com.sound.prankparty.Room.FavoriteSounds;
|
||||||
import com.sound.prankparty.Room.FavoriteSoundsDao;
|
import com.sound.prankparty.Room.FavoriteSoundsDao;
|
||||||
import com.sound.prankparty.databinding.ActivityPlaySoundBinding;
|
import com.sound.prankparty.databinding.ActivityPlaySoundBinding;
|
||||||
import com.sound.prankparty.max.MaxManager;
|
import com.sound.prankparty.topon.AdManager;
|
||||||
import com.sound.prankparty.max.onAdAfterAction;
|
import com.sound.prankparty.topon.onActionListener;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ public class PlaySoundActivity extends AppCompatActivity {
|
|||||||
binding = ActivityPlaySoundBinding.inflate(getLayoutInflater());
|
binding = ActivityPlaySoundBinding.inflate(getLayoutInflater());
|
||||||
setContentView(binding.getRoot());
|
setContentView(binding.getRoot());
|
||||||
|
|
||||||
MaxManager.onLoadAd();
|
AdManager.loadAllAd();
|
||||||
|
|
||||||
|
|
||||||
// 获取音频管理器
|
// 获取音频管理器
|
||||||
@ -73,7 +73,7 @@ public class PlaySoundActivity extends AppCompatActivity {
|
|||||||
binding.back.setOnClickListener(new View.OnClickListener() {
|
binding.back.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
showAd(new onAdAfterAction() {
|
AdManager.showTopOn(PlaySoundActivity.this,new onActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onAction() {
|
public void onAction() {
|
||||||
finish();
|
finish();
|
||||||
@ -302,7 +302,7 @@ public class PlaySoundActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
showAd(new onAdAfterAction() {
|
AdManager.showTopOn(this,new onActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onAction() {
|
public void onAction() {
|
||||||
finish();
|
finish();
|
||||||
@ -310,14 +310,5 @@ public class PlaySoundActivity extends AppCompatActivity {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showAd(onAdAfterAction listener) {
|
|
||||||
MaxManager.startShowMaxAd(this, new onAdAfterAction() {
|
|
||||||
@Override
|
|
||||||
public void onAction() {
|
|
||||||
listener.onAction();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,17 +7,13 @@ import android.widget.ProgressBar;
|
|||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
import com.app.wallpaper.max.WelComManager;
|
|
||||||
import com.sound.prankparty.databinding.ActivitySplashBinding;
|
import com.sound.prankparty.databinding.ActivitySplashBinding;
|
||||||
|
import com.sound.prankparty.topon.AdManager;
|
||||||
import kotlin.Unit;
|
|
||||||
import kotlin.jvm.functions.Function0;
|
|
||||||
import kotlin.jvm.functions.Function1;
|
|
||||||
|
|
||||||
public class SplashActivity extends AppCompatActivity {
|
public class SplashActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private ActivitySplashBinding binding;
|
private ActivitySplashBinding binding;
|
||||||
private long timer = 12000;
|
private static final long totalTime = 11000; // 倒计时总时间
|
||||||
private CountDownTimer countDownTimer;
|
private CountDownTimer countDownTimer;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -30,25 +26,24 @@ public class SplashActivity extends AppCompatActivity {
|
|||||||
// 使用 ViewBinding 引用 progressBar
|
// 使用 ViewBinding 引用 progressBar
|
||||||
ProgressBar progressBar = binding.progressBar;
|
ProgressBar progressBar = binding.progressBar;
|
||||||
|
|
||||||
|
AdManager.setAlreadyShow();
|
||||||
|
|
||||||
countDownTimer = WelComManager.initTimer(this, timer, new Function1<Long, Unit>() {
|
countDownTimer = AdManager.showWelcomeAd(this, totalTime, millisUntilFinished -> {
|
||||||
@Override
|
int percentage = (int) (100 - (float) millisUntilFinished / totalTime * 100);
|
||||||
public Unit invoke(Long aLong) {
|
progressBar.setProgress(percentage);
|
||||||
float l1 = (float) aLong / timer;
|
},
|
||||||
float v = 100 - l1 * 100;
|
this::startMain // 倒计时结束或广告展示结束时,跳转主界面
|
||||||
progressBar.setProgress((int) v);
|
);
|
||||||
return null;
|
|
||||||
}
|
countDownTimer.start();
|
||||||
}, new Function0<Unit>() {
|
|
||||||
@Override
|
|
||||||
public Unit invoke() {
|
|
||||||
startMainActivity();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startMainActivity() {
|
// 跳转到主界面的方法
|
||||||
|
private void startMain() {
|
||||||
|
// 确保进度条更新至满值
|
||||||
|
binding.progressBar.setProgress(100);
|
||||||
|
|
||||||
|
// 跳转到主界面
|
||||||
Intent intent = new Intent(SplashActivity.this, MainActivity.class);
|
Intent intent = new Intent(SplashActivity.this, MainActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
finish();
|
finish();
|
||||||
|
|||||||
@ -20,8 +20,9 @@ import com.sound.MainApplication;
|
|||||||
import com.sound.prankparty.Activity.PlaySoundActivity;
|
import com.sound.prankparty.Activity.PlaySoundActivity;
|
||||||
import com.sound.prankparty.JSON.SoundItem;
|
import com.sound.prankparty.JSON.SoundItem;
|
||||||
import com.sound.prankparty.R;
|
import com.sound.prankparty.R;
|
||||||
import com.sound.prankparty.max.MaxManager;
|
|
||||||
import com.sound.prankparty.max.onAdAfterAction;
|
import com.sound.prankparty.topon.AdManager;
|
||||||
|
import com.sound.prankparty.topon.onActionListener;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -92,7 +93,7 @@ public class AirHornRecyclerViewAdapter extends RecyclerView.Adapter<AirHornRecy
|
|||||||
|
|
||||||
|
|
||||||
private void showAdAndNavigate(SoundItem soundItem) {
|
private void showAdAndNavigate(SoundItem soundItem) {
|
||||||
MaxManager.startShowMaxAd(activity, new onAdAfterAction() {
|
AdManager.showTopOn(activity, new onActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onAction() {
|
public void onAction() {
|
||||||
Intent intent = new Intent(context, PlaySoundActivity.class);
|
Intent intent = new Intent(context, PlaySoundActivity.class);
|
||||||
|
|||||||
@ -19,12 +19,10 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
|||||||
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
|
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
|
||||||
import com.sound.MainApplication;
|
import com.sound.MainApplication;
|
||||||
import com.sound.prankparty.Activity.AirHornActivity;
|
import com.sound.prankparty.Activity.AirHornActivity;
|
||||||
import com.sound.prankparty.Activity.PlaySoundActivity;
|
|
||||||
import com.sound.prankparty.JSON.Category;
|
import com.sound.prankparty.JSON.Category;
|
||||||
import com.sound.prankparty.JSON.SoundItem;
|
|
||||||
import com.sound.prankparty.R;
|
import com.sound.prankparty.R;
|
||||||
import com.sound.prankparty.max.MaxManager;
|
import com.sound.prankparty.topon.AdManager;
|
||||||
import com.sound.prankparty.max.onAdAfterAction;
|
import com.sound.prankparty.topon.onActionListener;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -102,7 +100,7 @@ public class SoundRecyclerViewAdapter extends RecyclerView.Adapter<SoundRecycler
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void showAdAndNavigate(int currentColor, Category category) {
|
private void showAdAndNavigate(int currentColor, Category category) {
|
||||||
MaxManager.startShowMaxAd(activity, new onAdAfterAction() {
|
AdManager.showTopOn(activity, new onActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onAction() {
|
public void onAction() {
|
||||||
Intent intent = new Intent(context, AirHornActivity.class);
|
Intent intent = new Intent(context, AirHornActivity.class);
|
||||||
|
|||||||
@ -22,8 +22,7 @@ import com.sound.prankparty.Utils.ItemDecoration;
|
|||||||
import com.sound.prankparty.Utils.JsonParser;
|
import com.sound.prankparty.Utils.JsonParser;
|
||||||
import com.sound.prankparty.Utils.LoadJSON;
|
import com.sound.prankparty.Utils.LoadJSON;
|
||||||
import com.sound.prankparty.databinding.FragmentSoundBinding;
|
import com.sound.prankparty.databinding.FragmentSoundBinding;
|
||||||
import com.sound.prankparty.max.MaxManager;
|
import com.sound.prankparty.topon.AdManager;
|
||||||
import com.sound.prankparty.max.onAdAfterAction;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -41,7 +40,7 @@ public class SoundFragment extends Fragment {
|
|||||||
binding = FragmentSoundBinding.inflate(inflater, container, false);
|
binding = FragmentSoundBinding.inflate(inflater, container, false);
|
||||||
View view = binding.getRoot();
|
View view = binding.getRoot();
|
||||||
|
|
||||||
MaxManager.onLoadAd();
|
AdManager.loadAllAd();
|
||||||
|
|
||||||
// 设置 RecyclerView 的布局管理器和适配器
|
// 设置 RecyclerView 的布局管理器和适配器
|
||||||
binding.soundRecyclerview.setLayoutManager(new GridLayoutManager(getContext(), 2));
|
binding.soundRecyclerview.setLayoutManager(new GridLayoutManager(getContext(), 2));
|
||||||
@ -114,16 +113,6 @@ public class SoundFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void showAd(onAdAfterAction listener) {
|
|
||||||
MaxManager.startShowMaxAd(requireActivity(), new onAdAfterAction() {
|
|
||||||
@Override
|
|
||||||
public void onAction() {
|
|
||||||
listener.onAction();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分享纯文本
|
* 分享纯文本
|
||||||
*
|
*
|
||||||
|
|||||||
@ -1,11 +0,0 @@
|
|||||||
package com.sound.prankparty.max;
|
|
||||||
|
|
||||||
import com.applovin.mediation.MaxAd;
|
|
||||||
|
|
||||||
public interface MaxListener {
|
|
||||||
void onFail(MaxAd ad);
|
|
||||||
|
|
||||||
void onShowSuccess(MaxAd ad);
|
|
||||||
|
|
||||||
void onHidden();
|
|
||||||
}
|
|
||||||
@ -1,185 +0,0 @@
|
|||||||
package com.sound.prankparty.max;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
import com.applovin.mediation.MaxAd;
|
|
||||||
import com.applovin.mediation.MaxAdListener;
|
|
||||||
import com.applovin.mediation.MaxError;
|
|
||||||
import com.applovin.mediation.ads.MaxInterstitialAd;
|
|
||||||
import com.sound.MainApplication;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class MaxManager {
|
|
||||||
/**
|
|
||||||
* Keyboard_inter_1
|
|
||||||
* 7c434fe5706c6992
|
|
||||||
* Keyboard_inter_2
|
|
||||||
* 00624c6bceb0316f
|
|
||||||
* Keyboard_inter_3
|
|
||||||
* 98d734a39afa4806
|
|
||||||
* Keyboard_inter_4
|
|
||||||
* b034a4f35be23afe
|
|
||||||
*/
|
|
||||||
private static final String one_AD = "7c434fe5706c6992";
|
|
||||||
private static final String two_Ad = "00624c6bceb0316f";
|
|
||||||
private static final String three_ad = "98d734a39afa4806";
|
|
||||||
private static final String four_ad = "b034a4f35be23afe";
|
|
||||||
|
|
||||||
|
|
||||||
public static final int type_no_cache = 0;
|
|
||||||
public static final int type_has_cache = 1;
|
|
||||||
public static final int type_show_success = 2;
|
|
||||||
public static final int type_show_close = 3;
|
|
||||||
public static final int type_show_fail = 4;
|
|
||||||
|
|
||||||
private static List<MaxInterstitialAd> adList = new ArrayList<>();
|
|
||||||
|
|
||||||
public static MaxInterstitialAd getAd(List<MaxInterstitialAd> list) {
|
|
||||||
Collections.shuffle(list);
|
|
||||||
for (MaxInterstitialAd ad : list) {
|
|
||||||
if (ad.isReady()) {
|
|
||||||
return ad;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<MaxInterstitialAd> onLoadAd() {
|
|
||||||
if (adList.isEmpty()) {
|
|
||||||
MaxInterstitialAd AdT = new MaxInterstitialAd(two_Ad, MainApplication.getContext());
|
|
||||||
MaxInterstitialAd AdOne = new MaxInterstitialAd(one_AD, MainApplication.getContext());
|
|
||||||
MaxInterstitialAd AdThree = new MaxInterstitialAd(three_ad, MainApplication.getContext());
|
|
||||||
MaxInterstitialAd AdFour = new MaxInterstitialAd(four_ad, MainApplication.getContext());
|
|
||||||
adList.add(AdOne);
|
|
||||||
adList.add(AdT);
|
|
||||||
adList.add(AdThree);
|
|
||||||
adList.add(AdFour);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (MaxInterstitialAd ad : adList) {
|
|
||||||
if (!ad.isReady()) {
|
|
||||||
setMyListener(ad, new MaxListener() {
|
|
||||||
@Override
|
|
||||||
public void onFail(MaxAd ad) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onShowSuccess(MaxAd ad) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onHidden() {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
ad.loadAd();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return adList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setMyListener(MaxInterstitialAd ad, MaxListener maxListener) {
|
|
||||||
ad.setListener(new MaxAdListener() {
|
|
||||||
@Override
|
|
||||||
public void onAdLoaded(@NonNull MaxAd maxAd) {
|
|
||||||
Log.d(MainApplication.TAG, "-------onAdLoaded-----maxAd=" + maxAd.getAdUnitId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAdDisplayed(@NonNull MaxAd maxAd) {
|
|
||||||
Log.d(MainApplication.TAG, "-------onAdDisplayed-----maxAd=" + maxAd.getAdUnitId());
|
|
||||||
maxListener.onShowSuccess(maxAd);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAdHidden(@NonNull MaxAd maxAd) {
|
|
||||||
Log.d(MainApplication.TAG, "-------onAdHidden-----maxAd=" + maxAd.getAdUnitId());
|
|
||||||
maxListener.onHidden();
|
|
||||||
setMyListener(ad, new MaxListener() {
|
|
||||||
@Override
|
|
||||||
public void onFail(MaxAd ad) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onShowSuccess(MaxAd ad) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onHidden() {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
ad.loadAd();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAdClicked(@NonNull MaxAd maxAd) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAdLoadFailed(@NonNull String s, @NonNull MaxError maxError) {
|
|
||||||
Log.d(MainApplication.TAG, "-------onAdLoadFailed-----s=" + s+"----maxError="+maxError.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAdDisplayFailed(@NonNull MaxAd maxAd, @NonNull MaxError maxError) {
|
|
||||||
maxListener.onFail(maxAd);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void ShowAd(Activity activity, onAdStatusListener listener) {
|
|
||||||
MaxInterstitialAd ad = MaxManager.getAd(adList);
|
|
||||||
if (ad == null) {
|
|
||||||
listener.onAdStatus(type_no_cache);
|
|
||||||
} else {
|
|
||||||
listener.onAdStatus(type_has_cache);
|
|
||||||
MaxManager.setMyListener(ad, new MaxListener() {
|
|
||||||
@Override
|
|
||||||
public void onFail(MaxAd ad) {
|
|
||||||
listener.onAdStatus(type_show_fail);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onShowSuccess(MaxAd ad) {
|
|
||||||
listener.onAdStatus(type_show_success);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onHidden() {
|
|
||||||
listener.onAdStatus(type_show_close);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
ad.showAd(activity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void startShowMaxAd(Activity activity, onAdAfterAction listener) {
|
|
||||||
MaxManager.ShowAd(activity, new onAdStatusListener() {
|
|
||||||
@Override
|
|
||||||
public void onAdStatus(int type) {
|
|
||||||
if (type == MaxManager.type_show_close || type == MaxManager.type_show_fail || type == MaxManager.type_no_cache) {
|
|
||||||
if (listener != null)
|
|
||||||
listener.onAction();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,78 +0,0 @@
|
|||||||
package com.app.wallpaper.max
|
|
||||||
|
|
||||||
import android.app.Activity
|
|
||||||
import android.content.BroadcastReceiver
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.Intent
|
|
||||||
import android.content.IntentFilter
|
|
||||||
import android.os.CountDownTimer
|
|
||||||
import android.util.Log
|
|
||||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
|
||||||
|
|
||||||
import com.applovin.mediation.ads.MaxInterstitialAd
|
|
||||||
import com.sound.MainApplication
|
|
||||||
import com.sound.prankparty.max.MaxManager
|
|
||||||
|
|
||||||
|
|
||||||
object WelComManager {
|
|
||||||
|
|
||||||
private lateinit var timer: CountDownTimer
|
|
||||||
|
|
||||||
private var need_Show = true
|
|
||||||
|
|
||||||
private lateinit var lists: List<MaxInterstitialAd>
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun initTimer(activity: Activity, countTime: Long,countAction: (Long) -> Unit, goMainAction: () -> Unit): CountDownTimer {
|
|
||||||
need_Show = true
|
|
||||||
timer = object : CountDownTimer(countTime, 100) {
|
|
||||||
override fun onTick(millisUntilFinished: Long) {
|
|
||||||
countAction.invoke(millisUntilFinished)
|
|
||||||
if (need_Show) {
|
|
||||||
MaxManager.ShowAd(activity) {
|
|
||||||
Log.d(MainApplication.TAG, "--onTick----------it=$it")
|
|
||||||
if (it == MaxManager.type_has_cache) {
|
|
||||||
need_Show = false
|
|
||||||
}
|
|
||||||
if (it == MaxManager.type_show_close || it == MaxManager.type_show_fail) {
|
|
||||||
Log.d(MainApplication.TAG, "--onTick---------enter")
|
|
||||||
goMainAction.invoke()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onFinish() {
|
|
||||||
if (need_Show) {
|
|
||||||
MaxManager.ShowAd(activity) {
|
|
||||||
if (it == MaxManager.type_show_close || it == MaxManager.type_show_fail || it == MaxManager.type_no_cache) {
|
|
||||||
Log.d(MainApplication.TAG, "--onFinish---------enter")
|
|
||||||
goMainAction.invoke()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
startAd(activity)
|
|
||||||
return timer
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun startAd(activity: Activity) {
|
|
||||||
if (!MainApplication.initSDK) {
|
|
||||||
LocalBroadcastManager.getInstance(activity)
|
|
||||||
.registerReceiver(object : BroadcastReceiver() {
|
|
||||||
override fun onReceive(context: Context?, intent: Intent?) {
|
|
||||||
lists = MaxManager.onLoadAd()
|
|
||||||
timer.start()
|
|
||||||
Log.d(MainApplication.TAG, "------------1sucess")
|
|
||||||
}
|
|
||||||
}, IntentFilter(MainApplication.AD_BROADCAST))
|
|
||||||
} else {
|
|
||||||
lists = MaxManager.onLoadAd()
|
|
||||||
timer.start()
|
|
||||||
Log.d(MainApplication.TAG, "------------2sucess")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
package com.sound.prankparty.max;
|
|
||||||
|
|
||||||
public interface onAdAfterAction {
|
|
||||||
|
|
||||||
void onAction();
|
|
||||||
}
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
package com.sound.prankparty.max;
|
|
||||||
|
|
||||||
public interface onAdStatusListener {
|
|
||||||
|
|
||||||
void onAdStatus(int type);
|
|
||||||
}
|
|
||||||
10
app/src/main/java/com/sound/prankparty/topon/AdListener.java
Normal file
10
app/src/main/java/com/sound/prankparty/topon/AdListener.java
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package com.sound.prankparty.topon;
|
||||||
|
|
||||||
|
public interface AdListener {
|
||||||
|
void loadFail(String placeId);
|
||||||
|
void showSuccess();
|
||||||
|
|
||||||
|
void showFail();
|
||||||
|
|
||||||
|
void showClose();
|
||||||
|
}
|
||||||
254
app/src/main/java/com/sound/prankparty/topon/AdManager.java
Normal file
254
app/src/main/java/com/sound/prankparty/topon/AdManager.java
Normal file
@ -0,0 +1,254 @@
|
|||||||
|
package com.sound.prankparty.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.sound.MainApplication;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Prank _Int_3
|
||||||
|
n670f349b6985b
|
||||||
|
Prank _Int_2
|
||||||
|
n670f349b1b35c
|
||||||
|
Prank _Int_1
|
||||||
|
n670f349ab99bc
|
||||||
|
*/
|
||||||
|
|
||||||
|
private static final String place1Id = "n670f349ab99bc";
|
||||||
|
private static final String place2Id = "n670f349b1b35c";
|
||||||
|
private static final String place3Id = "n670f349b6985b";
|
||||||
|
|
||||||
|
|
||||||
|
private static boolean place1LoadFail = false;
|
||||||
|
private static boolean place2LoadFail = false;
|
||||||
|
private static boolean place3LoadFail = false;
|
||||||
|
|
||||||
|
private static boolean alreadyShow = false;
|
||||||
|
|
||||||
|
private static List<ATInterstitial> list = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
|
public static void loadAllAd() {
|
||||||
|
if (list.isEmpty()) {
|
||||||
|
ATInterstitial mInterstitialAd1 = new ATInterstitial(MainApplication.getContext(), place1Id);
|
||||||
|
ATInterstitial mInterstitialAd2 = new ATInterstitial(MainApplication.getContext(), place2Id);
|
||||||
|
ATInterstitial mInterstitialAd3 = new ATInterstitial(MainApplication.getContext(), 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(MainApplication.TAG, "-has Cache------------");
|
||||||
|
return ad;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Log.d(MainApplication.TAG, "-No Cache------------");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setCallBack(ATInterstitial ad, AdListener listener) {
|
||||||
|
ad.setAdListener(new ATInterstitialListener() {
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInterstitialAdLoaded() {
|
||||||
|
Log.d(MainApplication.TAG, "LoadLoaded " + ad.mPlacementId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInterstitialAdLoadFail(AdError adError) {
|
||||||
|
listener.loadFail(ad.mPlacementId);
|
||||||
|
Log.d(MainApplication.TAG, "LoadFail:--" + ad.mPlacementId + "--" + adError.getCode() + "---" + adError.getDesc());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInterstitialAdClicked(ATAdInfo atAdInfo) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInterstitialAdShow(ATAdInfo atAdInfo) {
|
||||||
|
Log.d(MainApplication.TAG, "AdShow " + atAdInfo.getShowId());
|
||||||
|
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 void setAlreadyShow(){
|
||||||
|
alreadyShow = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
package com.sound.prankparty.topon;
|
||||||
|
|
||||||
|
public interface AdStatusAction {
|
||||||
|
void onStatus(int adType);
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
package com.sound.prankparty.topon;
|
||||||
|
|
||||||
|
public interface CountAction {
|
||||||
|
void onCount(long millisUntilFinished);
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
package com.sound.prankparty.topon;
|
||||||
|
|
||||||
|
public interface GoMainAction {
|
||||||
|
void onGo();
|
||||||
|
}
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
package com.sound.prankparty.topon;
|
||||||
|
|
||||||
|
public interface onActionListener {
|
||||||
|
|
||||||
|
void onAction();
|
||||||
|
}
|
||||||
@ -5,6 +5,5 @@ plugins {
|
|||||||
}
|
}
|
||||||
buildscript {
|
buildscript {
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath("com.applovin.quality:AppLovinQualityServiceGradlePlugin:+")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -6,7 +6,7 @@
|
|||||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||||
# Specifies the JVM arguments used for the daemon process.
|
# Specifies the JVM arguments used for the daemon process.
|
||||||
# The setting is particularly useful for tweaking memory settings.
|
# 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.
|
# When configured, Gradle will run in incubating parallel mode.
|
||||||
# This option should only be used with decoupled projects. For more details, visit
|
# This option should only be used with decoupled projects. For more details, visit
|
||||||
# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
|
# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
|
||||||
|
|||||||
@ -10,8 +10,6 @@ pluginManagement {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
|
|
||||||
maven { url = uri("https://artifacts.applovin.com/android") }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dependencyResolutionManagement {
|
dependencyResolutionManagement {
|
||||||
@ -20,8 +18,27 @@ dependencyResolutionManagement {
|
|||||||
google()
|
google()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|
||||||
maven { url = uri("https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea") }
|
//Anythink(Core)
|
||||||
maven { url = uri("https://artifact.bytedance.com/repository/pangle") }
|
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")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user