feat(community): 크리에이터 커뮤니티 전체보기에 인라인 배너를 추가한다
This commit is contained in:
@@ -14,6 +14,9 @@ import androidx.activity.result.contract.ActivityResultContracts
|
|||||||
import androidx.recyclerview.widget.GridLayoutManager
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import com.yandex.mobile.ads.banner.BannerAdSize
|
||||||
|
import com.yandex.mobile.ads.common.AdRequest
|
||||||
|
import kr.co.vividnext.sodalive.BuildConfig
|
||||||
import kr.co.vividnext.sodalive.R
|
import kr.co.vividnext.sodalive.R
|
||||||
import kr.co.vividnext.sodalive.base.BaseActivity
|
import kr.co.vividnext.sodalive.base.BaseActivity
|
||||||
import kr.co.vividnext.sodalive.base.SodaDialog
|
import kr.co.vividnext.sodalive.base.SodaDialog
|
||||||
@@ -28,6 +31,7 @@ import kr.co.vividnext.sodalive.explorer.profile.creator_community.all.player.Cr
|
|||||||
import kr.co.vividnext.sodalive.explorer.profile.creator_community.modify.CreatorCommunityModifyActivity
|
import kr.co.vividnext.sodalive.explorer.profile.creator_community.modify.CreatorCommunityModifyActivity
|
||||||
import kr.co.vividnext.sodalive.extensions.dpToPx
|
import kr.co.vividnext.sodalive.extensions.dpToPx
|
||||||
import org.koin.android.ext.android.inject
|
import org.koin.android.ext.android.inject
|
||||||
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
class CreatorCommunityAllActivity : BaseActivity<ActivityCreatorCommunityAllBinding>(
|
class CreatorCommunityAllActivity : BaseActivity<ActivityCreatorCommunityAllBinding>(
|
||||||
ActivityCreatorCommunityAllBinding::inflate
|
ActivityCreatorCommunityAllBinding::inflate
|
||||||
@@ -142,6 +146,7 @@ class CreatorCommunityAllActivity : BaseActivity<ActivityCreatorCommunityAllBind
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
|
binding.yandexInlineBannerView.destroy()
|
||||||
mediaPlayerManager.stopContent()
|
mediaPlayerManager.stopContent()
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
}
|
}
|
||||||
@@ -257,10 +262,32 @@ class CreatorCommunityAllActivity : BaseActivity<ActivityCreatorCommunityAllBind
|
|||||||
)
|
)
|
||||||
|
|
||||||
setupRecyclerViews()
|
setupRecyclerViews()
|
||||||
|
setupInlineBanner()
|
||||||
|
|
||||||
switchToListMode(0, fromGridItemClick = false)
|
switchToListMode(0, fromGridItemClick = false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun setupInlineBanner() {
|
||||||
|
binding.yandexInlineBannerView.post {
|
||||||
|
val density = resources.displayMetrics.density
|
||||||
|
val adWidthPixels = binding.yandexInlineBannerView.width.takeIf { it > 0 } ?: screenWidth
|
||||||
|
val adWidthDp = (adWidthPixels / density).roundToInt()
|
||||||
|
val maxAdHeightDp = 90
|
||||||
|
|
||||||
|
binding.yandexInlineBannerView.apply {
|
||||||
|
setAdUnitId(BuildConfig.YANDEX_INLINE_BANNER_CREATOR_COMMUNITY_ALL_AD_UNIT_ID)
|
||||||
|
setAdSize(
|
||||||
|
BannerAdSize.inlineSize(
|
||||||
|
this@CreatorCommunityAllActivity,
|
||||||
|
adWidthDp,
|
||||||
|
maxAdHeightDp
|
||||||
|
)
|
||||||
|
)
|
||||||
|
loadAd(AdRequest.Builder().build())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressLint("NotifyDataSetChanged")
|
@SuppressLint("NotifyDataSetChanged")
|
||||||
private fun bindData() {
|
private fun bindData() {
|
||||||
viewModel.toastLiveData.observe(this) {
|
viewModel.toastLiveData.observe(this) {
|
||||||
|
|||||||
@@ -80,6 +80,15 @@
|
|||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
android:background="#909090" />
|
android:background="#909090" />
|
||||||
|
|
||||||
|
<com.yandex.mobile.ads.banner.BannerAdView
|
||||||
|
android:id="@+id/yandex_inline_banner_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="13.3dp"
|
||||||
|
android:layout_marginTop="13.3dp"
|
||||||
|
android:layout_marginBottom="13.3dp"
|
||||||
|
android:maxHeight="90dp" />
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
|
|||||||
Reference in New Issue
Block a user