V1.0.1(2) 广告版本更新
This commit is contained in:
parent
354b2298db
commit
daf5698a99
1
.gitignore
vendored
1
.gitignore
vendored
@ -15,3 +15,4 @@
|
|||||||
local.properties
|
local.properties
|
||||||
.idea/
|
.idea/
|
||||||
app/release/
|
app/release/
|
||||||
|
.safedk/
|
||||||
|
|||||||
@ -5,6 +5,12 @@ plugins {
|
|||||||
id("com.android.application")
|
id("com.android.application")
|
||||||
id("org.jetbrains.kotlin.android")
|
id("org.jetbrains.kotlin.android")
|
||||||
id ("kotlin-kapt")
|
id ("kotlin-kapt")
|
||||||
|
id("applovin-quality-service")
|
||||||
|
id("com.google.gms.google-services")
|
||||||
|
id("com.google.firebase.crashlytics")
|
||||||
|
}
|
||||||
|
applovin{
|
||||||
|
apiKey = "y87o4e7vb5bbqzuGVTFyOIfZiyBG0Nf0Ksq8S3m2MJOHf_A5BcWGJnKuQqoxwxVvtdQdiTC4O3MPzFwy8rJ9Cc"
|
||||||
}
|
}
|
||||||
val timestamp = SimpleDateFormat("MM_dd_HH_mm").format(Date())
|
val timestamp = SimpleDateFormat("MM_dd_HH_mm").format(Date())
|
||||||
android {
|
android {
|
||||||
@ -18,8 +24,8 @@ android {
|
|||||||
applicationId = "com.various.funny.sounds.audio"
|
applicationId = "com.various.funny.sounds.audio"
|
||||||
minSdk = 23
|
minSdk = 23
|
||||||
targetSdk = 34
|
targetSdk = 34
|
||||||
versionCode = 1
|
versionCode = 2
|
||||||
versionName = "1.0.0"
|
versionName = "1.0.1"
|
||||||
setProperty("archivesBaseName", "Various Funny Sounds_V" + versionName + "(${versionCode})_$timestamp")
|
setProperty("archivesBaseName", "Various Funny Sounds_V" + versionName + "(${versionCode})_$timestamp")
|
||||||
testInstrumentationRunner = "androidx.audio.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.audio.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
@ -61,4 +67,11 @@ dependencies {
|
|||||||
implementation ("androidx.room:room-ktx:2.6.1")
|
implementation ("androidx.room:room-ktx:2.6.1")
|
||||||
implementation ("androidx.room:room-runtime:2.6.1")
|
implementation ("androidx.room:room-runtime:2.6.1")
|
||||||
kapt ("androidx.room:room-compiler:2.6.1")
|
kapt ("androidx.room:room-compiler:2.6.1")
|
||||||
|
|
||||||
|
implementation("com.applovin:applovin-sdk:+")
|
||||||
|
implementation("com.applovin.mediation:vungle-adapter:+")
|
||||||
|
implementation("com.applovin.mediation:bytedance-adapter:+")
|
||||||
|
implementation(platform("com.google.firebase:firebase-bom:32.3.1"))
|
||||||
|
implementation("com.google.firebase:firebase-analytics-ktx")
|
||||||
|
implementation ("com.google.firebase:firebase-crashlytics-ktx")
|
||||||
}
|
}
|
||||||
29
app/google-services.json
Normal file
29
app/google-services.json
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"project_info": {
|
||||||
|
"project_number": "302797298052",
|
||||||
|
"project_id": "various-funny-sounds",
|
||||||
|
"storage_bucket": "various-funny-sounds.appspot.com"
|
||||||
|
},
|
||||||
|
"client": [
|
||||||
|
{
|
||||||
|
"client_info": {
|
||||||
|
"mobilesdk_app_id": "1:302797298052:android:853a3ab1d40f7a7b1b25d1",
|
||||||
|
"android_client_info": {
|
||||||
|
"package_name": "com.various.funny.sounds.audio"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"oauth_client": [],
|
||||||
|
"api_key": [
|
||||||
|
{
|
||||||
|
"current_key": "AIzaSyBbjKvStdaHM10KbT38jJoiMgrPA3IoVGw"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"services": {
|
||||||
|
"appinvite_service": {
|
||||||
|
"other_platform_oauth_client": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"configuration_version": "1"
|
||||||
|
}
|
||||||
@ -1,6 +1,12 @@
|
|||||||
package com.various.funny.sounds.audio
|
package com.various.funny.sounds.audio
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
|
import android.content.Intent
|
||||||
|
import android.util.Log
|
||||||
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||||
|
import com.applovin.sdk.AppLovinSdk
|
||||||
|
import com.applovin.sdk.AppLovinSdkInitializationConfiguration
|
||||||
import com.various.funny.sounds.audio.db.MyRoomBase
|
import com.various.funny.sounds.audio.db.MyRoomBase
|
||||||
import com.various.funny.sounds.audio.helper.ComUtils
|
import com.various.funny.sounds.audio.helper.ComUtils
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
@ -11,16 +17,21 @@ class VariousFunnySounds : Application() {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
lateinit var appContext: VariousFunnySounds
|
lateinit var appContext: VariousFunnySounds
|
||||||
|
const val MAX_SDK = "3cUMfTcsZKzlJevxK4IkNysgDAeQA4B5w332p3g8B9ZAgC54WQNZLVxuxnCx4sCHA5StLJnDTAFa68mFTi8rd8"
|
||||||
|
const val MAX_Provider = "max"
|
||||||
|
const val MAX_INIT_SDK_ACTION = "init_sdk_success"
|
||||||
|
var initSDkOk = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
appContext = this
|
appContext = this
|
||||||
|
MAXSDK()
|
||||||
getData()
|
getData()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("SuspiciousIndentation")
|
||||||
private fun getData() {
|
private fun getData() {
|
||||||
val open = assets.open("resource_target.json")
|
val open = assets.open("resource_target.json")
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
@ -30,7 +41,16 @@ class VariousFunnySounds : Application() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
private fun MAXSDK(){
|
||||||
|
val initConfig =
|
||||||
|
AppLovinSdkInitializationConfiguration.builder(MAX_SDK, this)
|
||||||
|
.setMediationProvider(MAX_Provider)
|
||||||
|
.build()
|
||||||
|
AppLovinSdk.getInstance(this).initialize(initConfig) {
|
||||||
|
initSDkOk = true
|
||||||
|
LocalBroadcastManager.getInstance(this).sendBroadcast(Intent(MAX_INIT_SDK_ACTION))
|
||||||
|
}
|
||||||
|
AppLovinSdk.getInstance(this).settings.setVerboseLogging(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
package com.various.funny.sounds.audio.max;
|
||||||
|
|
||||||
|
import com.applovin.mediation.MaxAd;
|
||||||
|
|
||||||
|
public interface MaxListener {
|
||||||
|
void onFail(MaxAd ad);
|
||||||
|
void onSuccess();
|
||||||
|
void onHidden( );
|
||||||
|
}
|
||||||
@ -0,0 +1,82 @@
|
|||||||
|
package com.various.funny.sounds.audio.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 java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class MaxManager {
|
||||||
|
|
||||||
|
private static final String id_1 = "d6fa375e3d84dbfc";
|
||||||
|
private static final String id_2 = "8f6d9428116466c8";
|
||||||
|
private static final String id_3 = "b8c94caf5277e32a";
|
||||||
|
|
||||||
|
public static MaxInterstitialAd checkCacheAd(List<MaxInterstitialAd> list) {
|
||||||
|
Collections.shuffle(list);
|
||||||
|
for (MaxInterstitialAd ad : list) {
|
||||||
|
if (ad.isReady()) {
|
||||||
|
return ad;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setMaxListener(MaxInterstitialAd ad, MaxListener maxListener) {
|
||||||
|
ad.setListener(new MaxAdListener() {
|
||||||
|
@Override
|
||||||
|
public void onAdLoaded(@NonNull MaxAd maxAd) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAdDisplayed(@NonNull MaxAd maxAd) {
|
||||||
|
maxListener.onSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAdHidden(@NonNull MaxAd maxAd) {
|
||||||
|
maxListener.onHidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
@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 List<MaxInterstitialAd> loadAd(Activity activity) {
|
||||||
|
MaxInterstitialAd Ad1 = new MaxInterstitialAd(id_1, activity);
|
||||||
|
Ad1.loadAd();
|
||||||
|
MaxInterstitialAd Ad2 = new MaxInterstitialAd(id_2, activity);
|
||||||
|
Ad2.loadAd();
|
||||||
|
MaxInterstitialAd Ad3 = new MaxInterstitialAd(id_3, activity);
|
||||||
|
Ad3.loadAd();
|
||||||
|
ArrayList<MaxInterstitialAd> maxInterstitialAds = new ArrayList<>();
|
||||||
|
maxInterstitialAds.add(Ad1);
|
||||||
|
maxInterstitialAds.add(Ad2);
|
||||||
|
maxInterstitialAds.add(Ad3);
|
||||||
|
return maxInterstitialAds;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,31 +1,90 @@
|
|||||||
package com.various.funny.sounds.audio.ui.activity
|
package com.various.funny.sounds.audio.ui.activity
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver
|
||||||
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.content.IntentFilter
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.CountDownTimer
|
import android.os.CountDownTimer
|
||||||
|
import android.util.Log
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||||
|
import com.applovin.mediation.MaxAd
|
||||||
|
import com.applovin.mediation.ads.MaxInterstitialAd
|
||||||
import com.various.funny.sounds.audio.R
|
import com.various.funny.sounds.audio.R
|
||||||
|
import com.various.funny.sounds.audio.VariousFunnySounds
|
||||||
|
import com.various.funny.sounds.audio.max.MaxListener
|
||||||
|
import com.various.funny.sounds.audio.max.MaxManager
|
||||||
|
|
||||||
class OpenActivity : AppCompatActivity() {
|
class OpenActivity : AppCompatActivity() {
|
||||||
|
private lateinit var listAd: List<MaxInterstitialAd>
|
||||||
|
private lateinit var countDownTimer: CountDownTimer
|
||||||
|
|
||||||
|
private var needShowAd = true
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_open)
|
setContentView(R.layout.activity_open)
|
||||||
initStatusBar()
|
initStatusBar()
|
||||||
val countDownTimer = object : CountDownTimer(2000, 1000) {
|
countDownTimer = object : CountDownTimer(12000, 500) {
|
||||||
override fun onTick(millisUntilFinished: Long) {
|
override fun onTick(millisUntilFinished: Long) {
|
||||||
|
if (needShowAd) {
|
||||||
|
startShowAd {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onFinish() {
|
override fun onFinish() {
|
||||||
startActivity(Intent(this@OpenActivity, HomeActivity::class.java))
|
if (needShowAd) {
|
||||||
|
startShowAd {
|
||||||
|
startActivity(Intent(this@OpenActivity, HomeActivity::class.java))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
checkAd()
|
||||||
|
}
|
||||||
|
private fun checkAd() {
|
||||||
|
if (!VariousFunnySounds.initSDkOk) {
|
||||||
|
LocalBroadcastManager.getInstance(this).registerReceiver(object : BroadcastReceiver() {
|
||||||
|
override fun onReceive(context: Context?, intent: Intent?) {
|
||||||
|
initAd()
|
||||||
|
}
|
||||||
|
}, IntentFilter(VariousFunnySounds.MAX_INIT_SDK_ACTION))
|
||||||
|
} else {
|
||||||
|
initAd()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun initAd() {
|
||||||
|
listAd = MaxManager.loadAd(this@OpenActivity)
|
||||||
countDownTimer.start()
|
countDownTimer.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun startShowAd(action: () -> Unit) {
|
||||||
|
val checkCacheAd = MaxManager.checkCacheAd(listAd)
|
||||||
|
if (checkCacheAd == null) {
|
||||||
|
action.invoke()
|
||||||
|
} else {
|
||||||
|
needShowAd = false
|
||||||
|
MaxManager.setMaxListener(checkCacheAd, object : MaxListener {
|
||||||
|
override fun onFail(ad: MaxAd?) {
|
||||||
|
startActivity(Intent(this@OpenActivity, HomeActivity::class.java))
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onSuccess() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onHidden() {
|
||||||
|
startActivity(Intent(this@OpenActivity, HomeActivity::class.java))
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
checkCacheAd.showAd()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun initStatusBar() {
|
private fun initStatusBar() {
|
||||||
val flags = window.decorView.systemUiVisibility or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
|
val flags = window.decorView.systemUiVisibility or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
|
||||||
window.decorView.systemUiVisibility = flags xor View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
|
window.decorView.systemUiVisibility = flags xor View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
|
||||||
|
|||||||
@ -7,12 +7,16 @@ import android.view.WindowManager
|
|||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
|
import com.applovin.mediation.MaxAd
|
||||||
|
import com.applovin.mediation.ads.MaxInterstitialAd
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.various.funny.sounds.audio.R
|
import com.various.funny.sounds.audio.R
|
||||||
import com.various.funny.sounds.audio.data.NewBeanChild
|
import com.various.funny.sounds.audio.data.NewBeanChild
|
||||||
import com.various.funny.sounds.audio.databinding.ActivityPlayBinding
|
import com.various.funny.sounds.audio.databinding.ActivityPlayBinding
|
||||||
import com.various.funny.sounds.audio.db.MyRoomBase
|
import com.various.funny.sounds.audio.db.MyRoomBase
|
||||||
import com.various.funny.sounds.audio.helper.ComUtils
|
import com.various.funny.sounds.audio.helper.ComUtils
|
||||||
|
import com.various.funny.sounds.audio.max.MaxListener
|
||||||
|
import com.various.funny.sounds.audio.max.MaxManager
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
@ -28,10 +32,11 @@ class PlayActivity : AppCompatActivity(), View.OnClickListener {
|
|||||||
private var mediaPlayer: MediaPlayer? = null
|
private var mediaPlayer: MediaPlayer? = null
|
||||||
|
|
||||||
private var isDownload = false
|
private var isDownload = false
|
||||||
|
private lateinit var listAds: List<MaxInterstitialAd>
|
||||||
private lateinit var newBeanChild: NewBeanChild
|
private lateinit var newBeanChild: NewBeanChild
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
listAds = MaxManager.loadAd(this@PlayActivity)
|
||||||
playBinding = ActivityPlayBinding.inflate(layoutInflater)
|
playBinding = ActivityPlayBinding.inflate(layoutInflater)
|
||||||
setContentView(playBinding.root)
|
setContentView(playBinding.root)
|
||||||
initStatusBar()
|
initStatusBar()
|
||||||
@ -61,15 +66,7 @@ class PlayActivity : AppCompatActivity(), View.OnClickListener {
|
|||||||
override fun onClick(v: View?) {
|
override fun onClick(v: View?) {
|
||||||
when (v) {
|
when (v) {
|
||||||
playBinding.imPlay -> {
|
playBinding.imPlay -> {
|
||||||
if(isDownload) {
|
showAd()
|
||||||
playBinding.imPlay.isSelected = !playBinding.imPlay.isSelected
|
|
||||||
play()
|
|
||||||
}else{
|
|
||||||
playBinding.progressbar.isVisible = true
|
|
||||||
startDownload()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
playBinding.iconBack -> {
|
playBinding.iconBack -> {
|
||||||
@ -88,6 +85,16 @@ class PlayActivity : AppCompatActivity(), View.OnClickListener {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun playAction() {
|
||||||
|
if (isDownload) {
|
||||||
|
playBinding.imPlay.isSelected = !playBinding.imPlay.isSelected
|
||||||
|
play()
|
||||||
|
} else {
|
||||||
|
playBinding.progressbar.isVisible = true
|
||||||
|
startDownload()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun initMediaPlayer() {
|
private fun initMediaPlayer() {
|
||||||
mediaPlayer = MediaPlayer()
|
mediaPlayer = MediaPlayer()
|
||||||
mediaPlayer?.isLooping = true
|
mediaPlayer?.isLooping = true
|
||||||
@ -106,7 +113,8 @@ class PlayActivity : AppCompatActivity(), View.OnClickListener {
|
|||||||
if (file == null) {
|
if (file == null) {
|
||||||
isDownload = false
|
isDownload = false
|
||||||
playBinding.imPlay.isSelected = false
|
playBinding.imPlay.isSelected = false
|
||||||
Toast.makeText(this@PlayActivity, getString(R.string.sorry), Toast.LENGTH_SHORT).show()
|
Toast.makeText(this@PlayActivity, getString(R.string.sorry), Toast.LENGTH_SHORT)
|
||||||
|
.show()
|
||||||
playBinding.progressbar.isVisible = false
|
playBinding.progressbar.isVisible = false
|
||||||
} else {
|
} else {
|
||||||
playBinding.progressbar.isVisible = false
|
playBinding.progressbar.isVisible = false
|
||||||
@ -137,6 +145,30 @@ class PlayActivity : AppCompatActivity(), View.OnClickListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun showAd() {
|
||||||
|
val checkCacheAd = MaxManager.checkCacheAd(listAds)
|
||||||
|
if (checkCacheAd != null) {
|
||||||
|
MaxManager.setMaxListener(checkCacheAd, object : MaxListener {
|
||||||
|
override fun onFail(ad: MaxAd?) {
|
||||||
|
playAction()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onSuccess() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onHidden() {
|
||||||
|
playAction()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
checkCacheAd.showAd()
|
||||||
|
} else {
|
||||||
|
playAction()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
|
|||||||
@ -2,54 +2,101 @@ package com.various.funny.sounds.audio.ui.activity
|
|||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
|
import com.applovin.mediation.MaxAd
|
||||||
|
import com.applovin.mediation.ads.MaxInterstitialAd
|
||||||
import com.various.funny.sounds.audio.databinding.ActivitySourceBinding
|
import com.various.funny.sounds.audio.databinding.ActivitySourceBinding
|
||||||
import com.various.funny.sounds.audio.helper.ComUtils
|
import com.various.funny.sounds.audio.helper.ComUtils
|
||||||
import com.various.funny.sounds.audio.helper.ItemSpace
|
import com.various.funny.sounds.audio.helper.ItemSpace
|
||||||
|
import com.various.funny.sounds.audio.max.MaxListener
|
||||||
|
import com.various.funny.sounds.audio.max.MaxManager
|
||||||
import com.various.funny.sounds.audio.ui.adapter.SourceAdapter
|
import com.various.funny.sounds.audio.ui.adapter.SourceAdapter
|
||||||
|
|
||||||
class SourceActivity : AppCompatActivity() {
|
class SourceActivity : AppCompatActivity() {
|
||||||
private lateinit var sourceBinding: ActivitySourceBinding
|
private lateinit var sourceBinding: ActivitySourceBinding
|
||||||
|
|
||||||
private lateinit var mAdapter:SourceAdapter
|
private lateinit var mAdapter: SourceAdapter
|
||||||
private lateinit var viewModel: SourceViewModel
|
private lateinit var viewModel: SourceViewModel
|
||||||
companion object{
|
|
||||||
|
companion object {
|
||||||
val INTENT_KEY_ID = "key_class_id"
|
val INTENT_KEY_ID = "key_class_id"
|
||||||
}
|
}
|
||||||
|
|
||||||
private lateinit var id:String
|
private lateinit var id: String
|
||||||
|
private lateinit var listAds: List<MaxInterstitialAd>
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
listAds = MaxManager.loadAd(this@SourceActivity)
|
||||||
|
|
||||||
sourceBinding = ActivitySourceBinding.inflate(layoutInflater)
|
sourceBinding = ActivitySourceBinding.inflate(layoutInflater)
|
||||||
setContentView(sourceBinding.root)
|
setContentView(sourceBinding.root)
|
||||||
id = intent.getStringExtra(INTENT_KEY_ID)!!
|
id = intent.getStringExtra(INTENT_KEY_ID)!!
|
||||||
viewModel = ViewModelProvider(this)[SourceViewModel::class.java]
|
viewModel = ViewModelProvider(this)[SourceViewModel::class.java]
|
||||||
viewModel.query(id)
|
viewModel.query(id)
|
||||||
mAdapter = SourceAdapter(this@SourceActivity)
|
mAdapter = SourceAdapter(this@SourceActivity)
|
||||||
viewModel.getList().observe(this){
|
viewModel.getList().observe(this) {
|
||||||
mAdapter.updateData(it)
|
mAdapter.updateData(it)
|
||||||
}
|
}
|
||||||
initStatusBar()
|
initStatusBar()
|
||||||
onInitSource()
|
onInitSource()
|
||||||
sourceBinding.iconBack.setOnClickListener {
|
sourceBinding.iconBack.setOnClickListener {
|
||||||
finish()
|
showAd(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private fun onInitSource(){
|
|
||||||
val i = ComUtils.getScreenWidthPx() - ComUtils.dpToPx(110f)*3
|
override fun onBackPressed() {
|
||||||
|
super.onBackPressed()
|
||||||
|
showAd(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun showAd(needFinish: Boolean) {
|
||||||
|
val checkCacheAd = MaxManager.checkCacheAd(listAds)
|
||||||
|
if (checkCacheAd != null) {
|
||||||
|
MaxManager.setMaxListener(checkCacheAd, object : MaxListener {
|
||||||
|
override fun onFail(ad: MaxAd?) {
|
||||||
|
if (needFinish) {
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onSuccess() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onHidden() {
|
||||||
|
if (needFinish) {
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
checkCacheAd.showAd()
|
||||||
|
} else {
|
||||||
|
if (needFinish) {
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun onInitSource() {
|
||||||
|
val i = ComUtils.getScreenWidthPx() - ComUtils.dpToPx(110f) * 3
|
||||||
val spacePx = i / 4
|
val spacePx = i / 4
|
||||||
|
|
||||||
sourceBinding.recyclerViewSource.run {
|
sourceBinding.recyclerViewSource.run {
|
||||||
adapter = mAdapter
|
adapter = mAdapter
|
||||||
layoutManager = GridLayoutManager(this@SourceActivity,3)
|
layoutManager = GridLayoutManager(this@SourceActivity, 3)
|
||||||
addItemDecoration(ItemSpace(spacePx))
|
addItemDecoration(ItemSpace(spacePx))
|
||||||
setPadding(spacePx,ComUtils.dpToPx(6f),0,0)
|
setPadding(spacePx, ComUtils.dpToPx(6f), 0, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private fun initStatusBar(){
|
|
||||||
|
private fun initStatusBar() {
|
||||||
val flags = window.decorView.systemUiVisibility or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
|
val flags = window.decorView.systemUiVisibility or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
|
||||||
window.decorView.systemUiVisibility = flags xor View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
|
window.decorView.systemUiVisibility = flags xor View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
|
||||||
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
|
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
|
||||||
|
|||||||
@ -4,11 +4,12 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:paddingTop="25dp"
|
|
||||||
android:background="@mipmap/home_background"
|
android:background="@mipmap/home_background"
|
||||||
|
android:paddingTop="25dp"
|
||||||
tools:context=".ui.activity.OpenActivity">
|
tools:context=".ui.activity.OpenActivity">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
android:id="@+id/image"
|
||||||
android:layout_width="206dp"
|
android:layout_width="206dp"
|
||||||
android:layout_height="206dp"
|
android:layout_height="206dp"
|
||||||
android:layout_marginTop="220dp"
|
android:layout_marginTop="220dp"
|
||||||
@ -17,4 +18,13 @@
|
|||||||
app:layout_constraintRight_toRightOf="parent"
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
android:indeterminateTint="@color/white"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/image" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@ -2,4 +2,12 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("com.android.application") version "8.1.3" apply false
|
id("com.android.application") version "8.1.3" apply false
|
||||||
id("org.jetbrains.kotlin.android") version "1.9.0" apply false
|
id("org.jetbrains.kotlin.android") version "1.9.0" 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
|
||||||
|
}
|
||||||
|
|
||||||
|
buildscript{
|
||||||
|
dependencies{
|
||||||
|
classpath("com.applovin.quality:AppLovinQualityServiceGradlePlugin:+")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -3,6 +3,7 @@ pluginManagement {
|
|||||||
google()
|
google()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
|
maven{url = uri("https://artifacts.applovin.com/android")}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dependencyResolutionManagement {
|
dependencyResolutionManagement {
|
||||||
@ -10,6 +11,7 @@ dependencyResolutionManagement {
|
|||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
maven ("https://artifact.bytedance.com/repository/pangle")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user