콘텐츠 상세 - 배너 광고 추가
This commit is contained in:
@@ -135,5 +135,9 @@
|
||||
android:name="com.google.firebase.messaging.default_notification_channel_id"
|
||||
android:value="@string/default_notification_channel_id" />
|
||||
<!-- [END fcm_default_channel] -->
|
||||
|
||||
<meta-data
|
||||
android:name="com.google.android.gms.ads.APPLICATION_ID"
|
||||
android:value="${ADMOB_APP_ID}" />
|
||||
</application>
|
||||
</manifest>
|
||||
|
@@ -1,10 +1,14 @@
|
||||
package kr.co.vividnext.sodalive.app
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.content.pm.ApplicationInfo
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Build
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import com.google.android.gms.ads.MobileAds
|
||||
import com.google.android.gms.common.ConnectionResult
|
||||
import com.google.android.gms.common.GoogleApiAvailability
|
||||
import com.orhanobut.logger.AndroidLogAdapter
|
||||
import com.orhanobut.logger.Logger
|
||||
import kr.co.vividnext.sodalive.BuildConfig
|
||||
@@ -26,6 +30,12 @@ class SodaLiveApp : Application() {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
|
||||
|
||||
SharedPreferenceManager.init(applicationContext)
|
||||
|
||||
if (isGooglePlayServicesAvailable(this)) {
|
||||
MobileAds.initialize(this) {
|
||||
Logger.e("ADMOB 초기화 - ${it.adapterStatusMap}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun isDebuggable(): Boolean {
|
||||
@@ -47,4 +57,10 @@ class SodaLiveApp : Application() {
|
||||
|
||||
return debuggable
|
||||
}
|
||||
|
||||
private fun isGooglePlayServicesAvailable(context: Context): Boolean {
|
||||
val googleApiAvailability = GoogleApiAvailability.getInstance()
|
||||
val resultCode = googleApiAvailability.isGooglePlayServicesAvailable(context)
|
||||
return resultCode == ConnectionResult.SUCCESS
|
||||
}
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@ import coil.load
|
||||
import coil.transform.CircleCropTransformation
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
import com.google.android.gms.ads.AdRequest
|
||||
import com.google.gson.Gson
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.audio_content.AudioContentPlayService
|
||||
@@ -95,6 +96,7 @@ class AudioContentDetailActivity : BaseActivity<ActivityAudioContentDetailBindin
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
binding.adView.resume()
|
||||
val intentFilter = IntentFilter(Constants.ACTION_AUDIO_CONTENT_RECEIVER)
|
||||
registerReceiver(audioContentReceiver, intentFilter)
|
||||
|
||||
@@ -104,8 +106,14 @@ class AudioContentDetailActivity : BaseActivity<ActivityAudioContentDetailBindin
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
unregisterReceiver(audioContentReceiver)
|
||||
binding.adView.pause()
|
||||
super.onPause()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
binding.adView.destroy()
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
override fun setupView() {
|
||||
@@ -262,6 +270,12 @@ class AudioContentDetailActivity : BaseActivity<ActivityAudioContentDetailBindin
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupAdMob() {
|
||||
val adRequest = AdRequest.Builder().build()
|
||||
binding.adView.visibility = View.VISIBLE
|
||||
binding.adView.loadAd(adRequest)
|
||||
}
|
||||
|
||||
private fun donation(can: Int, message: String) {
|
||||
viewModel.donation(audioContentId, can, message) {
|
||||
viewModel.getAudioContentDetail(audioContentId = audioContentId) { finish() }
|
||||
@@ -390,6 +404,8 @@ class AudioContentDetailActivity : BaseActivity<ActivityAudioContentDetailBindin
|
||||
isAlertPreview = it.creator.creatorId != SharedPreferenceManager.userId &&
|
||||
!it.existOrdered &&
|
||||
it.price > 0
|
||||
|
||||
if ((!it.existOrdered && it.price > 0) || it.price <= 0) setupAdMob()
|
||||
}
|
||||
|
||||
viewModel.isContentPlayLoopLiveData.observe(this) {
|
||||
|
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:ads="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
@@ -168,6 +169,15 @@
|
||||
tools:src="@drawable/btn_player_repeat" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<com.google.android.gms.ads.AdView
|
||||
android:id="@+id/ad_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="13.3dp"
|
||||
android:visibility="gone"
|
||||
ads:adSize="SMART_BANNER"
|
||||
ads:adUnitId="@string/admob_free_content_banner_unit_id" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
Reference in New Issue
Block a user