Commit 1968e851 authored by jyx's avatar jyx

Banner数据为空展示广告

parent ce9c13db
...@@ -32,12 +32,12 @@ object BannerManager { ...@@ -32,12 +32,12 @@ 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 - (20 * density + 0.5f) val pxWidth = displayMetrics.widthPixels - (10 * density + 0.5f)
return pxWidth / density + 0.5f return pxWidth / density + 0.5f
} }
private fun getViewHeight(): Float { private fun getViewHeight(): Float {
var pxHeight = BubbleUtils.dp2px(150) var pxHeight = BubbleUtils.dp2px(120)
return pxHeight.toFloat() return pxHeight.toFloat()
} }
......
...@@ -359,21 +359,25 @@ class MyFragment : BaseFragment(), ...@@ -359,21 +359,25 @@ class MyFragment : BaseFragment(),
*/ */
override fun getMyRotationChartSuc(data: RotationChartBean) { override fun getMyRotationChartSuc(data: RotationChartBean) {
mBannerData = data mBannerData = data
if (data.isShow) {
banner_view.visibility = View.VISIBLE banner_view.visibility = View.VISIBLE
mAdBannerAdapter = AdBannerAdapter(activity) mAdBannerAdapter = AdBannerAdapter(activity)
mAdBannerAdapter?.setOnPageClickListener(this) mAdBannerAdapter?.setOnPageClickListener(this)
mAdBannerAdapter?.let { mAdBannerAdapter?.let {
val list = mBannerData?.list val list = mutableListOf<RotationChartBean.ListBean?>()
list?.add(data.position, null) if (mBannerData?.list != null || mBannerData?.list!!.size == 0) {
list.addAll(it.mDatas)
banner_view.stopAutoScroll()
} else {
banner_view.startAutoScroll()
}
list.add(data.position, null)
it.setData(list) it.setData(list)
it.setAdPosition(data.position) it.setAdPosition(data.position)
} }
banner_view.setAdapter(mAdBannerAdapter) banner_view.setAdapter(mAdBannerAdapter)
} }
}
override fun onRefresh(refreshLayout: RefreshLayout) { override fun onRefresh(refreshLayout: RefreshLayout) {
onDestroyBroadcastReceiver() onDestroyBroadcastReceiver()
......
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