V1.0.4(5) MAX(Liftoff Monetize(vungle)、Mintegral、Pangle、Unity Ads)
This commit is contained in:
parent
c21730af24
commit
9e7c6f9bcc
@ -7,7 +7,13 @@ plugins {
|
|||||||
id("com.google.gms.google-services")
|
id("com.google.gms.google-services")
|
||||||
id("com.google.firebase.crashlytics")
|
id("com.google.firebase.crashlytics")
|
||||||
id("io.objectbox")
|
id("io.objectbox")
|
||||||
|
id("applovin-quality-service")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
applovin{
|
||||||
|
apiKey = "hPNBaWB5Xd1nKXGSXqaWC7W3ZKbCBDd9VX1xaGwyF0aIViWEwhSxqOeq4CuUrogatsst7TUIEMh2sApTIabO8G"
|
||||||
|
}
|
||||||
|
|
||||||
val timestamp = SimpleDateFormat("MM_dd_HH_mm").format(Date())
|
val timestamp = SimpleDateFormat("MM_dd_HH_mm").format(Date())
|
||||||
android {
|
android {
|
||||||
namespace = "com.nature.free.test"
|
namespace = "com.nature.free.test"
|
||||||
@ -18,8 +24,8 @@ android {
|
|||||||
applicationId = "com.nature.free.variouswallpaper"
|
applicationId = "com.nature.free.variouswallpaper"
|
||||||
minSdk = 23
|
minSdk = 23
|
||||||
targetSdk = 34
|
targetSdk = 34
|
||||||
versionCode = 4
|
versionCode = 5
|
||||||
versionName = "1.0.3"
|
versionName = "1.0.4"
|
||||||
setProperty(
|
setProperty(
|
||||||
"archivesBaseName",
|
"archivesBaseName",
|
||||||
"Various Wallpapers_V" + versionName + "(${versionCode})_$timestamp"
|
"Various Wallpapers_V" + versionName + "(${versionCode})_$timestamp"
|
||||||
@ -64,4 +70,14 @@ dependencies {
|
|||||||
implementation("com.google.firebase:firebase-crashlytics")
|
implementation("com.google.firebase:firebase-crashlytics")
|
||||||
implementation("com.google.firebase:firebase-analytics")
|
implementation("com.google.firebase:firebase-analytics")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------MAX(Liftoff Monetize(vungle)、Mintegral、Pangle、Unity Ads)
|
||||||
|
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:+")
|
||||||
|
//--------------------------MAX(Liftoff Monetize(vungle)、Mintegral、Pangle、Unity Ads)
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -9,6 +9,8 @@ import com.nature.free.test.base.BaseActivity;
|
|||||||
import com.nature.free.test.data.ClassData;
|
import com.nature.free.test.data.ClassData;
|
||||||
import com.nature.free.test.data.ClassData_;
|
import com.nature.free.test.data.ClassData_;
|
||||||
import com.nature.free.test.databinding.ActivityInfoBinding;
|
import com.nature.free.test.databinding.ActivityInfoBinding;
|
||||||
|
import com.nature.free.test.max.MaxManager;
|
||||||
|
import com.nature.free.test.max.onAdStatusListener;
|
||||||
import com.nature.free.test.objectbox.ObjectBox;
|
import com.nature.free.test.objectbox.ObjectBox;
|
||||||
import com.nature.free.test.other.MyAdapter;
|
import com.nature.free.test.other.MyAdapter;
|
||||||
import com.nature.free.test.other.MyItemSpace;
|
import com.nature.free.test.other.MyItemSpace;
|
||||||
@ -25,7 +27,7 @@ public class InfoActivity extends BaseActivity<ActivityInfoBinding> {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
MaxManager.onLoadAd();
|
||||||
init();
|
init();
|
||||||
mainBinding.back.setOnClickListener(new View.OnClickListener() {
|
mainBinding.back.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -43,11 +45,16 @@ public class InfoActivity extends BaseActivity<ActivityInfoBinding> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void showTopOnAd(Boolean isfinish) {
|
private void showTopOnAd(Boolean isfinish) {
|
||||||
|
MaxManager.ShowAd(InfoActivity.this, new onAdStatusListener() {
|
||||||
// TODO: 2024/7/30 showAd
|
@Override
|
||||||
if(isfinish){
|
public void onAdStatus(int type) {
|
||||||
|
if (type == MaxManager.type_show_close || type == MaxManager.type_show_fail || type == MaxManager.type_no_cache) {
|
||||||
|
if (isfinish) {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +68,7 @@ public class InfoActivity extends BaseActivity<ActivityInfoBinding> {
|
|||||||
ClassData classData = getData();
|
ClassData classData = getData();
|
||||||
if (classData != null) {
|
if (classData != null) {
|
||||||
mainBinding.tvName.setText(classData.getTitle());
|
mainBinding.tvName.setText(classData.getTitle());
|
||||||
myAdapter = new MyAdapter(this,false,false);
|
myAdapter = new MyAdapter(this, false, false);
|
||||||
myAdapter.refresh(classData.info);
|
myAdapter.refresh(classData.info);
|
||||||
mainBinding.recycler.setLayoutManager(new GridLayoutManager(this, 2));
|
mainBinding.recycler.setLayoutManager(new GridLayoutManager(this, 2));
|
||||||
mainBinding.recycler.setAdapter(myAdapter);
|
mainBinding.recycler.setAdapter(myAdapter);
|
||||||
|
|||||||
@ -1,6 +1,11 @@
|
|||||||
package com.nature.free.test
|
package com.nature.free.test
|
||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
|
import android.content.Intent
|
||||||
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||||
|
import com.applovin.sdk.AppLovinMediationProvider
|
||||||
|
import com.applovin.sdk.AppLovinSdk
|
||||||
|
import com.applovin.sdk.AppLovinSdkInitializationConfiguration
|
||||||
import com.nature.free.test.data.ClassData
|
import com.nature.free.test.data.ClassData
|
||||||
import com.nature.free.test.objectbox.ObjectBox
|
import com.nature.free.test.objectbox.ObjectBox
|
||||||
|
|
||||||
@ -24,17 +29,18 @@ class MyWallpaper : Application() {
|
|||||||
const val BITMAP_FILE_DIRECTORY = "MyWallpaper"
|
const val BITMAP_FILE_DIRECTORY = "MyWallpaper"
|
||||||
const val isMainEnterSetKey = "main_enter"
|
const val isMainEnterSetKey = "main_enter"
|
||||||
|
|
||||||
const val TAG ="------------------TAG"
|
const val TAG = "------------------TAG"
|
||||||
|
var initSDkOK = false
|
||||||
|
const val initAction = "INIT_SDK_ACTION"
|
||||||
}
|
}
|
||||||
|
|
||||||
private val APPId="h66a0cc207140e"
|
|
||||||
private val AppKey="acce079c140b9d4db923f8dac460dcec8"
|
private val sdk_key = "JtCdtf2lUaegRtQsZR87DfzVUvCvVLhEv12ECLpPHtvMZRggrNTscST27G7TuyAbgk2L_Gp67_BSP_BNe_qhOI"
|
||||||
private val debug_Key="4e26d6fdb6029c920a512f4d896f6331f47c82d0"
|
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
globalContext = this
|
globalContext = this
|
||||||
initTopOnSDk()
|
initMAxSDk()
|
||||||
ObjectBox.init(this)
|
ObjectBox.init(this)
|
||||||
if (ObjectBox.getBoxBean().all.size <= 0) {
|
if (ObjectBox.getBoxBean().all.size <= 0) {
|
||||||
init()
|
init()
|
||||||
@ -47,9 +53,17 @@ class MyWallpaper : Application() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initTopOnSDk(){
|
private fun initMAxSDk() {
|
||||||
|
val initConfig = AppLovinSdkInitializationConfiguration.builder(sdk_key, this)
|
||||||
|
.setMediationProvider(AppLovinMediationProvider.MAX)
|
||||||
|
.build()
|
||||||
|
// Initialize the SDK with the configuration
|
||||||
|
AppLovinSdk.getInstance(this).initialize(initConfig) { sdkConfig ->
|
||||||
|
// Start loading ads
|
||||||
|
initSDkOK = true
|
||||||
|
LocalBroadcastManager.getInstance(globalContext)
|
||||||
|
.sendBroadcast(Intent(initAction))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,19 @@
|
|||||||
package com.nature.free.test;
|
package com.nature.free.test;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.CountDownTimer;
|
import android.os.CountDownTimer;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.nature.free.test.base.BaseActivity;
|
import com.nature.free.test.base.BaseActivity;
|
||||||
import com.nature.free.test.databinding.ActivityWelBinding;
|
import com.nature.free.test.databinding.ActivityWelBinding;
|
||||||
|
import com.nature.free.test.max.WelComManager;
|
||||||
|
|
||||||
|
import kotlin.Unit;
|
||||||
|
import kotlin.jvm.functions.Function0;
|
||||||
|
import kotlin.jvm.functions.Function1;
|
||||||
|
|
||||||
public class SplashActivity extends BaseActivity<ActivityWelBinding> {
|
public class SplashActivity extends BaseActivity<ActivityWelBinding> {
|
||||||
|
|
||||||
@ -15,9 +23,23 @@ public class SplashActivity extends BaseActivity<ActivityWelBinding> {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
countDownTimer = WelComManager.initTimer(SplashActivity.this, time, new Function1<Long, Unit>() {
|
||||||
|
@Override
|
||||||
|
public Unit invoke(Long aLong) {
|
||||||
|
long number = time - aLong;
|
||||||
|
Double s = calculatePercentage(number, time);
|
||||||
|
Log.d(MyWallpaper.TAG, "--------------l=" + s);
|
||||||
|
mainBinding.customProgress.setProgress(s.floatValue());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}, new Function0<Unit>() {
|
||||||
|
@Override
|
||||||
|
public Unit invoke() {
|
||||||
goMain();
|
goMain();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,4 +66,7 @@ public class SplashActivity extends BaseActivity<ActivityWelBinding> {
|
|||||||
protected ActivityWelBinding getMainBinding() {
|
protected ActivityWelBinding getMainBinding() {
|
||||||
return ActivityWelBinding.inflate(getLayoutInflater());
|
return ActivityWelBinding.inflate(getLayoutInflater());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -28,6 +28,8 @@ import com.nature.free.test.base.BaseActivity;
|
|||||||
import com.nature.free.test.data.Wallpaper;
|
import com.nature.free.test.data.Wallpaper;
|
||||||
import com.nature.free.test.data.Wallpaper_;
|
import com.nature.free.test.data.Wallpaper_;
|
||||||
import com.nature.free.test.databinding.ActivityWallpaperBinding;
|
import com.nature.free.test.databinding.ActivityWallpaperBinding;
|
||||||
|
import com.nature.free.test.max.MaxManager;
|
||||||
|
import com.nature.free.test.max.onAdStatusListener;
|
||||||
import com.nature.free.test.objectbox.ObjectBox;
|
import com.nature.free.test.objectbox.ObjectBox;
|
||||||
import com.nature.free.test.other.DialogSet;
|
import com.nature.free.test.other.DialogSet;
|
||||||
|
|
||||||
@ -67,6 +69,7 @@ public class WallPaperActivity extends BaseActivity<ActivityWallpaperBinding> im
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
MaxManager.onLoadAd();
|
||||||
statusbar();
|
statusbar();
|
||||||
|
|
||||||
tempId = getIntent().getLongExtra(MyWallpaper.KEY_WALLPAPER, 1);
|
tempId = getIntent().getLongExtra(MyWallpaper.KEY_WALLPAPER, 1);
|
||||||
@ -132,15 +135,19 @@ public class WallPaperActivity extends BaseActivity<ActivityWallpaperBinding> im
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void apply(int which) {
|
private void apply(int which) {
|
||||||
|
MaxManager.ShowAd(WallPaperActivity.this, new onAdStatusListener() {
|
||||||
// TODO: 2024/7/30 showAd
|
@Override
|
||||||
|
public void onAdStatus(int type) {
|
||||||
|
if (type == MaxManager.type_show_close || type == MaxManager.type_show_fail || type == MaxManager.type_no_cache) {
|
||||||
mainBinding.load.setVisibility(View.VISIBLE);
|
mainBinding.load.setVisibility(View.VISIBLE);
|
||||||
if (mainBinding.check1.isSelected()) {
|
if (mainBinding.check1.isSelected()) {
|
||||||
setmWallpaper(which, mBitmapPro1);
|
setmWallpaper(which, mBitmapPro1);
|
||||||
} else if (mainBinding.check2.isSelected()) {
|
} else if (mainBinding.check2.isSelected()) {
|
||||||
setmWallpaper(which, mBitmapSource);
|
setmWallpaper(which, mBitmapSource);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,7 +302,7 @@ public class WallPaperActivity extends BaseActivity<ActivityWallpaperBinding> im
|
|||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (v.equals(mainBinding.back)) {
|
if (v.equals(mainBinding.back)) {
|
||||||
if (isMainEnter) {
|
if (isMainEnter) {
|
||||||
showTopOnAd();
|
showMaxAd();
|
||||||
} else {
|
} else {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
@ -362,10 +369,15 @@ public class WallPaperActivity extends BaseActivity<ActivityWallpaperBinding> im
|
|||||||
mainBinding.load.setVisibility(View.GONE);
|
mainBinding.load.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showTopOnAd() {
|
private void showMaxAd() {
|
||||||
|
MaxManager.ShowAd(WallPaperActivity.this, new onAdStatusListener() {
|
||||||
// TODO: 2024/7/30 showAd
|
@Override
|
||||||
|
public void onAdStatus(int type) {
|
||||||
|
if (type == MaxManager.type_show_close || type == MaxManager.type_show_fail || type == MaxManager.type_no_cache) {
|
||||||
finish();
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
11
app/src/main/java/com/nature/free/test/max/MaxListener.java
Normal file
11
app/src/main/java/com/nature/free/test/max/MaxListener.java
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package com.nature.free.test.max;
|
||||||
|
|
||||||
|
import com.applovin.mediation.MaxAd;
|
||||||
|
|
||||||
|
public interface MaxListener {
|
||||||
|
void onFail(MaxAd ad);
|
||||||
|
|
||||||
|
void onShowSuccess(MaxAd ad);
|
||||||
|
|
||||||
|
void onHidden();
|
||||||
|
}
|
||||||
165
app/src/main/java/com/nature/free/test/max/MaxManager.java
Normal file
165
app/src/main/java/com/nature/free/test/max/MaxManager.java
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
package com.nature.free.test.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.nature.free.test.MyWallpaper;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class MaxManager {
|
||||||
|
/**
|
||||||
|
* Ad_Units
|
||||||
|
e131fc7428da6271
|
||||||
|
acf4ea6b852b3a99
|
||||||
|
e8e6c260ab609443
|
||||||
|
*/
|
||||||
|
private static final String one_AD = "e131fc7428da6271";
|
||||||
|
private static final String two_Ad = "acf4ea6b852b3a99";
|
||||||
|
private static final String three_ad = "e8e6c260ab609443";
|
||||||
|
|
||||||
|
|
||||||
|
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, MyWallpaper.globalContext);
|
||||||
|
MaxInterstitialAd AdOne = new MaxInterstitialAd(one_AD, MyWallpaper.globalContext);
|
||||||
|
MaxInterstitialAd AdThree = new MaxInterstitialAd(three_ad, MyWallpaper.globalContext);
|
||||||
|
adList.add(AdOne);
|
||||||
|
adList.add(AdT);
|
||||||
|
adList.add(AdThree);
|
||||||
|
}
|
||||||
|
|
||||||
|
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(MyWallpaper.TAG, "-------onAdLoaded-----maxAd="+maxAd.getAdUnitId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAdDisplayed(@NonNull MaxAd maxAd) {
|
||||||
|
Log.d(MyWallpaper.TAG, "-------onAdDisplayed-----maxAd="+maxAd.getAdUnitId());
|
||||||
|
maxListener.onShowSuccess(maxAd);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAdHidden(@NonNull MaxAd maxAd) {
|
||||||
|
Log.d(MyWallpaper.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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
76
app/src/main/java/com/nature/free/test/max/WelComManager.kt
Normal file
76
app/src/main/java/com/nature/free/test/max/WelComManager.kt
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
package com.nature.free.test.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.nature.free.test.MyWallpaper
|
||||||
|
|
||||||
|
|
||||||
|
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(MyWallpaper.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(MyWallpaper.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(MyWallpaper.TAG, "--onFinish---------enter")
|
||||||
|
goMainAction.invoke()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
startAd(activity)
|
||||||
|
return timer
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun startAd(activity: Activity) {
|
||||||
|
if (!MyWallpaper.initSDkOK) {
|
||||||
|
LocalBroadcastManager.getInstance(activity)
|
||||||
|
.registerReceiver(object : BroadcastReceiver() {
|
||||||
|
override fun onReceive(context: Context?, intent: Intent?) {
|
||||||
|
lists = MaxManager.onLoadAd()
|
||||||
|
timer.start()
|
||||||
|
Log.d(MyWallpaper.TAG, "------------1sucess")
|
||||||
|
}
|
||||||
|
}, IntentFilter(MyWallpaper.initAction))
|
||||||
|
} else {
|
||||||
|
lists = MaxManager.onLoadAd()
|
||||||
|
timer.start()
|
||||||
|
Log.d(MyWallpaper.TAG, "------------2sucess")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
package com.nature.free.test.max;
|
||||||
|
|
||||||
|
public interface onAdStatusListener {
|
||||||
|
|
||||||
|
void onAdStatus(int type);
|
||||||
|
}
|
||||||
@ -5,6 +5,7 @@ plugins {
|
|||||||
|
|
||||||
id("com.google.gms.google-services") version "4.3.15" apply false
|
id("com.google.gms.google-services") version "4.3.15" apply false
|
||||||
id ("com.google.firebase.crashlytics") version "2.9.2" apply false
|
id ("com.google.firebase.crashlytics") version "2.9.2" apply false
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
@ -17,5 +18,6 @@ buildscript {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath("io.objectbox:objectbox-gradle-plugin:$objectboxVersion")
|
classpath("io.objectbox:objectbox-gradle-plugin:$objectboxVersion")
|
||||||
|
classpath("com.applovin.quality:AppLovinQualityServiceGradlePlugin:+")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
6
keystore.properties
Normal file
6
keystore.properties
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
app_name=Various Wallpapers
|
||||||
|
package_name=com.nature.free.variouswallpaper
|
||||||
|
keystoreFile=app/VariousWallpapers.jks
|
||||||
|
key_alias=VariousWallpaperskey0
|
||||||
|
key_store_password=VariousWallpapers
|
||||||
|
key_password=VariousWallpapers
|
||||||
@ -3,6 +3,7 @@ pluginManagement {
|
|||||||
google()
|
google()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
|
maven { url = uri("https://artifacts.applovin.com/android") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dependencyResolutionManagement {
|
dependencyResolutionManagement {
|
||||||
@ -11,7 +12,8 @@ dependencyResolutionManagement {
|
|||||||
google()
|
google()
|
||||||
mavenCentral()
|
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