V1.0.1(2)接入topon和firebase
This commit is contained in:
parent
743d4c6fc0
commit
9b3193e2b5
@ -5,6 +5,8 @@ plugins {
|
||||
alias(libs.plugins.android.application)
|
||||
alias(libs.plugins.kotlin.android)
|
||||
id("kotlin-kapt")
|
||||
id("com.google.gms.google-services")
|
||||
id("com.google.firebase.crashlytics")
|
||||
}
|
||||
val timestamp: String = SimpleDateFormat("MM_dd_HH_mm").format(Date())
|
||||
android {
|
||||
@ -15,8 +17,8 @@ android {
|
||||
applicationId = "com.wallpaper.wallpaperdream"
|
||||
minSdk = 23
|
||||
targetSdk = 34
|
||||
versionCode = 1
|
||||
versionName = "1.0.0"
|
||||
versionCode = 2
|
||||
versionName = "1.0.1"
|
||||
setProperty("archivesBaseName", "Wallpaper Dream_" + versionName + "(${versionCode})_$timestamp")
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
@ -63,5 +65,104 @@ dependencies {
|
||||
|
||||
implementation ("androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.7")
|
||||
|
||||
// Import the BoM for the Firebase platform
|
||||
implementation(platform("com.google.firebase:firebase-bom:33.7.0"))
|
||||
|
||||
// Add the dependencies for the Crashlytics and Analytics libraries
|
||||
// When using the BoM, you don't specify versions in Firebase library dependencies
|
||||
implementation("com.google.firebase:firebase-crashlytics")
|
||||
implementation("com.google.firebase:firebase-analytics")
|
||||
implementation("com.google.firebase:firebase-config")
|
||||
|
||||
//-----------------------------------------------TopOn(Mintegral、Pangle、UnitAds、Digital Turbine(Fyber)、Chartboost&Helium、Ironsource、Liftoff(Vungle)、Inmobi、Start.io、Appnext、Bigo)
|
||||
|
||||
//Anythink (Necessary)
|
||||
implementation("com.anythink.sdk:core-tpn:6.4.07")
|
||||
implementation("com.anythink.sdk:nativead-tpn:6.4.07")
|
||||
implementation("com.anythink.sdk:banner-tpn:6.4.07")
|
||||
implementation("com.anythink.sdk:interstitial-tpn:6.4.07")
|
||||
implementation("com.anythink.sdk:rewardedvideo-tpn:6.4.07")
|
||||
implementation("com.anythink.sdk:splash-tpn:6.4.07")
|
||||
|
||||
//Androidx (Necessary)
|
||||
implementation("androidx.appcompat:appcompat:1.1.0")
|
||||
implementation("androidx.browser:browser:1.4.0")
|
||||
|
||||
//StartApp
|
||||
implementation("com.anythink.sdk:adapter-tpn-startapp:6.4.07")
|
||||
implementation("com.startapp:inapp-sdk:5.0.2")
|
||||
|
||||
//Appnext
|
||||
implementation("com.anythink.sdk:adapter-tpn-appnext:6.4.07")
|
||||
implementation("com.appnext.sdk:ads:2.7.1.473")
|
||||
implementation("com.appnext.sdk:banners:2.7.1.473")
|
||||
implementation("com.appnext.sdk:native-ads2:2.7.1.473")
|
||||
implementation("com.appnext.sdk:actions:2.4.6.472")
|
||||
implementation("androidx.constraintlayout:constraintlayout:2.0.4")
|
||||
|
||||
//Vungle
|
||||
implementation("com.anythink.sdk:adapter-tpn-vungle:6.4.07")
|
||||
implementation("com.vungle:vungle-ads:7.4.0")
|
||||
implementation("com.google.android.gms:play-services-basement:18.1.0")
|
||||
implementation("com.google.android.gms:play-services-ads-identifier:18.0.1")
|
||||
|
||||
//UnityAds
|
||||
implementation("com.anythink.sdk:adapter-tpn-unityads:6.4.07")
|
||||
implementation("com.unity3d.ads:unity-ads:4.12.2")
|
||||
|
||||
//Ironsource
|
||||
implementation("com.anythink.sdk:adapter-tpn-ironsource:6.4.07")
|
||||
implementation("com.ironsource.sdk:mediationsdk:8.2.1")
|
||||
implementation("com.google.android.gms:play-services-appset:16.0.2")
|
||||
implementation("com.google.android.gms:play-services-ads-identifier:18.0.1")
|
||||
implementation("com.google.android.gms:play-services-basement:18.1.0")
|
||||
|
||||
//Bigo
|
||||
implementation("com.anythink.sdk:adapter-tpn-bigo:6.4.07")
|
||||
implementation("com.bigossp:bigo-ads:4.9.0")
|
||||
|
||||
//Pangle
|
||||
implementation("com.anythink.sdk:adapter-tpn-pangle-nonchina:6.4.07")
|
||||
implementation("com.pangle.global:ads-sdk:6.1.0.9")
|
||||
implementation("com.google.android.gms:play-services-ads-identifier:18.0.1")
|
||||
|
||||
//Inmobi
|
||||
implementation("com.anythink.sdk:adapter-tpn-inmobi:6.4.07")
|
||||
implementation("com.inmobi.monetization:inmobi-ads-kotlin:10.7.5")
|
||||
|
||||
//Mintegral
|
||||
implementation("com.anythink.sdk:adapter-tpn-mintegral-nonchina:6.4.07")
|
||||
implementation("com.mbridge.msdk.oversea:reward:16.8.11")
|
||||
implementation("com.mbridge.msdk.oversea:newinterstitial:16.8.11")
|
||||
implementation("com.mbridge.msdk.oversea:mbnative:16.8.11")
|
||||
implementation("com.mbridge.msdk.oversea:mbnativeadvanced:16.8.11")
|
||||
implementation("com.mbridge.msdk.oversea:mbsplash:16.8.11")
|
||||
implementation("com.mbridge.msdk.oversea:mbbanner:16.8.11")
|
||||
implementation("com.mbridge.msdk.oversea:mbbid:16.8.11")
|
||||
implementation("androidx.recyclerview:recyclerview:1.1.0")
|
||||
|
||||
//Chartboost
|
||||
implementation("com.anythink.sdk:adapter-tpn-chartboost:6.4.07")
|
||||
implementation("com.chartboost:chartboost-sdk:9.7.0")
|
||||
implementation("com.chartboost:chartboost-mediation-sdk:4.9.1")
|
||||
implementation("com.chartboost:chartboost-mediation-adapter-chartboost:4.9.7.0.0")
|
||||
implementation("com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:1.0.0")
|
||||
implementation("com.squareup.okhttp3:logging-interceptor:4.10.0")
|
||||
implementation("com.squareup.okhttp3:okhttp:4.10.0")
|
||||
implementation("com.squareup.retrofit2:converter-scalars:2.9.0")
|
||||
implementation("com.squareup.retrofit2:retrofit:2.9.0")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1")
|
||||
|
||||
//Fyber
|
||||
implementation("com.anythink.sdk:adapter-tpn-fyber:6.4.07")
|
||||
implementation("com.fyber:marketplace-sdk:8.3.0")
|
||||
implementation("com.google.android.gms:play-services-ads-identifier:18.0.1")
|
||||
|
||||
// Debugger UI Tools
|
||||
// implementation ("com.anythink.sdk:debugger-ui:1.1.0")
|
||||
|
||||
//----------------------------------------------TopOn
|
||||
|
||||
|
||||
}
|
||||
29
app/google-services.json
Normal file
29
app/google-services.json
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"project_info": {
|
||||
"project_number": "45568967834",
|
||||
"project_id": "wallpaper-dream",
|
||||
"storage_bucket": "wallpaper-dream.firebasestorage.app"
|
||||
},
|
||||
"client": [
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:45568967834:android:698a5179beff64ce080b23",
|
||||
"android_client_info": {
|
||||
"package_name": "com.wallpaper.wallpaperdream"
|
||||
}
|
||||
},
|
||||
"oauth_client": [],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyASIMoWGROcDfa_IEWNSAPPyOZkHNJ2o8k"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": []
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"configuration_version": "1"
|
||||
}
|
||||
131
app/proguard-rules.pro
vendored
131
app/proguard-rules.pro
vendored
@ -31,4 +31,133 @@
|
||||
|
||||
-keep class com.wallpaper.wallpaperdream.data.database.AppDatabase { *; }
|
||||
-keep class com.wallpaper.wallpaperdream.data.database.dao.WallpaperDataDao { *; }
|
||||
-keep class com.wallpaper.wallpaperdream.data.database.entity.WallpaperData { *; }
|
||||
-keep class com.wallpaper.wallpaperdream.data.database.entity.WallpaperData { *; }
|
||||
|
||||
#---------------------------------------------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
|
||||
|
||||
@ -4,7 +4,10 @@ import android.app.Application
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.util.Log
|
||||
import com.anythink.core.api.ATSDK
|
||||
import com.anythink.core.api.NetTrafficeCallback
|
||||
import com.wallpaper.wallpaperdream.data.repository.WallpaperRepository
|
||||
import com.wallpaper.wallpaperdream.topon.AdManager
|
||||
import com.wallpaper.wallpaperdream.utils.JsonUtils
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@ -19,6 +22,12 @@ class MyApplication : Application() {
|
||||
private const val PREF_NAME = "wallpaper_preferences"
|
||||
private const val KEY_INITIALIZED = "isInitDatabase"
|
||||
|
||||
const val TAG = "------------"
|
||||
|
||||
private var APPId = "h678a158e21b0b"
|
||||
private var AppKey = "a1b80d92e3c0b05688745606631cd6a07"
|
||||
private var DeBugKey = "529b9d845e53ac839536d321c0b6be5f6928b24d"
|
||||
|
||||
@JvmStatic
|
||||
fun getContext(): Context {
|
||||
return instance.applicationContext
|
||||
@ -29,6 +38,18 @@ class MyApplication : Application() {
|
||||
super.onCreate()
|
||||
instance = this
|
||||
|
||||
initSdk()
|
||||
|
||||
//确保Firebase初始化
|
||||
// FirebaseApp.initializeApp(this);
|
||||
//
|
||||
// // 输出日志以确认Firebase初始化
|
||||
// if (FirebaseApp.getApps(this).isNotEmpty()) {
|
||||
// Log.d(TAG, "Firebase 初始化成功1");
|
||||
// } else {
|
||||
// Log.e(TAG, "Firebase 初始化失败0");
|
||||
// }
|
||||
|
||||
val preferences: SharedPreferences = getSharedPreferences(PREF_NAME, MODE_PRIVATE)
|
||||
val isDatabaseInit = preferences.getBoolean(KEY_INITIALIZED, false)
|
||||
|
||||
@ -38,6 +59,25 @@ class MyApplication : Application() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun initSdk() {
|
||||
ATSDK.checkIsEuTraffic(this, object : NetTrafficeCallback {
|
||||
override fun onResultCallback(isEU: Boolean) {
|
||||
if (isEU && ATSDK.getGDPRDataLevel(this@MyApplication) == ATSDK.UNKNOWN) {
|
||||
ATSDK.showGdprAuth(this@MyApplication)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onErrorCallback(errorMsg: String) {
|
||||
Log.e(TAG, "onErrorCallback:$errorMsg")
|
||||
}
|
||||
})
|
||||
|
||||
ATSDK.init(this, APPId, AppKey)
|
||||
AdManager.loadAllAd()
|
||||
//测试工具
|
||||
// ATDebuggerUITest.showDebuggerUI(this,DeBugKey);
|
||||
}
|
||||
|
||||
private fun initDatabase() {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
val wallpaperRepository = WallpaperRepository(getContext())
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
package com.wallpaper.wallpaperdream.topon;
|
||||
|
||||
public interface AdListener {
|
||||
void loadFail(String placeId);
|
||||
void showSuccess();
|
||||
|
||||
void showFail();
|
||||
|
||||
void showClose();
|
||||
}
|
||||
@ -0,0 +1,249 @@
|
||||
package com.wallpaper.wallpaperdream.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.wallpaper.wallpaperdream.MyApplication;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
Wallpaper_INST_3
|
||||
n678a15adad1e5
|
||||
Wallpaper_INST_2
|
||||
n678a15ad35224
|
||||
Wallpaper_INST_1
|
||||
n678a15ac95342
|
||||
*/
|
||||
|
||||
private static final String place1Id = "n678a15ac95342";
|
||||
private static final String place2Id = "n678a15ad35224";
|
||||
private static final String place3Id = "n678a15adad1e5";
|
||||
|
||||
private static boolean place1LoadFail = false;
|
||||
private static boolean place2LoadFail = false;
|
||||
private static boolean place3LoadFail = false;
|
||||
|
||||
private static boolean alreadyShow = false;
|
||||
|
||||
private static final List<ATInterstitial> list = new ArrayList<>();
|
||||
|
||||
|
||||
public static void loadAllAd() {
|
||||
if (list.isEmpty()) {
|
||||
ATInterstitial mInterstitialAd1 = new ATInterstitial(MyApplication.getContext(), place1Id);
|
||||
ATInterstitial mInterstitialAd2 = new ATInterstitial(MyApplication.getContext(), place2Id);
|
||||
ATInterstitial mInterstitialAd3 = new ATInterstitial(MyApplication.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(MyApplication.TAG, "-has Cache------------");
|
||||
return ad;
|
||||
}
|
||||
}
|
||||
Log.d(MyApplication.TAG, "-No Cache------------");
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void setCallBack(ATInterstitial ad, AdListener listener) {
|
||||
ad.setAdListener(new ATInterstitialListener() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onInterstitialAdLoaded() {
|
||||
Log.d(MyApplication.TAG, "LoadLoaded " + ad.mPlacementId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInterstitialAdLoadFail(AdError adError) {
|
||||
listener.loadFail(ad.mPlacementId);
|
||||
Log.d(MyApplication.TAG, "LoadFail:--" + ad.mPlacementId + "--" + adError.getCode() + "---" + adError.getDesc());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInterstitialAdClicked(ATAdInfo atAdInfo) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInterstitialAdShow(ATAdInfo atAdInfo) {
|
||||
Log.d(MyApplication.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.wallpaper.wallpaperdream.topon;
|
||||
|
||||
public interface AdStatusAction {
|
||||
void onStatus(int adType);
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
package com.wallpaper.wallpaperdream.topon;
|
||||
|
||||
public interface CountAction {
|
||||
void onCount(long millisUntilFinished);
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
package com.wallpaper.wallpaperdream.topon;
|
||||
|
||||
public interface GoMainAction {
|
||||
void onGo();
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
package com.wallpaper.wallpaperdream.topon;
|
||||
|
||||
public interface onActionListener {
|
||||
|
||||
void onAction();
|
||||
}
|
||||
@ -11,6 +11,7 @@ import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.wallpaper.wallpaperdream.R
|
||||
import com.wallpaper.wallpaperdream.databinding.ActivityCategoryBinding
|
||||
import com.wallpaper.wallpaperdream.topon.AdManager
|
||||
import com.wallpaper.wallpaperdream.ui.adapter.ImageAdapter
|
||||
import com.wallpaper.wallpaperdream.utils.ItemDecoration
|
||||
import com.wallpaper.wallpaperdream.viewmodel.WallpaperViewModel
|
||||
@ -36,6 +37,12 @@ class CategoryActivity : AppCompatActivity() {
|
||||
insets
|
||||
}
|
||||
|
||||
AdManager.loadAllAd()
|
||||
|
||||
AdManager.showTopOn(this@CategoryActivity) {
|
||||
|
||||
}
|
||||
|
||||
initData()
|
||||
initEvent()
|
||||
}
|
||||
@ -54,7 +61,11 @@ class CategoryActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
private fun initEvent() {
|
||||
binding.back.setOnClickListener { finish() }
|
||||
binding.back.setOnClickListener {
|
||||
AdManager.showTopOn(this@CategoryActivity) {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
binding.text.text = name
|
||||
|
||||
loadImage()
|
||||
|
||||
@ -12,6 +12,7 @@ import android.view.View
|
||||
import android.widget.Toast
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
@ -24,6 +25,7 @@ import com.bumptech.glide.request.transition.Transition
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||
import com.wallpaper.wallpaperdream.R
|
||||
import com.wallpaper.wallpaperdream.databinding.ActivityImageBinding
|
||||
import com.wallpaper.wallpaperdream.topon.AdManager
|
||||
import com.wallpaper.wallpaperdream.utils.GallerySaver
|
||||
import com.wallpaper.wallpaperdream.utils.GallerySaver.REQUEST_CODE_WRITE_EXTERNAL_STORAGE
|
||||
import com.wallpaper.wallpaperdream.viewmodel.WallpaperViewModel
|
||||
@ -57,6 +59,12 @@ class ImageActivity : AppCompatActivity() {
|
||||
insets
|
||||
}
|
||||
|
||||
AdManager.loadAllAd()
|
||||
|
||||
AdManager.showTopOn(this@ImageActivity) {
|
||||
|
||||
}
|
||||
|
||||
initData()
|
||||
initEvent()
|
||||
}
|
||||
@ -76,19 +84,29 @@ class ImageActivity : AppCompatActivity() {
|
||||
private fun initEvent() {
|
||||
showProgress()
|
||||
|
||||
binding.back.setOnClickListener { finish() }
|
||||
binding.back.setOnClickListener {
|
||||
AdManager.showTopOn(this@ImageActivity) {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
binding.favorite.setOnClickListener {
|
||||
isFavorite = !isFavorite
|
||||
viewModel.updateIsLike(imagePath, name, isFavorite)
|
||||
}
|
||||
|
||||
binding.setWallpaper.setOnClickListener { showCustomBottomSheetDialog() }
|
||||
binding.setWallpaper.setOnClickListener {
|
||||
AdManager.showTopOn(this@ImageActivity) {
|
||||
showCustomBottomSheetDialog()
|
||||
}
|
||||
}
|
||||
|
||||
binding.download.setOnClickListener { v ->
|
||||
showProgress()
|
||||
val activity = v.context as ImageActivity
|
||||
gallerySaver.saveToGallery(activity, imagePath)
|
||||
AdManager.showTopOn(this@ImageActivity) {
|
||||
showProgress()
|
||||
val activity = v.context as ImageActivity
|
||||
gallerySaver.saveToGallery(activity, imagePath)
|
||||
}
|
||||
}
|
||||
|
||||
loadImage()
|
||||
@ -118,19 +136,19 @@ class ImageActivity : AppCompatActivity() {
|
||||
val bottomSheetDialog = BottomSheetDialog(this)
|
||||
val dialogView: View = LayoutInflater.from(this).inflate(R.layout.set_dialog, null)
|
||||
|
||||
dialogView.findViewById<View>(R.id.both).setOnClickListener { v: View? ->
|
||||
dialogView.findViewById<View>(R.id.both).setOnClickListener {
|
||||
showProgress()
|
||||
setWallpaperBoth(bitmap)
|
||||
bottomSheetDialog.dismiss()
|
||||
}
|
||||
|
||||
dialogView.findViewById<View>(R.id.lock).setOnClickListener { v: View? ->
|
||||
dialogView.findViewById<View>(R.id.lock).setOnClickListener {
|
||||
showProgress()
|
||||
setWallpaperLock(bitmap)
|
||||
bottomSheetDialog.dismiss()
|
||||
}
|
||||
|
||||
dialogView.findViewById<View>(R.id.desktop).setOnClickListener { v: View? ->
|
||||
dialogView.findViewById<View>(R.id.desktop).setOnClickListener {
|
||||
showProgress()
|
||||
setWallpaperDeskTop(bitmap)
|
||||
bottomSheetDialog.dismiss()
|
||||
@ -255,12 +273,13 @@ class ImageActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun loadImage() {
|
||||
Glide.with(this)
|
||||
.asBitmap()
|
||||
.load(imagePath)
|
||||
.error(R.mipmap.placeholder)
|
||||
.error(ContextCompat.getDrawable(this, R.mipmap.placeholder))
|
||||
.override(1080, 1920)
|
||||
.centerInside()
|
||||
.into(object : CustomTarget<Bitmap>() {
|
||||
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
|
||||
binding.image.setImageBitmap(resource)
|
||||
@ -269,19 +288,22 @@ class ImageActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
override fun onLoadCleared(placeholder: Drawable?) {
|
||||
binding.image.setImageDrawable(placeholder)
|
||||
binding.image.setImageDrawable(placeholder ?: getDefaultPlaceholder()) // 使用一个默认的占位符
|
||||
}
|
||||
|
||||
override fun onLoadFailed(errorDrawable: Drawable?) {
|
||||
super.onLoadFailed(errorDrawable)
|
||||
binding.image.setImageDrawable(
|
||||
errorDrawable ?: resources.getDrawable(R.mipmap.placeholder, null)
|
||||
)
|
||||
binding.image.setImageDrawable(errorDrawable ?: getDefaultPlaceholder())
|
||||
hideProgress()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun getDefaultPlaceholder(): Drawable {
|
||||
return ContextCompat.getDrawable(this, R.mipmap.placeholder) ?: resources.getDrawable(R.mipmap.placeholder, null)
|
||||
}
|
||||
|
||||
|
||||
private fun loadFavorite() {
|
||||
viewModel
|
||||
.getWallpaperLike(imagePath)
|
||||
|
||||
@ -14,6 +14,7 @@ import com.google.android.material.tabs.TabLayoutMediator
|
||||
import com.wallpaper.wallpaperdream.R
|
||||
import com.wallpaper.wallpaperdream.databinding.ActivityMainBinding
|
||||
import com.wallpaper.wallpaperdream.databinding.MainCustomBinding
|
||||
import com.wallpaper.wallpaperdream.topon.AdManager
|
||||
import com.wallpaper.wallpaperdream.ui.adapter.MainAdapter
|
||||
import com.wallpaper.wallpaperdream.ui.fragment.CategoryFragment
|
||||
import com.wallpaper.wallpaperdream.ui.fragment.FavoriteFragment
|
||||
@ -28,7 +29,6 @@ class MainActivity : AppCompatActivity() {
|
||||
binding = ActivityMainBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
|
||||
ViewCompat.setOnApplyWindowInsetsListener(
|
||||
findViewById(R.id.main)
|
||||
) { v: View, insets: WindowInsetsCompat ->
|
||||
@ -37,6 +37,8 @@ class MainActivity : AppCompatActivity() {
|
||||
insets
|
||||
}
|
||||
|
||||
AdManager.loadAllAd()
|
||||
|
||||
initData()
|
||||
initEvent()
|
||||
}
|
||||
|
||||
@ -13,6 +13,7 @@ import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
|
||||
import com.wallpaper.wallpaperdream.R
|
||||
import com.wallpaper.wallpaperdream.databinding.ActivitySplashBinding
|
||||
import com.wallpaper.wallpaperdream.topon.AdManager
|
||||
|
||||
class SplashActivity : AppCompatActivity() {
|
||||
private lateinit var binding: ActivitySplashBinding
|
||||
@ -33,23 +34,22 @@ class SplashActivity : AppCompatActivity() {
|
||||
insets
|
||||
}
|
||||
|
||||
val progressBar: ProgressBar = binding.progressBar
|
||||
AdManager.loadAllAd()
|
||||
|
||||
AdManager.setAlreadyShow()
|
||||
|
||||
Glide.with(this)
|
||||
.load(R.mipmap.placeholder)
|
||||
.transform(RoundedCorners(16))
|
||||
.into(binding.splashImage)
|
||||
|
||||
countDownTimer = object : CountDownTimer(TOTAL_TIME, 100) {
|
||||
override fun onTick(millisUntilFinished: Long) {
|
||||
countDownTimer = AdManager.showWelcomeAd(
|
||||
this, TOTAL_TIME, { millisUntilFinished ->
|
||||
val percentage = (100 - millisUntilFinished.toFloat() / TOTAL_TIME * 100).toInt()
|
||||
progressBar.progress = percentage
|
||||
}
|
||||
|
||||
override fun onFinish() {
|
||||
startMain()
|
||||
}
|
||||
}
|
||||
binding.progressBar.progress = percentage
|
||||
},
|
||||
{ this.startMain() }
|
||||
)
|
||||
|
||||
countDownTimer.start()
|
||||
}
|
||||
@ -71,6 +71,6 @@ class SplashActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val TOTAL_TIME: Long = 3000
|
||||
private const val TOTAL_TIME: Long = 11000
|
||||
}
|
||||
}
|
||||
@ -2,4 +2,7 @@
|
||||
plugins {
|
||||
alias(libs.plugins.android.application) apply false
|
||||
alias(libs.plugins.kotlin.android) 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
|
||||
}
|
||||
@ -6,7 +6,7 @@
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
||||
org.gradle.jvmargs=-Xmx4096m -Dfile.encoding=UTF-8
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. For more details, visit
|
||||
# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
|
||||
|
||||
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
||||
#Mon Dec 30 15:58:34 CST 2024
|
||||
#Fri Jan 17 14:58:50 CST 2025
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@ -16,6 +16,28 @@ 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