Compare commits
183 Commits
release_ol
...
develop
Author | SHA1 | Date | |
---|---|---|---|
![]() |
515912b40a | ||
![]() |
bf492ed403 | ||
![]() |
5ea7426e7d | ||
![]() |
013ed0a39d | ||
![]() |
1e80959db6 | ||
![]() |
06f31c3e9c | ||
![]() |
1bb3bb1c3e | ||
![]() |
3d478a5017 | ||
![]() |
d329c97f03 | ||
![]() |
d1fd822c42 | ||
![]() |
f86fea11b8 | ||
![]() |
e707da25a8 | ||
![]() |
4af7fcf877 | ||
![]() |
0695a74520 | ||
![]() |
fced114686 | ||
![]() |
3181a115d8 | ||
![]() |
4c48bef21b | ||
![]() |
60d274c79a | ||
![]() |
a48440209a | ||
![]() |
65bcf7a7ca | ||
![]() |
b307db446d | ||
![]() |
bed3184df9 | ||
![]() |
2c4fb0e056 | ||
![]() |
784aeebdf4 | ||
![]() |
043e79681d | ||
![]() |
b6972ee445 | ||
![]() |
4fd1bd73ea | ||
![]() |
afab35a691 | ||
![]() |
d508912a9c | ||
![]() |
ec2e46b0a4 | ||
![]() |
e2cf045ab7 | ||
![]() |
c2cdd5d6f1 | ||
![]() |
5bacadf9df | ||
![]() |
eb81154c1c | ||
![]() |
ae19a0c653 | ||
![]() |
44787e5041 | ||
![]() |
a8f12371a7 | ||
![]() |
950ce098dc | ||
![]() |
720cf52fd0 | ||
![]() |
5d4aa38b93 | ||
![]() |
a2faf14901 | ||
![]() |
665fecb427 | ||
![]() |
6fb428b536 | ||
![]() |
a01a362506 | ||
![]() |
44ad80c708 | ||
![]() |
f212af49f1 | ||
![]() |
3bcac093c7 | ||
![]() |
dd87492ffb | ||
![]() |
de79e73c9a | ||
![]() |
fac1497de3 | ||
![]() |
a8335e915c | ||
![]() |
53820a23c7 | ||
![]() |
8016cc860a | ||
![]() |
95e3e0768c | ||
![]() |
6f73f3f4fb | ||
![]() |
b6524ad94f | ||
![]() |
f5fc2f9d79 | ||
![]() |
be28ed2509 | ||
![]() |
5be60fe7b2 | ||
![]() |
522c4a9f6f | ||
![]() |
e478c9c202 | ||
![]() |
3ac10340d6 | ||
![]() |
a10471d1c2 | ||
![]() |
d47536cc13 | ||
![]() |
641c15a91e | ||
![]() |
f29dc93faa | ||
![]() |
42afa779db | ||
![]() |
d300ef179d | ||
![]() |
ecd6b8da81 | ||
![]() |
dec6e5e0c1 | ||
![]() |
18b680db70 | ||
![]() |
0fd330848c | ||
![]() |
d0d2418dbf | ||
![]() |
a129fb405e | ||
![]() |
91b006422c | ||
![]() |
d83dbe2337 | ||
![]() |
ce27034ca6 | ||
![]() |
340403fe0d | ||
![]() |
ac8dc50955 | ||
![]() |
32ef74df3a | ||
![]() |
e4cb690b68 | ||
![]() |
96de9e153c | ||
![]() |
35032c1f8e | ||
![]() |
3e1ab090aa | ||
![]() |
95aeda920a | ||
![]() |
60d6bbeae8 | ||
![]() |
0b339136cc | ||
![]() |
6e7743960c | ||
![]() |
7709020221 | ||
![]() |
b9d59e9477 | ||
![]() |
321fa1b9ea | ||
![]() |
ff746b5a11 | ||
![]() |
802383b9e8 | ||
![]() |
b41a2e0376 | ||
![]() |
732cea412c | ||
![]() |
52db404fc0 | ||
![]() |
2d954d21ef | ||
![]() |
b7eb1e66fa | ||
![]() |
6491efe708 | ||
![]() |
37ed8facf3 | ||
![]() |
6becbb6226 | ||
![]() |
ea19645fe8 | ||
![]() |
d48844dc14 | ||
![]() |
a939c29e3e | ||
![]() |
e55b4d7348 | ||
![]() |
583d5a139b | ||
![]() |
c7dd6ec61c | ||
![]() |
a58165213d | ||
![]() |
f21e117e7f | ||
![]() |
f9bd5b7a9f | ||
![]() |
b9251a89a5 | ||
![]() |
e81d75a8b8 | ||
![]() |
c691e5f570 | ||
![]() |
0e30b8e303 | ||
![]() |
3325ccaee9 | ||
![]() |
277c1a637e | ||
![]() |
8660f0e826 | ||
![]() |
dc46c16f3e | ||
![]() |
1dfa9e9d25 | ||
![]() |
5376774ab6 | ||
![]() |
cfe2a45e4b | ||
![]() |
d8a39a4729 | ||
![]() |
05935ca7f2 | ||
![]() |
f1ae820a5a | ||
![]() |
5cddd9f18d | ||
![]() |
19d6fed2fb | ||
![]() |
fb1bcfb642 | ||
![]() |
046ae8e04e | ||
![]() |
73f7998445 | ||
![]() |
c68419f2af | ||
![]() |
1f65f99221 | ||
![]() |
5125f08a20 | ||
![]() |
1d9e119f89 | ||
![]() |
30e468bdf3 | ||
![]() |
c5862701f5 | ||
![]() |
66dd5a0f16 | ||
![]() |
da8cbda0fa | ||
![]() |
5158ff178e | ||
![]() |
bf5c6436da | ||
![]() |
c65e7bfc3b | ||
![]() |
3f92ca82e9 | ||
![]() |
5909ccbc6c | ||
![]() |
cf2490b9e2 | ||
![]() |
fab25bd4f6 | ||
![]() |
c616082b21 | ||
![]() |
63cedcc467 | ||
![]() |
8d9781cf56 | ||
![]() |
b935216b6e | ||
![]() |
c5155aed0d | ||
![]() |
2e812f60f5 | ||
![]() |
49810b42b0 | ||
![]() |
6ba4f05b17 | ||
![]() |
8ec2e32240 | ||
![]() |
d740e2bcdb | ||
![]() |
f6068d745d | ||
![]() |
8c02426f6d | ||
![]() |
9eb632116e | ||
![]() |
76cca091d6 | ||
![]() |
16f8cf006a | ||
![]() |
92577ba1f1 | ||
![]() |
892b8192cc | ||
![]() |
71b8b4caf6 | ||
![]() |
b9c165f355 | ||
![]() |
b17077fe17 | ||
![]() |
faec2f542e | ||
![]() |
3defba88a5 | ||
![]() |
ca2b411bac | ||
![]() |
86b9f1b35f | ||
![]() |
10e9a630d2 | ||
![]() |
af3f90c0c8 | ||
![]() |
044fe4b53e | ||
![]() |
7fd56533f7 | ||
![]() |
2b078390e4 | ||
![]() |
8990405c6f | ||
![]() |
15cf083657 | ||
![]() |
529d1500ba | ||
![]() |
4c98e9422c | ||
![]() |
3de4273531 | ||
![]() |
60d60d3578 | ||
![]() |
56fdb706b4 | ||
![]() |
c1a1867511 | ||
![]() |
a59a2897e7 | ||
![]() |
28c2841923 |
151
app/build.gradle
151
app/build.gradle
@@ -3,12 +3,9 @@ apply plugin: 'com.android.application'
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'com.huawei.agconnect'
|
||||
apply plugin: 'com.tencent.vasdolly'
|
||||
apply from: '../mob.gradle'
|
||||
apply plugin: 'android-junk-code'
|
||||
|
||||
def onlyArm64 = Boolean.parseBoolean(only_arm64)
|
||||
|
||||
android {
|
||||
compileSdkVersion COMPILE_SDK_VERSION.toInteger()
|
||||
|
||||
@@ -21,29 +18,40 @@ android {
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
multiDexEnabled true
|
||||
|
||||
ndk {
|
||||
//设置支持的SO库架构
|
||||
if (onlyArm64) {
|
||||
abiFilters "arm64-v8a"
|
||||
} else {
|
||||
abiFilters "armeabi-v7a", "arm64-v8a"
|
||||
}
|
||||
}
|
||||
|
||||
// ndk {
|
||||
// abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86'
|
||||
// }
|
||||
flavorDimensions 'default'
|
||||
}
|
||||
|
||||
// splits {
|
||||
// abi {
|
||||
// enable true
|
||||
// reset()
|
||||
// include 'armeabi-v7a', 'arm64-v8a', 'x86'
|
||||
// universalApk true
|
||||
// }
|
||||
// }
|
||||
|
||||
//在apk文件后边生成版本号信息
|
||||
android.applicationVariants.all {
|
||||
variant ->
|
||||
variant.outputs.all {
|
||||
def date = new Date().format("MMddHHmm", TimeZone.getTimeZone("GMT+08"))
|
||||
outputFileName = "magic_${buildType.name}_v${defaultConfig.versionName}-${date}.apk"
|
||||
android.applicationVariants.configureEach { variant ->
|
||||
variant.outputs.configureEach { output ->
|
||||
def date = new Date().format("MMddHHmm", TimeZone.getTimeZone("GMT+08"))
|
||||
|
||||
def outputFile = output.outputFile
|
||||
if (outputFile == null || !outputFile.name.endsWith('.apk')) {
|
||||
return
|
||||
}
|
||||
|
||||
def abi = output.getFilter(com.android.build.OutputFile.ABI)
|
||||
if (abi == null) {
|
||||
abi = "universal"
|
||||
}
|
||||
outputFileName = "yinmeng_${variant.flavorName}_${buildType.name}_v${defaultConfig.versionName}_${defaultConfig.versionCode}_${abi}_${date}.apk"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
lintOptions {
|
||||
abortOnError false
|
||||
disable 'MissingTranslation'
|
||||
@@ -148,12 +156,13 @@ android {
|
||||
}
|
||||
|
||||
debug {
|
||||
println("minifyEnabled = " + minify_enabled)
|
||||
buildConfigField "String", "BASE_URL", "\"http://beta.api.nnbc123.cn/\""
|
||||
buildConfigField "String", "WEB_URL", "\"http://beta.api.nnbc123.cn\""
|
||||
buildConfigField "String", "BASE_URL_DEBUG", "BASE_URL"
|
||||
buildConfigField "String", "BASE_URL_STAGING", "\"https://api.nnbc123.cn/\""
|
||||
buildConfigField "String", "BASE_URL_RELEASE", "\"https://api.nnbc123.cn/\""
|
||||
minifyEnabled false
|
||||
minifyEnabled minify_enabled.toBoolean() // 是否混淆
|
||||
shrinkResources false
|
||||
signingConfig signingConfigs.v2
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
@@ -171,6 +180,64 @@ android {
|
||||
|
||||
buildToolsVersion = '30.0.3'
|
||||
|
||||
productFlavors {
|
||||
official {
|
||||
ndk {
|
||||
abiFilters 'armeabi-v7a', 'arm64-v8a'
|
||||
}
|
||||
}
|
||||
fir {
|
||||
ndk {
|
||||
abiFilters 'armeabi-v7a', 'arm64-v8a'
|
||||
}
|
||||
}
|
||||
mlq {
|
||||
ndk {
|
||||
abiFilters 'x86'
|
||||
}
|
||||
}
|
||||
yingyongbao {
|
||||
ndk {
|
||||
abiFilters 'armeabi-v7a'
|
||||
}
|
||||
}
|
||||
vivo {
|
||||
ndk {
|
||||
abiFilters 'arm64-v8a'
|
||||
}
|
||||
}
|
||||
oppo {
|
||||
ndk {
|
||||
abiFilters 'arm64-v8a'
|
||||
}
|
||||
}
|
||||
xiaomi {
|
||||
ndk {
|
||||
abiFilters 'arm64-v8a'
|
||||
}
|
||||
}
|
||||
huawei {
|
||||
ndk {
|
||||
abiFilters 'arm64-v8a'
|
||||
}
|
||||
}
|
||||
rongyao {
|
||||
ndk {
|
||||
abiFilters 'arm64-v8a'
|
||||
}
|
||||
}
|
||||
kuaishou_01 {
|
||||
ndk {
|
||||
abiFilters 'armeabi-v7a', 'arm64-v8a'
|
||||
}
|
||||
}
|
||||
}
|
||||
productFlavors.all { flavor ->
|
||||
flavor.manifestPlaceholders = [
|
||||
// 渠道
|
||||
CHANNEL_VALUE : name,
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -178,7 +245,7 @@ dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
|
||||
implementation fileTree(dir: 'aliyun-libs', include: ['*.jar', '*.aar'])
|
||||
implementation 'androidx.appcompat:appcompat:1.4.1'
|
||||
implementation 'com.google.android.material:material:1.4.+'
|
||||
implementation 'com.google.android.material:material:1.6.1'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||
@@ -247,7 +314,7 @@ dependencies {
|
||||
//oppo推送需要
|
||||
implementation 'commons-codec:commons-codec:1.6'
|
||||
|
||||
api 'com.tencent.vasdolly:helper:3.0.3'
|
||||
// api 'com.tencent.vasdolly:helper:3.0.3'
|
||||
implementation "io.github.tencent:vap:2.0.24"
|
||||
|
||||
implementation 'com.github.mmin18:realtimeblurview:1.2.1'
|
||||
@@ -265,36 +332,20 @@ repositories {
|
||||
|
||||
}
|
||||
|
||||
channel {
|
||||
//多渠道包的输出目录,默认为new File(project.buildDir,"channel")
|
||||
outputDir = new File(project.buildDir, "channelapk")
|
||||
//多渠道包的命名规则,默认为:${appName}-${versionName}-${versionCode}-${flavorName}-${buildType}-${buildTime}
|
||||
def only64 = onlyArm64 ? "-only64" : ""
|
||||
apkNameFormat = 'yinmeng-${buildType}only64-${flavorName}-v${versionName}-${buildTime}'.replace("only64", only64)
|
||||
//快速模式:生成渠道包时不进行校验(速度可以提升10倍以上,默认为false)
|
||||
fastMode = false
|
||||
//buildTime的时间格式,默认格式:yyyyMMdd-HHmmss
|
||||
buildTimeDateFormat = 'MMddHHmm'
|
||||
//低内存模式(仅针对V2签名,默认为false):只把签名块、中央目录和EOCD读取到内存,不把最大头的内容块读取到内存,在手机上合成APK时,可以使用该模式
|
||||
lowMemory = false
|
||||
}
|
||||
|
||||
android.applicationVariants.all { variant ->
|
||||
print("variant.name=" + variant.name)
|
||||
switch (variant.name) {//变体名称,如果没有设置productFlavors就是buildType名称,如果有设置productFlavors就是flavor+buildType,例如(freeRelease、proRelease)
|
||||
case "release":
|
||||
androidJunkCode.configMap.put(variant.name, {
|
||||
packageBase = "com.nnbc123.plugin.ui" //生成java类根包名
|
||||
packageCount = 30 //生成包数量
|
||||
activityCountPerPackage = 30 //每个包下生成Activity类数量
|
||||
excludeActivityJavaFile = false
|
||||
//是否排除生成Activity的Java文件,默认false(layout和写入AndroidManifest.xml还会执行),主要用于处理类似神策全埋点编译过慢问题
|
||||
otherCountPerPackage = 50 //每个包下生成其它类的数量
|
||||
methodCountPerClass = 20 //每个类下生成方法数量
|
||||
resPrefix = "mango_" //生成的layout、drawable、string等资源名前缀
|
||||
drawableCount = 300 //生成drawable资源数量
|
||||
stringCount = 300 //生成string数量
|
||||
})
|
||||
break
|
||||
if (variant.name.contains("release") || variant.name.contains("Release")) {
|
||||
androidJunkCode.configMap.put(variant.name, {
|
||||
packageBase = "com.nnbc123.plugin.ui" //生成java类根包名
|
||||
packageCount = 30 //生成包数量
|
||||
activityCountPerPackage = 30 //每个包下生成Activity类数量
|
||||
excludeActivityJavaFile = false
|
||||
//是否排除生成Activity的Java文件,默认false(layout和写入AndroidManifest.xml还会执行),主要用于处理类似神策全埋点编译过慢问题
|
||||
otherCountPerPackage = 50 //每个包下生成其它类的数量
|
||||
methodCountPerClass = 20 //每个类下生成方法数量
|
||||
resPrefix = "mango_" //生成的layout、drawable、string等资源名前缀
|
||||
drawableCount = 300 //生成drawable资源数量
|
||||
stringCount = 300 //生成string数量
|
||||
})
|
||||
}
|
||||
}
|
Binary file not shown.
BIN
app/libs/SudMGP-v1.3.6.1181.aar
Normal file
BIN
app/libs/SudMGP-v1.3.6.1181.aar
Normal file
Binary file not shown.
2
app/proguard-rules.pro
vendored
2
app/proguard-rules.pro
vendored
@@ -460,4 +460,4 @@
|
||||
# For BannerViewPager
|
||||
-keep class androidx.recyclerview.widget.** { *; }
|
||||
-keep class androidx.viewpager2.widget.** { *; }
|
||||
|
||||
-keep class io.agora.**{*;}
|
||||
|
@@ -66,7 +66,7 @@
|
||||
android:protectionLevel="signature" />
|
||||
|
||||
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
|
||||
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"/>
|
||||
<!-- 适配安卓12&11获取当前已安装的所有应用列表-->
|
||||
<queries>
|
||||
<intent>
|
||||
@@ -86,6 +86,10 @@
|
||||
android:theme="@style/MyMaterialTheme"
|
||||
android:usesCleartextTraffic="true"
|
||||
tools:replace="android:name,android:allowBackup">
|
||||
<!-- 多渠道 -->
|
||||
<meta-data
|
||||
android:name="CHANNEL"
|
||||
android:value="${CHANNEL_VALUE}" />
|
||||
<!-- 刘海屏适配 begin -->
|
||||
<!-- 小米 -->
|
||||
<meta-data
|
||||
@@ -212,14 +216,14 @@
|
||||
<service
|
||||
android:name="com.xiaomi.mipush.sdk.PushMessageHandler"
|
||||
android:enabled="true"
|
||||
android:exported="false" />
|
||||
android:exported="true" />
|
||||
<service
|
||||
android:name="com.xiaomi.mipush.sdk.MessageHandleService"
|
||||
android:enabled="true" /> <!-- 注:此service必须在2.2.5版本以后(包括2.2.5版本)加入 -->
|
||||
<receiver
|
||||
android:name="com.xiaomi.push.service.receivers.NetworkStatusReceiver"
|
||||
android:exported="true"
|
||||
tools:node="remove">>
|
||||
tools:node="remove">
|
||||
<intent-filter>
|
||||
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
|
||||
|
||||
@@ -1177,7 +1181,7 @@
|
||||
android:name="com.nnbc123.app.shipantics.RadishRankingActivity"
|
||||
android:theme="@style/room_message_activity" />
|
||||
<activity
|
||||
android:name="com.nnbc123.app.home.activity.MoreRoomActivity"
|
||||
android:name="com.nnbc123.app.game_room.GameRoomActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.nnbc123.app.avroom.wishlist.WishListCreateActivity"
|
||||
|
BIN
app/src/main/assets/svga/home_living_white.svga
Normal file
BIN
app/src/main/assets/svga/home_living_white.svga
Normal file
Binary file not shown.
BIN
app/src/main/assets/svga/home_voice_playing.svga
Normal file
BIN
app/src/main/assets/svga/home_voice_playing.svga
Normal file
Binary file not shown.
BIN
app/src/main/assets/svga/refresh_header.svga
Normal file
BIN
app/src/main/assets/svga/refresh_header.svga
Normal file
Binary file not shown.
BIN
app/src/main/assets/svga/user_in_live.svga
Normal file
BIN
app/src/main/assets/svga/user_in_live.svga
Normal file
Binary file not shown.
@@ -2,12 +2,10 @@ package com.nnbc123.app;
|
||||
|
||||
import static com.nnbc123.core.channel_page.model.ChannelPageModel.KEY_FLAG_VALID_CHANNEL_PAGE;
|
||||
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.text.TextUtils;
|
||||
@@ -16,7 +14,6 @@ import android.util.SparseArray;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
@@ -43,7 +40,6 @@ import com.nnbc123.app.application.ActivityStackManager;
|
||||
import com.nnbc123.app.avroom.activity.AVRoomActivity;
|
||||
import com.nnbc123.app.avroom.newuserchargegift.NewUserChargeGiftDialog;
|
||||
import com.nnbc123.app.base.BaseMvpActivity;
|
||||
import com.nnbc123.app.common.widget.CircleImageView;
|
||||
import com.nnbc123.app.common.widget.DragLayout;
|
||||
import com.nnbc123.app.community.dynamic.view.DynamicDetailActivity;
|
||||
import com.nnbc123.app.community.publish.view.PublishActivity;
|
||||
@@ -52,10 +48,9 @@ import com.nnbc123.app.family.view.activity.FamilyHomeActivity;
|
||||
import com.nnbc123.app.home.HomeViewModel;
|
||||
import com.nnbc123.app.home.dialog.NewUserHelloDialog;
|
||||
import com.nnbc123.app.home.dialog.ProtocolUpdateDialog;
|
||||
import com.nnbc123.app.home.fragment.HomeFragment;
|
||||
import com.nnbc123.app.home.fragment.home.HomeFragment;
|
||||
import com.nnbc123.app.home.fragment.MeFragment;
|
||||
import com.nnbc123.app.home.fragment.MsgFragment;
|
||||
import com.nnbc123.app.home.fragment.PartyFragment;
|
||||
import com.nnbc123.app.home.fragment.PmModeFragment;
|
||||
import com.nnbc123.app.home.presenter.MainPresenter;
|
||||
import com.nnbc123.app.home.view.IMainView;
|
||||
@@ -77,7 +72,6 @@ import com.nnbc123.app.ui.patriarch.help.PmDialogShowMrg;
|
||||
import com.nnbc123.app.ui.utils.ImageLoadUtils;
|
||||
import com.nnbc123.app.ui.utils.ImageLoadUtilsV2;
|
||||
import com.nnbc123.app.ui.webview.CommonWebViewActivity;
|
||||
import com.nnbc123.app.ui.widget.LivingIconView;
|
||||
import com.nnbc123.app.ui.widget.MainTabLayout;
|
||||
import com.nnbc123.app.utils.CleanLeakUtils;
|
||||
import com.nnbc123.app.utils.PushMessageHandler;
|
||||
@@ -176,7 +170,6 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
private Runnable touchRunnable;
|
||||
|
||||
{
|
||||
fragmentArray.put(MainTabType.TAB_TYPE_PARTY, new PartyFragment());
|
||||
fragmentArray.put(MainTabType.TAB_TYPE_HOME, new HomeFragment());
|
||||
fragmentArray.put(MainTabType.TAB_TYPE_MSG, new MsgFragment());
|
||||
fragmentArray.put(MainTabType.TAB_TYPE_SQUARE, new SquareFragment());
|
||||
@@ -508,7 +501,7 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
getMvpPresenter().exitRoom();
|
||||
QuickPassLoginAct.start(MainActivity.this);
|
||||
PmDialogShowMrg.get().onLogout();
|
||||
CustomerServerHelper.logout();
|
||||
// CustomerServerHelper.logout();
|
||||
}
|
||||
|
||||
public void onNeedLogin() {
|
||||
@@ -664,7 +657,7 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
|
||||
onTabClick(mCurrentTabType);
|
||||
|
||||
CustomerServerHelper.onLoginInfoUpdate(UserUtils.getUserInfo());
|
||||
// CustomerServerHelper.onLoginInfoUpdate(UserUtils.getUserInfo());
|
||||
}
|
||||
|
||||
|
||||
|
@@ -28,7 +28,9 @@ import androidx.multidex.MultiDex;
|
||||
|
||||
import com.bumptech.glide.request.target.ViewTarget;
|
||||
import com.bytedance.hume.readapk.HumeSDK;
|
||||
import com.chuhai.utils.MetaDataUtils;
|
||||
import com.coorchice.library.utils.LogUtils;
|
||||
import com.facebook.stetho.Stetho;
|
||||
import com.heytap.msp.push.HeytapPushManager;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.huawei.hms.support.common.ActivityMgr;
|
||||
@@ -60,7 +62,6 @@ import com.scwang.smartrefresh.layout.footer.ClassicsFooter;
|
||||
import com.tencent.bugly.Bugly;
|
||||
import com.tencent.bugly.beta.Beta;
|
||||
import com.tencent.bugly.crashreport.CrashReport;
|
||||
import com.tencent.vasdolly.helper.ChannelReaderUtil;
|
||||
import com.umeng.analytics.MobclickAgent;
|
||||
import com.umeng.commonsdk.UMConfigure;
|
||||
import com.nnbc123.app.BuildConfig;
|
||||
@@ -212,12 +213,12 @@ public class XChatApplication extends BaseApp {
|
||||
// 初始化 sp
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
String channel = "";
|
||||
channel = ChannelReaderUtil.getChannel(instance);
|
||||
String channel;
|
||||
channel = MetaDataUtils.INSTANCE.getStringData(Constants.CHANNEL_KEY, application);
|
||||
if (TextUtils.isEmpty(channel)) {
|
||||
channel = "official";
|
||||
}
|
||||
|
||||
Log.d("XChatApplication", "channel:" + channel);
|
||||
BasicConfig.INSTANCE.setOriginalChannel(channel);
|
||||
|
||||
//头条分包渠道
|
||||
@@ -227,6 +228,7 @@ public class XChatApplication extends BaseApp {
|
||||
channel = byteDanceChannel;
|
||||
}
|
||||
}
|
||||
Log.d("XChatApplication", "channel2:" + channel);
|
||||
BasicConfig.INSTANCE.setChannel(channel);
|
||||
|
||||
initEnv();
|
||||
@@ -275,6 +277,7 @@ public class XChatApplication extends BaseApp {
|
||||
ViewTarget.setTagId(R.id.tag_glide);
|
||||
|
||||
init(channel);
|
||||
initStetho(context);
|
||||
|
||||
if (!TextUtils.isEmpty(channel)) {
|
||||
CrashReport.setAppChannel(context, channel);
|
||||
@@ -304,7 +307,7 @@ public class XChatApplication extends BaseApp {
|
||||
// 集成测试
|
||||
UMConfigure.setLogEnabled(BuildConfig.DEBUG);
|
||||
} else {
|
||||
CustomerServerHelper.init(instance, null);
|
||||
// CustomerServerHelper.init(instance, null);
|
||||
}
|
||||
|
||||
LogUtils.d("init time = " + (System.currentTimeMillis() - startTime) + "ms");
|
||||
@@ -387,6 +390,7 @@ public class XChatApplication extends BaseApp {
|
||||
options.messageNotifierCustomization = messageNotifierCustomization;
|
||||
|
||||
options.appKey = Constants.nimAppKey;
|
||||
options.shouldConsiderRevokedMessageUnreadCount = true;
|
||||
|
||||
// 配置保存图片,文件,log 等数据的目录
|
||||
// 如果 options 中没有设置这个值,SDK 会使用下面代码示例中的位置作为 SDK 的数据目录。
|
||||
@@ -663,4 +667,18 @@ public class XChatApplication extends BaseApp {
|
||||
}
|
||||
GlobalHandleManager.get().unInit();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化Stetho(网络调试)
|
||||
*/
|
||||
private static void initStetho(Context context) {
|
||||
if (Env.isDebug()) {
|
||||
Stetho.initialize(
|
||||
Stetho.newInitializerBuilder(context)
|
||||
.enableDumpapp(Stetho.defaultDumperPluginsProvider(context))
|
||||
.enableWebKitInspector(Stetho.defaultInspectorModulesProvider(context))
|
||||
.build()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -93,7 +93,7 @@ public class AudioPlayerHelper {
|
||||
|
||||
try {
|
||||
player.setDataSource(filePath);
|
||||
} catch (IOException e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
preparing = true;
|
||||
@@ -122,6 +122,9 @@ public class AudioPlayerHelper {
|
||||
}
|
||||
|
||||
public void endPlay() {
|
||||
if (listener != null) {
|
||||
listener.onCompletion();
|
||||
}
|
||||
handler.removeMessages(WHAT_STATUS.COUNT_PLAY);
|
||||
if (player != null) {
|
||||
if (preparing) {
|
||||
|
@@ -35,7 +35,10 @@ class PrivilegeViewModel : BaseViewModel() {
|
||||
description: String,
|
||||
effectDay: Int,
|
||||
erbanNoStr: String,
|
||||
cardUrl: String
|
||||
cardUrl: String,
|
||||
duration: Long?,
|
||||
cardType: Int,
|
||||
effectUrl: String?,
|
||||
) {
|
||||
safeLaunch(
|
||||
block = {
|
||||
@@ -46,6 +49,9 @@ class PrivilegeViewModel : BaseViewModel() {
|
||||
effectDay,
|
||||
erbanNoStr,
|
||||
cardUrl,
|
||||
duration,
|
||||
cardType,
|
||||
effectUrl,
|
||||
AvRoomDataManager.get().roomUid.toString()
|
||||
)
|
||||
}
|
||||
@@ -59,5 +65,4 @@ class PrivilegeViewModel : BaseViewModel() {
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
}
|
@@ -2,15 +2,12 @@ package com.nnbc123.app.avroom.activity;
|
||||
|
||||
|
||||
import static android.view.View.VISIBLE;
|
||||
import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ALL_SERVICE_GIFT;
|
||||
import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_HEADER_TYPE_GIFT;
|
||||
import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT;
|
||||
import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY;
|
||||
import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ROOM_PK;
|
||||
import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_ROOM_PK_NOTIFY;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
@@ -65,10 +62,6 @@ import com.nnbc123.app.ui.user.UserInfoActivity;
|
||||
import com.nnbc123.app.ui.utils.ImageLoadUtils;
|
||||
import com.nnbc123.app.ui.webview.CommonWebViewActivity;
|
||||
import com.nnbc123.app.ui.widget.NobleOpenNoticeView;
|
||||
import com.nnbc123.app.ui.widget.dialog.AllServiceGiftDialog;
|
||||
import com.nnbc123.app.ui.widget.dialog.AllServiceGiftLevelOneDialog;
|
||||
import com.nnbc123.app.ui.widget.dialog.AllServiceGiftLevelThreeDialog;
|
||||
import com.nnbc123.app.ui.widget.dialog.AllServiceGiftLevelTwoDialog;
|
||||
import com.nnbc123.app.ui.widget.dialog.MonsterDialog;
|
||||
import com.nnbc123.app.ui.widget.marqueeview.Utils;
|
||||
import com.nnbc123.app.utils.UserUtils;
|
||||
@@ -92,7 +85,6 @@ import com.nnbc123.core.monsterhunting.bean.MonsterHuntingResult;
|
||||
import com.nnbc123.core.monsterhunting.bean.MonsterInfo;
|
||||
import com.nnbc123.core.monsterhunting.bean.MonsterProtocol;
|
||||
import com.nnbc123.core.monsterhunting.manager.MonsterDataManager;
|
||||
import com.nnbc123.core.noble.AllServiceGiftProtocol;
|
||||
import com.nnbc123.core.noble.NobleInfo;
|
||||
import com.nnbc123.core.noble.NobleResourceType;
|
||||
import com.nnbc123.core.noble.NobleUtil;
|
||||
@@ -119,7 +111,6 @@ import com.nnbc123.core.utils.LogUtils;
|
||||
import com.nnbc123.core.utils.StringUtils;
|
||||
import com.nnbc123.library.base.factory.CreatePresenter;
|
||||
import com.nnbc123.library.rxbus.RxBus;
|
||||
import com.nnbc123.library.utils.JavaUtil;
|
||||
import com.nnbc123.library.utils.SingleToastUtil;
|
||||
import com.nnbc123.library.utils.UIUtils;
|
||||
import com.opensource.svgaplayer.SVGADrawable;
|
||||
@@ -137,7 +128,6 @@ import java.lang.ref.WeakReference;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -197,8 +187,6 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
/*********************************显示全服礼物***************************************/
|
||||
|
||||
private GiftBroadcastObserver giftObserver;
|
||||
private Dialog giftDialog;
|
||||
private LinkedList<AllServiceGiftProtocol.DataBean> giftList;
|
||||
private boolean isResume = true;
|
||||
@Nullable
|
||||
private SingleRoomTipDialog singleRoomTipDialog;
|
||||
@@ -501,9 +489,6 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
super.onResume();
|
||||
AvRoomDataManager.get().roomNoDestory = true;
|
||||
registerGiftBroadcastMessage(true);
|
||||
if (giftList != null) {
|
||||
giftList.clear();
|
||||
}
|
||||
isResume = true;
|
||||
}
|
||||
|
||||
@@ -889,7 +874,10 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
if (AvRoomDataManager.get().haveStartDragon) {
|
||||
giveUpDragonBar();
|
||||
}
|
||||
|
||||
if (singleRoomTipDialog != null && singleRoomTipDialog.isAdded()) {
|
||||
singleRoomTipDialog.dismissAllowingStateLoss();
|
||||
singleRoomTipDialog = null;
|
||||
}
|
||||
// 避免 ISE
|
||||
if (mPwdDialogFragment != null && mPwdDialogFragment.isAdded()
|
||||
&& !isFinishing()) {
|
||||
@@ -901,12 +889,6 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
monsterDialog.dismiss();
|
||||
monsterDialog = null;
|
||||
}
|
||||
if (giftDialog != null && giftDialog.isShowing()) {
|
||||
giftDialog.setOnDismissListener(null);
|
||||
giftDialog.dismiss();
|
||||
giftDialog = null;
|
||||
}
|
||||
|
||||
if (limitEnterRoomHelper != null) {
|
||||
limitEnterRoomHelper.release();
|
||||
}
|
||||
@@ -1187,30 +1169,6 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
if (baseProtocol == null) return;
|
||||
|
||||
switch (baseProtocol.getFirst()) {
|
||||
case CUSTOM_MSG_HEADER_TYPE_GIFT:
|
||||
if (!isValid()) return;
|
||||
if (giftList == null) {
|
||||
giftList = new LinkedList<>();
|
||||
}
|
||||
int second2 = baseProtocol.getSecond();
|
||||
AllServiceGiftProtocol.DataBean data = JSON.parseObject(String.valueOf(baseProtocol.getData()), AllServiceGiftProtocol.DataBean.class);
|
||||
if (data == null || data.getGiftUrl() == null || data.isCeremonyGift())
|
||||
return;
|
||||
giftList.add(data);
|
||||
if (second2 == CUSTOM_MSG_ALL_SERVICE_GIFT) {
|
||||
if (giftDialog != null && giftDialog.isShowing()) {
|
||||
// 如果当前以及有礼物弹窗在展示,则需要等到他 dismiss 后再显示下一个
|
||||
AllServiceGiftProtocol.DataBean dataBean = giftList.peekFirst();
|
||||
if (dataBean != null) {
|
||||
return;
|
||||
} else {
|
||||
giftDialog.dismiss();
|
||||
}
|
||||
} else {
|
||||
showGiftDialog();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CUSTOM_MSG_LUCKY_GIFT:
|
||||
if (baseProtocol.getSecond() == CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY) {
|
||||
RoomReceivedLuckyGiftAttachment attachment = new RoomReceivedLuckyGiftAttachment(CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY);
|
||||
@@ -1233,39 +1191,6 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
}
|
||||
}
|
||||
|
||||
private void showGiftDialog() {
|
||||
if (giftList.size() == 0) return;
|
||||
giftDialog = generateAllServiceGiftDialog(this, giftList.peekFirst());
|
||||
giftDialog.setOnDismissListener(dialog -> {
|
||||
giftList.pollFirst();
|
||||
AllServiceGiftProtocol.DataBean dataBean = giftList.peekFirst();
|
||||
if (dataBean != null) {
|
||||
if (isValid()) {
|
||||
showGiftDialog();
|
||||
} else {
|
||||
giftList.clear();
|
||||
}
|
||||
}
|
||||
});
|
||||
giftDialog.show();
|
||||
}
|
||||
|
||||
private AllServiceGiftDialog generateAllServiceGiftDialog(Context context, AllServiceGiftProtocol.DataBean dataBean) {
|
||||
switch (JavaUtil.str2int(dataBean.getLevelNum())) {
|
||||
default:
|
||||
case AllServiceGiftDialog.ALL_SERVICE_GIFT_LEVEL_1:
|
||||
return new AllServiceGiftLevelOneDialog(context, dataBean);
|
||||
|
||||
case AllServiceGiftDialog.ALL_SERVICE_GIFT_LEVEL_2:
|
||||
|
||||
return new AllServiceGiftLevelTwoDialog(context, dataBean);
|
||||
|
||||
case AllServiceGiftDialog.ALL_SERVICE_GIFT_LEVEL_3:
|
||||
return new AllServiceGiftLevelThreeDialog(context, dataBean);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
|
@@ -13,7 +13,6 @@ import android.widget.RelativeLayout;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
|
||||
import com.huawei.multimedia.audiokit.utils.LogUtils;
|
||||
import com.netease.nim.uikit.StatusBarUtil;
|
||||
import com.netease.nimlib.sdk.chatroom.ChatRoomMessageBuilder;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
|
||||
@@ -54,7 +53,6 @@ import com.nnbc123.library.net.rxnet.callback.CallBack;
|
||||
import com.nnbc123.library.utils.CommonUtils;
|
||||
import com.nnbc123.library.utils.JavaUtil;
|
||||
import com.nnbc123.library.utils.ListUtils;
|
||||
import com.nnbc123.library.utils.LogUtil;
|
||||
import com.nnbc123.library.utils.codec.DESUtils;
|
||||
import com.nnbc123.library.utils.config.BasicConfig;
|
||||
|
||||
@@ -537,7 +535,9 @@ public class RoomSettingActivity extends BaseMvpActivity<IRoomSettingView, RoomS
|
||||
}
|
||||
List<String> labels = new ArrayList<>();
|
||||
for (RoomSettingTabInfo tabInfo : tabInfoList) {
|
||||
labels.add(tabInfo.getName());
|
||||
if (tabInfo.getName() != null) {
|
||||
labels.add(tabInfo.getName());
|
||||
}
|
||||
}
|
||||
new SelectLabelDialog(this, "房间标签", labels, roomInfo.getRoomTag(), (label, data, position) -> {
|
||||
mSelectTabInfo = tabInfoList.get(position);
|
||||
@@ -567,7 +567,9 @@ public class RoomSettingActivity extends BaseMvpActivity<IRoomSettingView, RoomS
|
||||
}
|
||||
List<String> labels = new ArrayList<>();
|
||||
for (SingleRoomSortInfo tabInfo : tabInfoList) {
|
||||
labels.add(tabInfo.getSortName());
|
||||
if (tabInfo.getSortName() != null) {
|
||||
labels.add(tabInfo.getSortName());
|
||||
}
|
||||
}
|
||||
new SelectLabelDialog(this, "房间分类", labels, roomInfo.getRoomTag(), (label, data, position) -> {
|
||||
singleRoomSortId = tabInfoList.get(position).getId();
|
||||
|
@@ -17,6 +17,7 @@ import com.netease.nimlib.sdk.RequestCallbackWrapper;
|
||||
import com.netease.nimlib.sdk.uinfo.constant.GenderEnum;
|
||||
import com.netease.nimlib.sdk.uinfo.model.NimUserInfo;
|
||||
import com.nnbc123.app.R;
|
||||
import com.nnbc123.app.support.LevelIconHelper;
|
||||
import com.nnbc123.app.ui.utils.ImageLoadUtils;
|
||||
import com.nnbc123.app.ui.widget.NobleAvatarView;
|
||||
import com.nnbc123.app.utils.RegexUtil;
|
||||
@@ -97,20 +98,25 @@ public class OnlineUserAdapter extends BaseMultiItemQuickAdapter<OnlineChatMembe
|
||||
// 官字
|
||||
baseViewHolder.getView(R.id.iv_user_official).setVisibility(onlineChatMember.isOfficial() ? View.VISIBLE : View.GONE);
|
||||
//经验等级
|
||||
AppCompatImageView ivUserExper = baseViewHolder.getView(R.id.iv_user_exper);
|
||||
String experLevelUrl = NobleUtil.getLevel(UserLevelResourceType.EXPER_URL, onlineChatMember.chatRoomMember);
|
||||
boolean isExperLevelUrlEmpty = TextUtils.isEmpty(experLevelUrl);
|
||||
ivUserExper.setVisibility(!isExperLevelUrlEmpty ? View.VISIBLE : View.GONE);
|
||||
if (!isExperLevelUrlEmpty) {
|
||||
ImageLoadUtils.loadImage(mContext, experLevelUrl, ivUserExper);
|
||||
AppCompatImageView wealthView = baseViewHolder.getView(R.id.iv_user_exper);
|
||||
Integer wealthIconId = LevelIconHelper.INSTANCE.getWealthIconByUrl(experLevelUrl);
|
||||
if (wealthIconId != null) {
|
||||
wealthView.setImageResource(wealthIconId);
|
||||
wealthView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
wealthView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
//魅力等级
|
||||
AppCompatImageView ivUserCharm = baseViewHolder.getView(R.id.iv_user_charm);
|
||||
String charmLevelUrl = NobleUtil.getLevel(UserLevelResourceType.CHARM_URL, onlineChatMember.chatRoomMember);
|
||||
boolean isCharmLevelUrlEmpty = TextUtils.isEmpty(charmLevelUrl);
|
||||
ivUserCharm.setVisibility(!isCharmLevelUrlEmpty ? View.VISIBLE : View.GONE);
|
||||
if (!isCharmLevelUrlEmpty) {
|
||||
ImageLoadUtils.loadImage(mContext, charmLevelUrl, ivUserCharm);
|
||||
AppCompatImageView charmView = baseViewHolder.getView(R.id.iv_user_charm);
|
||||
Integer charmIconId = LevelIconHelper.INSTANCE.getCharmIconByUrl(charmLevelUrl);
|
||||
if (charmIconId != null) {
|
||||
charmView.setImageResource(charmIconId);
|
||||
charmView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
charmView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// 官方主播铭牌标识
|
||||
|
@@ -1,36 +0,0 @@
|
||||
package com.nnbc123.app.avroom.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMember;
|
||||
import com.nnbc123.app.R;
|
||||
import com.nnbc123.app.ui.utils.ImageLoadUtils;
|
||||
import com.nnbc123.app.ui.widget.magicindicator.buildins.UIUtil;
|
||||
|
||||
|
||||
/**
|
||||
* 右滑操作的,写了暂时不用
|
||||
* Created by lvzebiao
|
||||
*/
|
||||
|
||||
public class RoomBlackListAdapter extends BaseQuickAdapter<ChatRoomMember, BaseViewHolder>{
|
||||
|
||||
private Context context;
|
||||
|
||||
private int itemWidth;
|
||||
|
||||
public RoomBlackListAdapter(Context context) {
|
||||
super(R.layout.list_item_room_black);
|
||||
this.context = context;
|
||||
itemWidth = UIUtil.getScreenWidth(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, ChatRoomMember chatRoomMember) {
|
||||
helper.setText(R.id.nick, chatRoomMember.getNick());
|
||||
ImageLoadUtils.loadAvatar(context, chatRoomMember.getAvatar(), helper.getView(R.id.avatar));
|
||||
helper.getView(R.id.layout_item).getLayoutParams().width = itemWidth;
|
||||
}
|
||||
}
|
@@ -1,27 +0,0 @@
|
||||
package com.nnbc123.app.avroom.adapter;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentPagerAdapter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RoomRankFragmentPageAdapter extends FragmentPagerAdapter {
|
||||
|
||||
private List<Fragment> fragmentList;
|
||||
|
||||
public RoomRankFragmentPageAdapter(FragmentManager fm, List<Fragment> fragmentList) {
|
||||
super(fm);
|
||||
this.fragmentList = fragmentList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
return fragmentList.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return fragmentList.size();
|
||||
}
|
||||
}
|
@@ -1,63 +0,0 @@
|
||||
package com.nnbc123.app.avroom.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.nnbc123.app.R;
|
||||
import com.nnbc123.app.avroom.fragment.RoomRankDialogUtils;
|
||||
import com.nnbc123.app.common.widget.CircleImageView;
|
||||
import com.nnbc123.app.ui.utils.ImageLoadUtils;
|
||||
import com.nnbc123.core.room.bean.RoomRankHalfHourRankInfo;
|
||||
import com.nnbc123.core.room.bean.RoomRankMultiItem;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class RoomRankHalfHourListAdapter extends BaseMultiItemQuickAdapter<RoomRankMultiItem, BaseViewHolder> {
|
||||
|
||||
public final static int TYPE_TIPS = 4;
|
||||
|
||||
public RoomRankHalfHourListAdapter(Context context) {
|
||||
super(new ArrayList<>());
|
||||
addItemType(RoomRankMultiItem.TYPE_LINEAR, R.layout.item_room_rank_layout);
|
||||
addItemType(RoomRankMultiItem.TYPE_EMPTY, R.layout.item_empty_list);
|
||||
addItemType(TYPE_TIPS, R.layout.item_rank_half_tips);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder baseViewHolder, RoomRankMultiItem roomConsumeInfo) {
|
||||
if (roomConsumeInfo == null) {
|
||||
return;
|
||||
}
|
||||
if (roomConsumeInfo.getItemType() == RoomRankMultiItem.TYPE_LINEAR) {
|
||||
setLinearData(baseViewHolder, roomConsumeInfo);
|
||||
} else if (roomConsumeInfo.getItemType() == RoomRankMultiItem.TYPE_EMPTY) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void setLinearData(BaseViewHolder baseViewHolder, RoomRankMultiItem roomConsumeInfo) {
|
||||
if (roomConsumeInfo == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
RoomRankHalfHourRankInfo roomRankHalfHourRankInfo = (RoomRankHalfHourRankInfo) roomConsumeInfo.getData();
|
||||
if (roomRankHalfHourRankInfo == null)
|
||||
return;
|
||||
|
||||
// 值
|
||||
TextView valueTV = baseViewHolder.getView(R.id.tv_room_rank_value);
|
||||
valueTV.setText(RoomRankDialogUtils.getRoomRankValueText(roomRankHalfHourRankInfo.getTotalNum()));
|
||||
|
||||
int drawable = RoomRankDialogUtils.getNumberImage(roomRankHalfHourRankInfo.getSeqNo());
|
||||
if (drawable != 0)
|
||||
baseViewHolder.setImageResource(R.id.iv_number, drawable);
|
||||
// 标题
|
||||
baseViewHolder.setText(R.id.tv_room_rank_title, roomRankHalfHourRankInfo.getRoomTitle());
|
||||
// 头像
|
||||
CircleImageView avatarView = baseViewHolder.getView(R.id.iv_room_rank_avatar);
|
||||
ImageLoadUtils.loadAvatar(mContext, roomRankHalfHourRankInfo.getAvatar(), avatarView, true);
|
||||
baseViewHolder.setText(R.id.tv_room_rank_id, "ID:" + roomRankHalfHourRankInfo.getErbanNo());
|
||||
}
|
||||
}
|
@@ -4,15 +4,22 @@ import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.util.Log
|
||||
import android.view.Gravity
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.bumptech.glide.request.target.CustomTarget
|
||||
import com.bumptech.glide.request.transition.Transition
|
||||
import com.chuhai.utils.PathUtils
|
||||
import com.hjq.toast.ToastUtils
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil
|
||||
import com.netease.nim.uikit.support.glide.GlideApp
|
||||
import com.nnbc123.app.ErbanTakePhotoActivity.TakePhotoCallBack
|
||||
import com.nnbc123.app.R
|
||||
import com.nnbc123.app.application.XChatApplication
|
||||
@@ -24,21 +31,25 @@ import com.nnbc123.app.common.util.BitmapUtil
|
||||
import com.nnbc123.app.databinding.DialogCreatePrivilegeCardBinding
|
||||
import com.nnbc123.app.takephoto.model.TResult
|
||||
import com.nnbc123.app.ui.utils.ImageLoadUtils
|
||||
import com.nnbc123.app.ui.utils.ImageLoadUtilsV2
|
||||
import com.nnbc123.app.ui.widget.dialog.CommonTipDialog
|
||||
import com.nnbc123.core.file.FileModel
|
||||
import com.nnbc123.core.privilege.bean.PrivilegeCardInfo
|
||||
import com.nnbc123.core.utils.Logger
|
||||
import com.nnbc123.core.utils.TextUtils
|
||||
import com.nnbc123.library.common.file.FileHelper
|
||||
import com.nnbc123.library.common.glide.GlideUtils
|
||||
import com.nnbc123.library.common.photo.PhotoProviderNew
|
||||
import com.nnbc123.library.common.support.PathHelper
|
||||
import com.nnbc123.library.common.util.PhotoCompressCallback
|
||||
import com.nnbc123.library.common.util.PhotoCompressUtil
|
||||
import com.nnbc123.library.easyphoto.constant.Type
|
||||
import com.nnbc123.library.easyphoto.models.album.entity.Photo
|
||||
import com.nnbc123.library.utils.SingleToastUtil
|
||||
import com.nnbc123.library.utils.codec.MD5Utils
|
||||
import com.yalantis.ucrop.UCrop
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
@@ -82,6 +93,9 @@ class CreatePrivilegeCardDialog : BaseDialog<DialogCreatePrivilegeCardBinding>()
|
||||
private var saveTipDialog: CommonTipDialog? = null
|
||||
|
||||
private var mUrl = ""
|
||||
private var effectUrl: String? = null
|
||||
private var cardType = 0
|
||||
private var duration: Long? = null
|
||||
|
||||
private var mUri: Uri? = null
|
||||
private var mJob: Job? = null
|
||||
@@ -103,8 +117,11 @@ class CreatePrivilegeCardDialog : BaseDialog<DialogCreatePrivilegeCardBinding>()
|
||||
binding.edExplain.setText(it.description)
|
||||
binding.edValid.setText(it.effectDay.toString())
|
||||
binding.edId.setText(it.erbanNoStr)
|
||||
ImageLoadUtilsV2.loadImage(binding.ivPic, it.cardUrl)
|
||||
loadImage(it.cardUrl)
|
||||
this.mUrl = it.cardUrl
|
||||
this.duration = it.duration
|
||||
this.cardType = it.cardType
|
||||
this.effectUrl = it.effectUrl
|
||||
}
|
||||
|
||||
binding.edName.addTextChangedListener(object : TextWatcher {
|
||||
@@ -184,10 +201,13 @@ class CreatePrivilegeCardDialog : BaseDialog<DialogCreatePrivilegeCardBinding>()
|
||||
|
||||
binding.ivPic.setOnClickListener {
|
||||
mUri = Uri.parse("file://${FileHelper.getRootCacheDir()?.path}/${getNowTime()}.jpg")
|
||||
PhotoProviderNew.photoProvider(
|
||||
PhotoProviderNew.photoVideoProvider(
|
||||
this,
|
||||
canChooseGif = true,
|
||||
resultCode = REQUEST_CODE_OPEN_PHOTO_PROVIDER
|
||||
resultCode = REQUEST_CODE_OPEN_PHOTO_PROVIDER,
|
||||
// maxFileSize = 1024 * 1024 * 20,
|
||||
// videoMaxSecond = 15,
|
||||
showVideoType = "mp4"
|
||||
)
|
||||
}
|
||||
binding.tvCancel.setOnClickListener {
|
||||
@@ -228,7 +248,10 @@ class CreatePrivilegeCardDialog : BaseDialog<DialogCreatePrivilegeCardBinding>()
|
||||
binding.edExplain.text.toString(),
|
||||
binding.edValid.text.toString().toInt(),
|
||||
binding.edId.text.toString(),
|
||||
mUrl
|
||||
mUrl,
|
||||
duration,
|
||||
cardType,
|
||||
effectUrl
|
||||
)
|
||||
saveTipDialog?.dismiss()
|
||||
}
|
||||
@@ -266,32 +289,11 @@ class CreatePrivilegeCardDialog : BaseDialog<DialogCreatePrivilegeCardBinding>()
|
||||
if (resultCode == BaseActivity.RESULT_OK) {
|
||||
when (requestCode) {
|
||||
REQUEST_CODE_OPEN_PHOTO_PROVIDER -> data?.let {
|
||||
val photos = PhotoProviderNew.getResultPhotoList(it) ?: return
|
||||
if (photos.isNotEmpty()) {
|
||||
val photo = photos[0]
|
||||
if(photo.path.endsWith(Type.GIF) || photo.type.endsWith(Type.GIF)){
|
||||
FileModel.get()
|
||||
.uploadFile(photo.path)
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe { url: String?, throwable: Throwable? ->
|
||||
if (throwable != null) {
|
||||
SingleToastUtil.showToast("上传失败")
|
||||
} else {
|
||||
url?.let { it1 ->
|
||||
GlideUtils.instance().loadUriGiftAndCrossFadeRound(
|
||||
it1, binding.ivPic, 10f)
|
||||
}
|
||||
if (url != null) {
|
||||
mUrl = url
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
crop(photo.uri, photo.size, mUri)
|
||||
}
|
||||
}
|
||||
val photo = PhotoProviderNew.getResultPhotoList(it)?.firstOrNull() ?: return
|
||||
onPhotoResult(photo)
|
||||
}
|
||||
UCrop.REQUEST_CROP ->{
|
||||
|
||||
UCrop.REQUEST_CROP -> {
|
||||
mUri?.path?.let {
|
||||
mJob = PhotoCompressUtil.compress(
|
||||
context as Activity,
|
||||
@@ -300,25 +302,7 @@ class CreatePrivilegeCardDialog : BaseDialog<DialogCreatePrivilegeCardBinding>()
|
||||
object : PhotoCompressCallback {
|
||||
@SuppressLint("CheckResult")
|
||||
override fun onSuccess(compressedImg: String) {
|
||||
FileModel.get()
|
||||
.uploadFile(compressedImg)
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe { url: String?, throwable: Throwable? ->
|
||||
if (throwable != null) {
|
||||
SingleToastUtil.showToast("上传失败")
|
||||
} else {
|
||||
ImageLoadUtils.loadRectImage(
|
||||
context,
|
||||
url,
|
||||
binding.ivPic,
|
||||
R.drawable.default_cover,
|
||||
ScreenUtil.dip2px(10f)
|
||||
)
|
||||
if (url != null) {
|
||||
mUrl = url
|
||||
}
|
||||
}
|
||||
}
|
||||
uploadImage(compressedImg)
|
||||
}
|
||||
|
||||
override fun onFail(e: Throwable) {
|
||||
@@ -386,25 +370,12 @@ class CreatePrivilegeCardDialog : BaseDialog<DialogCreatePrivilegeCardBinding>()
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
override fun takeSuccess(result: TResult?) {
|
||||
FileModel.get()
|
||||
.uploadFile(result?.image?.compressPath)
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe { url: String?, throwable: Throwable? ->
|
||||
if (throwable != null) {
|
||||
SingleToastUtil.showToast("上传失败")
|
||||
} else {
|
||||
ImageLoadUtils.loadRectImage(
|
||||
context,
|
||||
url,
|
||||
binding.ivPic,
|
||||
R.drawable.default_cover,
|
||||
ScreenUtil.dip2px(10f)
|
||||
)
|
||||
if (url != null) {
|
||||
mUrl = url
|
||||
}
|
||||
}
|
||||
}
|
||||
val path = result?.image?.compressPath
|
||||
if (path == null) {
|
||||
SingleToastUtil.showToast("文件不存在")
|
||||
return
|
||||
}
|
||||
uploadImage(path)
|
||||
}
|
||||
|
||||
override fun takeFail(result: TResult?, msg: String?) {
|
||||
@@ -420,4 +391,119 @@ class CreatePrivilegeCardDialog : BaseDialog<DialogCreatePrivilegeCardBinding>()
|
||||
mJob?.cancel()
|
||||
}
|
||||
|
||||
private fun uploadFile(path: String, onSuccess: (String) -> Unit) {
|
||||
val d = FileModel.get()
|
||||
.uploadFile(path)
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe { url: String?, throwable: Throwable? ->
|
||||
if (throwable != null || url.isNullOrEmpty()) {
|
||||
SingleToastUtil.showToast("上传失败")
|
||||
} else {
|
||||
onSuccess.invoke(url)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun uploadImage(path: String) {
|
||||
Log.d(TAG, "uploadImage path:${path}")
|
||||
uploadFile(path) {
|
||||
loadImage(path)
|
||||
mUrl = it
|
||||
cardType = 0
|
||||
effectUrl = null
|
||||
duration = null
|
||||
}
|
||||
}
|
||||
|
||||
private fun uploadGif(path: String) {
|
||||
Log.d(TAG, "uploadGif path:${path}")
|
||||
uploadFile(path) {
|
||||
loadImage(path)
|
||||
mUrl = it
|
||||
cardType = 1
|
||||
effectUrl = null
|
||||
duration = null
|
||||
}
|
||||
}
|
||||
|
||||
private fun uploadVideo(photo: Photo) {
|
||||
val path = photo.path
|
||||
Log.d(TAG, "uploadVideo path:${path}")
|
||||
GlideApp.with(this).asBitmap().dontTransform().load(path)
|
||||
.into(object : CustomTarget<Bitmap>() {
|
||||
override fun onResourceReady(
|
||||
resource: Bitmap,
|
||||
transition: Transition<in Bitmap>?
|
||||
) {
|
||||
val outPath = getImageTempPath(path)
|
||||
lifecycleScope.launch {
|
||||
Log.d(TAG, "uploadVideo 开始保存封面 outPath:${outPath}")
|
||||
val saveResult = com.chuhai.utils.ImageUtils.save(
|
||||
resource,
|
||||
outPath,
|
||||
Bitmap.CompressFormat.JPEG, false
|
||||
)
|
||||
if (saveResult) {
|
||||
Log.d(TAG, "uploadVideo 封面保存成功")
|
||||
withContext(Dispatchers.Main) {
|
||||
uploadFile(outPath) { cover ->
|
||||
uploadFile(path) { video ->
|
||||
loadImage(cover)
|
||||
this@CreatePrivilegeCardDialog.cardType = 2
|
||||
this@CreatePrivilegeCardDialog.duration = photo.duration
|
||||
this@CreatePrivilegeCardDialog.effectUrl = video
|
||||
this@CreatePrivilegeCardDialog.mUrl = cover
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Log.d(TAG, "uploadVideo 保存失败")
|
||||
SingleToastUtil.showToast("文件解析失败")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onLoadCleared(placeholder: Drawable?) {
|
||||
Log.d(TAG, "uploadVideo 封面解析失败")
|
||||
SingleToastUtil.showToast("视频解析失败")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun loadImage(path: String) {
|
||||
ImageLoadUtils.loadRectImage(
|
||||
context,
|
||||
path,
|
||||
binding.ivPic,
|
||||
R.drawable.default_cover,
|
||||
ScreenUtil.dip2px(10f)
|
||||
)
|
||||
}
|
||||
|
||||
private fun onPhotoResult(photo: Photo) {
|
||||
val path = photo.path
|
||||
Log.d(TAG, "onPhotoResult path:$path")
|
||||
if (path.endsWith("mp4") || photo.type.endsWith(Type.VIDEO)) {
|
||||
if (photo.duration > 15 * 1000) {
|
||||
SingleToastUtil.showToast("视频时长不能超过15秒")
|
||||
return
|
||||
}
|
||||
if (photo.size > (1024 * 1024 * 20)) {
|
||||
SingleToastUtil.showToast("上传文件最大不能超过20M")
|
||||
return
|
||||
}
|
||||
uploadVideo(photo)
|
||||
} else if (photo.path.endsWith(Type.GIF) || photo.type.endsWith(Type.GIF)) {
|
||||
uploadGif(path)
|
||||
} else {
|
||||
crop(photo.uri, photo.size, mUri)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getImageTempPath(path: String): String {
|
||||
return PathUtils.plusPathNotNull(
|
||||
PathHelper.getExternalDownloadCachePath(),
|
||||
"${MD5Utils.getMD5String(path)}.jpeg"
|
||||
)
|
||||
}
|
||||
}
|
@@ -3,13 +3,16 @@ package com.nnbc123.app.avroom.fragment
|
||||
import android.Manifest
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.graphics.drawable.GradientDrawable
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.provider.Settings
|
||||
import android.text.TextUtils
|
||||
import android.text.style.ForegroundColorSpan
|
||||
import android.view.*
|
||||
@@ -26,7 +29,6 @@ import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.nnbc123.core.Constants
|
||||
import com.nnbc123.core.DemoCache
|
||||
import com.nnbc123.core.UriProvider
|
||||
import com.nnbc123.core.auth.AuthModel
|
||||
import com.nnbc123.core.bean.RoomMicInfo
|
||||
import com.nnbc123.core.gift.GiftModel
|
||||
@@ -45,7 +47,6 @@ import com.nnbc123.core.music.event.MusicPlayingEvent
|
||||
import com.nnbc123.core.music.event.MusicStopEvent
|
||||
import com.nnbc123.core.room.anotherroompk.ShowGiftDialogEvent
|
||||
import com.nnbc123.core.room.anotherroompk.ShowUserInfoDialogEvent
|
||||
import com.nnbc123.core.room.bean.RoomContributeUserInfo
|
||||
import com.nnbc123.core.room.bean.RoomInfo
|
||||
import com.nnbc123.core.room.event.RoomAtEvent
|
||||
import com.nnbc123.core.room.event.RoomClearScreenEvent
|
||||
@@ -116,6 +117,8 @@ import com.netease.nimlib.sdk.StatusCode
|
||||
import com.netease.nimlib.sdk.chatroom.ChatRoomMessageBuilder
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomKickOutEvent
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage
|
||||
import com.nnbc123.app.avroom.hour_rank.RoomHourRankWidget
|
||||
import com.nnbc123.app.ui.widget.dialog.CommonTipDialog
|
||||
import com.orhanobut.logger.Logger
|
||||
import com.tbruyelle.rxpermissions2.RxPermissions
|
||||
import com.trello.rxlifecycle3.android.FragmentEvent
|
||||
@@ -250,6 +253,7 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
openOrCloseGiftValue(true)
|
||||
updateView()
|
||||
updateMicBtn()
|
||||
refreshHourRank()
|
||||
microView.setOnMicroItemClickListener(this)
|
||||
mDisposable = IMNetEaseManager.get().chatRoomEventObservable
|
||||
.subscribe { onReceiveRoomEvent(it) }
|
||||
@@ -285,7 +289,11 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
ivRadishEntrance?.isVisible = GoldBoxHelper.isShowRadish()
|
||||
if (ivRadishEntrance != null && GoldBoxHelper.isShowRadish()) {
|
||||
StatisticManager.Instance()
|
||||
.onEvent(StatisticsProtocol.EVENT_ROOM_POP_SHOW, "房间pop曝光", mapOf("name" to "星际探索"))
|
||||
.onEvent(
|
||||
StatisticsProtocol.EVENT_ROOM_POP_SHOW,
|
||||
"房间pop曝光",
|
||||
mapOf("name" to "星际探索")
|
||||
)
|
||||
}
|
||||
initWishListPager()
|
||||
}
|
||||
@@ -305,18 +313,22 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
GiftValueMrg.get().handleReconnect(false)
|
||||
}
|
||||
}
|
||||
|
||||
RoomEvent.ROOM_EXIT -> {
|
||||
// 退出房间,把标志置为 false
|
||||
AvRoomDataManager.get().isFromMentoring = false
|
||||
// 退出房间的时候,要停止倒计时
|
||||
EventBus.getDefault().post(MentoringStopCountingEvent())
|
||||
}
|
||||
|
||||
RoomEvent.DOWN_CROWDED_MIC -> if (AvRoomDataManager.get().isOwner(roomEvent.account)) {
|
||||
toast(R.string.crowded_down)
|
||||
}
|
||||
|
||||
RoomEvent.ROOM_MANAGER_ADD, RoomEvent.ROOM_MANAGER_REMOVE -> {
|
||||
updateView()
|
||||
}
|
||||
|
||||
RoomEvent.ROOM_INFO_UPDATE -> {
|
||||
Logger.i("房间更新事件")
|
||||
addOpenDatingTips() //一定要放在updateView之前!!!
|
||||
@@ -325,19 +337,24 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
updateView()
|
||||
updateRemoteMuteBtn()
|
||||
openOrCloseGiftValue(false)
|
||||
refreshHourRank()
|
||||
}
|
||||
|
||||
RoomEvent.ENTER_ROOM -> {
|
||||
Logger.i("进入房间事件")
|
||||
updateView()
|
||||
updateRemoteMuteBtn()
|
||||
openOrCloseGiftValue(true)
|
||||
GiftValueMrg.get().updateRoomGiftValue(false)
|
||||
refreshHourRank()
|
||||
}
|
||||
|
||||
RoomEvent.ADD_BLACK_LIST -> onChatRoomMemberBlackAdd(roomEvent.account)
|
||||
RoomEvent.MIC_QUEUE_STATE_CHANGE -> onQueueMicStateChange(
|
||||
roomEvent.micPosition,
|
||||
roomEvent.posState
|
||||
)
|
||||
|
||||
RoomEvent.KICK_DOWN_MIC_BY_S_ADMIN, RoomEvent.KICK_DOWN_MIC -> if (event == RoomEvent.KICK_DOWN_MIC) {
|
||||
SingleToastUtil.showToast(
|
||||
mContext.resources.getString(
|
||||
@@ -351,16 +368,20 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
RoomEvent.DOWN_MIC -> {
|
||||
onDownMicro(roomEvent.micPosition)
|
||||
}
|
||||
|
||||
RoomEvent.UP_MIC -> {
|
||||
onUpMicro(roomEvent.micPosition)
|
||||
}
|
||||
|
||||
RoomEvent.INVITE_UP_MIC -> if (AvRoomDataManager.get().isOwner(roomEvent.account)) {
|
||||
//自己的消息
|
||||
onInviteUpMic(roomEvent.micPosition)
|
||||
}
|
||||
|
||||
RoomEvent.KICK_OUT_ROOM -> {
|
||||
val reason = roomEvent.reason
|
||||
if (reason != null && reason.reason == ChatRoomKickOutEvent.ChatRoomKickOutReason.CHAT_ROOM_INVALID) {
|
||||
@@ -378,8 +399,10 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
AvRoomDataManager.get().removeChatRoomMember(targetUid)
|
||||
}
|
||||
}
|
||||
|
||||
RoomEvent.LEAVE_MODE -> microView.adapter.notifyDataSetChanged()
|
||||
RoomEvent.ROOM_CLEAN_SCREEN -> messageView.clear()
|
||||
RoomEvent.ROOM_HOUR_RANK -> refreshHourRank()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -530,7 +553,10 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
rootView.setOnClickListener {
|
||||
WishListPanelDialog.newInstance().show(mContext)
|
||||
StatisticManager.Instance()
|
||||
.onEvent(StatisticsProtocol.EVENT_WISHLIST_POP_CLICK, "礼物心愿气泡点击")
|
||||
.onEvent(
|
||||
StatisticsProtocol.EVENT_WISHLIST_POP_CLICK,
|
||||
"礼物心愿气泡点击"
|
||||
)
|
||||
}
|
||||
return rootView
|
||||
}
|
||||
@@ -756,12 +782,7 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
.onEvent(StatisticsProtocol.EVENT_ROOM_CHAT_CLICK, "语音房_公屏发言")
|
||||
sendMsg()
|
||||
}
|
||||
R.id.contribute_list -> {
|
||||
DialogWebViewActivity.start(mContext, UriProvider.getRoomRanking())
|
||||
StatisticManager.Instance()
|
||||
.onEvent(StatisticsProtocol.EVENT_MP_ROOM_RANKING_LIST_CLICK, "房间榜")
|
||||
mvpPresenter?.loadRoomRank()
|
||||
}
|
||||
|
||||
R.id.iv_first_charge_enter -> FirstChargeDialog.start(mContext)
|
||||
}
|
||||
}
|
||||
@@ -976,7 +997,15 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
(roomInfo.isLeaveMode || AvRoomDataManager.get().isSingleRoom)
|
||||
&& position == -1
|
||||
) {
|
||||
showUserCardDialog(roomInfo.uid.toString())
|
||||
val currentUid = AuthModel.get().currentUid.toString()
|
||||
if (roomInfo.isLeaveMode && !AvRoomDataManager.get().isSingleRoom && (AvRoomDataManager.get()
|
||||
.isRoomOwner(currentUid) || AvRoomDataManager.get().isRoomAdmin(currentUid)
|
||||
|| SuperAdminUtil.isSuperAdmin())
|
||||
) {
|
||||
SingleToastUtil.showToast("请先关闭离开模式")
|
||||
} else {
|
||||
showUserCardDialog(roomInfo.uid.toString())
|
||||
}
|
||||
} else {
|
||||
val roomQueueInfo = AvRoomDataManager.get()
|
||||
.getRoomQueueMemberInfoByMicPosition(position)
|
||||
@@ -1126,11 +1155,37 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
if (result) {
|
||||
mvpPresenter?.upMicroPhone(micPosition, currentUid, b)
|
||||
} else {
|
||||
toast("请给予麦克风权限后再试!")
|
||||
showDeniedTips(
|
||||
requireContext(),
|
||||
ResUtil.getString(R.string.permission_denied_tips_mic)
|
||||
)
|
||||
}
|
||||
}, { throwable: Throwable? -> toast("发生一些异常,请稍后重试!") })
|
||||
}
|
||||
|
||||
private fun showDeniedTips(context: Context, message: String) {
|
||||
CommonTipDialog(context).apply {
|
||||
setTipMsg(message)
|
||||
setOkText("去设置")
|
||||
setOnActionListener(
|
||||
object : CommonTipDialog.OnActionListener {
|
||||
override fun onOk() {
|
||||
//同意跳到应用详情页面
|
||||
val packageUri =
|
||||
Uri.parse("package:${context.packageName}")
|
||||
val intent = Intent(
|
||||
Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
|
||||
packageUri
|
||||
)
|
||||
(context as? Activity)?.startActivityForResult(
|
||||
intent, 0
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
}.show()
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否有麦克风权限
|
||||
*
|
||||
@@ -1253,18 +1308,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
microView.adapter.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun updateRoomRanks(data: List<RoomContributeUserInfo>) {
|
||||
val avatarList = arrayListOf<ImageView?>(
|
||||
mView.findViewById(R.id.iv_rank_0),
|
||||
mView.findViewById(R.id.iv_rank_1),
|
||||
mView.findViewById(R.id.iv_rank_2)
|
||||
)
|
||||
|
||||
for (i in 0 until avatarList.size) {
|
||||
avatarList[i]?.loadAvatar(data.getOrNull(i)?.avatar)
|
||||
}
|
||||
}
|
||||
|
||||
private fun onSendGiftBtnClick(giftId: Int = 0) {
|
||||
if (giftDialog == null) {
|
||||
GiftDialog.GIFT_DIALOG_FROM = "房间"
|
||||
@@ -1312,6 +1355,24 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
}, 200)
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新房间小时榜
|
||||
*/
|
||||
protected open fun refreshHourRank() {
|
||||
val data = AvRoomDataManager.get().hourRankInfo
|
||||
val widget = view?.findViewById<View>(R.id.hourRankWidget) as? RoomHourRankWidget ?: return
|
||||
when (AvRoomDataManager.get().mCurrentRoomInfo?.isPermitRoom) {
|
||||
1, 4 -> {
|
||||
widget.loadData(data)
|
||||
widget.isVisible = true
|
||||
}
|
||||
|
||||
else -> {
|
||||
widget.isVisible = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 底部按钮点击处理
|
||||
*/
|
||||
|
@@ -6,6 +6,7 @@ import android.view.View
|
||||
import androidx.core.view.isInvisible
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import com.gyf.immersionbar.ImmersionBar
|
||||
import com.nnbc123.app.R
|
||||
import com.nnbc123.app.avroom.adapter.GameMicroViewAdapter
|
||||
import com.nnbc123.app.avroom.adapter.GameMiniMicroViewAdapter
|
||||
@@ -58,6 +59,7 @@ class GameRoomFragment : BaseRoomFragment<IGameRoomView?, GameRoomPresenter?>(),
|
||||
override fun onFindViews() {
|
||||
super.onFindViews()
|
||||
gameBinding = DataBindingUtil.bind(mView)!!
|
||||
ImmersionBar.with(this).titleBarMarginTop(gameBinding.spaceTitleBar).init()
|
||||
gameBinding.lifecycleOwner = this
|
||||
gameBinding.click = this
|
||||
gameBinding.ktvModel = false
|
||||
@@ -169,22 +171,13 @@ class GameRoomFragment : BaseRoomFragment<IGameRoomView?, GameRoomPresenter?>(),
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
gameDelegate.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
gameDelegate.onResume()
|
||||
}
|
||||
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
gameDelegate.onPause()
|
||||
gameDelegate.onStart()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
gameDelegate.onPause()
|
||||
gameDelegate.onStop()
|
||||
}
|
||||
|
||||
|
@@ -8,11 +8,13 @@ import android.view.View
|
||||
import android.view.ViewConfiguration
|
||||
import android.widget.ImageView
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import cn.sharesdk.framework.Platform
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.gyf.immersionbar.ImmersionBar
|
||||
import com.netease.nim.uikit.common.util.string.StringUtil
|
||||
import com.netease.nimlib.sdk.chatroom.ChatRoomMessageBuilder
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage
|
||||
@@ -28,10 +30,12 @@ import com.nnbc123.app.databinding.FragmentChatroomGameMainBinding
|
||||
import com.nnbc123.app.friend.view.SelectFriendActivity
|
||||
import com.nnbc123.app.home.helper.OpenRoomHelper
|
||||
import com.nnbc123.app.ui.utils.loadAvatar
|
||||
import com.nnbc123.app.ui.webview.DialogWebViewActivity
|
||||
import com.nnbc123.app.ui.widget.ShareDialog
|
||||
import com.nnbc123.app.ui.widget.ShareDialog.OnShareDialogItemClick
|
||||
import com.nnbc123.app.utils.RegexUtil
|
||||
import com.nnbc123.app.vip.VipMainActivity
|
||||
import com.nnbc123.core.UriProvider
|
||||
import com.nnbc123.core.gift.bean.GiftMultiReceiverInfo
|
||||
import com.nnbc123.core.gift.bean.GiftReceiveInfo
|
||||
import com.nnbc123.core.gift.bean.LuckyBagGifts
|
||||
@@ -51,6 +55,9 @@ import com.nnbc123.core.room.anotherroompk.ShowUserInfoDialogEvent
|
||||
import com.nnbc123.core.room.bean.RoomContributeDataInfo
|
||||
import com.nnbc123.core.room.bean.RoomContributeUserInfo
|
||||
import com.nnbc123.core.room.bean.RoomInfo
|
||||
import com.nnbc123.core.room.bean.RoomModeType
|
||||
import com.nnbc123.core.room.game.GameInfo
|
||||
import com.nnbc123.core.room.game.GameModel
|
||||
import com.nnbc123.core.room.model.RoomContributeListModel
|
||||
import com.nnbc123.core.room.queuing_mic.event.HasAnimationEffect
|
||||
import com.nnbc123.core.share.ShareModel
|
||||
@@ -64,6 +71,7 @@ import com.nnbc123.core.utils.net.RxHelper
|
||||
import com.nnbc123.library.rxbus.RxBus
|
||||
import com.nnbc123.library.utils.FormatUtils
|
||||
import com.nnbc123.library.utils.JavaUtil
|
||||
import com.nnbc123.library.utils.ResUtil
|
||||
import com.nnbc123.library.utils.SingleToastUtil
|
||||
import com.trello.rxlifecycle3.android.FragmentEvent
|
||||
import io.reactivex.SingleObserver
|
||||
@@ -117,6 +125,7 @@ class HomePartyFragment : BaseFragment(), View.OnClickListener, OnShareDialogIte
|
||||
|
||||
override fun onFindViews() {
|
||||
_binding = DataBindingUtil.bind(mView)
|
||||
ImmersionBar.with(this).titleBarMarginTop(binding.layoutTitleBar).init()
|
||||
setupRoomTitleMarquee()
|
||||
}
|
||||
|
||||
@@ -238,16 +247,16 @@ class HomePartyFragment : BaseFragment(), View.OnClickListener, OnShareDialogIte
|
||||
}
|
||||
|
||||
//这里的2和4是服务端定义的错误状态 关闭排麦模式和关闭PK模式!
|
||||
private val isShowChangeGame: Boolean
|
||||
get() = false
|
||||
/* RoomInfo currentRoomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
|
||||
private val isShowChangeGame: Boolean get() {
|
||||
val currentRoomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
|
||||
return currentRoomInfo != null &&
|
||||
AvRoomDataManager.get().isRoomOwner() &&
|
||||
currentRoomInfo.getIsPermitRoom() != 1 &&
|
||||
currentRoomInfo.getType() != RoomInfo.ROOM_TYPE_SINGLE &&
|
||||
(currentRoomInfo.getRoomModeType() == RoomModeType.NORMAL_MODE ||
|
||||
currentRoomInfo.getRoomModeType() == 2 ||
|
||||
currentRoomInfo.getRoomModeType() == 4);*/
|
||||
currentRoomInfo.getRoomModeType() == 4)
|
||||
}
|
||||
|
||||
fun setRoomBg(roomInfo: RoomInfo?) {
|
||||
if (_binding == null) return
|
||||
@@ -419,6 +428,38 @@ class HomePartyFragment : BaseFragment(), View.OnClickListener, OnShareDialogIte
|
||||
setupFollowRoom()
|
||||
FOLLOW_ROOM_TYPE = if (AvRoomDataManager.get().isRoomFans) "2" else "1"
|
||||
setIdOnlineData()
|
||||
if (isShowChangeGame) {
|
||||
initRvGame()
|
||||
binding.layoutRankTop1.isVisible = false
|
||||
binding.layoutRankTop2.isVisible = false
|
||||
binding.llChangeGame.visibility = View.VISIBLE
|
||||
if (AvRoomDataManager.get().isOpenGame) {
|
||||
binding.tvCurrGame.text = it.mgName
|
||||
} else {
|
||||
binding.tvCurrGame.text = "扩列交友"
|
||||
}
|
||||
GameModel.getGameList()
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe { gameInfos ->
|
||||
if (AvRoomDataManager.get().isOpenGame) {
|
||||
for (i in gameInfos.indices) {
|
||||
val gameInfo: GameInfo = gameInfos[i]
|
||||
if (gameInfo.mgId.toLongOrNull() == it.mgId) {
|
||||
gameInfos.removeAt(i)
|
||||
break
|
||||
}
|
||||
}
|
||||
val gameInfo = GameInfo()
|
||||
gameInfo.name = "扩列交友"
|
||||
gameInfos.add(gameInfo)
|
||||
}
|
||||
gameAdapter?.setNewData(gameInfos)
|
||||
}
|
||||
} else {
|
||||
binding.llChangeGame.setVisibility(View.GONE)
|
||||
binding.layoutRankTop1.isVisible = true
|
||||
binding.layoutRankTop2.isVisible = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -467,11 +508,7 @@ class HomePartyFragment : BaseFragment(), View.OnClickListener, OnShareDialogIte
|
||||
.onEvent(StatisticsProtocol.EVENT_CP_ROOM_RANKING_LIST_CLICK, "房间榜")
|
||||
} else StatisticManager.Instance()
|
||||
.onEvent(StatisticsProtocol.EVENT_MP_ROOM_RANKING_LIST_CLICK, "房间榜")
|
||||
if (childFragmentManager.findFragmentByTag("dialog_fragment_room_rank") != null) {
|
||||
return
|
||||
}
|
||||
val roomRankDialogFragment = RoomRankDialogFragment.newInstance()
|
||||
roomRankDialogFragment.show(childFragmentManager, "dialog_fragment_room_rank")
|
||||
DialogWebViewActivity.start(mContext, UriProvider.getRoomRanking())
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
@@ -517,23 +554,7 @@ class HomePartyFragment : BaseFragment(), View.OnClickListener, OnShareDialogIte
|
||||
.compose(bindToLifecycle())
|
||||
.compose(RxHelper.handleBeanData())
|
||||
.subscribe { roomContributeDataInfo: RoomContributeDataInfo ->
|
||||
val rankings = roomContributeDataInfo.rankings
|
||||
updateRoomRanks(roomContributeDataInfo.rankings)
|
||||
var imageView: ImageView
|
||||
val avatarList = listOf(
|
||||
binding.ivRank0,
|
||||
binding.ivRank1,
|
||||
binding.ivRank2
|
||||
)
|
||||
for (i in avatarList.indices) {
|
||||
imageView = avatarList[i]
|
||||
if (rankings.size > i) {
|
||||
val info = rankings[i]
|
||||
imageView.loadAvatar(info.avatar)
|
||||
} else {
|
||||
imageView.setImageResource(R.drawable.default_avatar)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -8,6 +8,7 @@ import android.widget.ImageView;
|
||||
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
|
||||
import com.gyf.immersionbar.ImmersionBar;
|
||||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||||
import com.nnbc123.app.R;
|
||||
import com.nnbc123.app.avroom.activity.AVRoomActivity;
|
||||
@@ -133,6 +134,7 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
public void onFindViews() {
|
||||
super.onFindViews();
|
||||
gameBinding = DataBindingUtil.bind(mView);
|
||||
ImmersionBar.with(this).titleBarMarginTop(gameBinding.layoutRoot).init();
|
||||
gameBinding.setLifecycleOwner(this);
|
||||
gameBinding.setClick(this);
|
||||
gameBinding.setKtvModel(false);
|
||||
@@ -346,7 +348,6 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
}
|
||||
GiftValueMrg.get().updateRoomGiftValue(false);
|
||||
GiftModel.get().refreshGiftList(String.valueOf(AvRoomDataManager.get().getRoomUid())).subscribe();
|
||||
getMvpPresenter().loadRoomRank();
|
||||
EventBus.getDefault().post(new EnterRoomEvent(AvRoomDataManager.get().mCurrentRoomInfo.getType()));
|
||||
UserModel.get().getCurrentUserInfo()
|
||||
.compose(bindToLifecycle())
|
||||
@@ -656,14 +657,6 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
getMvpPresenter().cancelDragon();
|
||||
});
|
||||
break;
|
||||
case R.id.tv_hour_rank:
|
||||
DialogWebViewActivity.start(
|
||||
mContext,
|
||||
UriProvider.getRoomHourRankUrl(AvRoomDataManager.get().getRoomUid())
|
||||
);
|
||||
StatisticManager.Instance()
|
||||
.onEvent(StatisticsProtocol.EVENT_ROOM_RANKLIST_CLICK, "房间小时榜点击");
|
||||
break;
|
||||
case R.id.tv_notice_board:
|
||||
onRoomSettingsClick();
|
||||
break;
|
||||
|
@@ -1,5 +0,0 @@
|
||||
package com.nnbc123.app.avroom.fragment;
|
||||
|
||||
public interface IRoomRankDialogChangePageListener {
|
||||
void onChangePage(int pos);
|
||||
}
|
@@ -1,5 +0,0 @@
|
||||
package com.nnbc123.app.avroom.fragment;
|
||||
|
||||
public interface IRoomRankDialogDismissListener {
|
||||
void onDismiss();
|
||||
}
|
@@ -1,98 +0,0 @@
|
||||
package com.nnbc123.app.avroom.fragment;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import androidx.appcompat.app.AppCompatDialogFragment;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.nnbc123.app.R;
|
||||
import com.nnbc123.app.avroom.adapter.RoomRankFragmentPageAdapter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class RoomRankDialogFragment extends AppCompatDialogFragment implements IRoomRankDialogDismissListener, IRoomRankDialogChangePageListener {
|
||||
|
||||
private ViewPager mViewPager;
|
||||
|
||||
|
||||
public static RoomRankDialogFragment newInstance() {
|
||||
Bundle args = new Bundle();
|
||||
RoomRankDialogFragment fragment = new RoomRankDialogFragment();
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
if (getActivity() != null) {
|
||||
Dialog dialog = new Dialog(getActivity(), R.style.room_rank_dialog);
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(R.layout.dialog_fragment_room_rank);
|
||||
dialog.setCanceledOnTouchOutside(true);
|
||||
|
||||
// 设置弹出框布局参数,宽度铺满全屏,底部。
|
||||
Window window = dialog.getWindow();
|
||||
if (window != null) {
|
||||
WindowManager.LayoutParams wlp = window.getAttributes();
|
||||
wlp.gravity = Gravity.BOTTOM;
|
||||
wlp.width = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
wlp.height = WindowManager.LayoutParams.WRAP_CONTENT;
|
||||
window.setDimAmount(0.3f);
|
||||
window.setAttributes(wlp);
|
||||
window.setBackgroundDrawableResource(R.drawable.bg_room_rank);
|
||||
return dialog;
|
||||
} else {
|
||||
return super.onCreateDialog(savedInstanceState);
|
||||
}
|
||||
} else {
|
||||
return super.onCreateDialog(savedInstanceState);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.dialog_fragment_room_rank, container, false);
|
||||
mViewPager = view.findViewById(R.id.vp_room_rank);
|
||||
List<Fragment> fragmentList = new ArrayList<>();
|
||||
if (getChildFragmentManager().getFragments() != null && getChildFragmentManager().getFragments().size() != 0) {
|
||||
fragmentList = getChildFragmentManager().getFragments();
|
||||
} else {
|
||||
RoomRankListFragment roomInsideFragment = RoomRankListFragment.newInstance();
|
||||
roomInsideFragment.setDismissListener(this);
|
||||
roomInsideFragment.setChangePageListener(this);
|
||||
fragmentList.add(roomInsideFragment);
|
||||
}
|
||||
mViewPager.setAdapter(new RoomRankFragmentPageAdapter(getChildFragmentManager(), fragmentList));
|
||||
mViewPager.setOffscreenPageLimit(fragmentList.size());
|
||||
mViewPager.setCurrentItem(0, false);
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setCancelable(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDismiss() {
|
||||
dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangePage(int pos) {
|
||||
mViewPager.setCurrentItem(pos, false);
|
||||
}
|
||||
}
|
@@ -1,64 +0,0 @@
|
||||
package com.nnbc123.app.avroom.fragment;
|
||||
|
||||
import com.nnbc123.app.R;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class RoomRankDialogUtils {
|
||||
public static String getRoomRankValueText(int value) {
|
||||
if (value >= 10000) {
|
||||
BigDecimal bigDecimal = new BigDecimal(value / 10000.0);
|
||||
double doubleValue = bigDecimal.setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
return String.valueOf(doubleValue) + "万";
|
||||
} else {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
}
|
||||
|
||||
public static int getNumberImage(int number) {
|
||||
switch (number) {
|
||||
case 1:
|
||||
return R.drawable.ic_rank_1;
|
||||
case 2:
|
||||
return R.drawable.ic_rank_2;
|
||||
case 3:
|
||||
return R.drawable.ic_rank_3;
|
||||
case 4:
|
||||
return R.drawable.ic_rank_4;
|
||||
case 5:
|
||||
return R.drawable.ic_rank_5;
|
||||
case 6:
|
||||
return R.drawable.ic_rank_6;
|
||||
case 7:
|
||||
return R.drawable.ic_rank_7;
|
||||
case 8:
|
||||
return R.drawable.ic_rank_8;
|
||||
case 9:
|
||||
return R.drawable.ic_rank_9;
|
||||
case 10:
|
||||
return R.drawable.ic_rank_10;
|
||||
case 11:
|
||||
return R.drawable.ic_rank_11;
|
||||
case 12:
|
||||
return R.drawable.ic_rank_12;
|
||||
case 13:
|
||||
return R.drawable.ic_rank_13;
|
||||
case 14:
|
||||
return R.drawable.ic_rank_14;
|
||||
case 15:
|
||||
return R.drawable.ic_rank_15;
|
||||
case 16:
|
||||
return R.drawable.ic_rank_16;
|
||||
case 17:
|
||||
return R.drawable.ic_rank_17;
|
||||
case 18:
|
||||
return R.drawable.ic_rank_18;
|
||||
case 19:
|
||||
return R.drawable.ic_rank_19;
|
||||
case 20:
|
||||
return R.drawable.ic_rank_20;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,79 +0,0 @@
|
||||
package com.nnbc123.app.avroom.fragment;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import android.view.View;
|
||||
|
||||
import com.nnbc123.app.R;
|
||||
import com.nnbc123.app.avroom.adapter.RoomContributeListAdapter;
|
||||
import com.nnbc123.app.avroom.widget.RoomRankNavigatorAdapter;
|
||||
import com.nnbc123.app.base.BaseBindingFragment;
|
||||
import com.nnbc123.app.ui.widget.magicindicator.ViewPagerHelper;
|
||||
import com.nnbc123.app.ui.widget.magicindicator.buildins.commonnavigator.CommonNavigator;
|
||||
import com.nnbc123.library.annatation.ActLayoutRes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.nnbc123.app.databinding.FragmentRoomRankListBinding;
|
||||
|
||||
@ActLayoutRes(R.layout.fragment_room_rank_list)
|
||||
public class RoomRankListFragment extends BaseBindingFragment<FragmentRoomRankListBinding> implements View.OnClickListener, IRoomRankDialogDismissListener{
|
||||
|
||||
public static RoomRankListFragment newInstance() {
|
||||
return new RoomRankListFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initiate() {
|
||||
mBinding.setClick(this);
|
||||
List<Fragment> list = new ArrayList<>(2);
|
||||
list.add(new RoomContributeListFragment());
|
||||
list.add(RoomCharmListFragment.newInstance());
|
||||
mBinding.viewPager.setAdapter(new RoomContributeListAdapter(getChildFragmentManager(), list));
|
||||
|
||||
CommonNavigator commonNavigator = new CommonNavigator(getActivity());
|
||||
commonNavigator.setAdjustMode(true);
|
||||
|
||||
RoomRankNavigatorAdapter indicator = new RoomRankNavigatorAdapter();
|
||||
indicator.setOnItemSelectListener(position -> mBinding.viewPager.setCurrentItem(position));
|
||||
commonNavigator.setAdapter(indicator);
|
||||
mBinding.miRoomRank.setNavigator(commonNavigator);
|
||||
ViewPagerHelper.bind(mBinding.miRoomRank, mBinding.viewPager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.tv_room_rank_half_hour_tab:
|
||||
goToChangePage(0);
|
||||
break;
|
||||
|
||||
case R.id.tv_room_rank_in_room_tab:
|
||||
goToChangePage(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private IRoomRankDialogDismissListener dismissListener;
|
||||
private IRoomRankDialogChangePageListener changePageListener;
|
||||
@Override
|
||||
public void onDismiss() {
|
||||
if (dismissListener != null) {
|
||||
dismissListener.onDismiss();
|
||||
}
|
||||
}
|
||||
public void setDismissListener(IRoomRankDialogDismissListener dismissListener) {
|
||||
this.dismissListener = dismissListener;
|
||||
}
|
||||
/**
|
||||
* 修改最外层Dialog的显示页面
|
||||
*/
|
||||
private void goToChangePage(int pos) {
|
||||
if (changePageListener != null) {
|
||||
changePageListener.onChangePage(pos);
|
||||
}
|
||||
}
|
||||
|
||||
public void setChangePageListener(IRoomRankDialogChangePageListener changePageListener) {
|
||||
this.changePageListener = changePageListener;
|
||||
}
|
||||
}
|
@@ -9,24 +9,8 @@ import androidx.core.view.isVisible
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.viewModels
|
||||
import com.nnbc123.core.UriProvider
|
||||
import com.nnbc123.core.auth.AuthModel
|
||||
import com.nnbc123.core.fansteam.FansTeamInitInfo
|
||||
import com.nnbc123.core.home.bean.BannerInfo
|
||||
import com.nnbc123.core.im.custom.bean.FansTeamMsgAttachment
|
||||
import com.nnbc123.core.im.custom.bean.RequestUpmicAttachment
|
||||
import com.nnbc123.core.im.custom.bean.RoomPKAttachment
|
||||
import com.nnbc123.core.manager.AvRoomDataManager
|
||||
import com.nnbc123.core.manager.RoomEvent
|
||||
import com.nnbc123.core.pay.event.FirstChargeEvent
|
||||
import com.nnbc123.core.room.anotherroompk.ShowPkMatchEvent
|
||||
import com.nnbc123.core.room.anotherroompk.SingleRoomPKModel
|
||||
import com.nnbc123.core.statistic.StatisticManager
|
||||
import com.nnbc123.core.statistic.protocol.StatisticsProtocol
|
||||
import com.nnbc123.core.user.UserModel
|
||||
import com.nnbc123.core.user.bean.UserInfo
|
||||
import com.nnbc123.core.utils.CurrentTimeUtils
|
||||
import com.nnbc123.core.utils.toast
|
||||
import com.gyf.immersionbar.ImmersionBar
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil
|
||||
import com.nnbc123.app.R
|
||||
import com.nnbc123.app.avroom.adapter.OnMicroItemClickListener
|
||||
import com.nnbc123.app.avroom.adapter.SingleAnchorMicroViewAdapter
|
||||
@@ -44,9 +28,24 @@ import com.nnbc123.app.fansteam.FansTeamJoinedActivity
|
||||
import com.nnbc123.app.fansteam.FansTeamViewModel
|
||||
import com.nnbc123.app.ui.webview.CommonWebViewActivity
|
||||
import com.nnbc123.app.ui.webview.DialogWebViewActivity
|
||||
import com.nnbc123.core.UriProvider
|
||||
import com.nnbc123.core.fansteam.FansTeamInitInfo
|
||||
import com.nnbc123.core.home.bean.BannerInfo
|
||||
import com.nnbc123.core.im.custom.bean.RequestUpmicAttachment
|
||||
import com.nnbc123.core.im.custom.bean.RoomPKAttachment
|
||||
import com.nnbc123.core.manager.AvRoomDataManager
|
||||
import com.nnbc123.core.manager.RoomEvent
|
||||
import com.nnbc123.core.pay.event.FirstChargeEvent
|
||||
import com.nnbc123.core.room.anotherroompk.ShowPkMatchEvent
|
||||
import com.nnbc123.core.room.anotherroompk.SingleRoomPKModel
|
||||
import com.nnbc123.core.statistic.StatisticManager
|
||||
import com.nnbc123.core.statistic.protocol.StatisticsProtocol
|
||||
import com.nnbc123.core.user.UserModel
|
||||
import com.nnbc123.core.user.bean.UserInfo
|
||||
import com.nnbc123.core.utils.CurrentTimeUtils
|
||||
import com.nnbc123.core.utils.toast
|
||||
import com.nnbc123.library.base.factory.CreatePresenter
|
||||
import com.nnbc123.library.utils.TimeUtils
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil
|
||||
import com.trello.rxlifecycle3.android.FragmentEvent
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
@@ -88,6 +87,7 @@ class SingleRoomFragment : BaseRoomFragment<ISingleRoomView?, SingleRoomPresente
|
||||
override fun onFindViews() {
|
||||
super.onFindViews()
|
||||
gameBinding = DataBindingUtil.bind(mView)!!
|
||||
ImmersionBar.with(this).titleBarMarginTop(gameBinding.spaceTitleBar).init()
|
||||
gameBinding.lifecycleOwner = this
|
||||
gameBinding.click = this
|
||||
}
|
||||
@@ -112,13 +112,13 @@ class SingleRoomFragment : BaseRoomFragment<ISingleRoomView?, SingleRoomPresente
|
||||
}
|
||||
}
|
||||
|
||||
fansTeamViewModel.loadFansTeamInitInfo()
|
||||
// fansTeamViewModel.loadFansTeamInitInfo()
|
||||
|
||||
fansTeamViewModel.fansTeamInitInfoLiveData.observe(viewLifecycleOwner) {
|
||||
it?.let {
|
||||
updateFansTeamInfo(it)
|
||||
}
|
||||
}
|
||||
// fansTeamViewModel.fansTeamInitInfoLiveData.observe(viewLifecycleOwner) {
|
||||
// it?.let {
|
||||
// updateFansTeamInfo(it)
|
||||
// }
|
||||
// }
|
||||
|
||||
initRoomPkOrder(AvRoomDataManager.get().pkMatchStartTime)
|
||||
gameBinding.llRoomPkOrder.setOnClickListener {
|
||||
@@ -133,15 +133,6 @@ class SingleRoomFragment : BaseRoomFragment<ISingleRoomView?, SingleRoomPresente
|
||||
.subscribe()
|
||||
}
|
||||
}
|
||||
|
||||
gameBinding.tvHourRank.setOnClickListener {
|
||||
DialogWebViewActivity.start(
|
||||
mContext,
|
||||
UriProvider.getSingleRoomHourRankUrl(AvRoomDataManager.get().roomUid)
|
||||
)
|
||||
StatisticManager.Instance()
|
||||
.onEvent(StatisticsProtocol.EVENT_ROOM_RANKLIST_CLICK, "房间小时榜点击")
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@@ -206,23 +197,23 @@ class SingleRoomFragment : BaseRoomFragment<ISingleRoomView?, SingleRoomPresente
|
||||
RoomEvent.FANS_TEAM_OPEN_FAILED,
|
||||
RoomEvent.FANS_TEAM_JOIN,
|
||||
RoomEvent.FANS_TEAM_EXIT -> {
|
||||
(roomEvent.chatRoomMessage?.attachment as? FansTeamMsgAttachment)?.fansTeamMsgInfo?.let {
|
||||
val currFansTeamInitInfo = fansTeamViewModel.fansTeamInitInfoLiveData.value
|
||||
updateFansTeamInfo(
|
||||
FansTeamInitInfo(
|
||||
it.count,
|
||||
currFansTeamInitInfo?.fansLevelSeq ?: 1,
|
||||
roomEvent.event != RoomEvent.FANS_TEAM_OPEN_FAILED,
|
||||
if (AuthModel.get().currentUid == it.uid) {
|
||||
roomEvent.event == RoomEvent.FANS_TEAM_JOIN
|
||||
} else {
|
||||
currFansTeamInitInfo?.isAnchorFans ?: false
|
||||
},
|
||||
AvRoomDataManager.get().isRoomOwner,
|
||||
roomEvent.event == RoomEvent.FANS_TEAM_OPEN_FAILED
|
||||
)
|
||||
)
|
||||
}
|
||||
// (roomEvent.chatRoomMessage?.attachment as? FansTeamMsgAttachment)?.fansTeamMsgInfo?.let {
|
||||
// val currFansTeamInitInfo = fansTeamViewModel.fansTeamInitInfoLiveData.value
|
||||
// updateFansTeamInfo(
|
||||
// FansTeamInitInfo(
|
||||
// it.count,
|
||||
// currFansTeamInitInfo?.fansLevelSeq ?: 1,
|
||||
// roomEvent.event != RoomEvent.FANS_TEAM_OPEN_FAILED,
|
||||
// if (AuthModel.get().currentUid == it.uid) {
|
||||
// roomEvent.event == RoomEvent.FANS_TEAM_JOIN
|
||||
// } else {
|
||||
// currFansTeamInitInfo?.isAnchorFans ?: false
|
||||
// },
|
||||
// AvRoomDataManager.get().isRoomOwner,
|
||||
// roomEvent.event == RoomEvent.FANS_TEAM_OPEN_FAILED
|
||||
// )
|
||||
// )
|
||||
// }
|
||||
}
|
||||
RoomEvent.ROOM_PK_INVITE ->
|
||||
SingleRoomPkReceivedDialog.newInstance((roomEvent.chatRoomMessage.attachment as RoomPKAttachment).roomPkBean)
|
||||
@@ -276,13 +267,13 @@ class SingleRoomFragment : BaseRoomFragment<ISingleRoomView?, SingleRoomPresente
|
||||
gameBinding.microView.bindAdapter(SingleRoomPKMicroViewAdapter(context))
|
||||
gameBinding.viewPkBoard.isVisible = true
|
||||
gameBinding.microView.updateLayoutParams<ConstraintLayout.LayoutParams> {
|
||||
topMargin = ScreenUtil.dip2px(140f)
|
||||
topMargin = ScreenUtil.dip2px(50f)
|
||||
}
|
||||
} else if (!AvRoomDataManager.get().isOpenAnotherPKMode && gameBinding.microView.adapter !is SingleAnchorMicroViewAdapter) {
|
||||
gameBinding.microView.bindAdapter(SingleAnchorMicroViewAdapter(context))
|
||||
gameBinding.viewPkBoard.isVisible = false
|
||||
gameBinding.microView.updateLayoutParams<ConstraintLayout.LayoutParams> {
|
||||
topMargin = ScreenUtil.dip2px(110f)
|
||||
topMargin = ScreenUtil.dip2px(10f)
|
||||
}
|
||||
} else {
|
||||
gameBinding.microView.adapter?.notifyDataSetChanged()
|
||||
|
@@ -8,8 +8,8 @@ import com.nnbc123.app.BuildConfig;
|
||||
|
||||
public class AppConfig {
|
||||
|
||||
protected static final String APP_ID = "1467745235064848385";
|
||||
protected static final String APP_KEY = "BvjLDpWol7OihaYeFebuepx1bZu6cxU5";
|
||||
protected static final String APP_ID = "1735573973195948033";
|
||||
protected static final String APP_KEY = "r23OylNqnjOBPM0SDgVBfq6RCKMWAc0X";
|
||||
protected static boolean isTestEnv = BuildConfig.DEBUG;
|
||||
|
||||
}
|
||||
|
@@ -34,7 +34,7 @@ class GameDelegate(val activity: Activity, val container: FrameLayout, var mgId:
|
||||
private val TAG = "GameDelegate"
|
||||
private var APP_CODE = ""
|
||||
|
||||
private val mRoomID = AvRoomDataManager.get().roomUid.toString()
|
||||
private val mRoomID :String get() = AvRoomDataManager.get().roomUid.toString()
|
||||
private val mLanguage = "zh-CN" //语言
|
||||
|
||||
//调用游戏SDK的接口,成功加载游戏后可用:
|
||||
@@ -84,7 +84,10 @@ class GameDelegate(val activity: Activity, val container: FrameLayout, var mgId:
|
||||
}
|
||||
|
||||
fun updateGame(mgId: Long?) {
|
||||
if (mgId == null || mgId == 0L || mgId == mMGID || iSudFSTAPP == null) return
|
||||
if (mgId == null || mgId == 0L) return
|
||||
if (mgId == mMGID && iSudFSTAPP != null) {
|
||||
return
|
||||
}
|
||||
mMGID = mgId
|
||||
updateMyMicQueue(GameStatus.STATUS_NOT_JOIN)
|
||||
loadMG(activity, mUid, mRoomID, APP_CODE, mMGID, mLanguage)
|
||||
@@ -164,8 +167,11 @@ class GameDelegate(val activity: Activity, val container: FrameLayout, var mgId:
|
||||
language: String
|
||||
) {
|
||||
iSudFSTAPP?.destroyMG()
|
||||
SudMGP.getCfg().showLoadingGameBg = !isHideLoadingBg()
|
||||
iSudFSTAPP = SudMGP.loadMG(activity, userID, roomID, code, mgID, language, mISudFSMMG)
|
||||
addGameView(iSudFSTAPP!!.gameView)
|
||||
iSudFSTAPP?.apply {
|
||||
addGameView(gameView)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -226,6 +232,9 @@ class GameDelegate(val activity: Activity, val container: FrameLayout, var mgId:
|
||||
LogUtils.d(p0)
|
||||
}
|
||||
|
||||
override fun onGameLoadingProgress(p0: Int, p1: Int, p2: Int) {
|
||||
}
|
||||
|
||||
override fun onGameStarted() {
|
||||
}
|
||||
|
||||
@@ -285,7 +294,11 @@ class GameDelegate(val activity: Activity, val container: FrameLayout, var mgId:
|
||||
}
|
||||
|
||||
override fun onGetGameCfg(handle: ISudFSMStateHandle?, p1: String?) {
|
||||
handle?.success(gson.toJson(GameCfg()))
|
||||
val config = GameCfg()
|
||||
if (isHideGameBg()) {
|
||||
config.ui.game_bg.hide = true
|
||||
}
|
||||
handle?.success(gson.toJson(config))
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -313,9 +326,9 @@ class GameDelegate(val activity: Activity, val container: FrameLayout, var mgId:
|
||||
//游戏安全操作区域
|
||||
val viewGameRect = JSONObject()
|
||||
viewGameRect.put("left", 0)
|
||||
viewGameRect.put("top", ScreenUtil.dip2px(200f))
|
||||
viewGameRect.put("top", ScreenUtil.dip2px(180f))
|
||||
viewGameRect.put("right", 0)
|
||||
viewGameRect.put("bottom", ScreenUtil.dip2px(200f))
|
||||
viewGameRect.put("bottom", ScreenUtil.dip2px(150f))
|
||||
jsonObject.put("view_game_rect", viewGameRect)
|
||||
|
||||
//通知游戏
|
||||
@@ -655,6 +668,12 @@ class GameDelegate(val activity: Activity, val container: FrameLayout, var mgId:
|
||||
iSudFSTAPP?.destroyMG()
|
||||
}
|
||||
|
||||
private fun isHideLoadingBg(): Boolean {
|
||||
return mMGID == 1704460412809043970
|
||||
}
|
||||
private fun isHideGameBg(): Boolean {
|
||||
return mMGID == 1704460412809043970
|
||||
}
|
||||
}
|
||||
|
||||
internal interface AppLoginListener {
|
||||
|
@@ -0,0 +1,134 @@
|
||||
package com.nnbc123.app.avroom.hour_rank
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.animation.Animation
|
||||
import android.widget.FrameLayout
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import com.chuhai.utils.ktx.getColorById
|
||||
import com.chuhai.utils.ktx.singleClick
|
||||
import com.chuhai.utils.log.ILog
|
||||
import com.chuhai.utils.spannable.SpannableTextBuilder
|
||||
import com.nnbc123.app.R
|
||||
import com.nnbc123.app.databinding.RoomHourRankingWidgetBinding
|
||||
import com.nnbc123.app.ui.webview.DialogWebViewActivity
|
||||
import com.nnbc123.core.UriProvider
|
||||
import com.nnbc123.core.manager.AvRoomDataManager
|
||||
import com.nnbc123.core.room.bean.RoomHourRankInfo
|
||||
import com.nnbc123.core.room.bean.RoomInfo
|
||||
import com.nnbc123.core.statistic.StatisticManager
|
||||
import com.nnbc123.core.statistic.protocol.StatisticsProtocol
|
||||
import com.nnbc123.library.utils.FormatUtils
|
||||
|
||||
/**
|
||||
* Created by Max on 2023/11/7 11:48
|
||||
* Desc:小时榜组件
|
||||
**/
|
||||
class RoomHourRankWidget : FrameLayout, ILog {
|
||||
|
||||
private val binding: RoomHourRankingWidgetBinding =
|
||||
DataBindingUtil.inflate(
|
||||
LayoutInflater.from(
|
||||
context
|
||||
), R.layout.room_hour_ranking_widget, this, true
|
||||
)
|
||||
|
||||
private var inAnimation: Animation? = null
|
||||
private var outAnimation: Animation? = null
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyleAttr
|
||||
)
|
||||
|
||||
constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet?,
|
||||
defStyleAttr: Int,
|
||||
defStyleRes: Int
|
||||
) : super(context, attrs, defStyleAttr, defStyleRes)
|
||||
|
||||
init {
|
||||
inAnimation = binding.viewFlipper.inAnimation
|
||||
outAnimation = binding.viewFlipper.outAnimation
|
||||
singleClick {
|
||||
if (AvRoomDataManager.get().mCurrentRoomInfo?.type == RoomInfo.ROOM_TYPE_SINGLE) {
|
||||
DialogWebViewActivity.start(
|
||||
context,
|
||||
UriProvider.getSingleRoomHourRankUrl(AvRoomDataManager.get().roomUid)
|
||||
)
|
||||
} else {
|
||||
DialogWebViewActivity.start(
|
||||
context,
|
||||
UriProvider.getRoomHourRankUrl(AvRoomDataManager.get().roomUid)
|
||||
)
|
||||
}
|
||||
StatisticManager.Instance()
|
||||
.onEvent(StatisticsProtocol.EVENT_ROOM_RANKLIST_CLICK, "房间小时榜点击")
|
||||
}
|
||||
}
|
||||
|
||||
fun loadData(data: RoomHourRankInfo?) {
|
||||
val rank = data?.rank ?: 0
|
||||
val diff = data?.diffValue ?: 0
|
||||
updateRanking(rank)
|
||||
updateDiff(diff)
|
||||
if (rank <= 1 || rank > 30) {
|
||||
// 不需要轮播
|
||||
binding.viewFlipper.inAnimation = null
|
||||
binding.viewFlipper.outAnimation = null
|
||||
binding.viewFlipper.isAutoStart = false
|
||||
binding.viewFlipper.stopFlipping()
|
||||
binding.viewFlipper.displayedChild = 0
|
||||
} else {
|
||||
if (binding.viewFlipper.inAnimation == null) {
|
||||
binding.viewFlipper.inAnimation = inAnimation
|
||||
}
|
||||
if (binding.viewFlipper.outAnimation == null) {
|
||||
binding.viewFlipper.outAnimation = outAnimation
|
||||
}
|
||||
binding.viewFlipper.isAutoStart = true
|
||||
binding.viewFlipper.startFlipping()
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateRanking(rank: Long) {
|
||||
if (rank <= 0) {
|
||||
binding.tvRank.text = "小时榜"
|
||||
return
|
||||
}
|
||||
if (rank > 30) {
|
||||
binding.tvRank.text = "暂未上榜"
|
||||
return
|
||||
}
|
||||
SpannableTextBuilder(binding.tvRank).appendText(
|
||||
"小时榜 第 ",
|
||||
textColor = context.getColorById(R.color.white)
|
||||
).appendText(
|
||||
rank.toString(),
|
||||
textColor = context.getColorById(R.color.color_FFF265)
|
||||
).appendText(
|
||||
" 名",
|
||||
textColor = context.getColorById(R.color.white)
|
||||
).apply()
|
||||
}
|
||||
|
||||
private fun updateDiff(diff: Long) {
|
||||
val value = if (diff >= (1000 * 10000)) {
|
||||
"999w+"
|
||||
} else {
|
||||
FormatUtils.formatUnit(diff, 10000, "w")
|
||||
}
|
||||
SpannableTextBuilder(binding.tvDiff).appendText(
|
||||
"距上一名差 ",
|
||||
textColor = context.getColorById(R.color.white)
|
||||
).appendText(
|
||||
value,
|
||||
textColor = context.getColorById(R.color.color_FFF265)
|
||||
).apply()
|
||||
}
|
||||
}
|
@@ -43,6 +43,7 @@ import com.nnbc123.core.room.bean.RoomInfo;
|
||||
import com.nnbc123.core.room.giftvalue.helper.GiftValueMrg;
|
||||
import com.nnbc123.core.room.model.AvRoomModel;
|
||||
import com.nnbc123.core.room.model.MicQueueModel;
|
||||
import com.nnbc123.core.room.pk.model.PkModel;
|
||||
import com.nnbc123.core.room.queue.bean.MicMemberInfo;
|
||||
import com.nnbc123.core.room.queuing_mic.bean.QueuingMicMemeberInfo;
|
||||
import com.nnbc123.core.room.queuing_mic.event.QueuingMicNotEmptyEvent;
|
||||
@@ -148,6 +149,10 @@ public class AvRoomPresenter extends BaseMvpPresenter<IAvRoomView> {
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private void initAnotherPKData() {
|
||||
if (AvRoomDataManager.get().isOpenPKMode()) {
|
||||
// 进房后PK数据比麦位获取的快,导致PKModel.setCurPkInfo未被有效执行;所以在进房获取到麦位后,重新刷新setCurPkInfo
|
||||
PkModel.get().reloadPkInfo();
|
||||
}
|
||||
if (AvRoomDataManager.get().isOpenAnotherPKMode()) {
|
||||
RoomPKModel.INSTANCE.getRoomPKData(AvRoomDataManager.get().getRoomUid())
|
||||
.compose(bindToLifecycle())
|
||||
|
@@ -522,20 +522,6 @@ public class BaseRoomPresenter<V extends IBaseRoomView> extends BaseMvpPresenter
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
public void loadRoomRank() {
|
||||
String type = AvRoomDataManager.get().isSingleRoom() ? RoomContributeDataInfo.TYPE_ROOM_WEEK_RANKING : RoomContributeDataInfo.TYPE_ROOM_DAY_RANKING;
|
||||
RoomContributeListModel.get().getSingleRoomRanking(1, type)
|
||||
.compose(bindToLifecycle())
|
||||
.compose(RxHelper.handleBeanData())
|
||||
.subscribe(roomContributeDataInfo -> {
|
||||
// if (getMvpView() == null) {
|
||||
// return;
|
||||
// }
|
||||
getMvpView().updateRoomRanks(roomContributeDataInfo.getRankings());
|
||||
});
|
||||
}
|
||||
|
||||
/***
|
||||
* 发送房间消息
|
||||
* @param message
|
||||
|
@@ -1,103 +0,0 @@
|
||||
package com.nnbc123.app.avroom.presenter;
|
||||
|
||||
import com.nnbc123.app.avroom.fragment.IRoomRankHalfHourView;
|
||||
import com.nnbc123.core.manager.AvRoomDataManager;
|
||||
import com.nnbc123.core.room.bean.RoomInfo;
|
||||
import com.nnbc123.core.room.bean.RoomRankHalfHourDataInfo;
|
||||
import com.nnbc123.core.room.bean.RoomRankHalfHourRankInfo;
|
||||
import com.nnbc123.core.room.bean.RoomRankMultiItem;
|
||||
import com.nnbc123.core.room.model.RoomRankModel;
|
||||
import com.nnbc123.library.base.factory.AbstractMvpPresenter;
|
||||
import com.nnbc123.library.utils.SingleToastUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.SingleObserver;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class RoomRankHalfHourPresenter extends AbstractMvpPresenter<IRoomRankHalfHourView> {
|
||||
|
||||
public void getRankListInfo() {
|
||||
RoomInfo roomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
|
||||
if (roomInfo != null) {
|
||||
RoomRankModel.get()
|
||||
.getRoomRankHalfHourList(roomInfo.getUid())
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe(new SingleObserver<RoomRankHalfHourDataInfo>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(RoomRankHalfHourDataInfo roomRankHalfHourDataInfo) {
|
||||
if (roomRankHalfHourDataInfo != null) {
|
||||
|
||||
if (mMvpView != null) {
|
||||
if (roomRankHalfHourDataInfo.getMe() != null) {
|
||||
mMvpView.showMeInfo(roomRankHalfHourDataInfo.getMe());
|
||||
} else
|
||||
mMvpView.showMeInfo(null);
|
||||
|
||||
transformData(roomRankHalfHourDataInfo.getRankVoList());
|
||||
}
|
||||
|
||||
} else {
|
||||
if (mMvpView != null)
|
||||
mMvpView.loadDataFailure();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
if (mMvpView != null)
|
||||
mMvpView.loadDataFailure();
|
||||
SingleToastUtil.showToast(e.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void transformData(List<RoomRankHalfHourRankInfo> dataInfoList) {
|
||||
|
||||
if (dataInfoList != null) {
|
||||
List<RoomRankHalfHourRankInfo> top3rankInfo;
|
||||
if (dataInfoList.size() >= 3) {
|
||||
top3rankInfo = dataInfoList.subList(0, 3);
|
||||
} else {
|
||||
top3rankInfo = dataInfoList;
|
||||
}
|
||||
mMvpView.showTop3Info(top3rankInfo);
|
||||
// 第四名开始以后的信息
|
||||
List<RoomRankMultiItem> otherRankInfo = new ArrayList<>();
|
||||
if (dataInfoList.size() > 3) {
|
||||
|
||||
for (int i = 3; i < dataInfoList.size(); i++) {
|
||||
RoomRankHalfHourRankInfo info = dataInfoList.get(i);
|
||||
RoomRankMultiItem item = new RoomRankMultiItem();
|
||||
item.setItemType(RoomRankMultiItem.TYPE_LINEAR);
|
||||
item.setData(info);
|
||||
otherRankInfo.add(item);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// RoomRankMultiItem item = new RoomRankMultiItem();
|
||||
// item.setItemType(RoomRankHalfHourListAdapter.TYPE_TIPS);
|
||||
// otherRankInfo.add(item);
|
||||
mMvpView.showRankListInfo(otherRankInfo);
|
||||
|
||||
} else {
|
||||
mMvpView.showTop3Info(null);
|
||||
|
||||
List<RoomRankMultiItem> otherRankInfo = new ArrayList<>();
|
||||
RoomRankMultiItem item = new RoomRankMultiItem();
|
||||
item.setItemType(RoomRankMultiItem.TYPE_EMPTY);
|
||||
otherRankInfo.add(item);
|
||||
mMvpView.showRankListInfo(otherRankInfo);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -70,6 +70,4 @@ interface IBaseRoomView : IMvpBaseView {
|
||||
fun onFollowFail(msg: String?)
|
||||
|
||||
fun updateMicView()
|
||||
|
||||
fun updateRoomRanks(data: List<RoomContributeUserInfo>)
|
||||
}
|
@@ -402,10 +402,10 @@ public class BottomView extends FrameLayout implements View.OnClickListener {
|
||||
}
|
||||
ImageView ivAvatar = contentView.findViewById(R.id.iv_avatar);
|
||||
TextView tvNickname = contentView.findViewById(R.id.tv_nickname);
|
||||
TextView tvContent = contentView.findViewById(R.id.tv_content);
|
||||
// TextView tvContent = contentView.findViewById(R.id.tv_content);
|
||||
ImageLoadUtils.loadAvatar(userInfo.getAvatar(), ivAvatar);
|
||||
tvNickname.setText(StringExtensionKt.subAndReplaceDot(userInfo.getName(), 4));
|
||||
tvContent.setText(ImHelperUtils.getMsgDigest(recentContact));
|
||||
// tvContent.setText(ImHelperUtils.getMsgDigest(recentContact));
|
||||
|
||||
contentView.setOnClickListener(v -> RoomMsgActivity.startForPrivateChat(getContext(), recentContact.getFromAccount()));
|
||||
int[] vLoc = new int[2];
|
||||
|
@@ -125,59 +125,6 @@ public class GiftEffectView extends RelativeLayout implements SVGACallback {
|
||||
giftInfo = giftEffectInfo.getGift();
|
||||
}
|
||||
if (giftInfo != null) {
|
||||
int totalCoin = giftInfo.getGoldPrice() * giftEffectInfo.getGiftNum() * giftEffectInfo.getTargetUsers().size();
|
||||
if (totalCoin >= 520 &&
|
||||
giftEffectInfo.getGiftReceiveType() != GiftEffectInfo.GIFT_RECEIVE_TYPE_LUCKY
|
||||
&& !AvRoomDataManager.get().isSelfGamePlaying()) {//礼物栏
|
||||
ImageLoadUtils.loadImage(benefactorAvatar.getContext(), giftEffectInfo.getAvatar(), benefactorAvatar);
|
||||
ImageLoadUtils.loadImage(giftImg.getContext(), giftInfo.getGiftUrl(), giftImg);
|
||||
benefactorNick.setText(giftEffectInfo.getNick());
|
||||
giftNumber.setText("X" + giftEffectInfo.getGiftNum());
|
||||
giftName.setText(giftInfo.getGiftName());
|
||||
container.setVisibility(VISIBLE);
|
||||
if (giftEffectInfo.getGiftReceiveType() == GiftEffectInfo.GIFT_RECEIVE_TYPE_SINGLE) {
|
||||
GiftReceiver giftReceiver = giftEffectInfo.getTargetUsers().get(0);
|
||||
ImageLoadUtils.loadAvatar(receiverAvatar.getContext(), giftReceiver.getAvatar(), receiverAvatar);
|
||||
receiverNick.setText(giftReceiver.getNick());
|
||||
} else if (giftEffectInfo.getGiftReceiveType() == GiftEffectInfo.GIFT_RECEIVE_TYPE_ALL) {
|
||||
receiverAvatar.setImageResource(R.mipmap.app_logo);
|
||||
receiverNick.setText("全麦");
|
||||
} else if (giftEffectInfo.getGiftReceiveType() == GiftEffectInfo.GIFT_RECEIVE_TYPE_MULTI) {
|
||||
receiverAvatar.setImageResource(R.mipmap.app_logo);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (GiftReceiver targetUser : giftEffectInfo.getTargetUsers()) {
|
||||
RoomQueueInfo roomQueueInfo = AvRoomDataManager.get().getRoomQueueMemberInfoByAccount(targetUser.getUid() + "");
|
||||
if (roomQueueInfo == null) continue;
|
||||
sb.append(roomQueueInfo.mRoomMicInfo.getPosition() + 1).append("麦").append(",");
|
||||
}
|
||||
if (sb.length() > 0) {
|
||||
sb.replace(sb.lastIndexOf(","), sb.length(), "");
|
||||
}
|
||||
receiverNick.setText(sb.toString());
|
||||
}
|
||||
|
||||
Animation operatingAnim = AnimationUtils.loadAnimation(getContext(), R.anim.light_bg_rotate_anim);
|
||||
LinearInterpolator lin = new LinearInterpolator();
|
||||
operatingAnim.setInterpolator(lin);
|
||||
giftLightBg.setAnimation(operatingAnim);
|
||||
|
||||
final Point center = new Point();
|
||||
center.x = ResolutionUtils.getScreenWidth(getContext()) / 2;
|
||||
ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(container, "translationX", -UIUtil.dip2px(getContext(), 400), center.x - container.getWidth() / 2).setDuration(500);
|
||||
objectAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
|
||||
objectAnimator.start();
|
||||
|
||||
ObjectAnimator objectAnimator1 = ObjectAnimator.ofFloat(container, "alpha", 0.0F, 1.0F).setDuration(500);
|
||||
objectAnimator1.setInterpolator(new AccelerateDecelerateInterpolator());
|
||||
objectAnimator1.start();
|
||||
if (totalCoin < 4999) {
|
||||
imgBg.setImageResource(R.drawable.icon_gift_effect_bg_1);
|
||||
} else if (totalCoin < 9999) {
|
||||
imgBg.setImageResource(R.drawable.icon_gift_effect_bg_2);
|
||||
} else {
|
||||
imgBg.setImageResource(R.drawable.icon_gift_effect_bg_3);
|
||||
}
|
||||
}
|
||||
effectHandler.sendEmptyMessageDelayed(0, 6000);
|
||||
if (giftInfo.getOtherViewType() == 1 && !TextUtils.isEmpty(giftInfo.getViewUrl())) {
|
||||
drawVAPEffect(giftInfo.getViewUrl());
|
||||
|
@@ -24,7 +24,6 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
|
||||
import com.nnbc123.app.R;
|
||||
@@ -99,8 +98,11 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
private int mScreenWidth;
|
||||
private int mScreenHeight;
|
||||
private Keyframe[] keyScale;
|
||||
private Keyframe[] privilegeCardKeyScale;
|
||||
private Keyframe[] privilegeCardKeyTransY;
|
||||
private Keyframe[] keyTrans;
|
||||
private SvgaObjectPool mMagicViewPool;
|
||||
private PrivilegeCardEngine privilegeCardEngine;
|
||||
private volatile Hashtable<Integer, MonsterAttackInfo> currentAnimationMap = new Hashtable<>();
|
||||
|
||||
|
||||
@@ -126,8 +128,8 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
mScreenHeight = ResolutionUtils.getScreenHeight(getContext());
|
||||
giftWidth = UIUtil.dip2px(context, 80);
|
||||
giftHeight = UIUtil.dip2px(context, 80);
|
||||
privilegeWidth = UIUtil.dip2px(context, 120);
|
||||
privilegeHeight = UIUtil.dip2px(context, 68);
|
||||
privilegeWidth = UIUtil.dip2px(context, 240);
|
||||
privilegeHeight = UIUtil.dip2px(context, 136);
|
||||
|
||||
keyScale = new Keyframe[7];
|
||||
keyScale[0] = (Keyframe.ofFloat(0f, 1f));
|
||||
@@ -142,6 +144,18 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
keyTrans[1] = (Keyframe.ofFloat(0.2f, 0));
|
||||
keyTrans[2] = (Keyframe.ofFloat(0.3f, 0));
|
||||
|
||||
privilegeCardKeyScale = new Keyframe[4];
|
||||
privilegeCardKeyScale[0] = (Keyframe.ofFloat(0f, 0f));
|
||||
privilegeCardKeyScale[1] = (Keyframe.ofFloat(0.08f, 1f));
|
||||
privilegeCardKeyScale[2] = (Keyframe.ofFloat(0.92f, 1f));
|
||||
privilegeCardKeyScale[3] = (Keyframe.ofFloat(1f, 0f));
|
||||
privilegeCardKeyTransY = new Keyframe[4];
|
||||
int showY = mScreenHeight / 2 - mScreenHeight - privilegeHeight / 2;
|
||||
privilegeCardKeyTransY[0] = (Keyframe.ofFloat(0f, 0));
|
||||
privilegeCardKeyTransY[1] = (Keyframe.ofFloat(0.08f, showY));
|
||||
privilegeCardKeyTransY[2] = (Keyframe.ofFloat(0.92f, showY));
|
||||
privilegeCardKeyTransY[3] = (Keyframe.ofFloat(1f, 0));
|
||||
|
||||
giftEffectInfoList = new ArrayList<>();
|
||||
mMagicReceivedInfos = new ArrayList<>();
|
||||
giftEffectView = findViewById(R.id.gift_effect_view);
|
||||
@@ -149,6 +163,7 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
giftEffectView.setGiftEffectListener(this);
|
||||
handler = new UiHandler(this);
|
||||
mMagicViewPool = new SvgaObjectPool(this);
|
||||
privilegeCardEngine = new PrivilegeCardEngine(this, privilegeWidth, privilegeHeight);
|
||||
}
|
||||
|
||||
public void onReceiveMultiGiftMsg(MultiGiftReceiveInfo multiGiftReceiveInfo) {
|
||||
@@ -576,22 +591,18 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
RoomPrivilegeAttachment msgInfo = ((RoomPrivilegeAttachment) message.getAttachment());
|
||||
if (msgInfo == null) return;
|
||||
|
||||
SparseArray<Point> micViewPoint = AvRoomDataManager.get().mMicPointMap;
|
||||
|
||||
if (micViewPoint == null) {
|
||||
//产生空的原因是麦位坐标初始化有500ms延迟
|
||||
LogUtil.print("gift micViewPoint is null");
|
||||
if (!AvRoomDataManager.get().mIsNeedGiftEffect ||
|
||||
AvRoomDataManager.get().isSelfGamePlaying()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Point senderPoint = new Point(UIUtil.getScreenWidth(context) / 2 - privilegeWidth / 2,
|
||||
UIUtil.getScreenHeight(context) / 2);
|
||||
//礼物送到上面中间的位置
|
||||
Point receivePoint = new Point(UIUtil.getScreenWidth(context) / 2 - privilegeWidth / 2,
|
||||
UIUtil.getScreenHeight(context));
|
||||
drawPrivilegeGiftView(senderPoint, receivePoint, msgInfo.getCardUrl());
|
||||
if (msgInfo.getCardType() == 2) {
|
||||
// 视频类型
|
||||
privilegeCardEngine.onPrivilegeSignaling(msgInfo);
|
||||
} else {
|
||||
// 其他类型,继续走之前的老逻辑(PS:后续熟悉房间代码后再把这部分老代码迁移到privilegeCardEngine中吧)
|
||||
drawPrivilegeGiftView(msgInfo.getCardUrl());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void drawGiftEffect(GiftEffectInfo giftEffectInfo) {
|
||||
@@ -790,7 +801,7 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
});
|
||||
}
|
||||
|
||||
private void drawPrivilegeGiftView(Point senderPoint, Point receivePoint, String giftUrl) {
|
||||
private void drawPrivilegeGiftView(String giftUrl) {
|
||||
if (!AvRoomDataManager.get().mIsNeedGiftEffect ||
|
||||
AvRoomDataManager.get().isSelfGamePlaying()) {
|
||||
return;
|
||||
@@ -798,30 +809,16 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
if (giftUrl == null) {
|
||||
return;
|
||||
}
|
||||
final Point center = new Point();
|
||||
center.x = context.getResources().getDisplayMetrics().widthPixels / 2;
|
||||
center.y = context.getResources().getDisplayMetrics().heightPixels / 2;
|
||||
if (senderPoint == null || isGameRoomMoreThan6People()) {
|
||||
senderPoint = new Point(mScreenWidth / 2 - privilegeWidth / 2, UIUtil.dip2px(context, 25));
|
||||
}
|
||||
SVGAImageView imageView = mMagicViewPool.borrowPrivilegeObject(senderPoint);
|
||||
Point firstPoint = new Point(mScreenWidth / 2 - privilegeWidth / 2,
|
||||
mScreenHeight);
|
||||
SVGAImageView imageView = mMagicViewPool.borrowPrivilegeObject(firstPoint);
|
||||
GlideUtils.instance().loadGiftAndCrossFadeRound(
|
||||
giftUrl, imageView, 8f);
|
||||
|
||||
Keyframe keyTransX3 = (Keyframe.ofFloat(0.5f, center.x - senderPoint.x - privilegeWidth / 2));
|
||||
Keyframe keyTransX4 = (Keyframe.ofFloat(0.8f, center.x - senderPoint.x - privilegeWidth / 2));
|
||||
Keyframe keyTransX5 = (Keyframe.ofFloat(1f, receivePoint.x - senderPoint.x));
|
||||
|
||||
Keyframe keyTransY3 = (Keyframe.ofFloat(0.5f, center.y - senderPoint.y - privilegeHeight / 2));
|
||||
Keyframe keyTransY4 = (Keyframe.ofFloat(0.8f, center.y - senderPoint.y - privilegeHeight / 2));
|
||||
Keyframe keyTransY5 = (Keyframe.ofFloat(1f, receivePoint.y - senderPoint.y));
|
||||
|
||||
PropertyValuesHolder p0 = PropertyValuesHolder.ofKeyframe("translationX", keyTrans[0], keyTrans[1], keyTrans[2], keyTransX3, keyTransX4, keyTransX5);
|
||||
PropertyValuesHolder p1 = PropertyValuesHolder.ofKeyframe("translationY", keyTrans[0], keyTrans[1], keyTrans[2], keyTransY3, keyTransY4, keyTransY5);
|
||||
PropertyValuesHolder p2 = PropertyValuesHolder.ofKeyframe("scaleX", keyScale);
|
||||
PropertyValuesHolder p3 = PropertyValuesHolder.ofKeyframe("scaleY", keyScale);
|
||||
ObjectAnimator objectAnimator = ObjectAnimator.ofPropertyValuesHolder(imageView, p2, p3, p1, p0);
|
||||
objectAnimator.setDuration(3200);
|
||||
PropertyValuesHolder p1 = PropertyValuesHolder.ofKeyframe("translationY", privilegeCardKeyTransY);
|
||||
PropertyValuesHolder p2 = PropertyValuesHolder.ofKeyframe("scaleX", privilegeCardKeyScale);
|
||||
PropertyValuesHolder p3 = PropertyValuesHolder.ofKeyframe("scaleY", privilegeCardKeyScale);
|
||||
ObjectAnimator objectAnimator = ObjectAnimator.ofPropertyValuesHolder(imageView, p2, p3, p1);
|
||||
objectAnimator.setDuration(6000);
|
||||
objectAnimator.start();
|
||||
objectAnimator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
@@ -831,6 +828,7 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private boolean isGameRoomMoreThan6People() {
|
||||
RoomInfo roomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
|
||||
return AvRoomDataManager.get().isOpenGame() && roomInfo != null && roomInfo.getMgMicNum() > 6;
|
||||
@@ -858,6 +856,7 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
mMagicExplodeView.stopAnimation();
|
||||
mMagicExplodeView.clearAnimation();
|
||||
mMagicViewPool.shutdown();
|
||||
privilegeCardEngine.onCleared();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -883,7 +882,6 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
mSVGAVideoEntityMap.put(url, videoEntity);
|
||||
}
|
||||
|
||||
|
||||
private static class UiHandler extends Handler {
|
||||
private WeakReference<GiftV2View> mReference;
|
||||
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.nnbc123.app.avroom.widget;
|
||||
|
||||
import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GIFT;
|
||||
import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GIFT_COMPOUND;
|
||||
import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_KITCHEN;
|
||||
import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_PRIVILEGE;
|
||||
@@ -61,6 +62,7 @@ import com.nnbc123.app.avroom.dialog.PKResultDialog;
|
||||
import com.nnbc123.app.common.widget.CustomAutoWidthImageSpan;
|
||||
import com.nnbc123.app.common.widget.CustomImageSpan;
|
||||
import com.nnbc123.app.common.widget.OriginalDrawStatusClickSpan;
|
||||
import com.nnbc123.app.support.LevelIconHelper;
|
||||
import com.nnbc123.app.ui.utils.ImageLoadKt;
|
||||
import com.nnbc123.app.ui.utils.ImageLoadUtils;
|
||||
import com.nnbc123.app.ui.widget.DividerItemDecoration;
|
||||
@@ -92,6 +94,7 @@ import com.nnbc123.core.im.custom.bean.CarveUpGoldAttachment;
|
||||
import com.nnbc123.core.im.custom.bean.CleanScreenAttachment;
|
||||
import com.nnbc123.core.im.custom.bean.CustomAttachment;
|
||||
import com.nnbc123.core.im.custom.bean.DatingAttachment;
|
||||
import com.nnbc123.core.im.custom.bean.DressUpGiftAttachment;
|
||||
import com.nnbc123.core.im.custom.bean.FaceAttachment;
|
||||
import com.nnbc123.core.im.custom.bean.FansTeamMsgAttachment;
|
||||
import com.nnbc123.core.im.custom.bean.GiftAttachment;
|
||||
@@ -120,6 +123,7 @@ import com.nnbc123.core.im.custom.bean.RoomReceivedLuckyGiftAttachment;
|
||||
import com.nnbc123.core.im.custom.bean.RoomTipAttachment;
|
||||
import com.nnbc123.core.im.custom.bean.TarotAttachment;
|
||||
import com.nnbc123.core.im.custom.bean.TarotMsgBean;
|
||||
import com.nnbc123.core.im.custom.bean.UnLockGiftAttachment;
|
||||
import com.nnbc123.core.im.custom.bean.VipMessageAttachment;
|
||||
import com.nnbc123.core.im.custom.bean.WelcomeAttachment;
|
||||
import com.nnbc123.core.im.custom.bean.WishListAttachment;
|
||||
@@ -214,6 +218,7 @@ public class MessageView extends FrameLayout {
|
||||
private int whiteColor;
|
||||
private int greyColor;
|
||||
private int appColor;
|
||||
private int giftColor;
|
||||
private int badgeWidth;
|
||||
private int badgeHeight;
|
||||
private int sysIconHeight;
|
||||
@@ -276,6 +281,7 @@ public class MessageView extends FrameLayout {
|
||||
whiteColor = ContextCompat.getColor(context, R.color.white);
|
||||
greyColor = ContextCompat.getColor(context, R.color.white_transparent_50);
|
||||
appColor = ContextCompat.getColor(context, R.color.app_color);
|
||||
giftColor = ContextCompat.getColor(context, R.color.color_5CEFFF);
|
||||
paddingWidth = Utils.dip2px(context, 10);
|
||||
paddingHeight = Utils.dip2px(context, 8);
|
||||
badgeWidth = Utils.dip2px(context, 15);
|
||||
@@ -283,9 +289,9 @@ public class MessageView extends FrameLayout {
|
||||
sysIconHeight = Utils.dip2px(context, 14);
|
||||
smallFace = Utils.dip2px(context, 22);
|
||||
bigFace = Utils.dip2px(context, 30);
|
||||
//经验等级图片后台已经更换尺寸了,公屏同步下,尺寸是26:20
|
||||
expLevelHeight = Utils.dip2px(context, 20);
|
||||
expLevelWidth = expLevelHeight * 26 / 20;//expLevelHeight * 114 / 45
|
||||
//经验等级图片后台已经更换尺寸了,公屏同步下,尺寸是36:19
|
||||
expLevelHeight = Utils.dip2px(context, 19);
|
||||
expLevelWidth = expLevelHeight * 36 / 19;
|
||||
giftLength = Utils.dip2px(context, 35);
|
||||
// 内容区域
|
||||
layoutManger = new LinearLayoutManager(context, RecyclerView.VERTICAL, false);
|
||||
@@ -1007,9 +1013,16 @@ public class MessageView extends FrameLayout {
|
||||
setWishListComplete(chatRoomMessage, tvContent);
|
||||
}
|
||||
} else if (first == CUSTOM_MSG_PRIVILEGE) {
|
||||
if (second == CustomAttachment.CUSTOM_MSG_PRIVILEGE_SECOND) {
|
||||
if (second == CustomAttachment.CUSTOM_MSG_PRIVILEGE_SECOND || second == CustomAttachment.CUSTOM_MSG_PRIVILEGE_SECOND_VIDEO) {
|
||||
setPrivilegeNoticeMessage(chatRoomMessage, tvContent);
|
||||
}
|
||||
} else if (first == CUSTOM_MSG_GIFT) {
|
||||
setVIPMessageBackground(chatRoomMessage, tvContent);
|
||||
if (second == CustomAttachment.CUSTOM_MSG_GIFT_UNLOCK) {
|
||||
setUnLockGiftMsg(tvContent, (UnLockGiftAttachment) attachment, chatRoomMessage);
|
||||
} else if (second == CustomAttachment.CUSTOM_MSG_GIFT_DRESS) {
|
||||
setDressGiftMsg(tvContent, (DressUpGiftAttachment) attachment, chatRoomMessage);
|
||||
}
|
||||
} else {
|
||||
tvContent.setTextColor(Color.WHITE);
|
||||
tvContent.setText(tvContent.getResources().getText(R.string.not_support_message_tip));
|
||||
@@ -2059,8 +2072,26 @@ public class MessageView extends FrameLayout {
|
||||
builder.append(ivOfficialMask, SizeUtils.dp2px(mContext, 62), expLevelHeight);
|
||||
}
|
||||
//等级
|
||||
builder.append(userLevel, expLevelWidth, expLevelHeight);
|
||||
builder.append(charmLevel, expLevelWidth, expLevelHeight);
|
||||
Integer wealthIconId = LevelIconHelper.INSTANCE.getWealthIconByUrl(userLevel);
|
||||
Integer charmIconId = LevelIconHelper.INSTANCE.getCharmIconByUrl(charmLevel);
|
||||
Drawable wealthDrawable = null;
|
||||
Drawable charmDrawable = null;
|
||||
if (wealthIconId != null) {
|
||||
wealthDrawable = ResourcesCompat.getDrawable(getResources(),
|
||||
wealthIconId, null);
|
||||
}
|
||||
if (charmIconId != null) {
|
||||
charmDrawable = ResourcesCompat.getDrawable(getResources(),
|
||||
charmIconId, null);
|
||||
}
|
||||
if (wealthDrawable != null) {
|
||||
builder.append(wealthDrawable, expLevelWidth, expLevelHeight);
|
||||
}
|
||||
if (charmDrawable != null) {
|
||||
builder.append(charmDrawable, expLevelWidth, expLevelHeight);
|
||||
}
|
||||
// builder.append(userLevel, expLevelWidth, expLevelHeight);
|
||||
// builder.append(charmLevel, expLevelWidth, expLevelHeight);
|
||||
//铭牌
|
||||
String tvNamePlate = NobleUtil.getNamePlate(UserInfo.NAMEPLATE_WORD, chatRoomMessage).trim();
|
||||
String ivNamePlate = NobleUtil.getNamePlate(UserInfo.NAMEPLATE_PIC, chatRoomMessage);
|
||||
@@ -2587,7 +2618,16 @@ public class MessageView extends FrameLayout {
|
||||
String userLevel = NobleUtil.getLevel(UserLevelResourceType.EXPER_URL, chatRoomMessage);
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent);
|
||||
//等级
|
||||
text.append(userLevel, expLevelWidth, expLevelHeight);
|
||||
Integer wealthIconId = LevelIconHelper.INSTANCE.getWealthIconByUrl(userLevel);
|
||||
Drawable wealthDrawable = null;
|
||||
if (wealthIconId != null) {
|
||||
wealthDrawable = ResourcesCompat.getDrawable(getResources(),
|
||||
wealthIconId, null);
|
||||
}
|
||||
if (wealthDrawable != null) {
|
||||
text.append(wealthDrawable, expLevelWidth, expLevelHeight);
|
||||
}
|
||||
// text.append(userLevel, expLevelWidth, expLevelHeight);
|
||||
text.append(senderNick, new ForegroundColorSpan(appColor),
|
||||
new OriginalDrawStatusClickSpan() {
|
||||
@Override
|
||||
@@ -2900,6 +2940,53 @@ public class MessageView extends FrameLayout {
|
||||
|
||||
}
|
||||
|
||||
private void setUnLockGiftMsg(TextView tvContent, UnLockGiftAttachment attachment, ChatRoomMessage chatRoomMessage) {
|
||||
if (attachment == null) return;
|
||||
String nick = RegexUtil.getPrintableString(attachment.getNick());
|
||||
String giftName = attachment.getGiftNameNotNull();
|
||||
String giftImage = attachment.getGiftUrlNotNull();
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
.append(getNewUserDrawable(chatRoomMessage), badgeWidth, badgeHeight)
|
||||
.append(nick, new ForegroundColorSpan(appColor), new OriginalDrawStatusClickSpan() {
|
||||
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
if (clickConsumer != null) {
|
||||
Single.just(chatRoomMessage.getFromAccount()).subscribe(clickConsumer);
|
||||
}
|
||||
}
|
||||
})
|
||||
.append(" 已解锁礼物 ", new ForegroundColorSpan(whiteColor))
|
||||
.append(giftImage, giftLength, giftLength)
|
||||
.append(giftName, new ForegroundColorSpan(giftColor));
|
||||
tvContent.setText(text.build());
|
||||
tvContent.setOnClickListener(null);
|
||||
tvContent.setMovementMethod(new LinkMovementMethod());
|
||||
}
|
||||
|
||||
private void setDressGiftMsg(TextView tvContent, DressUpGiftAttachment attachment, ChatRoomMessage chatRoomMessage) {
|
||||
if (attachment == null) return;
|
||||
String nick = RegexUtil.getPrintableString(attachment.getNick());
|
||||
String dressName = attachment.getDressNameNotNull();
|
||||
String dressImage = attachment.getDressUrlNotNull();
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
.append(getNewUserDrawable(chatRoomMessage), badgeWidth, badgeHeight)
|
||||
.append(nick, new ForegroundColorSpan(appColor), new OriginalDrawStatusClickSpan() {
|
||||
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
if (clickConsumer != null) {
|
||||
Single.just(chatRoomMessage.getFromAccount()).subscribe(clickConsumer);
|
||||
}
|
||||
}
|
||||
})
|
||||
.append(" 获得 " + dressName + " ", new ForegroundColorSpan(whiteColor))
|
||||
.append(dressImage, giftLength);
|
||||
tvContent.setText(text.build());
|
||||
tvContent.setOnClickListener(null);
|
||||
tvContent.setMovementMethod(new LinkMovementMethod());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Drawable getNewUserDrawable(ChatRoomMessage chatRoomMessage) {
|
||||
boolean newUser = NobleUtil.getIsNewUser(UserInfo.IS_NEW_USER, chatRoomMessage);
|
||||
|
@@ -116,6 +116,9 @@ public class MicroView extends LinearLayout implements View.OnLayoutChangeListen
|
||||
}
|
||||
|
||||
private void subMsg() {
|
||||
if (isInEditMode()) {
|
||||
return;
|
||||
}
|
||||
subscribe = IMNetEaseManager.get()
|
||||
.getChatRoomEventObservable().subscribe(
|
||||
roomEvent -> onReceiveRoomEvent(roomEvent),
|
||||
|
@@ -0,0 +1,189 @@
|
||||
package com.nnbc123.app.avroom.widget
|
||||
|
||||
import android.animation.Animator
|
||||
import android.animation.AnimatorListenerAdapter
|
||||
import android.animation.Keyframe
|
||||
import android.animation.ObjectAnimator
|
||||
import android.animation.PropertyValuesHolder
|
||||
import android.graphics.Point
|
||||
import android.net.Uri
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import androidx.core.view.isVisible
|
||||
import com.chuhai.core.player.PlaybackState
|
||||
import com.chuhai.core.player.PlayerListener
|
||||
import com.chuhai.core.player.exo.ExoMediaItem
|
||||
import com.chuhai.core.player.exo.ExoPlayer
|
||||
import com.chuhai.utils.ICleared
|
||||
import com.chuhai.utils.ktx.dp
|
||||
import com.chuhai.utils.ktx.roundCorner
|
||||
import com.chuhai.utils.log.ILog
|
||||
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout
|
||||
import com.nnbc123.app.ui.widget.magicindicator.buildins.UIUtil
|
||||
import com.nnbc123.core.im.custom.bean.RoomPrivilegeAttachment
|
||||
import java.util.LinkedList
|
||||
|
||||
/**
|
||||
* Created by Max on 2023/11/3 10:18
|
||||
* Desc:特权卡(播放引擎)
|
||||
**/
|
||||
class PrivilegeCardEngine(
|
||||
private val parentView: ViewGroup,
|
||||
private val viewWidth: Int,
|
||||
private val viewHeight: Int,
|
||||
) : ICleared, ILog, PlayerListener {
|
||||
|
||||
private val screenWidth: Int by lazy(LazyThreadSafetyMode.NONE) {
|
||||
UIUtil.getScreenWidth(parentView.context)
|
||||
}
|
||||
private val screenHeight: Int by lazy(LazyThreadSafetyMode.NONE) {
|
||||
UIUtil.getScreenHeight(parentView.context)
|
||||
}
|
||||
|
||||
private val centerPoint by lazy(LazyThreadSafetyMode.NONE) {
|
||||
Point(
|
||||
screenWidth / 2,
|
||||
screenHeight / 2
|
||||
)
|
||||
}
|
||||
|
||||
private val player: ExoPlayer by lazy {
|
||||
ExoPlayer(parentView.context).apply {
|
||||
resizeMode = AspectRatioFrameLayout.RESIZE_MODE_ZOOM
|
||||
setListener(this@PrivilegeCardEngine)
|
||||
val params: FrameLayout.LayoutParams = FrameLayout.LayoutParams(viewWidth, viewHeight)
|
||||
this.layoutParams = params
|
||||
params.leftMargin = centerPoint.x - viewWidth / 2
|
||||
params.topMargin = screenHeight
|
||||
if (parentView.indexOfChild(this) == -1) parentView.addView(this)
|
||||
this.roundCorner(8.dp)
|
||||
}
|
||||
}
|
||||
|
||||
// 播放队列
|
||||
private val queue: LinkedList<String> by lazy {
|
||||
LinkedList()
|
||||
}
|
||||
|
||||
/**
|
||||
* 收到特权卡信令
|
||||
*/
|
||||
fun onPrivilegeSignaling(attachment: RoomPrivilegeAttachment) {
|
||||
val url = attachment.effectUrl
|
||||
if (attachment.cardType == 2 && !url.isNullOrEmpty()) {
|
||||
addVideo(url)
|
||||
}
|
||||
}
|
||||
|
||||
private fun addVideo(url: String) {
|
||||
queue.add(url)
|
||||
loopQueue()
|
||||
}
|
||||
|
||||
/**
|
||||
* 轮训队列
|
||||
*/
|
||||
private fun loopQueue() {
|
||||
if (queue.isEmpty()) {
|
||||
return
|
||||
}
|
||||
if (!isPlayEnd()) {
|
||||
// 当前还未播放结束
|
||||
return
|
||||
}
|
||||
val source = queue.poll() ?: return
|
||||
prepare(source)
|
||||
}
|
||||
|
||||
private fun prepare(url: String) {
|
||||
resetPlayer()
|
||||
player.prepare(ExoMediaItem(Uri.parse(url)))
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前播放器是否播放结束
|
||||
*/
|
||||
private fun isPlayEnd(): Boolean {
|
||||
val state = player.getPlaybackState()
|
||||
return state == PlaybackState.ENDED || state == PlaybackState.IDLE
|
||||
}
|
||||
|
||||
override fun onPlaybackStateChanged(state: PlaybackState) {
|
||||
super.onPlaybackStateChanged(state)
|
||||
when (state) {
|
||||
PlaybackState.READY -> {
|
||||
startShowAnim {
|
||||
player.setPlayWhenReady(true)
|
||||
}
|
||||
}
|
||||
|
||||
PlaybackState.ENDED, PlaybackState.IDLE -> {
|
||||
startHideAnim {
|
||||
loopQueue()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun startShowAnim(onEnd: () -> Unit) {
|
||||
val keyTransY1 = Keyframe.ofFloat(0f, 0f)
|
||||
val keyTransY2 =
|
||||
Keyframe.ofFloat(1f, (centerPoint.y - screenHeight - viewHeight / 2).toFloat())
|
||||
|
||||
val keyScale1 = Keyframe.ofFloat(0f, 0f)
|
||||
val keyScale2 = Keyframe.ofFloat(1f, 1f)
|
||||
|
||||
val p1 = PropertyValuesHolder.ofKeyframe("translationY", keyTransY1, keyTransY2)
|
||||
val p2 = PropertyValuesHolder.ofKeyframe("scaleX", keyScale1, keyScale2)
|
||||
val p3 = PropertyValuesHolder.ofKeyframe("scaleY", keyScale1, keyScale2)
|
||||
val objectAnimator = ObjectAnimator.ofPropertyValuesHolder(player, p2, p3, p1)
|
||||
objectAnimator.duration = 500
|
||||
objectAnimator.addListener(object : AnimatorListenerAdapter() {
|
||||
override fun onAnimationEnd(animation: Animator) {
|
||||
onEnd.invoke()
|
||||
}
|
||||
})
|
||||
player.isVisible = true
|
||||
objectAnimator.start()
|
||||
}
|
||||
|
||||
private fun startHideAnim(onEnd: () -> Unit) {
|
||||
val keyTransY1 =
|
||||
Keyframe.ofFloat(0f, (centerPoint.y - screenHeight - viewHeight / 2).toFloat())
|
||||
val keyTransY2 = Keyframe.ofFloat(1f, 0f)
|
||||
|
||||
val keyScale1 = Keyframe.ofFloat(0f, 1f)
|
||||
val keyScale2 = Keyframe.ofFloat(1f, 0f)
|
||||
|
||||
val p1 = PropertyValuesHolder.ofKeyframe("translationY", keyTransY1, keyTransY2)
|
||||
val p2 = PropertyValuesHolder.ofKeyframe("scaleX", keyScale1, keyScale2)
|
||||
val p3 = PropertyValuesHolder.ofKeyframe("scaleY", keyScale1, keyScale2)
|
||||
val objectAnimator = ObjectAnimator.ofPropertyValuesHolder(player, p2, p3, p1)
|
||||
objectAnimator.duration = 500
|
||||
objectAnimator.addListener(object : AnimatorListenerAdapter() {
|
||||
override fun onAnimationEnd(animation: Animator) {
|
||||
onEnd.invoke()
|
||||
}
|
||||
})
|
||||
objectAnimator.start()
|
||||
}
|
||||
|
||||
private fun resetPlayer() {
|
||||
player.stop()
|
||||
player.clearAnimation()
|
||||
player.translationY = 0f
|
||||
player.translationX = 0f
|
||||
player.alpha = 1f
|
||||
player.scaleX = 0f
|
||||
player.scaleY = 0f
|
||||
player.isVisible = false
|
||||
player.setPlayWhenReady(false)
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
queue.clear()
|
||||
resetPlayer()
|
||||
player.onCleared()
|
||||
}
|
||||
}
|
@@ -4,6 +4,7 @@ import static com.nnbc123.core.Constants.DEBUG_MAX_UID;
|
||||
import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MESS_HEAD_NOBLE;
|
||||
import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MESS_SUB_OPENNOBLE;
|
||||
import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MESS_SUB_RENEWNOBLE;
|
||||
import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ALL_SERVICE_GIFT;
|
||||
import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_HEADER_TYPE_GIFT;
|
||||
import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_RED_PACKAGE;
|
||||
import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ALL_DIAMOND;
|
||||
@@ -13,6 +14,7 @@ import static com.nnbc123.library.utils.UIUtils.getActivityByContext;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.Dialog;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -34,6 +36,7 @@ import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.core.util.Consumer;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
@@ -68,7 +71,7 @@ import com.nnbc123.app.ui.login.LoginPhoneActivity;
|
||||
import com.nnbc123.app.ui.pay.ChargeActivity;
|
||||
import com.nnbc123.app.ui.setting.ResetPasswordActivity;
|
||||
import com.nnbc123.app.ui.widget.DefaultToolBar;
|
||||
import com.nnbc123.app.ui.widget.dialog.AllServiceGiftLevelCeremonyDialog;
|
||||
import com.nnbc123.app.ui.widget.dialog.AllServiceGiftLevelDialog;
|
||||
import com.nnbc123.app.ui.widget.dialog.AllServiceVipLevelUPDialog;
|
||||
import com.nnbc123.app.ui.widget.dialog.GameInviteDialog;
|
||||
import com.nnbc123.app.ui.widget.dialog.OpenNobleGlobalNoticeDialog;
|
||||
@@ -113,6 +116,7 @@ import java.lang.ref.WeakReference;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
@@ -133,7 +137,7 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
*/
|
||||
|
||||
protected static final String STATUS_TAG = "STATUS_TAG";
|
||||
private final RxPermissions rxPermissions = new RxPermissions(this);
|
||||
public final RxPermissions rxPermissions = new RxPermissions(this);
|
||||
protected TitleBar mTitleBar;
|
||||
protected DefaultToolBar mToolBar;
|
||||
protected CompositeDisposable mCompositeDisposable;
|
||||
@@ -144,6 +148,8 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
private OpenNobleGlobalNoticeDialog mNoticeDialog;
|
||||
private boolean isShowingChargeDialog;
|
||||
|
||||
private Dialog giftDialog;
|
||||
private LinkedList<AllServiceGiftProtocol.DataBean> giftList;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -339,7 +345,14 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
mNoticeDialog.dismiss();
|
||||
mNoticeDialog = null;
|
||||
}
|
||||
|
||||
if (giftDialog != null && giftDialog.isShowing()) {
|
||||
giftDialog.setOnDismissListener(null);
|
||||
giftDialog.dismiss();
|
||||
giftDialog = null;
|
||||
}
|
||||
if (giftList != null) {
|
||||
giftList.clear();
|
||||
}
|
||||
super.onDestroy();
|
||||
LogUtil.i(this.getClass().getName(), "onDestroy");
|
||||
/* ImageLoadUtils.clearMemory(this);*/
|
||||
@@ -507,7 +520,6 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
.compose(bindUntilEvent(ActivityEvent.PAUSE))
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(this::onRoomEventReceived);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -821,6 +833,17 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
}, Throwable::printStackTrace);
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
public void checkPermission(Consumer<Boolean> consumer, String... mPerms) {
|
||||
rxPermissions.request(mPerms)
|
||||
.subscribe(aBoolean -> {
|
||||
if (consumer != null) {
|
||||
consumer.accept(aBoolean);
|
||||
}
|
||||
}, Throwable::printStackTrace);
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
public Observable<Boolean> checkPermission(String... mPerms) {
|
||||
return rxPermissions.request(mPerms);
|
||||
@@ -918,15 +941,53 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
UserUtils.getUserInfo() == null)
|
||||
return;
|
||||
AllServiceGiftProtocol.DataBean data = JSON.parseObject(String.valueOf(baseProtocol.getData()), AllServiceGiftProtocol.DataBean.class);
|
||||
if (data == null || data.getGiftUrl() == null || !data.isCeremonyGift())
|
||||
if (data == null || data.getGiftUrl() == null)
|
||||
return;
|
||||
new AllServiceGiftLevelCeremonyDialog(context, data).show();
|
||||
if (giftList == null) {
|
||||
giftList = new LinkedList<>();
|
||||
}
|
||||
int second2 = baseProtocol.getSecond();
|
||||
if (second2 == CUSTOM_MSG_ALL_SERVICE_GIFT) {
|
||||
giftList.add(data);
|
||||
if (giftDialog != null && giftDialog.isShowing()) {
|
||||
// 如果当前以及有礼物弹窗在展示,则需要等到他 dismiss 后再显示下一个
|
||||
AllServiceGiftProtocol.DataBean dataBean = giftList.peekFirst();
|
||||
if (dataBean != null) {
|
||||
return;
|
||||
} else {
|
||||
giftDialog.dismiss();
|
||||
}
|
||||
} else {
|
||||
showGiftDialog();
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void showGiftDialog() {
|
||||
if (giftList.size() == 0) return;
|
||||
giftDialog = generateAllServiceGiftDialog(this, giftList.peekFirst());
|
||||
giftDialog.setOnDismissListener(dialog -> {
|
||||
giftList.pollFirst();
|
||||
AllServiceGiftProtocol.DataBean dataBean = giftList.peekFirst();
|
||||
if (dataBean != null) {
|
||||
if (isValid()) {
|
||||
showGiftDialog();
|
||||
} else {
|
||||
giftList.clear();
|
||||
}
|
||||
}
|
||||
});
|
||||
giftDialog.show();
|
||||
}
|
||||
|
||||
private AllServiceGiftLevelDialog generateAllServiceGiftDialog(Context context, AllServiceGiftProtocol.DataBean dataBean) {
|
||||
return new AllServiceGiftLevelDialog(context, dataBean);
|
||||
}
|
||||
|
||||
public void onGrabApprenticesEvent(GrabApprenticesEvent event) {
|
||||
if (!isTopActivity()) return;
|
||||
if (dialog != null && dialog.isAdded()) {
|
||||
|
@@ -5,13 +5,17 @@ import android.content.DialogInterface
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.os.Bundle
|
||||
import android.view.*
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import com.nnbc123.app.ui.utils.getActivityContext
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil
|
||||
import com.nnbc123.app.ui.utils.getActivityContext
|
||||
import com.trello.rxlifecycle3.components.support.RxDialogFragment
|
||||
import java.lang.Exception
|
||||
import java.lang.reflect.ParameterizedType
|
||||
|
||||
abstract class BaseDialog<T : ViewBinding> : RxDialogFragment() {
|
||||
@@ -57,9 +61,13 @@ abstract class BaseDialog<T : ViewBinding> : RxDialogFragment() {
|
||||
}
|
||||
|
||||
fun show(context: Context?) {
|
||||
if (context == null) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
context?.let {
|
||||
show((getActivityContext(it) as FragmentActivity).supportFragmentManager, null)
|
||||
val fragmentActivity = getActivityContext(context) as? FragmentActivity
|
||||
fragmentActivity?.lifecycleScope?.launchWhenResumed {
|
||||
show(fragmentActivity.supportFragmentManager, null)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
|
@@ -0,0 +1,38 @@
|
||||
package com.nnbc123.app.common.permission
|
||||
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageManager
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.tbruyelle.rxpermissions2.RxPermissions
|
||||
|
||||
/**
|
||||
* Created by Max on 2024/1/8 10:25
|
||||
* Desc:
|
||||
**/
|
||||
object PermissionHelper {
|
||||
|
||||
fun isGranted(context: Context, permission: String): Boolean {
|
||||
return ContextCompat.checkSelfPermission(
|
||||
context,
|
||||
permission
|
||||
) == PackageManager.PERMISSION_GRANTED
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查权限是否都授权
|
||||
*/
|
||||
fun isAllGranted(context: Context, vararg permissions: String): Boolean {
|
||||
return permissions.firstOrNull {
|
||||
!isGranted(context, it)
|
||||
} == null
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查权限是否都授权
|
||||
*/
|
||||
fun isAllGranted(rxPermissions: RxPermissions, vararg perms: String): Boolean {
|
||||
return perms.firstOrNull {
|
||||
!rxPermissions.isGranted(it)
|
||||
} == null
|
||||
}
|
||||
}
|
@@ -269,7 +269,6 @@ public class CustomImageSpan extends ImageSpan {
|
||||
loading = true;
|
||||
GlideApp.with(reference.get())
|
||||
.asDrawable()
|
||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||
.dontAnimate()
|
||||
.dontTransform()
|
||||
.override(width, height)
|
||||
|
@@ -3,7 +3,9 @@ package com.nnbc123.app.common.widget;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewParent;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
@@ -67,22 +69,26 @@ public class DragLayout extends RelativeLayout {
|
||||
parentHeight = parent.getHeight();
|
||||
}
|
||||
|
||||
if (left < 0) {
|
||||
left = 0;
|
||||
int parentPaddingLeft = getParentPaddingLeft();
|
||||
if (left < parentPaddingLeft) {
|
||||
left = parentPaddingLeft;
|
||||
right = left + getWidth();
|
||||
}
|
||||
if (right > parentWidth) {
|
||||
right = parentWidth;
|
||||
int paddingPaddingRight = getParentPaddingRight();
|
||||
if (right > (parentWidth - paddingPaddingRight)) {
|
||||
right = (parentWidth - paddingPaddingRight);
|
||||
left = right - getWidth();
|
||||
}
|
||||
if (top < 0) {
|
||||
top = 0;
|
||||
|
||||
int parentPaddingTop = getParentPaddingTop();
|
||||
if (top < parentPaddingTop) {
|
||||
top = parentPaddingTop;
|
||||
bottom = top + getHeight();
|
||||
}
|
||||
|
||||
if (bottom > parentHeight) {
|
||||
|
||||
bottom = parentHeight;
|
||||
int paddingPaddingBottom = getParentPaddingBottom();
|
||||
if (bottom > (parentHeight - paddingPaddingBottom)) {
|
||||
bottom = (parentHeight - paddingPaddingBottom);
|
||||
top = bottom - getHeight();
|
||||
}
|
||||
|
||||
@@ -117,8 +123,8 @@ public class DragLayout extends RelativeLayout {
|
||||
}
|
||||
|
||||
if (layoutParams != null) {
|
||||
layoutParams.leftMargin = left;
|
||||
layoutParams.topMargin = top;
|
||||
layoutParams.leftMargin = left - getParentPaddingLeft();
|
||||
layoutParams.topMargin = top - getParentPaddingTop();
|
||||
layoutParams.width = getWidth();
|
||||
layoutParams.height = getHeight();
|
||||
setLayoutParams(layoutParams);
|
||||
@@ -150,22 +156,26 @@ public class DragLayout extends RelativeLayout {
|
||||
parentHeight = parent.getHeight();
|
||||
}
|
||||
|
||||
if (left < 0) {
|
||||
left = 0;
|
||||
int parentPaddingLeft = getParentPaddingLeft();
|
||||
if (left < parentPaddingLeft) {
|
||||
left = parentPaddingLeft;
|
||||
right = left + getWidth();
|
||||
}
|
||||
if (right > parentWidth) {
|
||||
right = parentWidth;
|
||||
int paddingPaddingRight = getParentPaddingRight();
|
||||
if (right > (parentWidth - paddingPaddingRight)) {
|
||||
right = (parentWidth - paddingPaddingRight);
|
||||
left = right - getWidth();
|
||||
}
|
||||
if (top < 0) {
|
||||
top = 0;
|
||||
|
||||
int parentPaddingTop = getParentPaddingTop();
|
||||
if (top < parentPaddingTop) {
|
||||
top = parentPaddingTop;
|
||||
bottom = top + getHeight();
|
||||
}
|
||||
|
||||
if (bottom > parentHeight) {
|
||||
|
||||
bottom = parentHeight;
|
||||
int paddingPaddingBottom = getParentPaddingBottom();
|
||||
if (bottom > (parentHeight - paddingPaddingBottom)) {
|
||||
bottom = (parentHeight - paddingPaddingBottom);
|
||||
top = bottom - getHeight();
|
||||
}
|
||||
|
||||
@@ -192,4 +202,36 @@ public class DragLayout extends RelativeLayout {
|
||||
return super.performClick();
|
||||
}
|
||||
|
||||
|
||||
protected int getParentPaddingLeft() {
|
||||
ViewParent viewParent = getParent();
|
||||
if (viewParent instanceof View) {
|
||||
return ((View) viewParent).getPaddingLeft();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected int getParentPaddingRight() {
|
||||
ViewParent viewParent = getParent();
|
||||
if (viewParent instanceof View) {
|
||||
return ((View) viewParent).getPaddingRight();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected int getParentPaddingTop() {
|
||||
ViewParent viewParent = getParent();
|
||||
if (viewParent instanceof View) {
|
||||
return ((View) viewParent).getPaddingTop();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected int getParentPaddingBottom() {
|
||||
ViewParent viewParent = getParent();
|
||||
if (viewParent instanceof View) {
|
||||
return ((View) viewParent).getPaddingBottom();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@@ -2,33 +2,24 @@ package com.nnbc123.app.common.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Bitmap.Config;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffXfermode;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.Outline;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.TypedValue;
|
||||
import android.widget.ImageView;
|
||||
import android.view.View;
|
||||
import android.view.ViewOutlineProvider;
|
||||
|
||||
import com.google.android.material.imageview.ShapeableImageView;
|
||||
import com.google.android.material.shape.CornerFamily;
|
||||
import com.google.android.material.shape.ShapeAppearanceModel;
|
||||
import com.nnbc123.app.R;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
|
||||
/**
|
||||
* 自定义View,实现圆角,圆形等效果
|
||||
*
|
||||
* @author zhy
|
||||
*/
|
||||
public class RectRoundImageView extends ImageView {
|
||||
public class RectRoundImageView extends ShapeableImageView {
|
||||
|
||||
/**
|
||||
* TYPE_CIRCLE / TYPE_ROUND
|
||||
@@ -37,42 +28,11 @@ public class RectRoundImageView extends ImageView {
|
||||
public static final int TYPE_CIRCLE = 0;
|
||||
public static final int TYPE_ROUND = 1;
|
||||
|
||||
/**
|
||||
* 图片
|
||||
*/
|
||||
private Bitmap mSrc;
|
||||
|
||||
/**
|
||||
* 圆角的大小
|
||||
*/
|
||||
private int mRadius = 8;
|
||||
|
||||
/**
|
||||
* 控件的宽度
|
||||
*/
|
||||
private int mWidth;
|
||||
/**
|
||||
* 控件的高度
|
||||
*/
|
||||
private int mHeight;
|
||||
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getmRadius() {
|
||||
return mRadius;
|
||||
}
|
||||
|
||||
public void setmRadius(int mRadius) {
|
||||
this.mRadius = mRadius;
|
||||
}
|
||||
|
||||
public RectRoundImageView(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
@@ -98,17 +58,6 @@ public class RectRoundImageView extends ImageView {
|
||||
for (int i = 0; i < n; i++) {
|
||||
int attr = a.getIndex(i);
|
||||
switch (attr) {
|
||||
case R.styleable.RectRoundImageView_src:
|
||||
// mSrc = BitmapFactory.decodeResource(getResources(),
|
||||
// a.getResourceId(attr, 0));
|
||||
InputStream is = getResources().openRawResource(a.getResourceId(attr, 0));
|
||||
BitmapFactory.Options opts = new BitmapFactory.Options();
|
||||
opts.inTempStorage = new byte[100 * 1024];
|
||||
opts.inPreferredConfig = Config.RGB_565;
|
||||
opts.inPurgeable = true;
|
||||
opts.inSampleSize = 4;
|
||||
mSrc = BitmapFactory.decodeStream(is, null, opts);
|
||||
break;
|
||||
case R.styleable.RectRoundImageView_type:
|
||||
type = a.getInt(attr, 0);// 默认为Circle
|
||||
break;
|
||||
@@ -121,197 +70,25 @@ public class RectRoundImageView extends ImageView {
|
||||
}
|
||||
setScaleType(ScaleType.CENTER_CROP);
|
||||
a.recycle();
|
||||
setup(type, mRadius);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 计算控件的高度和宽度
|
||||
*/
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
Drawable drawable = getDrawable();
|
||||
if (null != drawable) {
|
||||
mSrc = drawableToBitmap(getDrawable());
|
||||
}
|
||||
/**
|
||||
* 设置宽度
|
||||
*/
|
||||
int specMode = MeasureSpec.getMode(widthMeasureSpec);
|
||||
int specSize = MeasureSpec.getSize(widthMeasureSpec);
|
||||
|
||||
if (specMode == MeasureSpec.EXACTLY)// match_parent , accurate
|
||||
{
|
||||
mWidth = specSize;
|
||||
} else {
|
||||
// 由图片决定的宽
|
||||
int desireByImg = getPaddingLeft() + getPaddingRight()
|
||||
+ mSrc.getWidth();
|
||||
if (specMode == MeasureSpec.AT_MOST)// wrap_content
|
||||
{
|
||||
mWidth = Math.min(desireByImg, specSize);
|
||||
} else
|
||||
mWidth = desireByImg;
|
||||
}
|
||||
|
||||
/***
|
||||
* 设置高度
|
||||
*/
|
||||
|
||||
specMode = MeasureSpec.getMode(heightMeasureSpec);
|
||||
specSize = MeasureSpec.getSize(heightMeasureSpec);
|
||||
if (specMode == MeasureSpec.EXACTLY)// match_parent , accurate
|
||||
{
|
||||
mHeight = specSize;
|
||||
} else {
|
||||
int desire = getPaddingTop() + getPaddingBottom()
|
||||
+ mSrc.getHeight();
|
||||
|
||||
if (specMode == MeasureSpec.AT_MOST)// wrap_content
|
||||
{
|
||||
mHeight = Math.min(desire, specSize);
|
||||
} else
|
||||
mHeight = desire;
|
||||
}
|
||||
|
||||
setMeasuredDimension(mWidth, mHeight);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制
|
||||
*/
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
|
||||
switch (type) {
|
||||
// 如果是TYPE_CIRCLE绘制圆形
|
||||
case TYPE_CIRCLE:
|
||||
int min = Math.min(mWidth, mHeight);
|
||||
/**
|
||||
* 长度如果不一致,按小的值进行压缩
|
||||
*/
|
||||
if (null != mSrc) {
|
||||
mSrc = Bitmap.createScaledBitmap(mSrc, min, min, false);
|
||||
canvas.drawBitmap(createCircleImage(mSrc, min), 0, 0, null);
|
||||
private void setup(int type, int cornerSize) {
|
||||
if (type == TYPE_CIRCLE) {
|
||||
setOutlineProvider(new ViewOutlineProvider() {
|
||||
@Override
|
||||
public void getOutline(View view, Outline outline) {
|
||||
int min = Math.min(view.getWidth(), view.getHeight());
|
||||
int left = (view.getWidth() - min) / 2;
|
||||
int top = (view.getHeight() - min) / 2;
|
||||
outline.setOval(left, top, min, min);
|
||||
}
|
||||
break;
|
||||
case TYPE_ROUND:
|
||||
canvas.drawBitmap(createFramedPhoto(mWidth, mHeight, mSrc, mRadius), 0, 0, null);
|
||||
break;
|
||||
});
|
||||
setClipToOutline(true);
|
||||
} else if (type == TYPE_ROUND) {
|
||||
setShapeAppearanceModel(ShapeAppearanceModel.builder()
|
||||
.setAllCorners(CornerFamily.ROUNDED, cornerSize)
|
||||
.build());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Drawable → Bitmap
|
||||
*
|
||||
* @param drawable
|
||||
* @return
|
||||
*/
|
||||
|
||||
public static Bitmap drawableToBitmap(Drawable drawable) {
|
||||
|
||||
|
||||
Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
|
||||
|
||||
drawable.getIntrinsicHeight(),
|
||||
|
||||
drawable.getOpacity() != PixelFormat.OPAQUE ? Config.ARGB_8888
|
||||
|
||||
: Config.RGB_565);
|
||||
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
|
||||
//canvas.setBitmap(bitmap);
|
||||
|
||||
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
|
||||
|
||||
drawable.draw(canvas);
|
||||
|
||||
return bitmap;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据原图和变长绘制圆形图片
|
||||
*
|
||||
* @param source
|
||||
* @param min
|
||||
* @return
|
||||
*/
|
||||
private Bitmap createCircleImage(Bitmap source, int min) {
|
||||
final Paint paint = new Paint();
|
||||
paint.setAntiAlias(true);
|
||||
Bitmap target = Bitmap.createBitmap(min, min, Config.RGB_565);
|
||||
/**
|
||||
* 产生一个同样大小的画布
|
||||
*/
|
||||
Canvas canvas = new Canvas(target);
|
||||
/**
|
||||
* 首先绘制圆形
|
||||
*/
|
||||
canvas.drawCircle(min / 2, min / 2, min / 2, paint);
|
||||
/**
|
||||
* 使用SRC_IN,参考上面的说明
|
||||
*/
|
||||
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
|
||||
/**
|
||||
* 绘制图片
|
||||
*/
|
||||
canvas.drawBitmap(source, 0, 0, paint);
|
||||
return target;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据原图添加圆角
|
||||
*
|
||||
* @param source
|
||||
* @return
|
||||
*/
|
||||
private Bitmap createRoundConerImage(Bitmap source) {
|
||||
final Paint paint = new Paint();
|
||||
paint.setAntiAlias(true);
|
||||
Bitmap target = Bitmap.createBitmap(mWidth, mHeight, Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(target);
|
||||
RectF rect = new RectF(0, 0, source.getWidth(), source.getHeight());
|
||||
canvas.drawRoundRect(rect, mRadius, mRadius, paint);
|
||||
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
|
||||
canvas.drawBitmap(source, 0, 0, paint);
|
||||
return target;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param x 图像的宽度
|
||||
* @param y 图像的高度
|
||||
* @param image 源图片
|
||||
* @param outerRadiusRat 圆角的大小
|
||||
* @return 圆角图片
|
||||
*/
|
||||
Bitmap createFramedPhoto(int x, int y, Bitmap image, float outerRadiusRat) {
|
||||
//根据源文件新建一个darwable对象
|
||||
Drawable imageDrawable = new BitmapDrawable(image);
|
||||
// 新建一个新的输出图片
|
||||
Bitmap output = Bitmap.createBitmap(x, y, Config.ARGB_8888);
|
||||
|
||||
Canvas canvas = new Canvas(output);
|
||||
|
||||
// 新建一个矩形
|
||||
RectF outerRect = new RectF(0, 0, x, y);
|
||||
|
||||
// 产生一个红色的圆角矩形
|
||||
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
paint.setColor(Color.RED);
|
||||
canvas.drawRoundRect(outerRect, outerRadiusRat, outerRadiusRat, paint);
|
||||
|
||||
// 将源图片绘制到这个圆角矩形上
|
||||
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
|
||||
imageDrawable.setBounds(0, 0, x, y);
|
||||
canvas.saveLayer(outerRect, paint, Canvas.ALL_SAVE_FLAG);
|
||||
imageDrawable.draw(canvas);
|
||||
canvas.restore();
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
@@ -2,7 +2,6 @@ package com.nnbc123.app.decoration.adapter;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.netease.nim.uikit.support.glide.GlideApp;
|
||||
import com.nnbc123.app.R;
|
||||
@@ -39,62 +38,22 @@ public class MyCarAdapter extends BaseAdapter<CarInfo> {
|
||||
|
||||
helper.addOnClickListener(R.id.tv_used);
|
||||
|
||||
// 倒计时
|
||||
int remainingDay = item.getRemainingDay();
|
||||
int status = item.getStatus();
|
||||
boolean canUse;
|
||||
|
||||
if (remainingDay >= 0 && status == CarInfo.STATUS_USER_CAN_USE) {
|
||||
canUse = true;
|
||||
} else {
|
||||
canUse = false;
|
||||
}
|
||||
|
||||
// 时间
|
||||
if (remainingDay >= 0 && status == CarInfo.STATUS_USER_CAN_USE) {
|
||||
String days;
|
||||
if (item.getRemainingDay() > 99){
|
||||
days = "99+";
|
||||
}else {
|
||||
days = item.getRemainingDay()+"";
|
||||
if (item.getStatus() == CarInfo.STATUS_USER_CAN_USE) {
|
||||
binding.tvUsed.setVisibility(View.VISIBLE);
|
||||
binding.tvUsed.setEnabled(true);
|
||||
binding.tvCounters.setText(mContext.getString(R.string.decoration_remainder) + item.getExpireText());
|
||||
if (item.isUsing()) {
|
||||
binding.tvUsed.setText("取消使用");
|
||||
binding.tvUsed.setBackgroundResource(R.drawable.bg_common_cancel);
|
||||
} else {
|
||||
binding.tvUsed.setText("使用");
|
||||
binding.tvUsed.setBackgroundResource(R.drawable.bg_common_confirm);
|
||||
}
|
||||
binding.tvCounters.setText(String.format(binding.tvCounters.getResources().getString(R.string.decoration_status_wrapper),
|
||||
binding.tvCounters.getResources().getString(R.string.decoration_remainder) + days + "天"));
|
||||
} else {
|
||||
if (status == CarInfo.STATUS_OFF_SHELF || status == CarInfo.STATUS_OUT_OF_DATE) {
|
||||
binding.tvCounters.setText(String.format(binding.tvCounters.getResources().getString(R.string.decoration_status_wrapper),
|
||||
binding.tvCounters.getResources().getString(R.string.past_due)));
|
||||
}
|
||||
binding.tvUsed.setVisibility(View.GONE);
|
||||
binding.tvCounters.setText(binding.tvCounters.getResources().getString(R.string.past_due));
|
||||
}
|
||||
|
||||
|
||||
setUseButton(binding.tvUsed, canUse, item.isUsing());
|
||||
updateTag(item, binding.ivTag);
|
||||
|
||||
}
|
||||
|
||||
private void setUseButton(TextView tvUsed, boolean canUse, boolean isUsing) {
|
||||
|
||||
if (!canUse) {
|
||||
tvUsed.setVisibility(View.GONE);
|
||||
tvUsed.setText("使用");
|
||||
tvUsed.setBackgroundResource(R.drawable.bg_common_disable);
|
||||
tvUsed.setEnabled(false);
|
||||
tvUsed.setTextColor(mContext.getResources().getColor(R.color.text_secondary_878b9c));
|
||||
} else if (isUsing) {
|
||||
tvUsed.setVisibility(View.VISIBLE);
|
||||
tvUsed.setText("取消使用");
|
||||
tvUsed.setBackgroundResource(R.drawable.bg_common_cancel);
|
||||
tvUsed.setEnabled(true);
|
||||
tvUsed.setTextColor(mContext.getResources().getColor(R.color.text_normal_282828));
|
||||
} else {
|
||||
tvUsed.setVisibility(View.VISIBLE);
|
||||
tvUsed.setText("使用");
|
||||
tvUsed.setBackgroundResource(R.drawable.bg_common_confirm);
|
||||
tvUsed.setTextColor(mContext.getResources().getColor(R.color.text_title_282828));
|
||||
tvUsed.setEnabled(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void updateTag(CarInfo carInfo, ImageView ivTag) {
|
||||
|
@@ -55,25 +55,12 @@ public class MyChatBubbleAdapter extends BaseAdapter<ChatBubbleInfo> {
|
||||
binding.tvUsed.setVisibility(View.GONE);
|
||||
binding.tvUsed.setEnabled(false);
|
||||
binding.tvUsed.setText("使用");
|
||||
binding.tvCounters.setText(mContext.getString(R.string.past_due));
|
||||
} else {
|
||||
binding.tvUsed.setVisibility(View.VISIBLE);
|
||||
binding.tvUsed.setEnabled(true);
|
||||
|
||||
binding.tvCounters.setText(mContext.getString(R.string.decoration_remainder) + item.getExpireText());
|
||||
}
|
||||
|
||||
// 日期展示
|
||||
if (item.isHasExpired()) { // 过期
|
||||
binding.tvCounters.setText(mContext.getString(R.string.past_due));
|
||||
} else {
|
||||
String days;
|
||||
if (item.getExpireDays() > 99) {
|
||||
days = "99+";
|
||||
} else {
|
||||
days = item.getExpireDays() + "";
|
||||
}
|
||||
binding.tvCounters.setText(mContext.getString(R.string.decoration_remainder) + days + mContext.getString(R.string.day));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -46,30 +46,14 @@ public class MyHeadWearAdapter extends BaseAdapter<HeadWearInfo> {
|
||||
binding.ivTag.setImageResource(R.drawable.ic_mark_exclusive);
|
||||
}
|
||||
|
||||
// 过期状态不可使用
|
||||
if (item.getStatus() == 2) {
|
||||
binding.tvUsed.setVisibility(View.GONE);
|
||||
binding.tvUsed.setEnabled(false);
|
||||
binding.tvUsed.setText("使用");
|
||||
} else {
|
||||
if (item.getStatus() == 1) {
|
||||
binding.tvUsed.setVisibility(View.VISIBLE);
|
||||
binding.tvUsed.setEnabled(true);
|
||||
|
||||
}
|
||||
|
||||
// 日期展示
|
||||
if (item.getStatus() == 2) { // 过期
|
||||
binding.tvCounters.setText(mContext.getString(R.string.past_due));
|
||||
binding.tvCounters.setText(mContext.getString(R.string.decoration_remainder) + item.getExpireText());
|
||||
} else {
|
||||
String days;
|
||||
if (item.getExpireDays() > 99){
|
||||
days = "99+";
|
||||
}else {
|
||||
days = item.getExpireDays()+"";
|
||||
}
|
||||
binding.tvCounters.setText(mContext.getString(R.string.decoration_remainder) + days + mContext.getString(R.string.day));
|
||||
binding.tvUsed.setVisibility(View.GONE);
|
||||
binding.tvCounters.setText(mContext.getString(R.string.past_due));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -32,31 +32,16 @@ public class MyNamePlateAdapter extends BaseQuickAdapter<NamePlateInfo.Nameplate
|
||||
.load(item.getNameplateImage())
|
||||
.into(ivCover);
|
||||
|
||||
|
||||
//使用按钮
|
||||
TextView tvUsed = helper.getView(R.id.tv_used);
|
||||
tvUsed.setBackgroundResource(item.isUsing() ? R.drawable.bg_common_cancel : R.drawable.bg_common_confirm);
|
||||
tvUsed.setTextColor(item.isUsing() ? mContext.getResources().getColor(R.color.color_4C5AF1) :
|
||||
mContext.getResources().getColor(R.color.white));
|
||||
tvUsed.setText(item.isUsing() ? R.string.label_used : R.string.label_can_use);
|
||||
if (item.isIsExpired()) { // 过期
|
||||
// 日期展示
|
||||
if (!item.isExpired()) {
|
||||
helper.setText(R.id.tv_counters, mContext.getString(R.string.decoration_remainder) + item.getExpireText());
|
||||
tvUsed.setVisibility(View.VISIBLE);
|
||||
tvUsed.setText(item.isUsing() ? R.string.label_used : R.string.label_can_use);
|
||||
tvUsed.setEnabled(true);
|
||||
tvUsed.setBackgroundResource(item.isUsing() ? R.drawable.bg_common_cancel : R.drawable.bg_common_confirm);
|
||||
} else {
|
||||
helper.setText(R.id.tv_counters, mContext.getString(R.string.past_due));
|
||||
tvUsed.setVisibility(View.GONE);
|
||||
tvUsed.setEnabled(false);
|
||||
tvUsed.setBackgroundResource(R.drawable.bg_common_disable);
|
||||
tvUsed.setText("使用");
|
||||
tvUsed.setTextColor(mContext.getResources().getColor(R.color.text_secondary_878b9c));
|
||||
} else {
|
||||
String days;
|
||||
if (item.getExpireDays() > 99) {
|
||||
days = "99+";
|
||||
} else {
|
||||
days = item.getExpireDays() + "";
|
||||
}
|
||||
helper.setText(R.id.tv_counters, mContext.getString(R.string.decoration_remainder) + days + mContext.getString(R.string.day));
|
||||
tvUsed.setVisibility(View.VISIBLE);
|
||||
tvUsed.setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -54,25 +54,12 @@ public class MyUserCardWearAdapter extends BaseAdapter<UserCardWearInfo> {
|
||||
binding.tvUsed.setVisibility(View.GONE);
|
||||
binding.tvUsed.setEnabled(false);
|
||||
binding.tvUsed.setText("使用");
|
||||
binding.tvCounters.setText(mContext.getString(R.string.past_due));
|
||||
} else {
|
||||
binding.tvUsed.setVisibility(View.VISIBLE);
|
||||
binding.tvUsed.setEnabled(true);
|
||||
|
||||
binding.tvCounters.setText(mContext.getString(R.string.decoration_remainder) + item.getExpireText());
|
||||
}
|
||||
|
||||
// 日期展示
|
||||
if (item.isHasExpired()) { // 过期
|
||||
binding.tvCounters.setText(mContext.getString(R.string.past_due));
|
||||
} else {
|
||||
String days;
|
||||
if (item.getExpireDays() > 99) {
|
||||
days = "99+";
|
||||
} else {
|
||||
days = item.getExpireDays() + "";
|
||||
}
|
||||
binding.tvCounters.setText(mContext.getString(R.string.decoration_remainder) + days + mContext.getString(R.string.day));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,13 +1,18 @@
|
||||
package com.nnbc123.app.decoration.view.widgets;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.nnbc123.app.R;
|
||||
import com.nnbc123.app.ui.widget.magicindicator.buildins.UIUtil;
|
||||
import com.nnbc123.app.ui.widget.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter;
|
||||
import com.nnbc123.app.ui.widget.magicindicator.buildins.commonnavigator.abs.IPagerIndicator;
|
||||
import com.nnbc123.app.ui.widget.magicindicator.buildins.commonnavigator.abs.IPagerTitleView;
|
||||
import com.nnbc123.app.ui.widget.magicindicator.buildins.commonnavigator.indicators.LinePagerIndicator;
|
||||
import com.nnbc123.core.home.bean.TabInfo;
|
||||
|
||||
import java.util.List;
|
||||
@@ -38,9 +43,9 @@ public class MyDecorationMagicIndicator extends CommonNavigatorAdapter {
|
||||
public IPagerTitleView getTitleView(Context context, final int i) {
|
||||
BadgeScaleTransitionPagerTitleView scaleTransitionPagerTitleView = new BadgeScaleTransitionPagerTitleView(context);
|
||||
scaleTransitionPagerTitleView.setNormalColor(ContextCompat.getColor(mContext, R.color.text_secondary_878b9c));
|
||||
scaleTransitionPagerTitleView.setSelectedColor(ContextCompat.getColor(mContext, R.color.text_title_282828));
|
||||
scaleTransitionPagerTitleView.setSelectedColor(ContextCompat.getColor(mContext, R.color.color_2B2D33));
|
||||
scaleTransitionPagerTitleView.setMinScale(0.9f);
|
||||
scaleTransitionPagerTitleView.setTextSize(15);
|
||||
scaleTransitionPagerTitleView.setTextSize(14);
|
||||
scaleTransitionPagerTitleView.setText(mTitleList.get(i).getName());
|
||||
if (mTitleList.get(i).getName().equals("座驾")) {
|
||||
scaleTransitionPagerTitleView.findViewById(R.id.car_badge).setId(R.id.car_badge_garage);
|
||||
@@ -62,7 +67,16 @@ public class MyDecorationMagicIndicator extends CommonNavigatorAdapter {
|
||||
|
||||
@Override
|
||||
public IPagerIndicator getIndicator(Context context) {
|
||||
return null;
|
||||
LinePagerIndicator indicator = new LinePagerIndicator(context);
|
||||
indicator.setMode(LinePagerIndicator.MODE_EXACTLY);
|
||||
indicator.setLineHeight(UIUtil.dip2px(context, 4));
|
||||
indicator.setRoundRadius(UIUtil.dip2px(context, 2));
|
||||
indicator.setLineWidth(UIUtil.dip2px(context, 8));
|
||||
indicator.setColors(Color.parseColor("#FFDA24"));
|
||||
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
//lp.bottomMargin = 0;
|
||||
indicator.setLayoutParams(lp);
|
||||
return indicator;
|
||||
}
|
||||
|
||||
public void setOnItemSelectListener(OnItemSelectListener onItemSelectListener) {
|
||||
|
134
app/src/main/java/com/nnbc123/app/game_room/GameRoomActivity.kt
Normal file
134
app/src/main/java/com/nnbc123/app/game_room/GameRoomActivity.kt
Normal file
@@ -0,0 +1,134 @@
|
||||
package com.nnbc123.app.game_room
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.gyf.immersionbar.ImmersionBar
|
||||
import com.nnbc123.app.R
|
||||
import com.nnbc123.app.avroom.activity.AVRoomActivity
|
||||
import com.nnbc123.app.base.BaseBindingActivity
|
||||
import com.nnbc123.app.common.EmptyViewHelper
|
||||
import com.nnbc123.app.common.widget.dialog.DialogManager.AbsOkDialogListener
|
||||
import com.nnbc123.app.databinding.ActivityMoreRoomBinding
|
||||
import com.nnbc123.app.home.dialog.RecommendRoomDialog
|
||||
import com.nnbc123.app.ui.utils.RVDelegate
|
||||
import com.nnbc123.app.ui.webview.CommonWebViewActivity
|
||||
import com.nnbc123.core.UriProvider
|
||||
import com.nnbc123.core.bean.response.observeResult
|
||||
import com.nnbc123.core.home.bean.HomeRoomInfo
|
||||
import com.nnbc123.core.pay.PayModel.NOT_REAL_NAME_BEFORE_CHARGING
|
||||
import com.nnbc123.core.statistic.StatisticManager
|
||||
import com.nnbc123.core.statistic.protocol.StatisticsProtocol
|
||||
import com.nnbc123.core.utils.net.ServerException
|
||||
import com.nnbc123.library.annatation.ActLayoutRes
|
||||
|
||||
/**
|
||||
* 更多游戏-房间列表
|
||||
*/
|
||||
@ActLayoutRes(R.layout.activity_more_room)
|
||||
class GameRoomActivity : BaseBindingActivity<ActivityMoreRoomBinding>() {
|
||||
|
||||
private val gameTabAdapter = GameTabAdapter()
|
||||
private val roomAdapter = GameRoomAdapter()
|
||||
private lateinit var viewModel: GameRoomViewModel
|
||||
|
||||
private var rvDelegate: RVDelegate<HomeRoomInfo>? = null
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context) {
|
||||
val starter = Intent(context, GameRoomActivity::class.java)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
ImmersionBar.with(this).titleBarMarginTop(mBinding.ivBack).init()
|
||||
viewModel = ViewModelProvider(this)[GameRoomViewModel::class.java]
|
||||
initView()
|
||||
initEvent()
|
||||
initObserve()
|
||||
viewModel.getData()
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
mBinding.ivBack.setOnClickListener {
|
||||
finish()
|
||||
}
|
||||
mBinding.rvTop.adapter = gameTabAdapter
|
||||
|
||||
rvDelegate = RVDelegate.Builder<HomeRoomInfo>()
|
||||
.setAdapter(roomAdapter)
|
||||
.setRecyclerView(mBinding.recyclerView)
|
||||
.setEmptyView(EmptyViewHelper.createEmptyView(context, "暂无数据"))
|
||||
.setLayoutManager(GridLayoutManager(this, 2))
|
||||
.build()
|
||||
}
|
||||
|
||||
private fun initObserve() {
|
||||
viewModel.jumpLiveData.observeResult(this, success = {
|
||||
dialogManager.dismissDialog()
|
||||
it?.let {
|
||||
if (it.isPick) {
|
||||
AVRoomActivity.start(context, it.uid)
|
||||
} else {
|
||||
RecommendRoomDialog.newInstance(it).show(context)
|
||||
}
|
||||
}
|
||||
}, failed = {
|
||||
dialogManager.dismissDialog()
|
||||
if ((it as? ServerException)?.code == NOT_REAL_NAME_BEFORE_CHARGING) {
|
||||
dialogManager.showTipsDialog(getString(R.string.tips_need_to_certification),
|
||||
getString(R.string.go_to_certification),
|
||||
object : AbsOkDialogListener() {
|
||||
override fun onOk() {
|
||||
// 跳去实名认证页面
|
||||
CommonWebViewActivity.start(
|
||||
this@GameRoomActivity.context,
|
||||
UriProvider.getTutuRealNamePage()
|
||||
)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
toast(it.message)
|
||||
}
|
||||
})
|
||||
viewModel.gameTabLiveData.observe(this) {
|
||||
gameTabAdapter.setNewData(it)
|
||||
mBinding.rvTop.isVisible = !it.isNullOrEmpty()
|
||||
}
|
||||
viewModel.roomListLiveData.observe(this) {
|
||||
rvDelegate?.loadData(it)
|
||||
}
|
||||
}
|
||||
|
||||
private fun initEvent() {
|
||||
gameTabAdapter.setOnItemClickListener { adapter, view, position ->
|
||||
gameTabAdapter.getItem(position)?.let {
|
||||
StatisticManager.Instance().onEvent(
|
||||
StatisticsProtocol.EVENT_HOMEPAGE_MORE_GAME_TAB_CLICK,
|
||||
it.name
|
||||
)
|
||||
dialogManager.showProgressDialog(this)
|
||||
val type = if (it.isFriendsType == true) {
|
||||
2
|
||||
} else {
|
||||
1
|
||||
}
|
||||
viewModel.getJumpInfo(it.mgId ?: 0, type)
|
||||
}
|
||||
}
|
||||
roomAdapter.setOnItemClickListener { adapter, view, position ->
|
||||
roomAdapter.getItem(position)?.let {
|
||||
AVRoomActivity.start(context, it.uid)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
dialogManager?.dismissDialog()
|
||||
}
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
package com.nnbc123.app.game_room
|
||||
|
||||
import android.widget.ImageView
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.nnbc123.app.R
|
||||
import com.nnbc123.app.ui.utils.load
|
||||
import com.nnbc123.core.home.bean.HomeRoomInfo
|
||||
|
||||
/**
|
||||
* Created by Max on 2023/12/26 11:31
|
||||
* Desc:
|
||||
**/
|
||||
class GameRoomAdapter :
|
||||
BaseQuickAdapter<HomeRoomInfo, BaseViewHolder>(R.layout.game_room_item_room) {
|
||||
override fun convert(helper: BaseViewHolder, item: HomeRoomInfo) {
|
||||
helper.getView<ImageView>(R.id.iv_bg)
|
||||
.load(item.backgroundPic, defaultRes = R.drawable.game_room_bg_item_default)
|
||||
helper.getView<ImageView>(R.id.iv_room_cover).load(item.avatar)
|
||||
helper.setText(R.id.tv_room_name, item.title)
|
||||
helper.setText(R.id.tv_online_number, "${item.onlineNum}")
|
||||
|
||||
//gameState=0 (idle 状态,游戏未开始,空闲状态);gameState=1 (loading 状态,所有玩家都准备好,队长点击了开始游戏按钮,等待加载游戏场景开始游戏);gameState=2(playing状态,游戏进行中状态)
|
||||
if (item.mgId > 0) {
|
||||
when (item.state) {
|
||||
0 -> {
|
||||
helper.setText(R.id.tv_message, "游戏未开始,等待加入")
|
||||
}
|
||||
|
||||
else -> {
|
||||
helper.setText(R.id.tv_message, "游戏进行中,立即围观")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
helper.setText(R.id.tv_message, "扩列交友")
|
||||
}
|
||||
|
||||
val avatars: Array<ImageView> = arrayOf(
|
||||
helper.getView(R.id.iv_avatar_0),
|
||||
helper.getView(R.id.iv_avatar_1),
|
||||
helper.getView(R.id.iv_avatar_2),
|
||||
helper.getView(R.id.iv_avatar_3)
|
||||
)
|
||||
for (i in avatars.indices) {
|
||||
val avatarUrl = item.micUsers?.getOrNull(i)?.avatar
|
||||
avatars[i].load(avatarUrl, defaultRes = R.drawable.game_room_ic_mic)
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
package com.nnbc123.app.game_room
|
||||
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.nnbc123.app.base.BaseViewModel
|
||||
import com.nnbc123.core.bean.response.BeanResult
|
||||
import com.nnbc123.core.bean.response.ListResult
|
||||
import com.nnbc123.core.home.bean.HomeGameBean
|
||||
import com.nnbc123.core.home.bean.HomeRoomInfo
|
||||
import com.nnbc123.core.home.model.HomeModel
|
||||
import com.nnbc123.core.utils.toast
|
||||
|
||||
class GameRoomViewModel : BaseViewModel() {
|
||||
|
||||
val gameTabLiveData = MutableLiveData<List<HomeGameBean>>()
|
||||
val roomListLiveData = MutableLiveData<ListResult<HomeRoomInfo>>()
|
||||
|
||||
val jumpLiveData = MutableLiveData<BeanResult<HomeRoomInfo>?>()
|
||||
|
||||
fun getData() {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
roomListLiveData.value = ListResult.failed(1)
|
||||
gameTabLiveData.value = ArrayList<HomeGameBean>().apply {
|
||||
add(HomeGameBean(isFriendsType = true))
|
||||
}
|
||||
},
|
||||
block = {
|
||||
val result = HomeModel.getHomeGame()
|
||||
val gameList = ArrayList<HomeGameBean>()
|
||||
result?.miniGames?.let {
|
||||
gameList.addAll(it)
|
||||
}
|
||||
gameList.add(HomeGameBean(isFriendsType = true))
|
||||
gameTabLiveData.value = gameList
|
||||
roomListLiveData.value = ListResult.success(result?.playRooms, 1)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun getJumpInfo(id: Long, type: Int) {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
jumpLiveData.value = BeanResult.failed(it)
|
||||
},
|
||||
block = {
|
||||
jumpLiveData.value = BeanResult.success(HomeModel.getResourceJumpInfo(id, type))
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
package com.nnbc123.app.game_room
|
||||
|
||||
import android.widget.ImageView
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.nnbc123.app.R
|
||||
import com.nnbc123.app.ui.utils.load
|
||||
import com.nnbc123.core.home.bean.HomeGameBean
|
||||
|
||||
/**
|
||||
* Created by Max on 2023/12/26 11:31
|
||||
* Desc:
|
||||
**/
|
||||
class GameTabAdapter :
|
||||
BaseQuickAdapter<HomeGameBean, BaseViewHolder>(R.layout.game_room_item_tab) {
|
||||
override fun convert(helper: BaseViewHolder, item: HomeGameBean) {
|
||||
if (item.isFriendsType == true) {
|
||||
helper.getView<ImageView>(R.id.iv_cover)
|
||||
.setImageResource(R.drawable.game_room_bg_friends)
|
||||
} else {
|
||||
helper.getView<ImageView>(R.id.iv_cover).load(item.pic)
|
||||
}
|
||||
}
|
||||
}
|
90
app/src/main/java/com/nnbc123/app/home/FriendsViewModel.kt
Normal file
90
app/src/main/java/com/nnbc123/app/home/FriendsViewModel.kt
Normal file
@@ -0,0 +1,90 @@
|
||||
package com.nnbc123.app.home
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.nnbc123.app.base.BaseViewModel
|
||||
import com.nnbc123.core.bean.response.BeanResult
|
||||
import com.nnbc123.core.bean.response.ListResult
|
||||
import com.nnbc123.core.home.bean.HomeGameTab
|
||||
import com.nnbc123.core.home.bean.HomeRoomInfo
|
||||
import com.nnbc123.core.home.model.HomeModel
|
||||
import com.nnbc123.core.user.bean.UserInfo
|
||||
import com.nnbc123.core.utils.toast
|
||||
|
||||
/**
|
||||
* Created by Max on 2023/12/27 10:18
|
||||
* Desc:
|
||||
**/
|
||||
class FriendsViewModel: BaseViewModel() {
|
||||
|
||||
private val _resourceJumpLiveData = MutableLiveData<BeanResult<HomeRoomInfo>?>()
|
||||
val resourceJumpLiveData: LiveData<BeanResult<HomeRoomInfo>?> = _resourceJumpLiveData
|
||||
|
||||
private val _homeChatPickLiveData = MutableLiveData<String?>()
|
||||
val homeChatPickLiveData: LiveData<String?> = _homeChatPickLiveData
|
||||
|
||||
private val _newFriendLiveData = MutableLiveData<ListResult<UserInfo>>()
|
||||
val newFriendLiveData: LiveData<ListResult<UserInfo>> = _newFriendLiveData
|
||||
|
||||
val friendRecommendModeLiveData = MutableLiveData<ListResult<UserInfo>>()
|
||||
|
||||
val gameTabLiveData = MutableLiveData<MutableList<HomeGameTab>>()
|
||||
|
||||
fun getResourceJumpInfo(id: Long) {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
_resourceJumpLiveData.value = BeanResult.failed(it)
|
||||
},
|
||||
block = {
|
||||
_resourceJumpLiveData.value = BeanResult.success(HomeModel.getResourceJumpInfo(id, 0))
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun getHomeChatPick() {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
_homeChatPickLiveData.value = null
|
||||
it.message.toast()
|
||||
},
|
||||
block = {
|
||||
_homeChatPickLiveData.value = HomeModel.getHomeChatPick()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun getNewFriendList(gender: Int? = null, gameId: Long? = null) {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
_newFriendLiveData.value = ListResult.failed(1)
|
||||
},
|
||||
block = {
|
||||
val result = HomeModel.getNewFriendList(gender, gameId)
|
||||
_newFriendLiveData.value = ListResult.success(result, 1)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun getFriendRecommendMore() {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
friendRecommendModeLiveData.value = ListResult.failed(1)
|
||||
},
|
||||
block = {
|
||||
val result = HomeModel.getFriendRecommendMore()
|
||||
friendRecommendModeLiveData.value = ListResult.success(result, 1)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun getHomeGameTab() {
|
||||
safeLaunch {
|
||||
if (gameTabLiveData.value == null) {
|
||||
HomeModel.getHomeGameTabListByLocal()?.let {
|
||||
gameTabLiveData.value = it
|
||||
}
|
||||
}
|
||||
gameTabLiveData.value = HomeModel.getHomeGameTabList()
|
||||
}
|
||||
}
|
||||
}
|
@@ -2,136 +2,42 @@ package com.nnbc123.app.home
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.nnbc123.core.auth.AuthModel
|
||||
import com.nnbc123.core.bean.response.ListResult
|
||||
import com.nnbc123.core.community.CommunityConstant
|
||||
import com.nnbc123.core.home.bean.*
|
||||
import com.nnbc123.core.home.model.HomeModel
|
||||
import com.nnbc123.core.room.bean.AnchorInfo
|
||||
import com.nnbc123.core.room.bean.HomeLiveTopInfo
|
||||
import com.nnbc123.core.room.bean.SingleRoomSortInfo
|
||||
import com.nnbc123.core.statistic.StatisticManager
|
||||
import com.nnbc123.core.statistic.protocol.StatisticsProtocol
|
||||
import com.nnbc123.core.utils.toast
|
||||
import com.nnbc123.app.base.BaseViewModel
|
||||
import com.nnbc123.core.user.bean.UserInfo
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.async
|
||||
|
||||
class HomeViewModel : BaseViewModel() {
|
||||
|
||||
private val _bannerLiveData = MutableLiveData<List<BannerInfo>>()
|
||||
val bannerLiveData: LiveData<List<BannerInfo>> = _bannerLiveData
|
||||
|
||||
private val _partyBannerLiveData = MutableLiveData<List<BannerInfo>?>()
|
||||
val partyBannerLiveData: LiveData<List<BannerInfo>?> = _partyBannerLiveData
|
||||
|
||||
private val _hotRoomLiveData = MutableLiveData<ListResult<HomeRoomInfo>>()
|
||||
val hotRoomLiveData: LiveData<ListResult<HomeRoomInfo>> = _hotRoomLiveData
|
||||
|
||||
private val _gameRoomLiveData = MutableLiveData<ListResult<HomeRoomInfo>>()
|
||||
val gameRoomLiveData: LiveData<ListResult<HomeRoomInfo>> = _gameRoomLiveData
|
||||
|
||||
private val _pickRoomLiveData = MutableLiveData<HomeRoomInfo?>()
|
||||
val pickRoomLiveData: LiveData<HomeRoomInfo?> = _pickRoomLiveData
|
||||
|
||||
private val _openGameRoomLiveData = MutableLiveData<Long?>()
|
||||
val openGameRoomLiveData: LiveData<Long?> = _openGameRoomLiveData
|
||||
|
||||
private val _concernsLiveData = MutableLiveData<List<HomeRoomInfo>>()
|
||||
val concernsLiveData: LiveData<List<HomeRoomInfo>> = _concernsLiveData
|
||||
|
||||
private val _collectLiveData = MutableLiveData<ListResult<HomeRoomInfo>>()
|
||||
val collectLiveData: LiveData<ListResult<HomeRoomInfo>> = _collectLiveData
|
||||
|
||||
private val _tagLiveData = MutableLiveData<MutableList<HomeTagInfo>>()
|
||||
val tagLiveData: LiveData<MutableList<HomeTagInfo>> = _tagLiveData
|
||||
|
||||
private val _emptyLiveData = MutableLiveData<Boolean>()
|
||||
val emptyLiveData: LiveData<Boolean> = _emptyLiveData
|
||||
|
||||
private val _resourceLiveData = MutableLiveData<MutableList<ResourceInfo>>()
|
||||
val resourceLiveData: LiveData<MutableList<ResourceInfo>> = _resourceLiveData
|
||||
|
||||
private val _resourceJumpLiveData = MutableLiveData<HomeRoomInfo?>()
|
||||
val resourceJumpLiveData: LiveData<HomeRoomInfo?> = _resourceJumpLiveData
|
||||
|
||||
private val _homeChatPickLiveData = MutableLiveData<String?>()
|
||||
val homeChatPickLiveData: LiveData<String?> = _homeChatPickLiveData
|
||||
|
||||
private val _singleAnchorHomeLiveData = MutableLiveData<ListResult<HomeRoomInfo>>()
|
||||
val singleAnchorHomeLiveData: LiveData<ListResult<HomeRoomInfo>> = _singleAnchorHomeLiveData
|
||||
|
||||
|
||||
private val _singleRoomSortInfoLiveData = MutableLiveData<ListResult<SingleRoomSortInfo>>()
|
||||
val singleRoomSortInfoLiveData: LiveData<ListResult<SingleRoomSortInfo>> =
|
||||
_singleRoomSortInfoLiveData
|
||||
|
||||
private val _homeLiveTopInfoLiveData = MutableLiveData<HomeLiveTopInfo?>()
|
||||
val homeLiveTopInfoLiveData: LiveData<HomeLiveTopInfo?> = _homeLiveTopInfoLiveData
|
||||
|
||||
private val _anchorInfoLiveData = MutableLiveData<AnchorInfo?>()
|
||||
val anchorInfoLiveData: LiveData<AnchorInfo?> = _anchorInfoLiveData
|
||||
|
||||
private val _partyRecommendRoomLiveData = MutableLiveData<ListResult<HomeRoomInfo>>()
|
||||
val partyRecommendRoomLiveData: LiveData<ListResult<HomeRoomInfo>> =
|
||||
_partyRecommendRoomLiveData
|
||||
|
||||
private val _partyRecommendRoomMoreLiveData = MutableLiveData<ListResult<HomeRoomInfo>>()
|
||||
val partyRecommendRoomMoreLiveData: LiveData<ListResult<HomeRoomInfo>> =
|
||||
_partyRecommendRoomMoreLiveData
|
||||
|
||||
private val _giftServiceLiveData = MutableLiveData<ListResult<GiftServiceMsgVo>>()
|
||||
val giftServiceLiveData: LiveData<ListResult<GiftServiceMsgVo>> = _giftServiceLiveData
|
||||
|
||||
private val _newFriendLiveData = MutableLiveData<ListResult<UserInfo>>()
|
||||
val newFriendLiveData: LiveData<ListResult<UserInfo>> = _newFriendLiveData
|
||||
|
||||
fun getBannerInfo() {
|
||||
safeLaunch {
|
||||
_bannerLiveData.value = HomeModel.getHomeBanner("9")
|
||||
}
|
||||
}
|
||||
|
||||
fun getTagInfo() {
|
||||
safeLaunch {
|
||||
_tagLiveData.value = HomeModel.getHomeTag()
|
||||
}
|
||||
}
|
||||
|
||||
fun getHomeResource() {
|
||||
safeLaunch(
|
||||
block = {
|
||||
if (_resourceLiveData.value == null) {
|
||||
HomeModel.getHomeResourceByLocal()?.let {
|
||||
_resourceLiveData.value = it
|
||||
}
|
||||
}
|
||||
_resourceLiveData.value = HomeModel.getHomeResource()
|
||||
},
|
||||
onError = {
|
||||
}
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
fun getResourceJumpInfo(id: Int) {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
_resourceJumpLiveData.value = null
|
||||
it.message.toast()
|
||||
},
|
||||
block = {
|
||||
_resourceJumpLiveData.value = HomeModel.getResourceJumpInfo(id)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun getHomeChatPick() {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
_homeChatPickLiveData.value = null
|
||||
it.message.toast()
|
||||
},
|
||||
block = {
|
||||
_homeChatPickLiveData.value = HomeModel.getHomeChatPick()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun getHotRoom(pageNum: Int, pageSize: Int) {
|
||||
@@ -146,145 +52,6 @@ class HomeViewModel : BaseViewModel() {
|
||||
)
|
||||
}
|
||||
|
||||
fun getPartyBanner() {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
_partyBannerLiveData.value = null
|
||||
},
|
||||
block = {
|
||||
val result = HomeModel.getHotRoom()
|
||||
var bannerInfoList: List<BannerInfo>?
|
||||
bannerInfoList = result?.find { it.isBanner }?.bannerVoList
|
||||
if (bannerInfoList == null) {
|
||||
bannerInfoList = HomeModel.getPlayRoom()?.find { it.isBanner }?.bannerVoList
|
||||
}
|
||||
_partyBannerLiveData.value = bannerInfoList
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
fun getGameRoom(pageNum: Int, pageSize: Int) {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
_gameRoomLiveData.value = ListResult.failed(pageNum)
|
||||
},
|
||||
block = {
|
||||
val result = HomeModel.getGameRoom(pageNum, pageSize)
|
||||
_gameRoomLiveData.value = ListResult.success(result, pageNum)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun fastPickGameRoom(mgId: Long? = null) {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
it.message.toast()
|
||||
StatisticManager.Instance()
|
||||
.onEvent(
|
||||
StatisticsProtocol.EVENT_USERCENTER_QUICK_ENTRYSUCCESS_CLICK,
|
||||
"个人中心快捷进房点击未匹配成功"
|
||||
)
|
||||
},
|
||||
block = {
|
||||
val homeRoomInfo = HomeModel.fastPickGameRoom(mgId)
|
||||
if (homeRoomInfo?.isPick == true) {
|
||||
_pickRoomLiveData.value = homeRoomInfo
|
||||
} else if (homeRoomInfo?.isNeedOpenSelfRoom == true) {
|
||||
_openGameRoomLiveData.value = mgId
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
fun getCollectRoom(pageNum: Int, pageSize: Int) {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
_collectLiveData.value = ListResult.failed(pageNum)
|
||||
_emptyLiveData.value = true
|
||||
},
|
||||
block = {
|
||||
if (pageNum == 1) {
|
||||
val concernsRooms = async(Dispatchers.IO) {
|
||||
try {
|
||||
HomeModel.getConcernsRoom()
|
||||
} catch (e: Throwable) {
|
||||
null
|
||||
}
|
||||
}
|
||||
val collectRooms = async(Dispatchers.IO) {
|
||||
try {
|
||||
HomeModel.getCollectRoom(pageNum, pageSize)
|
||||
} catch (e: Throwable) {
|
||||
null
|
||||
}
|
||||
}
|
||||
_concernsLiveData.value = concernsRooms.await()
|
||||
val collectList = collectRooms.await()
|
||||
if (collectList == null) {
|
||||
_collectLiveData.value = ListResult.failed(pageNum)
|
||||
} else {
|
||||
_collectLiveData.value =
|
||||
ListResult.success(collectList.fansRoomList, pageNum)
|
||||
}
|
||||
_emptyLiveData.value = _concernsLiveData.value.isNullOrEmpty() &&
|
||||
_collectLiveData.value?.data.isNullOrEmpty()
|
||||
} else {
|
||||
val result = HomeModel.getCollectRoom(pageNum, pageSize)
|
||||
_collectLiveData.value = ListResult.success(result?.fansRoomList, pageNum)
|
||||
}
|
||||
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun requestSingleRoomSortList() {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
//保证最少有一个推荐tab,防止出现空白页
|
||||
_singleRoomSortInfoLiveData.value =
|
||||
ListResult.success(listOf(SingleRoomSortInfo(null, "推荐")), 1)
|
||||
},
|
||||
block = {
|
||||
val result = HomeModel.requestSingleRoomSortList()
|
||||
val fullResult = ArrayList<SingleRoomSortInfo>()
|
||||
fullResult.add(SingleRoomSortInfo(null, "推荐"))
|
||||
result?.let { fullResult.addAll(it) }
|
||||
_singleRoomSortInfoLiveData.value = ListResult.success(fullResult, 1)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun getHomeSingleAnchorList() {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
_singleAnchorHomeLiveData.value = ListResult.failed(1)
|
||||
},
|
||||
block = {
|
||||
val result = HomeModel.getHomeSingleAnchorList()
|
||||
_singleAnchorHomeLiveData.value = ListResult.success(
|
||||
if ((result?.size ?: 0) > 4) {
|
||||
result?.subList(0, 4)
|
||||
} else {
|
||||
result
|
||||
}, 1
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun requestHomeLiveTopInfo() {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
_homeLiveTopInfoLiveData.value = null
|
||||
},
|
||||
block = {
|
||||
_homeLiveTopInfoLiveData.value = HomeModel.requestHomeLiveTopInfo()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun requestAnchorInfo() {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
@@ -296,54 +63,4 @@ class HomeViewModel : BaseViewModel() {
|
||||
)
|
||||
}
|
||||
|
||||
fun getPartyRecommendRoomList() {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
_partyRecommendRoomLiveData.value = ListResult.failed(1)
|
||||
},
|
||||
block = {
|
||||
val result = HomeModel.getPartyRecommendRoomList(
|
||||
AuthModel.get().currentUid.toString(),
|
||||
CommunityConstant.VERSION_VALID_TYPE
|
||||
)
|
||||
_partyRecommendRoomLiveData.value = ListResult.success(result, 1)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun getPartyRecommendRoomMoreList() {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
_partyRecommendRoomMoreLiveData.value = ListResult.failed(1)
|
||||
},
|
||||
block = {
|
||||
val result = HomeModel.getPartyRecommendRoomMoreList()
|
||||
_partyRecommendRoomMoreLiveData.value = ListResult.success(result, 1)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun getServiceGiftRecord() {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
_giftServiceLiveData.value = ListResult.failed(1)
|
||||
},
|
||||
block = {
|
||||
val result = HomeModel.getServiceGiftRecord()
|
||||
_giftServiceLiveData.value = ListResult.success(result, 1)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun getNewFriendList(gender: Int? = null) {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
_newFriendLiveData.value = ListResult.failed(1)
|
||||
},
|
||||
block = {
|
||||
val result = HomeModel.getNewFriendList(gender)
|
||||
_newFriendLiveData.value = ListResult.success(result, 1)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
56
app/src/main/java/com/nnbc123/app/home/PartyViewModel.kt
Normal file
56
app/src/main/java/com/nnbc123/app/home/PartyViewModel.kt
Normal file
@@ -0,0 +1,56 @@
|
||||
package com.nnbc123.app.home
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.nnbc123.app.base.BaseViewModel
|
||||
import com.nnbc123.core.bean.response.BeanResult
|
||||
import com.nnbc123.core.bean.response.ListResult
|
||||
import com.nnbc123.core.home.bean.BannerInfo
|
||||
import com.nnbc123.core.home.bean.GiftServiceMsgVo
|
||||
import com.nnbc123.core.home.bean.HomeRoomInfo
|
||||
import com.nnbc123.core.home.model.HomeModel
|
||||
import com.nnbc123.core.utils.toast
|
||||
|
||||
/**
|
||||
* Created by Max on 2023/12/27 10:18
|
||||
* Desc:
|
||||
**/
|
||||
class PartyViewModel : BaseViewModel() {
|
||||
private val _giftServiceLiveData = MutableLiveData<ListResult<GiftServiceMsgVo>>()
|
||||
val giftServiceLiveData: LiveData<ListResult<GiftServiceMsgVo>> = _giftServiceLiveData
|
||||
|
||||
private val _bannerLiveData = MutableLiveData<List<BannerInfo>>()
|
||||
val bannerLiveData: LiveData<List<BannerInfo>> = _bannerLiveData
|
||||
|
||||
private val _resourceJumpLiveData = MutableLiveData<BeanResult<HomeRoomInfo>?>()
|
||||
val resourceJumpLiveData: LiveData<BeanResult<HomeRoomInfo>?> = _resourceJumpLiveData
|
||||
|
||||
fun getResourceJumpInfo(id: Long) {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
_resourceJumpLiveData.value = BeanResult.failed(it)
|
||||
},
|
||||
block = {
|
||||
_resourceJumpLiveData.value = BeanResult.success(HomeModel.getResourceJumpInfo(id, 0))
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun getBannerInfo() {
|
||||
safeLaunch {
|
||||
_bannerLiveData.value = HomeModel.getHomeBanner("1")
|
||||
}
|
||||
}
|
||||
|
||||
fun getServiceGiftRecord() {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
_giftServiceLiveData.value = ListResult.failed(1)
|
||||
},
|
||||
block = {
|
||||
val result = HomeModel.getServiceGiftRecord()
|
||||
_giftServiceLiveData.value = ListResult.success(result, 1)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
@@ -1,27 +0,0 @@
|
||||
package com.nnbc123.app.home
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.nnbc123.app.base.BaseViewModel
|
||||
import com.nnbc123.core.bean.response.ListResult
|
||||
import com.nnbc123.core.home.bean.HomeRoomInfo
|
||||
import com.nnbc123.core.home.model.HomeModel
|
||||
|
||||
class RoomCommonViewModel : BaseViewModel() {
|
||||
|
||||
private val _commonRoomLiveData = MutableLiveData<ListResult<HomeRoomInfo>>()
|
||||
val commonRoomLiveData: LiveData<ListResult<HomeRoomInfo>> = _commonRoomLiveData
|
||||
|
||||
fun getCommonRoom(tabId: Int, pageNum: Int, pageSize: Int) {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
_commonRoomLiveData.value = ListResult.failed(pageNum)
|
||||
},
|
||||
block = {
|
||||
val result = HomeModel.getCommonRoom(tabId, pageNum, pageSize)
|
||||
_commonRoomLiveData.value = ListResult.success(result, pageNum)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
}
|
@@ -1,27 +0,0 @@
|
||||
package com.nnbc123.app.home
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.nnbc123.app.base.BaseViewModel
|
||||
import com.nnbc123.core.bean.response.ListResult
|
||||
import com.nnbc123.core.home.bean.HomeRoomInfo
|
||||
import com.nnbc123.core.home.model.HomeModel
|
||||
|
||||
class RoomSingleViewModel : BaseViewModel() {
|
||||
|
||||
private val _singleAnchorMoreLiveData = MutableLiveData<ListResult<HomeRoomInfo>>()
|
||||
val singleAnchorMoreLiveData: LiveData<ListResult<HomeRoomInfo>> = _singleAnchorMoreLiveData
|
||||
|
||||
fun getMoreSingleAnchorList(id: Long?) {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
_singleAnchorMoreLiveData.value = ListResult.failed(1)
|
||||
},
|
||||
block = {
|
||||
val result = HomeModel.getMoreSingleAnchorList(id)
|
||||
_singleAnchorMoreLiveData.value = ListResult.success(result, 1)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
}
|
@@ -1,38 +0,0 @@
|
||||
package com.nnbc123.app.home.activity
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.nnbc123.app.R
|
||||
import com.nnbc123.app.base.BaseActivity
|
||||
import com.nnbc123.app.home.fragment.PartyFragment
|
||||
import com.netease.nim.uikit.StatusBarUtil
|
||||
|
||||
class MoreRoomActivity : BaseActivity() {
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context) {
|
||||
val starter = Intent(context, MoreRoomActivity::class.java)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_more_room)
|
||||
initTitleBar("更多房间")
|
||||
supportFragmentManager
|
||||
.beginTransaction()
|
||||
.replace(R.id.fcv, PartyFragment.newInstance())
|
||||
.commitAllowingStateLoss()
|
||||
}
|
||||
|
||||
override fun needSteepStateBar() = true
|
||||
|
||||
override fun setStatusBar() {
|
||||
super.setStatusBar()
|
||||
StatusBarUtil.transparencyBar(this)
|
||||
StatusBarUtil.StatusBarLightMode(this)
|
||||
}
|
||||
}
|
@@ -1,58 +0,0 @@
|
||||
package com.nnbc123.app.home.adapter;
|
||||
|
||||
import android.graphics.drawable.AnimationDrawable;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.nnbc123.app.R;
|
||||
import com.nnbc123.app.avroom.activity.AVRoomActivity;
|
||||
import com.nnbc123.app.common.widget.CircleImageView;
|
||||
import com.nnbc123.app.ui.user.UserInfoActivity;
|
||||
import com.nnbc123.app.ui.utils.ImageLoadUtilsV2;
|
||||
import com.nnbc123.core.home.bean.HomeRoomInfo;
|
||||
import com.nnbc123.core.statistic.StatisticManager;
|
||||
import com.nnbc123.core.statistic.protocol.StatisticsProtocol;
|
||||
import com.nnbc123.core.utils.StringExtensionKt;
|
||||
|
||||
public class HomeConcernsAdapter extends BaseQuickAdapter<HomeRoomInfo, BaseViewHolder> {
|
||||
|
||||
public HomeConcernsAdapter() {
|
||||
super(R.layout.item_home_concerns, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(@NonNull BaseViewHolder helper, HomeRoomInfo item) {
|
||||
if (item == null) {
|
||||
return;
|
||||
}
|
||||
CircleImageView circleImageView = helper.getView(R.id.civ_room_avatar);
|
||||
ImageLoadUtilsV2.loadImage(circleImageView, item.getAvatar());
|
||||
helper.setText(R.id.tv_room_name, StringExtensionKt.subAndReplaceDot(item.getNick(), 4));
|
||||
|
||||
if (item.getRoomUid() > 0) {
|
||||
helper.setVisible(R.id.view_avatar_bg, true);
|
||||
helper.setVisible(R.id.view_living, true);
|
||||
helper.setVisible(R.id.tv_live, true);
|
||||
if (helper.getView(R.id.view_living).getBackground() instanceof AnimationDrawable) {
|
||||
((AnimationDrawable) helper.getView(R.id.view_living).getBackground()).start();
|
||||
}
|
||||
helper.itemView.setOnClickListener(v -> {
|
||||
AVRoomActivity.startForFromType(mContext,
|
||||
item.getRoomUid(),
|
||||
AVRoomActivity.FROM_TYPE_USER,
|
||||
item.getNick(),
|
||||
String.valueOf(item.getUid()));
|
||||
StatisticManager.Instance()
|
||||
.onEvent(StatisticsProtocol.EVENT_GZR_ROOM_SUCCESS, "喜欢tab点击关注的人进入房间");
|
||||
});
|
||||
} else {
|
||||
helper.setVisible(R.id.view_avatar_bg, false);
|
||||
helper.setVisible(R.id.tv_live, false);
|
||||
helper.setVisible(R.id.view_living, false);
|
||||
helper.itemView.setOnClickListener(v -> UserInfoActivity.Companion.start(mContext, item.getUid()));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,64 @@
|
||||
package com.nnbc123.app.home.adapter
|
||||
|
||||
import android.widget.ImageView
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.nnbc123.app.R
|
||||
import com.nnbc123.app.ui.utils.load
|
||||
import com.nnbc123.core.home.bean.HomeGameTab
|
||||
|
||||
/**
|
||||
* Created by Max on 2023/12/25 10:30
|
||||
* Desc:
|
||||
**/
|
||||
class HomeFriendsGameTabAdapter :
|
||||
BaseQuickAdapter<HomeGameTab, BaseViewHolder>(R.layout.home_friends_item_game) {
|
||||
|
||||
var selectGameId: Long? = null
|
||||
private var selectPosition: Int? = null
|
||||
|
||||
override fun convertPayloads(
|
||||
helper: BaseViewHolder,
|
||||
item: HomeGameTab,
|
||||
payloads: MutableList<Any>
|
||||
) {
|
||||
super.convertPayloads(helper, item, payloads)
|
||||
convertState(helper, item)
|
||||
}
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: HomeGameTab) {
|
||||
convertState(helper, item)
|
||||
}
|
||||
|
||||
private fun convertState(helper: BaseViewHolder, item: HomeGameTab) {
|
||||
if (helper.absoluteAdapterPosition == selectPosition) {
|
||||
helper.getView<ImageView>(R.id.iv_cover).load(item.onClick, defaultRes = null)
|
||||
} else {
|
||||
helper.getView<ImageView>(R.id.iv_cover).load(item.onUnclick, defaultRes = null)
|
||||
}
|
||||
}
|
||||
|
||||
fun selectItem(position: Int?) {
|
||||
val item = getItem(position ?: -1)
|
||||
if (item == null || position == null) {
|
||||
val oldPosition = selectPosition
|
||||
this.selectGameId = null
|
||||
this.selectPosition = null
|
||||
if (oldPosition != null) {
|
||||
notifyItemChanged(oldPosition, true)
|
||||
}
|
||||
} else if (position == selectPosition) {
|
||||
this.selectGameId = null
|
||||
this.selectPosition = null
|
||||
notifyItemChanged(position, true)
|
||||
} else {
|
||||
val oldPosition = this.selectPosition
|
||||
this.selectGameId = item.gameId
|
||||
this.selectPosition = position
|
||||
if (oldPosition != null) {
|
||||
notifyItemChanged(oldPosition, true)
|
||||
}
|
||||
notifyItemChanged(position, true)
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,251 @@
|
||||
package com.nnbc123.app.home.adapter
|
||||
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.core.view.isVisible
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.chuhai.utils.ktx.singleClick
|
||||
import com.nnbc123.app.R
|
||||
import com.nnbc123.app.audio.helper.AudioPlayerHelper
|
||||
import com.nnbc123.app.audio.helper.OnPlayListener
|
||||
import com.nnbc123.app.avroom.activity.AVRoomActivity
|
||||
import com.nnbc123.app.ui.utils.load
|
||||
import com.nnbc123.app.ui.utils.loadFromAssets
|
||||
import com.nnbc123.app.vip.VipHelper
|
||||
import com.nnbc123.core.Constants
|
||||
import com.nnbc123.core.manager.AudioEngineManager
|
||||
import com.nnbc123.core.manager.AvRoomDataManager
|
||||
import com.nnbc123.core.user.bean.UserInfo
|
||||
import com.nnbc123.core.utils.StarUtils
|
||||
import com.nnbc123.library.utils.SingleToastUtil
|
||||
import com.opensource.svgaplayer.SVGADrawable
|
||||
import com.opensource.svgaplayer.SVGAImageView
|
||||
import com.opensource.svgaplayer.SVGAParser
|
||||
import com.opensource.svgaplayer.SVGAVideoEntity
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import java.util.Date
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
/**
|
||||
* Created by Max on 2023/12/18 18:33
|
||||
* Desc:
|
||||
**/
|
||||
class HomeFriendsUserAdapter :
|
||||
BaseQuickAdapter<UserInfo, BaseViewHolder>(R.layout.home_friends_list_item) {
|
||||
|
||||
private var disposable: Disposable? = null
|
||||
|
||||
private var isMute = false
|
||||
private var isRemoteMute = false
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: UserInfo) {
|
||||
// 昵称
|
||||
val nameView = helper.getView<TextView>(R.id.tv_name)
|
||||
nameView.text = item.nick
|
||||
VipHelper.loadVipNickColor(nameView, item.userVipInfoVO, "#2B2D33")
|
||||
// 头像
|
||||
helper.getView<ImageView>(R.id.iv_avatar).load(item.avatar)
|
||||
// 星座
|
||||
var star: String? = null
|
||||
if (item.birth > 0) {
|
||||
star = StarUtils.getConstellation(Date(item.birth))
|
||||
}
|
||||
helper.setGone(R.id.tv_constellation, !star.isNullOrEmpty())
|
||||
.setText(R.id.tv_constellation, star)
|
||||
// 状态
|
||||
if (item.isInOnline) {
|
||||
val svgaLiving = helper.getView<SVGAImageView>(R.id.svga_state_live)
|
||||
if (item.inRoomUid > 0L) {
|
||||
svgaLiving.loadFromAssets("svga/home_living_white.svga")
|
||||
svgaLiving.startAnimation()
|
||||
svgaLiving.isVisible = true
|
||||
helper.getView<View>(R.id.iv_state_leisure).isVisible = false
|
||||
helper.setText(R.id.tv_state, "直播中")
|
||||
} else {
|
||||
svgaLiving.stopAnimation()
|
||||
svgaLiving.isVisible = false
|
||||
helper.getView<View>(R.id.iv_state_leisure).isVisible = true
|
||||
helper.setText(R.id.tv_state, "空闲中")
|
||||
}
|
||||
helper.setGone(R.id.layout_state, true)
|
||||
} else {
|
||||
helper.setGone(R.id.layout_state, false)
|
||||
}
|
||||
// 房间
|
||||
val roomInfoView = helper.getView<View>(R.id.layout_room_info)
|
||||
if (item.roomTitle.isNullOrEmpty()) {
|
||||
roomInfoView.isVisible = false
|
||||
} else {
|
||||
roomInfoView.isVisible = true
|
||||
roomInfoView.isSelected = true
|
||||
helper.setText(R.id.tv_room_title, item.roomTitle)
|
||||
roomInfoView.singleClick {
|
||||
if (!item.isLock && item.inRoomUid > 0) {
|
||||
AVRoomActivity.start(it.context, item.inRoomUid)
|
||||
}
|
||||
}
|
||||
}
|
||||
// 声音
|
||||
val audioUrl = item.voiceCard?.getAudioUrl()
|
||||
val svagAudio = helper.getView<SVGAImageView>(R.id.svga_audio)
|
||||
if (audioUrl.isNullOrEmpty()) {
|
||||
svagAudio.stopAnimation()
|
||||
helper.setGone(R.id.layout_audio, false)
|
||||
} else {
|
||||
helper.getView<TextView>(R.id.tv_audio_duration).text =
|
||||
"${item.voiceCard?.getAudioDuration() ?: 0}”"
|
||||
helper.getView<View>(R.id.layout_audio)
|
||||
.setOnClickListener { toggleAudio(helper, item) }
|
||||
svagAudio.setImageResource(R.drawable.home_ic_audio_playing)
|
||||
helper.setGone(R.id.layout_audio, true)
|
||||
}
|
||||
|
||||
// 游戏
|
||||
val groupGame = helper.getView<View>(R.id.group_game)
|
||||
item.userGamePartnerVo?.let {
|
||||
val name =
|
||||
if (!it.firstGameName.isNullOrEmpty() && !it.secondGameName.isNullOrEmpty()) {
|
||||
"${it.firstGameName}|${it.secondGameName}"
|
||||
} else if (!it.firstGameName.isNullOrEmpty()) {
|
||||
it.firstGameName
|
||||
} else if (!it.secondGameName.isNullOrEmpty()) {
|
||||
it.secondGameName
|
||||
} else {
|
||||
null
|
||||
}
|
||||
helper.setText(R.id.tv_game_name, name)
|
||||
helper.getView<ImageView>(R.id.iv_game_icon).load(it.firstLogo)
|
||||
groupGame.isVisible = true
|
||||
} ?: kotlin.run {
|
||||
groupGame.isVisible = false
|
||||
}
|
||||
}
|
||||
|
||||
private fun toggleAudio(holder: BaseViewHolder, item: UserInfo) {
|
||||
if (item.isVoicePlaying) {
|
||||
stopAudio()
|
||||
} else {
|
||||
playAudio(holder, item)
|
||||
}
|
||||
}
|
||||
|
||||
private fun stopAudio() {
|
||||
AudioPlayerHelper.get().endPlay()
|
||||
}
|
||||
|
||||
private fun resetAudioUI(holder: BaseViewHolder, item: UserInfo) {
|
||||
item.isVoicePlaying = false
|
||||
|
||||
disposable?.dispose()
|
||||
holder.setImageResource(R.id.iv_audio_btn, R.drawable.home_ic_audio_play)
|
||||
holder.setText(
|
||||
R.id.tv_audio_duration,
|
||||
"${item.voiceCard?.getAudioDuration() ?: 0}”"
|
||||
)
|
||||
|
||||
val svgaImageView = holder.getView<SVGAImageView>(R.id.svga_audio)
|
||||
svgaImageView.stopAnimation()
|
||||
svgaImageView.setImageResource(R.drawable.home_ic_audio_playing)
|
||||
|
||||
AvRoomDataManager.get().mCurrentRoomInfo?.run {
|
||||
AudioEngineManager.get().isRemoteMute = isRemoteMute //非靜音
|
||||
AudioEngineManager.get().isMute = isMute //能説話
|
||||
AudioEngineManager.get().setRole(
|
||||
if (isRemoteMute) Constants.CLIENT_ROLE_AUDIENCE else Constants.CLIENT_ROLE_BROADCASTER
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun playAudio(holder: BaseViewHolder, item: UserInfo) {
|
||||
AudioPlayerHelper.get().endPlay()
|
||||
|
||||
item.isVoicePlaying = true
|
||||
|
||||
|
||||
holder.setImageResource(R.id.iv_audio_btn, R.drawable.home_ic_audio_pause)
|
||||
val svgaImageView = holder.getView<SVGAImageView>(R.id.svga_audio)
|
||||
SVGAParser.shareParser()
|
||||
.decodeFromAssets("svga/home_voice_playing.svga", object : SVGAParser.ParseCompletion {
|
||||
override fun onComplete(videoItem: SVGAVideoEntity) {
|
||||
if (item.isVoicePlaying) {
|
||||
val drawable = SVGADrawable(videoItem)
|
||||
svgaImageView.setImageDrawable(drawable)
|
||||
svgaImageView.startAnimation()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onError() {
|
||||
}
|
||||
})
|
||||
|
||||
val duration = item.voiceCard?.getAudioDuration() ?: 0
|
||||
disposable = Observable.interval(1L, TimeUnit.SECONDS)
|
||||
.subscribeOn(Schedulers.computation())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.map { it + 1 }
|
||||
.takeUntil { it == duration }
|
||||
.subscribe {
|
||||
holder.setText(
|
||||
R.id.tv_audio_duration,
|
||||
"${(duration - it)}”"
|
||||
)
|
||||
}
|
||||
|
||||
AvRoomDataManager.get().mCurrentRoomInfo?.run {
|
||||
isRemoteMute = AudioEngineManager.get().isRemoteMute
|
||||
isMute = AudioEngineManager.get().isMute
|
||||
AudioEngineManager.get().isRemoteMute = true //設置靜音
|
||||
AudioEngineManager.get().isMute = true //不能説話
|
||||
AudioEngineManager.get().setRole(Constants.CLIENT_ROLE_AUDIENCE)
|
||||
}
|
||||
|
||||
AudioPlayerHelper.get()
|
||||
.playInThread(item.voiceCard?.getAudioUrl(), object : OnPlayListener {
|
||||
override fun onError(error: String) {
|
||||
SingleToastUtil.showToast("播放出错,请重试")
|
||||
resetAudioUI(holder, item)
|
||||
}
|
||||
|
||||
override fun onPrepared() {}
|
||||
override fun onPlaying(currDuration: Long) {}
|
||||
override fun onCompletion() {
|
||||
resetAudioUI(holder, item)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
override fun onViewAttachedToWindow(holder: BaseViewHolder) {
|
||||
super.onViewAttachedToWindow(holder)
|
||||
if (holder.itemViewType == 0) {
|
||||
val svgaLiving = holder.getView<SVGAImageView>(R.id.svga_state_live)
|
||||
if (svgaLiving.isVisible) {
|
||||
svgaLiving?.loadFromAssets("svga/home_living_white.svga")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onViewDetachedFromWindow(holder: BaseViewHolder) {
|
||||
super.onViewDetachedFromWindow(holder)
|
||||
if (holder.itemViewType == 0) {
|
||||
val position = holder.absoluteAdapterPosition
|
||||
if (position < 0 || position >= data.size) {
|
||||
return
|
||||
}
|
||||
val item = data[position]
|
||||
if (item.isVoicePlaying) {
|
||||
stopAudio()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun setNewData(data: MutableList<UserInfo>?) {
|
||||
stopAudio()
|
||||
super.setNewData(data)
|
||||
}
|
||||
}
|
@@ -1,41 +0,0 @@
|
||||
package com.nnbc123.app.home.adapter
|
||||
|
||||
import android.widget.ImageView
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.nnbc123.app.R
|
||||
import com.nnbc123.app.avroom.activity.AVRoomActivity
|
||||
import com.nnbc123.app.ui.utils.load
|
||||
import com.nnbc123.core.room.bean.HomeLiveTopInfo
|
||||
import com.nnbc123.core.statistic.StatisticManager
|
||||
import com.nnbc123.core.statistic.protocol.StatisticsProtocol
|
||||
|
||||
|
||||
class HomeLiveTopAdapter :
|
||||
BaseQuickAdapter<HomeLiveTopInfo.SingleRoom, BaseViewHolder>(R.layout.item_home_live_top) {
|
||||
|
||||
private var onceLookStatus: Boolean = false
|
||||
|
||||
fun setOnceLookStatus(onceLookStatus: Boolean) {
|
||||
this.onceLookStatus = onceLookStatus
|
||||
}
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: HomeLiveTopInfo.SingleRoom) {
|
||||
helper.apply {
|
||||
getView<ImageView>(R.id.iv_room_image).load(item.avatar)
|
||||
setText(R.id.tv_room_title, item.title)
|
||||
setGone(R.id.iv_room_tag, item.isRecommend && onceLookStatus)
|
||||
}
|
||||
|
||||
helper.itemView.setOnClickListener {
|
||||
AVRoomActivity.start(mContext, item.uid)
|
||||
StatisticManager.Instance().onEvent(
|
||||
StatisticsProtocol.EVENT_RECENT_CARD_CLICK,
|
||||
"最近在看卡片点击",
|
||||
mapOf("room_id" to item.erbanNo)
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,128 @@
|
||||
package com.nnbc123.app.home.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.view.Gravity;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.nnbc123.app.R;
|
||||
import com.nnbc123.app.ui.widget.XRecyclerView.ScaleTransitionPagerTitleView;
|
||||
import com.nnbc123.app.ui.widget.magicindicator.buildins.UIUtil;
|
||||
import com.nnbc123.app.ui.widget.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter;
|
||||
import com.nnbc123.app.ui.widget.magicindicator.buildins.commonnavigator.abs.IPagerIndicator;
|
||||
import com.nnbc123.app.ui.widget.magicindicator.buildins.commonnavigator.abs.IPagerTitleView;
|
||||
import com.nnbc123.app.ui.widget.magicindicator.buildins.commonnavigator.indicators.DrawableIndicator;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class HomeMagicIndicatorAdapter extends CommonNavigatorAdapter {
|
||||
|
||||
private final List<? extends CharSequence> mTitleList;
|
||||
|
||||
private int textSize = 20;
|
||||
private float minScale = 0.7f;
|
||||
protected int mNormalColor = Color.BLACK;
|
||||
protected int mSelectedColor = Color.BLACK;
|
||||
private boolean showIndicator = true;
|
||||
private int resId = R.drawable.home_bg_indicator;
|
||||
|
||||
public HomeMagicIndicatorAdapter(Context context, List<? extends CharSequence> charSequences ) {
|
||||
this.mTitleList = charSequences;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mTitleList == null ? 0 : mTitleList.size();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IPagerTitleView getTitleView(Context context, final int i) {
|
||||
ScaleTransitionPagerTitleView scaleTransitionPagerTitleView = new ScaleTransitionPagerTitleView(context, true);
|
||||
scaleTransitionPagerTitleView.setNormalColor(mNormalColor);
|
||||
scaleTransitionPagerTitleView.setSelectedColor(mSelectedColor);
|
||||
scaleTransitionPagerTitleView.setMinScale(minScale);
|
||||
scaleTransitionPagerTitleView.setTextSize(textSize);
|
||||
scaleTransitionPagerTitleView.setAutoResetPivot(true);
|
||||
int padding = UIUtil.dip2px(context, 6);
|
||||
scaleTransitionPagerTitleView.setPadding(padding, 0, padding, 0);
|
||||
scaleTransitionPagerTitleView.setText(mTitleList.get(i));
|
||||
scaleTransitionPagerTitleView.setOnClickListener(view -> {
|
||||
if (mOnItemSelectListener != null) {
|
||||
mOnItemSelectListener.onItemSelect(i, scaleTransitionPagerTitleView);
|
||||
}
|
||||
|
||||
});
|
||||
return scaleTransitionPagerTitleView;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IPagerIndicator getIndicator(Context context) {
|
||||
if (!showIndicator) return null;
|
||||
DrawableIndicator indicator = new DrawableIndicator(context);
|
||||
indicator.setMode(DrawableIndicator.MODE_MATCH_EDGE);
|
||||
indicator.setIndicatorDrawable(context.getResources().getDrawable(resId));
|
||||
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, UIUtil.dip2px(context, 28));
|
||||
lp.gravity = Gravity.CENTER_VERTICAL;
|
||||
indicator.setLayoutParams(lp);
|
||||
return indicator;
|
||||
}
|
||||
|
||||
public void setResId(int resId) {
|
||||
this.resId = resId;
|
||||
}
|
||||
|
||||
public int getTextSize() {
|
||||
return textSize;
|
||||
}
|
||||
|
||||
public void setTextSize(int textSize) {
|
||||
this.textSize = textSize;
|
||||
}
|
||||
|
||||
public float getMinScale() {
|
||||
return minScale;
|
||||
}
|
||||
|
||||
public void setMinScale(float minScale) {
|
||||
this.minScale = minScale;
|
||||
}
|
||||
|
||||
public int getSelectedColor() {
|
||||
return mSelectedColor;
|
||||
}
|
||||
|
||||
public void setSelectedColor(int selectedColor) {
|
||||
mSelectedColor = selectedColor;
|
||||
}
|
||||
|
||||
public int getNormalColor() {
|
||||
return mNormalColor;
|
||||
}
|
||||
|
||||
public void setNormalColor(int normalColor) {
|
||||
mNormalColor = normalColor;
|
||||
}
|
||||
|
||||
public boolean isShowIndicator() {
|
||||
return showIndicator;
|
||||
}
|
||||
|
||||
public void setShowIndicator(boolean showIndicator) {
|
||||
this.showIndicator = showIndicator;
|
||||
}
|
||||
|
||||
private OnItemSelectListener mOnItemSelectListener;
|
||||
|
||||
public void setOnItemSelectListener(OnItemSelectListener onItemSelectListener) {
|
||||
mOnItemSelectListener = onItemSelectListener;
|
||||
}
|
||||
|
||||
public interface OnItemSelectListener {
|
||||
void onItemSelect(int position, TextView view);
|
||||
}
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
package com.nnbc123.app.home.adapter
|
||||
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import androidx.core.view.isVisible
|
||||
import com.nnbc123.app.R
|
||||
import com.nnbc123.app.ui.utils.load
|
||||
import com.nnbc123.app.ui.utils.loadAvatar
|
||||
import com.nnbc123.core.home.bean.GiftServiceMsgVo
|
||||
import com.nnbc123.core.utils.subAndReplaceDot2
|
||||
import com.zhpan.bannerview.BaseBannerAdapter
|
||||
import com.zhpan.bannerview.BaseViewHolder
|
||||
|
||||
/**
|
||||
* Created by Max on 2023/12/18 19:02
|
||||
* Desc:
|
||||
**/
|
||||
class HomePartyMessageAdapter : BaseBannerAdapter<GiftServiceMsgVo>() {
|
||||
|
||||
var clickListener: ((GiftServiceMsgVo) -> Unit)? = null
|
||||
override fun bindData(
|
||||
holder: BaseViewHolder<GiftServiceMsgVo>,
|
||||
item: GiftServiceMsgVo,
|
||||
position: Int,
|
||||
pageSize: Int
|
||||
) {
|
||||
holder.setText(R.id.tv_nick_send, item.senderNick.subAndReplaceDot2(4))
|
||||
holder.setText(R.id.tv_nick_receiver, item.receiverNick.subAndReplaceDot2(4))
|
||||
holder.setText(R.id.tv_gift_name, item.giftName.subAndReplaceDot2(4))
|
||||
holder.setText(R.id.tv_gift_num, "x${item.giftNum}")
|
||||
holder.findViewById<ImageView>(R.id.iv_avatar_send).loadAvatar(item.senderAvatar)
|
||||
holder.findViewById<ImageView>(R.id.iv_avatar_receiver).loadAvatar(item.receiverAvatar)
|
||||
holder.findViewById<ImageView>(R.id.iv_gift).load(item.giftPicUrl)
|
||||
val arrowView = holder.findViewById<View>(R.id.iv_arrow)
|
||||
arrowView.isVisible = !item.isLock
|
||||
arrowView.setOnClickListener {
|
||||
clickListener?.invoke(item)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getLayoutId(viewType: Int): Int {
|
||||
return R.layout.home_party_item_message
|
||||
}
|
||||
|
||||
fun getItem(position: Int): GiftServiceMsgVo? {
|
||||
return mList.getOrNull(position)
|
||||
}
|
||||
}
|
@@ -1,7 +1,5 @@
|
||||
package com.nnbc123.app.home.adapter
|
||||
|
||||
import android.text.TextUtils
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import androidx.core.view.isGone
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
@@ -10,34 +8,38 @@ import com.nnbc123.app.R
|
||||
import com.nnbc123.app.ui.utils.load
|
||||
import com.nnbc123.core.home.bean.HomeRoomInfo
|
||||
|
||||
class PartyHotAdapter :
|
||||
BaseQuickAdapter<HomeRoomInfo, BaseViewHolder>(R.layout.item_party_hot) {
|
||||
|
||||
/**
|
||||
* Created by Max on 2023/12/18 18:33
|
||||
* Desc:
|
||||
**/
|
||||
class HomePartyRoomAdapter :
|
||||
BaseQuickAdapter<HomeRoomInfo, BaseViewHolder>(R.layout.home_party_room_item) {
|
||||
override fun convert(helper: BaseViewHolder, item: HomeRoomInfo) {
|
||||
helper.apply {
|
||||
getView<ImageView>(R.id.iv_room_image).load(item.avatar)
|
||||
getView<ImageView>(R.id.iv_cover).load(item.avatar)
|
||||
setText(R.id.tv_online_number, "${item.onlineNum}")
|
||||
setText(R.id.tv_room_title, item.title)
|
||||
setText(R.id.tv_name, item.title)
|
||||
setGone(R.id.iv_tag, !item.tagPict.isNullOrEmpty())
|
||||
getView<ImageView>(R.id.iv_tag).load(item.tagPict)
|
||||
setGone(R.id.iv_pk, item.isCrossPking)
|
||||
val borderView = getView<ImageView>(R.id.iv_cover_border)
|
||||
if (item.backgroundPic.isNullOrEmpty()) {
|
||||
borderView.setImageDrawable(null)
|
||||
} else {
|
||||
borderView.load(item.backgroundPic, defaultRes = null)
|
||||
}
|
||||
}
|
||||
helper.setGone(R.id.tv_in_pk, item.isCrossPking)
|
||||
|
||||
helper.setGone(R.id.tv_tag_content, !TextUtils.isEmpty(item.iconContent))
|
||||
.setText(R.id.tv_tag_content, item.iconContent)
|
||||
|
||||
val avatars: Array<ImageView> = arrayOf(
|
||||
helper.getView(R.id.iv_avatar_0),
|
||||
helper.getView(R.id.iv_avatar_1),
|
||||
helper.getView(R.id.iv_avatar_2),
|
||||
helper.getView(R.id.iv_avatar_3),
|
||||
helper.getView(R.id.iv_avatar_4),
|
||||
helper.getView(R.id.iv_avatar_5)
|
||||
helper.getView(R.id.iv_avatar_4)
|
||||
)
|
||||
|
||||
for (i in avatars.indices) {
|
||||
val avatarUrl = item.micUsers?.getOrNull(i)?.avatar
|
||||
avatars[i].isGone = avatarUrl.isNullOrBlank()
|
||||
avatars[i].load(avatarUrl)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,88 +0,0 @@
|
||||
package com.nnbc123.app.home.adapter
|
||||
|
||||
import android.graphics.Color
|
||||
import android.graphics.LinearGradient
|
||||
import android.graphics.Shader
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.core.view.isGone
|
||||
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.makeramen.roundedimageview.RoundedImageView
|
||||
import com.nnbc123.app.R
|
||||
import com.nnbc123.app.home.helper.BannerHelper
|
||||
import com.nnbc123.app.ui.utils.ImageLoadUtilsV2
|
||||
import com.nnbc123.app.ui.utils.load
|
||||
import com.nnbc123.core.home.bean.HomeRoomInfo
|
||||
import com.nnbc123.core.utils.TextUtils
|
||||
import com.nnbc123.core.utils.ifNullOrEmpty
|
||||
|
||||
/**
|
||||
* create by lvzebiao @2019/11/13
|
||||
*/
|
||||
class HomePlayAdapter : BaseMultiItemQuickAdapter<HomeRoomInfo, BaseViewHolder>(null) {
|
||||
|
||||
init {
|
||||
addItemType(HomeRoomInfo.TYPE_ROOM, R.layout.item_home_play)
|
||||
addItemType(HomeRoomInfo.TYPE_BANNER, R.layout.item_room_banner)
|
||||
addItemType(HomeRoomInfo.TYPE_BROADCAST, R.layout.item_home_play_broadcast)
|
||||
}
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: HomeRoomInfo) {
|
||||
if (item.itemType == HomeRoomInfo.TYPE_ROOM ||
|
||||
item.itemType == HomeRoomInfo.TYPE_BROADCAST
|
||||
) {
|
||||
helper.setText(R.id.tv_room_title, item.title)
|
||||
helper.setGone(R.id.iv_room_tag, !TextUtils.isEmptyText(item.tagPict))
|
||||
ImageLoadUtilsV2.loadImage(helper.getView(R.id.iv_room_tag), item.tagPict)
|
||||
helper.setText(R.id.tv_online_number, "${item.onlineNum}")
|
||||
val tvMgName = helper.getView<TextView>(R.id.tv_mg_name)
|
||||
tvMgName.text = item.mgName.ifNullOrEmpty { "扩列交友" }
|
||||
if (item.mgName.isNullOrEmpty()) {
|
||||
setGradient(tvMgName, "#FF8C5FFF", "#FFFF969B")
|
||||
} else {
|
||||
setGradient(tvMgName, "#FF61C4FE", "#FFA979FF")
|
||||
}
|
||||
val avatars: Array<ImageView> = arrayOf(
|
||||
helper.getView(R.id.iv_avatar_0),
|
||||
helper.getView(R.id.iv_avatar_1),
|
||||
helper.getView(R.id.iv_avatar_2),
|
||||
helper.getView(R.id.iv_avatar_3),
|
||||
helper.getView(R.id.iv_avatar_4)
|
||||
)
|
||||
for (i in avatars.indices) {
|
||||
val avatarUrl = item.micUsers?.getOrNull(i)?.avatar
|
||||
avatars[i].isGone = avatarUrl.isNullOrBlank()
|
||||
avatars[i].load(avatarUrl)
|
||||
}
|
||||
val ivRoomImage = helper.getView<RoundedImageView>(R.id.iv_room_image)
|
||||
ImageLoadUtilsV2.loadAvatar(ivRoomImage, item.avatar)
|
||||
ivRoomImage.borderColor =
|
||||
Color.parseColor(if (item.gender == 1) "#CCD7FF" else "#FFD0D0")
|
||||
|
||||
if (item.itemType == HomeRoomInfo.TYPE_BROADCAST) {
|
||||
helper.setText(R.id.tv_broad_msg, item.broadMsg)
|
||||
} else {
|
||||
helper.setBackgroundRes(
|
||||
R.id.view_bg,
|
||||
if (item.gender == 1) R.drawable.bg_home_play_item_man else R.drawable.bg_home_play_item_woman
|
||||
)
|
||||
}
|
||||
} else {
|
||||
BannerHelper.setBanner(helper.getView(R.id.roll_view), item.bannerVoList)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun setGradient(textView: TextView, startColor: String, endColor: String) {
|
||||
val endX = textView.paint.textSize * textView.text.length
|
||||
val linearGradient = LinearGradient(
|
||||
0f, 0f, endX, 0f,
|
||||
Color.parseColor(startColor),
|
||||
Color.parseColor(endColor),
|
||||
Shader.TileMode.CLAMP
|
||||
)
|
||||
textView.paint.shader = linearGradient
|
||||
textView.invalidate()
|
||||
}
|
||||
}
|
@@ -1,91 +0,0 @@
|
||||
package com.nnbc123.app.home.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.netease.nim.uikit.support.glide.GlideApp;
|
||||
import com.nnbc123.app.R;
|
||||
import com.nnbc123.app.avroom.activity.AVRoomActivity;
|
||||
import com.nnbc123.app.ui.utils.ImageLoadUtils;
|
||||
import com.nnbc123.core.home.bean.HomeTabMapInfo;
|
||||
import com.nnbc123.core.statistic.StatisticManager;
|
||||
import com.nnbc123.core.statistic.protocol.StatisticsProtocol;
|
||||
|
||||
/**
|
||||
* <p> 首页热门adapter </p>
|
||||
*
|
||||
* @author Administrator
|
||||
* @date 2017/11/16
|
||||
*/
|
||||
public class HomeRoomFragmentAdapter extends BaseMultiItemQuickAdapter<HomeTabMapInfo, BaseViewHolder> {
|
||||
|
||||
private Context mContext;
|
||||
|
||||
/**
|
||||
* 校验跳转房间的频率
|
||||
*/
|
||||
public HomeRoomFragmentAdapter(Context context) {
|
||||
super(null);
|
||||
addItemType(HomeTabMapInfo.TYPE_NORMAL, R.layout.item_home_tab_map);
|
||||
addItemType(HomeTabMapInfo.TYPE_EMPTY, R.layout.item_erban_grid_empty);
|
||||
this.mContext = context;
|
||||
}
|
||||
|
||||
protected void convert(@NonNull BaseViewHolder helper, HomeTabMapInfo item) {
|
||||
if (item == null) {
|
||||
return;
|
||||
}
|
||||
switch (helper.getItemViewType()) {
|
||||
|
||||
case HomeTabMapInfo.TYPE_NORMAL:
|
||||
helper.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
StatisticManager.Instance().onEvent(StatisticsProtocol.EVENT_TJ_ROOM_SUCCESS, "首页_进入推荐房间");
|
||||
AVRoomActivity.startForFromType(mContext, item.getRoomUid(), AVRoomActivity.FROM_TYPE_RECOMMEND);
|
||||
}
|
||||
});
|
||||
helper.setText(R.id.tv_online_number, item.getOnlineNum() + "")
|
||||
.setText(R.id.tv_title, item.getTitle());
|
||||
|
||||
|
||||
//注意这里有三个标签,展示优先级 PK中>自定义>房间标签
|
||||
helper.setGone(R.id.tv_tag_in_pk, item.isCrossPking());
|
||||
|
||||
helper.setGone(R.id.tv_tag_content, !TextUtils.isEmpty(item.getIconContent()) && !item.isCrossPking())
|
||||
.setText(R.id.tv_tag_content, item.getIconContent());
|
||||
|
||||
ImageView mIvTabLabel = helper.getView(R.id.iv_tab_label);
|
||||
if (!TextUtils.isEmpty(item.getTagPict()) && !item.isCrossPking() && TextUtils.isEmpty(item.getIconContent())) {
|
||||
mIvTabLabel.setVisibility(View.VISIBLE);
|
||||
ImageLoadUtils.loadAvatarBig(item.getTagPict(), mIvTabLabel);
|
||||
} else {
|
||||
mIvTabLabel.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
ImageView ivCover = helper.getView(R.id.iv_cover);
|
||||
if (!TextUtils.isEmpty(item.getAvatar())) {
|
||||
ImageLoadUtils.loadAvatarBig(item.getAvatar(), ivCover, R.drawable.default_cover);
|
||||
} else {
|
||||
GlideApp.with(mContext)
|
||||
.load(R.drawable.default_cover)
|
||||
.placeholder(R.drawable.default_cover)
|
||||
.into(ivCover);
|
||||
}
|
||||
break;
|
||||
|
||||
case HomeTabMapInfo.TYPE_EMPTY:
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -1,51 +0,0 @@
|
||||
package com.nnbc123.app.home.adapter
|
||||
|
||||
import android.widget.ImageView
|
||||
import androidx.core.view.isVisible
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.opensource.svgaplayer.SVGAImageView
|
||||
import com.nnbc123.app.R
|
||||
import com.nnbc123.app.avroom.activity.AVRoomActivity
|
||||
import com.nnbc123.core.home.bean.HomeRoomInfo
|
||||
import com.nnbc123.app.ui.utils.load
|
||||
import com.nnbc123.app.ui.utils.loadFromAssets
|
||||
import com.nnbc123.core.statistic.StatisticManager
|
||||
import com.nnbc123.core.statistic.protocol.StatisticsProtocol
|
||||
import com.nnbc123.core.utils.TextUtils
|
||||
|
||||
/**
|
||||
* create by lvzebiao @2019/11/13
|
||||
* 人气主播更多
|
||||
*/
|
||||
class MoreSingleAnchorAdapter :
|
||||
BaseQuickAdapter<HomeRoomInfo, BaseViewHolder>(R.layout.item_home_single_anchor_more) {
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: HomeRoomInfo) {
|
||||
|
||||
val ivPking = helper.getView<SVGAImageView>(R.id.iv_pking)
|
||||
val ivTag = helper.getView<ImageView>(R.id.iv_tag)
|
||||
ivPking.isVisible = item.isCrossPking
|
||||
ivTag.isVisible = !TextUtils.isEmptyText(item.tagPict) && !item.isCrossPking
|
||||
if (item.isCrossPking) {
|
||||
ivPking.loadFromAssets("svga/single_room_pking.svga")
|
||||
} else {
|
||||
ivTag.load(item.tagPict)
|
||||
}
|
||||
helper.setText(R.id.tv_online_num, item.onlineNum.toString())
|
||||
.setText(R.id.tv_nickname, item.nick)
|
||||
.setText(R.id.tv_room_name, item.title)
|
||||
.setImageResource(
|
||||
R.id.iv_gender,
|
||||
if (item.gender == 1) R.drawable.ic_gender_male else R.drawable.ic_gender_female
|
||||
)
|
||||
helper.getView<ImageView>(R.id.iv_room_avatar)
|
||||
.load(item.avatar, 12f, R.drawable.default_cover)
|
||||
|
||||
helper.itemView.setOnClickListener {
|
||||
StatisticManager.Instance()
|
||||
.onEvent(StatisticsProtocol.EVENT_ZB_TAB_ROOM_SUCCESS, "直播tab进入房间成功")
|
||||
AVRoomActivity.start(mContext, item.uid)
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,55 +0,0 @@
|
||||
package com.nnbc123.app.home.adapter
|
||||
|
||||
import android.text.TextUtils
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import androidx.core.view.isGone
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.nnbc123.app.R
|
||||
import com.nnbc123.app.ui.utils.ImageLoadUtilsV2
|
||||
import com.nnbc123.app.ui.utils.load
|
||||
import com.nnbc123.core.home.bean.HomeRoomInfo
|
||||
|
||||
|
||||
class RoomCommonAdapter :
|
||||
BaseQuickAdapter<HomeRoomInfo, BaseViewHolder>(R.layout.item_room_common) {
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: HomeRoomInfo) {
|
||||
helper.apply {
|
||||
getView<ImageView>(R.id.iv_room_image).load(item.avatar)
|
||||
setText(R.id.tv_online_number, "${item.onlineNum}")
|
||||
setText(R.id.tv_room_title, item.title)
|
||||
}
|
||||
helper.setGone(R.id.tv_in_pk, item.isCrossPking)
|
||||
helper.setGone(R.id.iv_room_tag, !TextUtils.isEmpty(item.tagPict))
|
||||
ImageLoadUtilsV2.loadImage(helper.getView(R.id.iv_room_tag), item.tagPict)
|
||||
|
||||
helper.setGone(R.id.tv_tag_content, !TextUtils.isEmpty(item.iconContent))
|
||||
.setText(R.id.tv_tag_content, item.iconContent)
|
||||
|
||||
helper.getView<View>(R.id.view_bg).setBackgroundResource(
|
||||
when (helper.layoutPosition % 3) {
|
||||
0 -> R.drawable.bg_home_common_item0
|
||||
1 -> R.drawable.bg_home_common_item1
|
||||
else -> R.drawable.bg_home_common_item2
|
||||
}
|
||||
)
|
||||
|
||||
val avatars: Array<ImageView> = arrayOf(
|
||||
helper.getView(R.id.iv_avatar_0),
|
||||
helper.getView(R.id.iv_avatar_1),
|
||||
helper.getView(R.id.iv_avatar_2),
|
||||
helper.getView(R.id.iv_avatar_3),
|
||||
helper.getView(R.id.iv_avatar_4),
|
||||
helper.getView(R.id.iv_avatar_5)
|
||||
)
|
||||
|
||||
for (i in avatars.indices) {
|
||||
val avatarUrl = item.micUsers?.getOrNull(i)?.avatar
|
||||
avatars[i].isGone = avatarUrl.isNullOrBlank()
|
||||
avatars[i].load(avatarUrl)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,64 +0,0 @@
|
||||
package com.nnbc123.app.home.adapter
|
||||
|
||||
import android.graphics.Color
|
||||
import android.graphics.LinearGradient
|
||||
import android.graphics.Shader
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.core.view.isGone
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.nnbc123.app.R
|
||||
import com.nnbc123.app.avroom.activity.AVRoomActivity
|
||||
import com.nnbc123.app.ui.utils.load
|
||||
import com.nnbc123.core.home.bean.HomeRoomInfo
|
||||
import com.nnbc123.core.statistic.StatisticManager
|
||||
import com.nnbc123.core.statistic.protocol.StatisticsProtocol
|
||||
|
||||
|
||||
class RoomGameAdapter : BaseQuickAdapter<HomeRoomInfo, BaseViewHolder>(R.layout.item_room_game) {
|
||||
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: HomeRoomInfo) {
|
||||
helper.apply {
|
||||
getView<ImageView>(R.id.iv_room_image).load(item.avatar)
|
||||
setText(R.id.tv_room_title, item.title)
|
||||
itemView.setOnClickListener {
|
||||
StatisticManager.Instance()
|
||||
.onEvent(StatisticsProtocol.EVENT_MINI_GAME_ROOM_SUCCESS, "小游戏tab进入房间成功")
|
||||
AVRoomActivity.start(mContext, item.uid)
|
||||
}
|
||||
val tvRoomGame = helper.getView<TextView>(R.id.tv_room_game)
|
||||
tvRoomGame.text = item.mgName
|
||||
helper.setText(R.id.tv_game_status, if (item.state == 1) "游戏中" else "等人中")
|
||||
setGradient(tvRoomGame)
|
||||
}
|
||||
|
||||
val avatars: Array<ImageView> = arrayOf(
|
||||
helper.getView(R.id.iv_avatar_0),
|
||||
helper.getView(R.id.iv_avatar_1),
|
||||
helper.getView(R.id.iv_avatar_2),
|
||||
helper.getView(R.id.iv_avatar_3),
|
||||
helper.getView(R.id.iv_avatar_4)
|
||||
)
|
||||
for (i in avatars.indices) {
|
||||
val avatarUrl = item.micUsers?.getOrNull(i)?.avatar
|
||||
avatars[i].isGone = avatarUrl.isNullOrBlank()
|
||||
avatars[i].load(avatarUrl)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun setGradient(textView: TextView) {
|
||||
val endX = textView.paint.textSize * textView.text.length
|
||||
val linearGradient = LinearGradient(
|
||||
0f, 0f, endX, 0f,
|
||||
Color.parseColor("#FF61C4FE"),
|
||||
Color.parseColor("#FFA979FF"),
|
||||
Shader.TileMode.CLAMP
|
||||
)
|
||||
textView.paint.shader = linearGradient
|
||||
textView.invalidate()
|
||||
}
|
||||
|
||||
}
|
@@ -1,62 +0,0 @@
|
||||
package com.nnbc123.app.home.adapter
|
||||
|
||||
import android.widget.ImageView
|
||||
import androidx.core.view.isGone
|
||||
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.nnbc123.app.R
|
||||
import com.nnbc123.app.avroom.activity.AVRoomActivity
|
||||
import com.nnbc123.app.home.helper.BannerHelper
|
||||
import com.nnbc123.app.ui.utils.load
|
||||
import com.nnbc123.core.home.bean.HomeRoomInfo
|
||||
import com.nnbc123.core.statistic.StatisticManager
|
||||
import com.nnbc123.core.statistic.protocol.StatisticsProtocol
|
||||
import com.nnbc123.core.utils.TextUtils
|
||||
|
||||
|
||||
class RoomHotAdapter : BaseMultiItemQuickAdapter<HomeRoomInfo, BaseViewHolder>(null) {
|
||||
|
||||
init {
|
||||
addItemType(HomeRoomInfo.TYPE_ROOM, R.layout.item_room_hot)
|
||||
addItemType(HomeRoomInfo.TYPE_BROADCAST, R.layout.item_room_hot)
|
||||
addItemType(HomeRoomInfo.TYPE_BANNER, R.layout.item_room_banner)
|
||||
}
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: HomeRoomInfo) {
|
||||
if (item.itemType != HomeRoomInfo.TYPE_BANNER) {
|
||||
|
||||
helper.itemView.setOnClickListener {
|
||||
AVRoomActivity.start(mContext, item.uid)
|
||||
StatisticManager.Instance()
|
||||
.onEvent(StatisticsProtocol.EVENT_RM_ROOM_SUCCESS, "热门进入房间")
|
||||
}
|
||||
|
||||
helper.getView<ImageView>(R.id.iv_room_image).load(item.avatar,round = 8f)
|
||||
helper.setText(R.id.tv_online_number, "${item.onlineNum}")
|
||||
helper.setText(R.id.tv_room_title, item.title)
|
||||
helper.setText(R.id.tv_id, "ID:${item.erbanNo}")
|
||||
|
||||
helper.setVisible(R.id.tv_in_pk, item.isCrossPking)
|
||||
|
||||
helper.setVisible(R.id.iv_room_tag, !TextUtils.isEmptyText(item.tagPict))
|
||||
helper.getView<ImageView>(R.id.iv_room_tag).load(item.tagPict)
|
||||
|
||||
val avatars: Array<ImageView> = arrayOf(
|
||||
helper.getView(R.id.iv_avatar_0),
|
||||
helper.getView(R.id.iv_avatar_1),
|
||||
helper.getView(R.id.iv_avatar_2),
|
||||
helper.getView(R.id.iv_avatar_3),
|
||||
helper.getView(R.id.iv_avatar_4)
|
||||
)
|
||||
for (i in avatars.indices) {
|
||||
val avatarUrl = item.micUsers?.getOrNull(i)?.avatar
|
||||
avatars[i].isGone = avatarUrl.isNullOrBlank()
|
||||
avatars[i].load(avatarUrl)
|
||||
}
|
||||
} else {
|
||||
BannerHelper.setBanner(helper.getView(R.id.roll_view), item.bannerVoList)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -1,59 +0,0 @@
|
||||
package com.nnbc123.app.home.adapter
|
||||
|
||||
import android.widget.ImageView
|
||||
import androidx.core.view.isGone
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.nnbc123.app.R
|
||||
import com.nnbc123.app.avroom.activity.AVRoomActivity
|
||||
import com.nnbc123.app.ui.utils.ImageLoadUtilsV2
|
||||
import com.nnbc123.app.ui.utils.load
|
||||
import com.nnbc123.core.home.bean.HomeRoomInfo
|
||||
import com.nnbc123.core.statistic.StatisticManager
|
||||
import com.nnbc123.core.statistic.protocol.StatisticsProtocol
|
||||
import com.nnbc123.core.utils.TextUtils
|
||||
|
||||
|
||||
class RoomLikeAdapter : BaseQuickAdapter<HomeRoomInfo, BaseViewHolder>(R.layout.item_room_like) {
|
||||
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: HomeRoomInfo) {
|
||||
helper.apply {
|
||||
getView<ImageView>(R.id.iv_room_image).load(item.roomAvatar)
|
||||
setText(R.id.tv_online_number, "${item.roomOnlineNum}")
|
||||
setText(R.id.tv_room_title, item.roomName)
|
||||
setText(R.id.tv_id, "ID:${item.erbanNo}")
|
||||
}
|
||||
helper.setVisible(R.id.tv_in_pk, item.isCrossPking)
|
||||
helper.setVisible(R.id.iv_room_tag, !TextUtils.isEmptyText(item.tagPict))
|
||||
ImageLoadUtilsV2.loadImage(helper.getView(R.id.iv_room_tag), item.tagPict)
|
||||
|
||||
val avatars: Array<ImageView> = arrayOf(
|
||||
helper.getView(R.id.iv_avatar_0),
|
||||
helper.getView(R.id.iv_avatar_1),
|
||||
helper.getView(R.id.iv_avatar_2),
|
||||
helper.getView(R.id.iv_avatar_3),
|
||||
helper.getView(R.id.iv_avatar_4)
|
||||
)
|
||||
for (i in avatars.indices) {
|
||||
val avatarUrl = item.micUsers?.getOrNull(i)?.avatar
|
||||
avatars[i].isGone = avatarUrl.isNullOrBlank()
|
||||
avatars[i].load(avatarUrl)
|
||||
}
|
||||
helper.itemView.setOnClickListener {
|
||||
AVRoomActivity.start(mContext, item.roomUid)
|
||||
StatisticManager.Instance()
|
||||
.onEvent(StatisticsProtocol.EVENT_SCFJ_ROOM_SUCCESS, "成功进入收藏的房间")
|
||||
}
|
||||
if (item.isValid) {
|
||||
helper.setGone(R.id.tv_online_number, true)
|
||||
helper.setBackgroundRes(R.id.view_bg, R.drawable.bg_home_like_item)
|
||||
helper.setBackgroundRes(R.id.view_room_cover, R.drawable.bg_home_common_avatar)
|
||||
} else {
|
||||
helper.setGone(R.id.tv_online_number, false)
|
||||
helper.setBackgroundRes(R.id.view_bg, R.drawable.bg_home_like_item_disable)
|
||||
helper.setBackgroundRes(R.id.view_room_cover, R.drawable.bg_home_common_avatar_disable)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,111 +0,0 @@
|
||||
package com.nnbc123.app.home.adapter
|
||||
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.widget.AppCompatImageView
|
||||
import androidx.core.view.isVisible
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.nnbc123.app.R
|
||||
import com.nnbc123.app.avroom.activity.AVRoomActivity
|
||||
import com.nnbc123.app.ui.im.avtivity.NimP2PMessageActivity
|
||||
import com.nnbc123.app.ui.user.UserInfoActivity
|
||||
import com.nnbc123.app.ui.utils.ImageLoadUtilsV2
|
||||
import com.nnbc123.app.ui.utils.loadAvatar
|
||||
import com.nnbc123.app.ui.utils.loadFromAssets
|
||||
import com.nnbc123.app.vip.VipHelper
|
||||
import com.nnbc123.core.user.bean.UserInfo
|
||||
import com.nnbc123.core.utils.CurrentTimeUtils
|
||||
import com.nnbc123.core.utils.StarUtils
|
||||
import com.nnbc123.core.utils.TextUtils
|
||||
import com.nnbc123.core.utils.ifNullOrEmpty
|
||||
import com.opensource.svgaplayer.SVGAImageView
|
||||
import java.util.*
|
||||
|
||||
class RoomNewFriendsAdapter :
|
||||
BaseQuickAdapter<UserInfo, BaseViewHolder>(R.layout.item_room_new_friends) {
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: UserInfo) {
|
||||
val userGamePartnerInfo = item.userGamePartnerVo
|
||||
if (userGamePartnerInfo != null) {
|
||||
helper.getView<AppCompatImageView>(R.id.iv_game).visibility = View.VISIBLE
|
||||
helper.getView<LinearLayout>(R.id.ll_game_type).visibility = View.VISIBLE
|
||||
if (TextUtils.isEmptyText(userGamePartnerInfo.secondGameName)) {
|
||||
helper.setText(R.id.tv_game_type, userGamePartnerInfo.firstGameName)
|
||||
} else {
|
||||
helper.setText(
|
||||
R.id.tv_game_type,
|
||||
"${userGamePartnerInfo.firstGameName}|${userGamePartnerInfo.secondGameName}"
|
||||
)
|
||||
}
|
||||
ImageLoadUtilsV2.loadImage(
|
||||
helper.getView(R.id.iv_game_icon),
|
||||
userGamePartnerInfo.firstLogo
|
||||
)
|
||||
} else {
|
||||
helper.getView<AppCompatImageView>(R.id.iv_game).visibility = View.GONE
|
||||
helper.getView<LinearLayout>(R.id.ll_game_type).visibility = View.GONE
|
||||
}
|
||||
helper.getView<ImageView>(R.id.iv_avatar).loadAvatar(item.avatar)
|
||||
helper.setText(R.id.tv_desc, item.userDesc.ifNullOrEmpty { "我是个默认签名" })
|
||||
.setText(
|
||||
R.id.tv_age,
|
||||
((CurrentTimeUtils.getCurrentTime() - item.birth) / 1000 / 60 / 60 / 24 / 365).toString()
|
||||
)
|
||||
//设置星座
|
||||
val star = StarUtils.getConstellation(Date(item.birth))
|
||||
helper.setGone(R.id.tv_constellation, star != null)
|
||||
.setText(R.id.tv_constellation, star)
|
||||
helper.setBackgroundRes(
|
||||
R.id.ll_gender_age,
|
||||
if (item.gender == 1) R.drawable.shape_65d3f7_corner else R.drawable.shape_ff9cce_corner
|
||||
)
|
||||
helper.setImageResource(
|
||||
R.id.iv_gender,
|
||||
if (item.gender == 1) R.drawable.ic_home_man else R.drawable.ic_home_woman
|
||||
)
|
||||
val tvOnlineText = helper.getView<TextView>(R.id.tv_online_text)
|
||||
val ivTalk = helper.getView<AppCompatImageView>(R.id.iv_talk)
|
||||
val svgaLiving = helper.getView<SVGAImageView>(R.id.svga_living)
|
||||
val llOnline = helper.getView<View>(R.id.ll_online)
|
||||
val viewOnline = helper.getView<View>(R.id.view_online)
|
||||
|
||||
if (item.inRoomUid != 0L) {
|
||||
ivTalk.isVisible = false
|
||||
svgaLiving.isVisible = true
|
||||
viewOnline.isVisible = true
|
||||
svgaLiving.loadFromAssets("svga/home_living.svga")
|
||||
tvOnlineText.text = "直播中"
|
||||
llOnline.setOnClickListener {
|
||||
AVRoomActivity.start(mContext, item.inRoomUid)
|
||||
}
|
||||
} else {
|
||||
ivTalk.isVisible = true
|
||||
svgaLiving.isVisible = false
|
||||
viewOnline.isVisible = false
|
||||
tvOnlineText.text = "和TA聊"
|
||||
llOnline.setOnClickListener {
|
||||
NimP2PMessageActivity.start(mContext, item.uid.toString())
|
||||
}
|
||||
}
|
||||
|
||||
helper.getView<View>(R.id.iv_avatar).setOnClickListener {
|
||||
UserInfoActivity.Companion.start(mContext, item.uid)
|
||||
}
|
||||
|
||||
val tvNickname = helper.getView<TextView>(R.id.tv_nickname)
|
||||
tvNickname.text = item.nick
|
||||
VipHelper.loadVipNickColor(tvNickname, item.userVipInfoVO, "#282828")
|
||||
VipHelper.loadVipIcon(helper.getView(R.id.iv_vip_icon), item.userVipInfoVO)
|
||||
}
|
||||
|
||||
override fun onViewAttachedToWindow(holder: BaseViewHolder) {
|
||||
super.onViewAttachedToWindow(holder)
|
||||
val svgaLiving = holder.getView<SVGAImageView>(R.id.svga_living)
|
||||
svgaLiving?.loadFromAssets("svga/home_living.svga")
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -1,65 +0,0 @@
|
||||
package com.nnbc123.app.home.fragment
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.view.View
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import com.nnbc123.core.DemoCache
|
||||
import com.nnbc123.core.UriProvider
|
||||
import com.nnbc123.core.statistic.StatisticManager
|
||||
import com.nnbc123.core.statistic.protocol.StatisticsProtocol
|
||||
import com.nnbc123.app.R
|
||||
import com.nnbc123.app.base.BaseFragment
|
||||
import com.nnbc123.app.databinding.FragmentHomeBinding
|
||||
import com.nnbc123.app.home.helper.OpenRoomHelper
|
||||
import com.nnbc123.app.ui.search.SearchActivity
|
||||
import com.nnbc123.app.ui.webview.CommonWebViewActivity
|
||||
|
||||
/**
|
||||
* 音萌首页
|
||||
*/
|
||||
class HomeFragment : BaseFragment(), View.OnClickListener {
|
||||
private lateinit var mBinding: FragmentHomeBinding
|
||||
override fun onClick(v: View) {
|
||||
when (v.id) {
|
||||
R.id.tv_search -> {
|
||||
StatisticManager.Instance().onEvent(StatisticsProtocol.EVENT_SEARCH, "进入搜索页")
|
||||
SearchActivity.start(activity)
|
||||
//为啥触发条件这么恶心 我也不知道啊
|
||||
if (DemoCache.readAnchorCardView() == 0) {
|
||||
DemoCache.saveAnchorCardView(1)
|
||||
}
|
||||
}
|
||||
R.id.iv_ranking -> {
|
||||
StatisticManager.Instance()
|
||||
.onEvent(StatisticsProtocol.EVENT_HOME_RANK_CLICK, "首页_榜单")
|
||||
CommonWebViewActivity.start(mContext, UriProvider.getRanking())
|
||||
}
|
||||
R.id.iv_my_room -> {
|
||||
StatisticManager.Instance()
|
||||
.onEvent(StatisticsProtocol.EVENT_HOME_MY_ROOM_CLICK, "首页_我的房间")
|
||||
OpenRoomHelper.openHomePartyRoom(baseActivity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getRootLayoutId(): Int {
|
||||
return R.layout.fragment_home
|
||||
}
|
||||
|
||||
override fun onFindViews() {
|
||||
mBinding = DataBindingUtil.bind(mView)!!
|
||||
}
|
||||
|
||||
override fun onSetListener() {
|
||||
mBinding.click = this
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
override fun initiate() {
|
||||
requireActivity().supportFragmentManager
|
||||
.beginTransaction()
|
||||
.replace(R.id.fragment_container_view, RecommendFragment.newInstance())
|
||||
.commitAllowingStateLoss()
|
||||
}
|
||||
|
||||
}
|
@@ -1,104 +0,0 @@
|
||||
package com.nnbc123.app.home.fragment
|
||||
|
||||
import com.nnbc123.app.base.BaseFragment
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.nnbc123.app.home.adapter.HomePlayAdapter
|
||||
import com.nnbc123.app.ui.utils.RVDelegate
|
||||
import com.nnbc123.core.home.bean.HomeRoomInfo
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.nnbc123.app.common.EmptyViewHelper
|
||||
import com.nnbc123.core.statistic.StatisticManager
|
||||
import com.nnbc123.core.statistic.protocol.StatisticsProtocol
|
||||
import com.nnbc123.app.avroom.activity.AVRoomActivity
|
||||
import android.annotation.SuppressLint
|
||||
import com.nnbc123.core.home.model.GameHomeModel
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
import com.nnbc123.core.user.event.LoadLoginUserInfoEvent
|
||||
import com.nnbc123.core.home.event.RefreshHomeDataEvent
|
||||
import com.nnbc123.app.home.fragment.HomePlayFragment
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.nnbc123.app.R
|
||||
|
||||
/**
|
||||
* create by lvzebiao @2020/1/7
|
||||
*/
|
||||
class HomePlayFragment : BaseFragment() {
|
||||
private var recyclerView: RecyclerView? = null
|
||||
private lateinit var playAdapter: HomePlayAdapter
|
||||
private lateinit var rvDelegate: RVDelegate<HomeRoomInfo>
|
||||
|
||||
override fun getRootLayoutId(): Int {
|
||||
return R.layout.fragment_home_play
|
||||
}
|
||||
|
||||
override fun initiate() {
|
||||
recyclerView = mView.findViewById(R.id.recycler_view)
|
||||
EventBus.getDefault().register(this)
|
||||
playAdapter = HomePlayAdapter()
|
||||
rvDelegate = RVDelegate.Builder<HomeRoomInfo>()
|
||||
.setAdapter(playAdapter)
|
||||
.setLayoutManager(LinearLayoutManager(mContext))
|
||||
.setRecyclerView(recyclerView)
|
||||
.setEmptyView(EmptyViewHelper.createEmptyView(context, "暂无数据"))
|
||||
.build()
|
||||
playAdapter.onItemClickListener =
|
||||
BaseQuickAdapter.OnItemClickListener { _: BaseQuickAdapter<*, *>, _: View, position: Int ->
|
||||
val homePlayInfo = playAdapter.getItem(position)
|
||||
if (homePlayInfo != null) {
|
||||
StatisticManager.Instance()
|
||||
.onEvent(StatisticsProtocol.EVENT_KH_ROOM_SUCCESS, "点击组队开黑进入房间")
|
||||
AVRoomActivity.startForFromType(
|
||||
mContext,
|
||||
homePlayInfo.uid,
|
||||
AVRoomActivity.FROM_TYPE_RECOMMEND
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
loadData(true)
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private fun loadData(refresh: Boolean) {
|
||||
GameHomeModel.get().homePlayV2
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe { homePlayInfoList: List<HomeRoomInfo>?, throwable: Throwable? ->
|
||||
if (throwable != null) {
|
||||
rvDelegate.loadErr(refresh)
|
||||
} else {
|
||||
rvDelegate.loadData(homePlayInfoList?.filter { !it.isBanner }, refresh)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onLoadLoginUserInfoEvent(event: LoadLoginUserInfoEvent?) {
|
||||
if (isResumed) loadData(true)
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onRefreshHomeDataEvent(event: RefreshHomeDataEvent?) {
|
||||
if (isResumed) loadData(true)
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
EventBus.getDefault().unregister(this)
|
||||
super.onDestroyView()
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun newInstance(): HomePlayFragment {
|
||||
val fragment = HomePlayFragment()
|
||||
val bundle = Bundle()
|
||||
fragment.arguments = bundle
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,192 +0,0 @@
|
||||
package com.nnbc123.app.home.fragment;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.nnbc123.core.home.bean.HomeTabMapInfo;
|
||||
import com.nnbc123.core.home.event.RefreshHomeDataEvent;
|
||||
import com.nnbc123.core.home.model.GameHomeModel;
|
||||
import com.nnbc123.core.utils.net.RxHelper;
|
||||
import com.nnbc123.app.R;
|
||||
import com.nnbc123.app.base.BaseFragment;
|
||||
import com.nnbc123.app.home.adapter.HomeRoomFragmentAdapter;
|
||||
import com.nnbc123.library.utils.ListUtils;
|
||||
import com.trello.rxlifecycle3.android.FragmentEvent;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class HomeTabHomeFragment extends BaseFragment {
|
||||
public static final int ROWS = 3;
|
||||
private static final Comparator<HomeTabMapInfo> comp = (o1, o2) -> {
|
||||
int seq = o1.getSeq() - o2.getSeq();
|
||||
return Integer.compare(seq, 0);
|
||||
};
|
||||
private RecyclerView recyclerView;
|
||||
private HomeRoomFragmentAdapter mHomeRoomAdapter;
|
||||
|
||||
@NonNull
|
||||
public static HomeTabHomeFragment newInstance() {
|
||||
HomeTabHomeFragment fragment = new HomeTabHomeFragment();
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRootLayoutId() {
|
||||
return R.layout.fragment_home_room_tab;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFindViews() {
|
||||
super.onFindViews();
|
||||
recyclerView = mView.findViewById(R.id.recycler_view);
|
||||
initRecyclerView();
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求数据
|
||||
*/
|
||||
@SuppressLint("CheckResult")
|
||||
private void getData() {
|
||||
GameHomeModel.get()
|
||||
.getHomeTabHome()
|
||||
.compose(RxHelper.handleSchedulers())
|
||||
.compose(bindUntilEvent(FragmentEvent.DESTROY_VIEW))
|
||||
.subscribe((serviceResult, throwable) -> {
|
||||
if (throwable == null) {
|
||||
if (ListUtils.isListEmpty(serviceResult)) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<HomeTabMapInfo> roomsList = new ArrayList<>(serviceResult);//未处理的数
|
||||
List<HomeTabMapInfo> randomList = new ArrayList<>();//不是置顶的
|
||||
List<HomeTabMapInfo> finalList = new ArrayList<>();//最终的6条数据
|
||||
|
||||
for (int i = 0; i < roomsList.size(); i++) {
|
||||
roomsList.get(i).setItemType(HomeTabMapInfo.TYPE_NORMAL);//对原始数据设置type
|
||||
}
|
||||
for (int i = 0; i < roomsList.size(); i++) {
|
||||
if (roomsList.get(i).isIsTop()) {
|
||||
finalList.add(roomsList.get(i));
|
||||
} else {
|
||||
randomList.add(roomsList.get(i));
|
||||
}
|
||||
}
|
||||
sortSeqRoom(finalList);
|
||||
refreshRoomData(finalList, randomList);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新数据
|
||||
*/
|
||||
private void refreshRoomData(List<HomeTabMapInfo> finalList, List<HomeTabMapInfo> randomList) {
|
||||
List<HomeTabMapInfo> finalList1 = new ArrayList<>(finalList);//最终的6条数据
|
||||
List<HomeTabMapInfo> randomList1 = new ArrayList<>(randomList);//不是置顶的
|
||||
mHomeRoomAdapter.setNewData(getConvertData(finalList1, randomList1));
|
||||
}
|
||||
|
||||
private void initRecyclerView() {
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext(),LinearLayoutManager.HORIZONTAL,false));
|
||||
recyclerView.setItemAnimator(null);
|
||||
mHomeRoomAdapter = new HomeRoomFragmentAdapter(getContext());
|
||||
mHomeRoomAdapter.setEnableLoadMore(false);
|
||||
mHomeRoomAdapter.setEnableLoadMore(false);
|
||||
recyclerView.setAdapter(mHomeRoomAdapter);
|
||||
|
||||
View emptyView = getLayoutInflater().inflate(R.layout.layout_home_room_empty, null);
|
||||
ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
emptyView.setLayoutParams(lp);
|
||||
mHomeRoomAdapter.setEmptyView(emptyView);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转化房间数组,不足6的加上虚位以待
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
private List<HomeTabMapInfo> getConvertData(List<HomeTabMapInfo> finalList, List<HomeTabMapInfo> randomList) {
|
||||
List<HomeTabMapInfo> finalList1 = new ArrayList<>(finalList);//最终的6条数据
|
||||
List<HomeTabMapInfo> randomList1 = new ArrayList<>(randomList);//不是置顶的
|
||||
int ROOM_COUNT = 6;//首页显示6条数据
|
||||
randomList1 = randomList(randomList1);
|
||||
finalList1.addAll(randomList1);
|
||||
|
||||
if (finalList1.size() >= ROOM_COUNT) {
|
||||
finalList1 = finalList1.subList(0, ROOM_COUNT);
|
||||
} else {
|
||||
while (finalList1.size() < ROOM_COUNT) {
|
||||
HomeTabMapInfo info = new HomeTabMapInfo();
|
||||
info.setItemType(HomeTabMapInfo.TYPE_EMPTY);
|
||||
finalList1.add(info);
|
||||
}
|
||||
}
|
||||
return finalList1;
|
||||
}
|
||||
|
||||
/**
|
||||
* **************************** 排序 ***********************************
|
||||
*/
|
||||
private void sortSeqRoom(List<HomeTabMapInfo> list) {
|
||||
if (list.size() == 0) {
|
||||
return;
|
||||
}
|
||||
Collections.sort(list, comp);
|
||||
}
|
||||
|
||||
private List<HomeTabMapInfo> randomList(List<HomeTabMapInfo> sourceList) {
|
||||
if (sourceList == null || sourceList.size() == 0) {
|
||||
return sourceList;
|
||||
}
|
||||
ArrayList randomList = new ArrayList(sourceList.size());
|
||||
do {
|
||||
int randomIndex = Math.abs(new Random().nextInt(sourceList.size()));
|
||||
randomList.add(sourceList.remove(randomIndex));
|
||||
} while (sourceList.size() > 0);
|
||||
return randomList;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void initiate() {
|
||||
getData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onRefreshHomeDataEvent(RefreshHomeDataEvent event) {
|
||||
if (isResumed()) getData();
|
||||
}
|
||||
|
||||
}
|
@@ -1,185 +0,0 @@
|
||||
package com.nnbc123.app.home.fragment
|
||||
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.widget.TextView
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil
|
||||
import com.scwang.smartrefresh.layout.internal.ProgressDrawable
|
||||
import com.nnbc123.app.R
|
||||
import com.nnbc123.app.avroom.adapter.RoomVPAdapter
|
||||
import com.nnbc123.app.base.BaseViewBindingFragment
|
||||
import com.nnbc123.app.databinding.FragmentLiveBinding
|
||||
import com.nnbc123.app.home.HomeViewModel
|
||||
import com.nnbc123.app.home.adapter.HomeLiveTopAdapter
|
||||
import com.nnbc123.app.home.adapter.PartyMagicIndicatorAdapter
|
||||
import com.nnbc123.app.ui.utils.RVDelegate
|
||||
import com.nnbc123.app.ui.widget.magicindicator.ViewPagerHelper
|
||||
import com.nnbc123.app.ui.widget.magicindicator.buildins.commonnavigator.CommonNavigator
|
||||
import com.nnbc123.core.home.event.RefreshHomeDataEvent
|
||||
import com.nnbc123.core.room.bean.HomeLiveTopInfo
|
||||
import com.nnbc123.core.room.bean.SingleRoomSortInfo
|
||||
import com.nnbc123.core.statistic.StatisticManager
|
||||
import com.nnbc123.core.statistic.protocol.StatisticsProtocol
|
||||
import com.nnbc123.core.utils.CurrentTimeUtils
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
||||
/**
|
||||
* 音萌首页
|
||||
*/
|
||||
class LiveFragment : BaseViewBindingFragment<FragmentLiveBinding>(),
|
||||
PartyMagicIndicatorAdapter.OnItemSelectListener {
|
||||
|
||||
private val mFragments: ArrayList<Fragment> = ArrayList()
|
||||
private val mTabInfoList: ArrayList<String> = ArrayList()
|
||||
private var currentIndex = 0
|
||||
private var lastLoadDataTime = 0L
|
||||
|
||||
private lateinit var mAdapter: HomeLiveTopAdapter
|
||||
private lateinit var rvDelegate: RVDelegate<HomeLiveTopInfo.SingleRoom>
|
||||
private val homeViewModel: HomeViewModel by activityViewModels()
|
||||
|
||||
companion object {
|
||||
fun newInstance(): LiveFragment {
|
||||
val args = Bundle()
|
||||
val fragment = LiveFragment()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
mAdapter = HomeLiveTopAdapter()
|
||||
rvDelegate = RVDelegate.Builder<HomeLiveTopInfo.SingleRoom>()
|
||||
.setAdapter(mAdapter)
|
||||
.setLayoutManager(LinearLayoutManager(mContext, RecyclerView.HORIZONTAL, false))
|
||||
.setRecyclerView(binding.recyclerView)
|
||||
.build()
|
||||
initRefreshView()
|
||||
homeViewModel.singleRoomSortInfoLiveData.observe(
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
if (it.isSuccess) {
|
||||
it.data?.let { date -> onGetSingleRoomSortInfoSuccess(date) }
|
||||
}
|
||||
}
|
||||
|
||||
homeViewModel.homeLiveTopInfoLiveData.observe(viewLifecycleOwner) {
|
||||
it?.let {
|
||||
mAdapter.setOnceLookStatus(it.onceLookStatus)
|
||||
rvDelegate.loadData(it.singleRoomList, true)
|
||||
binding.tvTitle.text = if (it.onceLookStatus) "曾经看过的人" else "Top热播"
|
||||
}
|
||||
}
|
||||
|
||||
binding.viewPager.addOnPageChangeListener(object : ViewPager.SimpleOnPageChangeListener() {
|
||||
override fun onPageSelected(position: Int) {
|
||||
super.onPageSelected(position)
|
||||
StatisticManager.Instance().onEvent(
|
||||
StatisticsProtocol.EVENT_GEBO_TAB_CLICK,
|
||||
"个播页二级tab分类点击",
|
||||
mapOf("tab_name" to mTabInfoList.getOrElse(position) { "未知tab" })
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
loadData()
|
||||
StatisticManager.Instance().onEvent(
|
||||
StatisticsProtocol.EVENT_RECENT_CARD_SHOW, "最近在看卡片曝光"
|
||||
)
|
||||
}
|
||||
|
||||
private fun onGetSingleRoomSortInfoSuccess(info: List<SingleRoomSortInfo>) {
|
||||
var changed = false
|
||||
val oldTabInfoList: List<CharSequence> = ArrayList<CharSequence>(mTabInfoList)
|
||||
for (tagInfo in info) {
|
||||
if (!oldTabInfoList.contains(tagInfo.sortName)) {
|
||||
changed = true
|
||||
break
|
||||
}
|
||||
}
|
||||
//只有HomeTagInfo发生改变才刷新数据
|
||||
if (changed) {
|
||||
mTabInfoList.clear()
|
||||
mFragments.clear()
|
||||
for (tagInfo in info) {
|
||||
mTabInfoList.add(tagInfo.sortName)
|
||||
val fragment = RoomSingleFragment.newInstance(tagInfo.id)
|
||||
mFragments.add(fragment)
|
||||
}
|
||||
val commonNavigator = CommonNavigator(context)
|
||||
commonNavigator.setTitleWrapContent(false)
|
||||
commonNavigator.titleMargin = ScreenUtil.dip2px(2.0F)
|
||||
commonNavigator.setTitleGravity(Gravity.CENTER_VERTICAL)
|
||||
val magicIndicatorAdapter = PartyMagicIndicatorAdapter(mTabInfoList)
|
||||
magicIndicatorAdapter.textSize = 14
|
||||
magicIndicatorAdapter.setOnItemSelectListener(this)
|
||||
commonNavigator.adapter = magicIndicatorAdapter
|
||||
binding.magicIndicator.navigator = commonNavigator
|
||||
binding.viewPager.offscreenPageLimit = 2
|
||||
binding.viewPager.adapter = RoomVPAdapter(
|
||||
childFragmentManager,
|
||||
mFragments
|
||||
)
|
||||
ViewPagerHelper.bind(binding.magicIndicator, binding.viewPager)
|
||||
onItemSelect(currentIndex, null)
|
||||
}
|
||||
}
|
||||
|
||||
private fun initRefreshView() {
|
||||
binding.refreshLayout.setOnRefreshListener {
|
||||
binding.refreshLayout.finishRefresh()
|
||||
EventBus.getDefault().post(RefreshHomeDataEvent())
|
||||
}
|
||||
binding.refreshLayout.isEnableLoadmore = false
|
||||
binding.refreshLayout.isEnableOverScrollBounce = false
|
||||
val themeColor = requireContext().resources.getColor(R.color.color_666666)
|
||||
binding.refreshHeader.lastUpdateText.setTextColor(themeColor)
|
||||
binding.refreshHeader.titleText.setTextColor(themeColor)
|
||||
binding.refreshHeader.setBackgroundColor(Color.TRANSPARENT)
|
||||
val progressDrawable = ProgressDrawable()
|
||||
progressDrawable.setColor(themeColor)
|
||||
binding.refreshHeader.progressView.setImageDrawable(progressDrawable)
|
||||
}
|
||||
|
||||
override fun onItemSelect(position: Int, view: TextView?) {
|
||||
currentIndex = position
|
||||
binding.viewPager.currentItem = currentIndex
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onRefreshHomeDataEvent(event: RefreshHomeDataEvent?) {
|
||||
if (isResumed) {
|
||||
loadData()
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadData() {
|
||||
if (CurrentTimeUtils.getCurrentTime() - lastLoadDataTime < 15 * 1000) return
|
||||
lastLoadDataTime = CurrentTimeUtils.getCurrentTime()
|
||||
homeViewModel.requestSingleRoomSortList()
|
||||
homeViewModel.requestHomeLiveTopInfo()
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
EventBus.getDefault().register(this)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
EventBus.getDefault().unregister(this)
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -2,7 +2,6 @@ package com.nnbc123.app.home.fragment
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.text.TextUtils
|
||||
import android.util.SparseArray
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@@ -31,14 +30,14 @@ import com.nnbc123.app.home.activity.VisitorListActivity
|
||||
import com.nnbc123.app.home.adapter.MeCenterAdapter
|
||||
import com.nnbc123.app.home.helper.BannerHelper
|
||||
import com.nnbc123.app.home.helper.OpenRoomHelper
|
||||
import com.nnbc123.app.qiyukefu.CustomerServerHelper
|
||||
import com.nnbc123.app.skill.activity.SkillHomeActivity
|
||||
import com.nnbc123.app.skill.activity.SkillHomeActivity.Companion.start
|
||||
import com.nnbc123.app.support.LevelIconHelper
|
||||
import com.nnbc123.app.ui.im.avtivity.NimP2PMessageActivity
|
||||
import com.nnbc123.app.ui.patriarch.PatriarchModeActivity
|
||||
import com.nnbc123.app.ui.pay.ChargeActivity
|
||||
import com.nnbc123.app.ui.relation.AttentionListActivity
|
||||
import com.nnbc123.app.ui.relation.FansListActivity
|
||||
import com.nnbc123.app.ui.utils.ImageLoadUtils
|
||||
import com.nnbc123.app.ui.webview.CommonWebViewActivity
|
||||
import com.nnbc123.app.ui.widget.OnPageSelectedListener
|
||||
import com.nnbc123.app.utils.UserUtils
|
||||
@@ -56,12 +55,10 @@ import com.nnbc123.core.room.bean.RoomInfo
|
||||
import com.nnbc123.core.statistic.StatisticManager
|
||||
import com.nnbc123.core.statistic.protocol.StatisticsProtocol
|
||||
import com.nnbc123.core.user.UserModel
|
||||
import com.nnbc123.core.user.bean.UserExpInfo
|
||||
import com.nnbc123.core.user.bean.UserInfo
|
||||
import com.nnbc123.core.user.event.LoginUserInfoUpdateEvent
|
||||
import com.nnbc123.core.utils.CurrentTimeUtils
|
||||
import com.nnbc123.core.utils.StarUtils
|
||||
import com.nnbc123.core.utils.net.BeanObserver
|
||||
import com.nnbc123.core.utils.toast
|
||||
import com.trello.rxlifecycle3.android.FragmentEvent
|
||||
import io.reactivex.Observable
|
||||
@@ -240,12 +237,15 @@ class MeFragment : BaseFragment(), View.OnClickListener {
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (!isHidden) {
|
||||
StatisticManager.Instance().onEvent(StatisticsProtocol.EVENT_HOMEPAGE_SHOW, "我的")
|
||||
}
|
||||
if (mUserInfo?.isReview == true) {
|
||||
requestUpdateUserInfo()
|
||||
}
|
||||
initUserDate()
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private fun initUserDate() {
|
||||
UserModel.get().currentUserInfo
|
||||
@@ -273,7 +273,11 @@ class MeFragment : BaseFragment(), View.OnClickListener {
|
||||
if (it.isParentMode) {
|
||||
mBinding.meItemSkill.isVisible = false
|
||||
}
|
||||
it.userHeadwear?.effect?.let { effect ->
|
||||
var avatarBorder = it.userHeadwear?.effect
|
||||
if (avatarBorder.isNullOrEmpty()) {
|
||||
avatarBorder = it.userHeadwear?.pic
|
||||
}
|
||||
avatarBorder?.let { effect ->
|
||||
if (mBinding.ivHeadWear.tag != effect) {
|
||||
NobleUtil.loadHeadWear(effect, mBinding.ivHeadWear)
|
||||
mBinding.ivHeadWear.tag = effect
|
||||
@@ -327,15 +331,15 @@ class MeFragment : BaseFragment(), View.OnClickListener {
|
||||
mBinding.ivUserCharm.visibility = View.GONE
|
||||
mBinding.ivUserLevel.visibility = View.GONE
|
||||
if (userLevelVo != null) {
|
||||
val userLevelUrl = userLevelVo.getExperUrl()
|
||||
val userCharmUrl = userLevelVo.getCharmUrl()
|
||||
if (!TextUtils.isEmpty(userLevelUrl)) {
|
||||
mBinding.ivUserLevel.visibility = View.VISIBLE
|
||||
ImageLoadUtils.loadImage(mContext, userLevelUrl, mBinding.ivUserLevel)
|
||||
}
|
||||
if (!TextUtils.isEmpty(userCharmUrl)) {
|
||||
val charmIconId = LevelIconHelper.getCharmIcon(userLevelVo.charmLevelSeq)
|
||||
val wealthIconId = LevelIconHelper.getWealthIcon(userLevelVo.experLevelSeq)
|
||||
if (charmIconId != null) {
|
||||
mBinding.ivUserCharm.setImageResource(charmIconId)
|
||||
mBinding.ivUserCharm.visibility = View.VISIBLE
|
||||
ImageLoadUtils.loadImage(mContext, userCharmUrl, mBinding.ivUserCharm)
|
||||
}
|
||||
if (wealthIconId != null) {
|
||||
mBinding.ivUserLevel.setImageResource(wealthIconId)
|
||||
mBinding.ivUserLevel.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -415,7 +419,7 @@ class MeFragment : BaseFragment(), View.OnClickListener {
|
||||
"个人中心充值卡片点击"
|
||||
)
|
||||
}
|
||||
R.id.me_item_room -> OpenRoomHelper.openHomePartyRoom(requireActivity() as BaseActivity)
|
||||
R.id.me_item_room -> OpenRoomHelper.openRoom(requireActivity() as BaseActivity)
|
||||
R.id.me_item_level -> CommonWebViewActivity.start(
|
||||
mContext,
|
||||
UriProvider.getUserLevelUrl()
|
||||
@@ -435,7 +439,8 @@ class MeFragment : BaseFragment(), View.OnClickListener {
|
||||
UriProvider.getTutuRealNamePage()
|
||||
)
|
||||
R.id.tv_me_service -> {
|
||||
CustomerServerHelper.contactCustomerServer(mContext)
|
||||
NimP2PMessageActivity.start(requireContext(), "200014")
|
||||
// CustomerServerHelper.contactCustomerServer(mContext)
|
||||
}
|
||||
R.id.tv_user_id -> {
|
||||
mUserInfo?.let {
|
||||
|
@@ -17,6 +17,8 @@ import com.nnbc123.app.ui.im.friend.FriendListFragment
|
||||
import com.nnbc123.app.ui.im.recent.RecentListFragment
|
||||
import com.nnbc123.app.ui.widget.magicindicator.ViewPagerHelper
|
||||
import com.nnbc123.app.ui.widget.magicindicator.buildins.commonnavigator.CommonNavigator
|
||||
import com.nnbc123.core.statistic.StatisticManager
|
||||
import com.nnbc123.core.statistic.protocol.StatisticsProtocol
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
|
||||
/**
|
||||
@@ -42,6 +44,13 @@ class MsgFragment : BaseViewBindingFragment<FragmentMsgBinding>(),
|
||||
binding.viewPager.currentItem = currentIndex
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (!isHidden) {
|
||||
StatisticManager.Instance().onEvent(StatisticsProtocol.EVENT_HOMEPAGE_SHOW, "消息")
|
||||
}
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
val tagList = arrayListOf("消息", "好友")
|
||||
mFragments.clear()
|
||||
|
@@ -1,156 +0,0 @@
|
||||
package com.nnbc123.app.home.fragment
|
||||
|
||||
import android.os.Bundle
|
||||
import android.widget.TextView
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import com.coorchice.library.utils.LogUtils
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil
|
||||
import com.nnbc123.app.R
|
||||
import com.nnbc123.app.avroom.adapter.RoomVPAdapter
|
||||
import com.nnbc123.app.base.BaseFragment
|
||||
import com.nnbc123.app.databinding.FragmentPartyBinding
|
||||
import com.nnbc123.app.home.HomeViewModel
|
||||
import com.nnbc123.app.home.adapter.MainMagicIndicatorAdapter
|
||||
import com.nnbc123.app.home.helper.BannerHelper
|
||||
import com.nnbc123.app.ui.widget.magicindicator.ViewPagerHelper
|
||||
import com.nnbc123.app.ui.widget.magicindicator.buildins.commonnavigator.CommonNavigator
|
||||
import com.nnbc123.core.home.bean.HomeTagInfo
|
||||
import com.nnbc123.core.home.event.RefreshHomeDataEvent
|
||||
import com.nnbc123.core.statistic.StatisticManager
|
||||
import com.nnbc123.core.statistic.protocol.StatisticsProtocol
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
||||
/**
|
||||
* 音萌首页
|
||||
*/
|
||||
class PartyFragment : BaseFragment(), MainMagicIndicatorAdapter.OnItemSelectListener {
|
||||
private lateinit var mBinding: FragmentPartyBinding
|
||||
private val mFragments: ArrayList<Fragment> = ArrayList()
|
||||
private val mTabInfoList: ArrayList<CharSequence> = ArrayList()
|
||||
private val homeViewModel: HomeViewModel by activityViewModels()
|
||||
private var currentIndex = 0
|
||||
|
||||
companion object {
|
||||
fun newInstance(): PartyFragment {
|
||||
val args = Bundle()
|
||||
val fragment = PartyFragment()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
|
||||
override fun getRootLayoutId(): Int {
|
||||
return R.layout.fragment_party
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
EventBus.getDefault().register(this)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
EventBus.getDefault().unregister(this)
|
||||
}
|
||||
|
||||
override fun onFindViews() {
|
||||
mBinding = DataBindingUtil.bind(mView)!!
|
||||
}
|
||||
|
||||
override fun initiate() {
|
||||
homeViewModel.tagLiveData.observe(this) {
|
||||
it?.let {
|
||||
onGetHomeTagSuccess(it)
|
||||
}
|
||||
}
|
||||
homeViewModel.partyBannerLiveData.observe(this) {
|
||||
BannerHelper.setBanner(mBinding.rollView, it) { _, _ ->
|
||||
StatisticManager.Instance()
|
||||
.onEvent(StatisticsProtocol.EVENT_HOME_BANNER_CLICK, "首页_banner")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
homeViewModel.getTagInfo()
|
||||
homeViewModel.getPartyBanner()
|
||||
}
|
||||
|
||||
private fun onGetHomeTagSuccess(tagInfoList: MutableList<HomeTagInfo>) {
|
||||
tagInfoList.add(0,HomeTagInfo("热门"))
|
||||
var changed = false
|
||||
val oldTabInfoList: List<CharSequence> = ArrayList<CharSequence>(mTabInfoList)
|
||||
for (tagInfo in tagInfoList) {
|
||||
if (!oldTabInfoList.contains(tagInfo.name)) {
|
||||
changed = true
|
||||
break
|
||||
}
|
||||
}
|
||||
//只有HomeTagInfo发生改变才刷新数据
|
||||
if (changed) {
|
||||
LogUtils.e("$changed:oldTabInfoList")
|
||||
mTabInfoList.clear()
|
||||
mFragments.clear()
|
||||
for (i in tagInfoList.indices) {
|
||||
//过滤对象是空和没有标签名同时也没有子标签的情况
|
||||
var title: CharSequence?
|
||||
var fragment: Fragment?
|
||||
var name = tagInfoList[i].name
|
||||
if (name != null) {
|
||||
name = name.trim { it <= ' ' }
|
||||
}
|
||||
title = name
|
||||
mTabInfoList.add(title)
|
||||
val tabId: Int = tagInfoList[i].id
|
||||
fragment = when (title) {
|
||||
"热门" -> {
|
||||
PartyRecommendFragment.newInstance()
|
||||
}
|
||||
"喜欢" -> {
|
||||
RoomLikeFragment.newInstance()
|
||||
}
|
||||
"小游戏" -> {
|
||||
RoomGameFragment.newInstance()
|
||||
}
|
||||
else -> {
|
||||
RoomCommonFragment.newInstance(tabId)
|
||||
}
|
||||
}
|
||||
mFragments.add(fragment)
|
||||
}
|
||||
val commonNavigator = CommonNavigator(context)
|
||||
commonNavigator.setTitleWrapContent(true)
|
||||
commonNavigator.titleMargin = ScreenUtil.dip2px(6.0F)
|
||||
val magicIndicatorAdapter = MainMagicIndicatorAdapter(context, mTabInfoList)
|
||||
magicIndicatorAdapter.textSize = 16
|
||||
magicIndicatorAdapter.minScale = 0.85f
|
||||
magicIndicatorAdapter.setResId(R.drawable.ic_home_indicator_center)
|
||||
magicIndicatorAdapter.setOnItemSelectListener(this)
|
||||
commonNavigator.adapter = magicIndicatorAdapter
|
||||
mBinding.magicIndicator.navigator = commonNavigator
|
||||
mBinding.viewPager.offscreenPageLimit = 2
|
||||
mBinding.viewPager.adapter = RoomVPAdapter(
|
||||
childFragmentManager,
|
||||
mFragments
|
||||
)
|
||||
ViewPagerHelper.bind(mBinding.magicIndicator, mBinding.viewPager)
|
||||
onItemSelect(currentIndex, null)
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onRefreshHomeDataEvent(event: RefreshHomeDataEvent?) {
|
||||
if (isResumed) homeViewModel.getTagInfo()
|
||||
}
|
||||
|
||||
override fun onItemSelect(position: Int, view: TextView?) {
|
||||
currentIndex = position
|
||||
mBinding.viewPager.currentItem = currentIndex
|
||||
}
|
||||
|
||||
}
|
@@ -1,113 +0,0 @@
|
||||
package com.nnbc123.app.home.fragment
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.nnbc123.core.home.bean.HomeRoomInfo
|
||||
import com.nnbc123.core.home.event.RefreshHomeDataEvent
|
||||
import com.nnbc123.core.statistic.StatisticManager
|
||||
import com.nnbc123.core.statistic.protocol.StatisticsProtocol
|
||||
import com.nnbc123.app.avroom.activity.AVRoomActivity
|
||||
import com.nnbc123.app.base.BaseViewBindingFragment
|
||||
import com.nnbc123.app.common.EmptyViewHelper
|
||||
import com.nnbc123.app.databinding.FragmentPartyHotBinding
|
||||
import com.nnbc123.app.databinding.FragmentRoomCommonBinding
|
||||
import com.nnbc123.app.home.HomeViewModel
|
||||
import com.nnbc123.app.home.adapter.PartyHotAdapter
|
||||
import com.nnbc123.app.home.adapter.RoomCommonAdapter
|
||||
import com.nnbc123.app.ui.utils.RVDelegate
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
||||
class PartyRecommendFragment : BaseViewBindingFragment<FragmentPartyHotBinding>() {
|
||||
|
||||
companion object {
|
||||
fun newInstance(): PartyRecommendFragment {
|
||||
val args = Bundle()
|
||||
val fragment = PartyRecommendFragment()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private lateinit var mAdapter: PartyHotAdapter
|
||||
private lateinit var rvDelegate: RVDelegate<HomeRoomInfo>
|
||||
|
||||
private lateinit var mMoreAdapter: RoomCommonAdapter
|
||||
private lateinit var rvMoreDelegate: RVDelegate<HomeRoomInfo>
|
||||
|
||||
private val homeViewModel: HomeViewModel by activityViewModels()
|
||||
|
||||
override fun init() {
|
||||
mAdapter = PartyHotAdapter()
|
||||
rvDelegate = RVDelegate.Builder<HomeRoomInfo>()
|
||||
.setAdapter(mAdapter)
|
||||
.setLayoutManager(GridLayoutManager(mContext, 2, GridLayoutManager.VERTICAL, false))
|
||||
.setEmptyView(EmptyViewHelper.createEmptyView(mContext, "暂无房间"))
|
||||
.setRefreshLayout(binding.refreshLayout)
|
||||
.setRecyclerView(binding.recyclerView)
|
||||
.build()
|
||||
mAdapter.setOnItemClickListener { _, _, position ->
|
||||
mAdapter.getItem(position)?.let {
|
||||
AVRoomActivity.start(context, it.roomUid)
|
||||
StatisticManager.Instance()
|
||||
.onEvent(StatisticsProtocol.EVENT_COMMON_TAB_ROOM_SUCCESS, "通用tab进入房间成功")
|
||||
}
|
||||
}
|
||||
mMoreAdapter = RoomCommonAdapter()
|
||||
rvMoreDelegate = RVDelegate.Builder<HomeRoomInfo>()
|
||||
.setAdapter(mMoreAdapter)
|
||||
.setLayoutManager(LinearLayoutManager(mContext))
|
||||
.setEmptyView(EmptyViewHelper.createEmptyView(mContext, "暂无房间"))
|
||||
.setRefreshLayout(binding.refreshLayout)
|
||||
.setRecyclerView(binding.recyclerMoreView)
|
||||
.build()
|
||||
mMoreAdapter.setOnItemClickListener { _, _, position ->
|
||||
mMoreAdapter.getItem(position)?.let {
|
||||
AVRoomActivity.start(context, it.uid)
|
||||
StatisticManager.Instance()
|
||||
.onEvent(StatisticsProtocol.EVENT_COMMON_TAB_ROOM_SUCCESS, "通用tab进入房间成功")
|
||||
}
|
||||
}
|
||||
binding.refreshLayout.setOnRefreshListener {
|
||||
loadData(true)
|
||||
}
|
||||
homeViewModel.partyRecommendRoomLiveData.observe(this) {
|
||||
rvDelegate.loadData(it)
|
||||
}
|
||||
homeViewModel.partyRecommendRoomMoreLiveData.observe(this) {
|
||||
rvMoreDelegate.loadData(it)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
loadData(true)
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
fun loadData(isRefresh: Boolean) {
|
||||
binding.refreshLayout.isRefreshing = isRefresh
|
||||
homeViewModel.getPartyRecommendRoomList()
|
||||
homeViewModel.getPartyRecommendRoomMoreList()
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
EventBus.getDefault().register(this)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
EventBus.getDefault().unregister(this)
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onRefreshHomeDataEvent(event: RefreshHomeDataEvent?) {
|
||||
if (isResumed) loadData(true)
|
||||
}
|
||||
}
|
@@ -1,345 +0,0 @@
|
||||
package com.nnbc123.app.home.fragment
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.core.view.isGone
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import com.nnbc123.app.R
|
||||
import com.nnbc123.app.avroom.activity.AVRoomActivity
|
||||
import com.nnbc123.app.avroom.adapter.RoomVPAdapter
|
||||
import com.nnbc123.app.base.BaseFragment
|
||||
import com.nnbc123.app.common.EmptyViewHelper
|
||||
import com.nnbc123.app.databinding.FragmentRecommendBinding
|
||||
import com.nnbc123.app.home.HomeViewModel
|
||||
import com.nnbc123.app.home.adapter.GiftServiceAdapter
|
||||
import com.nnbc123.app.home.adapter.HomeSingleAnchorAdapter
|
||||
import com.nnbc123.app.home.adapter.MainMagicIndicatorAdapter
|
||||
import com.nnbc123.app.home.dialog.RecommendRoomDialog
|
||||
import com.nnbc123.app.home.helper.BannerHelper
|
||||
import com.nnbc123.app.ui.im.avtivity.NimP2PMessageActivity
|
||||
import com.nnbc123.app.ui.utils.RVDelegate
|
||||
import com.nnbc123.app.ui.utils.load
|
||||
import com.nnbc123.app.ui.webview.CommonWebViewActivity
|
||||
import com.nnbc123.app.ui.widget.NewFriendsFilterWindow
|
||||
import com.nnbc123.app.ui.widget.magicindicator.ViewPagerHelper
|
||||
import com.nnbc123.app.ui.widget.magicindicator.buildins.commonnavigator.CommonNavigator
|
||||
import com.nnbc123.core.auth.AuthModel
|
||||
import com.nnbc123.core.home.bean.GiftServiceMsgVo
|
||||
import com.nnbc123.core.home.event.RefreshHomeDataEvent
|
||||
import com.nnbc123.core.statistic.StatisticManager
|
||||
import com.nnbc123.core.statistic.protocol.StatisticsProtocol
|
||||
import com.scwang.smartrefresh.layout.internal.ProgressDrawable
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
/**
|
||||
* 音萌首页
|
||||
*/
|
||||
class RecommendFragment : BaseFragment(),
|
||||
MainMagicIndicatorAdapter.OnItemSelectListener {
|
||||
private lateinit var mBinding: FragmentRecommendBinding
|
||||
private var mFragmentsBottom: MutableList<Fragment> = ArrayList()
|
||||
private lateinit var singleAnchorAdapter: HomeSingleAnchorAdapter
|
||||
|
||||
private lateinit var giftServiceAdapter: GiftServiceAdapter
|
||||
private lateinit var rvDelegate: RVDelegate<GiftServiceMsgVo>
|
||||
private var disposable: Disposable? = null
|
||||
|
||||
private val homeViewModel: HomeViewModel by activityViewModels()
|
||||
private var currGender: Int? = null
|
||||
|
||||
//仅埋点使用,不影响业务逻辑
|
||||
private val abcArray = arrayOf("A", "B", "C", "D")
|
||||
private var currMatchClick = abcArray[0]
|
||||
|
||||
companion object {
|
||||
fun newInstance(): RecommendFragment {
|
||||
val args = Bundle()
|
||||
val fragment = RecommendFragment()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
|
||||
override fun getRootLayoutId(): Int {
|
||||
return R.layout.fragment_recommend
|
||||
}
|
||||
|
||||
|
||||
override fun onFindViews() {
|
||||
mBinding = DataBindingUtil.bind(mView)!!
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
loadData()
|
||||
homeViewModel.getServiceGiftRecord()
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
override fun initiate() {
|
||||
initRefreshView()
|
||||
initTitleTab()
|
||||
//initSingleAnchor()
|
||||
giftServiceAdapter = GiftServiceAdapter()
|
||||
giftServiceAdapter.setOnItemClickListener { _, _, position ->
|
||||
giftServiceAdapter.getItem(position)?.let {
|
||||
AVRoomActivity.start(mContext, it.roomUid)
|
||||
}
|
||||
}
|
||||
rvDelegate = RVDelegate.Builder<GiftServiceMsgVo>()
|
||||
.setAdapter(giftServiceAdapter)
|
||||
.setRecyclerView(mBinding.rvGiftService)
|
||||
.setEmptyView(EmptyViewHelper.createEmptyView(context, "暂无房间"))
|
||||
.setLayoutManager(LinearLayoutManager(mContext))
|
||||
.build()
|
||||
|
||||
homeViewModel.bannerLiveData.observe(this) {
|
||||
BannerHelper.setBanner(mBinding.rollView, it) { _, _ ->
|
||||
StatisticManager.Instance()
|
||||
.onEvent(StatisticsProtocol.EVENT_HOME_BANNER_CLICK, "首页_banner")
|
||||
}
|
||||
}
|
||||
homeViewModel.resourceLiveData.observe(this) {
|
||||
if (it.isNullOrEmpty() || it.size != 4) {
|
||||
mBinding.llResource.isGone = true
|
||||
return@observe
|
||||
}
|
||||
mBinding.llResource.isGone = false
|
||||
val resourceViews = arrayOf(
|
||||
mBinding.ivResource0,
|
||||
mBinding.ivResource1,
|
||||
mBinding.ivResource2,
|
||||
mBinding.ivResource3
|
||||
)
|
||||
for (i in resourceViews.indices) {
|
||||
resourceViews[i].load(it[i].icon)
|
||||
if (it[i].resourceType == 8) {
|
||||
mBinding.tvOnlineNum.text = "${it[i].resourceContent}人组队中"
|
||||
}
|
||||
resourceViews[i].setOnClickListener { _ ->
|
||||
currMatchClick = abcArray[i]
|
||||
StatisticManager.Instance().onEvent(
|
||||
"${currMatchClick}_match_click",
|
||||
"资源位点击",
|
||||
mapOf("user_id" to AuthModel.get().currentUid.toString())
|
||||
)
|
||||
when {
|
||||
it[i].resourceType == 5 -> {
|
||||
CommonWebViewActivity.start(context, it[i].resourceContent)
|
||||
}
|
||||
i == 3 -> {
|
||||
dialogManager.showProgressDialog(mContext)
|
||||
homeViewModel.getHomeChatPick()
|
||||
}
|
||||
else -> {
|
||||
dialogManager.showProgressDialog(mContext)
|
||||
homeViewModel.getResourceJumpInfo(it[i].id)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
homeViewModel.resourceJumpLiveData.observe(this) {
|
||||
dialogManager.dismissDialog()
|
||||
it?.let {
|
||||
if (it.isPick) {
|
||||
AVRoomActivity.start(context, it.uid)
|
||||
StatisticManager.Instance().onEvent(
|
||||
"${currMatchClick}_match_success",
|
||||
"资源位匹配成功",
|
||||
mapOf("user_id" to AuthModel.get().currentUid.toString())
|
||||
)
|
||||
} else {
|
||||
RecommendRoomDialog.newInstance(it).show(context)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
homeViewModel.homeChatPickLiveData.observe(viewLifecycleOwner) {
|
||||
dialogManager.dismissDialog()
|
||||
it?.let {
|
||||
if (it.isNotEmpty()) {
|
||||
NimP2PMessageActivity.start(context, it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
homeViewModel.giftServiceLiveData.observe(viewLifecycleOwner) {
|
||||
rvDelegate.loadData(it)
|
||||
}
|
||||
mBinding.rvGiftService.setOnTouchListener { _, _ -> true }
|
||||
disposable = Observable.intervalRange(0, Int.MAX_VALUE.toLong(), 0, 5, TimeUnit.SECONDS)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.filter { rvDelegate.adapter.itemCount > 0 && isResumed }
|
||||
.subscribe {
|
||||
val index = (it % rvDelegate.adapter.itemCount).toInt()
|
||||
if (index == 0) {
|
||||
mBinding.rvGiftService.scrollToPosition(index)
|
||||
} else {
|
||||
mBinding.rvGiftService.smoothScrollToPosition(index)
|
||||
}
|
||||
}
|
||||
mBinding.tvNewRefresh.setOnClickListener {
|
||||
homeViewModel.getNewFriendList(currGender)
|
||||
}
|
||||
mBinding.tvNewFilter.setOnClickListener {
|
||||
val popup = NewFriendsFilterWindow(
|
||||
mContext,
|
||||
mBinding.tvNewFilter.text.toString()
|
||||
)
|
||||
popup.setOnClickListener {
|
||||
popup.dismiss()
|
||||
when (it.id) {
|
||||
R.id.tv_all -> {
|
||||
homeViewModel.getNewFriendList()
|
||||
mBinding.tvNewFilter.text = "全部"
|
||||
currGender = null
|
||||
}
|
||||
R.id.tv_man -> {
|
||||
homeViewModel.getNewFriendList(1)
|
||||
mBinding.tvNewFilter.text = "男生"
|
||||
currGender = 1
|
||||
}
|
||||
R.id.tv_woman -> {
|
||||
homeViewModel.getNewFriendList(2)
|
||||
mBinding.tvNewFilter.text = "女生"
|
||||
currGender = 2
|
||||
}
|
||||
}
|
||||
}
|
||||
popup.show(mBinding.tvNewFilter, Gravity.BOTTOM)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun initRefreshView() {
|
||||
mBinding.refreshLayout.setOnRefreshListener {
|
||||
mBinding.refreshLayout.finishRefresh()
|
||||
EventBus.getDefault().post(RefreshHomeDataEvent())
|
||||
}
|
||||
mBinding.refreshLayout.isEnableLoadmore = false
|
||||
mBinding.refreshLayout.isEnableOverScrollBounce = false
|
||||
val themeColor = requireContext().resources.getColor(R.color.color_666666)
|
||||
mBinding.refreshHeader.lastUpdateText.setTextColor(themeColor)
|
||||
mBinding.refreshHeader.titleText.setTextColor(themeColor)
|
||||
mBinding.refreshHeader.setBackgroundColor(Color.TRANSPARENT)
|
||||
val progressDrawable = ProgressDrawable()
|
||||
progressDrawable.setColor(themeColor)
|
||||
mBinding.refreshHeader.progressView.setImageDrawable(progressDrawable)
|
||||
}
|
||||
|
||||
private fun initTitleTab() {
|
||||
val tagList = arrayListOf("发现新朋友", "组队开黑")
|
||||
mFragmentsBottom.add(RoomNewFriendsFragment.newInstance())
|
||||
mFragmentsBottom.add(HomePlayFragment.newInstance())
|
||||
val commonNavigator = CommonNavigator(context)
|
||||
commonNavigator.setTitleWrapContent(true)
|
||||
val magicIndicatorAdapter = MainMagicIndicatorAdapter(context, tagList)
|
||||
magicIndicatorAdapter.setResId(R.drawable.ic_home_indicator_center)
|
||||
magicIndicatorAdapter.textSize = 16
|
||||
magicIndicatorAdapter.minScale = 0.85f
|
||||
magicIndicatorAdapter.setOnItemSelectListener(this)
|
||||
commonNavigator.adapter = magicIndicatorAdapter
|
||||
mBinding.magicIndicator.navigator = commonNavigator
|
||||
commonNavigator.titleContainer.showDividers = LinearLayout.SHOW_DIVIDER_MIDDLE
|
||||
mBinding.viewPager.offscreenPageLimit = 5
|
||||
mBinding.viewPager.adapter =
|
||||
RoomVPAdapter(childFragmentManager, mFragmentsBottom)
|
||||
ViewPagerHelper.bind(mBinding.magicIndicator, mBinding.viewPager)
|
||||
mBinding.viewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
|
||||
override fun onPageScrolled(
|
||||
position: Int,
|
||||
positionOffset: Float,
|
||||
positionOffsetPixels: Int
|
||||
) {
|
||||
}
|
||||
|
||||
override fun onPageSelected(position: Int) {
|
||||
mBinding.tvNewRefresh.isVisible = position == 0
|
||||
mBinding.tvNewFilter.isVisible = position == 0
|
||||
}
|
||||
|
||||
override fun onPageScrollStateChanged(state: Int) {
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
private fun initSingleAnchor() {
|
||||
singleAnchorAdapter = HomeSingleAnchorAdapter()
|
||||
mBinding.rvSingleAnchor.adapter = singleAnchorAdapter
|
||||
val layoutManager =
|
||||
GridLayoutManager(requireContext(), 4, LinearLayoutManager.VERTICAL, false)
|
||||
mBinding.rvSingleAnchor.layoutManager = layoutManager
|
||||
homeViewModel.singleAnchorHomeLiveData.observe(this) {
|
||||
if (it.data.isNullOrEmpty()) {
|
||||
mBinding.llSingleAnchor.visibility = View.GONE
|
||||
mBinding.rvSingleAnchor.visibility = View.GONE
|
||||
} else {
|
||||
mBinding.llSingleAnchor.visibility = View.VISIBLE
|
||||
mBinding.rvSingleAnchor.visibility = View.VISIBLE
|
||||
}
|
||||
singleAnchorAdapter.setNewData(it.data)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onItemSelect(position: Int, view: TextView?) {
|
||||
if (mFragmentsBottom.isEmpty()) {
|
||||
return
|
||||
}
|
||||
mBinding.tvNewRefresh.isVisible = position == 0
|
||||
mBinding.tvNewFilter.isVisible = position == 0
|
||||
mBinding.viewPager.currentItem = position
|
||||
StatisticManager.Instance()
|
||||
.onEvent(StatisticsProtocol.EVENT_TJ_TABEXCHANGE, "用户切换tab次数,热门房间or组队开黑")
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onRefreshHomeDataEvent(event: RefreshHomeDataEvent?) {
|
||||
if (isResumed) {
|
||||
loadData()
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadData() {
|
||||
homeViewModel.getHomeResource()
|
||||
homeViewModel.getBannerInfo()
|
||||
//homeViewModel.getHomeSingleAnchorList()
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
disposable?.dispose()
|
||||
}
|
||||
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
EventBus.getDefault().register(this)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
EventBus.getDefault().unregister(this)
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -1,100 +0,0 @@
|
||||
package com.nnbc123.app.home.fragment
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.nnbc123.app.avroom.activity.AVRoomActivity
|
||||
import com.nnbc123.app.base.BaseViewBindingFragment
|
||||
import com.nnbc123.app.common.EmptyViewHelper
|
||||
import com.nnbc123.app.databinding.FragmentRoomCommonBinding
|
||||
import com.nnbc123.app.home.RoomCommonViewModel
|
||||
import com.nnbc123.app.home.adapter.RoomCommonAdapter
|
||||
import com.nnbc123.app.ui.utils.RVDelegate
|
||||
import com.nnbc123.core.home.bean.HomeRoomInfo
|
||||
import com.nnbc123.core.home.event.RefreshHomeDataEvent
|
||||
import com.nnbc123.core.statistic.StatisticManager
|
||||
import com.nnbc123.core.statistic.protocol.StatisticsProtocol
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
||||
class RoomCommonFragment : BaseViewBindingFragment<FragmentRoomCommonBinding>() {
|
||||
|
||||
companion object {
|
||||
fun newInstance(tabID: Int): RoomCommonFragment {
|
||||
val args = Bundle()
|
||||
args.putInt("tab_id", tabID)
|
||||
val fragment = RoomCommonFragment()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
|
||||
private val tabID: Int by lazy { arguments?.getInt("tab_id") ?: -1 }
|
||||
private var pageNum: Int = 1
|
||||
private val pageSize = 20
|
||||
|
||||
private lateinit var mAdapter: RoomCommonAdapter
|
||||
private lateinit var rvDelegate: RVDelegate<HomeRoomInfo>
|
||||
|
||||
private val roomCommonViewModel: RoomCommonViewModel by viewModels()
|
||||
|
||||
override fun init() {
|
||||
mAdapter = RoomCommonAdapter()
|
||||
rvDelegate = RVDelegate.Builder<HomeRoomInfo>()
|
||||
.setAdapter(mAdapter)
|
||||
.setLayoutManager(LinearLayoutManager(mContext))
|
||||
.setPageSize(20)
|
||||
.setEmptyView(EmptyViewHelper.createEmptyView(mContext, "暂无房间"))
|
||||
.setRefreshLayout(binding.refreshLayout)
|
||||
.setRecyclerView(binding.recyclerView)
|
||||
.build()
|
||||
mAdapter.setOnItemClickListener { _, _, position ->
|
||||
mAdapter.getItem(position)?.let {
|
||||
AVRoomActivity.start(context, it.roomUid)
|
||||
StatisticManager.Instance()
|
||||
.onEvent("tab${tabID}_success_room", "通过派对tab下面的房间,成功进房的统计")
|
||||
StatisticManager.Instance()
|
||||
.onEvent(StatisticsProtocol.EVENT_COMMON_TAB_ROOM_SUCCESS, "通用tab进入房间成功")
|
||||
}
|
||||
}
|
||||
mAdapter.setOnLoadMoreListener({
|
||||
loadData(false)
|
||||
}, binding.recyclerView)
|
||||
binding.refreshLayout.setOnRefreshListener {
|
||||
loadData(true)
|
||||
}
|
||||
roomCommonViewModel.commonRoomLiveData.observe(this) {
|
||||
rvDelegate.loadData(it)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
loadData(true)
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
fun loadData(isRefresh: Boolean) {
|
||||
binding.refreshLayout.isRefreshing = isRefresh
|
||||
pageNum = if (isRefresh) 1 else (pageNum + 1)
|
||||
roomCommonViewModel.getCommonRoom(tabID, pageNum, pageSize)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
EventBus.getDefault().register(this)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
EventBus.getDefault().unregister(this)
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onRefreshHomeDataEvent(event: RefreshHomeDataEvent?) {
|
||||
if (isResumed) loadData(true)
|
||||
}
|
||||
}
|
@@ -1,98 +0,0 @@
|
||||
package com.nnbc123.app.home.fragment
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.nnbc123.app.avroom.activity.AVRoomActivity
|
||||
import com.nnbc123.app.base.BaseViewBindingFragment
|
||||
import com.nnbc123.app.common.EmptyViewHelper
|
||||
import com.nnbc123.app.databinding.FragmentRoomGameBinding
|
||||
import com.nnbc123.app.home.HomeViewModel
|
||||
import com.nnbc123.app.home.adapter.RoomGameAdapter
|
||||
import com.nnbc123.app.ui.utils.RVDelegate
|
||||
import com.nnbc123.core.home.bean.HomeRoomInfo
|
||||
import com.nnbc123.core.home.event.RefreshHomeDataEvent
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
||||
class RoomGameFragment : BaseViewBindingFragment<FragmentRoomGameBinding>() {
|
||||
|
||||
companion object {
|
||||
fun newInstance(): RoomGameFragment {
|
||||
val args = Bundle()
|
||||
val fragment = RoomGameFragment()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
|
||||
private lateinit var roomHotAdapter: RoomGameAdapter
|
||||
private var page = 1
|
||||
private lateinit var rvDelegate: RVDelegate<HomeRoomInfo>
|
||||
private val pageSize = 20
|
||||
private val homeViewModel: HomeViewModel by activityViewModels()
|
||||
|
||||
override fun init() {
|
||||
roomHotAdapter = RoomGameAdapter()
|
||||
rvDelegate = RVDelegate.Builder<HomeRoomInfo>()
|
||||
.setAdapter(roomHotAdapter)
|
||||
.setRecyclerView(binding.recyclerView)
|
||||
.setEmptyView(EmptyViewHelper.createEmptyView(context, "暂无房间"))
|
||||
.setLayoutManager(LinearLayoutManager(mContext))
|
||||
.setRefreshLayout(binding.refreshLayout)
|
||||
.setPageSize(pageSize)
|
||||
.build()
|
||||
|
||||
roomHotAdapter.setOnLoadMoreListener({ loadData(false) }, binding.recyclerView)
|
||||
|
||||
binding.refreshLayout.setOnRefreshListener {
|
||||
loadData(true)
|
||||
}
|
||||
homeViewModel.gameRoomLiveData.observe(this) {
|
||||
rvDelegate.loadData(it)
|
||||
}
|
||||
|
||||
binding.tvMatch.setOnClickListener {
|
||||
homeViewModel.fastPickGameRoom()
|
||||
}
|
||||
|
||||
homeViewModel.pickRoomLiveData.observe(this) {
|
||||
it?.let {
|
||||
AVRoomActivity.start(mContext, it.uid)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
loadData(true)
|
||||
}
|
||||
|
||||
private fun loadData(isRefresh: Boolean) {
|
||||
|
||||
binding.refreshLayout.isRefreshing = isRefresh
|
||||
|
||||
if (isRefresh) {
|
||||
page = 1
|
||||
} else {
|
||||
page++
|
||||
}
|
||||
homeViewModel.getGameRoom(page, pageSize)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
EventBus.getDefault().register(this)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
EventBus.getDefault().unregister(this)
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onRefreshHomeDataEvent(event: RefreshHomeDataEvent?) {
|
||||
if (isResumed) loadData(true)
|
||||
}
|
||||
}
|
@@ -1,75 +0,0 @@
|
||||
package com.nnbc123.app.home.fragment
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.nnbc123.app.base.BaseViewBindingFragment
|
||||
import com.nnbc123.app.common.EmptyViewHelper
|
||||
import com.nnbc123.app.databinding.FragmentRoomHotBinding
|
||||
import com.nnbc123.app.home.HomeViewModel
|
||||
import com.nnbc123.app.home.adapter.RoomHotAdapter
|
||||
import com.nnbc123.app.ui.utils.RVDelegate
|
||||
import com.nnbc123.core.home.bean.HomeRoomInfo
|
||||
import com.nnbc123.core.home.event.RefreshHomeDataEvent
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
||||
|
||||
class RoomHotFragment : BaseViewBindingFragment<FragmentRoomHotBinding>() {
|
||||
|
||||
companion object {
|
||||
fun newInstance(): RoomHotFragment {
|
||||
val args = Bundle()
|
||||
val fragment = RoomHotFragment()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
|
||||
private lateinit var roomHotAdapter : RoomHotAdapter
|
||||
private lateinit var rvDelegate: RVDelegate<HomeRoomInfo>
|
||||
|
||||
private var page = 1
|
||||
private val pageSize = Int.MAX_VALUE
|
||||
private val homeViewModel: HomeViewModel by activityViewModels()
|
||||
|
||||
override fun init() {
|
||||
roomHotAdapter = RoomHotAdapter()
|
||||
rvDelegate = RVDelegate.Builder<HomeRoomInfo>()
|
||||
.setAdapter(roomHotAdapter)
|
||||
.setRecyclerView(binding.recyclerView)
|
||||
.setEmptyView(EmptyViewHelper.createEmptyView(context, "暂无房间"))
|
||||
.setLayoutManager(LinearLayoutManager(mContext))
|
||||
.setPageSize(pageSize)
|
||||
.build()
|
||||
|
||||
homeViewModel.hotRoomLiveData.observe(this) {
|
||||
rvDelegate.loadData(it)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
loadData(true)
|
||||
}
|
||||
|
||||
private fun loadData(isRefresh: Boolean) {
|
||||
homeViewModel.getHotRoom(page, pageSize)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
EventBus.getDefault().register(this)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
EventBus.getDefault().unregister(this)
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onRefreshHomeDataEvent(event: RefreshHomeDataEvent?) {
|
||||
if (isResumed) loadData(true)
|
||||
}
|
||||
}
|
@@ -1,135 +0,0 @@
|
||||
package com.nnbc123.app.home.fragment
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.core.view.isGone
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.google.android.material.appbar.AppBarLayout
|
||||
import com.nnbc123.app.base.BaseViewBindingFragment
|
||||
import com.nnbc123.app.common.EmptyViewHelper
|
||||
import com.nnbc123.app.databinding.FragmentRoomLikeBinding
|
||||
import com.nnbc123.app.home.HomeViewModel
|
||||
import com.nnbc123.app.home.adapter.HomeConcernsAdapter
|
||||
import com.nnbc123.app.home.adapter.RoomLikeAdapter
|
||||
import com.nnbc123.app.ui.relation.AttentionListActivity
|
||||
import com.nnbc123.app.ui.utils.RVDelegate
|
||||
import com.nnbc123.core.home.bean.HomeRoomInfo
|
||||
import com.nnbc123.core.home.event.RefreshHomeDataEvent
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
||||
|
||||
class RoomLikeFragment : BaseViewBindingFragment<FragmentRoomLikeBinding>() {
|
||||
|
||||
companion object {
|
||||
fun newInstance(): RoomLikeFragment {
|
||||
val args = Bundle()
|
||||
val fragment = RoomLikeFragment()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
|
||||
private lateinit var concernsAdapter : HomeConcernsAdapter
|
||||
private lateinit var likeRvDelegate: RVDelegate<HomeRoomInfo>
|
||||
|
||||
private lateinit var mAdapter : RoomLikeAdapter
|
||||
private lateinit var rvDelegate: RVDelegate<HomeRoomInfo>
|
||||
private var pageNum = 1
|
||||
private val pageSize = 20
|
||||
private val homeViewModel: HomeViewModel by activityViewModels()
|
||||
|
||||
override fun init() {
|
||||
|
||||
binding.appBarLayout.addOnOffsetChangedListener(
|
||||
AppBarLayout.OnOffsetChangedListener { _, verticalOffset ->
|
||||
binding.refreshLayout.isEnabled = verticalOffset == 0
|
||||
})
|
||||
concernsAdapter = HomeConcernsAdapter()
|
||||
likeRvDelegate = RVDelegate.Builder<HomeRoomInfo>()
|
||||
.setAdapter(concernsAdapter)
|
||||
.setRecyclerView(binding.rvLike)
|
||||
.setLayoutManager(GridLayoutManager(mContext,5, GridLayoutManager.VERTICAL, false))
|
||||
.build()
|
||||
|
||||
homeViewModel.concernsLiveData.observe(this) {
|
||||
likeRvDelegate.setNewData(it)
|
||||
val isGone = concernsAdapter.data.isNullOrEmpty()
|
||||
binding.tvMore.isGone = isGone
|
||||
binding.tvLike.isGone = isGone
|
||||
binding.rvLike.isGone = isGone
|
||||
}
|
||||
mAdapter = RoomLikeAdapter()
|
||||
rvDelegate = RVDelegate.Builder<HomeRoomInfo>()
|
||||
.setAdapter(mAdapter)
|
||||
.setLayoutManager(LinearLayoutManager(mContext))
|
||||
.setPageSize(pageSize)
|
||||
.setRefreshLayout(binding.refreshLayout)
|
||||
.setEmptyView(EmptyViewHelper.createEmptyView(mContext, "暂无收藏"))
|
||||
.setRecyclerView(binding.rvCollect)
|
||||
.build()
|
||||
|
||||
homeViewModel.collectLiveData.observe(this) {
|
||||
rvDelegate.loadData(it)
|
||||
}
|
||||
|
||||
mAdapter.setOnLoadMoreListener({
|
||||
loadData(false)
|
||||
}, binding.rvCollect)
|
||||
|
||||
binding.refreshLayout.setOnRefreshListener {
|
||||
loadData(true)
|
||||
}
|
||||
|
||||
homeViewModel.emptyLiveData.observe(this) {
|
||||
it?.let {
|
||||
binding.refreshLayout.isRefreshing = false
|
||||
binding.clEmpty.isVisible = it
|
||||
binding.coordinatorLayout.isVisible = !it
|
||||
}
|
||||
}
|
||||
|
||||
binding.tvGoPlay.setOnClickListener {
|
||||
(parentFragment as PartyFragment).onItemSelect(1, null)
|
||||
}
|
||||
|
||||
binding.tvMore.setOnClickListener {
|
||||
AttentionListActivity.start(context)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
loadData(true)
|
||||
}
|
||||
|
||||
private fun loadData(isRefresh: Boolean) {
|
||||
if (isRefresh) {
|
||||
pageNum = 1
|
||||
binding.refreshLayout.isRefreshing = true
|
||||
} else {
|
||||
pageNum++
|
||||
}
|
||||
homeViewModel.getCollectRoom(pageNum, pageSize)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
EventBus.getDefault().register(this)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
EventBus.getDefault().unregister(this)
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onRefreshHomeDataEvent(event: RefreshHomeDataEvent?) {
|
||||
if (isResumed) loadData(true)
|
||||
}
|
||||
|
||||
}
|
@@ -1,45 +0,0 @@
|
||||
package com.nnbc123.app.home.fragment
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.nnbc123.app.base.BaseViewBindingFragment
|
||||
import com.nnbc123.app.common.EmptyViewHelper
|
||||
import com.nnbc123.app.databinding.FragmentRoomHotBinding
|
||||
import com.nnbc123.app.home.HomeViewModel
|
||||
import com.nnbc123.app.home.adapter.RoomNewFriendsAdapter
|
||||
import com.nnbc123.app.ui.utils.RVDelegate
|
||||
import com.nnbc123.core.user.bean.UserInfo
|
||||
|
||||
|
||||
class RoomNewFriendsFragment : BaseViewBindingFragment<FragmentRoomHotBinding>() {
|
||||
|
||||
companion object {
|
||||
fun newInstance(): RoomNewFriendsFragment {
|
||||
val args = Bundle()
|
||||
val fragment = RoomNewFriendsFragment()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
|
||||
private lateinit var roomHotAdapter: RoomNewFriendsAdapter
|
||||
private lateinit var rvDelegate: RVDelegate<UserInfo>
|
||||
|
||||
private val homeViewModel: HomeViewModel by activityViewModels()
|
||||
|
||||
override fun init() {
|
||||
roomHotAdapter = RoomNewFriendsAdapter()
|
||||
rvDelegate = RVDelegate.Builder<UserInfo>()
|
||||
.setAdapter(roomHotAdapter)
|
||||
.setRecyclerView(binding.recyclerView)
|
||||
.setEmptyView(EmptyViewHelper.createEmptyView(context, "暂无新朋友"))
|
||||
.setLayoutManager(LinearLayoutManager(mContext))
|
||||
.build()
|
||||
homeViewModel.getNewFriendList()
|
||||
homeViewModel.newFriendLiveData.observe(this) {
|
||||
rvDelegate.loadData(it)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,86 +0,0 @@
|
||||
package com.nnbc123.app.home.fragment
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.nnbc123.app.base.BaseViewBindingFragment
|
||||
import com.nnbc123.app.common.EmptyViewHelper
|
||||
import com.nnbc123.app.databinding.FragmentRoomSingleBinding
|
||||
import com.nnbc123.app.home.RoomSingleViewModel
|
||||
import com.nnbc123.app.home.adapter.MoreSingleAnchorAdapter
|
||||
import com.nnbc123.app.ui.utils.RVDelegate
|
||||
import com.nnbc123.core.home.bean.HomeRoomInfo
|
||||
import com.nnbc123.core.home.event.RefreshHomeDataEvent
|
||||
import com.nnbc123.core.utils.CurrentTimeUtils
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
||||
|
||||
class RoomSingleFragment : BaseViewBindingFragment<FragmentRoomSingleBinding>() {
|
||||
|
||||
companion object {
|
||||
fun newInstance(id: Long?): RoomSingleFragment {
|
||||
val args = Bundle()
|
||||
if (id != null) {
|
||||
args.putLong("id", id)
|
||||
}
|
||||
val fragment = RoomSingleFragment()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
|
||||
private lateinit var adapter: MoreSingleAnchorAdapter
|
||||
private lateinit var rvDelegate: RVDelegate<HomeRoomInfo>
|
||||
|
||||
private val pageSize = Int.MAX_VALUE
|
||||
private val roomSingleViewModel: RoomSingleViewModel by viewModels()
|
||||
|
||||
private var lastLoadDataTime = 0L
|
||||
|
||||
private val id: Long? by lazy { requireArguments().getLong("id") }
|
||||
|
||||
override fun init() {
|
||||
adapter = MoreSingleAnchorAdapter()
|
||||
rvDelegate = RVDelegate.Builder<HomeRoomInfo>()
|
||||
.setAdapter(adapter)
|
||||
.setRecyclerView(binding.recyclerView)
|
||||
.setRefreshLayout(binding.refreshLayout)
|
||||
.setEmptyView(EmptyViewHelper.createEmptyView(context, "暂无房间"))
|
||||
.setLayoutManager(GridLayoutManager(mContext, 2))
|
||||
.setPageSize(pageSize)
|
||||
.build()
|
||||
binding.refreshLayout.setOnRefreshListener { loadData(true) }
|
||||
roomSingleViewModel.singleAnchorMoreLiveData.observe(this) {
|
||||
rvDelegate.loadData(it)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
loadData(false)
|
||||
}
|
||||
|
||||
private fun loadData(isForce: Boolean) {
|
||||
if (!isForce && CurrentTimeUtils.getCurrentTime() - lastLoadDataTime < 15 * 1000) return
|
||||
lastLoadDataTime = CurrentTimeUtils.getCurrentTime()
|
||||
binding.refreshLayout.isRefreshing = true
|
||||
roomSingleViewModel.getMoreSingleAnchorList(id)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
EventBus.getDefault().register(this)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
EventBus.getDefault().unregister(this)
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onRefreshHomeDataEvent(event: RefreshHomeDataEvent?) {
|
||||
if (isResumed) loadData(false)
|
||||
}
|
||||
}
|
@@ -0,0 +1,114 @@
|
||||
package com.nnbc123.app.home.fragment.home
|
||||
|
||||
import android.graphics.Color
|
||||
import android.view.Gravity
|
||||
import android.widget.LinearLayout
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import androidx.viewpager2.widget.ViewPager2.OnPageChangeCallback
|
||||
import com.chuhai.utils.ktx.singleClick
|
||||
import com.gyf.immersionbar.ImmersionBar
|
||||
import com.nnbc123.app.R
|
||||
import com.nnbc123.app.avroom.adapter.RoomVPAdapter
|
||||
import com.nnbc123.app.base.BaseBindingFragment
|
||||
import com.nnbc123.app.databinding.HomeFragmentBinding
|
||||
import com.nnbc123.app.home.adapter.HomeMagicIndicatorAdapter
|
||||
import com.nnbc123.app.home.fragment.home.friends.FriendsFragment
|
||||
import com.nnbc123.app.home.fragment.home.party.PartyFragment
|
||||
import com.nnbc123.app.home.helper.OpenRoomHelper
|
||||
import com.nnbc123.app.ui.search.SearchActivity
|
||||
import com.nnbc123.app.ui.webview.CommonWebViewActivity
|
||||
import com.nnbc123.app.ui.widget.magicindicator.ViewPagerHelper
|
||||
import com.nnbc123.app.ui.widget.magicindicator.buildins.commonnavigator.CommonNavigator
|
||||
import com.nnbc123.core.DemoCache
|
||||
import com.nnbc123.core.UriProvider
|
||||
import com.nnbc123.core.initial.InitialModel
|
||||
import com.nnbc123.core.statistic.StatisticManager
|
||||
import com.nnbc123.core.statistic.protocol.StatisticsProtocol
|
||||
import com.nnbc123.library.annatation.ActLayoutRes
|
||||
|
||||
/**
|
||||
* Created by Max on 2023/12/18 17:51
|
||||
* Desc:首页
|
||||
**/
|
||||
@ActLayoutRes(R.layout.home_fragment)
|
||||
class HomeFragment : BaseBindingFragment<HomeFragmentBinding>() {
|
||||
override fun initiate() {
|
||||
ImmersionBar.with(this).titleBarMarginTop(mBinding.vTitleBarTop).init()
|
||||
initTab()
|
||||
initEvent()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (!isHidden) {
|
||||
StatisticManager.Instance().onEvent(StatisticsProtocol.EVENT_HOMEPAGE_SHOW, "首页")
|
||||
}
|
||||
}
|
||||
|
||||
private fun initEvent() {
|
||||
mBinding.ivMyRoom.singleClick {
|
||||
StatisticManager.Instance()
|
||||
.onEvent(StatisticsProtocol.EVENT_HOMEPAGE_TOP_MY_ROOM_CLICK)
|
||||
OpenRoomHelper.openRoom(baseActivity)
|
||||
}
|
||||
|
||||
mBinding.ivRanking.singleClick {
|
||||
StatisticManager.Instance()
|
||||
.onEvent(StatisticsProtocol.EVENT_HOMEPAGE_TOP_RANK_CLICK)
|
||||
CommonWebViewActivity.start(mContext, UriProvider.getRanking())
|
||||
}
|
||||
|
||||
mBinding.tvSearch.singleClick {
|
||||
StatisticManager.Instance().onEvent(StatisticsProtocol.EVENT_HOMEPAGE_TOP_SEARCH_CLICK)
|
||||
SearchActivity.start(activity)
|
||||
//为啥触发条件这么恶心 我也不知道啊
|
||||
if (DemoCache.readAnchorCardView() == 0) {
|
||||
DemoCache.saveAnchorCardView(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun initTab() {
|
||||
val tagList = arrayListOf("派对", "交友")
|
||||
val fragmentList = listOf(PartyFragment(), FriendsFragment())
|
||||
val commonNavigator = CommonNavigator(context)
|
||||
commonNavigator.setTitleWrapContent(true)
|
||||
commonNavigator.setTitleGravity(Gravity.CENTER_VERTICAL)
|
||||
val magicIndicatorAdapter = HomeMagicIndicatorAdapter(context, tagList)
|
||||
magicIndicatorAdapter.setOnItemSelectListener { position, view ->
|
||||
mBinding.viewPager.currentItem = position
|
||||
}
|
||||
magicIndicatorAdapter.normalColor = Color.parseColor("#696D7A")
|
||||
magicIndicatorAdapter.selectedColor = Color.parseColor("#2B2D33")
|
||||
commonNavigator.adapter = magicIndicatorAdapter
|
||||
mBinding.magicIndicator.navigator = commonNavigator
|
||||
commonNavigator.titleContainer.showDividers = LinearLayout.SHOW_DIVIDER_MIDDLE
|
||||
mBinding.viewPager.offscreenPageLimit = 5
|
||||
mBinding.viewPager.adapter =
|
||||
RoomVPAdapter(childFragmentManager, fragmentList)
|
||||
ViewPagerHelper.bind(mBinding.magicIndicator, mBinding.viewPager)
|
||||
mBinding.viewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
|
||||
override fun onPageScrolled(
|
||||
position: Int,
|
||||
positionOffset: Float,
|
||||
positionOffsetPixels: Int
|
||||
) {
|
||||
}
|
||||
|
||||
override fun onPageSelected(position: Int) {
|
||||
StatisticManager.Instance()
|
||||
.onEvent(StatisticsProtocol.EVENT_HOMEPAGE_TOP_TBA_CLICK, "${position + 1}")
|
||||
}
|
||||
|
||||
override fun onPageScrollStateChanged(state: Int) {
|
||||
}
|
||||
|
||||
})
|
||||
InitialModel.get().cacheInitInfo?.defaultTab?.let {
|
||||
val tab = it - 1
|
||||
if (tab >= 0 && tab < tagList.size) {
|
||||
mBinding.viewPager.currentItem = tab
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,236 @@
|
||||
package com.nnbc123.app.home.fragment.home.friends
|
||||
|
||||
import android.view.Gravity
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import com.chuhai.utils.ktx.singleClick
|
||||
import com.nnbc123.app.R
|
||||
import com.nnbc123.app.avroom.activity.AVRoomActivity
|
||||
import com.nnbc123.app.base.BaseBindingFragment
|
||||
import com.nnbc123.app.common.widget.dialog.DialogManager
|
||||
import com.nnbc123.app.databinding.HomeFriendsFragmentBinding
|
||||
import com.nnbc123.app.home.FriendsViewModel
|
||||
import com.nnbc123.app.home.HomeViewModel
|
||||
import com.nnbc123.app.home.adapter.HomeFriendsGameTabAdapter
|
||||
import com.nnbc123.app.home.dialog.RecommendRoomDialog
|
||||
import com.nnbc123.app.ui.im.avtivity.NimP2PMessageActivity
|
||||
import com.nnbc123.app.ui.utils.load
|
||||
import com.nnbc123.app.ui.webview.CommonWebViewActivity
|
||||
import com.nnbc123.app.ui.widget.NewFriendsFilterWindow
|
||||
import com.nnbc123.core.UriProvider
|
||||
import com.nnbc123.core.bean.response.observeResult
|
||||
import com.nnbc123.core.pay.PayModel
|
||||
import com.nnbc123.core.statistic.StatisticManager
|
||||
import com.nnbc123.core.statistic.protocol.StatisticsProtocol
|
||||
import com.nnbc123.core.utils.net.ServerException
|
||||
import com.nnbc123.library.annatation.ActLayoutRes
|
||||
import com.scwang.smartrefresh.layout.listener.OnRefreshListener
|
||||
|
||||
/**
|
||||
* Created by Max on 2023/12/18 17:59
|
||||
* Desc:交友
|
||||
**/
|
||||
|
||||
@ActLayoutRes(R.layout.home_friends_fragment)
|
||||
class FriendsFragment : BaseBindingFragment<HomeFriendsFragmentBinding>() {
|
||||
|
||||
private val homeViewModel: HomeViewModel by activityViewModels()
|
||||
private val viewModel: FriendsViewModel by activityViewModels()
|
||||
|
||||
private val tabAdapter = HomeFriendsGameTabAdapter()
|
||||
|
||||
// 过滤条件:性别
|
||||
private var filterGender: Int? = null
|
||||
|
||||
// 过滤条件:游戏ID
|
||||
private val filterGameId: Long? get() = tabAdapter.selectGameId
|
||||
|
||||
private var genderPopup: NewFriendsFilterWindow? = null
|
||||
|
||||
override fun initiate() {
|
||||
initResource()
|
||||
initFilterTab()
|
||||
mBinding.tvGender.singleClick {
|
||||
showFilterGender()
|
||||
}
|
||||
mBinding.tvRefresh.singleClick {
|
||||
viewModel.getNewFriendList(filterGender, filterGameId)
|
||||
}
|
||||
mBinding.refreshLayout.isEnableLoadmore = false
|
||||
mBinding.refreshLayout.isEnableOverScrollBounce = false
|
||||
mBinding.refreshLayout.setOnRefreshListener { view ->
|
||||
mBinding.refreshLayout.finishRefresh()
|
||||
loadData(true)
|
||||
childFragmentManager.fragments.forEach {
|
||||
if (it is OnRefreshListener) {
|
||||
it.onRefresh(view)
|
||||
}
|
||||
}
|
||||
}
|
||||
childFragmentManager
|
||||
.beginTransaction()
|
||||
.replace(R.id.fragment_container_view, FriendsListFragment())
|
||||
.commitAllowingStateLoss()
|
||||
}
|
||||
|
||||
private fun initFilterTab() {
|
||||
mBinding.rvTab.adapter = tabAdapter
|
||||
tabAdapter.setOnItemClickListener { adapter, view, position ->
|
||||
tabAdapter.selectItem(position)
|
||||
refreshListData()
|
||||
}
|
||||
viewModel.gameTabLiveData.observe(viewLifecycleOwner)
|
||||
{
|
||||
if (!it.isNullOrEmpty()) {
|
||||
tabAdapter.setNewData(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun initResource() {
|
||||
mBinding.ivResourceMatch.singleClick {
|
||||
StatisticManager.Instance().onEvent(StatisticsProtocol.EVENT_HOMEPAGE_TOP_MATCH_CLICK)
|
||||
dialogManager.showProgressDialog(mContext)
|
||||
viewModel.getHomeChatPick()
|
||||
}
|
||||
|
||||
viewModel.resourceJumpLiveData.observeResult(this, success = {
|
||||
dialogManager.dismissDialog()
|
||||
it?.let {
|
||||
if (it.isPick) {
|
||||
AVRoomActivity.start(context, it.uid)
|
||||
} else {
|
||||
RecommendRoomDialog.newInstance(it).show(context)
|
||||
}
|
||||
}
|
||||
}, failed = {
|
||||
dialogManager.dismissDialog()
|
||||
if ((it as? ServerException)?.code == PayModel.NOT_REAL_NAME_BEFORE_CHARGING) {
|
||||
dialogManager.showTipsDialog(getString(R.string.tips_need_to_certification),
|
||||
getString(R.string.go_to_certification),
|
||||
object : DialogManager.AbsOkDialogListener() {
|
||||
override fun onOk() {
|
||||
// 跳去实名认证页面
|
||||
CommonWebViewActivity.start(
|
||||
this@FriendsFragment.context,
|
||||
UriProvider.getTutuRealNamePage()
|
||||
)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
toast(it.message)
|
||||
}
|
||||
})
|
||||
|
||||
viewModel.homeChatPickLiveData.observe(viewLifecycleOwner) {
|
||||
dialogManager.dismissDialog()
|
||||
it?.let {
|
||||
if (it.isNotEmpty()) {
|
||||
NimP2PMessageActivity.start(context, it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
homeViewModel.resourceLiveData.observe(this) {
|
||||
// 资源位5
|
||||
it.getOrNull(4)?.let { item ->
|
||||
mBinding.groupResource.isVisible = true
|
||||
mBinding.ivResource0.load(item.icon)
|
||||
mBinding.ivResource0.singleClick {
|
||||
StatisticManager.Instance().onEvent(
|
||||
StatisticsProtocol.EVENT_HOMEPAGE_TOP_RESOURCE_CLICK,
|
||||
"E"
|
||||
)
|
||||
when (item.resourceType) {
|
||||
5 -> {
|
||||
CommonWebViewActivity.start(context, item.resourceContent)
|
||||
}
|
||||
|
||||
else -> {
|
||||
dialogManager.showProgressDialog(mContext)
|
||||
viewModel.getResourceJumpInfo(item.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showFilterGender() {
|
||||
genderPopup = NewFriendsFilterWindow(
|
||||
mContext,
|
||||
mBinding.tvGender.text.toString()
|
||||
).apply {
|
||||
setOnClickListener {
|
||||
dismiss()
|
||||
when (it.id) {
|
||||
R.id.tv_all -> {
|
||||
updateGender(null)
|
||||
refreshListData()
|
||||
}
|
||||
|
||||
R.id.tv_man -> {
|
||||
updateGender(1)
|
||||
refreshListData()
|
||||
}
|
||||
|
||||
R.id.tv_woman -> {
|
||||
updateGender(2)
|
||||
refreshListData()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
genderPopup?.show(mBinding.tvGender, Gravity.BOTTOM)
|
||||
}
|
||||
|
||||
private fun updateGender(gender: Int?) {
|
||||
filterGender = gender
|
||||
when (gender) {
|
||||
1 -> {
|
||||
mBinding.tvGender.text = "男生"
|
||||
}
|
||||
|
||||
2 -> {
|
||||
mBinding.tvGender.text = "女生"
|
||||
}
|
||||
|
||||
else -> {
|
||||
mBinding.tvGender.text = "全部"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
loadData(false)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
if (genderPopup?.isShowing == true) {
|
||||
genderPopup?.dismiss()
|
||||
genderPopup = null
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadData(resetFilter: Boolean) {
|
||||
if (resetFilter) {
|
||||
// 重置条件
|
||||
updateGender(null)
|
||||
tabAdapter.selectItem(null)
|
||||
}
|
||||
if (viewModel.gameTabLiveData.value.isNullOrEmpty()) {
|
||||
viewModel.getHomeGameTab()
|
||||
}
|
||||
if (homeViewModel.resourceLiveData.value.isNullOrEmpty()) {
|
||||
// 和派对页共用数据了,派对页会刷新,这里不需要再刷新了
|
||||
homeViewModel.getHomeResource()
|
||||
}
|
||||
refreshListData()
|
||||
}
|
||||
|
||||
private fun refreshListData() {
|
||||
viewModel.getNewFriendList(filterGender, filterGameId)
|
||||
}
|
||||
}
|
@@ -0,0 +1,134 @@
|
||||
package com.nnbc123.app.home.fragment.home.friends
|
||||
|
||||
import android.graphics.Rect
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.chuhai.utils.UiUtils
|
||||
import com.nnbc123.app.R
|
||||
import com.nnbc123.app.base.BaseBindingFragment
|
||||
import com.nnbc123.app.databinding.HomeFriendsListFragmentBinding
|
||||
import com.nnbc123.app.home.FriendsViewModel
|
||||
import com.nnbc123.app.home.adapter.HomeFriendsUserAdapter
|
||||
import com.nnbc123.app.ui.user.UserInfoActivity
|
||||
import com.nnbc123.app.ui.utils.RVDelegate
|
||||
import com.nnbc123.core.statistic.StatisticManager
|
||||
import com.nnbc123.core.statistic.protocol.StatisticsProtocol
|
||||
import com.nnbc123.core.user.bean.UserInfo
|
||||
import com.nnbc123.library.annatation.ActLayoutRes
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout
|
||||
import com.scwang.smartrefresh.layout.listener.OnRefreshListener
|
||||
|
||||
/**
|
||||
* Created by Max on 2023/12/18 19:35
|
||||
* Desc:
|
||||
**/
|
||||
@ActLayoutRes(R.layout.home_friends_list_fragment)
|
||||
class FriendsListFragment : BaseBindingFragment<HomeFriendsListFragmentBinding>(),
|
||||
OnRefreshListener {
|
||||
private val adapter = HomeFriendsUserAdapter()
|
||||
private val viewModel: FriendsViewModel by activityViewModels()
|
||||
private var rvDelegate: RVDelegate<UserInfo>? = null
|
||||
private var headerEmptyView: View? = null
|
||||
private val recommendTitleView get() = headerEmptyView?.findViewById<View>(R.id.layout_title)
|
||||
|
||||
override fun initiate() {
|
||||
initView()
|
||||
initEvent()
|
||||
initObserve()
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
val spanCount = 2
|
||||
val listLeftRightPadding = UiUtils.dip2px(15f)
|
||||
val itemLeftRightMargin = UiUtils.dip2px(4.5f)
|
||||
mBinding.recyclerView.addItemDecoration(object : RecyclerView.ItemDecoration() {
|
||||
override fun getItemOffsets(
|
||||
outRect: Rect,
|
||||
view: View,
|
||||
parent: RecyclerView,
|
||||
state: RecyclerView.State
|
||||
) {
|
||||
super.getItemOffsets(outRect, view, parent, state)
|
||||
val pos = parent.getChildAdapterPosition(view) - adapter.headerLayoutCount
|
||||
val remainder = pos % spanCount
|
||||
if (pos < 0) {
|
||||
outRect.set(0, 0, 0, 0)
|
||||
} else if (remainder == 0) {
|
||||
// 第一列
|
||||
outRect.set(listLeftRightPadding, 0, itemLeftRightMargin, 0)
|
||||
} else if (remainder == (spanCount - 1)) {
|
||||
// 最后一列
|
||||
outRect.set(itemLeftRightMargin, 0, listLeftRightPadding, 0)
|
||||
} else {
|
||||
// 中间
|
||||
outRect.set(itemLeftRightMargin, 0, itemLeftRightMargin, 0)
|
||||
}
|
||||
}
|
||||
})
|
||||
rvDelegate = RVDelegate.Builder<UserInfo>()
|
||||
.setAdapter(adapter)
|
||||
.setRecyclerView(mBinding.recyclerView)
|
||||
.setLayoutManager(GridLayoutManager(mContext, spanCount))
|
||||
.build()
|
||||
initEmptyView()
|
||||
}
|
||||
|
||||
private fun initEmptyView() {
|
||||
headerEmptyView = LayoutInflater.from(requireContext())
|
||||
.inflate(R.layout.home_friends_list_item_empty, null)
|
||||
}
|
||||
|
||||
private fun initEvent() {
|
||||
adapter.setOnItemClickListener { adapter, view, position ->
|
||||
(adapter.getItem(position) as? UserInfo)?.let { item ->
|
||||
StatisticManager.Instance().onEvent(
|
||||
StatisticsProtocol.EVENT_HOMEPAGE_MORE_GAME_USER_CLICK,
|
||||
item.uid.toString()
|
||||
)
|
||||
UserInfoActivity.Companion.start(mContext, item.uid)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun initObserve() {
|
||||
viewModel.newFriendLiveData.observe(this) {
|
||||
if (it.data.isNullOrEmpty()) {
|
||||
if (adapter.headerLayoutCount == 0) {
|
||||
adapter.addHeaderView(headerEmptyView)
|
||||
adapter.headerLayout.clipChildren = false
|
||||
}
|
||||
val list = viewModel.friendRecommendModeLiveData.value?.data?.toMutableList()
|
||||
recommendTitleView?.isVisible = !list.isNullOrEmpty()
|
||||
adapter.setNewData(list)
|
||||
} else {
|
||||
adapter.removeAllHeaderView()
|
||||
rvDelegate?.loadData(it)
|
||||
}
|
||||
}
|
||||
viewModel.friendRecommendModeLiveData.observe(this) {
|
||||
if (adapter.headerLayoutCount != 0) {
|
||||
recommendTitleView?.isVisible = !it.data.isNullOrEmpty()
|
||||
adapter.setNewData(it.data?.toMutableList())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (viewModel.friendRecommendModeLiveData.value?.data.isNullOrEmpty()) {
|
||||
viewModel.getFriendRecommendMore()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onRefresh(refreshlayout: RefreshLayout?) {
|
||||
if (isVisible && lifecycle.currentState.isAtLeast(Lifecycle.State.RESUMED)) {
|
||||
// 刷新下更多推荐
|
||||
viewModel.getFriendRecommendMore()
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,207 @@
|
||||
package com.nnbc123.app.home.fragment.home.party
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.viewpager2.widget.ViewPager2
|
||||
import com.chuhai.utils.ktx.singleClick
|
||||
import com.nnbc123.app.R
|
||||
import com.nnbc123.app.avroom.activity.AVRoomActivity
|
||||
import com.nnbc123.app.base.BaseActivity
|
||||
import com.nnbc123.app.base.BaseBindingFragment
|
||||
import com.nnbc123.app.common.widget.dialog.DialogManager
|
||||
import com.nnbc123.app.databinding.HomePartyFragmentBinding
|
||||
import com.nnbc123.app.home.HomeViewModel
|
||||
import com.nnbc123.app.game_room.GameRoomActivity
|
||||
import com.nnbc123.app.home.PartyViewModel
|
||||
import com.nnbc123.app.home.adapter.HomePartyMessageAdapter
|
||||
import com.nnbc123.app.home.dialog.RecommendRoomDialog
|
||||
import com.nnbc123.app.home.helper.BannerHelper
|
||||
import com.nnbc123.app.ui.utils.load
|
||||
import com.nnbc123.app.ui.webview.CommonWebViewActivity
|
||||
import com.nnbc123.core.UriProvider
|
||||
import com.nnbc123.core.bean.response.observeResult
|
||||
import com.nnbc123.core.home.bean.BannerInfo
|
||||
import com.nnbc123.core.home.event.RefreshHomeDataEvent
|
||||
import com.nnbc123.core.im.custom.bean.RouterType
|
||||
import com.nnbc123.core.pay.PayModel
|
||||
import com.nnbc123.core.statistic.StatisticManager
|
||||
import com.nnbc123.core.statistic.protocol.StatisticsProtocol
|
||||
import com.nnbc123.core.utils.net.ServerException
|
||||
import com.nnbc123.library.annatation.ActLayoutRes
|
||||
import com.nnbc123.library.utils.JavaUtil
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
||||
/**
|
||||
* Created by Max on 2023/12/18 17:58
|
||||
* Desc:派对
|
||||
**/
|
||||
@ActLayoutRes(R.layout.home_party_fragment)
|
||||
class PartyFragment : BaseBindingFragment<HomePartyFragmentBinding>() {
|
||||
|
||||
private val homeViewModel: HomeViewModel by activityViewModels()
|
||||
private val viewModel: PartyViewModel by activityViewModels()
|
||||
|
||||
//仅埋点使用,不影响业务逻辑
|
||||
private val abcArray = arrayOf("A", "B", "C", "D")
|
||||
private var currMatchClick = abcArray[0]
|
||||
|
||||
override fun initiate() {
|
||||
initResource()
|
||||
initHotMessage()
|
||||
initBanner()
|
||||
mBinding.refreshLayout.isEnableLoadmore = false
|
||||
mBinding.refreshLayout.isEnableOverScrollBounce = false
|
||||
mBinding.refreshLayout.setOnRefreshListener {
|
||||
mBinding.refreshLayout.finishRefresh()
|
||||
EventBus.getDefault().post(RefreshHomeDataEvent())
|
||||
}
|
||||
childFragmentManager
|
||||
.beginTransaction()
|
||||
.replace(R.id.fragment_container_view, PartyHotRoomFragment())
|
||||
.commitAllowingStateLoss()
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onRefreshHomeDataEvent(event: RefreshHomeDataEvent?) {
|
||||
if (isResumed) {
|
||||
loadData()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
loadData()
|
||||
}
|
||||
|
||||
private fun loadData() {
|
||||
homeViewModel.getHomeResource()
|
||||
viewModel.getBannerInfo()
|
||||
viewModel.getServiceGiftRecord()
|
||||
}
|
||||
|
||||
private fun initHotMessage() {
|
||||
val adapter = HomePartyMessageAdapter()
|
||||
adapter.clickListener = {
|
||||
StatisticManager.Instance().onEvent(
|
||||
StatisticsProtocol.EVENT_HOMEPAGE_INFORM_CLICK,
|
||||
it.roomUid.toString()
|
||||
)
|
||||
AVRoomActivity.start(mContext, it.roomUid)
|
||||
}
|
||||
mBinding.hotMessage.apply {
|
||||
setOrientation(ViewPager2.ORIENTATION_VERTICAL)
|
||||
setAdapter(adapter)
|
||||
registerLifecycleObserver(lifecycle)
|
||||
setUserInputEnabled(false)
|
||||
}.create()
|
||||
viewModel.giftServiceLiveData.observe(viewLifecycleOwner) {
|
||||
if (it.isSuccess && !it.data.isNullOrEmpty()) {
|
||||
mBinding.hotMessage.isVisible = true
|
||||
mBinding.hotMessage.refreshData(it.data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun initResource() {
|
||||
mBinding.ivResourceMore.singleClick {
|
||||
StatisticManager.Instance()
|
||||
.onEvent(StatisticsProtocol.EVENT_HOMEPAGE_TOP_MORE_ROOM_CLICK)
|
||||
GameRoomActivity.start(requireContext())
|
||||
}
|
||||
|
||||
homeViewModel.resourceLiveData.observe(this) {
|
||||
if (it.isNullOrEmpty()) {
|
||||
mBinding.groupResource.isVisible = false
|
||||
return@observe
|
||||
}
|
||||
mBinding.groupResource.isVisible = true
|
||||
val resourceViews = arrayOf(
|
||||
mBinding.ivResource0,
|
||||
mBinding.ivResource1,
|
||||
mBinding.ivResource2,
|
||||
mBinding.ivResource3
|
||||
)
|
||||
for (i in resourceViews.indices) {
|
||||
resourceViews[i].load(it[i].icon)
|
||||
resourceViews[i].singleClick { _ ->
|
||||
currMatchClick = abcArray[i]
|
||||
StatisticManager.Instance().onEvent(
|
||||
StatisticsProtocol.EVENT_HOMEPAGE_TOP_RESOURCE_CLICK,
|
||||
currMatchClick
|
||||
)
|
||||
when (it[i].resourceType) {
|
||||
5 -> {
|
||||
CommonWebViewActivity.start(context, it[i].resourceContent)
|
||||
}
|
||||
|
||||
else -> {
|
||||
dialogManager.showProgressDialog(mContext)
|
||||
viewModel.getResourceJumpInfo(it[i].id)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.resourceJumpLiveData.observeResult(this, success = {
|
||||
dialogManager.dismissDialog()
|
||||
it?.let {
|
||||
if (it.isPick) {
|
||||
AVRoomActivity.start(context, it.uid)
|
||||
} else {
|
||||
RecommendRoomDialog.newInstance(it).show(context)
|
||||
}
|
||||
}
|
||||
}, failed = {
|
||||
dialogManager.dismissDialog()
|
||||
if ((it as? ServerException)?.code == PayModel.NOT_REAL_NAME_BEFORE_CHARGING) {
|
||||
dialogManager.showTipsDialog(getString(R.string.tips_need_to_certification),
|
||||
getString(R.string.go_to_certification),
|
||||
object : DialogManager.AbsOkDialogListener() {
|
||||
override fun onOk() {
|
||||
// 跳去实名认证页面
|
||||
CommonWebViewActivity.start(
|
||||
this@PartyFragment.context,
|
||||
UriProvider.getTutuRealNamePage()
|
||||
)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
toast(it.message)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun initBanner() {
|
||||
viewModel.bannerLiveData.observe(this) {
|
||||
BannerHelper.setBanner(mBinding.rollView, it) { _, data ->
|
||||
var roomId: Long? = null
|
||||
if (data.skipType == BannerInfo.SKIP_TYPE_ROUTER) {
|
||||
if (JavaUtil.str2int(data.routerType) == RouterType.ROOM) {
|
||||
roomId = JavaUtil.str2long(data.routerValue)
|
||||
}
|
||||
} else if (data.skipType == BannerInfo.SKIP_TYP_CHAT_ROOM) {
|
||||
roomId = JavaUtil.str2long(data.skipUri)
|
||||
}
|
||||
if (roomId != null) {
|
||||
StatisticManager.Instance()
|
||||
.onEvent(StatisticsProtocol.EVENT_HOMEPAGE_BANNER_CLICK, roomId.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
EventBus.getDefault().register(this)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
EventBus.getDefault().unregister(this)
|
||||
}
|
||||
}
|
@@ -0,0 +1,75 @@
|
||||
package com.nnbc123.app.home.fragment.home.party
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.nnbc123.app.R
|
||||
import com.nnbc123.app.avroom.activity.AVRoomActivity
|
||||
import com.nnbc123.app.base.BaseBindingFragment
|
||||
import com.nnbc123.app.common.EmptyViewHelper
|
||||
import com.nnbc123.app.databinding.HomePartyRoomFragmentBinding
|
||||
import com.nnbc123.app.home.HomeViewModel
|
||||
import com.nnbc123.app.home.adapter.HomePartyRoomAdapter
|
||||
import com.nnbc123.app.ui.utils.RVDelegate
|
||||
import com.nnbc123.core.home.bean.HomeRoomInfo
|
||||
import com.nnbc123.core.home.event.RefreshHomeDataEvent
|
||||
import com.nnbc123.core.statistic.StatisticManager
|
||||
import com.nnbc123.core.statistic.protocol.StatisticsProtocol
|
||||
import com.nnbc123.library.annatation.ActLayoutRes
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
||||
/**
|
||||
* Created by Max on 2023/12/18 19:35
|
||||
* Desc:
|
||||
**/
|
||||
@ActLayoutRes(R.layout.home_party_room_fragment)
|
||||
class PartyHotRoomFragment : BaseBindingFragment<HomePartyRoomFragmentBinding>() {
|
||||
private val adapter = HomePartyRoomAdapter()
|
||||
private val homeViewModel: HomeViewModel by activityViewModels()
|
||||
override fun initiate() {
|
||||
val rvDelegate = RVDelegate.Builder<HomeRoomInfo>()
|
||||
.setAdapter(adapter)
|
||||
.setRecyclerView(mBinding.recyclerView)
|
||||
.setEmptyView(EmptyViewHelper.createEmptyView(context, "暂无数据"))
|
||||
.setLayoutManager(GridLayoutManager(context, 2))
|
||||
.build()
|
||||
adapter.setOnItemClickListener { _, _, position ->
|
||||
adapter.getItem(position)?.let {
|
||||
AVRoomActivity.start(context, it.uid)
|
||||
StatisticManager.Instance()
|
||||
.onEvent(StatisticsProtocol.EVENT_HOMEPAGE_ROOM_CLICK, it.uid.toString())
|
||||
}
|
||||
}
|
||||
homeViewModel.hotRoomLiveData.observe(this) {
|
||||
rvDelegate.loadData(it)
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
fun loadData(isRefresh: Boolean) {
|
||||
homeViewModel.getHotRoom(1, Int.MAX_VALUE)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
EventBus.getDefault().register(this)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
loadData(true)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
EventBus.getDefault().unregister(this)
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onRefreshHomeDataEvent(event: RefreshHomeDataEvent?) {
|
||||
if (isResumed) loadData(true)
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user