admin
2020-09-10 a62905c725c5ffd88f29dfac644591cde18751e1
广告优化
32个文件已修改
4个文件已添加
1173 ■■■■ 已修改文件
BuWanVideo/AndroidManifest.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BuWanVideo/build.gradle 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BuWanVideo/res/layout/act_login.xml 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BuWanVideo/res/layout/activity_video_player.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BuWanVideo/res/layout/browser_fengxing_activity.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BuWanVideo/res/layout/item_search_result_sugguest.xml 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BuWanVideo/res/layout/item_search_result_top_bar_content.xml 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BuWanVideo/res/layout/item_video_search_result_video.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BuWanVideo/res/layout/search_result_top_bar.xml 70 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BuWanVideo/res/layout/video_episode_fragment.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BuWanVideo/src/com/doudou/ysvideo/wxapi/WXEntryActivity.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BuWanVideo/src/com/weikou/beibeivideo/BeibeiVideoAPI.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BuWanVideo/src/com/weikou/beibeivideo/ui/BaseActivity.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BuWanVideo/src/com/weikou/beibeivideo/ui/SplashActivity.java 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BuWanVideo/src/com/weikou/beibeivideo/ui/ad/VideoDetailVideoAdFragment.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BuWanVideo/src/com/weikou/beibeivideo/ui/login/LoginActivity.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BuWanVideo/src/com/weikou/beibeivideo/ui/main/MainActivity.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BuWanVideo/src/com/weikou/beibeivideo/ui/media/EpisodeFragment.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BuWanVideo/src/com/weikou/beibeivideo/ui/media/VideoDetailActivity.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BuWanVideo/src/com/weikou/beibeivideo/ui/media/VideoDetailFragment.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BuWanVideo/src/com/weikou/beibeivideo/ui/media/VideoEpisodeFragment.java 57 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BuWanVideo/src/com/weikou/beibeivideo/ui/recommend/RecommendFragment.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
BuWanVideo/src/com/weikou/beibeivideo/ui/recommend/SearchActivity.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BuWanVideo/src/com/weikou/beibeivideo/ui/recommend/SearchResultActivity.java 157 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BuWanVideo/src/com/weikou/beibeivideo/ui/video/SearchResultAdapter.java 23 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BuWanVideo/src/com/weikou/beibeivideo/ui/video/SuggestKeysAdapter.java 89 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BuWanVideo/src/com/weikou/beibeivideo/util/BeibeiConstant.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
BuWanVideo/src/com/weikou/beibeivideo/util/ExitDialog.java 109 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BuWanVideo/src/com/weikou/beibeivideo/util/ad/AdUtil.java 74 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BuWanVideo/src/com/weikou/beibeivideo/util/ad/CSJConstant.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BuWanVideo/src/com/weikou/beibeivideo/util/ad/ExpressAdManager.java 69 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BuWanVideo/src/com/weikou/beibeivideo/util/ad/SplashAdUtil.java 25 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BuWanVideo/src/com/weikou/beibeivideo/util/ad/manager/SearchResultAdManager.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
build.gradle 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
library-ViewPagerIndicator/src/com/viewpagerindicator/SearchTabPageIndicator.java 329 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
social_sdk_library_project/build.gradle 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BuWanVideo/AndroidManifest.xml
@@ -237,7 +237,7 @@
            android:value="570f28a578d6e12cba6f7f200b8d1c83"></meta-data>
        <meta-data
            android:name="UMENG_CHANNEL"
            android:value="qq"></meta-data>
            android:value="vivo"></meta-data>
        <provider
@@ -416,7 +416,7 @@
            android:exported="true"
            android:label="@string/app_name"
            android:launchMode="singleTop"
            android:taskAffinity="net.sourceforge.simcpux"
            android:taskAffinity="com.doudou.ysvideo"
            android:theme="@android:style/Theme.Translucent.NoTitleBar" />
        <!-- QQ分享 -->
