Compare commits

...

160 Commits

Author SHA1 Message Date
18401019693
df4d7d99ce Merge branch 'master' into 6.5.0
# Conflicts:
#	config.gradle
2023-04-14 17:50:27 +08:00
18401019693
f07e27904d 修改侧边栏跳转问题 2023-04-14 17:50:09 +08:00
18401019693
32e3584fef 修改侧边栏跳转问题 2023-04-14 16:09:02 +08:00
18142669586
90c7483dbc 修改关注点击问题 2023-04-14 13:41:52 +08:00
18401019693
e38262826d 关注ui修改,多人pk倒计时问题 2023-04-14 10:59:06 +08:00
18401019693
cbb1531356 心愿单位置移动 2023-04-14 10:46:13 +08:00
18401019693
0ed37aee11 心愿单位置移动 2023-04-14 10:40:14 +08:00
18401019693
c23ed7defb 心愿单位置移动 2023-04-13 18:25:19 +08:00
18401019693
06e077146b 心愿单位置移动 2023-04-13 17:57:40 +08:00
10588e4810 Merge remote-tracking branch 'origin/master' 2023-04-13 17:23:41 +08:00
4b7469d9d4 调整女神说banner布局 2023-04-13 17:23:29 +08:00
18142669586
eb21a17475 修改连麦样试 2023-04-13 17:22:05 +08:00
18142669586
974546697b Merge remote-tracking branch 'origin/master' 2023-04-13 16:45:07 +08:00
18142669586
8507fc1bb7 修改连麦样试 2023-04-13 16:44:41 +08:00
18401019693
bb4f8bb98e 心愿单设置加限制 2023-04-13 16:44:40 +08:00
4a4cc179bf 修复单人PK结算后新进来竖屏直播间,画面异常问题 2023-04-13 16:26:57 +08:00
18142669586
db8dc2a781 修改连麦样试 2023-04-13 15:57:11 +08:00
18401019693
4ae1b12be0 心愿单设置加限制 2023-04-13 15:45:51 +08:00
18401019693
06289b44d9 心愿单设置加限制 2023-04-13 13:08:58 +08:00
18401019693
32fa77be39 心愿单逻辑修改,ui修改 2023-04-13 13:04:12 +08:00
18142669586
9869a2376c 修改toat样试 2023-04-13 11:42:15 +08:00
af4176bcb7 移除ACache读取后最后一个换行符 2023-04-13 10:43:07 +08:00
499b73295d 修复人气票没传liveuid和stream问题 2023-04-13 10:07:42 +08:00
bec764a329 修复从直播间个人中心进去的分享按钮没反应问题 2023-04-12 15:26:57 +08:00
58c988a83a 修复ACache读多行文本未换行问题 2023-04-12 13:15:33 +08:00
18401019693
0506d82165 修改热度加成逻辑展示方式 2023-04-11 16:17:26 +08:00
cfc72f7441 根据需求调整送过一次联系方式礼物后,以后点击联系方式都是直接打开信件详情 2023-04-11 14:37:39 +08:00
18401019693
b305ba925b 修改热度加成逻辑展示方式 2023-04-11 14:14:42 +08:00
e99b18eec6 调整女神说ui 2023-04-10 18:22:37 +08:00
18401019693
38b080f082 6.5.0 2023-04-10 16:07:18 +08:00
18142669586
605f10d0ac 英文包 2023-04-10 15:37:19 +08:00
18142669586
f7480c6e43 修改中英文 2023-04-10 13:44:39 +08:00
ceef0f1e57 修改联系方式 2023-04-10 13:37:57 +08:00
18401019693
19c0c8c6e7 修改生成心愿单 2023-04-10 13:30:47 +08:00
d50c56bbb2 update 2023-04-10 13:07:08 +08:00
8ce65ced30 调整分享附带文案 2023-04-10 11:57:35 +08:00
18401019693
80e93f9981 关注消息修改 2023-04-10 11:54:25 +08:00
a34e90753c Merge remote-tracking branch 'origin/master' 2023-04-10 11:45:41 +08:00
a53da7a2b8 修复通过头像跳转到其他PK直播间,再上下滑回来会依旧保持PK倒计时状态 2023-04-10 11:45:15 +08:00
18401019693
bdd6124300 关注消息修改 2023-04-10 11:42:22 +08:00
47c3f59f74 修复通过头像跳转到其他PK直播间,再上下滑回来会依旧保持PK倒计时状态 2023-04-10 11:33:14 +08:00
76f94895fe 调整直播间UI 2023-04-10 11:14:53 +08:00
e0eea59539 调整直播间UI 2023-04-10 11:07:35 +08:00
18401019693
917d237b6d 关注消息修改 2023-04-10 10:45:07 +08:00
508f1a52ae 调整直播间UI 2023-04-10 10:22:32 +08:00
18401019693
4429dc7a4c 小助手消息修改 2023-04-10 10:05:48 +08:00
18401019693
296a6d24bb 心愿单修改 2023-04-10 09:57:24 +08:00
18142669586
6c19f0efc4 心愿单审核和贵族购买 2023-04-08 18:21:53 +08:00
18401019693
6f7a9a9310 心愿单修改 2023-04-08 18:11:35 +08:00
66e011f2d3 修复女神说主播端不隐藏的问题 2023-04-08 17:33:52 +08:00
18142669586
9e7909ec70 Merge remote-tracking branch 'origin/master' 2023-04-08 17:29:36 +08:00
18142669586
8ae58e9c14 心愿单审核和贵族购买 2023-04-08 17:27:26 +08:00
18401019693
2ce527cee8 心愿单修改 2023-04-08 17:26:39 +08:00
18401019693
28ef982b74 心愿单修改 2023-04-08 16:42:43 +08:00
b44524b25f 修复女神说不隐藏的问题 2023-04-08 16:27:33 +08:00
f76d649233 调整联系方式浮标UI 2023-04-08 16:20:43 +08:00
90fee86c19 修复信息红点显示错误问题 2023-04-08 16:11:41 +08:00
9707898af9 调整直播间UI
修复心愿单浮窗一堆问题
2023-04-08 15:45:47 +08:00
18401019693
9c3fbe0506 心愿单修改 2023-04-08 15:10:16 +08:00
a8178c51a0 调整直播间UI
修复进入直播间快速退出导致的闪退问题
2023-04-08 14:57:22 +08:00
18142669586
2b62d018b5 Merge remote-tracking branch 'origin/master' 2023-04-08 14:14:19 +08:00
18142669586
f7cf72f15f 修改聊天框长度 2023-04-08 14:14:06 +08:00
18401019693
b3d4d2b8f9 xiu gai xinyuan dan 2023-04-08 13:36:12 +08:00
18401019693
8cbbd4015f xiu gai xinyuan dan 2023-04-07 17:34:39 +08:00
51bf55fdeb 修复主播端开播热度值没背景 2023-04-07 16:46:20 +08:00
18401019693
18a5f46133 高等级飘屏修改 2023-04-07 16:44:02 +08:00
f201e0978e 修复主播端开播后点击屏幕无效问题 2023-04-07 16:23:10 +08:00
18401019693
63c2891650 心愿单修改, 2023-04-07 16:07:08 +08:00
af164f549f 修复开播后点击屏幕闪退问题
调整女神说背景固定大小
2023-04-07 16:01:59 +08:00
33034ce4d6 调整心愿单浮标大小
修复注册默认值没香港标识
调整小助手图片位置
2023-04-07 15:37:51 +08:00
18401019693
9d38ff7c8f 心愿单修改, 2023-04-07 15:28:19 +08:00
16caf60f77 更换心愿单浮标背景图
优化分享字符过多显示不全问题
优化女神说浮窗字数过多超过背景图问题
2023-04-07 14:45:12 +08:00
f3bca96ee8 Merge remote-tracking branch 'origin/master' 2023-04-07 14:43:57 +08:00
18142669586
b0ed276e23 修改新人任务的展示 2023-04-07 14:42:07 +08:00
906ff6cfa6 调整观众端点联系方式送礼界面恢复分类tab 2023-04-07 14:02:41 +08:00
6427311cec 修复单人PK发起方会重复两次倒计时问题 2023-04-07 13:58:18 +08:00
181f081706 修复单人PK会丢失结束连麦按钮问题 2023-04-07 11:34:24 +08:00
14490cacfa 修复多人PK不会隐藏女神说和联系方式的问题 2023-04-07 10:57:24 +08:00
6ff83dabff 调整信件top ui 2023-04-07 10:26:46 +08:00
a6d81ef666 移除测试用toast 2023-04-07 09:48:31 +08:00
11679a62a0 Merge remote-tracking branch 'origin/master' 2023-04-06 14:29:41 +08:00
36410ddcaa 调整女神说6字改回4字 2023-04-06 14:29:12 +08:00
18401019693
3bf6518e25 心愿单修改, 2023-04-06 14:20:46 +08:00
18142669586
028f2794bf Merge remote-tracking branch 'origin/master' 2023-04-06 13:32:18 +08:00
18142669586
1c198a44cf 页面修改 2023-04-06 13:31:52 +08:00
1fba3bd53e 调整邀请框的【复制】按钮位置和添加边框 2023-04-06 11:02:30 +08:00
fd15428ed9 新增主播联系方式详情页 2023-04-06 10:34:45 +08:00
18401019693
a5fd14cc0e 去除心愿单礼物贵族和守护的金额 2023-04-03 18:02:29 +08:00
18401019693
3c7a2d3964 心愿单增加礼物金额 2023-04-03 17:57:47 +08:00
18401019693
325d7254f0 视图资源文件修改,心愿单上传数据修改 2023-04-03 15:39:12 +08:00
18401019693
153d5ff159 修改心愿单生成 2023-04-03 15:29:21 +08:00
a86cf97d74 Merge remote-tracking branch 'origin/master' 2023-04-03 15:16:51 +08:00
192587f758 新增通过后端获取国家地区信息接口在注册时自动填写号码编号 2023-04-03 15:15:50 +08:00
18142669586
5697a19f91 Merge remote-tracking branch 'origin/master' 2023-04-03 15:10:13 +08:00
18142669586
1fa1874241 分享邀请码注册绑定 2023-04-03 15:07:48 +08:00
c43b581157 调整联系方式选项 2023-04-03 14:48:35 +08:00
ba5a80fb1d 改回联系方式礼物接口,仅显示热门分类下的礼物 2023-04-03 14:19:22 +08:00
73c8db8fb4 新增通过后端获取国家地区信息接口
调整送联系方式礼物时,不选择其他礼物
调整联系方式礼物接口
调整在模拟器超大分辨率模式下,信箱ui异常问题
2023-04-03 13:28:35 +08:00
18401019693
f55e1b9c05 修改 2023-04-02 17:29:14 +08:00
18401019693
e5a07613aa 修改随机pk轮播背景展示问题 2023-04-02 17:22:10 +08:00
ed46eb30a8 更新功能翻译资源 2023-04-02 17:22:05 +08:00
18401019693
971fceebcd 修改随机pk轮播背景展示问题 2023-04-02 16:37:05 +08:00
18401019693
329bd63229 新增功能翻译资源 2023-04-02 16:31:11 +08:00
18401019693
d320373b07 侧边栏修改,新增播放设置 2023-04-02 14:22:30 +08:00
326bb5ae7f 修复PK倒计时偶尔会提前结束问题(设置倒计时默认值为100解决)
修复PK【开始/结束】不会【隐藏/显示】女神说和联系方式浮窗
2023-04-01 18:29:12 +08:00
18401019693
95c39cca9d 心愿单直播间轮播入口(没有设置就隐藏) 2023-04-01 15:51:52 +08:00
18401019693
849677e50e 心愿单直播间轮播入口 2023-04-01 14:45:48 +08:00
c4ae047a4b 移除分享的结果的Toast 2023-04-01 11:33:20 +08:00
5657d5a00b 修正侧边栏【分享】按钮的文字 2023-04-01 11:22:51 +08:00
4b6b477351 Merge remote-tracking branch 'origin/master' 2023-04-01 11:18:17 +08:00
d035018ada 移除调试代码 2023-04-01 11:18:04 +08:00
e301e7bfce Merge branch 'dev_share'
# Conflicts:
#	main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java
2023-04-01 11:15:18 +08:00
97ad5c2d92 update 调整女神说布局大小 2023-04-01 11:14:24 +08:00
43e7713f6b update 兼容女神说接口变动 2023-04-01 09:51:26 +08:00
18142669586
cfce501d45 分享邀请码注册绑定 2023-04-01 09:44:13 +08:00
18401019693
b2f35fdc16 修复豪气榜神秘人问题 2023-03-31 17:52:00 +08:00
87afe9297d 移除调试内容 2023-03-31 17:32:52 +08:00
48f1d42739 Merge branch 'dev_use_discounts'
# Conflicts:
#	common/src/main/res/values/strings.xml
2023-03-31 17:27:24 +08:00
9eed92302d add 购买守护使用优惠卷 2023-03-31 17:26:28 +08:00
18401019693
f12f6a9130 心愿单完成 2023-03-31 16:44:22 +08:00
ef757a8adc update 分享支持社区分享按钮 2023-03-31 15:09:18 +08:00
0177a1314d update 购买守护优惠卷 2023-03-31 14:40:43 +08:00
26cb58463a update 直播間分享 2023-03-31 13:34:57 +08:00
18401019693
d1d8054c01 心愿单的重置提示 2023-03-30 17:43:42 +08:00
18401019693
2db89365bb 季心愿单的设置与展示 2023-03-30 16:46:02 +08:00
18401019693
87ba382e81 月心愿单的设置与展示 2023-03-30 16:36:53 +08:00
18401019693
55290a71aa 周心愿单的设置与展示 2023-03-30 16:28:06 +08:00
18401019693
5095de3c43 日心愿单重置 2023-03-30 16:17:25 +08:00
18401019693
70a91fedf3 心愿单添加部分功能实现 2023-03-30 14:16:50 +08:00
ef8f87d100 Merge branch 'master' into dev_share 2023-03-30 11:47:44 +08:00
6d83c6f8ae Merge branch 'dev_6.5.0_anchor_call_me'
# Conflicts:
#	common/src/main/java/com/yunbao/common/manager/IMLoginManager.java
#	common/src/main/res/values/strings.xml
#	live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java
2023-03-30 11:31:32 +08:00
ce2048b9a5 update 女神说主播端显示
update 联系方式改成svga
update PK时隐藏女神说和联系方式
2023-03-30 11:23:11 +08:00
c22da60b82 update 联系方式 2023-03-29 13:39:09 +08:00
c78bb79633 update 联系方式
update 女神说
2023-03-29 13:32:15 +08:00
3a980d22fd Merge branch 'dev_6.5.0_anchor_say' into dev_6.5.0_anchor_call_me
# Conflicts:
#	common/src/main/java/com/yunbao/common/http/PDLiveApi.java
#	common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java
#	main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java
2023-03-28 11:01:58 +08:00
2b56eff39a update 联系方式 2023-03-27 16:16:23 +08:00
18401019693
9472ccf6c8 修改整蛊界面 2023-03-27 16:00:23 +08:00
18401019693
59d384a81c 修改右下角任务浮标,星级挑战修改 2023-03-27 15:30:30 +08:00
18401019693
c02f24fdcd 修改礼物图标 2023-03-27 15:29:43 +08:00
18401019693
86c5334ab4 高等级入场提示 2023-03-27 14:22:29 +08:00
6ef8c3778b update 女神说 2023-03-27 11:09:03 +08:00
0c6eac2936 新增设置联系方式相关UI 2023-03-24 10:52:44 +08:00
18401019693
62e2b93bd5 修改特权页面背景 2023-03-23 17:43:44 +08:00
18401019693
d80bc3bd27 默认气泡的修改 2023-03-23 17:28:34 +08:00
18401019693
085f19c3ca 修改直播间聊天界面(横竖屏聊天框高度,关注消息修改)直播间头部布局样式修改 2023-03-23 16:36:16 +08:00
f4d23c57df 新增女神说相关UI 2023-03-23 14:26:52 +08:00
18401019693
95429402c7 修改礼物界面样式 2023-03-22 18:20:34 +08:00
18401019693
1da79d6f48 礼物界面,直播间下部按钮布局样式的更改 2023-03-22 18:16:40 +08:00
18401019693
926bd1a22e 直播间聊天内容等级样式更改 2023-03-22 16:57:50 +08:00
18401019693
554bfa137a 消息气泡位置,关注消息默认消息,样式更改 2023-03-22 16:55:51 +08:00
9e5a61f66c update 2023-03-21 18:20:11 +08:00
18401019693
be608fd90b 修改直播间聊天字体背景样式 2023-03-21 17:42:34 +08:00
c9e53b4dfd Merge branch 'master' into dev_share
# Conflicts:
#	app/src/main/java/com/shayu/phonelive/NeverCrashUtils.java
#	config.gradle
#	main/src/main/java/com/yunbao/main/activity/TestActivity.java
2023-03-21 15:00:53 +08:00
c2aba5da4b 优化:调整直播间聊天输入框点击发送后不隐藏软键盘和聊天框 2023-03-21 10:05:02 +08:00
60da453114 移除全局异常捕获后杀死进程 2023-02-13 16:05:20 +08:00
a50a7140fd update Share 2023-02-13 11:21:40 +08:00
15b232f52a update Share 2023-02-09 10:04:13 +08:00
3c80038bef update Share 2023-02-08 16:01:35 +08:00
ce8088059a 暂存测试几个用intent打开分享的平台 2023-02-07 15:45:42 +08:00
d14939c893 create ShareUtil 2023-02-06 15:57:56 +08:00
336 changed files with 17059 additions and 3081 deletions

1
Share/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build

73
Share/build.gradle Normal file
View File

@@ -0,0 +1,73 @@
apply plugin: 'com.android.library'
apply plugin: 'img-optimizer'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion rootProject.ext.android.compileSdkVersion
buildToolsVersion rootProject.ext.android.buildToolsVersion
packagingOptions {
pickFirst "lib/armeabi/libyuvutils.so"
pickFirst "lib/arm64-v8a/libyuvutils.so"
pickFirst "lib/armeabi-v7a/libyuvutils.so"
pickFirst "lib/armeabi/libyuvtools.so"
pickFirst "lib/arm64-v8a/libyuvtools.so"
pickFirst "lib/armeabi-v7a/libyuvtools.so"
exclude "lib/arm64-v8a/libmmcv_api_handgesture.so"
exclude "lib/arm64-v8a/libmmcv_api_express.so"
exclude "lib/arm64-v8a/libMediaEncoder.so"
exclude "lib/arm64-v8a/libarcore_sdk_c.so"
exclude "lib/arm64-v8a/libmediadecoder.so"
exclude "lib/arm64-v8a/libMediaMuxer.so"
exclude "lib/arm64-v8a/libarcore_sdk_jni.so"
exclude "lib/arm64-v8a/libMediaUtils.so"
exclude "lib/arm64-v8a/libcosmosffmpeg.so"
}
defaultConfig {
minSdkVersion rootProject.ext.android.minSdkVersion
targetSdkVersion rootProject.ext.android.targetSdkVersion
versionCode rootProject.ext.android.versionCode
versionName rootProject.ext.android.versionName
manifestPlaceholders = rootProject.ext.manifestPlaceholders
ndk {
abiFilters "armeabi-v7a", "arm64-v8a"
}
}
aaptOptions {
cruncherEnabled = false
useNewCruncher = false
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
repositories {
flatDir {
dirs 'libs', '../libs'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation rootProject.ext.dependencies["appcompat-androidx"]
implementation rootProject.ext.dependencies["recyclerview-androidx"]
//common
implementation project(path: ':common')
//Twitter
implementation 'com.twitter.sdk.android:twitter:3.1.1'
//facebook & Messenger
implementation 'com.facebook.android:facebook-share:15.2.0'
}

0
Share/consumer-rules.pro Normal file
View File

21
Share/proguard-rules.pro vendored Normal file
View File

@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View File

@@ -0,0 +1,26 @@
package com.yunbao.share;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.yunbao.share.test", appContext.getPackageName());
}
}

View File

@@ -0,0 +1,44 @@
<?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.pdlive.shayu">
<queries>
<package android:name="com.pdlive.shayu"/>
<package android:name="com.facebook.orca"/>
<package
android:name="com.facebook.composer" />
<package
android:name="com.facebook.katana" />
<package
android:name="com.facebook.messenger" />
<provider
android:authorities="com.facebook.katana.provider.PlatformProvider"
tools:ignore="ExportedContentProvider" />
</queries>
<application android:allowBackup="true">
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name"
android:screenOrientation="portrait" />
<provider
android:name="com.facebook.FacebookContentProvider"
android:authorities="com.facebook.app.FacebookContentProvider2011402032399020"
android:exported="true" />
<receiver
android:name="com.yunbao.share.receiver.TwitterResultReceiver"
android:exported="false">
<intent-filter>
<action android:name="com.twitter.sdk.android.tweetcomposer.UPLOAD_SUCCESS" />
<action android:name="com.twitter.sdk.android.tweetcomposer.UPLOAD_FAILURE" />
<action android:name="com.twitter.sdk.android.tweetcomposer.TWEET_COMPOSE_CANCEL" />
</intent-filter>
</receiver>
</application>
</manifest>

