Commit 849b1abd authored by jyx's avatar jyx

Banner展示逻辑修改

parent bb1506aa
......@@ -32,7 +32,7 @@ object BannerManager {
val displayMetrics = MintsApplication.getContext().resources.displayMetrics
val density = displayMetrics.density
// 屏幕宽度 - margin宽度
val pxWidth = displayMetrics.widthPixels - (10 * density + 0.5f)
val pxWidth = displayMetrics.widthPixels - (20 * density + 0.5f)
return pxWidth / density + 0.5f
}
......@@ -51,7 +51,7 @@ object BannerManager {
when (codeId) {
TtCsjAdManager.TT_AD_BANNER_MY -> {
expressViewAcceptedSizeWidth = getViewWidth()
expressViewAcceptedSizeHeight = getViewHeight()
expressViewAcceptedSizeHeight = 0f
}
}
......@@ -64,7 +64,7 @@ object BannerManager {
.setAdCount(1) //请求广告数量为1到3条
.setNativeAdType(AdSlot.TYPE_BANNER)
.setExpressViewAcceptedSize(expressViewAcceptedSizeWidth, expressViewAcceptedSizeHeight) //期望模板广告view的size,单位dp
.setImageAcceptedSize(640, 320) //这个参数设置即可,不影响模板广告的size
.setImageAcceptedSize(640, 240) //这个参数设置即可,不影响模板广告的size
.build()
it.loadBannerExpressAd(adSlot, object : TTAdNative.NativeExpressAdListener {
override fun onNativeExpressAdLoad(ads: MutableList<TTNativeExpressAd>?) {
......
......@@ -358,27 +358,23 @@ class MyFragment : BaseFragment(),
*/
override fun getMyRotationChartSuc(data: RotationChartBean) {
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) {
list.addAll(it.mDatas)
banner_view.setStopScroll(true)
banner_view.stopAutoScroll()
} else {
list.addAll(mBannerData!!.list)
banner_view.setStopScroll(false)
banner_view.startAutoScroll()
}
list.add(data.position, null)
it.setData(list)
it.setAdPosition(data.position)
if (mBannerData?.list == null || mBannerData?.list!!.size == 0) {
fl_my_banner.visibility = View.VISIBLE
banner_view.visibility = View.GONE
BannerManager.getTtBanner(TtCsjAdManager.TT_AD_BANNER_MY, fl_my_banner)
} else {
fl_my_banner.visibility = View.GONE
banner_view.visibility = View.VISIBLE
mAdBannerAdapter = AdBannerAdapter(activity)
mAdBannerAdapter?.let {
it.setOnPageClickListener(this)
it.setData(mBannerData?.list)
it.setAdPosition(data.position)
banner_view.setAdapter(it)
}
}
banner_view.setAdapter(mAdBannerAdapter)
}
override fun onRefresh(refreshLayout: RefreshLayout) {
......
......@@ -36,6 +36,12 @@
<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
android:id="@+id/fl_my_banner"
android:layout_width="wrap_content"
......@@ -45,12 +51,6 @@
android:background="@drawable/shape_bg_award"
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
android:id="@+id/banner_view"
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