Commit 70319ef7 authored by gaodapeng's avatar gaodapeng

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

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