feat(series-day): 시리즈 요일별 화면에 인라인 배너를 추가한다
This commit is contained in:
@@ -8,6 +8,9 @@ import android.widget.Toast
|
|||||||
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.audio_content.series.detail.SeriesDetailActivity
|
import kr.co.vividnext.sodalive.audio_content.series.detail.SeriesDetailActivity
|
||||||
import kr.co.vividnext.sodalive.base.BaseFragment
|
import kr.co.vividnext.sodalive.base.BaseFragment
|
||||||
import kr.co.vividnext.sodalive.common.Constants
|
import kr.co.vividnext.sodalive.common.Constants
|
||||||
@@ -40,6 +43,7 @@ class SeriesMainDayOfWeekFragment : BaseFragment<FragmentSeriesMainDayOfWeekBind
|
|||||||
loadingDialog = LoadingDialog(requireActivity(), layoutInflater)
|
loadingDialog = LoadingDialog(requireActivity(), layoutInflater)
|
||||||
|
|
||||||
setupDayOfWeekDay()
|
setupDayOfWeekDay()
|
||||||
|
setupInlineBanner()
|
||||||
setupSeriesView()
|
setupSeriesView()
|
||||||
|
|
||||||
val dayOfWeeks = listOf(
|
val dayOfWeeks = listOf(
|
||||||
@@ -59,6 +63,32 @@ class SeriesMainDayOfWeekFragment : BaseFragment<FragmentSeriesMainDayOfWeekBind
|
|||||||
viewModel.dayOfWeek = dayOfWeeks[dayIndex]
|
viewModel.dayOfWeek = dayOfWeeks[dayIndex]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDestroyView() {
|
||||||
|
binding.yandexInlineBannerView.destroy()
|
||||||
|
super.onDestroyView()
|
||||||
|
}
|
||||||
|
|
||||||
|
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_SERIES_MAIN_DAY_OF_WEEK_AD_UNIT_ID)
|
||||||
|
setAdSize(
|
||||||
|
BannerAdSize.inlineSize(
|
||||||
|
requireContext(),
|
||||||
|
adWidthDp,
|
||||||
|
maxAdHeightDp
|
||||||
|
)
|
||||||
|
)
|
||||||
|
loadAd(AdRequest.Builder().build())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun setupDayOfWeekDay() {
|
private fun setupDayOfWeekDay() {
|
||||||
val dayOfWeekAdapter = DayOfWeekAdapter(requireContext()) {
|
val dayOfWeekAdapter = DayOfWeekAdapter(requireContext()) {
|
||||||
adapter.clear()
|
adapter.clear()
|
||||||
|
|||||||
@@ -13,11 +13,20 @@
|
|||||||
android:nestedScrollingEnabled="false"
|
android:nestedScrollingEnabled="false"
|
||||||
android:paddingHorizontal="24dp" />
|
android:paddingHorizontal="24dp" />
|
||||||
|
|
||||||
|
<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="24dp"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:maxHeight="90dp" />
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/rv_series_day_of_week"
|
android:id="@+id/rv_series_day_of_week"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="0dp"
|
||||||
android:layout_marginTop="24dp"
|
android:layout_marginTop="24dp"
|
||||||
|
android:layout_weight="1"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
android:paddingHorizontal="24dp" />
|
android:paddingHorizontal="24dp" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
Reference in New Issue
Block a user