Commit 70319ef7 authored by gaodapeng's avatar gaodapeng

修改了部分逻辑,把replace改成setData,方便多次设置

parent 5f36cec8
......@@ -86,8 +86,10 @@ public class ImageVideoBanner extends FrameLayout implements ImageVideoFragment.
}
public void replaceData(List<com.widget.imagebanner.bean.BannerBean> listBean) {
mAdapter.replaceData(listBean);
public void setData(List<com.widget.imagebanner.bean.BannerBean> listBean) {
if (listBean != null) {
mAdapter.setData(listBean);
}
}
public void addData(List<com.widget.imagebanner.bean.BannerBean> listBean) {
......@@ -207,8 +209,10 @@ public class ImageVideoBanner extends FrameLayout implements ImageVideoFragment.
public void startBanner() {
//如果第一页是视频 不用定时器
if (mList.get(0).getType() == 0) {
startBanner(period);
if (mList.size() > 0) {
if (mList.get(0).getType() == 0) {
startBanner(period);
}
}
}
......@@ -288,24 +292,17 @@ public class ImageVideoBanner extends FrameLayout implements ImageVideoFragment.
return false;
}
public void replaceData(List<BannerBean> listBean) {
public void setData(@NonNull List<BannerBean> listBean) {
// 新数据和原来数据对比,不一致才去刷新
boolean change = compareData(listBean);
if (!change) {
notifyDataSetChanged();
// startBanner();
return;
}
if (null != listBean) {
mList.clear();
addData(listBean);
//如果第一张是图片 需要开启定时器
if (listBean.get(0).getType() == 0) {
startBanner();
}
autoCurrIndex = 0;
// startBanner();
}
mList.clear();
addData(listBean);
notifyDataSetChanged();
autoCurrIndex = 0;
}
......
......@@ -15,18 +15,18 @@
android:supportsRtl="true"
android:theme="@style/AppTheme">
<!--<activity-->
<!--android:name=".MainActivity"-->
<!--android:configChanges="orientation|keyboardHidden|screenSize|keyboard|navigation"-->
<!--android:exported="true"-->
<!--android:launchMode="singleTask"-->
<!--android:screenOrientation="portrait">-->
<!--<intent-filter>-->
<!--<action android:name="android.intent.action.MAIN" />-->
<!--<category android:name="android.intent.category.LAUNCHER" />-->
<!--</intent-filter>-->
<!--</activity>-->
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize|keyboard|navigation"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
......
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