3 文件已重命名
40个文件已修改
21个文件已添加
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | android:layout_width="match_parent" |
| | | android:id="@+id/fl_container" |
| | | android:layout_height="match_parent"> |
| | | |
| | | </FrameLayout> |
| | |
| | | |
| | | |
| | | <FrameLayout |
| | | android:layout_marginTop="-10dp" |
| | | android:id="@+id/fl_indicator" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content"></FrameLayout> |
| | |
| | | android:layout_height="wrap_content" |
| | | android:ellipsize="end" |
| | | android:lines="2" |
| | | android:textSize="11sp" |
| | | android:textSize="@dimen/video_list_title" |
| | | android:paddingRight="8dp" |
| | | android:textColor="@color/videoTitle" /> |
| | | |
| | |
| | | android:drawablePadding="5dp" |
| | | android:gravity="center" |
| | | android:text="热播推荐" |
| | | android:textSize="14sp" /> |
| | | android:textSize="@dimen/video_album_title" /> |
| | | </LinearLayout> |
| | |
| | | android:gravity="end" |
| | | android:paddingLeft="8dp" |
| | | android:paddingRight="8dp" |
| | | android:textSize="10sp" |
| | | android:singleLine="true" |
| | | android:textColor="@color/videoTag" /> |
| | | android:textColor="@color/videoTag" |
| | | android:textSize="@dimen/video_list_tag" /> |
| | | |
| | | <ImageView |
| | | android:id="@+id/iv_ad_logo" |
| | |
| | | android:layout_height="wrap_content" |
| | | android:ellipsize="end" |
| | | android:lines="2" |
| | | android:textSize="11sp" |
| | | android:paddingRight="8dp" |
| | | android:textColor="@color/videoTitle" /> |
| | | android:textColor="@color/videoTitle" |
| | | android:textSize="@dimen/video_list_title" /> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | |
| | | android:layout_toRightOf="@id/tv_category_icon" |
| | | android:text="什么鬼" |
| | | android:textColor="#DDDDDD" |
| | | android:textSize="16sp" /> |
| | | android:textSize="@dimen/video_album_title" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_category_name2" |
| | |
| | | android:layout_toRightOf="@id/tv_category_icon" |
| | | android:text="推广" |
| | | android:textColor="#DDDDDD" |
| | | android:textSize="16sp" /> |
| | | android:textSize="@dimen/video_album_title"/> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_category_name2" |
| | |
| | | <FrameLayout |
| | | android:id="@+id/custom_container" |
| | | android:layout_width="match_parent" |
| | | android:background="@color/red" |
| | | android:layout_height="match_parent" |
| | | android:layout_centerInParent="true"> |
| | | android:layout_centerInParent="true" |
| | | android:background="@color/red"> |
| | | |
| | | <!-- 原生广告的视频组件 --> |
| | | <com.qq.e.ads.nativ.MediaView |
| | |
| | | </FrameLayout> |
| | | </LinearLayout> |
| | | </com.qq.e.ads.nativ.widget.NativeAdContainer> |
| | | |
| | | <FrameLayout |
| | | android:id="@+id/fl_ad" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:visibility="gone"></FrameLayout> |
| | | |
| | | </com.lcjian.library.widget.RatioLayout> |
| | | |
| | | |
| | | </LinearLayout> |
| | |
| | | android:drawablePadding="15dp" |
| | | android:text="@string/my_favourites" |
| | | android:textColor="#DCDCDC" |
| | | android:textSize="10sp" /> |
| | | android:textSize="@dimen/mine_item_name" /> |
| | | </LinearLayout> |
| | | |
| | | <LinearLayout |
| | |
| | | android:drawablePadding="15dp" |
| | | android:text="关注" |
| | | android:textColor="#DCDCDC" |
| | | android:textSize="10sp" /> |
| | | android:textSize="@dimen/mine_item_name" /> |
| | | </LinearLayout> |
| | | |
| | | <LinearLayout |
| | |
| | | android:drawablePadding="15dp" |
| | | android:text="记录" |
| | | android:textColor="#DCDCDC" |
| | | android:textSize="10sp" /> |
| | | android:textSize="@dimen/mine_item_name" /> |
| | | </LinearLayout> |
| | | |
| | | <LinearLayout |
| | | android:id="@+id/ll_mine_novel" |
| | | android:layout_width="0dp" |
| | | android:layout_height="wrap_content" |
| | | android:layout_weight="1" |
| | | android:gravity="center_horizontal" |
| | | android:orientation="vertical" |
| | | android:padding="8dp"> |
| | | |
| | | <ImageView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="24dp" |
| | | android:src="@drawable/ic_mine_novel"></ImageView> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_mine_novel" |
| | | style="@style/TextBlackMedium" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginTop="9dp" |
| | | android:drawablePadding="15dp" |
| | | android:text="书架" |
| | | android:textColor="#DCDCDC" |
| | | android:textSize="@dimen/mine_item_name" /> |
| | | </LinearLayout> |
| | | |
| | | </LinearLayout> |
| | |
| | | android:layout_marginTop="28dp" |
| | | android:text="站内消息" |
| | | android:textColor="#ffdcdcdc" |
| | | android:textSize="10sp"></TextView> |
| | | android:textSize="@dimen/mine_item_name"></TextView> |
| | | </RelativeLayout> |
| | | |
| | | <View |
| | |
| | | android:layout_marginTop="28dp" |
| | | android:text="分享软件" |
| | | android:textColor="#ffdcdcdc" |
| | | android:textSize="10sp"></TextView> |
| | | android:textSize="@dimen/mine_item_name"></TextView> |
| | | </RelativeLayout> |
| | | |
| | | <View |
| | |
| | | android:layout_marginTop="28dp" |
| | | android:text="帮助中心" |
| | | android:textColor="#ffdcdcdc" |
| | | android:textSize="10sp"></TextView> |
| | | android:textSize="@dimen/mine_item_name"></TextView> |
| | | </RelativeLayout> |
| | | |
| | | </LinearLayout> |
| | |
| | | android:layout_marginTop="28dp" |
| | | android:text="关于我们" |
| | | android:textColor="#ffdcdcdc" |
| | | android:textSize="10sp"></TextView> |
| | | android:textSize="@dimen/mine_item_name"></TextView> |
| | | </RelativeLayout> |
| | | |
| | | <View |
| | |
| | | android:layout_marginTop="28dp" |
| | | android:text="设置" |
| | | android:textColor="#ffdcdcdc" |
| | | android:textSize="10sp"></TextView> |
| | | android:textSize="@dimen/mine_item_name"></TextView> |
| | | </RelativeLayout> |
| | | |
| | | <View |
| | |
| | | android:layout_toRightOf="@id/tv_category_icon" |
| | | android:paddingLeft="5dp" |
| | | android:text="什么鬼" |
| | | android:textSize="16sp" /> |
| | | android:textSize="17sp" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_category_name2" |
| | |
| | | android:background="@null" |
| | | android:textAppearance="?android:attr/textAppearance" |
| | | android:textColor="@color/white" |
| | | android:textSize="12sp" |
| | | android:textSize="15sp" |
| | | android:textCursorDrawable="@null" /> |
| | | |
| | | </LinearLayout> |
| | |
| | | android:layout_height="wrap_content" |
| | | android:padding="8dp" |
| | | android:text="@string/hot_search" |
| | | android:textSize="14sp" |
| | | android:textColor="#DDDDDD" /> |
| | | |
| | | <com.lcjian.library.widget.MyGridView |
| | |
| | | android:layout_height="wrap_content"> |
| | | |
| | | <TextView |
| | | android:textSize="14sp" |
| | | style="@style/TextBuleSmall" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | |
| | | android:textAppearance="?android:attr/textAppearance" |
| | | android:textColor="@color/white" |
| | | android:textCursorDrawable="@null" |
| | | android:textSize="12sp" /> |
| | | android:textSize="15sp" /> |
| | | |
| | | </LinearLayout> |
| | | |
New file |
| | |
| | | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | android:id="@+id/root" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:orientation="vertical"> |
| | | <RelativeLayout |
| | | android:id="@+id/ad_info_container" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:background="@color/colorAccent"> |
| | | |
| | | <!-- 原生广告的小图 --> |
| | | <ImageView |
| | | android:id="@+id/img_logo" |
| | | android:layout_width="64dp" |
| | | android:layout_height="64dp" |
| | | android:layout_alignParentLeft="true" |
| | | android:layout_alignParentTop="true" |
| | | android:layout_marginTop="10dp" |
| | | android:layout_marginRight="10dp" |
| | | android:layout_marginBottom="10dp" /> |
| | | |
| | | <!-- 原生广告的点击按钮 --> |
| | | <Button |
| | | android:id="@+id/btn_download" |
| | | android:layout_width="60dp" |
| | | android:layout_height="30dp" |
| | | android:layout_alignTop="@id/img_logo" |
| | | android:layout_alignParentRight="true" |
| | | android:layout_marginLeft="10dp" |
| | | android:layout_marginRight="10dp" |
| | | android:background="#00000000" |
| | | android:textColor="@android:color/white" |
| | | android:textSize="14sp" /> |
| | | |
| | | <!-- 原生广告的标题 --> |
| | | <TextView |
| | | android:id="@+id/text_title" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_alignTop="@id/img_logo" |
| | | android:layout_marginLeft="6dp" |
| | | android:layout_toLeftOf="@id/btn_download" |
| | | android:layout_toRightOf="@id/img_logo" |
| | | android:ellipsize="end" |
| | | android:singleLine="true" |
| | | android:textColor="#e0000000" /> |
| | | |
| | | <!-- 原生广告的描述 --> |
| | | <TextView |
| | | android:id="@+id/text_desc" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_below="@id/text_title" |
| | | android:layout_alignBottom="@id/img_logo" |
| | | android:layout_marginLeft="6dp" |
| | | android:layout_marginRight="6dp" |
| | | android:layout_toLeftOf="@id/btn_download" |
| | | android:layout_toRightOf="@id/img_logo" |
| | | android:textSize="10px" |
| | | android:ellipsize="end" |
| | | android:maxLines="2" |
| | | android:textColor="#a0000000" /> |
| | | </RelativeLayout> |
| | | <FrameLayout |
| | | android:id="@+id/custom_container" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_centerInParent="true"> |
| | | <!-- 原生广告的视频组件 --> |
| | | <com.qq.e.ads.nativ.MediaView |
| | | android:id="@+id/gdt_media_view" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center" |
| | | android:background="#000" /> |
| | | <!-- 原生广告的大图 --> |
| | | <ImageView |
| | | android:id="@+id/img_poster" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:scaleType="fitXY" /> |
| | | |
| | | <!-- 原生三小图 --> |
| | | <LinearLayout |
| | | android:id="@+id/native_3img_ad_container" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:orientation="vertical"> |
| | | |
| | | <TextView |
| | | android:id="@+id/native_3img_desc" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_margin="5dp" |
| | | android:ellipsize="end" |
| | | android:textColor="@android:color/black" /> |
| | | |
| | | <LinearLayout |
| | | android:id="@+id/native_3img" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_margin="5dp" |
| | | android:orientation="horizontal" |
| | | android:weightSum="3"> |
| | | |
| | | <ImageView |
| | | android:id="@+id/img_1" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:layout_margin="3dp" |
| | | android:layout_weight="1" |
| | | android:adjustViewBounds="true" |
| | | android:scaleType="fitXY" /> |
| | | |
| | | <ImageView |
| | | android:id="@+id/img_2" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:layout_margin="3dp" |
| | | android:layout_weight="1" |
| | | android:adjustViewBounds="true" |
| | | android:scaleType="fitXY" /> |
| | | |
| | | <ImageView |
| | | android:id="@+id/img_3" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:layout_margin="3dp" |
| | | android:layout_weight="1" |
| | | android:adjustViewBounds="true" |
| | | android:scaleType="fitXY" /> |
| | | </LinearLayout> |
| | | |
| | | <TextView |
| | | android:id="@+id/native_3img_title" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_margin="5dp" |
| | | android:textColor="@android:color/black" /> |
| | | </LinearLayout> |
| | | </FrameLayout> |
| | | </LinearLayout> |
| | |
| | | <dimen name="text_size_medium">16sp</dimen> |
| | | <dimen name="text_size_large">18sp</dimen> |
| | | <dimen name="text_size_xlarge">22sp</dimen> |
| | | |
| | | <dimen name="page_title_height">50dp</dimen> |
| | | <dimen name="album_item_width_short">200dp</dimen> |
| | | <dimen name="shadow_width">15dp</dimen> |
| | | <dimen name="slidingmenu_offset">80dp</dimen> |
| | | <dimen name="checkmark_area">40dip</dimen> |
| | | <dimen name="video_list_title">13sp</dimen> |
| | | <dimen name="video_list_tag">11sp</dimen> |
| | | <dimen name="mine_item_name">12sp</dimen> |
| | | <!--专辑标题 --> |
| | | <dimen name="video_album_title">17sp</dimen> |
| | | |
| | | |
| | | </resources> |
| | |
| | | <item name="android:fadingEdgeLength">8dp</item> |
| | | </style> |
| | | |
| | | |
| | | <style name="CustomTabPageIndicator1" parent="Widget.TabPageIndicator1"> |
| | | <item name="android:textAppearance">@style/CustomTabPageIndicator.Text</item> |
| | | <item name="android:textColor">@color/selector_category_two_text</item> |
| | |
| | | import com.weikou.beibeivideo.BeibeiVideoApplication; |
| | | import com.weikou.beibeivideo.ui.BaseActivity; |
| | | import com.weikou.beibeivideo.util.UserUtil; |
| | | import com.weikou.beibeivideo.util.novel.NovelJNZUtil; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | |
| | | user.optString("sex")); |
| | | edit.commit(); |
| | | |
| | | NovelJNZUtil.setUid(getApplicationContext()); |
| | | |
| | | SingleToast.showToast(getApplicationContext(), |
| | | "登录成功"); |
| | | } else { |
| | |
| | | public static void getChoiceClass(Context context, String uid, |
| | | ResponseHandlerInterface handler) { |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<String, String>(); |
| | | params.put("Method", "getVideoClass"); |
| | | params.put("Method", "getHomeClass"); |
| | | params.put("Uid", uid); |
| | | commonPost(context, BASE_URL + "class", params, handler); |
| | | } |
| | |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.content.IntentFilter; |
| | | import android.graphics.Color; |
| | | import android.support.multidex.MultiDex; |
| | | import android.util.Log; |
| | | |
| | |
| | | import com.weikou.beibeivideo.util.BeibeiConstant; |
| | | import com.weikou.beibeivideo.util.CrashHandler; |
| | | import com.weikou.beibeivideo.util.FunshionConstant; |
| | | import com.weikou.beibeivideo.util.UserUtil; |
| | | import com.weikou.beibeivideo.util.ad.TTAdManagerHolder; |
| | | import com.weikou.beibeivideo.util.downutil.StringUtils; |
| | | import com.weikou.beibeivideo.util.novel.NovelJNZUtil; |
| | | |
| | | public class BeibeiVideoApplication extends Application { |
| | | public static BeibeiVideoApplication application = null; |
| | |
| | | initCSJAd(); |
| | | GDTADManager.getInstance().initWith(this, BeibeiConstant.GDT_ID); |
| | | initWX(); |
| | | //初始化播放插件 |
| | | FSPlayer.init(this, FunshionConstant.APICODE); |
| | | try { |
| | | //初始化播放插件 |
| | | FSPlayer.init(this, FunshionConstant.APICODE); |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | //百度内容联盟 |
| | | AppActivity.setActionBarColorTheme(AppActivity.ActionBarColorTheme.ACTION_BAR_BLACK_THEME); |
| | | //聚能赚 |
| | | YmConfig.initNovel(this,"8845"); |
| | | try { |
| | | AppActivity.setActionBarColorTheme(AppActivity.ActionBarColorTheme.ACTION_BAR_BLACK_THEME); |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | try { |
| | | //聚能赚 |
| | | YmConfig.initNovel(this, "8845"); |
| | | NovelJNZUtil.setUid(this); |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
New file |
| | |
| | | package com.weikou.beibeivideo.entity.ad; |
| | | |
| | | import com.weikou.beibeivideo.util.BeibeiConstant; |
| | | import com.weikou.beibeivideo.util.ad.AdUtil; |
| | | import com.weikou.beibeivideo.util.ad.GDTConstant; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | //视频前贴广告的配置信息 |
| | | public class PlayVideoPreADSetting implements Serializable { |
| | | private AdUtil.AD_TYPE adType;//csj或者gdt |
| | | private String gdtAppId;//广点通的APPId |
| | | private String gdtPid;//广点通的PID |
| | | private String csjPid;//穿山甲的pid |
| | | |
| | | public PlayVideoPreADSetting(AdUtil.AD_TYPE adType, String gdtAppId, String gdtPid, String csjPid) { |
| | | this.adType = adType; |
| | | this.gdtAppId = gdtAppId; |
| | | this.gdtPid = gdtPid; |
| | | this.csjPid = csjPid; |
| | | } |
| | | |
| | | public AdUtil.AD_TYPE getAdType() { |
| | | return adType; |
| | | } |
| | | |
| | | public void setAdType(AdUtil.AD_TYPE adType) { |
| | | this.adType = adType; |
| | | } |
| | | |
| | | public String getGdtAppId() { |
| | | return gdtAppId; |
| | | } |
| | | |
| | | public void setGdtAppId(String gdtAppId) { |
| | | this.gdtAppId = gdtAppId; |
| | | } |
| | | |
| | | public String getGdtPid() { |
| | | return gdtPid; |
| | | } |
| | | |
| | | public void setGdtPid(String gdtPid) { |
| | | this.gdtPid = gdtPid; |
| | | } |
| | | |
| | | public String getCsjPid() { |
| | | return csjPid; |
| | | } |
| | | |
| | | public void setCsjPid(String csjPid) { |
| | | this.csjPid = csjPid; |
| | | } |
| | | |
| | | public static class PlayVideoPreADSettingFactory { |
| | | //默认广点通 |
| | | public static PlayVideoPreADSetting createDefault() { |
| | | return new PlayVideoPreADSetting(AdUtil.AD_TYPE.gdt, BeibeiConstant.GDT_ID, GDTConstant.PID_VIDEO_DETAIL_PLAYER, null); |
| | | } |
| | | |
| | | public static PlayVideoPreADSetting createGDT(String appId, String pid) { |
| | | return new PlayVideoPreADSetting(AdUtil.AD_TYPE.gdt, appId, pid, null); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.weikou.beibeivideo.entity.recommend; |
| | | |
| | | import com.google.gson.annotations.Expose; |
| | | import com.weikou.beibeivideo.entity.VideoType; |
| | | |
| | | public class HomeClass extends VideoType { |
| | | |
| | | @Expose |
| | | private String dataType;//数据类型 "recommend"-推荐 "class"-分类 "novel"-小说 |
| | | |
| | | public String getDataType() { |
| | | return dataType; |
| | | } |
| | | |
| | | public void setDataType(String dataType) { |
| | | this.dataType = dataType; |
| | | } |
| | | } |
| | |
| | | // if (res.getConfiguration().fontScale != 1) {//非默认值 |
| | | Configuration newConfig = new Configuration(); |
| | | newConfig.setToDefaults();//设置默认 |
| | | newConfig.fontScale=1.2f; |
| | | newConfig.fontScale=1.0f; |
| | | res.updateConfiguration(newConfig, res.getDisplayMetrics()); |
| | | // } |
| | | return res; |
File was renamed from BuWanVideo/src/com/weikou/beibeivideo/ui/ad/VideoDetailVideoAdFragment.java |
| | |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | | import android.widget.FrameLayout; |
| | | import android.widget.ImageView; |
| | | import android.widget.ProgressBar; |
| | | import android.widget.TextView; |
| | | |
| | | import com.bytedance.sdk.openadsdk.AdSlot; |
| | | import com.bytedance.sdk.openadsdk.TTAdManager; |
| | | import com.bytedance.sdk.openadsdk.TTAdNative; |
| | | import com.bytedance.sdk.openadsdk.TTSplashAd; |
| | | import com.qq.e.ads.cfg.VideoOption; |
| | | import com.qq.e.ads.nativ.MediaView; |
| | | import com.qq.e.ads.nativ.NativeADEventListener; |
| | |
| | | import com.qq.e.comm.constants.AdPatternType; |
| | | import com.qq.e.comm.util.AdError; |
| | | import com.weikou.beibeivideo.R; |
| | | import com.weikou.beibeivideo.entity.ad.PlayVideoPreADSetting; |
| | | import com.weikou.beibeivideo.util.BeibeiConstant; |
| | | import com.weikou.beibeivideo.util.DimenUtils; |
| | | 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.TTAdManagerHolder; |
| | | import com.weikou.beibeivideo.util.ui.IPageEventListener; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Calendar; |
| | | import java.util.List; |
| | | |
| | | public class VideoDetailVideoAdFragment extends Fragment implements View.OnClickListener { |
| | | /** |
| | | * 视频播放前贴广告 |
| | | */ |
| | | public class PlayVideoPreADFragment extends Fragment implements View.OnClickListener { |
| | | |
| | | private final static String TAG = "VideoDetailVideoAdFragment"; |
| | | |
| | | |
| | | private final static String TAG = PlayVideoPreADFragment.class.getName(); |
| | | |
| | | private MediaView mediaView; |
| | | |
| | | private NativeAdContainer mContainer; |
| | | |
| | | private NativeUnifiedADData mAdData; |
| | | //穿山甲广告 |
| | | private FrameLayout fl_ad; |
| | | |
| | | private NativeUnifiedADData mGDTAdData; |
| | | |
| | | private TextView tv_skip; |
| | | |
| | |
| | | |
| | | private IPageEventListener pageEventListener; |
| | | |
| | | public static PlayVideoPreADFragment newInstance() { |
| | | Bundle bundle = new Bundle(); |
| | | |
| | | PlayVideoPreADFragment fragment = new PlayVideoPreADFragment(); |
| | | fragment.setArguments(bundle); |
| | | return fragment; |
| | | } |
| | | |
| | | public void setPageEventListener(IPageEventListener pageEventListener) { |
| | | this.pageEventListener = pageEventListener; |
| | | } |
| | | |
| | | @Override |
| | | public void onCreate(@Nullable Bundle savedInstanceState) { |
| | | Log.i(TAG, "onCreate"); |
| | | super.onCreate(savedInstanceState); |
| | | } |
| | | |
| | |
| | | img_poster = root.findViewById(R.id.img_poster); |
| | | tv_skip = root.findViewById(R.id.tv_skip); |
| | | pb_progress = root.findViewById(R.id.pb_progress); |
| | | fl_ad = root.findViewById(R.id.fl_ad); |
| | | } |
| | | |
| | | @Nullable |
| | | @Override |
| | | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
| | | |
| | | |
| | | View root = LayoutInflater.from(getContext()).inflate(R.layout.item_video_detail_ad, null); |
| | | initView(root); |
| | | tv_skip.setOnClickListener(this); |
| | |
| | | timer = new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | if (remainTime - (mAdData.getVideoCurrentPosition() / 1000) > 0) { |
| | | tv_skip.setText((remainTime - (mAdData.getVideoCurrentPosition() / 1000)) + "s后可跳过"); |
| | | if (remainTime - (mGDTAdData.getVideoCurrentPosition() / 1000) > 0) { |
| | | tv_skip.setText((remainTime - (mGDTAdData.getVideoCurrentPosition() / 1000)) + "s后可跳过"); |
| | | tv_skip.setClickable(false); |
| | | } else { |
| | | tv_skip.setText("跳过"); |
| | |
| | | Runnable playErrorRunnable = null; |
| | | |
| | | public void loadVideoAD(final IVideoAdListener videoAdListener) { |
| | | loadVideoAD(videoAdListener, null); |
| | | } |
| | | |
| | | public void loadVideoAD(IVideoAdListener videoAdListener, PlayVideoPreADSetting setting) { |
| | | if (setting == null) |
| | | setting = PlayVideoPreADSetting.PlayVideoPreADSettingFactory.createDefault(); |
| | | tv_skip.setVisibility(View.GONE); |
| | | if (mAdData != null) |
| | | mAdData.destroy(); |
| | | if (mGDTAdData != null) |
| | | mGDTAdData.destroy(); |
| | | pb_progress.setVisibility(View.VISIBLE); |
| | | String pid = GDTConstant.PID_VIDEO_DETAIL_PLAYER; |
| | | String pid = setting.getGdtPid(); |
| | | //TODO 需要单独判断 |
| | | 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() { |
| | | // loadCSJ(CSJConstant.PLAY_VIDEO_PRE, videoAdListener); |
| | | loadGDT(setting.getGdtAppId(), pid, videoAdListener); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 加载穿山甲广告 |
| | | * |
| | | * @param code |
| | | * @param videoAdListener |
| | | */ |
| | | private void loadCSJ(String code, IVideoAdListener videoAdListener) { |
| | | |
| | | fl_ad.setVisibility(View.VISIBLE); |
| | | mContainer.setVisibility(View.GONE); |
| | | |
| | | TTAdManager ttAdManager = TTAdManagerHolder.get(); |
| | | TTAdNative mTTAdNative = ttAdManager.createAdNative(getContext()); |
| | | int width = DimenUtils.getScreenWidth(getContext()); |
| | | int height = width * 9 / 16; |
| | | |
| | | AdSlot adSlot = new AdSlot.Builder() |
| | | .setCodeId(code) |
| | | .setSupportDeepLink(true) |
| | | .setImageAcceptedSize(width, height) |
| | | .build(); |
| | | |
| | | mTTAdNative.loadSplashAd(adSlot, new TTAdNative.SplashAdListener() { |
| | | @Override |
| | | public void onError(int i, String s) { |
| | | videoAdListener.noAd(); |
| | | } |
| | | |
| | | @Override |
| | | public void onTimeout() { |
| | | videoAdListener.noAd(); |
| | | } |
| | | |
| | | @Override |
| | | public void onSplashAdLoad(TTSplashAd ad) { |
| | | fl_ad.removeAllViews(); |
| | | fl_ad.addView(ad.getSplashView()); |
| | | ad.setSplashInteractionListener(new TTSplashAd.AdInteractionListener() { |
| | | @Override |
| | | public void onAdClicked(View view, int i) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onAdShow(View view, int i) { |
| | | Log.i(TAG, "onAdShow"); |
| | | } |
| | | |
| | | @Override |
| | | public void onAdSkip() { |
| | | videoAdListener.finishPlay(); |
| | | } |
| | | |
| | | @Override |
| | | public void onAdTimeOver() { |
| | | videoAdListener.finishPlay(); |
| | | } |
| | | }); |
| | | |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 加载广点通广告 |
| | | * |
| | | * @param appId |
| | | * @param pid |
| | | * @param videoAdListener |
| | | */ |
| | | private void loadGDT(String appId, String pid, IVideoAdListener videoAdListener) { |
| | | fl_ad.setVisibility(View.GONE); |
| | | mContainer.setVisibility(View.VISIBLE); |
| | | NativeUnifiedAD mAdManager = new NativeUnifiedAD(getContext(), appId, pid, new NativeADUnifiedListener() { |
| | | |
| | | @Override |
| | | public void onNoAD(AdError adError) {//没有广告 |
| | | System.out.println(adError); |
| | | pb_progress.setVisibility(View.GONE); |
| | | if (videoAdListener != null) { |
| | | videoAdListener.finishPlay(); |
| | | videoAdListener.noAd(); |
| | | } |
| | | } |
| | | |
| | |
| | | System.out.println(list); |
| | | final NativeUnifiedADData ad = list.get(0); |
| | | //填充内容 |
| | | mAdData = ad; |
| | | mGDTAdData = ad; |
| | | List<View> clickableViews = new ArrayList<>(); |
| | | |
| | | ad.bindAdToView(getContext(), mContainer, null, clickableViews); |
| | |
| | | @Override |
| | | public void run() { |
| | | if (pb_progress.getVisibility() == View.VISIBLE) { |
| | | mAdData.destroy(); |
| | | mGDTAdData.destroy(); |
| | | if (videoAdListener != null) { |
| | | videoAdListener.finishPlay(); |
| | | } |
| | |
| | | } else { |
| | | pb_progress.setVisibility(View.GONE); |
| | | if (videoAdListener != null) { |
| | | videoAdListener.finishPlay(); |
| | | videoAdListener.noAd(); |
| | | } |
| | | } |
| | | } |
| | |
| | | tv_skip.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | if (mAdData != null) |
| | | mAdData.stopVideo(); |
| | | if (mGDTAdData != null) |
| | | mGDTAdData.stopVideo(); |
| | | if (videoAdListener != null) |
| | | videoAdListener.finishPlay(); |
| | | tv_skip.setVisibility(View.GONE); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | public void onResume() { |
| | | Log.i(TAG, "onResume"); |
| | | super.onResume(); |
| | | if (mAdData != null) { |
| | | if (mGDTAdData != null) { |
| | | // 必须要在Activity.onResume()时通知到广告数据,以便重置广告恢复状态 |
| | | mAdData.resume(); |
| | | mGDTAdData.resume(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onDestroy() { |
| | | super.onDestroy(); |
| | | if (mAdData != null) { |
| | | if (mGDTAdData != null) { |
| | | // 必须要在Actiivty.destroy()时通知到广告数据,以便释放内存 |
| | | mAdData.destroy(); |
| | | mGDTAdData.destroy(); |
| | | } |
| | | if (img_poster != null && timer != null) |
| | | img_poster.removeCallbacks(timer); |
| | |
| | | //结束播放 |
| | | public void finishPlay(); |
| | | |
| | | //没有广告填充 |
| | | public void noAd(); |
| | | |
| | | //开始播放 |
| | | public void startPlay(); |
| | | |
| | |
| | | import com.weikou.beibeivideo.ui.video.VideoCloumn1Adapter; |
| | | import com.weikou.beibeivideo.ui.video.VideoColumn2Adapter; |
| | | import com.weikou.beibeivideo.util.DimenUtils; |
| | | import com.weikou.beibeivideo.util.UserUtil; |
| | | import com.weikou.beibeivideo.util.ui.DividerItemDecoration; |
| | | import com.weikou.beibeivideo.R; |
| | | |
| | |
| | | |
| | | type = (VideoType) getArguments().getSerializable("videotype"); |
| | | |
| | | if(getArguments()!=null) |
| | | if (getArguments() != null) |
| | | getArguments().clear(); |
| | | |
| | | mHomeType = getActivity().getIntent().getStringExtra("home_type"); |
| | |
| | | mHomeType = (mHomeType == null ? "" : mHomeType); |
| | | mVideoType = (mVideoType == null ? "" : mVideoType); |
| | | mStarId = (mStarId == null ? "" : mStarId); |
| | | |
| | | |
| | | |
| | | mVideoInfos = new ArrayList<>(); |
| | |
| | | } |
| | | |
| | | private void getVideoList() { |
| | | SharedPreferences preferences = rv_category_video.getContext().getSharedPreferences( |
| | | "user", Context.MODE_PRIVATE); |
| | | String uid = preferences.getString("uid", ""); |
| | | String uid = UserUtil.getUid(rv_category_video.getContext()); |
| | | if (type == null) |
| | | return; |
| | | BeibeiVideoAPI.getVideoList(rv_category_video.getContext(), uid, mStarId, mHomeType, |
| | | type.getId(), String.valueOf(mCurrentPage), category_two + "", type.getCategoryType(), |
| | | new BasicTextHttpResponseHandler() { |
| | |
| | | |
| | | @Override |
| | | public void onClick(View v) { |
| | | TextView tv_new= view.findViewById(R.id.tv_more_new); |
| | | TextView tv_hot= view.findViewById(R.id.tv_more_hot); |
| | | TextView tv_new = view.findViewById(R.id.tv_more_new); |
| | | TextView tv_hot = view.findViewById(R.id.tv_more_hot); |
| | | |
| | | switch (v.getId()) { |
| | | case R.id.iv_videosfragment_download_failure: |
| | |
| | | import com.weikou.beibeivideo.util.BeibeiConstant; |
| | | import com.weikou.beibeivideo.util.XGPush; |
| | | import com.weikou.beibeivideo.R; |
| | | import com.weikou.beibeivideo.util.novel.NovelJNZUtil; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONException; |
| | |
| | | data.get("gender")); |
| | | edit.commit(); |
| | | |
| | | NovelJNZUtil.setUid(getApplicationContext()); |
| | | |
| | | SingleToast.showToast(LoginActivity.this, |
| | | "登录成功"); |
| | | XGPush.registerPush(LoginActivity.this); |
| | |
| | | response.getString("gender")); |
| | | edit.commit(); |
| | | |
| | | NovelJNZUtil.setUid(getApplicationContext()); |
| | | |
| | | SingleToast.showToast(LoginActivity.this, |
| | | "登录成功"); |
| | | XGPush.registerPush(LoginActivity.this); |
| | |
| | | import android.support.annotation.Nullable; |
| | | import android.support.v4.app.Fragment; |
| | | import android.support.v4.app.FragmentManager; |
| | | import android.support.v4.app.FragmentPagerAdapter; |
| | | import android.support.v4.app.FragmentStatePagerAdapter; |
| | | import android.support.v4.view.ViewPager; |
| | | import android.util.Log; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | | import android.widget.FrameLayout; |
| | | |
| | | import com.google.gson.FieldNamingPolicy; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.lcjian.library.RetainViewFragment; |
| | | import com.lcjian.library.util.cache.DiskLruCache; |
| | | import com.lcjian.library.util.common.StorageUtils; |
| | | import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator; |
| | | import com.viewpagerindicator.MTabPageIndicator; |
| | | import com.viewpagerindicator.IconPagerAdapter; |
| | | import com.viewpagerindicator.MainTabPageIndicator; |
| | | import com.weikou.beibeivideo.BasicTextHttpResponseHandler; |
| | | import com.weikou.beibeivideo.BeibeiVideoAPI; |
| | | import com.weikou.beibeivideo.R; |
| | | import com.weikou.beibeivideo.entity.VideoType; |
| | | import com.weikou.beibeivideo.entity.recommend.HomeClass; |
| | | import com.weikou.beibeivideo.ui.MyRetainViewFragment; |
| | | import com.weikou.beibeivideo.ui.dialog.UserProtocolDialog; |
| | | import com.weikou.beibeivideo.ui.recommend.NovelJNZFragment; |
| | | import com.weikou.beibeivideo.ui.recommend.RecommendFragment; |
| | | import com.weikou.beibeivideo.util.BeibeiConstant; |
| | | import com.weikou.beibeivideo.util.UserUtil; |
| | | import com.weikou.beibeivideo.R; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | |
| | | */ |
| | | |
| | | public class HomeFragment extends MyRetainViewFragment { |
| | | |
| | | private final String TAG = HomeFragment.class.getName(); |
| | | /* |
| | | * viewpager定义 |
| | | */ |
| | |
| | | getCategories(); |
| | | } |
| | | |
| | | List<VideoType> categories = new ArrayList<>(); |
| | | List<HomeClass> categories = new ArrayList<>(); |
| | | |
| | | |
| | | int count = 1; |
| | |
| | | .create(); |
| | | categories.clear(); |
| | | |
| | | List<VideoType> list = gson.fromJson( |
| | | List<HomeClass> list = gson.fromJson( |
| | | jsonObject.getJSONObject("Data") |
| | | .getJSONArray("data").toString(), |
| | | new TypeToken<List<VideoType>>() { |
| | | new TypeToken<List<HomeClass>>() { |
| | | }.getType()); |
| | | |
| | | categories.addAll(list); |
| | |
| | | }); |
| | | } |
| | | |
| | | class HomePageAdapter extends FragmentStatePagerAdapter { |
| | | class HomePageAdapter extends FragmentStatePagerAdapter implements IconPagerAdapter { |
| | | private FragmentManager fm; |
| | | |
| | | private List<VideoType> mlist; |
| | | private List<HomeClass> mlist; |
| | | |
| | | private Map<Integer, Fragment> fragments = new HashMap<>(); |
| | | private Map<String, Fragment> fragments = new HashMap<>(); |
| | | |
| | | public HomePageAdapter(FragmentManager fm, List<VideoType> list) { |
| | | public HomePageAdapter(FragmentManager fm, List<HomeClass> list) { |
| | | super(fm); |
| | | this.fm = fm; |
| | | this.mlist = list; |
| | |
| | | |
| | | @Override |
| | | public Fragment getItem(int position) { |
| | | Fragment fragment = RecommendFragment.newInstance(mlist.get(position), position + ""); |
| | | return fragment; |
| | | if ("novel".equalsIgnoreCase(mlist.get(position).getDataType())) { |
| | | return NovelJNZFragment.newInstance(); |
| | | } else { |
| | | Fragment fragment = RecommendFragment.newInstance(mlist.get(position), position + ""); |
| | | return fragment; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public int getIconResId(int index) { |
| | | if ("novel".equalsIgnoreCase(mlist.get(index).getDataType())) |
| | | return R.drawable.ic_tab_xiaoshuo; |
| | | else |
| | | return 0; |
| | | } |
| | | |
| | | @Override |
| | |
| | | @Nullable |
| | | @Override |
| | | public CharSequence getPageTitle(int position) { |
| | | return mlist.get(position).getName(); |
| | | if ("novel".equalsIgnoreCase(mlist.get(position).getDataType())) |
| | | return ""; |
| | | else |
| | | return mlist.get(position).getName(); |
| | | } |
| | | } |
| | | } |
| | |
| | | import com.weikou.beibeivideo.util.ad.manager.SearchResultAdManager; |
| | | import com.weikou.beibeivideo.R; |
| | | import com.yeshi.ec.library_baiducpu.fragment.BaiDuNewsFragment; |
| | | import com.yeshi.ec.library_baiducpu.fragment.BaiDuVideosFragment; |
| | | import com.ysh.wpc.appupdate.AppUpdate; |
| | | |
| | | import org.apache.http.Header; |
| | |
| | | mFragmentSwitchHelper = FragmentSwitchHelper.create( |
| | | R.id.fl_main_fragment_container, getSupportFragmentManager(), |
| | | new HomeFragment(), new CategoryFragment(), |
| | | new BaiDuNewsFragment(), new MineFragment(), new GuessLikeFragment()); |
| | | new BaiDuNewsFragment(), new MineFragment(), new BaiDuVideosFragment()); |
| | | rg_nav = findViewById(R.id.rg_nav); |
| | | rg_nav.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { |
| | | |
| | |
| | | break; |
| | | case R.id.rb_guess_like: { |
| | | mFragmentSwitchHelper |
| | | .changeFragment(GuessLikeFragment.class); |
| | | .changeFragment(BaiDuVideosFragment.class); |
| | | } |
| | | break; |
| | | case R.id.rb_nav_discover: { |
| | |
| | | import android.widget.TextView; |
| | | import android.widget.Toast; |
| | | |
| | | import com.androidquery.AQuery; |
| | | import com.bumptech.glide.Glide; |
| | | import com.iBookStar.views.YmConfig; |
| | | import com.lcjian.library.RetainViewFragment; |
| | | import com.lcjian.library.content.ConnectivityChangeHelper; |
| | | import com.lcjian.library.content.ConnectivityChangeHelper.OnConnectivityChangeListener; |
| | |
| | | |
| | | private ConnectivityChangeHelper mChangeHelper; |
| | | |
| | | private AQuery mAquery; |
| | | |
| | | private TextView tv_login;// 用户名 |
| | | private TextView tv_name; |
| | | private ImageView iv_user_logo;// 用户头像 |
| | |
| | | |
| | | @Override |
| | | public void onCreateView(View contentView, Bundle savedInstanceState) { |
| | | mAquery = new AQuery(contentView); |
| | | |
| | | tv_no_network = (TextView) contentView.findViewById(R.id.tv_no_network); |
| | | tv_no_network.setOnClickListener(this); |
| | |
| | | ll_mine_favourite.setOnClickListener(this); |
| | | ll_mine_follow.setOnClickListener(this); |
| | | ll_mine_watch_history.setOnClickListener(this); |
| | | mAquery.id(R.id.ll_mine_novel).clicked(this); |
| | | |
| | | rl_mine_about_us.setOnClickListener(this); |
| | | rl_mine_message.setOnClickListener(this); |
| | |
| | | case R.id.ll_mine_follow: |
| | | startActivity(new Intent(tv_no_network.getContext(), FollowActivity.class)); |
| | | break; |
| | | |
| | | //书架 |
| | | case R.id.ll_mine_novel: |
| | | YmConfig.openReader(); |
| | | break; |
| | | case R.id.rl_mine_message: |
| | | openMsg(); |
| | | break; |
| | |
| | | if (rv_episode.getLayoutManager() == null) |
| | | rv_episode.setLayoutManager(ms); |
| | | |
| | | |
| | | rv_episode.addItemDecoration(new SpacesItemDecoration(DimenUtils.dip2px(getContext(), 10))); |
| | | if (rv_episode.getItemDecorationCount() == 0) |
| | | rv_episode.addItemDecoration(new SpacesItemDecoration(DimenUtils.dip2px(getContext(), 10))); |
| | | } |
| | | |
| | | |
| | |
| | | public void onCreateView(View contentView, Bundle savedInstanceState) { |
| | | Log.i(TAG, "onCreateView"); |
| | | EventBus.getDefault().register(this); |
| | | mVideoInfo = (VideoInfo) getArguments() |
| | | Bundle bundle = getArguments(); |
| | | mVideoInfo = (VideoInfo) bundle |
| | | .getSerializable("video_info"); |
| | | mPlayingPosition = getArguments().getInt("playing_position"); |
| | | mStart = getArguments().getInt("start"); |
| | | mEnd = getArguments().getInt("end"); |
| | | mPlayingPosition = bundle.getInt("playing_position"); |
| | | mStart = bundle.getInt("start"); |
| | | mEnd = bundle.getInt("end"); |
| | | |
| | | if (getArguments() != null) |
| | | getArguments().clear(); |
| | | if (bundle != null) |
| | | bundle.clear(); |
| | | |
| | | //防止没有内容崩溃 |
| | | if (mVideoInfo == null) |
| | | return; |
| | | |
| | | tv_video_resource = contentView.findViewById(R.id.tv_video_resource); |
| | | ll_add_attention = contentView.findViewById(R.id.ll_add_attention); |
| | |
| | | import android.widget.ImageView; |
| | | import android.widget.LinearLayout; |
| | | import android.widget.LinearLayout.LayoutParams; |
| | | import android.widget.RelativeLayout; |
| | | import android.widget.TextView; |
| | | import android.widget.Toast; |
| | | |
| | |
| | | import com.lcjian.library.util.common.DimenUtils; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.loopj.android.http.JsonHttpResponseHandler; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.weikou.beibeivideo.BasicTextHttpResponseHandler; |
| | | import com.weikou.beibeivideo.BeibeiVideoAPI; |
| | | import com.weikou.beibeivideo.BeibeiVideoApplication; |
| | |
| | | import com.weikou.beibeivideo.entity.VideoInfo; |
| | | import com.weikou.beibeivideo.entity.VideoResource; |
| | | import com.weikou.beibeivideo.ui.BaseActivity; |
| | | import com.weikou.beibeivideo.ui.ad.VideoDetailVideoAdFragment; |
| | | import com.weikou.beibeivideo.ui.ad.PlayVideoPreADFragment; |
| | | import com.weikou.beibeivideo.ui.common.ShareActivity; |
| | | import com.weikou.beibeivideo.ui.mine.BrowserActivity; |
| | | import com.weikou.beibeivideo.ui.mine.FXBrowserActivity; |
| | | import com.weikou.beibeivideo.ui.video.VideoPlayerActivity; |
| | | import com.weikou.beibeivideo.util.BeibeiConstant; |
| | |
| | | |
| | | private FragmentManager fm = getSupportFragmentManager(); |
| | | |
| | | private VideoDetailVideoAdFragment mVideoDetailVideoAdFragment; |
| | | private PlayVideoPreADFragment mVideoDetailVideoAdFragment; |
| | | |
| | | private ImageView iv_select_play; |
| | | |
| | |
| | | /** |
| | | * 广告 |
| | | */ |
| | | mVideoDetailVideoAdFragment = new VideoDetailVideoAdFragment(); |
| | | mVideoDetailVideoAdFragment = new PlayVideoPreADFragment(); |
| | | getSupportFragmentManager().beginTransaction().replace(R.id.fl_ad, mVideoDetailVideoAdFragment).commit(); |
| | | |
| | | |
| | |
| | | return; |
| | | } |
| | | } |
| | | RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( |
| | | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( |
| | | (int) SystemCommon.getScreenWidth(this), |
| | | (int) ((SystemCommon.getScreenWidth(this) * 9) / 16)); |
| | | findViewById(R.id.fragment_video_play_container1).setLayoutParams( |
| | |
| | | iv_select_play.setVisibility(View.GONE); |
| | | |
| | | if (fl_ad.getVisibility() == View.VISIBLE && BeibeiConstant.AD_TYPE != null && BeibeiConstant.AD_TYPE.isPlayerAd()) { |
| | | mVideoDetailVideoAdFragment.loadVideoAD(new VideoDetailVideoAdFragment.IVideoAdListener() { |
| | | mVideoDetailVideoAdFragment.loadVideoAD(new PlayVideoPreADFragment.IVideoAdListener() { |
| | | @Override |
| | | public void finishPlay() { |
| | | clickPlay(); |
| | |
| | | @Override |
| | | public void startPlay() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void noAd() { |
| | | clickPlay(); |
| | | fl_ad.setVisibility(View.GONE); |
| | | } |
| | | }); |
| | | } else { |
| | |
| | | findViewById(R.id.fl_video_detail).setVisibility(View.GONE); |
| | | findViewById(R.id.v_status_bar).setVisibility(View.GONE); |
| | | setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); |
| | | android.widget.RelativeLayout.LayoutParams params = new android.widget.RelativeLayout.LayoutParams( |
| | | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( |
| | | LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); |
| | | findViewById(R.id.fragment_video_play_container1).setLayoutParams( |
| | | params); |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | findViewById(R.id.v_status_bar).setVisibility(View.VISIBLE); |
| | | android.widget.RelativeLayout.LayoutParams params = new android.widget.RelativeLayout.LayoutParams( |
| | | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( |
| | | (int) SystemCommon.getScreenWidth(this), |
| | | (int) ((SystemCommon.getScreenWidth(this) * 9) / 16)); |
| | | findViewById(R.id.fragment_video_play_container1).setLayoutParams( |
| | |
| | | import com.weikou.beibeivideo.entity.VideoInfo; |
| | | import com.weikou.beibeivideo.entity.VideoResource; |
| | | import com.weikou.beibeivideo.ui.BaseActivity; |
| | | import com.weikou.beibeivideo.ui.ad.VideoDetailVideoAdFragment; |
| | | import com.weikou.beibeivideo.ui.ad.PlayVideoPreADFragment; |
| | | import com.weikou.beibeivideo.ui.common.ShareActivity; |
| | | import com.weikou.beibeivideo.ui.video.FunshionPlayerFragment; |
| | | import com.weikou.beibeivideo.ui.video.VideoPlayerActivity; |
| | |
| | | |
| | | private FragmentManager fm = getSupportFragmentManager(); |
| | | |
| | | private VideoDetailVideoAdFragment mVideoDetailVideoAdFragment; |
| | | private PlayVideoPreADFragment mVideoDetailVideoAdFragment; |
| | | |
| | | //风行播放器 |
| | | private FunshionPlayerFragment mFunshionPlayerFragment; |
| | |
| | | } |
| | | |
| | | //广告 |
| | | mVideoDetailVideoAdFragment = new VideoDetailVideoAdFragment(); |
| | | mVideoDetailVideoAdFragment = new PlayVideoPreADFragment(); |
| | | //播放器 |
| | | mFunshionPlayerFragment = new FunshionPlayerFragment(); |
| | | |
| | |
| | | BeibeiConstant.AD_TYPE = null; |
| | | //需要加载广告 |
| | | if (BeibeiConstant.AD_TYPE != null && BeibeiConstant.AD_TYPE.isPlayerAd()) { |
| | | mVideoDetailVideoAdFragment = new VideoDetailVideoAdFragment(); |
| | | mVideoDetailVideoAdFragment = new PlayVideoPreADFragment(); |
| | | mVideoDetailVideoAdFragment.setPageEventListener(new IPageEventListener() { |
| | | @Override |
| | | public void onCreateView() { |
| | | mVideoDetailVideoAdFragment.loadVideoAD(new VideoDetailVideoAdFragment.IVideoAdListener() { |
| | | mVideoDetailVideoAdFragment.loadVideoAD(new PlayVideoPreADFragment.IVideoAdListener() { |
| | | @Override |
| | | public void finishPlay() { |
| | | getSupportFragmentManager().beginTransaction().remove(mVideoDetailVideoAdFragment); |
| | | getSupportFragmentManager().beginTransaction().remove(mVideoDetailVideoAdFragment).commit(); |
| | | clickPlay();//进入播放事件 |
| | | } |
| | | |
| | | @Override |
| | | public void startPlay() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void noAd() { |
| | | getSupportFragmentManager().beginTransaction().remove(mVideoDetailVideoAdFragment).commit(); |
| | | clickPlay();//进入播放事件 |
| | | } |
| | | }); |
| | | } |
| | |
| | | params1.height = 0; |
| | | |
| | | // Hide the status bar隐藏状态栏 |
| | | WindowManager.LayoutParams attrs = getWindow().getAttributes(); |
| | | attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN; |
| | | getWindow().setAttributes(attrs); |
| | | //测试 不做全屏 |
| | | // WindowManager.LayoutParams attrs = getWindow().getAttributes(); |
| | | // attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN; |
| | | // getWindow().setAttributes(attrs); |
| | | |
| | | Fragment videoDetailFragment = getSupportFragmentManager() |
| | | .findFragmentByTag("VideoDetailFragment"); |
New file |
| | |
| | | package com.weikou.beibeivideo.ui.recommend; |
| | | |
| | | import android.content.res.Configuration; |
| | | import android.content.res.Resources; |
| | | import android.os.Bundle; |
| | | import android.view.View; |
| | | import android.widget.FrameLayout; |
| | | |
| | | import com.iBookStar.views.YmWebView; |
| | | import com.lcjian.library.RetainViewFragment; |
| | | import com.weikou.beibeivideo.R; |
| | | |
| | | /** |
| | | * 聚能赚小说fragment |
| | | */ |
| | | public class NovelJNZFragment extends RetainViewFragment { |
| | | |
| | | private FrameLayout fl_container; |
| | | |
| | | |
| | | public static NovelJNZFragment newInstance() { |
| | | NovelJNZFragment fragment = new NovelJNZFragment(); |
| | | return fragment; |
| | | } |
| | | |
| | | @Override |
| | | public void onCreateView(View contentView, Bundle savedInstanceState) { |
| | | fl_container = contentView.findViewById(R.id.fl_container); |
| | | YmWebView wv = new YmWebView(getContext()); |
| | | fl_container.removeAllViews(); |
| | | fl_container.addView(wv); |
| | | wv.openBookStore(); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public int getContentResource() { |
| | | return R.layout.fragment_novel; |
| | | } |
| | | |
| | | @Override |
| | | public void onResume() { |
| | | super.onResume(); |
| | | } |
| | | } |
| | |
| | | import com.weikou.beibeivideo.entity.VideoInfo; |
| | | import com.weikou.beibeivideo.entity.VideoType; |
| | | import com.weikou.beibeivideo.entity.ad.ExpressAdContainer; |
| | | import com.weikou.beibeivideo.entity.recommend.HomeClass; |
| | | import com.weikou.beibeivideo.ui.category.bean.HotStar; |
| | | import com.weikou.beibeivideo.ui.mine.BrowserActivity; |
| | | import com.weikou.beibeivideo.util.BeibeiConstant; |
| | |
| | | |
| | | private Context context; |
| | | |
| | | public static Fragment newInstance(VideoType type, String position) { |
| | | if (Integer.parseInt(position) < 2) { |
| | | public static Fragment newInstance(HomeClass type, String position) { |
| | | if ("recommend".equalsIgnoreCase(type.getDataType())) { |
| | | RecommendFragment fragment = new RecommendFragment(); |
| | | Bundle bundle = new Bundle(); |
| | | bundle.putSerializable("videotype", type); |
| | |
| | | import android.content.IntentFilter; |
| | | import android.content.pm.ActivityInfo; |
| | | import android.content.res.Configuration; |
| | | import android.graphics.Bitmap; |
| | | import android.media.MediaPlayer; |
| | | import android.net.ConnectivityManager; |
| | | import android.net.NetworkInfo; |
| | |
| | | import android.view.View; |
| | | import android.view.View.OnClickListener; |
| | | import android.view.ViewGroup; |
| | | import android.widget.Button; |
| | | import android.widget.FrameLayout; |
| | | import android.widget.ImageView; |
| | | import android.widget.LinearLayout; |
| | | import android.widget.Toast; |
| | | |
| | | import com.androidquery.AQuery; |
| | | import com.androidquery.callback.AjaxStatus; |
| | | import com.androidquery.callback.BitmapAjaxCallback; |
| | | import com.bumptech.glide.Glide; |
| | | import com.fun.xm.Definition; |
| | | import com.fun.xm.FSCallback; |
| | | import com.fun.xm.FSIVideoPlayer; |
| | | import com.fun.xm.FSPlayer; |
| | | import com.fun.xm.FSVideoReqData; |
| | | import com.fun.xm.ad.FSAD; |
| | | import com.fun.xm.ad.FSSRAdData; |
| | | import com.fun.xm.ad.FSThirdAd; |
| | | import com.fun.xm.ad.adloader.FSPreMediaAdLoader; |
| | | import com.fun.xm.ad.adloader.FSSRFeedAdLoader; |
| | | import com.fun.xm.ad.adview.FSFeedAD; |
| | | import com.fun.xm.ad.adview.FSPreMediaView; |
| | | import com.fun.xm.ad.callback.FSFeedAdCallBack; |
| | | import com.fun.xm.ad.callback.FSPreMediaAdCallBack; |
| | | import com.funshion.video.logger.FSLogcat; |
| | | import com.funshion.video.util.FSError; |
| | |
| | | import com.lcjian.library.video.VideoEpisode; |
| | | import com.lcjian.library.video.VideoPlayerController; |
| | | import com.lcjian.library.widget.RatioLayout; |
| | | import com.qq.e.ads.cfg.VideoOption; |
| | | import com.qq.e.ads.nativ.MediaView; |
| | | import com.qq.e.ads.nativ.NativeADMediaListener; |
| | | import com.qq.e.ads.nativ.NativeUnifiedADData; |
| | | import com.qq.e.comm.constants.AdPatternType; |
| | | import com.qq.e.comm.util.AdError; |
| | | import com.weikou.beibeivideo.BasicTextHttpResponseHandler; |
| | | import com.weikou.beibeivideo.BeibeiVideoAPI; |
| | | import com.weikou.beibeivideo.BeibeiVideoApplication; |
| | |
| | | import com.weikou.beibeivideo.entity.VideoDetailInfo; |
| | | import com.weikou.beibeivideo.entity.VideoInfo; |
| | | import com.weikou.beibeivideo.entity.VideoResource; |
| | | import com.weikou.beibeivideo.entity.ad.PlayVideoPreADSetting; |
| | | import com.weikou.beibeivideo.entity.video.FunshionPlayInfo; |
| | | import com.weikou.beibeivideo.ui.ad.PlayVideoPreADFragment; |
| | | import com.weikou.beibeivideo.util.DimenUtils; |
| | | import com.weikou.beibeivideo.util.FunshionConstant; |
| | | import com.weikou.beibeivideo.util.UserUtil; |
| | |
| | | private FrameLayout fl_container, fl_ad; |
| | | |
| | | //风行广告加载器 |
| | | private FSPreMediaAdLoader fsPreMediaAdLoader; |
| | | private FSSRFeedAdLoader fssrFeedAdLoader; |
| | | |
| | | private FSPreMediaView mFSVideoAD; |
| | | |
| | |
| | | |
| | | private void initAd() { |
| | | FSAD.init(getContext().getApplicationContext(), Collections.singletonList(FunshionConstant.AD_ADP), FunshionConstant.AD_PARTENER, FunshionConstant.AD_TOKEN, FunshionConstant.AD_CHANNEL, FunshionConstant.AD_PRE_DOWNLOAD_CHANNEL); |
| | | fsPreMediaAdLoader = new FSPreMediaAdLoader(getContext(), FunshionConstant.AD_CHANNEL); |
| | | fssrFeedAdLoader = new FSSRFeedAdLoader(getContext(), FunshionConstant.AD_CHANNEL); |
| | | } |
| | | |
| | | private void loadAD() { |
| | |
| | | int width = fl_ad.getWidth(); |
| | | int height = fl_ad.getHeight(); |
| | | Log.i(TAG, String.format("fl_ad: width:%s height:%s", width, height)); |
| | | fsPreMediaAdLoader.loadAD(adid, "", width, height, true, false, new FSPreMediaAdCallBack() { |
| | | @Override |
| | | public void onCreate(FSPreMediaView fsadView) { |
| | | mFSVideoAD = fsadView; |
| | | fl_ad.removeAllViews(); |
| | | fl_ad.addView(fsadView); |
| | | } |
| | | |
| | | @Override |
| | | public void onCreateThirdAD(List<FSThirdAd> fsThirdAd) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onClose() { |
| | | adShowFinish(); |
| | | } |
| | | |
| | | @Override |
| | | public void onADLoad() { |
| | | if (null != mFSVideoAD) { |
| | | mFSVideoAD.showAD(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onVideoComplete() { |
| | | adShowFinish(); |
| | | } |
| | | |
| | | @Override |
| | | public void onADShow() { |
| | | |
| | | } |
| | | fssrFeedAdLoader.loadAD(adid, "", width, height, true, false, new FSFeedAdCallBack() { |
| | | |
| | | @Override |
| | | public void onClick() { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void onAdLoadedFail(int param1Int, String param1String) { |
| | | Log.v(TAG, "onAdLoadedFail param1Int:" + param1Int + " MSG:" + param1String); |
| | | adShowFinish(); |
| | | public void onAdLoadedFail(int i, String s) { |
| | | Log.i(TAG,"onAdLoadedFail:"+s); |
| | | } |
| | | |
| | | @Override |
| | | public void onCreate(FSFeedAD fsADView) { |
| | | Log.i(TAG,"onCreate"); |
| | | NativeUnifiedADData gdtad = fsADView.getAd(); |
| | | FSSRAdData fsad = fsADView.getFSAd(); |
| | | if (null != gdtad) { |
| | | //广点通数据自渲染 |
| | | initGDTSelfRenderView(fsADView, gdtad); |
| | | } |
| | | if (null != fsad) { |
| | | //风行数据自渲染 |
| | | initFSSelfRenderView(fsADView, fsad); |
| | | } |
| | | if (fsADView.getParent() != null) { |
| | | ((ViewGroup) fsADView.getParent()).removeAllViews(); |
| | | } |
| | | fl_ad.removeAllViews(); |
| | | fl_ad.addView(fsADView); |
| | | fsADView.render(); |
| | | } |
| | | |
| | | @Override |
| | | public void onCreateThirdAD(List<FSThirdAd> list) { |
| | | Log.i(TAG,"onCreateThirdAD"); |
| | | } |
| | | |
| | | @Override |
| | | public void onADShow() { |
| | | Log.i(TAG,"onADShow"); |
| | | } |
| | | }); |
| | | |
| | | |
| | | } |
| | | |
| | | private void initFSSelfRenderView(final FSFeedAD fsADView, FSSRAdData fsad) { |
| | | if (fsad.isImage()) { |
| | | ImageView imageView = new ImageView(getContext()); |
| | | Glide.with(this).load(fsad.getMaterial()).into(imageView); |
| | | List<View> clickableViews = new ArrayList<>(); |
| | | clickableViews.add(imageView); |
| | | fsADView.bindAdToView(imageView, clickableViews, null); |
| | | } else if (fsad.isVideo()) { |
| | | MediaView mediaView = new MediaView(getContext()); |
| | | fsADView.bindMediaView(mediaView, null, null); |
| | | |
| | | final Button button = new Button(getContext()); |
| | | button.setText("打开声音"); |
| | | button.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | if (fsADView.isMute()) { |
| | | fsADView.setMute(false); |
| | | button.setText("关闭声音"); |
| | | } else { |
| | | fsADView.setMute(true); |
| | | button.setText("打开声音"); |
| | | } |
| | | } |
| | | }); |
| | | List<View> clickableViews = new ArrayList<>(); |
| | | fsADView.bindAdToView(button, clickableViews, null); |
| | | } |
| | | } |
| | | |
| | | |
| | | //广点通广告控件 |
| | | protected AQuery mAQuery; |
| | | protected Button mDownloadButton; |
| | | protected MediaView mMediaView; |
| | | protected ImageView mImagePoster; |
| | | protected LinearLayout mNative3imgAdContainer; |
| | | |
| | | //自渲染view |
| | | private void initGDTSelfRenderView(FSFeedAD fsADView, NativeUnifiedADData ad) { |
| | | View mContainer = getLayoutInflater().inflate(R.layout.sr_gdt_ad_view, null); |
| | | mDownloadButton = mContainer.findViewById(R.id.btn_download); |
| | | mMediaView = mContainer.findViewById(R.id.gdt_media_view); |
| | | mImagePoster = mContainer.findViewById(R.id.img_poster); |
| | | mNative3imgAdContainer = mContainer.findViewById(R.id.native_3img_ad_container); |
| | | mAQuery = new AQuery(mContainer); |
| | | int patternType = ad.getAdPatternType(); |
| | | if (patternType == AdPatternType.NATIVE_VIDEO) { |
| | | ViewGroup.LayoutParams params = mContainer.getLayoutParams(); |
| | | if (null == params) { |
| | | params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); |
| | | } else { |
| | | params.height = FrameLayout.LayoutParams.MATCH_PARENT; |
| | | } |
| | | mContainer.setLayoutParams(params); |
| | | |
| | | } |
| | | if (patternType == AdPatternType.NATIVE_2IMAGE_2TEXT |
| | | || patternType == AdPatternType.NATIVE_VIDEO) { |
| | | mAQuery.id(R.id.img_poster).visibility(View.VISIBLE); |
| | | mAQuery.id(R.id.img_logo).image(ad.getIconUrl(), false, true); |
| | | Log.v(TAG, "Imgurl:" + ad.getImgUrl()); |
| | | mAQuery.id(R.id.img_poster).image(ad.getImgUrl(), false, true, 0, 0, |
| | | new BitmapAjaxCallback() { |
| | | @Override |
| | | protected void callback(String url, ImageView iv, Bitmap bm, AjaxStatus status) { |
| | | if (iv.getVisibility() == View.VISIBLE) { |
| | | iv.setImageBitmap(bm); |
| | | } |
| | | } |
| | | }); |
| | | mAQuery.id(R.id.text_title).textColor(R.color.colorAccent); |
| | | mAQuery.id(R.id.text_title).text(ad.getTitle()); |
| | | mAQuery.id(R.id.text_desc).text(ad.getDesc()); |
| | | } else if (patternType == AdPatternType.NATIVE_3IMAGE) { |
| | | mAQuery.id(R.id.img_1).image(ad.getImgList().get(0), false, true); |
| | | mAQuery.id(R.id.img_2).image(ad.getImgList().get(1), false, true); |
| | | mAQuery.id(R.id.img_3).image(ad.getImgList().get(2), false, true); |
| | | mAQuery.id(R.id.native_3img_title).text(ad.getTitle()); |
| | | mAQuery.id(R.id.native_3img_desc).text(ad.getDesc()); |
| | | } else if (patternType == AdPatternType.NATIVE_1IMAGE_2TEXT) { |
| | | mAQuery.id(R.id.img_logo).image(ad.getImgUrl(), false, true); |
| | | mAQuery.id(R.id.img_poster).clear(); |
| | | mAQuery.id(R.id.text_title).text(ad.getTitle()); |
| | | mAQuery.id(R.id.text_desc).text(ad.getDesc()); |
| | | } |
| | | |
| | | List<View> clickableViews = new ArrayList<>(); |
| | | List<View> customClickableViews = new ArrayList<>(); |
| | | // 所有广告类型,注册mDownloadButton的点击事件 |
| | | clickableViews.add(mDownloadButton); |
| | | if (ad.getAdPatternType() == AdPatternType.NATIVE_2IMAGE_2TEXT || |
| | | ad.getAdPatternType() == AdPatternType.NATIVE_1IMAGE_2TEXT) { |
| | | // 双图双文、单图双文:注册mImagePoster的点击事件 |
| | | clickableViews.add(mImagePoster); |
| | | } else if (ad.getAdPatternType() != AdPatternType.NATIVE_VIDEO) { |
| | | // 三小图广告:注册native_3img_ad_container的点击事件 |
| | | clickableViews.add(mNative3imgAdContainer); |
| | | } |
| | | //作为customClickableViews传入,点击不进入详情页,直接下载或进入落地页,只有视频广告生效, |
| | | // 如果是图文,clickableViews和customClickableViews点击逻辑一致 |
| | | fsADView.bindAdToView(mContainer, clickableViews, mDownloadButton); |
| | | |
| | | if (ad.getAdPatternType() == AdPatternType.NATIVE_VIDEO) { |
| | | // 视频广告,注册mMediaView的点击事件 |
| | | fsADView.post(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | Log.v(TAG, "showAd type video 2"); |
| | | mImagePoster.setVisibility(View.GONE); |
| | | mMediaView.setVisibility(View.VISIBLE); |
| | | // ad.startVideo(); |
| | | } |
| | | }); |
| | | |
| | | VideoOption.Builder builder = new VideoOption.Builder(); |
| | | |
| | | builder.setAutoPlayPolicy(VideoOption.AutoPlayPolicy.ALWAYS); |
| | | builder.setAutoPlayMuted(false); |
| | | builder.setDetailPageMuted(false); |
| | | builder.setNeedCoverImage(true); |
| | | builder.setNeedProgressBar(true); |
| | | builder.setEnableDetailPage(true); |
| | | builder.setEnableUserControl(false); |
| | | VideoOption videoOption = builder.build(); |
| | | fsADView.bindMediaView(mMediaView, videoOption, new NativeADMediaListener() { |
| | | @Override |
| | | public void onVideoInit() { |
| | | Log.d(TAG, "onVideoInit: "); |
| | | } |
| | | |
| | | @Override |
| | | public void onVideoLoading() { |
| | | Log.d(TAG, "onVideoLoading: "); |
| | | } |
| | | |
| | | @Override |
| | | public void onVideoReady() { |
| | | Log.d(TAG, "onVideoReady"); |
| | | } |
| | | |
| | | @Override |
| | | public void onVideoLoaded(int videoDuration) { |
| | | Log.d(TAG, "onVideoLoaded: "); |
| | | } |
| | | |
| | | @Override |
| | | public void onVideoStart() { |
| | | Log.d(TAG, "onVideoStart"); |
| | | } |
| | | |
| | | @Override |
| | | public void onVideoStop() { |
| | | Log.d(TAG, "onVideoStop"); |
| | | } |
| | | |
| | | @Override |
| | | public void onVideoPause() { |
| | | Log.d(TAG, "onVideoPause: "); |
| | | } |
| | | |
| | | @Override |
| | | public void onVideoResume() { |
| | | Log.d(TAG, "onVideoResume: "); |
| | | } |
| | | |
| | | @Override |
| | | public void onVideoClicked() { |
| | | Log.d(TAG, "onVideoClicked"); |
| | | } |
| | | |
| | | @Override |
| | | public void onVideoCompleted() { |
| | | Log.d(TAG, "onVideoCompleted: "); |
| | | } |
| | | |
| | | @Override |
| | | public void onVideoError(AdError error) { |
| | | |
| | | } |
| | | |
| | | }); |
| | | ad.startVideo(); |
| | | } else if (ad.getAdPatternType() == AdPatternType.NATIVE_2IMAGE_2TEXT || |
| | | ad.getAdPatternType() == AdPatternType.NATIVE_1IMAGE_2TEXT) { |
| | | // 双图双文、单图双文:注册mImagePoster的点击事件 |
| | | clickableViews.add(mImagePoster); |
| | | } else { |
| | | // 三小图广告:注册native_3img_ad_container的点击事件 |
| | | clickableViews.add(mNative3imgAdContainer); |
| | | } |
| | | } |
| | | |
| | | |
| | | //广告展示完成 |
| | | private void adShowFinish() { |
| | |
| | | vpc_funshion.setNetworkInfo(networkInfo, false); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | import android.app.Activity; |
| | | import android.app.Dialog; |
| | | import android.content.Context; |
| | | import android.content.DialogInterface; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.widget.FrameLayout; |
| | |
| | | params.height = android.view.WindowManager.LayoutParams.WRAP_CONTENT; |
| | | dialog.getWindow().setAttributes(params); |
| | | dialog.setCanceledOnTouchOutside(false); |
| | | dialog.setOnDismissListener(new OnDismissListener() { |
| | | @Override |
| | | public void onDismiss(DialogInterface dialog) { |
| | | fl_advertisement.removeAllViews(); |
| | | } |
| | | }); |
| | | return dialog; |
| | | } |
| | | |
| | |
| | | String uid = preferences.getString("uid", ""); |
| | | return uid; |
| | | } |
| | | |
| | | public static String getLoginUid(Context context) { |
| | | SharedPreferences preferences = context.getSharedPreferences("user", MODE_PRIVATE); |
| | | String uid = preferences.getString("LoginUid", ""); |
| | | return uid; |
| | | } |
| | | } |
| | |
| | | public static String SPLASH_AD = "887360667"; |
| | | |
| | | //软件退出广告 |
| | | public static String APP_EXIT="945469133"; |
| | | public static String APP_EXIT = "945469133"; |
| | | |
| | | //视频前贴 |
| | | public static String PLAY_VIDEO_PRE = "887389927"; |
| | | |
| | | //无效广告 |
| | | public static String INVALID_AD = "111111111"; |
| | | |
| | | } |
| | |
| | | import com.alibaba.baichuan.android.trade.model.OpenType; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.google.gson.Gson; |
| | | import com.iBookStar.views.YmConfig; |
| | | import com.lcjian.library.util.SystemCommon; |
| | | import com.lcjian.library.util.common.ClipboardUtil; |
| | | import com.lcjian.library.util.common.PackageUtils2; |
| | |
| | | params.put("Package", mContext.getPackageName()); |
| | | params.put("Version", version + ""); |
| | | params.put("Device", SystemCommon.getDeviceId(mContext)); |
| | | params.put("Time",System.currentTimeMillis()+""); |
| | | params.put("Time", System.currentTimeMillis() + ""); |
| | | LinkedHashMap<String, String> map = BeibeiVideoAPI.validateParams(params, mContext); |
| | | |
| | | Gson gson = new Gson(); |
| | |
| | | public void clearClipboard() { |
| | | ClipboardUtil.emptyClipboard(mContext); |
| | | } |
| | | |
| | | |
| | | //进入小说 |
| | | @JavascriptInterface |
| | | public void openNovel() { |
| | | YmConfig.openReader(); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.weikou.beibeivideo.util.novel; |
| | | |
| | | import android.content.Context; |
| | | |
| | | import com.iBookStar.views.YmConfig; |
| | | import com.weikou.beibeivideo.util.UserUtil; |
| | | import com.weikou.beibeivideo.util.downutil.StringUtils; |
| | | |
| | | public class NovelJNZUtil { |
| | | |
| | | public static void setUid(Context context) { |
| | | String uid = UserUtil.getLoginUid(context); |
| | | if (!StringUtils.isNullOrEmpty(uid)) |
| | | YmConfig.setOutUserId(uid); |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.ec.library_baiducpu.adapter; |
| | | |
| | | import android.content.Context; |
| | | import android.support.annotation.NonNull; |
| | | import android.support.v7.widget.RecyclerView; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | | import android.widget.RelativeLayout; |
| | | |
| | | import com.androidquery.AQuery; |
| | | import com.baidu.mobads.nativecpu.IBasicCPUData; |
| | | import com.yeshi.ec.library_baiducpu.R; |
| | | import com.yeshi.ec.library_baiducpu.entity.NativeCPUView; |
| | | import com.yeshi.ec.library_baiducpu.entity.NativeSmallVideoCPUView; |
| | | import com.yeshi.ec.library_baiducpu.entity.NativeVideoCPUView; |
| | | import com.yeshi.ec.library_baiducpu.fragment.BaiDuCPUContentFragment; |
| | | |
| | | import java.util.List; |
| | | |
| | | public class BaiduCPUContentAdapter extends RecyclerView.Adapter { |
| | | |
| | | private LayoutInflater inflater; |
| | | private AQuery aq; |
| | | private View footerView; |
| | | |
| | | private Context mContext; |
| | | |
| | | private List<IBasicCPUData> nrAdList; |
| | | |
| | | private final int TYPE_FOOTER = 1; |
| | | private final int TYPE_CONTENT = 2; |
| | | private int viewType; |
| | | |
| | | public BaiduCPUContentAdapter(Context context, int viewType, List<IBasicCPUData> nrAdList) { |
| | | inflater = LayoutInflater.from(context); |
| | | aq = new AQuery(context); |
| | | this.nrAdList = nrAdList; |
| | | this.mContext = context; |
| | | this.viewType = viewType; |
| | | } |
| | | |
| | | public void setFooterView(View footerView) { |
| | | this.footerView = footerView; |
| | | } |
| | | |
| | | |
| | | @NonNull |
| | | @Override |
| | | public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { |
| | | if (viewType == TYPE_CONTENT) |
| | | return new ViewHolder(inflater.inflate(R.layout.item_baidu_news, null, false)); |
| | | else |
| | | return new FooterViewHolder(footerView); |
| | | } |
| | | |
| | | @Override |
| | | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { |
| | | if (holder instanceof ViewHolder) { |
| | | ViewHolder viewHolder = (ViewHolder) holder; |
| | | final IBasicCPUData nrAd = nrAdList.get(position); |
| | | if (viewType == BaiDuCPUContentFragment.VIEW_TYPE_NEWS) { |
| | | NativeCPUView cpuView = new NativeCPUView(mContext); |
| | | if (cpuView.getParent() != null) { |
| | | ((ViewGroup) cpuView.getParent()).removeView(cpuView); |
| | | } |
| | | cpuView.setItemData(nrAd, aq); |
| | | viewHolder.rl_container.removeAllViews(); |
| | | viewHolder.rl_container.addView(cpuView); |
| | | nrAd.onImpression(viewHolder.view); |
| | | } else if (viewType == BaiDuCPUContentFragment.VIEW_TYPE_SMALLVIDEO) { |
| | | NativeSmallVideoCPUView cpuView = new NativeSmallVideoCPUView(mContext); |
| | | if (cpuView.getParent() != null) { |
| | | ((ViewGroup) cpuView.getParent()).removeView(cpuView); |
| | | } |
| | | cpuView.setItemData(nrAd, aq); |
| | | viewHolder.rl_container.removeAllViews(); |
| | | viewHolder.rl_container.addView(cpuView); |
| | | nrAd.onImpression(viewHolder.view); |
| | | } else if (viewType == BaiDuCPUContentFragment.VIEW_TYPE_VIDEO) { |
| | | NativeVideoCPUView cpuView = new NativeVideoCPUView(mContext); |
| | | if (cpuView.getParent() != null) { |
| | | ((ViewGroup) cpuView.getParent()).removeView(cpuView); |
| | | } |
| | | cpuView.setItemData(nrAd, aq); |
| | | viewHolder.rl_container.removeAllViews(); |
| | | viewHolder.rl_container.addView(cpuView); |
| | | nrAd.onImpression(viewHolder.view); |
| | | } |
| | | |
| | | viewHolder.view.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View view) { |
| | | nrAd.handleClick(view); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public int getItemCount() { |
| | | int count = nrAdList.size(); |
| | | if (footerView != null) |
| | | count++; |
| | | return count; |
| | | } |
| | | |
| | | @Override |
| | | public int getItemViewType(int position) { |
| | | if (position >= nrAdList.size()) |
| | | return TYPE_FOOTER; |
| | | else |
| | | return TYPE_CONTENT; |
| | | } |
| | | |
| | | class ViewHolder extends RecyclerView.ViewHolder { |
| | | RelativeLayout rl_container; |
| | | View view; |
| | | |
| | | public ViewHolder(View itemView) { |
| | | super(itemView); |
| | | view = itemView; |
| | | rl_container = itemView.findViewById(R.id.native_outer_view); |
| | | } |
| | | } |
| | | |
| | | class FooterViewHolder extends RecyclerView.ViewHolder { |
| | | public FooterViewHolder(View itemView) { |
| | | super(itemView); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | import com.androidquery.callback.BitmapAjaxCallback; |
| | | import com.baidu.mobads.nativecpu.IBasicCPUData; |
| | | import com.bumptech.glide.Glide; |
| | | import com.bumptech.glide.request.RequestOptions; |
| | | import com.yeshi.ec.library_baiducpu.R; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | |
| | | // } |
| | | // }); |
| | | |
| | | Glide.with(view.getContext()).load(data).transition(withCrossFade()).into( aq.id(view).getImageView()); |
| | | Glide.with(view.getContext()).load(data).apply(new RequestOptions().centerCrop().placeholder(R.color.img_bg)).transition(withCrossFade()).into( aq.id(view).getImageView()); |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.ec.library_baiducpu.entity; |
| | | |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.net.Uri; |
| | | import android.util.AttributeSet; |
| | | import android.util.Log; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.widget.ImageView; |
| | | import android.widget.LinearLayout; |
| | | import android.widget.RelativeLayout; |
| | | import android.widget.TextView; |
| | | |
| | | import com.androidquery.AQuery; |
| | | import com.baidu.mobads.nativecpu.IBasicCPUData; |
| | | import com.bumptech.glide.Glide; |
| | | import com.google.gson.Gson; |
| | | import com.lcjian.library.util.glide.GlideCircleTransform; |
| | | import com.yeshi.ec.library_baiducpu.R; |
| | | |
| | | import static com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade; |
| | | |
| | | public class NativeSmallVideoCPUView extends RelativeLayout { |
| | | |
| | | private final String TAG="NativeSmallVideoCPUView"; |
| | | |
| | | private final static long TIME_SECOND_YEAR = 365 * 24 * 60 * 60; |
| | | private final static long TIME_SECOND_MONTH = 30 * 24 * 60 * 60; |
| | | private final static long TIME_SECOND_DAY = 24 * 60 * 60; |
| | | private final static long TIME_SECOND_HOUR = 60 * 60; |
| | | private final static long TIME_SECOND_MINUTE = 60; |
| | | |
| | | private View mContainer; |
| | | private ImageView iv_video_pciture; |
| | | private LinearLayout ll_author_info, ll_ad_info; |
| | | private TextView tv_title; |
| | | private ImageView iv_portrait; |
| | | private TextView tv_play_count; |
| | | |
| | | |
| | | private String mType; // news,image,video,ad |
| | | private String mTitle; |
| | | |
| | | public NativeSmallVideoCPUView(Context context) { |
| | | this(context, null); |
| | | } |
| | | |
| | | public NativeSmallVideoCPUView(Context context, AttributeSet attrs) { |
| | | this(context, attrs, 0); |
| | | } |
| | | |
| | | public NativeSmallVideoCPUView(Context context, AttributeSet attrs, int defStyleAttr) { |
| | | super(context, attrs, defStyleAttr); |
| | | initView(context, attrs); |
| | | } |
| | | |
| | | private void initView(Context context, AttributeSet attrs) { |
| | | LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); |
| | | mContainer = inflater.inflate(R.layout.item_baidu_small_video, this, true); |
| | | iv_video_pciture = mContainer.findViewById(R.id.iv_video_pciture); |
| | | ll_author_info = mContainer.findViewById(R.id.ll_author_info); |
| | | ll_ad_info = mContainer.findViewById(R.id.ll_ad_info); |
| | | tv_title = mContainer.findViewById(R.id.tv_title); |
| | | iv_portrait = mContainer.findViewById(R.id.iv_portrait); |
| | | tv_play_count = mContainer.findViewById(R.id.tv_play_count); |
| | | } |
| | | |
| | | public void setItemData(final IBasicCPUData data, AQuery aq) { |
| | | if (data != null) { |
| | | mType = data.getType(); // news,image,video,ad |
| | | mTitle = data.getTitle(); |
| | | //展示广告图片 |
| | | |
| | | Log.i(TAG,"logo:"+data.getBaiduLogoUrl()); |
| | | Log.i(TAG,"thumbUrl:"+data.getThumbUrl()); |
| | | Log.i(TAG,"getImageUrls:"+new Gson().toJson(data.getImageUrls())); |
| | | Log.i(TAG,"getSmallImageUrls:"+new Gson().toJson(data.getSmallImageUrls())); |
| | | Log.i(TAG,"getExtra:"+new Gson().toJson(data.getExtra())); |
| | | |
| | | tv_title.setText(data.getTitle()); |
| | | if ("ad".equalsIgnoreCase(mType)) { |
| | | ll_ad_info.setVisibility(VISIBLE); |
| | | ll_author_info.setVisibility(GONE); |
| | | ll_ad_info.setOnClickListener(new OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | // show app privacy |
| | | startActivityForUrl(data.getAppPrivacyUrl()); |
| | | } |
| | | }); |
| | | ll_ad_info.setOnClickListener(new OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | // show app permission list |
| | | startActivityForUrl(data.getAppPermissionUrl()); |
| | | } |
| | | }); |
| | | Glide.with(getContext()).load(data.getImageUrls().get(0)).transition(withCrossFade()).into(iv_video_pciture); |
| | | } else { |
| | | |
| | | ll_ad_info.setVisibility(GONE); |
| | | ll_author_info.setVisibility(VISIBLE); |
| | | if ("smallvideo".equalsIgnoreCase(mType)) { |
| | | Glide.with(getContext()).load(data.getVUrl()).transition(withCrossFade()).into(iv_video_pciture); |
| | | Glide.with(getContext()).load(data.getIconUrl()).transform(new GlideCircleTransform(getContext())).transition(withCrossFade()).into(iv_portrait); |
| | | tv_play_count.setText(getFormatPlayCounts(data.getPlayCounts())); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | private String getFormatPlayCounts(int playCounts) { |
| | | StringBuilder sb = new StringBuilder(""); |
| | | if (playCounts < 0) { |
| | | sb.append(0); |
| | | } else if (playCounts < 10000) { |
| | | sb.append(playCounts); |
| | | } else { |
| | | sb.append(playCounts / 10000); |
| | | int remain = playCounts % 10000; |
| | | if (remain > 0) { |
| | | sb.append(".").append(remain / 1000); |
| | | } |
| | | sb.append("万"); |
| | | } |
| | | sb.append("次播放"); |
| | | return sb.toString(); |
| | | } |
| | | |
| | | private void startActivityForUrl(String url) { |
| | | try { |
| | | Intent intent = new Intent(); |
| | | intent.setData(Uri.parse(url)); |
| | | intent.setAction(Intent.ACTION_VIEW); |
| | | getContext().startActivity(intent); |
| | | } catch (Throwable tr) { |
| | | Log.e("NativeCPUView", "Show url error: " + tr.getMessage()); |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.yeshi.ec.library_baiducpu.entity; |
| | | |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.net.Uri; |
| | | import android.util.AttributeSet; |
| | | import android.util.Log; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.widget.ImageView; |
| | | import android.widget.LinearLayout; |
| | | import android.widget.RelativeLayout; |
| | | import android.widget.TextView; |
| | | |
| | | import com.androidquery.AQuery; |
| | | import com.baidu.mobads.nativecpu.IBasicCPUData; |
| | | import com.bumptech.glide.Glide; |
| | | import com.bumptech.glide.request.RequestOptions; |
| | | import com.lcjian.library.util.glide.GlideCircleTransform; |
| | | import com.yeshi.ec.library_baiducpu.R; |
| | | |
| | | import static com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade; |
| | | |
| | | public class NativeVideoCPUView extends RelativeLayout { |
| | | |
| | | private final static long TIME_SECOND_YEAR = 365 * 24 * 60 * 60; |
| | | private final static long TIME_SECOND_MONTH = 30 * 24 * 60 * 60; |
| | | private final static long TIME_SECOND_DAY = 24 * 60 * 60; |
| | | private final static long TIME_SECOND_HOUR = 60 * 60; |
| | | private final static long TIME_SECOND_MINUTE = 60; |
| | | |
| | | private View mContainer; |
| | | private ImageView iv_video_pciture; |
| | | private LinearLayout ll_author_info, ll_ad_info; |
| | | private TextView tv_title; |
| | | private ImageView iv_portrait; |
| | | private TextView tv_name; |
| | | private ImageView iv_baidu_logo; |
| | | private ImageView iv_play; |
| | | |
| | | |
| | | private String mType; // news,image,video,ad |
| | | private String mTitle; |
| | | |
| | | public NativeVideoCPUView(Context context) { |
| | | this(context, null); |
| | | } |
| | | |
| | | public NativeVideoCPUView(Context context, AttributeSet attrs) { |
| | | this(context, attrs, 0); |
| | | } |
| | | |
| | | public NativeVideoCPUView(Context context, AttributeSet attrs, int defStyleAttr) { |
| | | super(context, attrs, defStyleAttr); |
| | | initView(context, attrs); |
| | | } |
| | | |
| | | private void initView(Context context, AttributeSet attrs) { |
| | | LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); |
| | | mContainer = inflater.inflate(R.layout.item_baidu_video, this, true); |
| | | iv_video_pciture = mContainer.findViewById(R.id.iv_video_pciture); |
| | | ll_author_info = mContainer.findViewById(R.id.ll_author_info); |
| | | ll_ad_info = mContainer.findViewById(R.id.ll_ad_info); |
| | | tv_title = mContainer.findViewById(R.id.tv_title); |
| | | iv_portrait = mContainer.findViewById(R.id.iv_portrait); |
| | | tv_name = mContainer.findViewById(R.id.tv_name); |
| | | iv_baidu_logo = mContainer.findViewById(R.id.iv_baidu_logo); |
| | | iv_play = mContainer.findViewById(R.id.iv_play); |
| | | } |
| | | |
| | | public void setItemData(final IBasicCPUData data, AQuery aq) { |
| | | if (data != null) { |
| | | mType = data.getType(); // news,image,video,ad |
| | | mTitle = data.getTitle(); |
| | | //展示广告图片 |
| | | |
| | | tv_title.setText(data.getTitle()); |
| | | if ("ad".equalsIgnoreCase(mType)) { |
| | | iv_play.setVisibility(View.GONE); |
| | | ll_ad_info.setVisibility(VISIBLE); |
| | | ll_author_info.setVisibility(GONE); |
| | | Glide.with(getContext()).load(data.getImageUrls().get(0)).apply(new RequestOptions().centerCrop().placeholder(R.color.img_bg)).transition(withCrossFade()).into(iv_video_pciture); |
| | | Glide.with(getContext()).load(data.getBaiduLogoUrl()).apply(new RequestOptions().centerCrop().placeholder(R.color.img_bg)).transition(withCrossFade()).into(iv_baidu_logo); |
| | | |
| | | ll_ad_info.setOnClickListener(new OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | // show app privacy |
| | | startActivityForUrl(data.getAppPrivacyUrl()); |
| | | } |
| | | }); |
| | | ll_ad_info.setOnClickListener(new OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | // show app permission list |
| | | startActivityForUrl(data.getAppPermissionUrl()); |
| | | } |
| | | }); |
| | | } else { |
| | | iv_play.setVisibility(View.VISIBLE); |
| | | ll_ad_info.setVisibility(GONE); |
| | | ll_author_info.setVisibility(VISIBLE); |
| | | if ("video".equalsIgnoreCase(mType)) { |
| | | Glide.with(getContext()).load(data.getThumbUrl()).transition(withCrossFade()).apply(new RequestOptions().centerCrop().placeholder(R.color.img_bg)).into(iv_video_pciture); |
| | | Glide.with(getContext()).load(data.getIconUrl()).apply(new RequestOptions().centerCrop()).transform(new GlideCircleTransform(getContext())).transition(withCrossFade()).into(iv_portrait); |
| | | tv_name.setText(data.getAuthor()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | private String getFormatPlayCounts(int playCounts) { |
| | | StringBuilder sb = new StringBuilder(""); |
| | | if (playCounts < 0) { |
| | | sb.append(0); |
| | | } else if (playCounts < 10000) { |
| | | sb.append(playCounts); |
| | | } else { |
| | | sb.append(playCounts / 10000); |
| | | int remain = playCounts % 10000; |
| | | if (remain > 0) { |
| | | sb.append(".").append(remain / 1000); |
| | | } |
| | | sb.append("万"); |
| | | } |
| | | sb.append("次播放"); |
| | | return sb.toString(); |
| | | } |
| | | |
| | | private void startActivityForUrl(String url) { |
| | | try { |
| | | Intent intent = new Intent(); |
| | | intent.setData(Uri.parse(url)); |
| | | intent.setAction(Intent.ACTION_VIEW); |
| | | getContext().startActivity(intent); |
| | | } catch (Throwable tr) { |
| | | Log.e("NativeCPUView", "Show url error: " + tr.getMessage()); |
| | | } |
| | | } |
| | | } |
File was renamed from library-BaiduCPU/src/main/java/com/yeshi/ec/library_baiducpu/fragment/BaiDuNewsContentFragment.java |
| | |
| | | package com.yeshi.ec.library_baiducpu.fragment; |
| | | |
| | | import android.content.Context; |
| | | import android.graphics.Canvas; |
| | | import android.graphics.Color; |
| | | import android.graphics.Rect; |
| | | import android.os.Bundle; |
| | | import android.support.annotation.NonNull; |
| | | import android.support.v4.widget.SwipeRefreshLayout; |
| | | import android.support.v7.widget.GridLayoutManager; |
| | | import android.support.v7.widget.LinearLayoutManager; |
| | | import android.support.v7.widget.RecyclerView; |
| | | import android.util.Log; |
| | | import android.view.Gravity; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | | import android.widget.RelativeLayout; |
| | | import android.widget.TextView; |
| | | |
| | | import com.androidquery.AQuery; |
| | | import com.baidu.mobad.feeds.RequestParameters; |
| | | import com.baidu.mobads.nativecpu.CPUAdRequest; |
| | | import com.baidu.mobads.nativecpu.CpuLpFontSize; |
| | |
| | | import com.lcjian.library.util.common.DimenUtils; |
| | | import com.ut.device.UTDevice; |
| | | import com.yeshi.ec.library_baiducpu.R; |
| | | import com.yeshi.ec.library_baiducpu.entity.NativeCPUView; |
| | | import com.yeshi.ec.library_baiducpu.adapter.BaiduCPUContentAdapter; |
| | | import com.yeshi.ec.library_baiducpu.entity.SpinnerItem; |
| | | |
| | | import java.util.ArrayList; |
| | |
| | | /** |
| | | * 百度资讯 |
| | | */ |
| | | public class BaiDuNewsContentFragment extends RetainViewFragment implements NativeCPUManager.CPUAdListener { |
| | | public class BaiDuCPUContentFragment extends RetainViewFragment implements NativeCPUManager.CPUAdListener { |
| | | |
| | | public final static int VIEW_TYPE_NEWS = 1; |
| | | public final static int VIEW_TYPE_SMALLVIDEO = 2; |
| | | public final static int VIEW_TYPE_VIDEO = 3; |
| | | |
| | | private final String YOUR_APP_ID = "be796ac7"; // 双引号中填写自己的APPSID |
| | | private List<IBasicCPUData> nrAdList = new ArrayList<IBasicCPUData>(); |
| | | private NativeCPUManager mCpuManager; |
| | |
| | | |
| | | private boolean isLoad; |
| | | |
| | | private MyAdapter adapter; |
| | | private BaiduCPUContentAdapter adapter; |
| | | |
| | | private final static String TAG = "BaiDuNewsContent"; |
| | | |
| | | private TextView footerView; |
| | | |
| | | private int viewType; |
| | | |
| | | public static BaiDuNewsContentFragment newInstance(SpinnerItem spinnerItem) { |
| | | BaiDuNewsContentFragment fragment = new BaiDuNewsContentFragment(); |
| | | |
| | | public static BaiDuCPUContentFragment newInstance(SpinnerItem spinnerItem, int viewType) { |
| | | BaiDuCPUContentFragment fragment = new BaiDuCPUContentFragment(); |
| | | Bundle bundle = new Bundle(); |
| | | bundle.putSerializable("item", spinnerItem); |
| | | bundle.putInt("viewType", viewType); |
| | | fragment.setArguments(bundle); |
| | | return fragment; |
| | | } |
| | |
| | | isLoad = true; |
| | | if (nrAdList != null && nrAdList.size() > 0) |
| | | footerView.setVisibility(View.VISIBLE); |
| | | else |
| | | footerView.setVisibility(View.GONE); |
| | | loadAd(currentPage); |
| | | } |
| | | } |
| | |
| | | footerView.setTextSize(12); |
| | | } |
| | | |
| | | RecyclerView.ItemDecoration itemDecoration2 = new RecyclerView.ItemDecoration() { |
| | | @Override |
| | | public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { |
| | | super.onDraw(c, parent, state); |
| | | } |
| | | |
| | | @Override |
| | | public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) { |
| | | super.onDrawOver(c, parent, state); |
| | | } |
| | | |
| | | @Override |
| | | public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { |
| | | super.getItemOffsets(outRect, view, parent, state); |
| | | int index = parent.getChildAdapterPosition(view); |
| | | int total = parent.getAdapter().getItemCount(); |
| | | int minWidth = DimenUtils.dipToPixels(2, view.getContext()); |
| | | if (index % 2 == 0) { |
| | | outRect.left = 0; //第一列左边贴边 |
| | | outRect.right = minWidth; |
| | | } else { |
| | | outRect.right = 0; //第一列左边贴边 |
| | | outRect.left = minWidth; |
| | | } |
| | | |
| | | if (index - 1 > 0) { |
| | | outRect.top = minWidth; |
| | | } else |
| | | outRect.top = 0; |
| | | |
| | | if (total % 2 == 0) { |
| | | if (total > 2 && (index < total - 2)) |
| | | outRect.bottom = minWidth; |
| | | else |
| | | outRect.bottom = 0; |
| | | } else { |
| | | if (total > 2 && (index < total - 1)) |
| | | outRect.bottom = minWidth; |
| | | else |
| | | outRect.bottom = 0; |
| | | } |
| | | } |
| | | }; |
| | | |
| | | |
| | | private void initData() { |
| | | Bundle bundle = getArguments(); |
| | | SpinnerItem item = (SpinnerItem) bundle.getSerializable("item"); |
| | | viewType = bundle.getInt("viewType"); |
| | | bundle.clear(); |
| | | mChannelId = item.getmId(); |
| | | |
| | |
| | | */ |
| | | mCpuManager.setLpFontSize(CpuLpFontSize.SMALL); |
| | | mCpuManager.setLpDarkMode(true); |
| | | adapter = new MyAdapter(getContext()); |
| | | adapter = new BaiduCPUContentAdapter(getContext(), viewType, nrAdList); |
| | | rv_news.setAdapter(adapter); |
| | | rv_news.setLayoutManager(new LinearLayoutManager(getContext())); |
| | | |
| | | if (viewType == VIEW_TYPE_SMALLVIDEO) { |
| | | RecyclerView.LayoutManager layoutManager = new GridLayoutManager(getContext(), 2); |
| | | rv_news.setLayoutManager(layoutManager); |
| | | //统一分为2列 |
| | | ((GridLayoutManager) rv_news.getLayoutManager()).setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { |
| | | @Override |
| | | public int getSpanSize(int position) { |
| | | if (position >= nrAdList.size()) |
| | | return 2; |
| | | else |
| | | return 1; |
| | | } |
| | | }); |
| | | rv_news.addItemDecoration(itemDecoration2); |
| | | } else { |
| | | rv_news.setLayoutManager(new LinearLayoutManager(getContext())); |
| | | } |
| | | |
| | | srl_news.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { |
| | | @Override |
| | | public void onRefresh() { |
| | |
| | | @Override |
| | | public void onAdLoaded(List<IBasicCPUData> list) { |
| | | onLoadFinish(); |
| | | for (int i = list.size() - 1; i >= 0; i--) { |
| | | if ("ad".equalsIgnoreCase(list.get(i).getType())) { |
| | | list.remove(i--); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | int start = nrAdList.size(); |
| | | if (currentPage == 1) { |
| | | nrAdList.clear(); |
| | |
| | | @Override |
| | | public void onAdStatusChanged(String s) { |
| | | |
| | | } |
| | | |
| | | class MyAdapter extends RecyclerView.Adapter { |
| | | private LayoutInflater inflater; |
| | | private AQuery aq; |
| | | private View footerView; |
| | | |
| | | private final int TYPE_FOOTER = 1; |
| | | private final int TYPE_CONTENT = 2; |
| | | |
| | | |
| | | public MyAdapter(Context context) { |
| | | inflater = LayoutInflater.from(getContext()); |
| | | aq = new AQuery(context); |
| | | } |
| | | |
| | | public void setFooterView(View footerView) { |
| | | this.footerView = footerView; |
| | | } |
| | | |
| | | |
| | | @NonNull |
| | | @Override |
| | | public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { |
| | | if (viewType == TYPE_CONTENT) |
| | | return new ViewHolder(inflater.inflate(R.layout.item_baidu_news, null, false)); |
| | | else |
| | | return new FooterViewHolder(footerView); |
| | | } |
| | | |
| | | @Override |
| | | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { |
| | | if (holder instanceof ViewHolder) { |
| | | ViewHolder viewHolder = (ViewHolder) holder; |
| | | final IBasicCPUData nrAd = nrAdList.get(position); |
| | | final NativeCPUView cpuView = new NativeCPUView(getContext()); |
| | | if (cpuView.getParent() != null) { |
| | | ((ViewGroup) cpuView.getParent()).removeView(cpuView); |
| | | } |
| | | cpuView.setItemData(nrAd, aq); |
| | | viewHolder.rl_container.removeAllViews(); |
| | | viewHolder.rl_container.addView(cpuView); |
| | | nrAd.onImpression(viewHolder.view); |
| | | viewHolder.view.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View view) { |
| | | nrAd.handleClick(view); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public int getItemCount() { |
| | | int count = nrAdList.size(); |
| | | if (footerView != null) |
| | | count++; |
| | | return count; |
| | | } |
| | | |
| | | @Override |
| | | public int getItemViewType(int position) { |
| | | if (position >= nrAdList.size()) |
| | | return TYPE_FOOTER; |
| | | else |
| | | return TYPE_CONTENT; |
| | | } |
| | | |
| | | class ViewHolder extends RecyclerView.ViewHolder { |
| | | RelativeLayout rl_container; |
| | | View view; |
| | | |
| | | public ViewHolder(View itemView) { |
| | | super(itemView); |
| | | view = itemView; |
| | | rl_container = itemView.findViewById(R.id.native_outer_view); |
| | | } |
| | | } |
| | | |
| | | class FooterViewHolder extends RecyclerView.ViewHolder { |
| | | public FooterViewHolder(View itemView) { |
| | | super(itemView); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | import android.support.v4.app.FragmentManager; |
| | | import android.support.v4.app.FragmentStatePagerAdapter; |
| | | import android.support.v4.view.ViewPager; |
| | | import android.support.v4.widget.SwipeRefreshLayout; |
| | | import android.support.v7.widget.LinearLayoutManager; |
| | | import android.support.v7.widget.RecyclerView; |
| | | import android.view.View; |
| | | import android.widget.FrameLayout; |
| | | |
| | | import com.baidu.mobad.feeds.RequestParameters; |
| | | import com.baidu.mobads.nativecpu.CPUAdRequest; |
| | | import com.baidu.mobads.nativecpu.CpuLpFontSize; |
| | | import com.baidu.mobads.nativecpu.IBasicCPUData; |
| | | import com.baidu.mobads.nativecpu.NativeCPUManager; |
| | | import com.lcjian.library.RetainViewFragment; |
| | | import com.viewpagerindicator.FoundPageIndicator; |
| | | import com.viewpagerindicator.LinePageIndicator; |
| | | import com.viewpagerindicator.MainTabPageIndicator; |
| | | import com.viewpagerindicator.TabPageIndicator; |
| | | import com.viewpagerindicator.TitlePageIndicator; |
| | | import com.viewpagerindicator.FoundTabPageIndicator; |
| | | import com.yeshi.ec.library_baiducpu.R; |
| | | import com.yeshi.ec.library_baiducpu.entity.SpinnerItem; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | |
| | | */ |
| | | public class BaiDuNewsFragment extends RetainViewFragment { |
| | | |
| | | private FrameLayout fl_indicator; |
| | | private ViewPager viewPager; |
| | | private ContentAdapter contentAdapter; |
| | | private List<SpinnerItem> itemList = new ArrayList<>(); |
| | | private TabPageIndicator indicator; |
| | | private FoundTabPageIndicator indicator; |
| | | |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | private void initView(View contentView) { |
| | | fl_indicator = contentView.findViewById(R.id.fl_indicator); |
| | | viewPager = contentView.findViewById(R.id.vp_news); |
| | | } |
| | | |
| | | private void initData() { |
| | | itemList.add(new SpinnerItem("推荐频道", 1022)); |
| | | itemList.add(new SpinnerItem("小品", 1062)); |
| | | itemList.add(new SpinnerItem("娱乐频道", 1001)); |
| | | itemList.add(new SpinnerItem("热点频道", 1021)); |
| | | itemList.add(new SpinnerItem("热讯频道", 1081)); |
| | | itemList.add(new SpinnerItem("健康频道", 1043)); |
| | | itemList.add(new SpinnerItem("搞笑频道", 1025)); |
| | | itemList.add(new SpinnerItem("母婴频道", 1042)); |
| | | itemList.add(new SpinnerItem("时尚频道", 1009)); |
| | | itemList.add(new SpinnerItem("汽车频道", 1007)); |
| | | itemList.add(new SpinnerItem("军事频道", 1012)); |
| | | itemList.add(new SpinnerItem("生活频道", 1035)); |
| | | itemList.add(new SpinnerItem("游戏频道", 1040)); |
| | | itemList.add(new SpinnerItem("体育频道", 1002)); |
| | | itemList.add(new SpinnerItem("女人频道", 1034)); |
| | | itemList.add(new SpinnerItem("财经频道", 1006)); |
| | | itemList.add(new SpinnerItem("科技频道", 1013)); |
| | | itemList.add(new SpinnerItem("动漫频道", 1055)); |
| | | itemList.add(new SpinnerItem("文化频道", 1036)); |
| | | itemList.add(new SpinnerItem("手机频道", 1005)); |
| | | itemList.add(new SpinnerItem("房产频道", 1008)); |
| | | itemList.add(new SpinnerItem("本地频道", 1080)); |
| | | itemList.add(new SpinnerItem("广场舞", 1088)); |
| | | itemList.add(new SpinnerItem("猎奇", 1089)); |
| | | private void initData(View contentView) { |
| | | itemList.add(new SpinnerItem("推荐", 1022));//1022 |
| | | itemList.add(new SpinnerItem("今日热点", 1021));//热点 |
| | | itemList.add(new SpinnerItem("美女", 1024)); |
| | | itemList.add(new SpinnerItem("热榜搜索", 1090)); |
| | | itemList.add(new SpinnerItem("看点频道", 1047)); |
| | | itemList.add(new SpinnerItem("娱乐八卦", 1001)); |
| | | itemList.add(new SpinnerItem("大家在看", 1090)); |
| | | itemList.add(new SpinnerItem("实时资讯", 1081)); |
| | | itemList.add(new SpinnerItem("军事视野", 1012)); |
| | | itemList.add(new SpinnerItem("女人", 1034)); |
| | | itemList.add(new SpinnerItem("笑一笑", 1025)); |
| | | itemList.add(new SpinnerItem("游戏", 1040)); |
| | | itemList.add(new SpinnerItem("动漫", 1055)); |
| | | itemList.add(new SpinnerItem("奇闻", 1089)); |
| | | itemList.add(new SpinnerItem("精彩看点", 1047)); |
| | | itemList.add(new SpinnerItem("本地热榜", 1080)); |
| | | itemList.add(new SpinnerItem("广场舞", 1088)); |
| | | itemList.add(new SpinnerItem("健康", 1043)); |
| | | itemList.add(new SpinnerItem("母婴", 1042)); |
| | | itemList.add(new SpinnerItem("时尚", 1009)); |
| | | itemList.add(new SpinnerItem("汽车", 1007)); |
| | | itemList.add(new SpinnerItem("文化", 1036)); |
| | | itemList.add(new SpinnerItem("生活", 1035)); |
| | | itemList.add(new SpinnerItem("体育", 1002)); |
| | | itemList.add(new SpinnerItem("财经", 1006)); |
| | | itemList.add(new SpinnerItem("科技", 1013)); |
| | | itemList.add(new SpinnerItem("房产", 1008)); |
| | | itemList.add(new SpinnerItem("手机", 1005)); |
| | | |
| | | contentAdapter = new ContentAdapter( |
| | | getChildFragmentManager(), itemList); |
| | | viewPager.setAdapter(contentAdapter); |
| | | indicator = new TabPageIndicator( |
| | | viewPager.getContext()); |
| | | indicator.setViewPager(viewPager, 0); |
| | | fl_indicator.addView(indicator); |
| | | indicator = contentView.findViewById(R.id.indicator); |
| | | indicator.setViewPager(viewPager); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void onCreateView(View contentView, Bundle savedInstanceState) { |
| | | |
| | | initView(contentView); |
| | | initData(); |
| | | initData(contentView); |
| | | } |
| | | |
| | | class ContentAdapter extends FragmentStatePagerAdapter { |
| | |
| | | |
| | | @Override |
| | | public Fragment getItem(int position) { |
| | | Fragment fragment = BaiDuNewsContentFragment.newInstance(mlist.get(position)); |
| | | Fragment fragment = BaiDuCPUContentFragment.newInstance(mlist.get(position),BaiDuCPUContentFragment.VIEW_TYPE_NEWS); |
| | | return fragment; |
| | | } |
| | | |
| | |
| | | RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); |
| | | reLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); |
| | | mVideoContainer.addView(mCpuView, reLayoutParams); |
| | | Toast.makeText(getContext(), "加载AppSid:" + APP_ID, Toast.LENGTH_SHORT).show(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | import android.widget.FrameLayout; |
| | | |
| | | import com.lcjian.library.RetainViewFragment; |
| | | import com.viewpagerindicator.FoundTabPageIndicator; |
| | | import com.viewpagerindicator.MainTabPageIndicator; |
| | | import com.yeshi.ec.library_baiducpu.R; |
| | | import com.yeshi.ec.library_baiducpu.entity.SpinnerItem; |
| | |
| | | */ |
| | | public class BaiDuVideosFragment extends RetainViewFragment { |
| | | |
| | | private FrameLayout fl_indicator; |
| | | private ViewPager viewPager; |
| | | private ContentAdapter contentAdapter; |
| | | private List<SpinnerItem> itemList = new ArrayList<>(); |
| | | private MainTabPageIndicator indicator; |
| | | private FoundTabPageIndicator indicator; |
| | | |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | private void initView(View contentView) { |
| | | fl_indicator = contentView.findViewById(R.id.fl_indicator); |
| | | viewPager = contentView.findViewById(R.id.vp_news); |
| | | } |
| | | |
| | | private void initData() { |
| | | itemList.add(new SpinnerItem("小视频", 1085)); |
| | | itemList.add(new SpinnerItem("萌萌哒", 1065)); |
| | | itemList.add(new SpinnerItem("小品", 1062)); |
| | | itemList.add(new SpinnerItem("音乐", 1058)); |
| | | itemList.add(new SpinnerItem("搞笑", 1059)); |
| | | private void initData(View contentView) { |
| | | itemList.add(new SpinnerItem("影视", 1060)); |
| | | itemList.add(new SpinnerItem("游戏", 1067)); |
| | | itemList.add(new SpinnerItem("生活", 1066)); |
| | | itemList.add(new SpinnerItem("小视频", 1085)); |
| | | itemList.add(new SpinnerItem("小品", 1062)); |
| | | itemList.add(new SpinnerItem("观天下", 1064)); |
| | | itemList.add(new SpinnerItem("搞笑", 1059)); |
| | | itemList.add(new SpinnerItem("娱乐", 1061)); |
| | | itemList.add(new SpinnerItem("社会", 1063)); |
| | | itemList.add(new SpinnerItem("游戏", 1067)); |
| | | itemList.add(new SpinnerItem("生活", 1066)); |
| | | itemList.add(new SpinnerItem("音乐", 1058)); |
| | | itemList.add(new SpinnerItem("萌萌哒", 1065)); |
| | | |
| | | contentAdapter = new ContentAdapter( |
| | | getChildFragmentManager(), itemList); |
| | | viewPager.setAdapter(contentAdapter); |
| | | indicator = new MainTabPageIndicator( |
| | | viewPager.getContext()); |
| | | indicator.setViewPager(viewPager, 0); |
| | | fl_indicator.addView(indicator); |
| | | indicator = contentView.findViewById(R.id.indicator); |
| | | indicator.setViewPager(viewPager); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void onCreateView(View contentView, Bundle savedInstanceState) { |
| | | initView(contentView); |
| | | initData(); |
| | | initData(contentView); |
| | | } |
| | | |
| | | class ContentAdapter extends FragmentStatePagerAdapter { |
| | |
| | | |
| | | @Override |
| | | public Fragment getItem(int position) { |
| | | Fragment fragment = BaiDuShortVideosFragment.newInstance(mlist.get(position)); |
| | | return fragment; |
| | | if (mlist.get(position).getmId()==1085) |
| | | return BaiDuShortVideosFragment.newInstance(mlist.get(position)); |
| | | else |
| | | return BaiDuCPUContentFragment.newInstance(mlist.get(position), mlist.get(position).getmId()==1085? BaiDuCPUContentFragment.VIEW_TYPE_SMALLVIDEO : BaiDuCPUContentFragment.VIEW_TYPE_VIDEO); |
| | | } |
| | | |
| | | @Override |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <shape xmlns:android="http://schemas.android.com/apk/res/android" |
| | | android:shape="rectangle"> |
| | | <corners android:radius="20dp" /> |
| | | <solid android:color="#80000000" /> |
| | | |
| | | </shape> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <shape xmlns:android="http://schemas.android.com/apk/res/android" |
| | | android:shape="rectangle"> |
| | | <gradient |
| | | android:angle="270" |
| | | android:endColor="#00000000" |
| | | android:startColor="#90000000" /> |
| | | </shape> |
| | |
| | | android:id="@+id/fl_indicator" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginTop="-10dp"> |
| | | android:layout_marginTop="-10dp" |
| | | android:layout_marginBottom="-13dp"> |
| | | |
| | | <com.viewpagerindicator.FoundTabPageIndicator |
| | | android:id="@+id/indicator" |
| | | style="@style/NewsPageIndicator" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content"> |
| | | |
| | | </com.viewpagerindicator.FoundTabPageIndicator> |
| | | |
| | | |
| | | </FrameLayout> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?><!--百度小视频布局 --> |
| | | <com.lcjian.library.widget.RatioLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | xmlns:app="http://schemas.android.com/apk/res-auto" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | app:ratio="1.6"> |
| | | |
| | | |
| | | <FrameLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent"> |
| | | |
| | | <ImageView |
| | | android:id="@+id/iv_video_pciture" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:scaleType="centerCrop"> |
| | | |
| | | </ImageView> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="bottom" |
| | | android:orientation="vertical" |
| | | android:padding="5dp"> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_title" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginBottom="10dp" |
| | | android:ellipsize="end" |
| | | android:maxLines="2" |
| | | android:textColor="#ffffff" |
| | | android:textSize="15sp"></TextView> |
| | | |
| | | <!-- 作者信息 --> |
| | | <LinearLayout |
| | | android:id="@+id/ll_author_info" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content"> |
| | | |
| | | <ImageView |
| | | android:id="@+id/iv_portrait" |
| | | android:layout_width="20dp" |
| | | android:layout_height="20dp"></ImageView> |
| | | |
| | | <TextView |
| | | android:textColor="#ffffff" |
| | | android:id="@+id/tv_play_count" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginLeft="10dp"></TextView> |
| | | |
| | | </LinearLayout> |
| | | |
| | | <LinearLayout |
| | | android:id="@+id/ll_ad_info" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content"> |
| | | |
| | | <TextView |
| | | android:textColor="#ffffff" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:text="精选推荐"></TextView> |
| | | |
| | | <TextView |
| | | android:textColor="#ffffff" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginLeft="10dp" |
| | | android:text="广告"></TextView> |
| | | |
| | | </LinearLayout> |
| | | |
| | | |
| | | </LinearLayout> |
| | | |
| | | </FrameLayout> |
| | | |
| | | </com.lcjian.library.widget.RatioLayout> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?><!--百度小视频布局 --> |
| | | |
| | | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | xmlns:app="http://schemas.android.com/apk/res-auto" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:orientation="vertical"> |
| | | |
| | | <com.lcjian.library.widget.RatioLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | app:ratio="0.618"> |
| | | |
| | | |
| | | <FrameLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent"> |
| | | |
| | | <ImageView |
| | | android:id="@+id/iv_video_pciture" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:scaleType="centerCrop"> |
| | | |
| | | </ImageView> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_title" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="top" |
| | | android:layout_marginBottom="10dp" |
| | | android:background="@drawable/shape_baidu_title" |
| | | android:ellipsize="end" |
| | | android:maxLines="2" |
| | | android:paddingLeft="10dp" |
| | | android:paddingTop="10dp" |
| | | android:paddingRight="10dp" |
| | | android:paddingBottom="30dp" |
| | | android:textColor="#ffffff" |
| | | android:textSize="@dimen/baidu_cpu_title"></TextView> |
| | | |
| | | <TextView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="right|bottom" |
| | | android:layout_margin="10dp" |
| | | android:paddingLeft="10dp" |
| | | android:paddingTop="5dp" |
| | | android:paddingRight="10dp" |
| | | android:paddingBottom="5dp" |
| | | android:textColor="#ffffff" |
| | | android:textSize="10sp"></TextView> |
| | | |
| | | <ImageView |
| | | android:id="@+id/iv_play" |
| | | android:layout_width="50dp" |
| | | android:layout_height="50dp" |
| | | android:layout_gravity="center" |
| | | android:src="@drawable/ic_baidu_play"> |
| | | |
| | | </ImageView> |
| | | </FrameLayout> |
| | | |
| | | |
| | | </com.lcjian.library.widget.RatioLayout> |
| | | |
| | | |
| | | <LinearLayout |
| | | |
| | | android:layout_width="match_parent" |
| | | android:layout_height="48dp" |
| | | android:gravity="center_vertical" |
| | | android:orientation="vertical" |
| | | android:paddingLeft="15dp" |
| | | android:paddingRight="15dp"> |
| | | |
| | | <!-- 作者信息 --> |
| | | <LinearLayout |
| | | android:id="@+id/ll_author_info" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:gravity="center_vertical"> |
| | | |
| | | <ImageView |
| | | android:id="@+id/iv_portrait" |
| | | android:layout_width="20dp" |
| | | android:layout_height="20dp"></ImageView> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_name" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginLeft="10dp" |
| | | android:textColor="#ffffff"></TextView> |
| | | |
| | | </LinearLayout> |
| | | |
| | | <LinearLayout |
| | | android:id="@+id/ll_ad_info" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:gravity="center_vertical"> |
| | | |
| | | <TextView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:text="精选推荐" |
| | | android:textColor="#ffffff"></TextView> |
| | | |
| | | |
| | | <ImageView |
| | | android:id="@+id/iv_baidu_logo" |
| | | android:layout_width="20dp" |
| | | android:layout_height="20dp" |
| | | android:layout_marginLeft="10dp"></ImageView> |
| | | |
| | | <TextView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginLeft="2dp" |
| | | android:text="广告" |
| | | android:textColor="#ffffff"></TextView> |
| | | |
| | | </LinearLayout> |
| | | |
| | | |
| | | </LinearLayout> |
| | | |
| | | |
| | | </LinearLayout> |
| | |
| | | android:textColor="#FFFFFF" |
| | | android:layout_marginTop="4dp" |
| | | android:layout_marginBottom="4dp" |
| | | android:textSize="16sp" |
| | | android:textSize="@dimen/baidu_cpu_title" |
| | | android:ellipsize="end" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" /> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <resources> |
| | | <color name="img_bg">#ff333333</color> |
| | | </resources> |
| | | |
| | | |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <resources> |
| | | |
| | | <dimen name="baidu_cpu_title">18sp</dimen> |
| | | |
| | | </resources> |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <resources xmlns:android="http://schemas.android.com/apk/res/android"> |
| | | <style name="FoundPageIndicator" parent="Widget.TabPageIndicator1"> |
| | | <!-- 发现界面的indicator --> |
| | | <style name="NewsPageIndicator" parent="Widget.FoundTabPageIndicator"> |
| | | <item name="android:textSize">16sp</item> |
| | | <item name="android:background">@color/top_bar_color</item> |
| | | <item name="android:paddingLeft">8dp</item> |
| | | <item name="android:paddingRight">8dp</item> |
| | | </style> |
| | | |
| | | |
| | | </resources> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <!-- |
| | | Copyright (C) 2008 The Android Open Source Project |
| | | |
| | | 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. |
| | | 豆豆 影视大全 state_selected全部置为false |
| | | --> |
| | | |
| | | <selector xmlns:android="http://schemas.android.com/apk/res/android"> |
| | | |
| | | <!-- Non focused states --> |
| | | <item android:drawable="@color/lxy_bg_diaphanous" android:state_focused="false" android:state_pressed="false" android:state_selected="false"/> |
| | | <item android:drawable="@drawable/tab_selected_holo" android:state_focused="false" android:state_pressed="false" android:state_selected="true"/> |
| | | |
| | | <!-- Focused states --> |
| | | <item android:drawable="@color/lxy_bg_diaphanous" android:state_focused="true" android:state_pressed="false" android:state_selected="false"/> |
| | | <item android:drawable="@drawable/tab_selected_holo" android:state_focused="true" android:state_pressed="false" android:state_selected="true"/> |
| | | |
| | | <!-- Pressed --> |
| | | <!-- Non focused states --> |
| | | <item android:drawable="@color/lxy_bg_diaphanous" android:state_focused="false" android:state_pressed="true" android:state_selected="false"/> |
| | | <item android:drawable="@drawable/tab_selected_holo" android:state_focused="false" android:state_pressed="true" android:state_selected="true"/> |
| | | |
| | | <!-- Focused states --> |
| | | <item android:drawable="@color/lxy_bg_diaphanous" android:state_focused="true" android:state_pressed="true" android:state_selected="false"/> |
| | | <item android:drawable="@drawable/tab_selected_holo" android:state_focused="true" android:state_pressed="true" android:state_selected="true"/> |
| | | |
| | | </selector> |
| | |
| | | <item name="android:maxLines">1</item> |
| | | </style> |
| | | |
| | | <style name="Widget.FoundTabPageIndicator" parent="Widget"> |
| | | <item name="android:gravity">center</item> |
| | | <item name="android:background">@drawable/lxy__tab_indicator</item> |
| | | <item name="android:paddingLeft">22dip</item> |
| | | <item name="android:paddingRight">22dip</item> |
| | | <item name="android:paddingTop">12dp</item> |
| | | <item name="android:paddingBottom">12dp</item> |
| | | <item name="android:textAppearance">@style/TextAppearance.LxyTabPageIndicator</item> |
| | | <item name="android:textSize">12sp</item> |
| | | <item name="android:maxLines">1</item> |
| | | </style> |
| | | |
| | | <style name="TextAppearance.TabPageIndicator" parent="Widget"> |
| | | <item name="android:textStyle">bold</item> |
| | | <item name="android:textColor">#ff000000</item> |
File was renamed from library-ViewPagerIndicator/src/com/viewpagerindicator/FoundPageIndicator.java |
| | |
| | | /* |
| | | * 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.support.v4.view.PagerAdapter; |
| | | import android.support.v4.view.ViewPager; |
| | | import android.support.v4.view.ViewPager.OnPageChangeListener; |
| | | import android.text.SpannableStringBuilder; |
| | | import android.text.Spanned; |
| | | import android.text.style.ForegroundColorSpan; |
| | | import android.util.AttributeSet; |
| | | import android.util.TypedValue; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | | import android.view.WindowManager; |
| | | import android.widget.HorizontalScrollView; |
| | | import android.widget.LinearLayout; |
| | | import android.widget.TextView; |
| | | |
| | | import com.lcjian.library.widget.IsPad; |
| | | import com.lcjian.library.util.common.DimenUtils; |
| | | |
| | | 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 FoundPageIndicator extends HorizontalScrollView implements |
| | | public class FoundTabPageIndicator extends HorizontalScrollView implements |
| | | PageIndicator { |
| | | |
| | | /** |
| | | * Title text used when no title is provided by the adapter. |
| | | */ |
| | |
| | | |
| | | private OnTabReselectedListener mTabReselectedListener; |
| | | |
| | | public FoundPageIndicator(Context context) { |
| | | public FoundTabPageIndicator(Context context) { |
| | | this(context, null); |
| | | } |
| | | |
| | | public FoundPageIndicator(Context context, AttributeSet attrs) { |
| | | public FoundTabPageIndicator(Context context, AttributeSet attrs) { |
| | | super(context, attrs); |
| | | setHorizontalScrollBarEnabled(false); |
| | | |
| | | mTabLayout = new IcsLinearLayout(context, |
| | | R.attr.vpiTitlePageIndicatorStyle); |
| | | R.attr.vpiTabPageIndicatorStyle); |
| | | addView(mTabLayout, new ViewGroup.LayoutParams(WRAP_CONTENT, |
| | | MATCH_PARENT)); |
| | | } |
| | |
| | | if (mTabSelector != null) { |
| | | removeCallbacks(mTabSelector); |
| | | } |
| | | // Drawable mReview = getResources().getDrawable(R.drawable.video_review); |
| | | // mReview.setBounds(0, 0, mReview.getMinimumWidth(), |
| | | // mReview.getMinimumHeight()); |
| | | |
| | | for (int i = 0; i < mTabLayout.getChildCount(); i++) { |
| | | ((TextView) mTabLayout.getChildAt(i)).setTextColor(Color.argb(255, |
| | | 0, 0, 0)); |
| | | if (i == 1) { |
| | | SpannableStringBuilder builder = new SpannableStringBuilder(((TextView) tabView).getText().toString()); |
| | | ForegroundColorSpan span = new ForegroundColorSpan(Color.argb(255, 255, 115, 0)); |
| | | builder.setSpan(span, 2, ((TextView) tabView).getText().toString().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); |
| | | ((TextView) tabView).setText(builder); |
| | | } |
| | | ((TextView) mTabLayout.getChildAt(i)).setTextSize( |
| | | TypedValue.COMPLEX_UNIT_SP, 15); |
| | | ((TextView) mTabLayout.getChildAt(i)).setTextColor(Color.parseColor("#999999")); |
| | | } |
| | | ((TextView) tabView).setTextColor(Color.argb(255, 0, 0, 0));//豆豆系列 |
| | | |
| | | // ((TextView) tabView).setTextColor(Color.argb(255, 255, 115, 0));// 木瓜系列 |
| | | |
| | | ((TextView) tabView).setTextColor(Color.WHITE); |
| | | ((TextView) tabView).setTextSize( |
| | | TypedValue.COMPLEX_UNIT_SP, 20); |
| | | // ((TextView) tabView).setLayoutParams(new ViewGroup.LayoutParams(WRAP_CONTENT,WRAP_CONTENT)); |
| | | mTabSelector = new Runnable() { |
| | | public void run() { |
| | | final int scrollPos = tabView.getLeft() |
| | |
| | | mTabSelector = null; |
| | | } |
| | | }; |
| | | |
| | | post(mTabSelector); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void onAttachedToWindow() { |
| | |
| | | * @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); |
| | | if (IsPad.isPad(tabView.getContext())) |
| | | tabView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 25); |
| | | tabView.setText(text); |
| | | int width = ((WindowManager) getContext().getSystemService( |
| | | Context.WINDOW_SERVICE)).getDefaultDisplay().getWidth(); |
| | | tabView.setTextColor(R.color.black1); |
| | | tabView.setBackgroundResource(R.drawable.found__tab_indicator); |
| | | tabView.setPadding(0,0,0,DimenUtils.dip2px(getContext(), 6)); |
| | | |
| | | if (iconResId != 0) { |
| | | tabView.setCompoundDrawablesWithIntrinsicBounds(iconResId, 0, 0, 0); |
| | | } |
| | | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(WRAP_CONTENT, |
| | | MATCH_PARENT, 1); |
| | | |
| | | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( |
| | | width / 3, LayoutParams.WRAP_CONTENT); |
| | | // params.setMargins(20, 0, 20, 0); |
| | | mTabLayout.addView(tabView, new LinearLayout.LayoutParams(0, |
| | | LayoutParams.MATCH_PARENT, 1)); |
| | | switch (index) { |
| | | case 1: |
| | | SpannableStringBuilder builder = new SpannableStringBuilder(((TextView) tabView).getText().toString()); |
| | | ForegroundColorSpan span = new ForegroundColorSpan(Color.argb(255, 255, 115, 0)); |
| | | builder.setSpan(span, 2, ((TextView) tabView).getText().toString().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); |
| | | ((TextView) tabView).setText(builder); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | mTabLayout.addView(tabView, params); |
| | | MarginLayoutParams marginLayoutParams = (MarginLayoutParams) tabView.getLayoutParams(); |
| | | if (index == 0) |
| | | marginLayoutParams.leftMargin = 0; |
| | | else |
| | | marginLayoutParams.leftMargin = DimenUtils.dip2px(getContext(), 21); |
| | | |
| | | } |
| | | |
| | | @Override |
| | |
| | | private int mIndex; |
| | | |
| | | public TabView(Context context) { |
| | | super(context, null, R.attr.lxyTabPageIndicatorStyle); |
| | | super(context, null, R.attr.vpiTabPageIndicatorStyle); |
| | | } |
| | | |
| | | @Override |
| | |
| | | public int getIndex() { |
| | | return mIndex; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据手机的分辨率从 dp 的单位 转成为 px(像素) |
| | | */ |
| | | public static int dip2px(Context context, float dpValue) { |
| | | final float scale = context.getResources().getDisplayMetrics().density; |
| | | return (int) (dpValue * scale + 0.5f); |
| | | } |
| | | } |
| | |
| | | import android.widget.LinearLayout; |
| | | import android.widget.TextView; |
| | | |
| | | import com.lcjian.library.util.common.DimenUtils; |
| | | |
| | | /** |
| | | * This widget implements the dynamic action bar tab behavior that can change |
| | | * across different configurations or circumstances. |
| | |
| | | } |
| | | ((TextView) tabView).setTextColor(Color.WHITE); |
| | | ((TextView) tabView).setTextSize( |
| | | TypedValue.COMPLEX_UNIT_SP, 18); |
| | | TypedValue.COMPLEX_UNIT_SP, 20); |
| | | // ((TextView) tabView).setLayoutParams(new ViewGroup.LayoutParams(WRAP_CONTENT,WRAP_CONTENT)); |
| | | mTabSelector = new Runnable() { |
| | | public void run() { |
| | |
| | | tabView.setText(text); |
| | | tabView.setTextColor(R.color.black1); |
| | | |
| | | tabView.setBackgroundResource(R.drawable.found__tab_indicator); |
| | | |
| | | if (iconResId != 0) { |
| | | tabView.setCompoundDrawablesWithIntrinsicBounds(iconResId, 0, 0, 0); |
| | | } |
| | | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(WRAP_CONTENT, |
| | | MATCH_PARENT, 1); |
| | | |
| | | mTabLayout.addView(tabView, params); |
| | | MarginLayoutParams marginLayoutParams = (MarginLayoutParams) tabView.getLayoutParams(); |
| | | if (index == 0) |
| | | marginLayoutParams.leftMargin = DimenUtils.dip2px(getContext(), 10); |
| | | else |
| | | marginLayoutParams.leftMargin = DimenUtils.dip2px(getContext(), 21); |
| | | } |
| | | |
| | | @Override |
New file |
| | |
| | | package com.lcjian.library.util.glide; |
| | | |
| | | import android.content.Context; |
| | | import android.graphics.Bitmap; |
| | | import android.graphics.BitmapShader; |
| | | import android.graphics.Canvas; |
| | | import android.graphics.Paint; |
| | | import android.support.annotation.NonNull; |
| | | |
| | | import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool; |
| | | import com.bumptech.glide.load.resource.bitmap.BitmapTransformation; |
| | | |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.security.MessageDigest; |
| | | |
| | | /** |
| | | * glide 加载圆形图片 |
| | | * |
| | | * @author weikou2015 |
| | | */ |
| | | public class GlideCircleTransform extends BitmapTransformation { |
| | | |
| | | private static final String ID = GlideCircleTransform.class.getClass().getName(); |
| | | private static byte[] ID_BYTES = null; |
| | | |
| | | public GlideCircleTransform(Context context) { |
| | | try { |
| | | ID_BYTES = ID.getBytes(STRING_CHARSET_NAME); |
| | | } catch (UnsupportedEncodingException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | protected Bitmap transform(BitmapPool pool, Bitmap toTransform, |
| | | int outWidth, int outHeight) { |
| | | return circleCrop(pool, toTransform); |
| | | } |
| | | |
| | | private static Bitmap circleCrop(BitmapPool pool, Bitmap source) { |
| | | if (source == null) |
| | | return null; |
| | | |
| | | int size = Math.min(source.getWidth(), source.getHeight()); |
| | | int x = (source.getWidth() - size) / 2; |
| | | int y = (source.getHeight() - size) / 2; |
| | | |
| | | // TODO this could be acquired from the pool too |
| | | Bitmap squared = Bitmap.createBitmap(source, x, y, size, size); |
| | | |
| | | Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888); |
| | | if (result == null) { |
| | | result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); |
| | | } |
| | | |
| | | Canvas canvas = new Canvas(result); |
| | | Paint paint = new Paint(); |
| | | paint.setShader(new BitmapShader(squared, BitmapShader.TileMode.CLAMP, |
| | | BitmapShader.TileMode.CLAMP)); |
| | | paint.setAntiAlias(true); |
| | | float r = size / 2f; |
| | | canvas.drawCircle(r, r, r, paint); |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public int hashCode() { |
| | | return ID.hashCode(); |
| | | } |
| | | |
| | | @Override |
| | | public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) { |
| | | messageDigest.update(ID_BYTES); |
| | | } |
| | | } |
New file |
| | |
| | | package com.lcjian.library.util.glide; |
| | | |
| | | import android.content.Context; |
| | | import android.content.res.Resources; |
| | | import android.graphics.Bitmap; |
| | | import android.graphics.BitmapShader; |
| | | import android.graphics.Canvas; |
| | | import android.graphics.Paint; |
| | | import android.graphics.RectF; |
| | | import android.support.annotation.NonNull; |
| | | |
| | | import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool; |
| | | import com.bumptech.glide.load.resource.bitmap.BitmapTransformation; |
| | | |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.security.MessageDigest; |
| | | |
| | | /** |
| | | * glide 圆角图片加载 |
| | | * |
| | | * @author weikou2015 |
| | | */ |
| | | public class GlideRoundTransform extends BitmapTransformation { |
| | | private static final String ID = GlideRoundTransform.class.getClass().getName(); |
| | | private static byte[] ID_BYTES = null; |
| | | private static float radius = 0f; |
| | | |
| | | public GlideRoundTransform(Context context) { |
| | | this(context, 12); |
| | | try { |
| | | ID_BYTES = ID.getBytes(STRING_CHARSET_NAME); |
| | | } catch (UnsupportedEncodingException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | public GlideRoundTransform(Context context, int dp) { |
| | | this.radius = Resources.getSystem().getDisplayMetrics().density * dp; |
| | | try { |
| | | ID_BYTES = ID.getBytes(STRING_CHARSET_NAME); |
| | | } catch (UnsupportedEncodingException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | protected Bitmap transform(BitmapPool pool, Bitmap toTransform, |
| | | int outWidth, int outHeight) { |
| | | return roundCrop(pool, toTransform); |
| | | } |
| | | |
| | | private static Bitmap roundCrop(BitmapPool pool, Bitmap source) { |
| | | if (source == null) |
| | | return null; |
| | | |
| | | Bitmap result = pool.get(source.getWidth(), source.getHeight(), |
| | | Bitmap.Config.ARGB_8888); |
| | | if (result == null) { |
| | | result = Bitmap.createBitmap(source.getWidth(), source.getHeight(), |
| | | Bitmap.Config.ARGB_8888); |
| | | } |
| | | |
| | | Canvas canvas = new Canvas(result); |
| | | Paint paint = new Paint(); |
| | | paint.setShader(new BitmapShader(source, BitmapShader.TileMode.CLAMP, |
| | | BitmapShader.TileMode.CLAMP)); |
| | | paint.setAntiAlias(true); |
| | | RectF rectF = new RectF(0f, 0f, source.getWidth(), source.getHeight()); |
| | | canvas.drawRoundRect(rectF, radius, radius, paint); |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public int hashCode() { |
| | | return ID.hashCode(); |
| | | } |
| | | |
| | | @Override |
| | | public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) { |
| | | messageDigest.update(ID_BYTES); |
| | | } |
| | | } |