View File

@@ -0,0 +1,34 @@
package com.yunbao.share;
import android.content.Context;
import android.content.IntentFilter;
import android.net.Uri;
import androidx.core.content.FileProvider;
import com.twitter.sdk.android.tweetcomposer.TweetUploadService;
import com.yunbao.share.bean.ShareBuilder;
import com.yunbao.share.receiver.TwitterResultReceiver;
import java.io.File;
public abstract class AbsShareInterface {
protected final Context mContext;
public AbsShareInterface(Context context) {
this.mContext = context;
IntentFilter filter = new IntentFilter(TweetUploadService.UPLOAD_SUCCESS);
filter.addAction(TweetUploadService.UPLOAD_FAILURE);
filter.addAction(TweetUploadService.TWEET_COMPOSE_CANCEL);
context.registerReceiver(new TwitterResultReceiver(), filter);
}
public abstract void share(ShareBuilder builder, ICallback callback);
public Uri fileToUri(File file){
return FileProvider.getUriForFile(mContext,
mContext.getPackageName() + ".fileprovider",
file
);
}
}

View File

@@ -0,0 +1,6 @@
package com.yunbao.share;
public interface ICallback {
void onSuccess();
void onFailure();
}

View File

@@ -0,0 +1,130 @@
package com.yunbao.share.adapters;
import android.content.Context;
import android.os.Environment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.StringRes;
import androidx.recyclerview.widget.RecyclerView;
import com.pdlive.shayu.R;
import com.yunbao.share.ICallback;
import com.yunbao.share.bean.ShareBuilder;
import com.yunbao.share.platform.FacebookShare;
import com.yunbao.share.platform.Instagram;
import com.yunbao.share.platform.Line;
import com.yunbao.share.platform.MessengerShare;
import com.yunbao.share.platform.TwitterShare;
import com.yunbao.share.platform.WhatsApp;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
public class ShareAppAdapter extends RecyclerView.Adapter<ShareAppAdapter.AppViewHolder> {
private Context mContext;
private List<ShareBuilder> list;
public ShareAppAdapter(Context mContext) {
list = new ArrayList<>();
this.mContext = mContext;
}
public void setList(List<ShareBuilder> list) {
this.list = list;
notifyDataSetChanged();
}
@NonNull
@Override
public AppViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new AppViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_share_app, parent, false));
}
@Override
public void onBindViewHolder(@NonNull AppViewHolder holder, int position) {
ShareBuilder builder = list.get(position);
switch (builder.getType()) {
case ShareBuilder.APP_FACEBOOK:
holder.setData(builder, R.mipmap.icon_share_facebook, R.string.dialog_share_app_facebook);
break;
case ShareBuilder.APP_LINE:
holder.setData(builder, R.mipmap.icon_share_line, R.string.dialog_share_app_line);
break;
case ShareBuilder.APP_TWITTER:
holder.setData(builder, R.mipmap.icon_share_twitter, R.string.dialog_share_app_twitter);
break;
case ShareBuilder.APP_WHATSAPP:
holder.setData(builder, R.mipmap.icon_share_whatsapp, R.string.dialog_share_app_whatsapp);
break;
case ShareBuilder.APP_MESSENGER:
holder.setData(builder, R.mipmap.icon_share_messenger, R.string.dialog_share_app_messenger);
break;
case ShareBuilder.APP_INSTAGRAM:
holder.setData(builder, R.mipmap.icon_share_instagram, R.string.dialog_share_app_instagram);
break;
}
}
@Override
public int getItemCount() {
return list.size();
}
public static class AppViewHolder extends RecyclerView.ViewHolder {
ImageView icon;
TextView title;
public AppViewHolder(@NonNull View itemView) {
super(itemView);
icon = itemView.findViewById(R.id.share_app_icon);
title = itemView.findViewById(R.id.share_app_name);
}
public void setData(ShareBuilder bean, @DrawableRes int iconId, @StringRes int appName) {
icon.setImageResource(iconId);
title.setText(appName);
itemView.setOnClickListener(v -> {
switch (bean.getType()) {
case ShareBuilder.APP_FACEBOOK:
new FacebookShare(itemView.getContext()).share(bean, new ShareCallback());
break;
case ShareBuilder.APP_LINE:
new Line(itemView.getContext()).share(bean, new ShareCallback());
break;
case ShareBuilder.APP_TWITTER:
new TwitterShare(itemView.getContext()).share(bean, new ShareCallback());
break;
case ShareBuilder.APP_WHATSAPP:
new WhatsApp(itemView.getContext()).share(bean, new ShareCallback());
break;
case ShareBuilder.APP_MESSENGER:
new MessengerShare(itemView.getContext()).share(bean, new ShareCallback());
break;
case ShareBuilder.APP_INSTAGRAM:
new Instagram(itemView.getContext()).share(bean, new ShareCallback());
break;
}
});
}
private static class ShareCallback implements ICallback {
@Override
public void onSuccess() {
}
@Override
public void onFailure() {
}
}
}
}

View File

@@ -0,0 +1,136 @@
package com.yunbao.share.bean;
import androidx.annotation.NonNull;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.utils.StringUtil;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
public class ShareBuilder {
public static final int APP_FACEBOOK = 0;
public static final int APP_LINE = 1;
public static final int APP_TWITTER = 2;
public static final int APP_WHATSAPP = 3;
public static final int APP_MESSENGER = 4;
public static final int APP_INSTAGRAM = 5;
private String text;
private String link;
private File file;
private int type;
private String uid;
private String anchorId;
private String anchorName;
private String anchorAvatar;
public static String createLiveShareLink(String shareUid, String anchorId, String anchorName, String anchorAvatar) {
try {
return String.format(CommonAppConfig.HOST +
"/h5/activity/FriendInvitation/liveShare.html?user_id=%s&anchor_id=%s&anchor_name=%s&anchor_avatar=%s&isGoogle=%s",
shareUid,
anchorId,
URLEncoder.encode(anchorName, "UTF-8"),
URLEncoder.encode(anchorAvatar, "UTF-8"),
CommonAppConfig.IS_GOOGLE_PLAY ? "1" : "0"
);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
public static String createInviteLink(String shareUid){
return String.format("https://www.pdlive.com/public/app/download/index.html?user_id=%s&isGoogle=%s",
shareUid,
CommonAppConfig.IS_GOOGLE_PLAY ? "1" : "0"
);
}
public static ShareBuilder builder(int type) {
return new ShareBuilder(type);
}
private ShareBuilder(int type) {
this.type = type;
}
public int getType() {
return type;
}
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
public String getAnchorId() {
return anchorId;
}
public void setAnchorId(String anchorId) {
this.anchorId = anchorId;
}
public String getAnchorName() {
return anchorName;
}
public void setAnchorName(String anchorName) {
this.anchorName = anchorName;
}
public String getAnchorAvatar() {
return anchorAvatar;
}
public void setAnchorAvatar(String anchorAvatar) {
this.anchorAvatar = anchorAvatar;
}
public ShareBuilder setText(String text) {
this.text = text;
return this;
}
public ShareBuilder setLink(String link) {
this.link = link;
return this;
}
public ShareBuilder setFile(File file) {
this.file = file;
return this;
}
public String getText() {
if (StringUtil.isEmpty(text)) {
return getLink();
}
return text + "\n" + getLink();
}
public String getLink() {
if (StringUtil.isEmpty(link)) {
link = createLiveShareLink(uid, anchorId, anchorName, anchorAvatar);
}
return link;
}
public File getFile() {
return file;
}
@NonNull
@Override
public String toString() {
return "ShareBuilder{" +
"text='" + text + '\'' +
", link='" + link + '\'' +
", file=" + file +
'}';
}
}

View File

@@ -0,0 +1,48 @@
package com.yunbao.share.platform;
import android.app.Activity;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.NonNull;
import com.facebook.CallbackManager;
import com.facebook.FacebookCallback;
import com.facebook.FacebookException;
import com.facebook.share.Sharer;
import com.facebook.share.model.ShareLinkContent;
import com.facebook.share.widget.ShareDialog;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.share.AbsShareInterface;
import com.yunbao.share.ICallback;
import com.yunbao.share.bean.ShareBuilder;
public class FacebookShare extends AbsShareInterface {
public static CallbackManager callbackManager;
public FacebookShare(Context context) {
super(context);
}
@Override
public void share(ShareBuilder builder, ICallback callback) {
callbackManager= CallbackManager.Factory.create();
ShareLinkContent content = new ShareLinkContent.Builder()
.setContentUrl(Uri.parse(builder.getLink()))
.build();
ShareDialog dialog=new ShareDialog((Activity) mContext);
dialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {
@Override
public void onSuccess(Sharer.Result result) {
}
@Override
public void onCancel() {
}
@Override
public void onError(@NonNull FacebookException e) {
}
});
dialog.show(content);
}
}

View File

@@ -0,0 +1,27 @@
package com.yunbao.share.platform;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import com.yunbao.share.AbsShareInterface;
import com.yunbao.share.ICallback;
import com.yunbao.share.bean.ShareBuilder;
public class Instagram extends AbsShareInterface {
public Instagram(Context context) {
super(context);
}
@Override
public void share(ShareBuilder builder, ICallback callback) {
String type = "image/*";
Intent share = new Intent(Intent.ACTION_SEND);
Uri uri = fileToUri(builder.getFile());
share.setType(type);
share.putExtra(Intent.EXTRA_STREAM, uri);
share.setPackage("com.instagram.android");
mContext.startActivity(Intent.createChooser(share, "Share to"));
callback.onSuccess();
}
}

View File

@@ -0,0 +1,31 @@
package com.yunbao.share.platform;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import com.yunbao.share.AbsShareInterface;
import com.yunbao.share.ICallback;
import com.yunbao.share.bean.ShareBuilder;
import java.net.URLEncoder;
public class Line extends AbsShareInterface {
public Line(Context context) {
super(context);
}
@Override
public void share(ShareBuilder builder, ICallback callback) {
try {
Intent share = new Intent(Intent.ACTION_VIEW, Uri.parse("https://line.me/R/share?text=" + URLEncoder.encode(builder.getText(), "UTF-8")));
mContext.startActivity(share);
callback.onSuccess();
} catch (Exception e) {
callback.onFailure();
throw new RuntimeException(e);
}
}
}

View File

@@ -0,0 +1,57 @@
package com.yunbao.share.platform;
import android.app.Activity;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.NonNull;
import com.facebook.CallbackManager;
import com.facebook.FacebookCallback;
import com.facebook.FacebookException;
import com.facebook.FacebookSdk;
import com.facebook.share.Sharer;
import com.facebook.share.model.ShareLinkContent;
import com.facebook.share.widget.MessageDialog;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.share.AbsShareInterface;
import com.yunbao.share.ICallback;
import com.yunbao.share.bean.ShareBuilder;
public class MessengerShare extends AbsShareInterface {
public static CallbackManager callbackManager;
public MessengerShare(Context context) {
super(context);
FacebookSdk.setIsDebugEnabled(true);
}
@Override
public void share(ShareBuilder builder, ICallback callback) {
callbackManager = CallbackManager.Factory.create();
ShareLinkContent content = new ShareLinkContent.Builder()
.setContentUrl(Uri.parse(builder.getLink()))
.build();
MessageDialog dialog = new MessageDialog((Activity) mContext);
dialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {
@Override
public void onSuccess(Sharer.Result result) {
callback.onSuccess();
}
@Override
public void onCancel() {
}
@Override
public void onError(@NonNull FacebookException e) {
e.printStackTrace();
}
});
if(dialog.canShow(content)) {
dialog.show(content);
}else{
callback.onFailure();
}
}
}

View File

@@ -0,0 +1,73 @@
package com.yunbao.share.platform;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import com.twitter.sdk.android.core.Twitter;
import com.yunbao.share.AbsShareInterface;
import com.yunbao.share.ICallback;
import com.yunbao.share.bean.ShareBuilder;
import java.net.URLEncoder;
public class TwitterShare extends AbsShareInterface {
public TwitterShare(Context context) {
super(context);
Twitter.initialize(context);
}
@Override
public void share(ShareBuilder date, ICallback callback) {
/*
new TwitterAuthClient().authorize((Activity) mContext, new Callback<TwitterSession>() {
@Override
public void success(Result<TwitterSession> result) {
//获取以下登录成功返回信息进行登录验证
//获取登录用户信息
final TwitterSession activeSession=TwitterCore.getInstance().getSessionManager().getActiveSession();
Intent intent = new ComposerActivity.Builder(mContext)
.session(activeSession)
.image(fileToUri(date.getFile()))
.text(date.getText())
.hashtags("#twitter")
.createIntent();
mContext.startActivity(intent);
}
@Override
public void failure(TwitterException e) {
}
});*/
/* TweetComposer.Builder builder;
if (date.getFile() == null) {
try {
builder=new TweetComposer.Builder(mContext)
.text(date.getText())
.url(new URL(date.getLink()));
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
} else {
builder = new TweetComposer.Builder(mContext)
.text(date.getText())
.image(fileToUri(date.getFile()));
}
builder.show();*/
try {
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_VIEW);
sendIntent.putExtra(Intent.EXTRA_TEXT, date.getText());
// sendIntent.setType("text/plain");
//sendIntent.setPackage("com.twitter.composer.ComposerShareActivity");
sendIntent.setData(Uri.parse("https://twitter.com/intent/tweet?text=" +URLEncoder.encode(date.getText(),"UTF-8")));
mContext.startActivity(sendIntent);
callback.onSuccess();
} catch (Exception e) {
callback.onFailure();
}
}
}

View File

@@ -0,0 +1,30 @@
package com.yunbao.share.platform;
import android.content.Context;
import android.content.Intent;
import com.yunbao.share.AbsShareInterface;
import com.yunbao.share.ICallback;
import com.yunbao.share.bean.ShareBuilder;
public class WhatsApp extends AbsShareInterface {
public WhatsApp(Context context) {
super(context);
}
@Override
public void share(ShareBuilder builder, ICallback callback) {
try {
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, builder.getText());
sendIntent.setType("text/plain");
sendIntent.setPackage("com.whatsapp");
mContext.startActivity(sendIntent);
callback.onSuccess();
} catch (Exception e) {
callback.onFailure();
}
}
}

View File

@@ -0,0 +1,28 @@
package com.yunbao.share.receiver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import com.twitter.sdk.android.tweetcomposer.TweetUploadService;
import com.yunbao.common.utils.ToastUtil;
public class TwitterResultReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.i("分享log", "onReceive: "+intent.getAction());
if (TweetUploadService.UPLOAD_SUCCESS.equals(intent.getAction())) {
ToastUtil.show("推特分享成功");
// success
final Long tweetId = intent.getExtras().getLong(TweetUploadService.EXTRA_TWEET_ID);
} else if (TweetUploadService.UPLOAD_FAILURE.equals(intent.getAction())) {
// failure
ToastUtil.show("推特分享失败");
final Intent retryIntent = intent.getExtras().getParcelable(TweetUploadService.EXTRA_RETRY_INTENT);
} else if (TweetUploadService.TWEET_COMPOSE_CANCEL.equals(intent.getAction())) {
// cancel
ToastUtil.show("推特分享取消");
}
}
}

View File

@@ -0,0 +1,158 @@
package com.yunbao.share.ui;
import static android.content.Context.CLIPBOARD_SERVICE;
import android.app.Dialog;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.graphics.Color;
import android.graphics.LinearGradient;
import android.graphics.Shader;
import android.view.ViewTreeObserver;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.lxj.xpopup.XPopup;
import com.makeramen.roundedimageview.RoundedImageView;
import com.pdlive.shayu.R;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.dialog.AbsDialogPopupWindow;
import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.share.bean.ShareBuilder;
import com.yunbao.share.adapters.ShareAppAdapter;
import java.util.ArrayList;
import java.util.List;
public class InvitePopDialog extends AbsDialogPopupWindow {
private ShareAppAdapter adapter;
private RecyclerView list;
private RoundedImageView avatar;
private TextView info;
private TextView link;
private TextView title;
private List<ShareBuilder> data;
private String uid;
private String anchorId;
private String anchorName;
private String anchorAvatar;
private String url;
public InvitePopDialog(@NonNull Context context) {
super(context);
}
public InvitePopDialog setUid(String uid) {
this.uid = uid;
return this;
}
public InvitePopDialog setAnchorId(String anchorId) {
this.anchorId = anchorId;
return this;
}
public InvitePopDialog setAnchorName(String anchorName) {
this.anchorName = anchorName;
return this;
}
public InvitePopDialog setAnchorAvatar(String anchorAvatar) {
this.anchorAvatar = anchorAvatar;
return this;
}
@Override
public void buildDialog(XPopup.Builder builder) {
}
@Override
public int bindLayoutId() {
return R.layout.dialog_share;
}
@Override
protected void onCreate() {
super.onCreate();
findViewById(R.id.close).setOnClickListener(v -> dismiss());
((ImageView) findViewById(R.id.close)).setImageResource(R.mipmap.icon_invite_close);
findViewById(R.id.share_copy).setOnClickListener(v -> copyLink());
// findViewById(R.id.share_preview).setVisibility(GONE);
findViewById(R.id.share_dialog).setBackgroundResource(R.mipmap.bg_dialog_inviet);
title = findViewById(R.id.share_title);
list = findViewById(R.id.share_apps_list);
avatar = findViewById(R.id.share_avatar);
info = findViewById(R.id.share_info);
link = findViewById(R.id.share_link);
adapter = new ShareAppAdapter(getContext());
list.setLayoutManager(new GridLayoutManager(getContext(), 3));
list.setAdapter(adapter);
initData();
link.setText(url.substring(0, 40));
info.setText(R.string.dialog_invite_info);
avatar.setImageResource(R.mipmap.ic_launcher);
//title.setTextColor(getContext().getResources().getColorStateList(R.drawable.bg_invite_title));
title.setText(R.string.dialog_invite_title);
title.getViewTreeObserver().addOnGlobalLayoutListener(this::setTitleColor);
}
private void setTitleColor() {
int[] colors = {
Color.parseColor("#3377FF"),
Color.parseColor("#7F66FF"),
};
float[] position = {
0f,
1.0f
};
float height = title.getMeasuredHeight();
LinearGradient mLinearGradient = new LinearGradient(0, 0, 0, height, colors, position, Shader.TileMode.CLAMP);
title.getPaint().setShader(mLinearGradient);
title.invalidate();
}
private void initData() {
data = new ArrayList<>();
data.add(builder(ShareBuilder.APP_FACEBOOK));
data.add(builder(ShareBuilder.APP_LINE));
data.add(builder(ShareBuilder.APP_TWITTER));
data.add(builder(ShareBuilder.APP_WHATSAPP));
data.add(builder(ShareBuilder.APP_MESSENGER));
// data.add(builder(ShareBuilder.APP_INSTAGRAM));
adapter.setList(data);
}
private ShareBuilder builder(int type) {
ShareBuilder builder = ShareBuilder.builder(type);
builder.setText(WordUtil.getString(R.string.dialog_invite_info));
builder.setLink(url);
builder.setUid(uid);
builder.setAnchorId(anchorId);
builder.setAnchorName(anchorName);
builder.setAnchorAvatar(anchorAvatar);
return builder;
}
private void copyLink() {
ClipboardManager cm = (ClipboardManager) getContext().getSystemService(CLIPBOARD_SERVICE);
ClipData clipData = ClipData.newPlainText("text", info.getText() + "\n" + url);
cm.setPrimaryClip(clipData);
ToastUtil.show(WordUtil.getString(com.yunbao.common.R.string.copy_success));
}
public InvitePopDialog setUrl(String data) {
this.url = data + "&isGoogle=" + (CommonAppConfig.IS_GOOGLE_PLAY ? "1" : "0");
return this;
}
}

View File

