Commit ce9c13db authored by mengcuiguang's avatar mengcuiguang

代码优化

parent 907cc3f4
...@@ -44,7 +44,7 @@ public abstract class BannerBaseAdapter<T> extends PagerAdapter { ...@@ -44,7 +44,7 @@ public abstract class BannerBaseAdapter<T> extends PagerAdapter {
// return mDatas == null || mDatas.size() == 0 ? 0 : mDatas.size(); // return mDatas == null || mDatas.size() == 0 ? 0 : mDatas.size();
// } // }
public int getCount() { public int getCount() {
return mDatas == null || mDatas.size() == 0 ? 0 :Integer.MAX_VALUE; return mDatas == null || mDatas.size() == 0 ? 0 : Integer.MAX_VALUE;
} }
@Override @Override
...@@ -177,9 +177,15 @@ public abstract class BannerBaseAdapter<T> extends PagerAdapter { ...@@ -177,9 +177,15 @@ public abstract class BannerBaseAdapter<T> extends PagerAdapter {
} }
public void setBannerView(BannerView bannerView) { public void setBannerView(BannerView bannerView) {
this.mBannerView = bannerView; this.mBannerView = bannerView;
} }
public void setIndex() {
mBannerView.setCurrentIndex(0);
}
/** /**
* 条目页面的触摸事件 * 条目页面的触摸事件
*/ */
......
...@@ -34,7 +34,10 @@ import com.mints.goodmoney.mvp.presenters.MyPresenter ...@@ -34,7 +34,10 @@ import com.mints.goodmoney.mvp.presenters.MyPresenter
import com.mints.goodmoney.mvp.views.MyView import com.mints.goodmoney.mvp.views.MyView
import com.mints.goodmoney.service.AppInstallService import com.mints.goodmoney.service.AppInstallService
import com.mints.goodmoney.ui.activitys.* import com.mints.goodmoney.ui.activitys.*
import com.mints.goodmoney.ui.adapter.* import com.mints.goodmoney.ui.adapter.AdBannerAdapter
import com.mints.goodmoney.ui.adapter.GvMyAdapter
import com.mints.goodmoney.ui.adapter.MainMyAdapter
import com.mints.goodmoney.ui.adapter.ViewPagerAdapter
import com.mints.goodmoney.ui.adapter.listener.OnItemChildClickListener import com.mints.goodmoney.ui.adapter.listener.OnItemChildClickListener
import com.mints.goodmoney.ui.fragment.base.BaseFragment import com.mints.goodmoney.ui.fragment.base.BaseFragment
import com.mints.goodmoney.ui.widgets.ShareDialog import com.mints.goodmoney.ui.widgets.ShareDialog
...@@ -127,14 +130,8 @@ class MyFragment : BaseFragment(), ...@@ -127,14 +130,8 @@ class MyFragment : BaseFragment(),
initManager() initManager()
initView() initView()
initRecy() initRecy()
initBanner()
} }
private fun initBanner() {
mAdBannerAdapter = AdBannerAdapter(activity)
mAdBannerAdapter?.setOnPageClickListener(this)
banner_view.setAdapter(mAdBannerAdapter)
}
override fun onHiddenChanged(hidden: Boolean) { override fun onHiddenChanged(hidden: Boolean) {
if (hidden) { // 不在最前端界面显示 if (hidden) { // 不在最前端界面显示
...@@ -147,6 +144,9 @@ class MyFragment : BaseFragment(), ...@@ -147,6 +144,9 @@ class MyFragment : BaseFragment(),
override fun onPause() { override fun onPause() {
super.onPause() super.onPause()
banner_view.stopAutoScroll()
item_clock_signview.stopRedbox() item_clock_signview.stopRedbox()
} }
...@@ -166,9 +166,7 @@ class MyFragment : BaseFragment(), ...@@ -166,9 +166,7 @@ class MyFragment : BaseFragment(),
myPresenter.myRotationChart() myPresenter.myRotationChart()
// 防止banner刷新太快 banner_view.startAutoScroll()
// if (AntiShake.check(fl_my_banner?.id)) return
// BannerManager.getTtBanner(TtCsjAdManager.TT_AD_BANNER_MY, fl_my_banner)
// 刷新喜马拉雅信息流 // 刷新喜马拉雅信息流
TTPreLoadExpressXmlyManager.getInstance().loadTtFrameLayout() TTPreLoadExpressXmlyManager.getInstance().loadTtFrameLayout()
...@@ -360,15 +358,20 @@ class MyFragment : BaseFragment(), ...@@ -360,15 +358,20 @@ class MyFragment : BaseFragment(),
* 设置Banner * 设置Banner
*/ */
override fun getMyRotationChartSuc(data: RotationChartBean) { override fun getMyRotationChartSuc(data: RotationChartBean) {
banner_view.visibility = View.VISIBLE
mBannerData = data mBannerData = data
mAdBannerAdapter?.let { if (data.isShow) {
val list = mBannerData?.list banner_view.visibility = View.VISIBLE
list?.add(data.position, null) mAdBannerAdapter = AdBannerAdapter(activity)
it.setData(list) mAdBannerAdapter?.setOnPageClickListener(this)
it.setAdPosition(data.position) mAdBannerAdapter?.let {
it.notifyDataSetChanged() val list = mBannerData?.list
list?.add(data.position, null)
it.setData(list)
it.setAdPosition(data.position)
}
banner_view.setAdapter(mAdBannerAdapter)
} }
} }
override fun onRefresh(refreshLayout: RefreshLayout) { override fun onRefresh(refreshLayout: RefreshLayout) {
......
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