Commit bb1506aa authored by mengcuiguang's avatar mengcuiguang

代码优化

parent 1968e851
......@@ -164,8 +164,6 @@ class MyFragment : BaseFragment(),
myPresenter.userLogin()
}
myPresenter.myRotationChart()
banner_view.startAutoScroll()
// 刷新喜马拉雅信息流
......@@ -218,6 +216,7 @@ class MyFragment : BaseFragment(),
myPresenter.getSignInHomePageMsg()
myPresenter.myHotActivity()
myPresenter.getHallBaseMsg()
myPresenter.myRotationChart()
userConfig = data
handleRecyData()
......@@ -364,12 +363,16 @@ class MyFragment : BaseFragment(),
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)
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)
......
......@@ -64,6 +64,8 @@ public class BannerView extends FrameLayout {
private boolean isAnimScroll;
private boolean isAutoScroll;
private boolean isStopScroll = false;
private View mRootView;
private Handler mHandler = new Handler(Looper.getMainLooper());
private AutoScrollTask mScrollTask;
......@@ -171,12 +173,17 @@ public class BannerView extends FrameLayout {
}
}
// 一直给自己发消息
mHandler.postDelayed(this, mScrollDuration);
if (!isStopScroll) {
mHandler.postDelayed(this, mScrollDuration);
}
}
void start() {
mHandler.removeCallbacks(this);
mHandler.postDelayed(this, mScrollDuration);
if (!isStopScroll) {
mHandler.removeCallbacks(this);
mHandler.postDelayed(this, mScrollDuration);
}
}
void stop() {
......@@ -359,6 +366,11 @@ public class BannerView extends FrameLayout {
}
public void setCurrentIndex(int position) {
mViewPager.setCurrentItem(position);
}
public void setStopScroll(boolean stopScroll) {
isStopScroll = stopScroll;
}
}
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