BuWanVideo/build.gradle
@@ -70,8 +70,8 @@
    }
    defaultConfig {
        applicationId "com.doudou.ysvideo"
        versionCode 94
        versionName "3.7.6"
        versionCode 95
        versionName "3.7.7"
        multiDexEnabled = true
        minSdkVersion 17
        targetSdkVersion 27
BuWanVideo/res/layout/act_login.xml
@@ -59,16 +59,16 @@
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical"
                android:paddingLeft="50dp"
                android:paddingRight="50dp">
                android:orientation="vertical">
                <LinearLayout
                    android:id="@+id/ll_login_content"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal"
                    android:layout_marginLeft="50dp"
                    android:layout_marginTop="120dp"
                    android:layout_marginRight="50dp"
                    android:focusable="true"
                    android:focusableInTouchMode="true"
                    android:orientation="vertical">
@@ -93,14 +93,14 @@
                        <EditText
                            android:id="@+id/et_name"
                            style="@style/loginInputStyle"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="18dp"
                            android:background="@null"
                            android:digits="@string/rule_email"
                            android:hint="请输入账户邮箱"
                            android:inputType="textEmailAddress"
                            style="@style/loginInputStyle" />
                            android:inputType="textEmailAddress" />
                    </LinearLayout>
                    <LinearLayout
@@ -188,6 +188,8 @@
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="50dp"
                    android:layout_marginRight="50dp"
                    android:orientation="vertical"
                    android:paddingBottom="20dp">
BuWanVideo/res/layout/activity_video_player.xml
@@ -51,7 +51,6 @@
                android:layout_marginTop="3dp"
                android:ellipsize="end"
                android:maxLines="1"
                android:text="http://www,baidu.com"
                android:textColor="#DDDDDD"
                android:textSize="8sp"></TextView>
BuWanVideo/res/layout/browser_fengxing_activity.xml
@@ -55,7 +55,6 @@
                android:layout_marginTop="3dp"
                android:ellipsize="end"
                android:maxLines="1"
                android:text="http://www,baidu.com"
                android:textColor="#DDDDDD"
                android:textSize="8sp"></TextView>
BuWanVideo/res/layout/item_search_result_sugguest.xml
New file
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#656565"
    android:orientation="vertical"
    android:paddingLeft="17dp"
    android:paddingRight="17dp">
    <TextView
        android:id="@+id/tv_content"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="12dp"
        android:layout_marginBottom="12dp"
        android:text="那奶奶在哪里"
        android:textColor="#ffdddddd"
        android:textSize="12sp" />
    <View
        android:id="@+id/view_cutline"
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="#505050"></View>
</LinearLayout>
BuWanVideo/res/layout/item_search_result_top_bar_content.xml
New file
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical">
    <TextView
        android:id="@+id/tv_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/vpi__tab_selected_focused_holo"
        android:text="电视剧"
        android:paddingBottom="15dp"
        android:gravity="center"
        android:textColor="@color/white"
        android:textSize="17sp"></TextView>
</LinearLayout>
BuWanVideo/res/layout/item_video_search_result_video.xml
@@ -43,6 +43,17 @@
            android:textSize="15sp" />
        <TextView
            android:id="@+id/tv_tag"
            style="@style/TextGrayNormal"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="2dp"
            android:text="琅琊榜"
            android:textColor="#DCDCDC"
            android:textSize="14sp" />
    </LinearLayout>
</LinearLayout>
BuWanVideo/res/layout/search_result_top_bar.xml
@@ -1,63 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="40dp"
    android:layout_height="wrap_content"
    android:background="@color/theme"
    android:orientation="horizontal"
    android:padding="8dp">
    android:paddingLeft="8dp"
    android:paddingRight="8dp"
    android:paddingBottom="12dp">
    <FrameLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1">
    <HorizontalScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:scrollbars="none">
        <TextView
            android:id="@+id/tv_moive_all"
        <LinearLayout
            android:id="@+id/ll_top_bar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="right|center_vertical"
            android:background="@drawable/ic_select2"
            android:gravity="center"
            android:text="全部"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:textColor="@color/selector_bottom_bar_text" />
    </FrameLayout>
            android:gravity="center_vertical"
            android:orientation="horizontal">
    <FrameLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1">
        <TextView
            android:id="@+id/tv_moive"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:background="@drawable/ic_select1"
            android:gravity="center"
            android:text="正片"
            android:textColor="@color/selector_bottom_bar_text" />
    </FrameLayout>
    <FrameLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1">
        <TextView
            android:id="@+id/tv_moive_special"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="left|center_vertical"
            android:background="@drawable/ic_select1"
            android:gravity="center"
            android:text="专辑"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:textColor="@color/selector_bottom_bar_text" />
    </FrameLayout>
</LinearLayout>
        </LinearLayout>
    </HorizontalScrollView>
</FrameLayout>
BuWanVideo/res/layout/video_episode_fragment.xml
@@ -25,6 +25,7 @@
            <include layout="@layout/video_introduction" />
            <LinearLayout
                android:id="@+id/ll_relative_video"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="4dp"
BuWanVideo/src/com/doudou/ysvideo/wxapi/WXEntryActivity.java
@@ -21,13 +21,14 @@
import com.weikou.beibeivideo.BasicTextHttpResponseHandler;
import com.weikou.beibeivideo.BeibeiVideoAPI;
import com.weikou.beibeivideo.BeibeiVideoApplication;
import com.weikou.beibeivideo.ui.BaseActivity;
import com.weikou.beibeivideo.util.UserUtil;
import org.apache.http.Header;
import org.json.JSONObject;
public class WXEntryActivity extends Activity implements IWXAPIEventHandler {
public class WXEntryActivity extends BaseActivity implements IWXAPIEventHandler {
    private static final int RETURN_MSG_TYPE_LOGIN = 1;
    private static final int RETURN_MSG_TYPE_SHARE = 2;
    private static final int RETURN_MSG_TYPE_XCX = 19;
BuWanVideo/src/com/weikou/beibeivideo/BeibeiVideoAPI.java
@@ -197,11 +197,10 @@
    public static void search(Context context, String uid, String key,
                              String contentType, String page, ResponseHandlerInterface handler) {
        LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
        params.put("Method", "search");
        params.put("Method", "searchNew");
        params.put("Uid", uid);
        params.put("Key", key);
        params.put("Type", "1");
        params.put("ContentType", contentType);
        params.put("Type", contentType);
        params.put("Page", page);
        commonPost(context, BASE_URL + "user", params, handler);
    }
BuWanVideo/src/com/weikou/beibeivideo/ui/BaseActivity.java
@@ -38,6 +38,7 @@
//        if (res.getConfiguration().fontScale != 1) {//非默认值
        Configuration newConfig = new Configuration();
        newConfig.setToDefaults();//设置默认
        newConfig.fontScale=1.2f;
        res.updateConfiguration(newConfig, res.getDisplayMetrics());
//        }
        return res;
BuWanVideo/src/com/weikou/beibeivideo/ui/SplashActivity.java
@@ -57,6 +57,7 @@
import com.weikou.beibeivideo.util.PermissionsActivity;
import com.weikou.beibeivideo.util.PermissionsChecker;
import com.weikou.beibeivideo.util.SDCardUtil;
import com.weikou.beibeivideo.util.ad.AdUtil;
import com.weikou.beibeivideo.util.ad.CSJConstant;
import com.weikou.beibeivideo.util.ad.GDTConstant;
import com.weikou.beibeivideo.util.ad.SplashAdUtil;
@@ -125,7 +126,7 @@
        ad_close_time = findViewById(R.id.ad_close_time);
        iv_logo = findViewById(R.id.iv_logo);
        Glide.with(getApplicationContext()).load(R.drawable.ic_launcher).transform(new GlideRoundTransform(getApplicationContext(),5)).into(iv_logo);
        Glide.with(getApplicationContext()).load(R.drawable.ic_launcher).transform(new GlideRoundTransform(getApplicationContext(), 5)).into(iv_logo);
        SharedPreferences preferences = getSharedPreferences("link_page",
                Context.MODE_PRIVATE);
@@ -259,7 +260,6 @@
                                BeibeiConstant.GDT_DISCOVER_NATIVE = BeibeiConstant.GDT_DOWNLOAD_HINT_ID;
                                BeibeiConstant.GDT_GUESS_LIKE_NATIVE = BeibeiConstant.GDT_DOWNLOAD_HINT_ID;
                                BeibeiConstant.GDT_RECOMMEND_CATEGORY_NATIVE = BeibeiConstant.GDT_DOWNLOAD_HINT_ID;
                                BeibeiConstant.GDT_EXIT_DIALOG = BeibeiConstant.GDT_DOWNLOAD_HINT_ID;
                                BeibeiConstant.GDT_SEARCH_RESULT_MIN_NATIVE = BeibeiConstant.GDT_DOWNLOAD_HINT_ID;
                                BeibeiConstant.GDT_PLAYER_DETAIL = BeibeiConstant.GDT_DOWNLOAD_HINT_ID;
                                BeibeiConstant.GDT_CATEGORY_BANNER = BeibeiConstant.GDT_DOWNLOAD_HINT_ID;
@@ -269,7 +269,6 @@
                                GDTConstant.PID_2_VIDEO_LIST_SMALL_AD_COLUMN3 = BeibeiConstant.GDT_DOWNLOAD_HINT_ID;
                                GDTConstant.PID_2_VIDEO_LIST_SMALL_AD_COLUMN2 = BeibeiConstant.GDT_DOWNLOAD_HINT_ID;
                                GDTConstant.PID_HOME_RECOMMEND_BIG_IMG = BeibeiConstant.GDT_DOWNLOAD_HINT_ID;
                                GDTConstant.PID_VIDEO_DETAIL_PLAYER = BeibeiConstant.GDT_DOWNLOAD_HINT_ID;
                                CSJConstant.RECOMMEND_BIG_IMG_AD = CSJConstant.INVALID_AD;
                            }
@@ -404,7 +403,7 @@
     *
     * @param adType
     */
    private void loadSplashAd(final String adType) {
    private void loadSplashAd(final AdUtil.AD_TYPE adType) {
        SplashAdUtil.loadAD(adType, SplashActivity.this, vg_input, vg_ad, ad_close_time, new SplashAdUtil.SplashAdListener() {
            @Override
            public void close() {
@@ -418,9 +417,9 @@
            @Override
            public void noAd() {//初次加载未加载出广告
                if (AdTypeVO.TYPE_CSJ.equalsIgnoreCase(adType)) {
                if (AdUtil.AD_TYPE.csj==adType) {
                    //再次加载广点通广告
                    SplashAdUtil.loadAD(AdTypeVO.TYPE_GDT, SplashActivity.this, vg_input, vg_ad, ad_close_time, new SplashAdUtil.SplashAdListener() {
                    SplashAdUtil.loadAD(AdUtil.AD_TYPE.gdt, SplashActivity.this, vg_input, vg_ad, ad_close_time, new SplashAdUtil.SplashAdListener() {
                        @Override
                        public void close() {
                            runOnUiThread(new Runnable() {
@@ -442,10 +441,10 @@
                        }
                    });
                } else if (AdTypeVO.TYPE_GDT.equalsIgnoreCase(adType)) {
                } else if (AdUtil.AD_TYPE.gdt==adType) {
                    //再次加载穿山甲广告
                    //再次加载广点通广告
                    SplashAdUtil.loadAD(AdTypeVO.TYPE_CSJ, SplashActivity.this, vg_input, vg_ad, ad_close_time, new SplashAdUtil.SplashAdListener() {
                    SplashAdUtil.loadAD(AdUtil.AD_TYPE.csj, SplashActivity.this, vg_input, vg_ad, ad_close_time, new SplashAdUtil.SplashAdListener() {
                        @Override
                        public void close() {
                            runOnUiThread(new Runnable() {
@@ -499,11 +498,12 @@
                                if (jsonObject.getBoolean("IsPost")) {
                                    JSONObject data = jsonObject.getJSONObject("Data");
                                    JSONObject ad = data.optJSONObject("ad");
                                    String splash = ad.optString("splash");
                                    AdUtil.saveAdConfig(getApplicationContext(), ad);
                                    AdUtil.AD_TYPE splash = AdUtil.getAdType(getApplicationContext(), AdUtil.POSITION_SPLASH);
                                    loadSplashAd(splash);
                                }
                            } else {
                                loadSplashAd(AdTypeVO.TYPE_GDT);
                                loadSplashAd(AdUtil.AD_TYPE.gdt);
                            }
                        }
@@ -515,7 +515,7 @@
                        @Override
                        public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {
                            super.onFailure(statusCode, headers, responseString, throwable);
                            loadSplashAd(AdTypeVO.TYPE_GDT);
                            loadSplashAd(AdUtil.AD_TYPE.gdt);
                        }
                    });
BuWanVideo/src/com/weikou/beibeivideo/ui/ad/VideoDetailVideoAdFragment.java
@@ -27,6 +27,8 @@
import com.qq.e.comm.constants.AdPatternType;
import com.qq.e.comm.util.AdError;
import com.weikou.beibeivideo.R;
import com.weikou.beibeivideo.util.BeibeiConstant;
import com.weikou.beibeivideo.util.ad.AdUtil;
import com.weikou.beibeivideo.util.ad.GDTConstant;
import java.util.ArrayList;
@@ -105,7 +107,11 @@
        if (mAdData != null)
            mAdData.destroy();
        pb_progress.setVisibility(View.VISIBLE);
        NativeUnifiedAD mAdManager = new NativeUnifiedAD(getContext(), GDTConstant.PID_VIDEO_DETAIL_PLAYER, new NativeADUnifiedListener() {
        String pid = GDTConstant.PID_VIDEO_DETAIL_PLAYER;
        if (AdUtil.getAdType(getContext(), AdUtil.POSITION_VIDEO_PLAY_PRE) != AdUtil.AD_TYPE.gdt)
            pid = BeibeiConstant.GDT_DOWNLOAD_HINT_ID;
        NativeUnifiedAD mAdManager = new NativeUnifiedAD(getContext(), pid, new NativeADUnifiedListener() {
            @Override
            public void onNoAD(AdError adError) {//没有广告
@@ -262,7 +268,7 @@
                            Log.d(TAG, "onVideoCacheFailed:" + msg);
                        }
                    });
                }else{
                } else {
                    pb_progress.setVisibility(View.GONE);
                    if (videoAdListener != null) {
                        videoAdListener.finishPlay();
BuWanVideo/src/com/weikou/beibeivideo/ui/login/LoginActivity.java
@@ -219,7 +219,6 @@
        @Override
        public void onComplete(SHARE_MEDIA platform, int action, final Map<String, String> data) {
            dialog.dismiss();
            Toast.makeText(LoginActivity.this, new Gson().toJson(data), Toast.LENGTH_SHORT).show();
            Log.i("mResult", "返回的数据为----" + data);
            BeibeiVideoAPI.userLogin(LoginActivity.this, uid,
                    data.get("name"), data.get("openid"),
@@ -365,7 +364,7 @@
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
//        UMShareAPI.get(this).onActivityResult(requestCode, resultCode, data);
        UMShareAPI.get(this).onActivityResult(requestCode, resultCode, data);
    }
    Handler mHandler = new Handler() {
BuWanVideo/src/com/weikou/beibeivideo/ui/main/MainActivity.java
@@ -639,6 +639,7 @@
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            if (exitDialog != null) {
                exitDialogBuilder.showAd();
                exitDialog.show();
            }
            return true;
BuWanVideo/src/com/weikou/beibeivideo/ui/media/EpisodeFragment.java
@@ -62,6 +62,7 @@
import com.weikou.beibeivideo.util.BeibeiConstant;
import com.weikou.beibeivideo.util.GlideCircleTransform;
import com.weikou.beibeivideo.util.VideoUtil;
import com.weikou.beibeivideo.util.ad.AdUtil;
import com.weikou.beibeivideo.util.ad.ExpressAdManager;
import com.weikou.beibeivideo.R;
@@ -404,6 +405,8 @@
                public void run() {
                    Log.i(TAG, "refresh");
                    rv_episode.setAdapter(episodeAdapter);
                    if (mPlayingPosition > 4)
                        rv_episode.scrollToPosition(mPlayingPosition);
                }
            }, 500);
@@ -412,7 +415,7 @@
    // 加载播放页第一条广告,先设置加载上下文环境和条件
    private void loadAD1() {
        new ExpressAdManager(ExpressAdManager.SOURCE_GDT2, getContext()).loadVideoDetailPlayerBottomAd(new ExpressAdManager.IAdLoadListener() {
        new ExpressAdManager(AdUtil.AD_TYPE.gdt2, getContext()).loadVideoDetailPlayerBottomAd(new ExpressAdManager.IAdLoadListener() {
            @Override
            public void onSuccess(List<ExpressAdContainer> adList) {
                if (adList != null && adList.size() > 0) {
BuWanVideo/src/com/weikou/beibeivideo/ui/media/VideoDetailActivity.java
@@ -169,6 +169,8 @@
        if (getIntent().getSerializableExtra("video_info") != null) {
            videoInfo = (VideoInfo) getIntent().getSerializableExtra(
                    "video_info");
            if(videoInfo!=null)
                videoInfo.setVideoDetailList(null);
            if (getIntent().getBooleanExtra("isFromWatchHistory", false)) {
                Cursor cursor = getContentResolver().query(
                        WatchHistoryTable.CONTENT_URI, null,
@@ -246,6 +248,10 @@
                .findFragmentByTag("VideoDetailFragment");
        if (videoDetailFragment == null) {
            videoDetailFragment = new VideoDetailFragment();
            Bundle bundle=new Bundle();
            bundle.putInt("playing_position",getIntent().getIntExtra("playing_position",0));
            videoDetailFragment.setArguments(bundle);
            fm.beginTransaction()
                    .add(R.id.fragment_video_detail_container,
                            videoDetailFragment, "VideoDetailFragment")
@@ -711,7 +717,7 @@
                                        .getBooleanExtra("isFromWatchHistory",
                                                false);// 是否从观看记录点击过来
                                Log.i("mResult", "是否是从观看记录点击进来的:" + isFromWatchHistory);
                                if (isFromWatchHistory) {
                                if (isFromWatchHistory||position>0) {
                                    mPosition = getIntent().getIntExtra("playing_position", 0);
                                    EventBus.getDefault().post(videoInfo);
                                    getUrl(videoInfo.getVideoDetailList().get(mPosition), isSetup);
BuWanVideo/src/com/weikou/beibeivideo/ui/media/VideoDetailFragment.java
@@ -61,6 +61,8 @@
        View view = inflater.inflate(R.layout.video_detail_fragment, container,
                false);
        this.view = view;
        if (getArguments() != null)
            mPlayingPosition = getArguments().getInt("playing_position", 0);
        return view;
    }
BuWanVideo/src/com/weikou/beibeivideo/ui/media/VideoEpisodeFragment.java
@@ -48,6 +48,7 @@
import com.weikou.beibeivideo.ui.video.IVideoClickListener;
import com.weikou.beibeivideo.ui.video.VideoColumn2Adapter;
import com.weikou.beibeivideo.util.BeibeiConstant;
import com.weikou.beibeivideo.util.ad.AdUtil;
import com.weikou.beibeivideo.util.ad.ExpressAdManager;
import com.weikou.beibeivideo.widget.FullyGridLayoutManager;
import com.weikou.beibeivideo.R;
@@ -82,6 +83,7 @@
    private ImageView video_more_image;
    private LinearLayout video_introduction_more;
    private FrameLayout fl_native_ad_1;
    private LinearLayout ll_relative_video;
    public static boolean isShowMore = false;// 是否显示更多
    public static int page_varietyshow = 0;// 综艺节目的分页
@@ -181,6 +183,9 @@
        fl_native_ad_1 = contentView
                .findViewById(R.id.fl_native_ad_1);
        ll_relative_video = contentView
                .findViewById(R.id.ll_relative_video);
        contentView.findViewById(R.id.ll_container).setFocusable(true);
        contentView.findViewById(R.id.ll_container).setFocusableInTouchMode(true);
@@ -274,30 +279,34 @@
                                    new TypeToken<List<VideoInfo>>() {
                                    }.getType());
                            final VideoColumn2Adapter adapter = new VideoColumn2Adapter(getActivity(), getContext(), videoInfos, false, 2, new IVideoClickListener() {
                                @Override
                                public void onClick(VideoInfo video) {
                                    ChangeVideoEvent changeVideoEvent = new ChangeVideoEvent();
                                    changeVideoEvent.setVideoInfo(video);
                                    changeVideoEvent.setTag("VideoPlayerFragment");
                                    EventBus.getDefault().post(changeVideoEvent);
                                }
                            });
                            adapter.initRecyclerViewDisplayWidthColumn2(rv_video_related_video);
                            if (getActivity() == null)
                                return;
                            getActivity().runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    if (rv_video_related_video != null) {
                                        rv_video_related_video.setAdapter(adapter);
                            if (videoInfos == null || videoInfos.size() == 0) {
                                ll_relative_video.setVisibility(View.GONE);
                            } else {
                                ll_relative_video.setVisibility(View.VISIBLE);
                                final VideoColumn2Adapter adapter = new VideoColumn2Adapter(getActivity(), getContext(), videoInfos, false, 2, new IVideoClickListener() {
                                    @Override
                                    public void onClick(VideoInfo video) {
                                        ChangeVideoEvent changeVideoEvent = new ChangeVideoEvent();
                                        changeVideoEvent.setVideoInfo(video);
                                        changeVideoEvent.setTag("VideoPlayerFragment");
                                        EventBus.getDefault().post(changeVideoEvent);
                                    }
                                    if (adRunnable != null)
                                        rv_video_related_video.post(adRunnable);
                                }
                            });
                                });
                                adapter.initRecyclerViewDisplayWidthColumn2(rv_video_related_video);
                                if (getActivity() == null)
                                    return;
                                getActivity().runOnUiThread(new Runnable() {
                                    @Override
                                    public void run() {
                                        if (rv_video_related_video != null) {
                                            rv_video_related_video.setAdapter(adapter);
                                        }
                                        if (adRunnable != null)
                                            rv_video_related_video.post(adRunnable);
                                    }
                                });
                            }
                        }
                    }
                });
@@ -455,7 +464,7 @@
     */
    // 加载播放页第二条广告
    private void loadAD2() {
        new ExpressAdManager(ExpressAdManager.SOURCE_GDT2, getContext()).loadVideoDetailRelativeVideoBottomAd(new ExpressAdManager.IAdLoadListener() {
        new ExpressAdManager(AdUtil.AD_TYPE.gdt2, getContext()).loadVideoDetailRelativeVideoBottomAd(new ExpressAdManager.IAdLoadListener() {
            @Override
            public void onSuccess(List<ExpressAdContainer> adList) {
                if (adList != null && adList.size() > 0)
BuWanVideo/src/com/weikou/beibeivideo/ui/recommend/RecommendFragment.java
@@ -313,7 +313,7 @@
    private void loadAd() {
        try {
            ExpressAdManager recommendAdManager = new ExpressAdManager(ExpressAdManager.SOURCE_CSJ, context);
            ExpressAdManager recommendAdManager = new ExpressAdManager(AdUtil.AD_TYPE.csj, context);
            recommendAdManager.loadRecommendLargeAd(new ExpressAdManager.IAdLoadListener() {
                @Override
                public void onSuccess(final List<ExpressAdContainer> adList) {
BuWanVideo/src/com/weikou/beibeivideo/ui/recommend/SearchActivity.java
@@ -42,6 +42,7 @@
import com.weikou.beibeivideo.BasicTextHttpResponseHandler;
import com.weikou.beibeivideo.BeibeiVideoAPI;
import com.weikou.beibeivideo.ui.BaseActivity;
import com.weikou.beibeivideo.ui.video.SuggestKeysAdapter;
import com.weikou.beibeivideo.util.BeibeiConstant;
import com.weikou.beibeivideo.R;
@@ -290,10 +291,8 @@
                                    .getJSONObject("Data").getJSONArray("data")
                                    .toString(), new TypeToken<List<String>>() {
                            }.getType());
                            ArrayAdapter<String> adapter = new ArrayAdapter<String>(
                                    SearchActivity.this,
                                    android.R.layout.simple_list_item_1,
                                    results);
                            SuggestKeysAdapter adapter = new SuggestKeysAdapter(getApplicationContext(), results);
                            et_search_key.setAdapter(adapter);
                            adapter.notifyDataSetChanged();
                        }
BuWanVideo/src/com/weikou/beibeivideo/ui/recommend/SearchResultActivity.java
@@ -3,6 +3,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
@@ -24,7 +25,11 @@
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.BaseAdapter;
import android.widget.Filter;
import android.widget.Filterable;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.ProgressBar;
import android.widget.TextView;
@@ -40,10 +45,12 @@
import com.weikou.beibeivideo.BasicTextHttpResponseHandler;
import com.weikou.beibeivideo.BeibeiVideoAPI;
import com.weikou.beibeivideo.entity.VideoInfo;
import com.weikou.beibeivideo.entity.VideoType;
import com.weikou.beibeivideo.entity.ad.ExpressAdContainer;
import com.weikou.beibeivideo.entity.video.VideoContent;
import com.weikou.beibeivideo.ui.BaseActivity;
import com.weikou.beibeivideo.ui.video.SearchResultAdapter;
import com.weikou.beibeivideo.ui.video.SuggestKeysAdapter;
import com.weikou.beibeivideo.ui.video.VideoCloumn1Adapter;
import com.weikou.beibeivideo.util.DimenUtils;
import com.weikou.beibeivideo.util.ad.ExpressAdManager;
@@ -87,6 +94,10 @@
    private View loading;
    private LinearLayout ll_top_bar;
    List<VideoType> typeList;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
@@ -113,9 +124,8 @@
        et_search_key = findViewById(R.id.et_search_key);
        tv_search_cancel = findViewById(R.id.tv_search_cancel);
        rv_video_search = findViewById(R.id.rv_video_search);
        findViewById(R.id.tv_moive_all).setOnClickListener(this);
        findViewById(R.id.tv_moive).setOnClickListener(this);
        findViewById(R.id.tv_moive_special).setOnClickListener(this);
        ll_top_bar = findViewById(R.id.ll_top_bar);
        tv_search_cancel.setOnClickListener(this);
        et_search_key.addTextChangedListener(new TextWatcher() {
@@ -157,6 +167,8 @@
                mCurrentKey = parent.getItemAtPosition(position).toString();
                SoftKeyboardUtils.hideSoftInput(SearchResultActivity.this);
                mCurrentPage = 1;
                //清除顶部分类
                typeList = null;
                search(mCurrentKey, mCurrentType);
            }
        });
@@ -199,6 +211,8 @@
                    SoftKeyboardUtils.hideSoftInput(SearchResultActivity.this);
                    mCurrentPage = 1;
                    rl_search_result.setRefreshing(true);
                    //清除顶部分类
                    typeList = null;
                    search(mCurrentKey, mCurrentType);
                    return true;
                }
@@ -222,7 +236,7 @@
        });
        rv_video_search.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
        rv_video_search.setLayoutManager(new MyLinearLayoutManager(getApplicationContext()));
        DividerItemDecoration decoration = new DividerItemDecoration();
        decoration.setSize(DimenUtils.dip2px(rv_video_search.getContext(), 6));
        rv_video_search.addItemDecoration(decoration);
@@ -244,10 +258,12 @@
                int total = manager.getItemCount();
                if (newState == RecyclerView.SCROLL_STATE_IDLE) {
                    if ((!isLoad) && last == total - 1 && mVideoInfos.size() < 1000) {
                        mCurrentPage++;
                        isLoad = true;
                        loading.setVisibility(View.VISIBLE);
                        search(mCurrentKey, mCurrentType);
                        if (mVideoInfos != null && mVideoInfos.size() > 0 && !rl_search_result.isRefreshing()) {//列表中有数据才能加载更多
                            mCurrentPage++;
                            isLoad = true;
                            loading.setVisibility(View.VISIBLE);
                            search(mCurrentKey, mCurrentType);
                        }
                    }
                }
            }
@@ -262,6 +278,59 @@
        rl_search_result.setRefreshing(true);
        search(mCurrentKey, mCurrentType);
//        loadAd();
    }
    private void initTopBar(List<VideoType> videoTypeList) {
        int p = 0;
        ll_top_bar.removeAllViews();
        LayoutInflater inflater = LayoutInflater.from(getApplicationContext());
        for (int i = 0; i < videoTypeList.size(); i++) {
            final View view = inflater.inflate(R.layout.item_search_result_top_bar_content, null);
            TextView tv_name = view.findViewById(R.id.tv_name);
            tv_name.setText(videoTypeList.get(i).getName());
            setTopBarSelect(tv_name, i == p);
            ll_top_bar.addView(view);
            ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
            params.rightMargin = DimenUtils.dip2px(getApplicationContext(), 17);
            params.leftMargin = DimenUtils.dip2px(getApplicationContext(), 10);
            view.setTag(i);
            view.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    int p = Integer.parseInt(view.getTag() + "");
                    selectTopBar(p);
                    VideoType vt = videoTypeList.get(p);
                    if (StringUtils.isBlank(mCurrentType) || !mCurrentType.equalsIgnoreCase(vt.getId())) {
                        mCurrentPage = 1;
                        mCurrentType = vt.getId();
                        rl_search_result.setRefreshing(true);
                        search(mCurrentKey, mCurrentType);
                    }
                }
            });
        }
    }
    private void setTopBarSelect(TextView tv_name, boolean selected) {
        if (selected) {
            tv_name.setBackgroundResource(R.drawable.vpi__tab_selected_focused_holo);
            tv_name.setTextSize(17);
            tv_name.setTextColor(Color.parseColor("#FFFFFF"));
            tv_name.setPadding(0, 0, 0, DimenUtils.dip2px(getApplicationContext(), 5));
        } else {
            tv_name.setBackground(null);
            tv_name.setTextSize(12);
            tv_name.setTextColor(Color.parseColor("#999999"));
            tv_name.setPadding(0, 0, 0, 0);
        }
    }
    private void selectTopBar(int p) {
        for (int i = 0; i < ll_top_bar.getChildCount(); i++) {
            TextView tv = ll_top_bar.getChildAt(i).findViewById(R.id.tv_name);
            setTopBarSelect(tv, i == p);
        }
    }
    private void suggestSearch(String key) {
@@ -283,10 +352,7 @@
                                    .getJSONObject("Data").getJSONArray("data")
                                    .toString(), new TypeToken<List<String>>() {
                            }.getType());
                            ArrayAdapter<String> adapter = new ArrayAdapter<String>(
                                    SearchResultActivity.this,
                                    android.R.layout.simple_list_item_1,
                                    results);
                            SuggestKeysAdapter adapter = new SuggestKeysAdapter(getApplicationContext(), results);
                            et_search_key.setAdapter(adapter);
                            adapter.notifyDataSetChanged();
                        }
@@ -354,11 +420,24 @@
                            Gson gson = new GsonBuilder().setFieldNamingPolicy(
                                    FieldNamingPolicy.UPPER_CAMEL_CASE)
                                    .create();
                            JSONObject rootData = jsonObject.getJSONObject("Data");
                            List<VideoInfo> videoInfos = gson.fromJson(
                                    jsonObject.getJSONObject("Data")
                                            .getJSONArray("data").toString(),
                                    rootData.getJSONArray("data").toString(),
                                    new TypeToken<List<VideoInfo>>() {
                                    }.getType());
                            //设置导航栏
                            if (rootData.opt("typeList") != null) {
                                if (typeList == null) {
                                    typeList = gson.fromJson(
                                            rootData
                                                    .getJSONArray("typeList").toString(),
                                            new TypeToken<List<VideoType>>() {
                                            }.getType());
                                    initTopBar(typeList);
                                }
                            }
                            List<VideoContent> videoContentList = new ArrayList<>();
                            for (VideoInfo video : videoInfos) {
@@ -373,8 +452,9 @@
                                videoContentList.add(adPosition, VideoContent.createAdContent(adList.get(0)));
                                adList.remove(0);
                            }
                            if (mCurrentPage <= 1)
                            if (mCurrentPage <= 1) {
                                mVideoInfos.clear();
                            }
                            mVideoInfos.addAll(videoContentList);
                            adapter.notifyDataSetChanged();
@@ -419,36 +499,6 @@
            case R.id.tv_top_bar_left:
                finish();
                break;
            case R.id.tv_moive_all:
                rl_search_result.setRefreshing(true);
                mVideoInfos.clear();
                mCurrentPage = 1;
                mCurrentType = "0";
                findViewById(R.id.tv_moive_all).setBackgroundResource(R.drawable.ic_select2);
                findViewById(R.id.tv_moive).setBackgroundResource(R.drawable.ic_select1);
                findViewById(R.id.tv_moive_special).setBackgroundResource(R.drawable.ic_select1);
                search(mCurrentKey, mCurrentType);
                break;
            case R.id.tv_moive:
                mVideoInfos.clear();
                rl_search_result.setRefreshing(true);
                mCurrentPage = 1;
                mCurrentType = "1";
                findViewById(R.id.tv_moive_all).setBackgroundResource(R.drawable.ic_select1);
                findViewById(R.id.tv_moive).setBackgroundResource(R.drawable.ic_select2);
                findViewById(R.id.tv_moive_special).setBackgroundResource(R.drawable.ic_select1);
                search(mCurrentKey, mCurrentType);
                break;
            case R.id.tv_moive_special:
                mVideoInfos.clear();
                rl_search_result.setRefreshing(true);
                mCurrentPage = 1;
                mCurrentType = "2";
                findViewById(R.id.tv_moive_all).setBackgroundResource(R.drawable.ic_select1);
                findViewById(R.id.tv_moive).setBackgroundResource(R.drawable.ic_select1);
                findViewById(R.id.tv_moive_special).setBackgroundResource(R.drawable.ic_select2);
                search(mCurrentKey, mCurrentType);
                break;
            default:
                break;
        }
@@ -479,4 +529,21 @@
                .putString("history",
                        builder.substring(0, builder.length() - 1)).commit();
    }
    class MyLinearLayoutManager extends LinearLayoutManager {
        public MyLinearLayoutManager(Context context) {
            super(context);
        }
        @Override
        public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
            try {
                super.onLayoutChildren(recycler, state);
            } catch (IndexOutOfBoundsException e) {
                e.printStackTrace();
            }
        }
    }
}
BuWanVideo/src/com/weikou/beibeivideo/ui/video/SearchResultAdapter.java
@@ -2,6 +2,7 @@
import android.app.Activity;
import android.content.Intent;
import android.net.http.DelegatingSSLSession;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
@@ -13,6 +14,7 @@
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.lcjian.library.util.common.StringUtils;
import com.weikou.beibeivideo.entity.VideoDetailInfo;
import com.weikou.beibeivideo.entity.VideoInfo;
import com.weikou.beibeivideo.entity.ad.ExpressAdContainer;
@@ -95,12 +97,16 @@
            final VideoInfo info = videoContent.getVideo();
            final AlbumVideoHolder albumVideoHolder = (AlbumVideoHolder) holder;
            try {
                Glide.with(mContext).load(info.getPicture()).transition(withCrossFade()).placeholder(R.color.black).into(albumVideoHolder.iv_picture);
                String pic=info.getVpicture();
                if(StringUtils.isBlank(pic))
                    pic=info.getPicture();
                Glide.with(mContext).load(pic).transition(withCrossFade()).placeholder(R.color.black).into(albumVideoHolder.iv_picture);
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            }
            albumVideoHolder.tv_name.setText(info.getName() + "");
            albumVideoHolder.tv_type.setText(info.getYear() + "/" + info.getArea());
            albumVideoHolder.tv_type.setText(info.getTag());
            albumVideoHolder.tv_actors.setText(info.getMainActor());
@@ -173,7 +179,7 @@
                    @Override
                    public void onClick(View v) {
                        if (albumVideoHolder.tv_video_4.getVisibility() == View.VISIBLE) {
                            myClick(info, v, videoDetailInfos.size() - 2);
                            myClick(info, v,  Integer.parseInt(videoDetailInfos.get(3).getTag()));
                        }
                    }
                });
@@ -182,7 +188,7 @@
                    @Override
                    public void onClick(View v) {
                        if (albumVideoHolder.tv_video_5.getVisibility() == View.VISIBLE) {
                            myClick(info, v, videoDetailInfos.size() - 1);
                            myClick(info, v,  Integer.parseInt(videoDetailInfos.get(4).getTag()));
                        }
                    }
                });
@@ -198,6 +204,12 @@
                e.printStackTrace();
            }
            simpleVideoHolder.tv_movie_title.setText(info.getName() + "");
            if (!StringUtils.isBlank(info.getTag()))
                simpleVideoHolder.tv_tag.setText(info.getTag());
            else
                simpleVideoHolder.tv_tag.setText("");
            simpleVideoHolder.view.setOnClickListener(new View.OnClickListener() {
                @Override
@@ -323,7 +335,7 @@
    class SimpleVideoHolder extends RecyclerView.ViewHolder {
        ImageView iv_movie_cover;
        TextView tv_movie_title;
        TextView tv_movie_title, tv_tag;
        View view;
        public SimpleVideoHolder(View view) {
@@ -331,6 +343,7 @@
            this.view = view;
            iv_movie_cover = view.findViewById(R.id.iv_movie_cover);
            tv_movie_title = view.findViewById(R.id.tv_movie_title);
            tv_tag = view.findViewById(R.id.tv_tag);
        }
    }
BuWanVideo/src/com/weikou/beibeivideo/ui/video/SuggestKeysAdapter.java
New file
@@ -0,0 +1,89 @@
package com.weikou.beibeivideo.ui.video;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Filter;
import android.widget.Filterable;
import android.widget.TextView;
import com.weikou.beibeivideo.R;
import java.util.List;
public class SuggestKeysAdapter extends BaseAdapter implements Filterable {
    private ArrayFilter mFilter;
    private List<String> keys;
    private LayoutInflater layoutInflater;
    public SuggestKeysAdapter(Context context, List<String> keys) {
        this.keys = keys;
        layoutInflater = LayoutInflater.from(context);
    }
    @Override
    public int getCount() {
        return keys.size();
    }
    @Override
    public Object getItem(int position) {
        return keys.get(position);
    }
    @Override
    public long getItemId(int position) {
        return position;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = layoutInflater.inflate(R.layout.item_search_result_sugguest, null);
        TextView tv_content = view.findViewById(R.id.tv_content);
        View view_cutLine = view.findViewById(R.id.view_cutline);
        tv_content.setText(keys.get(position));
        if (position == keys.size() - 1) {
            view_cutLine.setVisibility(View.GONE);
        } else {
            view_cutLine.setVisibility(View.VISIBLE);
        }
        return view;
    }
    @Override
    public Filter getFilter() {
        if (mFilter == null) {
            mFilter = new ArrayFilter();
        }
        return mFilter;
    }
    private class ArrayFilter extends Filter {
        @Override
        protected FilterResults performFiltering(CharSequence prefix) {
            FilterResults results = new FilterResults();
            results.values = keys;
            results.count = keys.size();
            return results;
        }
        @Override
        protected void publishResults(CharSequence constraint,
                                      FilterResults results) {
            if (keys.size() > 0) {
                notifyDataSetChanged();
            } else {
                notifyDataSetInvalidated();
            }
        }
    }
}
BuWanVideo/src/com/weikou/beibeivideo/util/BeibeiConstant.java
@@ -4,7 +4,7 @@
public class BeibeiConstant {
    public final static boolean IS_TEST=false;
    public final static boolean IS_TEST = false;
    //首页推荐第一个广告
    public final static boolean AD_SETTING_RECOMMEND_FIRST = true;
@@ -79,6 +79,8 @@
    public static String GDT_SPLASH_POSITION_ID_HUAWEI = "5040607358287251";
    // 广点通 用于开屏广告_华为专用2
    public static String GDT_SPLASH_POSITION_ID_HUAWEI2 = "3050653675121935";
    //广点通VIVO开屏
    public static String GDT_SPLASH_VIVO_POSITION_ID = "3061221866743243";
    // 广点通 原生首页推荐一屏
    public static String GDT_RECOMMAND_MIN_NATIVE = "2020450766955933";
BuWanVideo/src/com/weikou/beibeivideo/util/ExitDialog.java
@@ -16,6 +16,11 @@
import com.qq.e.ads.nativ.NativeExpressADView;
import com.qq.e.comm.util.AdError;
import com.weikou.beibeivideo.R;
import com.weikou.beibeivideo.entity.ad.AdTypeVO;
import com.weikou.beibeivideo.entity.ad.ExpressAdContainer;
import com.weikou.beibeivideo.util.ad.AdUtil;
import com.weikou.beibeivideo.util.ad.ExpressAdManager;
import com.weikou.beibeivideo.util.ad.ExpressAdManager.IAdEventListener;
import java.util.List;
@@ -34,15 +39,18 @@
        this.setCancelable(false);
    }
    public static class Builder {
        private Activity context;
        private String positiveButtonText;
        private String negativeButtonText;
        private OnClickListener positiveButtonClickListener;
        private OnClickListener negativeButtonClickListener;
        ExpressAdManager expressAdManager;
        public Builder(Activity context) {
            this.context = context;
            expressAdManager = new ExpressAdManager(AdUtil.getAdType(context, AdUtil.POSITION_EXIT_APP), context);
        }
@@ -87,6 +95,8 @@
         */
        private FrameLayout fl_advertisement;
        private ExpressAdContainer expressAdContainer;
        public ExitDialog create() {
            LayoutInflater inflater = (LayoutInflater) context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
@@ -94,7 +104,7 @@
            final ExitDialog dialog = new ExitDialog(context, R.style.Dialog);
            View layout = inflater.inflate(R.layout.item_exit, null);
            fl_advertisement = layout.findViewById(R.id.fl_advertisement);
            nativeAd();
            loadAd();
            dialog.addContentView(layout, new FrameLayout.LayoutParams(
                    FrameLayout.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT));
            // set the confirm button
@@ -127,82 +137,47 @@
        private NativeExpressAD nativeExpressAD;
        // 1.加载广告,先设置加载上下文环境和条件
        private void nativeAd() {
            fl_advertisement.removeAllViews();
            nativeExpressAD = new NativeExpressAD(context, new ADSize(ADSize.FULL_WIDTH, ADSize.AUTO_HEIGHT),
                    BeibeiConstant.GDT_EXIT_DIALOG, new NativeExpressAD.NativeExpressADListener() {
        private void loadAd() {
            expressAdManager.loadAppExitAd(new ExpressAdManager.IAdLoadListener() {
                @Override
                public void onADLoaded(final List<NativeExpressADView> list) {
                    fl_advertisement.post(new Runnable() {
                        @Override
                        public void run() {
                            if (null != list && list.size() > 0) {
                                NativeExpressADView adView = list.get(0);
                                adView.render();
                                FrameLayout parent = (FrameLayout) adView.getParent();
                                if (parent != null) {
                                    parent.removeAllViews();
                                }
                                fl_advertisement.addView(adView);
                public void onSuccess(List<ExpressAdContainer> adList) {
                    if (adList != null && adList.size() > 0) {
                        ExpressAdManager.renderAd(context, adList.get(0), new ExpressAdManager.IAdRenderListener() {
                            @Override
                            public void onRenderSuccess(List<ExpressAdContainer> adList) {
                                expressAdContainer = adList.get(0);
                            }
                        }
                    });
                            @Override
                            public void onRenderFail(List<ExpressAdContainer> adList) {
                            }
                        }, null);
                    }
                }
            });
                @Override
                public void onRenderFail(NativeExpressADView nativeExpressADView) {
        }
                }
        public void showAd() {
            if (expressAdContainer != null) {
                ExpressAdManager.bindCloseListener(context,expressAdContainer,new IAdEventListener(){
                @Override
                public void onRenderSuccess(NativeExpressADView nativeExpressADView) {
                }
                @Override
                public void onADExposure(NativeExpressADView nativeExpressADView) {
                }
                @Override
                public void onADClicked(NativeExpressADView nativeExpressADView) {
                }
                @Override
                public void onADClosed(NativeExpressADView nativeExpressADView) {
                }
                @Override
                public void onADLeftApplication(NativeExpressADView nativeExpressADView) {
                }
                @Override
                public void onADOpenOverlay(NativeExpressADView nativeExpressADView) {
                }
                @Override
                public void onADCloseOverlay(NativeExpressADView nativeExpressADView) {
                }
                @Override
                public void onNoAD(AdError adError) {
                }
            }); // 传入Activity
            // 注意:如果您在联盟平台上新建原生模板广告位时,选择了支持视频,那么可以进行个性化设置(可选)
            nativeExpressAD.setVideoOption(new VideoOption.Builder()
                    .setAutoPlayPolicy(VideoOption.AutoPlayPolicy.WIFI) // WIFI 环境下可以自动播放视频
                    .setAutoPlayMuted(true) // 自动播放时为静音
                    .build()); //
            nativeExpressAD.loadAD(2);
                    @Override
                    public void closeAd(ExpressAdContainer ad) {
                        fl_advertisement.removeAllViews();
                    }
                });
                ExpressAdManager.fillAd(expressAdContainer, fl_advertisement);
            }
        }
        public void refreshAd() {
            nativeAd();
            loadAd();
        }
    }
BuWanVideo/src/com/weikou/beibeivideo/util/ad/AdUtil.java
@@ -1,26 +1,86 @@
package com.weikou.beibeivideo.util.ad;
import android.content.Context;
import android.content.SharedPreferences;
import com.weikou.beibeivideo.entity.ad.AdTypeVO;
import com.weikou.beibeivideo.util.BeibeiConstant;
import com.weikou.beibeivideo.util.downutil.StringUtils;
//穿山甲广告
import org.json.JSONException;
import org.json.JSONObject;
//广告帮助
public class AdUtil {
    public enum AD_TYPE {
        gdt("广点通"), csj("穿山甲"), gdt2("广点通2.0");
    public static int getSmallExpressAdType() {
        private String name;
        private AD_TYPE(String name) {
            this.name = name;
        }
    }
    public final static String POSITION_SPLASH = "splash";//开屏
    public final static String POSITION_VIDEO_PLAY_PRE = "videoPlayPre";//视频播放前贴
    public final static String POSITION_EXIT_APP = "exitApp";//APP退出广告
    public static AD_TYPE getSmallExpressAdType() {
        if (BeibeiConstant.AD_TYPE != null && AdTypeVO.TYPE_CSJ.equalsIgnoreCase(BeibeiConstant.AD_TYPE.getExpressSmallType())) {
            return ExpressAdManager.SOURCE_CSJ;
            return AD_TYPE.csj;
        } else {
            return ExpressAdManager.SOURCE_GDT;
            return AD_TYPE.gdt;
        }
    }
    public static int getBigExpressAdType() {
    public static AD_TYPE getBigExpressAdType() {
        if (BeibeiConstant.AD_TYPE != null && AdTypeVO.TYPE_CSJ.equalsIgnoreCase(BeibeiConstant.AD_TYPE.getExpressBigType())) {
            return ExpressAdManager.SOURCE_CSJ;
            return AD_TYPE.csj;
        } else {
            return ExpressAdManager.SOURCE_GDT2;
            return AD_TYPE.gdt2;
        }
    }
    /**
     * 保存广告配置
     *
     * @param context
     * @param json
     */
    public static void saveAdConfig(Context context, JSONObject json) {
        SharedPreferences share = context.getSharedPreferences("adConfig", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = share.edit();
        editor.putString("config", json.toString());
        editor.commit();
    }
    /**
     * 获取广告类型
     *
     * @param context
     * @param positionName
     * @return
     */
    public static AD_TYPE getAdType(Context context, String positionName) {
        SharedPreferences share = context.getSharedPreferences("adConfig", Context.MODE_PRIVATE);
        String config = share.getString("config", "");
        if (!StringUtils.isNullOrEmpty(config)) {//万一没设置起就用广点通
            try {
                JSONObject object = new JSONObject(config);
                return AD_TYPE.valueOf(object.optString(positionName));
            } catch (JSONException e) {
                e.printStackTrace();
            } catch (Exception e1) {
                return null;
            }
        } else {
            return AD_TYPE.gdt;
        }
        return null;
    }
}
BuWanVideo/src/com/weikou/beibeivideo/util/ad/CSJConstant.java
@@ -1,8 +1,19 @@
package com.weikou.beibeivideo.util.ad;
public class CSJConstant {
    //首页大广告
    public static String RECOMMEND_BIG_IMG_AD = "945375047";
    //VIVO开屏
    public static String SPLASH_AD_VIVO = "887378583";
    //开屏广告
    public static String SPLASH_AD = "887360667";
    //软件退出广告
    public static String APP_EXIT="945469133";
    public static String INVALID_AD = "111111111";
}
BuWanVideo/src/com/weikou/beibeivideo/util/ad/ExpressAdManager.java
@@ -32,22 +32,20 @@
 * 信息流广告管理
 */
public class ExpressAdManager {
    public final static int SOURCE_GDT = 1;//广点通
    public final static int SOURCE_GDT2 = 11;//广点通2.0
    public final static int SOURCE_CSJ = 2;//穿山甲
    final static String TAG = "ExpressAdManager";
    int sourceType = SOURCE_GDT;
    AdUtil.AD_TYPE sourceType = AdUtil.AD_TYPE.gdt;
    private TTAdNative mTTAdNative;
    private Context mContext;
    public ExpressAdManager(int adSource, Context context) {
    public ExpressAdManager(AdUtil.AD_TYPE adSource, Context context) {
        sourceType = adSource;
        this.mContext = context;
        if (sourceType == SOURCE_CSJ) {
        if (sourceType == AdUtil.AD_TYPE.csj) {
            TTAdManager ttAdManager = TTAdManagerHolder.get();
            mTTAdNative = ttAdManager.createAdNative(context);
//            TTAdManagerHolder.get().requestPermissionIfNecessary(context);
@@ -66,7 +64,7 @@
     * @param adLoadListener
     */
    public void loadAd(int widthDP, int heightDP, String pid, int count, final IAdLoadListener adLoadListener) {
        if (sourceType == SOURCE_GDT) {
        if (sourceType == AdUtil.AD_TYPE.gdt) {
            loadGDT(pid, widthDP, heightDP, count, new IGDTAdLoadListener() {
                @Override
                public void onSuccess(List<NativeExpressADView> adList) {
@@ -83,7 +81,7 @@
                }
            }, mContext);
        } else if (sourceType == SOURCE_GDT2) {
        } else if (sourceType == AdUtil.AD_TYPE.gdt2) {
            loadGDT2(pid, widthDP, heightDP, count, new IGDTAdLoadListener() {
                @Override
                public void onSuccess(List<NativeExpressADView> adList) {
@@ -101,7 +99,7 @@
                }
            }, mContext);
        } else if (sourceType == SOURCE_CSJ) {
        } else if (sourceType == AdUtil.AD_TYPE.csj) {
            loadCSJ(pid, widthDP, heightDP, count, new ICSJAdLoadListener() {
                @Override
                public void onSuccess(List<TTNativeExpressAd> adList) {
@@ -130,12 +128,12 @@
        int width = deviceWidth - 6;
        int height = (int) (width * 0.8);
        String pid = null;
        if (sourceType == SOURCE_CSJ) {
        if (sourceType == AdUtil.AD_TYPE.csj) {
            pid = CSJConstant.RECOMMEND_BIG_IMG_AD;
            height = (int) (width * 0.56);
        } else if (sourceType == SOURCE_GDT) {
        } else if (sourceType == AdUtil.AD_TYPE.gdt) {
            pid = BeibeiConstant.GDT_RECOMMAND_NATIVE;
        } else if (sourceType == SOURCE_GDT2) {
        } else if (sourceType == AdUtil.AD_TYPE.gdt2) {
            pid = GDTConstant.PID_HOME_RECOMMEND_BIG_IMG;
        }
        //获取屏幕的宽
@@ -152,9 +150,9 @@
    public void loadRecommendSmallAd(final IAdLoadListener adLoadListener) {
        //加载大图
        String pid = null;
        if (sourceType == SOURCE_CSJ) {
        if (sourceType == AdUtil.AD_TYPE.csj) {
            pid = "945375047";
        } else if (sourceType == SOURCE_GDT) {
        } else if (sourceType == AdUtil.AD_TYPE.gdt) {
            pid = BeibeiConstant.GDT_RECOMMAND_MIN_NATIVE;
        }
        //获取屏幕的宽
@@ -174,9 +172,9 @@
    public void loadVideoDetailPlayerBottomAd(final IAdLoadListener adLoadListener) {
        //加载大图
        String pid = null;
        if (sourceType == SOURCE_CSJ) {
        if (sourceType == AdUtil.AD_TYPE.csj) {
            pid = "945375047";
        } else if (sourceType == SOURCE_GDT2) {
        } else if (sourceType == AdUtil.AD_TYPE.gdt2) {
            pid = GDTConstant.PID_2_VIDEO_DETAIL_PLAY_EXPRESS1;
        }
        //获取屏幕的宽
@@ -196,9 +194,9 @@
    public void loadVideoDetailRelativeVideoBottomAd(final IAdLoadListener adLoadListener) {
        //加载大图
        String pid = null;
        if (sourceType == SOURCE_CSJ) {
        if (sourceType == AdUtil.AD_TYPE.csj) {
            pid = "945375047";
        } else if (sourceType == SOURCE_GDT2) {
        } else if (sourceType == AdUtil.AD_TYPE.gdt2) {
            pid = GDTConstant.PID_2_VIDEO_DETAIL_PLAY_EXPRESS2;
        }
        if (mContext == null)
@@ -220,9 +218,9 @@
    public void loadRecommendCategorySmallAd(final IAdLoadListener adLoadListener) {
        //加载大图
        String pid = null;
        if (sourceType == SOURCE_CSJ) {
        if (sourceType == AdUtil.AD_TYPE.csj) {
            pid = "945375047";
        } else if (sourceType == SOURCE_GDT) {
        } else if (sourceType == AdUtil.AD_TYPE.gdt) {
            pid = BeibeiConstant.GDT_RECOMMEND_CATEGORY_MIN_NATIVE;
        }
        //获取屏幕的宽
@@ -242,9 +240,9 @@
    public void loadSearchResultSmallAd(int count, final IAdLoadListener adLoadListener) {
        //加载大图
        String pid = null;
        if (sourceType == SOURCE_CSJ) {
        if (sourceType == AdUtil.AD_TYPE.csj) {
            pid = "945379581";
        } else if (sourceType == SOURCE_GDT) {
        } else if (sourceType == AdUtil.AD_TYPE.gdt) {
            pid = BeibeiConstant.GDT_SEARCH_RESULT_MIN_NATIVE;
        }
        //获取屏幕的宽
@@ -267,9 +265,9 @@
        //加载大图
        String pid = null;
        if (sourceType == SOURCE_CSJ) {
        if (sourceType == AdUtil.AD_TYPE.csj) {
            pid = "945406595";
        } else if (sourceType == SOURCE_GDT2) {
        } else if (sourceType == AdUtil.AD_TYPE.gdt2) {
            if (columns == 3)
                pid = GDTConstant.PID_2_VIDEO_LIST_SMALL_AD_COLUMN3;
            else if (columns == 2)
@@ -294,6 +292,29 @@
    /**
     * 加载APP退出广告
     *
     * @param adLoadListener
     */
    public void loadAppExitAd(final IAdLoadListener adLoadListener) {
        //加载大图
        String pid = null;
        if (sourceType == AdUtil.AD_TYPE.csj) {
            pid = CSJConstant.APP_EXIT;
        } else if (sourceType == AdUtil.AD_TYPE.gdt) {
            pid = BeibeiConstant.GDT_EXIT_DIALOG;
        }
        //获取屏幕的宽
        int deviceWidth = DimenUtils.getScreenWidth(mContext);
        deviceWidth = DimenUtils.px2dip(mContext, deviceWidth);
        int width = deviceWidth * 3 / 4;
        int height = (int) (width / 1.78f);
        loadAd(width, height, pid, 1, adLoadListener);
    }
    /**
     * 加载广点通广告
     *
     * @param positionId
BuWanVideo/src/com/weikou/beibeivideo/util/ad/SplashAdUtil.java
@@ -9,6 +9,7 @@
import com.bytedance.sdk.openadsdk.TTAdManager;
import com.bytedance.sdk.openadsdk.TTAdNative;
import com.bytedance.sdk.openadsdk.TTSplashAd;
import com.lcjian.library.util.ManifestDataUtil;
import com.qq.e.ads.splash.SplashAD;
import com.qq.e.ads.splash.SplashADListener;
import com.qq.e.comm.util.AdError;
@@ -29,14 +30,14 @@
     * @param tv_time
     * @param splashAdListener
     */
    public static void loadAD(String adType, Activity context, final View skip, ViewGroup vg_ad, final TextView tv_time, final SplashAdListener splashAdListener) {
        if (StringUtils.isNullOrEmpty(adType)) {
    public static void loadAD(AdUtil.AD_TYPE adType, Activity context, final View skip, ViewGroup vg_ad, final TextView tv_time, final SplashAdListener splashAdListener) {
        if (adType==null) {
            splashAdListener.close();
            return;
        }
        if (AdTypeVO.TYPE_CSJ.equalsIgnoreCase(adType)) {
        if (AdUtil.AD_TYPE.csj==adType) {
            loadCSJ(context, skip, vg_ad, splashAdListener);
        } else if (AdTypeVO.TYPE_GDT.equalsIgnoreCase(adType)) {
        } else if (AdUtil.AD_TYPE.gdt==adType) {
            loadGDT(context, skip, vg_ad, tv_time, splashAdListener);
        } else {
            splashAdListener.close();
@@ -44,7 +45,13 @@
    }
    private static void loadGDT(Activity context, final View skip, ViewGroup vg_ad, final TextView tv_time, final SplashAdListener splashAdListener) {
        new SplashAD(context, skip, BeibeiConstant.GDT_SPLASH_POSITION_ID, new SplashADListener() {
        String channel = ManifestDataUtil.getAppMetaData(context, "UMENG_CHANNEL");
        String code = BeibeiConstant.GDT_SPLASH_POSITION_ID;
        if ("vivo".equalsIgnoreCase(channel)) {
            code = BeibeiConstant.GDT_SPLASH_VIVO_POSITION_ID;
        }
        new SplashAD(context, skip, code, new SplashADListener() {
            @Override
            public void onADDismissed() {
                splashAdListener.close();
@@ -119,8 +126,14 @@
            width = 720;
        if (height == 0)
            height = 1080;
        String channel = ManifestDataUtil.getAppMetaData(context, "UMENG_CHANNEL");
        String code = CSJConstant.SPLASH_AD;
        if ("vivo".equalsIgnoreCase(channel)) {
            code = CSJConstant.SPLASH_AD_VIVO;
        }
        AdSlot adSlot = new AdSlot.Builder()
                .setCodeId("887360667")
                .setCodeId(code)
                .setSupportDeepLink(true)
                .setImageAcceptedSize(width, height)
                .build();
BuWanVideo/src/com/weikou/beibeivideo/util/ad/manager/SearchResultAdManager.java
@@ -4,6 +4,7 @@
import android.content.Context;
import com.weikou.beibeivideo.entity.ad.ExpressAdContainer;
import com.weikou.beibeivideo.util.ad.AdUtil;
import com.weikou.beibeivideo.util.ad.ExpressAdManager;
import java.util.List;
@@ -21,7 +22,7 @@
    public SearchResultAdManager(Context context) {
        mContext = context;
        if (expressAdManager == null)
            expressAdManager = new ExpressAdManager(ExpressAdManager.SOURCE_GDT, mContext);
            expressAdManager = new ExpressAdManager(AdUtil.AD_TYPE.gdt, mContext);
    }
    public static SearchResultAdManager getInstance(Context context) {
build.gradle
@@ -20,5 +20,6 @@
        }
        maven { url 'https://jitpack.io' }
        maven { url 'https://dl.bintray.com/umsdk/release' }
        maven { url "https://dl.bintray.com/thelasterstar/maven/" }
    }
}
library-ViewPagerIndicator/src/com/viewpagerindicator/SearchTabPageIndicator.java
New file
@@ -0,0 +1,329 @@
/*
 * Copyright (C) 2011 The Android Open Source Project
 * Copyright (C) 2011 Jake Wharton
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.viewpagerindicator;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Color;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;
import android.widget.TextView;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
/**
 * This widget implements the dynamic action bar tab behavior that can change
 * across different configurations or circumstances.
 */
public class SearchTabPageIndicator extends HorizontalScrollView implements
        PageIndicator {
    /**
     * Title text used when no title is provided by the adapter.
     */
    private static final CharSequence EMPTY_TITLE = "";
    /**
     * Interface for a callback when the selected tab has been reselected.
     */
    public interface OnTabReselectedListener {
        /**
         * Callback when the selected tab has been reselected.
         *
         * @param position Position of the current center item.
         */
        void onTabReselected(int position);
    }
    private Runnable mTabSelector;
    /**
     * ViewPager中tab的点击事件
     */
    private final OnClickListener mTabClickListener = new OnClickListener() {
        public void onClick(View view) {
            TabView tabView = (TabView) view;
            final int oldSelected = mViewPager.getCurrentItem();
            final int newSelected = tabView.getIndex();
            mViewPager.setCurrentItem(newSelected);
            if (oldSelected == newSelected && mTabReselectedListener != null) {
                mTabReselectedListener.onTabReselected(newSelected);
            }
        }
    };
    private final IcsLinearLayout mTabLayout;
    private ViewPager mViewPager;
    private OnPageChangeListener mListener;
    private int mMaxTabWidth;
    private int mSelectedTabIndex;
    private OnTabReselectedListener mTabReselectedListener;
    public SearchTabPageIndicator(Context context) {
        this(context, null);
    }
    public SearchTabPageIndicator(Context context, AttributeSet attrs) {
        super(context, attrs);
        setHorizontalScrollBarEnabled(false);
        mTabLayout = new IcsLinearLayout(context,
                R.attr.vpiTabPageIndicatorStyle);
        addView(mTabLayout, new ViewGroup.LayoutParams(WRAP_CONTENT,
                MATCH_PARENT));
    }
    public void setOnTabReselectedListener(OnTabReselectedListener listener) {
        mTabReselectedListener = listener;
    }
    @Override
    public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
        final boolean lockedExpanded = widthMode == MeasureSpec.EXACTLY;
        setFillViewport(lockedExpanded);
        final int childCount = mTabLayout.getChildCount();
        if (childCount > 1
                && (widthMode == MeasureSpec.EXACTLY || widthMode == MeasureSpec.AT_MOST)) {
            if (childCount > 2) {
                mMaxTabWidth = (int) (MeasureSpec.getSize(widthMeasureSpec) * 0.4f);
            } else {
                mMaxTabWidth = MeasureSpec.getSize(widthMeasureSpec) / 2;
            }
        } else {
            mMaxTabWidth = -1;
        }
        final int oldWidth = getMeasuredWidth();
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        final int newWidth = getMeasuredWidth();
        if (lockedExpanded && oldWidth != newWidth) {
            // Recenter the tab display if we're at a new (scrollable) size.
            setCurrentItem(mSelectedTabIndex);
        }
    }
    /**
     * 单个Tab
     *
     * @param position
     */
    @SuppressLint("ResourceAsColor")
    private void animateToTab(final int position) {
        final View tabView = mTabLayout.getChildAt(position);
        if (mTabSelector != null) {
            removeCallbacks(mTabSelector);
        }
        for (int i = 0; i < mTabLayout.getChildCount(); i++) {
            ((TextView) mTabLayout.getChildAt(i)).setTextSize(
                    TypedValue.COMPLEX_UNIT_SP, 15);
            ((TextView) mTabLayout.getChildAt(i)).setTextColor(Color.parseColor("#999999"));
        }
        ((TextView) tabView).setTextColor(Color.WHITE);
        ((TextView) tabView).setTextSize(
                TypedValue.COMPLEX_UNIT_SP, 18);
//        ((TextView) tabView).setLayoutParams(new ViewGroup.LayoutParams(WRAP_CONTENT,WRAP_CONTENT));
        mTabSelector = new Runnable() {
            public void run() {
                final int scrollPos = tabView.getLeft()
                        - (getWidth() - tabView.getWidth()) / 2;
                smoothScrollTo(scrollPos, 0);
                mTabSelector = null;
            }
        };
        post(mTabSelector);
    }
    @Override
    public void onAttachedToWindow() {
        super.onAttachedToWindow();
        if (mTabSelector != null) {
            // Re-post the selector we saved
            post(mTabSelector);
        }
    }
    @Override
    public void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        if (mTabSelector != null) {
            removeCallbacks(mTabSelector);
        }
    }
    /**
     * 添加tabView
     *
     * @param index
     * @param text
     * @param iconResId
     */
    @SuppressLint("ResourceAsColor")
    private void addTab(int index, CharSequence text, int iconResId) {
        final TabView tabView = new TabView(getContext());
        tabView.mIndex = index;
        tabView.setFocusable(true);
        tabView.setOnClickListener(mTabClickListener);
        tabView.setText(text);
        tabView.setTextColor(R.color.black1);
        if (iconResId != 0) {
            tabView.setCompoundDrawablesWithIntrinsicBounds(iconResId, 0, 0, 0);
        }
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(WRAP_CONTENT,
                MATCH_PARENT, 1);
        mTabLayout.addView(tabView, params);
    }
    @Override
    public void onPageScrollStateChanged(int arg0) {
        if (mListener != null) {
            mListener.onPageScrollStateChanged(arg0);
        }
    }
    @Override
    public void onPageScrolled(int arg0, float arg1, int arg2) {
        if (mListener != null) {
            mListener.onPageScrolled(arg0, arg1, arg2);
        }
    }
    @Override
    public void onPageSelected(int arg0) {
        setCurrentItem(arg0);
        if (mListener != null) {
            mListener.onPageSelected(arg0);
        }
    }
    @Override
    public void setViewPager(ViewPager view) {
        if (mViewPager != null) {
            mViewPager.setOnPageChangeListener(null);
        }
        final PagerAdapter adapter = view.getAdapter();
        if (adapter == null) {
            throw new IllegalStateException(
                    "ViewPager does not have adapter instance.");
        }
        mViewPager = view;
        view.setOnPageChangeListener(this);
        notifyDataSetChanged();
    }
    public void notifyDataSetChanged() {
        mTabLayout.removeAllViews();
        PagerAdapter adapter = mViewPager.getAdapter();
        IconPagerAdapter iconAdapter = null;
        if (adapter instanceof IconPagerAdapter) {
            iconAdapter = (IconPagerAdapter) adapter;
        }
        final int count = adapter.getCount();
        for (int i = 0; i < count; i++) {
            CharSequence title = adapter.getPageTitle(i);
            if (title == null) {
                title = EMPTY_TITLE;
            }
            int iconResId = 0;
            if (iconAdapter != null) {
                iconResId = iconAdapter.getIconResId(i);
            }
            addTab(i, title, iconResId);
        }
        if (mSelectedTabIndex > count) {
            mSelectedTabIndex = count - 1;
        }
        setCurrentItem(mSelectedTabIndex);
        requestLayout();
    }
    @Override
    public void setViewPager(ViewPager view, int initialPosition) {
        setViewPager(view);
        setCurrentItem(initialPosition);
    }
    /**
     * 设置当前Item
     */
    @Override
    public void setCurrentItem(int item) {
        if (mViewPager == null) {
            throw new IllegalStateException("ViewPager has not been bound.");
        }
        mSelectedTabIndex = item;
        mViewPager.setCurrentItem(item);
        final int tabCount = mTabLayout.getChildCount();
        for (int i = 0; i < tabCount; i++) {
            final View child = mTabLayout.getChildAt(i);
            final boolean isSelected = (i == item);
            child.setSelected(isSelected);
            if (isSelected) {
                animateToTab(item);
            }
        }
    }
    @Override
    public void setOnPageChangeListener(OnPageChangeListener listener) {
        mListener = listener;
    }
    /**
     * 重写textview
     *
     * @author weikou2015
     */
    private class TabView extends TextView {
        private int mIndex;
        public TabView(Context context) {
            super(context, null, R.attr.vpiTabPageIndicatorStyle);
        }
        @Override
        public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
            // Re-measure if we went beyond our maximum size.
            if (mMaxTabWidth > 0 && getMeasuredWidth() > mMaxTabWidth) {
                super.onMeasure(MeasureSpec.makeMeasureSpec(mMaxTabWidth,
                        MeasureSpec.EXACTLY), heightMeasureSpec);
            }
        }
        public int getIndex() {
            return mIndex;
        }
    }
}
social_sdk_library_project/build.gradle
@@ -3,6 +3,8 @@
dependencies {
    api fileTree(include: '*', dir: 'libs')
    api 'com.sina.weibo.sdk:core:4.4.3:openDefaultRelease@aar'
    api files('libs/umeng-asms-armeabi-v1.1.3.aar')
    api files('libs/umeng-common-9.2.4.jar')
    api files('libs/umeng-crash-armeabi-v0.0.4.aar')