Commit bb1506aa authored by mengcuiguang's avatar mengcuiguang

代码优化

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