1.ADSWindowManager单例中防止所有视频广告位都无法播放进入播放死循环
2.自定义组件在layout目录缺失xml文件进行补充
This commit is contained in:
@@ -36,8 +36,8 @@ public class ADSWindowManager implements HomeMultiView.MultiViewListener{
|
||||
|
||||
/**是否开启播放模式*/
|
||||
private boolean isPlayMode=false;
|
||||
|
||||
|
||||
//防止所有视频广告位都无法播放 进入startVideo()死循环
|
||||
private boolean hasOncePlayOk;
|
||||
private ADSWindowManager(Context context){
|
||||
this.mContext =context;
|
||||
mHandler=new MyHandler(Looper.getMainLooper());
|
||||
@@ -66,7 +66,7 @@ public class ADSWindowManager implements HomeMultiView.MultiViewListener{
|
||||
for (MultiView multiView:mMultiViewList){
|
||||
multiView.setMultiViewListener(this);
|
||||
}
|
||||
|
||||
if(hasOncePlayOk) hasOncePlayOk=false;
|
||||
}
|
||||
public void startVideo(){
|
||||
isPlayMode =true;
|
||||
@@ -121,19 +121,24 @@ public class ADSWindowManager implements HomeMultiView.MultiViewListener{
|
||||
if(multiView instanceof AdMultiView){
|
||||
LogUtils.loge(" ad playing id:" + adInfo.getId());
|
||||
multiView.onVideoRestart(adInfo.getLocalFilePath());
|
||||
hasOncePlayOk=true;
|
||||
return;
|
||||
}
|
||||
File file = new File(adInfo.getLocalFilePath());
|
||||
if (file.isFile() && file.exists()) {
|
||||
LogUtils.loge(" ad playing id:" + adInfo.getId());
|
||||
multiView.onVideoRestart(adInfo.getLocalFilePath());
|
||||
hasOncePlayOk=true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
LogUtils.loge("error file is not exists:"+adInfo.getLocalFilePath());
|
||||
|
||||
if(mMultiViewList.size()-1==currentADIndex&&!hasOncePlayOk){
|
||||
hasOncePlayOk=false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
currentADIndex++;
|
||||
if (currentADIndex >= mMultiViewList.size()) { //所有文件都不存在,跳出循环,都不播放
|
||||
|
||||
35
app/src/main/res/layout/ad_multi_layout.xml
Normal file
35
app/src/main/res/layout/ad_multi_layout.xml
Normal file
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/layout_rect_group"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:ignore="MissingDefaultResource">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/multi_inside"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
>
|
||||
<ImageView
|
||||
android:id="@+id/img_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerInParent="true"/>
|
||||
<TextView
|
||||
android:id="@+id/tx_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="53dp"
|
||||
android:background="@drawable/item_text_bg"
|
||||
android:textSize="15sp"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingTop="12dp"
|
||||
android:paddingBottom="19dp"
|
||||
android:gravity="left"
|
||||
android:textColor="@color/btn_text_color"/>
|
||||
<RelativeLayout
|
||||
android:id="@+id/ad_root"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
@@ -129,6 +129,7 @@ public class DownLoadTaskThread implements Runnable {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LogUtils.loge("download Exception===>"+e.getMessage());
|
||||
// TODO: 2025/12/17 异常检验-tmp是否存在,不存在再建一个0KB临时空文件可保证 文件以后一定能下载下来
|
||||
if (observer != null) {
|
||||
observer.onError(bean, bean.getTaskId(), e.getMessage());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user