V1.0.1(7),接入Max广告
This commit is contained in:
parent
591e2834b8
commit
ad1a65bf48
BIN
.safedk/api/SafeDKAndroid-6.4.6.jar
Normal file
BIN
.safedk/api/SafeDKAndroid-6.4.6.jar
Normal file
Binary file not shown.
17
.safedk/app_sdks.lst
Normal file
17
.safedk/app_sdks.lst
Normal file
@ -0,0 +1,17 @@
|
||||
106f9be0e66f52f36eaaaff4dd231971
|
||||
75939c4ce23c53ad9534d43be176b3e9
|
||||
217e8f437c9fc4244d6e74653ac8a8c7
|
||||
66b774de6608db14a84e972fba1ec954
|
||||
e1c9ddef73e5621f62c717badf1be3f2
|
||||
daaea35726ab7cd457ab61d4538fb822
|
||||
946dbe0d5ed7fee91c8ece64d035e70b
|
||||
1be9e72506f3307ce6a9e78d26d65bd0
|
||||
7eac188d3286b05ccbba774f63a2c049
|
||||
4df96d3bc9afd17b812e65e6c6add1ef
|
||||
974322f19d813702ea048d95288d2b8c
|
||||
29015bbfcc182d80e7f75bd2c38e4521
|
||||
dd2971b0681141d57b221687791ad1bd
|
||||
86a0d598cde251321e21a0da4ab94065
|
||||
74616804a7dc29147dfb0afe122a9fd2
|
||||
35695de726f6044576c830bf197f36f7
|
||||
|
||||
BIN
.safedk/dex/SafeDKAndroid-6.4.6.dex
Normal file
BIN
.safedk/dex/SafeDKAndroid-6.4.6.dex
Normal file
Binary file not shown.
BIN
.safedk/dex/android-support-multidex.dex
Normal file
BIN
.safedk/dex/android-support-multidex.dex
Normal file
Binary file not shown.
2
.safedk/hashes.safedk
Normal file
2
.safedk/hashes.safedk
Normal file
@ -0,0 +1,2 @@
|
||||
#Fri Sep 27 18:24:10 CST 2024
|
||||
json=-2010694683
|
||||
1
.safedk/list.enc
Normal file
1
.safedk/list.enc
Normal file
File diff suppressed because one or more lines are too long
5
.safedk/plugin.properties
Normal file
5
.safedk/plugin.properties
Normal file
@ -0,0 +1,5 @@
|
||||
#
|
||||
#Fri Sep 27 18:24:10 CST 2024
|
||||
sdk_analysis_plugin_version=5.4.6
|
||||
set_multidex=true
|
||||
y87o4e7vb5bbqzuGVTFyOIfZiyBG0Nf0Ksq8S3m2MJOHf_A5BcWGJnKuQqoxwxVvtdQdiTC4O3MPzFwy8rJ9Cc=3cUMfTcsZKzlJevxK4IkNysgDAeQA4B5w332p3g8B9ZAgC54WQNZLVxuxnCx4sCHA5StLJnDTAFa68mFTi8rd8
|
||||
34
.safedk/proguard-safedk.pro
Normal file
34
.safedk/proguard-safedk.pro
Normal file
@ -0,0 +1,34 @@
|
||||
-keep class androidx.multidex.** { *; }
|
||||
-keep class androidx.browser.customtabs.CustomTabsIntent { *; }
|
||||
-keep class androidx.** {
|
||||
*** startActivityForResult(***);
|
||||
*** startActivity(***);
|
||||
}
|
||||
-keep class android.support.multidex.** { *; }
|
||||
-keep class android.support.v4.app.** { *; }
|
||||
-keep class com.google.android.gms.location.FusedLocationProviderApi { *; }
|
||||
-keep class com.google.android.gms.location.LocationListener { *; }
|
||||
-keep class io.fabric.sdk.android.** { *; }
|
||||
-keep class okio.** { *; }
|
||||
-keep class retrofit2.** { *; }
|
||||
-keep class okhttp3.** { *; }
|
||||
-keep class com.squareup.okhttp.** { *; }
|
||||
-keep class com.android.volley.** { *; }
|
||||
-keep class com.flurry.** { *; }
|
||||
-keep class org.apache.** { *; }
|
||||
-keep class com.applovin.** { *; }
|
||||
-keep class com.google.android.gms.ads.** { *; }
|
||||
-keep class com.ironsource.** { *; }
|
||||
-keep class com.fyber.inneractive.** { *; }
|
||||
-keep class com.vungle.** { *; }
|
||||
-keep class com.unity3d.ads.** { *; }
|
||||
-keep class com.unity3d.services.** { *; }
|
||||
-keep class com.mintegral.msdk.** { *; }
|
||||
-keep class com.mbridge.msdk.** { *; }
|
||||
-keep class com.adcolony.sdk.** { *; }
|
||||
-keep class com.inmobi.** { *; }
|
||||
-keep class com.five_corp.** { *; }
|
||||
-keep class com.bytedance.** { *; }
|
||||
-keep class com.smaato.** { *; }
|
||||
-keep class com.safedk.** { *; }
|
||||
-keep class com.applovin.quality.** { *; }
|
||||
@ -4,8 +4,13 @@ import java.text.SimpleDateFormat
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.android.application)
|
||||
id("applovin-quality-service")
|
||||
id("org.jetbrains.kotlin.android")
|
||||
id ("kotlin-kapt")
|
||||
}
|
||||
applovin{
|
||||
apiKey = "y87o4e7vb5bbqzuGVTFyOIfZiyBG0Nf0Ksq8S3m2MJOHf_A5BcWGJnKuQqoxwxVvtdQdiTC4O3MPzFwy8rJ9Cc"
|
||||
}
|
||||
|
||||
val timestamp = SimpleDateFormat("MM_dd_HH_mm").format(Date())
|
||||
|
||||
|
||||
@ -21,8 +26,8 @@ android {
|
||||
applicationId = "com.sound.prankparty"
|
||||
minSdk = 23
|
||||
targetSdk = 34
|
||||
versionCode = 1
|
||||
versionName = "1.0.0"
|
||||
versionCode = 2
|
||||
versionName = "1.0.1"
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
@ -38,6 +43,9 @@ android {
|
||||
)
|
||||
}
|
||||
}
|
||||
kotlinOptions{
|
||||
jvmTarget ="1.8"
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
@ -59,4 +67,18 @@ dependencies {
|
||||
implementation("com.airbnb.android:lottie:6.5.0")
|
||||
implementation ("androidx.room:room-runtime:2.6.1")
|
||||
annotationProcessor ("androidx.room:room-compiler:2.6.1")
|
||||
|
||||
|
||||
//--------------------------MAX(Liftoff Monetize(vungle)、Mintegral、Pangle、Unity Ads、inmobi)
|
||||
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:+")
|
||||
implementation("com.squareup.picasso:picasso:2.71828")
|
||||
implementation("androidx.recyclerview:recyclerview:1.1.0")
|
||||
//MAX
|
||||
|
||||
}
|
||||
@ -2,6 +2,14 @@ package com.sound;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
import com.applovin.sdk.AppLovinMediationProvider;
|
||||
import com.applovin.sdk.AppLovinSdk;
|
||||
import com.applovin.sdk.AppLovinSdkConfiguration;
|
||||
import com.applovin.sdk.AppLovinSdkInitializationConfiguration;
|
||||
|
||||
public class MainApplication extends Application {
|
||||
/**
|
||||
@ -9,18 +17,28 @@ public class MainApplication extends Application {
|
||||
*/
|
||||
private static Context mContext;
|
||||
|
||||
public static final String TAG = "--------------";
|
||||
public static final String AD_BROADCAST = "on_success_action";
|
||||
private static final String MAX_SDK = "Kwbl2wDLdNgp3kE8gk7WW_CCEBAee8xOIUJZQtEdNZX1iwclqFHlbgrUJt_g4zzSHJosSKIN13gv5Lqoe0bPvg";
|
||||
public static Boolean initSDK = false;
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
//获取应用的上下文并赋值给 mContext
|
||||
mContext = getApplicationContext();
|
||||
|
||||
initSdk();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取context
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static Context getContext(){
|
||||
public static Context getContext() {
|
||||
return mContext;
|
||||
}
|
||||
|
||||
@ -30,4 +48,23 @@ public class MainApplication extends Application {
|
||||
super.onLowMemory();
|
||||
}
|
||||
|
||||
|
||||
private void initSdk() {
|
||||
|
||||
AppLovinSdkInitializationConfiguration initConfig = AppLovinSdkInitializationConfiguration.builder(MAX_SDK, this)
|
||||
.setMediationProvider(AppLovinMediationProvider.MAX)
|
||||
.build();
|
||||
AppLovinSdk.getInstance(this).initialize(initConfig, new AppLovinSdk.SdkInitializationListener() {
|
||||
@Override
|
||||
public void onSdkInitialized(final AppLovinSdkConfiguration sdkConfig) {
|
||||
initSDK = true;
|
||||
LocalBroadcastManager.getInstance(mContext).sendBroadcast(new Intent(AD_BROADCAST));
|
||||
}
|
||||
});
|
||||
AppLovinSdk.getInstance(this).getSettings().setVerboseLogging(true);
|
||||
//MAX广告测试
|
||||
// AppLovinSdk.getInstance( this ).showMediationDebugger();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package com.sound.prankparty.Activity;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
@ -11,6 +12,8 @@ import com.sound.prankparty.JSON.Category;
|
||||
import com.sound.prankparty.JSON.SoundItem;
|
||||
import com.sound.prankparty.Utils.ItemDecoration;
|
||||
import com.sound.prankparty.databinding.ActivityAirhonrBinding;
|
||||
import com.sound.prankparty.max.MaxManager;
|
||||
import com.sound.prankparty.max.onAdAfterAction;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -25,6 +28,8 @@ public class AirHornActivity extends AppCompatActivity {
|
||||
binding = ActivityAirhonrBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
MaxManager.onLoadAd();
|
||||
|
||||
binding.airHornRecyclerview.setLayoutManager(new GridLayoutManager(this, 3));
|
||||
|
||||
// 接收传递的 List<Category> 对象
|
||||
@ -39,13 +44,48 @@ public class AirHornActivity extends AppCompatActivity {
|
||||
List<SoundItem> soundItemList = categories.getSoundItemList();
|
||||
String categoryName = categories.getCategoryName();
|
||||
|
||||
binding.airHornRecyclerview.setAdapter(new AirHornRecyclerViewAdapter(this, soundItemList,receivedColor));
|
||||
binding.airHornRecyclerview.setAdapter(new AirHornRecyclerViewAdapter(this, soundItemList,receivedColor,AirHornActivity.this));
|
||||
|
||||
binding.airHornTitle.setText(categoryName);
|
||||
binding.airHornBack.setOnClickListener(v -> finish());
|
||||
binding.airHornBack.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showAd(new onAdAfterAction() {
|
||||
|
||||
@Override
|
||||
public void onAction() {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// 为 RecyclerView 添加自定义的间距装饰。
|
||||
ItemDecoration itemDecoration = new ItemDecoration(16, 19, 10);
|
||||
binding.airHornRecyclerview.addItemDecoration(itemDecoration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
showAd(new onAdAfterAction() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void showAd(onAdAfterAction listener) {
|
||||
MaxManager.startShowMaxAd(this, new onAdAfterAction() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
listener.onAction();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -27,6 +27,8 @@ import com.sound.prankparty.Room.AppDatabase;
|
||||
import com.sound.prankparty.Room.FavoriteSounds;
|
||||
import com.sound.prankparty.Room.FavoriteSoundsDao;
|
||||
import com.sound.prankparty.databinding.ActivityPlaySoundBinding;
|
||||
import com.sound.prankparty.max.MaxManager;
|
||||
import com.sound.prankparty.max.onAdAfterAction;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@ -50,6 +52,9 @@ public class PlaySoundActivity extends AppCompatActivity {
|
||||
binding = ActivityPlaySoundBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
MaxManager.onLoadAd();
|
||||
|
||||
|
||||
// 获取音频管理器
|
||||
audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
|
||||
|
||||
@ -65,7 +70,17 @@ public class PlaySoundActivity extends AppCompatActivity {
|
||||
Log.d("qweeq", soundItemList.getMp3Url());
|
||||
|
||||
binding.text.setText(soundItemList.getTitle());
|
||||
binding.back.setOnClickListener(v -> finish());
|
||||
binding.back.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showAd(new onAdAfterAction() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// 检查数据库中是否存在该音频的收藏记录
|
||||
checkFavoriteStatus();
|
||||
@ -283,4 +298,26 @@ public class PlaySoundActivity extends AppCompatActivity {
|
||||
mediaPlayer = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
showAd(new onAdAfterAction() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void showAd(onAdAfterAction listener) {
|
||||
MaxManager.startShowMaxAd(this, new onAdAfterAction() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
listener.onAction();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,19 +2,23 @@ package com.sound.prankparty.Activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.CountDownTimer;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.app.wallpaper.max.WelComManager;
|
||||
import com.sound.prankparty.databinding.ActivitySplashBinding;
|
||||
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function0;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
|
||||
public class SplashActivity extends AppCompatActivity {
|
||||
|
||||
private static final int SPLASH_TIME_OUT = 3000; // Splash持续时间
|
||||
private static final int PROGRESS_MAX = 100; // 进度条最大值
|
||||
private ActivitySplashBinding binding;
|
||||
private long timer = 12000;
|
||||
private CountDownTimer countDownTimer;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -25,27 +29,38 @@ public class SplashActivity extends AppCompatActivity {
|
||||
|
||||
// 使用 ViewBinding 引用 progressBar
|
||||
ProgressBar progressBar = binding.progressBar;
|
||||
progressBar.setMax(PROGRESS_MAX); // 设置进度条最大值
|
||||
|
||||
// Handler处理跳转
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
Intent intent = new Intent(SplashActivity.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}, SPLASH_TIME_OUT);
|
||||
|
||||
// 进度条进展
|
||||
new Thread(() -> {
|
||||
for (int i = 0; i <= PROGRESS_MAX; i++) {
|
||||
final int progress = i;
|
||||
runOnUiThread(() -> progressBar.setProgress(progress));
|
||||
try {
|
||||
// 这里的计算使得进度条在3秒内完成
|
||||
Thread.sleep(SPLASH_TIME_OUT / PROGRESS_MAX);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
countDownTimer = WelComManager.initTimer(this, timer, new Function1<Long, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(Long aLong) {
|
||||
float l1 = (float) aLong / timer;
|
||||
float v = 100 - l1 * 100;
|
||||
progressBar.setProgress((int) v);
|
||||
return null;
|
||||
}
|
||||
}).start();
|
||||
}, new Function0<Unit>() {
|
||||
@Override
|
||||
public Unit invoke() {
|
||||
startMainActivity();
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void startMainActivity() {
|
||||
Intent intent = new Intent(SplashActivity.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if(countDownTimer!=null){
|
||||
countDownTimer.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.sound.prankparty.Adapter;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
@ -19,19 +20,23 @@ import com.sound.MainApplication;
|
||||
import com.sound.prankparty.Activity.PlaySoundActivity;
|
||||
import com.sound.prankparty.JSON.SoundItem;
|
||||
import com.sound.prankparty.R;
|
||||
import com.sound.prankparty.max.MaxManager;
|
||||
import com.sound.prankparty.max.onAdAfterAction;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AirHornRecyclerViewAdapter extends RecyclerView.Adapter<AirHornRecyclerViewAdapter.AirhonrViewHolder> {
|
||||
|
||||
private final Context context;
|
||||
private Activity activity;
|
||||
private final List<SoundItem> soundItemList;
|
||||
private final int color;
|
||||
|
||||
public AirHornRecyclerViewAdapter(Context context, List<SoundItem> soundItemList,int color) {
|
||||
public AirHornRecyclerViewAdapter(Context context, List<SoundItem> soundItemList,int color,Activity activity) {
|
||||
this.context = context;
|
||||
this.soundItemList = soundItemList;
|
||||
this.color = color;
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@ -74,9 +79,8 @@ public class AirHornRecyclerViewAdapter extends RecyclerView.Adapter<AirHornRecy
|
||||
.into(holder.imageView);
|
||||
|
||||
holder.imageView.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(context, PlaySoundActivity.class);
|
||||
intent.putExtra("1234", soundItem);
|
||||
context.startActivity(intent);
|
||||
// 调用 showAd 方法并在广告播放完成后进行跳转
|
||||
showAdAndNavigate(soundItem);
|
||||
});
|
||||
|
||||
}
|
||||
@ -86,6 +90,20 @@ public class AirHornRecyclerViewAdapter extends RecyclerView.Adapter<AirHornRecy
|
||||
return soundItemList.size();
|
||||
}
|
||||
|
||||
|
||||
private void showAdAndNavigate(SoundItem soundItem) {
|
||||
MaxManager.startShowMaxAd(activity, new onAdAfterAction() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
Intent intent = new Intent(context, PlaySoundActivity.class);
|
||||
intent.putExtra("1234", soundItem);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static class AirhonrViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
ImageView imageView;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.sound.prankparty.Adapter;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
@ -18,8 +19,12 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
|
||||
import com.sound.MainApplication;
|
||||
import com.sound.prankparty.Activity.AirHornActivity;
|
||||
import com.sound.prankparty.Activity.PlaySoundActivity;
|
||||
import com.sound.prankparty.JSON.Category;
|
||||
import com.sound.prankparty.JSON.SoundItem;
|
||||
import com.sound.prankparty.R;
|
||||
import com.sound.prankparty.max.MaxManager;
|
||||
import com.sound.prankparty.max.onAdAfterAction;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -28,10 +33,12 @@ public class SoundRecyclerViewAdapter extends RecyclerView.Adapter<SoundRecycler
|
||||
private Context context;
|
||||
private List<Category> categoryList;
|
||||
private final int[] colors;
|
||||
private Activity activity;
|
||||
|
||||
public SoundRecyclerViewAdapter(Context context, List<Category> categoryList) {
|
||||
public SoundRecyclerViewAdapter(Context context, List<Category> categoryList,Activity activity) {
|
||||
this.context = context;
|
||||
this.categoryList = categoryList;
|
||||
this.activity = activity;
|
||||
|
||||
colors = new int[]{
|
||||
ContextCompat.getColor(context, R.color.color2),
|
||||
@ -88,14 +95,24 @@ public class SoundRecyclerViewAdapter extends RecyclerView.Adapter<SoundRecycler
|
||||
.into(holder.imageView);
|
||||
|
||||
holder.imageView.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(context, AirHornActivity.class);
|
||||
intent.putExtra("color", currentColor); // 添加颜色值到 Intent
|
||||
intent.putExtra("123",category);
|
||||
context.startActivity(intent);
|
||||
// 调用 showAd 方法并在广告播放完成后进行跳转
|
||||
showAdAndNavigate(currentColor,category);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void showAdAndNavigate(int currentColor,Category category) {
|
||||
MaxManager.startShowMaxAd(activity, new onAdAfterAction() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
Intent intent = new Intent(context, AirHornActivity.class);
|
||||
intent.putExtra("color", currentColor); // 添加颜色值到 Intent
|
||||
intent.putExtra("123",category);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return categoryList.size();
|
||||
|
||||
@ -22,6 +22,8 @@ import com.sound.prankparty.Utils.ItemDecoration;
|
||||
import com.sound.prankparty.Utils.JsonParser;
|
||||
import com.sound.prankparty.Utils.LoadJSON;
|
||||
import com.sound.prankparty.databinding.FragmentSoundBinding;
|
||||
import com.sound.prankparty.max.MaxManager;
|
||||
import com.sound.prankparty.max.onAdAfterAction;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -39,6 +41,8 @@ public class SoundFragment extends Fragment {
|
||||
binding = FragmentSoundBinding.inflate(inflater, container, false);
|
||||
View view = binding.getRoot();
|
||||
|
||||
MaxManager.onLoadAd();
|
||||
|
||||
// 设置 RecyclerView 的布局管理器和适配器
|
||||
binding.soundRecyclerview.setLayoutManager(new GridLayoutManager(getContext(), 2));
|
||||
|
||||
@ -47,7 +51,7 @@ public class SoundFragment extends Fragment {
|
||||
// 解析读取的 String
|
||||
List<Category> categories = JsonParser.parseJson(jsonString);
|
||||
|
||||
binding.soundRecyclerview.setAdapter(new SoundRecyclerViewAdapter(getContext(), categories));
|
||||
binding.soundRecyclerview.setAdapter(new SoundRecyclerViewAdapter(getContext(), categories,requireActivity()));
|
||||
|
||||
// 为 RecyclerView 添加自定义的间距装饰
|
||||
ItemDecoration itemDecoration = new ItemDecoration(16, 19, 10);
|
||||
@ -109,6 +113,17 @@ public class SoundFragment extends Fragment {
|
||||
bottomSheetDialog.show();
|
||||
}
|
||||
|
||||
|
||||
private void showAd(onAdAfterAction listener) {
|
||||
MaxManager.startShowMaxAd(requireActivity(), new onAdAfterAction() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
listener.onAction();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 分享纯文本
|
||||
*
|
||||
|
||||
11
app/src/main/java/com/sound/prankparty/max/MaxListener.java
Normal file
11
app/src/main/java/com/sound/prankparty/max/MaxListener.java
Normal file
@ -0,0 +1,11 @@
|
||||
package com.sound.prankparty.max;
|
||||
|
||||
import com.applovin.mediation.MaxAd;
|
||||
|
||||
public interface MaxListener {
|
||||
void onFail(MaxAd ad);
|
||||
|
||||
void onShowSuccess(MaxAd ad);
|
||||
|
||||
void onHidden();
|
||||
}
|
||||
185
app/src/main/java/com/sound/prankparty/max/MaxManager.java
Normal file
185
app/src/main/java/com/sound/prankparty/max/MaxManager.java
Normal file
@ -0,0 +1,185 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
78
app/src/main/java/com/sound/prankparty/max/WelComManager.kt
Normal file
78
app/src/main/java/com/sound/prankparty/max/WelComManager.kt
Normal file
@ -0,0 +1,78 @@
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
package com.sound.prankparty.max;
|
||||
|
||||
public interface onAdAfterAction {
|
||||
|
||||
void onAction();
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
package com.sound.prankparty.max;
|
||||
|
||||
public interface onAdStatusListener {
|
||||
|
||||
void onAdStatus(int type);
|
||||
}
|
||||
@ -1,4 +1,10 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
plugins {
|
||||
alias(libs.plugins.android.application) apply false
|
||||
id("org.jetbrains.kotlin.android") version "1.9.0" apply false
|
||||
}
|
||||
buildscript {
|
||||
dependencies {
|
||||
classpath("com.applovin.quality:AppLovinQualityServiceGradlePlugin:+")
|
||||
}
|
||||
}
|
||||
@ -9,6 +9,9 @@ pluginManagement {
|
||||
}
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
|
||||
maven { url = uri("https://artifacts.applovin.com/android") }
|
||||
|
||||
}
|
||||
}
|
||||
dependencyResolutionManagement {
|
||||
@ -16,6 +19,9 @@ dependencyResolutionManagement {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
|
||||
maven { url = uri("https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea") }
|
||||
maven { url = uri("https://artifact.bytedance.com/repository/pangle") }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user