@@ -0,0 +1,146 @@
package com.yunbao.share.ui;
import static android.content.Context.CLIPBOARD_SERVICE;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.lxj.xpopup.XPopup;
import com.makeramen.roundedimageview.RoundedImageView;
import com.pdlive.shayu.R;
import com.yunbao.common.dialog.AbsDialogPopupWindow;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.share.bean.ShareBuilder;
import com.yunbao.share.adapters.ShareAppAdapter;
import java.util.ArrayList;
import java.util.List;
public class SharePopDialog extends AbsDialogPopupWindow {
private ShareAppAdapter adapter;
private RecyclerView list;
private RoundedImageView avatar;
private TextView info;
private TextView link;
private List<ShareBuilder> data;
private String uid;
private String anchorId;
private String anchorName;
private String anchorAvatar;
private String shareLink;
public SharePopDialog(@NonNull Context context) {
super(context);
}
public SharePopDialog setUid(String uid) {
this.uid = uid;
return this;
}
public SharePopDialog setAnchorId(String anchorId) {
this.anchorId = anchorId;
return this;
}
public SharePopDialog setAnchorName(String anchorName) {
this.anchorName = anchorName;
return this;
}
public SharePopDialog setAnchorAvatar(String anchorAvatar) {
this.anchorAvatar = anchorAvatar;
return this;
}
public SharePopDialog setShareLink(String link) {
this.shareLink = link;
return this;
}
@Override
public void buildDialog(XPopup.Builder builder) {
}
@Override
public int bindLayoutId() {
return R.layout.dialog_share;
}
@Override
protected void onCreate() {
super.onCreate();
findViewById(R.id.close).setOnClickListener(v -> dismiss());
findViewById(R.id.share_copy).setOnClickListener(v -> copyLink());
list = findViewById(R.id.share_apps_list);
avatar = findViewById(R.id.share_avatar);
info = findViewById(R.id.share_info);
link = findViewById(R.id.share_link);
adapter = new ShareAppAdapter(getContext());
list.setLayoutManager(new GridLayoutManager(getContext(), 3));
list.setAdapter(adapter);
initData();
}
private void initData() {
data = new ArrayList<>();
data.add(builder(ShareBuilder.APP_FACEBOOK));
data.add(builder(ShareBuilder.APP_LINE));
data.add(builder(ShareBuilder.APP_TWITTER));
data.add(builder(ShareBuilder.APP_WHATSAPP));
data.add(builder(ShareBuilder.APP_MESSENGER));
//data.add(builder(ShareBuilder.APP_INSTAGRAM));
adapter.setList(data);
String url;
if (shareLink == null) {
url = ShareBuilder.createLiveShareLink(uid, anchorId, anchorName, anchorAvatar).substring(0, 40) + "...";
} else {
if (shareLink.length() > 40) {
url = shareLink.substring(0, 40) + "...";
} else {
url = shareLink;
}
}
link.setText(url);
info.setText(String.format(WordUtil.getString(R.string.dialog_share_info), StringUtil.isEmpty(anchorName) ? "" : anchorName));
ImgLoader.display(getContext(), anchorAvatar, avatar);
}
private ShareBuilder builder(int type) {
ShareBuilder builder = ShareBuilder.builder(type);
builder.setText(String.format(WordUtil.getString(R.string.dialog_share_info), StringUtil.isEmpty(anchorName) ? "" : anchorName));
builder.setUid(uid);
builder.setAnchorId(anchorId);
builder.setAnchorName(anchorName);
builder.setAnchorAvatar(anchorAvatar);
if (shareLink != null) {
builder.setLink(shareLink);
}
return builder;
}
private void copyLink() {
String url;
if (shareLink != null) {
url = shareLink;
} else {
url = ShareBuilder.createLiveShareLink(uid, anchorId, anchorName, anchorAvatar);
}
ClipboardManager cm = (ClipboardManager) getContext().getSystemService(CLIPBOARD_SERVICE);
ClipData clipData = ClipData.newPlainText("text",info.getText().toString()+"\n"+url);
cm.setPrimaryClip(clipData);
ToastUtil.show(WordUtil.getString(com.yunbao.common.R.string.copy_success));
}
}

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:width="189dp" android:height="42dp">
<shape android:shape="rectangle">
<gradient android:type="linear" android:useLevel="true" android:startColor="#ffffc621" android:endColor="#ffffae05" android:angle="135" />
<corners android:radius="21dp" />
</shape>
</item>
</selector>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:width="112dp" android:height="42dp">
<shape android:shape="rectangle">
<stroke android:width="1dp" android:color="#ffffffff" />
<gradient android:type="linear" android:useLevel="true" android:startColor="#3377FF" android:endColor="#7F66FF" android:angle="90" />
<corners android:topLeftRadius="22dp" android:topRightRadius="22dp" android:bottomLeftRadius="22dp" android:bottomRightRadius="22dp" />
</shape>
</item>
</selector>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<corners android:radius="15dp" />
<solid android:color="#ffffff" />
<stroke
android:width="1dp"
android:color="#EBEBEB" />
</shape>
</item>
</selector>

View File

@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:id="@+id/share_dialog"
android:layout_height="wrap_content"
android:background="@mipmap/bg_dialog_share">
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="16dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/share_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_weight="1"
android:text="@string/dialog_invite_title"
android:textColor="@drawable/bg_invite_title"
android:textSize="16sp"
android:textStyle="bold" />
<ImageView
android:id="@+id/close"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginEnd="16dp"
app:srcCompat="@mipmap/icon_dialog_charge_close" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/share_apps_list"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout2"
tools:itemCount="6"
tools:layoutManager="GridLayoutManager"
tools:listitem="@layout/item_share_app"
tools:spanCount="3" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:id="@+id/share_dialog"
android:layout_height="wrap_content"
android:background="@mipmap/bg_dialog_share">
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="16dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/share_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_weight="1"
android:text="@string/dialog_share_title"
android:textColor="#333333"
android:textSize="16sp"
android:textStyle="bold" />
<ImageView
android:id="@+id/close"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginEnd="16dp"
app:srcCompat="@mipmap/icon_share_close" />
</LinearLayout>
<include
android:id="@+id/share_preview"
layout="@layout/view_share_preview"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="14dp"
android:layout_marginEnd="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout2" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/share_apps_list"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/share_preview"
tools:itemCount="6"
tools:layoutManager="GridLayoutManager"
tools:listitem="@layout/item_share_app"
tools:spanCount="3" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/linearLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/share_app_icon"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_marginStart="35dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="35dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="@tools:sample/avatars" />
<TextView
android:id="@+id/share_app_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="12dp"
android:text="TextView"
android:textColor="#666666"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/share_app_icon" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_preview"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="2dp"
android:orientation="horizontal">
<com.makeramen.roundedimageview.RoundedImageView
android:id="@+id/share_avatar"
android:layout_width="40dp"
android:layout_height="40dp"
android:scaleType="centerCrop"
android:src="@drawable/m_chu_xia"
app:riv_oval="true" />
<TextView
android:id="@+id/share_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_weight="1"
android:text="@string/dialog_share_info"
android:textColor="#333333"
android:textSize="12sp" />
<TextView
android:id="@+id/share_copy"
android:layout_width="70dp"
android:layout_height="32dp"
android:layout_gravity="center"
android:layout_marginEnd="16dp"
android:background="@drawable/bg_btn"
android:gravity="center"
android:layout_marginStart="25dp"
android:text="@string/dialog_share_copy"
android:textColor="@color/white"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/share_layout_link"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="12dp"
android:layout_marginBottom="12dp"
android:orientation="horizontal">
<ImageView
android:layout_width="16dp"
android:layout_height="16dp"
android:src="@mipmap/icon_share_url" />
<TextView
android:id="@+id/share_link"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="TextView"
android:textColor="#999999"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 548 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 484 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 955 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="dialog_share_title">Share</string>
<string name="dialog_share_info">Come and watch %s live on PDLIVE and meet more interesting people!</string>
<string name="dialog_invite_title">Invite Friends</string>
<string name="dialog_invite_info">Come to PDLIVE to discover more and better live streams.</string>
<string name="dialog_share_copy">Copy</string>
</resources>

View File

@@ -0,0 +1,17 @@
<resources>
<string name="com.twitter.sdk.android.CONSUMER_KEY" translatable="false">ZWRrZnRUNlBlcHVxMXpsMzVmb2k6MTpjaQ</string>
<string name="com.twitter.sdk.android.CONSUMER_SECRET" translatable="false">aq0eV4R1pqMK_AAeKRWnjPr7ErGMGgTPGgZJdm73WeRY-Kluws</string>
<string name="dialog_share_title">分享</string>
<string name="dialog_share_info">快來 PDLIVE觀看%s直播認識更多有趣的朋友吧</string>
<string name="dialog_share_app_facebook" translatable="false">Facebook</string>
<string name="dialog_share_app_line" translatable="false">Line</string>
<string name="dialog_share_app_twitter" translatable="false">Twitter</string>
<string name="dialog_share_app_whatsapp" translatable="false">WhatsApp</string>
<string name="dialog_share_app_messenger" translatable="false">Messenger</string>
<string name="dialog_share_app_instagram" translatable="false">Instagram</string>
<string name="dialog_invite_title">邀請好友</string>
<string name="dialog_invite_info">快來 PDLIVE觀看直播認識更多有趣的朋友吧</string>
<string name="dialog_share_copy">複製</string>
</resources>

View File

@@ -0,0 +1,17 @@
package com.yunbao.share;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}

View File

@@ -6,6 +6,8 @@
<uses-permission
android:name="android.permission.CALL_PHONE"
tools:node="remove" />
<uses-permission android:name="android.permission.CHANGE_CONFIGURATION"
tools:ignore="ProtectedPermissions" />
<uses-permission
android:name="android.permission.READ_LOGS"
tools:ignore="ProtectedPermissions"
@@ -92,6 +94,7 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:supportsRtl="true"
android:preserveLegacyExternalStorage="true"
android:requestLegacyExternalStorage="true"
android:theme="@style/AppTheme"

View File

