删掉max集成
This commit is contained in:
parent
cd287e1228
commit
3789b03f6b
6
.idea/compiler.xml
generated
6
.idea/compiler.xml
generated
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="17" />
|
||||
</component>
|
||||
</project>
|
||||
19
.idea/gradle.xml
generated
19
.idea/gradle.xml
generated
@ -1,19 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/app" />
|
||||
</set>
|
||||
</option>
|
||||
<option name="resolveExternalAnnotations" value="false" />
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
9
.idea/misc.xml
generated
9
.idea/misc.xml
generated
@ -1,9 +0,0 @@
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
</project>
|
||||
@ -1,14 +1,13 @@
|
||||
import java.util.Date
|
||||
import java.text.SimpleDateFormat
|
||||
plugins {
|
||||
id 'com.android.application'
|
||||
id 'org.jetbrains.kotlin.android'
|
||||
id 'applovin-quality-service'
|
||||
id 'com.google.gms.google-services'
|
||||
id 'com.google.firebase.crashlytics'
|
||||
}
|
||||
|
||||
applovin {
|
||||
apiKey = "BoZtE6LMU2QaUEowq3SoQFO_HqwztZQdgF3VZGmNRR17TGv0XhXSwlT6LiaRllitI7yAsCkSGo_pfE0yfipADf"
|
||||
}
|
||||
String timestamp = new SimpleDateFormat("MM_dd_HH_mm").format(new Date())
|
||||
|
||||
android {
|
||||
namespace 'com.keyboard.journey'
|
||||
@ -20,7 +19,7 @@ android {
|
||||
targetSdk 34
|
||||
versionCode 5
|
||||
versionName "1.0.5"
|
||||
|
||||
setProperty("archivesBaseName", "Keyboard Journey_V" + versionName + "(${versionCode})_$timestamp")
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
@ -72,12 +71,8 @@ dependencies {
|
||||
//7z
|
||||
implementation 'com.github.omicronapps:7-Zip-JBinding-4Android:Release-16.02-2.02'
|
||||
|
||||
implementation 'com.applovin:applovin-sdk:12.1.0'
|
||||
implementation 'com.applovin.mediation:vungle-adapter:6.12.0.0'
|
||||
implementation 'com.applovin.mediation:mintegral-adapter:16.2.31.0'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.3.2'
|
||||
// implementation 'com.applovin.mediation:bytedance-adapter:4.7.0.8.0'
|
||||
implementation 'com.applovin.mediation:unityads-adapter:4.4.1.0'
|
||||
|
||||
|
||||
implementation(platform("com.google.firebase:firebase-bom:32.2.2"))
|
||||
implementation("com.google.firebase:firebase-analytics-ktx")
|
||||
implementation("com.google.firebase:firebase-crashlytics-ktx")
|
||||
|
||||
@ -16,10 +16,6 @@
|
||||
android:theme="@style/Theme.KeyboardJourney"
|
||||
tools:targetApi="31">
|
||||
|
||||
|
||||
<meta-data android:name="applovin.sdk.key"
|
||||
android:value="wt2KAZMCf_SkV_coMIB7GWtaOQtCd2ZFRK8hFAQo7zbXpIGpG5iI0fZ0sMJr5n_cCO3LEVU66gpxe099OFXXvv"/>
|
||||
|
||||
<activity
|
||||
android:name=".JourneyStartActivity"
|
||||
android:exported="true">
|
||||
|
||||
@ -1,18 +1,16 @@
|
||||
package com.keyboard.journey
|
||||
|
||||
import android.app.Application
|
||||
import com.applovin.sdk.AppLovinSdk
|
||||
import com.applovin.sdk.AppLovinSdkConfiguration
|
||||
|
||||
class JourneyApp : Application() {
|
||||
companion object {
|
||||
lateinit var app: JourneyApp
|
||||
const val TAG = "----------"
|
||||
}
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
app = this
|
||||
AppLovinSdk.getInstance(this).mediationProvider = "max"
|
||||
AppLovinSdk.getInstance(this).initializeSdk()
|
||||
|
||||
}
|
||||
}
|
||||
@ -6,7 +6,6 @@ import android.view.View
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.gyf.immersionbar.ktx.immersionBar
|
||||
import com.keyboard.journey.ad.MaxAdsInsUtil
|
||||
import com.keyboard.journey.adapter.CategoryDetailsDataAdapter
|
||||
import com.keyboard.journey.bean.CategoryDataBean
|
||||
import com.keyboard.journey.bean.ItemDataBean
|
||||
@ -36,7 +35,7 @@ class JourneyCategoryDetailsActivity : AppCompatActivity() {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = JourneyCategoryDetailsActivityBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
MaxAdsInsUtil.showAdRandomMode(this)
|
||||
// TODO: showAd
|
||||
bean = intent.getSerializableExtra(CATEGORY_DETAILS_BEAN_KEY) as MainDataBean?
|
||||
if (bean == null) {
|
||||
finish()
|
||||
@ -45,7 +44,7 @@ class JourneyCategoryDetailsActivity : AppCompatActivity() {
|
||||
initView()
|
||||
initData()
|
||||
|
||||
MaxAdsInsUtil.loadAllAdIsNotCached(this)
|
||||
|
||||
}
|
||||
|
||||
private fun initBar() {
|
||||
|
||||
@ -4,9 +4,7 @@ import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.bumptech.glide.Glide
|
||||
import com.gyf.immersionbar.ktx.immersionBar
|
||||
import com.keyboard.journey.ad.MaxAdsInsUtil
|
||||
import com.keyboard.journey.bean.DetailsBean
|
||||
import com.keyboard.journey.bean.ItemDataBean
|
||||
import com.keyboard.journey.databinding.JourneyDetailsActivityBinding
|
||||
@ -33,12 +31,12 @@ class JourneyDetailsActivity : AppCompatActivity(), OnDownloadListener {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = JourneyDetailsActivityBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
MaxAdsInsUtil.showAdRandomMode(this)
|
||||
// TODO: showAd
|
||||
bean = intent.getSerializableExtra(KEY_JOURNEY_DETAILS_BEAN) as ItemDataBean?
|
||||
initBar()
|
||||
initView()
|
||||
initData()
|
||||
MaxAdsInsUtil.loadAllAdIsNotCached(this)
|
||||
|
||||
}
|
||||
|
||||
private fun initBar() {
|
||||
|
||||
@ -6,6 +6,7 @@ import android.graphics.Color
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.provider.Settings
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.Toast
|
||||
@ -14,7 +15,6 @@ import androidx.core.view.GravityCompat
|
||||
import androidx.drawerlayout.widget.DrawerLayout
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.gyf.immersionbar.ktx.immersionBar
|
||||
import com.keyboard.journey.ad.MaxAdsInsUtil
|
||||
import com.keyboard.journey.adapter.BannerImgAdapter
|
||||
import com.keyboard.journey.adapter.MainDataAdapter
|
||||
import com.keyboard.journey.bean.CategoryDataBean
|
||||
@ -25,7 +25,6 @@ import com.keyboard.journey.util.NetworkUtil
|
||||
import com.keyboard.journey.util.getRandomInt
|
||||
import com.keyboard.journey.util.isMyInputMethodDefault
|
||||
import com.keyboard.journey.util.isMyInputMethodEnabled
|
||||
import com.keyboard.journey.util.openPrivacyPolicy
|
||||
import com.keyboard.journey.util.shareAppInfo
|
||||
import com.youth.banner.listener.OnPageChangeListener
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
@ -35,15 +34,9 @@ import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.awaitAll
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
import kotlinx.coroutines.withContext
|
||||
import okhttp3.Call
|
||||
import okhttp3.Callback
|
||||
import okhttp3.Response
|
||||
import org.libpag.PAGFile
|
||||
import java.io.IOException
|
||||
import kotlin.coroutines.resume
|
||||
import kotlin.coroutines.resumeWithException
|
||||
|
||||
|
||||
class JourneyMActivity : AppCompatActivity() {
|
||||
@ -54,21 +47,21 @@ class JourneyMActivity : AppCompatActivity() {
|
||||
private var backPressedOnce = false
|
||||
private var currentBannerType = 0
|
||||
|
||||
private lateinit var bannerStr0: String
|
||||
private lateinit var bannerStr1: String
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = JourneyActivityMainBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
bannerStr0 = getString(R.string.recommend)
|
||||
bannerStr1 = getString(R.string.cool)
|
||||
initBar()
|
||||
initView()
|
||||
initData()
|
||||
}
|
||||
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
MaxAdsInsUtil.loadAllAdIsNotCached(this)
|
||||
}
|
||||
|
||||
private suspend fun getFetchCategory(
|
||||
key: String,
|
||||
offset: Int,
|
||||
@ -102,9 +95,6 @@ class JourneyMActivity : AppCompatActivity() {
|
||||
override fun onSuccess(data: List<MainDataBean>) {
|
||||
GlobalScope.launch(Dispatchers.IO) {
|
||||
val jobs = data.map { bean ->
|
||||
if (bean.title == "For You") {
|
||||
bean.title = "Recommend"
|
||||
}
|
||||
GlobalScope.async(Dispatchers.IO) {
|
||||
val resultCategory = getFetchCategory(
|
||||
bean.key, getRandomInt(1, 15),
|
||||
@ -118,6 +108,7 @@ class JourneyMActivity : AppCompatActivity() {
|
||||
withContext(Dispatchers.Main) {
|
||||
dataList.clear()
|
||||
dataList.addAll(list)
|
||||
Log.d(JourneyApp.TAG, "--------------dataList=${dataList.size}")
|
||||
mainAdapter?.notifyDataSetChanged()
|
||||
loadingClose()
|
||||
}
|
||||
@ -161,14 +152,21 @@ class JourneyMActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
binding.bannerBtn.setOnClickListener {
|
||||
|
||||
val recommend = dataList.filter { it.title == "Recommend" }
|
||||
val cool = dataList.filter { it.title == "Cool" }
|
||||
for (data in dataList) {
|
||||
Log.d(JourneyApp.TAG, "---------- data=${data.title}")
|
||||
}
|
||||
val recommend = dataList.filter { it.title.contains("For You") }
|
||||
val cool = dataList.filter { it.title.contains(bannerStr1) }
|
||||
if (currentBannerType == 0) {
|
||||
Log.d(JourneyApp.TAG, "----------0 recommend.size=${recommend.size}")
|
||||
val intent = Intent(this, JourneyCategoryDetailsActivity::class.java)
|
||||
intent.putExtra(JourneyCategoryDetailsActivity.CATEGORY_DETAILS_BEAN_KEY, recommend[0])
|
||||
intent.putExtra(
|
||||
JourneyCategoryDetailsActivity.CATEGORY_DETAILS_BEAN_KEY,
|
||||
recommend[0]
|
||||
)
|
||||
startActivity(intent)
|
||||
} else if (currentBannerType == 1) {
|
||||
Log.d(JourneyApp.TAG, "----------1 cool.size=${cool.size}")
|
||||
val intent = Intent(this, JourneyCategoryDetailsActivity::class.java)
|
||||
intent.putExtra(JourneyCategoryDetailsActivity.CATEGORY_DETAILS_BEAN_KEY, cool[0])
|
||||
startActivity(intent)
|
||||
@ -180,7 +178,11 @@ class JourneyMActivity : AppCompatActivity() {
|
||||
if (enabled && default) {
|
||||
binding.dialogStepLayout.visibility = View.GONE
|
||||
|
||||
Toast.makeText(this,"The keyboard has been set up successfully!",Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(
|
||||
this,
|
||||
"The keyboard has been set up successfully!",
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
} else {
|
||||
binding.dialogStepLayout.visibility = View.VISIBLE
|
||||
updateSetMyInputMethod()
|
||||
@ -252,7 +254,7 @@ class JourneyMActivity : AppCompatActivity() {
|
||||
currentBannerType = 0
|
||||
binding.indicatorLayout.setBackgroundColor(getColor(R.color.banner_indicator_one_bg))
|
||||
binding.indicatorImg.setImageResource(R.mipmap.top_banner_one_img)
|
||||
binding.indicatorTxt.text = getString(R.string.recommend)
|
||||
binding.indicatorTxt.text = bannerStr0
|
||||
binding.indicatorGoBg.setCardBackgroundColor(getColor(R.color.banner_indicator_one_go_bg_color))
|
||||
binding.indicatorLineOneBg.setBackgroundColor(getColor(R.color.banner_indicator_one_go_bg_color))
|
||||
binding.indicatorLineTowBg.setBackgroundColor(getColor(R.color.black_10))
|
||||
@ -262,7 +264,7 @@ class JourneyMActivity : AppCompatActivity() {
|
||||
currentBannerType = 1
|
||||
binding.indicatorLayout.setBackgroundColor(getColor(R.color.banner_indicator_tow_bg))
|
||||
binding.indicatorImg.setImageResource(R.mipmap.top_banner_tow_img)
|
||||
binding.indicatorTxt.text = getString(R.string.cool)
|
||||
binding.indicatorTxt.text = bannerStr1
|
||||
binding.indicatorGoBg.setCardBackgroundColor(getColor(R.color.banner_indicator_tow_go_bg_color))
|
||||
binding.indicatorLineOneBg.setBackgroundColor(getColor(R.color.black_10))
|
||||
binding.indicatorLineTowBg.setBackgroundColor(getColor(R.color.banner_indicator_tow_go_bg_color))
|
||||
|
||||
@ -3,16 +3,9 @@ package com.keyboard.journey
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.applovin.mediation.MaxError
|
||||
import com.gyf.immersionbar.ktx.immersionBar
|
||||
import com.keyboard.journey.ad.AdLoadListener
|
||||
import com.keyboard.journey.ad.AdShowFailed
|
||||
import com.keyboard.journey.ad.AdShowListener
|
||||
import com.keyboard.journey.ad.MaxAdsInsUtil
|
||||
import com.keyboard.journey.databinding.JourneyStartActivityBinding
|
||||
import org.libpag.PAGFile
|
||||
import java.util.Timer
|
||||
import java.util.TimerTask
|
||||
|
||||
class JourneyStartActivity : AppCompatActivity() {
|
||||
companion object {
|
||||
@ -20,7 +13,7 @@ class JourneyStartActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
private lateinit var binding: JourneyStartActivityBinding
|
||||
private var timer: DelayTimer? = null // 可变变量,初始化为 null
|
||||
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@ -30,61 +23,11 @@ class JourneyStartActivity : AppCompatActivity() {
|
||||
fullScreen(true)
|
||||
statusBarDarkFont(false)
|
||||
}
|
||||
timer = DelayTimer(SPLASH_TIME_OUT, callback = {
|
||||
LogUtil.logMsgD("loaded ing")
|
||||
if (adCanShow()) {
|
||||
timer?.stop()
|
||||
showAd()
|
||||
}
|
||||
}, com = {
|
||||
startMain()
|
||||
})
|
||||
loadAd()
|
||||
if (timer != null) {
|
||||
timer?.start()
|
||||
}
|
||||
|
||||
loadingPlay()
|
||||
startMain()
|
||||
}
|
||||
|
||||
private fun loadAd() {
|
||||
MaxAdsInsUtil.loadMaxAd(
|
||||
this,
|
||||
MaxAdsInsUtil.Placement.SPLASH_AD_ID, object : AdLoadListener {
|
||||
override fun loaded() {
|
||||
LogUtil.logMsgD("loaded")
|
||||
}
|
||||
|
||||
override fun loadFailed(error: MaxError?) {
|
||||
LogUtil.logMsgD(error.toString())
|
||||
startMain()
|
||||
timer?.stop()
|
||||
}
|
||||
})
|
||||
MaxAdsInsUtil.loadSplashAllAd(this)
|
||||
}
|
||||
|
||||
private fun adCanShow(): Boolean {
|
||||
return MaxAdsInsUtil.canShowAd(MaxAdsInsUtil.Placement.SPLASH_AD_ID)
|
||||
}
|
||||
|
||||
private fun showAd() {
|
||||
MaxAdsInsUtil.showMaxAd(
|
||||
this,
|
||||
MaxAdsInsUtil.Placement.SPLASH_AD_ID,
|
||||
object : AdShowListener {
|
||||
override fun onAdShown() {
|
||||
|
||||
}
|
||||
|
||||
override fun onAdShowFailed(error: AdShowFailed?) {
|
||||
startMain()
|
||||
}
|
||||
|
||||
override fun onAdClosed() {
|
||||
startMain()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun startMain() {
|
||||
val intent = Intent(this, JourneyMActivity::class.java)
|
||||
@ -109,32 +52,5 @@ class JourneyStartActivity : AppCompatActivity() {
|
||||
super.onDestroy()
|
||||
loadingClose()
|
||||
}
|
||||
}
|
||||
|
||||
class DelayTimer(
|
||||
private val totalDelayInMillis: Long,
|
||||
private val callback: () -> Unit,
|
||||
private val com: () -> Unit
|
||||
) {
|
||||
|
||||
private val timer = Timer()
|
||||
private var elapsedTime: Long = 0
|
||||
|
||||
fun start() {
|
||||
timer.scheduleAtFixedRate(object : TimerTask() {
|
||||
override fun run() {
|
||||
if (elapsedTime < totalDelayInMillis) {
|
||||
callback.invoke()
|
||||
elapsedTime += 1000 // 每秒钟递增
|
||||
} else {
|
||||
com.invoke()
|
||||
stop()
|
||||
}
|
||||
}
|
||||
}, 0, 1000) // 每秒钟执行一次
|
||||
}
|
||||
|
||||
fun stop() {
|
||||
timer.cancel()
|
||||
}
|
||||
}
|
||||
@ -13,7 +13,6 @@ import android.view.View
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.gyf.immersionbar.ktx.immersionBar
|
||||
import com.keyboard.journey.ad.MaxAdsInsUtil
|
||||
import com.keyboard.journey.databinding.JourneyPreviewActivityBinding
|
||||
import com.keyboard.journey.util.currentlyThemeUFileString
|
||||
import com.keyboard.journey.util.getBitmapXXDrawable
|
||||
@ -34,7 +33,7 @@ class PreviewActivity : AppCompatActivity() {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = JourneyPreviewActivityBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
MaxAdsInsUtil.loadAllAdIsNotCached(this)
|
||||
|
||||
initBar()
|
||||
themeUrl = intent.getStringExtra(KEY_PREVIEW_URL).toString()
|
||||
registerReceiver()
|
||||
@ -54,8 +53,8 @@ class PreviewActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
MaxAdsInsUtil.showAdRandomMode(this)
|
||||
super.onBackPressed()
|
||||
// TODO: showAd
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
|
||||
@ -1,8 +0,0 @@
|
||||
package com.keyboard.journey.ad
|
||||
|
||||
import com.applovin.mediation.MaxError
|
||||
|
||||
interface AdLoadListener {
|
||||
fun loadFailed(error: MaxError?) {}
|
||||
fun loaded() {}
|
||||
}
|
||||
@ -1,5 +0,0 @@
|
||||
package com.keyboard.journey.ad
|
||||
|
||||
data class AdShowFailed(
|
||||
val msg: String = "",
|
||||
)
|
||||
@ -1,7 +0,0 @@
|
||||
package com.keyboard.journey.ad
|
||||
|
||||
interface AdShowListener {
|
||||
fun onAdShown() {}
|
||||
fun onAdShowFailed(error: AdShowFailed?) {}
|
||||
fun onAdClosed() {}
|
||||
}
|
||||
@ -1,21 +0,0 @@
|
||||
package com.keyboard.journey.ad
|
||||
|
||||
import com.applovin.mediation.ads.MaxInterstitialAd
|
||||
|
||||
class InstAdCacheManager {
|
||||
private val mMaxAdCacheDict: MutableMap<String, MaxInterstitialAd> = mutableMapOf()
|
||||
|
||||
companion object {
|
||||
val instance: InstAdCacheManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
|
||||
InstAdCacheManager()
|
||||
}
|
||||
}
|
||||
|
||||
fun setAdCache(place: String, adCache: MaxInterstitialAd) {
|
||||
mMaxAdCacheDict[place] = adCache
|
||||
}
|
||||
|
||||
fun getAdCache(place: String): MaxInterstitialAd? {
|
||||
return mMaxAdCacheDict[place]
|
||||
}
|
||||
}
|
||||
@ -1,59 +0,0 @@
|
||||
package com.keyboard.journey.ad
|
||||
|
||||
import android.app.Activity
|
||||
import com.applovin.mediation.MaxAd
|
||||
import com.applovin.mediation.MaxAdListener
|
||||
import com.applovin.mediation.MaxError
|
||||
import com.applovin.mediation.ads.MaxInterstitialAd
|
||||
|
||||
class MaxAdInstLoad {
|
||||
private var mPlace: String
|
||||
private var adLoadListener: AdLoadListener? = null
|
||||
private var activity: Activity? = null
|
||||
|
||||
constructor(activity: Activity, place: String, listener: AdLoadListener?) {
|
||||
this.mPlace = place
|
||||
this.adLoadListener = listener
|
||||
this.activity = activity
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(place: String, listener: AdLoadListener?) {
|
||||
this.mPlace = place
|
||||
this.adLoadListener = listener
|
||||
init()
|
||||
}
|
||||
|
||||
private fun init() {
|
||||
val interstitialAd = MaxInterstitialAd(mPlace, activity)
|
||||
interstitialAd.setListener(object : MaxAdListener {
|
||||
override fun onAdLoaded(p0: MaxAd) {
|
||||
// Handle ad loaded event
|
||||
InstAdCacheManager.instance.setAdCache(mPlace, interstitialAd)
|
||||
adLoadListener?.loaded()
|
||||
}
|
||||
|
||||
override fun onAdDisplayed(p0: MaxAd) {
|
||||
// Handle ad displayed event
|
||||
}
|
||||
|
||||
override fun onAdHidden(p0: MaxAd) {
|
||||
// Handle ad hidden event
|
||||
}
|
||||
|
||||
override fun onAdClicked(p0: MaxAd) {
|
||||
// Handle ad clicked event
|
||||
}
|
||||
|
||||
override fun onAdLoadFailed(p0: String, p1: MaxError) {
|
||||
// Handle ad load failure event
|
||||
adLoadListener?.loadFailed(p1)
|
||||
}
|
||||
|
||||
override fun onAdDisplayFailed(p0: MaxAd, p1: MaxError) {
|
||||
// Handle ad display failure event
|
||||
}
|
||||
})
|
||||
interstitialAd.loadAd()
|
||||
}
|
||||
}
|
||||
@ -1,58 +0,0 @@
|
||||
package com.keyboard.journey.ad
|
||||
|
||||
import android.app.Activity
|
||||
import com.applovin.mediation.MaxAd
|
||||
import com.applovin.mediation.MaxAdListener
|
||||
import com.applovin.mediation.MaxError
|
||||
|
||||
class MaxAdInstShower {
|
||||
private var mPlace: String
|
||||
private var showListener: AdShowListener? = null
|
||||
private var activity: Activity? = null
|
||||
|
||||
constructor(activity: Activity, place: String, showListener: AdShowListener?) {
|
||||
this.mPlace = place
|
||||
this.showListener = showListener
|
||||
this.activity = activity
|
||||
init()
|
||||
}
|
||||
|
||||
constructor(place: String, showListener: AdShowListener?) {
|
||||
this.mPlace = place
|
||||
this.showListener = showListener
|
||||
init()
|
||||
}
|
||||
|
||||
private fun init() {
|
||||
val interstitialAd = InstAdCacheManager.instance.getAdCache(mPlace)
|
||||
interstitialAd?.setListener(object : MaxAdListener {
|
||||
override fun onAdLoaded(p0: MaxAd) {
|
||||
// Handle ad loaded event
|
||||
}
|
||||
|
||||
override fun onAdDisplayed(p0: MaxAd) {
|
||||
// Handle ad displayed event
|
||||
showListener?.onAdShown()
|
||||
}
|
||||
|
||||
override fun onAdHidden(p0: MaxAd) {
|
||||
// Handle ad hidden event
|
||||
showListener?.onAdClosed()
|
||||
}
|
||||
|
||||
override fun onAdClicked(p0: MaxAd) {
|
||||
// Handle ad clicked event
|
||||
}
|
||||
|
||||
override fun onAdLoadFailed(p0: String, p1: MaxError) {
|
||||
// Handle ad load failure event
|
||||
showListener?.onAdShowFailed(AdShowFailed(p1.message))
|
||||
}
|
||||
|
||||
override fun onAdDisplayFailed(p0: MaxAd, p1: MaxError) {
|
||||
// Handle ad display failure event
|
||||
}
|
||||
})
|
||||
interstitialAd?.showAd()
|
||||
}
|
||||
}
|
||||
@ -1,82 +0,0 @@
|
||||
package com.keyboard.journey.ad
|
||||
|
||||
import android.app.Activity
|
||||
import java.util.Random
|
||||
|
||||
object MaxAdsInsUtil {
|
||||
|
||||
object Placement {
|
||||
const val SPLASH_AD_ID = "f17d90b8ffcd8c43"
|
||||
const val MAX_AD_ID_ONE = "b940838b4e632b48"
|
||||
const val MAX_AD_ID_TOW = "872bcabcd258447b"
|
||||
|
||||
val adPlaceAllList = listOf(
|
||||
SPLASH_AD_ID,
|
||||
MAX_AD_ID_ONE,
|
||||
MAX_AD_ID_TOW
|
||||
)
|
||||
}
|
||||
|
||||
fun loadSplashAllAd(act: Activity) {
|
||||
Placement.adPlaceAllList.drop(1).forEach { placement ->
|
||||
loadAdIfNotCached(act, placement)
|
||||
}
|
||||
}
|
||||
|
||||
fun loadAllAdIsNotCached(act: Activity) {
|
||||
Placement.adPlaceAllList.forEach { placement ->
|
||||
loadAdIfNotCached(act, placement)
|
||||
}
|
||||
}
|
||||
|
||||
fun loadAdIfNotCached(act: Activity, placement: String, listener: AdLoadListener? = null) {
|
||||
if (act.isFinishing || canShowAd(placement)) return
|
||||
loadMaxAd(act, placement, listener)
|
||||
}
|
||||
|
||||
fun showAdRandomMode(act: Activity) {
|
||||
val adPlace: MutableList<String> = ArrayList()
|
||||
Placement.adPlaceAllList.forEach { placement ->
|
||||
if (canShowAd(placement)) {
|
||||
adPlace.add(placement)
|
||||
}
|
||||
}
|
||||
if (adPlace.isNotEmpty()) {
|
||||
val placeId = Random().nextInt(adPlace.size)
|
||||
val place = adPlace[placeId]
|
||||
showAdIfCached(act, place)
|
||||
}
|
||||
}
|
||||
|
||||
fun showAdIfCached(act: Activity, placement: String, listener: AdShowListener? = null) {
|
||||
if (act.isFinishing || !canShowAd(placement)) {
|
||||
listener?.onAdShowFailed(AdShowFailed("No cache for ads"))
|
||||
} else {
|
||||
showMaxAd(act, placement, listener)
|
||||
}
|
||||
}
|
||||
|
||||
fun loadMaxAd(
|
||||
act: Activity,
|
||||
adID: String,
|
||||
loadListener: AdLoadListener?
|
||||
): MaxAdInstLoad {
|
||||
return MaxAdInstLoad(act, adID, loadListener)
|
||||
}
|
||||
|
||||
fun showMaxAd(
|
||||
act: Activity,
|
||||
adID: String,
|
||||
listener: AdShowListener?
|
||||
): MaxAdInstShower {
|
||||
return MaxAdInstShower(act, adID, listener)
|
||||
}
|
||||
|
||||
fun canShowAd(adID: String): Boolean {
|
||||
InstAdCacheManager.instance.getAdCache(adID)?.let {
|
||||
return it.isReady
|
||||
} ?: let {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,9 +1,5 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
buildscript {
|
||||
dependencies {
|
||||
classpath("com.applovin.quality:AppLovinQualityServiceGradlePlugin:5.0.7")
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'com.android.application' version '8.0.1' apply false
|
||||
id 'com.android.library' version '8.0.1' apply false
|
||||
|
||||
@ -4,7 +4,6 @@ pluginManagement {
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
maven { url 'https://jitpack.io' }
|
||||
maven { url 'https://artifacts.applovin.com/android' }
|
||||
}
|
||||
}
|
||||
dependencyResolutionManagement {
|
||||
@ -12,12 +11,9 @@ dependencyResolutionManagement {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
|
||||
maven { url 'https://jitpack.io' }
|
||||
maven { url 'https://artifacts.applovin.com/android' }
|
||||
maven { url "https://s01.oss.sonatype.org/content/groups/public" }
|
||||
maven { url "https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea" }
|
||||
// maven { url "https://artifact.bytedance.com/repository/pangle" }
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user