Commit 849b1abd authored by jyx's avatar jyx

Banner展示逻辑修改

parent bb1506aa
...@@ -32,7 +32,7 @@ object BannerManager { ...@@ -32,7 +32,7 @@ object BannerManager {
val displayMetrics = MintsApplication.getContext().resources.displayMetrics val displayMetrics = MintsApplication.getContext().resources.displayMetrics
val density = displayMetrics.density val density = displayMetrics.density
// 屏幕宽度 - margin宽度 // 屏幕宽度 - margin宽度
val pxWidth = displayMetrics.widthPixels - (10 * density + 0.5f) val pxWidth = displayMetrics.widthPixels - (20 * density + 0.5f)
return pxWidth / density + 0.5f return pxWidth / density + 0.5f
} }
...@@ -51,7 +51,7 @@ object BannerManager { ...@@ -51,7 +51,7 @@ object BannerManager {
when (codeId) { when (codeId) {
TtCsjAdManager.TT_AD_BANNER_MY -> { TtCsjAdManager.TT_AD_BANNER_MY -> {
expressViewAcceptedSizeWidth = getViewWidth() expressViewAcceptedSizeWidth = getViewWidth()
expressViewAcceptedSizeHeight = getViewHeight() expressViewAcceptedSizeHeight = 0f
} }
} }
...@@ -64,7 +64,7 @@ object BannerManager { ...@@ -64,7 +64,7 @@ object BannerManager {
.setAdCount(1) //请求广告数量为1到3条 .setAdCount(1) //请求广告数量为1到3条
.setNativeAdType(AdSlot.TYPE_BANNER) .setNativeAdType(AdSlot.TYPE_BANNER)
.setExpressViewAcceptedSize(expressViewAcceptedSizeWidth, expressViewAcceptedSizeHeight) //期望模板广告view的size,单位dp .setExpressViewAcceptedSize(expressViewAcceptedSizeWidth, expressViewAcceptedSizeHeight) //期望模板广告view的size,单位dp
.setImageAcceptedSize(640, 320) //这个参数设置即可,不影响模板广告的size .setImageAcceptedSize(640, 240) //这个参数设置即可,不影响模板广告的size
.build() .build()
it.loadBannerExpressAd(adSlot, object : TTAdNative.NativeExpressAdListener { it.loadBannerExpressAd(adSlot, object : TTAdNative.NativeExpressAdListener {
override fun onNativeExpressAdLoad(ads: MutableList<TTNativeExpressAd>?) { override fun onNativeExpressAdLoad(ads: MutableList<TTNativeExpressAd>?) {
......
...@@ -358,27 +358,23 @@ class MyFragment : BaseFragment(), ...@@ -358,27 +358,23 @@ class MyFragment : BaseFragment(),
*/ */
override fun getMyRotationChartSuc(data: RotationChartBean) { override fun getMyRotationChartSuc(data: RotationChartBean) {
mBannerData = data mBannerData = data
banner_view.visibility = View.VISIBLE
mAdBannerAdapter = AdBannerAdapter(activity)
mAdBannerAdapter?.setOnPageClickListener(this)
mAdBannerAdapter?.let {
val list = mutableListOf<RotationChartBean.ListBean?>()
if (mBannerData?.list == null || mBannerData?.list!!.size == 0) { if (mBannerData?.list == null || mBannerData?.list!!.size == 0) {
list.addAll(it.mDatas) fl_my_banner.visibility = View.VISIBLE
banner_view.setStopScroll(true) banner_view.visibility = View.GONE
banner_view.stopAutoScroll() BannerManager.getTtBanner(TtCsjAdManager.TT_AD_BANNER_MY, fl_my_banner)
} else { } else {
list.addAll(mBannerData!!.list) fl_my_banner.visibility = View.GONE
banner_view.setStopScroll(false) banner_view.visibility = View.VISIBLE
banner_view.startAutoScroll() mAdBannerAdapter = AdBannerAdapter(activity)
}
list.add(data.position, null)
it.setData(list) mAdBannerAdapter?.let {
it.setOnPageClickListener(this)
it.setData(mBannerData?.list)
it.setAdPosition(data.position) it.setAdPosition(data.position)
banner_view.setAdapter(it)
}
} }
banner_view.setAdapter(mAdBannerAdapter)
} }
override fun onRefresh(refreshLayout: RefreshLayout) { override fun onRefresh(refreshLayout: RefreshLayout) {
......
...@@ -36,6 +36,12 @@ ...@@ -36,6 +36,12 @@
<include layout="@layout/item_fragment_main_my_clock" /> <include layout="@layout/item_fragment_main_my_clock" />
<include layout="@layout/item_divider_gray" />
<include layout="@layout/item_fragment_main_my_promotions" />
<include layout="@layout/item_divider_gray" />
<FrameLayout <FrameLayout
android:id="@+id/fl_my_banner" android:id="@+id/fl_my_banner"
android:layout_width="wrap_content" android:layout_width="wrap_content"
...@@ -45,12 +51,6 @@ ...@@ -45,12 +51,6 @@
android:background="@drawable/shape_bg_award" android:background="@drawable/shape_bg_award"
android:visibility="gone" /> android:visibility="gone" />
<include layout="@layout/item_divider_gray" />
<include layout="@layout/item_fragment_main_my_promotions" />
<include layout="@layout/item_divider_gray" />
<com.mints.goodmoney.ui.widgets.BannerView <com.mints.goodmoney.ui.widgets.BannerView
android:id="@+id/banner_view" android:id="@+id/banner_view"
android:layout_width="match_parent" android:layout_width="match_parent"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment