1
This commit is contained in:
1
live/build.gradle
Normal file
1
live/build.gradle
Normal file
@@ -0,0 +1 @@
|
||||
apply plugin: 'com.android.library'
|
||||
316
live/img_optimizer.log
Normal file
316
live/img_optimizer.log
Normal file
@@ -0,0 +1,316 @@
|
||||
2019-11-01 13:59:50 info: Task optimizeLiveRelease begin:
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:50 info: 154 images need to be optimized.
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:50 info: Succeed! 492B-->373B, 24.186993% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_user_5.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:50 info: Succeed! 5789B-->3453B, 40.352394% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_gift_prize_pool_4.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:50 info: Succeed! 851B-->783B, 7.990599% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_gift_prize_pool_5.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:50 info: Succeed! 3028B-->2196B, 27.476883% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_light_6.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:51 info: Succeed! 3151B-->2163B, 31.355125% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_light_4.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:51 info: Succeed! 20161B-->13671B, 32.190865% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_jin_guang.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:51 info: Succeed! 1782B-->1286B, 27.833895% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_user_6.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:51 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_gift_guard.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:51 info: Succeed! 920B-->719B, 21.847826% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_arrow_right_4.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:51 info: Succeed! 18993B-->8077B, 57.473804% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_gift_prize_pool_6.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:51 info: Succeed! 2502B-->1828B, 26.93845% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_gift_luck_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:51 info: Succeed! 4559B-->3017B, 33.823208% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_gift.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:51 info: Succeed! 2952B-->2392B, 18.97019% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_user_7.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:51 info: Succeed! 3228B-->2285B, 29.213135% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_light_5.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:51 info: Succeed! 1838B-->1055B, 42.600655% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_func_camera.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:51 info: Succeed! 3175B-->2154B, 32.157482% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_light_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:51 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_user_3.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:51 info: Succeed! 80314B-->26352B, 67.18878% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_gift_prize_pool_2.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:51 info: Succeed! 464B-->378B, 18.534483% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_close_2.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:51 info: Succeed! 738B-->510B, 30.894308% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_close_3.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:51 info: Succeed! 46126B-->17792B, 61.427395% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_gift_prize_pool_3.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:52 info: Succeed! 23123B-->10135B, 56.16918% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_user_2.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:52 info: Succeed! 2222B-->1825B, 17.866787% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_func_game.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:52 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_func_share.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:52 info: Succeed! 3215B-->2221B, 30.917574% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_light_2.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:52 info: Succeed! 49665B-->29357B, 40.88996% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_gift_prize_pool_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:52 info: Succeed! 6954B-->3649B, 47.526604% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_gift_count_8.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:52 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_arrow_right_3.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:52 info: Succeed! 6925B-->3623B, 47.682312% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_gift_count_9.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:52 info: Succeed! 3290B-->2344B, 28.7538% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_chat_vip.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:52 info: Succeed! 200276B-->39093B, 80.48044% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_user_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:52 info: Succeed! 3222B-->2207B, 31.502172% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_light_3.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:52 info: Succeed! 213B-->190B, 10.798122% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_gift_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:52 info: Succeed! 2942B-->1746B, 40.65262% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_chat.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:52 info: Succeed! 1240B-->1064B, 14.193548% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_type_time_2.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:52 info: Succeed! 1741B-->1455B, 16.427341% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_func_flash_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:52 info: Succeed! 3441B-->2605B, 24.295263% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_func_rp.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:52 info: Succeed! 8636B-->7461B, 13.605836% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_gift_anim_3.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:53 info: Succeed! 385B-->280B, 27.272728% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_ready_close.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:53 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_gift_2.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:53 info: Succeed! 2237B-->1925B, 13.94725% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_type_time_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:53 info: Succeed! 388B-->329B, 15.206185% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_gift_3.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:53 info: Succeed! 8523B-->6645B, 22.034494% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_gift_anim_6.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:53 info: Succeed! 2291B-->2245B, 2.0078568% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_send_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:53 info: Succeed! 1692B-->679B, 59.869976% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_ready_add.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:53 info: Succeed! 978B-->954B, 2.4539878% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_type_pay_2.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:53 info: Succeed! 1974B-->1460B, 26.0385% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_share_link.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:53 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_send_0.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:53 info: Succeed! 2506B-->1837B, 26.69593% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_type_pwd_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:53 info: Succeed! 8898B-->7719B, 13.250169% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_gift_anim_7.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:53 info: Succeed! 1205B-->618B, 48.71369% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_gift_anim_5.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:53 info: Succeed! 152039B-->48860B, 67.86351% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_red_pack_8.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:53 info: Succeed! 14845B-->6946B, 53.209835% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_gift_lian.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:53 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_type_pay_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:53 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_title_laba.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:53 info: Succeed! 3650B-->1668B, 54.30137% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_red_pack_9.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:54 info: Succeed! 1224B-->1207B, 1.3888888% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_type_pwd_2.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:54 info: Succeed! 315B-->308B, 2.2222223% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_star.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:54 info: Succeed! 15994B-->14996B, 6.23984% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_gift_anim_4.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:54 info: Succeed! 6346B-->4156B, 34.509926% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_gift_anim_9.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:54 info: Succeed! 1142B-->848B, 25.744308% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_record_pause.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:54 info: Succeed! 6405B-->3854B, 39.82826% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_red_pack_4.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:54 info: Succeed! 18619B-->8045B, 56.79145% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_gift_lian_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:54 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_func_flash.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:54 info: Succeed! 21877B-->9995B, 54.312748% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_gift_lian_0.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:54 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_red_pack_5.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:54 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_gift_hot.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:54 info: Succeed! 3184B-->2028B, 36.306534% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_share.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:54 info: Succeed! 11100B-->10058B, 9.387387% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_gift_anim_8.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:54 info: Succeed! 6976B-->3224B, 53.784405% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_red_pack_7.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:54 info: Succeed! 11763B-->5413B, 53.982826% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_pk_result_win.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:54 info: Succeed! 3097B-->1850B, 40.26477% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_msg.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:54 info: Succeed! 977B-->915B, 6.345957% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_red_pack_btn_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:54 info: Succeed! 1813B-->291B, 83.94926% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/bg_gift_list.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:54 info: Succeed! 787B-->675B, 14.231258% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_red_pack_btn_0.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:55 info: Succeed! 136316B-->53281B, 60.913612% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_red_pack_6.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:55 info: Succeed! 2192B-->1690B, 22.90146% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_link_mic.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:55 info: Succeed! 4151B-->2492B, 39.966274% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_guard_type_0.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:55 info: Succeed! 923B-->540B, 41.495125% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_gift_hao.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:55 info: Succeed! 4628B-->2810B, 39.282627% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_red_pack_2.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:55 info: Succeed! 3372B-->2723B, 19.246738% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_beauty_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:55 info: Succeed! 2754B-->2215B, 19.571533% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_chat_liang.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:55 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_ready_room_type.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:55 info: Succeed! 4776B-->2833B, 40.68258% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_red_pack_3.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:55 info: Succeed! 652B-->579B, 11.196319% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_search_back.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:55 info: Succeed! 4234B-->2476B, 41.52102% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_guard_type_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:55 info: Succeed! 130421B-->59279B, 54.547962% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_red_pack_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:55 info: Succeed! 1081B-->643B, 40.51804% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_guard_buy_0_0.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:55 info: Succeed! 2563B-->2087B, 18.571985% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_chat_m.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:56 info: Succeed! 6383B-->4202B, 34.168884% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_gift_anim_10.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:56 info: Succeed! 7506B-->3483B, 53.597122% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_red_pack.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:56 info: Succeed! 1159B-->782B, 32.52804% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_guard_buy_0_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:56 info: Succeed! 1277B-->939B, 26.468285% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_record_play.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:56 info: Succeed! 1468B-->1467B, 0.06811989% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_func_music.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:56 info: Succeed! 2205B-->1394B, 36.780045% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_close.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:56 info: Succeed! 4072B-->3023B, 25.761297% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_func_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:56 info: Succeed! 3766B-->2317B, 38.475838% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_chat_guard_2.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:56 info: Succeed! 4739B-->2826B, 40.367165% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_danmu_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:56 info: Succeed! 4842B-->2924B, 39.611732% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_gift_count_4.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:56 info: Succeed! 5505B-->3458B, 37.18438% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/bg_guard_buy_top_2.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:56 info: Succeed! 6105B-->3415B, 44.062244% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_gift_count_5.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:56 info: Succeed! 3811B-->2221B, 41.721333% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_danmu_0.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:56 info: Succeed! 2166B-->1297B, 40.120037% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_func_0.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:56 info: Succeed! 3740B-->2332B, 37.64706% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_chat_guard_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:56 info: Succeed! 40371B-->13257B, 67.16207% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_guard_top_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:56 info: Succeed! 966B-->768B, 20.496895% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_search.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:56 info: Succeed! 3638B-->2552B, 29.851566% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_gift_count_7.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:56 info: Succeed! 4993B-->3547B, 28.960545% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/bg_guard_buy_top_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:57 info: Succeed! 6796B-->3589B, 47.18952% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_gift_count_6.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:57 info: Succeed! 26253B-->14690B, 44.04449% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_guard_top_0.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:57 info: Succeed! 256B-->164B, 35.9375% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_admin_delete.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:57 info: Succeed! 1103B-->884B, 19.85494% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_type_normal_2.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:57 info: Succeed! 1359B-->823B, 39.440765% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_guard_buy_1_0.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:57 info: Succeed! 3331B-->2522B, 24.287% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_user_list_2.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:57 info: Succeed! 5613B-->3233B, 42.40157% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_gift_count_2.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:57 info: Succeed! 1690B-->1328B, 21.420118% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_ready_location_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:57 info: Succeed! 2010B-->1267B, 36.965176% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_ready_location_0.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:57 info: Succeed! 5577B-->3562B, 36.130535% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_gift_count_3.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:57 info: Succeed! 3375B-->2533B, 24.948149% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_user_list_3.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:57 info: Succeed! 1273B-->808B, 36.527885% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_guard_buy_1_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:57 info: Succeed! 1785B-->1762B, 1.2885154% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_func_beauty.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:57 info: Succeed! 392B-->244B, 37.7551% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_arrow_right.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:57 info: Succeed! 3663B-->2608B, 28.801529% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_func_lm.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:57 info: Succeed! 924B-->809B, 12.445888% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_ready_camera.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:57 info: Succeed! 2318B-->2012B, 13.2010355% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_type_normal_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:57 info: Succeed! 3271B-->2526B, 22.77591% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_user_list_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:57 info: Succeed! 3781B-->2578B, 31.81698% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_gift_count_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:57 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_gift_luck.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:57 info: Succeed! 6180B-->3369B, 45.485435% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_pk.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:57 info: Succeed! 6380B-->3399B, 46.724136% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_gift_count_0.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:57 info: Succeed! 1932B-->1147B, 40.63147% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_link_mic_1.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:58 info: Succeed! 3468B-->2724B, 21.453287% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_user_8.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:58 info: Succeed! 11331B-->5152B, 54.531815% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-mdpi/icon_live_pk_result_ping.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:58 info: Succeed! 7378B-->3698B, 49.878017% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-hdpi/pk17.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:58 info: Succeed! 7017B-->3909B, 44.29243% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-hdpi/pk03.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:58 info: Succeed! 7018B-->3920B, 44.14363% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-hdpi/pk02.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:58 info: Succeed! 7763B-->3803B, 51.011208% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-hdpi/pk16.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:58 info: Succeed! 7975B-->3759B, 52.865204% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-hdpi/pk14.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:58 info: Succeed! 7993B-->3831B, 52.07056% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-hdpi/pk15.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:58 info: Succeed! 5511B-->3312B, 39.902016% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-hdpi/pk01.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:58 info: Succeed! 7003B-->3886B, 44.509495% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-hdpi/pk05.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:58 info: Succeed! 7042B-->3698B, 47.48651% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-hdpi/pk11.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:58 info: Succeed! 6893B-->3677B, 46.65603% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-hdpi/pk10.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:58 info: Succeed! 7005B-->3903B, 44.282654% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-hdpi/pk04.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:58 info: Succeed! 7675B-->3735B, 51.335506% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-hdpi/pk12.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:58 info: Succeed! 6997B-->3924B, 43.918823% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-hdpi/pk06.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:59 info: Succeed! 9998B-->5402B, 45.969193% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-hdpi/pk07.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:59 info: Succeed! 7955B-->3726B, 53.161533% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-hdpi/pk13.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:59 info: Succeed! 11352B-->5993B, 47.207542% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-hdpi/pk09.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:59 info: Succeed! 10793B-->5705B, 47.141666% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-hdpi/pk08.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:59 info: Succeed! 6982B-->3632B, 47.980522% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-hdpi/pk18.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:59 info: Succeed! 6774B-->3610B, 46.708% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-hdpi/pk19.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:59 warn: Skipped! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-hdpi/icon_guard_buy_top.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:59 info: Succeed! 7477B-->4482B, 40.05617% saved! /Users/yaling/Documents/bayue/denglong_release4/live/src/main/res/mipmap-xxxhdpi/bg_live_pk.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:59 info: Total: 154, Succeed: 140, Skipped: 14, Failed: 0, Saved: 793.123046875KB
|
||||
----------------------------------------
|
||||
2019-11-01 13:59:59 info: Task optimizeLiveRelease executed successfully.
|
||||
----------------------------------------
|
||||
25
live/proguard-rules.pro
vendored
Normal file
25
live/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in /Users/macpro/Library/Android/sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# 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
|
||||
129
live/src/main/AndroidManifest.xml
Normal file
129
live/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,129 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.yunbao.live">
|
||||
<!--com.kugou.fanxing.allinone.watch.liveroominone.media.FALiveRoomInOneActivity"-->
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name=".activity.LiveTRTCAnchorActivity" />
|
||||
<activity
|
||||
android:name=".activity.LiveAnchorActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme"
|
||||
android:windowSoftInputMode="adjustPan|stateAlwaysHidden" />
|
||||
<activity
|
||||
android:name=".activity.GiftWallActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme"
|
||||
android:windowSoftInputMode="adjustPan|stateAlwaysHidden" />
|
||||
<activity
|
||||
android:name=".activity.LiveAudienceActivity"
|
||||
android:configChanges="screenLayout|orientation"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme"
|
||||
android:windowSoftInputMode="adjustPan|stateAlwaysHidden"
|
||||
tools:targetApi="n" />
|
||||
<activity
|
||||
android:name=".activity.LiveChooseClassActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.FALiveRoomInOneActivity"
|
||||
android:resizeableActivity="true"
|
||||
android:screenOrientation="portrait"
|
||||
android:supportsPictureInPicture="true"
|
||||
tools:targetApi="n" />
|
||||
<activity
|
||||
android:name=".activity.LiveReportActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustPan|stateAlwaysHidden" />
|
||||
<activity
|
||||
android:name=".activity.LiveAddImpressActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.LiveContributeActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.LiveGuardListActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.LiveRecordActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.LiveRecordPlayActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.RoomManageActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.RoomManageDetailActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.LiveAdminListActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.LiveShutUpActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.LiveBlackActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.Beauty360Activity2"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.Beauty360Activity3"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.WebViewActivityMedal"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.SudGameActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.MedalQuestionWebViewActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.ZhuangBanActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||
android:screenOrientation="portrait" /> <!-- Android 9.0移除了apache的HttpClient,而金山sdk中用到了这个,不加这个的话在Android 9.0会崩溃 -->
|
||||
<activity
|
||||
android:name=".activity.SystemMessageActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.LiveRyAnchorActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<uses-library
|
||||
android:name="org.apache.http.legacy"
|
||||
android:required="false" />
|
||||
|
||||
<activity
|
||||
android:name=".activity.PDLiveConversationActivity"
|
||||
android:hardwareAccelerated="true"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateAlwaysHidden|adjustResize" />
|
||||
<activity
|
||||
android:name=".activity.PDLIiveChatActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/DialogActivity" />
|
||||
<activity
|
||||
android:name=".activity.EditNameRemarksActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".views.OlineListActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".activity.CompensateActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
BIN
live/src/main/assets/chat_message_bg.png
Normal file
BIN
live/src/main/assets/chat_message_bg.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 712 B |
BIN
live/src/main/assets/double_click_tip.svga
Normal file
BIN
live/src/main/assets/double_click_tip.svga
Normal file
Binary file not shown.
BIN
live/src/main/assets/filterData.zip
Normal file
BIN
live/src/main/assets/filterData.zip
Normal file
Binary file not shown.
BIN
live/src/main/assets/free_gift_tip.svga
Normal file
BIN
live/src/main/assets/free_gift_tip.svga
Normal file
Binary file not shown.
BIN
live/src/main/assets/hdsn.svga
Normal file
BIN
live/src/main/assets/hdsn.svga
Normal file
Binary file not shown.
BIN
live/src/main/assets/ic_live_anchor_call_me.svga
Normal file
BIN
live/src/main/assets/ic_live_anchor_call_me.svga
Normal file
Binary file not shown.
BIN
live/src/main/assets/littlepanda1.svga
Normal file
BIN
live/src/main/assets/littlepanda1.svga
Normal file
Binary file not shown.
BIN
live/src/main/assets/littlepanda10.svga
Normal file
BIN
live/src/main/assets/littlepanda10.svga
Normal file
Binary file not shown.
BIN
live/src/main/assets/littlepanda11.svga
Normal file
BIN
live/src/main/assets/littlepanda11.svga
Normal file
Binary file not shown.
BIN
live/src/main/assets/littlepanda12.svga
Normal file
BIN
live/src/main/assets/littlepanda12.svga
Normal file
Binary file not shown.
BIN
live/src/main/assets/littlepanda13.svga
Normal file
BIN
live/src/main/assets/littlepanda13.svga
Normal file
Binary file not shown.
BIN
live/src/main/assets/littlepanda14.svga
Normal file
BIN
live/src/main/assets/littlepanda14.svga
Normal file
Binary file not shown.
BIN
live/src/main/assets/littlepanda15.svga
Normal file
BIN
live/src/main/assets/littlepanda15.svga
Normal file
Binary file not shown.
BIN
live/src/main/assets/littlepanda16.svga
Normal file
BIN
live/src/main/assets/littlepanda16.svga
Normal file
Binary file not shown.
BIN
live/src/main/assets/littlepanda17.svga
Normal file
BIN
live/src/main/assets/littlepanda17.svga
Normal file
Binary file not shown.
BIN
live/src/main/assets/littlepanda18.svga
Normal file
BIN
live/src/main/assets/littlepanda18.svga
Normal file
Binary file not shown.
BIN
live/src/main/assets/littlepanda19.svga
Normal file
BIN
live/src/main/assets/littlepanda19.svga
Normal file
Binary file not shown.
BIN
live/src/main/assets/littlepanda2.svga
Normal file
BIN
live/src/main/assets/littlepanda2.svga
Normal file
Binary file not shown.
BIN
live/src/main/assets/littlepanda3.svga
Normal file
BIN
live/src/main/assets/littlepanda3.svga
Normal file
Binary file not shown.
BIN
live/src/main/assets/littlepanda4.svga
Normal file
BIN
live/src/main/assets/littlepanda4.svga
Normal file
Binary file not shown.
BIN
live/src/main/assets/littlepanda5.svga
Normal file
BIN
live/src/main/assets/littlepanda5.svga
Normal file
Binary file not shown.
BIN
live/src/main/assets/littlepanda6.svga
Normal file
BIN
live/src/main/assets/littlepanda6.svga
Normal file
Binary file not shown.
BIN
live/src/main/assets/littlepanda7.svga
Normal file
BIN
live/src/main/assets/littlepanda7.svga
Normal file
Binary file not shown.
BIN
live/src/main/assets/littlepanda8.svga
Normal file
BIN
live/src/main/assets/littlepanda8.svga
Normal file
Binary file not shown.
BIN
live/src/main/assets/littlepanda9.svga
Normal file
BIN
live/src/main/assets/littlepanda9.svga
Normal file
Binary file not shown.
BIN
live/src/main/assets/littlepanda_craft.svga
Normal file
BIN
live/src/main/assets/littlepanda_craft.svga
Normal file
Binary file not shown.
BIN
live/src/main/assets/live_follow_tip.svga
Normal file
BIN
live/src/main/assets/live_follow_tip.svga
Normal file
Binary file not shown.
BIN
live/src/main/assets/model-all.zip
Normal file
BIN
live/src/main/assets/model-all.zip
Normal file
Binary file not shown.
BIN
live/src/main/assets/rectangle_new.png
Normal file
BIN
live/src/main/assets/rectangle_new.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
BIN
live/src/main/assets/week_bg.svga
Normal file
BIN
live/src/main/assets/week_bg.svga
Normal file
Binary file not shown.
139
live/src/main/java/com/yunbao/live/LiveConfig.java
Normal file
139
live/src/main/java/com/yunbao/live/LiveConfig.java
Normal file
@@ -0,0 +1,139 @@
|
||||
package com.yunbao.live;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.yunbao.common.CommonAppContext;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.live.bean.LiveKsyConfigBean;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/10/7.
|
||||
* 直播相关的参数配置
|
||||
*/
|
||||
|
||||
public class LiveConfig {
|
||||
//推流参数配置
|
||||
// public static final int PUSH_CAP_RESOLUTION = StreamerConstants.VIDEO_RESOLUTION_540P;//采集分辨率
|
||||
// public static final int PUSH_PREVIEW_RESOLUTION = StreamerConstants.VIDEO_RESOLUTION_540P;//直播预览分辨率
|
||||
// public static final int LINK_MIC_PUSH_PREVIEW_RESOLUTION = StreamerConstants.VIDEO_RESOLUTION_540P;//连麦预览分辨率
|
||||
// public static final int PUSH_VIDEO_RESOLUTION = StreamerConstants.VIDEO_RESOLUTION_480P;//推流分辨率
|
||||
// public static final int PUSH_ENCODE_TYPE = AVConst.CODEC_ID_AVC;//H264
|
||||
// public static final int PUSH_ENCODE_METHOD = StreamerConstants.ENCODE_METHOD_SOFTWARE;//软编
|
||||
// public static final int PUSH_ENCODE_SCENE = VideoEncodeFormat.ENCODE_SCENE_SHOWSELF;//秀场模式
|
||||
// public static final int PUSH_ENCODE_PROFILE = VideoEncodeFormat.ENCODE_PROFILE_LOW_POWER;//低功耗
|
||||
public static final int PUSH_FRAME_RATE = 20;//采集帧率
|
||||
public static final int PUSH_VIDEO_BITRATE = 500;//视频码率
|
||||
public static final int PUSH_VIDEO_BITRATE_MAX = 800;//视频码率
|
||||
public static final int PUSH_VIDEO_BITRATE_MIN = 300;//视频码率
|
||||
public static final int PUSH_AUDIO_BITRATE = 48;//音频码率
|
||||
public static final int PUSH_GOP = 3;//gop
|
||||
|
||||
|
||||
public static LiveKsyConfigBean getDefaultKsyConfig() {
|
||||
LiveKsyConfigBean bean = new LiveKsyConfigBean();
|
||||
// bean.setEncodeMethod(PUSH_ENCODE_METHOD);
|
||||
// bean.setTargetResolution(PUSH_VIDEO_RESOLUTION);
|
||||
bean.setTargetFps(PUSH_FRAME_RATE);
|
||||
bean.setTargetGop(PUSH_GOP);
|
||||
bean.setVideoKBitrate(PUSH_VIDEO_BITRATE);
|
||||
bean.setVideoKBitrateMax(PUSH_VIDEO_BITRATE_MAX);
|
||||
bean.setVideoKBitrateMin(PUSH_VIDEO_BITRATE_MIN);
|
||||
bean.setAudioKBitrate(PUSH_AUDIO_BITRATE);
|
||||
bean.setPreviewFps(PUSH_FRAME_RATE);
|
||||
// bean.setPreviewResolution(PUSH_PREVIEW_RESOLUTION);
|
||||
return bean;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取手机相关信息,开播时候用到
|
||||
*/
|
||||
// public static String getSystemParams() {
|
||||
//// String sysParams = StringUtil.contact(
|
||||
//// android.os.Build.BRAND,//手机厂商
|
||||
//// "_",
|
||||
//// android.os.Build.MODEL,//手机型号
|
||||
//// "_",
|
||||
//// android.os.Build.VERSION.RELEASE,//系统版本号
|
||||
//// "_",
|
||||
//// getMemory(),
|
||||
//// "_",
|
||||
//// getNetworkType()
|
||||
//// );
|
||||
//// L.e("开播", "手机信息------> " + sysParams);
|
||||
//// return sysParams;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 获取手机内存大小
|
||||
*/
|
||||
public static String getMemory() {
|
||||
String MemorySize = "NONE";
|
||||
BufferedReader br = null;
|
||||
try {
|
||||
FileReader fileReader = new FileReader("/proc/meminfo");
|
||||
br = new BufferedReader(fileReader, 8192);
|
||||
String str = br.readLine();// 读取meminfo第一行,系统总内存大小
|
||||
if (!TextUtils.isEmpty(str)) {
|
||||
String[] array = str.split("\\s+");
|
||||
int totalRam = (int) Math.ceil(Double.valueOf(array[1]) / (1024 * 1024));
|
||||
MemorySize = StringUtil.contact(String.valueOf(totalRam), "GB");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return MemorySize;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前网络类型
|
||||
**/
|
||||
// public static String getNetworkType() {
|
||||
// String netType = "NONE";
|
||||
// ConnectivityManager manager = (ConnectivityManager) CommonAppContext.sInstance.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
// NetworkInfo networkInfo = manager.getActiveNetworkInfo();
|
||||
// if (networkInfo == null) {
|
||||
// return netType;
|
||||
// }
|
||||
// int nType = networkInfo.getType();
|
||||
// if (nType == ConnectivityManager.TYPE_WIFI) {
|
||||
// netType = "WIFI";
|
||||
// } else if (nType == ConnectivityManager.TYPE_MOBILE) {
|
||||
// int nSubType = networkInfo.getSubtype();
|
||||
// TelephonyManager telephonyManager = (TelephonyManager) CommonAppContext.sInstance.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
// if (nSubType == TelephonyManager.NETWORK_TYPE_LTE
|
||||
// && !telephonyManager.isNetworkRoaming()) {
|
||||
// netType = "4G";
|
||||
// } else if (nSubType == TelephonyManager.NETWORK_TYPE_UMTS
|
||||
// || nSubType == TelephonyManager.NETWORK_TYPE_HSDPA
|
||||
// || nSubType == TelephonyManager.NETWORK_TYPE_EVDO_0
|
||||
// && !telephonyManager.isNetworkRoaming()) {
|
||||
// } else if (nSubType == TelephonyManager.NETWORK_TYPE_GPRS
|
||||
// || nSubType == TelephonyManager.NETWORK_TYPE_EDGE
|
||||
// || nSubType == TelephonyManager.NETWORK_TYPE_CDMA
|
||||
// && !telephonyManager.isNetworkRoaming()) {
|
||||
// netType = "2G";
|
||||
// } else
|
||||
// netType = "NO DISPLAY";
|
||||
// }
|
||||
// return netType;
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,338 @@
|
||||
package com.yunbao.live.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
|
||||
//Camera360美颜2
|
||||
public class Beauty360Activity2 extends Activity {
|
||||
// implements SurfaceHolder.Callback,
|
||||
// SurfaceTexture.OnFrameAvailableListener,
|
||||
// SeekBar.OnSeekBarChangeListener, Camera.PreviewCallback, MyItemClickListener {
|
||||
//
|
||||
// private float mPinkValue = 0.4f;
|
||||
// private float mWhitenValue = 0.7f;
|
||||
// private float mReddenValue = 0.5f;
|
||||
// private int mSoftenValue = 70;
|
||||
// private int mFilterValue = 100;
|
||||
// private boolean mClear = false;
|
||||
//
|
||||
// private RecyclerView mListView;
|
||||
// private MyRecycleAdapter4LvJing mAdapter;
|
||||
// private List<IRecycleCell> mListData;
|
||||
// private String mCurFilterStrength;
|
||||
//
|
||||
// private PreviewUtils mPreviewUtils;
|
||||
// private SurfaceView mSurfaceView;
|
||||
// private boolean mFirstFrame = true;
|
||||
//
|
||||
// private boolean isSticker = false;
|
||||
// private boolean zipSuccess = false;
|
||||
// Context mContext;
|
||||
// TextView tvSticker;
|
||||
// private OrientationEventListener mOrientationListener;
|
||||
// TXLivePusher mTxLivePusher;
|
||||
//
|
||||
// @Override
|
||||
// protected void onCreate(Bundle savedInstanceState) {
|
||||
// super.onCreate(savedInstanceState);
|
||||
// setContentView(com.by.lib_beauty360.R.layout.activity_main2);
|
||||
// mContext = this;
|
||||
// mPreviewUtils = new PreviewUtils(getApplicationContext(), this);
|
||||
// initViews();
|
||||
//
|
||||
// /**
|
||||
// * 贴纸zip 解压到本地
|
||||
// */
|
||||
// new UnzipAssets().unZipRequest(this, "TestSticker.zip", new UnzipAssets.IUnZipCallBack() {
|
||||
// @Override
|
||||
// public void onStart() {
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void Response(String outFileDirectory) {
|
||||
// zipSuccess = true;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError() {
|
||||
// }
|
||||
// });
|
||||
// mTxLivePusher=getTxLivePush();
|
||||
// }
|
||||
//
|
||||
// public void initViews() {
|
||||
// mSurfaceView = (SurfaceView) findViewById(com.by.lib_beauty360.R.id.surface_view);
|
||||
//
|
||||
// SeekBar m_Seekpink = (SeekBar) findViewById(com.by.lib_beauty360.R.id.seek_pink);
|
||||
// m_Seekpink.setOnSeekBarChangeListener(this);
|
||||
// m_Seekpink.setProgress((int) (mPinkValue * 100));
|
||||
// TextView tv_pink = (TextView) findViewById(com.by.lib_beauty360.R.id.pink_value);
|
||||
// tv_pink.setText(String.valueOf(mPinkValue));
|
||||
//
|
||||
// SeekBar m_Seekwhiten = (SeekBar) findViewById(com.by.lib_beauty360.R.id.seek_whiten);
|
||||
// m_Seekwhiten.setOnSeekBarChangeListener(this);
|
||||
// m_Seekwhiten.setProgress((int) (mWhitenValue * 100));
|
||||
// TextView tv_whiten = (TextView) findViewById(com.by.lib_beauty360.R.id.whiten_value);
|
||||
// tv_whiten.setText(String.valueOf(mWhitenValue));
|
||||
//
|
||||
// SeekBar m_Seekredden = (SeekBar) findViewById(com.by.lib_beauty360.R.id.seek_redden);
|
||||
// m_Seekredden.setOnSeekBarChangeListener(this);
|
||||
// m_Seekredden.setProgress((int) (mReddenValue * 100));
|
||||
// TextView tv_redden = (TextView) findViewById(com.by.lib_beauty360.R.id.redden_value);
|
||||
// tv_redden.setText(String.valueOf(mReddenValue));
|
||||
//
|
||||
//
|
||||
// SeekBar m_Seeksoften = (SeekBar) findViewById(com.by.lib_beauty360.R.id.seek_soften);
|
||||
// m_Seeksoften.setOnSeekBarChangeListener(this);
|
||||
// m_Seeksoften.setProgress(mSoftenValue);
|
||||
// TextView tv_soften = (TextView) findViewById(com.by.lib_beauty360.R.id.soften_value);
|
||||
// tv_soften.setText(String.valueOf(mSoftenValue));
|
||||
//
|
||||
// SeekBar m_SeeksFilter = (SeekBar) findViewById(com.by.lib_beauty360.R.id.filter_redden);
|
||||
// m_SeeksFilter.setOnSeekBarChangeListener(this);
|
||||
// m_SeeksFilter.setProgress(mFilterValue);
|
||||
// TextView tv_filter = (TextView) findViewById(com.by.lib_beauty360.R.id.filter_value);
|
||||
// tv_filter.setText(String.valueOf(mFilterValue));
|
||||
//
|
||||
// tvSticker = (TextView) findViewById(com.by.lib_beauty360.R.id.tv_sticker);
|
||||
// tvSticker.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// if (!zipSuccess) return;
|
||||
// if (!isSticker) {
|
||||
// tvSticker.setText("取消贴纸");
|
||||
// isSticker = true;
|
||||
// mPreviewUtils.setSticker(AppConfig.STICKER_LOCAL_PATH + "TestSticker/dog");
|
||||
// } else {
|
||||
// tvSticker.setText("贴纸");
|
||||
// isSticker = false;
|
||||
// mPreviewUtils.removeSticker();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// });
|
||||
// tvSticker.setVisibility(View.VISIBLE);
|
||||
//
|
||||
// View layoutSurface = findViewById(com.by.lib_beauty360.R.id.layout_surface);
|
||||
// layoutSurface.setOnTouchListener(new View.OnTouchListener() {
|
||||
// @Override
|
||||
// public boolean onTouch(View v, MotionEvent event) {
|
||||
// switch (event.getAction()) {
|
||||
// case MotionEvent.ACTION_DOWN:
|
||||
// case MotionEvent.ACTION_MOVE:
|
||||
// clearAllBuffer();
|
||||
// break;
|
||||
// case MotionEvent.ACTION_CANCEL:
|
||||
// case MotionEvent.ACTION_UP:
|
||||
// resetBuffer();
|
||||
// break;
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// mListView = (RecyclerView) findViewById(com.by.lib_beauty360.R.id.listview);
|
||||
// LinearLayoutManager mLayoutManager = new LinearLayoutManager(mListView.getContext(), LinearLayoutManager.HORIZONTAL, false);
|
||||
// mListView.setLayoutManager(mLayoutManager);
|
||||
// ConstructList();
|
||||
// mAdapter = new MyRecycleAdapter4LvJing(this, mListData);
|
||||
// mListView.setAdapter(mAdapter);
|
||||
// mListView.setItemAnimator(new DefaultItemAnimator());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
// int id = seekBar.getId();
|
||||
// if (id == com.by.lib_beauty360.R.id.seek_pink) {
|
||||
// if (fromUser) {
|
||||
// mPinkValue = progress / 100f;
|
||||
// mPreviewUtils.SetSkinColor(mPinkValue, mWhitenValue, mReddenValue);
|
||||
// TextView tv_pink = (TextView) findViewById(com.by.lib_beauty360.R.id.pink_value);
|
||||
// tv_pink.setText(String.valueOf(mPinkValue));
|
||||
// }
|
||||
// } else if (id == com.by.lib_beauty360.R.id.seek_whiten) {
|
||||
// if (fromUser) {
|
||||
// mWhitenValue = progress / 100f;
|
||||
// mPreviewUtils.SetSkinColor(mPinkValue, mWhitenValue, mReddenValue);
|
||||
// TextView tv_whiten = (TextView) findViewById(com.by.lib_beauty360.R.id.whiten_value);
|
||||
// tv_whiten.setText(String.valueOf(mWhitenValue));
|
||||
// }
|
||||
// } else if (id == com.by.lib_beauty360.R.id.seek_redden) {
|
||||
// if (fromUser) {
|
||||
// mReddenValue = progress / 100f;
|
||||
// mPreviewUtils.SetSkinColor(mPinkValue, mWhitenValue, mReddenValue);
|
||||
// TextView tv_redden = (TextView) findViewById(com.by.lib_beauty360.R.id.redden_value);
|
||||
// tv_redden.setText(String.valueOf(mReddenValue));
|
||||
// }
|
||||
// } else if (id == com.by.lib_beauty360.R.id.filter_redden) {
|
||||
// if (fromUser) {
|
||||
// mFilterValue = progress;
|
||||
// mPreviewUtils.SetColorFilterStrength(mFilterValue);
|
||||
// TextView tv_blur = (TextView) findViewById(com.by.lib_beauty360.R.id.filter_value);
|
||||
// tv_blur.setText(String.valueOf(mFilterValue));
|
||||
// }
|
||||
// } else if (id == com.by.lib_beauty360.R.id.seek_soften) {
|
||||
// if (fromUser) {
|
||||
// mSoftenValue = progress;
|
||||
// mPreviewUtils.SetSkinSoftenStrength(mSoftenValue);
|
||||
// TextView tv_soften = (TextView) findViewById(com.by.lib_beauty360.R.id.soften_value);
|
||||
// tv_soften.setText(String.valueOf(mSoftenValue));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void onResume() {
|
||||
// super.onResume();
|
||||
// mPreviewUtils.onresume();//启动照相机
|
||||
// reStartEngine();
|
||||
//
|
||||
// // 注册方向回调,检测屏幕方向改变
|
||||
// if (null == mOrientationListener) {
|
||||
// mOrientationListener = new OrientationEventListener(this) {
|
||||
// @Override
|
||||
// public void onOrientationChanged(int orientation) {
|
||||
// mPreviewUtils.onScreenOriChanged(orientation);
|
||||
// }
|
||||
// };
|
||||
// mOrientationListener.enable();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void reStartEngine() {
|
||||
// DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
|
||||
// float fScreenHeight = displayMetrics.heightPixels;
|
||||
//
|
||||
// int iLayoutHeight = (int) fScreenHeight;//- (int)(fScreenHeight * 0.2f);
|
||||
// int iLayoutWidth = (int) ((iLayoutHeight / (float) mPreviewUtils.getCameraWidth()) * mPreviewUtils.getCameraHeight());
|
||||
//
|
||||
// mSurfaceView.getHolder().addCallback(this);
|
||||
//
|
||||
// ViewGroup.LayoutParams surfaceLayout;
|
||||
// surfaceLayout = mSurfaceView.getLayoutParams();
|
||||
// surfaceLayout.width = iLayoutWidth;
|
||||
// surfaceLayout.height = iLayoutHeight;
|
||||
// mSurfaceView.setLayoutParams(surfaceLayout);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// protected void onPause() {
|
||||
// super.onPause();
|
||||
// mPreviewUtils.pause();
|
||||
// mFirstFrame = true;
|
||||
//
|
||||
// if (null != mOrientationListener) {
|
||||
// mOrientationListener.disable();
|
||||
// mOrientationListener = null;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void onDestroy() {
|
||||
// super.onDestroy();
|
||||
// mPreviewUtils.freeRes();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void surfaceCreated(SurfaceHolder holder) {
|
||||
// mPreviewUtils.startCameraPreview(holder);//开始预览 绑定surface
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
|
||||
// mPreviewUtils.setCameraInfo(width, height);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void surfaceDestroyed(SurfaceHolder holder) {
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onFrameAvailable(SurfaceTexture surfaceTexture) {
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onPreviewFrame(byte[] data, Camera camera) {
|
||||
// mPreviewUtils.frameProcess(data, 0, mFirstFrame, false);//data 可以传空 根据TextureId进行美颜
|
||||
// mFirstFrame = false;
|
||||
// if (mTxLivePusher != null)
|
||||
// {
|
||||
// mTxLivePusher.sendCustomVideoData(mPreviewUtils.getSkinSoftenByte(),TXLivePusher.YUV_420P
|
||||
// ,mPreviewUtils.getCameraHeight(),mPreviewUtils.getCameraWidth());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private TXLivePusher getTxLivePush() {
|
||||
// TXLivePusher livePusher = new TXLivePusher(this);
|
||||
// TXLivePushConfig livePushConfig = new TXLivePushConfig();
|
||||
//
|
||||
// int customModeType = TXLiveConstants.CUSTOM_MODE_VIDEO_CAPTURE;
|
||||
// // 只能分辨率的宽和高小于或者等于预览画面的宽和高的分辨率
|
||||
// // 还能选择 360x640 等,但不能选择 540x960。因指定分辨率的高(960) > 预览画面的高(720),编码器无法裁剪画面。
|
||||
// livePushConfig.setVideoResolution(TXLiveConstants.VIDEO_RESOLUTION_TYPE_640_360);
|
||||
// livePushConfig.setAutoAdjustBitrate(false);
|
||||
// livePushConfig.setVideoBitrate(1300);
|
||||
// livePushConfig.setVideoEncodeGop(3);
|
||||
// livePushConfig.setCustomModeType(customModeType);
|
||||
// livePusher.setConfig(livePushConfig);
|
||||
// return livePusher;
|
||||
// }
|
||||
//
|
||||
// private void ConstructList() {
|
||||
// mListData = new ArrayList<>();
|
||||
// for (int i = 0; i < AppConfig.mFilterName.length; ++i) {
|
||||
// ItemData4LvJing itemData = new ItemData4LvJing();
|
||||
// itemData.filterName = AppConfig.mFilterName[i];
|
||||
// itemData.filterType = AppConfig.mFilterType[i];
|
||||
// mListData.add(new HomeItemCell4LvJing(this, itemData, this));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onItemClick(String filtertype) {
|
||||
// if (TextUtils.isEmpty(filtertype))
|
||||
// return;
|
||||
//
|
||||
// if (filtertype.equals(mCurFilterStrength)) {
|
||||
// return;
|
||||
// }
|
||||
// mCurFilterStrength = filtertype;
|
||||
// mPreviewUtils.SetColorFilterByName(filtertype);
|
||||
// mPreviewUtils.SetColorFilterStrength(mFilterValue);
|
||||
// mAdapter.notifyDataSetChanged();
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getCurFilterType() {
|
||||
// return mCurFilterStrength;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// private void clearAllBuffer() {
|
||||
// if (mClear) return;
|
||||
// mClear = true;
|
||||
// mPreviewUtils.SetSkinColor(0, 0, 0);
|
||||
// mPreviewUtils.SetSkinSoftenStrength(0);
|
||||
// mPreviewUtils.SetColorFilterStrength(0);
|
||||
// }
|
||||
//
|
||||
// private void resetBuffer() {
|
||||
// mClear = false;
|
||||
// mPreviewUtils.SetSkinColor(mPinkValue, mWhitenValue, mReddenValue);
|
||||
// mPreviewUtils.SetSkinSoftenStrength(mSoftenValue);
|
||||
// mPreviewUtils.SetColorFilterStrength(mFilterValue);
|
||||
//
|
||||
// }
|
||||
//
|
||||
//}
|
||||
}
|
||||
@@ -0,0 +1,375 @@
|
||||
package com.yunbao.live.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
|
||||
public class Beauty360Activity3 extends Activity {
|
||||
// implements SurfaceHolder.Callback,
|
||||
// SurfaceTexture.OnFrameAvailableListener,
|
||||
// SeekBar.OnSeekBarChangeListener, Camera.PreviewCallback, MyItemClickListener, ITXLivePushListener {
|
||||
//
|
||||
// private static final String TAG = "PGSDKLive";
|
||||
// private float mPinkValue = 0.4f;
|
||||
// private float mWhitenValue = 0.7f;
|
||||
// private float mReddenValue = 0.5f;
|
||||
// private int mSoftenValue = 70;
|
||||
// private int mFilterValue = 100;
|
||||
// private boolean mClear = false;
|
||||
//
|
||||
// private RecyclerView mListView;
|
||||
// private MyRecycleAdapter4LvJing mAdapter;
|
||||
// private List<IRecycleCell> mListData;
|
||||
// private String mCurFilterStrength;
|
||||
//
|
||||
// private PreviewUtils mPreviewUtils;
|
||||
// private SurfaceView mSurfaceView;
|
||||
// private boolean mFirstFrame = true;
|
||||
//
|
||||
// private boolean isSticker = false;
|
||||
// private boolean zipSuccess = false;
|
||||
// Context mContext;
|
||||
// TextView tvSticker;
|
||||
// private OrientationEventListener mOrientationListener;
|
||||
//
|
||||
//
|
||||
// private TXLivePushConfig mLivePushConfig; // SDK 推流 config
|
||||
// private TXLivePusher mLivePusher; // SDK 推流类
|
||||
//
|
||||
// private int mCurrentVideoResolution = TXLiveConstants.VIDEO_RESOLUTION_TYPE_540_960; // 当前分辨率
|
||||
//// private boolean ; // 当前是否正在推流
|
||||
//
|
||||
// private String TMPURL = "rtmp://65652.livepush.myqcloud.com/live/test?txSecret=a33ac1d577e6dddfcdab70918497a3a7&txTime=5DBC567F";
|
||||
// @Override
|
||||
// protected void onCreate(Bundle savedInstanceState) {
|
||||
// super.onCreate(savedInstanceState);
|
||||
// setContentView(R.layout.activity_main2);
|
||||
// initPusher(); // 初始化 SDK 推流器
|
||||
// mContext = this;
|
||||
//
|
||||
// mPreviewUtils = new PreviewUtils(getApplicationContext(), this);
|
||||
// initViews();
|
||||
//
|
||||
// /**
|
||||
// * 贴纸zip 解压到本地
|
||||
// */
|
||||
// new UnzipAssets().unZipRequest(this, "TestSticker.zip", new UnzipAssets.IUnZipCallBack() {
|
||||
// @Override
|
||||
// public void onStart() {
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void Response(String outFileDirectory) {
|
||||
// zipSuccess = true;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError() {
|
||||
// }
|
||||
// });
|
||||
//
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public void initViews() {
|
||||
// mSurfaceView = (SurfaceView) findViewById(R.id.surface_view);
|
||||
//
|
||||
// SeekBar m_Seekpink = (SeekBar) findViewById(R.id.seek_pink);
|
||||
// m_Seekpink.setOnSeekBarChangeListener(this);
|
||||
// m_Seekpink.setProgress((int) (mPinkValue * 100));
|
||||
// TextView tv_pink = (TextView) findViewById(R.id.pink_value);
|
||||
// tv_pink.setText(String.valueOf(mPinkValue));
|
||||
//
|
||||
// SeekBar m_Seekwhiten = (SeekBar) findViewById(R.id.seek_whiten);
|
||||
// m_Seekwhiten.setOnSeekBarChangeListener(this);
|
||||
// m_Seekwhiten.setProgress((int) (mWhitenValue * 100));
|
||||
// TextView tv_whiten = (TextView) findViewById(R.id.whiten_value);
|
||||
// tv_whiten.setText(String.valueOf(mWhitenValue));
|
||||
//
|
||||
// SeekBar m_Seekredden = (SeekBar) findViewById(R.id.seek_redden);
|
||||
// m_Seekredden.setOnSeekBarChangeListener(this);
|
||||
// m_Seekredden.setProgress((int) (mReddenValue * 100));
|
||||
// TextView tv_redden = (TextView) findViewById(R.id.redden_value);
|
||||
// tv_redden.setText(String.valueOf(mReddenValue));
|
||||
//
|
||||
//
|
||||
// SeekBar m_Seeksoften = (SeekBar) findViewById(R.id.seek_soften);
|
||||
// m_Seeksoften.setOnSeekBarChangeListener(this);
|
||||
// m_Seeksoften.setProgress(mSoftenValue);
|
||||
// TextView tv_soften = (TextView) findViewById(R.id.soften_value);
|
||||
// tv_soften.setText(String.valueOf(mSoftenValue));
|
||||
//
|
||||
// SeekBar m_SeeksFilter = (SeekBar) findViewById(R.id.filter_redden);
|
||||
// m_SeeksFilter.setOnSeekBarChangeListener(this);
|
||||
// m_SeeksFilter.setProgress(mFilterValue);
|
||||
// TextView tv_filter = (TextView) findViewById(R.id.filter_value);
|
||||
// tv_filter.setText(String.valueOf(mFilterValue));
|
||||
//
|
||||
// tvSticker = (TextView) findViewById(R.id.tv_sticker);
|
||||
// tvSticker.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// if (!zipSuccess) return;
|
||||
// if (!isSticker) {
|
||||
// tvSticker.setText("取消贴纸");
|
||||
// isSticker = true;
|
||||
// mPreviewUtils.setSticker(AppConfig.STICKER_LOCAL_PATH + "TestSticker/dog");
|
||||
// startRTMPPush();
|
||||
// } else {
|
||||
// tvSticker.setText("贴纸");
|
||||
// isSticker = false;
|
||||
// mPreviewUtils.removeSticker();
|
||||
// stopRTMPPush();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// });
|
||||
// tvSticker.setVisibility(View.VISIBLE);
|
||||
//
|
||||
// View layoutSurface = findViewById(R.id.layout_surface);
|
||||
// layoutSurface.setOnTouchListener(new View.OnTouchListener() {
|
||||
// @Override
|
||||
// public boolean onTouch(View v, MotionEvent event) {
|
||||
// switch (event.getAction()) {
|
||||
// case MotionEvent.ACTION_DOWN:
|
||||
// case MotionEvent.ACTION_MOVE:
|
||||
// clearAllBuffer();
|
||||
// break;
|
||||
// case MotionEvent.ACTION_CANCEL:
|
||||
// case MotionEvent.ACTION_UP:
|
||||
// resetBuffer();
|
||||
// break;
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// mListView = (RecyclerView) findViewById(R.id.listview);
|
||||
// LinearLayoutManager mLayoutManager = new LinearLayoutManager(mListView.getContext(), LinearLayoutManager.HORIZONTAL, false);
|
||||
// mListView.setLayoutManager(mLayoutManager);
|
||||
// ConstructList();
|
||||
// mAdapter = new MyRecycleAdapter4LvJing(this, mListData);
|
||||
// mListView.setAdapter(mAdapter);
|
||||
// mListView.setItemAnimator(new DefaultItemAnimator());
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 初始化 SDK 推流器
|
||||
// */
|
||||
// private void initPusher() {
|
||||
// mLivePusher = new TXLivePusher(this);
|
||||
// mLivePushConfig = new TXLivePushConfig();
|
||||
// mLivePushConfig.setVideoEncodeGop(5);
|
||||
// // 添加播放回调
|
||||
// mLivePusher.setPushListener(this);
|
||||
// mLivePushConfig.setPauseImg(300, 5);
|
||||
// mLivePushConfig.setPauseFlag(TXLiveConstants.PAUSE_FLAG_PAUSE_VIDEO);// 设置暂停时,只停止画面采集,不停止声音采集。
|
||||
// // 设置推流分辨率
|
||||
// mLivePushConfig.setVideoResolution(mCurrentVideoResolution);
|
||||
// // 横竖屏推流相关
|
||||
// int renderRotation = 0;
|
||||
// mLivePushConfig.setHomeOrientation(TXLiveConstants.VIDEO_ANGLE_HOME_DOWN);
|
||||
// mLivePusher.setRenderRotation(renderRotation);
|
||||
// mLivePusher.setMirror(true);
|
||||
// mLivePushConfig.setWatermark(null, 0, 0, 0);
|
||||
// // 设置推流配置
|
||||
// mLivePusher.setConfig(mLivePushConfig);
|
||||
//
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onPushEvent(int event, Bundle param) {
|
||||
// String msg = param.getString(TXLiveConstants.EVT_DESCRIPTION);
|
||||
// String pushEventLog = "receive event: " + event + ", " + msg;//1001
|
||||
// Log.d(TAG, pushEventLog);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNetStatus(Bundle status) {
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void onResume() {
|
||||
// super.onResume();
|
||||
// mPreviewUtils.onresume();//启动照相机
|
||||
// reStartEngine();
|
||||
//
|
||||
// if (null == mOrientationListener) {
|
||||
// mOrientationListener = new OrientationEventListener(this) {
|
||||
// @Override
|
||||
// public void onOrientationChanged(int orientation) {
|
||||
// mPreviewUtils.onScreenOriChanged(orientation);
|
||||
// }
|
||||
// };
|
||||
// mOrientationListener.enable();
|
||||
// }
|
||||
//
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public void reStartEngine() {
|
||||
// DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
|
||||
// float fScreenHeight = displayMetrics.heightPixels;
|
||||
//
|
||||
// int iLayoutHeight = (int) fScreenHeight;//- (int)(fScreenHeight * 0.2f);
|
||||
// int iLayoutWidth = (int) ((iLayoutHeight / (float) mPreviewUtils.getCameraWidth()) * mPreviewUtils.getCameraHeight());
|
||||
//
|
||||
// mSurfaceView.getHolder().addCallback(this);
|
||||
//
|
||||
// ViewGroup.LayoutParams surfaceLayout;
|
||||
// surfaceLayout = mSurfaceView.getLayoutParams();
|
||||
// surfaceLayout.width = iLayoutWidth;
|
||||
// surfaceLayout.height = iLayoutHeight;
|
||||
// mSurfaceView.setLayoutParams(surfaceLayout);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// protected void onPause() {
|
||||
// super.onPause();
|
||||
// mPreviewUtils.pause();
|
||||
// mFirstFrame = true;
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void onStop() {
|
||||
// super.onStop();
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void onDestroy() {
|
||||
// super.onDestroy();
|
||||
// mPreviewUtils.freeRes();
|
||||
// stopRTMPPush(); // 停止推流
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// public void surfaceCreated(SurfaceHolder holder) {
|
||||
// mPreviewUtils.startCameraPreview(holder);//开始预览 绑定surface
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
|
||||
// mPreviewUtils.setCameraInfo(width, height);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void surfaceDestroyed(SurfaceHolder holder) {
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onFrameAvailable(SurfaceTexture surfaceTexture) {
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onPreviewFrame(byte[] data, Camera camera) {
|
||||
// mPreviewUtils.frameProcess(data, 0, mFirstFrame, false);//data 可以传空 根据TextureId进行美颜
|
||||
// mFirstFrame = false;
|
||||
// mLivePusher.sendCustomVideoData(mPreviewUtils.getSkinSoftenByte(), TXLivePusher.RGB_RGBA, mPreviewUtils.getCameraWidth(), mPreviewUtils.getCameraHeight());
|
||||
// }
|
||||
//
|
||||
// private void ConstructList() {
|
||||
// mListData = new ArrayList<>();
|
||||
// for (int i = 0; i < AppConfig.mFilterName.length; ++i) {
|
||||
// ItemData4LvJing itemData = new ItemData4LvJing();
|
||||
// itemData.filterName = AppConfig.mFilterName[i];
|
||||
// itemData.filterType = AppConfig.mFilterType[i];
|
||||
// mListData.add(new HomeItemCell4LvJing(this, itemData, this));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onItemClick(String filtertype) {
|
||||
// if (TextUtils.isEmpty(filtertype))
|
||||
// return;
|
||||
//
|
||||
// if (filtertype.equals(mCurFilterStrength)) {
|
||||
// return;
|
||||
// }
|
||||
// mCurFilterStrength = filtertype;
|
||||
// mPreviewUtils.SetColorFilterByName(filtertype);
|
||||
// mPreviewUtils.SetColorFilterStrength(mFilterValue);
|
||||
// mAdapter.notifyDataSetChanged();
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getCurFilterType() {
|
||||
// return mCurFilterStrength;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// private void clearAllBuffer() {
|
||||
// if (mClear) return;
|
||||
// mClear = true;
|
||||
// mPreviewUtils.SetSkinColor(0, 0, 0);
|
||||
// mPreviewUtils.SetSkinSoftenStrength(0);
|
||||
// mPreviewUtils.SetColorFilterStrength(0);
|
||||
// }
|
||||
//
|
||||
// private void resetBuffer() {
|
||||
// mClear = false;
|
||||
// mPreviewUtils.SetSkinColor(mPinkValue, mWhitenValue, mReddenValue);
|
||||
// mPreviewUtils.SetSkinSoftenStrength(mSoftenValue);
|
||||
// mPreviewUtils.SetColorFilterStrength(mFilterValue);
|
||||
//
|
||||
// }
|
||||
//
|
||||
// private boolean startRTMPPush() {
|
||||
// String tRTMPURL = "";
|
||||
// String inputUrl = TMPURL;
|
||||
// if (!TextUtils.isEmpty(inputUrl)) {
|
||||
// String url[] = inputUrl.split("###");
|
||||
// if (url.length > 0) {
|
||||
// tRTMPURL = url[0];
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (TextUtils.isEmpty(tRTMPURL) || (!tRTMPURL.trim().toLowerCase().startsWith("rtmp://"))) {
|
||||
// Toast.makeText(getApplicationContext(), "推流地址不合法,目前支持rtmp推流!", Toast.LENGTH_SHORT).show();
|
||||
// Bundle params = new Bundle();
|
||||
// params.putString(TXLiveConstants.EVT_DESCRIPTION, "检查地址合法性");
|
||||
// return false;
|
||||
// }
|
||||
// // 输出状态log
|
||||
// Bundle params = new Bundle();
|
||||
// params.putString(TXLiveConstants.EVT_DESCRIPTION, "检查地址合法性");
|
||||
// // 发起推流
|
||||
// int ret = mLivePusher.startPusher(tRTMPURL.trim());
|
||||
// Log.d("发起推流","ret="+ret);
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 停止 RTMP 推流
|
||||
// */
|
||||
// private void stopRTMPPush() {
|
||||
// mLivePusher.stopBGM();
|
||||
// mLivePusher.stopCameraPreview(true);
|
||||
// mLivePusher.setPushListener(null);
|
||||
// mLivePusher.stopPusher();
|
||||
// // 移除垫片图像
|
||||
// mLivePushConfig.setPauseImg(null);
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
package com.yunbao.live.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Outline;
|
||||
import android.text.format.DateUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewOutlineProvider;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.blankj.utilcode.util.StringUtils;
|
||||
import com.ms.banner.Banner;
|
||||
import com.ms.banner.BannerConfig;
|
||||
import com.ms.banner.listener.OnBannerClickListener;
|
||||
import com.umeng.analytics.MobclickAgent;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.bean.IMLoginModel;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.common.views.TopGradual;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.adapter.MsgSysGiftAdapter;
|
||||
import com.yunbao.live.bean.MsgSysGiftInfoBean;
|
||||
import com.yunbao.live.bean.SlideBean;
|
||||
import com.yunbao.live.bean.SystemMessageBean;
|
||||
import com.yunbao.live.http.ImHttpUtil;
|
||||
import com.yunbao.live.views.CustomMyViewHolder;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Route(path = RouteUtil.PATH_COMPENSATE_ACTIVITY)
|
||||
public class CompensateActivity extends AbsActivity {
|
||||
|
||||
TextView content;
|
||||
TextView time;
|
||||
RecyclerView recyclerView;
|
||||
MsgSysGiftAdapter msgSysGiftAdapter;
|
||||
String msgId, mBanner, mContent, link;
|
||||
Button submit;
|
||||
|
||||
ImageView imgContent;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_compensate;
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void refreshStatus(SystemMessageBean systemMessageBean) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
setTitle(getIntent().getStringExtra("title"));
|
||||
EventBus.getDefault().register(this);
|
||||
content = findViewById(R.id.content);
|
||||
submit = findViewById(R.id.submit);
|
||||
time = findViewById(R.id.time);
|
||||
imgContent = findViewById(R.id.img_content);
|
||||
|
||||
recyclerView = findViewById(R.id.hor_recycler);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false));
|
||||
recyclerView.addItemDecoration(new TopGradual());
|
||||
|
||||
msgSysGiftAdapter = new MsgSysGiftAdapter(mContext);
|
||||
|
||||
recyclerView.setAdapter(msgSysGiftAdapter);
|
||||
|
||||
msgId = getIntent().getStringExtra("msgid");
|
||||
mBanner = getIntent().getStringExtra("banner");
|
||||
mContent = getIntent().getStringExtra("content");
|
||||
link = getIntent().getStringExtra("link");
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy" + getString(R.string.sys_msg_year) + "MM" + getString(R.string.sys_msg_month) + "dd" + getString(R.string.sys_msg_day) + " HH:mm");
|
||||
Date currenTimeZone = new Date(Long.parseLong(getIntent().getStringExtra("time") + "000"));
|
||||
time.setText(sdf.format(currenTimeZone));
|
||||
|
||||
content.setText(mContent);
|
||||
if (!getIntent().getBooleanExtra("receive", false)) {
|
||||
submit.setBackground(mContext.getDrawable(R.mipmap.icon_sys_received));
|
||||
submit.setText(getString(R.string.receive2));
|
||||
submit.setTextColor(mContext.getResources().getColor(R.color.gray_F4F4F4));
|
||||
}
|
||||
submit.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ImHttpUtil.receiveGift(msgId, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
SystemMessageBean systemMessageBean = new SystemMessageBean();
|
||||
systemMessageBean.setId(msgId);
|
||||
EventBus.getDefault().post(systemMessageBean);
|
||||
submit.setBackground(mContext.getDrawable(R.mipmap.icon_sys_received));
|
||||
submit.setText(getString(R.string.receive2));
|
||||
submit.setTextColor(mContext.getResources().getColor(R.color.gray_F4F4F4));
|
||||
ToastUtil.show(msg);
|
||||
} else {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
getMessageGiftInfo();
|
||||
|
||||
if (!StringUtils.isEmpty(mBanner)) {
|
||||
ImgLoader.display(mContext, mBanner, imgContent);
|
||||
findViewById(R.id.lt_advertisement).setVisibility(View.VISIBLE);
|
||||
|
||||
if (!StringUtils.isEmpty(link)) {
|
||||
IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo();
|
||||
StringBuffer urlBuffer = new StringBuffer();
|
||||
urlBuffer.append(link).append("&uid=").append(userInfo.getId()).append("&token=").append(userInfo.getToken()).append("&isZh=").append(WordUtil.isNewZh() ? "1" : 0);
|
||||
|
||||
findViewById(R.id.lt_advertisement).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mContext.startActivity(new Intent(mContext, ZhuangBanActivity.class).putExtra("url", urlBuffer.toString()));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void getMessageGiftInfo() {
|
||||
ImHttpUtil.getMessageGiftInfo(msgId, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
List<MsgSysGiftInfoBean> list = JSON.parseArray(Arrays.toString(info), MsgSysGiftInfoBean.class);
|
||||
msgSysGiftAdapter.setList(list);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package com.yunbao.live.activity;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.text.InputFilter;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.blankj.utilcode.util.GsonUtils;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.http.CommonHttpUtil;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.manager.InstructorRemarkManager;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.bean.SearchUserBean;
|
||||
import com.yunbao.common.http.LiveHttpUtil;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import io.rong.imkit.userinfo.RongUserInfoManager;
|
||||
import io.rong.imlib.model.UserInfo;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Chen Haoxuan on 2022/7/1.
|
||||
* 修改备注
|
||||
*/
|
||||
|
||||
public class EditNameRemarksActivity extends AbsActivity implements View.OnClickListener {
|
||||
|
||||
private EditText mEditText;
|
||||
private String userId;
|
||||
public final static String NAMEREMARK = "NameRemark";
|
||||
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_edit_remarks;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
setTitle(mContext.getString(R.string.edit_profile_update_remarks));
|
||||
userId = getIntent().getStringExtra(NAMEREMARK);
|
||||
mEditText = (EditText) findViewById(R.id.edit);
|
||||
mEditText.setFilters(new InputFilter[]{
|
||||
new InputFilter.LengthFilter(10)
|
||||
});
|
||||
findViewById(R.id.btn_save).setOnClickListener(this);
|
||||
String content = InstructorRemarkManager.get(mContext).getInstructorRemark().get(userId);
|
||||
if (!TextUtils.isEmpty(content)) {
|
||||
mEditText.setText(content);
|
||||
mEditText.setSelection(content.length());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (!canClick()) {
|
||||
return;
|
||||
}
|
||||
final String content = mEditText.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(content)) {
|
||||
//获取用户信息
|
||||
UserInfo userInfo = RongUserInfoManager.getInstance().getUserInfo(userId);
|
||||
if (null != userInfo && !TextUtils.isEmpty(userInfo.getExtra())) {
|
||||
SearchUserBean userBean = GsonUtils.fromJson(userInfo.getExtra(), SearchUserBean.class);
|
||||
LiveHttpUtil.setInstructorRemark(userId, content, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
ToastUtil.show(msg);
|
||||
if (code == 0) {
|
||||
InstructorRemarkManager.get(mContext).removeInstructorRemark(userId);
|
||||
//刷新列表内用户信息
|
||||
addUserInfoProvider(userBean.getUserNiceName());
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
LiveHttpUtil.setInstructorRemark(userId, content, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
ToastUtil.show(msg);
|
||||
if (code == 0) {
|
||||
InstructorRemarkManager.get(mContext).addInstructorRemark(userId, content);
|
||||
//刷新列表内用户信息
|
||||
addUserInfoProvider(content);
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新用户信息
|
||||
*/
|
||||
public void addUserInfoProvider(String remark) {
|
||||
CommonHttpUtil.getUserBaseinfo(userId, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
JSONObject obj = JSON.parseObject(info[0]);
|
||||
SearchUserBean userBean = JSON.toJavaObject(obj, SearchUserBean.class);
|
||||
String userNiceName = remark;
|
||||
UserInfo userInfo = new UserInfo(userId, userNiceName, Uri.parse(userBean.getAvatar()));
|
||||
//使用空白字段存储自己服务器用户的所有的信息
|
||||
userInfo.setExtra(GsonUtils.toJson(userBean));
|
||||
RongUserInfoManager.getInstance().refreshUserInfoCache(userInfo);
|
||||
EventBus.getDefault().post(userNiceName);
|
||||
finish();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.yunbao.live.activity;
|
||||
|
||||
import android.app.PictureInPictureParams;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Build;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.live.R;
|
||||
|
||||
/**
|
||||
* 画中画act
|
||||
*/
|
||||
public class FALiveRoomInOneActivity extends AbsActivity {
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.view_flaot_live;
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
@Override
|
||||
public void main() {
|
||||
super.init();
|
||||
PictureInPictureParams params = new PictureInPictureParams.Builder()
|
||||
.build();
|
||||
enterPictureInPictureMode(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode, Configuration newConfig) {
|
||||
super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
package com.yunbao.live.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.makeramen.roundedimageview.RoundedImageView;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.event.GiftWallItemEvent;
|
||||
import com.yunbao.common.event.LiveGiftDialogEvent;
|
||||
import com.yunbao.common.fragment.AllServiceChampionFragment;
|
||||
import com.yunbao.common.fragment.GiftWithoutWallFragment;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.dialog.CodexDialog;
|
||||
import com.yunbao.live.dialog.GiftWallItemPopup;
|
||||
import com.yunbao.live.dialog.MedalAchievementPopup;
|
||||
import com.yunbao.live.views.GiftAlreadyWallFragment;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Route(path = RouteUtil.PATH_GIFT_WALL)
|
||||
public class GiftWallActivity extends AbsActivity {
|
||||
private LinearLayout layoutLitIcon, layoutUnlitIcon, layoutAllServiceChampion;
|
||||
private TextView textLitIcon, textUnlitIcon, textAllServiceChampion, anchorName;
|
||||
private View viewAllServiceChampion, viewUnlitIcon, viewLitIcon;
|
||||
private RoundedImageView avatar;
|
||||
private List<TextView> tabText = new ArrayList<>();
|
||||
private List<View> tabView = new ArrayList<>();
|
||||
private String mStream, mAnchorName, mLiveUid, mAvatarUrl;
|
||||
private int isAttention = 0;//是否关注 0=没关注,
|
||||
private boolean isLive;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_live_gift_wall;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
Bus.getOn(this);
|
||||
initView();
|
||||
initDate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
Bus.getOff(this);
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
layoutLitIcon = findViewById(R.id.layout_lit_icon);
|
||||
layoutUnlitIcon = findViewById(R.id.layout_unlit_icon);
|
||||
layoutAllServiceChampion = findViewById(R.id.layout_all_service_champion);
|
||||
textLitIcon = findViewById(R.id.text_lit_icon);
|
||||
textUnlitIcon = findViewById(R.id.text_unlit_icon);
|
||||
textAllServiceChampion = findViewById(R.id.text_all_service_champion);
|
||||
viewAllServiceChampion = findViewById(R.id.view_all_service_champion);
|
||||
viewUnlitIcon = findViewById(R.id.view_unlit_icon);
|
||||
viewLitIcon = findViewById(R.id.view_lit_icon);
|
||||
avatar = findViewById(R.id.avatar);
|
||||
anchorName = findViewById(R.id.anchor_name);
|
||||
tabText.add(textLitIcon);
|
||||
tabText.add(textUnlitIcon);
|
||||
tabText.add(textAllServiceChampion);
|
||||
tabView.add(viewLitIcon);
|
||||
tabView.add(viewUnlitIcon);
|
||||
tabView.add(viewAllServiceChampion);
|
||||
selectTab(textLitIcon, viewLitIcon);
|
||||
ViewClicksAntiShake.clicksAntiShake(layoutLitIcon, () -> {
|
||||
selectTab(textLitIcon, viewLitIcon);
|
||||
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||
transaction.replace(R.id.context_layout_gift, GiftAlreadyWallFragment.newInstance(mStream, mLiveUid, mLiveUid, isLive,false));
|
||||
transaction.commit();
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(layoutUnlitIcon, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
selectTab(textUnlitIcon, viewUnlitIcon);
|
||||
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||
transaction.replace(R.id.context_layout_gift, GiftWithoutWallFragment.newInstance(mStream, mLiveUid, mLiveUid));
|
||||
transaction.commit();
|
||||
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(layoutAllServiceChampion, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
selectTab(textAllServiceChampion, viewAllServiceChampion);
|
||||
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||
transaction.replace(R.id.context_layout_gift, AllServiceChampionFragment.newInstance(mStream, mLiveUid));
|
||||
transaction.commit();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.codex_layout), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
new XPopup.Builder(GiftWallActivity.this)
|
||||
.enableDrag(false)
|
||||
.asCustom(new CodexDialog(GiftWallActivity.this, mStream, mLiveUid, mLiveUid,false,false))
|
||||
.show();
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.medal_achievement), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
new XPopup.Builder(GiftWallActivity.this)
|
||||
.enableDrag(false)
|
||||
.asCustom(new MedalAchievementPopup(GiftWallActivity.this, isLive, mLiveUid, mLiveUid))
|
||||
.show();
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(avatar, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
forwardHomePage();
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(anchorName, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
forwardHomePage();
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.close_btn), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initDate() {
|
||||
Intent intent = getIntent();
|
||||
if (intent == null) {
|
||||
return;
|
||||
}
|
||||
mLiveUid = intent.getStringExtra(Constants.LIVE_UID);
|
||||
mStream = intent.getStringExtra(Constants.STREAM);
|
||||
mAnchorName = intent.getStringExtra("mAnchorName");
|
||||
mAvatarUrl = intent.getStringExtra("mAvatarUrl");
|
||||
isAttention = intent.getIntExtra("isAttention", 0);
|
||||
isLive = intent.getBooleanExtra("isLive", false);
|
||||
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||
transaction.replace(R.id.context_layout_gift, GiftAlreadyWallFragment.newInstance(mStream, mLiveUid, mLiveUid, isLive, false));
|
||||
transaction.commit();
|
||||
ImgLoader.display(GiftWallActivity.this, mAvatarUrl, avatar);
|
||||
anchorName.setText(mAnchorName);
|
||||
if (isLive) {
|
||||
textLitIcon.setText(getString(R.string.lit_icon));
|
||||
} else {
|
||||
textLitIcon.setText(getString(R.string.been_sent));
|
||||
}
|
||||
}
|
||||
|
||||
private void selectTab(TextView textView, View tab) {
|
||||
for (TextView view : tabText) {
|
||||
if (textView == view) {
|
||||
view.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD_ITALIC);
|
||||
} else {
|
||||
view.setTypeface(Typeface.SANS_SERIF, Typeface.ITALIC);
|
||||
}
|
||||
}
|
||||
for (View view : tabView) {
|
||||
view.setVisibility(view == tab ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void forwardHomePage() {
|
||||
finish();
|
||||
RouteUtil.forwardUserHome(mContext, mLiveUid, false, mLiveUid, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关于点击礼物分类的通知
|
||||
*/
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onGiftWallItemEvent(GiftWallItemEvent event) {
|
||||
new XPopup.Builder(this)
|
||||
.asCustom(new GiftWallItemPopup(this, event.getGiftWallModel(), event.isUnlit(), mLiveUid, mLiveUid, mStream, false,event.isCsb()))
|
||||
.show();
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onLiveGiftDialogEvent(LiveGiftDialogEvent event) {
|
||||
ToastUtil.show(getString(R.string.the__gifts_in_the_studio));
|
||||
}
|
||||
}
|
||||
1688
live/src/main/java/com/yunbao/live/activity/LiveActivity.java
Normal file
1688
live/src/main/java/com/yunbao/live/activity/LiveActivity.java
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,48 @@
|
||||
package com.yunbao.live.activity;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.views.LiveAddImpressViewHolder;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/10/15.
|
||||
* 添加印象
|
||||
*/
|
||||
|
||||
public class LiveAddImpressActivity extends AbsActivity {
|
||||
|
||||
private LiveAddImpressViewHolder mLiveAddImpressViewHolder;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_empty;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
String toUid = getIntent().getStringExtra(Constants.TO_UID);
|
||||
if (TextUtils.isEmpty(toUid)) {
|
||||
return;
|
||||
}
|
||||
mLiveAddImpressViewHolder = new LiveAddImpressViewHolder(mContext, (ViewGroup) findViewById(R.id.container));
|
||||
mLiveAddImpressViewHolder.subscribeActivityLifeCycle();
|
||||
mLiveAddImpressViewHolder.addToParent();
|
||||
mLiveAddImpressViewHolder.setToUid(toUid);
|
||||
mLiveAddImpressViewHolder.loadData();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (mLiveAddImpressViewHolder != null && mLiveAddImpressViewHolder.isUpdatedImpress()) {
|
||||
setResult(RESULT_OK);
|
||||
finish();
|
||||
} else {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.yunbao.live.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.views.LiveAdminListViewHolder;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2019/4/27.
|
||||
*/
|
||||
|
||||
public class LiveAdminListActivity extends AbsActivity {
|
||||
|
||||
public static void forward(Context context, String liveUid) {
|
||||
Intent intent = new Intent(context, LiveAdminListActivity.class);
|
||||
intent.putExtra(Constants.LIVE_UID, liveUid);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_live_admin_list;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
String liveUid = getIntent().getStringExtra(Constants.LIVE_UID);
|
||||
if (TextUtils.isEmpty(liveUid)) {
|
||||
return;
|
||||
}
|
||||
LiveAdminListViewHolder liveAdminListViewHolder = new LiveAdminListViewHolder(mContext, (ViewGroup) findViewById(R.id.container), liveUid);
|
||||
liveAdminListViewHolder.addToParent();
|
||||
liveAdminListViewHolder.subscribeActivityLifeCycle();
|
||||
liveAdminListViewHolder.loadData();
|
||||
}
|
||||
}
|
||||
1113
live/src/main/java/com/yunbao/live/activity/LiveAnchorActivity.java
Normal file
1113
live/src/main/java/com/yunbao/live/activity/LiveAnchorActivity.java
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,123 @@
|
||||
package com.yunbao.live.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.adapter.RefreshAdapter;
|
||||
import com.yunbao.common.custom.CommonRefreshView;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.adapter.LiveBlackAdapter;
|
||||
import com.yunbao.live.bean.LiveShutUpBean;
|
||||
import com.yunbao.common.http.LiveHttpConsts;
|
||||
import com.yunbao.common.http.LiveHttpUtil;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2019/4/27.
|
||||
* 直播间拉黑用户列表
|
||||
*/
|
||||
|
||||
public class LiveBlackActivity extends AbsActivity implements OnItemClickListener<LiveShutUpBean> {
|
||||
|
||||
|
||||
public static void forward(Context context, String liveUid) {
|
||||
Intent intent = new Intent(context, LiveBlackActivity.class);
|
||||
intent.putExtra(Constants.LIVE_UID, liveUid);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
private CommonRefreshView mRefreshView;
|
||||
private LiveBlackAdapter mAdapter;
|
||||
private String mLiveUid;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_shut_up;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
setTitle(mContext.getString(R.string.live_user_black_list));
|
||||
mLiveUid = getIntent().getStringExtra(Constants.LIVE_UID);
|
||||
if (TextUtils.isEmpty(mLiveUid)) {
|
||||
return;
|
||||
}
|
||||
mRefreshView = findViewById(R.id.refreshView);
|
||||
mRefreshView.setEmptyLayoutId(R.layout.view_no_data_black);
|
||||
mRefreshView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
|
||||
mRefreshView.setDataHelper(new CommonRefreshView.DataHelper<LiveShutUpBean>() {
|
||||
@Override
|
||||
public RefreshAdapter<LiveShutUpBean> getAdapter() {
|
||||
if (mAdapter == null) {
|
||||
mAdapter = new LiveBlackAdapter(mContext);
|
||||
mAdapter.setOnItemClickListener(LiveBlackActivity.this);
|
||||
}
|
||||
return mAdapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadData(int p, HttpCallback callback) {
|
||||
LiveHttpUtil.getLiveBlackList(mLiveUid, p, callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LiveShutUpBean> processData(String[] info) {
|
||||
return JSON.parseArray(Arrays.toString(info), LiveShutUpBean.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefreshSuccess(List<LiveShutUpBean> list, int listCount) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefreshFailure() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadMoreSuccess(List<LiveShutUpBean> loadItemList, int loadItemCount) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadMoreFailure() {
|
||||
|
||||
}
|
||||
});
|
||||
mRefreshView.initData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(final LiveShutUpBean bean, int position) {
|
||||
LiveHttpUtil.liveCancelBlack(mLiveUid, bean.getUid(), new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
if (mAdapter != null) {
|
||||
mAdapter.removeItem(bean.getUid());
|
||||
}
|
||||
}
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
LiveHttpUtil.cancel(LiveHttpConsts.GET_LIVE_BLACK_LIST);
|
||||
LiveHttpUtil.cancel(LiveHttpConsts.LIVE_CANCEL_BLACK);
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.yunbao.live.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.bean.ConfigBean;
|
||||
import com.yunbao.common.bean.LiveClassBean;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.adapter.LiveReadyClassAdapter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/10/7.
|
||||
* 选择直播频道
|
||||
*/
|
||||
|
||||
public class LiveChooseClassActivity extends AbsActivity implements OnItemClickListener<LiveClassBean> {
|
||||
|
||||
private RecyclerView mRecyclerView;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_live_choose_class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
setTitle(mContext.getString(R.string.live_class_choose));
|
||||
mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView);
|
||||
mRecyclerView.setHasFixedSize(true);
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
|
||||
final int checkedClassId = getIntent().getIntExtra(Constants.CLASS_ID, 0);
|
||||
CommonAppConfig.getInstance().getConfig(new CommonCallback<ConfigBean>() {
|
||||
@Override
|
||||
public void callback(ConfigBean configBean) {
|
||||
if (configBean != null) {
|
||||
List<LiveClassBean> list1 = configBean.getLiveClass();
|
||||
List<LiveClassBean> list = new ArrayList<>();
|
||||
for(int i = 0; i < list1.size(); i++) {
|
||||
if(!list1.get(i).getName().equals("New")&&!list1.get(i).getName().equals("Hot")&&!list1.get(i).getName().equals("熱門")&&!list1.get(i).getName().equals("新秀")){
|
||||
list.add(list1.get(i));
|
||||
}
|
||||
}
|
||||
if (list == null) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0, size = list.size(); i < size; i++) {
|
||||
LiveClassBean bean = list.get(i);
|
||||
if (bean.getId() == checkedClassId) {
|
||||
bean.setChecked(true);
|
||||
} else {
|
||||
bean.setChecked(false);
|
||||
}
|
||||
}
|
||||
LiveReadyClassAdapter adapter = new LiveReadyClassAdapter(mContext, list);
|
||||
adapter.setOnItemClickListener(LiveChooseClassActivity.this);
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onItemClick(LiveClassBean bean, int position) {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(Constants.CLASS_ID, bean.getId());
|
||||
intent.putExtra(Constants.CLASS_NAME, bean.getName());
|
||||
setResult(RESULT_OK, intent);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.yunbao.live.activity;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.views.LiveContributeViewHolder;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/10/19.
|
||||
*/
|
||||
|
||||
public class LiveContributeActivity extends AbsActivity {
|
||||
|
||||
private LiveContributeViewHolder mLiveContributeViewHolder;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_empty;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
String toUid = getIntent().getStringExtra(Constants.TO_UID);
|
||||
if (TextUtils.isEmpty(toUid)) {
|
||||
return;
|
||||
}
|
||||
mLiveContributeViewHolder = new LiveContributeViewHolder(mContext, (ViewGroup) findViewById(R.id.container), toUid);
|
||||
mLiveContributeViewHolder.addToParent();
|
||||
mLiveContributeViewHolder.loadData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
if(mLiveContributeViewHolder!=null){
|
||||
mLiveContributeViewHolder.release();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package com.yunbao.live.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.adapter.RefreshAdapter;
|
||||
import com.yunbao.common.custom.CommonRefreshView;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.live.adapter.GuardAdapter;
|
||||
import com.yunbao.live.bean.GuardUserBean;
|
||||
import com.yunbao.common.http.LiveHttpConsts;
|
||||
import com.yunbao.common.http.LiveHttpUtil;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/11/15.
|
||||
*/
|
||||
|
||||
public class LiveGuardListActivity extends AbsActivity {
|
||||
|
||||
public static void forward(Context context, String toUid) {
|
||||
Intent intent = new Intent(context, LiveGuardListActivity.class);
|
||||
intent.putExtra(Constants.TO_UID, toUid);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
private CommonRefreshView mRefreshView;
|
||||
private GuardAdapter mGuardAdapter;
|
||||
private String mToUid;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_guard_list;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
setTitle(mContext.getString(R.string.guard_list));
|
||||
mToUid = getIntent().getStringExtra(Constants.TO_UID);
|
||||
if (TextUtils.isEmpty(mToUid)) {
|
||||
return;
|
||||
}
|
||||
mRefreshView = findViewById(R.id.refreshView);
|
||||
boolean self = mToUid.equals(CommonAppConfig.getInstance().getUid());
|
||||
mRefreshView.setEmptyLayoutId(self ? R.layout.view_no_data_guard_anc_2 : R.layout.view_no_data_guard_aud_2);
|
||||
mRefreshView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
|
||||
mRefreshView.setDataHelper(new CommonRefreshView.DataHelper<GuardUserBean>() {
|
||||
@Override
|
||||
public RefreshAdapter<GuardUserBean> getAdapter() {
|
||||
if (mGuardAdapter == null) {
|
||||
mGuardAdapter = new GuardAdapter(mContext, false);
|
||||
}
|
||||
return mGuardAdapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadData(int p, HttpCallback callback) {
|
||||
LiveHttpUtil.getGuardList(mToUid, p, callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GuardUserBean> processData(String[] info) {
|
||||
return JSON.parseArray(Arrays.toString(info), GuardUserBean.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefreshSuccess(List<GuardUserBean> list, int listCount) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefreshFailure() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadMoreSuccess(List<GuardUserBean> loadItemList, int loadItemCount) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadMoreFailure() {
|
||||
|
||||
}
|
||||
});
|
||||
mRefreshView.initData();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
LiveHttpUtil.cancel(LiveHttpConsts.GET_GUARD_LIST);
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.yunbao.live.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.views.LiveRecordViewHolder;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/9/30.
|
||||
*/
|
||||
|
||||
public class LiveRecordActivity extends AbsActivity {
|
||||
|
||||
public static void forward(Context context, UserBean userBean) {
|
||||
if (userBean == null) {
|
||||
return;
|
||||
}
|
||||
Intent intent = new Intent(context, LiveRecordActivity.class);
|
||||
intent.putExtra(Constants.USER_BEAN, userBean);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
private UserBean mUserBean;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_live_record;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
setTitle(mContext.getString(R.string.live_record));
|
||||
mUserBean = getIntent().getParcelableExtra(Constants.USER_BEAN);
|
||||
if (mUserBean == null) {
|
||||
return;
|
||||
}
|
||||
LiveRecordViewHolder liveRecordViewHolder = new LiveRecordViewHolder(mContext, (ViewGroup) findViewById(R.id.container),mUserBean.getId());
|
||||
liveRecordViewHolder.setActionListener(new LiveRecordViewHolder.ActionListener() {
|
||||
@Override
|
||||
public UserBean getUserBean() {
|
||||
return mUserBean;
|
||||
}
|
||||
});
|
||||
liveRecordViewHolder.addToParent();
|
||||
liveRecordViewHolder.subscribeActivityLifeCycle();
|
||||
liveRecordViewHolder.loadData();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,290 @@
|
||||
package com.yunbao.live.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.bean.NewLevelModel;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.CommonHttpUtil;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.manager.NewLevelManager;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.bean.SearchUserBean;
|
||||
import com.yunbao.live.dialog.LiveShareDialogFragment;
|
||||
import com.yunbao.live.presenter.UserHomeSharePresenter;
|
||||
import com.yunbao.live.views.LiveRecordPlayViewHolder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/10/29.
|
||||
*/
|
||||
|
||||
public class LiveRecordPlayActivity extends AbsActivity implements
|
||||
LiveRecordPlayViewHolder.ActionListener, View.OnClickListener, LiveShareDialogFragment.ActionListener {
|
||||
|
||||
private LiveRecordPlayViewHolder mLiveRecordPlayViewHolder;
|
||||
private ImageView mAvatar;
|
||||
private ImageView mLevelAnchor;
|
||||
private TextView mName;
|
||||
private TextView mID;
|
||||
private View mBtnFollow;
|
||||
private SeekBar mSeekBar;
|
||||
private long mDuration;
|
||||
private TextView mCurTimeTextView;
|
||||
private TextView mDurationTextView;
|
||||
private ImageView mBtnPlay;
|
||||
private UserBean mUserBean;
|
||||
private UserHomeSharePresenter mUserHomeSharePresenter;
|
||||
private boolean mPausePlay;
|
||||
|
||||
public static void forward(Context context, String url, UserBean userBean) {
|
||||
if (TextUtils.isEmpty(url) || userBean == null) {
|
||||
return;
|
||||
}
|
||||
Intent intent = new Intent(context, LiveRecordPlayActivity.class);
|
||||
intent.putExtra(Constants.URL, url);
|
||||
intent.putExtra(Constants.USER_BEAN, userBean);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_live_record_play;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isStatusBarWhite() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
Intent intent = getIntent();
|
||||
mUserBean = intent.getParcelableExtra(Constants.USER_BEAN);
|
||||
if (mUserBean == null) {
|
||||
return;
|
||||
}
|
||||
String url = intent.getStringExtra(Constants.URL);
|
||||
if (TextUtils.isEmpty(url)) {
|
||||
return;
|
||||
}
|
||||
mAvatar = (ImageView) findViewById(R.id.avatar);
|
||||
mLevelAnchor = (ImageView) findViewById(R.id.level_anchor);
|
||||
mName = (TextView) findViewById(R.id.name);
|
||||
mID = (TextView) findViewById(R.id.id_val);
|
||||
mBtnFollow = findViewById(R.id.btn_follow);
|
||||
ImgLoader.displayAvatar(mContext, mUserBean.getAvatar(), mAvatar);
|
||||
List<NewLevelModel> models = new NewLevelManager(mContext).getNewAnchorLevelModels();
|
||||
String imgUrl = "";
|
||||
for (NewLevelModel newLevelModel : models) {
|
||||
if (newLevelModel.getLeveMin() <= mUserBean.getLevelAnchor() && mUserBean.getLevelAnchor() <= newLevelModel.getLeveMax()) {
|
||||
imgUrl = newLevelModel.getIcon();
|
||||
}
|
||||
ImgLoader.display(mContext, imgUrl, mLevelAnchor);
|
||||
}
|
||||
mName.setText(mUserBean.getUserNiceName());
|
||||
mID.setText(mUserBean.getLiangNameTip());
|
||||
if (mUserBean instanceof SearchUserBean) {
|
||||
SearchUserBean searchUserBean = (SearchUserBean) mUserBean;
|
||||
int attention = searchUserBean.getAttention();
|
||||
if (attention == 0) {
|
||||
if (mBtnFollow.getVisibility() != View.VISIBLE) {
|
||||
mBtnFollow.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
mBtnFollow.setOnClickListener(this);
|
||||
}
|
||||
mUserHomeSharePresenter = new UserHomeSharePresenter(mContext);
|
||||
mUserHomeSharePresenter.setToUid(mUserBean.getId())
|
||||
.setToName(mUserBean.getUserNiceName())
|
||||
.setAvatarThumb(mUserBean.getAvatarThumb())
|
||||
.setFansNum(String.valueOf(mUserBean.getFans()));
|
||||
findViewById(R.id.btn_back).setOnClickListener(this);
|
||||
findViewById(R.id.btn_share).setOnClickListener(this);
|
||||
mBtnPlay = findViewById(R.id.btn_play);
|
||||
mBtnPlay.setOnClickListener(this);
|
||||
mSeekBar = (SeekBar) findViewById(R.id.seek_bar);
|
||||
mSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
if (mLiveRecordPlayViewHolder != null) {
|
||||
mLiveRecordPlayViewHolder.clickResume();
|
||||
int progress = seekBar.getProgress();
|
||||
mLiveRecordPlayViewHolder.seekTo(mDuration * progress / 100000f);
|
||||
}
|
||||
}
|
||||
});
|
||||
mCurTimeTextView = findViewById(R.id.cur_time);
|
||||
mDurationTextView = findViewById(R.id.duration);
|
||||
ViewGroup container = (ViewGroup) findViewById(R.id.container);
|
||||
mLiveRecordPlayViewHolder = new LiveRecordPlayViewHolder(mContext, container);
|
||||
mLiveRecordPlayViewHolder.setActionListener(this);
|
||||
mLiveRecordPlayViewHolder.subscribeActivityLifeCycle();
|
||||
mLiveRecordPlayViewHolder.addToParent();
|
||||
mLiveRecordPlayViewHolder.play(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
if (mLiveRecordPlayViewHolder != null) {
|
||||
mLiveRecordPlayViewHolder.release();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
if (mLiveRecordPlayViewHolder != null) {
|
||||
mLiveRecordPlayViewHolder.release();
|
||||
}
|
||||
if (mUserHomeSharePresenter != null) {
|
||||
mUserHomeSharePresenter.release();
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgress(int progress) {
|
||||
if (mSeekBar != null) {
|
||||
mSeekBar.setProgress(progress);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDuration(long duration) {
|
||||
mDuration = duration;
|
||||
if (mDurationTextView != null) {
|
||||
mDurationTextView.setText(StringUtil.getDurationText(duration));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCurTime(long curTime) {
|
||||
if (mCurTimeTextView != null) {
|
||||
mCurTimeTextView.setText(StringUtil.getDurationText(curTime));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClickPause() {
|
||||
if (mBtnPlay != null) {
|
||||
mBtnPlay.setImageResource(R.mipmap.icon_live_record_play);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClickResume() {
|
||||
if (mBtnPlay != null) {
|
||||
mBtnPlay.setImageResource(R.mipmap.icon_live_record_pause);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int i = v.getId();
|
||||
if (i == R.id.btn_back) {
|
||||
onBackPressed();
|
||||
|
||||
} else if (i == R.id.btn_share) {
|
||||
share();
|
||||
|
||||
} else if (i == R.id.btn_play) {
|
||||
togglePlay();
|
||||
|
||||
} else if (i == R.id.btn_follow) {
|
||||
follow();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换播放暂停
|
||||
*/
|
||||
private void togglePlay() {
|
||||
if (mLiveRecordPlayViewHolder != null) {
|
||||
if (mPausePlay) {
|
||||
mLiveRecordPlayViewHolder.clickResume();
|
||||
} else {
|
||||
mLiveRecordPlayViewHolder.clickPause();
|
||||
}
|
||||
mPausePlay = !mPausePlay;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 关注主播
|
||||
*/
|
||||
private void follow() {
|
||||
if (mUserBean == null) {
|
||||
return;
|
||||
}
|
||||
CommonHttpUtil.setAttention(mUserBean.getId(), new CommonCallback<Integer>() {
|
||||
@Override
|
||||
public void callback(Integer isAttention) {
|
||||
if (isAttention == 1) {
|
||||
if (mBtnFollow.getVisibility() == View.VISIBLE) {
|
||||
mBtnFollow.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 分享
|
||||
*/
|
||||
private void share() {
|
||||
LiveShareDialogFragment fragment = new LiveShareDialogFragment();
|
||||
fragment.setActionListener(this);
|
||||
fragment.show(((AbsActivity) mContext).getSupportFragmentManager(), "LiveShareDialogFragment");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(String type) {
|
||||
if (Constants.LINK.equals(type)) {
|
||||
copyLink();
|
||||
} else {
|
||||
shareHomePage(type);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制页面链接
|
||||
*/
|
||||
private void copyLink() {
|
||||
if (mUserHomeSharePresenter != null) {
|
||||
mUserHomeSharePresenter.copyLink();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分享页面链接
|
||||
*/
|
||||
private void shareHomePage(String type) {
|
||||
if (mUserHomeSharePresenter != null) {
|
||||
mUserHomeSharePresenter.shareHomePage(type);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
package com.yunbao.live.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.http.CommonHttpUtil;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.interfaces.KeyBoardHeightChangeListener;
|
||||
import com.yunbao.common.utils.KeyBoardHeightUtil;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.adapter.LiveReportAdapter;
|
||||
import com.yunbao.live.bean.LiveReportBean;
|
||||
import com.yunbao.common.http.LiveHttpConsts;
|
||||
import com.yunbao.common.http.LiveHttpUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/12/15.
|
||||
* 直播间举报 短视频举报功能共用此页面
|
||||
*/
|
||||
@Route(path = RouteUtil.PATH_LIVEREPORT)
|
||||
public class LiveReportActivity extends AbsActivity implements LiveReportAdapter.ActionListener, KeyBoardHeightChangeListener {
|
||||
|
||||
public static void forward(Context context, String toUid) {
|
||||
Intent intent = new Intent(context, LiveReportActivity.class);
|
||||
intent.putExtra(Constants.TO_UID, toUid);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
public static void forward2(Context context, String VideoId) {
|
||||
Intent intent = new Intent(context, LiveReportActivity.class);
|
||||
intent.putExtra(Constants.VIDEO_ID, VideoId);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
public static void forward3(Context context, String dynamic_id, int intoIndex, String community_type, String comment_id) {
|
||||
Intent intent = new Intent(context, LiveReportActivity.class);
|
||||
intent.putExtra(Constants.TO_UID, dynamic_id);
|
||||
intent.putExtra(Constants.INTOINDEX, intoIndex);
|
||||
intent.putExtra("community_type", community_type);
|
||||
intent.putExtra("comment_id", comment_id);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
private String community_type;
|
||||
private String comment_id;
|
||||
private String mToUid;
|
||||
private String mVideoId;
|
||||
private int mIntoIndex;
|
||||
private RecyclerView mRecyclerView;
|
||||
private LiveReportAdapter mAdapter;
|
||||
private KeyBoardHeightUtil mKeyBoardHeightUtil;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_video_report;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
setTitle(mContext.getString(R.string.report));
|
||||
mToUid = getIntent().getStringExtra(Constants.TO_UID);
|
||||
mVideoId = getIntent().getStringExtra(Constants.VIDEO_ID);
|
||||
mIntoIndex = getIntent().getIntExtra(Constants.INTOINDEX, 0);
|
||||
community_type = getIntent().getStringExtra("community_type");
|
||||
comment_id = getIntent().getStringExtra("comment_id");
|
||||
mRecyclerView = findViewById(R.id.recyclerView);
|
||||
mRecyclerView.setHasFixedSize(true);
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
|
||||
mKeyBoardHeightUtil = new KeyBoardHeightUtil(mContext, findViewById(android.R.id.content), this);
|
||||
LiveHttpUtil.getLiveReportList(new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
List<LiveReportBean> list = JSON.parseArray(Arrays.toString(info), LiveReportBean.class);
|
||||
mAdapter = new LiveReportAdapter(mContext, list);
|
||||
mAdapter.setActionListener(LiveReportActivity.this);
|
||||
if (mRecyclerView != null) {
|
||||
mRecyclerView.setAdapter(mAdapter);
|
||||
}
|
||||
if (mKeyBoardHeightUtil != null) {
|
||||
mKeyBoardHeightUtil.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReportClick(LiveReportBean bean, String text) {
|
||||
// if (TextUtils.isEmpty(mToUid)) {
|
||||
// return;
|
||||
// }
|
||||
// if (bean == null) {
|
||||
// ToastUtil.show(mContext.getString(R.string.video_report_tip_3);
|
||||
// return;
|
||||
// }
|
||||
// String content = bean.getName();
|
||||
// if (!TextUtils.isEmpty(text)) {
|
||||
// content += " " + text;
|
||||
// }
|
||||
// LiveHttpUtil.setReport(mToUid, content, mReportCallback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReportClick(LiveReportBean bean, String text, File file1, File file2, File file3) {
|
||||
if (TextUtils.isEmpty(mToUid)) {
|
||||
mToUid = "";
|
||||
}
|
||||
if (bean == null) {
|
||||
ToastUtil.show(mContext.getString(R.string.video_report_tip_3));
|
||||
return;
|
||||
}
|
||||
String content = "";
|
||||
try {
|
||||
content = bean.getName();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (!TextUtils.isEmpty(text)) {
|
||||
content += " " + text;
|
||||
}
|
||||
if (mIntoIndex == 0) {
|
||||
LiveHttpUtil.setReport(mToUid, content, file1, file2, file3, mVideoId, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
ToastUtil.show(mContext.getString(R.string.video_report_tip_4));
|
||||
onBackPressed();
|
||||
} else {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
CommonHttpUtil.setCommunityReport(community_type, comment_id, mToUid, text, file1, file2, file3, bean.getId(), new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
ToastUtil.show(mContext.getString(R.string.video_report_tip_4));
|
||||
onBackPressed();
|
||||
} else {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKeyBoardHeightChanged(int visibleHeight, int keyboardHeight) {
|
||||
if (mRecyclerView != null) {
|
||||
mRecyclerView.setTranslationY(-keyboardHeight);
|
||||
}
|
||||
if (keyboardHeight > 0 && mAdapter != null) {
|
||||
mRecyclerView.smoothScrollToPosition(mAdapter.getItemCount() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSoftInputShowed() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private void release() {
|
||||
LiveHttpUtil.cancel(LiveHttpConsts.GET_LIVE_REPORT_LIST);
|
||||
LiveHttpUtil.cancel(LiveHttpConsts.SET_REPORT);
|
||||
if (mKeyBoardHeightUtil != null) {
|
||||
mKeyBoardHeightUtil.release();
|
||||
}
|
||||
mKeyBoardHeightUtil = null;
|
||||
if (mAdapter != null) {
|
||||
mAdapter.setActionListener(null);
|
||||
}
|
||||
mAdapter = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
release();
|
||||
super.onBackPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
release();
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,123 @@
|
||||
package com.yunbao.live.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.adapter.RefreshAdapter;
|
||||
import com.yunbao.common.custom.CommonRefreshView;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.adapter.LiveShutUpAdapter;
|
||||
import com.yunbao.live.bean.LiveShutUpBean;
|
||||
import com.yunbao.common.http.LiveHttpConsts;
|
||||
import com.yunbao.common.http.LiveHttpUtil;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2019/4/27.
|
||||
* 直播间禁言用户列表
|
||||
*/
|
||||
|
||||
public class LiveShutUpActivity extends AbsActivity implements OnItemClickListener<LiveShutUpBean> {
|
||||
|
||||
|
||||
public static void forward(Context context, String liveUid) {
|
||||
Intent intent = new Intent(context, LiveShutUpActivity.class);
|
||||
intent.putExtra(Constants.LIVE_UID, liveUid);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
private CommonRefreshView mRefreshView;
|
||||
private LiveShutUpAdapter mAdapter;
|
||||
private String mLiveUid;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_shut_up;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
setTitle(mContext.getString(R.string.live_user_shut_up_list));
|
||||
mLiveUid = getIntent().getStringExtra(Constants.LIVE_UID);
|
||||
if (TextUtils.isEmpty(mLiveUid)) {
|
||||
return;
|
||||
}
|
||||
mRefreshView = findViewById(R.id.refreshView);
|
||||
mRefreshView.setEmptyLayoutId(R.layout.view_no_data_shut_up);
|
||||
mRefreshView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
|
||||
mRefreshView.setDataHelper(new CommonRefreshView.DataHelper<LiveShutUpBean>() {
|
||||
@Override
|
||||
public RefreshAdapter<LiveShutUpBean> getAdapter() {
|
||||
if (mAdapter == null) {
|
||||
mAdapter = new LiveShutUpAdapter(mContext);
|
||||
mAdapter.setOnItemClickListener(LiveShutUpActivity.this);
|
||||
}
|
||||
return mAdapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadData(int p, HttpCallback callback) {
|
||||
LiveHttpUtil.getLiveShutUpList(mLiveUid, p, callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LiveShutUpBean> processData(String[] info) {
|
||||
return JSON.parseArray(Arrays.toString(info), LiveShutUpBean.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefreshSuccess(List<LiveShutUpBean> list, int listCount) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefreshFailure() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadMoreSuccess(List<LiveShutUpBean> loadItemList, int loadItemCount) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadMoreFailure() {
|
||||
|
||||
}
|
||||
});
|
||||
mRefreshView.initData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(final LiveShutUpBean bean, int position) {
|
||||
LiveHttpUtil.liveCancelShutUp(mLiveUid, bean.getUid(), new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
if (mAdapter != null) {
|
||||
mAdapter.removeItem(bean.getUid());
|
||||
}
|
||||
}
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
LiveHttpUtil.cancel(LiveHttpConsts.GET_LIVE_SHUT_UP_LIST);
|
||||
LiveHttpUtil.cancel(LiveHttpConsts.LIVE_CANCEL_SHUT_UP);
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,368 @@
|
||||
package com.yunbao.live.activity;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import androidx.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.tencent.liteav.TXLiteAVCode;
|
||||
import com.tencent.liteav.device.TXDeviceManager;
|
||||
import com.tencent.rtmp.ui.TXCloudVideoView;
|
||||
import com.tencent.trtc.TRTCCloud;
|
||||
import com.tencent.trtc.TRTCCloudDef;
|
||||
import com.tencent.trtc.TRTCCloudListener;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.common.bean.LiveRoomTypeBean;
|
||||
import com.yunbao.live.dialog.LiveBeautyDialogFragment;
|
||||
import com.yunbao.live.dialog.LiveRoomTypeDialogFragment;
|
||||
import com.yunbao.common.http.LiveHttpUtil;
|
||||
import com.yunbao.live.momo.GenerateTestUserSig;
|
||||
import com.yunbao.live.momo.TencentTRTCBeautyManager;
|
||||
import com.yunbao.live.utils.TRTCBaseActivity;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import static com.tencent.trtc.TRTCCloudDef.TRTC_APP_SCENE_LIVE;
|
||||
import static com.tencent.trtc.TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_BIG;
|
||||
|
||||
public class LiveTRTCAnchorActivity extends TRTCBaseActivity {
|
||||
|
||||
|
||||
private TXCloudVideoView mTxcvvAnchorPreviewView;
|
||||
private ImageView mButtonSwitchCamera;
|
||||
|
||||
private TRTCCloud mTRTCCloud;
|
||||
private TXDeviceManager mTXDeviceManager;
|
||||
private TRTCCloudDef.TRTCParams mTRTCParams;
|
||||
private boolean mIsFrontCamera = true;
|
||||
private String mRoomId = "1256732";
|
||||
private String mUserId = "95895736";
|
||||
String TAG = "TX";
|
||||
private Handler mMainHandler;
|
||||
public TencentTRTCBeautyManager tencentTRTCBeautyManager;
|
||||
|
||||
public static View ready_view;
|
||||
//美颜
|
||||
TextView btn_beauty;
|
||||
private TextView mLiveTypeTextView;//房间类型TextView
|
||||
private int mLiveClassID;//直播频道id
|
||||
private int mLiveType;//房间类型
|
||||
private int mLiveTypeVal;//房间密码
|
||||
|
||||
TextView live_class;
|
||||
EditText mEditTitle;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_live_trtcanchor);
|
||||
|
||||
|
||||
mTRTCCloud = TRTCCloud.sharedInstance(LiveTRTCAnchorActivity.this);
|
||||
mMainHandler = new Handler(Looper.getMainLooper());
|
||||
|
||||
mTXDeviceManager = mTRTCCloud.getDeviceManager();
|
||||
mTRTCCloud.setListener(new TRTCCloudImplListener(LiveTRTCAnchorActivity.this));
|
||||
|
||||
mTRTCCloud.setLocalVideoProcessListener(TRTCCloudDef.TRTC_VIDEO_PIXEL_FORMAT_Texture_2D,
|
||||
TRTCCloudDef.TRTC_VIDEO_BUFFER_TYPE_TEXTURE,
|
||||
new TRTCCloudListener.TRTCVideoFrameListener() {
|
||||
|
||||
@Override
|
||||
public void onGLContextCreated() {
|
||||
mMainHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
tencentTRTCBeautyManager = new TencentTRTCBeautyManager(LiveTRTCAnchorActivity.this);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onProcessVideoFrame(TRTCCloudDef.TRTCVideoFrame srcFrame, TRTCCloudDef.TRTCVideoFrame dstFrame) {
|
||||
if (tencentTRTCBeautyManager != null) {
|
||||
dstFrame.texture.textureId = tencentTRTCBeautyManager.renderWithTexture(srcFrame.texture.textureId, srcFrame.width, srcFrame.height, srcFrame.rotation == 270);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGLContextDestory() {
|
||||
tencentTRTCBeautyManager.textureDestoryed();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
if (checkPermission()) {
|
||||
initView();
|
||||
enterRoom();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
exitRoom();
|
||||
}
|
||||
|
||||
|
||||
protected void initView() {
|
||||
mButtonSwitchCamera = findViewById(R.id.live_btn_switch_camera);
|
||||
mTxcvvAnchorPreviewView = findViewById(R.id.live_cloud_view_main);
|
||||
btn_beauty = findViewById(R.id.btn_beauty);
|
||||
ready_view = (View) findViewById(R.id.ready_view);
|
||||
live_class = (TextView) findViewById(R.id.live_class);
|
||||
mEditTitle = (EditText) findViewById(R.id.edit_title);
|
||||
mLiveTypeTextView = (TextView) findViewById(R.id.btn_room_type);
|
||||
mLiveTypeTextView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
chooseLiveType();
|
||||
}
|
||||
});
|
||||
findViewById(R.id.btn_start_live).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
startLive();
|
||||
}
|
||||
});
|
||||
live_class.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(LiveTRTCAnchorActivity.this, LiveChooseClassActivity.class);
|
||||
intent.putExtra(Constants.CLASS_ID, mLiveClassID);
|
||||
startActivityForResult(intent, 1);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
btn_beauty.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
LiveBeautyDialogFragment fragment = new LiveBeautyDialogFragment();
|
||||
// fragment.setiBeautyModule(BeautyManager.iBeautyModule);
|
||||
fragment.show(getSupportFragmentManager(), "LiveBeautyDialogFragment");
|
||||
ready_view.setVisibility(View.GONE);
|
||||
|
||||
}
|
||||
});
|
||||
mTRTCCloud.setListener(new TRTCCloudImplListener(LiveTRTCAnchorActivity.this));
|
||||
mButtonSwitchCamera.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
switchCamera();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void enterRoom() {
|
||||
|
||||
mTRTCParams = new TRTCCloudDef.TRTCParams();
|
||||
mTRTCParams.sdkAppId = GenerateTestUserSig.SDKAPPID;
|
||||
mTRTCParams.userId = mUserId;
|
||||
mTRTCParams.roomId = Integer.parseInt(mRoomId);
|
||||
mTRTCParams.userSig = GenerateTestUserSig.genTestUserSig(mTRTCParams.userId);
|
||||
mTRTCParams.role = TRTCCloudDef.TRTCRoleAnchor;
|
||||
|
||||
mTRTCCloud.startLocalPreview(mIsFrontCamera, mTxcvvAnchorPreviewView);
|
||||
mTRTCCloud.startLocalAudio(TRTCCloudDef.TRTC_AUDIO_QUALITY_DEFAULT);
|
||||
mTRTCCloud.enterRoom(mTRTCParams, TRTC_APP_SCENE_LIVE);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == 1 && resultCode == RESULT_OK) {
|
||||
mLiveClassID = data.getIntExtra(Constants.CLASS_ID, 0);
|
||||
live_class.setText(data.getStringExtra(Constants.CLASS_NAME));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 请求创建直播间接口,开始直播
|
||||
*/
|
||||
private void createRoom() {
|
||||
if (mLiveClassID == 0) {
|
||||
ToastUtil.show(WordUtil.getNewString(R.string.live_choose_live_class));
|
||||
return;
|
||||
}
|
||||
String title = mEditTitle.getText().toString().trim();
|
||||
LiveHttpUtil.newcreateRoom(title, mLiveClassID, mLiveType, mLiveTypeVal, null,0, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, final String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
L.e("开播", "createRoom------->" + info[0]);
|
||||
final CommonAppConfig appConfig = CommonAppConfig.getInstance();
|
||||
UserBean u = appConfig.getUserBean();
|
||||
|
||||
try {
|
||||
JSONObject data = new JSONObject(info[0]);
|
||||
mTRTCCloud.startPublishing(data.getString("stream"), TRTC_VIDEO_STREAM_TYPE_BIG);
|
||||
ready_view.setVisibility(View.VISIBLE);
|
||||
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
} else {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
protected void switchCamera() {
|
||||
if (mIsFrontCamera) {
|
||||
mIsFrontCamera = false;
|
||||
} else {
|
||||
mIsFrontCamera = true;
|
||||
}
|
||||
mTXDeviceManager.switchCamera(mIsFrontCamera);
|
||||
}
|
||||
|
||||
|
||||
protected class TRTCCloudImplListener extends TRTCCloudListener {
|
||||
|
||||
private WeakReference<LiveTRTCAnchorActivity> mContext;
|
||||
|
||||
public TRTCCloudImplListener(LiveTRTCAnchorActivity activity) {
|
||||
super();
|
||||
mContext = new WeakReference<>(activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoteUserEnterRoom(String userId) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoteUserLeaveRoom(String userId, int reason) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUserVideoAvailable(String userId, boolean available) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int errCode, String errMsg, Bundle extraInfo) {
|
||||
Log.d(TAG, "sdk callback onError");
|
||||
LiveTRTCAnchorActivity activity = mContext.get();
|
||||
if (activity != null) {
|
||||
Toast.makeText(activity, "onError: " + errMsg + "[" + errCode + "]", Toast.LENGTH_SHORT).show();
|
||||
if (errCode == TXLiteAVCode.ERR_ROOM_ENTER_FAIL) {
|
||||
activity.exitRoom();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected void exitRoom() {
|
||||
if (mTRTCCloud != null) {
|
||||
mTRTCCloud.stopLocalAudio();
|
||||
mTRTCCloud.stopLocalPreview();
|
||||
mTRTCCloud.exitRoom();
|
||||
mTRTCCloud.setListener(null);
|
||||
}
|
||||
mTRTCCloud = null;
|
||||
TRTCCloud.destroySharedInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPermissionGranted() {
|
||||
initView();
|
||||
enterRoom();
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择直播类型
|
||||
*/
|
||||
private void chooseLiveType() {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt(Constants.CHECKED_ID, mLiveType);
|
||||
LiveRoomTypeDialogFragment fragment = new LiveRoomTypeDialogFragment();
|
||||
fragment.setArguments(bundle);
|
||||
fragment.setCallback(new CommonCallback<LiveRoomTypeBean>() {
|
||||
@Override
|
||||
public void callback(LiveRoomTypeBean bean) {
|
||||
if (bean.getId() == Constants.LIVE_TYPE_NORMAL) {
|
||||
onLiveTypeNormal(bean);
|
||||
} else {
|
||||
onLiveTypePwd(bean);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
fragment.show((this).getSupportFragmentManager(), "LiveRoomTypeDialogFragment");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 普通房间
|
||||
*/
|
||||
private void onLiveTypeNormal(LiveRoomTypeBean bean) {
|
||||
mLiveType = bean.getId();
|
||||
mLiveTypeTextView.setText(bean.getName());
|
||||
mLiveTypeVal = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 密码房间
|
||||
*/
|
||||
private void onLiveTypePwd(final LiveRoomTypeBean bean) {
|
||||
DialogUitl.showSimpleInputDialog(this, getApplicationContext().getString(R.string.live_set_pwd), DialogUitl.INPUT_TYPE_NUMBER_PASSWORD, 8, new DialogUitl.SimpleCallback() {
|
||||
@Override
|
||||
public void onConfirmClick(Dialog dialog, String content) {
|
||||
if (TextUtils.isEmpty(content)) {
|
||||
ToastUtil.show(getString(R.string.live_set_pwd_empty));
|
||||
} else {
|
||||
mLiveType = bean.getId();
|
||||
mLiveTypeTextView.setText(bean.getName());
|
||||
if (StringUtil.isInt(content)) {
|
||||
mLiveTypeVal = Integer.parseInt(content);
|
||||
}
|
||||
dialog.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 点击开始直播按钮
|
||||
*/
|
||||
private void startLive() {
|
||||
createRoom();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,247 @@
|
||||
package com.yunbao.live.activity;
|
||||
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.provider.MediaStore;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.ValueCallback;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/9/25.
|
||||
* 我的徽章 右上角问号h5页面
|
||||
*/
|
||||
|
||||
public class MedalQuestionWebViewActivity extends AbsActivity {
|
||||
|
||||
private ProgressBar mProgressBar;
|
||||
private WebView mWebView;
|
||||
private final int CHOOSE = 100;//Android 5.0以下的
|
||||
private final int CHOOSE_ANDROID_5 = 200;//Android 5.0以上的
|
||||
private ValueCallback<Uri> mValueCallback;
|
||||
private ValueCallback<Uri[]> mValueCallback2;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_webview;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
String url = getIntent().getStringExtra(Constants.URL);
|
||||
L.e("H5---2>" + url);
|
||||
// LinearLayout rootView = (LinearLayout) findViewById(R.id.rootView);
|
||||
mProgressBar = (ProgressBar) findViewById(R.id.progressbar);
|
||||
mWebView = findViewById(R.id.webView);
|
||||
// LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
// params.topMargin = DpUtil.dp2px(1);
|
||||
// mWebView.setLayoutParams(params);
|
||||
// mWebView.setOverScrollMode(View.OVER_SCROLL_NEVER);
|
||||
mWebView.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
L.e("H5-------->" + url);
|
||||
if (url.startsWith(Constants.COPY_PREFIX)) {
|
||||
String content = url.substring(Constants.COPY_PREFIX.length());
|
||||
if (!TextUtils.isEmpty(content)) {
|
||||
copy(content);
|
||||
}
|
||||
} else {
|
||||
view.loadUrl(url);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
setTitle(view.getTitle());
|
||||
}
|
||||
});
|
||||
mWebView.setWebChromeClient(new WebChromeClient() {
|
||||
@Override
|
||||
public void onProgressChanged(WebView view, int newProgress) {
|
||||
if (newProgress == 100) {
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
} else {
|
||||
mProgressBar.setProgress(newProgress);
|
||||
}
|
||||
}
|
||||
|
||||
//以下是在各个Android版本中 WebView调用文件选择器的方法
|
||||
// For Android < 3.0
|
||||
public void openFileChooser(ValueCallback<Uri> valueCallback) {
|
||||
openImageChooserActivity(valueCallback);
|
||||
}
|
||||
|
||||
// For Android >= 3.0
|
||||
public void openFileChooser(ValueCallback valueCallback, String acceptType) {
|
||||
openImageChooserActivity(valueCallback);
|
||||
}
|
||||
|
||||
//For Android >= 4.1
|
||||
public void openFileChooser(ValueCallback<Uri> valueCallback,
|
||||
String acceptType, String capture) {
|
||||
openImageChooserActivity(valueCallback);
|
||||
}
|
||||
|
||||
// For Android >= 5.0
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public boolean onShowFileChooser(WebView webView,
|
||||
ValueCallback<Uri[]> filePathCallback,
|
||||
FileChooserParams fileChooserParams) {
|
||||
mValueCallback2 = filePathCallback;
|
||||
Intent intent = fileChooserParams.createIntent();
|
||||
startActivityForResult(intent, CHOOSE_ANDROID_5);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
mWebView.getSettings().setJavaScriptEnabled(true);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
}
|
||||
mWebView.loadUrl(url);
|
||||
}
|
||||
|
||||
private void openImageChooserActivity(ValueCallback<Uri> valueCallback) {
|
||||
mValueCallback = valueCallback;
|
||||
Intent intent = new Intent();
|
||||
if (Build.VERSION.SDK_INT < 19) {
|
||||
intent.setAction(Intent.ACTION_GET_CONTENT);
|
||||
} else {
|
||||
intent.setAction(Intent.ACTION_PICK);
|
||||
intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||
}
|
||||
intent.setType("image/*");
|
||||
startActivityForResult(Intent.createChooser(intent, mContext.getString(R.string.choose_flie)), CHOOSE);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
||||
super.onActivityResult(requestCode, resultCode, intent);
|
||||
switch (requestCode) {
|
||||
case CHOOSE://5.0以下选择图片后的回调
|
||||
processResult(resultCode, intent);
|
||||
break;
|
||||
case CHOOSE_ANDROID_5://5.0以上选择图片后的回调
|
||||
processResultAndroid5(resultCode, intent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void processResult(int resultCode, Intent intent) {
|
||||
if (mValueCallback == null) {
|
||||
return;
|
||||
}
|
||||
if (resultCode == RESULT_OK && intent != null) {
|
||||
Uri result = intent.getData();
|
||||
mValueCallback.onReceiveValue(result);
|
||||
} else {
|
||||
mValueCallback.onReceiveValue(null);
|
||||
}
|
||||
mValueCallback = null;
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
private void processResultAndroid5(int resultCode, Intent intent) {
|
||||
if (mValueCallback2 == null) {
|
||||
return;
|
||||
}
|
||||
if (resultCode == RESULT_OK && intent != null) {
|
||||
mValueCallback2.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, intent));
|
||||
} else {
|
||||
mValueCallback2.onReceiveValue(null);
|
||||
}
|
||||
mValueCallback2 = null;
|
||||
}
|
||||
|
||||
protected boolean canGoBack() {
|
||||
return mWebView != null && mWebView.canGoBack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (isNeedExitActivity()) {
|
||||
finish();
|
||||
} else {
|
||||
if (canGoBack()) {
|
||||
mWebView.goBack();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean isNeedExitActivity() {
|
||||
if (mWebView != null) {
|
||||
String url = mWebView.getUrl();
|
||||
if (!TextUtils.isEmpty(url)) {
|
||||
return url.contains("g=Appapi&m=Auth&a=success")//身份认证成功页面
|
||||
|| url.contains("g=Appapi&m=Family&a=home");//家族申请提交成功页面
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void forward(Context context, String url, boolean addArgs) {
|
||||
if (addArgs) {
|
||||
url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()+ "&isZh=" + (WordUtil.isNewZh() ? "1" : 0);
|
||||
}
|
||||
Intent intent = new Intent(context, MedalQuestionWebViewActivity.class);
|
||||
intent.putExtra(Constants.URL, url);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
public static void forward(Context context, String url) {
|
||||
forward(context, url, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
if (mWebView != null) {
|
||||
ViewGroup parent = (ViewGroup) mWebView.getParent();
|
||||
if (parent != null) {
|
||||
parent.removeView(mWebView);
|
||||
}
|
||||
mWebView.destroy();
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制到剪贴板
|
||||
*/
|
||||
private void copy(String content) {
|
||||
ClipboardManager cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
ClipData clipData = ClipData.newPlainText("text", content);
|
||||
cm.setPrimaryClip(clipData);
|
||||
ToastUtil.show(getString(R.string.copy_success));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,677 @@
|
||||
package com.yunbao.live.activity;
|
||||
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.media.Ringtone;
|
||||
import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.PopupWindow;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.cardview.widget.CardView;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.WebViewActivity;
|
||||
import com.yunbao.common.bean.ChatRemarksBean;
|
||||
import com.yunbao.common.event.UpdateTablePoint;
|
||||
import com.yunbao.common.http.CommonHttpUtil;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.utils.SpUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.adapter.ImListAdapter;
|
||||
import com.yunbao.live.bean.ImUserBean;
|
||||
import com.yunbao.live.bean.RongIMEvent;
|
||||
import com.yunbao.live.bean.SearchUserBean;
|
||||
import com.yunbao.live.http.ImHttpConsts;
|
||||
import com.yunbao.live.http.ImHttpUtil;
|
||||
import com.yunbao.live.views.ChatListViewHolder;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import io.rong.imlib.RongIMClient;
|
||||
import io.rong.imlib.model.Conversation;
|
||||
import io.rong.imlib.model.Message;
|
||||
import io.rong.message.RecallNotificationMessage;
|
||||
import io.rong.message.TextMessage;
|
||||
|
||||
public class MyTUIConversationFragment extends Fragment {
|
||||
|
||||
private LinearLayout lt_nodata_msg;
|
||||
private View mBaseView;
|
||||
private RecyclerView mRecyclerView;
|
||||
public static ImListAdapter mAdapter;
|
||||
private ChatListViewHolder.ActionListener mActionListener;
|
||||
private SystemMessageActivity systemMessageActivity;
|
||||
private List<ImUserBean> listUserBean;
|
||||
private int tabPoint = 0;
|
||||
private Handler mHandler;
|
||||
private long timeStamp = 0;
|
||||
private int count = 10;
|
||||
private final int runOnUI = 20;
|
||||
private Message messageHandler;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
|
||||
mBaseView = inflater.inflate(R.layout.my_conversation_fragment, container, false);
|
||||
initView();
|
||||
return mBaseView;
|
||||
}
|
||||
|
||||
//获取动态信息
|
||||
public void loadData() {
|
||||
ImHttpUtil.getImUserInfo("", new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
|
||||
if (mRecyclerView != null && mAdapter != null && listUserBean != null) {
|
||||
if (Constants.firstInto == 0) {
|
||||
listUserBean.clear();
|
||||
listUserBean = JSON.parseArray(Arrays.toString(info), ImUserBean.class);
|
||||
Constants.firstInto = 1;
|
||||
tabPoint = 0;
|
||||
timeStamp = 0;
|
||||
getRyChatList();
|
||||
} else {
|
||||
List<ImUserBean> newlistUserBean = JSON.parseArray(Arrays.toString(info), ImUserBean.class);
|
||||
if (listUserBean.size() > 2) {
|
||||
listUserBean.remove(0);
|
||||
listUserBean.add(0, newlistUserBean.get(0));
|
||||
listUserBean.remove(1);
|
||||
listUserBean.add(1, newlistUserBean.get(1));
|
||||
listUserBean.remove(2);
|
||||
listUserBean.add(2, newlistUserBean.get(2));
|
||||
mHandler.sendEmptyMessage(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (listUserBean.size() >= 2) {
|
||||
//目前就三条消息,需求判断前两条消息是否有未读消息
|
||||
for (int i = 0; i < listUserBean.size() - 2; i++) {
|
||||
//消息对象
|
||||
ImUserBean userBean = listUserBean.get(i);
|
||||
//未读消息数
|
||||
String number = userBean.getNum();
|
||||
//未读消息不为空并且大于0
|
||||
if (!TextUtils.isEmpty(number) && Integer.parseInt(number) > 0) {
|
||||
tabPoint = Integer.parseInt(number);
|
||||
changeTablePoint();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setActionListener(ChatListViewHolder.ActionListener actionListener) {
|
||||
mActionListener = actionListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
release();
|
||||
}
|
||||
|
||||
public void release() {
|
||||
EventBus.getDefault().unregister(this);
|
||||
mActionListener = null;
|
||||
|
||||
ImHttpUtil.cancel(ImHttpConsts.GET_SYSTEM_MESSAGE_LIST);
|
||||
ImHttpUtil.cancel(ImHttpConsts.GET_IM_USER_INFO);
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
systemMessageActivity = new SystemMessageActivity();
|
||||
|
||||
lt_nodata_msg = (LinearLayout) mBaseView.findViewById(R.id.lt_nodata_msg);
|
||||
mRecyclerView = (RecyclerView) mBaseView.findViewById(R.id.my_msg_recyclerView);
|
||||
mRecyclerView.setHasFixedSize(false);
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
|
||||
mAdapter = new ImListAdapter(getContext());
|
||||
|
||||
mAdapter.setActionListener(new ImListAdapter.ActionListener() {
|
||||
@Override
|
||||
public void onItemClick(ImUserBean bean) {
|
||||
|
||||
if (bean.getLink() != null && !bean.getLink().equals("")) {
|
||||
// startActivity(new Intent(getContext(), ZhuangBanActivity.class).putExtra("url", bean.getLink()));
|
||||
startActivity(new Intent(getContext(), WebViewActivity.class).putExtra("url", bean.getLink()));
|
||||
} else if ("1".equals(bean.getType()) || "2".equals(bean.getType())) {//系统消息,互动消息,猜你喜欢
|
||||
systemMessageActivity.forward(getContext(), bean.getType(), "", bean.getTitle(), "");
|
||||
} else if ("3".equals(bean.getType())) {
|
||||
if (bean.getLink() != null && !"".equals(bean.getLink())) {
|
||||
WebViewActivity.forward(getActivity(), bean.getLink(),false);
|
||||
} else {
|
||||
systemMessageActivity.forward(getContext(), bean.getType(), "", bean.getTitle(), "");
|
||||
}
|
||||
} else {//聊天消息
|
||||
openMessage(bean, bean.getUserId(), 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemDelete(ImUserBean bean, int p, View v) {
|
||||
showMoreDialog(v, p, bean);
|
||||
}
|
||||
});
|
||||
mRecyclerView.setAdapter(mAdapter);
|
||||
|
||||
RongIMClient.setOnRecallMessageListener(listenerBack);
|
||||
|
||||
Constants.nowId = "";
|
||||
Constants.remarks = "";
|
||||
Constants.isAdmin = "";
|
||||
timeStamp = 0;
|
||||
listUserBean = new ArrayList<>();
|
||||
// loadData();
|
||||
|
||||
mHandler = new Handler() {
|
||||
@SuppressLint("HandlerLeak")
|
||||
@Override
|
||||
public void handleMessage(android.os.Message msg) {
|
||||
switch (msg.what) {
|
||||
case 1:
|
||||
mAdapter.setList(listUserBean);
|
||||
if (listUserBean.size() > 3) {
|
||||
if (lt_nodata_msg.getVisibility() == View.VISIBLE) {
|
||||
lt_nodata_msg.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case runOnUI:
|
||||
if (lt_nodata_msg.getVisibility() == View.VISIBLE) {
|
||||
lt_nodata_msg.setVisibility(View.GONE);
|
||||
}
|
||||
if (systemMessageActivity != null && !Constants.nowId.equals("")) {
|
||||
if (!Constants.isShowLiveDialog) {//首页单聊插入消息
|
||||
if (messageHandler.getObjectName().equals("RC:TxtMsg")) {
|
||||
systemMessageActivity.getNewMsg(messageHandler);
|
||||
} else if (messageHandler.getObjectName().equals("RC:ImgMsg")) {
|
||||
systemMessageActivity.getNewMsg(messageHandler);
|
||||
} else if (messageHandler.getObjectName().equals("RC:SightMsg")) {
|
||||
systemMessageActivity.getNewMsg(messageHandler);
|
||||
}
|
||||
cleanMessage(null, messageHandler.getTargetId());
|
||||
getOneUserChat(messageHandler.getTargetId());
|
||||
}
|
||||
} else {
|
||||
if (systemMessageActivity.nowUid != null && !messageHandler.getTargetId().equals(systemMessageActivity.nowUid)) {
|
||||
//新信息提示
|
||||
try {
|
||||
Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
|
||||
Ringtone r = RingtoneManager.getRingtone(getActivity(), notification);
|
||||
r.play();
|
||||
} catch (Exception e) {
|
||||
e.getMessage();
|
||||
}
|
||||
}
|
||||
getChatPoint();
|
||||
getOneUserChat(messageHandler.getTargetId());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
getNameRemarks();
|
||||
}
|
||||
|
||||
//打开单聊
|
||||
private void openMessage(ImUserBean bean, String targetId, int messageId) {
|
||||
Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
|
||||
long timestamp = new Date().getTime();
|
||||
|
||||
RongIMClient.getInstance().clearMessagesUnreadStatus(conversationType, targetId, timestamp, new RongIMClient.OperationCallback() {
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
if (bean != null) {
|
||||
Constants.nowId = bean.getUserId();
|
||||
Constants.remarks = bean.getRemarks();
|
||||
Constants.isAdmin = bean.getIs_admin();
|
||||
if (Constants.isAdmin == null) {
|
||||
Constants.isAdmin = "0";
|
||||
}
|
||||
systemMessageActivity.forward(getContext(), bean.getType(), bean.getUserId(), bean.getTitle(), bean.getImage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(RongIMClient.ErrorCode errorCode) {
|
||||
ToastUtil.show(getResources().getString(R.string.load_failure));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//撤回消息
|
||||
RongIMClient.OnRecallMessageListener listenerBack = new RongIMClient.OnRecallMessageListener() {
|
||||
@Override
|
||||
public boolean onMessageRecalled(Message message, RecallNotificationMessage recallNotificationMessage) {
|
||||
if (systemMessageActivity != null && !Constants.nowId.equals("")) {
|
||||
systemMessageActivity.getWithdrawMsg(message.getMessageId());
|
||||
}
|
||||
getOneUserChat(message.getTargetId());
|
||||
|
||||
getChatPoint();
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
//获取会话列表
|
||||
private void getRyChatList() {
|
||||
Conversation.ConversationType[] conversationTypes = {Conversation.ConversationType.PRIVATE, Conversation.ConversationType.GROUP};
|
||||
RongIMClient.getInstance().getConversationListByPage(new RongIMClient.ResultCallback<List<Conversation>>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<Conversation> conversations) {
|
||||
if (conversations != null) {
|
||||
if (conversations.size() > 0) {
|
||||
timeStamp = conversations.get(conversations.size() - 1).getSentTime();
|
||||
}
|
||||
for (Conversation conversation2 : conversations) {
|
||||
ImUserBean imUserBean = new ImUserBean();
|
||||
imUserBean.setAddtime(conversation2.getSentTime() + "");
|
||||
imUserBean.setNum(conversation2.getUnreadMessageCount() + "");
|
||||
imUserBean.setLink("");
|
||||
imUserBean.setUserId(conversation2.getTargetId());
|
||||
imUserBean.setType("-1");
|
||||
if (conversation2.getObjectName().equals("RC:TxtMsg")) {
|
||||
TextMessage rongMsg = (TextMessage) conversation2.getLatestMessage();
|
||||
imUserBean.setContent(rongMsg.getContent());
|
||||
} else if (conversation2.getObjectName().equals("RC:ImgMsg")) {
|
||||
imUserBean.setContent(getResources().getString(R.string.im_input_img));
|
||||
} else if (conversation2.getObjectName().equals("RC:SightMsg")) {
|
||||
imUserBean.setContent(getResources().getString(R.string.video));
|
||||
} else {
|
||||
imUserBean.setContent("");
|
||||
}
|
||||
listUserBean.add(imUserBean);
|
||||
}
|
||||
// if (conversations.size() < 10) {
|
||||
// getUserData();
|
||||
// } else {
|
||||
getRyChatList();
|
||||
// }
|
||||
} else {
|
||||
|
||||
getUserData();
|
||||
}
|
||||
if (listUserBean.size() == 3) {
|
||||
lt_nodata_msg.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
lt_nodata_msg.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(RongIMClient.ErrorCode ErrorCode) {
|
||||
getRyChatList();
|
||||
mAdapter.setList(listUserBean);
|
||||
}
|
||||
}, timeStamp, count, conversationTypes);
|
||||
|
||||
}
|
||||
|
||||
private void getChatPoint() {
|
||||
Conversation.ConversationType[] conversationTypes = {Conversation.ConversationType.PRIVATE, Conversation.ConversationType.GROUP};
|
||||
boolean containBlocked = true;
|
||||
RongIMClient.getInstance().getUnreadCount(conversationTypes, containBlocked,
|
||||
new RongIMClient.ResultCallback<Integer>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(Integer unReadCount) {
|
||||
//未读消息大于1并且列表页面处于不可见状态消息图标展示红点
|
||||
if (unReadCount >= 1) {
|
||||
tabPoint = unReadCount;
|
||||
changeTablePoint();
|
||||
|
||||
} else {
|
||||
tabPoint = 0;
|
||||
changeTablePoint();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(RongIMClient.ErrorCode ErrorCode) {
|
||||
tabPoint = 0;
|
||||
changeTablePoint();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//未读数
|
||||
private void changeTablePoint() {
|
||||
EventBus.getDefault().post(new UpdateTablePoint(tabPoint));
|
||||
}
|
||||
|
||||
//获取会话列表的用户信息
|
||||
private void getUserData() {
|
||||
for (int i = 0; i < listUserBean.size(); i++) {
|
||||
int finalI = i;
|
||||
if (i > 2) {
|
||||
CommonHttpUtil.getUserBaseinfo(listUserBean.get(i).getUserId(), new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
JSONObject obj = JSON.parseObject(info[0]);
|
||||
SearchUserBean userBean = JSON.toJavaObject(obj, SearchUserBean.class);
|
||||
String toName = userBean.getUserNiceName();
|
||||
String avatar = userBean.getAvatar();
|
||||
String is_admin = userBean.getIs_admin();
|
||||
listUserBean.get(finalI).setTitle(toName);
|
||||
listUserBean.get(finalI).setImage(avatar);
|
||||
listUserBean.get(finalI).setIs_admin(is_admin);
|
||||
if (Constants.remarksListNow != null) {
|
||||
for (int j = 0; j < Constants.remarksListNow.size(); j++) {
|
||||
if (Constants.remarksListNow.get(j).getUserId().equals(listUserBean.get(finalI).getUserId())) {
|
||||
listUserBean.get(finalI).setRemarks(Constants.remarksListNow.get(j).getRemarks());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (finalI == listUserBean.size() - 1) {
|
||||
mAdapter.setList(listUserBean);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//获取单个会话
|
||||
private void getOneUserChat(String uid) {
|
||||
Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
|
||||
RongIMClient.getInstance().getConversation(conversationType, uid, new RongIMClient.ResultCallback<Conversation>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(Conversation conversation) {
|
||||
// 成功并返回会话信息
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!Constants.nowId.equals("")) {
|
||||
cleanMessage(null, conversation.getTargetId());
|
||||
conversation.setUnreadMessageCount(0);
|
||||
}
|
||||
if (conversation != null && conversation.getTargetId() != null) {
|
||||
if (listUserBean.size() > 3) {
|
||||
for (int i = 0; i < listUserBean.size(); i++) {
|
||||
if (listUserBean.get(i).getUserId() != null) {
|
||||
if (listUserBean.get(i).getUserId().equals(conversation.getTargetId())) {
|
||||
listUserBean.get(i).setAddtime(conversation.getSentTime() + "");
|
||||
listUserBean.get(i).setNum(conversation.getUnreadMessageCount() + "");
|
||||
listUserBean.get(i).setLink("");
|
||||
listUserBean.get(i).setUserId(conversation.getTargetId());
|
||||
listUserBean.get(i).setType("-1");
|
||||
if (conversation.getObjectName().equals("RC:TxtMsg")) {
|
||||
TextMessage rongMsg = (TextMessage) conversation.getLatestMessage();
|
||||
listUserBean.get(i).setContent(rongMsg.getContent());
|
||||
} else if (conversation.getObjectName().equals("RC:ImgMsg")) {
|
||||
listUserBean.get(i).setContent(getResources().getString(R.string.im_input_img));
|
||||
} else if (conversation.getObjectName().equals("RC:SightMsg")) {
|
||||
listUserBean.get(i).setContent(getResources().getString(R.string.video));
|
||||
} else {
|
||||
listUserBean.get(i).setContent("");
|
||||
}
|
||||
Collections.swap(listUserBean, i, 3);
|
||||
mHandler.sendEmptyMessage(1);
|
||||
|
||||
return;
|
||||
} else if (i == listUserBean.size() - 1) {
|
||||
getOneUserData(uid, conversation);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
getOneUserData(uid, conversation);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(RongIMClient.ErrorCode errorCode) {
|
||||
|
||||
}
|
||||
});
|
||||
CommonHttpUtil.getUserBaseinfo(uid, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
JSONObject obj = JSON.parseObject(info[0]);
|
||||
SearchUserBean userBean = JSON.toJavaObject(obj, SearchUserBean.class);
|
||||
String toName = userBean.getUserNiceName();
|
||||
String avatar = userBean.getAvatar();
|
||||
mAdapter.setList(listUserBean);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//获取单个会话列表的用户信息
|
||||
private void getOneUserData(String uid, Conversation conversation) {
|
||||
CommonHttpUtil.getUserBaseinfo(uid, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
JSONObject obj = JSON.parseObject(info[0]);
|
||||
SearchUserBean userBean = JSON.toJavaObject(obj, SearchUserBean.class);
|
||||
ImUserBean imUserBean = new ImUserBean();
|
||||
imUserBean.setAddtime(conversation.getSentTime() + "");
|
||||
imUserBean.setNum(conversation.getUnreadMessageCount() + "");
|
||||
imUserBean.setLink("");
|
||||
imUserBean.setUserId(conversation.getTargetId());
|
||||
imUserBean.setType("-1");
|
||||
imUserBean.setImage(userBean.getAvatar());
|
||||
imUserBean.setTitle(userBean.getUserNiceName());
|
||||
imUserBean.setIs_admin(userBean.getIs_admin());
|
||||
if (conversation.getObjectName().equals("RC:TxtMsg")) {
|
||||
TextMessage rongMsg = (TextMessage) conversation.getLatestMessage();
|
||||
imUserBean.setContent(rongMsg.getContent());
|
||||
} else if (conversation.getObjectName().equals("RC:ImgMsg")) {
|
||||
imUserBean.setContent(getResources().getString(R.string.im_input_img));
|
||||
} else if (conversation.getObjectName().equals("RC:SightMsg")) {
|
||||
imUserBean.setContent(getResources().getString(R.string.video));
|
||||
} else {
|
||||
imUserBean.setContent("");
|
||||
}
|
||||
if (listUserBean.size() > 3)
|
||||
listUserBean.add(3, imUserBean);
|
||||
// if (listUserBean.size() > 4) {
|
||||
// Collections.swap(listUserBean, listUserBean.size() - 1, 3);
|
||||
// }
|
||||
mHandler.sendEmptyMessage(1);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//view当前点击的控件,手指长按任意位置弹窗
|
||||
private void showMoreDialog(View v, int position, ImUserBean bean) {
|
||||
View pop_layout = LayoutInflater.from(getContext()).inflate(R.layout.popwindow_chat_withdraw, null);
|
||||
final PopupWindow mPopupWindow = new PopupWindow(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
mPopupWindow.setContentView(pop_layout);
|
||||
mPopupWindow.setFocusable(true);
|
||||
mPopupWindow.setOutsideTouchable(true);
|
||||
mPopupWindow.setBackgroundDrawable(new BitmapDrawable());
|
||||
mPopupWindow.update();
|
||||
|
||||
int w = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
|
||||
int h = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
|
||||
pop_layout.measure(w, h);
|
||||
//获取PopWindow宽和高,Constants.xIndex手势X轴Constants.xIndey手势Y轴
|
||||
int mHeight = pop_layout.getMeasuredHeight();
|
||||
int mWidth = pop_layout.getMeasuredWidth();
|
||||
//偏移量
|
||||
getActivity().getWindowManager();
|
||||
int xoff = Constants.xIndex - 2 * mWidth - 70;
|
||||
int yoff = 0 - (pop_layout.getHeight() - Constants.yindex) - 70;
|
||||
mPopupWindow.showAsDropDown(v, xoff, yoff, Gravity.RIGHT);
|
||||
|
||||
TextView tv_withdraw;
|
||||
CardView cv_chat;
|
||||
cv_chat = (CardView) pop_layout.findViewById(R.id.cv_chat);
|
||||
tv_withdraw = (TextView) pop_layout.findViewById(R.id.tv_withdraw);
|
||||
|
||||
// cv_chat.setBackgroundColor(getResources().getColor(R.color.gray_dcdcdc));
|
||||
tv_withdraw.setText(getResources().getString(R.string.delete));
|
||||
tv_withdraw.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mAdapter != null) {
|
||||
mAdapter.removeItem(position);
|
||||
cleanMessage(bean, "");
|
||||
removeMessage(bean);
|
||||
}
|
||||
mPopupWindow.dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//清除指定会话未读数
|
||||
private void cleanMessage(ImUserBean bean, String toId) {
|
||||
Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
|
||||
String targetId = "";
|
||||
if (bean != null) {
|
||||
targetId = bean.getUserId();
|
||||
} else {
|
||||
targetId = toId;
|
||||
}
|
||||
long timestamp = new Date().getTime();
|
||||
|
||||
RongIMClient.getInstance().clearMessagesUnreadStatus(conversationType, targetId, timestamp, new RongIMClient.OperationCallback() {
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
Log.i("Log", "清除未读数成功");
|
||||
getChatPoint();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(RongIMClient.ErrorCode errorCode) {
|
||||
Log.i("Log", "清除未读数失败");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//删除会话
|
||||
private void removeMessage(ImUserBean bean) {
|
||||
Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
|
||||
String targetId = bean.getUserId();
|
||||
long timestamp = new Date().getTime();
|
||||
|
||||
RongIMClient.getInstance().removeConversation(conversationType, targetId, new RongIMClient.ResultCallback<Boolean>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(Boolean success) {
|
||||
listUserBean.remove(bean);
|
||||
getChatPoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(RongIMClient.ErrorCode errorCode) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
getChatPoint();
|
||||
loadData();
|
||||
if (!"".equals(Constants.nowSendUid)) {
|
||||
getOneUserChat(Constants.nowSendUid);
|
||||
Constants.nowSendUid = "";
|
||||
}
|
||||
if (!"".equals(Constants.isSetRemark)) {
|
||||
for (int i = 0; i < listUserBean.size(); i++) {
|
||||
if (Constants.isSetRemark.equals(listUserBean.get(i).getUserId())) {
|
||||
listUserBean.get(i).setRemarks(Constants.isSetRemarkText);
|
||||
mHandler.sendEmptyMessage(1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
//存储备注名称
|
||||
// public void saveNameRemarks(List<ChatRemarksBean> remarksList) {
|
||||
// Gson gson = new Gson();
|
||||
// String str = gson.toJson(remarksList);
|
||||
// //用Sp或者sqlit也一样,已经变成json格式的一串字符串了
|
||||
// sharedPreferences.edit().putString("remarksList", str);
|
||||
// }
|
||||
|
||||
//取出备注的名称
|
||||
public void getNameRemarks() {
|
||||
Gson gson = new Gson();
|
||||
Type type = new TypeToken<List<ChatRemarksBean>>() {
|
||||
}.getType();
|
||||
Constants.remarksListNow = gson.fromJson(SpUtil.getStringValue("remarksList"), type);
|
||||
}
|
||||
|
||||
//粘性事件
|
||||
@Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
|
||||
public void onRongIMEvent(RongIMEvent event) {
|
||||
if (event.isInitRongIM()) {
|
||||
onResume();
|
||||
}
|
||||
//删除粘性事件
|
||||
RongIMEvent stickyEvent = EventBus.getDefault().getStickyEvent(RongIMEvent.class);
|
||||
if (stickyEvent != null) {
|
||||
EventBus.getDefault().removeStickyEvent(stickyEvent);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
package com.yunbao.live.activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.yunbao.common.bean.LiveBean;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.manager.imrongcloud.MessageIMManager;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.adapter.SystemChatMessageAdapter;
|
||||
import com.yunbao.live.bean.ImUserBean;
|
||||
import com.yunbao.live.event.RecommendLiveRoomEvent;
|
||||
import com.yunbao.common.http.LiveHttpUtil;
|
||||
import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import io.rong.imkit.conversationlist.ConversationListFragment;
|
||||
|
||||
/**
|
||||
* 直播页面聊天列表
|
||||
*/
|
||||
public class PDLIiveChatActivity extends FragmentActivity {
|
||||
private ConversationListFragment conversationListFragment;
|
||||
private FrameLayout container;
|
||||
private PDLIiveChatActivity mContext;
|
||||
private LinearLayout ltNodataMsg;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
setContentView(R.layout.activity_pd_chat);
|
||||
mContext = this;
|
||||
windowColor();
|
||||
initView();
|
||||
|
||||
Bus.getOn(this);
|
||||
}
|
||||
|
||||
|
||||
public void windowColor() {
|
||||
|
||||
Window window = getWindow();
|
||||
//取消设置Window半透明的Flag
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
//添加Flag把状态栏设为可绘制模式
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
||||
//设置状态栏为透明/或者需要的颜色
|
||||
window.setStatusBarColor(getResources().getColor(R.color.transparent));
|
||||
|
||||
getWindow().setGravity(Gravity.BOTTOM);//设置显示在底部 默认在中间
|
||||
WindowManager.LayoutParams lp = getWindow().getAttributes();
|
||||
lp.width = WindowManager.LayoutParams.MATCH_PARENT;//设置宽度满屏
|
||||
lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
|
||||
getWindow().setAttributes(lp);
|
||||
setFinishOnTouchOutside(true);//允许点击空白处关闭
|
||||
ltNodataMsg = findViewById(R.id.lt_nodata_msg);
|
||||
container = findViewById(R.id.container);
|
||||
if (IMLoginManager.get(mContext).hintChat()) {
|
||||
container.setVisibility(View.GONE);
|
||||
ltNodataMsg.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
container.setVisibility(View.VISIBLE);
|
||||
ltNodataMsg.setVisibility(View.GONE);
|
||||
|
||||
//展示会话列表
|
||||
conversationListFragment = new ConversationListFragment();
|
||||
FragmentManager manager = getSupportFragmentManager();
|
||||
FragmentTransaction transaction = manager.beginTransaction();
|
||||
transaction.replace(R.id.container, conversationListFragment);
|
||||
transaction.commit();
|
||||
//自定义空数据背景View
|
||||
conversationListFragment.setEmptyView(com.yunbao.live.R.layout.view_layout_msg);
|
||||
initData();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化控件
|
||||
*/
|
||||
private void initView() {
|
||||
container = findViewById(R.id.container);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化数据
|
||||
*/
|
||||
private void initData() {
|
||||
IMLoginManager.get(mContext).checkInstructor();
|
||||
|
||||
// //刷新列表内用户信息
|
||||
// addUserInfoProvider();
|
||||
|
||||
//获取一下系统通知
|
||||
MessageIMManager.get(this).getSystemMessages();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加头部系统消息
|
||||
*
|
||||
* @param listUserBean 数据源
|
||||
*/
|
||||
private void addSystemMessagesView(List<ImUserBean> listUserBean) {
|
||||
//倒序展示
|
||||
Collections.reverse(listUserBean);
|
||||
//展示会话列表
|
||||
conversationListFragment = new ConversationListFragment();
|
||||
FragmentManager manager = getSupportFragmentManager();
|
||||
FragmentTransaction transaction = manager.beginTransaction();
|
||||
transaction.replace(R.id.container, conversationListFragment);
|
||||
transaction.commit();
|
||||
//自定义空数据背景View
|
||||
conversationListFragment.setEmptyView(com.yunbao.live.R.layout.view_layout_msg);
|
||||
//初始化系统消息界面
|
||||
View rootView = LayoutInflater.from(mContext).inflate(R.layout.view_system_message, null, true);
|
||||
RecyclerView systemMessageList = rootView.findViewById(R.id.system_message_list);
|
||||
SystemChatMessageAdapter messageAdapter = new SystemChatMessageAdapter(mContext);
|
||||
messageAdapter.addDataAll(listUserBean);
|
||||
systemMessageList.setHasFixedSize(false);
|
||||
systemMessageList.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, true));
|
||||
systemMessageList.setAdapter(messageAdapter);
|
||||
conversationListFragment.addHeaderView(rootView);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 刷新用户信息(异步)
|
||||
// */
|
||||
// public void addUserInfoProvider() {
|
||||
// RongUserInfoManager.getInstance().setUserInfoProvider(userId -> {
|
||||
// CommonHttpUtil.getUserBaseinfo(userId, new HttpCallback() {
|
||||
// @Override
|
||||
// public void onSuccess(int code, String msg, String[] info) {
|
||||
// if (code == 0 && info.length > 0) {
|
||||
// JSONObject obj = JSON.parseObject(info[0]);
|
||||
// SearchUserBean userBean = JSON.toJavaObject(obj, SearchUserBean.class);
|
||||
// String userNiceName = "";
|
||||
// String remark = InstructorRemarkManager.get(mContext).getInstructorRemark().get(userId);
|
||||
// if (!TextUtils.isEmpty(remark)) {
|
||||
// userNiceName = remark;
|
||||
// } else {
|
||||
// userNiceName = userBean.getUserNiceName();
|
||||
// }
|
||||
// if (!TextUtils.isEmpty(userNiceName) && !TextUtils.isEmpty(userBean.getAvatar())) {
|
||||
// UserInfo userInfo = new UserInfo(userId, userNiceName, Uri.parse(userBean.getAvatar()));
|
||||
// //使用空白字段存储自己服务器用户的所有的信息
|
||||
// userInfo.setExtra(GsonUtils.toJson(userBean));
|
||||
// RongUserInfoManager.getInstance().refreshUserInfoCache(userInfo);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// return null;
|
||||
// }, true);
|
||||
//
|
||||
// }
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
EventBus.getDefault().post(new io.rong.imlib.model.Message());
|
||||
Bus.getOff(this);
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onRecommendLiveRoomEvent(RecommendLiveRoomEvent event) {
|
||||
LiveHttpUtil.getLiveInfo(event.getLiveuid(), new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
|
||||
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
|
||||
@Override
|
||||
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
|
||||
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckError(String contextError) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
RouteUtil.forwardUserHome(mContext, event.getLiveuid(), 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,264 @@
|
||||
package com.yunbao.live.activity;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import com.blankj.utilcode.util.GsonUtils;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.activity.SelectImageActivity;
|
||||
import com.yunbao.common.bean.IMLoginModel;
|
||||
import com.yunbao.common.bean.ImageEntity;
|
||||
import com.yunbao.common.bean.NoviceInstructorModel;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.manager.NoviceInstructorManager;
|
||||
import com.yunbao.common.manager.imrongcloud.MessageIMManager;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.bean.SearchUserBean;
|
||||
import com.yunbao.live.dialog.MenuPopuwWindow;
|
||||
import com.yunbao.live.event.InputPanelViewHolderEvent;
|
||||
import com.yunbao.live.utils.WindowSoftModeAdjustResizeExecutor;
|
||||
import com.yunbao.live.views.InputPanelViewHolder;
|
||||
import com.yunbao.live.views.PDLiveConversationFragment;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import io.rong.imkit.IMCenter;
|
||||
import io.rong.imkit.userinfo.RongUserInfoManager;
|
||||
import io.rong.imlib.RongIMClient;
|
||||
import io.rong.imlib.model.Conversation;
|
||||
import io.rong.imlib.model.UserInfo;
|
||||
|
||||
/**
|
||||
* 聊天会话界面
|
||||
*/
|
||||
public class PDLiveConversationActivity extends AbsActivity implements View.OnClickListener {
|
||||
private PDLiveConversationFragment conversationFragment;
|
||||
private PDLiveConversationActivity mContext;
|
||||
private InputPanelViewHolder inputPanel;
|
||||
private TextView titleView;
|
||||
private ImageView imgMore, imBack;
|
||||
private boolean isAdmin = false;
|
||||
private final int PERMISSION_REQUEST_CODE = 0;
|
||||
private final int SELECT_VIDEO_REQUEST = 0x0002;
|
||||
private final int SELECT_IMAGE_REQUEST = 0x0001;
|
||||
private ArrayList<ImageEntity> mSelectImages = new ArrayList<>();
|
||||
private String targetId = "";
|
||||
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_conversation;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
super.main();
|
||||
EventBus.getDefault().register(this);
|
||||
mContext = this;
|
||||
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
|
||||
initView();
|
||||
initData();
|
||||
WindowSoftModeAdjustResizeExecutor.assistActivity(this);
|
||||
//设置会话界面操作监听器
|
||||
MessageIMManager.get(this).addConversationClickListener();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 数据的设置
|
||||
*/
|
||||
private void initData() {
|
||||
targetId = getIntent().getStringExtra("targetId");
|
||||
NoviceInstructorModel model = NoviceInstructorManager.get(this).getNoviceInstructor();
|
||||
|
||||
//绑定聊天用户id
|
||||
inputPanel.setTargetId(targetId);
|
||||
//获取用户信息
|
||||
UserInfo userInfo = RongUserInfoManager.getInstance().getUserInfo(targetId);
|
||||
if (null != userInfo) {
|
||||
titleView.setText(userInfo.getName());
|
||||
if (!TextUtils.isEmpty(userInfo.getExtra())) {
|
||||
SearchUserBean userBean = GsonUtils.fromJson(userInfo.getExtra(), SearchUserBean.class);
|
||||
//新手指导员
|
||||
if (!TextUtils.isEmpty(userBean.getIs_admin()) && TextUtils.equals(userBean.getIs_admin(), "1")) {
|
||||
if (model != null && !TextUtils.isEmpty(model.getMsgZdySendText())) {
|
||||
inputPanel.setPresetInformation(model.getMsgZdySendText());
|
||||
}
|
||||
isAdmin = true;
|
||||
imgMore.setVisibility(View.GONE);
|
||||
} else {//非指导员
|
||||
isAdmin = false;
|
||||
imgMore.setVisibility(View.VISIBLE);
|
||||
}
|
||||
inputPanel.setAdmin(isAdmin);
|
||||
Log.e("PDLiveConversation", userInfo.getExtra());
|
||||
}
|
||||
} else {
|
||||
titleView.setText("系統消息");
|
||||
inputPanel.setVisibility(View.GONE);
|
||||
}
|
||||
getDraft();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化布局
|
||||
*/
|
||||
private void initView() {
|
||||
try {
|
||||
// 添加会话界面
|
||||
conversationFragment = new PDLiveConversationFragment();
|
||||
FragmentManager manager = getSupportFragmentManager();
|
||||
FragmentTransaction transaction = manager.beginTransaction();
|
||||
transaction.replace(R.id.container, conversationFragment);
|
||||
transaction.commit();
|
||||
inputPanel = findViewById(R.id.input_panel);
|
||||
titleView = findViewById(R.id.titleView);
|
||||
imgMore = findViewById(R.id.img_more);
|
||||
imBack = findViewById(R.id.btn_back);
|
||||
imgMore.setOnClickListener(this);
|
||||
imBack.setOnClickListener(this);
|
||||
|
||||
inputPanel.addMediaMessageCallback(new InputPanelViewHolder.MediaMessageCallback() {
|
||||
@Override
|
||||
public void choosePic(int intoIndex) {
|
||||
jumpPic(intoIndex);
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int id = v.getId();
|
||||
//菜单
|
||||
if (id == R.id.img_more) {
|
||||
IMLoginModel model = IMLoginManager.get(mContext).getUserInfo();
|
||||
new MenuPopuwWindow(mContext).setIsAdmin(model.getIsAdmin(), targetId).show(imgMore);
|
||||
} else if (id == R.id.btn_back) {//返回
|
||||
onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
//intoIndex 1=调用相机,2=照片选取,3=视频选取
|
||||
public void jumpPic(int intoIndex) {
|
||||
String permission1=Manifest.permission.READ_EXTERNAL_STORAGE;
|
||||
String permission2= Manifest.permission.WRITE_EXTERNAL_STORAGE;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
permission1=Manifest.permission.READ_MEDIA_IMAGES;
|
||||
permission2=Manifest.permission.READ_MEDIA_VIDEO;
|
||||
}
|
||||
|
||||
//选择图片
|
||||
int isPermission1 = ContextCompat.checkSelfPermission(mContext, permission1);
|
||||
int isPermission2 = ContextCompat.checkSelfPermission(mContext, permission2);
|
||||
if (isPermission1 == PackageManager.PERMISSION_GRANTED && isPermission2 == PackageManager.PERMISSION_GRANTED) {
|
||||
startActivity(intoIndex);
|
||||
} else {
|
||||
//申请权限
|
||||
ActivityCompat.requestPermissions(mContext, new String[]{permission1,
|
||||
permission2}, PERMISSION_REQUEST_CODE);
|
||||
}
|
||||
}
|
||||
|
||||
private void startActivity(int intoIndex) {
|
||||
mSelectImages.clear();
|
||||
Intent intent = new Intent(mContext, SelectImageActivity.class);
|
||||
intent.putParcelableArrayListExtra("selected_images", mSelectImages);
|
||||
intent.putExtra("intoIndex", intoIndex);
|
||||
if (intoIndex == 3) {
|
||||
startActivityForResult(intent, SELECT_VIDEO_REQUEST);
|
||||
} else {
|
||||
startActivityForResult(intent, SELECT_IMAGE_REQUEST);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取草稿箱信息系
|
||||
*/
|
||||
private void getDraft() {
|
||||
RongIMClient.getInstance().getTextMessageDraft(Conversation.ConversationType.PRIVATE, targetId, new RongIMClient.ResultCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String s) {
|
||||
if (!TextUtils.isEmpty(s))
|
||||
inputPanel.setPresetInformation(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(RongIMClient.ErrorCode errorCode) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (resultCode == RESULT_OK) {
|
||||
if (requestCode == SELECT_IMAGE_REQUEST && data != null) {
|
||||
ArrayList<ImageEntity> selectImages = data.getParcelableArrayListExtra(SelectImageActivity.EXTRA_RESULT);
|
||||
for (ImageEntity entity : selectImages) {
|
||||
inputPanel.sendImageFile(entity.getPath());
|
||||
}
|
||||
|
||||
} else if (requestCode == SELECT_VIDEO_REQUEST && data != null) {
|
||||
ArrayList<ImageEntity> selectImages = data.getParcelableArrayListExtra(SelectImageActivity.EXTRA_RESULT);
|
||||
for (ImageEntity entity : selectImages) {
|
||||
inputPanel.sendVideoFile(entity.getPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
//获取输入框信息存进输入框
|
||||
String content = inputPanel.getPresetInformation();
|
||||
if (!TextUtils.isEmpty(content)) {
|
||||
IMCenter.getInstance().saveTextMessageDraft(Conversation.ConversationType.PRIVATE, targetId, content, null);
|
||||
}
|
||||
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
|
||||
//消息中心
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onMessageIMEvent(String event) {
|
||||
if (!TextUtils.isEmpty(event)) {
|
||||
titleView.setText(event);
|
||||
}
|
||||
}
|
||||
|
||||
//消息中心
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onInputPanelViewHolderEvent(InputPanelViewHolderEvent event) {
|
||||
((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
|
||||
inputPanel.hidePluginList();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
package com.yunbao.live.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.adapter.ViewPagerAdapter;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.views.AbsCommonViewHolder;
|
||||
import com.yunbao.live.views.LiveMyLiveRoomViewHolder;
|
||||
import com.yunbao.live.views.LiveMyRoomViewHolder;
|
||||
|
||||
import net.lucode.hackware.magicindicator.MagicIndicator;
|
||||
import net.lucode.hackware.magicindicator.ViewPagerHelper;
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.CommonNavigator;
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter;
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerIndicator;
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerTitleView;
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.indicators.LinePagerIndicator;
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.ColorTransitionPagerTitleView;
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.SimplePagerTitleView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2019/4/27.
|
||||
*/
|
||||
|
||||
public class RoomManageActivity extends AbsActivity {
|
||||
|
||||
private static final int PAGE_COUNT = 2;
|
||||
private List<FrameLayout> mViewList;
|
||||
private MagicIndicator mIndicator;
|
||||
private AbsCommonViewHolder[] mViewHolders;
|
||||
private ViewPager mViewPager;
|
||||
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_room_manage;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
mViewList = new ArrayList<>();
|
||||
for (int i = 0; i < PAGE_COUNT; i++) {
|
||||
FrameLayout frameLayout = new FrameLayout(mContext);
|
||||
frameLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
mViewList.add(frameLayout);
|
||||
}
|
||||
mViewPager = (ViewPager) findViewById(R.id.viewPager);
|
||||
if (PAGE_COUNT > 1) {
|
||||
mViewPager.setOffscreenPageLimit(PAGE_COUNT - 1);
|
||||
}
|
||||
mViewPager.setAdapter(new ViewPagerAdapter(mViewList));
|
||||
mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
loadPageData(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged(int state) {
|
||||
|
||||
}
|
||||
});
|
||||
mViewHolders = new AbsCommonViewHolder[PAGE_COUNT];
|
||||
mIndicator = (MagicIndicator) findViewById(R.id.indicator);
|
||||
final String[] titles = new String[]{mContext.getString(R.string.live_my_live_room),mContext.getString(R.string.live_my_room)};
|
||||
CommonNavigator commonNavigator = new CommonNavigator(mContext);
|
||||
commonNavigator.setAdapter(new CommonNavigatorAdapter() {
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return titles.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPagerTitleView getTitleView(Context context, final int index) {
|
||||
SimplePagerTitleView simplePagerTitleView = new ColorTransitionPagerTitleView(context);
|
||||
simplePagerTitleView.setNormalColor(ContextCompat.getColor(mContext, R.color.gray1));
|
||||
simplePagerTitleView.setSelectedColor(ContextCompat.getColor(mContext, R.color.textColor));
|
||||
simplePagerTitleView.setText(titles[index]);
|
||||
simplePagerTitleView.setTextSize(17);
|
||||
simplePagerTitleView.getPaint().setFakeBoldText(true);
|
||||
simplePagerTitleView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mViewPager != null) {
|
||||
mViewPager.setCurrentItem(index);
|
||||
}
|
||||
}
|
||||
});
|
||||
return simplePagerTitleView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPagerIndicator getIndicator(Context context) {
|
||||
LinePagerIndicator linePagerIndicator = new LinePagerIndicator(context);
|
||||
linePagerIndicator.setMode(LinePagerIndicator.MODE_EXACTLY);
|
||||
linePagerIndicator.setLineWidth(DpUtil.dp2px(18));
|
||||
linePagerIndicator.setRoundRadius(DpUtil.dp2px(2));
|
||||
linePagerIndicator.setColors(ContextCompat.getColor(mContext, R.color.global));
|
||||
return linePagerIndicator;
|
||||
}
|
||||
|
||||
});
|
||||
mIndicator.setNavigator(commonNavigator);
|
||||
LinearLayout titleContainer = commonNavigator.getTitleContainer();
|
||||
titleContainer.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
|
||||
titleContainer.setDividerDrawable(new ColorDrawable() {
|
||||
@Override
|
||||
public int getIntrinsicWidth() {
|
||||
return DpUtil.dp2px(30);
|
||||
}
|
||||
});
|
||||
ViewPagerHelper.bind(mIndicator, mViewPager);
|
||||
loadPageData(0);
|
||||
}
|
||||
|
||||
|
||||
private void loadPageData(int position) {
|
||||
if (mViewHolders == null) {
|
||||
return;
|
||||
}
|
||||
AbsCommonViewHolder vh = mViewHolders[position];
|
||||
if (vh == null) {
|
||||
if (mViewList != null && position < mViewList.size()) {
|
||||
FrameLayout parent = mViewList.get(position);
|
||||
if (parent == null) {
|
||||
return;
|
||||
}
|
||||
if (position == 0) {
|
||||
vh = new LiveMyLiveRoomViewHolder(mContext, parent);
|
||||
} else if (position == 1) {
|
||||
vh = new LiveMyRoomViewHolder(mContext, parent);
|
||||
}
|
||||
if (vh == null) {
|
||||
return;
|
||||
}
|
||||
mViewHolders[position] = vh;
|
||||
vh.addToParent();
|
||||
vh.subscribeActivityLifeCycle();
|
||||
}
|
||||
}
|
||||
if (vh != null) {
|
||||
vh.loadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.yunbao.live.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.View;
|
||||
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.bean.LiveAdminRoomBean;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2019/4/27.
|
||||
*/
|
||||
|
||||
public class RoomManageDetailActivity extends AbsActivity implements View.OnClickListener {
|
||||
|
||||
public static void forward(Context context, LiveAdminRoomBean bean) {
|
||||
Intent intent = new Intent(context, RoomManageDetailActivity.class);
|
||||
intent.putExtra(Constants.LIVE_ADMIN_ROOM, bean);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
|
||||
private LiveAdminRoomBean mAdminRoomBean;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_room_manage_detail;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
mAdminRoomBean = getIntent().getParcelableExtra(Constants.LIVE_ADMIN_ROOM);
|
||||
if (mAdminRoomBean == null) {
|
||||
return;
|
||||
}
|
||||
setTitle(StringUtil.contact(mAdminRoomBean.getUserNiceName(), mContext.getString(R.string.live_admin_room)));
|
||||
findViewById(R.id.btn_user_shut_up).setOnClickListener(this);
|
||||
findViewById(R.id.btn_user_black).setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int i = v.getId();
|
||||
if (i == R.id.btn_user_shut_up) {
|
||||
LiveShutUpActivity.forward(mContext, mAdminRoomBean.getLiveUid());
|
||||
} else if (i == R.id.btn_user_black) {
|
||||
LiveBlackActivity.forward(mContext, mAdminRoomBean.getLiveUid());
|
||||
}
|
||||
}
|
||||
}
|
||||
682
live/src/main/java/com/yunbao/live/activity/SudGameActivity.java
Normal file
682
live/src/main/java/com/yunbao/live/activity/SudGameActivity.java
Normal file
@@ -0,0 +1,682 @@
|
||||
package com.yunbao.live.activity;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.google.gson.Gson;
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.adapter.SudGameChatAdapter;
|
||||
import com.yunbao.common.adapter.SudGameUserListAdapter;
|
||||
import com.yunbao.common.bean.CheckRemainingBalance;
|
||||
import com.yunbao.common.bean.CreateSudRoomModel;
|
||||
import com.yunbao.common.bean.CustomSidebarChildModel;
|
||||
import com.yunbao.common.bean.CustomSidebarInfoModel;
|
||||
import com.yunbao.common.bean.HttpCallbackModel;
|
||||
import com.yunbao.common.bean.RoomMicStatusModel;
|
||||
import com.yunbao.common.bean.SudGameChatImModel;
|
||||
import com.yunbao.common.bean.SudGameUserModel;
|
||||
import com.yunbao.common.dialog.SudGameInputPopupWindow;
|
||||
import com.yunbao.common.event.CheckRemainingBalanceEvent;
|
||||
import com.yunbao.common.event.SudGameSocketImEvent;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.manager.imrongcloud.GameMicManager;
|
||||
import com.yunbao.common.sud.QuickStartGameViewModel;
|
||||
import com.yunbao.common.sud.model.GameConfigModel;
|
||||
import com.yunbao.common.sud.model.GameViewInfoModel;
|
||||
import com.yunbao.common.sud.state.SudMGPMGState;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.ProcessResultUtil;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.common.views.LiveSudGameHistoryPopup;
|
||||
import com.yunbao.common.views.TopGradual;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
import com.yunbao.live.dialog.LiveUserDialogFragment;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import cn.rongcloud.rtc.api.RCRTCEngine;
|
||||
import cn.rongcloud.rtc.api.RCRTCRemoteUser;
|
||||
import cn.rongcloud.rtc.api.RCRTCRoom;
|
||||
import cn.rongcloud.rtc.api.stream.RCRTCInputStream;
|
||||
import cn.rongcloud.rtc.base.RTCErrorCode;
|
||||
|
||||
@Route(path = RouteUtil.PATH_SudGameActivity)
|
||||
public class SudGameActivity extends AbsActivity implements GameMicManager.MeetingCallback {
|
||||
private FrameLayout gameContainer;
|
||||
private long mInteractionID;
|
||||
private String mLiveUid;
|
||||
private final QuickStartGameViewModel gameViewModel = new QuickStartGameViewModel(); // 创建ViewModel
|
||||
|
||||
private CreateSudRoomModel mCreateSudRoomModel;
|
||||
private TextView roomName, roomNumber;
|
||||
private GameMicManager gameMicManager;
|
||||
private ImageView gameCloseWheat, gameSeat;
|
||||
private boolean disable = true, publishDefault = false;
|
||||
|
||||
private RecyclerView chatList, userList;
|
||||
private SudGameChatAdapter mLiveChatAdapter;
|
||||
private SudGameUserListAdapter sudGameUserListAdapter;
|
||||
private ProcessResultUtil mProcessResultUtil;
|
||||
private List<String> muteUser = new ArrayList<>();
|
||||
private boolean imOff;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_sud_game;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
Bus.getOn(this);
|
||||
super.main();
|
||||
initView();
|
||||
initDate();
|
||||
}
|
||||
|
||||
private List<CustomSidebarChildModel> customSidebarChildModels = new ArrayList<>();
|
||||
|
||||
private void initDate() {
|
||||
|
||||
LiveNetManager.get(mContext)
|
||||
.getCustomSidebarInfo("1", new HttpCallback<List<CustomSidebarInfoModel>>() {
|
||||
@Override
|
||||
public void onSuccess(List<CustomSidebarInfoModel> data) {
|
||||
for (CustomSidebarInfoModel datum : data) {
|
||||
if (datum.getType().equals("6")) {
|
||||
customSidebarChildModels = datum.getChild();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
// 设置禁用麦克风采集
|
||||
RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable);
|
||||
ImgLoader.display(mContext, R.mipmap.icon_game_close_wheat, gameCloseWheat);
|
||||
gameCloseWheat.setVisibility(View.INVISIBLE);
|
||||
|
||||
|
||||
mProcessResultUtil = new ProcessResultUtil(this);
|
||||
LiveNetManager.get(mContext)
|
||||
.getRoomMicStatus(new HttpCallback<RoomMicStatusModel>() {
|
||||
@Override
|
||||
public void onSuccess(RoomMicStatusModel data) {
|
||||
gameMicManager = new GameMicManager();
|
||||
gameMicManager.attachView(SudGameActivity.this);
|
||||
gameMicManager.config(SudGameActivity.this);
|
||||
//语音
|
||||
if (TextUtils.equals(data.getMicStatus(), "1")) {
|
||||
imOff = true;
|
||||
gameSeat.setVisibility(View.VISIBLE);
|
||||
userList.setVisibility(View.VISIBLE);
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!mProcessResultUtil.checkPermissions(new String[]{Manifest.permission.RECORD_AUDIO})) {
|
||||
ToastUtil.show("拒绝权限将无法使用上麦功能");
|
||||
mProcessResultUtil.requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}, 1500);
|
||||
} else {
|
||||
imOff = false;
|
||||
gameSeat.setVisibility(View.GONE);
|
||||
userList.setVisibility(View.GONE);
|
||||
}
|
||||
if (TextUtils.equals(data.getImStatus(), "1")) {
|
||||
findViewById(R.id.game_review_input).setVisibility(View.VISIBLE);
|
||||
chatList.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
findViewById(R.id.game_review_input).setVisibility(View.GONE);
|
||||
chatList.setVisibility(View.GONE);
|
||||
}
|
||||
gameMicManager.joinRoom(mLiveUid, imOff);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
imOff = false;
|
||||
//文字
|
||||
findViewById(R.id.game_review_input).setVisibility(View.GONE);
|
||||
chatList.setVisibility(View.GONE);
|
||||
//语音
|
||||
gameCloseWheat.setVisibility(View.GONE);
|
||||
gameSeat.setVisibility(View.GONE);
|
||||
userList.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
|
||||
LiveNetManager.get(mContext)
|
||||
.leaveMic(mLiveUid, new HttpCallback<HttpCallbackModel>() {
|
||||
@Override
|
||||
public void onSuccess(HttpCallbackModel data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
if (gameMicManager != null) {
|
||||
gameMicManager.leaveRoom();
|
||||
gameMicManager.detachView();
|
||||
}
|
||||
Bus.getOff(this);
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
|
||||
String createSudRoomJson = getIntent().getStringExtra("CreateSudRoom");
|
||||
mCreateSudRoomModel = new Gson().fromJson(createSudRoomJson, CreateSudRoomModel.class);
|
||||
mInteractionID = mCreateSudRoomModel.getLongSudGameId();
|
||||
mLiveUid = mCreateSudRoomModel.getSudGameRoomId();
|
||||
|
||||
gameContainer = findViewById(R.id.game_container);
|
||||
roomName = findViewById(R.id.room_name);
|
||||
roomNumber = findViewById(R.id.room_number);
|
||||
gameCloseWheat = findViewById(R.id.game_close_wheat);
|
||||
gameSeat = findViewById(R.id.game_seat);
|
||||
chatList = findViewById(R.id.chat_list);
|
||||
userList = findViewById(R.id.user_list);
|
||||
//聊天栏
|
||||
FrameLayout.LayoutParams params1 = (FrameLayout.LayoutParams)
|
||||
chatList.getLayoutParams();
|
||||
params1.topMargin = DpUtil.dp2px(65);
|
||||
chatList.setLayoutParams(params1);
|
||||
|
||||
chatList.setHasFixedSize(true);
|
||||
LinearLayoutManager layoutManager = new LinearLayoutManager(mContext);
|
||||
layoutManager.setOrientation(RecyclerView.VERTICAL);
|
||||
layoutManager.setStackFromEnd(true);
|
||||
chatList.setLayoutManager(layoutManager);
|
||||
chatList.addItemDecoration(new TopGradual());
|
||||
chatList.setItemViewCacheSize(10);
|
||||
mLiveChatAdapter = new SudGameChatAdapter(mContext);
|
||||
chatList.setAdapter(mLiveChatAdapter);
|
||||
sudGameUserListAdapter = new SudGameUserListAdapter(new ArrayList<>());
|
||||
ImgLoader.display(mContext, WordUtil.isNewZh() ? R.mipmap.icon_game_seat : R.mipmap.icon_game_seat_en, gameSeat);
|
||||
sudGameUserListAdapter.setSudGameSmallCallBack(new SudGameUserListAdapter.SudGameSmallCallBack() {
|
||||
@Override
|
||||
public void unMute(String userID, int position) {
|
||||
if (!TextUtils.equals(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()), userID)) {
|
||||
gameMicManager.refreshStreams(userID, false, position);
|
||||
} else {
|
||||
ToastUtil.show(WordUtil.isNewZh() ? "無法對本人靜音" : "Unable to mute myself");
|
||||
}
|
||||
muteUser.remove(userID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mute(String userID, int position) {
|
||||
muteUser.add(userID);
|
||||
if (!TextUtils.equals(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()), userID)) {
|
||||
gameMicManager.refreshStreams(userID, true, position);
|
||||
} else {
|
||||
ToastUtil.show(WordUtil.isNewZh() ? "無法對本人靜音" : "Unable to mute myself");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viewInformation(SudGameUserModel sudGameUserModel) {
|
||||
LiveUserDialogFragment fragment = new LiveUserDialogFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(Constants.LIVE_UID, "uid");
|
||||
bundle.putString(Constants.STREAM, "");
|
||||
bundle.putString(Constants.TO_UID, sudGameUserModel.getId() + "");
|
||||
fragment.setArguments(bundle);
|
||||
fragment.show(((SudGameActivity) mContext).getSupportFragmentManager(), "LiveUserDialogFragment");
|
||||
}
|
||||
});
|
||||
userList.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false));
|
||||
userList.setAdapter(sudGameUserListAdapter);
|
||||
if (mCreateSudRoomModel != null) {
|
||||
roomName.setText(mCreateSudRoomModel.getRoomName());
|
||||
roomNumber.setText(mCreateSudRoomModel.getSudGameRoomId());
|
||||
}
|
||||
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.exit), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
gameViewModel.onDestroy();
|
||||
finish();
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.sud_history), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
|
||||
new XPopup.Builder(mContext)
|
||||
.enableDrag(false)
|
||||
.asCustom(new LiveSudGameHistoryPopup(mContext, customSidebarChildModels)).show();
|
||||
}
|
||||
});
|
||||
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.game_seat), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
if (imOff && gameMicManager != null) {
|
||||
if (mProcessResultUtil.checkPermissions(new String[]{Manifest.permission.RECORD_AUDIO})) {
|
||||
if (publishDefault) {
|
||||
disable = true;
|
||||
// 设置禁用麦克风采集
|
||||
RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable);
|
||||
// ImgLoader.display(mContext, R.mipmap.icon_game_close_wheat, gameCloseWheat);
|
||||
gameMicManager.unPublishStreams();
|
||||
} else {
|
||||
if (sudGameUserListAdapter.isMicMax()) {
|
||||
ToastUtil.show(WordUtil.isNewZh() ? "上麥人數最大7人" : "The maximum number of people on the microphone is 7");
|
||||
} else {
|
||||
gameMicManager.publishDefaultAVStream();
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
mProcessResultUtil.requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(gameCloseWheat, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
if (imOff && gameMicManager != null) {
|
||||
|
||||
gameCloseWheat.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (disable) {
|
||||
disable = false;
|
||||
// 设置禁用麦克风采集
|
||||
RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable);
|
||||
ImgLoader.display(mContext, R.mipmap.icon_game_open_wheat, gameCloseWheat);
|
||||
LiveNetManager.get(mContext)
|
||||
.onMic(mLiveUid, new HttpCallback<HttpCallbackModel>() {
|
||||
@Override
|
||||
public void onSuccess(HttpCallbackModel data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
ToastUtil.show(WordUtil.isNewZh() ? "麥克風已開啟" : "Microphone turned on");
|
||||
} else {
|
||||
disable = true;
|
||||
// 设置禁用麦克风采集
|
||||
RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable);
|
||||
ImgLoader.display(mContext, R.mipmap.icon_game_close_wheat, gameCloseWheat);
|
||||
LiveNetManager.get(mContext)
|
||||
.offMic(mLiveUid, new HttpCallback<HttpCallbackModel>() {
|
||||
@Override
|
||||
public void onSuccess(HttpCallbackModel data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
ToastUtil.show(WordUtil.isNewZh() ? "麥克風已關閉" : "Microphone turned off");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.game_review_input), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
new XPopup.Builder(mContext)
|
||||
.enableDrag(false)
|
||||
.asCustom(new SudGameInputPopupWindow(mContext, new SudGameInputPopupWindow.SudGameInputCallBack() {
|
||||
@Override
|
||||
public void sendMessage(String textMessage) {
|
||||
gameMicManager.sendMessage(textMessage);
|
||||
}
|
||||
}))
|
||||
.show();
|
||||
}
|
||||
});
|
||||
|
||||
gameViewModel.gameViewLiveData.observe(this, new Observer<View>() {
|
||||
@Override
|
||||
public void onChanged(View view) {
|
||||
if (view == null) { // 在关闭游戏时,把游戏View给移除
|
||||
gameContainer.removeAllViews();
|
||||
} else { // 把游戏View添加到容器内
|
||||
gameContainer.addView(view, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
// 加载游戏,参数定义可查看BaseGameViewModel.switchGame()方法注释
|
||||
// 游戏配置
|
||||
GameConfigModel gameConfigModel = gameViewModel.getGameConfigModel();
|
||||
gameConfigModel.ui.ping.hide = true; // 配置不隐藏ping值
|
||||
gameConfigModel.ui.level.hide = true; // 配置不隐藏ping值
|
||||
gameConfigModel.ui.lobby_game_setting.hide = true; // 配置不隐藏ping值
|
||||
|
||||
gameConfigModel.ui.lobby_players.custom = true;
|
||||
gameConfigModel.ui.join_btn.custom = true;
|
||||
gameConfigModel.ui.game_settle_again_btn.custom = true;
|
||||
gameConfigModel.ui.start_btn.custom = true;
|
||||
|
||||
|
||||
// SudMGP平台64bit游戏ID
|
||||
gameViewModel.switchGame((Activity) mContext, mLiveUid, mInteractionID);
|
||||
// gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfIn(true, -1, true, 1);
|
||||
// gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfCaptain(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()));
|
||||
// ViewClicksAntiShake.clicksAntiShake(gameTitle, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
// @Override
|
||||
// public void onViewClicks() {
|
||||
//
|
||||
// }
|
||||
// });
|
||||
// 设置游戏安全操作区域
|
||||
GameViewInfoModel.GameViewRectModel gameViewRectModel = new GameViewInfoModel.GameViewRectModel();
|
||||
gameViewRectModel.left = 0;
|
||||
gameViewRectModel.top = DpUtil.dp2px(155);
|
||||
gameViewRectModel.right = 0;
|
||||
gameViewRectModel.bottom = DpUtil.dp2px(155);
|
||||
gameViewModel.gameViewRectModel = gameViewRectModel;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onCheckRemainingBalanceEvent(CheckRemainingBalanceEvent event) {
|
||||
switch (event.getSudMGPMGState()) {
|
||||
case SudMGPMGState.MG_COMMON_SELF_CLICK_JOIN_BTN:
|
||||
case SudMGPMGState.MG_COMMON_SELF_CLICK_GAME_SETTLE_AGAIN_BTN:
|
||||
|
||||
LiveNetManager.get(mContext).checkRemainingBalance(mCreateSudRoomModel.getSudGameRoomId(), new HttpCallback<CheckRemainingBalance>() {
|
||||
@Override
|
||||
public void onSuccess(CheckRemainingBalance data) {
|
||||
if (TextUtils.equals(String.valueOf(data.getGoldenBeanRemainingBalance()), "1")) {
|
||||
gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfIn(true, event.getSeatIndex(), true, 1);
|
||||
} else {
|
||||
if (IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) {
|
||||
ToastUtil.show("貨幣数量不足 ");
|
||||
} else {
|
||||
ToastUtil.show("Shortage of money");
|
||||
}
|
||||
|
||||
}
|
||||
// ToastUtil.show(data.toString());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
if (IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) {
|
||||
ToastUtil.show("貨幣数量不足 ");
|
||||
} else {
|
||||
ToastUtil.show("Shortage of money");
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
break;
|
||||
case SudMGPMGState.MG_COMMON_GAME_SETTLE:
|
||||
gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfIn(false, event.getSeatIndex(), true, 1);
|
||||
break;
|
||||
case SudMGPMGState.MG_COMMON_SELF_CLICK_START_BTN:
|
||||
LiveNetManager.get(mContext).gameStartCheckRemainingBalance(mCreateSudRoomModel.getSudGameId(),
|
||||
mCreateSudRoomModel.getSudGameRoomId(), new
|
||||
HttpCallback<CheckRemainingBalance>() {
|
||||
@Override
|
||||
public void onSuccess(CheckRemainingBalance data) {
|
||||
if (data.getStatus() == 1) {
|
||||
gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfPlaying(true);
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
ToastUtil.show(error);
|
||||
}
|
||||
});
|
||||
break;
|
||||
case SudMGPMGState.MG_COMMON_GAME_STATE:
|
||||
LiveNetManager.get(mContext).deductMoney(mCreateSudRoomModel.getSudGameRoomId());
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJoinRoomSuccess(RCRTCRoom rcrtcRoom) {
|
||||
LiveNetManager.get(mContext).getRoomMicData(mLiveUid, new HttpCallback<List<SudGameUserModel>>() {
|
||||
@Override
|
||||
public void onSuccess(List<SudGameUserModel> data) {
|
||||
|
||||
gameMicManager.refreshStreams(data);
|
||||
sudGameUserListAdapter.refreshSudGameUserList(data, muteUser);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
ToastUtil.show(error);
|
||||
}
|
||||
});
|
||||
// 主动订阅远端用户发布的资源
|
||||
// gameMicManager.subscribeAVStream();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJoinRoomFailed(RTCErrorCode rtcErrorCode) {
|
||||
ToastUtil.show("加入失败 " + rtcErrorCode.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPublishSuccess() {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ImgLoader.display(mContext, WordUtil.isNewZh() ? R.mipmap.icon_game_hang_up : R.mipmap.icon_game_hang_up_en, gameSeat);
|
||||
publishDefault = true;
|
||||
gameCloseWheat.setVisibility(View.VISIBLE);
|
||||
disable = false;
|
||||
// 设置禁用麦克风采集
|
||||
RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable);
|
||||
ImgLoader.display(mContext, R.mipmap.icon_game_open_wheat, gameCloseWheat);
|
||||
}
|
||||
});
|
||||
|
||||
LiveNetManager.get(mContext)
|
||||
.joinMic(mLiveUid, new HttpCallback<HttpCallbackModel>() {
|
||||
@Override
|
||||
public void onSuccess(HttpCallbackModel data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPublishFailed() {
|
||||
ToastUtil.show(WordUtil.isNewZh() ? "語音加入失敗" : "Voice joining failed");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSubscribeSuccess(List<RCRTCInputStream> inputStreamList) {
|
||||
// ToastUtil.show("订阅成功 ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSubscribeFailed() {
|
||||
ToastUtil.show("订阅失败 ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSubscribeSuccess(String userID, boolean mute, int position) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mute) {
|
||||
ToastUtil.show(WordUtil.isNewZh() ? "已靜音該用戶" : "The user has been muted");
|
||||
} else {
|
||||
ToastUtil.show(WordUtil.isNewZh() ? "已取消該用戶靜音" : "The user has been unmuted");
|
||||
}
|
||||
sudGameUserListAdapter.muteUser(userID, mute, position);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSubscribeFailed(String userID) {
|
||||
ToastUtil.show("订阅失败 ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUserJoined(RCRTCRemoteUser rcrtcRemoteUser) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUserLeft(RCRTCRemoteUser rcrtcRemoteUser) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertItem(SudGameChatImModel sudGameChatImModel) {
|
||||
mLiveChatAdapter.insertItem(sudGameChatImModel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshSudGameUserList(List<SudGameUserModel> personList) {
|
||||
sudGameUserListAdapter.refreshSudGameUserList(personList, muteUser);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnPublishStreamsSuccess() {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ImgLoader.display(mContext, WordUtil.isNewZh() ? R.mipmap.icon_game_seat : R.mipmap.icon_game_seat_en, gameSeat);
|
||||
publishDefault = false;
|
||||
gameCloseWheat.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
});
|
||||
LiveNetManager.get(mContext)
|
||||
.leaveMic(mLiveUid, new HttpCallback<HttpCallbackModel>() {
|
||||
@Override
|
||||
public void onSuccess(HttpCallbackModel data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnPublishStreamsFailed() {
|
||||
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onSudGameSocketImEvent(SudGameSocketImEvent event) {
|
||||
gameMicManager.processingMessage(event);
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onSudGameUserModel(SudGameUserModel model) {
|
||||
if (model.isNullUser()) {
|
||||
if (!publishDefault) {
|
||||
if (mProcessResultUtil.checkPermissions(new String[]{Manifest.permission.RECORD_AUDIO})) {
|
||||
if (sudGameUserListAdapter.isMicMax()) {
|
||||
ToastUtil.show(WordUtil.isNewZh() ? "上麥人數最大7人" : "The maximum number of people on the microphone is 7");
|
||||
} else {
|
||||
gameMicManager.publishDefaultAVStream();
|
||||
}
|
||||
|
||||
} else {
|
||||
mProcessResultUtil.requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
} else {
|
||||
ToastUtil.show(WordUtil.isNewZh() ? "已經是上麥狀態" : "It is already in the wheat state");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
package com.yunbao.live.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.activity.SelectImageActivity;
|
||||
import com.yunbao.common.bean.ImageEntity;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.bean.SystemMessageBean;
|
||||
import com.yunbao.live.views.SystemMessageViewHolder;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
import io.rong.imlib.RongIMClient;
|
||||
import io.rong.imlib.model.Conversation;
|
||||
import io.rong.imlib.model.Message;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/11/24.
|
||||
*/
|
||||
|
||||
public class SystemMessageActivity extends AbsActivity {
|
||||
|
||||
public static SystemMessageViewHolder mSystemMessageViewHolder;
|
||||
public static String type;//-1=单聊消息,1=系统消息,2=互动消息,3=猜你喜欢,-2=web页面打开
|
||||
public static String type2 = "0";//判断是否注册监听
|
||||
public static String nowUid, nowTitle, mowHeadImg;
|
||||
|
||||
public static void forward(Context context, String type, String uid, String title, String headImg) {
|
||||
context.startActivity(new Intent(context, SystemMessageActivity.class).putExtra("type", type).putExtra("uid", uid).putExtra("title", title).putExtra("headImg", headImg));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_sys_msg;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
|
||||
Constants.isSetRemark = "";
|
||||
Constants.isSetRemarkText = "";
|
||||
type = getIntent().getStringExtra("type");
|
||||
if ("-2".equals(type)) {
|
||||
type = "-1";
|
||||
type2 = "-2";
|
||||
} else {
|
||||
type2 = "0";
|
||||
}
|
||||
nowUid = getIntent().getStringExtra("uid");
|
||||
nowTitle = getIntent().getStringExtra("title");
|
||||
mowHeadImg = getIntent().getStringExtra("headImg");
|
||||
// mowMsgId = getIntent().getIntExtra("headImg", 0);
|
||||
// if ("".equals(nowUid)) {
|
||||
mSystemMessageViewHolder = new SystemMessageViewHolder(mContext, (ViewGroup) findViewById(R.id.root), SystemMessageActivity.this);
|
||||
mSystemMessageViewHolder.addToParent();
|
||||
mSystemMessageViewHolder.loadData();
|
||||
// } else {
|
||||
// mSystemMessageViewHolder = new SystemMessageViewHolder(mContext, (ViewGroup) findViewById(R.id.root));
|
||||
// mSystemMessageViewHolder.addToParent();
|
||||
// mSystemMessageViewHolder.loadData();
|
||||
// }
|
||||
init();
|
||||
|
||||
mSystemMessageViewHolder.btn_back.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//更新新消息
|
||||
public void getNewMsg(Message message) {
|
||||
if (mSystemMessageViewHolder != null && !"".equals(nowUid)) {
|
||||
mSystemMessageViewHolder.intoMsg(message);
|
||||
}
|
||||
}
|
||||
|
||||
//撤回消息
|
||||
public void getWithdrawMsg(int messageId) {
|
||||
if (mSystemMessageViewHolder != null && !"".equals(nowUid)) {
|
||||
mSystemMessageViewHolder.withdrawMsg(messageId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
if (mSystemMessageViewHolder != null) {
|
||||
mSystemMessageViewHolder.release();
|
||||
}
|
||||
nowUid = "";
|
||||
nowTitle = "";
|
||||
Constants.nowId = "";
|
||||
Constants.remarks = "";
|
||||
Constants.isAdmin = "";
|
||||
if ("-2".equals(type2)) {
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (resultCode == RESULT_OK) {
|
||||
if (data != null) {
|
||||
ArrayList<ImageEntity> selectImages = data.getParcelableArrayListExtra(SelectImageActivity.EXTRA_RESULT);
|
||||
sendBack(requestCode, selectImages);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void sendBack(int requestCode, ArrayList<ImageEntity> selectImages) {
|
||||
mSystemMessageViewHolder.mSelectImages.clear();
|
||||
mSystemMessageViewHolder.mSelectImages.addAll(selectImages);
|
||||
Log.i("Log", "mSystemMessageViewHolder.mSelectImages=" + mSystemMessageViewHolder.mSelectImages.size());
|
||||
if (mSystemMessageViewHolder.mSelectImages.size() > 0) {
|
||||
//发送
|
||||
if (requestCode == mSystemMessageViewHolder.SELECT_IMAGE_REQUEST) {
|
||||
Log.i("Log", "发送图片");
|
||||
mSystemMessageViewHolder.getPiclist();
|
||||
} else if (requestCode == mSystemMessageViewHolder.SELECT_VIDEO_REQUEST) {
|
||||
Log.i("Log", "发送视频");
|
||||
mSystemMessageViewHolder.mediaVideo(mSystemMessageViewHolder.mSelectImages.get(0).getPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//清除指定会话未读数
|
||||
private void cleanMessage(String toId) {
|
||||
Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
|
||||
String targetId = toId;
|
||||
long timestamp = new Date().getTime();
|
||||
|
||||
RongIMClient.getInstance().clearMessagesUnreadStatus(conversationType, targetId, timestamp, new RongIMClient.OperationCallback() {
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
Log.i("Log", "清除未读数成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(RongIMClient.ErrorCode errorCode) {
|
||||
Log.i("Log", "清除未读数失败");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,345 @@
|
||||
package com.yunbao.live.activity;
|
||||
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.provider.MediaStore;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.ValueCallback;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.CommonAppContext;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.HtmlConfig;
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.bean.LiveBean;
|
||||
import com.yunbao.common.event.JavascriptInterfaceEvent;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.http.LiveHttpUtil;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.JavascriptInterfaceUtils;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
|
||||
import com.yunbao.common.utils.MicStatusManager;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.live.dialog.LiveUserDialogFragment;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/9/25.
|
||||
* 我的徽章 h5页面
|
||||
*/
|
||||
|
||||
public class WebViewActivityMedal extends AbsActivity {
|
||||
|
||||
private ProgressBar mProgressBar;
|
||||
private WebView mWebView;
|
||||
private final int CHOOSE = 100;//Android 5.0以下的
|
||||
private final int CHOOSE_ANDROID_5 = 200;//Android 5.0以上的
|
||||
private ValueCallback<Uri> mValueCallback;
|
||||
private ValueCallback<Uri[]> mValueCallback2;
|
||||
private ImageView mIvQuestion;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_webview_medal;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
Bus.getOn(this);
|
||||
String url = getIntent().getStringExtra(Constants.URL);
|
||||
L.e("H5---3>" + url);
|
||||
LinearLayout rootView = (LinearLayout) findViewById(R.id.rootView);
|
||||
mIvQuestion = findViewById(R.id.btn_question);
|
||||
mProgressBar = (ProgressBar) findViewById(R.id.progressbar);
|
||||
ivQuestionClick();
|
||||
mWebView = new WebView(mContext);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
params.topMargin = DpUtil.dp2px(1);
|
||||
mWebView.setLayoutParams(params);
|
||||
mWebView.setOverScrollMode(View.OVER_SCROLL_NEVER);
|
||||
rootView.addView(mWebView);
|
||||
mWebView.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
L.e("H5-------->" + url);
|
||||
if (url.startsWith(Constants.COPY_PREFIX)) {
|
||||
String content = url.substring(Constants.COPY_PREFIX.length());
|
||||
if (!TextUtils.isEmpty(content)) {
|
||||
copy(content);
|
||||
}
|
||||
} else {
|
||||
view.loadUrl(url);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
setTitle(view.getTitle());
|
||||
}
|
||||
});
|
||||
mWebView.setWebChromeClient(new WebChromeClient() {
|
||||
@Override
|
||||
public void onProgressChanged(WebView view, int newProgress) {
|
||||
if (newProgress == 100) {
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
} else {
|
||||
mProgressBar.setProgress(newProgress);
|
||||
}
|
||||
}
|
||||
|
||||
//以下是在各个Android版本中 WebView调用文件选择器的方法
|
||||
// For Android < 3.0
|
||||
public void openFileChooser(ValueCallback<Uri> valueCallback) {
|
||||
openImageChooserActivity(valueCallback);
|
||||
}
|
||||
|
||||
// For Android >= 3.0
|
||||
public void openFileChooser(ValueCallback valueCallback, String acceptType) {
|
||||
openImageChooserActivity(valueCallback);
|
||||
}
|
||||
|
||||
//For Android >= 4.1
|
||||
public void openFileChooser(ValueCallback<Uri> valueCallback,
|
||||
String acceptType, String capture) {
|
||||
openImageChooserActivity(valueCallback);
|
||||
}
|
||||
|
||||
// For Android >= 5.0
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public boolean onShowFileChooser(WebView webView,
|
||||
ValueCallback<Uri[]> filePathCallback,
|
||||
FileChooserParams fileChooserParams) {
|
||||
mValueCallback2 = filePathCallback;
|
||||
Intent intent = fileChooserParams.createIntent();
|
||||
startActivityForResult(intent, CHOOSE_ANDROID_5);
|
||||
return true;
|
||||
}
|
||||
|
||||
});
|
||||
mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(mContext, mWebView), "androidObject");
|
||||
mWebView.getSettings().setJavaScriptEnabled(true);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
}
|
||||
mWebView.loadUrl(url);
|
||||
}
|
||||
|
||||
private void ivQuestionClick() {
|
||||
mIvQuestion.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
MedalQuestionWebViewActivity.forward(mContext, HtmlConfig.MEDAL_QUESTION + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private LiveRoomCheckLivePresenter mCheckLivePresenter;
|
||||
|
||||
private void gotoLive(final String live_id) {
|
||||
LiveHttpUtil.getLiveInfo(live_id + "", new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
|
||||
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
|
||||
@Override
|
||||
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
|
||||
if (liveBean == null) {
|
||||
return;
|
||||
}
|
||||
if (MicStatusManager.getInstance().isMic(liveUid)) {
|
||||
MicStatusManager.getInstance().showDownMicDialog(mContext);
|
||||
return;
|
||||
}
|
||||
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveTypeVal), Integer.parseInt(liveSdk));
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckError(String contextError) {
|
||||
|
||||
}
|
||||
});
|
||||
} else {
|
||||
RouteUtil.forwardUserHome(mContext, String.valueOf(live_id), 0);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 显示个人资料弹窗
|
||||
*/
|
||||
private void showUserDialog(String toUid, String liveId) {
|
||||
if (!TextUtils.isEmpty(liveId) && !TextUtils.isEmpty(toUid)) {
|
||||
LiveUserDialogFragment fragment = new LiveUserDialogFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(Constants.LIVE_UID, liveId);
|
||||
bundle.putString(Constants.STREAM, "");
|
||||
bundle.putString(Constants.TO_UID, toUid);
|
||||
fragment.setArguments(bundle);
|
||||
fragment.show(((WebViewActivityMedal) mContext).getSupportFragmentManager(), "LiveUserDialogFragment");
|
||||
}
|
||||
}
|
||||
|
||||
private void openImageChooserActivity(ValueCallback<Uri> valueCallback) {
|
||||
mValueCallback = valueCallback;
|
||||
Intent intent = new Intent();
|
||||
if (Build.VERSION.SDK_INT < 19) {
|
||||
intent.setAction(Intent.ACTION_GET_CONTENT);
|
||||
} else {
|
||||
intent.setAction(Intent.ACTION_PICK);
|
||||
intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||
}
|
||||
intent.setType("image/*");
|
||||
startActivityForResult(Intent.createChooser(intent, mContext.getString(R.string.choose_flie)), CHOOSE);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
||||
super.onActivityResult(requestCode, resultCode, intent);
|
||||
switch (requestCode) {
|
||||
case CHOOSE://5.0以下选择图片后的回调
|
||||
processResult(resultCode, intent);
|
||||
break;
|
||||
case CHOOSE_ANDROID_5://5.0以上选择图片后的回调
|
||||
processResultAndroid5(resultCode, intent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void processResult(int resultCode, Intent intent) {
|
||||
if (mValueCallback == null) {
|
||||
return;
|
||||
}
|
||||
if (resultCode == RESULT_OK && intent != null) {
|
||||
Uri result = intent.getData();
|
||||
mValueCallback.onReceiveValue(result);
|
||||
} else {
|
||||
mValueCallback.onReceiveValue(null);
|
||||
}
|
||||
mValueCallback = null;
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
private void processResultAndroid5(int resultCode, Intent intent) {
|
||||
if (mValueCallback2 == null) {
|
||||
return;
|
||||
}
|
||||
if (resultCode == RESULT_OK && intent != null) {
|
||||
mValueCallback2.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, intent));
|
||||
} else {
|
||||
mValueCallback2.onReceiveValue(null);
|
||||
}
|
||||
mValueCallback2 = null;
|
||||
}
|
||||
|
||||
protected boolean canGoBack() {
|
||||
return mWebView != null && mWebView.canGoBack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (isNeedExitActivity()) {
|
||||
finish();
|
||||
} else {
|
||||
if (canGoBack()) {
|
||||
mWebView.goBack();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean isNeedExitActivity() {
|
||||
if (mWebView != null) {
|
||||
String url = mWebView.getUrl();
|
||||
if (!TextUtils.isEmpty(url)) {
|
||||
return url.contains("g=Appapi&m=Auth&a=success")//身份认证成功页面
|
||||
|| url.contains("g=Appapi&m=Family&a=home");//家族申请提交成功页面
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void forward(Context context, String url, boolean addArgs) {
|
||||
if (addArgs) {
|
||||
url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken();
|
||||
}
|
||||
Intent intent = new Intent(context, WebViewActivityMedal.class);
|
||||
intent.putExtra(Constants.URL, url + "&isZh=" + ((IMLoginManager.get(CommonAppContext.sInstance.getBaseContext()).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
public static void forward(Context context, String url) {
|
||||
forward(context, url, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
Bus.getOff(this);
|
||||
if (mWebView != null) {
|
||||
ViewGroup parent = (ViewGroup) mWebView.getParent();
|
||||
if (parent != null) {
|
||||
parent.removeView(mWebView);
|
||||
}
|
||||
mWebView.destroy();
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制到剪贴板
|
||||
*/
|
||||
private void copy(String content) {
|
||||
ClipboardManager cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
ClipData clipData = ClipData.newPlainText("text", content);
|
||||
cm.setPrimaryClip(clipData);
|
||||
ToastUtil.show(getString(R.string.copy_success));
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onJavascriptInterfaceEvent(JavascriptInterfaceEvent event) {
|
||||
if (!TextUtils.isEmpty(event.getMethod())) {
|
||||
if (TextUtils.equals(event.getMethod(), "androidMethodLookToLive")) {
|
||||
//看直播
|
||||
gotoLive(event.getLiveId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,437 @@
|
||||
package com.yunbao.live.activity;
|
||||
|
||||
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.provider.MediaStore;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.ValueCallback;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebResourceRequest;
|
||||
import android.webkit.WebResourceResponse;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.opensource.svgaplayer.SVGACallback;
|
||||
import com.opensource.svgaplayer.SVGADrawable;
|
||||
import com.opensource.svgaplayer.SVGAImageView;
|
||||
import com.opensource.svgaplayer.SVGAParser;
|
||||
import com.opensource.svgaplayer.SVGAVideoEntity;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.bean.LiveBean;
|
||||
import com.yunbao.common.event.JavascriptInterfaceEvent;
|
||||
import com.yunbao.common.event.LiveRoomChangeEvent;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.http.LiveHttpUtil;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.JavascriptInterfaceUtils;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
|
||||
import com.yunbao.common.utils.MicStatusManager;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.SVGAViewUtils;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.share.ui.InvitePopDialog;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
;
|
||||
|
||||
@Route(path = RouteUtil.PATH_LiveZHUANGBANACTIVITY)
|
||||
public class ZhuangBanActivity extends AbsActivity {
|
||||
|
||||
private ProgressBar mProgressBar;
|
||||
private WebView mWebView;
|
||||
private final int CHOOSE = 100;//Android 5.0以下的
|
||||
private final int CHOOSE_ANDROID_5 = 200;//Android 5.0以上的
|
||||
private ValueCallback<Uri> mValueCallback;
|
||||
private ValueCallback<Uri[]> mValueCallback2;
|
||||
private SVGAImageView svga;
|
||||
private FrameLayout title;
|
||||
private TextView titleView, htmlError;
|
||||
private RelativeLayout rootView;
|
||||
private boolean mIsLive = false;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_zhuang_ban_new;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
Bus.getOn(this);
|
||||
String url = getIntent().getStringExtra(Constants.URL);
|
||||
String titleString = getIntent().getStringExtra("title");
|
||||
mIsLive = getIntent().getIntExtra("isLive", 0) == 1;
|
||||
L.e("H5---2s>" + url);
|
||||
LinearLayout rootView = (LinearLayout) findViewById(R.id.rootView);
|
||||
mProgressBar = (ProgressBar) findViewById(R.id.progressbar);
|
||||
svga = (SVGAImageView) findViewById(R.id.svga);
|
||||
titleView = (TextView) findViewById(R.id.titleView);
|
||||
htmlError = (TextView) findViewById(R.id.html_error);
|
||||
title = findViewById(R.id.ft_title);
|
||||
if (isFullWindow) {
|
||||
title.setVisibility(View.GONE);
|
||||
}
|
||||
if (getIntent().hasExtra("title")) {
|
||||
if (TextUtils.isEmpty(titleString)) {
|
||||
title.setVisibility(View.GONE);
|
||||
} else {
|
||||
if (TextUtils.equals(titleString, "blank")) {
|
||||
title.setVisibility(View.GONE);
|
||||
} else {
|
||||
title.setVisibility(View.VISIBLE);
|
||||
titleView.setText(titleString);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
mWebView = new WebView(mContext);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
params.topMargin = DpUtil.dp2px(1);
|
||||
mWebView.setLayoutParams(params);
|
||||
mWebView.setOverScrollMode(View.OVER_SCROLL_NEVER);
|
||||
rootView.addView(mWebView);
|
||||
|
||||
mWebView.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
L.e("H5-------->" + url);
|
||||
if (url.startsWith(Constants.COPY_PREFIX)) {
|
||||
String content = url.substring(Constants.COPY_PREFIX.length());
|
||||
if (!TextUtils.isEmpty(content)) {
|
||||
copy(content);
|
||||
}
|
||||
} else {
|
||||
mWebView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
view.loadUrl(url);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
setTitle(view.getTitle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
|
||||
super.onReceivedError(view, errorCode, description, failingUrl);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
|
||||
super.onReceivedHttpError(view, request, errorResponse);
|
||||
// 这个方法在6.0才出现
|
||||
int statusCode = errorResponse.getStatusCode();
|
||||
if (404 == statusCode || 500 == statusCode) {
|
||||
if (!request.getUrl().toString().contains("favicon")) {
|
||||
htmlError.setVisibility(View.VISIBLE);
|
||||
htmlError.setText("errorCode:" + statusCode + "\n failingUrl:" + request.getUrl());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
mWebView.setWebChromeClient(new WebChromeClient() {
|
||||
@Override
|
||||
public void onProgressChanged(WebView view, int newProgress) {
|
||||
if (newProgress == 100) {
|
||||
mProgressBar.setVisibility(View.GONE);
|
||||
} else {
|
||||
mProgressBar.setProgress(newProgress);
|
||||
}
|
||||
}
|
||||
|
||||
//以下是在各个Android版本中 WebView调用文件选择器的方法
|
||||
// For Android < 3.0
|
||||
public void openFileChooser(ValueCallback<Uri> valueCallback) {
|
||||
openImageChooserActivity(valueCallback);
|
||||
}
|
||||
|
||||
// For Android >= 3.0
|
||||
public void openFileChooser(ValueCallback valueCallback, String acceptType) {
|
||||
openImageChooserActivity(valueCallback);
|
||||
}
|
||||
|
||||
//For Android >= 4.1
|
||||
public void openFileChooser(ValueCallback<Uri> valueCallback,
|
||||
String acceptType, String capture) {
|
||||
openImageChooserActivity(valueCallback);
|
||||
}
|
||||
|
||||
// For Android >= 5.0
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public boolean onShowFileChooser(WebView webView,
|
||||
ValueCallback<Uri[]> filePathCallback,
|
||||
FileChooserParams fileChooserParams) {
|
||||
mValueCallback2 = filePathCallback;
|
||||
Intent intent = fileChooserParams.createIntent();
|
||||
startActivityForResult(intent, CHOOSE_ANDROID_5);
|
||||
return true;
|
||||
}
|
||||
|
||||
});
|
||||
mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(mContext, mWebView)
|
||||
.setPageClose(true)
|
||||
.setLiveZhuangBana(true), "androidObject");
|
||||
mWebView.getSettings().setJavaScriptEnabled(true);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
}
|
||||
mWebView.loadUrl(url);
|
||||
}
|
||||
|
||||
|
||||
private void openImageChooserActivity(ValueCallback<Uri> valueCallback) {
|
||||
mValueCallback = valueCallback;
|
||||
Intent intent = new Intent();
|
||||
if (Build.VERSION.SDK_INT < 19) {
|
||||
intent.setAction(Intent.ACTION_GET_CONTENT);
|
||||
} else {
|
||||
intent.setAction(Intent.ACTION_PICK);
|
||||
intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||
}
|
||||
intent.setType("image/*");
|
||||
startActivityForResult(Intent.createChooser(intent, mContext.getString(R.string.choose_flie)), CHOOSE);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
||||
super.onActivityResult(requestCode, resultCode, intent);
|
||||
switch (requestCode) {
|
||||
case CHOOSE://5.0以下选择图片后的回调
|
||||
processResult(resultCode, intent);
|
||||
break;
|
||||
case CHOOSE_ANDROID_5://5.0以上选择图片后的回调
|
||||
processResultAndroid5(resultCode, intent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void processResult(int resultCode, Intent intent) {
|
||||
if (mValueCallback == null) {
|
||||
return;
|
||||
}
|
||||
if (resultCode == RESULT_OK && intent != null) {
|
||||
Uri result = intent.getData();
|
||||
mValueCallback.onReceiveValue(result);
|
||||
} else {
|
||||
mValueCallback.onReceiveValue(null);
|
||||
}
|
||||
mValueCallback = null;
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
private void processResultAndroid5(int resultCode, Intent intent) {
|
||||
if (mValueCallback2 == null) {
|
||||
return;
|
||||
}
|
||||
if (resultCode == RESULT_OK && intent != null) {
|
||||
mValueCallback2.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, intent));
|
||||
} else {
|
||||
mValueCallback2.onReceiveValue(null);
|
||||
}
|
||||
mValueCallback2 = null;
|
||||
}
|
||||
|
||||
protected boolean canGoBack() {
|
||||
return mWebView != null && mWebView.canGoBack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (isNeedExitActivity()) {
|
||||
finish();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean isNeedExitActivity() {
|
||||
if (mWebView != null) {
|
||||
String url = mWebView.getUrl();
|
||||
if (!TextUtils.isEmpty(url)) {
|
||||
return url.contains("g=Appapi&m=Auth&a=success")//身份认证成功页面
|
||||
|| url.contains("g=Appapi&m=Family&a=home");//家族申请提交成功页面
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static void forward(Context context, String url, boolean addArgs, int isLive) {
|
||||
if (addArgs) {
|
||||
url += "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()+ "&isZh=" + (WordUtil.isNewZh() ? "1" : 0);
|
||||
}
|
||||
Intent intent = new Intent(context, ZhuangBanActivity.class);
|
||||
Log.i("tag", url);
|
||||
intent.putExtra(Constants.URL, url);
|
||||
if (url.contains("Noble/index.html") || url.contains("RongYuQiang")) {
|
||||
intent.putExtra("title", "");
|
||||
}
|
||||
intent.putExtra("isLive", isLive);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
public static void forward(Context context, String url, int isLive) {
|
||||
forward(context, url, true, isLive);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
Bus.getOff(this);
|
||||
if (mWebView != null) {
|
||||
ViewGroup parent = (ViewGroup) mWebView.getParent();
|
||||
if (parent != null) {
|
||||
parent.removeView(mWebView);
|
||||
}
|
||||
mWebView.destroy();
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制到剪贴板
|
||||
*/
|
||||
private void copy(String content) {
|
||||
ClipboardManager cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
ClipData clipData = ClipData.newPlainText("text", content);
|
||||
cm.setPrimaryClip(clipData);
|
||||
ToastUtil.show(getString(R.string.copy_success));
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onJavascriptInterfaceEvent(JavascriptInterfaceEvent event) {
|
||||
if (!TextUtils.isEmpty(event.getMethod())) {
|
||||
if (TextUtils.equals(event.getMethod(), "androidOpeningNoble")) {
|
||||
try {
|
||||
new SVGAParser(mContext).parse(new URL(event.getSvg()), new SVGAParser.ParseCompletion() {
|
||||
@Override
|
||||
public void onComplete(SVGAVideoEntity videoItem) {
|
||||
svga.setVisibility(View.VISIBLE);
|
||||
SVGADrawable drawable = new SVGADrawable(videoItem);
|
||||
svga.setImageDrawable(drawable);
|
||||
svga.setLoops(1);
|
||||
SVGAViewUtils.playEndClear(svga);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
}
|
||||
});
|
||||
svga.setCallback(new SVGACallback() {
|
||||
@Override
|
||||
public void onPause() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinished() {
|
||||
svga.clear();
|
||||
svga.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRepeat() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStep(int i, double v) {
|
||||
}
|
||||
});
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if (event.getMethod().equals("androidInviteShare")) {
|
||||
new InvitePopDialog(mContext)
|
||||
.setUrl(event.getData())
|
||||
.showDialog();
|
||||
} else if (TextUtils.equals(event.getMethod(), "androidMethodLookToLive")) {
|
||||
//看直播
|
||||
gotoLive(event.getLiveId());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void gotoLive(final String live_id) {
|
||||
|
||||
LiveHttpUtil.getLiveInfo(live_id, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
|
||||
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
|
||||
@Override
|
||||
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
|
||||
if (liveBean == null) {
|
||||
return;
|
||||
}
|
||||
if (MicStatusManager.getInstance().isMic(liveUid)) {
|
||||
MicStatusManager.getInstance().showDownMicDialog(mContext);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mIsLive) {
|
||||
if (MicStatusManager.getInstance().isMic(liveUid)) {
|
||||
MicStatusManager.getInstance().showDownMicDialog(mContext);
|
||||
return;
|
||||
}
|
||||
EventBus.getDefault().post(new LiveRoomChangeEvent(liveBean, liveType, Integer.parseInt(liveTypeVal)));
|
||||
finish();
|
||||
} else {
|
||||
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveTypeVal), Integer.parseInt(liveSdk));
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckError(String contextError) {
|
||||
|
||||
}
|
||||
});
|
||||
} else {
|
||||
RouteUtil.forwardUserHome(mContext, live_id, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,307 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.opensource.svgaplayer.SVGADrawable;
|
||||
import com.opensource.svgaplayer.SVGAImageView;
|
||||
import com.opensource.svgaplayer.SVGAParser;
|
||||
import com.opensource.svgaplayer.SVGAVideoEntity;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.adapter.RefreshAdapter;
|
||||
import com.yunbao.common.bean.BaseModel;
|
||||
import com.yunbao.common.bean.LevelBean;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.custom.CommonRefreshView;
|
||||
import com.yunbao.common.dialog.AbsDialogFragment;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.API;
|
||||
import com.yunbao.common.http.ResponseModel;
|
||||
import com.yunbao.common.manager.MicUserManager;
|
||||
import com.yunbao.common.manager.MicedUserManager;
|
||||
import com.yunbao.common.utils.CommonIconUtil;
|
||||
import com.yunbao.common.utils.SVGAViewUtils;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.activity.LiveActivity;
|
||||
import com.yunbao.live.socket.SocketSendBean;
|
||||
import com.yunbao.live.utils.LiveTextRender;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.functions.Consumer;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import io.rong.imkit.IMCenter;
|
||||
import io.rong.imlib.IRongCallback;
|
||||
import io.rong.imlib.RongIMClient;
|
||||
import io.rong.imlib.model.Conversation;
|
||||
import io.rong.imlib.model.Message;
|
||||
import io.rong.message.TextMessage;
|
||||
|
||||
public class AnchorUserMicInfoAdapter extends RefreshAdapter<UserBean> {
|
||||
public static final int TYPE_MIC_LIST = 1;//连麦列表
|
||||
public static final int TYPE_MIC_REQUEST = 2;//请求连麦
|
||||
public static final int TYPE_MIC_INVITE = 3;//邀请连麦
|
||||
|
||||
private AbsDialogFragment fragments;
|
||||
private CommonRefreshView refreshView;
|
||||
private String mLiveUid;
|
||||
|
||||
public AnchorUserMicInfoAdapter(Context context, AbsDialogFragment fragment) {
|
||||
super(context);
|
||||
this.fragments = fragment;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
public void setRefreshView(CommonRefreshView refreshView) {
|
||||
this.refreshView = refreshView;
|
||||
}
|
||||
|
||||
public void setLiveUid(String mLiveUid) {
|
||||
this.mLiveUid = mLiveUid;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
||||
return new AnchorUserMicInfoAdapter.Vh(mInflater.inflate(R.layout.item_anchor_mic_info, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder vh, int position) {
|
||||
// vh.setIsRecyclable(false);
|
||||
((AnchorUserMicInfoAdapter.Vh) vh).setData(mList.get(position), position);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mList.size();
|
||||
}
|
||||
|
||||
|
||||
class Vh extends RecyclerView.ViewHolder {
|
||||
ImageView mAvatar;
|
||||
TextView mName;
|
||||
ImageView mSex;
|
||||
ImageView mLevel;
|
||||
ImageView mClose;
|
||||
SVGAImageView gift_svga;
|
||||
Button mBtn;
|
||||
|
||||
public Vh(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
mAvatar = (ImageView) itemView.findViewById(R.id.avatar);
|
||||
mName = (TextView) itemView.findViewById(R.id.name);
|
||||
mSex = (ImageView) itemView.findViewById(R.id.sex);
|
||||
mLevel = (ImageView) itemView.findViewById(R.id.level);
|
||||
gift_svga = (SVGAImageView) itemView.findViewById(R.id.gift_svga);
|
||||
mBtn = itemView.findViewById(R.id.mic_btn);
|
||||
mClose = itemView.findViewById(R.id.mic_exit);
|
||||
mBtn.setOnClickListener(v -> {
|
||||
if (MicedUserManager.get().getMicUserList().size() < 3) {
|
||||
if (v.getTag() != null) {
|
||||
UserBean tag = (UserBean) v.getTag();
|
||||
if (tag.getTypeMic() == TYPE_MIC_REQUEST) {
|
||||
SocketSendBean bean = createSocketSendBean().param("targetId", tag.getId());
|
||||
applyMic(tag, 1, bean);
|
||||
ToastUtil.show(mContext.getString(R.string.live_mic_invite));
|
||||
} else if (tag.getTypeMic() == TYPE_MIC_INVITE) {
|
||||
applyMic(tag, 4, createSocketSendBean());
|
||||
ToastUtil.show(mContext.getString(R.string.live_mic_request));
|
||||
for (int i = 0; i < mList.size(); i++) {
|
||||
if (TextUtils.equals(mList.get(i).getId(), tag.getId())) {
|
||||
mList.get(i).setRequest(true);
|
||||
notifyItemChanged(i);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}else {
|
||||
ToastUtil.show(mContext.getString(R.string.live_mic_max));
|
||||
}
|
||||
});
|
||||
mClose.setOnClickListener(v -> {
|
||||
if (v.getTag() != null) {
|
||||
API.get().createPDLiveApi(false)
|
||||
.killDrLm(((UserBean) v.getTag()).getId(), mLiveUid)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(new Consumer<ResponseModel<BaseModel>>() {
|
||||
@Override
|
||||
public void accept(ResponseModel<BaseModel> stringResponseModel) throws Exception {
|
||||
applyMic((UserBean) v.getTag(), 8, createSocketSendBean());
|
||||
ToastUtil.show(mContext.getString(R.string.live_mic_user_down));
|
||||
refreshView.initData();
|
||||
}
|
||||
}, Throwable::printStackTrace).isDisposed();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
SocketSendBean createSocketSendBean() {
|
||||
return new SocketSendBean()
|
||||
.param("_method_", Constants.LIAN_MAI)
|
||||
.param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName())
|
||||
.param("avatar", CommonAppConfig.getInstance().getUserBean().getAvatar())
|
||||
.param("uid", CommonAppConfig.getInstance().getUid());
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送IM消息
|
||||
*
|
||||
* @param action 4为同意请求,1为邀请,其余见 {@link com.yunbao.live.socket.SocketRyClient} Constants.LIAN_MAI解析
|
||||
*/
|
||||
void applyMic(UserBean bean, int action, SocketSendBean msg) {
|
||||
msg.param("action", action);
|
||||
msg.create();
|
||||
Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
|
||||
TextMessage messageContent = TextMessage.obtain(msg.mResult.toString());
|
||||
io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain(bean.getId(), conversationType, messageContent);
|
||||
RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
|
||||
@Override
|
||||
public void onAttached(io.rong.imlib.model.Message message) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(io.rong.imlib.model.Message message) {
|
||||
Log.e("ry", "发送成功");
|
||||
|
||||
IMCenter.getInstance().deleteRemoteMessages(Conversation.ConversationType.PRIVATE, message.getTargetId(), new Message[]{message}, null);
|
||||
IMCenter.getInstance().clearMessagesUnreadStatus(Conversation.ConversationType.PRIVATE, message.getTargetId(), null);
|
||||
if (bean.getTypeMic() == TYPE_MIC_REQUEST) {
|
||||
MicUserManager.get().removeMiscUser(bean.getId());
|
||||
}
|
||||
if (bean.getTypeMic() == TYPE_MIC_LIST && action == 8) {
|
||||
MicedUserManager.get().removeMiscUser(bean.getId());
|
||||
}
|
||||
|
||||
refreshView.initData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) {
|
||||
Log.e("ry", "发送失敗" + errorCode.toString());
|
||||
refreshView.initData();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void setData(final UserBean bean, int position) {
|
||||
|
||||
mAvatar.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
((LiveActivity) mContext).showUserDialog(bean.getId());
|
||||
fragments.dismiss();
|
||||
}
|
||||
});
|
||||
mClose.setTag(bean);
|
||||
mBtn.setTag(bean);
|
||||
switch (bean.getTypeMic()) {
|
||||
case TYPE_MIC_LIST:
|
||||
mClose.setVisibility(View.VISIBLE);
|
||||
mBtn.setVisibility(View.GONE);
|
||||
break;
|
||||
case TYPE_MIC_REQUEST:
|
||||
case TYPE_MIC_INVITE:
|
||||
mClose.setVisibility(View.GONE);
|
||||
mBtn.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
}
|
||||
if (bean.getTypeMic() == TYPE_MIC_REQUEST) {
|
||||
mBtn.setText("同意");
|
||||
if (!WordUtil.isNewZh()) {
|
||||
mBtn.setText("agree");
|
||||
}
|
||||
mBtn.setBackgroundResource(R.drawable.bg_anchor_mic_info_btn_ok);
|
||||
} else if (bean.getTypeMic() == TYPE_MIC_INVITE) {
|
||||
|
||||
|
||||
mBtn.setBackgroundResource(R.drawable.bg_anchor_mic_info_btn_invite);
|
||||
if (bean.isMicList()) {
|
||||
mBtn.setEnabled(false);
|
||||
mBtn.setClickable(false);
|
||||
mBtn.setSelected(false);
|
||||
mBtn.setText(WordUtil.isNewZh() ? "連麥中" : "Trung");
|
||||
} else {
|
||||
mBtn.setEnabled(true);
|
||||
mBtn.setClickable(true);
|
||||
mBtn.setSelected(true);
|
||||
// if (bean.isRequest()){
|
||||
// mBtn.setText(WordUtil.isNewZh() ? "已邀请" : "Invited");
|
||||
// }else {
|
||||
mBtn.setText(WordUtil.isNewZh() ? "邀请" : "invite");
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
ImgLoader.display(mContext, bean.getAvatar(), mAvatar);
|
||||
gift_svga.setImageDrawable(null);
|
||||
if (bean.getDress() != null) {
|
||||
if (bean.getDress().getAvatar_frame().contains("svga")) {
|
||||
|
||||
try {
|
||||
new SVGAParser(mContext).parse(new URL(bean.getDress().getAvatar_frame()), new SVGAParser.ParseCompletion() {
|
||||
@Override
|
||||
public void onComplete(SVGAVideoEntity videoItem) {
|
||||
SVGADrawable drawable = new SVGADrawable(videoItem);
|
||||
gift_svga.setImageDrawable(drawable);
|
||||
SVGAViewUtils.playEndClear(gift_svga, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
}
|
||||
});
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
ImgLoader.display2(mContext, bean.getDress().getAvatar_frame(), gift_svga);
|
||||
}
|
||||
}
|
||||
mName.setText(bean.getUserNiceName());
|
||||
|
||||
mSex.setImageResource(CommonIconUtil.getSexIcon(bean.getSex()));
|
||||
new LiveTextRender().getLevelImage(mContext, bean.getLevel(), new ImgLoader.DrawableCallback() {
|
||||
@Override
|
||||
public void onLoadSuccess(Drawable drawable) {
|
||||
ImgLoader.display2(mContext, drawable, mLevel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFailed() {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
119
live/src/main/java/com/yunbao/live/adapter/BeautyAdapter.java
Normal file
119
live/src/main/java/com/yunbao/live/adapter/BeautyAdapter.java
Normal file
@@ -0,0 +1,119 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.bean.BeautyFaceBean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BeautyAdapter extends RecyclerView.Adapter<BeautyAdapter.Vh> {
|
||||
|
||||
private Context mContext;
|
||||
private List<BeautyFaceBean> mList;
|
||||
private LayoutInflater mInflater;
|
||||
|
||||
//选中的
|
||||
public int choice = 0;
|
||||
private View.OnClickListener mOnClickListener;
|
||||
private OnItemClickListener<BeautyFaceBean> mOnItemClickListener;
|
||||
|
||||
public BeautyAdapter(Context context) {
|
||||
mContext = context;
|
||||
mInflater = LayoutInflater.from(context);
|
||||
mList = new ArrayList<>();
|
||||
mOnClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Object tag = v.getTag();
|
||||
if (tag != null) {
|
||||
int position = (int) tag;
|
||||
BeautyFaceBean bean = mList.get(position);
|
||||
choice = position;
|
||||
if (mOnItemClickListener != null) {
|
||||
mOnItemClickListener.onItemClick(bean, position);
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener<BeautyFaceBean> onItemClickListener) {
|
||||
mOnItemClickListener = onItemClickListener;
|
||||
}
|
||||
|
||||
|
||||
public void setList(List<BeautyFaceBean> list) {
|
||||
Log.i("tags",choice+"choice");
|
||||
if (list != null && list.size() > 0) {
|
||||
mList.clear();
|
||||
mList.addAll(list);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Vh onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new Vh(mInflater.inflate(R.layout.item_beauty, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull Vh vh, int i) {
|
||||
vh.setData(i);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mList.size();
|
||||
}
|
||||
|
||||
class Vh extends RecyclerView.ViewHolder {
|
||||
|
||||
TextView mName,value;
|
||||
LinearLayout bg;
|
||||
ImageView ico;
|
||||
|
||||
public Vh(View itemView) {
|
||||
super(itemView);
|
||||
mName = itemView.findViewById(R.id.name);
|
||||
value = itemView.findViewById(R.id.value);
|
||||
bg = itemView.findViewById(R.id.bg);
|
||||
ico = itemView.findViewById(R.id.ico);
|
||||
itemView.setOnClickListener(mOnClickListener);
|
||||
}
|
||||
|
||||
void setData(final int position) {
|
||||
itemView.setTag(position);
|
||||
if(mList.get(position).getB_name()!=null){
|
||||
value.setVisibility(View.INVISIBLE);
|
||||
}else{
|
||||
value.setVisibility(View.VISIBLE);
|
||||
}
|
||||
mName.setText(mList.get(position).getTitle());
|
||||
value.setText(mList.get(position).getValue()+"");
|
||||
ico.setImageResource(mList.get(position).getImg_id());
|
||||
if(position == choice){
|
||||
bg.setBackgroundResource(R.mipmap.box_c);
|
||||
}else{
|
||||
bg.setBackgroundResource(R.mipmap.box);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
49
live/src/main/java/com/yunbao/live/adapter/CodexAdapter.java
Normal file
49
live/src/main/java/com/yunbao/live/adapter/CodexAdapter.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.bean.GiftGuideModel;
|
||||
import com.yunbao.live.views.CodexViewHolder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CodexAdapter extends RecyclerView.Adapter {
|
||||
private List<GiftGuideModel> giftGuideModels = new ArrayList<>();
|
||||
private boolean history,sbWy;
|
||||
private String mStream, mLiveUid,toUid;
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View herdView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_codex, parent, false);
|
||||
return new CodexViewHolder(herdView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
CodexViewHolder codexViewHolder = (CodexViewHolder) holder;
|
||||
codexViewHolder.showData(giftGuideModels.get(position), history,mStream,mLiveUid,toUid,sbWy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return giftGuideModels.size();
|
||||
}
|
||||
|
||||
public void addAllData(List<GiftGuideModel> mGiftWall, boolean history, String mStream, String mLiveUid, String toUid, boolean sbWy) {
|
||||
this.history = history;
|
||||
this.mStream = mStream;
|
||||
this.mLiveUid = mLiveUid;
|
||||
this.toUid = toUid;
|
||||
this.sbWy = sbWy;
|
||||
giftGuideModels.clear();
|
||||
giftGuideModels.addAll(mGiftWall);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.bean.GiftWallModel;
|
||||
import com.yunbao.live.views.CodexItemViewHolder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CodexItemAdapter extends RecyclerView.Adapter {
|
||||
private List<GiftWallModel> giftData = new ArrayList<>();
|
||||
private String toUid, mLiveUid;
|
||||
private boolean sbWy;
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View herdView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_codex_item, parent, false);
|
||||
return new CodexItemViewHolder(herdView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
CodexItemViewHolder codexItemViewHolder = (CodexItemViewHolder) holder;
|
||||
codexItemViewHolder.showData(giftData.get(position), toUid, mLiveUid, sbWy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return giftData.size();
|
||||
}
|
||||
|
||||
public void addAllData(List<GiftWallModel> mGiftWall, String toUid, String mLiveUid, boolean sbWy) {
|
||||
this.toUid = toUid;
|
||||
this.mLiveUid = mLiveUid;
|
||||
this.sbWy = sbWy;
|
||||
giftData.clear();
|
||||
giftData.addAll(mGiftWall);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentPagerAdapter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FragmentAdapter extends FragmentPagerAdapter {
|
||||
|
||||
|
||||
|
||||
private List<Fragment> listfragment; //创建一个List<Fragment>
|
||||
|
||||
//定义构造带两个参数
|
||||
|
||||
public FragmentAdapter(FragmentManager fm, List<Fragment> list) {
|
||||
super(fm);
|
||||
this.listfragment = list;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
public Fragment getItem(int arg0) {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
return listfragment.get(arg0); //返回第几个fragment
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
public int getCount() {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
return listfragment.size(); //总共有多少个fragment
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.common.bean.LiveGiftBean;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.event.LiveGiftItemEvent;
|
||||
import com.yunbao.live.views.FrameGiftViewHolder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FrameGiftAdapter extends RecyclerView.Adapter {
|
||||
private List<LiveGiftBean> giftJson = new ArrayList<>();
|
||||
private int contextLayoutGiftHeight = 0;
|
||||
private String mStream, mLiveUid, wishGiftId;
|
||||
|
||||
public FrameGiftAdapter(int contextLayoutGiftHeight, List<LiveGiftBean> giftJson, String mStream, String mLiveUid, String wishGiftId) {
|
||||
this.contextLayoutGiftHeight = contextLayoutGiftHeight;
|
||||
this.giftJson = giftJson;
|
||||
this.mStream = mStream;
|
||||
this.mLiveUid = mLiveUid;
|
||||
this.wishGiftId = wishGiftId;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View herdView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_frame_gift, parent, false);
|
||||
return new FrameGiftViewHolder(herdView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
|
||||
if (!TextUtils.isEmpty(wishGiftId) && TextUtils.equals(giftJson.get(position).getId() + "", wishGiftId)) {
|
||||
Bus.get().post(new LiveGiftItemEvent().setLiveGiftModel(giftJson.get(position)));
|
||||
}
|
||||
|
||||
FrameGiftViewHolder frameGiftViewHolder = (FrameGiftViewHolder) holder;
|
||||
frameGiftViewHolder.showData(contextLayoutGiftHeight, giftJson.get(position));
|
||||
frameGiftViewHolder.giftSelect(giftJson.get(position), position, mStream, mLiveUid, new FrameGiftViewHolder.FrameGiftClickListener() {
|
||||
@Override
|
||||
public void onCallBack(int position, LiveGiftBean model) {
|
||||
Bus.get().post(new LiveGiftItemEvent().setLiveGiftModel(model));
|
||||
wishGiftId = null;
|
||||
giftSelect(model);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void giftSelect(LiveGiftBean model) {
|
||||
for (int i = 0; i < giftJson.size(); i++) {
|
||||
giftJson.get(i).setChecked(giftJson.get(i).getId() == model.getId());
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return giftJson.size();
|
||||
}
|
||||
|
||||
public void refreshWrapListAfterSend(LiveGiftBean model) {
|
||||
for (int i = 0; i < giftJson.size(); i++) {
|
||||
if (giftJson.get(i).getId() == model.getId()) {
|
||||
int giftNum = giftJson.get(i).getBlindBoxTicket();
|
||||
giftJson.get(i).setBlindBoxTicket(giftNum - 1);
|
||||
}
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,254 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.makeramen.roundedimageview.RoundedImageView;
|
||||
import com.yunbao.common.adapter.RefreshAdapter;
|
||||
import com.yunbao.common.bean.RandomPkUserBean;
|
||||
import com.yunbao.common.bean.SetAttentsModel;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.LiveHttpUtil;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.activity.LiveRyAnchorActivity;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 单人PK/多人PK邀请的对话框适配器
|
||||
*/
|
||||
public class FreePkRecyclerAdapter extends RefreshAdapter<RandomPkUserBean> {
|
||||
private static final int HEAD = 0;
|
||||
private static final int ITEM = 2;
|
||||
private int freePkNum;//PK次数
|
||||
private int mDrPkNum = -1;//多人PK剩余次数,为-1则认为是单人PK
|
||||
|
||||
public void setFreePkNum(int freePkNum) {
|
||||
this.freePkNum = freePkNum;
|
||||
}
|
||||
|
||||
public FreePkRecyclerAdapter(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public void setDrPkNum(int mDrPkNum) {
|
||||
this.mDrPkNum = mDrPkNum;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public HeadViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
if (viewType == HEAD) {
|
||||
return new HeadViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_random_pk_rv_head, parent, false));
|
||||
}
|
||||
return new ItemViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_random_pk_rv, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
if (getItemViewType(position) == ITEM) {
|
||||
((ItemViewHolder) holder).setData(mList.get(position), position);
|
||||
} else {
|
||||
((HeadViewHolder) holder).setData(mList.get(position), position);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (position == 0) {
|
||||
return HEAD;
|
||||
}
|
||||
return ITEM;
|
||||
}
|
||||
|
||||
private class HeadViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
public HeadViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
|
||||
}
|
||||
|
||||
public void setData(RandomPkUserBean bean, int position) {
|
||||
if (!WordUtil.isNewZh() && itemView.findViewById(R.id.text1) != null) {
|
||||
((TextView) itemView.findViewById(R.id.text1)).setText("number");
|
||||
((TextView) itemView.findViewById(R.id.text2)).setText("user");
|
||||
((TextView) itemView.findViewById(R.id.text3)).setText("status");
|
||||
((TextView) itemView.findViewById(R.id.text4)).setText("Controls");
|
||||
((TextView) itemView.findViewById(R.id.text5)).setText("follow");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, String> yaoqing = new HashMap<>();
|
||||
|
||||
public class ItemViewHolder extends HeadViewHolder {
|
||||
private TextView mNum;
|
||||
private TextView mName;
|
||||
private TextView mId;
|
||||
private TextView mStatus;
|
||||
private RoundedImageView mAvatar;
|
||||
private ImageView mPkStatus;
|
||||
private ImageView mFollow;
|
||||
|
||||
public ItemViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
mNum = itemView.findViewById(R.id.item_id);
|
||||
mName = itemView.findViewById(R.id.item_name);
|
||||
mId = itemView.findViewById(R.id.item_uid);
|
||||
mStatus = itemView.findViewById(R.id.item_status);
|
||||
mAvatar = itemView.findViewById(R.id.item_avatar);
|
||||
mPkStatus = itemView.findViewById(R.id.item_pk);
|
||||
mFollow = itemView.findViewById(R.id.item_follow);
|
||||
mPkStatus.setOnClickListener(v -> {
|
||||
RandomPkUserBean bean = (RandomPkUserBean) itemView.getTag();
|
||||
if (bean.isPk()) {
|
||||
ToastUtil.show(mContext.getString(R.string.free_pk_user_pking));
|
||||
return;
|
||||
}
|
||||
if (freePkNum == 0 && mDrPkNum == -1) {
|
||||
ToastUtil.show(mContext.getString(R.string.free_pk_num_null));
|
||||
// return;
|
||||
}
|
||||
|
||||
LiveHttpUtil.getMicList(LiveRyAnchorActivity.mLiveUid, 0, new com.yunbao.common.http.HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
System.out.println("code = " + code + ", msg = " + msg + ", info = " + Arrays.deepToString(info));
|
||||
//非0认为未开通连麦权限
|
||||
if (code != 0) {
|
||||
if (mDrPkNum == -1) {
|
||||
if (WordUtil.isNewZh()) {
|
||||
ToastUtil.show("邀请 " + bean.getUserNiceName() + " 发送成功");
|
||||
} else {
|
||||
ToastUtil.show("invite " + bean.getUserNiceName() + " successful");
|
||||
}
|
||||
mOnItemClickListener.onItemClick(bean, -1);
|
||||
((LiveRyAnchorActivity) mContext).linkMicAnchorApply(bean.getId(), bean.getId(),
|
||||
((LiveRyAnchorActivity) mContext).buildLinkMicJSON().toString()
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (mDrPkNum <= 0) {
|
||||
if (WordUtil.isNewZh()) {
|
||||
ToastUtil.show("多人次數已用完");
|
||||
} else {
|
||||
ToastUtil.show("Multiple times have been used up");
|
||||
}
|
||||
return;
|
||||
}
|
||||
yaoqing.put(bean.getId(), bean.getId());
|
||||
if (yaoqing.size() < 5) {
|
||||
((LiveRyAnchorActivity) mContext).linkDrMicAnchorApply(bean.getId(), bean.getId());
|
||||
} else {
|
||||
ToastUtil.show(WordUtil.isNewZh() ? "多人PK最大參與人數為4人" : "The maximum number of participants in a multiplayer PK is 4 people");
|
||||
}
|
||||
if (freePkRecyclerListener != null) {
|
||||
freePkRecyclerListener.onClose();
|
||||
}
|
||||
|
||||
} else {
|
||||
if (WordUtil.isNewZh()) {
|
||||
ToastUtil.show("請先關閉語音連麥");
|
||||
} else {
|
||||
ToastUtil.show("Please disable the voice connection first");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
mFollow.setOnClickListener(v -> {
|
||||
RandomPkUserBean bean = (RandomPkUserBean) itemView.getTag();
|
||||
LiveNetManager.get(mContext).setAttents(bean.getId(), new HttpCallback<SetAttentsModel>() {
|
||||
@Override
|
||||
public void onSuccess(SetAttentsModel data) {
|
||||
bean.setAttention(data.getIsattent());
|
||||
if ("1".equals(data.getIsattent())) {
|
||||
ToastUtil.show(mContext.getString(R.string.following));
|
||||
mOnItemClickListener.onItemClick(bean, 1);
|
||||
} else {
|
||||
ToastUtil.show(mContext.getString(R.string.unfollow_cancel));
|
||||
mOnItemClickListener.onItemClick(bean, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
ToastUtil.show(WordUtil.isNewZh() ? "抱歉!出錯了!" : "i \\'m sorry! An error occurred");
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(RandomPkUserBean bean, int position) {
|
||||
super.setData(bean, position);
|
||||
if (bean == null) {
|
||||
return;
|
||||
}
|
||||
itemView.setTag(bean);
|
||||
mNum.setText((position) + "");
|
||||
if (position % 2 == 0) {
|
||||
itemView.setBackgroundResource(R.drawable.bg_item_random_pk_type_1);
|
||||
} else {
|
||||
itemView.setBackgroundResource(R.drawable.bg_item_random_pk_type_2);
|
||||
}
|
||||
ImgLoader.display(mContext, bean.getAvatar(), mAvatar);
|
||||
if (bean.getUserNiceName().length() > 4) {
|
||||
mName.setText(bean.getUserNiceName().substring(0, 4) + "...");
|
||||
} else {
|
||||
mName.setText(bean.getUserNiceName());
|
||||
}
|
||||
mId.setText(bean.getId());
|
||||
if (bean.isPk()) {
|
||||
mStatus.setText("PK中");
|
||||
ImgLoader.display(mContext, R.mipmap.ic_random_pk_pk, mPkStatus);
|
||||
if (!WordUtil.isNewZh()) {
|
||||
mStatus.setText("PK");
|
||||
}
|
||||
} else {
|
||||
mStatus.setText("空闲");
|
||||
ImgLoader.display(mContext, R.mipmap.ic_random_pk_pk_unselect, mPkStatus);
|
||||
if (!WordUtil.isNewZh()) {
|
||||
mStatus.setText("free");
|
||||
}
|
||||
}
|
||||
if (bean.isAttention()) {
|
||||
ImgLoader.display(mContext, R.mipmap.ic_random_pk_like, mFollow);
|
||||
} else {
|
||||
ImgLoader.display(mContext, R.mipmap.ic_random_pk_like_unselect, mFollow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private FreePkRecyclerListener freePkRecyclerListener;
|
||||
|
||||
public FreePkRecyclerAdapter setFreePkRecyclerListener(FreePkRecyclerListener freePkRecyclerListener) {
|
||||
this.freePkRecyclerListener = freePkRecyclerListener;
|
||||
return this;
|
||||
}
|
||||
|
||||
public interface FreePkRecyclerListener {
|
||||
void onClose();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.bean.ActiveModel;
|
||||
import com.yunbao.live.views.FunGamesViewHolder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FunGamesAdapter extends RecyclerView.Adapter {
|
||||
private List<ActiveModel> activeModels = new ArrayList<>();
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View funGameView = LayoutInflater.from(parent.getContext()).inflate(R.layout.view_fun_games, parent, false);
|
||||
return new FunGamesViewHolder(funGameView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
if (holder instanceof FunGamesViewHolder) {
|
||||
FunGamesViewHolder funGamesViewHolder = (FunGamesViewHolder) holder;
|
||||
funGamesViewHolder.showView(activeModels.get(position));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return activeModels.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置数据源
|
||||
*
|
||||
* @param mActiveModels
|
||||
*/
|
||||
public void addData(List<ActiveModel> mActiveModels) {
|
||||
activeModels.clear();
|
||||
activeModels.addAll(mActiveModels);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.bean.GiftTopBean;
|
||||
import com.yunbao.live.views.GiftTitleViewHolder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class GiftTitleAdapter extends RecyclerView.Adapter {
|
||||
|
||||
List<GiftTopBean> name = new ArrayList<>();
|
||||
private int index = 0;
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View herdView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_gift_top_new, parent, false);
|
||||
return new GiftTitleViewHolder(herdView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
GiftTitleViewHolder itemViewHolder = (GiftTitleViewHolder) holder;
|
||||
itemViewHolder.showData(name.get(position), position, new GiftTitleViewHolder.ClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks(int mPosition) {
|
||||
index = mPosition;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
itemViewHolder.selectData(index == position,name.get(position).getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return name.size();
|
||||
}
|
||||
|
||||
public void addAllData(List<GiftTopBean> giftTopBeans) {
|
||||
name.clear();
|
||||
name.addAll(giftTopBeans);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void uncheck() {
|
||||
index = -1;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setTitleIndex(int i) {
|
||||
index=i;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
108
live/src/main/java/com/yunbao/live/adapter/GiftTopAdapter.java
Normal file
108
live/src/main/java/com/yunbao/live/adapter/GiftTopAdapter.java
Normal file
@@ -0,0 +1,108 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.bean.GiftTopBean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GiftTopAdapter extends RecyclerView.Adapter<GiftTopAdapter.Vh> {
|
||||
|
||||
private Context mContext;
|
||||
private List<GiftTopBean> mList;
|
||||
private LayoutInflater mInflater;
|
||||
//选中的
|
||||
public int choice = 0;
|
||||
private View.OnClickListener mOnClickListener;
|
||||
private OnItemClickListener<GiftTopBean> mOnItemClickListener;
|
||||
|
||||
public GiftTopAdapter(Context context) {
|
||||
mContext = context;
|
||||
mInflater = LayoutInflater.from(context);
|
||||
mList = new ArrayList<>();
|
||||
mOnClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Object tag = v.getTag();
|
||||
if (tag != null) {
|
||||
int position = (int) tag;
|
||||
GiftTopBean bean = mList.get(position);
|
||||
choice = position;
|
||||
if (mOnItemClickListener != null) {
|
||||
mOnItemClickListener.onItemClick(bean, position);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener<GiftTopBean> onItemClickListener) {
|
||||
mOnItemClickListener = onItemClickListener;
|
||||
}
|
||||
|
||||
|
||||
public void setList(List<GiftTopBean> list) {
|
||||
Log.i("tags",choice+"choice");
|
||||
if (list != null && list.size() > 0) {
|
||||
mList.clear();
|
||||
mList.addAll(list);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void setChoice(int choice) {
|
||||
this.choice = choice;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Vh onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new Vh(mInflater.inflate(R.layout.item_gift_top, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull Vh vh, int i) {
|
||||
vh.setData(i);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mList.size();
|
||||
}
|
||||
|
||||
class Vh extends RecyclerView.ViewHolder {
|
||||
|
||||
TextView mName;
|
||||
|
||||
public Vh(View itemView) {
|
||||
super(itemView);
|
||||
mName = itemView.findViewById(R.id.name);
|
||||
itemView.setOnClickListener(mOnClickListener);
|
||||
}
|
||||
|
||||
void setData(final int position) {
|
||||
itemView.setTag(position);
|
||||
mName.setText(mList.get(position).getName());
|
||||
if(position == choice){
|
||||
mName.setTextColor(Color.parseColor("#FFBE41"));
|
||||
}else{
|
||||
mName.setTextColor(Color.parseColor("#B6B6B6"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
179
live/src/main/java/com/yunbao/live/adapter/GuardAdapter.java
Normal file
179
live/src/main/java/com/yunbao/live/adapter/GuardAdapter.java
Normal file
@@ -0,0 +1,179 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.text.Html;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.adapter.RefreshAdapter;
|
||||
import com.yunbao.common.bean.LevelBean;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.utils.CommonIconUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.bean.GuardUserBean;
|
||||
import com.yunbao.live.utils.LiveTextRender;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/11/6.
|
||||
*/
|
||||
|
||||
public class GuardAdapter extends RefreshAdapter<GuardUserBean> {
|
||||
|
||||
private static final int HEAD = 1;
|
||||
private static final int NORMAL = 0;
|
||||
private String mVotesName;
|
||||
private String mWeekContributeString;//本周贡献
|
||||
private boolean mDialog;
|
||||
private Drawable mGuardDrawable0;
|
||||
private Drawable mGuardDrawable1;
|
||||
private Drawable mGuardDrawable2;
|
||||
private boolean isShowTitle;
|
||||
|
||||
public GuardAdapter(Context context, boolean dialog, boolean isShowTitle) {
|
||||
super(context);
|
||||
this.isShowTitle = isShowTitle;
|
||||
mDialog = dialog;
|
||||
mVotesName = CommonAppConfig.getInstance().getVotesName();
|
||||
mWeekContributeString =mContext.getString(R.string.guard_week_con);
|
||||
mGuardDrawable0 = ContextCompat.getDrawable(context, R.mipmap.icon_guard_type_0);
|
||||
mGuardDrawable1 = ContextCompat.getDrawable(context, R.mipmap.icon_guard_type_1);
|
||||
mGuardDrawable2 = ContextCompat.getDrawable(context, R.mipmap.icon_guard_type_2);
|
||||
}
|
||||
|
||||
public GuardAdapter(Context context, boolean dialog) {
|
||||
this(context, dialog, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if(!isShowTitle){
|
||||
return NORMAL;
|
||||
}
|
||||
if (position == 0) {
|
||||
return HEAD;
|
||||
}
|
||||
return NORMAL;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
if (viewType == HEAD) {
|
||||
return new HeadVh(mInflater.inflate(mDialog ? R.layout.guard_list_head : R.layout.guard_list_head_2, parent, false));
|
||||
}
|
||||
return new Vh(mInflater.inflate(mDialog ? R.layout.guard_list : R.layout.guard_list_2, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder vh, int position) {
|
||||
if (vh instanceof HeadVh) {
|
||||
((HeadVh) vh).setData(mList.get(position));
|
||||
} else {
|
||||
((Vh) vh).setData(mList.get(position));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mList.size();
|
||||
}
|
||||
|
||||
|
||||
class HeadVh extends RecyclerView.ViewHolder {
|
||||
|
||||
ImageView mAvatar;
|
||||
TextView mName;
|
||||
ImageView mSex;
|
||||
ImageView mLevel;
|
||||
TextView mVotes;
|
||||
|
||||
|
||||
public HeadVh(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
mAvatar = (ImageView) itemView.findViewById(R.id.avatar);
|
||||
mName = (TextView) itemView.findViewById(R.id.name);
|
||||
mSex = (ImageView) itemView.findViewById(R.id.sex);
|
||||
mLevel = (ImageView) itemView.findViewById(R.id.level);
|
||||
mVotes = (TextView) itemView.findViewById(R.id.votes);
|
||||
}
|
||||
|
||||
void setData(GuardUserBean bean) {
|
||||
ImgLoader.displayAvatar(mContext, bean.getAvatar(), mAvatar);
|
||||
mName.setText(bean.getUserNiceName());
|
||||
mSex.setImageResource(CommonIconUtil.getSexIcon(bean.getSex()));
|
||||
|
||||
new LiveTextRender().getLevelImage(mContext, bean.getLevel(), new ImgLoader.DrawableCallback() {
|
||||
@Override
|
||||
public void onLoadSuccess(Drawable drawable) {
|
||||
ImgLoader.display2(mContext, drawable, mLevel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFailed() {
|
||||
|
||||
}
|
||||
});
|
||||
mVotes.setText(Html.fromHtml(" <font color='#ffdd00'>" + bean.getContribute() + "</font> " + mVotesName));
|
||||
}
|
||||
}
|
||||
|
||||
class Vh extends RecyclerView.ViewHolder {
|
||||
|
||||
ImageView mIcon;
|
||||
ImageView mAvatar;
|
||||
TextView mName;
|
||||
ImageView mSex;
|
||||
ImageView mLevel;
|
||||
TextView mVotes;
|
||||
|
||||
|
||||
public Vh(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
mIcon = (ImageView) itemView.findViewById(R.id.icon);
|
||||
mAvatar = (ImageView) itemView.findViewById(R.id.avatar);
|
||||
mName = (TextView) itemView.findViewById(R.id.name);
|
||||
mSex = (ImageView) itemView.findViewById(R.id.sex);
|
||||
mLevel = (ImageView) itemView.findViewById(R.id.level);
|
||||
mVotes = (TextView) itemView.findViewById(R.id.votes);
|
||||
if(!WordUtil.isNewZh()) {
|
||||
((TextView) itemView.findViewById(R.id.votesTitle)).setText("Contribution");
|
||||
}
|
||||
}
|
||||
|
||||
void setData(GuardUserBean bean) {
|
||||
ImgLoader.displayAvatar(mContext, bean.getAvatar(), mAvatar);
|
||||
mName.setText(bean.getUserNiceName());
|
||||
mSex.setImageResource(CommonIconUtil.getSexIcon(bean.getSex()));
|
||||
new LiveTextRender().getLevelImage(mContext, bean.getLevel(), new ImgLoader.DrawableCallback() {
|
||||
@Override
|
||||
public void onLoadSuccess(Drawable drawable) {
|
||||
ImgLoader.display2(mContext, drawable, mLevel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFailed() {
|
||||
|
||||
}
|
||||
});
|
||||
mVotes.setText(bean.getContribute() + " " + mVotesName);
|
||||
if (bean.getType() == Constants.GUARD_TYPE_DAY) {
|
||||
mIcon.setImageDrawable(mGuardDrawable0);
|
||||
} else if (bean.getType() == Constants.GUARD_TYPE_MONTH) {
|
||||
mIcon.setImageDrawable(mGuardDrawable1);
|
||||
} else if (bean.getType() == Constants.GUARD_TYPE_YEAR) {
|
||||
mIcon.setImageDrawable(mGuardDrawable2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.bean.GuardRightBean;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/11/6.
|
||||
*/
|
||||
|
||||
public class GuardRightAdapter extends RecyclerView.Adapter<GuardRightAdapter.Vh> {
|
||||
|
||||
private Context mContext;
|
||||
private List<GuardRightBean> mList;
|
||||
private LayoutInflater mInflater;
|
||||
// private int mColor1;
|
||||
// private int mColor2;
|
||||
|
||||
public GuardRightAdapter(Context context, List<GuardRightBean> list) {
|
||||
mContext = context;
|
||||
mList = list;
|
||||
mInflater = LayoutInflater.from(context);
|
||||
// mColor1 = ContextCompat.getColor(context, R.color.textColor);
|
||||
// mColor2 = ContextCompat.getColor(context, R.color.gray3);
|
||||
}
|
||||
|
||||
public void setList(List<GuardRightBean> mList) {
|
||||
this.mList = mList;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Vh onCreateViewHolder(@NonNull ViewGroup parent, int position) {
|
||||
return new Vh(mInflater.inflate(R.layout.guard_right, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull Vh vh, int position) {
|
||||
vh.setData(mList.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mList.size();
|
||||
}
|
||||
|
||||
class Vh extends RecyclerView.ViewHolder {
|
||||
|
||||
ImageView mIcon;
|
||||
TextView mTitle;
|
||||
TextView mDes;
|
||||
|
||||
public Vh(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
mIcon = (ImageView) itemView.findViewById(R.id.icon);
|
||||
mTitle = (TextView) itemView.findViewById(R.id.title);
|
||||
mDes = (TextView) itemView.findViewById(R.id.des);
|
||||
}
|
||||
|
||||
void setData(GuardRightBean bean) {
|
||||
mTitle.setText(bean.getTitle());
|
||||
mDes.setText(bean.getDes());
|
||||
if (bean.isChecked()) {
|
||||
ImgLoader.display(mContext, bean.getIcon1(), mIcon);
|
||||
} else {
|
||||
ImgLoader.display(mContext, bean.getIcon0(), mIcon);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
415
live/src/main/java/com/yunbao/live/adapter/ImListAdapter.java
Normal file
415
live/src/main/java/com/yunbao/live/adapter/ImListAdapter.java
Normal file
@@ -0,0 +1,415 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.bean.ImUserBean;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/10/24.
|
||||
*/
|
||||
|
||||
public class ImListAdapter extends RecyclerView.Adapter
|
||||
// implements ItemSlideHelper.Callback
|
||||
{
|
||||
|
||||
private static final int HEAD = -1;
|
||||
private static final int ANCHOR = -2;
|
||||
private Context mContext;
|
||||
private RecyclerView mRecyclerView;
|
||||
private List<ImUserBean> mList;
|
||||
private LayoutInflater mInflater;
|
||||
private View.OnClickListener mOnClickListener;
|
||||
private View.OnClickListener mOnDeleteClickListener;
|
||||
private View.OnLongClickListener mOnDeleteLongClickListener;
|
||||
private ActionListener mActionListener;
|
||||
|
||||
|
||||
public ImListAdapter(Context context) {
|
||||
mContext = context;
|
||||
mList = new ArrayList<>();
|
||||
mList.add(new ImUserBean());
|
||||
mInflater = LayoutInflater.from(context);
|
||||
|
||||
mOnClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Object tag = v.getTag();
|
||||
if (tag != null) {
|
||||
int position = (int) tag;
|
||||
ImUserBean bean = mList.get(position);
|
||||
// if (bean.getUnReadCount() != 0) {
|
||||
// bean.setUnReadCount(0);
|
||||
// notifyItemChanged(position, Constants.PAYLOAD);
|
||||
// }
|
||||
if (mActionListener != null) {
|
||||
mList.get(position).setNum("0");
|
||||
mActionListener.onItemClick(bean);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
mOnDeleteClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Object tag = v.getTag();
|
||||
if (tag != null) {
|
||||
int position = (int) tag;
|
||||
if (position >= 3) {
|
||||
ImUserBean bean = mList.get(position);
|
||||
removeItem(position);
|
||||
if (mActionListener != null) {
|
||||
mActionListener.onItemDelete(bean, mList.size(), v);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
mOnDeleteLongClickListener = new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
Object tag = v.getTag();
|
||||
if (tag != null) {
|
||||
int position = (int) tag;
|
||||
if (position >= 3) {
|
||||
ImUserBean bean = mList.get(position);
|
||||
if (mActionListener != null) {
|
||||
mActionListener.onItemDelete(bean, position, v);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public void setList(List<ImUserBean> list) {
|
||||
if (list != null && list.size() > 0) {
|
||||
mList.clear();
|
||||
mList.addAll(list);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除数据源
|
||||
*/
|
||||
public void removeAllDate() {
|
||||
if (mList != null) {
|
||||
mList.clear();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void setActionListener(ActionListener actionListener) {
|
||||
mActionListener = actionListener;
|
||||
}
|
||||
|
||||
public void removeItem(int position) {
|
||||
mList.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeChanged(position, mList.size());
|
||||
}
|
||||
|
||||
|
||||
public void insertItem(ImUserBean bean) {
|
||||
int position = mList.size();
|
||||
mList.add(bean);
|
||||
notifyItemInserted(position);
|
||||
}
|
||||
|
||||
// public void resetAllUnReadCount() {
|
||||
// if (mList != null && mList.size() > 0) {
|
||||
// for (ImUserBean bean : mList) {
|
||||
// bean.setUnReadCount(0);
|
||||
// }
|
||||
// notifyDataSetChanged();
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
// if (position == 0) {
|
||||
// return HEAD;
|
||||
// } else if (mList.get(position).isAnchorItem()) {
|
||||
// return ANCHOR;
|
||||
// }
|
||||
return 0;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new Vh(mInflater.inflate(R.layout.item_im_list, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder vh, int position, @NonNull List payloads) {
|
||||
Object payload = payloads.size() > 0 ? payloads.get(0) : null;
|
||||
// if (vh instanceof Vh) {
|
||||
((Vh) vh).setData(mList.get(position), position, payload);
|
||||
// } else if (vh instanceof AnchorVh) {
|
||||
// ((AnchorVh) vh).setData(mList.get(position), position, payload);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mList.size();
|
||||
}
|
||||
|
||||
|
||||
class Vh extends RecyclerView.ViewHolder {
|
||||
|
||||
ImageView mAvatar;
|
||||
TextView mName, name_remarks;
|
||||
ImageView mSex;
|
||||
ImageView mLevel;
|
||||
TextView mMsg;
|
||||
TextView mTime;
|
||||
View mBtnDelete;
|
||||
TextView mRedPoint;
|
||||
ImageView img_new;
|
||||
|
||||
public Vh(View itemView) {
|
||||
super(itemView);
|
||||
mAvatar = (ImageView) itemView.findViewById(R.id.avatar);
|
||||
mName = (TextView) itemView.findViewById(R.id.name);
|
||||
name_remarks = (TextView) itemView.findViewById(R.id.name_remarks);
|
||||
mSex = (ImageView) itemView.findViewById(R.id.sex);
|
||||
mLevel = (ImageView) itemView.findViewById(R.id.level);
|
||||
mMsg = (TextView) itemView.findViewById(R.id.msg);
|
||||
mTime = (TextView) itemView.findViewById(R.id.time);
|
||||
mRedPoint = (TextView) itemView.findViewById(R.id.red_point);
|
||||
mBtnDelete = itemView.findViewById(R.id.btn_delete);
|
||||
itemView.setOnClickListener(mOnClickListener);
|
||||
itemView.setOnLongClickListener(mOnDeleteLongClickListener);
|
||||
// mBtnDelete.setOnClickListener(mOnDeleteClickListener);
|
||||
|
||||
img_new = (ImageView) itemView.findViewById(R.id.img_new);
|
||||
}
|
||||
|
||||
void setData(ImUserBean bean, int position, Object payload) {
|
||||
itemView.setTag(position);
|
||||
mBtnDelete.setTag(position);
|
||||
if (payload == null) {
|
||||
ImgLoader.displayWithError(mContext, bean.getImage(), mAvatar, R.mipmap.chat_head_mo);
|
||||
|
||||
if (bean.getRemarks() != null) {
|
||||
// name_remarks.setText(bean.getRemarks());
|
||||
mName.setText(bean.getTitle() + "(" + bean.getRemarks() + ")");
|
||||
} else {
|
||||
mName.setText(bean.getTitle());
|
||||
// name_remarks.setText("");
|
||||
}
|
||||
// mSex.setImageResource(CommonIconUtil.getSexIcon(bean.getSex()));
|
||||
// LevelBean levelBean = CommonAppConfig.getInstance().getLevel(bean.getLevel());
|
||||
// if (levelBean != null) {
|
||||
// ImgLoader.display(mContext,levelBean.getThumb(), mLevel);
|
||||
// }
|
||||
}
|
||||
if (position == 2) {
|
||||
if (bean.getLink() != null && !"".equals(bean.getLink())) {
|
||||
mMsg.setText(bean.getContent());
|
||||
} else {
|
||||
mMsg.setText(mContext.getResources().getString(R.string.chat_like));
|
||||
}
|
||||
} else {
|
||||
if (position == 1) {
|
||||
if (bean.getContent() != null && !"".equals(bean.getContent())) {
|
||||
mMsg.setText(bean.getContent());
|
||||
} else {
|
||||
mMsg.setText(mContext.getResources().getString(R.string.chat_action_no));
|
||||
}
|
||||
} else {
|
||||
if (bean.getContent() != null && bean.getContent().length() > 0) {
|
||||
mMsg.setText(bean.getContent());
|
||||
} else {
|
||||
mMsg.setText("");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (position > 2) {
|
||||
mAvatar.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (!"1".equals(bean.getIs_admin())) {
|
||||
RouteUtil.forwardUserHome(mContext, bean.getUserId(), 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
mAvatar.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
if (bean.getAddtime() != null && !bean.getAddtime().equals("0")) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||
Date currenTimeZone;
|
||||
if (bean.getType().equals("-1")) {
|
||||
currenTimeZone = new Date(Long.parseLong(bean.getAddtime()));
|
||||
} else {
|
||||
currenTimeZone = new Date(Long.parseLong(bean.getAddtime() + "000"));
|
||||
}
|
||||
mTime.setText(sdf.format(currenTimeZone));
|
||||
}
|
||||
if (bean.getNum() != null && !bean.getNum().equals("0")) {
|
||||
if (mRedPoint.getVisibility() != View.VISIBLE) {
|
||||
mRedPoint.setVisibility(View.VISIBLE);
|
||||
}
|
||||
mRedPoint.setText(String.valueOf(bean.getNum()));
|
||||
} else {
|
||||
if (mRedPoint.getVisibility() == View.VISIBLE) {
|
||||
mRedPoint.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
if ("1".equals(bean.getIs_admin())) {
|
||||
ImgLoader.display(mContext, "https://downs.yaoulive.com/Instructors.png", img_new);
|
||||
img_new.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
img_new.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// class AnchorVh extends RecyclerView.ViewHolder {
|
||||
//
|
||||
// ImageView mAvatar;
|
||||
// TextView mName;
|
||||
// ImageView mSex;
|
||||
// ImageView mLevel;
|
||||
// TextView mMsg;
|
||||
// TextView mTime;
|
||||
// TextView mRedPoint;
|
||||
// View mBtnPriChat;
|
||||
//
|
||||
// public AnchorVh(View itemView) {
|
||||
// super(itemView);
|
||||
// mAvatar = (ImageView) itemView.findViewById(R.id.avatar);
|
||||
// mName = (TextView) itemView.findViewById(R.id.name);
|
||||
// mSex = (ImageView) itemView.findViewById(R.id.sex);
|
||||
// mLevel = (ImageView) itemView.findViewById(R.id.level);
|
||||
// mMsg = (TextView) itemView.findViewById(R.id.msg);
|
||||
// mTime = (TextView) itemView.findViewById(R.id.time);
|
||||
// mRedPoint = (TextView) itemView.findViewById(R.id.red_point);
|
||||
//// mBtnPriChat = itemView.findViewById(R.id.btn_pri_chat);
|
||||
// itemView.setOnClickListener(mOnClickListener);
|
||||
// }
|
||||
//
|
||||
// void setData(ImUserBean bean, int position, Object payload) {
|
||||
// itemView.setTag(position);
|
||||
// if (payload == null) {
|
||||
// ImgLoader.display(mContext, bean.getImage(), mAvatar);
|
||||
// mName.setText(bean.getTitle());
|
||||
//// mSex.setImageResource(CommonIconUtil.getSexIcon(bean.getSex()));
|
||||
//// LevelBean levelBean = CommonAppConfig.getInstance().getLevel(bean.getLevel());
|
||||
//// if (levelBean != null) {
|
||||
//// ImgLoader.display(mContext,levelBean.getThumb(), mLevel);
|
||||
//// }
|
||||
// }
|
||||
// mMsg.setText(bean.getContent());
|
||||
//
|
||||
// if (!bean.getNum().equals("")) {
|
||||
// if (mBtnPriChat.getVisibility() == View.VISIBLE) {
|
||||
// mBtnPriChat.setVisibility(View.INVISIBLE);
|
||||
// }
|
||||
// if (!bean.getAddtime().equals("0")) {
|
||||
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||
// Date currenTimeZone = new Date(Long.parseLong(bean.getAddtime() + "000"));
|
||||
// mTime.setText(sdf.format(currenTimeZone));
|
||||
// }
|
||||
// if (!bean.getNum().equals("")) {
|
||||
// if (mRedPoint.getVisibility() != View.VISIBLE) {
|
||||
// mRedPoint.setVisibility(View.VISIBLE);
|
||||
// }
|
||||
// mRedPoint.setText(String.valueOf(bean.getNum()));
|
||||
// } else {
|
||||
// if (mRedPoint.getVisibility() == View.VISIBLE) {
|
||||
// mRedPoint.setVisibility(View.INVISIBLE);
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// mTime.setText("");
|
||||
// if (mRedPoint.getVisibility() == View.VISIBLE) {
|
||||
// mRedPoint.setVisibility(View.INVISIBLE);
|
||||
// }
|
||||
// if (mBtnPriChat.getVisibility() != View.VISIBLE) {
|
||||
// mBtnPriChat.setVisibility(View.VISIBLE);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
@Override
|
||||
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
|
||||
super.onAttachedToRecyclerView(recyclerView);
|
||||
mRecyclerView = recyclerView;
|
||||
//添加事件监听
|
||||
// mRecyclerView.addOnItemTouchListener(new ItemSlideHelper(mContext, this));
|
||||
}
|
||||
|
||||
// //滑动等 事件操作
|
||||
// @Override
|
||||
// public int getHorizontalRange(RecyclerView.ViewHolder vh) {
|
||||
// return DpUtil.dp2px(60);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public RecyclerView.ViewHolder getChildViewHolder(View childView) {
|
||||
// if (mRecyclerView != null && childView != null) {
|
||||
// return mRecyclerView.getChildViewHolder(childView);
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public View findTargetView(float x, float y) {
|
||||
// return mRecyclerView.findChildViewUnder(x, y);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean useLeftScroll() {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onLeftScroll(RecyclerView.ViewHolder holder) {
|
||||
//
|
||||
// }
|
||||
|
||||
public interface ActionListener {
|
||||
|
||||
void onItemClick(ImUserBean bean);
|
||||
|
||||
void onItemDelete(ImUserBean bean, int size, View v);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.makeramen.roundedimageview.RoundedImageView;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.adapter.RefreshAdapter;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.bean.SystemMessageBean;
|
||||
import com.yunbao.live.views.SystemMessageViewHolder;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 互動信息
|
||||
*/
|
||||
public class InteractionMessageAdapter extends RefreshAdapter<SystemMessageBean> {
|
||||
private SystemMessageViewHolder nowSystemMessageViewHolder;
|
||||
|
||||
public InteractionMessageAdapter(Context context, SystemMessageViewHolder systemMessageViewHolder) {
|
||||
super(context);
|
||||
this.nowSystemMessageViewHolder = systemMessageViewHolder;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new InteractionMessageAdapter.Vh(mInflater.inflate(R.layout.item_interaction_msg, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder vh, int position) {
|
||||
((InteractionMessageAdapter.Vh) vh).setData(mList.get(position));
|
||||
}
|
||||
|
||||
class Vh extends RecyclerView.ViewHolder {
|
||||
RoundedImageView mIco;
|
||||
TextView mContent;
|
||||
TextView mTime;
|
||||
TextView mText;
|
||||
LinearLayout toView, lt_content2, lt_reply, lt_img;
|
||||
ImageView img_content_pic1, img_content_pic2, img_content_pic3, img_content2_pic1, img_content2_pic2, img_item_interaction;
|
||||
RelativeLayout rt_root;
|
||||
|
||||
public Vh(View itemView) {
|
||||
super(itemView);
|
||||
mIco = itemView.findViewById(R.id.ico);
|
||||
mContent = itemView.findViewById(R.id.content);
|
||||
mTime = itemView.findViewById(R.id.time);
|
||||
mText = itemView.findViewById(R.id.text);
|
||||
toView = itemView.findViewById(R.id.to_view);
|
||||
lt_content2 = itemView.findViewById(R.id.lt_content2);
|
||||
img_content_pic1 = itemView.findViewById(R.id.img_content_pic1);
|
||||
img_content_pic2 = itemView.findViewById(R.id.img_content_pic2);
|
||||
img_content_pic3 = itemView.findViewById(R.id.img_content_pic3);
|
||||
img_content2_pic1 = itemView.findViewById(R.id.img_content2_pic1);
|
||||
img_content2_pic2 = itemView.findViewById(R.id.img_content2_pic2);
|
||||
rt_root = itemView.findViewById(R.id.rt_root);
|
||||
lt_reply = itemView.findViewById(R.id.lt_reply);
|
||||
lt_img = itemView.findViewById(R.id.lt_img);
|
||||
img_item_interaction = itemView.findViewById(R.id.img_item_interaction);
|
||||
|
||||
}
|
||||
|
||||
void setData(SystemMessageBean bean) {
|
||||
ImgLoader.displayWithError(mContext, bean.getAvatar_thumb(), mIco, R.mipmap.chat_head_mo);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||
Date currenTimeZone = new Date(Long.parseLong(bean.getAddtime() + "000"));
|
||||
mTime.setText(sdf.format(currenTimeZone));
|
||||
mText.setText(bean.getUser_nicename());
|
||||
mContent.setText(bean.getContent());
|
||||
mIco.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
RouteUtil.forwardUserHome(mContext, bean.getUid(), 2);
|
||||
}
|
||||
});
|
||||
if (bean.getDynamic_id() != null && !"0".equals(bean.getDynamic_id())) {
|
||||
lt_img.setVisibility(View.VISIBLE);
|
||||
rt_root.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Constants.myIntoIndex = 2;
|
||||
Constants.chatActionUrl=CommonAppConfig.HOST
|
||||
+ "/h5/shequ/index.html#/h5/shequ/details?isDetailsChat=1&dynamic_uid="
|
||||
+ bean.getUid()
|
||||
+ "&id=" + bean.getDynamic_id();
|
||||
RouteUtil.forwardUserHome(mContext, bean.getUid(), 2);
|
||||
}
|
||||
});
|
||||
if (bean.getType() != null && !"0".equals(bean.getType())) {
|
||||
lt_reply.setVisibility(View.VISIBLE);
|
||||
lt_reply.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
nowSystemMessageViewHolder.editPopupWindow(bean.getDynamic_id(), bean.getTo_comment_id());
|
||||
}
|
||||
});
|
||||
} else {
|
||||
lt_reply.setVisibility(View.GONE);
|
||||
}
|
||||
ImgLoader.displayWithError(mContext, bean.getShowImg(), img_item_interaction, R.mipmap.chat_head_mo);
|
||||
} else {
|
||||
lt_img.setVisibility(View.GONE);
|
||||
lt_reply.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.common.bean.LevelBean;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.utils.CommonIconUtil;
|
||||
import com.yunbao.live.utils.LiveTextRender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/10/16.
|
||||
*/
|
||||
|
||||
public class LiveAdminListAdapter extends RecyclerView.Adapter<LiveAdminListAdapter.Vh> {
|
||||
|
||||
private Context mContext;
|
||||
private List<UserBean> mList;
|
||||
private LayoutInflater mInflater;
|
||||
private View.OnClickListener mOnClickListener;
|
||||
private OnItemClickListener<UserBean> mOnItemClickListener;
|
||||
|
||||
public LiveAdminListAdapter(Context context, List<UserBean> list) {
|
||||
mContext=context;
|
||||
mInflater = LayoutInflater.from(context);
|
||||
mList = list;
|
||||
mOnClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Object tag = v.getTag();
|
||||
if (tag != null) {
|
||||
int position = (int) tag;
|
||||
if (mOnItemClickListener != null) {
|
||||
mOnItemClickListener.onItemClick(mList.get(position), position);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener<UserBean> onItemClickListener) {
|
||||
mOnItemClickListener = onItemClickListener;
|
||||
}
|
||||
|
||||
public void setList(List<UserBean> list){
|
||||
mList=list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Vh onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new Vh(mInflater.inflate(R.layout.item_live_admin_list, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull Vh holder, int position) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull Vh vh, int position, @NonNull List<Object> payloads) {
|
||||
Object payload = payloads.size() > 0 ? payloads.get(0) : null;
|
||||
vh.setData(mList.get(position), position, payload);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mList.size();
|
||||
}
|
||||
|
||||
class Vh extends RecyclerView.ViewHolder {
|
||||
|
||||
ImageView mAvatar;
|
||||
TextView mName;
|
||||
ImageView mSex;
|
||||
ImageView mLevel;
|
||||
View mBtnDel;
|
||||
|
||||
public Vh(View itemView) {
|
||||
super(itemView);
|
||||
mAvatar =(ImageView) itemView.findViewById(R.id.avatar);
|
||||
mName =(TextView) itemView.findViewById(R.id.name);
|
||||
mSex = (ImageView) itemView.findViewById(R.id.sex);
|
||||
mLevel =(ImageView) itemView.findViewById(R.id.level);
|
||||
mBtnDel = itemView.findViewById(R.id.btn_delete);
|
||||
mBtnDel.setOnClickListener(mOnClickListener);
|
||||
}
|
||||
|
||||
void setData(UserBean bean, int position, Object payload) {
|
||||
mBtnDel.setTag(position);
|
||||
if (payload == null) {
|
||||
ImgLoader.displayAvatar(mContext,bean.getAvatar(), mAvatar);
|
||||
mName.setText(bean.getUserNiceName());
|
||||
mSex.setImageResource(CommonIconUtil.getSexIcon(bean.getSex()));
|
||||
new LiveTextRender().getLevelImage(mContext, bean.getLevel(), new ImgLoader.DrawableCallback() {
|
||||
@Override
|
||||
public void onLoadSuccess(Drawable drawable) {
|
||||
ImgLoader.display2(mContext, drawable, mLevel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFailed() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removeItem(String uid) {
|
||||
if (TextUtils.isEmpty(uid)) {
|
||||
return;
|
||||
}
|
||||
int position = -1;
|
||||
for (int i = 0, size = mList.size(); i < size; i++) {
|
||||
if (uid.equals(mList.get(i).getId())) {
|
||||
position = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (position >= 0) {
|
||||
mList.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeChanged(position, mList.size(), Constants.PAYLOAD);
|
||||
}
|
||||
}
|
||||
|
||||
public void clear(){
|
||||
mList.clear();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void release(){
|
||||
if(mList!=null){
|
||||
mList.clear();
|
||||
}
|
||||
mOnClickListener=null;
|
||||
mOnItemClickListener=null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.yunbao.common.adapter.RefreshAdapter;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.bean.LiveAdminRoomBean;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2019/4/27.
|
||||
*/
|
||||
|
||||
public class LiveAdminRoomAdapter extends RefreshAdapter<LiveAdminRoomBean> {
|
||||
|
||||
private String mSuffix;
|
||||
private View.OnClickListener mOnClickListener;
|
||||
|
||||
public LiveAdminRoomAdapter(Context context) {
|
||||
super(context);
|
||||
mSuffix =mContext.getString(R.string.live_admin_room);
|
||||
mOnClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Object tag = v.getTag();
|
||||
if (tag != null && mOnItemClickListener != null) {
|
||||
mOnItemClickListener.onItemClick((LiveAdminRoomBean) tag, 0);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new Vh(mInflater.inflate(R.layout.item_live_admin_room, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder vh, int position) {
|
||||
((Vh) vh).setData(mList.get(position));
|
||||
}
|
||||
|
||||
class Vh extends RecyclerView.ViewHolder {
|
||||
|
||||
TextView mName;
|
||||
|
||||
public Vh(View itemView) {
|
||||
super(itemView);
|
||||
mName = itemView.findViewById(R.id.name);
|
||||
itemView.setOnClickListener(mOnClickListener);
|
||||
}
|
||||
|
||||
void setData(LiveAdminRoomBean bean) {
|
||||
itemView.setTag(bean);
|
||||
mName.setText(StringUtil.contact(bean.getUserNiceName(), mSuffix));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,318 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.common.bean.LiveAnchorCallMeModel;
|
||||
import com.yunbao.common.bean.PrankGiftBean;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.dialog.GiftPopDialog;
|
||||
import com.yunbao.live.dialog.LiveAnchorEditCallMeEditAppDialog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class LiveAnchorEditCallMeAdapter extends RecyclerView.Adapter<LiveAnchorEditCallMeAdapter.BaseViewHolder> {
|
||||
public static final int TYPE_GIFT = 0;
|
||||
public static final int TYPE_LETTER = 1;
|
||||
public static final int TYPE_APP_WECHAT = 2;
|
||||
public static final int TYPE_APP_LINE = 3;
|
||||
public static final int TYPE_APP_WHATSAPP = 4;
|
||||
private Context mContext;
|
||||
private OnItemClickListener<TmpData> onItemClickListener;
|
||||
private List<TmpData> list = new ArrayList<>();
|
||||
|
||||
public LiveAnchorEditCallMeAdapter(Context mContext) {
|
||||
this.mContext = mContext;
|
||||
}
|
||||
|
||||
public void setList(List<TmpData> list) {
|
||||
this.list = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener<TmpData> onItemClickListener) {
|
||||
this.onItemClickListener = onItemClickListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return list.get(position).getType();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public BaseViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
BaseViewHolder holder;
|
||||
switch (viewType) {
|
||||
case TYPE_GIFT:
|
||||
holder = new GiftViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_anchor_call_me_gift, parent, false));
|
||||
break;
|
||||
case TYPE_LETTER:
|
||||
holder = new LetterViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_anchor_call_me_letter, parent, false));
|
||||
break;
|
||||
default:
|
||||
holder = new AppViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_anchor_call_me_app, parent, false));
|
||||
}
|
||||
return holder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull BaseViewHolder holder, int position) {
|
||||
holder.setData(list.get(position), position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
|
||||
public static class TmpData {
|
||||
private String value;
|
||||
private int status;
|
||||
private int type;
|
||||
|
||||
public TmpData() {
|
||||
}
|
||||
|
||||
public TmpData(String value, int status, int type) {
|
||||
this.value = value;
|
||||
this.status = status;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
||||
public class BaseViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
public BaseViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
|
||||
public void setData(TmpData data, int position) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class GiftViewHolder extends BaseViewHolder {
|
||||
|
||||
private View select;
|
||||
private ImageView giftIcon;
|
||||
|
||||
public GiftViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
select = itemView.findViewById(R.id.select);
|
||||
giftIcon = itemView.findViewById(R.id.gift_icon);
|
||||
select.setOnClickListener(v -> {
|
||||
initGiftData();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(TmpData data, int position) {
|
||||
super.setData(data, position);
|
||||
if (!StringUtil.isEmpty(data.getValue())) {
|
||||
ImgLoader.display(mContext, data.getValue(), giftIcon);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void initGiftData() {
|
||||
new GiftPopDialog(mContext, new GiftPopDialog.ActionListener() {
|
||||
|
||||
@Override
|
||||
public void onSelectGift(PrankGiftBean bean) {
|
||||
if (bean != null) {
|
||||
ImgLoader.display(mContext, bean.getIcon(), giftIcon);
|
||||
if (onItemClickListener != null) {
|
||||
onItemClickListener.onItemClick(new TmpData(bean.getGiftId() + "", 1, TYPE_GIFT), getAbsoluteAdapterPosition());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDismiss() {
|
||||
}
|
||||
})
|
||||
.setShowNumber(false)
|
||||
.setTitle(mContext.getString(R.string.live_anchor_edit_call_me_select_gift))
|
||||
.setHideGiftType(true)
|
||||
.showDialog()
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class LetterViewHolder extends BaseViewHolder {
|
||||
TextView letter;
|
||||
View edit;
|
||||
|
||||
public LetterViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
letter = itemView.findViewById(R.id.letterText);
|
||||
edit = itemView.findViewById(R.id.edit);
|
||||
edit.setOnClickListener(v -> {
|
||||
new LiveAnchorEditCallMeEditAppDialog(mContext, TYPE_LETTER).setDefValue(list.get(1).getValue()).setOnValueListener(new OnItemClickListener<String>() {
|
||||
@Override
|
||||
public void onItemClick(String bean, int position) {
|
||||
if (StringUtil.isEmpty(bean)) {
|
||||
letter.setText(R.string.live_anchor_edit_call_me_letter_content);
|
||||
letter.setTextColor(Color.parseColor("#80FFFFFF"));
|
||||
list.get(1).setValue(bean);
|
||||
if (onItemClickListener != null) {
|
||||
onItemClickListener.onItemClick(new TmpData("", 1, TYPE_LETTER), getAbsoluteAdapterPosition());
|
||||
}
|
||||
} else {
|
||||
letter.setText(bean);
|
||||
letter.setTextColor(Color.WHITE);
|
||||
list.get(1).setValue(bean);
|
||||
if (onItemClickListener != null) {
|
||||
onItemClickListener.onItemClick(new TmpData(letter.getText().toString(), 1, TYPE_LETTER), getAbsoluteAdapterPosition());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}).showDialog();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(TmpData data, int position) {
|
||||
super.setData(data, position);
|
||||
if(StringUtil.isEmpty(data.getValue())){
|
||||
letter.setText(R.string.live_anchor_edit_call_me_letter_content);
|
||||
letter.setTextColor(Color.parseColor("#80FFFFFF"));
|
||||
}else {
|
||||
letter.setText(data.getValue());
|
||||
letter.setTextColor(Color.WHITE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class AppViewHolder extends BaseViewHolder {
|
||||
TextView contact;
|
||||
View edit;
|
||||
ImageView status;
|
||||
ImageView icon;
|
||||
|
||||
public AppViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
contact = itemView.findViewById(R.id.contact);
|
||||
edit = itemView.findViewById(R.id.app_edit);
|
||||
status = itemView.findViewById(R.id.app_switch);
|
||||
icon = itemView.findViewById(R.id.gift_icon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(TmpData data, int position) {
|
||||
super.setData(data, position);
|
||||
if (StringUtil.isEmpty(data.getValue())) {
|
||||
contact.setTag(null);
|
||||
contact.setText(mContext.getString(R.string.live_anchor_edit_call_me_not_filled));
|
||||
contact.setTextColor(Color.parseColor("#80FFFFFF"));
|
||||
} else {
|
||||
contact.setTag(data.getValue());
|
||||
contact.setText(data.getValue());
|
||||
contact.setTextColor(Color.WHITE);
|
||||
}
|
||||
if (data.getStatus() == 0) {
|
||||
status.setImageResource(R.mipmap.special_icon_off);
|
||||
} else if (data.getStatus() == 1) {
|
||||
status.setImageResource(R.mipmap.special_icon_on);
|
||||
}
|
||||
status.setTag(data.getStatus());
|
||||
status.setOnClickListener(v -> {
|
||||
if (StringUtil.isEmpty((String) contact.getTag())) {
|
||||
ToastUtil.show(mContext.getString(R.string.live_anchor_edit_call_me_not_filled_toash));
|
||||
return;
|
||||
}
|
||||
int tag = (int) v.getTag();
|
||||
if (tag == 0) {
|
||||
status.setImageResource(R.mipmap.special_icon_on);
|
||||
status.setTag(1);
|
||||
} else {
|
||||
status.setImageResource(R.mipmap.special_icon_off);
|
||||
status.setTag(0);
|
||||
}
|
||||
if (onItemClickListener != null) {
|
||||
onItemClickListener.onItemClick(new TmpData((String) contact.getTag(), (Integer) status.getTag(), data.getType()), position);
|
||||
}
|
||||
});
|
||||
edit.setOnClickListener(v -> {
|
||||
new LiveAnchorEditCallMeEditAppDialog(mContext, data.getType()).setDefValue((String) contact.getTag()).setOnValueListener(new OnItemClickListener<String>() {
|
||||
@Override
|
||||
public void onItemClick(String bean, int position) {
|
||||
if (StringUtil.isEmpty(bean)) {
|
||||
contact.setTag(null);
|
||||
contact.setHint(mContext.getString(R.string.live_anchor_edit_call_me_not_filled));
|
||||
if(position==0) {
|
||||
contact.setTextColor(Color.parseColor("#80FFFFFF"));
|
||||
}
|
||||
} else {
|
||||
contact.setTag(bean);
|
||||
contact.setText(bean);
|
||||
contact.setTextColor(Color.WHITE);
|
||||
}
|
||||
if (onItemClickListener != null) {
|
||||
onItemClickListener.onItemClick(new TmpData((String) contact.getTag(), (Integer) status.getTag(), data.getType()), position);
|
||||
}
|
||||
}
|
||||
}).showDialog();
|
||||
});
|
||||
switch (data.getType()) {
|
||||
case TYPE_APP_WECHAT:
|
||||
icon.setImageResource(R.mipmap.icon_wechat_x);
|
||||
break;
|
||||
case TYPE_APP_LINE:
|
||||
icon.setImageResource(R.mipmap.icon_line_x);
|
||||
break;
|
||||
case TYPE_APP_WHATSAPP:
|
||||
icon.setImageResource(R.mipmap.icon_whatsapp_x);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.live.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class LiveAnchorSayItemsAdapter extends RecyclerView.Adapter<LiveAnchorSayItemsAdapter.ItemsViewHolder> {
|
||||
private Context mContext;
|
||||
private List<String> list;
|
||||
private int click = -1;
|
||||
private OnItemClickListener<String> onItemClickListener;
|
||||
|
||||
public LiveAnchorSayItemsAdapter(Context mContext) {
|
||||
this.mContext = mContext;
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void setList(List<String> list) {
|
||||
this.list = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener<String> onItemClickListener) {
|
||||
this.onItemClickListener = onItemClickListener;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ItemsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new ItemsViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_anchor_say, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ItemsViewHolder holder, int position) {
|
||||
holder.setData(list.get(position), position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public class ItemsViewHolder extends RecyclerView.ViewHolder {
|
||||
private TextView textView;
|
||||
private ImageView icon;
|
||||
|
||||
public ItemsViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
textView = itemView.findViewById(R.id.anchor_say_text);
|
||||
icon = itemView.findViewById(R.id.anchor_say_icon);
|
||||
itemView.setOnClickListener(v -> click());
|
||||
textView.setOnClickListener(v -> click());
|
||||
icon.setOnClickListener(v -> click());
|
||||
|
||||
}
|
||||
|
||||
private void click() {
|
||||
click = getAbsoluteAdapterPosition();
|
||||
if (onItemClickListener != null) {
|
||||
onItemClickListener.onItemClick(list.get(click), click);
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setData(String text, int position) {
|
||||
// textView.setText("已输入的\n内容已输\n入的内容\n已输入的");
|
||||
ImgLoader.display(mContext, text, icon);
|
||||
if (position == click) {
|
||||
itemView.setBackgroundResource(R.drawable.bg_anchor_say_select);
|
||||
} else {
|
||||
itemView.setBackgroundResource(R.drawable.bg_anchor_say);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
123
live/src/main/java/com/yunbao/live/adapter/LiveBlackAdapter.java
Normal file
123
live/src/main/java/com/yunbao/live/adapter/LiveBlackAdapter.java
Normal file
@@ -0,0 +1,123 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.adapter.RefreshAdapter;
|
||||
import com.yunbao.common.bean.LevelBean;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.utils.CommonIconUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.bean.LiveShutUpBean;
|
||||
import com.yunbao.live.utils.LiveTextRender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2019/4/27.
|
||||
*/
|
||||
|
||||
public class LiveBlackAdapter extends RefreshAdapter<LiveShutUpBean> {
|
||||
|
||||
private View.OnClickListener mOnClickListener;
|
||||
|
||||
public LiveBlackAdapter(Context context) {
|
||||
super(context);
|
||||
mOnClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Object tag = v.getTag();
|
||||
if (tag != null) {
|
||||
int position = (int) tag;
|
||||
if (mOnItemClickListener != null) {
|
||||
mOnItemClickListener.onItemClick(mList.get(position), position);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new Vh(mInflater.inflate(R.layout.item_black, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder vh, int position) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder vh, int position, @NonNull List payloads) {
|
||||
Object payload = payloads.size() > 0 ? payloads.get(0) : null;
|
||||
((Vh) vh).setData(mList.get(position), position, payload);
|
||||
}
|
||||
|
||||
public void removeItem(String uid) {
|
||||
if (TextUtils.isEmpty(uid)) {
|
||||
return;
|
||||
}
|
||||
int position = -1;
|
||||
for (int i = 0, size = mList.size(); i < size; i++) {
|
||||
if (uid.equals(mList.get(i).getUid())) {
|
||||
position = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (position >= 0) {
|
||||
mList.remove(position);
|
||||
// notifyItemRemoved(position);
|
||||
// notifyItemRangeChanged(position, mList.size(), Constants.PAYLOAD);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class Vh extends RecyclerView.ViewHolder {
|
||||
|
||||
ImageView mAvatar;
|
||||
TextView mName;
|
||||
ImageView mSex;
|
||||
ImageView mLevel;
|
||||
View mBtnDel;
|
||||
|
||||
public Vh(View itemView) {
|
||||
super(itemView);
|
||||
mAvatar = itemView.findViewById(R.id.avatar);
|
||||
mName = itemView.findViewById(R.id.name);
|
||||
mSex = itemView.findViewById(R.id.sex);
|
||||
mLevel = itemView.findViewById(R.id.level);
|
||||
mBtnDel = itemView.findViewById(R.id.btn_delete);
|
||||
mBtnDel.setOnClickListener(mOnClickListener);
|
||||
}
|
||||
|
||||
void setData(LiveShutUpBean bean, int position, Object payload) {
|
||||
mBtnDel.setTag(position);
|
||||
if (payload == null) {
|
||||
ImgLoader.displayAvatar(mContext, bean.getAvatar(), mAvatar);
|
||||
mName.setText(bean.getUserNiceName());
|
||||
mSex.setImageResource(CommonIconUtil.getSexIcon(bean.getSex()));
|
||||
new LiveTextRender().getLevelImage(mContext, bean.getLevel(), new ImgLoader.DrawableCallback() {
|
||||
@Override
|
||||
public void onLoadSuccess(Drawable drawable) {
|
||||
ImgLoader.display2(mContext, drawable, mLevel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFailed() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
745
live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java
Normal file
745
live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java
Normal file
@@ -0,0 +1,745 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import static com.yunbao.live.bean.LiveChatBean.AI_AUTOMATIC_SPEECH;
|
||||
import static com.yunbao.live.bean.LiveChatBean.LUCKY_100_CHECK;
|
||||
import static com.yunbao.live.bean.LiveChatBean.LUCKY_ANGEL;
|
||||
import static com.yunbao.live.bean.LiveChatBean.RECOMMEND_CARD_NOTIFY;
|
||||
import static com.yunbao.live.bean.LiveChatBean.STAR_CHALLENGE_UPGRADE_NOTIFY;
|
||||
import static com.yunbao.live.bean.LiveChatBean.SYSTEM3_COLOR;
|
||||
import static com.yunbao.live.bean.LiveChatBean.TYPE_TO_USER_MSG;
|
||||
import static com.yunbao.live.bean.LiveChatBean.WISH_LIST_PROGRESS;
|
||||
import static com.yunbao.live.bean.LiveChatBean.XYD_COMPLETE;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextUtils;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.LinearLayoutCompat;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.makeramen.roundedimageview.RoundedImageView;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.bean.IMLoginModel;
|
||||
import com.yunbao.common.bean.OlineUserlistModel;
|
||||
import com.yunbao.common.custom.VerticalImageSpan;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.SpUtil;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.common.views.weight.ClipPathCircleImage;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.activity.LiveAudienceActivity;
|
||||
import com.yunbao.live.bean.LiveChatBean;
|
||||
import com.yunbao.live.dialog.LiveHDDialogFragment;
|
||||
import com.yunbao.live.event.LiveAudienceEvent;
|
||||
import com.yunbao.live.utils.LiveTextRender;
|
||||
import com.yunbao.live.utils.LoadDian9TuUtil;
|
||||
import com.yunbao.live.views.LiveRoomViewHolder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/10/10.
|
||||
*/
|
||||
|
||||
public class LiveChatAdapter extends RecyclerView.Adapter {
|
||||
public final static int MSG_HOUR_RANK_CHANGE = -100;//收到小时榜推送,发送一条弹幕
|
||||
|
||||
private Context mContext;
|
||||
private List<LiveChatBean> mList;
|
||||
private LayoutInflater mInflater;
|
||||
private View.OnClickListener mOnClickListener;
|
||||
private OnItemClickListener<LiveChatBean> mOnItemClickListener;
|
||||
private RecyclerView mRecyclerView;
|
||||
private LinearLayoutManager mLayoutManager;
|
||||
|
||||
private IMLoginModel model;
|
||||
private int mRecyclerViewScrolledDy;
|
||||
|
||||
private int mPosition;
|
||||
private boolean isBottom = false;
|
||||
private int fountSize = 13;
|
||||
private String isFans;
|
||||
|
||||
public LiveChatAdapter setFans(String fans) {
|
||||
isFans = fans;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LiveChatAdapter(Context context) {
|
||||
mContext = context;
|
||||
mList = new ArrayList<>();
|
||||
mInflater = LayoutInflater.from(context);
|
||||
model = IMLoginManager.get(context).getUserInfo();
|
||||
mOnClickListener = v -> {
|
||||
Object tag = v.getTag();
|
||||
if (tag != null) {
|
||||
LiveChatBean bean = (LiveChatBean) tag;
|
||||
if (mOnItemClickListener != null) {
|
||||
if (bean.getType() != LiveChatBean.SYSTEM) {
|
||||
mOnItemClickListener.onItemClick(bean, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
if (SpUtil.getInstance().isExists("pd_live_room_fount_size")) {
|
||||
try {
|
||||
fountSize = Integer.parseInt(SpUtil.getStringValue("pd_live_room_fount_size"));
|
||||
} catch (Exception ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener<LiveChatBean> onItemClickListener) {
|
||||
mOnItemClickListener = onItemClickListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return mList.get(position).getType();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
if (viewType == LiveChatBean.RED_PACK) {
|
||||
return new RedPackVh(mInflater.inflate(R.layout.item_live_chat_red_pack, parent, false));
|
||||
} else {
|
||||
return new Vh(mInflater.inflate(R.layout.item_live_chat, parent, false));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder vh, int position) {
|
||||
if (vh instanceof Vh) {
|
||||
((Vh) vh).setData(mList.get(position), position);
|
||||
} else if (vh instanceof RedPackVh) {
|
||||
((RedPackVh) vh).setData(mList.get(position));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) {
|
||||
mRecyclerView = recyclerView;
|
||||
mLayoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
|
||||
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
||||
super.onScrolled(recyclerView, dx, dy);
|
||||
if (isBottom && dy >= 0) return;
|
||||
Log.i(TAG, "onScrolled: " + dy);
|
||||
mRecyclerViewScrolledDy = dy;
|
||||
isBottom = false;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
|
||||
super.onScrollStateChanged(recyclerView, newState);
|
||||
if (newState == 0 && isSlideToBottom(recyclerView)) {
|
||||
// Log.i(TAG, "onScrollStateChanged: 到底部了");
|
||||
mRecyclerViewScrolledDy = 0;
|
||||
scrollToBottom();
|
||||
isBottom = true;
|
||||
} else if (newState == 0) {
|
||||
// Log.i(TAG, "onScrollStateChanged: 不是底部");
|
||||
isBottom = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void switchFount(int fount) {
|
||||
fountSize = fount;
|
||||
SpUtil.setStringValue("pd_live_room_fount_size", fountSize + "");
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
class RedPackVh extends RecyclerView.ViewHolder {
|
||||
|
||||
LinearLayout mBg;
|
||||
TextView mTextView;
|
||||
|
||||
public RedPackVh(View itemView) {
|
||||
super(itemView);
|
||||
mBg = (LinearLayout) itemView.findViewById(R.id.bg);
|
||||
mTextView = (TextView) itemView.findViewById(R.id.text_txt);
|
||||
}
|
||||
|
||||
void setData(LiveChatBean bean) {
|
||||
mTextView.setText(bean.getContent());
|
||||
mTextView.setTextSize(fountSize);
|
||||
}
|
||||
}
|
||||
|
||||
class Vh extends RecyclerView.ViewHolder {
|
||||
|
||||
LinearLayout mBg, view_follow, view_action_game, view_zg, xydComplete;
|
||||
TextView mTextView, tv_chat_active_into, tv_chat_avtive_name, tv_zg_anchorname, textTxt2, automatic_chat;
|
||||
RoundedImageView avatar;
|
||||
View v_chat_active_close;
|
||||
RecyclerView rv_chat_active;
|
||||
ImageView img_zg_img, btnAttention, textLeave;
|
||||
LinearLayoutCompat attentionLayout;
|
||||
ClipPathCircleImage clipImage2;
|
||||
|
||||
public Vh(View itemView) {
|
||||
super(itemView);
|
||||
mBg = (LinearLayout) itemView.findViewById(R.id.bg);
|
||||
mTextView = (TextView) itemView.findViewById(R.id.text_txt);
|
||||
textTxt2 = (TextView) itemView.findViewById(R.id.text_txt2);
|
||||
attentionLayout = (LinearLayoutCompat) itemView.findViewById(R.id.attention_layout);
|
||||
clipImage2 = (ClipPathCircleImage) itemView.findViewById(R.id.clip_image2);
|
||||
itemView.setOnClickListener(mOnClickListener);
|
||||
|
||||
view_follow = (LinearLayout) itemView.findViewById(R.id.view_follow);
|
||||
avatar = (RoundedImageView) itemView.findViewById(R.id.avatar);
|
||||
|
||||
view_action_game = (LinearLayout) itemView.findViewById(R.id.view_action_game);
|
||||
tv_chat_active_into = (TextView) itemView.findViewById(R.id.tv_chat_active_into);
|
||||
tv_chat_avtive_name = (TextView) itemView.findViewById(R.id.tv_chat_avtive_name);
|
||||
v_chat_active_close = (View) itemView.findViewById(R.id.v_chat_active_close);
|
||||
rv_chat_active = (RecyclerView) itemView.findViewById(R.id.rv_chat_active);
|
||||
|
||||
view_zg = (LinearLayout) itemView.findViewById(R.id.view_zg);
|
||||
xydComplete = (LinearLayout) itemView.findViewById(R.id.xyd_complete);
|
||||
tv_zg_anchorname = (TextView) itemView.findViewById(R.id.tv_zg_anchorname);
|
||||
automatic_chat = (TextView) itemView.findViewById(R.id.automatic_chat);
|
||||
img_zg_img = (ImageView) itemView.findViewById(R.id.img_zg_img);
|
||||
btnAttention = (ImageView) itemView.findViewById(R.id.btn_attention);
|
||||
textLeave = (ImageView) itemView.findViewById(R.id.text_leave);
|
||||
|
||||
}
|
||||
|
||||
void setData(final LiveChatBean bean, int position) {
|
||||
itemView.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
if (!TextUtils.isEmpty(bean.getId()) && !TextUtils.isEmpty(bean.getUserNiceName())) {
|
||||
Bus.get().post(new LiveAudienceEvent()
|
||||
.setType(LiveAudienceEvent.LiveAudienceType.INPUT_DIALOG)
|
||||
.setOlineUserlistModel(new OlineUserlistModel().setId(bean.getId()).setUserNicename(bean.getUserNiceName())));
|
||||
|
||||
}
|
||||
|
||||
Log.e("eqwewqeweq", bean.toString());
|
||||
return true;
|
||||
}
|
||||
});
|
||||
mTextView.setTextSize(fountSize);
|
||||
automatic_chat.setTextSize(fountSize);
|
||||
itemView.setTag(bean);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
params.setMargins(0, 0, DpUtil.dp2px(80), 0);
|
||||
params.gravity = Gravity.CENTER_VERTICAL;
|
||||
mBg.setLayoutParams(params);
|
||||
if (bean.getType() == 6) {//大作战活动
|
||||
view_action_game.setVisibility(View.VISIBLE);
|
||||
bean.setHeart(position);
|
||||
params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
params.setMargins(0, 0, 80, 12);
|
||||
mBg.setLayoutParams(params);
|
||||
|
||||
mTextView.setVisibility(View.GONE);
|
||||
tv_chat_avtive_name.setText(bean.getUserNiceName());
|
||||
|
||||
String wordStore = bean.getMedalLevelImageUrl();
|
||||
String[] word = wordStore.split(",");
|
||||
List<String> wordsList = Arrays.asList(word);
|
||||
Collections.reverse(wordsList);
|
||||
|
||||
ListAdapter listAdapter = new ListAdapter(mContext, wordsList);
|
||||
GridLayoutManager gridLayoutManager = new GridLayoutManager(mContext, 10);
|
||||
rv_chat_active.setLayoutManager(gridLayoutManager);
|
||||
rv_chat_active.setAdapter(listAdapter);
|
||||
|
||||
//点击打开活动
|
||||
tv_chat_active_into.setOnClickListener(v -> {
|
||||
String url = CommonAppConfig.HOST + "/" + bean.getContent() + "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + LiveRoomViewHolder.mLiveUid + "&isZh=" + (WordUtil.isNewZh() ? "1" : 0);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", url);
|
||||
LiveHDDialogFragment fragment = new LiveHDDialogFragment();
|
||||
fragment.setArguments(bundle);
|
||||
fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
|
||||
});
|
||||
v_chat_active_close.setOnClickListener(v -> removetItem(bean));
|
||||
} else if (bean.getType() == -3 || bean.getType() == -4 || bean.getType() == -5) {//整蛊
|
||||
if (bean.getBubble() != null && !bean.getBubble().equals("")) {
|
||||
//加载.9图聊天气泡
|
||||
new LoadDian9TuUtil().loadDian9Tu(mContext, mBg, bean.getBubble(), 1);
|
||||
} else {
|
||||
// mBg.setBackgroundResource(R.drawable.bg_live_chat_item);
|
||||
new LoadDian9TuUtil().loadDian9TuAssets(mContext, mBg, 1);
|
||||
}
|
||||
SpannableStringBuilder builder = new SpannableStringBuilder();
|
||||
if (bean.getType() == -3) {
|
||||
String str1 = WordUtil.isNewZh() ? "整蠱來了! " : "Pranks are coming";
|
||||
String str2 = WordUtil.isNewZh() ? "向 " : "to";
|
||||
builder.append(str1);
|
||||
int length = builder.length();
|
||||
builder.append(bean.getUserNiceName());
|
||||
builder.setSpan(new ForegroundColorSpan(0xFF73FFFF), length, length + bean.getUserNiceName().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
builder.append(str2);
|
||||
int length2 = builder.length();
|
||||
builder.append(bean.getAnchorName());
|
||||
builder.setSpan(new ForegroundColorSpan(0xFF73FFFF), length2, length2 + bean.getAnchorName().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
builder.append(WordUtil.isNewZh() ? "發出了 " + bean.getContent(): "Sent out " + bean.getContent());
|
||||
mTextView.setText(builder);
|
||||
} else if (bean.getType() == -4) {
|
||||
String str1 = WordUtil.isNewZh() ? "成功拯救了 " : "Succeeded in saving";
|
||||
String str2 = WordUtil.isNewZh() ? "免除了 " : "Exempt from";
|
||||
int length = builder.length();
|
||||
builder.append(bean.getMedal());
|
||||
builder.setSpan(new ForegroundColorSpan(0xFF73FFFF), length, length + bean.getMedal().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
builder.append(str1);
|
||||
int length2 = builder.length();
|
||||
builder.append(bean.getAnchorName());
|
||||
builder.setSpan(new ForegroundColorSpan(0xFF73FFFF), length2, length2 + bean.getAnchorName().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
builder.append(str2 + bean.getUserNiceName() + (WordUtil.isNewZh() ? "發出了 " : "Sent out ") + bean.getContent());
|
||||
mTextView.setText(builder);
|
||||
} else if (bean.getType() == -5) {
|
||||
mBg.setBackground(null);
|
||||
mTextView.setVisibility(View.GONE);
|
||||
view_zg.setVisibility(View.VISIBLE);
|
||||
tv_zg_anchorname.setText(Constants.nowAnchorName);
|
||||
ImgLoader.display(mContext, bean.getPrankIcon(), img_zg_img);
|
||||
}
|
||||
} else if (bean.getType() == -6) {
|
||||
if (bean.getBubble() != null && !bean.getBubble().equals("")) {
|
||||
//加载.9图聊天气泡
|
||||
new LoadDian9TuUtil().loadDian9Tu(mContext, mBg, bean.getBubble(), 1);
|
||||
} else {
|
||||
// mBg.setBackgroundResource(R.drawable.bg_live_chat_item);
|
||||
new LoadDian9TuUtil().loadDian9TuAssets(mContext, mBg, 1);
|
||||
}
|
||||
String str1 = WordUtil.isNewZh() ? "火力四射,魅力無限!感謝" : "Full of firepower!Unlimited charm!";
|
||||
String str2 = WordUtil.isNewZh() ? "為本直播間加成熱度" : "Thank you for adding popularity to this live room";
|
||||
SpannableStringBuilder builder = new SpannableStringBuilder();
|
||||
builder.append(str1);
|
||||
int length = builder.length();
|
||||
builder.append(bean.getUserNiceName());
|
||||
builder.setSpan(new ForegroundColorSpan(0xffffff00), length, length + bean.getUserNiceName().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
builder.append(str2);
|
||||
int length2 = builder.length();
|
||||
builder.append(bean.getHot_card());
|
||||
builder.setSpan(new ForegroundColorSpan(0xffffff00), length2, length2 + bean.getHot_card().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
mTextView.setText(builder);
|
||||
} else if (bean.getType() == -7) {
|
||||
if (bean.getBubble() != null && !bean.getBubble().equals("")) {
|
||||
//加载.9图聊天气泡
|
||||
new LoadDian9TuUtil().loadDian9Tu(mContext, mBg, bean.getBubble(), 1);
|
||||
} else {
|
||||
// mBg.setBackgroundResource(R.drawable.bg_live_chat_item);
|
||||
new LoadDian9TuUtil().loadDian9TuAssets(mContext, mBg, 1);
|
||||
}
|
||||
String str1 = WordUtil.isNewZh() ? "甜蜜不停,愛意不斷!恭喜" : "Sweetness never stops, love never stops!";
|
||||
String str2 = WordUtil.isNewZh() ? "在甜蜜約會中搶購到了" : "who is on a sweet date for grabbing ";
|
||||
String str3 = "!";
|
||||
SpannableStringBuilder builder = new SpannableStringBuilder();
|
||||
builder.append(str1);
|
||||
int length = builder.length();
|
||||
builder.append(bean.getUserNiceName());
|
||||
builder.setSpan(new ForegroundColorSpan(0xffffff00), length, length + bean.getUserNiceName().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
builder.append(str2);
|
||||
int length2 = builder.length();
|
||||
builder.append(bean.getHot_num());
|
||||
builder.append(str3);
|
||||
builder.setSpan(new ForegroundColorSpan(0xffffff00), length2, length2 + bean.getHot_num().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
mTextView.setText(builder);
|
||||
} else if (bean.getType() == -10) {
|
||||
mBg.setBackground(null);
|
||||
} else if (bean.getType() == LiveChatBean.BLIND_BOX) {
|
||||
Log.e("BLIND_BOX", bean.toString());
|
||||
new LoadDian9TuUtil().loadDian9TuAssets(mContext, mBg, 1);
|
||||
new LiveTextRender().blindBox(mContext, mTextView, bean);
|
||||
} else if (bean.getType() == LiveChatBean.SYSTEM) {
|
||||
boolean isContains = false;
|
||||
for (LiveChatBean model : mList) {
|
||||
if (!TextUtils.isEmpty(model.getContent()) && (model.getContent().contains("堅決維護青少年群體精神文明健康") || model.getContent().contains("click to register if you like. pdlive conducts"))) {
|
||||
isContains = true;
|
||||
}
|
||||
}
|
||||
if (isContains) {
|
||||
mTextView.setTextColor(0xffffffff);
|
||||
new LoadDian9TuUtil().loadDian9TuAssets(mContext, mBg, 1);
|
||||
mTextView.setText(bean.getContent());
|
||||
}
|
||||
} else if (bean.getType() == LiveChatBean.SYSTEM2) {
|
||||
mTextView.setTextColor(Color.parseColor("#ffffff"));
|
||||
new LoadDian9TuUtil().loadDian9TuAssets(mContext, mBg, 1);
|
||||
mTextView.setText(bean.getContent());
|
||||
} else if (bean.getType() == TYPE_TO_USER_MSG) {
|
||||
mTextView.setText(Html.fromHtml("<font color='#FBEABF'>@" + bean.getUserNiceName() + "</font> " + bean.getContent()));
|
||||
new LoadDian9TuUtil().loadDian9TuAssets(mContext, mBg, 1);
|
||||
}
|
||||
// else if (bean.getType() == -1) {//自动消息,关注
|
||||
// boolean isContains = false;
|
||||
// for (LiveChatBean model : mList) {
|
||||
// if (bean.getType() == -1) {
|
||||
// isContains = true;
|
||||
// }
|
||||
// }
|
||||
// if (isContains) {
|
||||
// mBg.setBackground(null);
|
||||
// mTextView.setVisibility(View.GONE);
|
||||
// view_follow.setVisibility(View.VISIBLE);
|
||||
// ImgLoader.display(mContext, bean.getId(), avatar);
|
||||
// bean.setHeart(position);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
else if (bean.getType() == -2) {//自动消息,点击发言
|
||||
LinearLayout.LayoutParams params3 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
params3.setMargins(0, 8, DpUtil.dp2px(80), 8);
|
||||
params3.gravity = Gravity.CENTER_VERTICAL;
|
||||
mBg.setLayoutParams(params3);
|
||||
mBg.setBackground(null);
|
||||
mTextView.setVisibility(View.GONE);
|
||||
bean.setHeart(position);
|
||||
ImgLoader.display(mContext, bean.getId(), clipImage2);
|
||||
attentionLayout.setVisibility(View.VISIBLE);
|
||||
if (TextUtils.isEmpty(isFans)) {
|
||||
btnAttention.setVisibility(bean.isAttention() ? View.GONE : View.VISIBLE);
|
||||
} else {
|
||||
btnAttention.setVisibility(TextUtils.equals(isFans, "1") ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
|
||||
// btnAttention.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// LiveRoomViewHolder.follow();
|
||||
// btnAttention.setVisibility(View.GONE);
|
||||
// }
|
||||
// });
|
||||
} else if (bean.getType() == MSG_HOUR_RANK_CHANGE) {
|
||||
mBg.setBackgroundResource(R.drawable.bg_chat_automatic_item);
|
||||
mTextView.setText(bean.getContent());
|
||||
bean.setHeart(position);
|
||||
} else if (bean.getType() == RECOMMEND_CARD_NOTIFY) {
|
||||
//加载.9图聊天气泡
|
||||
new LoadDian9TuUtil().loadDian9Tu(mContext, mBg, bean.getBubble(), 1);
|
||||
new LiveTextRender().recommendCardNotify(mContext, mTextView, bean);
|
||||
} else if (bean.getType() == WISH_LIST_PROGRESS) {
|
||||
//加载.9图聊天气泡
|
||||
new LoadDian9TuUtil().loadDian9TuAssets(mContext, mBg, 1);
|
||||
xydComplete.setVisibility(View.VISIBLE);
|
||||
|
||||
new LiveTextRender().getLiveLevelImage(mContext, bean.getLevel(), false, new ImgLoader.DrawableCallback() {
|
||||
@Override
|
||||
public void onLoadSuccess(Drawable drawable) {
|
||||
textTxt2.setText(userNicenamehighlight(bean.getContent(), bean.getAtUserName(), bean.getUserNiceName(), drawable));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFailed() {
|
||||
|
||||
}
|
||||
});
|
||||
mTextView.setVisibility(View.GONE);
|
||||
textLeave.setVisibility(View.GONE);
|
||||
} else if (bean.getType() == XYD_COMPLETE) {
|
||||
//加载.9图聊天气泡
|
||||
new LoadDian9TuUtil().loadDian9TuAssets(mContext, mBg, 1);
|
||||
xydComplete.setVisibility(View.VISIBLE);
|
||||
|
||||
new LiveTextRender().getLiveLevelImage(mContext, bean.getLevel(), false, new ImgLoader.DrawableCallback() {
|
||||
@Override
|
||||
public void onLoadSuccess(Drawable drawable) {
|
||||
textTxt2.setText(userNicenamehighlight(bean.getContent(), bean.getAtUserName(), bean.getUserNiceName(), drawable));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFailed() {
|
||||
|
||||
}
|
||||
});
|
||||
mTextView.setVisibility(View.GONE);
|
||||
textLeave.setVisibility(View.GONE);
|
||||
} else if (bean.getType() == AI_AUTOMATIC_SPEECH) {
|
||||
//加载.9图聊天气泡
|
||||
new LoadDian9TuUtil().loadDian9Tu(mContext, mBg, bean.getAiAutomaticSpeechModel().getSystemBubble(), 1);
|
||||
new LiveTextRender().aiAutomaticSpeech(mContext, mTextView, bean.getAiAutomaticSpeechModel());
|
||||
} else if (bean.getType() == STAR_CHALLENGE_UPGRADE_NOTIFY) {
|
||||
//加载.9图聊天气泡
|
||||
if (!TextUtils.isEmpty(bean.getMsgModel().getSystemBubble())) {
|
||||
new LoadDian9TuUtil().loadDian9Tu(mContext, mBg, bean.getMsgModel().getSystemBubble(), 1);
|
||||
new LiveTextRender().starChallengeUpgradeNotify(mContext, mTextView, bean.getMsgModel());
|
||||
}
|
||||
} else if (bean.getType() == LUCKY_ANGEL) {
|
||||
if (!TextUtils.isEmpty(bean.getMsgModel().getSystem_bubble())) {
|
||||
bean.setId(bean.getMsgModel().getUserId());
|
||||
itemView.setTag(bean);
|
||||
new LoadDian9TuUtil().loadDian9Tu(mContext, mBg, bean.getMsgModel().getSystem_bubble(), 1);
|
||||
new LiveTextRender().luckyAngel(mContext, mTextView, bean.getMsgModel());
|
||||
}
|
||||
|
||||
} else if (bean.getType() == LUCKY_100_CHECK) {
|
||||
if (!TextUtils.isEmpty(bean.getMsgModel().getSystem_bubble())) {
|
||||
bean.setId(bean.getMsgModel().getUserId());
|
||||
itemView.setTag(bean);
|
||||
new LoadDian9TuUtil().loadDian9Tu(mContext, mBg, bean.getMsgModel().getSystem_bubble(), 1);
|
||||
new LiveTextRender().lucky100(mContext, mTextView, bean.getMsgModel());
|
||||
}
|
||||
} else if (bean.getType() == SYSTEM3_COLOR) {
|
||||
mTextView.setText(Html.fromHtml(bean.getContent()));
|
||||
if (!StringUtil.isEmpty(bean.getBubble())) {
|
||||
new LoadDian9TuUtil().loadDian9Tu(mContext, mBg, bean.getBubble(), 1);
|
||||
}
|
||||
} else {
|
||||
if (bean.getBubble() != null && !bean.getBubble().equals("")) {
|
||||
//加载.9图聊天气泡
|
||||
new LoadDian9TuUtil().loadDian9Tu(mContext, mBg, bean.getBubble(), 1);
|
||||
} else {
|
||||
// mBg.setBackgroundResource(R.drawable.bg_live_chat_item);
|
||||
new LoadDian9TuUtil().loadDian9TuAssets(mContext, mBg, 1);
|
||||
}
|
||||
if (bean.getType() == LiveChatBean.ENTER_ROOM || bean.getType() == LiveChatBean.LIGHT) {
|
||||
mTextView.setTextColor(0xffc8c8c8);
|
||||
} else {
|
||||
mTextView.setTextColor(0xffffffff);
|
||||
}
|
||||
|
||||
new LiveTextRender().render(mContext, mTextView, bean);
|
||||
}
|
||||
Animation animation = AnimationUtils.loadAnimation(itemView.getContext(), R.anim.live_chat_msg_in);
|
||||
itemView.startAnimation(animation);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public synchronized void insertItem(LiveChatBean bean) {
|
||||
if (bean == null) {
|
||||
return;
|
||||
}
|
||||
if (bean.getType() == LiveChatBean.TYPE_TO_USER_MSG
|
||||
&& !CommonAppConfig.getInstance().getUid().equals(bean.getAtUserID())) {
|
||||
return;
|
||||
}
|
||||
// Log.i(TAG, "insertItem: " + bean.getContent()+" size = "+(mList.size()+1));
|
||||
int size = mList.size();
|
||||
//设置最大展示99条消息
|
||||
if (size >= 100 && (isBottom || mRecyclerViewScrolledDy == 0)) {
|
||||
|
||||
mList.subList(0, 50).clear();
|
||||
notifyItemRangeRemoved(0, 50);
|
||||
}
|
||||
mList.add(bean);
|
||||
if (getItemCount() == 1) {
|
||||
notifyDataSetChanged();
|
||||
} else {
|
||||
notifyItemInserted(getItemCount());
|
||||
}
|
||||
// size = mList.size();
|
||||
if (isBottom || mRecyclerViewScrolledDy == 0) {
|
||||
scrollToBottom();
|
||||
} else {
|
||||
Bus.get().post(new LiveAudienceEvent()
|
||||
.setType(LiveAudienceEvent.LiveAudienceType.NEW_MESSAGE_REMINDER));
|
||||
|
||||
if (bean.getType() != LiveChatBean.TYPE_TO_USER_MSG &&
|
||||
bean.getAtUserID() != null
|
||||
&& bean.getAtUserID().contains(String.valueOf(model.getId()))) {
|
||||
Bus.get().post(new LiveAudienceEvent()
|
||||
.setType(LiveAudienceEvent.LiveAudienceType.AT_MESSAGE));
|
||||
mPosition = size;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void scrollToBottom(final RecyclerView recyclerView) {
|
||||
// scroll to last item to get the view of last item
|
||||
final LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
|
||||
final int lastItemPosition = getItemCount() - 1;
|
||||
recyclerView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
layoutManager.scrollToPositionWithOffset(lastItemPosition, Integer.MIN_VALUE);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String TAG = "聊天测试";
|
||||
|
||||
/**
|
||||
* 判断是否滚到底部
|
||||
*
|
||||
* @param recyclerView
|
||||
* @return
|
||||
*/
|
||||
public boolean isSlideToBottom(RecyclerView recyclerView) {
|
||||
if (recyclerView == null) return false;
|
||||
if (recyclerView.computeVerticalScrollExtent() + recyclerView.computeVerticalScrollOffset() >= recyclerView.computeVerticalScrollRange())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void removetItem(LiveChatBean bean) {
|
||||
if (bean == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
mList.remove(bean.getHeart());
|
||||
notifyItemRemoved(bean.getHeart());
|
||||
notifyItemRangeChanged(bean.getHeart(), getItemCount());
|
||||
|
||||
}
|
||||
|
||||
public void scrollToBottom() {
|
||||
if (mList.size() > 0) {
|
||||
mRecyclerView.smoothScrollToPosition(getItemCount());
|
||||
}
|
||||
mRecyclerViewScrolledDy = 0;
|
||||
}
|
||||
|
||||
public void scrollToAt() {
|
||||
if (mList.size() > 0) {
|
||||
mRecyclerView.smoothScrollToPosition(mPosition);
|
||||
}
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
if (mList != null) {
|
||||
mList.clear();
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public class ListAdapter extends
|
||||
RecyclerView.Adapter<ListAdapter.ViewHolder> {
|
||||
private LayoutInflater mInflater;
|
||||
private List<String> mDatas;
|
||||
|
||||
/**
|
||||
* 是否可选
|
||||
*/
|
||||
public ListAdapter(Context context, List<String> datats) {
|
||||
mInflater = LayoutInflater.from(context);
|
||||
mDatas = datats;
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
ImageView ico;
|
||||
|
||||
public ViewHolder(View arg0) {
|
||||
super(arg0);
|
||||
ico = (ImageView) arg0.findViewById(R.id.ico);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mDatas.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建ViewHolder
|
||||
*/
|
||||
@Override
|
||||
public ListAdapter.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
|
||||
View view = mInflater.inflate(R.layout.item_chat_active,
|
||||
viewGroup, false);
|
||||
ListAdapter.ViewHolder viewHolder = new ListAdapter.ViewHolder(view);
|
||||
|
||||
return viewHolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置值
|
||||
*/
|
||||
@Override
|
||||
public void onBindViewHolder(final ListAdapter.ViewHolder viewHolder, @SuppressLint("RecyclerView") final int position) {
|
||||
int img = 0;
|
||||
if ("1".equals(mDatas.get(position))) {
|
||||
img = R.mipmap.monster_1;
|
||||
} else if ("2".equals(mDatas.get(position))) {
|
||||
img = R.mipmap.monster_2;
|
||||
} else if ("3".equals(mDatas.get(position))) {
|
||||
img = R.mipmap.monster_3;
|
||||
} else if ("4".equals(mDatas.get(position))) {
|
||||
img = R.mipmap.monster_4;
|
||||
} else if ("5".equals(mDatas.get(position))) {
|
||||
img = R.mipmap.monster_5;
|
||||
} else if ("6".equals(mDatas.get(position))) {
|
||||
img = R.mipmap.monster_6;
|
||||
} else if ("7".equals(mDatas.get(position))) {
|
||||
img = R.mipmap.monster_7;
|
||||
} else if ("8".equals(mDatas.get(position))) {
|
||||
img = R.mipmap.monster_8;
|
||||
}
|
||||
if (img != 0) {
|
||||
viewHolder.ico.setBackground(mContext.getResources().getDrawable(img));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Spanned userNicenamehighlight(String context, String keyword, String keyword2, Drawable levelDrawable) {
|
||||
// String contextHtml = "";
|
||||
// String keywordHtml2;
|
||||
// String keywordHtml;
|
||||
// if (TextUtils.isEmpty(keyword) || TextUtils.isEmpty(keyword2)) {
|
||||
// keywordHtml2 = TextUtils.isEmpty(keyword) ? "1" : keyword;
|
||||
// keywordHtml = TextUtils.isEmpty(keyword) ? "1" : keyword;
|
||||
// } else {
|
||||
// keywordHtml2 = "</font><font color='#4BFFD4'size='42px'>" + keyword + "</font><font color='#ffffff'size='42px'>";
|
||||
// keywordHtml = "</font><font color='#4BFFD4'size='42px'>" + keyword2 + "</font><font color='#ffffff'size='42px'>";
|
||||
// }
|
||||
//
|
||||
// contextHtml = "<font color='#ffffff'size='42px'>" + context + "</font>";
|
||||
// contextHtml = contextHtml.replace(keyword, keywordHtml2).replace(keyword2, keywordHtml);
|
||||
|
||||
SpannableStringBuilder builder = new SpannableStringBuilder();
|
||||
int index = 0;
|
||||
|
||||
if (levelDrawable != null) {
|
||||
builder.append(" ");
|
||||
levelDrawable.setBounds(0, 0, DpUtil.dp2px(18), DpUtil.dp2px(18));
|
||||
builder.setSpan(new VerticalImageSpan(levelDrawable), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
index = builder.length();
|
||||
}
|
||||
builder.append(context);
|
||||
builder.setSpan(new ForegroundColorSpan(Color.parseColor("#4BFFD4")), index + context.indexOf(keyword), index + context.indexOf(keyword) + keyword.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
builder.setSpan(new ForegroundColorSpan(Color.parseColor("#4BFFD4")), index + context.indexOf(keyword2), index + context.indexOf(keyword2) + keyword2.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.PointF;
|
||||
import android.util.DisplayMetrics;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearSmoothScroller;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
public class LiveChatRecyclerViewLayoutManager extends LinearLayoutManager {
|
||||
private static final float MILLISECONDS_PER_INCH = 150f;
|
||||
public LiveChatRecyclerViewLayoutManager(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) {
|
||||
// super.smoothScrollToPosition(recyclerView, state, position);
|
||||
LinearSmoothScroller linearSmoothScroller = new LinearSmoothScroller(recyclerView.getContext())
|
||||
{
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public PointF computeScrollVectorForPosition(int targetPosition) {
|
||||
return LiveChatRecyclerViewLayoutManager.this.computeScrollVectorForPosition(targetPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float calculateSpeedPerPixel(DisplayMetrics displayMetrics) {
|
||||
// System.out.println("----->自定义滑动 = "+MILLISECONDS_PER_INCH+" > "+( MILLISECONDS_PER_INCH / displayMetrics.densityDpi));
|
||||
return MILLISECONDS_PER_INCH / displayMetrics.densityDpi;
|
||||
}
|
||||
|
||||
};
|
||||
linearSmoothScroller.setTargetPosition(position);
|
||||
startSmoothScroll(linearSmoothScroller);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.bean.LiveDataInfoModel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class LiveDataInfoRecyclerAdapter extends RecyclerView.Adapter<LiveDataInfoRecyclerAdapter.LiveDataHolder> {
|
||||
private Context mContext;
|
||||
private List<LiveDataInfoModel> list=new ArrayList<>();
|
||||
|
||||
public LiveDataInfoRecyclerAdapter(Context mContext) {
|
||||
this.mContext = mContext;
|
||||
}
|
||||
|
||||
public void setList(List<LiveDataInfoModel> list) {
|
||||
this.list = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public LiveDataHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new LiveDataHolder(LayoutInflater.from(mContext).inflate(R.layout.item_live_data, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull LiveDataHolder holder, int position) {
|
||||
holder.setData(list.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public static class LiveDataHolder extends RecyclerView.ViewHolder {
|
||||
private TextView title, data;
|
||||
|
||||
public LiveDataHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
title = itemView.findViewById(R.id.item_title);
|
||||
data = itemView.findViewById(R.id.item_data);
|
||||
}
|
||||
|
||||
public void setData(LiveDataInfoModel model) {
|
||||
if (model.getColor() != null) {
|
||||
data.setText(Html.fromHtml("<font color='" + model.getColor() + "'>" + model.getData() + "</font>"));
|
||||
} else {
|
||||
data.setText(model.getData());
|
||||
}
|
||||
title.setText(model.getTitle());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.common.bean.FansGroupGiftPackInfo;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.live.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class LiveFansGroupBuyAdapter extends RecyclerView.Adapter<LiveFansGroupBuyAdapter.ViewHolder> {
|
||||
Context mContext;
|
||||
List<FansGroupGiftPackInfo.Gift> list = new ArrayList<>();
|
||||
|
||||
public LiveFansGroupBuyAdapter(Context mContext) {
|
||||
this.mContext = mContext;
|
||||
}
|
||||
|
||||
public void setList(List<FansGroupGiftPackInfo.Gift> list) {
|
||||
this.list.clear();
|
||||
this.list = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new ViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_fans_group_buy_list, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
holder.setData(list.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
private ImageView giftIcon;
|
||||
private TextView day;
|
||||
private TextView title;
|
||||
private TextView introduce;
|
||||
private ImageView diamondIcon;
|
||||
|
||||
public ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
giftIcon = itemView.findViewById(R.id.giftIcon);
|
||||
day = itemView.findViewById(R.id.day);
|
||||
title = itemView.findViewById(R.id.title);
|
||||
introduce = itemView.findViewById(R.id.introduce);
|
||||
diamondIcon = itemView.findViewById(R.id.diamondIcon);
|
||||
}
|
||||
|
||||
public void setData(FansGroupGiftPackInfo.Gift gift) {
|
||||
title.setText(gift.getGiftName());
|
||||
introduce.setText(gift.getNeedCoin());
|
||||
if (gift.getRestrict() > 0) {
|
||||
day.setText(gift.getRestrict() + mContext.getString(R.string.bonus_day));
|
||||
day.setVisibility(View.VISIBLE);
|
||||
}else{
|
||||
day.setVisibility(View.GONE);
|
||||
}
|
||||
try {
|
||||
int i = Integer.parseInt(gift.getNeedCoin());
|
||||
diamondIcon.setVisibility(View.VISIBLE);
|
||||
} catch (Exception e) {
|
||||
diamondIcon.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
ImgLoader.display(mContext, gift.getGiftIcon(), giftIcon);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.common.bean.FansGroupGiftPack;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
import com.yunbao.live.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class LiveFansGroupSendGiftAdapter extends RecyclerView.Adapter<LiveFansGroupSendGiftAdapter.ViewHolder> {
|
||||
Context mContext;
|
||||
List<FansGroupGiftPack> list = new ArrayList<>();
|
||||
private OnItemClickListener<FansGroupGiftPack> onItemClickListener;
|
||||
|
||||
|
||||
public LiveFansGroupSendGiftAdapter(Context mContext) {
|
||||
this.mContext = mContext;
|
||||
}
|
||||
|
||||
public void setList(List<FansGroupGiftPack> list) {
|
||||
this.list.clear();
|
||||
this.list = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener<FansGroupGiftPack> onItemClickListener) {
|
||||
this.onItemClickListener = onItemClickListener;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public LiveFansGroupSendGiftAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new LiveFansGroupSendGiftAdapter.ViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_fans_group_package_list, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull LiveFansGroupSendGiftAdapter.ViewHolder holder, int position) {
|
||||
holder.setData(list.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
private ImageView giftIcon;
|
||||
private TextView day;
|
||||
private TextView title;
|
||||
private TextView send;
|
||||
|
||||
public ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
giftIcon = itemView.findViewById(R.id.giftIcon);
|
||||
day = itemView.findViewById(R.id.day);
|
||||
title = itemView.findViewById(R.id.title);
|
||||
send = itemView.findViewById(R.id.send);
|
||||
}
|
||||
|
||||
public void setData(FansGroupGiftPack pack) {
|
||||
if (pack.getQuantity() > 0) {
|
||||
title.setText(pack.getGiftName()+" *"+pack.getQuantity());
|
||||
} else {
|
||||
title.setText(pack.getGiftName());
|
||||
}
|
||||
ImgLoader.display(mContext, pack.getIcon(), giftIcon);
|
||||
ViewClicksAntiShake.clicksAntiShake(send, () -> {
|
||||
if (onItemClickListener != null) {
|
||||
onItemClickListener.onItemClick(pack, 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.activity.LiveRyAnchorActivity;
|
||||
import com.yunbao.live.bean.LiveFunctionBean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.yunbao.live.activity.LiveAnchorActivity.leave;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/10/9.
|
||||
*/
|
||||
|
||||
public class LiveFunctionAdapter extends RecyclerView.Adapter<LiveFunctionAdapter.Vh> {
|
||||
|
||||
private List<LiveFunctionBean> mList;
|
||||
private LayoutInflater mInflater;
|
||||
private View.OnClickListener mOnClickListener;
|
||||
private OnItemClickListener<Integer> mOnItemClickListener;
|
||||
|
||||
public LiveFunctionAdapter(Context context, boolean hasGame, boolean openFlash) {
|
||||
mList = new ArrayList<>();
|
||||
mList.add(new LiveFunctionBean(Constants.LIVE_FUNC_BEAUTY, R.mipmap.icon_live_func_beauty, R.string.live_beauty));
|
||||
mList.add(new LiveFunctionBean(Constants.LIVE_FUNC_CAMERA, R.mipmap.icon_live_func_camera, R.string.live_camera));
|
||||
mList.add(new LiveFunctionBean(Constants.LIVE_FUNC_LINK_MIC, R.mipmap.icon_danrenpk, R.string.live_link_pk));
|
||||
mList.add(new LiveFunctionBean(Constants.LIVE_FUNC_DR, R.mipmap.icon_duorenpk, R.string.live_dr));
|
||||
if (!(context instanceof LiveRyAnchorActivity)) {
|
||||
mList.add(new LiveFunctionBean(Constants.LIVE_FUNC_MIC, R.mipmap.icon_microphone, R.string.live_mic));
|
||||
}
|
||||
|
||||
|
||||
if (leave == 0) {
|
||||
mList.add(new LiveFunctionBean(Constants.LIVE_FUNC_ZSLK, R.mipmap.icon_leave, R.string.live_zslk));
|
||||
} else {
|
||||
mList.add(new LiveFunctionBean(Constants.LIVE_FUNC_ZSLK, R.mipmap.icon_leave_p, R.string.live_zslk1));
|
||||
}
|
||||
|
||||
mList.add(new LiveFunctionBean(Constants.LIVE_FUNC_WISHLIST, R.mipmap.icon_xinyuandan, R.string.live_wishlist));
|
||||
mList.add(new LiveFunctionBean(Constants.LIVE_FUNC_ZG, R.mipmap.icon_zhenggu, R.string.live_zg));
|
||||
mList.add(new LiveFunctionBean(Constants.LIVE_FUNC_WKS, R.mipmap.icon_weekstar, R.string.live_wks));
|
||||
|
||||
|
||||
mInflater = LayoutInflater.from(context);
|
||||
mOnClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Object tag = v.getTag();
|
||||
if (tag != null) {
|
||||
int functionID = (int) tag;
|
||||
if (mOnItemClickListener != null) {
|
||||
mOnItemClickListener.onItemClick(functionID, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener<Integer> onItemClickListener) {
|
||||
mOnItemClickListener = onItemClickListener;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Vh onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new Vh(mInflater.inflate(R.layout.item_live_function, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull Vh vh, int position) {
|
||||
vh.setData(mList.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mList.size();
|
||||
}
|
||||
|
||||
class Vh extends RecyclerView.ViewHolder {
|
||||
|
||||
ImageView mIcon;
|
||||
TextView mName;
|
||||
|
||||
|
||||
public Vh(View itemView) {
|
||||
super(itemView);
|
||||
mIcon = (ImageView) itemView.findViewById(R.id.icon);
|
||||
mName = (TextView) itemView.findViewById(R.id.name);
|
||||
itemView.setOnClickListener(mOnClickListener);
|
||||
}
|
||||
|
||||
void setData(LiveFunctionBean bean) {
|
||||
itemView.setTag(bean.getID());
|
||||
mIcon.setImageResource(bean.getIcon());
|
||||
mName.setText(bean.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
341
live/src/main/java/com/yunbao/live/adapter/LiveGiftAdapter.java
Normal file
341
live/src/main/java/com/yunbao/live/adapter/LiveGiftAdapter.java
Normal file
@@ -0,0 +1,341 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.text.TextUtils;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.AccelerateDecelerateInterpolator;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
import android.view.animation.ScaleAnimation;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.bean.LiveGiftBean;
|
||||
import com.yunbao.common.bean.LiveGiftBean2;
|
||||
import com.yunbao.common.custom.MyRadioButton;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.GiftCacheUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.custom.GiftMarkView;
|
||||
import com.yunbao.live.dialog.SendRendPacketPopup;
|
||||
import com.yunbao.common.event.LiveGiftDialogEvent;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/10/12.
|
||||
*/
|
||||
|
||||
public class LiveGiftAdapter extends RecyclerView.Adapter<LiveGiftAdapter.Vh> {
|
||||
|
||||
private Context mContext;
|
||||
private List<LiveGiftBean> mList;
|
||||
private LayoutInflater mInflater;
|
||||
private String mCoinName;
|
||||
private View.OnClickListener mOnClickListener;
|
||||
private ActionListener mActionListener;
|
||||
private int mCheckedPosition = -1;
|
||||
private ScaleAnimation mAnimation;
|
||||
private View mAnimView;
|
||||
private String mName1, mName2;
|
||||
boolean isTouch = true;
|
||||
private String mLiveUid;
|
||||
|
||||
public void setTouch(boolean touch) {
|
||||
isTouch = touch;
|
||||
}
|
||||
|
||||
public LiveGiftAdapter(Context context, LayoutInflater inflater, List<LiveGiftBean> list, String coinName, String liveUid) {
|
||||
mContext = context;
|
||||
mInflater = inflater;
|
||||
mList = list;
|
||||
mLiveUid = liveUid;
|
||||
mCoinName = coinName;
|
||||
mName1 = CommonAppConfig.getInstance().getCoinName();
|
||||
mName2 = CommonAppConfig.getInstance().getGoldCoinName();
|
||||
mOnClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (!isTouch) {
|
||||
return;
|
||||
}
|
||||
Object tag = v.getTag();
|
||||
if (tag != null) {
|
||||
int position = (int) tag;
|
||||
LiveGiftBean bean = mList.get(position);
|
||||
if (!bean.isChecked() && bean.getType() != 9999999) {
|
||||
if (!cancelChecked()) {
|
||||
if (mActionListener != null) {
|
||||
mActionListener.onCancel();
|
||||
}
|
||||
}
|
||||
|
||||
bean.setChecked(true);
|
||||
notifyItemChanged(position, Constants.PAYLOAD);
|
||||
View view = bean.getView();
|
||||
if (view != null) {
|
||||
view.startAnimation(mAnimation);
|
||||
mAnimView = view;
|
||||
}
|
||||
mCheckedPosition = position;
|
||||
if (mActionListener != null) {
|
||||
mActionListener.onItemChecked(bean);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
mAnimation = new ScaleAnimation(0.9f, 1.1f, 0.9f, 1.1f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
|
||||
mAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
|
||||
mAnimation.setDuration(400);
|
||||
mAnimation.setRepeatMode(Animation.REVERSE);
|
||||
mAnimation.setRepeatCount(-1);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Vh onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new Vh(mInflater.inflate(R.layout.item_live_gift, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull Vh vh, int position) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull Vh vh, int position, @NonNull List<Object> payloads) {
|
||||
Object payload = payloads.size() > 0 ? payloads.get(0) : null;
|
||||
vh.setData(mList.get(position), position, payload);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mList.size();
|
||||
}
|
||||
|
||||
public List<LiveGiftBean> getList() {
|
||||
return mList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消选中
|
||||
*/
|
||||
public boolean cancelChecked() {
|
||||
if (mCheckedPosition >= 0 && mCheckedPosition < mList.size()) {
|
||||
LiveGiftBean bean = mList.get(mCheckedPosition);
|
||||
if (bean.isChecked()) {
|
||||
View view = bean.getView();
|
||||
if (mAnimView == view) {
|
||||
mAnimView.clearAnimation();
|
||||
} else {
|
||||
if (view != null) {
|
||||
view.clearAnimation();
|
||||
}
|
||||
}
|
||||
mAnimView = null;
|
||||
bean.setChecked(false);
|
||||
notifyItemChanged(mCheckedPosition, Constants.PAYLOAD);
|
||||
}
|
||||
mCheckedPosition = -1;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setActionListener(ActionListener actionListener) {
|
||||
mActionListener = actionListener;
|
||||
}
|
||||
|
||||
public void release() {
|
||||
if (mAnimView != null) {
|
||||
mAnimView.clearAnimation();
|
||||
}
|
||||
if (mList != null) {
|
||||
mList.clear();
|
||||
}
|
||||
mOnClickListener = null;
|
||||
mActionListener = null;
|
||||
}
|
||||
|
||||
|
||||
class Vh extends RecyclerView.ViewHolder {
|
||||
|
||||
GiftMarkView mMark;
|
||||
ImageView mIcon;
|
||||
TextView mName;
|
||||
TextView mPrice;
|
||||
MyRadioButton mRadioButton;
|
||||
TextView tvRedpoint;
|
||||
ImageView mPayico;
|
||||
TextView expire;
|
||||
ImageView mLoading;
|
||||
LinearLayout mLoadingLayout;
|
||||
|
||||
public Vh(View itemView) {
|
||||
super(itemView);
|
||||
mMark = (GiftMarkView) itemView.findViewById(R.id.mark);
|
||||
mIcon = (ImageView) itemView.findViewById(R.id.icon);
|
||||
mName = (TextView) itemView.findViewById(R.id.name);
|
||||
mPrice = (TextView) itemView.findViewById(R.id.price);
|
||||
mRadioButton = (MyRadioButton) itemView.findViewById(R.id.radioButton);
|
||||
tvRedpoint = (TextView) itemView.findViewById(R.id.tvRedpoint);
|
||||
mPayico = (ImageView) itemView.findViewById(R.id.pay_ico);
|
||||
expire = (TextView) itemView.findViewById(R.id.expire);
|
||||
|
||||
mLoading = itemView.findViewById(R.id.gift_loading);
|
||||
mLoadingLayout = itemView.findViewById(R.id.gift_loading_layout);
|
||||
mLoadingLayout.setOnClickListener(v -> {
|
||||
mLoading.setImageResource(R.mipmap.icon_loading_gift);
|
||||
Animation animation = AnimationUtils.loadAnimation(mContext, R.anim.anim_loading_gift);
|
||||
animation.setRepeatMode(Animation.RESTART);
|
||||
animation.setRepeatCount(Animation.INFINITE);
|
||||
animation.setInterpolator(new LinearInterpolator());
|
||||
mLoading.startAnimation(animation);
|
||||
LiveGiftBean bean = mList.get((Integer) v.getTag());
|
||||
GiftCacheUtil.getInstance().pause();
|
||||
GiftCacheUtil.getInstance().downloadGiftForId(mContext, bean, new CommonCallback<File>() {
|
||||
@Override
|
||||
public void callback(File bean) {
|
||||
if (bean == null) {
|
||||
ToastUtil.show(mContext.getString(R.string.load_failure_2));
|
||||
mLoading.setImageResource(R.mipmap.icon_download_gift);
|
||||
animation.setRepeatCount(0);
|
||||
animation.setDuration(0);
|
||||
animation.cancel();
|
||||
mLoading.setAnimation(animation);
|
||||
} else {
|
||||
mLoadingLayout.setVisibility(View.GONE);
|
||||
}
|
||||
GiftCacheUtil.getInstance().restart();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void setData(LiveGiftBean bean, int position, Object payload) {
|
||||
if (IMLoginManager.get(mContext).isNewUserGif()) {
|
||||
if (position == 0 && bean.getTag() != null) {
|
||||
mRadioButton.setBackgroundResource(R.mipmap.live_gift_light_bg);
|
||||
}
|
||||
}
|
||||
if (payload == null) {
|
||||
ImgLoader.display(mContext, bean.getIcon(), mIcon);
|
||||
mName.setText(bean.getName());
|
||||
if (bean.getType() == 9999999) {
|
||||
mPayico.setVisibility(View.GONE);
|
||||
mPrice.setText(mContext.getString(R.string.build_up_popularity));
|
||||
mPrice.setTextColor(Color.parseColor("#db8c4a"));
|
||||
mPrice.setTextSize(TypedValue.COMPLEX_UNIT_SP,8);
|
||||
ViewClicksAntiShake.clicksAntiShake(mRadioButton, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
Bus.get().post(new LiveGiftDialogEvent());
|
||||
new XPopup.Builder(mContext)
|
||||
.asCustom(new SendRendPacketPopup(mContext, mLiveUid))
|
||||
.show();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
mPrice.setTextSize(TypedValue.COMPLEX_UNIT_SP,11);
|
||||
mRadioButton.setOnClickListener(mOnClickListener);
|
||||
mPrice.setTextColor(Color.parseColor("#c8c8c8"));
|
||||
mPayico.setVisibility(View.VISIBLE);
|
||||
bean.setView(mIcon);
|
||||
if (bean.getSendType() != null && bean.getSendType().equals("1")) {
|
||||
// mCoinName = mName2;
|
||||
mPayico.setImageResource(R.mipmap.gold_coin);
|
||||
} else {
|
||||
// mCoinName = mName1;
|
||||
mPayico.setImageResource(R.mipmap.diamond);
|
||||
}
|
||||
mPrice.setText(bean.getPrice());
|
||||
}
|
||||
|
||||
if (IMLoginManager.get(mContext).isNewUserGif() && position == 0 && bean.getTag() != null) {
|
||||
mPayico.setVisibility(View.GONE);
|
||||
mPrice.setText(R.string.free);
|
||||
mPrice.setTextColor(Color.parseColor("#FFF269"));
|
||||
}
|
||||
expire.setVisibility(View.GONE);
|
||||
if (bean.getEnd_time() != null) {
|
||||
expire.setVisibility(View.VISIBLE);
|
||||
expire.setText(bean.getEnd_time());
|
||||
}
|
||||
//包裹数量
|
||||
if (!TextUtils.isEmpty(bean.getGiftNum())) {
|
||||
try {
|
||||
tvRedpoint.setVisibility(View.VISIBLE);
|
||||
tvRedpoint.setText(bean.getGiftNum());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int mark = bean.getMark();
|
||||
|
||||
if (bean.getSwf() != null && !bean.getSwf().contains("svga")) {
|
||||
if (mark == LiveGiftBean2.MARK_HOT) {
|
||||
mMark.setIconRes(R.mipmap.icon_live_gift_hot, 0);
|
||||
} else if (mark == LiveGiftBean2.MARK_GUARD) {
|
||||
mMark.setIconRes(R.mipmap.icon_live_gift_guard, 0);
|
||||
} else if (mark == LiveGiftBean2.MARK_LUCK) {
|
||||
mMark.setIconRes(R.mipmap.icon_live_gift_luck, 0);
|
||||
} else if (bean.getIsweek() != null && bean.getIsweek().equals("1")) {
|
||||
mMark.setIconRes(0, R.mipmap.icon_live_gift_weekstar);
|
||||
} else {
|
||||
mMark.setIconRes(0, 0);
|
||||
}
|
||||
} else {
|
||||
if (mark == LiveGiftBean2.MARK_HOT) {
|
||||
mMark.setIconRes(R.mipmap.icon_live_gift_hot, R.mipmap.icon_live_gift_hao);
|
||||
} else if (mark == LiveGiftBean2.MARK_GUARD) {
|
||||
mMark.setIconRes(R.mipmap.icon_live_gift_guard, R.mipmap.icon_live_gift_hao);
|
||||
} else if (mark == LiveGiftBean2.MARK_LUCK) {
|
||||
mMark.setIconRes(R.mipmap.icon_live_gift_luck, R.mipmap.icon_live_gift_hao);
|
||||
} else if (bean.getIsweek() != null && bean.getIsweek().equals("1")) {
|
||||
mMark.setIconRes(0, R.mipmap.icon_live_gift_weekstar);
|
||||
} else {
|
||||
mMark.setIconRes(0, R.mipmap.icon_live_gift_hao);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
mRadioButton.setTag(position);
|
||||
mRadioButton.doChecked(bean.isChecked());
|
||||
if (bean.getSwf() != null && bean.getSwf().isEmpty()) {
|
||||
mLoadingLayout.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
mLoadingLayout.setVisibility(GiftCacheUtil.checkGiftIsDownload(bean.getId()) ? View.GONE : View.VISIBLE);
|
||||
mLoadingLayout.setTag(position);
|
||||
}
|
||||
}
|
||||
|
||||
public interface ActionListener {
|
||||
void onCancel();
|
||||
|
||||
void onItemChecked(LiveGiftBean bean);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.live.R;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/10/13.
|
||||
*/
|
||||
|
||||
public class LiveGiftCountAdapter extends RecyclerView.Adapter<LiveGiftCountAdapter.Vh> {
|
||||
|
||||
private String[] mArray;
|
||||
private LayoutInflater mInflater;
|
||||
private View.OnClickListener mOnClickListener;
|
||||
private OnItemClickListener<String> mOnItemClickListener;
|
||||
|
||||
public LiveGiftCountAdapter(Context context) {
|
||||
mArray = new String[]{"1", "10", "66", "88", "100", "520", "1314"};
|
||||
mInflater = LayoutInflater.from(context);
|
||||
mOnClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Object tag = v.getTag();
|
||||
if (tag != null && mOnItemClickListener != null) {
|
||||
mOnItemClickListener.onItemClick((String) tag, 0);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener<String> onItemClickListener) {
|
||||
mOnItemClickListener = onItemClickListener;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Vh onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new Vh(mInflater.inflate(R.layout.item_live_gift_count, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull Vh vh, int position) {
|
||||
vh.setData(mArray[position]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mArray.length;
|
||||
}
|
||||
|
||||
class Vh extends RecyclerView.ViewHolder {
|
||||
|
||||
public Vh(View itemView) {
|
||||
super(itemView);
|
||||
itemView.setOnClickListener(mOnClickListener);
|
||||
}
|
||||
|
||||
void setData(String text) {
|
||||
itemView.setTag(text);
|
||||
((TextView) itemView).setText(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentPagerAdapter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LiveGiftFragmentPagerAdapter extends FragmentPagerAdapter {
|
||||
|
||||
private List<Fragment> fragmentList;
|
||||
|
||||
|
||||
public LiveGiftFragmentPagerAdapter(FragmentManager fm, Context mContext, List<Fragment> fragmentList) {
|
||||
super(fm);
|
||||
|
||||
this.fragmentList = fragmentList;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment getItem(int i) {
|
||||
return fragmentList.get(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return fragmentList.size();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.viewpager.widget.PagerAdapter;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.bean.LiveGiftBean;
|
||||
import com.yunbao.live.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/7/11.
|
||||
*/
|
||||
|
||||
public class LiveGiftPagerAdapter extends PagerAdapter {
|
||||
|
||||
private Context mContext;
|
||||
private List<RecyclerView> mViewList;
|
||||
private static final int GIFT_COUNT = 8;//每页8个礼物
|
||||
private int mPage = -1;
|
||||
private ActionListener mActionListener;
|
||||
private String mLiveUid;
|
||||
public LiveGiftPagerAdapter(Context context, List<LiveGiftBean> giftList,String liveUid) {
|
||||
mContext = context;
|
||||
mLiveUid = liveUid;
|
||||
mViewList = new ArrayList<>();
|
||||
int fromIndex = 0;
|
||||
int size = giftList.size();
|
||||
int pageCount = size / GIFT_COUNT;
|
||||
if (size % GIFT_COUNT > 0) {
|
||||
pageCount++;
|
||||
}
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
String coinName = CommonAppConfig.getInstance().getCoinName();
|
||||
LiveGiftAdapter.ActionListener actionListener = new LiveGiftAdapter.ActionListener() {
|
||||
@Override
|
||||
public void onCancel() {
|
||||
if (mPage >= 0 && mPage < mViewList.size()) {
|
||||
LiveGiftAdapter adapter = (LiveGiftAdapter) mViewList.get(mPage).getAdapter();
|
||||
if (adapter != null) {
|
||||
adapter.cancelChecked();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemChecked(LiveGiftBean bean) {
|
||||
mPage = bean.getPage();
|
||||
if (mActionListener != null) {
|
||||
mActionListener.onItemChecked(bean);
|
||||
}
|
||||
}
|
||||
};
|
||||
for (int i = 0; i < pageCount; i++) {
|
||||
RecyclerView recyclerView = (RecyclerView) inflater.inflate(R.layout.view_gift_page, null, false);
|
||||
recyclerView.setHasFixedSize(true);
|
||||
recyclerView.setLayoutManager(new GridLayoutManager(context, 4, GridLayoutManager.VERTICAL, false));
|
||||
int endIndex = fromIndex + GIFT_COUNT;
|
||||
if (endIndex > size) {
|
||||
endIndex = size;
|
||||
}
|
||||
List<LiveGiftBean> list = new ArrayList<>();
|
||||
for (int j = fromIndex; j < endIndex; j++) {
|
||||
LiveGiftBean bean = giftList.get(j);
|
||||
bean.setPage(i);
|
||||
list.add(bean);
|
||||
}
|
||||
LiveGiftAdapter adapter = new LiveGiftAdapter(mContext, inflater, list, coinName,mLiveUid);
|
||||
adapter.setActionListener(actionListener);
|
||||
recyclerView.setAdapter(adapter);
|
||||
mViewList.add(recyclerView);
|
||||
fromIndex = endIndex;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新指定礼物id的item 界面
|
||||
*
|
||||
* @param giftId
|
||||
*/
|
||||
public void refreshId(int giftId) {
|
||||
for (RecyclerView recyclerView : mViewList) {
|
||||
RecyclerView.Adapter<?> adapter = recyclerView.getAdapter();
|
||||
if (adapter instanceof LiveGiftAdapter) {
|
||||
for (int i = 0; i < ((LiveGiftAdapter) adapter).getList().size(); i++) {
|
||||
if (((LiveGiftAdapter) adapter).getList().get(i).getId() == giftId) {
|
||||
adapter.notifyItemChanged(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void notifyRefresh() {
|
||||
if (mViewList != null) {
|
||||
for (RecyclerView recyclerView : mViewList) {
|
||||
LiveGiftAdapter adapter = (LiveGiftAdapter) recyclerView.getAdapter();
|
||||
if (adapter != null) {
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void notifyRefresh(int position) {
|
||||
if (mViewList != null) {
|
||||
for (RecyclerView recyclerView : mViewList) {
|
||||
LiveGiftAdapter adapter = (LiveGiftAdapter) recyclerView.getAdapter();
|
||||
if (adapter != null) {
|
||||
adapter.notifyItemChanged(position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mViewList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isViewFromObject(View view, Object object) {
|
||||
return view == object;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object instantiateItem(ViewGroup container, int position) {
|
||||
View view = mViewList.get(position);
|
||||
container.addView(view);
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void destroyItem(ViewGroup container, int position, Object object) {
|
||||
container.removeView(mViewList.get(position));
|
||||
}
|
||||
|
||||
public void release() {
|
||||
if (mViewList != null) {
|
||||
for (RecyclerView recyclerView : mViewList) {
|
||||
LiveGiftAdapter adapter = (LiveGiftAdapter) recyclerView.getAdapter();
|
||||
if (adapter != null) {
|
||||
adapter.release();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 禁止用户点击更换礼物
|
||||
*/
|
||||
public void disTouch(int giftId) {
|
||||
for (RecyclerView recyclerView : mViewList) {
|
||||
RecyclerView.Adapter<?> adapter = recyclerView.getAdapter();
|
||||
if (adapter instanceof LiveGiftAdapter) {
|
||||
for (int i = 0; i < ((LiveGiftAdapter) adapter).getList().size(); i++) {
|
||||
if (((LiveGiftAdapter) adapter).getList().get(i).getId() == giftId) {
|
||||
((LiveGiftAdapter) adapter).setTouch(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface ActionListener {
|
||||
void onItemChecked(LiveGiftBean bean);
|
||||
}
|
||||
|
||||
|
||||
public void setActionListener(ActionListener actionListener) {
|
||||
mActionListener = actionListener;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.LinearGradient;
|
||||
import android.graphics.Shader;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.bean.GuardBuyBean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 守护购买列表适配器
|
||||
*/
|
||||
public class LiveNewGuardBuyItemsAdapter extends RecyclerView.Adapter<LiveNewGuardBuyItemsAdapter.Vh> {
|
||||
|
||||
List<GuardBuyBean> items = new ArrayList<>();
|
||||
private final Context context;
|
||||
private int selectId = 1;
|
||||
private OnItemSelectListener itemSelect;
|
||||
|
||||
public LiveNewGuardBuyItemsAdapter(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public void setItems(List<GuardBuyBean> items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
public void setOnItemSelectListener(OnItemSelectListener listener) {
|
||||
this.itemSelect = listener;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Vh onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new Vh(LayoutInflater.from(context).inflate(R.layout.item_dialog_guard_buy, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull Vh holder, int position) {
|
||||
GuardBuyBean bean = items.get(position);
|
||||
holder.setData(bean, bean.getId());
|
||||
}
|
||||
|
||||
public void changeItem(int id) {
|
||||
this.selectId = id;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return items.size();
|
||||
}
|
||||
|
||||
protected class Vh extends RecyclerView.ViewHolder {
|
||||
private LinearLayout buyButton;
|
||||
private TextView title;
|
||||
private TextView msg;
|
||||
private TextView coin;
|
||||
|
||||
public Vh(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
buyButton = itemView.findViewById(R.id.guard_buy_button);
|
||||
title = itemView.findViewById(R.id.guard_buy_title);
|
||||
msg = itemView.findViewById(R.id.guard_buy_goback);
|
||||
coin = itemView.findViewById(R.id.guard_buy_money);
|
||||
|
||||
buyButton.setOnClickListener(view -> {
|
||||
buyButton.setBackgroundResource(R.drawable.img_k_selected);
|
||||
changeItem((int) title.getTag());
|
||||
notifyDataSetChanged();
|
||||
if (itemSelect != null) {
|
||||
itemSelect.onSelectId((int) title.getTag());
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private void setData(GuardBuyBean bean, int id) {
|
||||
String coin = bean.getCoin() + "";
|
||||
title.setText(bean.getName());
|
||||
if (getAbsoluteAdapterPosition() == 2) {//全年守护要渐变色
|
||||
int[] colors = {
|
||||
Color.parseColor("#E38100"),
|
||||
Color.parseColor("#F1B868"),
|
||||
Color.parseColor("#DA9505"),
|
||||
Color.parseColor("#FDB871"),
|
||||
Color.parseColor("#E57810")
|
||||
};
|
||||
float[] position = {
|
||||
0f,
|
||||
0.2f,
|
||||
0.4f,
|
||||
0.8f,
|
||||
1.0f
|
||||
};
|
||||
LinearGradient mLinearGradient = new LinearGradient(0, 0, title.getPaint().getTextSize() * title.getText().length(), 0, colors, position, Shader.TileMode.CLAMP);
|
||||
title.getPaint().setShader(mLinearGradient);
|
||||
title.invalidate();
|
||||
}
|
||||
title.setTag(id);
|
||||
String msgText =context.getString(R.string.buy_guard_back_coin);
|
||||
msg.setText(msgText + coin);
|
||||
this.coin.setText(coin);
|
||||
if (id == selectId) {
|
||||
buyButton.setBackgroundResource(R.drawable.img_k_selected);
|
||||
} else {
|
||||
buyButton.setBackgroundResource(R.drawable.img_k_uncheck);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 用于回调通知当前选择id
|
||||
*/
|
||||
public interface OnItemSelectListener {
|
||||
void onSelectId(int id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,256 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.bean.LiveWishlistBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 直播 心愿单
|
||||
*/
|
||||
|
||||
public class LiveNewWishListAdapter extends RecyclerView.Adapter<LiveNewWishListAdapter.Vh> {
|
||||
private List<LiveWishlistBean> mWishList;
|
||||
private LayoutInflater mInflater;
|
||||
private View.OnClickListener mOnClickListener;
|
||||
private OnItemClickListener<LiveWishlistBean> mOnItemClickListener;
|
||||
private Context mContext;
|
||||
|
||||
public LiveNewWishListAdapter(Context context, boolean noLink) {
|
||||
mContext = context;
|
||||
mInflater = LayoutInflater.from(context);
|
||||
mOnClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Object tag = v.getTag();
|
||||
if (tag != null) {
|
||||
if (mOnItemClickListener != null) {
|
||||
mOnItemClickListener.onItemClick((LiveWishlistBean) tag, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public void setData(List<LiveWishlistBean> list) {
|
||||
mWishList = list;
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener<LiveWishlistBean> onItemClickListener) {
|
||||
mOnItemClickListener = onItemClickListener;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Vh onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new Vh(mInflater.inflate(R.layout.item_new_live_wish_list, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull Vh vh, int position) {
|
||||
vh.setData(mWishList.get(position), position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mWishList.size();
|
||||
}
|
||||
|
||||
class Vh extends RecyclerView.ViewHolder {
|
||||
|
||||
ImageView mIcon;
|
||||
TextView mName;
|
||||
TextView mNum;
|
||||
TextView mIncrease;
|
||||
TextView mDecrease;
|
||||
View mRlDelete;
|
||||
ProgressBar pb_wishlist;
|
||||
TextView tvProgress;
|
||||
TextView tvWishIndex;
|
||||
|
||||
public Vh(View itemView) {
|
||||
super(itemView);
|
||||
mIcon = (ImageView) itemView.findViewById(R.id.icon);
|
||||
mName = (TextView) itemView.findViewById(R.id.name);
|
||||
mNum = (TextView) itemView.findViewById(R.id.tv_num);
|
||||
mIncrease = (TextView) itemView.findViewById(R.id.tv_increase);
|
||||
mDecrease = (TextView) itemView.findViewById(R.id.tv_decrease);
|
||||
mRlDelete = itemView.findViewById(R.id.iv_delete);
|
||||
pb_wishlist = itemView.findViewById(R.id.pb_wishlist);
|
||||
tvProgress = itemView.findViewById(R.id.tvProgress);
|
||||
tvWishIndex = itemView.findViewById(R.id.tvWishIndex);
|
||||
|
||||
itemView.setOnClickListener(mOnClickListener);
|
||||
}
|
||||
|
||||
void setData(LiveWishlistBean bean, int pos) {
|
||||
itemView.setTag(bean);
|
||||
ImgLoader.display(mContext, bean.getWishlist_icon(), mIcon);
|
||||
mName.setText(bean.getWishlist_name());
|
||||
mNum.setText("x"+bean.getWishlist_num());
|
||||
int pro = 0;
|
||||
try {
|
||||
int num1 = Integer.parseInt(bean.getWishlist_progress());
|
||||
int num2 = Integer.parseInt(bean.getWishlist_num());
|
||||
pro = num1 * 100 / num2;
|
||||
//如果进度大于0,则不允许删除该礼物
|
||||
if (num1 > 0) {
|
||||
mRlDelete.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
mRlDelete.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
pb_wishlist.setProgress(pro);
|
||||
if (bean.getWishlist_num().isEmpty() || bean.getWishlist_progress().isEmpty()) {
|
||||
tvProgress.setText("");
|
||||
} else {
|
||||
tvProgress.setText(bean.getWishlist_progress() + "/" + bean.getWishlist_num());
|
||||
}
|
||||
if (pro >= 100) {
|
||||
tvWishIndex.setText("已达成");
|
||||
} else {
|
||||
tvWishIndex.setText("心愿" + getNameByIndex(pos));
|
||||
}
|
||||
// tvWishIndex.setText("心愿"+getNameByIndex(pos+1));
|
||||
decreaseClick(bean);
|
||||
increaseClick(bean);
|
||||
numTextClick(bean);
|
||||
mRlDeleteClick(pos);
|
||||
|
||||
}
|
||||
|
||||
private String getNameByIndex(int pos) {
|
||||
String ret = "";
|
||||
String arr[] = {"一", "二", "三", "四", "五", "六", "七", "八", "九", "十"};
|
||||
try {
|
||||
ret = arr[pos];
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private void mRlDeleteClick(final int pos) {
|
||||
mRlDelete.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ToastUtil.show("删除" + mWishList.get(pos).getWishlist_name() + "成功");
|
||||
mWishList.remove(pos);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void numTextClick(final LiveWishlistBean bean) {
|
||||
mNum.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
DialogUitl.showSimpleInputDialog(mContext,
|
||||
"请输入" + bean.getWishlist_name() + "的数量",
|
||||
DialogUitl.INPUT_TYPE_NUMBER, 5,
|
||||
new DialogUitl.SimpleCallback() {
|
||||
@Override
|
||||
public void onConfirmClick(Dialog dialog, String content) {
|
||||
if (TextUtils.isEmpty(content)) {
|
||||
ToastUtil.show(mContext.getString(R.string.live_set_wishlist_num));
|
||||
} else {
|
||||
int num;
|
||||
if (StringUtil.isInt(content)) {
|
||||
num = Integer.parseInt(content);
|
||||
if (num <= 0) {
|
||||
ToastUtil.show("数字必须大于0");
|
||||
} else {
|
||||
mNum.setText("x"+num);
|
||||
bean.setWishlist_num(num + "");
|
||||
}
|
||||
}
|
||||
dialog.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void increaseClick(final LiveWishlistBean bean) {
|
||||
mIncrease.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
try {
|
||||
int num = Integer.parseInt(mNum.getText().toString().replace("x",""));
|
||||
num++;
|
||||
mNum.setText("x"+num );
|
||||
bean.setWishlist_num(num + "");
|
||||
tvProgress.setText(bean.getWishlist_progress() + "/" +num);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void decreaseClick(final LiveWishlistBean bean) {
|
||||
mDecrease.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
try {
|
||||
int num = Integer.parseInt(mNum.getText().toString().replace("x",""));
|
||||
if (num > 1) {
|
||||
num--;
|
||||
mNum.setText("x"+num );
|
||||
bean.setWishlist_num(num + "");
|
||||
tvProgress.setText(bean.getWishlist_progress() + "/" +num);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.common.bean.LiveGiftBean;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.event.LiveGiftItemEvent;
|
||||
import com.yunbao.live.views.LiveParcelItemViewHolder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class LiveParcelItemAdapter extends RecyclerView.Adapter {
|
||||
private List<LiveGiftBean> giftJson = new ArrayList<>();
|
||||
private int contextLayoutGiftHeight = 0;
|
||||
private String mStream, mLiveUid;
|
||||
|
||||
public LiveParcelItemAdapter(int contextLayoutGiftHeight, List<LiveGiftBean> giftJson, String mStream, String mLiveUid) {
|
||||
this.contextLayoutGiftHeight = contextLayoutGiftHeight;
|
||||
this.giftJson = giftJson;
|
||||
this.mStream = mStream;
|
||||
this.mLiveUid = mLiveUid;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View herdView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_live_parcel, parent, false);
|
||||
return new LiveParcelItemViewHolder(herdView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
LiveParcelItemViewHolder frameGiftViewHolder = (LiveParcelItemViewHolder) holder;
|
||||
frameGiftViewHolder.showData(contextLayoutGiftHeight, giftJson.get(position));
|
||||
frameGiftViewHolder.giftSelect(giftJson.get(position), position, mStream, mLiveUid, new LiveParcelItemViewHolder.FrameGiftClickListener() {
|
||||
@Override
|
||||
public void onCallBack(int position, LiveGiftBean model) {
|
||||
model.setPageGift(true);
|
||||
Bus.get().post(new LiveGiftItemEvent().setLiveGiftModel(model));
|
||||
giftSelect(model);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void giftSelect(LiveGiftBean model) {
|
||||
for (int i = 0; i < giftJson.size(); i++) {
|
||||
giftJson.get(i).setChecked(giftJson.get(i).getId() == model.getId());
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void refreshWrapListAfterSend(LiveGiftBean model) {
|
||||
for (int i = 0; i < giftJson.size(); i++) {
|
||||
if (giftJson.get(i).getId() == model.getId()) {
|
||||
|
||||
|
||||
String giftNum = giftJson.get(i).getGiftNum();
|
||||
int number = 0;
|
||||
try {
|
||||
number = Integer.parseInt(giftNum);
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
number = 0;
|
||||
}
|
||||
if (number == 1) {
|
||||
|
||||
giftJson.remove(i);
|
||||
} else {
|
||||
giftJson.get(i).setGiftNum(String.valueOf(number - 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return giftJson.size();
|
||||
}
|
||||
}
|
||||
105
live/src/main/java/com/yunbao/live/adapter/LivePkAdapter.java
Normal file
105
live/src/main/java/com/yunbao/live/adapter/LivePkAdapter.java
Normal file
@@ -0,0 +1,105 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.common.adapter.RefreshAdapter;
|
||||
import com.yunbao.common.bean.NewLevelModel;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.manager.NewLevelManager;
|
||||
import com.yunbao.common.utils.CommonIconUtil;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.bean.LivePkBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/11/15.
|
||||
*/
|
||||
|
||||
public class LivePkAdapter extends RefreshAdapter<LivePkBean> {
|
||||
|
||||
private View.OnClickListener mOnClickListener;
|
||||
private String mLivePkInviteString;//邀请连麦
|
||||
private String mLivePkInviteString2;//已邀请
|
||||
|
||||
public LivePkAdapter(Context context) {
|
||||
super(context);
|
||||
mOnClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Object tag = v.getTag();
|
||||
if (tag != null && mOnItemClickListener != null) {
|
||||
mOnItemClickListener.onItemClick((LivePkBean) tag, 0);
|
||||
}
|
||||
}
|
||||
};
|
||||
mLivePkInviteString = "PK";
|
||||
mLivePkInviteString2 = mContext.getString(R.string.live_pk_invite_2);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new Vh(mInflater.inflate(R.layout.item_live_pk, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder vh, int position) {
|
||||
((Vh) vh).setData(mList.get(position));
|
||||
}
|
||||
|
||||
|
||||
class Vh extends RecyclerView.ViewHolder {
|
||||
|
||||
ImageView mAvatar;
|
||||
TextView mName, leave;
|
||||
ImageView mSex;
|
||||
ImageView mLevel;
|
||||
TextView mBtnInvite;
|
||||
|
||||
public Vh(View itemView) {
|
||||
super(itemView);
|
||||
mAvatar = (ImageView) itemView.findViewById(R.id.avatar);
|
||||
mName = (TextView) itemView.findViewById(R.id.name);
|
||||
leave = itemView.findViewById(R.id.leave);
|
||||
mSex = (ImageView) itemView.findViewById(R.id.sex);
|
||||
mLevel = (ImageView) itemView.findViewById(R.id.level);
|
||||
mBtnInvite = (TextView) itemView.findViewById(R.id.btn_invite);
|
||||
mBtnInvite.setOnClickListener(mOnClickListener);
|
||||
}
|
||||
|
||||
void setData(LivePkBean bean) {
|
||||
mBtnInvite.setTag(bean);
|
||||
ImgLoader.display(mContext, bean.getAvatar(), mAvatar);
|
||||
mName.setText(bean.getUserNiceName());
|
||||
mSex.setImageResource(CommonIconUtil.getSexIcon(bean.getSex()));
|
||||
|
||||
List<NewLevelModel> models = new NewLevelManager(itemView.getContext()).getNewAnchorLevelModels();
|
||||
int anchorLevel = 0;
|
||||
anchorLevel = bean.getLevelAnchor();
|
||||
String imgUrl = "";
|
||||
for (NewLevelModel newLevelModel : models) {
|
||||
if (newLevelModel.getLeveMin() <= anchorLevel && anchorLevel <= newLevelModel.getLeveMax()) {
|
||||
imgUrl = newLevelModel.getThumb();
|
||||
}
|
||||
}
|
||||
leave.setText(String.valueOf(bean.getLevelAnchor()));
|
||||
ImgLoader.display(itemView.getContext(), imgUrl, mLevel);
|
||||
|
||||
if (bean.isLinkMic()) {
|
||||
mBtnInvite.setText(mLivePkInviteString2);
|
||||
mBtnInvite.setEnabled(false);
|
||||
} else {
|
||||
mBtnInvite.setText(mLivePkInviteString);
|
||||
mBtnInvite.setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,264 @@
|
||||
package com.yunbao.live.adapter;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.yunbao.common.bean.PrankGiftBean;
|
||||
import com.yunbao.common.bean.PrankTurntableBean;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.live.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class LivePrankRecyclerAdapter extends RecyclerView.Adapter<LivePrankRecyclerAdapter.PrankRecyclerViewHolder> {
|
||||
public static final int TYPE_TURNTABLE = 0;
|
||||
public static final int TYPE_GIFT = 1;
|
||||
|
||||
private Context mContext;
|
||||
private List<?> list = new ArrayList<>();
|
||||
private OnItemClickListener<String> onItemClickListener;
|
||||
private int viewType = TYPE_TURNTABLE;
|
||||
|
||||
|
||||
public LivePrankRecyclerAdapter(Context mContext) {
|
||||
this.mContext = mContext;
|
||||
}
|
||||
|
||||
public void setList(List<?> list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener<String> onItemClickListener) {
|
||||
this.onItemClickListener = onItemClickListener;
|
||||
}
|
||||
|
||||
public void setViewType(int viewType) {
|
||||
this.viewType = viewType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return this.viewType;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public PrankRecyclerViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
if (viewType == TYPE_TURNTABLE) {
|
||||
return new TurntableViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_live_prank_turntable_config, parent, false));
|
||||
} else {
|
||||
return new GiftViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_live_prank_gift, parent, false));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull PrankRecyclerViewHolder holder, int position) {
|
||||
if (viewType == TYPE_TURNTABLE) {
|
||||
((TurntableViewHolder) holder).setDate((PrankTurntableBean) list.get(position), position);
|
||||
} else {
|
||||
((GiftViewHolder) holder).setDate((PrankGiftBean) list.get(position), position);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public void clearList() {
|
||||
list.clear();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public <T> List<T> getList() {
|
||||
return (List<T>) list;
|
||||
}
|
||||
|
||||
public boolean getViewTypeOfList() {
|
||||
return viewType == TYPE_TURNTABLE;
|
||||
}
|
||||
|
||||
public static abstract class PrankRecyclerViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
|
||||
public PrankRecyclerViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class GiftViewHolder extends PrankRecyclerViewHolder {
|
||||
private ImageView mIcon;
|
||||
private TextView mTitle;
|
||||
private TextView mName;
|
||||
private TextView mNum;
|
||||
private ImageView mRemove;
|
||||
|
||||
public GiftViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
mIcon = itemView.findViewById(R.id.gift_icon);
|
||||
mTitle = itemView.findViewById(R.id.gift_title);
|
||||
mName = itemView.findViewById(R.id.gift_name);
|
||||
mNum = itemView.findViewById(R.id.gift_num);
|
||||
mRemove = itemView.findViewById(R.id.gift_close);
|
||||
mRemove.setOnClickListener(v -> {
|
||||
PrankGiftBean bean = (PrankGiftBean) v.getTag();
|
||||
onItemClickListener.onItemClick(bean.getGiftId(), (Integer) itemView.getTag());
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void setDate(PrankGiftBean bean, int position) {
|
||||
ImgLoader.display(mContext, bean.getIcon(), mIcon);
|
||||
itemView.setTag(position);
|
||||
mName.setText(bean.getName());
|
||||
mTitle.setText(bean.getTitle());
|
||||
mNum.setText(bean.getNum() + "");
|
||||
mRemove.setTag(bean);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class TurntableViewHolder extends PrankRecyclerViewHolder {
|
||||
private TextView title;
|
||||
private TextView probability;
|
||||
private TextView context;
|
||||
|
||||
public TurntableViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
title = itemView.findViewById(R.id.prank_turntable_title);
|
||||
probability = itemView.findViewById(R.id.prank_turntable_probability);
|
||||
context = itemView.findViewById(R.id.prank_turntable_val);
|
||||
context.setOnClickListener(v -> {
|
||||
if (IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) {
|
||||
DialogUitl.showSimpleInputDialog(mContext, "填寫整蠱內容", DialogUitl.INPUT_TYPE_TEXT, 10, new DialogUitl.SimpleCallback() {
|
||||
@Override
|
||||
public void onConfirmClick(Dialog dialog, String content) {
|
||||
if (WordUtil.isSpecialChar(content)) {
|
||||
ToastUtil.show("整蠱內容不能包含特殊字符");
|
||||
return;
|
||||
}
|
||||
if (content.length() >= 2 && content.length() <= 10) {
|
||||
context.setText(content);
|
||||
onItemClickListener.onItemClick(content, ((PrankTurntableBean) list.get((Integer) itemView.getTag())).getId());
|
||||
((PrankTurntableBean) list.get((Integer) itemView.getTag())).setContext(content);
|
||||
dialog.dismiss();
|
||||
} /*else if (content.length() == 0) {
|
||||
context.setText("");
|
||||
onItemClickListener.onItemClick(content, ((PrankTurntableBean)list.get((Integer) itemView.getTag())).getId());
|
||||
dialog.dismiss();
|
||||
} */ else {
|
||||
ToastUtil.show("最少2個字,最多10個字");
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
DialogUitl.showSimpleInputDialog(mContext, "Fill in the content of the prank", DialogUitl.INPUT_TYPE_TEXT, 10, new DialogUitl.SimpleCallback() {
|
||||
@Override
|
||||
public void onConfirmClick(Dialog dialog, String content) {
|
||||
if (WordUtil.isSpecialChar(content)) {
|
||||
ToastUtil.show("The prank content cannot contain special characters");
|
||||
return;
|
||||
}
|
||||
if (content.length() >= 2 && content.length() <= 10) {
|
||||
context.setText(content);
|
||||
onItemClickListener.onItemClick(content, ((PrankTurntableBean) list.get((Integer) itemView.getTag())).getId());
|
||||
((PrankTurntableBean) list.get((Integer) itemView.getTag())).setContext(content);
|
||||
dialog.dismiss();
|
||||
} /*else if (content.length() == 0) {
|
||||
context.setText("");
|
||||
onItemClickListener.onItemClick(content, ((PrankTurntableBean)list.get((Integer) itemView.getTag())).getId());
|
||||
dialog.dismiss();
|
||||
} */ else {
|
||||
ToastUtil.show("Fill in a minimum of 2 words and a maximum of 10 words");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public void setDate(PrankTurntableBean bean, int position) {
|
||||
if (IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) {
|
||||
title.setText("轉盤" + getChineseNum(bean.getId()) + "號位");
|
||||
} else {
|
||||
title.setText("Turntable" + getChineseNum(bean.getId()));
|
||||
}
|
||||
|
||||
probability.setText(getProbability(bean.getId(), mContext));
|
||||
context.setText(bean.getContext());
|
||||
itemView.setTag(position);
|
||||
}
|
||||
|
||||
private String getChineseNum(int id) {
|
||||
switch (id) {
|
||||
case 1:
|
||||
return "一";
|
||||
case 2:
|
||||
return "二";
|
||||
case 3:
|
||||
return "三";
|
||||
case 4:
|
||||
return "四";
|
||||
case 5:
|
||||
return "五";
|
||||
case 6:
|
||||
return "六";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private String getProbability(int id, Context mContext) {
|
||||
if (IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) {
|
||||
switch (id) {
|
||||
case 1:
|
||||
return "抽取幾率:40%";
|
||||
case 2:
|
||||
return "抽取幾率:30%";
|
||||
case 3:
|
||||
return "抽取幾率:15%";
|
||||
case 4:
|
||||
return "抽取幾率:10%";
|
||||
case 5:
|
||||
return "抽取幾率:4%";
|
||||
default:
|
||||
return "抽取幾率:1%";
|
||||
}
|
||||
} else {
|
||||
switch (id) {
|
||||
case 1:
|
||||
return "Extraction probability:40%";
|
||||
case 2:
|
||||
return "Extraction probability:30%";
|
||||
case 3:
|
||||
return "Extraction probability:15%";
|
||||
case 4:
|
||||
return "Extraction probability:10%";
|
||||
case 5:
|
||||
return "Extraction probability:4%";
|
||||
default:
|
||||
return "Extraction probability:1%";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user