| | |
| | | android:protectionLevel="signature" /> |
| | | <uses-permission android:name="${applicationId}.permission.KW_SDK_BROADCAST" /> |
| | | |
| | | <uses-sdk tools:overrideLibrary="com.bytedance.pangrowthsdk,com.bytedance.novel.pangolin" /> |
| | | |
| | | <application |
| | | android:name="com.weikou.beibeivideo.BeibeiVideoApplication" |
| | | android:allowBackup="true" |
| | |
| | | |
| | | |
| | | <activity |
| | | android:name="com.weikou.beibeivideo.ui.mine.GoldCornActivity" |
| | | android:label="@string/app_name" |
| | | android:launchMode="singleTask" |
| | | android:screenOrientation="portrait"></activity> |
| | | |
| | | |
| | | <activity |
| | | android:name="com.weikou.beibeivideo.ui.common.LiveBrowserActivity" |
| | | android:label="@string/app_name" |
| | | android:windowSoftInputMode="adjustResize" /> |
| | |
| | | <service android:name="com.weikou.beibeivideo.service.DownLoadFileService" /> |
| | | |
| | | |
| | | <service |
| | | android:name="com.sohuvideo.player.statistic.LogService" |
| | | android:exported="false" |
| | | android:label="CoreService"></service> |
| | | |
| | | <meta-data |
| | | android:name="android.max_aspect" |
| | | android:value="2.1" /> |
| | | android:value="2.5" /> |
| | | |
| | | <!-- umeng相关Start --> |
| | | <!--<activity--> |
| | |
| | | android:value="570f28a578d6e12cba6f7f200b8d1c83"></meta-data> |
| | | <meta-data |
| | | android:name="UMENG_CHANNEL" |
| | | android:value="QQ"></meta-data> |
| | | android:value="xiaomi"></meta-data> |
| | | |
| | | |
| | | <provider |
| | |
| | | </intent-filter> |
| | | </receiver> |
| | | |
| | | <provider |
| | | android:name="com.bytedance.sdk.dp.act.DPProvider" |
| | | android:authorities="${applicationId}.BDDPProvider" |
| | | android:exported="false" /> |
| | | |
| | | |
| | | |
| | | |
New file |
| | |
| | | { |
| | | "init": { |
| | | "site_id": "5095354", |
| | | "app_id": "300965", |
| | | "partner": "pangle_300965", |
| | | "secure_key": "5af9b5efe0d87dbaaa0972fcca3b951a" |
| | | }, |
| | | "feed": { |
| | | "news_list_ad_code_id": "947236258", |
| | | "news_first_ad_code_id": "947236259", |
| | | "news_second_ad_code_id": "947236270", |
| | | "video_first_ad_code_id": "", |
| | | "video_second_ad_code_id": "947236271", |
| | | "related_ad_code_id": "947236272", |
| | | "news_draw_ad_code_id": "947236264", |
| | | "news_draw_native_ad_code_id": "947236243", |
| | | "news_outer_list_ad_code_id": "947236245", |
| | | "news_outer_first_ad_code_id": "947236254", |
| | | "news_outer_second_ad_code_id": "947236265", |
| | | "outer_video_second_ad_code_id": "947236247", |
| | | "outer_related_ad_code_id": "947236261", |
| | | "news_outer_draw_ad_code_id": "947236262", |
| | | "news_outer_draw_native_ad_code_id": "947236255", |
| | | "news_interstitial_code_id": "947236240" |
| | | }, |
| | | "small_video": { |
| | | "draw_ad_code_id": "947236250", |
| | | "draw_native_ad_code_id": "947236251", |
| | | "grid_ad_code_id": "947236242", |
| | | "grid_draw_ad_code_id": "947236268", |
| | | "grid_draw_native_ad_code_id": "947236253", |
| | | "video_card_ad_code_id": "947236239", |
| | | "video_card_draw_ad_code_id": "947236257", |
| | | "video_card_draw_native_ad_code_id": "947236256", |
| | | "interstitial_ad_code_id": "947236249", |
| | | "interstitial_note_ad_code_id": "947236267", |
| | | "staggered_grid_ad_code_id": "947236244", |
| | | "staggered_grid_draw_ad_code_id": "947236250", |
| | | "staggered_grid_draw_native_ad_code_id": "947236251" |
| | | }, |
| | | "novel": { |
| | | "status": 1, |
| | | "pre_ad_code_id": "947236560", |
| | | "mid_ad_code_id": "947236557", |
| | | "exciting_ad_code_id": "947236547", |
| | | "interstitial_code_id": "947236540", |
| | | "banner_ad_code_id": "947236558", |
| | | "end_ad_code_id": "947236544" |
| | | } |
| | | } |
| | |
| | | implementation 'com.github.ybq:Android-SpinKit:1.4.0' |
| | | |
| | | implementation 'com.qhutch.elevationimageview:elevationimageview:2.4' |
| | | |
| | | implementation ('com.pangle.cn:pangrowth-sdk:1.7.0.0'){ |
| | | exclude group: 'com.pangle.cn', module: 'pangrowth-dpsdk-live' |
| | | exclude group: 'com.pangle.cn', module: 'pangrowth-game-sdk' |
| | | exclude group: 'com.pangle.cn', module: 'pangrowth-luckycat-sdk' |
| | | } |
| | | |
| | | //indicator |
| | | implementation 'com.github.hackware1993:MagicIndicator:1.7.0' |
| | | } |
| | | android { |
| | | signingConfigs { |
| | |
| | | |
| | | defaultConfig { |
| | | applicationId "com.doudou.ysvideo" |
| | | versionCode 122 |
| | | versionName "3.10.4" |
| | | versionCode 127 |
| | | versionName "3.10.9" |
| | | multiDexEnabled = true |
| | | minSdkVersion 17 |
| | | targetSdkVersion 29 |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <selector xmlns:android="http://schemas.android.com/apk/res/android"> |
| | | |
| | | <item android:drawable="@drawable/ic_novel_highlight" android:state_checked="true"></item> |
| | | <item android:drawable="@drawable/ic_novel" android:state_checked="false"></item> |
| | | |
| | | </selector> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <shape xmlns:android="http://schemas.android.com/apk/res/android"> |
| | | |
| | | <corners android:radius="10dp" /> |
| | | <solid android:color="@color/white" /> |
| | | </shape> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <shape xmlns:android="http://schemas.android.com/apk/res/android"> |
| | | |
| | | <solid android:color="#FFEBEBEB"></solid> |
| | | <corners android:radius="20dp"></corners> |
| | | |
| | | </shape> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <shape xmlns:android="http://schemas.android.com/apk/res/android"> |
| | | <solid android:color="#FFFFEF6B"></solid> |
| | | <corners android:radius="20dp"></corners> |
| | | <stroke android:width="1px" android:color="#FF64A300"></stroke> |
| | | </shape> |
| | |
| | | <stroke |
| | | android:width="1dp" |
| | | android:color="#885E24"></stroke> |
| | | <padding |
| | | android:bottom="6dp" |
| | | android:left="9dp" |
| | | android:right="9dp" |
| | | android:top="6dp"></padding> |
| | | |
| | | </shape> |
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="match_parent" |
| | | android:background="@color/page_content_bg_color" |
| | | android:orientation="vertical"> |
| | | |
| | | <include layout="@layout/view_activity_top_navbar"></include> |
| | | |
| | | <FrameLayout |
| | | android:id="@+id/fl_container" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="0dp" |
| | | android:layout_weight="1"></FrameLayout> |
| | | </LinearLayout> |
New file |
| | |
| | | <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent"> |
| | | |
| | | |
| | | <androidx.viewpager.widget.ViewPager |
| | | android:id="@+id/vp_draw_videos" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent"> |
| | | |
| | | |
| | | </androidx.viewpager.widget.ViewPager> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content"> |
| | | |
| | | <View |
| | | android:layout_width="0dp" |
| | | android:layout_height="1dp" |
| | | android:layout_weight="1"> |
| | | |
| | | |
| | | </View> |
| | | |
| | | <net.lucode.hackware.magicindicator.MagicIndicator |
| | | android:id="@+id/magic_indicator" |
| | | android:layout_width="0dp" |
| | | android:layout_height="32sp" |
| | | android:layout_marginTop="10dp" |
| | | android:layout_weight="2" |
| | | android:gravity="center" /> |
| | | |
| | | <View |
| | | android:layout_width="0dp" |
| | | android:layout_height="1dp" |
| | | android:layout_weight="1"> |
| | | |
| | | |
| | | </View> |
| | | |
| | | |
| | | </LinearLayout> |
| | | |
| | | |
| | | </FrameLayout> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:background="@color/white" |
| | | android:orientation="vertical"> |
| | | |
| | | |
| | | <FrameLayout |
| | | android:layout_marginTop="7.5dp" |
| | | android:layout_marginBottom="7.5dp" |
| | | android:layout_width="228dp" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center_horizontal" |
| | | android:background="@drawable/shape_feed_videos_nav_bg"> |
| | | |
| | | <net.lucode.hackware.magicindicator.MagicIndicator |
| | | android:id="@+id/magic_indicator" |
| | | android:layout_width="match_parent" |
| | | android:layout_margin="2.5dp" |
| | | android:layout_height="20dp" |
| | | android:padding="0dp" |
| | | android:layout_gravity="center" /> |
| | | |
| | | </FrameLayout> |
| | | |
| | | |
| | | <androidx.viewpager.widget.ViewPager |
| | | android:id="@+id/vp_feed_videos" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="0dp" |
| | | android:layout_weight="1"> |
| | | |
| | | |
| | | </androidx.viewpager.widget.ViewPager> |
| | | |
| | | |
| | | </LinearLayout> |
| | |
| | | <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:background="@color/theme" |
| | | android:background="@color/white" |
| | | android:orientation="vertical"> |
| | | |
| | | <FrameLayout |
| | | android:id="@+id/fl_content" |
| | | <com.weikou.beibeivideo.widget.MySwipeRefreshLayout |
| | | android:id="@+id/srl_ks" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent"></FrameLayout> |
| | | android:layout_height="match_parent"> |
| | | |
| | | <FrameLayout |
| | | android:id="@+id/fl_content" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent"></FrameLayout> |
| | | </com.weikou.beibeivideo.widget.MySwipeRefreshLayout> |
| | | |
| | | </FrameLayout> |
| | |
| | | android:background="@drawable/shape_vip_bg" |
| | | android:gravity="center_vertical" |
| | | android:orientation="horizontal" |
| | | android:padding="9dp"> |
| | | android:padding="7dp"> |
| | | |
| | | <ImageView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:src="@drawable/icon_vip_logo"></ImageView> |
| | | <FrameLayout |
| | | android:layout_width="35dp" |
| | | android:layout_height="35dp"> |
| | | |
| | | <ImageView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_gravity="center" |
| | | android:src="@drawable/icon_vip_logo"></ImageView> |
| | | |
| | | </FrameLayout> |
| | | |
| | | |
| | | <TextView |
| | | android:layout_width="wrap_content" |
| | |
| | | android:layout_marginLeft="9dp" |
| | | android:text="开通VIP,看蓝光院线大片!" |
| | | android:textColor="#ff885e24" |
| | | android:textSize="12sp" /> |
| | | android:textSize="14sp" /> |
| | | |
| | | <View |
| | | android:layout_width="0dp" |
| | |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_vip_open" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_width="68dp" |
| | | android:layout_height="25dp" |
| | | android:layout_marginRight="4dp" |
| | | android:background="@drawable/shape_vip_open_btn" |
| | | android:gravity="center" |
| | | android:text="开通会员" |
| | | android:textColor="#ff885e24" |
| | | |
| | | android:textSize="10sp" /> |
| | | android:textSize="12sp" /> |
| | | |
| | | </LinearLayout> |
| | | |
| | | |
| | | <com.lcjian.library.widget.RatioLayout xmlns:app="http://schemas.android.com/apk/res-auto" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginLeft="12dp" |
| | | android:layout_marginTop="8.5dp" |
| | | android:layout_marginRight="12dp" |
| | | app:ratio="0.1369"> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:background="@drawable/ic_mine_goldcorn_bg" |
| | | android:gravity="center_vertical" |
| | | android:orientation="horizontal" |
| | | android:padding="7dp"> |
| | | |
| | | <FrameLayout |
| | | android:layout_width="35dp" |
| | | android:layout_height="35dp"> |
| | | |
| | | <ImageView |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:src="@drawable/icon_mine_goldcorn"></ImageView> |
| | | </FrameLayout> |
| | | |
| | | |
| | | <TextView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginLeft="9dp" |
| | | android:text="赚影视豆,免费看大片" |
| | | android:textColor="#FF007A06" |
| | | android:textSize="14sp" /> |
| | | |
| | | <View |
| | | android:layout_width="0dp" |
| | | android:layout_height="1dp" |
| | | android:layout_weight="1"></View> |
| | | |
| | | <TextView |
| | | android:id="@+id/tv_goldcorn" |
| | | android:layout_width="68dp" |
| | | android:layout_height="25dp" |
| | | android:layout_marginRight="4dp" |
| | | android:background="@drawable/shape_mine_goldcorn_btn_bg" |
| | | android:gravity="center" |
| | | android:text="影视豆" |
| | | android:textColor="#FF007A06" |
| | | android:textSize="12sp" /> |
| | | |
| | | </LinearLayout> |
| | | |
| | | </com.lcjian.library.widget.RatioLayout> |
| | | |
| | | |
| | | <com.lcjian.library.widget.RatioLayout |
| | | android:id="@+id/rl_banner" |
| | | android:layout_width="match_parent" |
| | |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:orientation="horizontal" |
| | | android:paddingTop="1dp" |
| | | android:paddingTop="8dp" |
| | | android:paddingBottom="8dp"> |
| | | |
| | | <RadioButton |
| | |
| | | android:textSize="10sp" /> |
| | | |
| | | <RadioButton |
| | | android:id="@+id/rb_guess_like" |
| | | android:id="@+id/rb_nav_draw_video" |
| | | android:layout_width="0dp" |
| | | android:layout_height="wrap_content" |
| | | android:layout_weight="1" |
| | |
| | | |
| | | |
| | | <RadioButton |
| | | android:id="@+id/rb_gold_corn" |
| | | android:layout_width="0dp" |
| | | android:layout_height="wrap_content" |
| | | android:layout_weight="1" |
| | | android:button="@null" |
| | | android:drawableTop="@drawable/selector_nav_gold_corn" |
| | | android:drawablePadding="4dp" |
| | | android:gravity="center_horizontal" |
| | | android:text="影视豆" |
| | | android:textAppearance="?android:attr/textAppearanceSmall" |
| | | android:textColor="@color/selector_bottom_bar_text" |
| | | android:textSize="10sp" /> |
| | | |
| | | |
| | | |
| | | |
| | | <RadioButton |
| | | android:id="@+id/rb_nav_discover" |
| | | android:layout_width="0dp" |
| | | android:layout_height="wrap_content" |
| | |
| | | android:drawableTop="@drawable/selector_discover" |
| | | android:drawablePadding="4dp" |
| | | android:gravity="center_horizontal" |
| | | android:text="@string/discover" |
| | | android:text="发现" |
| | | android:textAppearance="?android:attr/textAppearanceSmall" |
| | | android:textColor="@color/selector_bottom_bar_text" |
| | | android:textSize="10sp" /> |
| | | |
| | | |
| | | |
| | | |
| | | <RadioButton |
| | | android:id="@+id/rb_nav_novel" |
| | | android:layout_width="0dp" |
| | | android:layout_height="wrap_content" |
| | | android:layout_weight="1" |
| | | android:button="@null" |
| | | android:drawableTop="@drawable/selector_novel" |
| | | android:drawablePadding="4dp" |
| | | android:gravity="center_horizontal" |
| | | android:text="小说" |
| | | android:textAppearance="?android:attr/textAppearanceSmall" |
| | | android:textColor="@color/selector_bottom_bar_text" |
| | | android:textSize="10sp" /> |
| | |
| | | <resources> |
| | | <string name="app_name">影视大全布丸</string> |
| | | <string name="recommend">推荐</string> |
| | | <string name="recommend">刷视频</string> |
| | | <string name="category">分类</string> |
| | | <string name="discover">发现</string> |
| | | <string name="mine">我的</string> |
| | |
| | | import com.alibaba.baichuan.android.trade.AlibcTradeSDK; |
| | | import com.alibaba.baichuan.android.trade.callback.AlibcTradeInitCallback; |
| | | import com.baidu.mobads.AppActivity; |
| | | import com.bytedance.novel.pangolin.NovelConfig; |
| | | import com.bytedance.novel.pangolin.NovelSDK; |
| | | import com.bytedance.novel.pangolin.PangolinDocker; |
| | | import com.bytedance.novel.pangolin.data.NormalFontType; |
| | | import com.bytedance.novel.pangolin.data.ReaderFontType; |
| | | import com.bytedance.sdk.dp.DPSdk; |
| | | import com.bytedance.sdk.dp.DPSdkConfig; |
| | | import com.bytedance.sdk.openadsdk.TTAdSdk; |
| | | import com.funshion.playsdk.register.IAuthCodeGetter; |
| | | import com.kwad.sdk.api.KsAdSDK; |
| | |
| | | import com.weikou.beibeivideo.util.ad.GDTConstant; |
| | | import com.weikou.beibeivideo.util.ad.TTAdManagerHolder; |
| | | import com.weikou.beibeivideo.util.downutil.StringUtils; |
| | | import com.yeshi.appupdate.util.PackageUtils2; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.greenrobot.eventbus.EventBus; |
| | |
| | | |
| | | initWX(application); |
| | | initX5(application); |
| | | //百度内容联盟 |
| | | try { |
| | | AppActivity.setActionBarColorTheme(AppActivity.ActionBarColorTheme.ACTION_BAR_WHITE_THEME); |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | initNovel(application); |
| | | initDPSDK(application); |
| | | } |
| | | |
| | | |
| | |
| | | .build()); |
| | | } |
| | | |
| | | private static void initNovel(Application application) { |
| | | if (!AdUtil.isCanInitCSJ()) { |
| | | return; |
| | | } |
| | | |
| | | NovelConfig config = new NovelConfig.Builder() |
| | | .appName(application.getString(R.string.app_name)) //接入小说SDK的App的英文名 必填 |
| | | .appVersionName(PackageUtils2.getVersionName(application)) //接入小说SDKApp的版本名称 必填 |
| | | .appVersionCode(PackageUtils2.getVersionCode(application)) //接入小说SDK App的版本号 必填 |
| | | .channel(ManifestDataUtil.getAppMetaData(application, "UMENG_CHANNEL")) //渠道号维度。开发者自定义字符串即可(建议不要包含test)。选填 |
| | | .initInnerApplog(true) // 是否使用小说sdk来初始化applog sdk。默认为false,需要开发者在App中单独初始化applog sdk,且必须在小说sdk之前初始化。 |
| | | .initInnerOpenAdSdk(true) //是否使用小说sdk来初始化广告sdk,如果为true,需要设置siteId。默认为false,需开发者在App中单独初始化广告sdk并在小说sdk之前初始化。 |
| | | .jsonFileName("SDK_Setting_5095354.json")//json配置文件的名称 必填 |
| | | .normalFontSize(NormalFontType.NORMAL) //全局字号大小 可选 |
| | | .readerFontSize(ReaderFontType.TWO) //阅读器字号大小 可选 |
| | | .build(); |
| | | NovelSDK.INSTANCE.attach(new PangolinDocker(config), application); |
| | | } |
| | | |
| | | private static boolean dpSDKIninted; |
| | | |
| | | public static void initDPSDK(Application application) { |
| | | if (!AdUtil.isCanInitCSJ()) { |
| | | return; |
| | | } |
| | | if (!dpSDKIninted) { |
| | | DPSdkConfig.Builder configBuilder = new DPSdkConfig.Builder() |
| | | .debug(true) |
| | | .preloadDraw(true) |
| | | .needInitAppLog(false) |
| | | .setIsAndroidx(true) |
| | | .initListener(new DPSdkConfig.InitListener() { |
| | | @Override |
| | | public void onInitComplete(boolean b) { |
| | | dpSDKIninted = b; |
| | | } |
| | | }) //接入了红包功能需要传入的参数,没有接入的话可以忽略该配置 |
| | | // .luckConfig(new DPSdkConfig.LuckConfig().application(application).enableLuck(false)) |
| | | // .liveConfig(new DPSdkConfig.LiveConfig()) |
| | | |
| | | ;//若您需要接入直播,参考「直播接入文档」;否则可忽略此参数。 |
| | | DPSdk.init(application, "SDK_Setting_5095354.json", configBuilder.build()); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | class MyActivityLifecycleCallbacks implements Application.ActivityLifecycleCallbacks { |
| | | private int mFinalCount; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void onAdClick() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onNoAd() { |
| | | |
| | | } |
| | |
| | | * @author Administrator |
| | | */ |
| | | public class AdTag implements Parcelable { |
| | | |
| | | public AdTag(){ |
| | | |
| | | } |
| | | |
| | | @Expose |
| | | private String id; |
| | | @Expose |
| | |
| | | * |
| | | */ |
| | | public class AdminInfo implements Serializable { |
| | | |
| | | public AdminInfo(){ |
| | | |
| | | } |
| | | |
| | | /** |
| | | * serialVersionUID |
| | |
| | | import com.google.gson.annotations.Expose; |
| | | |
| | | public class PlayUrl implements Serializable { |
| | | |
| | | public PlayUrl(){ |
| | | |
| | | } |
| | | /** |
| | | * |
| | | */ |
| | |
| | | */ |
| | | public class VideoDetailInfo implements Serializable { |
| | | |
| | | public VideoDetailInfo(){ |
| | | |
| | | } |
| | | |
| | | /** |
| | | * serialVersionUID |
| | | */ |
| | |
| | | private String eId; |
| | | @Expose |
| | | private String picture; |
| | | @Expose |
| | | private String tag; |
| | | |
| | | private VideoInfo video; |
| | | |
| | |
| | | this.tag = tag; |
| | | } |
| | | |
| | | private String tag; |
| | | |
| | | } |
| | |
| | | */ |
| | | public class VideoInfo implements Serializable { |
| | | |
| | | public VideoInfo() { |
| | | |
| | | } |
| | | |
| | | /** |
| | | * serialVersionUID |
| | | */ |
| | |
| | | this.director = director; |
| | | } |
| | | |
| | | public static class VideoAlbumMoreInfo implements Serializable{ |
| | | public static class VideoAlbumMoreInfo implements Serializable { |
| | | |
| | | public VideoAlbumMoreInfo(){ |
| | | |
| | | } |
| | | |
| | | @Expose |
| | | private String name; |
| | | @Expose |
| | | private int jumpPosition; |
| | | |
| | | public String getName() { |
| | |
| | | */ |
| | | public class VideoResource implements Serializable { |
| | | |
| | | public VideoResource(){ |
| | | |
| | | } |
| | | |
| | | /** |
| | | * serialVersionUID |
| | | */ |
| | |
| | | */ |
| | | public class VideoType implements Serializable { |
| | | |
| | | public VideoType(){ |
| | | |
| | | } |
| | | |
| | | /** |
| | | * serialVersionUID |
| | | */ |
| | |
| | | exitApp("exitApp"),//APP退出广告 |
| | | videoSearch("videoSearch"),//搜索页广告 |
| | | videoDetailFullVideo("videoDetailFullVideo"),//视频全屏广告 |
| | | pptvNoAdReward("pptvNoAdReward")//PPTV无广告激励视频 |
| | | pptvNoAdReward("pptvNoAdReward"),//PPTV无广告激励视频 |
| | | homeInterstitial("homeInterstitial")//首页插屏 |
| | | ; |
| | | |
| | | private String positionName; |
| | |
| | | public class HomeClass extends VideoType { |
| | | |
| | | @Expose |
| | | private String dataType;//数据类型 "recommend"-推荐 "class"-分类 "novel"-小说 "common"-常见 |
| | | private String dataType;//数据类型 "recommend"-推荐 "class"-分类 "novel"-小说 "common"-常见 "feedVideos"-feed流 |
| | | |
| | | //数据Key |
| | | @Expose |
| | |
| | | import android.widget.ImageView; |
| | | import android.widget.TextView; |
| | | |
| | | import com.bytedance.sdk.openadsdk.AdSlot; |
| | | import com.google.gson.Gson; |
| | | import com.lcjian.library.dialog.DialogUtil; |
| | | import com.lcjian.library.util.ScreenUtils; |
| | |
| | | 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.KSConstant; |
| | | import com.weikou.beibeivideo.util.ui.TopStatusSettings; |
| | | |
| | | import org.apache.http.Header; |
| | |
| | | super.onPause(); |
| | | } |
| | | |
| | | |
| | | private String getDay(long time) { |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String date = format.format(new Date(time)); |
| | |
| | | |
| | | AdUtil.saveAdConfig(getApplicationContext(), ad); |
| | | AdUtil.AD_TYPE splash = AdUtil.getAdType(getApplicationContext(), AdPositionEnum.splash); |
| | | //是否在上线 |
| | | if (AdUtil.getAdType(getApplicationContext(), AdPositionEnum.splashHotStart) == null) { |
| | | KSConstant.PID_FEED = 8010000022L; |
| | | KSConstant.PID_FULL_VIDEO = 8010000015L; |
| | | //广告下载二次确认框 |
| | | |
| | | } |
| | | |
| | | |
| | | String pid = AdUtil.getAdPid(getApplicationContext(), AdPositionEnum.splash); |
| | | if (StringUtils.isBlank(pid)) { |
| | | if (splash != null) { |
| | |
| | | import androidx.annotation.Nullable; |
| | | import androidx.fragment.app.Fragment; |
| | | |
| | | import android.util.Log; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | |
| | | */ |
| | | public class SplashADFragment extends Fragment implements View.OnClickListener { |
| | | |
| | | private static final String TAG = "SplashADFragment"; |
| | | private LinearLayout ll_input; |
| | | private TextView ad_close_time; |
| | | private FrameLayout fl_ad; |
| | |
| | | if (adLoadResultListener != null) |
| | | adLoadResultListener.onNoAd(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onAdClick() { |
| | | if (adLoadResultListener != null) |
| | | adLoadResultListener.onAdClick(); |
| | | } |
| | | }); |
| | | } |
| | |
| | | ad_close_time.setVisibility(View.GONE); |
| | | } |
| | | |
| | | |
| | | boolean adClick = false; |
| | | |
| | | @Nullable |
| | | @Override |
| | | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
| | |
| | | |
| | | @Override |
| | | public void onClose() { |
| | | if (mAdShowListener != null) |
| | | //广告关闭点击之后先不忙调用关闭方法 |
| | | if (mAdShowListener != null && !adClick) { |
| | | mAdShowListener.onClose(); |
| | | Log.i(TAG, "广告关闭"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onAdClick() { |
| | | adClick = true; |
| | | Log.i(TAG, "广告点击"); |
| | | } |
| | | }); |
| | | } |
| | | return root; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void onResume() { |
| | | super.onResume(); |
| | | Log.i(TAG, "onResume"); |
| | | if (adClick) { |
| | | //广告关闭点击之后,回来时再跳转 |
| | | adClick = false; |
| | | if (mAdShowListener != null) |
| | | mAdShowListener.onClose(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onPause() { |
| | | super.onPause(); |
| | | Log.i(TAG, "onPause"); |
| | | } |
| | | |
| | | @Override |
| | | public void onClick(View v) { |
| | |
| | | |
| | | public void onAdLoad(SplashAdLoadInfo adLoadInfo); |
| | | |
| | | public void onAdClick(); |
| | | |
| | | public void onNoAd(); |
| | | |
| | | public void onClose(); |
| | |
| | | import com.weikou.beibeivideo.ui.mine.BrowserActivity; |
| | | import com.weikou.beibeivideo.ui.mine.WatchHistoryActivity; |
| | | import com.weikou.beibeivideo.ui.recommend.SearchActivity; |
| | | import com.weikou.beibeivideo.util.JsonUtil; |
| | | import com.weikou.beibeivideo.util.downutil.StringUtils; |
| | | import com.weikou.beibeivideo.util.ui.TopStatusSettings; |
| | | |
| | |
| | | findViewById(R.id.pager) |
| | | .setVisibility(View.VISIBLE); |
| | | |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | List<VideoType> videoType = gson.fromJson( |
| | | List<VideoType> videoType = JsonUtil.videoGson.fromJson( |
| | | jsonObject.getJSONObject("Data") |
| | | .getJSONArray("data").toString(), |
| | | new TypeToken<List<VideoType>>() { |
| | |
| | | import com.weikou.beibeivideo.entity.video.VideoContent; |
| | | import com.weikou.beibeivideo.ui.video.VideoCloumn1Adapter; |
| | | import com.weikou.beibeivideo.util.DimenUtils; |
| | | import com.weikou.beibeivideo.util.JsonUtil; |
| | | import com.weikou.beibeivideo.util.ui.DividerItemDecoration; |
| | | import com.weikou.beibeivideo.R; |
| | | |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | List<VideoInfo> videoInfos = gson.fromJson( |
| | | |
| | | List<VideoInfo> videoInfos = JsonUtil.videoGson.fromJson( |
| | | jsonObject.getJSONObject("Data") |
| | | .getJSONArray("data").toString(), |
| | | new TypeToken<List<VideoInfo>>() { |
| | |
| | | import com.weikou.beibeivideo.entity.video.VideoContent; |
| | | import com.weikou.beibeivideo.ui.video.VideoCloumn1Adapter; |
| | | import com.weikou.beibeivideo.util.DimenUtils; |
| | | import com.weikou.beibeivideo.util.JsonUtil; |
| | | import com.weikou.beibeivideo.util.ui.DividerItemDecoration; |
| | | |
| | | import org.apache.http.Header; |
| | |
| | | System.out.println("hhhhh====" |
| | | + jsonObject.getJSONObject("Data") |
| | | .toString()); |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | List<VideoInfo> videoInfos = gson.fromJson( |
| | | List<VideoInfo> videoInfos = JsonUtil.videoGson.fromJson( |
| | | jsonObject.getJSONObject("Data") |
| | | .getJSONArray("data").toString(), |
| | | new TypeToken<List<VideoInfo>>() { |
| | |
| | | import com.weikou.beibeivideo.ui.category.NewStarAdapter; |
| | | import com.weikou.beibeivideo.ui.category.bean.HotStar; |
| | | import com.weikou.beibeivideo.R; |
| | | import com.weikou.beibeivideo.util.JsonUtil; |
| | | import com.weikou.beibeivideo.widget.MySwipeRefreshLayout; |
| | | |
| | | import org.apache.http.Header; |
| | |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | List<HotStar> hotStarList = gson.fromJson( |
| | | |
| | | List<HotStar> hotStarList = JsonUtil.videoGson.fromJson( |
| | | jsonObject.getJSONObject("Data") |
| | | .getJSONArray("data").toString(), |
| | | new TypeToken<List<HotStar>>() { |
| | |
| | | import com.weikou.beibeivideo.ui.BaseActivity; |
| | | import com.weikou.beibeivideo.ui.login.LoginActivity; |
| | | import com.weikou.beibeivideo.R; |
| | | import com.weikou.beibeivideo.util.JsonUtil; |
| | | import com.weikou.beibeivideo.util.ui.TopStatusSettings; |
| | | import com.weikou.beibeivideo.widget.MySwipeRefreshLayout; |
| | | |
| | |
| | | return; |
| | | } |
| | | |
| | | Gson gson = new GsonBuilder() |
| | | .setPrettyPrinting() |
| | | .setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | List<Attention> list = gson.fromJson(jsonObject |
| | | List<Attention> list = JsonUtil.videoGson.fromJson(jsonObject |
| | | .getJSONObject("Data").getJSONArray("data") |
| | | .toString(), new TypeToken<List<Attention>>() { |
| | | }.getType()); |
| | |
| | | import com.weikou.beibeivideo.entity.VideoInfo; |
| | | import com.weikou.beibeivideo.ui.BaseActivity; |
| | | import com.weikou.beibeivideo.ui.media.VideoDetailActivity2; |
| | | import com.weikou.beibeivideo.util.JsonUtil; |
| | | import com.weikou.beibeivideo.util.ui.TopStatusSettings; |
| | | import com.weikou.beibeivideo.widget.MySwipeRefreshLayout; |
| | | |
| | |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | mVideoInfos.clear(); |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | List<VideoInfo> videoInfos = gson.fromJson( |
| | | List<VideoInfo> videoInfos = JsonUtil.videoGson.fromJson( |
| | | jsonObject.getJSONObject("Data") |
| | | .getJSONArray("data").toString(), |
| | | new TypeToken<List<VideoInfo>>() { |
| | |
| | | fl_download_failure.setVisibility(View.GONE); |
| | | lv_video.setVisibility(View.VISIBLE); |
| | | |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | List<VideoInfo> videoInfos = gson.fromJson( |
| | | List<VideoInfo> videoInfos = JsonUtil.videoGson.fromJson( |
| | | jsonObject.getJSONObject("Data") |
| | | .getJSONArray("data").toString(), |
| | | new TypeToken<List<VideoInfo>>() { |
| | |
| | | import com.weikou.beibeivideo.entity.VideoType; |
| | | import com.weikou.beibeivideo.ui.video.VideoColumn2Adapter; |
| | | import com.weikou.beibeivideo.util.DimenUtils; |
| | | import com.weikou.beibeivideo.util.JsonUtil; |
| | | import com.weikou.beibeivideo.util.UserUtil; |
| | | import com.weikou.beibeivideo.util.ui.DividerItemDecoration; |
| | | import com.weikou.beibeivideo.R; |
| | |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | iv_download_failure.setVisibility(View.GONE); |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | List<VideoInfo> videoInfos = gson.fromJson( |
| | | List<VideoInfo> videoInfos = JsonUtil.videoGson.fromJson( |
| | | jsonObject.getJSONObject("Data") |
| | | .getJSONArray("data").toString(), |
| | | new TypeToken<List<VideoInfo>>() { |
| | |
| | | import com.weikou.beibeivideo.ui.MyRetainViewFragment; |
| | | import com.weikou.beibeivideo.ui.category.CategoryAdapter; |
| | | import com.weikou.beibeivideo.ui.recommend.SearchActivity; |
| | | import com.weikou.beibeivideo.util.JsonUtil; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | |
| | | try { |
| | | snapshot = cache.get(getKey("getCategoriesChannel")); |
| | | if (snapshot != null) { |
| | | Gson gson = new GsonBuilder() |
| | | .setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | List<VideoType> categories = gson.fromJson( |
| | | List<VideoType> categories = JsonUtil.videoGson.fromJson( |
| | | snapshot.getString(0), |
| | | new TypeToken<List<VideoType>>() { |
| | | }.getType()); |
| | |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | List<VideoType> categories = gson.fromJson( |
| | | |
| | | List<VideoType> categories = JsonUtil.videoGson.fromJson( |
| | | jsonObject.getJSONObject("Data") |
| | | .getJSONArray("data").toString(), |
| | | new TypeToken<List<VideoType>>() { |
New file |
| | |
| | | package com.weikou.beibeivideo.ui.main; |
| | | |
| | | import android.os.Bundle; |
| | | import android.util.Log; |
| | | import android.view.View; |
| | | |
| | | import com.bytedance.sdk.dp.DPSdk; |
| | | import com.bytedance.sdk.dp.DPWidgetDrawParams; |
| | | import com.bytedance.sdk.dp.DPWidgetGridParams; |
| | | import com.bytedance.sdk.dp.IDPGridListener; |
| | | import com.bytedance.sdk.dp.IDPNewsListener; |
| | | import com.bytedance.sdk.dp.IDPWidget; |
| | | import com.weikou.beibeivideo.R; |
| | | import com.weikou.beibeivideo.ui.MyRetainViewFragment; |
| | | import com.weikou.beibeivideo.widget.MySwipeRefreshLayout; |
| | | |
| | | import java.util.Map; |
| | | |
| | | import androidx.fragment.app.Fragment; |
| | | import androidx.fragment.app.FragmentManager; |
| | | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; |
| | | |
| | | /** |
| | | * 主页面--抖音视频流 |
| | | */ |
| | | public class DYFeedFragment extends MyRetainViewFragment { |
| | | private static final String TAG = "DYFeedFragment"; |
| | | private FragmentManager fragmentManager; |
| | | private IDPWidget mIDPWidget; |
| | | private MySwipeRefreshLayout swipeRefreshLayout; |
| | | |
| | | public DYFeedFragment() { |
| | | super(); |
| | | } |
| | | |
| | | public DYFeedFragment(FragmentManager fragmentManager) { |
| | | super(); |
| | | this.fragmentManager = fragmentManager; //fragmentManager; |
| | | setName(DYNewsFragment.class.getName()); |
| | | } |
| | | |
| | | private Fragment fragment; |
| | | |
| | | |
| | | @Override |
| | | public int getContentResource() { |
| | | return R.layout.fragment_ks_video; |
| | | } |
| | | |
| | | @Override |
| | | public void onResume() { |
| | | super.onResume(); |
| | | if (mIDPWidget != null && mIDPWidget.getFragment() != null) { |
| | | mIDPWidget.getFragment().onResume(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onPause() { |
| | | super.onPause(); |
| | | if (mIDPWidget != null && mIDPWidget.getFragment() != null) { |
| | | mIDPWidget.getFragment().onPause(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void setUserVisibleHint(boolean isVisibleToUser) { |
| | | super.setUserVisibleHint(isVisibleToUser); |
| | | if (mIDPWidget != null && mIDPWidget.getFragment() != null) { |
| | | mIDPWidget.getFragment().setUserVisibleHint(isVisibleToUser); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onHiddenChanged(boolean hidden) { |
| | | super.onHiddenChanged(hidden); |
| | | if (mIDPWidget != null && mIDPWidget.getFragment() != null) { |
| | | mIDPWidget.getFragment().onHiddenChanged(hidden); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onCreateView(View contentView, Bundle savedInstanceState) { |
| | | Log.i(TAG, "onCreateView"); |
| | | swipeRefreshLayout = contentView.findViewById(R.id.srl_ks); |
| | | swipeRefreshLayout.setEnabled(true); |
| | | swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { |
| | | @Override |
| | | public void onRefresh() { |
| | | mIDPWidget.refresh(); |
| | | } |
| | | }); |
| | | init(); |
| | | } |
| | | |
| | | private void init() { |
| | | mIDPWidget = DPSdk.factory().createDoubleFeed(DPWidgetGridParams.obtain().listener(new IDPGridListener() { |
| | | @Override |
| | | public void onDPRefreshFinish() { |
| | | super.onDPRefreshFinish(); |
| | | swipeRefreshLayout.setRefreshing(false); |
| | | } |
| | | }) |
| | | ); |
| | | Fragment fragment = mIDPWidget.getFragment(); |
| | | if (fragment != null) { |
| | | getChildFragmentManager().beginTransaction().replace(R.id.fl_content, fragment).commitAllowingStateLoss(); |
| | | } |
| | | } |
| | | |
| | | private static void log(String msg) { |
| | | Log.d(TAG, String.valueOf(msg)); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.weikou.beibeivideo.ui.main; |
| | | |
| | | import android.os.Bundle; |
| | | import android.util.Log; |
| | | import android.view.View; |
| | | |
| | | import com.bytedance.sdk.dp.DPSdk; |
| | | import com.bytedance.sdk.dp.DPWidgetNewsParams; |
| | | import com.bytedance.sdk.dp.IDPNewsListener; |
| | | import com.bytedance.sdk.dp.IDPWidget; |
| | | import com.kwad.sdk.api.KsAdSDK; |
| | | import com.kwad.sdk.api.KsContentPage; |
| | | import com.kwad.sdk.api.KsFeedPage; |
| | | import com.kwad.sdk.api.KsScene; |
| | | import com.weikou.beibeivideo.R; |
| | | import com.weikou.beibeivideo.ui.MyRetainViewFragment; |
| | | import com.weikou.beibeivideo.util.ad.KSConstant; |
| | | import com.weikou.beibeivideo.widget.MySwipeRefreshLayout; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import androidx.annotation.Nullable; |
| | | import androidx.fragment.app.Fragment; |
| | | import androidx.fragment.app.FragmentManager; |
| | | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; |
| | | |
| | | /** |
| | | * 主页面--快手视频 |
| | | */ |
| | | public class DYNewsFragment extends MyRetainViewFragment { |
| | | private static final String TAG = "DYNewsFragment"; |
| | | private FragmentManager fragmentManager; |
| | | private IDPWidget mIDPWidget; |
| | | private MySwipeRefreshLayout swipeRefreshLayout; |
| | | |
| | | public DYNewsFragment() { |
| | | super(); |
| | | } |
| | | |
| | | public DYNewsFragment(FragmentManager fragmentManager) { |
| | | super(); |
| | | this.fragmentManager = fragmentManager; //fragmentManager; |
| | | setName(DYNewsFragment.class.getName()); |
| | | } |
| | | |
| | | private Fragment fragment; |
| | | |
| | | |
| | | @Override |
| | | public int getContentResource() { |
| | | return R.layout.fragment_ks_video; |
| | | } |
| | | |
| | | @Override |
| | | public void onResume() { |
| | | super.onResume(); |
| | | if (mIDPWidget != null && mIDPWidget.getFragment() != null) { |
| | | mIDPWidget.getFragment().onResume(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onPause() { |
| | | super.onPause(); |
| | | if (mIDPWidget != null && mIDPWidget.getFragment() != null) { |
| | | mIDPWidget.getFragment().onPause(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void setUserVisibleHint(boolean isVisibleToUser) { |
| | | super.setUserVisibleHint(isVisibleToUser); |
| | | if (mIDPWidget != null && mIDPWidget.getFragment() != null) { |
| | | mIDPWidget.getFragment().setUserVisibleHint(isVisibleToUser); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onHiddenChanged(boolean hidden) { |
| | | super.onHiddenChanged(hidden); |
| | | if (mIDPWidget != null && mIDPWidget.getFragment() != null) { |
| | | mIDPWidget.getFragment().onHiddenChanged(hidden); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onCreateView(View contentView, Bundle savedInstanceState) { |
| | | Log.i(TAG, "onCreateView"); |
| | | swipeRefreshLayout = contentView.findViewById(R.id.srl_ks); |
| | | swipeRefreshLayout.setEnabled(false); |
| | | initNewsWidget(); |
| | | } |
| | | |
| | | private void initNewsWidget() { |
| | | mIDPWidget = DPSdk.factory().createNewsTabs(DPWidgetNewsParams.obtain() |
| | | .listener(new IDPNewsListener() { |
| | | @Override |
| | | public void onDPRefreshFinish() { |
| | | log("onDPRefreshFinish"); |
| | | } |
| | | |
| | | @Override |
| | | public void onDPNewsItemClick(Map<String, Object> map) { |
| | | log("onDPNewsItemClick"); |
| | | } |
| | | |
| | | @Override |
| | | public void onDPVideoPlay(Map<String, Object> map) { |
| | | log("onDPVideoPlay"); |
| | | } |
| | | |
| | | @Override |
| | | public void onDPVideoPause(Map<String, Object> map) { |
| | | log("onDPVideoPause"); |
| | | } |
| | | |
| | | @Override |
| | | public void onDPVideoContinue(Map<String, Object> map) { |
| | | log("onDPVideoContinue"); |
| | | } |
| | | |
| | | @Override |
| | | public void onDPVideoOver(Map<String, Object> map) { |
| | | log("onDPVideoOver"); |
| | | } |
| | | |
| | | @Override |
| | | public void onDPNewsDetailEnter(Map<String, Object> map) { |
| | | log("onDPNewsDetailEnter"); |
| | | } |
| | | |
| | | @Override |
| | | public void onDPNewsDetailExit(Map<String, Object> map) { |
| | | log("onDPNewsDetailExit"); |
| | | } |
| | | |
| | | |
| | | })); |
| | | |
| | | Fragment fragment = mIDPWidget.getFragment(); |
| | | if (fragment != null) { |
| | | fragmentManager.beginTransaction().replace(R.id.fl_content, fragment).commitAllowingStateLoss(); |
| | | } |
| | | } |
| | | |
| | | private static void log(String msg) { |
| | | Log.d(TAG, String.valueOf(msg)); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.weikou.beibeivideo.ui.main; |
| | | |
| | | import android.content.Context; |
| | | import android.os.Bundle; |
| | | import android.util.Log; |
| | | import android.view.View; |
| | | |
| | | import com.bytedance.sdk.dp.DPSdk; |
| | | import com.bytedance.sdk.dp.DPWidgetDrawParams; |
| | | import com.bytedance.sdk.dp.DPWidgetNewsParams; |
| | | import com.bytedance.sdk.dp.IDPNewsListener; |
| | | import com.bytedance.sdk.dp.IDPWidget; |
| | | import com.kwad.sdk.api.KsAdSDK; |
| | | import com.kwad.sdk.api.KsContentPage; |
| | | import com.kwad.sdk.api.KsScene; |
| | | import com.weikou.beibeivideo.R; |
| | | import com.weikou.beibeivideo.ui.MyRetainViewFragment; |
| | | import com.weikou.beibeivideo.util.ad.KSConstant; |
| | | import com.weikou.beibeivideo.widget.MySwipeRefreshLayout; |
| | | |
| | | import java.util.Map; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | import androidx.annotation.Nullable; |
| | | import androidx.fragment.app.Fragment; |
| | | import androidx.fragment.app.FragmentManager; |
| | | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; |
| | | |
| | | /** |
| | | * 主页面--抖音沉浸式视频流 |
| | | */ |
| | | public class DYVideoFragment extends MyRetainViewFragment { |
| | | private static final String TAG = "DYVideoFragment"; |
| | | private IDPWidget mIDPWidget; |
| | | private MySwipeRefreshLayout swipeRefreshLayout; |
| | | |
| | | |
| | | public DYVideoFragment() { |
| | | super(); |
| | | setName(DYNewsFragment.class.getName()); |
| | | } |
| | | |
| | | @Override |
| | | public void onCreate(@Nullable Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | | Log.i(TAG, "onCreate"); |
| | | } |
| | | |
| | | @Override |
| | | public int getContentResource() { |
| | | return R.layout.fragment_ks_video; |
| | | } |
| | | |
| | | @Override |
| | | public void onResume() { |
| | | super.onResume(); |
| | | Log.i(TAG, "onResume"); |
| | | if (mIDPWidget != null && mIDPWidget.getFragment() != null) { |
| | | mIDPWidget.getFragment().onResume(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onPause() { |
| | | Log.i(TAG, "onPause"); |
| | | super.onPause(); |
| | | if (mIDPWidget != null && mIDPWidget.getFragment() != null) { |
| | | mIDPWidget.getFragment().onPause(); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void setUserVisibleHint(boolean isVisibleToUser) { |
| | | Log.i(TAG, "setUserVisibleHint:" + isVisibleToUser); |
| | | super.setUserVisibleHint(isVisibleToUser); |
| | | if (mIDPWidget != null && mIDPWidget.getFragment() != null) { |
| | | mIDPWidget.getFragment().setUserVisibleHint(isVisibleToUser); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onHiddenChanged(boolean hidden) { |
| | | Log.i(TAG, "onHiddenChanged:" + hidden); |
| | | super.onHiddenChanged(hidden); |
| | | if (mIDPWidget != null && mIDPWidget.getFragment() != null) { |
| | | mIDPWidget.getFragment().onHiddenChanged(hidden); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onCreateView(View contentView, Bundle savedInstanceState) { |
| | | Log.i(TAG, "onCreateView"); |
| | | swipeRefreshLayout = contentView.findViewById(R.id.srl_ks); |
| | | swipeRefreshLayout.setEnabled(false); |
| | | init(); |
| | | } |
| | | |
| | | private void init() { |
| | | mIDPWidget = DPSdk.factory().createDraw(DPWidgetDrawParams.obtain().hideClose(true, null) |
| | | .listener(new IDPNewsListener() { |
| | | @Override |
| | | public void onDPRefreshFinish() { |
| | | log("onDPRefreshFinish"); |
| | | } |
| | | |
| | | @Override |
| | | public void onDPNewsItemClick(Map<String, Object> map) { |
| | | log("onDPNewsItemClick"); |
| | | } |
| | | |
| | | @Override |
| | | public void onDPVideoPlay(Map<String, Object> map) { |
| | | log("onDPVideoPlay"); |
| | | } |
| | | |
| | | @Override |
| | | public void onDPVideoPause(Map<String, Object> map) { |
| | | log("onDPVideoPause"); |
| | | } |
| | | |
| | | @Override |
| | | public void onDPVideoContinue(Map<String, Object> map) { |
| | | log("onDPVideoContinue"); |
| | | } |
| | | |
| | | @Override |
| | | public void onDPVideoOver(Map<String, Object> map) { |
| | | log("onDPVideoOver"); |
| | | } |
| | | |
| | | @Override |
| | | public void onDPNewsDetailEnter(Map<String, Object> map) { |
| | | log("onDPNewsDetailEnter"); |
| | | } |
| | | |
| | | @Override |
| | | public void onDPNewsDetailExit(Map<String, Object> map) { |
| | | log("onDPNewsDetailExit"); |
| | | } |
| | | |
| | | |
| | | })); |
| | | |
| | | Fragment fragment = mIDPWidget.getFragment(); |
| | | if (fragment != null) { |
| | | getChildFragmentManager().beginTransaction().add(R.id.fl_content, fragment).commitAllowingStateLoss(); |
| | | } |
| | | } |
| | | |
| | | private static void log(String msg) { |
| | | Log.d(TAG, String.valueOf(msg)); |
| | | } |
| | | |
| | | @Override |
| | | public void onDetach() { |
| | | super.onDetach(); |
| | | Log.i(TAG, "onDetach"); |
| | | } |
| | | |
| | | @Override |
| | | public void onAttach(@NonNull Context context) { |
| | | super.onAttach(context); |
| | | Log.i(TAG, "onAttach"); |
| | | } |
| | | |
| | | @Override |
| | | public void onDestroy() { |
| | | super.onDestroy(); |
| | | if (mIDPWidget != null) { |
| | | mIDPWidget.destroy(); |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.weikou.beibeivideo.ui.main; |
| | | |
| | | import android.content.Context; |
| | | import android.graphics.Canvas; |
| | | import android.graphics.Color; |
| | | import android.graphics.Paint; |
| | | import android.graphics.RectF; |
| | | import android.graphics.Typeface; |
| | | import android.os.Build; |
| | | import android.os.Bundle; |
| | | import android.provider.CalendarContract; |
| | | import android.util.Log; |
| | | import android.view.Gravity; |
| | | import android.view.View; |
| | | import android.view.animation.Interpolator; |
| | | import android.view.animation.LinearInterpolator; |
| | | import android.widget.FrameLayout; |
| | | import android.widget.TextView; |
| | | |
| | | import com.kwad.sdk.api.KsAdSDK; |
| | | import com.kwad.sdk.api.KsContentPage; |
| | | import com.kwad.sdk.api.KsFeedPage; |
| | | import com.kwad.sdk.api.KsScene; |
| | | import com.lcjian.library.util.common.DimenUtils; |
| | | import com.weikou.beibeivideo.R; |
| | | import com.weikou.beibeivideo.ui.MyRetainViewFragment; |
| | | import com.weikou.beibeivideo.util.ad.AdUtil; |
| | | import com.weikou.beibeivideo.util.ad.KSConstant; |
| | | import com.weikou.beibeivideo.widget.MySwipeRefreshLayout; |
| | | |
| | | import net.lucode.hackware.magicindicator.FragmentContainerHelper; |
| | | import net.lucode.hackware.magicindicator.MagicIndicator; |
| | | import net.lucode.hackware.magicindicator.ViewPagerHelper; |
| | | import net.lucode.hackware.magicindicator.buildins.ArgbEvaluatorHolder; |
| | | import net.lucode.hackware.magicindicator.buildins.UIUtil; |
| | | import net.lucode.hackware.magicindicator.buildins.commonnavigator.CommonNavigator; |
| | | import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter; |
| | | import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerIndicator; |
| | | import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerTitleView; |
| | | import net.lucode.hackware.magicindicator.buildins.commonnavigator.indicators.LinePagerIndicator; |
| | | import net.lucode.hackware.magicindicator.buildins.commonnavigator.model.PositionData; |
| | | import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.ColorTransitionPagerTitleView; |
| | | import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.CommonPagerTitleView; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | import androidx.annotation.Nullable; |
| | | import androidx.fragment.app.Fragment; |
| | | import androidx.fragment.app.FragmentManager; |
| | | import androidx.fragment.app.FragmentStatePagerAdapter; |
| | | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; |
| | | import androidx.viewpager.widget.ViewPager; |
| | | |
| | | /** |
| | | * 主页面--快手视频 |
| | | */ |
| | | public class DrawVideoFragment extends MyRetainViewFragment { |
| | | private static final String TAG = "DrawVideoFragment"; |
| | | private FragmentManager fragmentManager; |
| | | private MagicIndicator magic_indicator; |
| | | private ViewPager vp_draw_videos; |
| | | |
| | | public DrawVideoFragment() { |
| | | super(); |
| | | } |
| | | |
| | | public DrawVideoFragment(FragmentManager fragmentManager) { |
| | | super(); |
| | | this.fragmentManager = fragmentManager; //fragmentManager; |
| | | setName(DrawVideoFragment.class.getName()); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public int getContentResource() { |
| | | return R.layout.fragment_draw_videos; |
| | | } |
| | | |
| | | @Override |
| | | public void onResume() { |
| | | super.onResume(); |
| | | Log.i(TAG, "onResume"); |
| | | } |
| | | |
| | | @Override |
| | | public void onPause() { |
| | | super.onPause(); |
| | | Log.i(TAG, "onPause"); |
| | | } |
| | | |
| | | @Override |
| | | public void onCreate(@Nullable Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | | Log.i(TAG, "onCreate"); |
| | | } |
| | | |
| | | private void initView(View view) { |
| | | magic_indicator = view.findViewById(R.id.magic_indicator); |
| | | vp_draw_videos = view.findViewById(R.id.vp_draw_videos); |
| | | } |
| | | |
| | | @Override |
| | | public void onCreateView(View contentView, Bundle savedInstanceState) { |
| | | Log.i(TAG, "onCreateView"); |
| | | initView(contentView); |
| | | init(); |
| | | } |
| | | |
| | | public void init() { |
| | | vp_draw_videos.setAdapter(new DrawVideoTypesAdapter(getChildFragmentManager())); |
| | | CommonNavigator commonNavigator = new CommonNavigator(getActivity()); |
| | | commonNavigator.setAdapter(navigatorAdapter); |
| | | commonNavigator.setAdjustMode(true); |
| | | magic_indicator.setNavigator(commonNavigator); |
| | | ViewPagerHelper.bind(magic_indicator, vp_draw_videos); |
| | | vp_draw_videos.setCurrentItem(0); |
| | | if (getTypeCount() <= 1) { |
| | | magic_indicator.setVisibility(View.GONE); |
| | | } |
| | | } |
| | | |
| | | |
| | | private CommonNavigatorAdapter navigatorAdapter = new CommonNavigatorAdapter() { |
| | | |
| | | @Override |
| | | public int getCount() { |
| | | return getTypeCount(); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public IPagerTitleView getTitleView(final Context context, final int index) { |
| | | ColorTransitionPagerTitleView colorTransitionPagerTitleView = new ColorTransitionPagerTitleView(context); |
| | | colorTransitionPagerTitleView.setNormalColor(Color.parseColor("#80FFFFFF")); |
| | | colorTransitionPagerTitleView.setSelectedColor(Color.WHITE); |
| | | colorTransitionPagerTitleView.setText(index == 0 ? "热门" : "推荐"); |
| | | colorTransitionPagerTitleView.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View view) { |
| | | vp_draw_videos.setCurrentItem(index); |
| | | } |
| | | }); |
| | | colorTransitionPagerTitleView.setTextSize(18); |
| | | colorTransitionPagerTitleView.getPaint().setFakeBoldText(true); |
| | | colorTransitionPagerTitleView.setShadowLayer(3.0f,0,2,Color.parseColor("#80000000")); |
| | | |
| | | |
| | | return colorTransitionPagerTitleView; |
| | | } |
| | | |
| | | //此为tab指示器回调 |
| | | @Override |
| | | public IPagerIndicator getIndicator(Context context) { |
| | | LinePagerIndicator indicator = new LinePagerIndicator(context); |
| | | indicator.setColors(Color.WHITE); |
| | | indicator.setMode(LinePagerIndicator.MODE_WRAP_CONTENT); |
| | | indicator.setRoundRadius(5); |
| | | return indicator; |
| | | } |
| | | }; |
| | | |
| | | |
| | | class DrawVideoTypesAdapter extends FragmentStatePagerAdapter { |
| | | |
| | | private FragmentManager fm; |
| | | |
| | | public DrawVideoTypesAdapter(@NonNull FragmentManager fm) { |
| | | super(fm); |
| | | this.fm = fm; |
| | | } |
| | | |
| | | @Override |
| | | public int getItemPosition(@NonNull Object object) { |
| | | return super.getItemPosition(object); |
| | | } |
| | | |
| | | @NonNull |
| | | @Override |
| | | public Fragment getItem(int position) { |
| | | Log.i(TAG, "getItem:" + position); |
| | | if (getTypeCount() > 1) { |
| | | if (position == 0) { |
| | | return new DYVideoFragment(); |
| | | } else { |
| | | return new KSVideoFragment(); |
| | | } |
| | | } else { |
| | | return new KSVideoFragment(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public int getCount() { |
| | | return getTypeCount(); |
| | | } |
| | | } |
| | | |
| | | |
| | | private int getTypeCount() { |
| | | if (AdUtil.isCanInitCSJ()) { |
| | | return 2; |
| | | } else { |
| | | return 1; |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | |
New file |
| | |
| | | package com.weikou.beibeivideo.ui.main; |
| | | |
| | | import android.content.Context; |
| | | import android.graphics.Canvas; |
| | | import android.graphics.Color; |
| | | import android.graphics.Paint; |
| | | import android.graphics.RectF; |
| | | import android.os.Build; |
| | | import android.os.Bundle; |
| | | import android.util.Log; |
| | | import android.view.Gravity; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | | import android.view.animation.Interpolator; |
| | | import android.view.animation.LinearInterpolator; |
| | | |
| | | import com.kwad.sdk.api.KsAdSDK; |
| | | import com.kwad.sdk.api.KsContentPage; |
| | | import com.kwad.sdk.api.KsFeedPage; |
| | | import com.kwad.sdk.api.KsScene; |
| | | import com.weikou.beibeivideo.R; |
| | | import com.weikou.beibeivideo.ui.MyRetainViewFragment; |
| | | import com.weikou.beibeivideo.util.ad.AdUtil; |
| | | import com.weikou.beibeivideo.util.ad.KSConstant; |
| | | import com.weikou.beibeivideo.widget.MySwipeRefreshLayout; |
| | | |
| | | import net.lucode.hackware.magicindicator.FragmentContainerHelper; |
| | | import net.lucode.hackware.magicindicator.MagicIndicator; |
| | | import net.lucode.hackware.magicindicator.ViewPagerHelper; |
| | | import net.lucode.hackware.magicindicator.buildins.ArgbEvaluatorHolder; |
| | | import net.lucode.hackware.magicindicator.buildins.UIUtil; |
| | | import net.lucode.hackware.magicindicator.buildins.commonnavigator.CommonNavigator; |
| | | import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter; |
| | | import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerIndicator; |
| | | import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerTitleView; |
| | | import net.lucode.hackware.magicindicator.buildins.commonnavigator.indicators.LinePagerIndicator; |
| | | import net.lucode.hackware.magicindicator.buildins.commonnavigator.model.PositionData; |
| | | import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.ColorTransitionPagerTitleView; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | import androidx.annotation.Nullable; |
| | | import androidx.fragment.app.Fragment; |
| | | import androidx.fragment.app.FragmentManager; |
| | | import androidx.fragment.app.FragmentStatePagerAdapter; |
| | | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; |
| | | import androidx.viewpager.widget.ViewPager; |
| | | |
| | | /** |
| | | * 主页面--快手视频 |
| | | */ |
| | | public class FeedVideoFragment extends MyRetainViewFragment { |
| | | private static final String TAG = "KSFeedFragment"; |
| | | private ViewPager vp_feed_videos; |
| | | private MagicIndicator magic_indicator; |
| | | |
| | | public FeedVideoFragment() { |
| | | super(); |
| | | } |
| | | |
| | | public FeedVideoFragment(FragmentManager fragmentManager) { |
| | | super(); |
| | | setName(FeedVideoFragment.class.getName()); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public int getContentResource() { |
| | | return R.layout.fragment_feed_videos; |
| | | } |
| | | |
| | | @Override |
| | | public void onCreateView(View contentView, Bundle savedInstanceState) { |
| | | Log.i(TAG, "onCreateView"); |
| | | initView(contentView); |
| | | init(); |
| | | } |
| | | |
| | | private void initView(View view) { |
| | | magic_indicator = view.findViewById(R.id.magic_indicator); |
| | | vp_feed_videos = view.findViewById(R.id.vp_feed_videos); |
| | | } |
| | | |
| | | |
| | | public void init() { |
| | | vp_feed_videos.setAdapter(new FeedVideoTypesAdapter(getChildFragmentManager())); |
| | | CommonNavigator commonNavigator = new CommonNavigator(getActivity()); |
| | | commonNavigator.setAdapter(navigatorAdapter); |
| | | commonNavigator.setAdjustMode(true); |
| | | magic_indicator.setNavigator(commonNavigator); |
| | | ViewPagerHelper.bind(magic_indicator, vp_feed_videos); |
| | | vp_feed_videos.setCurrentItem(0); |
| | | if (getTypeCount() <= 1) { |
| | | magic_indicator.setVisibility(View.GONE); |
| | | } |
| | | } |
| | | |
| | | |
| | | private CommonNavigatorAdapter navigatorAdapter = new CommonNavigatorAdapter() { |
| | | |
| | | @Override |
| | | public int getCount() { |
| | | return getTypeCount(); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public IPagerTitleView getTitleView(final Context context, final int index) { |
| | | ColorTransitionPagerTitleView colorTransitionPagerTitleView = new ColorTransitionPagerTitleView(context); |
| | | colorTransitionPagerTitleView.setNormalColor(Color.parseColor("#FF717481")); |
| | | colorTransitionPagerTitleView.setSelectedColor(Color.parseColor("#FF159FFF")); |
| | | colorTransitionPagerTitleView.setText(index == 0 ? "热门" : "推荐"); |
| | | colorTransitionPagerTitleView.setLayoutParams(new ViewGroup.LayoutParams(UIUtil.dip2px(context, 114), ViewPager.LayoutParams.WRAP_CONTENT)); |
| | | colorTransitionPagerTitleView.setGravity(Gravity.CENTER); |
| | | // colorTransitionPagerTitleView.setBackgroundColor(Color.RED); |
| | | colorTransitionPagerTitleView.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View view) { |
| | | vp_feed_videos.setCurrentItem(index); |
| | | } |
| | | }); |
| | | colorTransitionPagerTitleView.setTextSize(12); |
| | | return colorTransitionPagerTitleView; |
| | | } |
| | | |
| | | //此为tab指示器回调 |
| | | @Override |
| | | public IPagerIndicator getIndicator(Context context) { |
| | | LinePagerIndicator indicator = new LinePagerIndicator(context); |
| | | indicator.setColors(Color.parseColor("#FFF8F8F8")); |
| | | indicator.setMode(LinePagerIndicator.MODE_MATCH_EDGE); |
| | | indicator.setRoundRadius(UIUtil.dip2px(context, 20)); |
| | | indicator.setLineHeight(UIUtil.dip2px(context, 20)); |
| | | indicator.setYOffset(UIUtil.dip2px(context, 0)); |
| | | |
| | | return indicator; |
| | | } |
| | | }; |
| | | |
| | | class FeedVideoNavIndicator extends View implements IPagerIndicator { |
| | | |
| | | public static final int MODE_MATCH_EDGE = 0; // 直线宽度 == title宽度 - 2 * mXOffset |
| | | public static final int MODE_WRAP_CONTENT = 1; // 直线宽度 == title内容宽度 - 2 * mXOffset |
| | | public static final int MODE_EXACTLY = 2; // 直线宽度 == mLineWidth |
| | | |
| | | private int mMode; // 默认为MODE_MATCH_EDGE模式 |
| | | |
| | | // 控制动画 |
| | | private Interpolator mStartInterpolator = new LinearInterpolator(); |
| | | private Interpolator mEndInterpolator = new LinearInterpolator(); |
| | | |
| | | private float mYOffset; // 相对于底部的偏移量,如果你想让直线位于title上方,设置它即可 |
| | | private float mLineHeight; |
| | | private float mXOffset; |
| | | private float mLineWidth; |
| | | private float mRoundRadius; |
| | | |
| | | private Paint mPaint; |
| | | private List<PositionData> mPositionDataList; |
| | | private List<Integer> mColors; |
| | | |
| | | private RectF mLineRect = new RectF(); |
| | | |
| | | public FeedVideoNavIndicator(Context context) { |
| | | super(context); |
| | | init(context); |
| | | } |
| | | |
| | | private void init(Context context) { |
| | | mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); |
| | | mPaint.setStyle(Paint.Style.STROKE); |
| | | mPaint.setStrokeWidth(UIUtil.dip2px(getContext(), 1)); |
| | | mLineHeight = UIUtil.dip2px(context, 3); |
| | | mLineWidth = UIUtil.dip2px(context, 10); |
| | | } |
| | | |
| | | @Override |
| | | protected void onDraw(Canvas canvas) { |
| | | canvas.drawRoundRect(mLineRect, mRoundRadius, mRoundRadius, mPaint); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { |
| | | if (mPositionDataList == null || mPositionDataList.isEmpty()) { |
| | | return; |
| | | } |
| | | |
| | | // 计算颜色 |
| | | if (mColors != null && mColors.size() > 0) { |
| | | int currentColor = mColors.get(Math.abs(position) % mColors.size()); |
| | | int nextColor = mColors.get(Math.abs(position + 1) % mColors.size()); |
| | | int color = ArgbEvaluatorHolder.eval(positionOffset, currentColor, nextColor); |
| | | mPaint.setColor(color); |
| | | } |
| | | |
| | | // 计算锚点位置 |
| | | PositionData current = FragmentContainerHelper.getImitativePositionData(mPositionDataList, position); |
| | | PositionData next = FragmentContainerHelper.getImitativePositionData(mPositionDataList, position + 1); |
| | | |
| | | float leftX; |
| | | float nextLeftX; |
| | | float rightX; |
| | | float nextRightX; |
| | | if (mMode == MODE_MATCH_EDGE) { |
| | | leftX = current.mLeft + mXOffset; |
| | | nextLeftX = next.mLeft + mXOffset; |
| | | rightX = current.mRight - mXOffset; |
| | | nextRightX = next.mRight - mXOffset; |
| | | } else if (mMode == MODE_WRAP_CONTENT) { |
| | | leftX = current.mContentLeft + mXOffset; |
| | | nextLeftX = next.mContentLeft + mXOffset; |
| | | rightX = current.mContentRight - mXOffset; |
| | | nextRightX = next.mContentRight - mXOffset; |
| | | } else { // MODE_EXACTLY |
| | | leftX = current.mLeft + (current.width() - mLineWidth) / 2; |
| | | nextLeftX = next.mLeft + (next.width() - mLineWidth) / 2; |
| | | rightX = current.mLeft + (current.width() + mLineWidth) / 2; |
| | | nextRightX = next.mLeft + (next.width() + mLineWidth) / 2; |
| | | } |
| | | |
| | | mLineRect.left = leftX + (nextLeftX - leftX) * mStartInterpolator.getInterpolation(positionOffset); |
| | | mLineRect.right = rightX + (nextRightX - rightX) * mEndInterpolator.getInterpolation(positionOffset); |
| | | mLineRect.top = getHeight() - mLineHeight - mYOffset; |
| | | mLineRect.bottom = getHeight() - mYOffset; |
| | | |
| | | invalidate(); |
| | | } |
| | | |
| | | @Override |
| | | public void onPageSelected(int position) { |
| | | } |
| | | |
| | | @Override |
| | | public void onPageScrollStateChanged(int state) { |
| | | } |
| | | |
| | | @Override |
| | | public void onPositionDataProvide(List<PositionData> dataList) { |
| | | mPositionDataList = dataList; |
| | | } |
| | | |
| | | public float getYOffset() { |
| | | return mYOffset; |
| | | } |
| | | |
| | | public void setYOffset(float yOffset) { |
| | | mYOffset = yOffset; |
| | | } |
| | | |
| | | public float getXOffset() { |
| | | return mXOffset; |
| | | } |
| | | |
| | | public void setXOffset(float xOffset) { |
| | | mXOffset = xOffset; |
| | | } |
| | | |
| | | public float getLineHeight() { |
| | | return mLineHeight; |
| | | } |
| | | |
| | | public void setLineHeight(float lineHeight) { |
| | | mLineHeight = lineHeight; |
| | | } |
| | | |
| | | public float getLineWidth() { |
| | | return mLineWidth; |
| | | } |
| | | |
| | | public void setLineWidth(float lineWidth) { |
| | | mLineWidth = lineWidth; |
| | | } |
| | | |
| | | public float getRoundRadius() { |
| | | return mRoundRadius; |
| | | } |
| | | |
| | | public void setRoundRadius(float roundRadius) { |
| | | mRoundRadius = roundRadius; |
| | | } |
| | | |
| | | public int getMode() { |
| | | return mMode; |
| | | } |
| | | |
| | | public void setMode(int mode) { |
| | | if (mode == MODE_EXACTLY || mode == MODE_MATCH_EDGE || mode == MODE_WRAP_CONTENT) { |
| | | mMode = mode; |
| | | } else { |
| | | throw new IllegalArgumentException("mode " + mode + " not supported."); |
| | | } |
| | | } |
| | | |
| | | public Paint getPaint() { |
| | | return mPaint; |
| | | } |
| | | |
| | | public List<Integer> getColors() { |
| | | return mColors; |
| | | } |
| | | |
| | | public void setColors(Integer... colors) { |
| | | mColors = Arrays.asList(colors); |
| | | } |
| | | |
| | | public Interpolator getStartInterpolator() { |
| | | return mStartInterpolator; |
| | | } |
| | | |
| | | public void setStartInterpolator(Interpolator startInterpolator) { |
| | | mStartInterpolator = startInterpolator; |
| | | if (mStartInterpolator == null) { |
| | | mStartInterpolator = new LinearInterpolator(); |
| | | } |
| | | } |
| | | |
| | | public Interpolator getEndInterpolator() { |
| | | return mEndInterpolator; |
| | | } |
| | | |
| | | public void setEndInterpolator(Interpolator endInterpolator) { |
| | | mEndInterpolator = endInterpolator; |
| | | if (mEndInterpolator == null) { |
| | | mEndInterpolator = new LinearInterpolator(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | class FeedVideoTypesAdapter extends FragmentStatePagerAdapter { |
| | | |
| | | private FragmentManager fm; |
| | | |
| | | public FeedVideoTypesAdapter(@NonNull FragmentManager fm) { |
| | | super(fm); |
| | | this.fm = fm; |
| | | } |
| | | |
| | | @Override |
| | | public int getItemPosition(@NonNull Object object) { |
| | | return super.getItemPosition(object); |
| | | } |
| | | |
| | | @NonNull |
| | | @Override |
| | | public Fragment getItem(int position) { |
| | | Log.i(TAG, "getItem:" + position); |
| | | if (getTypeCount() > 1) { |
| | | if (position == 0) { |
| | | return new DYFeedFragment(fm); |
| | | } else { |
| | | return new KSFeedFragment(fm); |
| | | } |
| | | } else { |
| | | return new KSFeedFragment(fm); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public int getCount() { |
| | | return getTypeCount(); |
| | | } |
| | | } |
| | | |
| | | private int getTypeCount() { |
| | | if (AdUtil.isCanInitCSJ()) { |
| | | return 2; |
| | | } else { |
| | | return 1; |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import com.weikou.beibeivideo.ui.recommend.GuessLikeAdapter; |
| | | import com.weikou.beibeivideo.util.BeibeiConstant; |
| | | import com.weikou.beibeivideo.R; |
| | | import com.weikou.beibeivideo.util.JsonUtil; |
| | | import com.weikou.beibeivideo.widget.MySwipeRefreshLayout; |
| | | |
| | | import org.apache.http.Header; |
| | |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | List<VideoInfo> list = gson.fromJson( |
| | | |
| | | List<VideoInfo> list = JsonUtil.videoGson.fromJson( |
| | | jsonObject.getJSONObject("Data") |
| | | .getJSONArray("data").toString(), |
| | | new TypeToken<List<VideoInfo>>() { |
| | |
| | | import com.weikou.beibeivideo.ui.dialog.FloatADDialog; |
| | | import com.weikou.beibeivideo.ui.recommend.RecommendFragment; |
| | | import com.weikou.beibeivideo.util.BeibeiConstant; |
| | | import com.weikou.beibeivideo.util.JsonUtil; |
| | | import com.weikou.beibeivideo.util.UmengEventUtil; |
| | | import com.weikou.beibeivideo.util.cache.DiskLruCacheManager; |
| | | |
| | |
| | | pager.getContext()); |
| | | |
| | | if (!StringUtils.isBlank(cacheValue)) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE).create(); |
| | | List<HomeClass> list = gson.fromJson( |
| | | |
| | | List<HomeClass> list = JsonUtil.videoGson.fromJson( |
| | | cacheValue, |
| | | new TypeToken<List<HomeClass>>() { |
| | | }.getType()); |
| | |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | |
| | | categories.clear(); |
| | | |
| | | List<HomeClass> list = gson.fromJson( |
| | | List<HomeClass> list = JsonUtil.videoGson.fromJson( |
| | | jsonObject.getJSONObject("Data") |
| | | .getJSONArray("data").toString(), |
| | | new TypeToken<List<HomeClass>>() { |
| | | }.getType()); |
| | | |
| | | categories.addAll(list); |
| | | if (categories.size() > 0) { |
| | | HomeClass feedVideos = new HomeClass(); |
| | | feedVideos.setDataType("feedVideos"); |
| | | feedVideos.setName("刷一刷"); |
| | | categories.add(1, feedVideos); |
| | | } |
| | | |
| | | if (categories != null) |
| | | for (int i = 0; i < categories.size(); i++) { |
| | | if (categories.get(i).getDataType().equalsIgnoreCase("novel")) { |
| | |
| | | |
| | | |
| | | count++; |
| | | DiskLruCacheManager.getInstance(BeibeiVideoApplication.application).cache(getKey("getCategories"), gson.toJson(categories)); |
| | | DiskLruCacheManager.getInstance(BeibeiVideoApplication.application).cache(getKey("getCategories"), JsonUtil.videoGson.toJson(categories)); |
| | | } |
| | | } |
| | | |
New file |
| | |
| | | package com.weikou.beibeivideo.ui.main; |
| | | |
| | | import android.os.Bundle; |
| | | import android.util.Log; |
| | | import android.view.View; |
| | | |
| | | import com.kwad.sdk.api.KsAdSDK; |
| | | import com.kwad.sdk.api.KsContentPage; |
| | | import com.kwad.sdk.api.KsFeedPage; |
| | | import com.kwad.sdk.api.KsScene; |
| | | import com.weikou.beibeivideo.R; |
| | | import com.weikou.beibeivideo.ui.MyRetainViewFragment; |
| | | import com.weikou.beibeivideo.util.ad.KSConstant; |
| | | import com.weikou.beibeivideo.widget.MySwipeRefreshLayout; |
| | | |
| | | import androidx.annotation.Nullable; |
| | | import androidx.fragment.app.Fragment; |
| | | import androidx.fragment.app.FragmentManager; |
| | | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; |
| | | |
| | | /** |
| | | * 主页面--快手视频 |
| | | */ |
| | | public class KSFeedFragment extends MyRetainViewFragment { |
| | | private static final String TAG = "KSFeedFragment"; |
| | | private FragmentManager fragmentManager; |
| | | private KsFeedPage ksFeedPage; |
| | | private MySwipeRefreshLayout swipeRefreshLayout; |
| | | |
| | | public KSFeedFragment() { |
| | | super(); |
| | | } |
| | | |
| | | public KSFeedFragment(FragmentManager fragmentManager) { |
| | | super(); |
| | | this.fragmentManager = fragmentManager; //fragmentManager; |
| | | setName(KSFeedFragment.class.getName()); |
| | | } |
| | | |
| | | private Fragment fragment; |
| | | |
| | | |
| | | @Override |
| | | public int getContentResource() { |
| | | return R.layout.fragment_ks_video; |
| | | } |
| | | |
| | | @Override |
| | | public void onResume() { |
| | | super.onResume(); |
| | | Log.i(TAG, "onResume"); |
| | | } |
| | | |
| | | @Override |
| | | public void onPause() { |
| | | super.onPause(); |
| | | Log.i(TAG, "onPause"); |
| | | } |
| | | |
| | | @Override |
| | | public void onCreate(@Nullable Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | | Log.i(TAG, "onCreate"); |
| | | } |
| | | |
| | | @Override |
| | | public void onCreateView(View contentView, Bundle savedInstanceState) { |
| | | Log.i(TAG, "onCreateView"); |
| | | swipeRefreshLayout = contentView.findViewById(R.id.srl_ks); |
| | | swipeRefreshLayout.setEnabled(false); |
| | | init(); |
| | | } |
| | | |
| | | public void init() { |
| | | if (ksFeedPage == null) { |
| | | preInit(); |
| | | } |
| | | if (ksFeedPage != null) { |
| | | this.fragment = ksFeedPage.getFragment(); |
| | | if (fragmentManager != null && this.fragment != null) |
| | | getChildFragmentManager().beginTransaction().add(R.id.fl_content, fragment).commitAllowingStateLoss(); |
| | | } |
| | | } |
| | | |
| | | public void preInit() { |
| | | KsScene adScene = new KsScene.Builder(KSConstant.PID_FEED).build(); |
| | | ksFeedPage = KsAdSDK.getLoadManager().loadFeedPage(adScene); |
| | | ksFeedPage.setPageListener(new KsContentPage.PageListener() { |
| | | @Override |
| | | public void onPageEnter(KsContentPage.ContentItem contentItem) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onPageResume(KsContentPage.ContentItem contentItem) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onPagePause(KsContentPage.ContentItem contentItem) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onPageLeave(KsContentPage.ContentItem contentItem) { |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import com.weikou.beibeivideo.ui.baidu.BaiDuVideosFragment; |
| | | import com.weikou.beibeivideo.ui.recommend.GuessLikeAdapter; |
| | | import com.weikou.beibeivideo.util.BeibeiConstant; |
| | | import com.weikou.beibeivideo.util.ad.KSConstant; |
| | | import com.weikou.beibeivideo.widget.MySwipeRefreshLayout; |
| | | |
| | | import org.apache.http.Header; |
| | |
| | | */ |
| | | public class KSVideoFragment extends MyRetainViewFragment { |
| | | private static final String TAG = "KSVideoFragment"; |
| | | private KsContentPage ksContentPage; |
| | | private MySwipeRefreshLayout swipeRefreshLayout; |
| | | |
| | | |
| | | public KSVideoFragment() { |
| | | super(); |
| | |
| | | @Override |
| | | public void onResume() { |
| | | super.onResume(); |
| | | Log.i(TAG, "onResume"); |
| | | if (ksContentPage != null && ksContentPage.getFragment() != null) { |
| | | ksContentPage.getFragment().onResume(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onPause() { |
| | | super.onPause(); |
| | | Log.i(TAG, "onPause"); |
| | | if (ksContentPage != null && ksContentPage.getFragment() != null) { |
| | | ksContentPage.getFragment().onPause(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void setUserVisibleHint(boolean isVisibleToUser) { |
| | | super.setUserVisibleHint(isVisibleToUser); |
| | | if (ksContentPage != null && ksContentPage.getFragment() != null) { |
| | | ksContentPage.getFragment().setUserVisibleHint(isVisibleToUser); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onHiddenChanged(boolean hidden) { |
| | | super.onHiddenChanged(hidden); |
| | | if (ksContentPage != null && ksContentPage.getFragment() != null) { |
| | | ksContentPage.getFragment().onHiddenChanged(hidden); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | @Override |
| | | public void onCreateView(View contentView, Bundle savedInstanceState) { |
| | | Log.i(TAG, "onCreateView"); |
| | | // init(); |
| | | swipeRefreshLayout = contentView.findViewById(R.id.srl_ks); |
| | | swipeRefreshLayout.setEnabled(false); |
| | | init(); |
| | | } |
| | | |
| | | public void init(FragmentManager fragmentManager, Fragment fragment) { |
| | | if (this.fragment == null) { |
| | | this.fragment = fragment; |
| | | fragmentManager.beginTransaction().add(R.id.fl_content, fragment).commitAllowingStateLoss(); |
| | | public void init() { |
| | | if (ksContentPage == null) { |
| | | preInit(); |
| | | } |
| | | if (ksContentPage != null) { |
| | | this.fragment = ksContentPage.getFragment(); |
| | | if (this.fragment != null) |
| | | getChildFragmentManager().beginTransaction().add(R.id.fl_content, fragment).commitAllowingStateLoss(); |
| | | } |
| | | } |
| | | |
| | | private void init() { |
| | | KsScene adScene = new KsScene.Builder(8010000001L).build(); |
| | | KsContentPage ksContentPage = KsAdSDK.getLoadManager().loadContentPage(adScene); |
| | | ksContentPage.onPageLeaveIntercept(new KsContentPage.KsPageLeaveClickListener() { |
| | | @Override |
| | | public void onPageLeaveClick() { |
| | | |
| | | } |
| | | }); |
| | | ksContentPage.addPageLoadListener(new KsContentPage.OnPageLoadListener() { |
| | | |
| | | |
| | | @Override |
| | | public void onLoadStart(KsContentPage ksContentPage, int i) { |
| | | Log.i(TAG, "onLoadStart"); |
| | | } |
| | | |
| | | @Override |
| | | public void onLoadFinish(KsContentPage ksContentPage, int i) { |
| | | Log.i(TAG, "onLoadFinish"); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onLoadError(KsContentPage ksContentPage, String s) { |
| | | Log.i(TAG, "onLoadError"); |
| | | } |
| | | }); |
| | | |
| | | |
| | | fragment = ksContentPage.getFragment(); |
| | | |
| | | public void preInit() { |
| | | KsScene adScene = new KsScene.Builder(KSConstant.PID_FULL_VIDEO).build(); |
| | | ksContentPage = KsAdSDK.getLoadManager().loadContentPage(adScene); |
| | | } |
| | | |
| | | |
| | |
| | | import android.content.SharedPreferences.Editor; |
| | | import android.content.pm.ActivityInfo; |
| | | import android.database.Cursor; |
| | | import android.graphics.Color; |
| | | import android.net.wifi.WifiInfo; |
| | | import android.net.wifi.WifiManager; |
| | | import android.os.Build; |
| | | import android.os.Bundle; |
| | | import android.util.Log; |
| | | import android.view.KeyEvent; |
| | |
| | | import com.androidquery.AQuery; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.kwad.sdk.api.KsAdSDK; |
| | | import com.kwad.sdk.api.KsContentPage; |
| | | import com.kwad.sdk.api.KsScene; |
| | | import com.lcjian.library.util.FragmentSwitchHelper; |
| | | import com.lcjian.library.util.ManifestDataUtil; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.mozillaonline.providers.downloads.DownloadService; |
| | | import com.qq.e.ads.cfg.VideoOption; |
| | |
| | | import com.weikou.beibeivideo.R; |
| | | import com.weikou.beibeivideo.db.MessageTable; |
| | | import com.weikou.beibeivideo.entity.NewComment; |
| | | import com.weikou.beibeivideo.entity.ad.AdPositionEnum; |
| | | import com.weikou.beibeivideo.entity.recommend.HomeTabChangeInfo; |
| | | import com.weikou.beibeivideo.ui.BaseActivity; |
| | | import com.weikou.beibeivideo.ui.baidu.BaiDuNewsFragment; |
| | | import com.weikou.beibeivideo.ui.baidu.BaiDuVideosFragment; |
| | | import com.weikou.beibeivideo.ui.login.LoginActivity; |
| | | import com.weikou.beibeivideo.ui.login.PersonInfoActivity; |
| | | import com.weikou.beibeivideo.ui.mine.BrowserActivity; |
| | |
| | | import com.weikou.beibeivideo.ui.push.PushOpenClickActivity; |
| | | import com.weikou.beibeivideo.ui.recommend.SearchActivity; |
| | | import com.weikou.beibeivideo.util.BeibeiConstant; |
| | | import com.weikou.beibeivideo.util.DimenUtils; |
| | | import com.weikou.beibeivideo.util.ExitDialog; |
| | | import com.weikou.beibeivideo.util.LoginFirstDialog; |
| | | import com.weikou.beibeivideo.util.UserUtil; |
| | | 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.InterstitialAdUtil; |
| | | import com.weikou.beibeivideo.util.ui.TopStatusSettings; |
| | | import com.yeshi.appupdate.AppUpdate; |
| | | import com.yeshi.push.PushUtil; |
| | |
| | | import java.util.Random; |
| | | |
| | | import androidx.annotation.Nullable; |
| | | import androidx.fragment.app.Fragment; |
| | | import androidx.loader.app.LoaderManager; |
| | | import androidx.loader.content.CursorLoader; |
| | | import androidx.loader.content.Loader; |
| | |
| | | |
| | | private AQuery mAQuery; |
| | | |
| | | private Runnable adCallback; |
| | | |
| | | @Override |
| | | protected void onSaveInstanceState(Bundle outState) { |
| | | outState.putString("flash back", "MainActivity flash show"); |
| | | super.onSaveInstanceState(outState); |
| | | } |
| | | |
| | | private Fragment[] getFragments() { |
| | | |
| | | return new Fragment[]{ |
| | | new HomeFragment(), new DrawVideoFragment(getSupportFragmentManager()), |
| | | new DYNewsFragment(getSupportFragmentManager()), new MineFragment(), new NovelFragment(getSupportFragmentManager()) |
| | | |
| | | }; |
| | | } |
| | | |
| | | private void navClick(RadioGroup group, int checkedId) { |
| | | setSearchBarVisibility(); |
| | | switch (checkedId) { |
| | | case R.id.rb_nav_recommend: { |
| | | mFragmentSwitchHelper |
| | | .changeFragment(HomeFragment.class); |
| | | } |
| | | break; |
| | | case R.id.rb_nav_draw_video: { |
| | | mFragmentSwitchHelper |
| | | .changeFragment(DrawVideoFragment.class); |
| | | } |
| | | break; |
| | | case R.id.rb_nav_discover: { |
| | | mFragmentSwitchHelper |
| | | .changeFragment(DYNewsFragment.class); |
| | | } |
| | | break; |
| | | case R.id.rb_nav_novel: { |
| | | mFragmentSwitchHelper |
| | | .changeFragment(NovelFragment.class); |
| | | } |
| | | break; |
| | | case R.id.rb_nav_mine: { |
| | | mFragmentSwitchHelper.changeFragment(MineFragment.class); |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | findViewById(R.id.ll_activity_login).setOnClickListener(this); |
| | | findViewById(R.id.fl_category).setOnClickListener(this); |
| | | |
| | | TopStatusSettings.setStatusViewAndDeepColor(this); |
| | | |
| | | initialer.run(); |
| | | |
| | | mFragmentSwitchHelper = FragmentSwitchHelper.create( |
| | | R.id.fl_main_fragment_container, getSupportFragmentManager(), |
| | | new HomeFragment(), new KSVideoFragment(), |
| | | BaiDuVideosFragment.newInstance(), new MineFragment(), GoldCornFragment.newInstance()); |
| | | R.id.fl_main_fragment_container, getSupportFragmentManager(), getFragments() |
| | | ); |
| | | rg_nav = findViewById(R.id.rg_nav); |
| | | rg_nav.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { |
| | | |
| | | @Override |
| | | public void onCheckedChanged(RadioGroup group, int checkedId) { |
| | | switch (checkedId) { |
| | | case R.id.rb_nav_recommend: { |
| | | mFragmentSwitchHelper |
| | | .changeFragment(HomeFragment.class); |
| | | if (!YouthUtil.isOpenYouthMode(getApplicationContext())) |
| | | mAQuery.id(R.id.ll_top).visibility(View.VISIBLE); |
| | | } |
| | | break; |
| | | case R.id.rb_guess_like: { |
| | | mAQuery.id(R.id.ll_top).visibility(View.GONE); |
| | | mFragmentSwitchHelper |
| | | .changeFragment(KSVideoFragment.class); |
| | | |
| | | fl_category.post(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | ((KSVideoFragment) mFragmentSwitchHelper.getFragmentByName(KSVideoFragment.class.getName())).init(getSupportFragmentManager(), ksContentPage.getFragment()); |
| | | } |
| | | }); |
| | | |
| | | |
| | | } |
| | | break; |
| | | case R.id.rb_gold_corn: { |
| | | if (!YouthUtil.isOpenYouthMode(getApplicationContext())) |
| | | mAQuery.id(R.id.ll_top).visibility(View.VISIBLE); |
| | | mFragmentSwitchHelper |
| | | .changeFragment(GoldCornFragment.class); |
| | | } |
| | | break; |
| | | case R.id.rb_nav_discover: { |
| | | if (!YouthUtil.isOpenYouthMode(getApplicationContext())) |
| | | mAQuery.id(R.id.ll_top).visibility(View.VISIBLE); |
| | | mFragmentSwitchHelper |
| | | .changeFragment(BaiDuVideosFragment.class); |
| | | } |
| | | break; |
| | | case R.id.rb_nav_mine: { |
| | | if (!YouthUtil.isOpenYouthMode(getApplicationContext())) |
| | | mAQuery.id(R.id.ll_top).visibility(View.VISIBLE); |
| | | mFragmentSwitchHelper.changeFragment(MineFragment.class); |
| | | } |
| | | break; |
| | | } |
| | | navClick(group, checkedId); |
| | | } |
| | | }); |
| | | getHotSearch(); |
| | |
| | | }); |
| | | } |
| | | }); |
| | | KsScene adScene = new KsScene.Builder(8010000001L).build(); |
| | | ksContentPage = KsAdSDK.getLoadManager().loadContentPage(adScene); |
| | | //显示广告 |
| | | showInterstitialAd(); |
| | | } |
| | | |
| | | private KsContentPage ksContentPage; |
| | | |
| | | /** |
| | | * 预加载广告 |
| | |
| | | if (YouthUtil.isOpenYouthMode(getApplicationContext())) { |
| | | mAQuery.id(R.id.ll_top).visibility(View.GONE); |
| | | mAQuery.id(R.id.rb_nav_discover).visibility(View.GONE); |
| | | mAQuery.id(R.id.rb_gold_corn).visibility(View.GONE); |
| | | mAQuery.id(R.id.rb_guess_like).visibility(View.GONE); |
| | | ((RadioGroup) mAQuery.id(R.id.rg_nav).getView()).setPadding(0, DimenUtils.dip2px(getApplicationContext(), 5), 0, 0); |
| | | mAQuery.id(R.id.rb_nav_draw_video).visibility(View.GONE); |
| | | mAQuery.id(R.id.rb_nav_novel).visibility(View.GONE); |
| | | } else { |
| | | mAQuery.id(R.id.ll_top).visibility(View.VISIBLE); |
| | | mAQuery.id(R.id.rb_nav_discover).visibility(View.VISIBLE); |
| | | mAQuery.id(R.id.rb_gold_corn).visibility(View.VISIBLE); |
| | | mAQuery.id(R.id.rb_guess_like).visibility(View.VISIBLE); |
| | | ((RadioGroup) mAQuery.id(R.id.rg_nav).getView()).setPadding(0, 0, 0, 0); |
| | | setSearchBarVisibility(); |
| | | mAQuery.id(R.id.rb_nav_draw_video).visibility(View.VISIBLE); |
| | | //Android 5.0以上且不是正在上线 |
| | | if (AdUtil.isCanInitCSJ() && AdUtil.getAdType(getApplicationContext(), AdPositionEnum.splashHotStart) != null) { |
| | | mAQuery.id(R.id.rb_nav_discover).visibility(View.VISIBLE); |
| | | mAQuery.id(R.id.rb_nav_novel).visibility(View.VISIBLE); |
| | | } else { |
| | | mAQuery.id(R.id.rb_nav_discover).visibility(View.GONE); |
| | | mAQuery.id(R.id.rb_nav_novel).visibility(View.GONE); |
| | | } |
| | | // ((RadioGroup) mAQuery.id(R.id.rg_nav).getView()).setPadding(0, 0, 0, 0); |
| | | } |
| | | } |
| | | |
| | | private void setSearchBarVisibility() { |
| | | if (YouthUtil.isOpenYouthMode(getApplicationContext())) { |
| | | mAQuery.id(R.id.ll_top).visibility(View.GONE); |
| | | } else { |
| | | if (mAQuery.id(R.id.rb_nav_draw_video).isChecked() || mAQuery.id(R.id.rb_nav_novel).isChecked() || mAQuery.id(R.id.rb_nav_discover).isChecked()) { |
| | | mAQuery.id(R.id.ll_top).visibility(View.GONE); |
| | | } else { |
| | | mAQuery.id(R.id.ll_top).visibility(View.VISIBLE); |
| | | } |
| | | if (mAQuery.id(R.id.rb_nav_draw_video).isChecked()) { |
| | | // mAQuery.id(R.id.v_status_bar).background(Color.BLACK); |
| | | //TODO 设置状态栏为深色 |
| | | TopStatusSettings.setStatusViewAndLightColor(this); |
| | | } else { |
| | | // mAQuery.id(R.id.v_status_bar).backgroundColor(Color.WHITE); |
| | | //状态栏为浅色 |
| | | TopStatusSettings.setStatusViewAndDeepColor(this); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | AppUpdate.destoryAppUpdate(); |
| | | } |
| | | |
| | | @Override |
| | | protected void onDestroy() { |
| | | super.onDestroy(); |
| | | if (adCallback != null && rg_nav != null) { |
| | | rg_nav.removeCallbacks(adCallback); |
| | | } |
| | | } |
| | | |
| | | |
| | | //显示插屏广告 |
| | | private void showInterstitialAd() { |
| | | |
| | | final AdUtil.AD_TYPE adType = AdUtil.getAdType(getApplicationContext(), AdPositionEnum.homeInterstitial); |
| | | if (adType == null) { |
| | | return; |
| | | } |
| | | |
| | | adCallback = new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | AdUtil.AD_TYPE type = adType; |
| | | //Android 5.0以下广告兼容 |
| | | if (type == AdUtil.AD_TYPE.csj && !AdUtil.isCanInitCSJ()) { |
| | | type = AdUtil.AD_TYPE.gdt; |
| | | } |
| | | |
| | | if (type == AdUtil.AD_TYPE.csj) { |
| | | InterstitialAdUtil.showAd(MainActivity.this, type, CSJConstant.HOME_INTERSTITIALAD); |
| | | } else { |
| | | InterstitialAdUtil.showAd(MainActivity.this, type, GDTConstant.HOME_INTERSTITIAL); |
| | | } |
| | | |
| | | |
| | | } |
| | | }; |
| | | //延迟三秒显示 |
| | | rg_nav.postDelayed(adCallback, 3000); |
| | | } |
| | | |
| | | private String callCmd(String cmd, String filter) { |
| | | String result = ""; |
| | |
| | | return; |
| | | |
| | | try { |
| | | setSearchBarVisibility(); |
| | | switch (Integer.parseInt(position)) { |
| | | case 0: |
| | | findViewById(R.id.rb_nav_recommend).performClick(); |
| | |
| | | }); |
| | | break; |
| | | case 1: |
| | | findViewById(R.id.rb_nav_discover).performClick(); |
| | | findViewById(R.id.rb_nav_draw_video).performClick(); |
| | | break; |
| | | case 2: |
| | | findViewById(R.id.rb_gold_corn).performClick(); |
| | | findViewById(R.id.rb_nav_discover).performClick(); |
| | | break; |
| | | case 3: |
| | | findViewById(R.id.rb_guess_like).performClick(); |
| | | findViewById(R.id.rb_nav_novel).performClick(); |
| | | break; |
| | | case 4: |
| | | findViewById(R.id.rb_nav_mine).performClick(); |
| | |
| | | import androidx.loader.content.CursorLoader; |
| | | import androidx.loader.content.Loader; |
| | | |
| | | import android.util.Log; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.view.View.OnClickListener; |
| | |
| | | import com.weikou.beibeivideo.ui.login.LoginActivity; |
| | | import com.weikou.beibeivideo.ui.login.PersonInfoActivity; |
| | | import com.weikou.beibeivideo.ui.mine.BrowserActivity; |
| | | import com.weikou.beibeivideo.ui.mine.GoldCornActivity; |
| | | import com.weikou.beibeivideo.ui.mine.HelpAndTicklingActivity; |
| | | import com.weikou.beibeivideo.ui.mine.MyFavouriteActivity; |
| | | import com.weikou.beibeivideo.ui.mine.SettingsActivity; |
| | |
| | | */ |
| | | public class MineFragment extends MyRetainViewFragment implements |
| | | OnClickListener, LoaderManager.LoaderCallbacks<Cursor> { |
| | | |
| | | private final String TAG="MineFragment"; |
| | | |
| | | |
| | | public MineFragment() { |
| | |
| | | |
| | | |
| | | contentView.findViewById(R.id.mine_rl_head).setOnClickListener(this); |
| | | |
| | | contentView.findViewById(R.id.tv_goldcorn).setOnClickListener(this); |
| | | |
| | | ll_mine_favourite.setOnClickListener(this); |
| | | ll_mine_follow.setOnClickListener(this); |
| | | ll_mine_watch_history.setOnClickListener(this); |
| | |
| | | // break; |
| | | case R.id.ll_mine_follow: |
| | | startActivity(new Intent(tv_no_network.getContext(), FollowActivity.class)); |
| | | break; |
| | | |
| | | //影视豆 |
| | | case R.id.tv_goldcorn: |
| | | startActivity(new Intent(tv_no_network.getContext(), GoldCornActivity.class)); |
| | | break; |
| | | |
| | | //书架 |
| | |
| | | @Override |
| | | public void onResume() { |
| | | super.onResume(); |
| | | Log.i(TAG,"onResume"); |
| | | // 获取缓存中的消息状态 |
| | | SharedPreferences preferences = tv_no_network.getContext().getSharedPreferences( |
| | | "user", Context.MODE_PRIVATE); |
| | |
| | | |
| | | @Override |
| | | public void onPause() { |
| | | Log.i(TAG,"onPause"); |
| | | super.onPause(); |
| | | mChangeHelper.unregisterReceiver(); |
| | | } |
New file |
| | |
| | | package com.weikou.beibeivideo.ui.main; |
| | | |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.content.SharedPreferences; |
| | | import android.content.pm.PackageInfo; |
| | | import android.content.pm.PackageManager.NameNotFoundException; |
| | | import android.os.Bundle; |
| | | import android.provider.Settings; |
| | | import android.view.View; |
| | | import android.view.View.OnClickListener; |
| | | import android.widget.FrameLayout; |
| | | import android.widget.GridView; |
| | | import android.widget.TextView; |
| | | |
| | | import com.bytedance.novel.pangolin.NovelSDK; |
| | | 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.content.ConnectivityChangeHelper; |
| | | import com.lcjian.library.content.ConnectivityChangeHelper.OnConnectivityChangeListener; |
| | | import com.lcjian.library.util.cache.DiskLruCache; |
| | | import com.lcjian.library.util.common.StorageUtils; |
| | | import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator; |
| | | 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.ui.MyRetainViewFragment; |
| | | import com.weikou.beibeivideo.ui.category.CategoryAdapter; |
| | | import com.weikou.beibeivideo.ui.recommend.SearchActivity; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | |
| | | import androidx.fragment.app.FragmentManager; |
| | | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; |
| | | |
| | | /** |
| | | * 小说 |
| | | */ |
| | | public class NovelFragment extends MyRetainViewFragment implements |
| | | OnClickListener { |
| | | private FragmentManager fragmentManager; |
| | | |
| | | public NovelFragment(FragmentManager fragmentManager) { |
| | | super(); |
| | | setName(NovelFragment.class.getName()); |
| | | this.fragmentManager = fragmentManager; |
| | | } |
| | | |
| | | @Override |
| | | public void onCreate(Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | | } |
| | | |
| | | @Override |
| | | public int getContentResource() { |
| | | return R.layout.fragment_novel; |
| | | } |
| | | |
| | | @Override |
| | | public void onCreateView(View contentView, Bundle savedInstanceState) { |
| | | fragmentManager.beginTransaction().replace(R.id.fl_container, NovelSDK.INSTANCE.getNovelFragment(), "novel").commitAllowingStateLoss(); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void onResume() { |
| | | super.onResume(); |
| | | NovelSDK.INSTANCE.getNovelFragment().onResume(); |
| | | } |
| | | |
| | | @Override |
| | | public void onPause() { |
| | | super.onPause(); |
| | | NovelSDK.INSTANCE.getNovelFragment().onPause(); |
| | | } |
| | | |
| | | @Override |
| | | public void onDestroy() { |
| | | super.onDestroy(); |
| | | NovelSDK.INSTANCE.getNovelFragment().onDestroy(); |
| | | } |
| | | |
| | | @Override |
| | | public void onClick(View v) { |
| | | |
| | | } |
| | | } |
| | |
| | | import com.weikou.beibeivideo.ui.dialog.VideoResourceListDialog; |
| | | import com.weikou.beibeivideo.ui.login.LoginActivity; |
| | | import com.weikou.beibeivideo.ui.video.EpisodeNewAdapter; |
| | | import com.weikou.beibeivideo.util.JsonUtil; |
| | | import com.weikou.beibeivideo.util.UserUtil; |
| | | import com.weikou.beibeivideo.util.VideoUtil; |
| | | import com.weikou.beibeivideo.util.ad.AdUtil; |
| | |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | VideoResource resource = gson.fromJson( |
| | | |
| | | VideoResource resource = JsonUtil.videoGson.fromJson( |
| | | jsonObject.getJSONObject("Data") |
| | | .getJSONObject("Resource") |
| | | .toString(), |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | |
| | | final VideoInfo videoInfo = gson |
| | | |
| | | final VideoInfo videoInfo = JsonUtil.videoGson |
| | | .fromJson(jsonObject.getJSONObject("Data") |
| | | .toString(), |
| | | new TypeToken<VideoInfo>() { |
| | |
| | | episodeHasMore = data.optBoolean("hasMore"); |
| | | JSONArray array = data.optJSONArray("list"); |
| | | if (array != null && array.length() > 0) {// |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | List<VideoDetailInfo> list = gson.fromJson(array.toString(), new TypeToken<List<VideoDetailInfo>>() { |
| | | |
| | | List<VideoDetailInfo> list = JsonUtil.videoGson.fromJson(array.toString(), new TypeToken<List<VideoDetailInfo>>() { |
| | | }.getType()); |
| | | if (list != null && list.size() > 0) { |
| | | episodePage++; |
| | |
| | | import com.weikou.beibeivideo.ui.video.VideoPlayerActivity; |
| | | import com.weikou.beibeivideo.ui.video.VideoPlayerBrowserActivity; |
| | | import com.weikou.beibeivideo.util.BeibeiConstant; |
| | | import com.weikou.beibeivideo.util.JsonUtil; |
| | | import com.weikou.beibeivideo.util.VideoUtil; |
| | | import com.weikou.beibeivideo.util.ui.TopStatusSettings; |
| | | |
| | |
| | | update(); |
| | | } |
| | | |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | final VideoInfo videoInfo = gson |
| | | |
| | | final VideoInfo videoInfo = JsonUtil.videoGson |
| | | .fromJson(jsonObject.getJSONObject("Data") |
| | | .toString(), |
| | | new TypeToken<VideoInfo>() { |
| | |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | VideoResource resource = gson.fromJson( |
| | | |
| | | VideoResource resource = JsonUtil.videoGson.fromJson( |
| | | jsonObject.getJSONObject("Data") |
| | | .getJSONObject("Resource") |
| | | .toString(), |
| | |
| | | values.put(WatchHistoryTable.VIDEO_DETAIL_ID, videoDetailId); |
| | | values.put(WatchHistoryTable.VIDEO_THIRD_TYPE, |
| | | videoInfo.getThirdType()); |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE).create(); |
| | | |
| | | values.put(WatchHistoryTable.VIDEO_DETAIL, |
| | | gson.toJson(videoInfo)); |
| | | JsonUtil.videoGson.toJson(videoInfo)); |
| | | values.put(WatchHistoryTable.WATCH_TIME, 0); |
| | | values.put(WatchHistoryTable.VIDEO_RESOURCE, from); |
| | | values.put(WatchHistoryTable.VIDEO_RESOURCE_ID, resoureID); |
| | |
| | | import com.weikou.beibeivideo.ui.video.VideoPlayerBrowserActivity; |
| | | import com.weikou.beibeivideo.ui.video.FunshionPlayerFragment; |
| | | import com.weikou.beibeivideo.util.BeibeiConstant; |
| | | import com.weikou.beibeivideo.util.JsonUtil; |
| | | import com.weikou.beibeivideo.util.UmengEventUtil; |
| | | import com.weikou.beibeivideo.util.VideoUtil; |
| | | import com.weikou.beibeivideo.util.ad.CSJConstant; |
| | |
| | | update(); |
| | | } |
| | | |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | |
| | | JSONObject videoJson = data.optJSONObject("Video"); |
| | | final VideoInfo videoInfo = gson |
| | | final VideoInfo videoInfo = JsonUtil.videoGson |
| | | .fromJson(videoJson |
| | | .toString(), |
| | | new TypeToken<VideoInfo>() { |
| | |
| | | } |
| | | |
| | | if (data.optJSONObject("AdInfo") != null) { |
| | | adInfo = gson.fromJson(data.optJSONObject("AdInfo").toString(), VideoDetailAdInfoVO.class); |
| | | adInfo = JsonUtil.videoGson.fromJson(data.optJSONObject("AdInfo").toString(), VideoDetailAdInfoVO.class); |
| | | } |
| | | // 关注 |
| | | if (data.optJSONObject("Attention") != null) { |
| | |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | VideoResource resource = gson.fromJson( |
| | | |
| | | VideoResource resource = JsonUtil.videoGson.fromJson( |
| | | jsonObject.getJSONObject("Data") |
| | | .getJSONObject("Resource") |
| | | .toString(), |
| | |
| | | values.put(WatchHistoryTable.VIDEO_DETAIL_ID, videoDetailId); |
| | | values.put(WatchHistoryTable.VIDEO_THIRD_TYPE, |
| | | videoInfo.getThirdType()); |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE).create(); |
| | | |
| | | values.put(WatchHistoryTable.VIDEO_DETAIL, |
| | | gson.toJson(videoInfo)); |
| | | JsonUtil.videoGson.toJson(videoInfo)); |
| | | values.put(WatchHistoryTable.WATCH_TIME, 0); |
| | | values.put(WatchHistoryTable.VIDEO_RESOURCE, from); |
| | | values.put(WatchHistoryTable.VIDEO_RESOURCE_ID, resoureID); |
| | |
| | | import com.weikou.beibeivideo.entity.video.ChangeVideoEvent; |
| | | import com.weikou.beibeivideo.ui.video.IVideoClickListener; |
| | | import com.weikou.beibeivideo.ui.video.VideoColumn2Adapter; |
| | | import com.weikou.beibeivideo.util.JsonUtil; |
| | | import com.weikou.beibeivideo.util.ad.AdUtil; |
| | | import com.weikou.beibeivideo.util.ad.ExpressAdManager; |
| | | |
| | |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | final List<VideoInfo> videoInfos = gson.fromJson( |
| | | |
| | | final List<VideoInfo> videoInfos = JsonUtil.videoGson.fromJson( |
| | | jsonObject.getJSONObject("Data") |
| | | .getJSONArray("data").toString(), |
| | | new TypeToken<List<VideoInfo>>() { |
| | |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | List<VideoInfo> videoInfos = gson.fromJson( |
| | | |
| | | List<VideoInfo> videoInfos = JsonUtil.videoGson.fromJson( |
| | | jsonObject.getJSONObject("Data") |
| | | .getJSONArray("data").toString(), |
| | | new TypeToken<List<VideoInfo>>() { |
| | |
| | | import com.weikou.beibeivideo.entity.VideoInfo; |
| | | import com.weikou.beibeivideo.entity.VideoResource; |
| | | import com.weikou.beibeivideo.R; |
| | | import com.weikou.beibeivideo.util.JsonUtil; |
| | | import com.weikou.beibeivideo.util.VideoUtil; |
| | | |
| | | import org.greenrobot.eventbus.EventBus; |
| | |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | VideoResource resource = gson.fromJson( |
| | | |
| | | VideoResource resource = JsonUtil.videoGson.fromJson( |
| | | jsonObject.getJSONObject("Data") |
| | | .getJSONObject("Resource") |
| | | .toString(), |
New file |
| | |
| | | package com.weikou.beibeivideo.ui.mine; |
| | | |
| | | import android.app.ProgressDialog; |
| | | import android.content.Context; |
| | | import android.content.SharedPreferences; |
| | | import android.os.Bundle; |
| | | import android.text.TextUtils; |
| | | import android.view.View; |
| | | import android.view.View.OnClickListener; |
| | | import android.widget.Button; |
| | | import android.widget.EditText; |
| | | import android.widget.TextView; |
| | | import android.widget.Toast; |
| | | |
| | | import com.kwad.sdk.api.proxy.IFragmentActivityProxy; |
| | | import com.kwad.sdk.api.proxy.app.BaseFragmentActivity; |
| | | import com.weikou.beibeivideo.BasicTextHttpResponseHandler; |
| | | import com.weikou.beibeivideo.BeibeiVideoAPI; |
| | | import com.weikou.beibeivideo.R; |
| | | import com.weikou.beibeivideo.ui.BaseActivity; |
| | | import com.weikou.beibeivideo.ui.main.GoldCornFragment; |
| | | import com.weikou.beibeivideo.util.ui.TopStatusSettings; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | |
| | | public class GoldCornActivity extends BaseActivity implements OnClickListener { |
| | | |
| | | private TextView tv_top_bar_left; |
| | | private TextView tv_top_bar_middle; |
| | | |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | | setContentView(R.layout.activity_gold_corn); |
| | | TopStatusSettings.setStatusViewAndDeepColor(this); |
| | | tv_top_bar_left = (TextView) findViewById(R.id.tv_top_bar_left); |
| | | tv_top_bar_middle = (TextView) findViewById(R.id.tv_top_bar_middle); |
| | | tv_top_bar_middle.setText("影视豆"); |
| | | tv_top_bar_left.setOnClickListener(this); |
| | | getSupportFragmentManager().beginTransaction().add(R.id.fl_container, GoldCornFragment.newInstance()).commit(); |
| | | } |
| | | |
| | | @Override |
| | | public void onClick(View v) { |
| | | switch (v.getId()) { |
| | | case R.id.tv_top_bar_left: { |
| | | finish(); |
| | | } |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | import com.weikou.beibeivideo.ui.common.ListVideoAdapter; |
| | | import com.weikou.beibeivideo.ui.discover.GoodsFavouriteAdapter; |
| | | import com.weikou.beibeivideo.ui.login.LoginActivity; |
| | | import com.weikou.beibeivideo.util.JsonUtil; |
| | | import com.weikou.beibeivideo.util.ui.TopStatusSettings; |
| | | import com.weikou.beibeivideo.widget.MySwipeRefreshLayout; |
| | | |
| | |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | List<VideoInfo> videoInfos = gson.fromJson( |
| | | |
| | | List<VideoInfo> videoInfos = JsonUtil.videoGson.fromJson( |
| | | jsonObject.getJSONObject("Data") |
| | | .getJSONArray("data").toString(), |
| | | new TypeToken<List<VideoInfo>>() { |
| | |
| | | import com.weikou.beibeivideo.R; |
| | | import com.weikou.beibeivideo.entity.vo.WatchHistoryVO; |
| | | import com.weikou.beibeivideo.ui.dialog.LoadingDialogUtil; |
| | | import com.weikou.beibeivideo.util.JsonUtil; |
| | | import com.weikou.beibeivideo.util.UserUtil; |
| | | import com.weikou.beibeivideo.widget.MySwipeRefreshLayout; |
| | | |
| | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { |
| | | if (jsonObject.optBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | |
| | | JSONObject data = jsonObject.optJSONObject("Data"); |
| | | count = data.optLong("count"); |
| | | Type type = new TypeToken<List<WatchHistoryVO>>() { |
| | | }.getType(); |
| | | |
| | | List<WatchHistoryVO> list = gson.fromJson(data.optJSONArray("list").toString(), type); |
| | | List<WatchHistoryVO> list = JsonUtil.videoGson.fromJson(data.optJSONArray("list").toString(), type); |
| | | currentPage = page; |
| | | if (voList == null) |
| | | voList = new ArrayList<>(); |
| | |
| | | import com.weikou.beibeivideo.entity.VideoType; |
| | | import com.weikou.beibeivideo.ui.category.CategoryRecommendAdapter; |
| | | import com.weikou.beibeivideo.util.DimenUtils; |
| | | import com.weikou.beibeivideo.util.JsonUtil; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | List<VideoInfo> videoInfos = gson.fromJson( |
| | | |
| | | List<VideoInfo> videoInfos = JsonUtil.videoGson.fromJson( |
| | | jsonObject.getJSONObject("Data") |
| | | .getJSONArray("data").toString(), |
| | | new TypeToken<List<VideoInfo>>() { |
| | |
| | | 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.main.FeedVideoFragment; |
| | | import com.weikou.beibeivideo.ui.main.MainActivity; |
| | | import com.weikou.beibeivideo.ui.media.VideoDetailActivity; |
| | | import com.weikou.beibeivideo.ui.mine.BrowserActivity; |
| | | import com.weikou.beibeivideo.util.BeibeiConstant; |
| | | import com.weikou.beibeivideo.util.CustomShareDialog; |
| | | import com.weikou.beibeivideo.util.DimenUtils; |
| | | import com.weikou.beibeivideo.util.JsonUtil; |
| | | import com.weikou.beibeivideo.util.JumpActivityUtil; |
| | | import com.weikou.beibeivideo.util.ad.AdUtil; |
| | | import com.weikou.beibeivideo.util.ad.ExpressAdManager; |
| | |
| | | |
| | | public class RecommendFragment extends RetainViewFragment implements |
| | | OnClickListener { |
| | | |
| | | private final String TAG = "RecommendFragment"; |
| | | |
| | | private SwipeRefreshLayout rl_recommend; |
| | | |
| | |
| | | bundle.putInt("position", Integer.parseInt(position)); |
| | | fragment.setArguments(bundle); |
| | | return fragment; |
| | | } else if ("feedVideos".equalsIgnoreCase(type.getDataType())) { |
| | | return new FeedVideoFragment(); |
| | | } else { |
| | | CategoryRecommendFragment fragment = new CategoryRecommendFragment(); |
| | | Bundle bundle = new Bundle(); |
| | |
| | | return; |
| | | if (mRecommendNewAdapter.getAdCount() == 0) { |
| | | if (adList != null && adList.size() > 0) { |
| | | mRecommendNewAdapter.addAdToPosition(adList.get(0), 3); |
| | | mRecommendNewAdapter.addAdToPosition(adList.get(0), 1); |
| | | adList.remove(0); |
| | | } |
| | | mRecommendNewAdapter.notifyDataSetChanged(); |
| | | } |
| | |
| | | |
| | | private List<ExpressAdContainer> adList; |
| | | |
| | | private void loadAd() { |
| | | private synchronized void loadAd() { |
| | | //有没消耗的广告 |
| | | if (RecommendFragment.this.adList != null && RecommendFragment.this.adList.size() > 0) { |
| | | return; |
| | | } |
| | | if (position != 0)//只有推荐才有广告 |
| | | { |
| | | return; |
| | | } |
| | | Log.i(TAG, "请求首页大广告"); |
| | | try { |
| | | ExpressAdManager recommendAdManager = new ExpressAdManager(AdUtil.AD_TYPE.csj, context); |
| | | recommendAdManager.loadRecommendLargeAd(new ExpressAdManager.IAdLoadListener() { |
| | |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | try { |
| | | snapshot = cache.get(getKey("getHomeType") + type.getId()); |
| | | if (snapshot != null) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE).create(); |
| | | List<HomeType> homeTypes = gson.fromJson( |
| | | List<HomeType> homeTypes = JsonUtil.videoGson.fromJson( |
| | | snapshot.getString(0), |
| | | new TypeToken<List<HomeType>>() { |
| | | }.getType()); |
| | |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder() |
| | | .setPrettyPrinting() |
| | | .setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | |
| | | JSONObject data = jsonObject |
| | | .getJSONObject("Data"); |
| | | List<HomeAd> homeAds = gson.fromJson(data.getJSONArray("data") |
| | | List<HomeAd> homeAds = JsonUtil.videoGson.fromJson(data.getJSONArray("data") |
| | | .toString(), new TypeToken<List<HomeAd>>() { |
| | | }.getType()); |
| | | //获取banner比例 |
| | |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder().setVersion(1.0).setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | |
| | | List<HomeType> homeTypes = new ArrayList<HomeType>(); |
| | | JSONArray array = jsonObject.getJSONObject("Data") |
| | | .getJSONArray("data"); |
| | |
| | | |
| | | |
| | | if (obj.optJSONObject("Ad") != null) |
| | | type.setAd(gson.fromJson(obj.optJSONObject("Ad").toString(), HomeType.HomeTypeAd.class)); |
| | | type.setAd(JsonUtil.videoGson.fromJson(obj.optJSONObject("Ad").toString(), HomeType.HomeTypeAd.class)); |
| | | |
| | | JSONArray homeArray = obj |
| | | .optJSONArray("HomeVideoList"); |
| | |
| | | if (homeArray != null && homeArray.length() > 0) { |
| | | for (int j = 0; j < homeArray.length(); j++) { |
| | | |
| | | homeList.add(gson.fromJson(homeArray |
| | | homeList.add(JsonUtil.videoGson.fromJson(homeArray |
| | | .optJSONObject(j).toString(), |
| | | HomeVideo.class)); |
| | | } |
| | |
| | | if (itemArray != null && itemArray.length() > 0) { |
| | | for (int k = 0; k < itemArray.length(); k++) { |
| | | if (itemArray.optJSONObject(k) != null) { |
| | | itemList.add(gson.fromJson( |
| | | itemList.add(JsonUtil.videoGson.fromJson( |
| | | itemArray.optJSONObject(k) |
| | | .toString(), |
| | | HomeTypeItem.class)); |
| | |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | hotStars.clear(); |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | List<HotStar> hotStarList = gson.fromJson( |
| | | |
| | | List<HotStar> hotStarList = JsonUtil.videoGson.fromJson( |
| | | jsonObject.getJSONObject("Data") |
| | | .getJSONArray("data").toString(), |
| | | new TypeToken<List<HotStar>>() { |
| | |
| | | import com.weikou.beibeivideo.ui.common.VideosLiveActivity; |
| | | import com.weikou.beibeivideo.ui.discover.StarsActivity; |
| | | import com.weikou.beibeivideo.ui.video.VideoRecommendAdapter; |
| | | import com.weikou.beibeivideo.util.JsonUtil; |
| | | import com.weikou.beibeivideo.util.JumpActivityUtil; |
| | | import com.weikou.beibeivideo.util.ad.ExpressAdManager; |
| | | import com.weikou.beibeivideo.util.downutil.StringUtils; |
| | |
| | | public final int TYPE_HEADER = 10001; |
| | | public final int TYPE_FOOTER = 10002; |
| | | |
| | | private Gson gson = new GsonBuilder().setVersion(1.0).setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | |
| | | |
| | | private View headerView; |
| | | private View footerView; |
| | |
| | | List<HomeVideo> homeList = new ArrayList<>(); |
| | | if (homeArray != null && homeArray.length() > 0) { |
| | | for (int j = 0; j < homeArray.length(); j++) { |
| | | homeList.add(gson.fromJson(homeArray |
| | | homeList.add(JsonUtil.videoGson.fromJson(homeArray |
| | | .optJSONObject(j).toString(), |
| | | HomeVideo.class)); |
| | | } |
| | |
| | | import com.weikou.beibeivideo.ui.BaseActivity; |
| | | import com.weikou.beibeivideo.ui.video.SearchResultAdapter; |
| | | import com.weikou.beibeivideo.util.DimenUtils; |
| | | import com.weikou.beibeivideo.util.JsonUtil; |
| | | import com.weikou.beibeivideo.util.UmengEventUtil; |
| | | import com.weikou.beibeivideo.util.ad.ExpressAdManager; |
| | | import com.weikou.beibeivideo.util.ad.GDTConstant; |
| | |
| | | makeGoldCornRunnable = GoldCornUtil.makeGoldCorn(getIntent(), et_search_key, null, null, 2, null); |
| | | |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | |
| | | JSONObject rootData = jsonObject.getJSONObject("Data"); |
| | | List<VideoInfo> videoInfos = gson.fromJson( |
| | | List<VideoInfo> videoInfos = JsonUtil.videoGson.fromJson( |
| | | |
| | | rootData.getJSONArray("data").toString(), |
| | | new TypeToken<List<VideoInfo>>() { |
| | |
| | | //设置导航栏 |
| | | if (rootData.opt("typeList") != null) { |
| | | if (typeList == null) { |
| | | typeList = gson.fromJson( |
| | | typeList = JsonUtil.videoGson.fromJson( |
| | | rootData |
| | | .getJSONArray("typeList").toString(), |
| | | new TypeToken<List<VideoType>>() { |
| | |
| | | import com.weikou.beibeivideo.entity.VideoResource; |
| | | import com.weikou.beibeivideo.entity.video.FunshionPlayInfo; |
| | | import com.weikou.beibeivideo.util.FunshionConstant; |
| | | import com.weikou.beibeivideo.util.JsonUtil; |
| | | import com.weikou.beibeivideo.util.UmengEventUtil; |
| | | import com.weikou.beibeivideo.util.UserUtil; |
| | | import com.weikou.beibeivideo.util.VideoUtil; |
| | |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | VideoResource resource = gson.fromJson( |
| | | |
| | | VideoResource resource = JsonUtil.videoGson.fromJson( |
| | | jsonObject.getJSONObject("Data") |
| | | .getJSONObject("Resource") |
| | | .toString(), |
New file |
| | |
| | | package com.weikou.beibeivideo.util; |
| | | |
| | | import com.google.gson.FieldNamingPolicy; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | |
| | | public class JsonUtil { |
| | | |
| | | public static Gson videoGson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .excludeFieldsWithoutExposeAnnotation() |
| | | .create(); |
| | | |
| | | } |
| | |
| | | import android.content.SharedPreferences; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.weikou.beibeivideo.entity.VideoDetailInfo; |
| | |
| | | private static void saveTempVideoDetailList(Context context, List<VideoDetailInfo> detailInfos) { |
| | | SharedPreferences sharedPreferences = context.getSharedPreferences("videoTempInfo", Context.MODE_PRIVATE); |
| | | SharedPreferences.Editor editor = sharedPreferences.edit(); |
| | | editor.putString("videoDetailInfoList", new Gson().toJson(detailInfos)); |
| | | |
| | | Gson gson= new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); |
| | | |
| | | editor.putString("videoDetailInfoList", gson.toJson(detailInfos)); |
| | | editor.commit(); |
| | | } |
| | | |
| | |
| | | * @return |
| | | */ |
| | | private static List<VideoDetailInfo> getTempVideoDetailList(Context context) { |
| | | Gson gson= new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); |
| | | SharedPreferences sharedPreferences = context.getSharedPreferences("videoTempInfo", Context.MODE_PRIVATE); |
| | | String content = sharedPreferences.getString("videoDetailInfoList", ""); |
| | | if (!StringUtils.isEmpty(content)) { |
| | | return new Gson().fromJson(content, new TypeToken<List<VideoDetailInfo>>() { |
| | | return gson.fromJson(content, new TypeToken<List<VideoDetailInfo>>() { |
| | | }.getType()); |
| | | } |
| | | return new ArrayList<>(); |
| | |
| | | |
| | | import android.content.Context; |
| | | import android.content.SharedPreferences; |
| | | import android.os.Build; |
| | | |
| | | import com.weikou.beibeivideo.entity.ad.AdPositionEnum; |
| | | import com.weikou.beibeivideo.entity.ad.AdTypeVO; |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 穿山甲广告是否需要初始化 |
| | | * |
| | | * @return |
| | | */ |
| | | public static boolean isCanInitCSJ() { |
| | | return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP; |
| | | // return true; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | public static String VIDEO_DETAIL_INTERSTITIALAD="946608275"; |
| | | |
| | | |
| | | //首页插屏 |
| | | public static String HOME_INTERSTITIALAD="947410891"; |
| | | |
| | | |
| | | } |
| | |
| | | ad.getGdt2().render(); |
| | | |
| | | } else if (ad.getCsj() != null) { |
| | | Log.i(TAG, "广告曝光:csj"); |
| | | ad.getCsj().setExpressInteractionListener(new TTNativeExpressAd.ExpressAdInteractionListener() { |
| | | @Override |
| | | public void onAdClicked(View view, int i) { |
| | |
| | | public static String PID_2_VIDEO_DETAIL_INTERSTITIAL = "7002342568464590"; |
| | | |
| | | |
| | | //首页插屏广告 |
| | | public static String HOME_INTERSTITIAL = "4052677643473516"; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.weikou.beibeivideo.util.ad; |
| | | |
| | | |
| | | import android.app.Activity; |
| | | |
| | | import com.bytedance.sdk.openadsdk.AdSlot; |
| | | import com.bytedance.sdk.openadsdk.TTAdConstant; |
| | | import com.bytedance.sdk.openadsdk.TTAdNative; |
| | | import com.bytedance.sdk.openadsdk.TTAdSdk; |
| | | import com.bytedance.sdk.openadsdk.TTFullScreenVideoAd; |
| | | import com.qq.e.ads.cfg.VideoOption; |
| | | import com.qq.e.ads.interstitial2.UnifiedInterstitialAD; |
| | | import com.qq.e.ads.interstitial2.UnifiedInterstitialADListener; |
| | | import com.qq.e.comm.util.AdError; |
| | | |
| | | public class InterstitialAdUtil { |
| | | |
| | | |
| | | public static void showAd(Activity context, AdUtil.AD_TYPE adType, String pid) { |
| | | if (adType == null) { |
| | | return; |
| | | } |
| | | |
| | | if (adType == AdUtil.AD_TYPE.csj) { |
| | | loadCSJ(context, pid); |
| | | } else if (adType == AdUtil.AD_TYPE.gdt) { |
| | | showGDT(context, pid); |
| | | } |
| | | } |
| | | |
| | | private static void loadCSJ(Activity context, String codeId) { |
| | | TTAdNative mTTAdNative = TTAdSdk.getAdManager().createAdNative(context); |
| | | AdSlot adSlot = new AdSlot.Builder() |
| | | .setCodeId(codeId) |
| | | //模板广告需要设置期望个性化模板广告的大小,单位dp,激励视频场景,只要设置的值大于0即可 |
| | | .setExpressViewAcceptedSize(300, 300) |
| | | .setSupportDeepLink(true) |
| | | .setOrientation(TTAdConstant.VERTICAL)//必填参数,期望视频的播放方向:TTAdConstant.HORIZONTAL 或 TTAdConstant.VERTICAL |
| | | .build(); |
| | | |
| | | mTTAdNative.loadFullScreenVideoAd(adSlot, new TTAdNative.FullScreenVideoAdListener() { |
| | | //请求广告失败 |
| | | @Override |
| | | public void onError(int code, String message) { |
| | | |
| | | } |
| | | |
| | | //广告物料加载完成的回调 |
| | | @Override |
| | | public void onFullScreenVideoAdLoad(TTFullScreenVideoAd ad) { |
| | | |
| | | } |
| | | |
| | | //广告视频/图片加载完成的回调,接入方可以在这个回调后展示广告 |
| | | @Override |
| | | public void onFullScreenVideoCached() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onFullScreenVideoCached(TTFullScreenVideoAd ttFullScreenVideoAd) { |
| | | ttFullScreenVideoAd.showFullScreenVideoAd(context); |
| | | } |
| | | }); |
| | | |
| | | |
| | | } |
| | | |
| | | private static UnifiedInterstitialAD iad = null; |
| | | |
| | | private static void showGDT(Activity context, String pid) { |
| | | |
| | | VideoOption.Builder builder = new VideoOption.Builder(); |
| | | VideoOption option = builder.build(); |
| | | iad = new UnifiedInterstitialAD(context, pid, new UnifiedInterstitialADListener() { |
| | | |
| | | @Override |
| | | public void onADReceive() { |
| | | if (iad != null && iad.isValid()) { |
| | | iad.showAsPopupWindow(context); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onVideoCached() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onNoAD(AdError adError) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onADOpened() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onADExposure() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onADClicked() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onADLeftApplication() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onADClosed() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onRenderSuccess() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onRenderFail() { |
| | | |
| | | } |
| | | }); |
| | | |
| | | iad.setVideoOption(option); |
| | | iad.loadAD(); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.weikou.beibeivideo.util.ad; |
| | | |
| | | public class KSConstant { |
| | | |
| | | public static long PID_FULL_VIDEO = 8010000001L; |
| | | public static long PID_FEED = 8010000008L; |
| | | |
| | | } |
| | |
| | | code = BeibeiConstant.GDT_SPLASH_POSITION_ID; |
| | | if (skip != null) |
| | | skip.setVisibility(View.VISIBLE); |
| | | gdtSplashAD = new SplashAD(context, skip, code, new SplashADListener() { |
| | | gdtSplashAD = new SplashAD(context, code, new SplashADListener() { |
| | | @Override |
| | | public void onADDismissed() { |
| | | splashAdListener.close(); |
| | |
| | | @Override |
| | | public void onADClicked() { |
| | | System.out.println(""); |
| | | splashAdListener.onAdClick(); |
| | | |
| | | } |
| | | |
| | | @Override |
| | |
| | | Log.i(TAG, "GDT:onADLoaded-" + l); |
| | | splashAdListener.onAdLoad(new SplashAdLoadInfo(gdtSplashAD, System.currentTimeMillis() + (l - SystemClock.elapsedRealtime()))); |
| | | } |
| | | }, 0); |
| | | }, 3500); |
| | | |
| | | gdtSplashAD.fetchAdOnly(); |
| | | } |
| | | |
| | |
| | | |
| | | public void onAdLoad(SplashAdLoadInfo adLoadInfo); |
| | | |
| | | public void onAdClick(); |
| | | |
| | | public void close(); |
| | | |
| | | public void noAd(); |
| | |
| | | import com.bytedance.sdk.openadsdk.TTAdConstant; |
| | | import com.bytedance.sdk.openadsdk.TTAdManager; |
| | | import com.bytedance.sdk.openadsdk.TTAdSdk; |
| | | import com.weikou.beibeivideo.R; |
| | | import com.weikou.beibeivideo.entity.ad.AdPositionEnum; |
| | | |
| | | /** |
| | | * 可以用一个单例来保存TTAdManager实例,在需要初始化sdk的时候调用 |
| | |
| | | } |
| | | |
| | | private static TTAdConfig buildConfig(Context context) { |
| | | return new TTAdConfig.Builder() |
| | | TTAdConfig.Builder builder = new TTAdConfig.Builder() |
| | | .appId("5095354") |
| | | .useTextureView(true) //使用TextureView控件播放视频,默认为SurfaceView,当有SurfaceView冲突的场景,可以使用TextureView |
| | | .appName("影视大全布丸") |
| | | .appName(context.getString(R.string.app_name)) |
| | | .titleBarTheme(TTAdConstant.TITLE_BAR_THEME_DARK) |
| | | .allowShowNotify(true) //是否允许sdk展示通知栏提示 |
| | | .allowShowPageWhenScreenLock(true) //是否在锁屏场景支持展示广告落地页 |
| | | .debug(true) //测试阶段打开,可以通过日志排查问题,上线时去除该调用 |
| | | .directDownloadNetworkType(TTAdConstant.NETWORK_STATE_WIFI) |
| | | // .directDownloadNetworkType(TTAdConstant.NETWORK_STATE_WIFI) |
| | | .supportMultiProcess(true)//是否支持多进程 |
| | | .asyncInit(true) |
| | | .needClearTaskReset() |
| | | //.httpStack(new MyOkStack3())//自定义网络库,demo中给出了okhttp3版本的样例,其余请自行开发或者咨询工作人员。 |
| | | .build(); |
| | | .needClearTaskReset(); |
| | | //.httpStack(new MyOkStack3())//自定义网络库,demo中给出了okhttp3版本的样例,其余请自行开发或者咨询工作人员。 |
| | | if (AdUtil.getAdType(context, AdPositionEnum.splashHotStart) != null) { |
| | | builder.directDownloadNetworkType(TTAdConstant.NETWORK_STATE_WIFI); |
| | | } |
| | | |
| | | return builder.build(); |
| | | } |
| | | } |
| | |
| | | //判断是否是AndroidN以及更高的版本 |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { |
| | | intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); |
| | | Uri contentUri = FileProvider.getUriForFile(context.getApplicationContext(), BuildConfig.APPLICATION_ID + ".fileprovider", file); |
| | | Uri contentUri = FileProvider.getUriForFile(context.getApplicationContext(), "com.doudou.ysvideo.fileprovider", file); |
| | | intent.setDataAndType(contentUri, "application/vnd.android.package-archive"); |
| | | } else { |
| | | Uri uri = Uri.fromFile(file); |
| | |
| | | } |
| | | } |
| | | |
| | | public static void setStatusViewAndLightColor(Activity mActivity) { |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { |
| | | Window window = mActivity.getWindow(); |
| | | window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); |
| | | window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
| | | | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); |
| | | window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); |
| | | window.setStatusBarColor(Color.BLACK); |
| | | //设置状态栏文字颜色及图标为深色 |
| | | mActivity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); |
| | | |
| | | int result = 0; |
| | | int resourceId = mActivity.getResources().getIdentifier("status_bar_height", |
| | | "dimen", "android"); |
| | | if (resourceId > 0) { |
| | | result = mActivity.getResources().getDimensionPixelSize(resourceId); |
| | | } |
| | | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, |
| | | result); |
| | | mActivity.findViewById(R.id.v_status_bar).setLayoutParams(params); |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { |
| | | try { |
| | | Class decorViewClazz = Class.forName("com.android.internal.policy.DecorView"); |
| | | Field field = decorViewClazz.getDeclaredField("mSemiTransparentStatusBarColor"); |
| | | field.setAccessible(true); |
| | | field.setInt(window.getDecorView(), Color.TRANSPARENT); //改为透明 |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } else { |
| | | mActivity.findViewById(R.id.v_status_bar).setVisibility(View.GONE); |
| | | } |
| | | } |
| | | |
| | | |
| | | public static void setStatusViewAndDeepColor(Activity mActivity, View stateBar, View stateBar1) { |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { |
| | |
| | | url "https://maven.aliyun.com/repository/google" |
| | | } |
| | | |
| | | maven{url 'https://artifact.bytedance.com/repository/Volcengine/'} |
| | | |
| | | maven { url 'https://repo1.maven.org/maven2/' } |
| | | |
| | | jcenter() |
| | |
| | | maven { url 'http://developer.huawei.com/repo/' } |
| | | |
| | | maven { url 'https://artifact.bytedance.com/repository/pangle'} |
| | | |
| | | |
| | | } |
| | | |
| | | dependencies { |
| | |
| | | url "https://maven.aliyun.com/repository/google" |
| | | } |
| | | |
| | | maven{url 'https://artifact.bytedance.com/repository/Volcengine/'} |
| | | |
| | | maven { url 'https://repo1.maven.org/maven2/' } |
| | | |
| | | jcenter() |
| | |
| | | } |
| | | |
| | | maven { url 'https://jitpack.io' } |
| | | maven { url 'https://dl.bintray.com/umsdk/release' } |
| | | maven { url "https://dl.bintray.com/thelasterstar/maven/" } |
| | | // maven { url 'https://dl.bintray.com/umsdk/release' } |
| | | // maven { url "https://dl.bintray.com/thelasterstar/maven/" } |
| | | maven { url 'http://developer.huawei.com/repo/' } |
| | | maven { url 'https://artifact.bytedance.com/repository/pangle'} |
| | | |
| | | } |
| | | } |
| | |
| | | android.enableJetifier=true |
| | | android.useAndroidX=true |
| | | android.useAndroidX=true |
| | | org.gradle.jvmargs=-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 |
| | |
| | | return 0; |
| | | } |
| | | } |
| | | |
| | | public static String getVersionName(Context context) { |
| | | try { |
| | | PackageInfo pi = context.getPackageManager().getPackageInfo( |
| | | context.getPackageName(), 0); |
| | | return pi.versionName; |
| | | } catch (NameNotFoundException e) { |
| | | e.printStackTrace(); |
| | | return ""; |
| | | } |
| | | } |
| | | } |