Repository: lingxiaopua/BiliBili Branch: master Commit: 5a9aa28e0660 Files: 465 Total size: 1.4 MB Directory structure: gitextract_tczigxgc/ ├── .gitattributes.txt ├── .gitignore ├── LICENSE ├── README.md ├── app/ │ ├── .gitignore │ ├── CMakeLists.txt │ ├── build.gradle │ ├── libs/ │ │ ├── Java-WebSocket-1.3.8.jar │ │ └── tbs_sdk_thirdapp_v4.3.0.1020_43633_sharewithdownload_withoutGame_obfs_20190111_105200.jar │ ├── proguard-rules.pro │ └── src/ │ ├── androidTest/ │ │ └── java/ │ │ └── com/ │ │ └── bilibili/ │ │ └── lingxiao/ │ │ └── ExampleInstrumentedTest.kt │ ├── main/ │ │ ├── AndroidManifest.xml │ │ ├── cpp/ │ │ │ └── native-lib.cpp │ │ ├── java/ │ │ │ └── com/ │ │ │ └── bilibili/ │ │ │ └── lingxiao/ │ │ │ ├── App.kt │ │ │ ├── GlobalProperties.kt │ │ │ ├── HttpTrans.kt │ │ │ ├── InitIalizeService.kt │ │ │ ├── SplashActivity.kt │ │ │ ├── dagger/ │ │ │ │ ├── UiComponent.kt │ │ │ │ ├── UiModule.kt │ │ │ │ └── scope/ │ │ │ │ └── PerUi.kt │ │ │ ├── database/ │ │ │ │ ├── NetCacheDatabase.kt │ │ │ │ ├── RegionTable.kt │ │ │ │ ├── UserInfoTable.kt │ │ │ │ ├── dao/ │ │ │ │ │ └── UserDao.kt │ │ │ │ └── db/ │ │ │ │ └── AppDatabase.kt │ │ │ ├── home/ │ │ │ │ ├── MainActivity.kt │ │ │ │ ├── dynamic/ │ │ │ │ │ └── DynamicFragment.kt │ │ │ │ ├── find/ │ │ │ │ │ ├── FindView.kt │ │ │ │ │ ├── RankListView.kt │ │ │ │ │ ├── TopicView.kt │ │ │ │ │ ├── model/ │ │ │ │ │ │ ├── HotWordsData.kt │ │ │ │ │ │ ├── RankListData.kt │ │ │ │ │ │ ├── SearchResultData.kt │ │ │ │ │ │ └── TopicCardData.kt │ │ │ │ │ ├── presenter/ │ │ │ │ │ │ ├── FindPresenter.kt │ │ │ │ │ │ ├── RankListPresenter.kt │ │ │ │ │ │ ├── SearchDetailPresenter.kt │ │ │ │ │ │ └── TopicCenterPresenter.kt │ │ │ │ │ └── ui/ │ │ │ │ │ ├── FindFragment.kt │ │ │ │ │ ├── RankListActivity.kt │ │ │ │ │ ├── RankListFragment.kt │ │ │ │ │ ├── SearchDetailActivity.kt │ │ │ │ │ ├── SearchDetailFragment.kt │ │ │ │ │ └── TopicCenterActivity.kt │ │ │ │ ├── live/ │ │ │ │ │ ├── BannerImageLoader.kt │ │ │ │ │ ├── DanMaKuTool.kt │ │ │ │ │ ├── LivePlatform.kt │ │ │ │ │ ├── adapter/ │ │ │ │ │ │ ├── FansAdapter.kt │ │ │ │ │ │ ├── FleetAdapter.kt │ │ │ │ │ │ ├── LiveRecommendAdapter.kt │ │ │ │ │ │ ├── LiveRecyAdapter.kt │ │ │ │ │ │ ├── PartitionAdapter.kt │ │ │ │ │ │ ├── PartitionVideoAdapter.kt │ │ │ │ │ │ └── PlayPagerAdapter.kt │ │ │ │ │ ├── model/ │ │ │ │ │ │ ├── FansGoldListData.kt │ │ │ │ │ │ ├── FleetListData.kt │ │ │ │ │ │ ├── LiveAllData.kt │ │ │ │ │ │ ├── LiveChatData.kt │ │ │ │ │ │ ├── LiveData.java │ │ │ │ │ │ ├── LiveDataNew.java │ │ │ │ │ │ ├── LiveTabData.kt │ │ │ │ │ │ ├── LiveUpData.kt │ │ │ │ │ │ ├── LiveUserData.kt │ │ │ │ │ │ ├── MultiItemLiveData.java │ │ │ │ │ │ └── UpInfoData.kt │ │ │ │ │ ├── presenter/ │ │ │ │ │ │ ├── FansDetailPresenter.kt │ │ │ │ │ │ ├── FleetPresenter.kt │ │ │ │ │ │ ├── InteractPresenter.kt │ │ │ │ │ │ ├── LiveAllPresenter.kt │ │ │ │ │ │ ├── LivePlayPresenter.kt │ │ │ │ │ │ ├── LivePresenter.kt │ │ │ │ │ │ ├── LiveTabPresenter.kt │ │ │ │ │ │ └── UpVideoPresenter.kt │ │ │ │ │ ├── ui/ │ │ │ │ │ │ ├── LiveAllActivity.kt │ │ │ │ │ │ ├── LiveAllFragment.kt │ │ │ │ │ │ ├── LiveFragment.kt │ │ │ │ │ │ ├── LiveMoreActivity.kt │ │ │ │ │ │ ├── LivePlayActivity.kt │ │ │ │ │ │ ├── SearchDialogFragment.kt │ │ │ │ │ │ ├── StreamHomeActivity.kt │ │ │ │ │ │ └── play/ │ │ │ │ │ │ ├── FansDetailFragment.kt │ │ │ │ │ │ ├── FansFragment.kt │ │ │ │ │ │ ├── FleetListFragment.kt │ │ │ │ │ │ ├── InteractFragment.kt │ │ │ │ │ │ └── UpInfoFragment.kt │ │ │ │ │ └── view/ │ │ │ │ │ ├── FansDetailView.kt │ │ │ │ │ ├── LiveAllView.kt │ │ │ │ │ ├── LivePlayView.kt │ │ │ │ │ ├── LiveTabView.kt │ │ │ │ │ └── LiveView.kt │ │ │ │ ├── mikan/ │ │ │ │ │ ├── MiKanPresenter.kt │ │ │ │ │ ├── MikanView.kt │ │ │ │ │ ├── adapter/ │ │ │ │ │ │ ├── MiKanFallAdapter.kt │ │ │ │ │ │ └── MikanAdapter.kt │ │ │ │ │ ├── model/ │ │ │ │ │ │ ├── MiKanFallData.kt │ │ │ │ │ │ ├── MiKanRecommendData.kt │ │ │ │ │ │ └── MikanData.kt │ │ │ │ │ └── ui/ │ │ │ │ │ └── MikanFragment.kt │ │ │ │ ├── navigation/ │ │ │ │ │ ├── SettingActivity.kt │ │ │ │ │ └── ThemeActivity.kt │ │ │ │ ├── recommend/ │ │ │ │ │ ├── RecommendPresenter.kt │ │ │ │ │ ├── RecommendTrans.kt │ │ │ │ │ ├── model/ │ │ │ │ │ │ └── RecommendData.kt │ │ │ │ │ ├── ui/ │ │ │ │ │ │ ├── RecommendFragment.kt │ │ │ │ │ │ └── RecommendRecyAdapter.kt │ │ │ │ │ └── view/ │ │ │ │ │ └── RecommendView.kt │ │ │ │ └── region/ │ │ │ │ ├── RegionAdapter.kt │ │ │ │ ├── model/ │ │ │ │ │ ├── BangumiDetailData.kt │ │ │ │ │ ├── BangumiRecommendData.kt │ │ │ │ │ ├── MultiRegionData.kt │ │ │ │ │ ├── RegionData.kt │ │ │ │ │ ├── RegionDetailData.kt │ │ │ │ │ └── RegionRecommendData.kt │ │ │ │ ├── presenter/ │ │ │ │ │ ├── BangumiDetailPresenter.kt │ │ │ │ │ ├── RegionDetailPresenter.kt │ │ │ │ │ └── RegionPresenter.kt │ │ │ │ ├── ui/ │ │ │ │ │ ├── BangumiDetailActivity.kt │ │ │ │ │ ├── RegionDetailFragment.kt │ │ │ │ │ ├── RegionFragment.kt │ │ │ │ │ └── RegionTabActivity.kt │ │ │ │ └── view/ │ │ │ │ ├── BangumiView.kt │ │ │ │ ├── RegionDetailView.kt │ │ │ │ └── RegionView.kt │ │ │ ├── play/ │ │ │ │ ├── DoubleCommentView.kt │ │ │ │ ├── VideoPresenter.kt │ │ │ │ ├── adapter/ │ │ │ │ │ ├── CommentAdapter.kt │ │ │ │ │ ├── EndPageAdapter.kt │ │ │ │ │ └── VideoDetailAdapter.kt │ │ │ │ ├── model/ │ │ │ │ │ ├── CommentData.kt │ │ │ │ │ ├── VideoData.kt │ │ │ │ │ ├── VideoDetailData.kt │ │ │ │ │ └── VideoRecoData.kt │ │ │ │ └── ui/ │ │ │ │ ├── CommentDetailFragment.kt │ │ │ │ ├── CommentFragment.kt │ │ │ │ ├── IntroduceFragment.kt │ │ │ │ └── PlayActivity.kt │ │ │ ├── user/ │ │ │ │ ├── LoginActivity.kt │ │ │ │ ├── LoginPresenter.kt │ │ │ │ └── LoginView.kt │ │ │ ├── utils/ │ │ │ │ ├── DateUtil.kt │ │ │ │ ├── MD5Util.kt │ │ │ │ ├── StringUtil.kt │ │ │ │ ├── ToastUtil.kt │ │ │ │ └── UIUtil.kt │ │ │ ├── web/ │ │ │ │ └── WebActivity.kt │ │ │ └── widget/ │ │ │ ├── ArcView.kt │ │ │ ├── ColorTextView.kt │ │ │ ├── FindLineView.kt │ │ │ ├── FoldableLayout.kt │ │ │ ├── LaybelLayout.kt │ │ │ ├── LinearCardView.kt │ │ │ ├── RippleAnimation.kt │ │ │ ├── ScrollerloadRecyclerView.kt │ │ │ ├── behavior/ │ │ │ │ ├── PlayerBehavior.kt │ │ │ │ ├── ScrollAwareFabBehaviorDefault.kt │ │ │ │ └── TransferHeaderBehavior.kt │ │ │ └── skin/ │ │ │ ├── SkinTabLayout.kt │ │ │ ├── SlidTabLayout.kt │ │ │ └── SmartSkinRefreshLayout.kt │ │ └── res/ │ │ ├── anim/ │ │ │ ├── left_in.xml │ │ │ ├── left_out.xml │ │ │ ├── pop_hide.xml │ │ │ ├── pop_left_hide.xml │ │ │ ├── pop_right_show.xml │ │ │ ├── pop_show.xml │ │ │ ├── pop_watch_later_hide.xml │ │ │ ├── pop_watch_later_show.xml │ │ │ ├── right_in.xml │ │ │ └── right_out.xml │ │ ├── drawable/ │ │ │ ├── bangumi_follow_animlist.xml │ │ │ ├── bg_bottom_menu.xml │ │ │ ├── button_white_line_background.xml │ │ │ ├── ic_image_left.xml │ │ │ ├── ic_img_agree.xml │ │ │ ├── ic_img_comment.xml │ │ │ ├── ic_img_danmaku.xml │ │ │ ├── ic_img_disagree.xml │ │ │ ├── ic_img_download.xml │ │ │ ├── ic_img_game.xml │ │ │ ├── ic_img_header.xml │ │ │ ├── ic_img_live_people.xml │ │ │ ├── ic_img_more_menu.xml │ │ │ ├── ic_img_password.xml │ │ │ ├── ic_img_refresh.xml │ │ │ ├── ic_img_relay.xml │ │ │ ├── ic_img_right.xml │ │ │ ├── ic_img_scan_qr_code.xml │ │ │ ├── ic_img_search.xml │ │ │ ├── ic_img_toggle_down.xml │ │ │ ├── ic_img_toggle_up.xml │ │ │ ├── ic_img_tv.xml │ │ │ ├── ic_img_up_name.xml │ │ │ ├── ic_launcher_background.xml │ │ │ ├── ic_nav_big_vip.xml │ │ │ ├── ic_nav_buyset.xml │ │ │ ├── ic_nav_circle.xml │ │ │ ├── ic_nav_collect.xml │ │ │ ├── ic_nav_create_center.xml │ │ │ ├── ic_nav_free_flow.xml │ │ │ ├── ic_nav_history.xml │ │ │ ├── ic_nav_home.xml │ │ │ ├── ic_nav_next_watch.xml │ │ │ ├── ic_nav_outline.xml │ │ │ ├── ic_nav_skin.xml │ │ │ ├── ic_search_api_material_dark.xml │ │ │ ├── ic_search_qr.xml │ │ │ ├── ic_upper_choose.xml │ │ │ ├── layer_night.xml │ │ │ ├── layer_setting.xml │ │ │ ├── layer_theme.xml │ │ │ ├── login_button_background.xml │ │ │ ├── nav_menu_text_color.xml │ │ │ ├── pop_selector.xml │ │ │ ├── progress_style_circle.xml │ │ │ ├── radius_text_background.xml │ │ │ ├── register_button_background.xml │ │ │ ├── ripple_background.xml │ │ │ └── text_live_background.xml │ │ ├── drawable-xhdpi/ │ │ │ └── pop_bottom_text.xml │ │ ├── drawable-xxhdpi/ │ │ │ ├── button_more_background.xml │ │ │ └── button_pop_background.xml │ │ ├── layout/ │ │ │ ├── activity_bangumi_detail.xml │ │ │ ├── activity_live_all.xml │ │ │ ├── activity_live_more.xml │ │ │ ├── activity_live_play.xml │ │ │ ├── activity_login.xml │ │ │ ├── activity_main.xml │ │ │ ├── activity_play.xml │ │ │ ├── activity_rank_list.xml │ │ │ ├── activity_search_detail.xml │ │ │ ├── activity_setting.xml │ │ │ ├── activity_splash.xml │ │ │ ├── activity_stream_home.xml │ │ │ ├── activity_theme.xml │ │ │ ├── activity_topic_center.xml │ │ │ ├── activity_web.xml │ │ │ ├── bottom_menu.xml │ │ │ ├── content_bangumi_contract.xml │ │ │ ├── content_bangumi_detail.xml │ │ │ ├── find_line_view.xml │ │ │ ├── footer_live_showall.xml │ │ │ ├── footer_loadmore.xml │ │ │ ├── fragment_comment.xml │ │ │ ├── fragment_comment_detail.xml │ │ │ ├── fragment_dialog_search.xml │ │ │ ├── fragment_dynamic.xml │ │ │ ├── fragment_fans.xml │ │ │ ├── fragment_fans_detail.xml │ │ │ ├── fragment_find.xml │ │ │ ├── fragment_fleet.xml │ │ │ ├── fragment_interact.xml │ │ │ ├── fragment_introduce.xml │ │ │ ├── fragment_live.xml │ │ │ ├── fragment_mikan.xml │ │ │ ├── fragment_recommend.xml │ │ │ ├── fragment_region.xml │ │ │ ├── fragment_region_detail.xml │ │ │ ├── fragment_up_info.xml │ │ │ ├── item_bangumi_tv.xml │ │ │ ├── item_comment.xml │ │ │ ├── item_endpage.xml │ │ │ ├── item_fans_list.xml │ │ │ ├── item_fleet_header_top.xml │ │ │ ├── item_fleet_list.xml │ │ │ ├── item_hot_segment.xml │ │ │ ├── item_live_category.xml │ │ │ ├── item_live_chat.xml │ │ │ ├── item_live_video.xml │ │ │ ├── item_mikan_fall.xml │ │ │ ├── item_mikan_top_bar.xml │ │ │ ├── item_mikan_video.xml │ │ │ ├── item_play_support_quility.xml │ │ │ ├── item_rank_list.xml │ │ │ ├── item_rank_list_child.xml │ │ │ ├── item_region.xml │ │ │ ├── item_region_bottom_bar.xml │ │ │ ├── item_region_top_bar.xml │ │ │ ├── item_theme.xml │ │ │ ├── item_topic_card.xml │ │ │ ├── item_video.xml │ │ │ ├── item_videodetail_recommend.xml │ │ │ ├── layout_banner.xml │ │ │ ├── layout_category.xml │ │ │ ├── layout_empty.xml │ │ │ ├── layout_header_comment_detail.xml │ │ │ ├── layout_header_room_info.xml │ │ │ ├── layout_laybel_watch_more.xml │ │ │ ├── layout_partition.xml │ │ │ ├── layout_recommend.xml │ │ │ ├── linear_card_view.xml │ │ │ ├── live_top_region.xml │ │ │ ├── mikan_content_cn.xml │ │ │ ├── mikan_content_jp.xml │ │ │ ├── mikan_header.xml │ │ │ ├── nav_header.xml │ │ │ ├── normal_refresh_view.xml │ │ │ ├── pop_comment.xml │ │ │ ├── pop_detail_menu.xml │ │ │ ├── pop_user_info.xml │ │ │ ├── pop_watch_later.xml │ │ │ ├── popwindow_play_support_quality.xml │ │ │ ├── title_bar.xml │ │ │ └── top_recommend_bar.xml │ │ ├── menu/ │ │ │ └── nav_menu.xml │ │ ├── mipmap-anydpi-v26/ │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ ├── values/ │ │ │ ├── attrs.xml │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ ├── ids.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ └── xml/ │ │ ├── file_path.xml │ │ └── network_security_config.xml │ └── test/ │ └── java/ │ └── com/ │ └── bilibili/ │ └── lingxiao/ │ └── ExampleUnitTest.kt ├── build.gradle ├── common/ │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src/ │ ├── androidTest/ │ │ └── java/ │ │ └── com/ │ │ └── camera/ │ │ └── lingxiao/ │ │ └── common/ │ │ └── ExampleInstrumentedTest.java │ ├── main/ │ │ ├── AndroidManifest.xml │ │ ├── java/ │ │ │ └── com/ │ │ │ └── camera/ │ │ │ └── lingxiao/ │ │ │ └── common/ │ │ │ ├── Common.kt │ │ │ ├── VersionModle.kt │ │ │ ├── api/ │ │ │ │ └── MainApi.kt │ │ │ ├── app/ │ │ │ │ ├── ActivityController.kt │ │ │ │ ├── BaseActivity.kt │ │ │ │ ├── BaseFragment.kt │ │ │ │ ├── BasePresenter.kt │ │ │ │ ├── BaseTransation.kt │ │ │ │ ├── BaseView.kt │ │ │ │ └── ContentValue.kt │ │ │ ├── body/ │ │ │ │ └── CosplayBody.kt │ │ │ ├── example/ │ │ │ │ ├── HttpModle.kt │ │ │ │ ├── HttpPresenter.kt │ │ │ │ ├── HttpTrans.kt │ │ │ │ ├── HttpView.kt │ │ │ │ └── MainActivity.kt │ │ │ ├── exception/ │ │ │ │ ├── ApiException.kt │ │ │ │ ├── ExceptionEngine.kt │ │ │ │ ├── ServerException.kt │ │ │ │ └── crash/ │ │ │ │ └── CrashActivity.kt │ │ │ ├── http/ │ │ │ │ ├── HttpResultFunction.kt │ │ │ │ ├── OtherServerFunction.kt │ │ │ │ ├── ParseHelper.kt │ │ │ │ ├── RxActionManager.kt │ │ │ │ ├── RxActionManagerImpl.kt │ │ │ │ ├── ServerResultFunction.kt │ │ │ │ ├── request/ │ │ │ │ │ ├── HttpRequest.kt │ │ │ │ │ └── HttpRequestListener.kt │ │ │ │ └── response/ │ │ │ │ └── HttpResponse.kt │ │ │ ├── listener/ │ │ │ │ └── LifeCycleListener.kt │ │ │ ├── observable/ │ │ │ │ └── HttpRxObservable.kt │ │ │ ├── observer/ │ │ │ │ ├── HttpRxCallback.kt │ │ │ │ └── HttpRxObserver.kt │ │ │ ├── oss/ │ │ │ │ ├── Auth.java │ │ │ │ ├── Base64.java │ │ │ │ ├── Constants.java │ │ │ │ ├── Etag.java │ │ │ │ ├── Json.java │ │ │ │ ├── QiNiuSdkHelper.java │ │ │ │ ├── StringMap.java │ │ │ │ ├── StringUtils.java │ │ │ │ └── UrlSafeBase64.java │ │ │ ├── rxbus/ │ │ │ │ ├── RxBus.java │ │ │ │ └── SkinChangedEvent.kt │ │ │ └── utills/ │ │ │ ├── BitmapUtil.kt │ │ │ ├── LogUtils.java │ │ │ ├── MD5Util.java │ │ │ ├── PopwindowUtil.kt │ │ │ ├── RetrofitUtil.kt │ │ │ ├── RxJavaHelp.java │ │ │ └── SpUtils.java │ │ ├── module/ │ │ │ └── AndroidManifest.xml │ │ └── res/ │ │ ├── drawable/ │ │ │ └── ic_launcher_background.xml │ │ ├── layout/ │ │ │ ├── activity_crash.xml │ │ │ └── activity_main.xml │ │ ├── mipmap-anydpi-v26/ │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ └── values/ │ │ ├── colors.xml │ │ ├── ids.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test/ │ └── java/ │ └── com/ │ └── camera/ │ └── lingxiao/ │ └── common/ │ └── ExampleUnitTest.java ├── gradle/ │ └── wrapper/ │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── gradlew ├── gradlew.bat ├── ijkplayer/ │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src/ │ ├── androidTest/ │ │ └── java/ │ │ └── com/ │ │ └── bilibili/ │ │ └── lingxiao/ │ │ └── ijkplayer/ │ │ └── ExampleInstrumentedTest.kt │ ├── main/ │ │ ├── AndroidManifest.xml │ │ ├── java/ │ │ │ └── com/ │ │ │ └── bilibili/ │ │ │ └── lingxiao/ │ │ │ └── ijkplayer/ │ │ │ ├── MainActivity.kt │ │ │ ├── NetworkUtil.kt │ │ │ ├── PlayActivity.kt │ │ │ ├── PlayState.kt │ │ │ ├── application/ │ │ │ │ ├── App.java │ │ │ │ └── Settings.java │ │ │ ├── danmuku/ │ │ │ │ ├── BiliDanmuku.kt │ │ │ │ ├── BiliDanmukuCompressionTools.java │ │ │ │ └── BiliDanmukuParser.java │ │ │ ├── localvideo/ │ │ │ │ ├── VideoAdapter.java │ │ │ │ ├── VideoListActivity.kt │ │ │ │ └── VideoModel.kt │ │ │ ├── media/ │ │ │ │ ├── AndroidMediaController.java │ │ │ │ ├── FileMediaDataSource.java │ │ │ │ ├── IMediaController.java │ │ │ │ ├── IRenderView.java │ │ │ │ ├── IjkVideoView.java │ │ │ │ ├── InfoHudViewHolder.java │ │ │ │ ├── MeasureHelper.java │ │ │ │ ├── MediaPlayerCompat.java │ │ │ │ ├── PlayerManager.java │ │ │ │ ├── SurfaceRenderView.java │ │ │ │ ├── TableLayoutBinder.java │ │ │ │ └── TextureRenderView.java │ │ │ ├── services/ │ │ │ │ └── MediaPlayerService.java │ │ │ └── widget/ │ │ │ └── SimplePlayerView.kt │ │ ├── module/ │ │ │ └── AndroidManifest.xml │ │ └── res/ │ │ ├── drawable/ │ │ │ ├── button_shape.xml │ │ │ ├── ic_img_back.xml │ │ │ ├── ic_img_fullscreen.xml │ │ │ ├── ic_img_light.xml │ │ │ ├── ic_img_more.xml │ │ │ ├── ic_img_pause.xml │ │ │ ├── ic_img_play.xml │ │ │ ├── ic_img_volice.xml │ │ │ ├── ic_launcher_background.xml │ │ │ ├── progress_red.xml │ │ │ ├── round_red.xml │ │ │ ├── simple_player_btn.xml │ │ │ └── simple_player_center_bg.xml │ │ ├── drawable-v24/ │ │ │ └── ic_launcher_foreground.xml │ │ ├── layout/ │ │ │ ├── activity_main.xml │ │ │ ├── activity_play.xml │ │ │ ├── activity_video_list.xml │ │ │ ├── simple_player_controlbar.xml │ │ │ ├── simple_player_controlbar_fullscreen.xml │ │ │ ├── simple_player_topbar.xml │ │ │ ├── simple_player_touch_gestures.xml │ │ │ ├── simple_player_view_player.xml │ │ │ ├── table_media_info.xml │ │ │ ├── table_media_info_row1.xml │ │ │ ├── table_media_info_row2.xml │ │ │ ├── table_media_info_section.xml │ │ │ └── video_item.xml │ │ ├── mipmap-anydpi-v26/ │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ └── values/ │ │ ├── colors.xml │ │ ├── strings.xml │ │ ├── strings_pref.xml │ │ └── styles.xml │ └── test/ │ └── java/ │ └── com/ │ └── bilibili/ │ └── lingxiao/ │ └── ijkplayer/ │ └── ExampleUnitTest.kt ├── settings.gradle └── skinLibrary/ ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src/ ├── androidTest/ │ └── java/ │ └── com/ │ └── lingxiao/ │ └── skinlibrary/ │ └── ExampleInstrumentedTest.java ├── main/ │ ├── AndroidManifest.xml │ ├── java/ │ │ └── com/ │ │ └── lingxiao/ │ │ └── skinlibrary/ │ │ └── SkinLib.kt │ └── res/ │ └── values/ │ ├── colors.xml │ └── strings.xml └── test/ └── java/ └── com/ └── lingxiao/ └── skinlibrary/ └── ExampleUnitTest.java ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitattributes.txt ================================================ *.java linguist-language=kotlin ================================================ FILE: .gitignore ================================================ *.iml .gradle *.apk /local.properties /.idea /.idea/caches/build_file_checksums.ser /.idea/libraries /.idea/modules.xml /.idea/workspace.xml .DS_Store /build /captures .externalNativeBuild ================================================ FILE: LICENSE ================================================ GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software. A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public. The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version. An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU Affero General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Remote Network Interaction; Use with the GNU General Public License. Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements. You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see . ================================================ FILE: README.md ================================================ # BiliBili 转行了各位,所以这个项目大概率不会更新了。B站的有些接口更新了,B站官方之前的版本也不能用了,大家可以自己根据最新的版本抓包得到接口。 使用ijkplayer,实现一个仿B站的Android客户端。使用组件化的思想对项目进行拆分,目前分出两个组件,一个是网络请求组件,一个是视频播放组件。 扫码体验: ![](https://blog-1252348761.cos.ap-chengdu.myqcloud.com/bilibili/1577761537.png) ### 组件化实现方案 组件化使用的方案出自张华洋的文章:[Android组件化方案](https://blog.csdn.net/guiying712/article/details/55213884) 在gradle.properties中,有一个isModule值,为true时是组件化模式,为false为library。在业务组件的build.gradle中读取 isModule,代码如下: ```java if (isModule.toBoolean()) { apply plugin: 'com.android.application' } else { apply plugin: 'com.android.library' } ``` 在 AndroidStudio 中每一个组件都会有对应的 AndroidManifest.xml,application和library使用的AndroidManifest.xml不同,所以要为组件开发模式下的业务组件再创建一个 AndroidManifest.xml,然后根据isModule指定AndroidManifest.xml的文件路径,让业务组件在集成模式和组件模式下使用不同的AndroidManifest.xml: ```java sourceSets { main { if (isModule.toBoolean()) { manifest.srcFile 'src/main/module/AndroidManifest.xml' } else { manifest.srcFile 'src/main/AndroidManifest.xml' } } } ``` ### 组件功能介绍 #### ijkplayer组件(功能组件) 该组件是一个视频播放组件,在ubuntu16.04上集成编译了ijkplayer,支持rtsp和rtmp的视频直播推流。提供了一个自定义view,可以使用该view实现本地/网络视频的播放、暂停、快进、视频亮度、音量的调节。[ijkplayer0.8.8下载地址](!https://blog-1252348761.cos.ap-chengdu.myqcloud.com/camera/ijkplayer0.8.8-2019-02-20.zip ) 使用方式如下: 声明所需权限,用于播放网络视频和本地视频: ```xml ``` 注意,如果横竖屏切换不想重新走一遍生命周期,还需要在表单中设置Activity的configChanges属性: ```xml ``` 在Activity/Fragment中的oncreate方法里: ```kotlin override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_play) //屏幕常亮 getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) /** 普通播放 start **/ var url = getIntent().getStringExtra("url"); simple_view .setVideoUrl(url) .setVideoTitle("这是标题") .startPlay() } override fun onConfigurationChanged(newConfig: Configuration?) { super.onConfigurationChanged(newConfig) //横竖屏切换 显示/隐藏actionbar var isPortrait = simple_view.onConfigurationChang(newConfig) if (isPortrait) { supportActionBar?.show() } else { supportActionBar?.hide() } } override fun onBackPressed() { simple_view.onBackPressed() if (!simple_view.isPortrait){ supportActionBar?.show() }else{ super.onBackPressed() } } override fun onPause() { super.onPause() simple_view.onPause() } override fun onResume() { super.onResume() simple_view.onResume() } override fun onDestroy() { super.onDestroy() simple_view.onDestory() } ``` #### common组件(功能组件) 1. common组件是基础库,添加一些公用的类; 2. 网络请求、图片加载、工具类、base类等; 3. 声明APP需要的uses-permission; 4. 定义mvp架构实现网络请求 ### 目前完成的功能 - 整体架构搭建 - 对b站客户端抓包,分析接口 - 主界面布局完成 - 完成直播播放页面 - 完成推荐视频的播放 - 视频弹幕获取 项目截图:
直播界面 聊天界面 个人信息popwindow 主播信息界面 粉丝榜 大航海
视频播放 视频评论 侧滑 分区 追番 webview
================================================ FILE: app/.gitignore ================================================ /build ================================================ FILE: app/CMakeLists.txt ================================================ # For more information about using CMake with Android Studio, read the # documentation: https://d.android.com/studio/projects/add-native-code.html # Sets the minimum version of CMake required to build the native library. cmake_minimum_required(VERSION 3.4.1) # Creates and names a library, sets it as either STATIC # or SHARED, and provides the relative paths to its source code. # You can define multiple libraries, and CMake builds them for you. # Gradle automatically packages shared libraries with your APK. add_library( # Sets the name of the library. native-lib # Sets the library as a shared library. SHARED # Provides a relative path to your source file(s). src/main/cpp/native-lib.cpp) # Searches for a specified prebuilt library and stores the path as a # variable. Because CMake includes system libraries in the search path by # default, you only need to specify the name of the public NDK library # you want to add. CMake verifies that the library exists before # completing its build. find_library( # Sets the name of the path variable. log-lib # Specifies the name of the NDK library that # you want CMake to locate. log) # Specifies libraries CMake should link to your target library. You # can link multiple libraries, such as libraries you define in this # build script, prebuilt third-party libraries, or system libraries. target_link_libraries( # Specifies the target library. native-lib # Links the target library to the log library # included in the NDK. ${log-lib}) ================================================ FILE: app/build.gradle ================================================ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-kapt' android { compileSdkVersion rootProject.ext.compileSdkVersion defaultConfig { applicationId "com.bilibili.lingxiao" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode rootProject.ext.versionCode versionName rootProject.ext.versionName testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' externalNativeBuild { cmake { cppFlags "" } } vectorDrawables.useSupportLibrary = true ndk { // 设置支持的SO库架构 abiFilters 'armeabi-v7a', 'x86', 'x86_64' } } compileOptions { sourceCompatibility = '1.8' targetCompatibility = '1.8' } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } externalNativeBuild { cmake { path "CMakeLists.txt" } } packagingOptions { exclude 'META-INF/proguard/androidx-annotations.pro' exclude 'META-INF/kotlinx-io.kotlin_module' exclude 'META-INF/atomicfu.kotlin_module' exclude 'META-INF/kotlinx-coroutines-io.kotlin_module' } } dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'androidx.constraintlayout:constraintlayout:2.0.1' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' implementation "com.trello.rxlifecycle2:rxlifecycle:$rootProject.ext.rxlifescyleVersion" // If you want to use Android Lifecycle for providers implementation "com.trello.rxlifecycle2:rxlifecycle-android-lifecycle:$rootProject.ext.rxlifescyleVersion" // If you want pre-written Activities and Fragments you can subclass as providers implementation "com.trello.rxlifecycle2:rxlifecycle-components:$rootProject.ext.rxlifescyleVersion" // If you want to use Kotlin syntax implementation "com.trello.rxlifecycle2:rxlifecycle-kotlin:$rootProject.ext.rxlifescyleVersion" // If you want to use Kotlin syntax with Android Lifecycle implementation "com.trello.rxlifecycle2:rxlifecycle-android-lifecycle-kotlin:$rootProject.ext.rxlifescyleVersion" implementation "pub.devrel:easypermissions:$rootProject.ext.easypermissionsVersion" implementation "com.facebook.fresco:fresco:$rootProject.ext.frescoVersion" // 支持 GIF 动图,需要添加 implementation "com.facebook.fresco:animated-gif:$rootProject.ext.frescoVersion" implementation project(':common') implementation project(':ijkplayer') implementation 'com.squareup.okhttp3:okhttp:3.13.1' implementation 'com.google.code.gson:gson:2.8.5' implementation "com.google.dagger:dagger:$rootProject.ext.daggerVersion" kapt "com.google.dagger:dagger-compiler:$rootProject.ext.daggerVersion" annotationProcessor "com.google.dagger:dagger-compiler:$rootProject.ext.daggerVersion" implementation "com.youth.banner:banner:$rootProject.ext.bannerVersion" implementation "com.github.zackratos.ultimatebar:ultimatebar2:$rootProject.ext.ultimatebarVersion" implementation "org.greenrobot:eventbus:$rootProject.ext.eventBusVersion" //其中latest.release指代最新版本号,也可以指定明确的版本号,例如2.2.0 //烈焰弹幕 implementation "com.github.ctiao:DanmakuFlameMaster:$rootProject.ext.danmakuVersion" implementation "com.github.ctiao:ndkbitmap-armv7a:$rootProject.ext.danmakuNdk" // Other ABIs: optional implementation "com.github.ctiao:ndkbitmap-armv5:$rootProject.ext.danmakuNdk" implementation "com.github.ctiao:ndkbitmap-x86:$rootProject.ext.danmakuNdk" implementation project(':skinLibrary') implementation 'androidx.recyclerview:recyclerview:1.0.0' implementation "com.flyco.tablayout:FlycoTabLayout_Lib:$rootProject.ext.FlycoTabLayout" implementation files('libs/tbs_sdk_thirdapp_v4.3.0.1020_43633_sharewithdownload_withoutGame_obfs_20190111_105200.jar') //骨架屏 implementation 'com.github.sharish:ShimmerRecyclerView:v1.3' // Use if Kotlin user. //kapt "com.github.agrosner.dbflow:processor:$rootProject.ext.dbFlowVersion" // core set of libraries //implementation "com.github.agrosner.dbflow:core:$rootProject.ext.dbFlowVersion" //implementation "com.github.agrosner.dbflow:lib:$rootProject.ext.dbFlowVersion" annotationProcessor "com.github.Raizlabs.DBFlow:dbflow-processor:$rootProject.ext.dbFlowVersion" implementation "com.github.Raizlabs.DBFlow:dbflow-core:$rootProject.ext.dbFlowVersion" implementation "com.github.Raizlabs.DBFlow:dbflow:$rootProject.ext.dbFlowVersion" implementation group: 'com.hiczp', name: 'bilibili-api', version: '0.1.0' implementation "androidx.room:room-runtime:$rootProject.room_version" annotationProcessor "androidx.room:room-compiler:$rootProject.room_version" // For Kotlin use kapt instead of annotationProcessor //implementation "com.ashokvarma.android:bottom-navigation-bar:$rootProject.ext.bottomNavigationBar" //implementation files('libs/Java-WebSocket-1.3.8.jar') //implementation 'com.github.paulyung541:LaybelLayout:v1.2.0' } ================================================ FILE: app/proguard-rules.pro ================================================ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the # proguardFiles setting in build.gradle. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html # If your project uses WebView with JS, uncomment the following # and specify the fully qualified class name to the JavaScript interface # class: #-keepclassmembers class fqcn.of.javascript.interface.for.webview { # public *; #} # Uncomment this to preserve the line number information for # debugging stack traces. #-keepattributes SourceFile,LineNumberTable # If you keep the line number information, uncomment this to # hide the original source file name. #-renamesourcefileattribute SourceFile # banner 的混淆代码 -keep class com.youth.banner.** { *; } -dontwarn com.tencent.bugly.** -keep public class com.tencent.bugly.**{*;} -keep class android.support.**{*;} #fresco混淆 # Keep our interfaces so they can be used by other ProGuard rules. # See http://sourceforge.net/p/proguard/bugs/466/ -keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip -keep,allowobfuscation @interface com.facebook.soloader.DoNotOptimize # Do not strip any method/class that is annotated with @DoNotStrip -keep @com.facebook.common.internal.DoNotStrip class * -keepclassmembers class * { @com.facebook.common.internal.DoNotStrip *; } # Do not strip any method/class that is annotated with @DoNotOptimize -keep @com.facebook.soloader.DoNotOptimize class * -keepclassmembers class * { @com.facebook.soloader.DoNotOptimize *; } # Keep native methods -keepclassmembers class * { native ; } -dontwarn okio.** -dontwarn com.squareup.okhttp.** -dontwarn okhttp3.** -dontwarn javax.annotation.** -dontwarn com.android.volley.toolbox.** -dontwarn com.facebook.infer.** #-optimizationpasses 7 #-optimizations !code/simplification/arithmetic,!field/*,!class/merging/* -dontoptimize -dontusemixedcaseclassnames -verbose -dontskipnonpubliclibraryclasses -dontskipnonpubliclibraryclassmembers -dontwarn dalvik.** -dontwarn com.tencent.smtt.** #-overloadaggressively # ------------------ Keep LineNumbers and properties ---------------- # -keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,*Annotation*,EnclosingMethod # -------------------------------------------------------------------------- # Addidional for x5.sdk classes for apps -keep class com.tencent.smtt.export.external.**{ *; } -keep class com.tencent.tbs.video.interfaces.IUserStateChangedListener { *; } -keep class com.tencent.smtt.sdk.CacheManager { public *; } -keep class com.tencent.smtt.sdk.CookieManager { public *; } -keep class com.tencent.smtt.sdk.WebHistoryItem { public *; } -keep class com.tencent.smtt.sdk.WebViewDatabase { public *; } -keep class com.tencent.smtt.sdk.WebBackForwardList { public *; } -keep public class com.tencent.smtt.sdk.WebView { public ; public ; } -keep public class com.tencent.smtt.sdk.WebView$HitTestResult { public static final ; public java.lang.String getExtra(); public int getType(); } -keep public class com.tencent.smtt.sdk.WebView$WebViewTransport { public ; } -keep public class com.tencent.smtt.sdk.WebView$PictureListener { public ; public ; } -keepattributes InnerClasses -keep public enum com.tencent.smtt.sdk.WebSettings$** { *; } -keep public enum com.tencent.smtt.sdk.QbSdk$** { *; } -keep public class com.tencent.smtt.sdk.WebSettings { public *; } -keepattributes Signature -keep public class com.tencent.smtt.sdk.ValueCallback { public ; public ; } -keep public class com.tencent.smtt.sdk.WebViewClient { public ; public ; } -keep public class com.tencent.smtt.sdk.DownloadListener { public ; public ; } -keep public class com.tencent.smtt.sdk.WebChromeClient { public ; public ; } -keep public class com.tencent.smtt.sdk.WebChromeClient$FileChooserParams { public ; public ; } -keep class com.tencent.smtt.sdk.SystemWebChromeClient{ public *; } # 1. extension interfaces should be apparent -keep public class com.tencent.smtt.export.external.extension.interfaces.* { public protected *; } # 2. interfaces should be apparent -keep public class com.tencent.smtt.export.external.interfaces.* { public protected *; } -keep public class com.tencent.smtt.sdk.WebViewCallbackClient { public protected *; } -keep public class com.tencent.smtt.sdk.WebStorage$QuotaUpdater { public ; public ; } -keep public class com.tencent.smtt.sdk.WebIconDatabase { public ; public ; } -keep public class com.tencent.smtt.sdk.WebStorage { public ; public ; } -keep public class com.tencent.smtt.sdk.DownloadListener { public ; public ; } -keep public class com.tencent.smtt.sdk.QbSdk { public ; public ; } -keep public class com.tencent.smtt.sdk.QbSdk$PreInitCallback { public ; public ; } -keep public class com.tencent.smtt.sdk.CookieSyncManager { public ; public ; } -keep public class com.tencent.smtt.sdk.Tbs* { public ; public ; } -keep public class com.tencent.smtt.utils.LogFileUtils { public ; public ; } -keep public class com.tencent.smtt.utils.TbsLog { public ; public ; } -keep public class com.tencent.smtt.utils.TbsLogClient { public ; public ; } -keep public class com.tencent.smtt.sdk.CookieSyncManager { public ; public ; } # Added for game demos -keep public class com.tencent.smtt.sdk.TBSGamePlayer { public ; public ; } -keep public class com.tencent.smtt.sdk.TBSGamePlayerClient* { public ; public ; } -keep public class com.tencent.smtt.sdk.TBSGamePlayerClientExtension { public ; public ; } -keep public class com.tencent.smtt.sdk.TBSGamePlayerService* { public ; public ; } -keep public class com.tencent.smtt.utils.Apn { public ; public ; } -keep class com.tencent.smtt.** { *; } # end -keep public class com.tencent.smtt.export.external.extension.proxy.ProxyWebViewClientExtension { public ; public ; } -keep class MTT.ThirdAppInfoNew { *; } -keep class com.tencent.mtt.MttTraceEvent { *; } # Game related -keep public class com.tencent.smtt.gamesdk.* { public protected *; } -keep public class com.tencent.smtt.sdk.TBSGameBooter { public ; public ; } -keep public class com.tencent.smtt.sdk.TBSGameBaseActivity { public protected *; } -keep public class com.tencent.smtt.sdk.TBSGameBaseActivityProxy { public protected *; } -keep public class com.tencent.smtt.gamesdk.internal.TBSGameServiceClient { public *; } #--------------------------------------------------------------------------- #------------------ 下方是android平台自带的排除项,这里不要动 ---------------- -keep public class * extends android.app.Activity{ public ; public ; } -keep public class * extends android.app.Application{ public ; public ; } -keep public class * extends android.app.Service -keep public class * extends android.content.BroadcastReceiver -keep public class * extends android.content.ContentProvider -keep public class * extends android.app.backup.BackupAgentHelper -keep public class * extends android.preference.Preference -keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String); } -keepclasseswithmembers class * { public (android.content.Context, android.util.AttributeSet); } -keepclasseswithmembers class * { public (android.content.Context, android.util.AttributeSet, int); } -keepattributes *Annotation* -keepclasseswithmembernames class *{ native ; } -keep class * implements android.os.Parcelable { public static final android.os.Parcelable$Creator *; } #------------------ 下方是共性的排除项目 ---------------- # 方法名中含有“JNI”字符的,认定是Java Native Interface方法,自动排除 # 方法名中含有“JRI”字符的,认定是Java Reflection Interface方法,自动排除 -keepclasseswithmembers class * { ... *JNI*(...); } -keepclasseswithmembernames class * { ... *JRI*(...); } -keep class **JNI* {*;} #dbflow -keep class * extends com.raizlabs.android.dbflow.config.DatabaseHolder { *; } ================================================ FILE: app/src/androidTest/java/com/bilibili/lingxiao/ExampleInstrumentedTest.kt ================================================ package com.bilibili.lingxiao import androidx.test.platform.app.InstrumentationRegistry import androidx.test.ext.junit.runners.AndroidJUnit4 import org.junit.Test import org.junit.runner.RunWith import org.junit.Assert.* /** * Instrumented test, which will execute on an Android device. * * See [testing documentation](http://d.android.com/tools/testing). */ @RunWith(AndroidJUnit4::class) class ExampleInstrumentedTest { @Test fun useAppContext() { // Context of the app under test. val appContext = InstrumentationRegistry.getTargetContext() assertEquals("com.bilibili.lingxiao", appContext.packageName) } } ================================================ FILE: app/src/main/AndroidManifest.xml ================================================ ================================================ FILE: app/src/main/cpp/native-lib.cpp ================================================ #include #include extern "C" JNIEXPORT jstring JNICALL Java_com_bilibili_lingxiao_MainActivity_stringFromJNI( JNIEnv *env, jobject /* this */) { std::string hello = "Hello from C++"; return env->NewStringUTF(hello.c_str()); } ================================================ FILE: app/src/main/java/com/bilibili/lingxiao/App.kt ================================================ package com.bilibili.lingxiao import android.app.Application import androidx.room.Room import com.bilibili.lingxiao.database.db.AppDatabase import com.bilibili.lingxiao.utils.UIUtil import com.facebook.drawee.backends.pipeline.Fresco class App : Application() { private val TAG = App::class.java.simpleName override fun onCreate() { super.onCreate() Fresco.initialize(this) UIUtil.init(this) InitIalizeService.initialize(this); } } ================================================ FILE: app/src/main/java/com/bilibili/lingxiao/GlobalProperties.kt ================================================ package com.bilibili.lingxiao import android.util.Log import com.bilibili.lingxiao.utils.MD5Util import com.bilibili.lingxiao.utils.UIUtil import com.camera.lingxiao.common.oss.StringUtils import okhttp3.HttpUrl import java.net.URLEncoder import java.security.NoSuchAlgorithmException import java.text.SimpleDateFormat import java.util.* object GlobalProperties { const val LIVE_HOST = "http://live.bilibili.com/AppIndex/home/?" //直播api const val LIVE_HOST_NEW = "https://api.live.bilibili.com/xlive/app-interface/v2/index/feed?" //直播api const val COMMEND_HOST = "http://app.bilibili.com/x/feed/index?" //推荐api const val DETAIL_HOST = "http://api.bilibili.cn/view?" //视频详情 const val COMMEND_VIDEO_HOST = "http://api.bilibili.cn/recommend?" //视频详情下面的推荐 const val COMMENT_HOST = "http://api.bilibili.com/x/v2/reply/main?" //评论 const val COMMENT_DOUBLE_HOST = "http://api.bilibili.com/x/v2/reply/reply/cursor?" //楼中楼评论 const val BANGUMI_CN_AND_JP_HOST = "http://bangumi.bilibili.com/appindex/follow_index_page?" //国内外推荐番剧 const val BANGUMI_FALL_HOST = "http://bangumi.bilibili.com/appindex/follow_index_fall?" //编辑推荐番剧 const val BANGUMI_DETAIL = "https://bangumi.bilibili.com/api/season_v5?" //番剧详情 const val BANGUMI_RECOMMEND = "https://bangumi.bilibili.com/api/season/recommend/rnd/" //番剧详情下面的推荐 const val CATEGORY_HOST = "http://app.bilibili.com/x/v2/region?" //分区 const val CATEGORY_RECOMMEND_HOST = "http://app.bilibili.com/x/v2/show/index?" //分区推荐 const val REGION_DETAIL_URL = "https://app.bilibili.com/x/v2/region/dynamic?" //分区详情 const val REGION_DETAIL_LOADMORE_URL = "https://app.bilibili.com/x/v2/region/dynamic/list?" //分区加载更多 const val REGION_LOCALITY_URL = "http://app.bilibili.com/x/v2/show/change/" //分区局部更新 const val USER_AGENT = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Mobile Safari/537.36" //var LIVE_UP_INFO = "https://api.live.bilibili.com/room/v1/Room/get_info" //获取up主的信息 const val LIVE_UP_INFO = "http://api.live.bilibili.com/xlive/app-room/v1/index/getInfoByRoom?" const val LIVE_USER_INFO = "http://api.live.bilibili.com/live_user/v1/card/card_user?" //获取直播间用户的信息 const val LIVE_DANMAKU_URL = "wss://broadcastlv.chat.bilibili.com:2245/sub" //直播弹幕 websocket const val LIVE_UP_GOLD_LIST = "http://api.live.bilibili.com/rankdb/v1/RoomRank/tabRanks?" //金瓜子榜 礼物榜 const val LIVE_FANS_LIST = "http://api.live.bilibili.com/rankdb/v2/RoomRank/mobileMedalRank?" //粉丝榜 const val LIVE_FLEET_LIST = "http://api.live.bilibili.com/live_user/v1/Guard/topList?" //大航海 const val LIVE_UP_VIDEO_LIST = "http://api.live.bilibili.com/bili-api/x/internal/v2/archive/up/passed?" //直播up主的视频投稿 const val LIVE_UP_CHAT_HISTORY = "http://api.live.bilibili.com/xlive/app-room/v1/dM/gethistory?" //直播评论 const val LIVE_ALL_URL = "http://api.live.bilibili.com/room/v3/Area/getRoomList" //获取全部直播列表 const val LIVE_TAB_LIST_URL = "http://api.live.bilibili.com/room/v1/Area/getList" //直播分类所有tab const val SEARCH_HOT = "http://app.bilibili.com/x/v2/search/hot?" //大家都在搜 const val SEARCH_KEYWORD = "http://app.bilibili.com/x/v2/search?" const val TOPIC_CENTER = "http://api.bilibili.com/topic/getlist?" const val ACTIVITY_CENTER = "http://api.bilibili.com/event/getlist?" const val ORIGIN_RANKING_LIST = "http://app.bilibili.com/x/v2/rank?" //原创排行榜 const val ALL_REGION_RANKING_LIST = "http://app.bilibili.com/x/v2/rank/region?" //全区排行榜 const val BLACK_DOOR = "https://www.bilibili.com/blackroom/ban" //小黑屋 const val ROUND_SHOP = "http://bmall.bilibili.com/" //周边商城 const val MY_SERVICE_HELP = "https://www.bilibili.com/h5/faq" const val IMAGE_RULE_480_300 = "@480w_300h_1e_1c.webp" //图片尺寸 const val IMAGE_RULE_240_150 = "@240w_150h_1e_1c.webp" const val IMAGE_RULE_160_100 = "@160w_100h_1e_1c.webp" const val IMAGE_RULE_90_90 = "@90w_90h_1e_1c.webp" const val IMAGE_RULE_60_60 = "@60w_60h_1e_1c.webp" const val IMAGE_RULE_200_266 = "@200w_266h_1e_1c.webp" //4:3 private val SECRET_KEY = "ea85624dfcf12d7cc7b2b3a94fac1f2c" const val PARAM_SIGN = "sign" const val APP_KEY = "c1b107428d337928" const val BUILD = "5400000" const val MOBI_APP = "android" const val PLATFORM = "android" const val DEVICE = "android" const val NETWORK_WIFI = "wifi" val SCALE = UIUtil.getDensityString() const val SRC = "bili" const val VERSION = "5.19.0.519000" const val HOME_COLUMNS = "home_columns" //首页列数 const val LOGIN_RESPONSE = "login_response" //登录成功之后保存,用于恢复登录的状态 //TODO: 暂时将用户信息存在xml里 const val USER_INFO = "user_info" val TAG = GlobalProperties::class.java.simpleName /** * 将所有参数(包括变量名和值及=&符号)排序后加上appsecret(只有值)之后做md5,md5 按照32位小写加密 * 得到返回结果即为所求sign值 */ fun getSign(map: Map): String { //拼接参数(按顺序) + SecretKey val orignSign = getUrlParamsByMap(map) + SECRET_KEY //进行MD5加密 var sign = "" try { sign = MD5Util.getMD5(orignSign).trim() Log.i(TAG, "加密后的sign: $sign") } catch (e: NoSuchAlgorithmException) { Log.e(TAG, "sign encryption failed: ${e.printStackTrace()}") } return sign } fun getTraceId(): String { val df = SimpleDateFormat("yyyyMMddHHmm", Locale.getDefault()) val df2 = SimpleDateFormat("s", Locale.getDefault()) val s = StringBuilder() s.append(df.format(Date())) s.append("000") s.append(df2.format(Date())) return s.toString() } /** * 获取当前Unix时间戳 * @return */ fun getSystemTime(): String { val ts = System.currentTimeMillis() / 1000 return ts.toString() } /** * 将map转换成url参数 * @param map * @return */ fun getUrlParamsByMap(map: Map): String { var params = StringBuffer() val it = map.iterator() while (it.hasNext()) { val str = it.next() params.append(str.key) params.append("=") params.append(str.value) if (it.hasNext()) { params.append("&") } } return params.toString() } /** * 判断用户是否登录 * 根据token判断 */ fun userLogined() :Boolean{ return false } } ================================================ FILE: app/src/main/java/com/bilibili/lingxiao/HttpTrans.kt ================================================ package com.bilibili.lingxiao import android.util.Log import com.bilibili.lingxiao.home.find.model.HotWordsData import com.bilibili.lingxiao.home.find.model.RankListData import com.bilibili.lingxiao.home.find.model.SearchResultData import com.bilibili.lingxiao.home.find.model.TopicCardData import com.bilibili.lingxiao.home.live.model.* import com.bilibili.lingxiao.home.mikan.model.MiKanFallData import com.bilibili.lingxiao.home.mikan.model.MiKanRecommendData import com.bilibili.lingxiao.home.region.model.* import com.bilibili.lingxiao.play.model.CommentData import com.bilibili.lingxiao.play.model.VideoDetailData import com.bilibili.lingxiao.play.model.VideoRecoData import com.camera.lingxiao.common.app.BaseTransation import com.camera.lingxiao.common.http.ParseHelper import com.camera.lingxiao.common.http.request.HttpRequest import com.camera.lingxiao.common.observer.HttpRxCallback import com.camera.lingxiao.common.utills.LogUtils import com.google.gson.Gson import com.google.gson.JsonElement import com.google.gson.reflect.TypeToken import com.trello.rxlifecycle2.LifecycleProvider class HttpTrans(mLifecycle: LifecycleProvider<*>) : BaseTransation(mLifecycle) { private var debug = true private val TAG = HttpTrans::class.java.simpleName fun getLiveList(callback : HttpRxCallback){ request.clear() request.put("_device",GlobalProperties.DEVICE) request.put("appkey",GlobalProperties.APP_KEY) request.put("build",GlobalProperties.BUILD) request.put("device",GlobalProperties.DEVICE) request.put("mobi_app",GlobalProperties.MOBI_APP) request.put("platform",GlobalProperties.PLATFORM) //request.put("room_id",roomId) request.put("scale",GlobalProperties.SCALE) request.put("src",GlobalProperties.SRC) request.put("trace_id",GlobalProperties.getTraceId()) request.put("ts",GlobalProperties.getSystemTime()) request.put("version",GlobalProperties.VERSION) callback.setParseHelper(object : ParseHelper { override fun parse(element: JsonElement): Any? { LogUtils.d("获取到的数据" + element) var modle = Gson().fromJson(element, LiveData::class.java) val obj = arrayOfNulls(1) obj[0] = modle return obj } }) if (debug){ var url = GlobalProperties.LIVE_HOST_NEW + GlobalProperties.getUrlParamsByMap(request) Log.d(TAG,"拼接的url---->$url, 屏幕像素---->${GlobalProperties.SCALE}" ) } getRequest().requestFullPath(HttpRequest.Method.GET,GlobalProperties.LIVE_HOST_NEW, request, mLifecycle,callback) } /** * @param page 页码 * @param id 用户的av号 * fav 是否读取会员收藏状态 (默认 false) */ fun getDetailInfo(page:Int,id:String,callback : HttpRxCallback) { request.clear() request.put("_device",GlobalProperties.DEVICE) request.put("appkey",GlobalProperties.APP_KEY) request.put("build",GlobalProperties.BUILD) request.put("device",GlobalProperties.DEVICE) request.put("mobi_app",GlobalProperties.MOBI_APP) request.put("platform",GlobalProperties.PLATFORM) request.put("scale",GlobalProperties.SCALE) request.put("src",GlobalProperties.SRC) request.put("trace_id",GlobalProperties.getTraceId()) request.put("ts",GlobalProperties.getSystemTime()) request.put("version",GlobalProperties.VERSION) request.put("page",page) request.put("id",id) callback.setParseHelper(object : ParseHelper { override fun parse(element: JsonElement): Any? { LogUtils.d("获取到的数据" + element) var modle = Gson().fromJson(element, VideoDetailData::class.java) val obj = arrayOfNulls(1) obj[0] = modle return obj } }) if (debug){ var url = GlobalProperties.DETAIL_HOST + GlobalProperties.getUrlParamsByMap(request) Log.d(TAG,"拼接的获取视频详情的url---->$url") } getRequest().requestFullPathWithoutCheck(HttpRequest.Method.GET,GlobalProperties.DETAIL_HOST,request, mLifecycle,callback) } /** * 获取视频播放详情下面的推荐列表 * @param tid 分类编号 new排序为必填 其他为可选 * @param page 结果分页选择 默认为第1页 * @param pagesize 单页返回的记录条数,最大不超过100,默认为30 * @param order 排序方式 default new review hot damku comment promote */ fun getRecommendList(tid:Int,page:Int,pagesize:Int,order:String,callback: HttpRxCallback){ request.clear() request.put("tid",tid) request.put("page",page) request.put("pagesize",pagesize) request.put("order",order) callback.setParseHelper(object : ParseHelper { override fun parse(element: JsonElement): Any? { LogUtils.d("获取到的数据" + element) val modle = Gson().fromJson(element, VideoRecoData::class.java) val obj = arrayOfNulls(1) obj[0] = modle return obj } }) if (debug){ var url = GlobalProperties.COMMEND_VIDEO_HOST + GlobalProperties.getUrlParamsByMap(request) Log.d(TAG,"拼接视频播放详情下面的推荐列表的url---->" + url) } getRequest().requestFullPathWithoutCheck(HttpRequest.Method.GET,GlobalProperties.COMMEND_VIDEO_HOST,request, mLifecycle,callback) } /** * @param oid av号 * @param ps 每次请求获取多少个 * @param next 获取对应的评论楼层 根据all_count获取,如果为0就是带热评的 * 比如all_count为80 ps为20, 那么next为0 则获取到 60-80之间的楼层 next为80 一样是60-80之间的楼层,但是没有热评 */ fun getComment(oid:String,next:Int,callback: HttpRxCallback){ request.clear() request.put("appkey",GlobalProperties.APP_KEY) request.put("build",GlobalProperties.BUILD) request.put("device",GlobalProperties.DEVICE) request.put("mobi_app",GlobalProperties.MOBI_APP) request.put("platform",GlobalProperties.PLATFORM) //request.put("pn",page) request.put("next",next) request.put("ps",20) request.put("sort",0) request.put("type",1) request.put("oid",oid) request.put("trace_id",GlobalProperties.getTraceId()) request.put("ts",GlobalProperties.getSystemTime()) request.put("version",GlobalProperties.VERSION) callback.setParseHelper(object : ParseHelper { override fun parse(element: JsonElement): Any? { var modle = Gson().fromJson(element, CommentData::class.java) val obj = arrayOfNulls(1) obj[0] = modle return obj } }) if (debug){ var url = GlobalProperties.COMMENT_HOST + GlobalProperties.getUrlParamsByMap(request) Log.d(TAG,"拼接的评论url---->$url") } getRequest().requestFullPath(HttpRequest.Method.GET,GlobalProperties.COMMENT_HOST,request, mLifecycle,callback) } /** * 楼中楼评论 * http://api.bilibili.com/x/v2/reply/reply/cursor?oid=46996647&plat=2&root=1473740845&size=20&sort=0&type=1 */ fun getDoubleComment(oid:Int,root:Int,size:Int,callback: HttpRxCallback){ request.clear() request.put("oid",oid) request.put("plat",2) request.put("root",root) request.put("size",size) request.put("sort",0) request.put("type",1) request.put("ts",GlobalProperties.getSystemTime()) callback.setParseHelper(object : ParseHelper { override fun parse(element: JsonElement): Any? { var jsonData = element.asJsonObject var jsonRoot = jsonData.getAsJsonObject("root") var modle = Gson().fromJson(jsonRoot, CommentData.Reply::class.java) val obj = arrayOfNulls(1) obj[0] = modle return obj } }) if (debug){ var url = GlobalProperties.COMMENT_DOUBLE_HOST + GlobalProperties.getUrlParamsByMap(request) Log.d(TAG,"拼接的楼中楼评论url---->$url") } getRequest().requestFullPath(HttpRequest.Method.GET,GlobalProperties.COMMENT_DOUBLE_HOST,request, mLifecycle,callback) } /** * 获取国内,日本推荐的番剧 * https://bangumi.bilibili.com/appindex/follow_index_page?appkey=1d8b6e7d45233436&build=502000&mobi_app=android&platform=android&ts=1493967208000&sign=3eff79d895af9cf800016%20fe8f6bc6ce0 */ fun getBanGumiRecommend(callback: HttpRxCallback){ request.clear() request.put("appkey",GlobalProperties.APP_KEY) request.put("build",GlobalProperties.BUILD) request.put("device",GlobalProperties.DEVICE) request.put("mobi_app",GlobalProperties.MOBI_APP) request.put("platform",GlobalProperties.PLATFORM) request.put("ts",GlobalProperties.getSystemTime()) request.put("version",GlobalProperties.VERSION) //request.put("sign",GlobalProperties.) callback.setParseHelper(object : ParseHelper { override fun parse(element: JsonElement): Any? { var modle = Gson().fromJson(element, MiKanRecommendData::class.java) val obj = arrayOfNulls(1) obj[0] = modle return obj } }) if (debug){ var url = GlobalProperties.BANGUMI_CN_AND_JP_HOST + GlobalProperties.getUrlParamsByMap(request) Log.d(TAG,"拼接番剧的url---->$url") } getRequest().requestFullPathWithoutCheck(HttpRequest.Method.GET,GlobalProperties.BANGUMI_CN_AND_JP_HOST, request,mLifecycle,callback) } /** * 获取编辑推荐的番剧 * https://bangumi.bilibili.com/appindex/follow_index_fall?appkey=1d8b6e7d45233436&build=509000&cursor=0&mobi_app=android&platform=android&ts=1499937514&sign=2dae626fed99d43abbc9d09cfd124641 */ fun getBanGumiFall(cursor:Long,callback: HttpRxCallback){ request.clear() request.put("appkey",GlobalProperties.APP_KEY) request.put("build",GlobalProperties.BUILD) request.put("cursor",cursor) request.put("mobi_app",GlobalProperties.MOBI_APP) request.put("platform",GlobalProperties.PLATFORM) request.put("ts",GlobalProperties.getSystemTime()) request.put("version",GlobalProperties.VERSION) callback.setParseHelper(object : ParseHelper { override fun parse(element: JsonElement): Any? { var modle = Gson().fromJson(element, MiKanFallData::class.java) val obj = arrayOfNulls(1) obj[0] = modle return obj } }) if (debug){ var url = GlobalProperties.BANGUMI_FALL_HOST + GlobalProperties.getUrlParamsByMap(request) Log.d(TAG,"拼接编辑推荐的番剧的url---->$url") } getRequest().requestFullPathWithoutCheck(HttpRequest.Method.GET,GlobalProperties.BANGUMI_FALL_HOST,request, mLifecycle,callback) } fun getRegion(callback: HttpRxCallback){ request.clear() request.put("build",GlobalProperties.BUILD) callback.setParseHelper(object : ParseHelper { override fun parse(element: JsonElement): Any? { val type = object : TypeToken>() {}.getType() var modle:List = Gson().fromJson>(element, type) val obj = arrayOfNulls(1) obj[0] = modle return obj } }) if (debug){ var url = GlobalProperties.CATEGORY_HOST + GlobalProperties.getUrlParamsByMap(request) Log.d(TAG,"拼接分区的url---->$url") } getRequest().requestFullPath(HttpRequest.Method.GET,GlobalProperties.CATEGORY_HOST,request, mLifecycle,callback) } /** * 分区推荐信息 */ fun getRegionRecommend(callback: HttpRxCallback){ request.clear() request.put("appkey",GlobalProperties.APP_KEY) request.put("build",GlobalProperties.BUILD) request.put("mobi_app",GlobalProperties.MOBI_APP) request.put("platform",GlobalProperties.PLATFORM) request.put("ts",GlobalProperties.getSystemTime()) callback.setParseHelper(object : ParseHelper { override fun parse(element: JsonElement): Any? { val type = object : TypeToken>() {}.getType() var modle:List = Gson().fromJson>(element, type) val obj = arrayOfNulls(1) obj[0] = modle return obj } }) if (debug){ var url = GlobalProperties.CATEGORY_RECOMMEND_HOST + GlobalProperties.getUrlParamsByMap(request) Log.d(TAG,"拼接分区推荐的url---->$url") } getRequest().requestFullPath(HttpRequest.Method.GET, GlobalProperties.CATEGORY_RECOMMEND_HOST,request, mLifecycle, callback) } /** * 获取直播间up的信息,主要是uid的获取 * 这个接口必须要使用sign签名 */ fun getLiveUpInfo(roomId:Int,callback: HttpRxCallback){ request.clear() request.put("actionKey","appkey") request.put("appkey",GlobalProperties.APP_KEY) request.put("build",GlobalProperties.BUILD) request.put("channel","bilibiil140") request.put("device",GlobalProperties.DEVICE) request.put("mobi_app",GlobalProperties.MOBI_APP) request.put("platform",GlobalProperties.PLATFORM) request.put("room_id",roomId) request.put("ts",GlobalProperties.getSystemTime()) request.put("sign",GlobalProperties.getSign(request)) //计算签名,然后作为参数 这里其实可以写一个拦截器,对所有请求进行签名 callback.setParseHelper(object : ParseHelper { override fun parse(element: JsonElement): Any? { var modle = Gson().fromJson(element,LiveUpData::class.java) val obj = arrayOfNulls(1) obj[0] = modle return obj } }) if (debug){ Log.d(TAG,"获取直播up信息的url---->"+ GlobalProperties.LIVE_UP_INFO + GlobalProperties.getUrlParamsByMap(request)) } getRequest().requestFullPath(HttpRequest.Method.GET, GlobalProperties.LIVE_UP_INFO, request,mLifecycle, callback) } /** * 获取直播间用户的信息 * @param ruid 直播间up主的uid * @param uid 直播间用户的uid */ fun getLiveUserInfo(ruid:Int,uid :Int,callback: HttpRxCallback){ request.clear() request.put("ruid",ruid) request.put("uid",uid) callback.setParseHelper(object : ParseHelper { override fun parse(element: JsonElement): Any? { var modle = Gson().fromJson(element,LiveUserData::class.java) val obj = arrayOfNulls(1) obj[0] = modle return obj } }) if (debug){ var url = GlobalProperties.LIVE_USER_INFO + GlobalProperties.getUrlParamsByMap(request) Log.d(TAG,"获取直播用户信息的url---->$url") } getRequest().requestFullPath(HttpRequest.Method.GET, GlobalProperties.LIVE_USER_INFO, request,mLifecycle, callback) } /** * 获取金瓜榜 */ fun getLiveGoldList(roomId:Int,ruid:Int,callback: HttpRxCallback){ request.clear() request.put("next_offset","0") request.put("room_id",roomId) request.put("ruid",ruid) request.put("rank_type","gold-rank") callback.setParseHelper(object : ParseHelper { override fun parse(element: JsonElement): Any? { //val type = object : TypeToken>() {}.getType() //var modle:List = Gson().fromJson>(element, type) var modle: FansGoldListData = Gson().fromJson(element, FansGoldListData::class.java) val obj = arrayOfNulls(1) obj[0] = modle return obj } }) if (debug){ var url = GlobalProperties.LIVE_UP_GOLD_LIST + GlobalProperties.getUrlParamsByMap(request) Log.d(TAG,"获取直播up金瓜榜的url---->$url") } getRequest().requestFullPath(HttpRequest.Method.GET, GlobalProperties.LIVE_UP_GOLD_LIST, request,mLifecycle, callback) } /** * 获取礼物榜 */ fun getLiveToDayList(roomId:Int,ruid:Int,callback: HttpRxCallback){ request.clear() request.put("next_offset",0) request.put("room_id",roomId) request.put("ruid",ruid) request.put("rank_type","today-rank") callback.setParseHelper(object : ParseHelper { override fun parse(element: JsonElement): Any? { //val type = object : TypeToken>() {}.getType() //var modle:List = Gson().fromJson>(element, type) var modle: FansGoldListData = Gson().fromJson(element, FansGoldListData::class.java) val obj = arrayOfNulls(1) obj[0] = modle return obj } }) if (debug){ var url = GlobalProperties.LIVE_UP_GOLD_LIST + GlobalProperties.getUrlParamsByMap(request) Log.d(TAG,"获取直播up礼物榜的url---->$url") } getRequest().requestFullPath(HttpRequest.Method.GET, GlobalProperties.LIVE_UP_GOLD_LIST, request,mLifecycle, callback) } /** * 获取粉丝榜 */ fun getLiveFansList(roomId:Int,ruid:Int,callback: HttpRxCallback){ request.clear() request.put("page",1) request.put("roomid",roomId) request.put("ruid",ruid) callback.setParseHelper(object : ParseHelper { override fun parse(element: JsonElement): Any? { //val type = object : TypeToken>() {}.getType() //var modle:List = Gson().fromJson>(element, type) var modle: FansGoldListData = Gson().fromJson(element, FansGoldListData::class.java) val obj = arrayOfNulls(1) obj[0] = modle return obj } }) if (debug){ var url = GlobalProperties.LIVE_FANS_LIST + GlobalProperties.getUrlParamsByMap(request) Log.d(TAG,"获取直播up粉丝榜的url---->$url") } getRequest().requestFullPath(HttpRequest.Method.GET, GlobalProperties.LIVE_FANS_LIST, request,mLifecycle, callback) } /** * 获取大航海 * @param page 1 页码 * @param pageSize 20 个数 */ fun getLiveFleetList(page:Int,pageSize:Int,ruid:Int,callback: HttpRxCallback){ request.clear() request.put("page",page) request.put("page_size",pageSize) request.put("ruid",ruid) request.put("mobi_app",GlobalProperties.MOBI_APP) request.put("ts",GlobalProperties.getSystemTime()) callback.setParseHelper(object : ParseHelper { override fun parse(element: JsonElement): Any? { var modle: FleetListData = Gson().fromJson(element, FleetListData::class.java) val obj = arrayOfNulls(1) obj[0] = modle return obj } }) if (debug){ var url = GlobalProperties.LIVE_FLEET_LIST + GlobalProperties.getUrlParamsByMap(request) Log.d(TAG,"获取直播up大航海的url---->$url") } getRequest().requestFullPath(HttpRequest.Method.GET, GlobalProperties.LIVE_FLEET_LIST, request,mLifecycle, callback) } /** * 直播up主的视频投稿 */ fun getLiveUpVideoList(page:Int,pageSize:Int,ruid:Int,callback: HttpRxCallback){ request.clear() request.put("pn",page) request.put("ps",pageSize) request.put("mid",ruid) request.put("mobi_app",GlobalProperties.MOBI_APP) request.put("ts",GlobalProperties.getSystemTime()) callback.setParseHelper(object : ParseHelper { override fun parse(element: JsonElement): Any? { val type = object : TypeToken>() {}.getType() var modle:List = Gson().fromJson>(element, type) val obj = arrayOfNulls(1) obj[0] = modle return obj } }) if (debug){ var url = GlobalProperties.LIVE_UP_VIDEO_LIST + GlobalProperties.getUrlParamsByMap(request) Log.d(TAG,"获取直播up视频投稿的url---->$url") } getRequest().requestFullPath(HttpRequest.Method.GET, GlobalProperties.LIVE_UP_VIDEO_LIST, request,mLifecycle, callback) } /** * 获取聊天的历史记录 */ fun getHistoryChat(roomId: Int,callback: HttpRxCallback){ request.clear() request.put("room_id",roomId) request.put("mobi_app",GlobalProperties.MOBI_APP) request.put("ts",GlobalProperties.getSystemTime()) callback.setParseHelper(object : ParseHelper { override fun parse(element: JsonElement): Any? { var modle = Gson().fromJson(element, LiveChatData::class.java) val obj = arrayOfNulls(1) obj[0] = modle return obj } }) if (debug){ var url = GlobalProperties.LIVE_UP_CHAT_HISTORY + GlobalProperties.getUrlParamsByMap(request) Log.d(TAG,"获取直播up聊天的历史记录的url---->$url") } getRequest().requestFullPath(HttpRequest.Method.GET, GlobalProperties.LIVE_UP_CHAT_HISTORY, request,mLifecycle, callback) } /** * 获取所有的直播列表 * @param page 从1开始 * @param pageSize 30 * @param areaId 分区的id * @param parentAreaId 大分区的id 这两个为0 就是获取所有的tab * @param type 类型 live_time 最新 online 热门 还有其他类型 */ fun getLiveAllList(page:Int,pageSize:Int,type:String,areaId:Int,parentAreaId:Int,callback: HttpRxCallback){ request.clear() request.put("page",page) request.put("page_size",pageSize) request.put("sort_type",type) request.put("area_id",areaId) request.put("parent_area_id",parentAreaId) request.put("platform",GlobalProperties.PLATFORM) callback.setParseHelper(object : ParseHelper { override fun parse(element: JsonElement): Any? { var modle = Gson().fromJson(element, LiveAllData::class.java) val obj = arrayOfNulls(1) obj[0] = modle return obj } }) getRequest().requestFullPath(HttpRequest.Method.GET, GlobalProperties.LIVE_ALL_URL, request,mLifecycle, callback) } /** * 获取所有的直播分类tab * @param parent_id 最外层的分类 */ fun getLiveTabList(parent_id:Int,callback: HttpRxCallback){ request.clear() request.put("parent_id",parent_id) request.put("platform",GlobalProperties.PLATFORM) callback.setParseHelper(object : ParseHelper { override fun parse(element: JsonElement): Any? { val type = object : TypeToken>() {}.getType() var modle:List = Gson().fromJson>(element, type) val obj = arrayOfNulls(1) obj[0] = modle return obj } }) getRequest().requestFullPath(HttpRequest.Method.GET, GlobalProperties.LIVE_TAB_LIST_URL, request,mLifecycle, callback) } /** * 获取分区详情 * https://app.bilibili.com/x/v2/region/dynamic?build=5410000&mobi_app=android&platform=android&rid=167 */ fun getRegionList(tid:Int,callback: HttpRxCallback){ request.clear() request.put("build",GlobalProperties.BUILD) request.put("mobi_app",GlobalProperties.MOBI_APP) request.put("platform",GlobalProperties.PLATFORM) request.put("rid",tid) callback.setParseHelper(object : ParseHelper { override fun parse(element: JsonElement): Any? { var modle = Gson().fromJson(element, RegionDetailData::class.java) val obj = arrayOfNulls(1) obj[0] = modle return obj } }) if (debug){ var url = GlobalProperties.REGION_DETAIL_URL + GlobalProperties.getUrlParamsByMap(request) Log.d(TAG,"获取分区详情的url---->$url") } getRequest().requestFullPath(HttpRequest.Method.GET, GlobalProperties.REGION_DETAIL_URL, request,mLifecycle, callback) } /** * 分区加载更多 */ fun getRegionMoreList(rid:Int,callback: HttpRxCallback){ request.clear() request.put("build",GlobalProperties.BUILD) request.put("pull",false) request.put("platform",GlobalProperties.PLATFORM) request.put("rid",rid) request.put("ctime",GlobalProperties.getSystemTime()) callback.setParseHelper(object : ParseHelper { override fun parse(element: JsonElement): Any? { var modle = Gson().fromJson(element, RegionDetailData::class.java) val obj = arrayOfNulls(1) obj[0] = modle return obj } }) getRequest().requestFullPath(HttpRequest.Method.GET, GlobalProperties.REGION_DETAIL_LOADMORE_URL, request,mLifecycle, callback) } /** * 分区局部刷新 */ fun refreshRegionLocality(type:String,rand:Int,rid:Int,callback: HttpRxCallback){ request.clear() request.put("rand",rand) request.put("rid",rid) request.put("platform",GlobalProperties.PLATFORM) var url = "${GlobalProperties.REGION_LOCALITY_URL}$type?" callback.setParseHelper(object : ParseHelper { override fun parse(element: JsonElement): Any? { val type = object : TypeToken>() {}.getType() var modle:List = Gson().fromJson>(element, type) val obj = arrayOfNulls(1) obj[0] = modle return obj } }) getRequest().requestFullPath(HttpRequest.Method.GET, url, request,mLifecycle, callback) } /** * 番剧详情 */ fun getBangumiDetail(season_id:String,type:String,callback: HttpRxCallback){ request.clear() request.put("appkey",GlobalProperties.APP_KEY) request.put("build",GlobalProperties.BUILD) request.put("mobi_app",GlobalProperties.MOBI_APP) request.put("platform",GlobalProperties.PLATFORM) request.put("season_id",season_id) request.put("ts",GlobalProperties.getSystemTime()) request.put("type",type) request.put("sign",GlobalProperties.getSign(request)) //计算签名,然后作为参数 这里其实可以写一个拦截器,对所有请求进行签名 callback.setParseHelper(object : ParseHelper { override fun parse(element: JsonElement): Any? { var modle = Gson().fromJson(element, BangumiDetailData::class.java) val obj = arrayOfNulls(1) obj[0] = modle return obj } }) if (debug){ var url = GlobalProperties.BANGUMI_DETAIL + GlobalProperties.getUrlParamsByMap(request) Log.d(TAG,"获取番剧详情的url---->$url") } getRequest().requestFullPathWithoutCheck(HttpRequest.Method.GET, GlobalProperties.BANGUMI_DETAIL, request,mLifecycle, callback) } /** * 番剧详情下面的推荐 * https://bangumi.bilibili.com/api/season/recommend/rnd/24618.json */ fun getBangumiDetailRecommend(season_id:String,callback: HttpRxCallback){ request.clear() var url = GlobalProperties.BANGUMI_RECOMMEND + "$season_id.json" callback.setParseHelper(object : ParseHelper { override fun parse(element: JsonElement): Any? { var modle = Gson().fromJson(element, BangumiRecommendData::class.java) val obj = arrayOfNulls(1) obj[0] = modle return obj } }) if (debug){ Log.d(TAG,"获取番剧详情下面的推荐的url---->$url") } getRequest().requestFullPathWithoutCheck(HttpRequest.Method.GET, url, request,mLifecycle, callback) } fun getHotSearchWords(limit :Int,callback: HttpRxCallback){ request.clear() request.put("build",GlobalProperties.BUILD) request.put("limit",limit) request.put("platform",GlobalProperties.PLATFORM) callback.setParseHelper(object : ParseHelper { override fun parse(element: JsonElement): Any? { var modle = Gson().fromJson(element, HotWordsData::class.java) val obj = arrayOfNulls(1) obj[0] = modle return obj } }) if (debug){ var url = GlobalProperties.SEARCH_HOT + GlobalProperties.getUrlParamsByMap(request) Log.d(TAG,"获取大家都在搜的url---->$url") } getRequest().requestFullPath(HttpRequest.Method.GET, GlobalProperties.SEARCH_HOT, request,mLifecycle, callback) } /** * 根据关键字获取搜索结果 * @param word 关键字 * @param page 从1开始 * @param pageSize 20 */ fun getSearchResult(word :String, page:Int,pageSize:Int,callback: HttpRxCallback){ request.clear() request.put("build",GlobalProperties.BUILD) request.put("duration",0) request.put("keyword",word) request.put("platform",GlobalProperties.PLATFORM) request.put("pn",page) request.put("ps",pageSize) callback.setParseHelper(object : ParseHelper { override fun parse(element: JsonElement): Any? { var modle = Gson().fromJson(element, SearchResultData::class.java) val obj = arrayOfNulls(1) obj[0] = modle return obj } }) if (debug){ var url = GlobalProperties.SEARCH_KEYWORD + GlobalProperties.getUrlParamsByMap(request) Log.d(TAG,"获取搜索结果url---->$url") } getRequest().requestFullPath(HttpRequest.Method.GET, GlobalProperties.SEARCH_KEYWORD, request,mLifecycle, callback) } /** * 话题中心 */ fun getTopicCenter(page:Int,pageSize:Int,callback: HttpRxCallback){ request.clear() request.put("page",page) request.put("pageSize",pageSize) callback.setParseHelper(object : ParseHelper { override fun parse(element: JsonElement): Any? { var modle = Gson().fromJson(element, TopicCardData::class.java) val obj = arrayOfNulls(1) obj[0] = modle return obj } }) if (debug){ var url = GlobalProperties.TOPIC_CENTER + GlobalProperties.getUrlParamsByMap(request) Log.d(TAG,"获取话题中心url---->$url") } getRequest().requestFullPathWithoutCheck(HttpRequest.Method.GET, GlobalProperties.TOPIC_CENTER, request,mLifecycle, callback) } /** * 活动中心 */ fun getActivityCenter(page:Int,pageSize:Int,callback: HttpRxCallback){ request.clear() request.put("page",page) request.put("pageSize",pageSize) callback.setParseHelper(object : ParseHelper { override fun parse(element: JsonElement): Any? { var modle = Gson().fromJson(element, TopicCardData::class.java) val obj = arrayOfNulls(1) obj[0] = modle return obj } }) if (debug){ var url = GlobalProperties.ACTIVITY_CENTER + GlobalProperties.getUrlParamsByMap(request) Log.d(TAG,"获取活动中心url---->$url") } getRequest().requestFullPathWithoutCheck(HttpRequest.Method.GET, GlobalProperties.ACTIVITY_CENTER, request,mLifecycle, callback) } /** * 原创排行榜 * //原创 * order = bangumi 番剧 * order = all 全站 * order = origin 原创 */ fun getOriginRankingList(type :String, page:Int,pageSize:Int,callback: HttpRxCallback){ request.clear() request.put("order",type) request.put("page",page) request.put("pageSize",pageSize) callback.setParseHelper(object : ParseHelper { override fun parse(element: JsonElement): Any? { val type = object : TypeToken>() {}.getType() var modle :List = Gson().fromJson(element, type) val obj = arrayOfNulls(1) obj[0] = modle return obj } }) if (debug){ var url = GlobalProperties.ORIGIN_RANKING_LIST + GlobalProperties.getUrlParamsByMap(request) Log.d(TAG,"获取原创排行榜url---->$url") } getRequest().requestFullPath(HttpRequest.Method.GET, GlobalProperties.ORIGIN_RANKING_LIST, request,mLifecycle, callback) } /** * 全区排行榜 * @param rid 分区获取到的rid */ fun getAllRegionRankingList(rid :Int, page:Int,pageSize:Int,callback: HttpRxCallback){ request.clear() request.put("rid",rid) request.put("page",page) request.put("pageSize",pageSize) callback.setParseHelper(object : ParseHelper { override fun parse(element: JsonElement): Any? { val type = object : TypeToken>() {}.getType() var modle :List = Gson().fromJson(element, type) val obj = arrayOfNulls(1) obj[0] = modle return obj } }) if (debug){ var url = GlobalProperties.ALL_REGION_RANKING_LIST + GlobalProperties.getUrlParamsByMap(request) Log.d(TAG,"获取全区排行榜url---->$url") } getRequest().requestFullPath(HttpRequest.Method.GET, GlobalProperties.ALL_REGION_RANKING_LIST, request,mLifecycle, callback) } } ================================================ FILE: app/src/main/java/com/bilibili/lingxiao/InitIalizeService.kt ================================================ package com.bilibili.lingxiao import android.app.Application import android.app.IntentService import android.app.Notification import android.app.NotificationChannel import android.app.NotificationManager import android.content.Intent import android.content.Context import android.graphics.Color import android.os.Build import androidx.annotation.RequiresApi import androidx.core.app.NotificationCompat import com.bilibili.lingxiao.database.NetCacheDatabase import com.camera.lingxiao.common.Common import com.lingxiao.skinlibrary.SkinLib import com.raizlabs.android.dbflow.config.FlowManager import com.tencent.smtt.sdk.QbSdk import com.raizlabs.android.dbflow.config.FlowConfig /** * An [IntentService] subclass for handling asynchronous task requests in * a service on a separate handler thread. * * * 初始化操作都放进这个service */ class InitIalizeService : IntentService("InitIalizeService") { override fun onCreate() { super.onCreate() if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { //startForeground(1,new Notification()); startMyOwnForeground() } } @RequiresApi(api = Build.VERSION_CODES.O) private fun startMyOwnForeground() { val NOTIFICATION_CHANNEL_ID = "com.example.simpleapp" val channelName = "My Background Service" val chan = NotificationChannel(NOTIFICATION_CHANNEL_ID, channelName, NotificationManager.IMPORTANCE_NONE) chan.lightColor = Color.BLUE chan.lockscreenVisibility = Notification.VISIBILITY_PRIVATE val manager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager manager.createNotificationChannel(chan) val notificationBuilder = NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID) val notification = notificationBuilder.setOngoing(true) .setSmallIcon(R.mipmap.ic_launcher) .setContentTitle("App is running in background") .setPriority(NotificationManager.IMPORTANCE_MIN) .setCategory(Notification.CATEGORY_SERVICE) .build() startForeground(2, notification) } override fun onHandleIntent(intent: Intent?) { if (intent != null) { val action = intent.action if (ACTION_FOO == action) { performInit() } } } /** * 初始化操作 */ private fun performInit() { SkinLib.init(mContext as Application) QbSdk.initX5Environment(this, null) Common.initCrash(this, true) FlowManager.init(FlowConfig.Builder(this).build()) } companion object { // IntentService can perform, e.g. ACTION_FETCH_NEW_ITEMS private val ACTION_FOO = "com.lingxiaosuse.picture.tudimension.service.action.FOO" private lateinit var mContext: Context fun initialize(context: Context) { val intent = Intent(context, InitIalizeService::class.java) intent.action = ACTION_FOO if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { context.startForegroundService(intent) } else { context.startService(intent) } //context.startService(intent); mContext = context } } } ================================================ FILE: app/src/main/java/com/bilibili/lingxiao/SplashActivity.kt ================================================ package com.bilibili.lingxiao import android.view.View import android.view.animation.Animation import com.camera.lingxiao.common.app.BaseActivity import android.view.animation.ScaleAnimation import android.view.animation.AnimationSet import com.bilibili.lingxiao.home.MainActivity import kotlinx.android.synthetic.main.activity_splash.* class SplashActivity : BaseActivity() { override val contentLayoutId: Int get() = R.layout.activity_splash override fun initWidget() { super.initWidget() startAnim(splash_root) } private fun startAnim(view: View) { val animationSet = AnimationSet(true) val scaleAnimation = ScaleAnimation( 0.98f, 1.0f, 0.98f, 1.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f ) scaleAnimation.duration = 1000 //将AlphaAnimation这个已经设置好的动画添加到 AnimationSet中 animationSet.addAnimation(scaleAnimation) animationSet.fillAfter = true //启动动画 view.startAnimation(animationSet) scaleAnimation.setAnimationListener(object : Animation.AnimationListener { override fun onAnimationStart(animation: Animation) { } override fun onAnimationEnd(animation: Animation) { StartActivity(MainActivity::class.java, true) } override fun onAnimationRepeat(animation: Animation) { } }) } } ================================================ FILE: app/src/main/java/com/bilibili/lingxiao/dagger/UiComponent.kt ================================================ package com.bilibili.lingxiao.dagger import com.bilibili.lingxiao.home.MainActivity import com.bilibili.lingxiao.home.region.ui.RegionFragment import com.bilibili.lingxiao.home.live.ui.LiveFragment import com.bilibili.lingxiao.home.mikan.ui.MikanFragment import com.bilibili.lingxiao.home.recommend.ui.RecommendFragment import com.bilibili.lingxiao.dagger.scope.PerUi import com.bilibili.lingxiao.home.dynamic.DynamicFragment import com.bilibili.lingxiao.home.find.ui.FindFragment import com.bilibili.lingxiao.home.live.ui.play.FansFragment import com.bilibili.lingxiao.home.live.ui.play.FleetListFragment import com.bilibili.lingxiao.home.live.ui.play.InteractFragment import com.bilibili.lingxiao.home.live.ui.play.UpInfoFragment import com.bilibili.lingxiao.home.live.ui.LivePlayActivity import com.bilibili.lingxiao.play.ui.CommentDetailFragment import com.bilibili.lingxiao.play.ui.CommentFragment import com.bilibili.lingxiao.play.ui.IntroduceFragment import com.bilibili.lingxiao.play.ui.PlayActivity import dagger.Component @Component(modules = [UiModule::class]) @PerUi interface UiComponent { fun inject(liveFragment: LiveFragment) fun inject(recommendFragment: RecommendFragment) fun inject(hotFragment: RegionFragment) fun inject(mikanFragment: MikanFragment) fun inject(dynamicFragment: DynamicFragment) fun inject(findFragment: FindFragment) fun inject(introduceFragment: IntroduceFragment) fun inject(commentFragment: CommentFragment) fun inject(commentDetailFragment: CommentDetailFragment) fun inject(interactFragment: InteractFragment) fun inject(upInfoFragment: UpInfoFragment) fun inject(fansFragment: FansFragment) fun inject(fleetListFragment: FleetListFragment) fun inject(mainActivity: MainActivity) fun inject(playActivity: PlayActivity) fun inject(livePlayActivity: LivePlayActivity) } ================================================ FILE: app/src/main/java/com/bilibili/lingxiao/dagger/UiModule.kt ================================================ package com.bilibili.lingxiao.dagger import android.content.Context import com.bilibili.lingxiao.home.region.ui.RegionFragment import com.bilibili.lingxiao.home.live.ui.LiveFragment import com.bilibili.lingxiao.home.mikan.ui.MikanFragment import com.bilibili.lingxiao.home.recommend.ui.RecommendFragment import com.bilibili.lingxiao.dagger.scope.PerUi import com.bilibili.lingxiao.home.dynamic.DynamicFragment import com.bilibili.lingxiao.home.find.ui.FindFragment import com.bilibili.lingxiao.home.live.ui.play.FansFragment import com.bilibili.lingxiao.home.live.ui.play.FleetListFragment import com.bilibili.lingxiao.home.live.ui.play.InteractFragment import com.bilibili.lingxiao.home.live.ui.play.UpInfoFragment import com.bilibili.lingxiao.play.ui.CommentDetailFragment import com.bilibili.lingxiao.play.ui.CommentFragment import com.bilibili.lingxiao.play.ui.IntroduceFragment import dagger.Module import dagger.Provides @Module class UiModule { @Provides @PerUi fun provideLiveFragment() : LiveFragment { return LiveFragment() } @Provides @PerUi fun provideRecommendFragment() : RecommendFragment { return RecommendFragment() } @Provides @PerUi fun provideHotFragment() : RegionFragment { return RegionFragment() } @Provides @PerUi fun provideMikanFragment() : MikanFragment { return MikanFragment() } @Provides @PerUi fun provideDynamicFragment() : DynamicFragment { return DynamicFragment() } @Provides @PerUi fun provideFindFragment() : FindFragment { return FindFragment() } @Provides @PerUi fun provideIntroduceFragment() : IntroduceFragment { return IntroduceFragment() } @Provides @PerUi fun provideCommentFragment() : CommentFragment { return CommentFragment() } @Provides @PerUi fun provideInteractFragment() : InteractFragment { return InteractFragment() } @Provides @PerUi fun provideUpInfoFragment() : UpInfoFragment { return UpInfoFragment() } @Provides @PerUi fun provideFansFragment() : FansFragment { return FansFragment() } @Provides @PerUi fun provideFleetListFragment() : FleetListFragment { return FleetListFragment() } @Provides @PerUi fun provideCommentDetailFragment() : CommentDetailFragment { return CommentDetailFragment() } private lateinit var context: Context fun UiModule(context: Context) { this.context = context } @Provides @PerUi fun provideContext() : Context { return context } } ================================================ FILE: app/src/main/java/com/bilibili/lingxiao/dagger/scope/PerUi.kt ================================================ package com.bilibili.lingxiao.dagger.scope import javax.inject.Scope import java.lang.annotation.Retention import java.lang.annotation.RetentionPolicy /** * 自定义Scope实现单例 * 不只用dagger提供的Singleton而且还用自定义的,是因为我们使用的域不一样 */ @Scope @Retention(RetentionPolicy.RUNTIME) annotation class PerUi ================================================ FILE: app/src/main/java/com/bilibili/lingxiao/database/NetCacheDatabase.kt ================================================ package com.bilibili.lingxiao.database import com.raizlabs.android.dbflow.annotation.Database @Database(name = NetCacheDatabase.NAME,version = NetCacheDatabase.VERSION) class NetCacheDatabase { companion object{ const val NAME = "NetCache" const val VERSION = 1 } } ================================================ FILE: app/src/main/java/com/bilibili/lingxiao/database/RegionTable.kt ================================================ package com.bilibili.lingxiao.database import com.raizlabs.android.dbflow.annotation.Column import com.raizlabs.android.dbflow.annotation.PrimaryKey import com.raizlabs.android.dbflow.annotation.Table import com.raizlabs.android.dbflow.structure.BaseModel @Table(database = NetCacheDatabase::class) class RegionTable : BaseModel(){ @PrimaryKey var reid: Int = 0 //var children: List? by oneToMany { select from Children::class } @Column var logo = "" @Column var name = "" @Column var tid: Int? = null @Column var type: Int? = null @Column var uri: String? = null @Column var updateAt :Long = 0L } ================================================ FILE: app/src/main/java/com/bilibili/lingxiao/database/UserInfoTable.kt ================================================ package com.bilibili.lingxiao.database import androidx.room.Embedded import androidx.room.Entity import androidx.room.PrimaryKey import com.hiczp.bilibili.api.app.model.MyInfo @Entity data class UserInfoTable( @PrimaryKey val uid: Long, var birthday: String, //生日 var coins: Int, // 硬币 var face: String,//头像 var level: Int, // 等级 var name: String, // czp3009 var sex: Int, // 0 var sign: String, var silence: Int, // 0 var telStatus: Int, // 1 @Embedded var official: MyInfo.Data.Official, @Embedded var vip: MyInfo.Data.Vip ) { } ================================================ FILE: app/src/main/java/com/bilibili/lingxiao/database/dao/UserDao.kt ================================================ package com.bilibili.lingxiao.database.dao import androidx.room.* import com.bilibili.lingxiao.database.UserInfoTable @Dao interface UserDao { @Insert(onConflict = OnConflictStrategy.REPLACE) //发生冲突后 取代旧数据同时继续事务 fun insertUser(userInfoTable: UserInfoTable) @Delete fun deleteUser(userInfoTable: UserInfoTable) @Update fun update(userInfoTable: UserInfoTable) @Query("SELECT * FROM UserInfoTable WHERE uid IS :mid LIMIT 1") fun findById(mid:Long):UserInfoTable? @Query("SELECT * FROM UserInfoTable LIMIT 1") fun findUser():UserInfoTable? } ================================================ FILE: app/src/main/java/com/bilibili/lingxiao/database/db/AppDatabase.kt ================================================ package com.bilibili.lingxiao.database.db import androidx.room.Database import androidx.room.RoomDatabase import com.bilibili.lingxiao.database.UserInfoTable import com.bilibili.lingxiao.database.dao.UserDao @Database(entities = arrayOf(UserInfoTable::class), version = 1) abstract class AppDatabase :RoomDatabase(){ abstract fun userDao(): UserDao } ================================================ FILE: app/src/main/java/com/bilibili/lingxiao/home/MainActivity.kt ================================================ package com.bilibili.lingxiao.home import android.Manifest import android.net.Uri import androidx.appcompat.app.ActionBarDrawerToggle import android.view.Gravity import android.view.View import android.view.ViewGroup import android.widget.ImageView import android.widget.LinearLayout import android.widget.TextView import com.bilibili.lingxiao.GlobalProperties import com.bilibili.lingxiao.R import com.bilibili.lingxiao.home.dynamic.DynamicFragment import com.bilibili.lingxiao.home.find.ui.FindFragment import com.bilibili.lingxiao.home.live.adapter.PlayPagerAdapter import com.bilibili.lingxiao.home.region.ui.RegionFragment import com.bilibili.lingxiao.home.live.ui.LiveFragment import com.bilibili.lingxiao.home.mikan.ui.MikanFragment import com.bilibili.lingxiao.home.navigation.SettingActivity import com.bilibili.lingxiao.home.navigation.ThemeActivity import com.bilibili.lingxiao.home.recommend.ui.RecommendFragment import com.bilibili.lingxiao.user.LoginActivity import com.bilibili.lingxiao.utils.ToastUtil import com.bilibili.lingxiao.utils.UIUtil import com.camera.lingxiao.common.app.BaseActivity import com.camera.lingxiao.common.app.BaseFragment import com.camera.lingxiao.common.rxbus.SkinChangedEvent import com.camera.lingxiao.common.utills.PopwindowUtil import com.github.zackratos.ultimatebar.UltimateBar import kotlinx.android.synthetic.main.activity_main.* import org.greenrobot.eventbus.Subscribe import org.greenrobot.eventbus.ThreadMode import pub.devrel.easypermissions.AppSettingsDialog import pub.devrel.easypermissions.EasyPermissions import javax.inject.Inject import com.camera.lingxiao.common.app.ActivityController import com.camera.lingxiao.common.utills.SpUtils import com.facebook.drawee.drawable.ScalingUtils import com.facebook.drawee.view.SimpleDraweeView import com.facebook.imagepipeline.common.ImageDecodeOptionsBuilder import com.google.android.material.internal.NavigationMenuView import com.google.gson.Gson import com.hiczp.bilibili.api.app.model.MyInfo class MainActivity : BaseActivity() { private val tabArray by lazy { resources.getStringArray(R.array.main_tab) } private var drawerOpened = false private val mPermessions = arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE) @Inject lateinit var liveFragment: LiveFragment @Inject lateinit var recommendFragment: RecommendFragment @Inject lateinit var categoryFragment: RegionFragment @Inject lateinit var mikanFragment: MikanFragment @Inject lateinit var dynamicFragment: DynamicFragment @Inject lateinit var findFragment: FindFragment private var fragmentList:ArrayList = arrayListOf() override val contentLayoutId: Int get() = R.layout.activity_main override fun initInject() { super.initInject() UIUtil.getUiComponent().inject(this) } override fun isRegisterEventBus(): Boolean { return true } @Subscribe(threadMode = ThreadMode.MAIN,sticky = true) fun onSkinChanged(event : SkinChangedEvent){ UltimateBar.newColorBuilder() .statusColor(event.color) // 状态栏颜色 .applyNav(true) // 是否应用到导航栏 .navColor(event.color) // 导航栏颜色 .build(this) .apply() } @Subscribe(threadMode = ThreadMode.MAIN) fun onLogined(user: MyInfo){ changeLoginedState(user) } override fun initWidget() { super.initWidget() //权限检测 if (!EasyPermissions.hasPermissions(this, *mPermessions)){ //没有权限就申请 EasyPermissions.requestPermissions(this, "申请权限", 100, *mPermessions) } setSupportActionBar(main_toolbar) //设置返回键可用 //supportActionBar?.setHomeButtonEnabled(true); //supportActionBar?.setDisplayHomeAsUpEnabled(true); supportActionBar?.setDisplayShowTitleEnabled(false) initNavigationView() initTabLayout() image_header.setOnClickListener { StartActivity(LoginActivity::class.java,false) } image_download.setOnClickListener { } image_game.setOnClickListener { } image_search.setOnClickListener { val popwindowUtil = PopwindowUtil.PopupWindowBuilder(this@MainActivity) .setView(R.layout.fragment_dialog_search) .size(ViewGroup.LayoutParams.MATCH_PARENT.toFloat(),ViewGroup.LayoutParams.WRAP_CONTENT.toFloat()) .setFocusable(true) .setTouchable(true) .setOutsideTouchable(true) .create() popwindowUtil.showAtLocation(it,0,-it.height,Gravity.TOP,0.5f) popwindowUtil.getView(R.id.image_exit)!!.setOnClickListener { popwindowUtil.dissmiss() } } val info = SpUtils.getString(this, GlobalProperties.USER_INFO, "") if (info.isNotEmpty()){ val userInfo = Gson().fromJson(info,MyInfo::class.java) changeLoginedState(userInfo) } } private lateinit var navigationView:View private fun initNavigationView() { val drawerToggle = object : ActionBarDrawerToggle(this,main_drawer_layout, main_toolbar, R.string.open, R.string.close ){ override fun onDrawerOpened(drawerView: View) { super.onDrawerOpened(drawerView) drawerOpened = true } override fun onDrawerClosed(drawerView: View) { super.onDrawerClosed(drawerView) drawerOpened = false } } main_drawer_layout.addDrawerListener(drawerToggle)//设置侧滑监听 //drawerToggle.syncState()//设置左箭头与Home图标的切换与侧滑同步 image_drawer_home.setOnClickListener { if (drawerOpened){ main_drawer_layout.closeDrawer(Gravity.START) }else{ main_drawer_layout.openDrawer(Gravity.START) } } navigationView = main_navigation.inflateHeaderView(R.layout.nav_header) val headerView = navigationView.findViewById(R.id.nav_header) headerView.setOnClickListener{ StartActivity(LoginActivity::class.java,false) } findViewById(R.id.ll_nav_setting) .setOnClickListener { StartActivity(SettingActivity::class.java,false) } findViewById(R.id.ll_nav_theme) .setOnClickListener { StartActivity(ThemeActivity::class.java,false) } //隐藏NavigationView右侧滚动条 val navigationMenuView = main_navigation.getChildAt(0) as NavigationMenuView navigationMenuView.isVerticalScrollBarEnabled = false } private fun changeLoginedState(user:MyInfo){ val name = navigationView.findViewById(R.id.text_name) val dynamicNum = navigationView.findViewById(R.id.dynamic_num) val followedNum = navigationView.findViewById(R.id.followed_num) val followingNum = navigationView.findViewById(R.id.following_num) val headerView = navigationView.findViewById(R.id.nav_header) headerView.hierarchy.actualImageScaleType = ScalingUtils.ScaleType.CENTER_CROP val imageDecode = ImageDecodeOptionsBuilder().setForceStaticImage(true).build() user.data.let { headerView.setImageURI(Uri.parse(it.face)) name.text = it.name dynamicNum.text = "0" followedNum.text = "0" followingNum.text = "0" } image_header.setImageURI(Uri.parse(user.data.face)) username.text = user.data.name } private fun initTabLayout() { for (name in tabArray){ main_tabLayout.addTab(main_tabLayout.newTab().setText(name)) } fragmentList.add(liveFragment) fragmentList.add(recommendFragment) fragmentList.add(categoryFragment) fragmentList.add(mikanFragment) fragmentList.add(dynamicFragment) fragmentList.add(findFragment) main_viewPager.adapter = PlayPagerAdapter(supportFragmentManager, tabArray, fragmentList) main_tabLayout.setupWithViewPager(main_viewPager) main_viewPager.currentItem = 1 //设置viewpager缓存页面个数 main_viewPager.offscreenPageLimit = 4 } private var preTime: Long = 0 override fun onBackPressed() { if (drawerOpened){ main_drawer_layout.closeDrawers() }else{ val nowTime = System.currentTimeMillis() if (nowTime - preTime > 2000) { ToastUtil.show("再按一次退出") preTime = nowTime } else { ActivityController.finishAll() } //super.onBackPressed() } } override fun onDestroy() { super.onDestroy() fragmentList.clear() } override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray) { super.onRequestPermissionsResult(requestCode, permissions, grantResults) EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults) } override fun onPermissionsDenied(requestCode: Int, perms: MutableList) { if (EasyPermissions.somePermissionPermanentlyDenied(this, perms)) { AppSettingsDialog.Builder(this).build().show() } } override fun onPermissionsGranted(requestCode: Int, perms: MutableList) { } } ================================================ FILE: app/src/main/java/com/bilibili/lingxiao/home/dynamic/DynamicFragment.kt ================================================ package com.bilibili.lingxiao.home.dynamic import android.view.View import com.bilibili.lingxiao.R import com.bilibili.lingxiao.utils.UIUtil import com.camera.lingxiao.common.app.BaseFragment class DynamicFragment :BaseFragment(){ override val contentLayoutId: Int get() = R.layout.fragment_dynamic override fun initInject() { super.initInject() UIUtil.getUiComponent().inject(this) } override fun initWidget(root: View) { super.initWidget(root) } } ================================================ FILE: app/src/main/java/com/bilibili/lingxiao/home/find/FindView.kt ================================================ package com.bilibili.lingxiao.home.find import com.bilibili.lingxiao.home.find.model.HotWordsData import com.bilibili.lingxiao.home.find.model.SearchResultData import com.bilibili.lingxiao.home.region.model.RegionData interface FindView { fun onGetHotWords(wordsData: HotWordsData) fun onGetSearchResult(result: SearchResultData) fun onGetRegion(list: List) } ================================================ FILE: app/src/main/java/com/bilibili/lingxiao/home/find/RankListView.kt ================================================ package com.bilibili.lingxiao.home.find import com.bilibili.lingxiao.home.find.model.RankListData import com.bilibili.lingxiao.home.region.model.RegionData import com.camera.lingxiao.common.app.BaseView interface RankListView :BaseView{ fun onGetRankList(data :MutableList) } ================================================ FILE: app/src/main/java/com/bilibili/lingxiao/home/find/TopicView.kt ================================================ package com.bilibili.lingxiao.home.find import com.bilibili.lingxiao.home.find.model.TopicCardData import com.camera.lingxiao.common.app.BaseView interface TopicView :BaseView{ fun onGetTopicResult(data :TopicCardData) } ================================================ FILE: app/src/main/java/com/bilibili/lingxiao/home/find/model/HotWordsData.kt ================================================ package com.bilibili.lingxiao.home.find.model import com.google.gson.annotations.SerializedName data class HotWordsData( @SerializedName("list") val list: List, @SerializedName("trackid") val trackid: String ) { data class HotWord( @SerializedName("keyword") val keyword: String, @SerializedName("name_type") val nameType: String, @SerializedName("status") val status: String, @SerializedName("word_type") val wordType: Int ) } ================================================ FILE: app/src/main/java/com/bilibili/lingxiao/home/find/model/RankListData.kt ================================================ package com.bilibili.lingxiao.home.find.model import com.google.gson.annotations.SerializedName data class RankListData( @SerializedName("data") val `data`: List ) { data class Item( @SerializedName("param") val `param`: String, @SerializedName("children") val children: List?, @SerializedName("cid") val cid: Int, @SerializedName("cover") val cover: String, @SerializedName("danmaku") val danmaku: Int, @SerializedName("duration") val duration: Int, @SerializedName("face") val face: String, @SerializedName("favourite") val favourite: Int, @SerializedName("follower") val follower: Int, @SerializedName("goto") val goto: String, @SerializedName("like") val like: Int, @SerializedName("mid") val mid: Int, @SerializedName("name") val name: String, @SerializedName("official_verify") val officialVerify: OfficialVerify, @SerializedName("play") val play: Int, @SerializedName("pts") val pts: Int, @SerializedName("pubdate") val pubdate: Int, @SerializedName("reply") val reply: Int, @SerializedName("rid") val rid: Int, @SerializedName("rname") val rname: String, @SerializedName("title") val title: String, @SerializedName("uri") val uri: String ) { data class OfficialVerify( @SerializedName("desc") val desc: String, @SerializedName("type") val type: Int ) data class Children( @SerializedName("param") val `param`: String, @SerializedName("cid") val cid: Int, @SerializedName("cover") val cover: String, @SerializedName("danmaku") val danmaku: Int, @SerializedName("duration") val duration: Int, @SerializedName("face") val face: String, @SerializedName("favourite") val favourite: Int, @SerializedName("goto") val goto: String, @SerializedName("like") val like: Int, @SerializedName("mid") val mid: Int, @SerializedName("name") val name: String, @SerializedName("play") val play: Int, @SerializedName("pts") val pts: Int, @SerializedName("pubdate") val pubdate: Int, @SerializedName("reply") val reply: Int, @SerializedName("rid") val rid: Int, @SerializedName("rname") val rname: String, @SerializedName("title") val title: String, @SerializedName("uri") val uri: String ) } } ================================================ FILE: app/src/main/java/com/bilibili/lingxiao/home/find/model/SearchResultData.kt ================================================ package com.bilibili.lingxiao.home.find.model import com.google.gson.annotations.SerializedName data class SearchResultData( @SerializedName("array") val array: Int, @SerializedName("attribute") val attribute: Int, @SerializedName("item") val item: List, @SerializedName("items") val items: Items, @SerializedName("nav") val nav: List