admin
2021-04-01 c1ab529f3f27020b99db713e785e4a703a054e05
首页与搜索页广告优化
3个文件已修改
85 ■■■■ 已修改文件
BuWanVideo/res/layout/item_recommend_home_type_ad.xml 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BuWanVideo/src/com/weikou/beibeivideo/ui/recommend/SearchResultActivity.java 64 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BuWanVideo/src/com/weikou/beibeivideo/util/ad/ExpressAdManager.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
BuWanVideo/res/layout/item_recommend_home_type_ad.xml
@@ -9,8 +9,10 @@
        android:id="@+id/ll_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingBottom="6dp"
        android:orientation="vertical">
        android:orientation="vertical"
        android:paddingLeft="6dp"
        android:paddingRight="6dp"
        android:paddingBottom="6dp">
        <RelativeLayout
            android:id="@+id/rl_title_item"
@@ -18,11 +20,11 @@
            android:layout_height="wrap_content"
            android:layout_marginLeft="8dp"
            android:layout_marginRight="8dp"
            android:padding="8dp">
            android:padding="8dp"
            android:visibility="gone">
            <ImageView
                android:visibility="gone"
                android:id="@+id/tv_category_icon"
                android:layout_width="20dp"
                android:layout_height="20dp"
@@ -30,7 +32,8 @@
                android:layout_alignParentLeft="true"
                android:layout_centerVertical="true"
                android:layout_marginRight="5dp"
                android:src="@drawable/ic_title_spread" />
                android:src="@drawable/ic_title_spread"
                android:visibility="gone" />
            <TextView
                android:id="@+id/tv_category_name"
@@ -40,7 +43,7 @@
                android:layout_toRightOf="@id/tv_category_icon"
                android:text="推广"
                android:textColor="#DDDDDD"
                android:textSize="@dimen/video_album_title"/>
                android:textSize="@dimen/video_album_title" />
            <TextView
                android:id="@+id/tv_category_name2"
@@ -60,9 +63,9 @@
            android:id="@+id/fl_ad"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/white"
            android:layout_marginLeft="3dp"
            android:layout_marginRight="3dp">
            android:layout_marginRight="3dp"
            android:background="@color/white">
        </FrameLayout>
BuWanVideo/src/com/weikou/beibeivideo/ui/recommend/SearchResultActivity.java
@@ -394,28 +394,27 @@
                });
    }
    private void fillAD(List<ExpressAdContainer> adList) {
        if (adList != null) {
            SearchResultActivity.this.adList.addAll(adList);
        }
    private synchronized void fillAD(List<ExpressAdContainer> adList) {
        if (adList.size() > 0) {
            boolean hasAd = false;
            if (mVideoInfos != null && mVideoInfos.size() > 0)
                for (VideoContent vc : mVideoInfos) {
                    if (vc.getType() == VideoContent.TYPE_AD) {
                        hasAd = true;
                        break;
                    }
        //判断当前页面是否需要广告
        int albumCount = 0;
        if (mVideoInfos != null && mVideoInfos.size() > 0)
            for (int i = 0; i < mVideoInfos.size(); i++) {
                VideoContent vc = mVideoInfos.get(i);
                if (vc.getType() == VideoContent.TYPE_AD) {
                    //更新广告
                    vc.setAd(adList.get(0));
                    adapter.notifyItemChanged(i);
                    return;
                } else if (vc.getVideo().getShowType() == 1) {
                    albumCount++;
                }
            //不存在广告
            if (!hasAd && mVideoInfos.size() > 2) {
                //TODO 测试
                VideoContent videoContent = VideoContent.createAdContent(SearchResultActivity.this.adList.get(0));
                mVideoInfos.add(2, videoContent);
                SearchResultActivity.this.adList.remove(0);
                adapter.notifyDataSetChanged();
            }
        if (albumCount >= 2) {
            VideoContent videoContent = VideoContent.createAdContent(adList.get(0));
            mVideoInfos.add(2, videoContent);
            adapter.notifyItemInserted(2);
        }
    }
@@ -461,7 +460,6 @@
//        SearchResultAdManager.getInstance(getApplicationContext()).autoLoadAd();
//    }
    private List<ExpressAdContainer> adList = new ArrayList<>();
    private void search(String key, String videoType) {
@@ -507,17 +505,23 @@
                            }
                            if (adList.size() > 0) {
                                int adPosition = (int) (videoContentList.size() * Math.random());
                                if (mCurrentPage == 1)
                                    adPosition = 0;
                                videoContentList.add(adPosition, VideoContent.createAdContent(adList.get(0)));
                                adList.remove(0);
                            }
                            //记录当前的广告信息
                            VideoContent adContent = null;
                            int adContentP = -1;
                            if (mCurrentPage <= 1) {
                                for (int i = 0; i < mVideoInfos.size(); i++) {
                                    if (mVideoInfos.get(i).getType() == VideoContent.TYPE_AD) {
                                        adContent = mVideoInfos.get(i);
                                        adContentP = i;
                                    }
                                }
                                mVideoInfos.clear();
                            }
                            mVideoInfos.addAll(videoContentList);
                            if (adContent != null && mVideoInfos.size() >= adContentP) {
                                mVideoInfos.add(adContentP, adContent);
                            }
                            adapter.notifyDataSetChanged();
                            if (mVideoInfos != null && mVideoInfos.size() > 0) {
@@ -530,10 +534,8 @@
                                rl_search_result.setVisibility(View.GONE);
                            }
                            //加载下一次要用的广告
                            if (videoInfos.size() > 0) {
                                if (adList.size() < 1)
                                    loadAd();
                            if (mCurrentPage == 1) {
                                loadAd();
                            }
                        }
                    }
BuWanVideo/src/com/weikou/beibeivideo/util/ad/ExpressAdManager.java
@@ -127,7 +127,7 @@
        //加载大图
        int deviceWidth = DimenUtils.getScreenWidth(mContext);
        deviceWidth = DimenUtils.px2dip(mContext, deviceWidth);
        int width = deviceWidth - 6;
        int width = deviceWidth - 8 * 2;
        int height = (int) (width * 0.8);
        String pid = null;
        if (sourceType == AdUtil.AD_TYPE.csj) {