V1.0.1(3) 接入topon
This commit is contained in:
parent
f6dfb665f9
commit
d75ef07e97
@ -15,8 +15,8 @@ android {
|
||||
applicationId = "com.air.airhornprank"
|
||||
minSdk = 23
|
||||
targetSdk = 34
|
||||
versionCode = 1
|
||||
versionName = "1.0.0"
|
||||
versionCode = 3
|
||||
versionName = "1.0.1"
|
||||
setProperty(
|
||||
"archivesBaseName",
|
||||
"airhornprank_v" + versionName + "(${versionCode})_$timestamp"
|
||||
@ -58,6 +58,98 @@ dependencies {
|
||||
kapt("androidx.room:room-compiler:$room_version")
|
||||
|
||||
implementation("com.airbnb.android:lottie:6.0.0")
|
||||
implementation ("javax.annotation:javax.annotation-api:1.3.2")
|
||||
implementation("javax.annotation:javax.annotation-api:1.3.2")
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------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.1.0")
|
||||
|
||||
//----------------------------------------------TopOn
|
||||
|
||||
}
|
||||
130
app/proguard-rules.pro
vendored
130
app/proguard-rules.pro
vendored
@ -34,3 +34,133 @@
|
||||
# Please add these rules to your existing keep rules in order to suppress warnings.
|
||||
# This is generated automatically by the Android Gradle plugin.
|
||||
-dontwarn javax.annotation.Nullable
|
||||
|
||||
|
||||
#---------------------------------------------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
|
||||
|
||||
@ -11,10 +11,27 @@
|
||||
"type": "SINGLE",
|
||||
"filters": [],
|
||||
"attributes": [],
|
||||
"versionCode": 1,
|
||||
"versionName": "1.0.0",
|
||||
"outputFile": "airhornprank_v1.0.0(1)_10_24_10_27-release.apk"
|
||||
"versionCode": 3,
|
||||
"versionName": "1.0.1",
|
||||
"outputFile": "airhornprank_v1.0.1(3)_10_28_11_28-release.apk"
|
||||
}
|
||||
],
|
||||
"elementType": "File"
|
||||
"elementType": "File",
|
||||
"baselineProfiles": [
|
||||
{
|
||||
"minApi": 28,
|
||||
"maxApi": 30,
|
||||
"baselineProfiles": [
|
||||
"baselineProfiles/1/airhornprank_v1.0.1(3)_10_28_11_28-release.dm"
|
||||
]
|
||||
},
|
||||
{
|
||||
"minApi": 31,
|
||||
"maxApi": 2147483647,
|
||||
"baselineProfiles": [
|
||||
"baselineProfiles/0/airhornprank_v1.0.1(3)_10_28_11_28-release.dm"
|
||||
]
|
||||
}
|
||||
],
|
||||
"minSdkVersionForDexing": 23
|
||||
}
|
||||
@ -2,11 +2,15 @@ package com.air.airhornprank;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.SharedPreferences;
|
||||
import android.util.Log;
|
||||
|
||||
|
||||
import com.air.airhornprank.data.MyDataBase;
|
||||
import com.air.airhornprank.data.Mydata;
|
||||
import com.air.airhornprank.tool.Mytools;
|
||||
import com.air.airhornprank.topon.AdManager;
|
||||
import com.anythink.core.api.ATSDK;
|
||||
import com.anythink.core.api.NetTrafficeCallback;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -27,15 +31,53 @@ public class PrankSkin extends Application {
|
||||
private static final String KEY_IS_CREATE = "iscreate";
|
||||
private static List<Mydata> mydataList = new ArrayList<>();
|
||||
|
||||
|
||||
private static final String AppKey = "a48c3836ca5119a551cf008e2c2a57e7a";
|
||||
private static final String APPId = "h671ef3aa249f4";
|
||||
|
||||
public static String TAG = "-------AirHornPrank----------";
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
app = this;
|
||||
|
||||
initSDk();
|
||||
|
||||
initData();
|
||||
initCreate();
|
||||
}
|
||||
|
||||
|
||||
private void initSDk() {
|
||||
|
||||
ATSDK.checkIsEuTraffic(this, new NetTrafficeCallback() {
|
||||
|
||||
@Override
|
||||
public void onResultCallback(boolean isEU) {
|
||||
Log.e(TAG, "onResultCallback:" + isEU);
|
||||
if (isEU && ATSDK.getGDPRDataLevel(PrankSkin.this) == ATSDK.UNKNOWN) {
|
||||
ATSDK.showGdprAuth(PrankSkin.this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onErrorCallback(String errorMsg) {
|
||||
Log.e(TAG, "onErrorCallback:" + errorMsg);
|
||||
}
|
||||
});
|
||||
|
||||
ATSDK.init(this, APPId, AppKey);
|
||||
AdManager.loadAllAd();
|
||||
//测试工具
|
||||
// ATDebuggerUITest.showDebuggerUI(this,"a8dd4a3f1c38a5a3cadb4f39385fb682af63df07");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void initCreate() {
|
||||
Mytools.runIO(new Runnable() {
|
||||
@Override
|
||||
|
||||
@ -19,6 +19,8 @@ import com.air.airhornprank.data.Mydata;
|
||||
import com.air.airhornprank.databinding.ActivityListBinding;
|
||||
import com.air.airhornprank.tool.Mytools;
|
||||
import com.air.airhornprank.tool.StaticValue;
|
||||
import com.air.airhornprank.topon.AdManager;
|
||||
import com.air.airhornprank.topon.onActionListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -36,6 +38,8 @@ public class ListActivity extends AppCompatActivity {
|
||||
binding = ActivityListBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
AdManager.loadAllAd();
|
||||
|
||||
EdgeToEdge.enable(this);
|
||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.activity_list), (v, insets) -> {
|
||||
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||
@ -48,7 +52,12 @@ public class ListActivity extends AppCompatActivity {
|
||||
binding.listBack.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
AdManager.showTopOn(ListActivity.this, new onActionListener() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@ -76,8 +85,29 @@ public class ListActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
private void initView(List<Mydata> allData) {
|
||||
thumAdapter = new ListAdapter(this, allData, color);
|
||||
binding.preListRv.setAdapter(thumAdapter);
|
||||
binding.preListRv.setLayoutManager(new GridLayoutManager(this, 3));
|
||||
// 调用 AdManager 中的 showTopOn 方法来展示广告
|
||||
AdManager.showTopOn(this, new onActionListener() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
// 在广告展示完成后初始化 RecyclerView
|
||||
thumAdapter = new ListAdapter(ListActivity.this, allData, color);
|
||||
binding.preListRv.setAdapter(thumAdapter);
|
||||
binding.preListRv.setLayoutManager(new GridLayoutManager(ListActivity.this, 3));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
// 在按下系统返回键时调用 AdManager 的 showTopOn 方法
|
||||
super.onBackPressed();
|
||||
AdManager.showTopOn(this, new onActionListener() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
ListActivity.super.onBackPressed();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -20,6 +20,8 @@ import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.SeekBar;
|
||||
|
||||
import com.air.airhornprank.topon.AdManager;
|
||||
import com.air.airhornprank.topon.onActionListener;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.target.CustomTarget;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
@ -52,6 +54,8 @@ public class PreViewActivity extends AppCompatActivity {
|
||||
binding = ActivityPreViewBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
AdManager.loadAllAd();
|
||||
|
||||
EdgeToEdge.enable(this);
|
||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.activity_preview), (v, insets) -> {
|
||||
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||
@ -102,11 +106,20 @@ public class PreViewActivity extends AppCompatActivity {
|
||||
binding.prePlay.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
try {
|
||||
playprank();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
AdManager.showTopOn(PreViewActivity.this, new onActionListener() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
|
||||
try {
|
||||
playprank();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ public class SettingActivity extends AppCompatActivity {
|
||||
|
||||
private void initEvent() {
|
||||
binding.settingBack.setOnClickListener(v -> finish());
|
||||
binding.versionText.setText("1.0.0");
|
||||
binding.versionText.setText("1.0.1");
|
||||
|
||||
binding.settingPrivacy.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
||||
@ -1,61 +1,87 @@
|
||||
package com.air.airhornprank.activity;
|
||||
|
||||
import androidx.activity.EdgeToEdge;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.CountDownTimer;
|
||||
import android.util.Log;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.air.airhornprank.R;
|
||||
import com.air.airhornprank.databinding.ActivitySplashBinding;
|
||||
import com.air.airhornprank.tool.CustomProgressBar;
|
||||
import com.air.airhornprank.topon.AdManager;
|
||||
|
||||
public class SplashActivity extends AppCompatActivity {
|
||||
ActivitySplashBinding binding;
|
||||
private CustomProgressBar progressBar;
|
||||
private CountDownTimer countDownTimer;
|
||||
private float i = 0;
|
||||
|
||||
private static final long totalTime = 11000; // 倒计时总时间
|
||||
private static final String TAG = "InitialActivity"; // 日志标签
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
binding = ActivitySplashBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
setContentView(R.layout.activity_splash);
|
||||
|
||||
EdgeToEdge.enable(this);
|
||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.activity_splash), (v, insets) -> {
|
||||
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
||||
return insets;
|
||||
});
|
||||
// 日志输出:进入 onCreate 方法
|
||||
Log.d(TAG, "onCreate: InitialActivity started");
|
||||
|
||||
countDownTimer = new CountDownTimer(2100, 100) {
|
||||
@Override
|
||||
public void onTick(long l) {
|
||||
i++;
|
||||
binding.splashPg.setProgress(i);
|
||||
// if (!isAlreadyShow) {
|
||||
// showAd(false);
|
||||
// }
|
||||
}
|
||||
// 加载广告
|
||||
AdManager.loadAllAd();
|
||||
Log.d(TAG, "onCreate: Ads loaded");
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
// if (!isAlreadyShow) {
|
||||
// showAd(true);
|
||||
// }
|
||||
starMainactivity();
|
||||
}
|
||||
};
|
||||
progressBar = findViewById(R.id.splash_pg);
|
||||
|
||||
// 重置进度条到初始状态
|
||||
progressBar.setProgress(0);
|
||||
|
||||
AdManager.setAlreadyShow();
|
||||
|
||||
// 每次进入活动时,重新创建并启动倒计时
|
||||
countDownTimer = AdManager.showWelcomeAd(
|
||||
SplashActivity.this,
|
||||
totalTime,
|
||||
millisUntilFinished -> {
|
||||
int percentage = (int) (100 - (float) millisUntilFinished / totalTime * 100);
|
||||
progressBar.setProgress(percentage);
|
||||
|
||||
// 日志输出:倒计时进度
|
||||
Log.d(TAG, "onCreate: Progress updated to " + percentage + "%");
|
||||
},
|
||||
this::startMain // 倒计时结束或广告展示结束时,跳转主界面
|
||||
);
|
||||
|
||||
// 日志输出:倒计时开始
|
||||
Log.d(TAG, "onCreate: Countdown timer started");
|
||||
countDownTimer.start();
|
||||
}
|
||||
|
||||
private void starMainactivity() {
|
||||
// 跳转到主界面的方法
|
||||
private void startMain() {
|
||||
// 确保进度条更新至满值
|
||||
progressBar.setProgress(100);
|
||||
|
||||
// 日志输出:倒计时结束,准备跳转到主界面
|
||||
Log.d(TAG, "startMain: Countdown finished, starting MainActivity");
|
||||
|
||||
// 跳转到主界面
|
||||
Intent intent = new Intent(SplashActivity.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
// 日志输出:进入 onDestroy 方法
|
||||
Log.d(TAG, "onDestroy: InitialActivity is being destroyed");
|
||||
|
||||
// 在页面销毁时,清理倒计时资源
|
||||
if (countDownTimer != null) {
|
||||
countDownTimer.cancel();
|
||||
Log.d(TAG, "onDestroy: Countdown timer cancelled");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -34,6 +34,8 @@ import com.air.airhornprank.data.MyDataBase;
|
||||
import com.air.airhornprank.data.Mydata;
|
||||
import com.air.airhornprank.databinding.FragmentCustomBinding;
|
||||
import com.air.airhornprank.tool.StaticValue;
|
||||
import com.air.airhornprank.topon.AdManager;
|
||||
import com.air.airhornprank.topon.onActionListener;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@ -57,6 +59,8 @@ public class CustomFragment extends Fragment {
|
||||
Bundle savedInstanceState) {
|
||||
binding = FragmentCustomBinding.inflate(inflater, container, false);
|
||||
|
||||
AdManager.loadAllAd();
|
||||
|
||||
initData();
|
||||
|
||||
initEvent();
|
||||
@ -99,13 +103,13 @@ public class CustomFragment extends Fragment {
|
||||
binding.add.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showDialog();
|
||||
showDialogWithAd();
|
||||
}
|
||||
});
|
||||
binding.addHide.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showDialog();
|
||||
showDialogWithAd();
|
||||
}
|
||||
});
|
||||
binding.customDelete.setOnClickListener(new View.OnClickListener() {
|
||||
@ -117,6 +121,18 @@ public class CustomFragment extends Fragment {
|
||||
});
|
||||
}
|
||||
|
||||
private void showDialogWithAd() {
|
||||
// 调用 AdManager 的 showTopOn 方法来展示广告
|
||||
AdManager.showTopOn(getActivity(), new onActionListener() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
// 广告展示完成后调用 showDialog 方法
|
||||
showDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void showDialog() {
|
||||
dialog = new Dialog(requireContext());
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
|
||||
10
app/src/main/java/com/air/airhornprank/topon/AdListener.java
Normal file
10
app/src/main/java/com/air/airhornprank/topon/AdListener.java
Normal file
@ -0,0 +1,10 @@
|
||||
package com.air.airhornprank.topon;
|
||||
|
||||
public interface AdListener {
|
||||
void loadFail(String placeId);
|
||||
void showSuccess();
|
||||
|
||||
void showFail();
|
||||
|
||||
void showClose();
|
||||
}
|
||||
252
app/src/main/java/com/air/airhornprank/topon/AdManager.java
Normal file
252
app/src/main/java/com/air/airhornprank/topon/AdManager.java
Normal file
@ -0,0 +1,252 @@
|
||||
package com.air.airhornprank.topon;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.CountDownTimer;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.air.airhornprank.PrankSkin;
|
||||
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 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
|
||||
* n671ef3c8437e7
|
||||
* prank_int_2
|
||||
* n671ef3c81a343
|
||||
* prank_int_1
|
||||
* n671ef3c7e099a
|
||||
*/
|
||||
|
||||
private static final String place1Id = "n671ef3c7e099a";
|
||||
private static final String place2Id = "n671ef3c81a343";
|
||||
private static final String place3Id = "n671ef3c8437e7";
|
||||
|
||||
|
||||
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(PrankSkin.app, place1Id);
|
||||
ATInterstitial mInterstitialAd2 = new ATInterstitial(PrankSkin.app, place2Id);
|
||||
ATInterstitial mInterstitialAd3 = new ATInterstitial(PrankSkin.app, 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(PrankSkin.TAG, "-has Cache------------");
|
||||
return ad;
|
||||
}
|
||||
}
|
||||
Log.d(PrankSkin.TAG, "-No Cache------------");
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void setCallBack(ATInterstitial ad, AdListener listener) {
|
||||
ad.setAdListener(new ATInterstitialListener() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onInterstitialAdLoaded() {
|
||||
Log.d(PrankSkin.TAG, "LoadLoaded " + ad.mPlacementId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInterstitialAdLoadFail(AdError adError) {
|
||||
listener.loadFail(ad.mPlacementId);
|
||||
Log.d(PrankSkin.TAG, "LoadFail:--" + ad.mPlacementId + "--" + adError.getCode() + "---" + adError.getDesc());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInterstitialAdClicked(ATAdInfo atAdInfo) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInterstitialAdShow(ATAdInfo atAdInfo) {
|
||||
Log.d(PrankSkin.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.air.airhornprank.topon;
|
||||
|
||||
public interface AdStatusAction {
|
||||
void onStatus(int adType);
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
package com.air.airhornprank.topon;
|
||||
|
||||
public interface CountAction {
|
||||
void onCount(long millisUntilFinished);
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
package com.air.airhornprank.topon;
|
||||
|
||||
public interface GoMainAction {
|
||||
void onGo();
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
package com.air.airhornprank.topon;
|
||||
|
||||
public interface onActionListener {
|
||||
|
||||
void onAction();
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
plugins {
|
||||
id("com.android.application") version "8.1.3" apply false
|
||||
id("com.android.application") version "8.5.1" apply false
|
||||
id("org.jetbrains.kotlin.android") version "1.9.0" apply false
|
||||
}
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
||||
#Wed Jul 31 10:28:15 CST 2024
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@ -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")
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user