@@ -13,6 +13,7 @@ import android.os.Looper;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import android.os.Process;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -39,8 +40,10 @@ import com.yunbao.common.manager.imrongcloud.InstructorSendRewardProvider;
import com.yunbao.common.manager.imrongcloud.MessageIMManager;
import com.yunbao.common.manager.imrongcloud.RecommendLiveRoom;
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
import com.yunbao.common.utils.AppManager;
import com.yunbao.common.utils.L;
import com.yunbao.common.utils.SpUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.live.socket.SocketRyClient;
import com.yunbao.live.utils.LiveImDeletUtil;
import com.yunbao.live.views.PortraitLiveManager;
@@ -104,12 +107,14 @@ public class AppContext extends CommonAppContext {
return;
}
}
AppManager.getInstance().removeActivity(activity);
}
@Override
public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle savedInstanceState) {
activities.add(new WeakReference<>(activity));
CrashSaveBean.getInstance().setActivitySize(activities);
AppManager.getInstance().addActivity(activity);
}
@Override
@@ -125,6 +130,12 @@ public class AppContext extends CommonAppContext {
if (!isMainProcess()) {
return;
}
AppManager.runDebugCode(new Runnable() {
@Override
public void run() {
ToastUtil.show("Debug代码");
}
});
CrashSaveBean.getInstance().setStartTime(System.currentTimeMillis());
//注册全局异常捕获
registerError();
@@ -277,18 +288,21 @@ public class AppContext extends CommonAppContext {
.setMainCrashHandler((t, e) -> {
Log.e("ApplicationError", "主线程异常");//此处log只是展示当debug为true时主类内部log会打印异常信息
e.printStackTrace();
//闪退后finish所有Activity并且杀死进程
/* for (WeakReference<Activity> activity : activities) {
if (activity != null && activity.get() != null) {
activity.get().finish();
AppManager.runDebugCode(()->{
//闪退后finish所有Activity并且杀死进程
for (WeakReference<Activity> activity : activities) {
if (activity != null && activity.get() != null) {
activity.get().finish();
}
}
}
*//* Process.killProcess(Process.myPid());
System.exit(0);*//*
setFirebaseCrashData();
new Handler(Looper.getMainLooper()).postDelayed(() -> {
throw new RuntimeException(e);
}, 100);*/
Process.killProcess(Process.myPid());
System.exit(0);
setFirebaseCrashData();
new Handler(Looper.getMainLooper()).postDelayed(() -> {
throw new RuntimeException(e);
}, 100);
});
})
.setUncaughtCrashHandler((t, e) -> {
Log.e("ApplicationError", "子线程异常");//此处log只是展示当debug为true时主类内部log会打印异常信息

View File

@@ -8,7 +8,9 @@ import android.os.Looper;
import android.util.Log;
import android.widget.Toast;
import com.yunbao.common.BuildConfig;
import com.yunbao.common.bean.CrashSaveBean;
import com.yunbao.common.utils.AppManager;
import com.yunbao.common.utils.FileUtil;
import com.yunbao.common.utils.SpUtil;
@@ -90,10 +92,12 @@ public class NeverCrashUtils {
*
* @param application application
*/
private boolean errorWhile = true;
public void register(Application application) {
//主线程异常拦截
new Handler(Looper.getMainLooper()).post(() -> {
while (true) {
while (errorWhile) {
try {
Looper.loop();
} catch (Throwable e) {
@@ -101,10 +105,12 @@ public class NeverCrashUtils {
Log.e(TAG, "未捕获的主线程异常行为", e);
}
e.printStackTrace();
//Toast.makeText(application, "发生闪退:"+e.getMessage(), Toast.LENGTH_SHORT).show();
AppManager.runDebugCode(() -> Toast.makeText(application, "发生闪退:" + e.getMessage(), Toast.LENGTH_SHORT).show());
FileUtil.saveStringToFile(new File(application.getDir("files", Context.MODE_PRIVATE).getAbsolutePath()), throwableToString(e), "error.log");
getMainCrashHandler().mainException(Looper.getMainLooper().getThread(), e);
// return;
AppManager.runDebugCode(() -> errorWhile = false);
// return;
}
}
});
@@ -139,11 +145,11 @@ public class NeverCrashUtils {
writer.write("PhoneName=" + Build.BRAND + "\n");
writer.write("Phone=" + Build.MODEL + "\n");
writer.write("CPU=" + Arrays.toString(Build.SUPPORTED_ABIS) + "\n");
writer.write("runTime=" + (System.currentTimeMillis() - CrashSaveBean.getInstance().getStartTime())+ "\n");
writer.write("enterRoom=" + CrashSaveBean.getInstance().getEnterRoom()+ "\n");
writer.write("slidingRoom=" + CrashSaveBean.getInstance().getSlidingRoom()+ "\n");
writer.write("playSvga=" + CrashSaveBean.getInstance().getPlaySvga()+ "\n");
writer.write("ActivitySize=" + CrashSaveBean.getInstance().getActivitySize()+ "\n");
writer.write("runTime=" + (System.currentTimeMillis() - CrashSaveBean.getInstance().getStartTime()) + "\n");
writer.write("enterRoom=" + CrashSaveBean.getInstance().getEnterRoom() + "\n");
writer.write("slidingRoom=" + CrashSaveBean.getInstance().getSlidingRoom() + "\n");
writer.write("playSvga=" + CrashSaveBean.getInstance().getPlaySvga() + "\n");
writer.write("ActivitySize=" + CrashSaveBean.getInstance().getActivitySize() + "\n");
writer.write("UserData=" + SpUtil.getInstance().getStringValue(SpUtil.USER_INFO) + "\n");
writer.write("[ERROR]");
PrintWriter printWriter = new PrintWriter(writer);

View File

@@ -162,8 +162,8 @@ dependencies {
api 'cn.rongcloud.sdk:im_kit:5.2.5.4' // 即时通讯 UI 基础组件
//融云小视频模块
api 'cn.rongcloud.sdk:sight:5.2.5.4'
api 'com.facebook.android:facebook-android-sdk:15.0.1'
implementation 'com.facebook.android:facebook-android-sdk:15.0.1'
api 'com.facebook.android:facebook-android-sdk:15.2.0'
implementation 'com.facebook.android:facebook-android-sdk:15.2.0'
api('com.twitter.sdk.android:twitter-core:3.1.1@aar') {
transitive = true
@@ -190,4 +190,5 @@ dependencies {
api 'com.github.li-xiaojun:XPopup:2.9.1'
api 'com.github.shenbengit:PagerGridLayoutManager:1.1.7'
}

View File

@@ -74,10 +74,12 @@ public class CommonAppContext extends MultiDexApplication {
} else {
locale = getResources().getConfiguration().locale;
}
if (locale.getLanguage().equals("en")) {
lang = "english";
} else {
if (locale.getLanguage().equals("zh")) {
lang = "chinese";
} else {
lang = "english";
}
Log.i("lang", lang);

View File

@@ -76,7 +76,7 @@ public class Constants {
public static final String PAY_BUY_COIN_ALI = "Charge.getAliOrder";
public static final String PAY_BUY_COIN_WX = "Charge.getWxOrder";
// public static final String PACKAGE_NAME_ALI = "com.eg.android.AlipayGphone";//支付宝的包名
// public static final String PACKAGE_NAME_ALI = "com.eg.android.AlipayGphone";//支付宝的包名
public static final String PACKAGE_NAME_WX = "com.tencent.mm";//微信的包名
public static final String PACKAGE_NAME_QQ = "com.tencent.mobileqq";//QQ的包名
public static final String LAT = "lat";
@@ -133,7 +133,7 @@ public class Constants {
public static final int LIVE_FUNC_WKS = 2014;//語音
public static final int LIVE_FUNC_ZSLK = 2015;//語音
public static final int LIVE_FUNC_RANDOM_PK = 2016;//随机PK
public static final int LIVE_ROBOT= 2017;//机器人
public static final int LIVE_ROBOT = 2017;//机器人
//socket
public static final String SOCKET_CONN = "conn";
@@ -177,6 +177,8 @@ public class Constants {
public static final String SUPER_VISION = "supervision";//超级发言警告
public static final String PK_RANK_UPDATE = "RankingRankUpdate";//PK排位赛更新数据
public static final String CUSTOM_FULL_SERVICE_NOTIFY = "customFullServiceNotify";//全服通知
public static final String XYD_COMPLETE = "XydComplete";//心愿单完成通知
public static final String WISH_LIST_PROGRESS = "wishListProgress";//心愿单进度通知
//游戏socket
public static final String SOCKET_GAME_ZJH = "startGame";//炸金花

View File

@@ -27,6 +27,7 @@ import com.yunbao.common.Constants;
import com.yunbao.common.R;
import com.yunbao.common.event.JavascriptInterfaceEvent;
import com.yunbao.common.utils.AndroidBug5497Workaround;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.DeviceUtils;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.JavascriptInterfaceUtils;
@@ -63,6 +64,7 @@ public class WebViewActivity extends AbsActivity {
protected void main() {
String url = getIntent().getStringExtra(Constants.URL);
L.e("H5--->" + url);
Bus.getOn(this);
LinearLayout rootView = (LinearLayout) findViewById(R.id.rootView);
mProgressBar = (ProgressBar) findViewById(R.id.progressbar);
btnEdit = (ImageView) findViewById(R.id.btn_edit);
@@ -254,6 +256,7 @@ public class WebViewActivity extends AbsActivity {
Constants.myIntoIndex = 0;
indexInto = 0;
Constants.LoginKefu = true;
Bus.getOff(this);
super.onDestroy();
}
@@ -309,5 +312,16 @@ public class WebViewActivity extends AbsActivity {
@Subscribe(threadMode = ThreadMode.MAIN)
public void onJavascriptInterfaceEvent(JavascriptInterfaceEvent event) {
indexInto = event.getIndexInto();
if (event.getMethod().equals("androidInviteShare")) {
try {
Class<?> clz = mContext.getClassLoader().loadClass("com.yunbao.share.ui.InvitePopDialog");
Object invite = clz.getConstructor(Context.class).newInstance(mContext);
invite = invite.getClass().getMethod("setUrl", String.class).invoke(invite, event.getData());
assert invite != null;
invite.getClass().getMethod("showDialog").invoke(invite);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
}

View File

@@ -0,0 +1,164 @@
package com.yunbao.common.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.WishModel;
import com.yunbao.common.event.LiveNewWishListCloseEvent;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.views.DayWishItemViewHolder;
import com.yunbao.common.views.LunarWishItemViewHolder;
import com.yunbao.common.views.SeasonalWishItemViewHolder;
import com.yunbao.common.views.WeekWishItemViewHolder;
import java.util.ArrayList;
import java.util.List;
public class LiveNewWishAdapter extends RecyclerView.Adapter {
private int type = 0;
private List<WishModel> wishList = new ArrayList<>();
public void addData(List<WishModel> wishModelList, int type) {
this.type = type;
wishList.clear();
wishList.addAll(wishModelList);
wishList.add(null);
notifyDataSetChanged();
}
public void addGiftListModel(WishModel model) {
switch (type) {
case 1:
Bus.get().post(new LiveNewWishListCloseEvent().setDayWish(true));
break;
case 2:
Bus.get().post(new LiveNewWishListCloseEvent().setZhouXin(true));
break;
case 3:
Bus.get().post(new LiveNewWishListCloseEvent().setLunarWish(true));
break;
case 4:
Bus.get().post(new LiveNewWishListCloseEvent().setSeasonalWish(true));
break;
}
wishList.add(0, model);
notifyDataSetChanged();
}
public List<WishModel> getWishList() {
return wishList;
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
if (type == 1) {
View dayWish = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_day_wish, parent, false);
return new DayWishItemViewHolder(dayWish);
} else if (type == 2) {
View weekWish = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_week_wish, parent, false);
return new WeekWishItemViewHolder(weekWish);
} else if (type == 3) {
View lunarWish = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_lunar_wish, parent, false);
return new LunarWishItemViewHolder(lunarWish);
} else {
View seasonalWish = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_seasonal_wish, parent, false);
return new SeasonalWishItemViewHolder(seasonalWish);
}
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (position == wishList.size()) return;
if (holder instanceof DayWishItemViewHolder) {
DayWishItemViewHolder dayWishItemViewHolder = (DayWishItemViewHolder) holder;
dayWishItemViewHolder.steDayWishData(wishList.get(position), position, new DayWishItemViewHolder.DayWishItemListener() {
@Override
public void onDelete(int index) {
Bus.get().post(new LiveNewWishListCloseEvent().setDayWish(true));
wishList.remove(index);
notifyDataSetChanged();
}
@Override
public void onUpdate(WishModel model, int index) {
Bus.get().post(new LiveNewWishListCloseEvent().setDayWish(true));
wishList.remove(index);
wishList.add(index, model);
notifyItemChanged(index);
}
});
} else if (holder instanceof WeekWishItemViewHolder) {
WeekWishItemViewHolder weekWishItemViewHolder = (WeekWishItemViewHolder) holder;
weekWishItemViewHolder.steWeekWishData(wishList.get(position), position, new WeekWishItemViewHolder.WeekWishItemListener() {
@Override
public void onDelete(int index) {
Bus.get().post(new LiveNewWishListCloseEvent().setZhouXin(true));
wishList.remove(index);
notifyDataSetChanged();
}
@Override
public void onUpdate(WishModel model, int index) {
Bus.get().post(new LiveNewWishListCloseEvent().setZhouXin(true));
wishList.remove(index);
wishList.add(index, model);
notifyItemChanged(index);
}
});
} else if (holder instanceof LunarWishItemViewHolder) {
LunarWishItemViewHolder lunarWishItemViewHolder = (LunarWishItemViewHolder) holder;
lunarWishItemViewHolder.steLunarWishData(wishList.get(position), position, new LunarWishItemViewHolder.LunarWishItemListener() {
@Override
public void onDelete(int index) {
Bus.get().post(new LiveNewWishListCloseEvent().setLunarWish(true));
wishList.remove(index);
notifyDataSetChanged();
}
@Override
public void onUpdate(WishModel model, int index) {
Bus.get().post(new LiveNewWishListCloseEvent().setLunarWish(true));
wishList.remove(index);
wishList.add(index, model);
notifyItemChanged(index);
}
});
} else if (holder instanceof SeasonalWishItemViewHolder) {
SeasonalWishItemViewHolder seasonalWishItemViewHolder = (SeasonalWishItemViewHolder) holder;
seasonalWishItemViewHolder.steSeasonalWish(wishList.get(position), position, new SeasonalWishItemViewHolder.SeasonalWishItemListener() {
@Override
public void onDelete(int index) {
Bus.get().post(new LiveNewWishListCloseEvent().setSeasonalWish(true));
wishList.remove(index);
notifyDataSetChanged();
}
@Override
public void onUpdate(WishModel model, int index) {
Bus.get().post(new LiveNewWishListCloseEvent().setSeasonalWish(true));
wishList.remove(index);
wishList.add(index, model);
notifyItemChanged(index);
}
});
}
}
@Override
public int getItemCount() {
return wishList.size();
}
}

View File

@@ -0,0 +1,56 @@
package com.yunbao.common.adapter;
import android.annotation.SuppressLint;
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.GiftListModel;
import com.yunbao.common.event.LiveNewWishGiftEvent;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.views.LiveNewWishGiftViewHolder;
import com.yunbao.common.views.weight.ViewClicksAntiShake;
import java.util.ArrayList;
import java.util.List;
public class LiveNewWishGiftAdapter extends RecyclerView.Adapter {
private List<GiftListModel> giftListModels = new ArrayList<>();
public LiveNewWishGiftAdapter(List<GiftListModel> giftListModels) {
this.giftListModels = giftListModels;
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View dayWish = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_gitf_wish, parent, false);
return new LiveNewWishGiftViewHolder(dayWish);
}
private int index = -1;
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, @SuppressLint("RecyclerView") int position) {
LiveNewWishGiftViewHolder wishGiftViewHolder = (LiveNewWishGiftViewHolder) holder;
wishGiftViewHolder.setData(giftListModels.get(position), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
index = position;
notifyDataSetChanged();
Bus.get().post(new LiveNewWishGiftEvent().setModel(giftListModels.get(position)));
}
});
wishGiftViewHolder.onSelect(index == position);
}
@Override
public int getItemCount() {
return giftListModels.size();
}
}

View File

@@ -0,0 +1,30 @@
package com.yunbao.common.adapter;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;
import java.util.ArrayList;
import java.util.List;
public class LiveNewWishListAdapter extends FragmentStateAdapter {
private List<Fragment> list = new ArrayList<>();
public LiveNewWishListAdapter(@NonNull FragmentActivity fragmentActivity, List<Fragment> list) {
super(fragmentActivity);
this.list = list;
}
@NonNull
@Override
public Fragment createFragment(int position) {
return list.get(position);
}
@Override
public int getItemCount() {
return list.size();
}
}

View File

@@ -1,6 +1,9 @@
package com.yunbao.common.bean;
import androidx.annotation.NonNull;
import com.alibaba.fastjson.annotation.JSONField;
import com.google.gson.annotations.SerializedName;
/**
* Created by cxf on 2019/3/30.
@@ -15,7 +18,81 @@ public class BannerBean {
private String mIntoUrl;
private int type;
private String name;
private int activityId=0;
private int activityId = 0;
private int mIconRes;
//心愿单展示数据
@SerializedName("wishlist_icon")
private String wishlistIcon;
@SerializedName("wishlist_num")
private String wishlistNum;
@SerializedName("wishlist_progress")
private String wishlistProgress;
@SerializedName("wishlist_name")
private String wishlistName;
private Object data;//用来存储任意bean
public String getmImageUrl() {
return mImageUrl;
}
public BannerBean setmImageUrl(String mImageUrl) {
this.mImageUrl = mImageUrl;
return this;
}
public String getmLink() {
return mLink;
}
public BannerBean setmLink(String mLink) {
this.mLink = mLink;
return this;
}
public int getmIconRes() {
return mIconRes;
}
public BannerBean setmIconRes(int mIconRes) {
this.mIconRes = mIconRes;
return this;
}
public String getWishlistIcon() {
return wishlistIcon;
}
public BannerBean setWishlistIcon(String wishlistIcon) {
this.wishlistIcon = wishlistIcon;
return this;
}
public String getWishlistNum() {
return wishlistNum;
}
public BannerBean setWishlistNum(String wishlistNum) {
this.wishlistNum = wishlistNum;
return this;
}
public String getWishlistProgress() {
return wishlistProgress;
}
public BannerBean setWishlistProgress(String wishlistProgress) {
this.wishlistProgress = wishlistProgress;
return this;
}
public String getWishlistName() {
return wishlistName;
}
public BannerBean setWishlistName(String wishlistName) {
this.wishlistName = wishlistName;
return this;
}
private StarChallengeStatusModel model;
@@ -79,27 +156,49 @@ public class BannerBean {
public int getType() {
return type;
}
@JSONField(name = "type")
public void setType(int type) {
this.type = type;
}
@JSONField(name = "name")
public String getName() {
return name;
}
@JSONField(name = "name")
public void setName(String name) {
this.name = name;
}
@JSONField(name = "active_id")
public int getActivityId() {
return activityId;
}
@JSONField(name = "active_id")
public void setActivityId(int activityId) {
this.activityId = activityId;
}
public int getIconRes() {
return mIconRes;
}
public void setIconRes(int mIconRes) {
this.mIconRes = mIconRes;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
@NonNull
@Override
public String toString() {
return "BannerBean{" +
@@ -110,6 +209,12 @@ public class BannerBean {
", mIntoUrl='" + mIntoUrl + '\'' +
", type=" + type +
", name='" + name + '\'' +
", activityId=" + activityId +
", mIconRes=" + mIconRes +
", wishlistIcon='" + wishlistIcon + '\'' +
", wishlistNum='" + wishlistNum + '\'' +
", wishlistProgress='" + wishlistProgress + '\'' +
", wishlistName='" + wishlistName + '\'' +
", model=" + model +
'}';
}

View File

@@ -0,0 +1,109 @@
package com.yunbao.common.bean;
import androidx.annotation.NonNull;
import com.google.gson.annotations.SerializedName;
/**
* 优惠卷
*/
public class DiscountsModel extends BaseModel {
//------------------贵族--------------------
public static final int TYPE_VISCOUNT=1;//子爵
public static final int TYPE_MARQUIS=2;//侯爵
public static final int TYPE_DUKE=3;//公爵
public static final int TYPE_KING=4;//国王
public static final int TYPE_EMPEROR=5;//皇帝
//------------------守护--------------------
public static final int TYPE_WEEKS=6;//周守护
public static final int TYPE_MONTH=7;//月守护
public static final int TYPE_YEARS=8;//月守护
@SerializedName("userCouponId")
private int userCouponID;
@SerializedName("num")
private int num;
@SerializedName("endTime")
private long endTime;
@SerializedName("img")
private String img;
@SerializedName("name")
private String name;
@SerializedName("discount")
private double discount;
@SerializedName("describe")
private String describe;
public DiscountsModel() {
}
public int getUserCouponID() {
return userCouponID;
}
public void setUserCouponID(int userCouponID) {
this.userCouponID = userCouponID;
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
public long getEndTime() {
return endTime;
}
public void setEndTime(long endTime) {
this.endTime = endTime;
}
public String getImg() {
return img;
}
public void setImg(String img) {
this.img = img;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getDiscount() {
return discount;
}
public void setDiscount(double discount) {
this.discount = discount;
}
public String getDescribe() {
return describe;
}
public void setDescribe(String describe) {
this.describe = describe;
}
@NonNull
@Override
public String toString() {
return "DiscountsModel{" +
"userCouponID=" + userCouponID +
", num=" + num +
", endTime=" + endTime +
", img='" + img + '\'' +
", name='" + name + '\'' +
", discount=" + discount +
", describe='" + describe + '\'' +
'}';
}
}

View File

@@ -30,6 +30,17 @@ public class EnterRoomNewModel extends BaseModel {
private List<LiveRoomActivityModel> liveRoomActivityModels = new ArrayList<>();//活动列表
@SerializedName("clarityType")
private int clarityType;
@SerializedName("wishListProgress")
private WishModel wishListProgress;
public WishModel getWishListProgress() {
return wishListProgress;
}
public EnterRoomNewModel setWishListProgress(WishModel wishListProgress) {
this.wishListProgress = wishListProgress;
return this;
}
public List<LiveRoomActivityModel> getLiveRoomActivityModels() {
return liveRoomActivityModels;

View File

@@ -0,0 +1,72 @@
package com.yunbao.common.bean;
import com.google.gson.annotations.SerializedName;
public class GiftListModel extends BaseModel {
@SerializedName("name")
private String name;
@SerializedName("price")
private String price;
@SerializedName("img")
private String img;
@SerializedName("id")
private String id;
@SerializedName("gift_type")
private String giftType;
public String getName() {
return name;
}
public GiftListModel setName(String name) {
this.name = name;
return this;
}
public String getPrice() {
return price;
}
public GiftListModel setPrice(String price) {
this.price = price;
return this;
}
public String getImg() {
return img;
}
public GiftListModel setImg(String img) {
this.img = img;
return this;
}
public String getId() {
return id;
}
public GiftListModel setId(String id) {
this.id = id;
return this;
}
public String getGiftType() {
return giftType;
}
public GiftListModel setGiftType(String giftType) {
this.giftType = giftType;
return this;
}
@Override
public String toString() {
return "GiftListModel{" +
"name='" + name + '\'' +
", price='" + price + '\'' +
", img='" + img + '\'' +
", id='" + id + '\'' +
", giftType='" + giftType + '\'' +
'}';
}
}

View File

@@ -28,4 +28,12 @@ public class HttpCallbackModel extends BaseModel {
public void setMsg(String msg) {
this.msg = msg;
}
@Override
public String toString() {
return "HttpCallbackModel{" +
"code=" + code +
", msg='" + msg + '\'' +
'}';
}
}

View File

@@ -0,0 +1,184 @@
package com.yunbao.common.bean;
import androidx.annotation.NonNull;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.annotations.SerializedName;
/**
* 联系方式
*/
public class LiveAnchorCallMeModel extends BaseModel {
@SerializedName("id")
private int id;
@SerializedName("isShow")
private int isShow;
@SerializedName("gift_id")
private int giftId;
@SerializedName("giftImage")
private String giftImage;
@SerializedName("content")
private String content;
@SerializedName("wechat")
private AppBean wechat;
@SerializedName("line")
private AppBean line;
@SerializedName("whatsApp")
private AppBean whatsApp;
@SerializedName("isGet")
private int isGet;
@SerializedName("link")
private String link;
public LiveAnchorCallMeModel() {
}
public int getIsGet() {
return isGet;
}
public void setIsGet(int isGet) {
this.isGet = isGet;
}
public String getLink() {
return link;
}
public void setLink(String link) {
this.link = link;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getGiftImage() {
return giftImage;
}
public void setGiftImage(String giftImage) {
this.giftImage = giftImage;
}
public int getIsShow() {
return isShow;
}
public void setIsShow(int isShow) {
this.isShow = isShow;
}
public int getGiftId() {
return giftId;
}
public void setGiftId(int giftId) {
this.giftId = giftId;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public AppBean getWechat() {
if (wechat == null) {
wechat = new AppBean();
}
return wechat;
}
public void setWechat(AppBean wechat) {
this.wechat = wechat;
}
public AppBean getLine() {
if (line == null) {
line = new AppBean();
}
return line;
}
public void setLine(AppBean line) {
this.line = line;
}
public AppBean getWhatsApp() {
if (whatsApp == null) {
whatsApp = new AppBean();
}
return whatsApp;
}
public void setWhatsApp(AppBean whatsApp) {
this.whatsApp = whatsApp;
}
@Override
public String toString() {
return "LiveAnchorCallMeModel{" +
"id=" + id +
", isShow=" + isShow +
", giftId=" + giftId +
", giftImage='" + giftImage + '\'' +
", content='" + content + '\'' +
", wechat=" + wechat +
", line=" + line +
", whatsApp=" + whatsApp +
", isGet=" + isGet +
", link='" + link + '\'' +
'}';
}
public static class AppBean {
private String number;
private int isShow;
public AppBean() {
}
public AppBean(String number, int isShow) {
this.number = number;
this.isShow = isShow;
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
public int getIsShow() {
return isShow;
}
public void setIsShow(int isShow) {
this.isShow = isShow;
}
@NonNull
@Override
public String toString() {
return "AppBean{" +
"number='" + number + '\'' +
", isShow=" + isShow +
'}';
}
public JSONObject toJSONObject() {
return (JSONObject) JSON.toJSON(this);
}
}
}

View File

@@ -0,0 +1,80 @@
package com.yunbao.common.bean;
import com.google.gson.annotations.SerializedName;
import java.util.List;
public class LiveAnchorSayModel extends BaseModel{
@SerializedName("livePreview")
private LivePreview livePreview;
@SerializedName("style")
private List<String> style;
public LiveAnchorSayModel() {
}
public LivePreview getLivePreview() {
return livePreview;
}
public void setLivePreview(LivePreview livePreview) {
this.livePreview = livePreview;
}
public List<String> getStyle() {
return style;
}
public void setStyle(List<String> style) {
this.style = style;
}
public class LivePreview{
private int isShow;
private String content;
private String styleImage;
public LivePreview() {
}
public int getIsShow() {
return isShow;
}
public void setIsShow(int isShow) {
this.isShow = isShow;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getStyleImage() {
return styleImage;
}
public void setStyleImage(String styleImage) {
this.styleImage = styleImage;
}
@Override
public String toString() {
return "LivePreview{" +
"isShow=" + isShow +
", content='" + content + '\'' +
", styleImage='" + styleImage + '\'' +
'}';
}
}
@Override
public String toString() {
return "LiveAnchorSayModel{" +
"livePreview=" + livePreview +
", style=" + style +
'}';
}
}

View File

@@ -0,0 +1,155 @@
package com.yunbao.common.bean;
import androidx.annotation.NonNull;
import com.google.gson.annotations.SerializedName;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.utils.StringUtil;
public class LiveUserMailBoxModel extends BaseModel {
@SerializedName("id")
private int id;
@SerializedName("uid")
private int uid;
@SerializedName("liveuid")
private int liveUid;
@SerializedName("is_read")
private int isRead;
@SerializedName("content")
private String content;
@SerializedName("create_time")
private String createTime;
@SerializedName("gift_id")
private int giftId;
@SerializedName("userName")
private String userName;
@SerializedName("anchorName")
private String anchorName;
@SerializedName("url")
private String url;
public LiveUserMailBoxModel() {
}
public LiveUserMailBoxModel(int id, int uid, int liveUid, String content, String createTime, int giftId, String userName, String anchorName) {
this.id = id;
this.uid = uid;
this.liveUid = liveUid;
this.content = content;
this.createTime = createTime;
this.giftId = giftId;
this.userName = userName;
this.anchorName = anchorName;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getUid() {
return uid;
}
public void setUid(int uid) {
this.uid = uid;
}
public int getLiveUid() {
return liveUid;
}
public void setLiveUid(int liveUid) {
this.liveUid = liveUid;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
public int getGiftId() {
return giftId;
}
public void setGiftId(int giftId) {
this.giftId = giftId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getAnchorName() {
return anchorName;
}
public void setAnchorName(String anchorName) {
this.anchorName = anchorName;
}
public int getIsRead() {
return isRead;
}
public void setIsRead(int isRead) {
this.isRead = isRead;
}
public String getUrl() {
if (StringUtil.isEmpty(url)) {
url = "http://www.baidu.com";
} else {
if (!url.startsWith("http")) {
url = CommonAppConfig.HOST + "/" + url;
}
if (url.contains("?")) {
url += "&";
} else {
url += "?";
}
url += "uid=" + CommonAppConfig.getInstance().getUid() + "&token="
+ CommonAppConfig.getInstance().getToken();
}
return url;
}
public void setUrl(String url) {
this.url = url;
}
@NonNull
@Override
public String toString() {
return "LiveUserMailBoxModel{" +
"id=" + id +
", uid=" + uid +
", liveUid=" + liveUid +
", isRead=" + isRead +
", content='" + content + '\'' +
", createTime='" + createTime + '\'' +
", giftId=" + giftId +
", userName='" + userName + '\'' +
", anchorName='" + anchorName + '\'' +
", url='" + url + '\'' +
'}';
}
}

View File

@@ -2,6 +2,7 @@ package com.yunbao.common.bean;
import android.text.TextUtils;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
/**
@@ -17,6 +18,17 @@ public class NewLevelModel extends BaseModel {
private String levemax;
@SerializedName("thumb")
private String thumb;
@SerializedName("icon")
private String icon;
@SerializedName("colour")
private String colour;
@SerializedName("live_icon")
private String liveIcon = "https://downs.yaoulive.com/level1/img_1-9.png";
public static NewLevelModel objectFromData(String str) {
return new Gson().fromJson(str, NewLevelModel.class);
}
public String getId() {
return id;
@@ -67,4 +79,28 @@ public class NewLevelModel extends BaseModel {
this.thumb = thumb;
return this;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
public String getColour() {
return colour;
}
public void setColour(String colour) {
this.colour = colour;
}
public String getLiveIcon() {
return liveIcon;
}
public void setLiveIcon(String liveIcon) {
this.liveIcon = liveIcon;
}
}

View File

@@ -0,0 +1,16 @@
package com.yunbao.common.bean;
public class UserAreaBean extends BaseModel {
private String area;
public UserAreaBean() {
}
public String getArea() {
return area;
}
public void setArea(String area) {
this.area = area;
}
}

View File

@@ -0,0 +1,46 @@
package com.yunbao.common.bean;
import com.google.gson.annotations.SerializedName;
import java.util.ArrayList;
import java.util.List;
/**
* 心愿单礼物配置
*/
public class WishListGiftConfModel extends BaseModel {
@SerializedName("giftList")
private List<GiftListModel> giftList = new ArrayList<>();
@SerializedName("guardList")
private List<GiftListModel> guardList = new ArrayList<>();
@SerializedName("nobleList")
private List<GiftListModel> nobleList = new ArrayList<>();
public List<GiftListModel> getGiftList() {
return giftList;
}
public WishListGiftConfModel setGiftList(List<GiftListModel> giftList) {
this.giftList = giftList;
return this;
}
public List<GiftListModel> getGuardList() {
return guardList;
}
public WishListGiftConfModel setGuardList(List<GiftListModel> guardList) {
this.guardList = guardList;
return this;
}
public List<GiftListModel> getNobleList() {
return nobleList;
}
public WishListGiftConfModel setNobleList(List<GiftListModel> nobleList) {
this.nobleList = nobleList;
return this;
}
}

View File

@@ -2,11 +2,12 @@ package com.yunbao.common.bean;
import com.google.gson.annotations.SerializedName;
import java.util.ArrayList;
import java.util.List;
public class WishListModel extends BaseModel {
@SerializedName("wishList")
private List<WishModel> wishList;
@SerializedName(value = "wishList",alternate = {"wishlist"})
private List<WishModel> wishList = new ArrayList<>();
@SerializedName("img")
private String img;

View File

@@ -0,0 +1,31 @@
package com.yunbao.common.bean;
import com.google.gson.annotations.SerializedName;
import java.util.List;
public class WishListModel2 extends BaseModel {
@SerializedName("wishlist")
private List<List<WishModel>> wishlist;
@SerializedName("img")
private String img;
public List<List<WishModel>> getWishlist() {
return wishlist;
}
public WishListModel2 setWishlist(List<List<WishModel>> wishlist) {
this.wishlist = wishlist;
return this;
}
public String getImg() {
return img;
}
public WishListModel2 setImg(String img) {
this.img = img;
return this;
}
}

View File

@@ -1,5 +1,6 @@
package com.yunbao.common.bean;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class WishModel extends BaseModel {
@@ -22,6 +23,23 @@ public class WishModel extends BaseModel {
private String wishlistName;
@SerializedName("create_time")
private String createTime;
@SerializedName("type")
private int type;
@SerializedName("gift_type")
private int giftType;
@SerializedName("price")
private int price;
@Expose(serialize = false)
private int isShow = -1;
public int getIsShow() {
return isShow;
}
public WishModel setIsShow(int isShow) {
this.isShow = isShow;
return this;
}
public String getId() {
return id;
@@ -103,4 +121,51 @@ public class WishModel extends BaseModel {
this.createTime = createTime;
return this;
}
public int getType() {
return type;
}
public WishModel setType(int type) {
this.type = type;
return this;
}
public int getGiftType() {
return giftType;
}
public WishModel setGiftType(int giftType) {
this.giftType = giftType;
return this;
}
public int getPrice() {
return price;
}
public WishModel setPrice(int price) {
this.price = price;
return this;
}
public int wishProgress() {
int progress = 0;
try {
progress = Integer.parseInt(wishlistNum);
} catch (NumberFormatException e) {
progress = 0;
}
return progress;
}
public int wishCurrent() {
int current = 0;
try {
current = Integer.parseInt(wishlistProgress);
} catch (NumberFormatException e) {
current = 0;
}
return current;
}
}

View File

@@ -0,0 +1,160 @@
package com.yunbao.common.bean;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class WishModel2 extends BaseModel {
@SerializedName("id")
private String id;
@SerializedName("dtime")
private String dtime;
@SerializedName("luid")
private String luid;
@SerializedName("lid")
private String lid;
@SerializedName("wishlist_icon")
private String wishlistIcon;
@SerializedName("wishlist_num")
private String wishlistNum;
@SerializedName("wishlist_progress")
private String wishlistProgress;
@SerializedName("wishlist_name")
private String wishlistName;
@SerializedName("create_time")
private String createTime;
@SerializedName("type")
private int type;
@SerializedName("gift_type")
private int giftType;
@SerializedName("price")
private int price;
public String getId() {
return id;
}
public WishModel2 setId(String id) {
this.id = id;
return this;
}
public String getDtime() {
return dtime;
}
public WishModel2 setDtime(String dtime) {
this.dtime = dtime;
return this;
}
public String getLuid() {
return luid;
}
public WishModel2 setLuid(String luid) {
this.luid = luid;
return this;
}
public String getLid() {
return lid;
}
public WishModel2 setLid(String lid) {
this.lid = lid;
return this;
}
public String getWishlistIcon() {
return wishlistIcon;
}
public WishModel2 setWishlistIcon(String wishlistIcon) {
this.wishlistIcon = wishlistIcon;
return this;
}
public String getWishlistNum() {
return wishlistNum;
}
public WishModel2 setWishlistNum(String wishlistNum) {
this.wishlistNum = wishlistNum;
return this;
}
public String getWishlistProgress() {
return wishlistProgress;
}
public WishModel2 setWishlistProgress(String wishlistProgress) {
this.wishlistProgress = wishlistProgress;
return this;
}
public String getWishlistName() {
return wishlistName;
}
public WishModel2 setWishlistName(String wishlistName) {
this.wishlistName = wishlistName;
return this;
}
public String getCreateTime() {
return createTime;
}
public WishModel2 setCreateTime(String createTime) {
this.createTime = createTime;
return this;
}
public int getType() {
return type;
}
public WishModel2 setType(int type) {
this.type = type;
return this;
}
public int getGiftType() {
return giftType;
}
public WishModel2 setGiftType(int giftType) {
this.giftType = giftType;
return this;
}
public int getPrice() {
return price;
}
public WishModel2 setPrice(int price) {
this.price = price;
return this;
}
public int wishProgress() {
int progress = 0;
try {
progress = Integer.parseInt(wishlistNum);
} catch (NumberFormatException e) {
progress = 0;
}
return progress;
}
public int wishCurrent() {
int current = 0;
try {
current = Integer.parseInt(wishlistProgress);
} catch (NumberFormatException e) {
current = 0;
}
return current;
}
}

View File

@@ -0,0 +1,338 @@
package com.yunbao.common.bean;
import com.google.gson.annotations.SerializedName;
public class XydCompleteModel extends BaseModel {
@SerializedName("_method_")
private String method;
@SerializedName("action")
private String action;
@SerializedName("msgtype")
private String msgtype;
@SerializedName("level")
private int level;
@SerializedName("uname")
private String uname;
@SerializedName("uid")
private String uid;
@SerializedName("uhead")
private String uhead;
@SerializedName("evensend")
private String evensend;
@SerializedName("liangname")
private String liangname;
@SerializedName("vip_type")
private String vipType;
@SerializedName("svg")
private String svg;
@SerializedName("ancherName")
private String ancherName;
@SerializedName("userName")
private String userName;
@SerializedName("medal_name")
private String medalName;
@SerializedName("medal_level")
private String medalLevel;
@SerializedName("guard_type")
private String guardType;
@SerializedName("medal")
private String medal;
@SerializedName("medal_honor")
private String medalHonor;
@SerializedName("good_num")
private int goodNum;
@SerializedName("roomnum")
private String roomnum;
@SerializedName("msg")
private String msg;
@SerializedName("liveId")
private String liveId;
@SerializedName("swf")
private String swf;
@SerializedName("swftime")
private String swftime;
@SerializedName("swftype")
private int swftype;
@SerializedName("type")
private int type;
@SerializedName("giftname")
private String giftname;
@SerializedName("equipment")
private String equipment;
@SerializedName("bubble")
private String bubble;
@SerializedName("xydgiftname")
private String xydgiftname;
public String getXydgiftname() {
return xydgiftname;
}
public XydCompleteModel setXydgiftname(String xydgiftname) {
this.xydgiftname = xydgiftname;
return this;
}
public String getMethod() {
return method;
}
public XydCompleteModel setMethod(String method) {
this.method = method;
return this;
}
public String getAction() {
return action;
}
public XydCompleteModel setAction(String action) {
this.action = action;
return this;
}
public String getMsgtype() {
return msgtype;
}
public XydCompleteModel setMsgtype(String msgtype) {
this.msgtype = msgtype;
return this;
}
public int getLevel() {
return level;
}
public XydCompleteModel setLevel(int level) {
this.level = level;
return this;
}
public String getUname() {
return uname;
}
public XydCompleteModel setUname(String uname) {
this.uname = uname;
return this;
}
public String getUid() {
return uid;
}
public XydCompleteModel setUid(String uid) {
this.uid = uid;
return this;
}
public String getUhead() {
return uhead;
}
public XydCompleteModel setUhead(String uhead) {
this.uhead = uhead;
return this;
}
public String getEvensend() {
return evensend;
}
public XydCompleteModel setEvensend(String evensend) {
this.evensend = evensend;
return this;
}
public String getLiangname() {
return liangname;
}
public XydCompleteModel setLiangname(String liangname) {
this.liangname = liangname;
return this;
}
public String getVipType() {
return vipType;
}
public XydCompleteModel setVipType(String vipType) {
this.vipType = vipType;
return this;
}
public String getSvg() {
return svg;
}
public XydCompleteModel setSvg(String svg) {
this.svg = svg;
return this;
}
public String getAncherName() {
return ancherName;
}
public XydCompleteModel setAncherName(String ancherName) {
this.ancherName = ancherName;
return this;
}
public String getUserName() {
return userName;
}
public XydCompleteModel setUserName(String userName) {
this.userName = userName;
return this;
}
public String getMedalName() {
return medalName;
}
public XydCompleteModel setMedalName(String medalName) {
this.medalName = medalName;
return this;
}
public String getMedalLevel() {
return medalLevel;
}
public XydCompleteModel setMedalLevel(String medalLevel) {
this.medalLevel = medalLevel;
return this;
}
public String getGuardType() {
return guardType;
}
public XydCompleteModel setGuardType(String guardType) {
this.guardType = guardType;
return this;
}
public String getMedal() {
return medal;
}
public XydCompleteModel setMedal(String medal) {
this.medal = medal;
return this;
}
public String getMedalHonor() {
return medalHonor;
}
public XydCompleteModel setMedalHonor(String medalHonor) {
this.medalHonor = medalHonor;
return this;
}
public int getGoodNum() {
return goodNum;
}
public XydCompleteModel setGoodNum(int goodNum) {
this.goodNum = goodNum;
return this;
}
public String getRoomnum() {
return roomnum;
}
public XydCompleteModel setRoomnum(String roomnum) {
this.roomnum = roomnum;
return this;
}
public String getMsg() {
return msg;
}
public XydCompleteModel setMsg(String msg) {
this.msg = msg;
return this;
}
public String getLiveId() {
return liveId;
}
public XydCompleteModel setLiveId(String liveId) {
this.liveId = liveId;
return this;
}
public String getSwf() {
return swf;
}
public XydCompleteModel setSwf(String swf) {
this.swf = swf;
return this;
}
public String getSwftime() {
return swftime;
}
public XydCompleteModel setSwftime(String swftime) {
this.swftime = swftime;
return this;
}
public int getSwftype() {
return swftype;
}
public XydCompleteModel setSwftype(int swftype) {
this.swftype = swftype;
return this;
}
public int getType() {
return type;
}
public XydCompleteModel setType(int type) {
this.type = type;
return this;
}
public String getGiftname() {
return giftname;
}
public XydCompleteModel setGiftname(String giftname) {
this.giftname = giftname;
return this;
}
public String getEquipment() {
return equipment;
}
public XydCompleteModel setEquipment(String equipment) {
this.equipment = equipment;
return this;
}
public String getBubble() {
return bubble;
}
public XydCompleteModel setBubble(String bubble) {
this.bubble = bubble;
return this;
}
}

View File

@@ -27,6 +27,7 @@ public abstract class AbsDialogPopupWindow extends BottomPopupView {
public void showDialog() {
XPopup.Builder builder = new XPopup.Builder(mContext);
builder.isDestroyOnDismiss(true);
builder.enableDrag(false);
buildDialog(builder);
builder.asCustom(this).show();
}

View File

@@ -21,6 +21,30 @@ public class CustomDrawerPopupEvent extends BaseModel {
private boolean reportLayout = false;
//刷新
private boolean refresh = false;
//特效設置
private boolean effects = false;
//小窗播放
private boolean smallWindow = false;
//畫質選擇
private boolean qualitySelection = false;
public boolean isSmallWindow() {
return smallWindow;
}
public CustomDrawerPopupEvent setSmallWindow(boolean smallWindow) {
this.smallWindow = smallWindow;
return this;
}
public boolean isQualitySelection() {
return qualitySelection;
}
public CustomDrawerPopupEvent setQualitySelection(boolean qualitySelection) {
this.qualitySelection = qualitySelection;
return this;
}
public boolean isRefresh() {
return refresh;
@@ -102,4 +126,13 @@ public class CustomDrawerPopupEvent extends BaseModel {
isDisMiss = disMiss;
return this;
}
public boolean isEffects() {
return effects;
}
public CustomDrawerPopupEvent setEffects(boolean effects) {
this.effects = effects;
return this;
}
}

View File

@@ -0,0 +1,17 @@
package com.yunbao.common.event;
import com.yunbao.common.bean.BaseModel;
import com.yunbao.common.bean.GiftListModel;
public class LiveNewWishGiftEvent extends BaseModel {
private GiftListModel model;
public GiftListModel getModel() {
return model;
}
public LiveNewWishGiftEvent setModel(GiftListModel model) {
this.model = model;
return this;
}
}

View File

@@ -0,0 +1,46 @@
package com.yunbao.common.event;
import com.yunbao.common.bean.BaseModel;
public class LiveNewWishListCloseEvent extends BaseModel {
private boolean dayWish = false;
private boolean zhouXin = false;
private boolean lunarWish = false;
private boolean seasonalWish = false;
public boolean isDayWish() {
return dayWish;
}
public LiveNewWishListCloseEvent setDayWish(boolean dayWish) {
this.dayWish = dayWish;
return this;
}
public boolean isZhouXin() {
return zhouXin;
}
public LiveNewWishListCloseEvent setZhouXin(boolean zhouXin) {
this.zhouXin = zhouXin;
return this;
}
public boolean isLunarWish() {
return lunarWish;
}
public LiveNewWishListCloseEvent setLunarWish(boolean lunarWish) {
this.lunarWish = lunarWish;
return this;
}
public boolean isSeasonalWish() {
return seasonalWish;
}
public LiveNewWishListCloseEvent setSeasonalWish(boolean seasonalWish) {
this.seasonalWish = seasonalWish;
return this;
}
}

View File

@@ -0,0 +1,28 @@
package com.yunbao.common.event;
import com.yunbao.common.bean.BaseModel;
import com.yunbao.common.bean.GiftListModel;
public class LiveNewWishListEvent extends BaseModel {
private GiftListModel model;
private int type = 0;
public int getType() {
return type;
}
public LiveNewWishListEvent setType(int type) {
this.type = type;
return this;
}
public GiftListModel getModel() {
return model;
}
public LiveNewWishListEvent setModel(GiftListModel model) {
this.model = model;
return this;
}
}

View File

@@ -0,0 +1,6 @@
package com.yunbao.common.event;
import com.yunbao.common.bean.BaseModel;
public class PopupViewDismissEvent extends BaseModel {
}

View File

@@ -0,0 +1,136 @@
package com.yunbao.common.fragment;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.tabs.TabLayout;
import com.shencoder.pagergridlayoutmanager.PagerGridLayoutManager;
import com.yunbao.common.R;
import com.yunbao.common.adapter.LiveNewWishGiftAdapter;
import com.yunbao.common.bean.GiftListModel;
import com.yunbao.common.utils.DpUtil;
import java.io.Serializable;
import java.util.List;
public class LiveNewWishGiftFragment extends BaseFragment {
private List<GiftListModel> giftListModels;
private RecyclerView giftList;
private LiveNewWishGiftAdapter liveNewWishGiftAdapter;
private TabLayout wishTab;
@Override
public View createView(LayoutInflater inflater, ViewGroup container) {
return inflater.inflate(R.layout.view_live_new_wish_gitf, container, false);
}
@Override
protected void initVariables(Bundle bundle) {
giftListModels = (List<GiftListModel>) bundle.getSerializable("GiftList");
for (GiftListModel model : giftListModels) {
Log.e("LiveNewWishGiftFragment", model.getName());
}
//
}
@Override
protected void initViews(Bundle savedInstanceState, View contentView) {
wishTab = contentView.findViewById(R.id.wish_tab);
wishTab.setSelectedTabIndicatorColor(Color.TRANSPARENT);
wishTab.setFocusableInTouchMode(false);
//计算总页数
int pagerCount = giftListModels.size() / 8;
if (giftListModels.size() % 8 != 0) {
++pagerCount;
}
if (pagerCount > 1) {
for (int i = 0; i < pagerCount; i++) {
TextView wishItem = (TextView) LayoutInflater.from(getContext()).inflate(R.layout.view_tablaout_wish_item, null, false);
TabLayout.Tab tab = wishTab.newTab().setCustomView(wishItem).setId(i);
wishTab.addTab(tab, i == 0);
}
ViewGroup tabs = (ViewGroup) wishTab.getChildAt(0);
//设置边距,tab宽
for (int i = 0; i < tabs.getChildCount(); i++) {
View tab = tabs.getChildAt(i);
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) tab.getLayoutParams();
layoutParams.rightMargin = DpUtil.dp2px(5);
layoutParams.leftMargin = DpUtil.dp2px(5);
layoutParams.width = DpUtil.dp2px(6);
layoutParams.height = DpUtil.dp2px(6);
tab.setLayoutParams(layoutParams);
wishTab.requestLayout();
}
wishTab.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
View customView = tab.getCustomView();
customView.setSelected(true);
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
View customView = tab.getCustomView();
customView.setSelected(false);
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
} else {
wishTab.setVisibility(View.GONE);
}
giftList = contentView.findViewById(R.id.gift_list);
liveNewWishGiftAdapter = new LiveNewWishGiftAdapter(giftListModels);
PagerGridLayoutManager layoutManager = new PagerGridLayoutManager( /*rows*/2,
/*columns*/ 4,
/*PagerGridLayoutManager.VERTICAL*/PagerGridLayoutManager.HORIZONTAL,
/*reverseLayout*/ false);
layoutManager.setHandlingSlidingConflictsEnabled(true);
giftList.setLayoutManager(layoutManager);
giftList.setAdapter(liveNewWishGiftAdapter);
layoutManager.setPagerChangedListener(new PagerGridLayoutManager.PagerChangedListener() {
@Override
public void onPagerCountChanged(int pagerCount) {
Log.e("LiveNewWishGiftFragment", "onPagerCountChanged-pagerCount:" + pagerCount);
}
@Override
public void onPagerIndexSelected(int prePagerIndex, int currentPagerIndex) {
Log.e("LiveNewWishGiftFragment", "onPagerIndexSelected-prePagerIndex " + prePagerIndex + ",currentPagerIndex:" + currentPagerIndex);
if (wishTab.getVisibility() == View.VISIBLE)
wishTab.getTabAt(currentPagerIndex).select();
}
});
}
@Override
protected void loadData() {
}
public static LiveNewWishGiftFragment newInstance(List<GiftListModel> giftListModels) {
LiveNewWishGiftFragment searchRecommendFragment = new LiveNewWishGiftFragment();
Bundle bundle = new Bundle();
bundle.putSerializable("GiftList", (Serializable) giftListModels);
searchRecommendFragment.setArguments(bundle);
return searchRecommendFragment;
}
}

View File

@@ -0,0 +1,156 @@
package com.yunbao.common.fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.gson.Gson;
import com.lxj.xpopup.XPopup;
import com.yunbao.common.R;
import com.yunbao.common.adapter.LiveNewWishAdapter;
import com.yunbao.common.bean.WishListModel;
import com.yunbao.common.bean.WishModel;
import com.yunbao.common.bean.WishModel2;
import com.yunbao.common.event.LiveNewWishListCloseEvent;
import com.yunbao.common.event.PopupViewDismissEvent;
import com.yunbao.common.http.base.HttpCallback;
import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.views.LiveNewWishGiftPopup;
import com.yunbao.common.views.weight.ViewClicksAntiShake;
import java.util.ArrayList;
import java.util.List;
public class LiveNewWishListFragment extends BaseFragment {
private int type = 0;
private RecyclerView wishList;
private LiveNewWishAdapter liveNewWishAdapter;
private ImageView imageView2, tvDone;
@Override
public View createView(LayoutInflater layoutInflater, ViewGroup viewGroup) {
return layoutInflater.inflate(R.layout.view_live_new_wish, viewGroup, false);
}
@Override
protected void initVariables(Bundle bundle) {
type = bundle.getInt("type", 0);
}
@Override
protected void initViews(Bundle savedInstanceState, View contentView) {
wishList = contentView.findViewById(R.id.wish_list);
imageView2 = contentView.findViewById(R.id.imageView2);
tvDone = contentView.findViewById(R.id.tvDone);
liveNewWishAdapter = new LiveNewWishAdapter();
wishList.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
wishList.setAdapter(liveNewWishAdapter);
imageView2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new XPopup.Builder(getContext())
.enableDrag(false)
.asCustom(new LiveNewWishGiftPopup(getActivity(), type))
.show();
}
});
ViewClicksAntiShake.clicksAntiShake(tvDone, new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
saveWish();
Bus.get().post(new PopupViewDismissEvent());
}
});
}
@Override
protected void loadData() {
LiveNetManager.get(getContext()).getWishlistV2(type, new HttpCallback<WishListModel>() {
@Override
public void onSuccess(WishListModel data) {
liveNewWishAdapter.addData(data.getWishList(), type);
}
@Override
public void onError(String error) {
ToastUtil.show(R.string.net_error);
}
});
}
public static LiveNewWishListFragment newInstance(int type) {
LiveNewWishListFragment searchRecommendFragment = new LiveNewWishListFragment();
Bundle bundle = new Bundle();
bundle.putInt("type", type);
searchRecommendFragment.setArguments(bundle);
return searchRecommendFragment;
}
public void addGiftListModel(WishModel model) {
liveNewWishAdapter.addGiftListModel(model);
}
public void clearGiftListModel() {
List<WishModel> wishList = new ArrayList<>();
liveNewWishAdapter.addData(wishList, type);
}
public void saveWish() {
List<WishModel> wishList = liveNewWishAdapter.getWishList();
List<WishModel2> wishList2 = new ArrayList<>();
Gson gson = new Gson();
for (WishModel model : wishList) {
if (model!=null){
WishModel2 model2 = gson.fromJson(gson.toJson(model), WishModel2.class);
wishList2.add(model2);
}
}
if (wishList2.size() == 0) {
Bus.get().post(new PopupViewDismissEvent());
} else {
if (wishList2.size()>10){
ToastUtil.show(R.string.must_hint);
return;
}
LiveNetManager.get(getContext()).
setWishlistV2(type, gson.toJson(wishList2), new HttpCallback<String>() {
@Override
public void onSuccess(String data) {
}
@Override
public void onError(String error) {
ToastUtil.show(R.string.net_error);
}
});
switch (type) {
case 1:
Bus.get().post(new LiveNewWishListCloseEvent().setDayWish(false));
break;
case 2:
Bus.get().post(new LiveNewWishListCloseEvent().setZhouXin(false));
break;
case 3:
Bus.get().post(new LiveNewWishListCloseEvent().setLunarWish(false));
break;
case 4:
Bus.get().post(new LiveNewWishListCloseEvent().setSeasonalWish(false));
break;
}
}
}
}

View File

@@ -44,7 +44,7 @@ public class API extends BaseApi {
public PDLiveApi pdLiveApi(Context context) {
if (null == pdLiveApi) {
//实例化gson
pdLiveApi=createPDLiveApi(true);
pdLiveApi = createPDLiveApi(true, true);
}
return pdLiveApi;
}
@@ -52,10 +52,23 @@ public class API extends BaseApi {
/**
* 创建新的PDLiveApi兼容部分接口需要控制是否添加UID参数
* 仅有需要不添加uid的接口使用默认请用pdLiveApi()
*
* @param isNeedUid 是否需要用户uid参数
* @return PDLiveApi
*/
public PDLiveApi createPDLiveApi(boolean isNeedUid){
public PDLiveApi createPDLiveApi(boolean isNeedUid) {
return createPDLiveApi(isNeedUid, true);
}
/**
* 创建新的PDLiveApi兼容部分接口需要控制是否添加UID参数
* 仅有需要不添加uid或token的接口使用默认请用pdLiveApi()
*
* @param isNeedUid 是否需要用户uid参数
* @param isNeedToken 是否需要用户Token
* @return PDLiveApi
*/
public PDLiveApi createPDLiveApi(boolean isNeedUid, boolean isNeedToken) {
Gson gson = new GsonBuilder()
.registerTypeAdapter(Date.class, new DateTypeAdapter())
.create();
@@ -64,20 +77,20 @@ public class API extends BaseApi {
OkHttpClient.Builder builder = new OkHttpClient()
.newBuilder()
.addInterceptor(initQuery(isNeedUid,CommonAppContext.sInstance.getApplicationContext()))
.addInterceptor(initQuery(isNeedUid, isNeedToken, CommonAppContext.sInstance.getApplicationContext()))
.addInterceptor(loggingInterceptor);
return create(builder.build(),
GsonConverterFactory.create(gson), RxJava2CallAdapterFactory.create(), CommonAppConfig.HOST, PDLiveApi.class);
}
//公共参数
public Interceptor initQuery(boolean isNeedUid,final Context context) {
public Interceptor initQuery(boolean isNeedUid, boolean isNeedToken, final Context context) {
Interceptor addQueryParameterInterceptor = new Interceptor() {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
//配置公共参数
request = new ParamsContext(request, context).getInRequest(isNeedUid);
request = new ParamsContext(request, context).getInRequest(isNeedUid, isNeedToken);
return chain.proceed(request);
}
};

View File

@@ -158,10 +158,12 @@ public class CommonHttpUtil {
} else {
locale = context.getResources().getConfiguration().locale;
}
if (locale.getLanguage().equals("en")) {
lang = "english";
} else {
if (locale.getLanguage().equals("zh")) {
lang = "chinese";
} else {
lang = "english";
}
}
Log.i("来了", lang);
@@ -217,6 +219,8 @@ public class CommonHttpUtil {
}
if (obj.containsKey("clarity")) {
IMLoginManager.get(context).setClarity(obj.getString("clarity"));
} if (obj.containsKey("defaultBubbleUrl")) {
IMLoginManager.get(context).setDefaultBubbleUrl(obj.getString("defaultBubbleUrl"));
}
} catch (Exception e) {
String error = "info[0]:" + info[0] + "\n\n\n" + "Exception:" + e.getClass() + "---message--->" + e.getMessage();

View File

@@ -1,11 +1,13 @@
package com.yunbao.common.http;
import com.alibaba.fastjson.JSONObject;
import com.yunbao.common.bean.ActiveModel;
import com.yunbao.common.bean.AnchorRecommendModel;
import com.yunbao.common.bean.BaseModel;
import com.yunbao.common.bean.CheckLiveModel;
import com.yunbao.common.bean.ContributeModel;
import com.yunbao.common.bean.CustomSidebarInfoModel;
import com.yunbao.common.bean.DiscountsModel;
import com.yunbao.common.bean.EnterRoomNewModel;
import com.yunbao.common.bean.FaceBookUpModel;
import com.yunbao.common.bean.HourRank;
@@ -14,11 +16,14 @@ import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.bean.LinkMicUserBeanV2;
import com.yunbao.common.bean.ListInfoMessageModel;
import com.yunbao.common.bean.LiveAiRobotBean;
import com.yunbao.common.bean.LiveAnchorCallMeModel;
import com.yunbao.common.bean.LiveAnchorSayModel;
import com.yunbao.common.bean.LiveDataInfoModel;
import com.yunbao.common.bean.LiveInfoModel;
import com.yunbao.common.bean.LiveRoomActivityBanner;
import com.yunbao.common.bean.LiveStetUpStatusModel;
import com.yunbao.common.bean.LiveTaskModel;
import com.yunbao.common.bean.LiveUserMailBoxModel;
import com.yunbao.common.bean.MsgSwitchDetailModel;
import com.yunbao.common.bean.NewPeopleInfo;
import com.yunbao.common.bean.NobleRankHideUserListModel;
@@ -32,7 +37,11 @@ import com.yunbao.common.bean.SearchModel;
import com.yunbao.common.bean.SetAttentsModel;
import com.yunbao.common.bean.SlideInBannerModel;
import com.yunbao.common.bean.StarChallengeStatusModel;
import com.yunbao.common.bean.UserAreaBean;
import com.yunbao.common.bean.VipModel;
import com.yunbao.common.bean.WishListGiftConfModel;
import com.yunbao.common.bean.WishListModel;
import com.yunbao.common.bean.WishListModel2;
import java.util.List;
import java.util.Map;
@@ -575,4 +584,106 @@ public interface PDLiveApi {
Observable<ResponseModel<List<ListInfoMessageModel>>> getAnchorMsg(
@Query("liveuid") String liveUid, @Query("page") int page, @Query("limit") int limit
);
/**
* 获取女神说数据
*/
@GET("/api/public/?service=Live.getLivePreviewInfo")
Observable<ResponseModel<LiveAnchorSayModel>> getLivePreviewInfo(
@Query("liveuid") String liveUid
);
/**
* 设置女神说
*
* @param isShow 是否显示
* @param content 内容
* @param styleImage 女神说底图地址
*
*/
@GET("/api/public/?service=Live.setLivePreview")
Observable<ResponseModel<String>> setLivePreviewInfo(
@Query("liveuid") String liveUid,
@Query("isShow") int isShow,
@Query("content") String content,
@Query("styleImage")String styleImage
);
/**
* 设置主播联系方式
*/
@GET("/api/public/?service=Live.setAnchorContact")
Observable<ResponseModel<String>> setAnchorContact(
@Query("liveuid") String liveUid,
@Query("isShow") int show,
@Query("gift_id") int giftId,
@Query("content") String content,
@Query("wechat") JSONObject wechat,
@Query("line") JSONObject line,
@Query("whatsApp") JSONObject whatsApp
);
/**
* 获取主播联系方式
*/
@GET("/api/public/?service=Live.getContactInfo")
Observable<ResponseModel<LiveAnchorCallMeModel>> getContactInfo(
@Query("liveuid") String liveUid
);
/**
* 获取收件箱信息
*/
@GET("/api/public/?service=Live.getContactMsg")
Observable<ResponseModel<List<LiveUserMailBoxModel>>> getContactMsg();
/**
* 删除联系方式信件
*/
@GET("/api/public/?service=Live.delContactMsg")
Observable<ResponseModel<String>> delContactMsg(
@Query("msgId") int msgId
);
/**
* 获取心愿单配置
*
* @return
*/
@GET("/api/public/?service=Guide.getWishlistV2")
Observable<ResponseModel<List<WishListModel>>> getWishlistV2( @Query("type") int type);
/**
* 获取礼物配置
*
* @param type 1日心愿单2周3月4季度
* @return
*/
@GET("/api/public/?service=Guide.getWishListGiftConf")
Observable<ResponseModel<WishListGiftConfModel>> getWishListGiftConf(
@Query("type") int type
);
/**
* 设置心愿单
*
* @param type 1日心愿单2周3月4季度
* @param list 列表json数据
* @return
*/
@GET("/api/public/?service=Guide.setWishlistV2")
Observable<ResponseModel<List<String>>> setWishlistV2(
@Query("type") int type,
@Query("list") String list
);
/**
* 获取折扣卷信息
*/
@GET("/api/public/?service=Coupon.getUserCoupon")
Observable<ResponseModel<List<DiscountsModel>>> getDiscountInfo(
@Query("type") int type
);
/**
* 获取地区
*/
@GET("/api/public/?service=User.getUserArea")
Observable<ResponseModel<UserAreaBean>> getUserArea();
}

View File

@@ -20,7 +20,7 @@ public class GetRequestParams implements IRequestParam {
* @return
*/
@Override
public Request getRequest(boolean isNeedUid, Request request, Context context) {
public Request getRequest(boolean isNeedUid,boolean isNeedToken, Request request, Context context) {
//添加公共参数
if (IMLoginManager.isLogin(context)) {
IMLoginModel model = IMLoginManager.get(context).getUserInfo();
@@ -36,7 +36,9 @@ public class GetRequestParams implements IRequestParam {
if (isNeedUid) {
builder.addQueryParameter("uid", String.valueOf(model.getId()));
}
builder.addQueryParameter("token", model.getToken());
if(isNeedToken) {
builder.addQueryParameter("token", model.getToken());
}
}
return request.newBuilder().url(builder.build()).build();

View File

@@ -5,5 +5,5 @@ import android.content.Context;
import okhttp3.Request;
public interface IRequestParam {
Request getRequest(boolean isNeedUid,Request request, Context context);
Request getRequest(boolean isNeedUid,boolean isNeedToken, Request request, Context context);
}

View File

@@ -14,7 +14,7 @@ public class ParamsContext {
this.request = request;
}
public Request getInRequest(boolean isNeedUid) {
public Request getInRequest(boolean isNeedUid,boolean isNeedToken) {
switch (request.method()) {
case "GET":
iRequestParam = new GetRequestParams();
@@ -23,6 +23,6 @@ public class ParamsContext {
iRequestParam = new PostRequestParams();
break;
}
return iRequestParam.getRequest(isNeedUid,request, context);
return iRequestParam.getRequest(isNeedUid,isNeedToken,request, context);
}
}

View File

@@ -12,7 +12,7 @@ import okhttp3.Request;
public class PostRequestParams implements IRequestParam {
@Override
public Request getRequest(boolean isNeedUid, Request request, Context context) {
public Request getRequest(boolean isNeedUid,boolean isNeedToken, Request request, Context context) {
if (request.body() instanceof FormBody) {
FormBody.Builder bodyBuilder = new FormBody.Builder();
@@ -32,7 +32,9 @@ public class PostRequestParams implements IRequestParam {
if (isNeedUid) {
bodyBuilder.addEncoded("uid", String.valueOf(model.getId()));
}
bodyBuilder.addEncoded("token", model.getToken());
if(isNeedToken) {
bodyBuilder.addEncoded("token", model.getToken());
}
formBody = bodyBuilder.build();
}
}

View File

@@ -10,17 +10,21 @@ import com.yunbao.common.bean.ActiveModel;
import com.yunbao.common.bean.BaseModel;
import com.yunbao.common.bean.CheckLiveModel;
import com.yunbao.common.bean.CustomSidebarInfoModel;
import com.yunbao.common.bean.DiscountsModel;
import com.yunbao.common.bean.EnterRoomNewModel;
import com.yunbao.common.bean.HttpCallbackModel;
import com.yunbao.common.bean.LinkMicUserBean;
import com.yunbao.common.bean.LinkMicUserBeanV2;
import com.yunbao.common.bean.ListInfoMessageModel;
import com.yunbao.common.bean.LiveAiRobotBean;
import com.yunbao.common.bean.LiveAnchorCallMeModel;
import com.yunbao.common.bean.LiveAnchorSayModel;
import com.yunbao.common.bean.LiveDataInfoModel;
import com.yunbao.common.bean.LiveInfoModel;
import com.yunbao.common.bean.LiveRoomActivityBanner;
import com.yunbao.common.bean.LiveStetUpStatusModel;
import com.yunbao.common.bean.LiveTaskModel;
import com.yunbao.common.bean.LiveUserMailBoxModel;
import com.yunbao.common.bean.NobleRankHideUserListModel;
import com.yunbao.common.bean.NobleTrumpetModel;
import com.yunbao.common.bean.PkRankBean;
@@ -30,7 +34,10 @@ import com.yunbao.common.bean.RandomPkUserBean;
import com.yunbao.common.bean.RankPkInfoBean;
import com.yunbao.common.bean.SetAttentsModel;
import com.yunbao.common.bean.StarChallengeStatusModel;
import com.yunbao.common.bean.UserAreaBean;
import com.yunbao.common.bean.VipModel;
import com.yunbao.common.bean.WishListGiftConfModel;
import com.yunbao.common.bean.WishListModel;
import com.yunbao.common.http.API;
import com.yunbao.common.http.ResponseModel;
import com.yunbao.common.http.base.CheckLiveCallBack;
@@ -364,6 +371,7 @@ public class LiveNetManager {
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
Log.e("异常", "checkLive: ",throwable);
if (callBack != null) {
callBack.onError(throwable.getMessage());
}
@@ -1145,6 +1153,256 @@ public class LiveNetManager {
}).isDisposed();
}
/**
* 获取女神说数据
*/
public void getLivePreviewInfo(String liveUid, HttpCallback<LiveAnchorSayModel> callback) {
API.get().pdLiveApi(mContext)
.getLivePreviewInfo(liveUid)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(listResponseModel -> {
callback.onSuccess(listResponseModel.getData().getInfo());
}, throwable -> {
callback.onError(throwable.getMessage());
}).isDisposed();
}
/**
* 设置女神说
*
* @param isShow 是否显示
* @param content 内容
* @param styleImage 女神说底图地址
*/
public void setLivePreviewInfo(String liveUid,
int isShow,
String content,
String styleImage, HttpCallback<String> callback) {
API.get().pdLiveApi(mContext)
.setLivePreviewInfo(liveUid, isShow, content, styleImage)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(listResponseModel -> {
if (callback != null) {
callback.onSuccess(listResponseModel.getData().getInfo());
}
}, throwable -> {
if (callback != null) {
callback.onError(throwable.getMessage());
}
}).isDisposed();
}
/**
* 设置主播联系方式
*
* @param liveUid 直播间id
* @param callMe 载体
* @param callback 回调
*/
public void setAnchorCallMe(String liveUid,
LiveAnchorCallMeModel callMe,
HttpCallback<String> callback) {
API.get().createPDLiveApi(false, false)
.setAnchorContact(liveUid,
callMe.getIsShow(),
callMe.getGiftId(),
callMe.getContent(),
callMe.getWechat().toJSONObject(),
callMe.getLine().toJSONObject(),
callMe.getWhatsApp().toJSONObject())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(listResponseModel -> {
if (callback != null) {
callback.onSuccess(listResponseModel.getData().getInfo());
}
}, throwable -> {
if (callback != null) {
callback.onError(throwable.getMessage());
}
}).isDisposed();
}
/**
* 获取收件箱信息
*
* @param callback 回调
*/
public void getContactMsg(HttpCallback<List<LiveUserMailBoxModel>> callback) {
API.get().pdLiveApi(mContext)
.getContactMsg()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(listResponseModel -> {
if (callback != null) {
callback.onSuccess(listResponseModel.getData().getInfo());
}
}, throwable -> {
if (callback != null) {
callback.onError(throwable.getMessage());
}
}).isDisposed();
}
/**
* 获取主播联系方式
*
* @param liveUid 直播间id
* @param callback 回调
*/
public void getContactInfo(String liveUid, HttpCallback<LiveAnchorCallMeModel> callback) {
API.get().pdLiveApi(mContext)
.getContactInfo(liveUid)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(listResponseModel -> {
if (callback != null) {
callback.onSuccess(listResponseModel.getData().getInfo());
}
}, throwable -> {
if (callback != null) {
callback.onError(throwable.getMessage());
}
}).isDisposed();
}
/**
* 删除联系方式信件
*
* @param msgId 信息id
* @param callback 回调
*/
public void delContactInfo(int msgId, HttpCallback<String> callback) {
API.get().pdLiveApi(mContext)
.delContactMsg(msgId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(listResponseModel -> {
if (callback != null) {
callback.onSuccess(listResponseModel.getData().getInfo());
}
}, throwable -> {
if (callback != null) {
callback.onError(throwable.getMessage());
}
}).isDisposed();
}
/**
* 获取心愿单配置
*
* @param callback
*/
public void getWishlistV2(int type, HttpCallback<WishListModel> callback) {
API.get().pdLiveApi(mContext)
.getWishlistV2(type)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<ResponseModel<List<WishListModel>>>() {
@Override
public void accept(ResponseModel<List<WishListModel>> listResponseModel) throws Exception {
if (callback != null) {
callback.onSuccess(listResponseModel.getData().getInfo().get(0));
}
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
if (callback != null) {
callback.onError(throwable.getMessage());
}
}
}).isDisposed();
}
public void getWishListGiftConf(int type, HttpCallback<WishListGiftConfModel> callback) {
API.get().pdLiveApi(mContext)
.getWishListGiftConf(type)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<ResponseModel<WishListGiftConfModel>>() {
@Override
public void accept(ResponseModel<WishListGiftConfModel> wishListGiftConfModelResponseModel) throws Exception {
if (callback != null) {
callback.onSuccess(wishListGiftConfModelResponseModel.getData().getInfo());
}
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
if (callback != null) {
callback.onError(throwable.getMessage());
}
}
}).isDisposed();
}
public void setWishlistV2(int type, String list, HttpCallback<String> callback) {
API.get().pdLiveApi(mContext)
.setWishlistV2(type, list)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<ResponseModel<List<String>>>() {
@Override
public void accept(ResponseModel<List<String>> stringResponseModel) throws Exception {
if (callback != null) {
callback.onSuccess(stringResponseModel.getData().getInfo().get(0));
}
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
if (callback != null) {
callback.onError(throwable.getMessage());
}
}
}).isDisposed();
}
public void getDiscountInfo(int type,HttpCallback<List<DiscountsModel>> callback) {
API.get().pdLiveApi(mContext)
.getDiscountInfo(type)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<ResponseModel<List<DiscountsModel>>>() {
@Override
public void accept(ResponseModel<List<DiscountsModel>> wishListGiftConfModelResponseModel) throws Exception {
if (callback != null) {
callback.onSuccess(wishListGiftConfModelResponseModel.getData().getInfo());
}
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
if (callback != null) {
callback.onError(throwable.getMessage());
}
}
}).isDisposed();
}
public void getUserArea(HttpCallback<UserAreaBean> callback) {
API.get().pdLiveApi(mContext)
.getUserArea()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<ResponseModel<UserAreaBean>>() {
@Override
public void accept(ResponseModel<UserAreaBean> wishListGiftConfModelResponseModel) throws Exception {
if (callback != null) {
callback.onSuccess(wishListGiftConfModelResponseModel.getData().getInfo());
}
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
if (callback != null) {
callback.onError(throwable.getMessage());
}
}
}).isDisposed();
}
/**
* 直播间取消网络请求
*/

View File

@@ -42,6 +42,19 @@ public class IMLoginManager extends BaseCacheManager {
private final String SELECT_CLARITY = "selectClarity";
private final String CLARITY = "clarity";
private final String xiaJBG = "xiaJBG";
private final String keyDefaultBubbleUrl = "defaultBubbleUrl";
private final String STATUS_ANCHOR_SAY = "anchorSay";
private final String STATUS_ANCHOR_CALL = "anchorCallMe";
public void setDefaultBubbleUrl(String defaultBubbleUrl) {
put(keyDefaultBubbleUrl, defaultBubbleUrl);
}
public String getKeyDefaultBubbleUrl() {
return getString(keyDefaultBubbleUrl);
}
public void setXiaJBG(boolean xjbg) {
put(xiaJBG, xjbg);
@@ -84,6 +97,34 @@ public class IMLoginManager extends BaseCacheManager {
}
/**
* 获取女神说设置状态
*/
public int getAnchorSayStatus() {
return getInt(STATUS_ANCHOR_SAY, 0);
}
/**
* 获取联系主播方式设置状态
*/
public int getAnchorCallStatus() {
return getInt(STATUS_ANCHOR_CALL, 0);
}
/**
* 设置女神说设置状态
*/
public void setAnchorSayStatus(int status) {
put(STATUS_ANCHOR_SAY, status);
}
/**
* 设置联系主播方式设置状态
*/
public void setAnchorCallMeStatus(int status) {
put(STATUS_ANCHOR_CALL, status);
}
public boolean isHint() {
return 1 == getInt(IS_HINT, 0);
}

View File

@@ -16,6 +16,8 @@ import java.util.List;
public class NewLevelManager extends BaseCacheManager {
private final String KEY_USER_LEVEL = "keyUserLevel";
private final String KEY_ANCHOR_LEVEL = "keyAnchorLevel";
private final String KEY_LIVE_LEVEL = "keyLiveLevel";
private List<NewLevelModel> newLevelModels = new ArrayList<>();
private List<NewLevelModel> keyAnchorLevel = new ArrayList<>();

View File

@@ -22,6 +22,7 @@ import android.graphics.Canvas;
import android.graphics.PixelFormat;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.Log;
import org.json.JSONArray;
import org.json.JSONObject;
@@ -160,8 +161,9 @@ public class ACache {
String readString = "";
String currentLine;
while ((currentLine = in.readLine()) != null) {
readString += currentLine;
readString += currentLine + "\n";
}
readString = readString.substring(0, readString.length() - 1);
if (!Utils.isDue(readString)) {
return Utils.clearDateInfo(readString);
} else {

View File

@@ -0,0 +1,20 @@
package com.yunbao.common.server;
import static android.content.Intent.EXTRA_CHOSEN_COMPONENT;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
public class ShareBroadcastReceiver extends BroadcastReceiver {
public static final int REQUEST_CODE = 888;
private static final String TAG = "分享log";
@Override
public void onReceive(Context context, Intent intent) {
Log.i(TAG, "onReceive");
Log.i(TAG, intent.getAction() + " | " + intent.getParcelableExtra(EXTRA_CHOSEN_COMPONENT));
}
}

View File

@@ -0,0 +1,141 @@
package com.yunbao.common.utils;
import android.app.Activity;
import com.yunbao.common.BuildConfig;
import java.util.Stack;
public class AppManager {
private static Stack<Activity> activityStack;
public AppManager() {
}
/**
* 单一实例
*/
public static AppManager getInstance() {
return SingleApp.INSTANCE;
}
public static class SingleApp {
public static AppManager INSTANCE = new AppManager();
}
/**
* 添加Activity到堆栈
*/
public void addActivity(Activity activity) {
if (activityStack == null) {
activityStack = new Stack<Activity>();
}
activityStack.add(activity);
}
/**
* 移除Activity
*/
public void removeActivity(Activity activity) {
activityStack.remove(activity);
}
/**
* 获取指定的Activity
*/
public static Activity getActivity(Class<?> cls) {
if (activityStack != null)
for (Activity activity : activityStack) {
if (activity.getClass().equals(cls)) {
return activity;
}
}
return null;
}
/**
* 获取当前显示Activity堆栈中最后一个传入的activity
*/
public Activity getLastActivity() {
Activity activity = activityStack.lastElement();
return activity;
}
/**
* 获取所有Activity
*/
public Stack<Activity> getAllActivityStacks() {
return activityStack;
}
/**
* 结束指定的Activity
*/
public void finishActivity(Activity activity) {
if (activity != null) {
if (!activity.isFinishing()) {
activity.finish();
activityStack.remove(activity);
}
}
}
/**
* 结束指定类名的Activity
*/
public void finishActivity(Class<?> cls) {
for (Activity activity : activityStack) {
if (activity.getClass().equals(cls)) {
finishActivity(activity);
break;
}
}
}
/**
* 结束除当前传入以外所有Activity
*/
public void finishOthersActivity(Class<?> cls) {
if (activityStack != null)
for (Activity activity : activityStack) {
if (!activity.getClass().equals(cls)) {
activity.finish();
}
}
}
/**
* 结束所有Activity
*/
public void finishAllActivity() {
if (activityStack != null)
for (Activity activity : activityStack) {
activity.finish();
}
activityStack.clear();
}
/**
*仅在debug下运行的代码
*/
public static void runDebugCode(Runnable runnable) {
if (BuildConfig.DEBUG) {
// runnable.run();
}
}
/**
* 退出应用程序
*/
public void AppExit() {
try {
finishAllActivity();
android.os.Process.killProcess(android.os.Process.myPid());// 杀死该应用进程
System.exit(0);
} catch (Exception e) {
}
}
}

View File

@@ -1,10 +1,12 @@
package com.yunbao.common.utils;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.CommonAppContext;
import com.yunbao.common.Constants;
import com.yunbao.common.R;
import com.yunbao.common.bean.LiveGiftBean;
@@ -43,7 +45,7 @@ public class GiftCacheUtil {
/**
* 单独下载
*/
public static void getFile(String fileName, String url, String forwhat, final CommonCallback<File> commonCallback) {
public static void getFile(Context context,String fileName, String url, String forwhat, final CommonCallback<File> commonCallback) {
if (commonCallback == null) {
return;
}
@@ -60,7 +62,9 @@ public class GiftCacheUtil {
} else {
DownloadUtil downloadUtil = new DownloadUtil();
if (forwhat.equals("1")) {
ToastUtil.show(R.string.gift_way);
ToastUtils toastUtil = new ToastUtils(context);
toastUtil.InitToast();
toastUtil.show();
}
downloadUtil.download(CommonHttpConsts.DOWNLOAD_GIF, dir, fileName, url, new DownloadUtil.Callback() {
String TAG="下载";
@@ -141,13 +145,13 @@ public class GiftCacheUtil {
/**
* 插队优先下载指定id礼物
*/
public void downloadGiftForId(LiveGiftBean bean, CommonCallback<File> mDownloadGifCallback) {
public void downloadGiftForId(Context context,LiveGiftBean bean, CommonCallback<File> mDownloadGifCallback) {
if (checkGiftIsDownload(bean.getId())) {
mDownloadGifCallback.callback(getGiftForId(bean.getId()));
return;
}
clickId.add(bean.getId()+"");
getFile(getDownloadSaveName(bean.getId()), bean.getSwf(), "0", new CommonCallback<File>() {
getFile(context,getDownloadSaveName(bean.getId()), bean.getSwf(), "0", new CommonCallback<File>() {
@Override
public void callback(File bean) {
if(bean!=null) {

View File

@@ -395,6 +395,21 @@ public class JavascriptInterfaceUtils {
}
//心愿单守護购买
@JavascriptInterface
public void BuyProtection(String by) {
Bus.get().post(new JavascriptInterfaceEvent()
.setMethod("BuyProtection").setData(by));
}
//心愿单贵族购买
@JavascriptInterface
public void BuyVIP(String by) {
Bus.get().post(new JavascriptInterfaceEvent()
.setMethod("BuyVIP").setData(by));
}
@JavascriptInterface
public String androidMethodLookLive(String uId, String liveId, String isLiving) {
//跳转个人主页
@@ -446,7 +461,7 @@ public class JavascriptInterfaceUtils {
} else {
url1 = svg;
}
GiftCacheUtil.getFile(Constants.GIF_CAR_PREFIX + id, url1, "0", new CommonCallback<File>() {
GiftCacheUtil.getFile(mContext, Constants.GIF_CAR_PREFIX + id, url1, "0", new CommonCallback<File>() {
@Override
public void callback(File bean) {
@@ -478,23 +493,53 @@ public class JavascriptInterfaceUtils {
/**
* 设置webView高度
*
* @param useDp 是否用dp换算
*/
@JavascriptInterface
public void setHeight(String height, String width,boolean useDp) {
public void setHeight(String height, String width, boolean useDp) {
if ("0".equals(height)) {
return;
}
Handler handler = new Handler(Looper.getMainLooper());
handler.post(() -> {
ViewGroup.LayoutParams params = mWebView.getLayoutParams();
if("-1".equals(height)){
params.height=ViewGroup.LayoutParams.MATCH_PARENT;
}else {
params.height = useDp?DpUtil.dp2px(Integer.parseInt(height)):Integer.parseInt(height);
if ("-1".equals(height)) {
params.height = ViewGroup.LayoutParams.MATCH_PARENT;
} else {
params.height = useDp ? DpUtil.dp2px(Integer.parseInt(height)) : Integer.parseInt(height);
}
mWebView.setLayoutParams(params);
mWebView.setVisibility(View.VISIBLE);
});
}
/**
* 社区分享
*
* @param avatar 头像
* @param link 分享连接
*/
@JavascriptInterface
public void androidCommunityShare(String avatar, String link) {
JSONObject json = new JSONObject();
json.put("avatar", avatar);
json.put("link", link);
Bus.get().post(new JavascriptInterfaceEvent()
.setMethod("androidCommunityShare")
.setData(json.toJSONString()));
}
@JavascriptInterface
public void androidInviteShare(String url) {
Bus.get().post(new JavascriptInterfaceEvent()
.setMethod("androidInviteShare")
.setData(url));
}
@JavascriptInterface
public void closeLiveRoom() {
Bus.get().post(new JavascriptInterfaceEvent()
.setMethod("closeLiveRoom"));
}
}

View File

@@ -0,0 +1,53 @@
package com.yunbao.common.utils;
import static android.app.PendingIntent.FLAG_IMMUTABLE;
import static android.app.PendingIntent.FLAG_UPDATE_CURRENT;
import static android.content.Intent.EXTRA_CHOSEN_COMPONENT;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Bitmap;
import android.net.Uri;
import com.yunbao.common.server.ShareBroadcastReceiver;
import java.io.File;
/**
* 分享工具
*/
public class ShareUtil {
public static void share(Context context, String content) {
share(context, content, null);
}
public static void share(Context context, File image) {
share(context, null, image);
}
public static void share(Context context, String content, File image) {
Intent shareIntent = new Intent(Intent.ACTION_SEND);
if (image != null) {
Uri uri = Uri.fromFile(image);
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
shareIntent.setType("image/*");
//当用户选择短信时使用sms_body取得文字
shareIntent.putExtra("sms_body", content);
} else {
shareIntent.setType("text/plain");
}
shareIntent.putExtra(Intent.EXTRA_TEXT, content);
//自定义选择框的标题
PendingIntent pi = PendingIntent.getBroadcast(context, ShareBroadcastReceiver.REQUEST_CODE,
new Intent(context, ShareBroadcastReceiver.class), PendingIntent.FLAG_MUTABLE);
context.registerReceiver(new ShareBroadcastReceiver(),new IntentFilter(EXTRA_CHOSEN_COMPONENT));
shareIntent = Intent.createChooser(shareIntent, null, pi.getIntentSender());
context.startActivity(Intent.createChooser(shareIntent, "Share"));
//系统默认标题
}
}

View File

@@ -3,6 +3,7 @@ package com.yunbao.common.utils;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
@@ -13,6 +14,7 @@ import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import com.yunbao.common.BuildConfig;
import com.yunbao.common.CommonAppContext;
import com.yunbao.common.R;
@@ -76,7 +78,16 @@ public class ToastUtil {
dialog.show();
new Handler(Looper.getMainLooper()).postDelayed(dialog::dismiss, delayMillis);
}
public static void showDebug(String s){
if(BuildConfig.DEBUG){
show(s);
}
}
public static void showDebug(int s){
if(BuildConfig.DEBUG){
show(s);
}
}
public static void show(String s) {
if (TextUtils.isEmpty(s)) {
return;

View File

@@ -0,0 +1,46 @@
package com.yunbao.common.utils;
import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import com.yunbao.common.R;
public class ToastUtils {
private Context context;
private TextView tipsText;
private Toast toast = null;
public ToastUtils(Context context){
this.context = context;
}
public void InitToast(){
if (toast == null) {
toast = new Toast(context);
View view = LayoutInflater.from(context).inflate(R.layout.toast_utils, null, false);
toast.setView(view);
toast.setGravity(Gravity.CENTER, 0, 0);
}
}
public void setGravity(int gravity){
toast.setGravity(Gravity.CENTER, 0, 0);
}
public void setText(String tips){
tipsText.setText(tips);
}
public void show(){
toast.show();
}
public void setShowTime(int time){
toast.setDuration(time);
}
public void setTextColor(int color){
tipsText.setTextColor(context.getResources().getColor(color));
}
public void setTextSize(float size){
tipsText.setTextSize(size);
}
}

View File

@@ -33,4 +33,30 @@ public class WordsTypeUtil {
}
return changeText;
}
/**
* @param {*} num
* @returns ---汉字
*/
// 转换数字为大写
public static String numberConvertToUppercase(int number) {
String[] upperCaseNumber = {"", "", "", "", "", "", "", "", "", "", ""};
int length = String.valueOf(number).length();
if (length == 1) {
return upperCaseNumber[number];
} else if (length == 2) {
if (number == 10) {
return upperCaseNumber[number];
} else if (number > 10 && number < 20) {
return upperCaseNumber[10] + upperCaseNumber[number - 10];
} else {
int num1 = number / 10;
int num2 = number - (num1 * 10);
return upperCaseNumber[num1] + upperCaseNumber[10] + upperCaseNumber[num2];
}
} else {
return String.valueOf(number);
}
}
}

View File

@@ -93,13 +93,13 @@ public class CustomDrawerPopupView extends DrawerPopupView {
}
}
});
//特效设置
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.effects_settings_layout), new ViewClicksAntiShake.ViewClicksCallBack() {
//分享
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.share_layout), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
dismiss();
if (callBack != null) {
callBack.effectsSetting();
callBack.share();
}
}
});
@@ -146,6 +146,20 @@ public class CustomDrawerPopupView extends DrawerPopupView {
.popupPosition(PopupPosition.Top)
.asCustom(new MoreMenuPopupView(mContext))
.show();
}
});
//播放设置
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.live_play_setting), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
XPopup.Builder builder = new XPopup.Builder(getContext()).atView(findViewById(R.id.more_menu));
builder.hasShadowBg(false)
.isDestroyOnDismiss(true)
.isLightStatusBar(false)
.popupPosition(PopupPosition.Top)
.asCustom(new PlaySettingPopupView(mContext))
.show();
}
});
@@ -203,6 +217,8 @@ public class CustomDrawerPopupView extends DrawerPopupView {
void online();
void reportLayout();
void share();
}
@Subscribe(threadMode = ThreadMode.MAIN)
@@ -233,6 +249,18 @@ public class CustomDrawerPopupView extends DrawerPopupView {
dismiss();
callBack.reportLayout();
}
if (event.isEffects()) {
dismiss();
callBack.effectsSetting();
}
if (event.isSmallWindow()) {
dismiss();
callBack.floatSetting();
}
if (event.isQualitySelection()) {
dismiss();
callBack.changeVideo();
}
}
if (event.isRefresh()) {

View File

@@ -0,0 +1,106 @@
package com.yunbao.common.views;
import android.view.View;
import android.widget.FrameLayout;
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.R;
import com.yunbao.common.bean.WishModel;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.utils.WordsTypeUtil;
import com.yunbao.common.views.weight.ViewClicksAntiShake;
/**
* 日心愿单
*/
public class DayWishItemViewHolder extends RecyclerView.ViewHolder {
private TextView wishTab, wishlistName, wishlistProgress, wishlistNum, wishlistNum2, subtraction, addition;
private ImageView wishIcon;
private FrameLayout wishIconBg, tabBg,iconCancel;
private ProgressBar progressBar;
public DayWishItemViewHolder(@NonNull View itemView) {
super(itemView);
wishTab = itemView.findViewById(R.id.wish_tab);
wishIcon = itemView.findViewById(R.id.wish_icon);
tabBg = itemView.findViewById(R.id.tab_bg);
wishIconBg = itemView.findViewById(R.id.wish_icon_bg);
iconCancel = itemView.findViewById(R.id.icon_cancel);
wishlistName = itemView.findViewById(R.id.wishlist_name);
progressBar = itemView.findViewById(R.id.progressBar);
wishlistProgress = itemView.findViewById(R.id.wishlist_progress);
wishlistNum = itemView.findViewById(R.id.wishlist_num);
wishlistNum2 = itemView.findViewById(R.id.wishlist_num2);
subtraction = itemView.findViewById(R.id.subtraction);
addition = itemView.findViewById(R.id.addition);
}
public void steDayWishData(WishModel model, int index, DayWishItemListener listener) {
if (model != null) {
itemView.findViewById(R.id.hind_layout).setVisibility(View.VISIBLE);
itemView.findViewById(R.id.wish_icon_bg).setVisibility(View.VISIBLE);
itemView.findViewById(R.id.progress_bar).setVisibility(View.VISIBLE);
iconCancel.setVisibility(View.VISIBLE);
wishTab.setVisibility(View.VISIBLE);
wishlistName.setVisibility(View.VISIBLE);
wishTab.setText(String.format(itemView.getContext().getString(R.string.wish_number), WordsTypeUtil.numberConvertToUppercase(index + 1)));
ImgLoader.display(itemView.getContext(), model.getWishlistIcon(), wishIcon);
tabBg.setBackgroundResource(R.mipmap.bg_day_wish);
wishIconBg.setBackgroundResource(R.mipmap.background_wish_item);
wishlistName.setText(model.getWishlistName());
progressBar.setMax(model.wishProgress());
progressBar.setProgress(model.wishCurrent());//当前进度
wishlistProgress.setText(model.getWishlistProgress());
wishlistNum.setText(String.format("/%s", model.getWishlistNum()));
wishlistNum2.setText(String.format("x%s", model.getWishlistNum()));
ViewClicksAntiShake.clicksAntiShake(iconCancel, new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
if (listener != null) {
listener.onDelete(index);
}
}
});
ViewClicksAntiShake.clicksAntiShake(addition, new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
int number = model.wishProgress();
model.setWishlistNum(String.valueOf(number + 1));
if (listener != null) {
listener.onUpdate(model, index);
}
}
});
ViewClicksAntiShake.clicksAntiShake(subtraction, new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
int number = model.wishProgress();
model.setWishlistNum(String.valueOf(number - 1));
if (listener != null) {
listener.onUpdate(model, index);
}
}
});
} else {
itemView.findViewById(R.id.hind_layout).setVisibility(View.GONE);
itemView.findViewById(R.id.progress_bar).setVisibility(View.GONE);
tabBg.setBackground(null);
wishTab.setVisibility(View.GONE);
wishlistName.setVisibility(View.GONE);
iconCancel.setVisibility(View.GONE);
itemView.findViewById(R.id.wish_icon_bg).setVisibility(View.GONE);
}
}
public interface DayWishItemListener {
void onDelete(int index);
void onUpdate(WishModel model, int index);
}
}

View File

@@ -11,7 +11,8 @@ import com.yunbao.common.R;
import com.yunbao.common.views.weight.ViewClicksAntiShake;
public class HintCustomPopup extends CenterPopupView {
private String title, contest;
private String title, contest,openCancel,openOk;
private TextView liveOpenCancel, liveOpenOk;
public HintCustomPopup(@NonNull Context context, String title, String contest) {
super(context);
@@ -23,6 +24,16 @@ public class HintCustomPopup extends CenterPopupView {
super(context);
}
public HintCustomPopup setLiveOpenCancel(String openCancel) {
this.openCancel = openCancel;
return this;
}
public HintCustomPopup setLiveOpenOk(String openOk) {
this.openOk = openOk;
return this;
}
// 返回自定义弹窗的布局
@Override
protected int getImplLayoutId() {
@@ -35,19 +46,23 @@ public class HintCustomPopup extends CenterPopupView {
super.onCreate();
TextView titleText = findViewById(R.id.title);
TextView contestText = findViewById(R.id.contest);
liveOpenCancel = findViewById(R.id.live_open_cancel);
liveOpenOk = findViewById(R.id.live_open_ok);
liveOpenOk.setText(openOk);
liveOpenCancel.setText(openCancel);
if (!TextUtils.isEmpty(title)) {
titleText.setText(title);
}
if (!TextUtils.isEmpty(contest)) {
contestText.setText(contest);
}
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.live_open_ok), () -> {
ViewClicksAntiShake.clicksAntiShake(liveOpenOk, () -> {
if (callBack != null) {
callBack.onSure();
}
dismiss();
});
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.live_open_cancel), () -> {
ViewClicksAntiShake.clicksAntiShake(liveOpenCancel, () -> {
if (callBack != null) {
callBack.onCancel();
}

View File

@@ -0,0 +1,173 @@
package com.yunbao.common.views;
import android.graphics.Color;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.widget.ViewPager2;
import com.google.android.material.tabs.TabLayout;
import com.lxj.xpopup.core.BottomPopupView;
import com.yunbao.common.R;
import com.yunbao.common.adapter.LiveNewWishListAdapter;
import com.yunbao.common.bean.GiftListModel;
import com.yunbao.common.bean.WishListGiftConfModel;
import com.yunbao.common.event.LiveNewWishGiftEvent;
import com.yunbao.common.event.LiveNewWishListEvent;
import com.yunbao.common.fragment.LiveNewWishGiftFragment;
import com.yunbao.common.http.base.HttpCallback;
import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.views.weight.ViewClicksAntiShake;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.util.ArrayList;
import java.util.List;
public class LiveNewWishGiftPopup extends BottomPopupView {
private TabLayout wishTab;
private int type = 0;
private ViewPager2 fragmentViewpager;
private FragmentActivity mContext;
private ArrayList<Fragment> ViewList = new ArrayList<>(); //页卡视图集合
private GiftListModel model = null;
private Button wishGitfButton;
public LiveNewWishGiftPopup(@NonNull FragmentActivity context, int type) {
super(context);
this.type = type;
mContext = context;
}
// 返回自定义弹窗的布局
@Override
protected int getImplLayoutId() {
return R.layout.dialog_live_new_wish_gitf;
}
// 执行初始化操作比如findView设置点击或者任何你弹窗内的业务逻辑
@Override
protected void onCreate() {
super.onCreate();
Bus.getOn(this);
initView();
initDate();
}
@Override
protected void onDismiss() {
super.onDismiss();
Bus.getOff(this);
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onLiveNewWishGiftEvent(LiveNewWishGiftEvent event) {
model = event.getModel();
Log.e("LiveNewWishGiftPopup", model.toString());
}
private void initView() {
fragmentViewpager = findViewById(R.id.context_layout);
wishGitfButton = findViewById(R.id.wish_gitf_button);
wishTab = findViewById(R.id.wish_tab);
wishTab.setSelectedTabIndicatorColor(Color.TRANSPARENT);
wishTab.setFocusableInTouchMode(false);
for (int i = 0; i < 3; i++) {
TextView wishItem = (TextView) LayoutInflater.from(getContext())
.inflate(R.layout.view_tablaout_wish_item, null, false);
switch (i) {
case 0:
wishItem.setText(R.string.live_gift);
wishItem.setTextColor(Color.parseColor("#FFBE41"));
break;
case 1:
wishItem.setText(R.string.aristocrat);
wishItem.setTextColor(Color.parseColor("#B6B6B6"));
break;
case 2:
wishItem.setText(R.string.live_guard);
wishItem.setTextColor(Color.parseColor("#B6B6B6"));
break;
}
TabLayout.Tab tab = wishTab.newTab().setCustomView(wishItem).setId(i);
wishTab.addTab(tab, i == 0);
}
ViewGroup tabs = (ViewGroup) wishTab.getChildAt(0);
//设置边距,tab宽
for (int i = 0; i < tabs.getChildCount() - 1; i++) {
View tab = tabs.getChildAt(i);
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) tab.getLayoutParams();
layoutParams.setMarginEnd(DpUtil.dp2px(4));
layoutParams.width = DpUtil.dp2px(58);
tab.setLayoutParams(layoutParams);
wishTab.requestLayout();
}
wishTab.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
TextView customView = (TextView) tab.getCustomView();
customView.setTextColor(Color.parseColor("#FFBE41"));
fragmentViewpager.setCurrentItem(tab.getId(), false);
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
TextView customView = (TextView) tab.getCustomView();
customView.setTextColor(Color.parseColor("#B6B6B6"));
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
ViewClicksAntiShake.clicksAntiShake(wishGitfButton, new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
if (model != null) {
Bus.get().post(new LiveNewWishListEvent()
.setModel(model)
.setType(type));
}
dismiss();
}
});
}
private void initDate() {
LiveNetManager.get(getContext()).getWishListGiftConf(type, new HttpCallback<WishListGiftConfModel>() {
@Override
public void onSuccess(WishListGiftConfModel data) {
ViewList.add(LiveNewWishGiftFragment.newInstance(data.getGiftList()));
ViewList.add(LiveNewWishGiftFragment.newInstance(data.getNobleList()));
ViewList.add(LiveNewWishGiftFragment.newInstance(data.getGuardList()));
LiveNewWishListAdapter liveNewWishListAdapter = new LiveNewWishListAdapter(mContext, ViewList);
fragmentViewpager.setAdapter(liveNewWishListAdapter);
fragmentViewpager.setOffscreenPageLimit(1); //预加载页面数
//禁止左右滑动,false为禁止
fragmentViewpager.setUserInputEnabled(false);
}
@Override
public void onError(String error) {
ToastUtil.show(R.string.net_error);
}
});
}
}

View File

@@ -0,0 +1,45 @@
package com.yunbao.common.views;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.yunbao.common.R;
import com.yunbao.common.bean.GiftListModel;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.views.weight.ViewClicksAntiShake;
/**
* 心愿礼物配置页面
*/
public class LiveNewWishGiftViewHolder extends RecyclerView.ViewHolder {
private ImageView giftImg;
private TextView giftName, price;
public LiveNewWishGiftViewHolder(@NonNull View itemView) {
super(itemView);
giftImg = itemView.findViewById(R.id.gift_img);
giftName = itemView.findViewById(R.id.gift_name);
price = itemView.findViewById(R.id.price);
}
public void setData(GiftListModel model, ViewClicksAntiShake.ViewClicksCallBack callBack) {
ImgLoader.display(itemView.getContext(), model.getImg(), giftImg);
giftName.setText(model.getName());
price.setText(model.getPrice());
ViewClicksAntiShake.clicksAntiShake(itemView.findViewById(R.id.wish_gift), callBack);
if (TextUtils.equals(model.getGiftType(), "1")) {
itemView.findViewById(R.id.lin_price).setVisibility(View.VISIBLE);
} else {
itemView.findViewById(R.id.lin_price).setVisibility(View.GONE);
}
}
public void onSelect(boolean select) {
itemView.findViewById(R.id.wish_gift).setSelected(select);
}
}

View File

@@ -0,0 +1,352 @@
package com.yunbao.common.views;
import android.graphics.Color;
import android.text.TextUtils;
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 androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.widget.ViewPager2;
import com.google.android.material.tabs.TabLayout;
import com.google.gson.Gson;
import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.core.BottomPopupView;
import com.yunbao.common.R;
import com.yunbao.common.adapter.LiveNewWishListAdapter;
import com.yunbao.common.bean.WishModel;
import com.yunbao.common.bean.WishModel2;
import com.yunbao.common.event.LiveNewWishListCloseEvent;
import com.yunbao.common.event.LiveNewWishListEvent;
import com.yunbao.common.event.PopupViewDismissEvent;
import com.yunbao.common.fragment.LiveNewWishListFragment;
import com.yunbao.common.http.base.HttpCallback;
import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.views.weight.ViewClicksAntiShake;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
/**
* 新版心愿单
*/
public class LiveNewWishListPopup extends BottomPopupView {
private TabLayout wishTab;
private FragmentActivity mContext;
private ViewPager2 fragmentViewpager;
private ArrayList<Fragment> ViewList = new ArrayList<>(); //页卡视图集合
private int type = 1;
private TextView replacementWish;
private boolean dayWish;
private boolean zhouXin;
private boolean lunarWish;
private boolean seasonalWish;
private String ct;
private LiveNewWishListFragment dayWishFragment, zhouXinFragment, lunarWishFragment, seasonalWishFragment;
private ImageView wishListTop;
public LiveNewWishListPopup(@NonNull FragmentActivity context) {
super(context);
mContext = context;
ct = Locale.getDefault().getLanguage();
}
// 返回自定义弹窗的布局
@Override
protected int getImplLayoutId() {
return R.layout.dialog_live_new_wish_list;
}
// 执行初始化操作比如findView设置点击或者任何你弹窗内的业务逻辑
@Override
protected void onCreate() {
super.onCreate();
Bus.getOn(this);
initView();
initDate();
}
@Override
public void dismiss() {
if (dayWish || zhouXin || lunarWish || seasonalWish) {
saveWishDialog(true);
return;
}
super.dismiss();
}
private HintCustomPopup hintCustomPopup;
private void saveWishDialog(boolean isDismiss) {
if (hintCustomPopup != null) return;
hintCustomPopup = new HintCustomPopup(
getContext(),
getContext().getString(R.string.replacement_reset_confirmed_cancel3),
getContext().getString(R.string.replacement_reset_confirmed_cancel2))
.setLiveOpenCancel(getContext().getString(R.string.replacement_reset_confirmed_cancel4))
.setLiveOpenOk(getContext().getString(R.string.save))
.setCallBack(new HintCustomPopup.HintCustomCallBack() {
@Override
public void onSure() {
hintCustomPopup = null;
if (dayWish) {
dayWishFragment.saveWish();
} else if (zhouXin) {
zhouXinFragment.saveWish();
} else if (lunarWish) {
lunarWishFragment.saveWish();
} else if (seasonalWish) {
seasonalWishFragment.saveWish();
}
if (isDismiss) {
dismiss();
}
}
@Override
public void onCancel() {
dayWish = false;
zhouXin = false;
lunarWish = false;
seasonalWish = false;
hintCustomPopup = null;
if (isDismiss) {
dismiss();
}
}
});
new XPopup.Builder(getContext())
.asCustom(hintCustomPopup)
.show();
}
@Override
protected void onDismiss() {
Bus.getOff(this);
super.onDismiss();
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onPopupViewDismissEvent(PopupViewDismissEvent event) {
dismiss();
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onLiveNewWishListCloseEvent(LiveNewWishListCloseEvent event) {
dayWish = event.isDayWish();
zhouXin = event.isZhouXin();
lunarWish = event.isLunarWish();
seasonalWish = event.isSeasonalWish();
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onLiveNewWishListEvent(LiveNewWishListEvent event) {
WishModel model = new WishModel();
model.setLid(event.getModel().getId())
.setWishlistName(event.getModel().getName())
.setWishlistIcon(event.getModel().getImg())
.setWishlistNum("1")
.setLuid("" + IMLoginManager.get(mContext).getUserInfo().getId())
.setWishlistProgress("0")
.setPrice(Integer.parseInt(event.getModel().getPrice()))
.setGiftType(Integer.parseInt(event.getModel().getGiftType()))
.setType(event.getType());
switch (event.getType()) {
case 1:
dayWishFragment.addGiftListModel(model);
break;
case 2:
zhouXinFragment.addGiftListModel(model);
break;
case 3:
lunarWishFragment.addGiftListModel(model);
break;
case 4:
seasonalWishFragment.addGiftListModel(model);
break;
}
}
private void initView() {
fragmentViewpager = findViewById(R.id.context_layout);
wishTab = findViewById(R.id.wish_tab);
wishListTop = findViewById(R.id.wish_list_top);
replacementWish = findViewById(R.id.replacement_wish);
wishTab.setSelectedTabIndicatorColor(Color.TRANSPARENT);
wishTab.setFocusableInTouchMode(false);
dayWishFragment = LiveNewWishListFragment.newInstance(1);
zhouXinFragment = LiveNewWishListFragment.newInstance(2);
lunarWishFragment = LiveNewWishListFragment.newInstance(3);
seasonalWishFragment = LiveNewWishListFragment.newInstance(4);
ViewList.add(dayWishFragment);
ViewList.add(zhouXinFragment);
ViewList.add(lunarWishFragment);
ViewList.add(seasonalWishFragment);
if (TextUtils.equals(ct, "zh")) {
wishListTop.setBackgroundResource(R.drawable.wish_list_day_zh);
} else {
wishListTop.setBackgroundResource(R.drawable.wish_list_day_en);
}
LiveNewWishListAdapter liveNewWishListAdapter = new LiveNewWishListAdapter(mContext, ViewList);
fragmentViewpager.setAdapter(liveNewWishListAdapter);
fragmentViewpager.setOffscreenPageLimit(1); //预加载页面数
//禁止左右滑动,false为禁止
fragmentViewpager.setUserInputEnabled(false);
for (int i = 0; i < 4; i++) {
TextView wishItem = (TextView) LayoutInflater.from(getContext())
.inflate(R.layout.view_tablaout_wish_item, null, false);
switch (i) {
case 0:
wishItem.setText(R.string.day_wish);
break;
case 1:
wishItem.setText(R.string.zhou_xin);
break;
case 2:
wishItem.setText(R.string.lunar_wish);
break;
case 3:
wishItem.setText(R.string.seasonal_wish);
break;
}
TabLayout.Tab tab = wishTab.newTab().setCustomView(wishItem).setId(i);
wishTab.addTab(tab, i == 0);
}
ViewGroup tabs = (ViewGroup) wishTab.getChildAt(0);
//设置边距,tab宽
for (int i = 0; i < tabs.getChildCount() - 1; i++) {
View tab = tabs.getChildAt(i);
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) tab.getLayoutParams();
layoutParams.setMarginEnd(DpUtil.dp2px(6));
layoutParams.width = DpUtil.dp2px(83);
tab.setLayoutParams(layoutParams);
wishTab.requestLayout();
}
wishTab.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
View customView = tab.getCustomView();
customView.setSelected(true);
fragmentViewpager.setCurrentItem(tab.getId(), false);
type = tab.getId() + 1;
switch (type) {
case 1:
if (TextUtils.equals(ct, "zh")) {
wishListTop.setBackgroundResource(R.drawable.wish_list_day_zh);
} else {
wishListTop.setBackgroundResource(R.drawable.wish_list_day_en);
}
replacementWish.setText(R.string.replacement_wish_day);
break;
case 2:
if (TextUtils.equals(ct, "zh")) {
wishListTop.setBackgroundResource(R.drawable.wish_list_week_zh);
} else {
wishListTop.setBackgroundResource(R.drawable.wish_list_week_en);
}
replacementWish.setText(R.string.replacement_wish_zhou);
break;
case 3:
if (TextUtils.equals(ct, "zh")) {
wishListTop.setBackgroundResource(R.drawable.wish_list_lunar_zh);
} else {
wishListTop.setBackgroundResource(R.drawable.wish_list_lunar_en);
}
replacementWish.setText(R.string.replacement_wish_lunar);
break;
case 4:
if (TextUtils.equals(ct, "zh")) {
wishListTop.setBackgroundResource(R.drawable.wish_list_seasonal_zh);
} else {
wishListTop.setBackgroundResource(R.drawable.wish_list_seasonal_en);
}
replacementWish.setText(R.string.replacement_wish_seasonal);
break;
}
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
View customView = tab.getCustomView();
customView.setSelected(false);
if (dayWish || zhouXin || lunarWish || seasonalWish) {
saveWishDialog(false);
}
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
ViewClicksAntiShake.clicksAntiShake(replacementWish, () -> new XPopup.Builder(getContext())
.asCustom(new ReplacementHintCustomPopup(getContext(), type, type -> {
switch (type) {
case 1:
dayWishFragment.clearGiftListModel();
dayWish = false;
break;
case 2:
zhouXinFragment.clearGiftListModel();
zhouXin = false;
break;
case 3:
lunarWishFragment.clearGiftListModel();
lunarWish = false;
break;
case 4:
seasonalWishFragment.clearGiftListModel();
seasonalWish = false;
break;
}
List<WishModel2> wishList2 = new ArrayList<>();
Gson gson = new Gson();
if (wishList2.size()>10){
ToastUtil.show(R.string.must_hint);
return;
}
LiveNetManager.get(getContext()).
setWishlistV2(type, gson.toJson(wishList2), new HttpCallback<String>() {
@Override
public void onSuccess(String data) {
ToastUtil.show(data);
}
@Override
public void onError(String error) {
ToastUtil.show(R.string.net_error);
}
});
}))
.show());
}
private void initDate() {
}
}

View File

@@ -24,7 +24,9 @@ public class LiveOpenCustomPopup extends CenterPopupView {
//房间类型
private LiveRoomTypeBean liveRoomTypeBean;
private TextView textClarity, textLiveRoomType, textLiveClass, textLiveWishlist, textRobot;
private TextView textClarity, textLiveRoomType, textLiveClass, textLiveWishlist, textRobot, textSay, textCall;
private int status_say, status_call;
public LiveOpenCustomPopup setClassBean(LiveClassBean classBean) {
this.classBean = classBean;
@@ -65,6 +67,8 @@ public class LiveOpenCustomPopup extends CenterPopupView {
textLiveClass = findViewById(R.id.text_live_class);
textLiveWishlist = findViewById(R.id.text_live_wishlist);
textRobot = findViewById(R.id.text_robot);
textSay = findViewById(R.id.text_say);
textCall = findViewById(R.id.text_call);
if (classBean != null) {
textLiveClass.setText(classBean.getName());
}
@@ -114,6 +118,24 @@ public class LiveOpenCustomPopup extends CenterPopupView {
}
}
});
//设置女神说
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.line_say), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
if (callBack != null) {
callBack.openAnchorSay();
}
}
});
//设置联系方式
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.line_call), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
if (callBack != null) {
callBack.openCallMe();
}
}
});
}
public void setSelectClarity(int selectClarity) {
@@ -130,7 +152,27 @@ public class LiveOpenCustomPopup extends CenterPopupView {
}
}
public void setSayStatus(boolean isShow) {
textSay.setText(isShow ? R.string.do_set : R.string.not_set);
}
public void setCallMeStatus(boolean isShow) {
textCall.setText(isShow ? R.string.robot_yes : R.string.robot_no);
}
public LiveOpenCustomPopup setSayStatus(int status) {
this.status_say = status;
return this;
}
public LiveOpenCustomPopup setCallMeStatus(int status) {
this.status_call = status;
return this;
}
public void initDate() {
textSay.setText(status_say == 1 ? R.string.do_set : R.string.not_set);
textCall.setText(status_call == 1 ? R.string.robot_yes : R.string.robot_no);
LiveNetManager.get(getContext())
.getLiveStetUpStatus(String.valueOf(IMLoginManager.get(getContext()).getUserInfo().getId()),
new HttpCallback<LiveStetUpStatusModel>() {
@@ -142,7 +184,7 @@ public class LiveOpenCustomPopup extends CenterPopupView {
@Override
public void onError(String error) {
ToastUtil.show( R.string.net_error);
ToastUtil.show(R.string.net_error);
}
});
@@ -174,5 +216,11 @@ public class LiveOpenCustomPopup extends CenterPopupView {
//打開心願單
void openWishlist();
//设置女神说
void openAnchorSay();
//设置联系方式
void openCallMe();
}
}

Some files were not shown because too many files have changed in this diff Show More