Compare commits
16 Commits
72802ef7be
...
cesi
| Author | SHA1 | Date | |
|---|---|---|---|
| bcdfe106c2 | |||
| e55effea1a | |||
| bba729f5d0 | |||
| 59eeb1415b | |||
| a0ecafbbd7 | |||
| ea82b59b0a | |||
| 407b21c33f | |||
| 5f573e607d | |||
| 1c54f0c072 | |||
| f12ed5ef84 | |||
| c446c7bb49 | |||
| 2551f7cfbc | |||
| 867435ee90 | |||
| fc544229fe | |||
| 4e0ea44f21 | |||
| a3255c39fb |
4
.idea/deploymentTargetSelector.xml
generated
@@ -4,10 +4,10 @@
|
|||||||
<selectionStates>
|
<selectionStates>
|
||||||
<SelectionState runConfigName="app">
|
<SelectionState runConfigName="app">
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
<option name="selectionMode" value="DROPDOWN" />
|
||||||
<DropdownSelection timestamp="2025-09-12T11:20:24.786143600Z">
|
<DropdownSelection timestamp="2025-09-18T12:45:46.137835600Z">
|
||||||
<Target type="DEFAULT_BOOT">
|
<Target type="DEFAULT_BOOT">
|
||||||
<handle>
|
<handle>
|
||||||
<DeviceId pluginId="Default" identifier="serial=emulator-5554;connection=d14b13d7" />
|
<DeviceId pluginId="PhysicalDevice" identifier="serial=6705124a" />
|
||||||
</handle>
|
</handle>
|
||||||
</Target>
|
</Target>
|
||||||
</DropdownSelection>
|
</DropdownSelection>
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ android {
|
|||||||
|
|
||||||
ndk {
|
ndk {
|
||||||
//设置支持的so库
|
//设置支持的so库
|
||||||
abiFilters 'arm64-v8a', 'armeabi'
|
// abiFilters 'arm64-v8a', 'armeabi','arm64'
|
||||||
// abiFilters 'armeabi-v7a', 'arm64-v8a'
|
abiFilters 'arm64-v8a','armeabi-v7a'
|
||||||
}
|
}
|
||||||
|
|
||||||
javaCompileOptions {
|
javaCompileOptions {
|
||||||
@@ -55,7 +55,7 @@ android {
|
|||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
minifyEnabled true
|
minifyEnabled false
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
signingConfig signingConfigs.release
|
signingConfig signingConfigs.release
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ android {
|
|||||||
|
|
||||||
debug {
|
debug {
|
||||||
debuggable true
|
debuggable true
|
||||||
minifyEnabled true
|
minifyEnabled false
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
signingConfig signingConfigs.debug
|
signingConfig signingConfigs.debug
|
||||||
|
|
||||||
|
|||||||
@@ -11,9 +11,9 @@
|
|||||||
"type": "SINGLE",
|
"type": "SINGLE",
|
||||||
"filters": [],
|
"filters": [],
|
||||||
"attributes": [],
|
"attributes": [],
|
||||||
"versionCode": 102,
|
"versionCode": 158,
|
||||||
"versionName": "1.0.0",
|
"versionName": "1.0.5",
|
||||||
"outputFile": "秘地_1.0.0_102.apk"
|
"outputFile": "秘地_1.0.5_158.apk"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"elementType": "File",
|
"elementType": "File",
|
||||||
@@ -22,14 +22,14 @@
|
|||||||
"minApi": 28,
|
"minApi": 28,
|
||||||
"maxApi": 30,
|
"maxApi": 30,
|
||||||
"baselineProfiles": [
|
"baselineProfiles": [
|
||||||
"baselineProfiles/1/秘地_1.0.0_102.dm"
|
"baselineProfiles/1/秘地_1.0.5_158.dm"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"minApi": 31,
|
"minApi": 31,
|
||||||
"maxApi": 2147483647,
|
"maxApi": 2147483647,
|
||||||
"baselineProfiles": [
|
"baselineProfiles": [
|
||||||
"baselineProfiles/0/秘地_1.0.0_102.dm"
|
"baselineProfiles/0/秘地_1.0.5_158.dm"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -143,7 +143,6 @@
|
|||||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:screenOrientation="behind"
|
android:screenOrientation="behind"
|
||||||
android:launchMode="singleTask"
|
|
||||||
android:theme="@style/main_SplashThemeImage">
|
android:theme="@style/main_SplashThemeImage">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 126 KiB After Width: | Height: | Size: 142 KiB |
@@ -5,39 +5,98 @@ import android.content.Intent;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.PersistableBundle;
|
import android.os.PersistableBundle;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.alibaba.android.arouter.launcher.ARouter;
|
import com.alibaba.android.arouter.launcher.ARouter;
|
||||||
import com.xscm.modulelogin.activity.ImproveInfoActivity;
|
import com.xscm.modulelogin.activity.ImproveInfoActivity;
|
||||||
import com.xscm.moduleutil.activity.BaseAppCompatActivity;
|
import com.xscm.moduleutil.activity.BaseAppCompatActivity;
|
||||||
|
import com.xscm.moduleutil.base.AppStateListener;
|
||||||
|
import com.xscm.moduleutil.base.AppStateManager;
|
||||||
import com.xscm.moduleutil.base.CommonAppContext;
|
import com.xscm.moduleutil.base.CommonAppContext;
|
||||||
import com.xscm.moduleutil.dialog.PolicyDialog;
|
import com.xscm.moduleutil.dialog.PolicyDialog;
|
||||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||||
import com.xscm.moduleutil.utils.SpUtil;
|
import com.xscm.moduleutil.utils.SpUtil;
|
||||||
import com.xscm.midi.databinding.ActivityLaunchPageBinding;
|
import com.xscm.midi.databinding.ActivityLaunchPageBinding;
|
||||||
|
/**
|
||||||
public class LaunchPageActivity extends BaseAppCompatActivity<ActivityLaunchPageBinding> {
|
APP准备启动
|
||||||
|
*
|
||||||
|
* _oo0oo_
|
||||||
|
* o8888888o
|
||||||
|
* 88" . "88
|
||||||
|
* (| -_- |)
|
||||||
|
* 0\ = /0
|
||||||
|
* ___/`---'\___
|
||||||
|
* .' \\| |// '.
|
||||||
|
* / \\||| : |||// \
|
||||||
|
* / _||||| -卍-|||||- \
|
||||||
|
* | | \\\ - /// | |
|
||||||
|
* | \_| ''\---/'' |_/ |
|
||||||
|
* \ .-\__ '-' ___/-. /
|
||||||
|
* ___'. .' /--.--\ `. .'___
|
||||||
|
* ."" '< `.___\_<|>_/___.' >' "".
|
||||||
|
* | | : `- \`.;`\ _ /`;.`/ - ` : | |
|
||||||
|
* \ \ `_. \_ __\ /__ _/ .-` / /
|
||||||
|
*=====`-.____`.___ \_____/___.-`___.-'=====
|
||||||
|
* `=---='
|
||||||
|
*
|
||||||
|
* 佛祖保佑 永无BUG
|
||||||
|
* 佛曰:
|
||||||
|
* 写字楼里写字间,写字间里程序员;
|
||||||
|
* 程序人员写程序,又拿程序换酒钱。
|
||||||
|
* 酒醒只在网上坐,酒醉还来网下眠;
|
||||||
|
* 酒醉酒醒日复日,网上网下年复年。
|
||||||
|
* 但愿老死电脑间,不愿鞠躬老板前;
|
||||||
|
* 奔驰宝马贵者趣,公交自行程序员。
|
||||||
|
* 别人笑我忒疯癫,我笑自己命太贱;
|
||||||
|
* 不见满街漂亮妹,哪个归得程序员?
|
||||||
|
*/
|
||||||
|
public class LaunchPageActivity extends BaseAppCompatActivity<ActivityLaunchPageBinding> {
|
||||||
private Handler handler;
|
private Handler handler;
|
||||||
private PolicyDialog policyDialog;
|
private PolicyDialog policyDialog;
|
||||||
|
private AppStateListener appStateListener;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) {
|
public void onCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) {
|
||||||
super.onCreate(savedInstanceState, persistentState);
|
super.onCreate(savedInstanceState, persistentState);
|
||||||
|
|
||||||
|
// 获取Application实例并设置监听器
|
||||||
|
CommonAppContext app = (CommonAppContext) getApplication();
|
||||||
|
appStateListener = AppStateManager.getInstance();
|
||||||
|
app.setAppStateListener(appStateListener);
|
||||||
|
|
||||||
if (!isTaskRoot()) {
|
if (!isTaskRoot()) {
|
||||||
|
|
||||||
|
if (SpUtil.getUnderagePassword() != null && !SpUtil.getUnderagePassword().isEmpty()) {
|
||||||
|
ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url() + "/web/index.html#/pages/feedback/teenage?id=" + SpUtil.getToken())
|
||||||
|
.withString("type", "1").navigation();//type==1:青少年模式
|
||||||
|
} else {
|
||||||
|
// 如果没有设置青少年模式,应该导航到首页
|
||||||
|
try {
|
||||||
|
ARouter.getInstance().build(ARouteConstants.ME).navigation();
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e("LaunchPageActivity", "导航到首页失败", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// if (shouldRestoreRoom()) {
|
||||||
|
// ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("form", "首页").withString("roomId", CommonAppContext.getInstance().playId).navigation();
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldRestoreRoom() {
|
private boolean shouldRestoreRoom() {
|
||||||
// 检查是否应该恢复房间:
|
// 检查是否应该恢复房间:
|
||||||
// 1. 应用有正在播放的房间
|
// 1. 应用有正在播放的房间
|
||||||
// 2. 应用应该显示房间
|
// 2. 应用应该显示房间
|
||||||
// 3. 应用是从后台恢复的(通过检查 CommonAppContext 状态)
|
// 3. 应用是从后台恢复的(通过检查 CommonAppContext 状态)
|
||||||
return CommonAppContext.getInstance().isPlaying
|
return CommonAppContext.getInstance().isPlaying
|
||||||
&& CommonAppContext.getInstance().isShow
|
&& CommonAppContext.getInstance().isShow;
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initData() {
|
protected void initData() {
|
||||||
handler = new Handler();
|
handler = new Handler();
|
||||||
@@ -74,6 +133,7 @@ public class LaunchPageActivity extends BaseAppCompatActivity<ActivityLaunchPage
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
// 如果 PolicyDialog 仍在显示,则 dismiss 它
|
// 如果 PolicyDialog 仍在显示,则 dismiss 它
|
||||||
@@ -89,6 +149,7 @@ public class LaunchPageActivity extends BaseAppCompatActivity<ActivityLaunchPage
|
|||||||
|
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initView() {
|
protected void initView() {
|
||||||
|
|
||||||
@@ -106,14 +167,12 @@ public class LaunchPageActivity extends BaseAppCompatActivity<ActivityLaunchPage
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutId() {
|
protected int getLayoutId() {
|
||||||
return R.layout.activity_launch_page;
|
return R.layout.activity_launch_page;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import com.example.modulevocal.presenter.RealNamePresenter;
|
|||||||
import com.xscm.moduleutil.activity.BaseMvpActivity;
|
import com.xscm.moduleutil.activity.BaseMvpActivity;
|
||||||
import com.xscm.moduleutil.bean.RealNameBean;
|
import com.xscm.moduleutil.bean.RealNameBean;
|
||||||
import com.xscm.moduleutil.color.ThemeableDrawableUtils;
|
import com.xscm.moduleutil.color.ThemeableDrawableUtils;
|
||||||
|
import com.xscm.moduleutil.dialog.ConfirmDialog;
|
||||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||||
import com.xscm.moduleutil.utils.ColorManager;
|
import com.xscm.moduleutil.utils.ColorManager;
|
||||||
import com.xscm.moduleutil.utils.SpUtil;
|
import com.xscm.moduleutil.utils.SpUtil;
|
||||||
@@ -112,6 +113,7 @@ public class RealNameActivity extends BaseMvpActivity<RealNamePresenter, Activit
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
Log.d("@@@", "刷脸失败!");
|
Log.d("@@@", "刷脸失败!");
|
||||||
|
// queren1();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//刷脸结束后,及时释放资源
|
//刷脸结束后,及时释放资源
|
||||||
@@ -125,15 +127,50 @@ public class RealNameActivity extends BaseMvpActivity<RealNamePresenter, Activit
|
|||||||
Log.d("@@@", "刷脸失败!");
|
Log.d("@@@", "刷脸失败!");
|
||||||
//刷脸结束后,及时释放资源
|
//刷脸结束后,及时释放资源
|
||||||
WbCloudFaceVerifySdk.getInstance().release();
|
WbCloudFaceVerifySdk.getInstance().release();
|
||||||
|
// queren1();
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendCodeSuccess() {
|
public void sendCodeSuccess() {
|
||||||
|
// queren();
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
private void queren() {
|
||||||
|
// 创建并显示确认对话框
|
||||||
|
new ConfirmDialog(this,
|
||||||
|
"温馨提示",
|
||||||
|
"恭喜您获得内测资格,将获得10万金币",
|
||||||
|
"确认",
|
||||||
|
"",
|
||||||
|
v -> {
|
||||||
|
// 点击“确认”按钮时执行
|
||||||
|
finish();
|
||||||
|
},
|
||||||
|
v -> {
|
||||||
|
// 点击“取消”按钮时什么都不做
|
||||||
|
|
||||||
|
}, true, 0).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void queren1() {
|
||||||
|
// 创建并显示确认对话框
|
||||||
|
new ConfirmDialog(this,
|
||||||
|
"温馨提示",
|
||||||
|
"实名未通过,重新实名",
|
||||||
|
"确认",
|
||||||
|
"",
|
||||||
|
v -> {
|
||||||
|
// 点击“确认”按钮时执行
|
||||||
|
finish();
|
||||||
|
},
|
||||||
|
v -> {
|
||||||
|
// 点击“取消”按钮时什么都不做
|
||||||
|
|
||||||
|
}, true, 0).show();
|
||||||
|
}
|
||||||
private void onClick(View view) {
|
private void onClick(View view) {
|
||||||
if (view.getId()== R.id.btnSubmit){
|
if (view.getId()== R.id.btnSubmit){
|
||||||
if (mBinding.edName.getText().toString().isEmpty()){
|
if (mBinding.edName.getText().toString().isEmpty()){
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 89 KiB |
BIN
app/src/main/res/drawable/login_log.webp
Normal file
|
After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 7.9 KiB |
|
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 7.9 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 7.9 KiB |
|
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 7.9 KiB |
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 9.0 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 9.0 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 46 KiB |
|
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 12 KiB |
BIN
app/src/main/res/mipmap-xhdpi/screen.png
Normal file
|
After Width: | Height: | Size: 228 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 89 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 23 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/screen.png
Normal file
|
After Width: | Height: | Size: 549 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 142 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 2.0 MiB After Width: | Height: | Size: 1.0 MiB |
@@ -19,6 +19,8 @@ buildscript {
|
|||||||
|
|
||||||
// ✅ 添加 ARouter 插件依赖
|
// ✅ 添加 ARouter 插件依赖
|
||||||
classpath 'com.alibaba:arouter-register:1.0.2'
|
classpath 'com.alibaba:arouter-register:1.0.2'
|
||||||
|
|
||||||
|
// classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2' // add plugin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
plugins {
|
plugins {
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ isBuildModule=false
|
|||||||
#org.gradle.deamon=false
|
#org.gradle.deamon=false
|
||||||
android.injected.testOnly=false
|
android.injected.testOnly=false
|
||||||
|
|
||||||
APP_VERSION_NAME=1.0.1
|
APP_VERSION_NAME=1.1.0
|
||||||
APP_VERSION_CODE=130
|
APP_VERSION_CODE=163
|
||||||
|
|
||||||
org.gradle.jvm.toolchain.useLegacyAdapters=false
|
org.gradle.jvm.toolchain.useLegacyAdapters=false
|
||||||
#org.gradle.java.home=C\:\\Users\\qx\\.jdks\\ms-17.0.15
|
#org.gradle.java.home=C\:\\Users\\qx\\.jdks\\ms-17.0.15
|
||||||
@@ -48,4 +48,7 @@ beta=false
|
|||||||
|
|
||||||
org.gradle.caching=false
|
org.gradle.caching=false
|
||||||
# ??APT????
|
# ??APT????
|
||||||
kapt.incremental.apt=false
|
kapt.incremental.apt=false
|
||||||
|
|
||||||
|
# 或者禁用特定模块的增量编译
|
||||||
|
#org.gradle.configureondemand=false
|
||||||
@@ -163,4 +163,5 @@ android-library = { id = "com.android.library", version.ref = "agp" }
|
|||||||
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlinVersion" }
|
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlinVersion" }
|
||||||
#kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlinVersion" }
|
#kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlinVersion" }
|
||||||
#alibaba-arouter = { id = "com.alibaba.arouter", version.ref = "arouter" }
|
#alibaba-arouter = { id = "com.alibaba.arouter", version.ref = "arouter" }
|
||||||
|
greendao-plugin = { id = "org.greenrobot.greendao", version.ref = "greendaoGradlePlugin" }
|
||||||
|
|
||||||
|
|||||||
8
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,8 +1,6 @@
|
|||||||
#Wed May 07 09:31:48 CST 2025
|
#Mon Sep 22 21:05:11 CST 2025
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
#distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-8.7-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/distsl.
|
||||||
#distributionUrl=file:///D:/Greadle/gradle-8.10.2-all.zip
|
|
||||||
distributionUrl=file:///D:/Gradle/gradle-8.10.2-bin.zip
|
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public class ImproveInfoActivity extends BaseMvpActivity<ImproveInfoPresenter, A
|
|||||||
mBinding.edNickName.setText(userBean.getNickname());
|
mBinding.edNickName.setText(userBean.getNickname());
|
||||||
}
|
}
|
||||||
mBinding.edNickName.setClearIconVisible(true);
|
mBinding.edNickName.setClearIconVisible(true);
|
||||||
ImageUtils.loadHeadCC(userBean.getAvatar(), mBinding.rvUserHead);
|
// ImageUtils.loadHeadCC(userBean.getAvatar(), mBinding.rvUserHead);
|
||||||
if (!TextUtils.isEmpty(user_no_parent) && !"0".equals(user_no_parent)) {
|
if (!TextUtils.isEmpty(user_no_parent) && !"0".equals(user_no_parent)) {
|
||||||
mBinding.etInviteCode.setText(user_no_parent);
|
mBinding.etInviteCode.setText(user_no_parent);
|
||||||
mBinding.etInviteCode.setKeyListener(null);
|
mBinding.etInviteCode.setKeyListener(null);
|
||||||
@@ -203,7 +203,7 @@ public class ImproveInfoActivity extends BaseMvpActivity<ImproveInfoPresenter, A
|
|||||||
.setImageEngine(GlideEngine.createGlideEngine())
|
.setImageEngine(GlideEngine.createGlideEngine())
|
||||||
.setMaxSelectNum(1)
|
.setMaxSelectNum(1)
|
||||||
.isPreviewImage(true)
|
.isPreviewImage(true)
|
||||||
.isDisplayCamera(true)
|
.isDisplayCamera(false)
|
||||||
.setOutputCameraDir(Constants.FILE_PATH)
|
.setOutputCameraDir(Constants.FILE_PATH)
|
||||||
.isOriginalSkipCompress(true)
|
.isOriginalSkipCompress(true)
|
||||||
.forResult(requestCode); //结果回调onActivityResult code
|
.forResult(requestCode); //结果回调onActivityResult code
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ public class LoginPresenter extends BasePresenter<LoginContacter.View> implement
|
|||||||
|
|
||||||
public void loginSuccess(List<UserBean> userBean) {
|
public void loginSuccess(List<UserBean> userBean) {
|
||||||
if (userBean == null) {
|
if (userBean == null) {
|
||||||
ToastUtils.showShort("登录失败请重试");
|
// ToastUtils.showShort("登录失败请重试");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (userBean.size() == 1) {
|
if (userBean.size() == 1) {
|
||||||
|
|||||||
@@ -31,32 +31,51 @@
|
|||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
<com.xscm.moduleutil.widget.GifAvatarOvalView
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/rv_user_head"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="@dimen/dp_74"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="@dimen/dp_74"
|
>
|
||||||
android:layout_gravity="center_horizontal"
|
|
||||||
android:layout_marginTop="@dimen/dp_10"
|
<com.xscm.moduleutil.widget.GifAvatarOvalView
|
||||||
android:src="@mipmap/me_img_upld_head"
|
android:id="@+id/rv_user_head"
|
||||||
app:riv_oval="true" />
|
android:layout_width="@dimen/dp_74"
|
||||||
|
android:layout_height="@dimen/dp_74"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:src="@mipmap/user_wait_header"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:riv_oval="true" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="@dimen/dp_24"
|
||||||
|
android:layout_height="@dimen/dp_24"
|
||||||
|
android:src="@mipmap/zhaop"
|
||||||
|
android:scaleType="fitCenter"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@+id/rv_user_head"
|
||||||
|
app:layout_constraintEnd_toEndOf="@+id/rv_user_head"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="@dimen/dp_80"
|
android:layout_height="@dimen/dp_80"
|
||||||
android:layout_marginLeft="@dimen/dp_40"
|
android:layout_marginLeft="@dimen/dp_40"
|
||||||
android:layout_marginTop="@dimen/dp_54"
|
android:layout_marginTop="@dimen/dp_34"
|
||||||
android:layout_marginRight="@dimen/dp_40"
|
android:layout_marginRight="@dimen/dp_40">
|
||||||
>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv_ts"
|
android:id="@+id/tv_ts"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:letterSpacing="0.1"
|
||||||
android:text="起个好听的名字"
|
android:text="起个好听的名字"
|
||||||
android:textColor="#73000000"
|
android:textColor="#73000000"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold" />
|
||||||
android:letterSpacing="0.1"/>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/ll"
|
android:id="@+id/ll"
|
||||||
@@ -69,13 +88,13 @@
|
|||||||
<com.xscm.moduleutil.widget.ClearEditText
|
<com.xscm.moduleutil.widget.ClearEditText
|
||||||
android:id="@+id/ed_nick_name"
|
android:id="@+id/ed_nick_name"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
android:background="@drawable/bg_r100_hui"
|
android:background="@drawable/bg_r100_hui"
|
||||||
android:hint="请输入昵称"
|
|
||||||
android:gravity="center|left"
|
android:gravity="center|left"
|
||||||
android:paddingStart="10dp"
|
android:hint="请输入昵称"
|
||||||
android:maxLength="10"
|
android:maxLength="10"
|
||||||
|
android:paddingStart="10dp"
|
||||||
android:paddingEnd="@dimen/dp_10"
|
android:paddingEnd="@dimen/dp_10"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:text=""
|
android:text=""
|
||||||
@@ -85,13 +104,12 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv_user_name"
|
android:id="@+id/tv_user_name"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_weight="0.2"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="随机"
|
android:layout_weight="0.2"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
|
android:text="随机"
|
||||||
android:textColor="@color/color_FF6C49E4"
|
android:textColor="@color/color_FF6C49E4"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp" />
|
||||||
/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
@@ -102,6 +120,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="@dimen/dp_40"
|
android:layout_marginLeft="@dimen/dp_40"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -109,13 +128,13 @@
|
|||||||
android:textColor="#73000000"
|
android:textColor="#73000000"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text=" (注册成功,不可更改)"
|
android:text=" (注册成功,不可更改)"
|
||||||
android:textColor="#33000000"
|
android:textColor="#33000000"
|
||||||
android:textSize="12sp"
|
android:textSize="12sp" />
|
||||||
/>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
@@ -124,27 +143,25 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/dp_72"
|
android:layout_height="@dimen/dp_72"
|
||||||
android:layout_marginStart="@dimen/dp_40"
|
android:layout_marginStart="@dimen/dp_40"
|
||||||
android:layout_marginEnd="@dimen/dp_40"
|
|
||||||
android:layout_marginTop="12dp"
|
android:layout_marginTop="12dp"
|
||||||
android:orientation="horizontal"
|
android:layout_marginEnd="@dimen/dp_40"
|
||||||
android:background="@drawable/selector_sex_mm">
|
android:background="@drawable/selector_sex_mm"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/rl_nv"
|
android:id="@+id/rl_nv"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:gravity="center"
|
android:gravity="center">
|
||||||
>
|
|
||||||
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/iv_boy"
|
android:id="@+id/iv_boy"
|
||||||
android:layout_width="@dimen/dp_137"
|
android:layout_width="@dimen/dp_137"
|
||||||
android:layout_height="@dimen/dp_72"
|
android:layout_height="@dimen/dp_72"
|
||||||
android:src="@mipmap/check_boy"
|
|
||||||
android:scaleType="fitCenter"
|
android:scaleType="fitCenter"
|
||||||
/>
|
android:src="@mipmap/check_boy" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
@@ -152,16 +169,14 @@
|
|||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:gravity="center"
|
android:gravity="center">
|
||||||
>
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/iv_girl"
|
android:id="@+id/iv_girl"
|
||||||
android:layout_width="@dimen/dp_137"
|
android:layout_width="@dimen/dp_137"
|
||||||
android:layout_height="@dimen/dp_72"
|
android:layout_height="@dimen/dp_72"
|
||||||
android:src="@mipmap/check_girl"
|
|
||||||
android:scaleType="fitCenter"
|
android:scaleType="fitCenter"
|
||||||
/>
|
android:src="@mipmap/check_girl" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
@@ -174,6 +189,7 @@
|
|||||||
android:layout_marginStart="@dimen/dp_40"
|
android:layout_marginStart="@dimen/dp_40"
|
||||||
android:layout_marginTop="@dimen/dp_24"
|
android:layout_marginTop="@dimen/dp_24"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -195,24 +211,24 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv_year"
|
android:id="@+id/tv_year"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_height="@dimen/dp_44"
|
android:layout_height="@dimen/dp_44"
|
||||||
|
android:layout_weight="1"
|
||||||
android:background="@drawable/bg_r100_hui"
|
android:background="@drawable/bg_r100_hui"
|
||||||
android:singleLine="true"
|
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
|
android:singleLine="true"
|
||||||
android:text="2001"
|
android:text="2001"
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="@dimen/dp_0"
|
android:layout_width="@dimen/dp_0"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginStart="@dimen/dp_7"
|
||||||
|
android:layout_marginEnd="@dimen/dp_7"
|
||||||
android:layout_weight="0.2"
|
android:layout_weight="0.2"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:text="年"
|
android:text="年"
|
||||||
android:layout_marginStart="@dimen/dp_7"
|
|
||||||
android:layout_marginEnd="@dimen/dp_7"
|
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
@@ -220,49 +236,49 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv_month"
|
android:id="@+id/tv_month"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_height="@dimen/dp_44"
|
android:layout_height="@dimen/dp_44"
|
||||||
|
android:layout_weight="1"
|
||||||
android:background="@drawable/bg_r100_hui"
|
android:background="@drawable/bg_r100_hui"
|
||||||
|
android:gravity="center"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:text="12"
|
android:text="12"
|
||||||
android:gravity="center"
|
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="@dimen/dp_0"
|
android:layout_width="@dimen/dp_0"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="0.2"
|
|
||||||
android:gravity="center"
|
|
||||||
android:layout_marginStart="@dimen/dp_7"
|
android:layout_marginStart="@dimen/dp_7"
|
||||||
android:layout_marginEnd="@dimen/dp_7"
|
android:layout_marginEnd="@dimen/dp_7"
|
||||||
|
android:layout_weight="0.2"
|
||||||
|
android:gravity="center"
|
||||||
android:text="月"
|
android:text="月"
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv_day"
|
android:id="@+id/tv_day"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_height="@dimen/dp_44"
|
android:layout_height="@dimen/dp_44"
|
||||||
|
android:layout_weight="1"
|
||||||
android:background="@drawable/bg_r100_hui"
|
android:background="@drawable/bg_r100_hui"
|
||||||
android:singleLine="true"
|
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
|
android:singleLine="true"
|
||||||
android:text="1"
|
android:text="1"
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="@dimen/dp_0"
|
android:layout_width="@dimen/dp_0"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginStart="@dimen/dp_7"
|
||||||
|
android:layout_marginEnd="@dimen/dp_7"
|
||||||
android:layout_weight="0.2"
|
android:layout_weight="0.2"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:text="日"
|
android:text="日"
|
||||||
android:layout_marginStart="@dimen/dp_7"
|
|
||||||
android:layout_marginEnd="@dimen/dp_7"
|
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
@@ -301,15 +317,14 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/dp_42"
|
android:layout_height="@dimen/dp_42"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_centerInParent="true"
|
|
||||||
android:background="@drawable/theme_bg"
|
|
||||||
android:layout_marginLeft="@dimen/dp_40"
|
android:layout_marginLeft="@dimen/dp_40"
|
||||||
android:layout_marginRight="@dimen/dp_40"
|
android:layout_marginRight="@dimen/dp_40"
|
||||||
android:layout_marginBottom="@dimen/dp_20"
|
android:layout_marginBottom="@dimen/dp_20"
|
||||||
android:gravity="center"
|
android:background="@drawable/theme_bg"
|
||||||
>
|
android:gravity="center">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/iv_commit_bg"
|
android:id="@+id/iv_commit_bg"
|
||||||
@@ -317,8 +332,8 @@
|
|||||||
android:layout_height="@dimen/dp_75"
|
android:layout_height="@dimen/dp_75"
|
||||||
android:layout_marginLeft="10dp"
|
android:layout_marginLeft="10dp"
|
||||||
android:layout_marginRight="10dp"
|
android:layout_marginRight="10dp"
|
||||||
android:visibility="gone"
|
android:src="@drawable/theme_bg"
|
||||||
android:src="@drawable/theme_bg" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@@ -330,15 +345,14 @@
|
|||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:visibility="gone"/>
|
android:visibility="gone" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="21dp"
|
android:layout_height="21dp"
|
||||||
android:text="进入秘地"
|
android:text="进入秘地"
|
||||||
android:textColor="@color/color_white"
|
android:textColor="@color/color_white"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp" />
|
||||||
/>
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -207,7 +207,13 @@ dependencies {
|
|||||||
|
|
||||||
api 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.5'
|
api 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.5'
|
||||||
api 'io.github.mayzs:paho.mqtt.android:1.2.1'
|
api 'io.github.mayzs:paho.mqtt.android:1.2.1'
|
||||||
// api project(':LocalAar')
|
// room数据库
|
||||||
|
// def room_version = "2.5.0"
|
||||||
|
// implementation "androidx.room:room-runtime:$room_version"
|
||||||
|
// implementation "androidx.room:room-ktx:$room_version"
|
||||||
|
// annotationProcessor "androidx.room:room-compiler:$room_version"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//2. 云normal SDK,
|
//2. 云normal SDK,
|
||||||
//aar的名称,例如:WbCloudNormal-v5.1.10-123456789.aar,填入 'WbCloudNormal-v5.1.10-123456789.aar'
|
//aar的名称,例如:WbCloudNormal-v5.1.10-123456789.aar,填入 'WbCloudNormal-v5.1.10-123456789.aar'
|
||||||
|
|||||||
@@ -2,28 +2,32 @@ package com.xscm.moduleutil.activity;
|
|||||||
|
|
||||||
import static androidx.core.content.ContextCompat.getSystemService;
|
import static androidx.core.content.ContextCompat.getSystemService;
|
||||||
|
|
||||||
|
import static com.xscm.moduleutil.base.CommonAppContext.postDelayed;
|
||||||
|
|
||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
import android.animation.AnimatorListenerAdapter;
|
import android.animation.AnimatorListenerAdapter;
|
||||||
|
import android.animation.AnimatorSet;
|
||||||
import android.animation.ObjectAnimator;
|
import android.animation.ObjectAnimator;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.PixelFormat;
|
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
import android.util.DisplayMetrics;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewTreeObserver;
|
import android.view.animation.AccelerateInterpolator;
|
||||||
import android.view.WindowManager;
|
import android.view.animation.Animation;
|
||||||
import android.view.animation.DecelerateInterpolator;
|
import android.view.animation.DecelerateInterpolator;
|
||||||
|
import android.view.animation.TranslateAnimation;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
@@ -44,17 +48,17 @@ import com.hjq.toast.ToastUtils;
|
|||||||
import com.tencent.qcloud.tuikit.tuichat.bean.ChatInfo;
|
import com.tencent.qcloud.tuikit.tuichat.bean.ChatInfo;
|
||||||
import com.xscm.moduleutil.R;
|
import com.xscm.moduleutil.R;
|
||||||
import com.xscm.moduleutil.base.CommonAppContext;
|
import com.xscm.moduleutil.base.CommonAppContext;
|
||||||
|
import com.xscm.moduleutil.base.RoomManager;
|
||||||
import com.xscm.moduleutil.bean.XLHBean;
|
import com.xscm.moduleutil.bean.XLHBean;
|
||||||
import com.xscm.moduleutil.event.MqttBean;
|
import com.xscm.moduleutil.event.MqttBean;
|
||||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||||
import com.xscm.moduleutil.utils.BackgroundManager;
|
import com.xscm.moduleutil.utils.BackgroundManager;
|
||||||
import com.xscm.moduleutil.utils.ColorManager;
|
import com.xscm.moduleutil.utils.ColorManager;
|
||||||
import com.xscm.moduleutil.utils.DialogUtils;
|
|
||||||
import com.xscm.moduleutil.utils.DisplayUtil;
|
import com.xscm.moduleutil.utils.DisplayUtil;
|
||||||
import com.xscm.moduleutil.utils.ImageUtils;
|
import com.xscm.moduleutil.utils.ImageUtils;
|
||||||
import com.xscm.moduleutil.utils.LanguageUtil;
|
|
||||||
import com.xscm.moduleutil.utils.SpUtil;
|
import com.xscm.moduleutil.utils.SpUtil;
|
||||||
import com.xscm.moduleutil.widget.PiaoPingManager;
|
import com.xscm.moduleutil.utils.SystemUtils;
|
||||||
|
import com.xscm.moduleutil.widget.QXGiftDriftView;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.greenrobot.eventbus.Subscribe;
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
@@ -68,10 +72,6 @@ import java.util.Map;
|
|||||||
public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends AppCompatActivity
|
public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends AppCompatActivity
|
||||||
implements BackgroundManager.BackgroundUpdateListener, ColorManager.ColorChangeListener {
|
implements BackgroundManager.BackgroundUpdateListener, ColorManager.ColorChangeListener {
|
||||||
|
|
||||||
// @Override
|
|
||||||
// protected void attachBaseContext(Context newBase) {
|
|
||||||
// super.attachBaseContext(LanguageUtil.attachBaseContext(newBase));
|
|
||||||
// }
|
|
||||||
@Override
|
@Override
|
||||||
protected void attachBaseContext(Context newBase) {
|
protected void attachBaseContext(Context newBase) {
|
||||||
// 设置字体缩放比例为1.0f,即不跟随系统字体大小变化
|
// 设置字体缩放比例为1.0f,即不跟随系统字体大小变化
|
||||||
@@ -104,7 +104,7 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
|||||||
ActivityUtils.finishAllActivities();
|
ActivityUtils.finishAllActivities();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QXGiftDriftView qxGiftDriftView;
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -147,7 +147,6 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
|||||||
EventBus.getDefault().register(this);
|
EventBus.getDefault().register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 在Activity中
|
// 在Activity中
|
||||||
@@ -399,15 +398,10 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 在类中添加以下成员变量
|
|
||||||
private final List<MqttBean> messageQueue = new ArrayList<>(); // 消息队列
|
|
||||||
private boolean isPlaying = false; // 播放状态标志
|
|
||||||
private boolean isPlaying2 = false; // 播放状态标志
|
|
||||||
private final Object queueLock = new Object(); // 队列同步锁
|
|
||||||
|
|
||||||
/// 礼物特效
|
/// 礼物特效
|
||||||
// 在类中添加以下成员变量
|
// 在类中添加以下成员变量
|
||||||
private final List<MqttBean> mqttMessageQueue = new ArrayList<>(); // MQTT消息队列
|
private final List<MqttBean.ListBean> mqttMessageQueue = new ArrayList<>(); // MQTT消息队列
|
||||||
private final List<XLHBean> xlhMessageQueue = new ArrayList<>(); // XLH消息队列
|
private final List<XLHBean> xlhMessageQueue = new ArrayList<>(); // XLH消息队列
|
||||||
private boolean isMqttPlaying = false; // MQTT播放状态标志
|
private boolean isMqttPlaying = false; // MQTT播放状态标志
|
||||||
private boolean isXlhPlaying = false; // XLH播放状态标志
|
private boolean isXlhPlaying = false; // XLH播放状态标志
|
||||||
@@ -421,13 +415,17 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
|||||||
public void onMessageReceived(MqttBean mqttBean) {
|
public void onMessageReceived(MqttBean mqttBean) {
|
||||||
LogUtils.e("收到MQTT", mqttBean);
|
LogUtils.e("收到MQTT", mqttBean);
|
||||||
if (mqttBean == null) return;
|
if (mqttBean == null) return;
|
||||||
|
if (SpUtil.getFloatingScreen() == 1) {
|
||||||
|
synchronized (mqttQueueLock) {
|
||||||
|
|
||||||
synchronized (mqttQueueLock) {
|
mqttMessageQueue.addAll(mqttBean.getList());
|
||||||
mqttMessageQueue.add(mqttBean);
|
// if (!isMqttPlaying) {
|
||||||
if (!isMqttPlaying) {
|
// isMqttPlaying = true;
|
||||||
isMqttPlaying = true;
|
processNextMqttMessage();
|
||||||
processNextMqttMessage();
|
// }
|
||||||
}
|
}
|
||||||
|
}else {
|
||||||
|
mqttMessageQueue.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -436,19 +434,22 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
|||||||
public void onEvent(XLHBean event) {
|
public void onEvent(XLHBean event) {
|
||||||
LogUtils.e("收到XLH", event);
|
LogUtils.e("收到XLH", event);
|
||||||
if (event == null) return;
|
if (event == null) return;
|
||||||
|
if (SpUtil.getFloatingScreen() == 1) {
|
||||||
synchronized (xlhQueueLock) {
|
synchronized (xlhQueueLock) {
|
||||||
xlhMessageQueue.add(event);
|
xlhMessageQueue.add(event);
|
||||||
if (!isXlhPlaying) {
|
if (!isXlhPlaying) {
|
||||||
isXlhPlaying = true;
|
isXlhPlaying = true;
|
||||||
processNextXlhMessage();
|
processNextXlhMessage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
xlhMessageQueue.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理下一个MQTT消息
|
// 处理下一个MQTT消息
|
||||||
private void processNextMqttMessage() {
|
private void processNextMqttMessage() {
|
||||||
MqttBean mqttBean;
|
MqttBean.ListBean mqttBean;
|
||||||
synchronized (mqttQueueLock) {
|
synchronized (mqttQueueLock) {
|
||||||
if (mqttMessageQueue.isEmpty()) {
|
if (mqttMessageQueue.isEmpty()) {
|
||||||
isMqttPlaying = false;
|
isMqttPlaying = false;
|
||||||
@@ -475,7 +476,12 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
|||||||
ViewGroup decorView;
|
ViewGroup decorView;
|
||||||
ViewGroup decorView1;
|
ViewGroup decorView1;
|
||||||
|
|
||||||
private void showFloatingMessage(MqttBean mqttBean) {
|
private void showFloatingMessage(MqttBean.ListBean mqttBean) {
|
||||||
|
|
||||||
|
// QXGiftDriftView.getInstance( this).addGiftModel(mqttBean);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 清理之前的视图(如果存在)
|
// 清理之前的视图(如果存在)
|
||||||
if (currentMqttView != null && currentMqttView.getParent() != null) {
|
if (currentMqttView != null && currentMqttView.getParent() != null) {
|
||||||
@@ -566,43 +572,113 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetAndStartMqttAnimation(View view, Runnable onAnimationEnd) {
|
private void resetAndStartMqttAnimation(View view, Runnable onAnimationEnd) {
|
||||||
try {
|
try {
|
||||||
view.setTranslationX(view.getWidth());
|
int screenWidth = getScreenWidth();
|
||||||
ObjectAnimator animator1 = ObjectAnimator.ofFloat(view, "translationX", view.getWidth(), 0f);
|
// 设置初始位置:在屏幕右侧外部(完全不可见)
|
||||||
animator1.setDuration(1500);
|
view.setTranslationX(screenWidth);
|
||||||
animator1.setInterpolator(new DecelerateInterpolator(2.0f));
|
|
||||||
animator1.start();
|
|
||||||
|
|
||||||
view.postDelayed(() -> {
|
|
||||||
try {
|
|
||||||
ObjectAnimator animator2 = ObjectAnimator.ofFloat(view, "translationX", 0f, -view.getWidth());
|
|
||||||
animator2.setDuration(1500);
|
|
||||||
animator2.setInterpolator(new DecelerateInterpolator(2.0f));
|
|
||||||
animator2.addListener(new AnimatorListenerAdapter() {
|
|
||||||
@Override
|
|
||||||
public void onAnimationEnd(Animator animation) {
|
|
||||||
onAnimationEnd.run();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
TranslateAnimation enterAnim = new TranslateAnimation(
|
||||||
public void onAnimationCancel(Animator animation) {
|
Animation.ABSOLUTE, screenWidth,
|
||||||
onAnimationEnd.run();
|
Animation.ABSOLUTE, (screenWidth - SystemUtils.getWidth(316)) / 2,
|
||||||
}
|
Animation.ABSOLUTE, 0,
|
||||||
});
|
Animation.ABSOLUTE, 0
|
||||||
animator2.start();
|
);
|
||||||
} catch (Exception e) {
|
enterAnim.setDuration(1500);
|
||||||
LogUtils.e("MQTT动画执行失败", e);
|
enterAnim.setAnimationListener(new Animation.AnimationListener() {
|
||||||
onAnimationEnd.run();
|
@Override
|
||||||
|
public void onAnimationStart(Animation animation) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAnimationEnd(Animation animation) {
|
||||||
|
// 停留后退出
|
||||||
|
postDelayed(() -> {
|
||||||
|
TranslateAnimation exitAnim = new TranslateAnimation(
|
||||||
|
Animation.ABSOLUTE, (screenWidth - SystemUtils.getWidth(316)) / 2,
|
||||||
|
Animation.ABSOLUTE, -screenWidth,
|
||||||
|
Animation.ABSOLUTE, 0,
|
||||||
|
Animation.ABSOLUTE, 0
|
||||||
|
);
|
||||||
|
exitAnim.setDuration(2000);
|
||||||
|
exitAnim.setAnimationListener(new Animation.AnimationListener() {
|
||||||
|
@Override
|
||||||
|
public void onAnimationStart(Animation animation) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAnimationEnd(Animation animation) {
|
||||||
|
// 移除视图并处理下一个
|
||||||
|
// ViewGroup rootView = (ViewGroup) getParent();
|
||||||
|
// if (rootView != null) {
|
||||||
|
// rootView.removeView(QXGiftDriftView.this);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (!dataArray.isEmpty()) {
|
||||||
|
// dataArray.remove(0);
|
||||||
|
// }
|
||||||
|
// isPlaying = false;
|
||||||
|
//
|
||||||
|
// if (!dataArray.isEmpty()) {
|
||||||
|
// giftAction();
|
||||||
|
// }
|
||||||
|
onAnimationEnd.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAnimationRepeat(Animation animation) {}
|
||||||
|
});
|
||||||
|
view.startAnimation(exitAnim);
|
||||||
|
}, 3000); // 停留1秒
|
||||||
}
|
}
|
||||||
}, 3000);
|
|
||||||
|
@Override
|
||||||
|
public void onAnimationRepeat(Animation animation) {}
|
||||||
|
});
|
||||||
|
view.startAnimation(enterAnim);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ObjectAnimator animator1 = ObjectAnimator.ofFloat(view, "translationX", view.getWidth(), 0f);
|
||||||
|
// animator1.setDuration(1500);
|
||||||
|
// animator1.setInterpolator(new DecelerateInterpolator(1f));
|
||||||
|
// animator1.start();
|
||||||
|
|
||||||
|
// view.postDelayed(() -> {
|
||||||
|
// try {
|
||||||
|
// ObjectAnimator animator2 = ObjectAnimator.ofFloat(view, "translationX", 0f, -view.getWidth());
|
||||||
|
// animator2.setDuration(3000);
|
||||||
|
// animator2.setInterpolator(new DecelerateInterpolator(2.0f));
|
||||||
|
// animator2.addListener(new AnimatorListenerAdapter() {
|
||||||
|
// @Override
|
||||||
|
// public void onAnimationEnd(Animator animation) {
|
||||||
|
// onAnimationEnd.run();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void onAnimationCancel(Animator animation) {
|
||||||
|
// onAnimationEnd.run();
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// animator2.start();
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// LogUtils.e("MQTT动画执行失败", e);
|
||||||
|
// onAnimationEnd.run();
|
||||||
|
// }
|
||||||
|
// }, 3000);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogUtils.e("MQTT动画启动失败", e);
|
LogUtils.e("MQTT动画启动失败", e);
|
||||||
onAnimationEnd.run();
|
onAnimationEnd.run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 添加获取屏幕宽度的方法
|
||||||
|
private int getScreenWidth() {
|
||||||
|
DisplayMetrics displayMetrics = new DisplayMetrics();
|
||||||
|
if (getWindowManager() != null) {
|
||||||
|
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
|
||||||
|
return displayMetrics.widthPixels;
|
||||||
|
}
|
||||||
|
return getResources().getDisplayMetrics().widthPixels;
|
||||||
|
}
|
||||||
private void resetAndStartXlhAnimation(View view, Runnable onAnimationEnd) {
|
private void resetAndStartXlhAnimation(View view, Runnable onAnimationEnd) {
|
||||||
try {
|
try {
|
||||||
view.setTranslationX(view.getWidth());
|
view.setTranslationX(view.getWidth());
|
||||||
@@ -639,18 +715,18 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateFloatingViewData(View view, MqttBean mqttBean) {
|
private void updateFloatingViewData(View view, MqttBean.ListBean mqttBean) {
|
||||||
TextView textView = view.findViewById(R.id.tv_name);
|
TextView textView = view.findViewById(R.id.tv_name);
|
||||||
TextView textView2 = view.findViewById(R.id.tv_to_name);
|
TextView textView2 = view.findViewById(R.id.tv_to_name);
|
||||||
TextView tv_time = view.findViewById(R.id.tv_num);
|
TextView tv_time = view.findViewById(R.id.tv_num);
|
||||||
|
|
||||||
if (mqttBean.getList() != null) {
|
if (mqttBean != null) {
|
||||||
textView2.setText("送给" + (mqttBean.getList().getToUserName() != null ? mqttBean.getList().getToUserName() : ""));
|
textView2.setText("送给" + (mqttBean.getToUserName() != null ? mqttBean.getToUserName() : ""));
|
||||||
textView.setText(mqttBean.getList().getFromUserName() != null ? mqttBean.getList().getFromUserName() : "");
|
textView.setText(mqttBean.getFromUserName() != null ? mqttBean.getFromUserName() : "");
|
||||||
if (mqttBean.getList().getGift_picture() != null) {
|
if (mqttBean.getGift_picture() != null) {
|
||||||
ImageUtils.loadHeadCC(mqttBean.getList().getGift_picture(), view.findViewById(R.id.iv_piaoping));
|
ImageUtils.loadHeadCC(mqttBean.getGift_picture(), view.findViewById(R.id.iv_piaoping));
|
||||||
}
|
}
|
||||||
tv_time.setText("x" + (mqttBean.getList().getNumber() != null ? mqttBean.getList().getNumber() : "1"));
|
tv_time.setText("x" + (mqttBean.getNumber() != null ? mqttBean.getNumber() : "1"));
|
||||||
} else {
|
} else {
|
||||||
textView2.setText("送给");
|
textView2.setText("送给");
|
||||||
textView.setText("");
|
textView.setText("");
|
||||||
@@ -680,8 +756,9 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
|||||||
private void handleItemClick(XLHBean xlhBean) {
|
private void handleItemClick(XLHBean xlhBean) {
|
||||||
// 这里可以根据实际需求实现跳转逻辑
|
// 这里可以根据实际需求实现跳转逻辑
|
||||||
// 例如:跳转到礼物详情页面、用户主页等
|
// 例如:跳转到礼物详情页面、用户主页等
|
||||||
|
// 使用缓存数据进入房间
|
||||||
ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("from", "我的界面").withString("roomId", xlhBean.getRoom_id()).navigation();
|
RoomManager.getInstance().fetchRoomDataAndEnter(getApplicationContext(), xlhBean.getRoom_id(), "");
|
||||||
|
// ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("from", "我的界面").withString("roomId", xlhBean.getRoom_id()).navigation();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import android.Manifest;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.res.Configuration;
|
||||||
|
import android.content.res.Resources;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
@@ -11,9 +14,21 @@ import androidx.core.content.ContextCompat;
|
|||||||
import androidx.databinding.ViewDataBinding;
|
import androidx.databinding.ViewDataBinding;
|
||||||
|
|
||||||
import com.blankj.utilcode.util.LogUtils;
|
import com.blankj.utilcode.util.LogUtils;
|
||||||
|
import com.tencent.imsdk.v2.V2TIMConversationListener;
|
||||||
|
import com.tencent.imsdk.v2.V2TIMConversationManager;
|
||||||
|
import com.tencent.imsdk.v2.V2TIMSDKListener;
|
||||||
|
import com.tencent.imsdk.v2.V2TIMValueCallback;
|
||||||
|
import com.tencent.qcloud.tuicore.TUIConfig;
|
||||||
|
import com.tencent.qcloud.tuicore.TUIConstants;
|
||||||
|
import com.tencent.qcloud.tuicore.TUICore;
|
||||||
|
import com.tencent.qcloud.tuicore.interfaces.TUILoginListener;
|
||||||
import com.xscm.moduleutil.base.CommonAppContext;
|
import com.xscm.moduleutil.base.CommonAppContext;
|
||||||
|
import com.xscm.moduleutil.base.RoomManager;
|
||||||
import com.xscm.moduleutil.bean.UserBean;
|
import com.xscm.moduleutil.bean.UserBean;
|
||||||
import com.xscm.moduleutil.bean.UserInfo;
|
import com.xscm.moduleutil.bean.UserInfo;
|
||||||
|
import com.xscm.moduleutil.dialog.ConfirmDialog;
|
||||||
|
import com.xscm.moduleutil.event.UnreadCountEvent;
|
||||||
|
import com.xscm.moduleutil.http.RetrofitClient;
|
||||||
import com.xscm.moduleutil.utils.LanguageUtil;
|
import com.xscm.moduleutil.utils.LanguageUtil;
|
||||||
import com.xscm.moduleutil.utils.location.LocationProvider;
|
import com.xscm.moduleutil.utils.location.LocationProvider;
|
||||||
import com.xscm.moduleutil.utils.location.SystemLocationProvider;
|
import com.xscm.moduleutil.utils.location.SystemLocationProvider;
|
||||||
@@ -28,13 +43,13 @@ import org.greenrobot.eventbus.Subscribe;
|
|||||||
import org.greenrobot.eventbus.ThreadMode;
|
import org.greenrobot.eventbus.ThreadMode;
|
||||||
|
|
||||||
public abstract class BaseMvpActivity<P extends IPresenter, VDB extends ViewDataBinding> extends BaseAppCompatActivity<VDB> implements
|
public abstract class BaseMvpActivity<P extends IPresenter, VDB extends ViewDataBinding> extends BaseAppCompatActivity<VDB> implements
|
||||||
IView<Activity> , LocationProvider.LocationCallback
|
IView<Activity> {
|
||||||
{
|
|
||||||
|
|
||||||
protected P MvpPre;
|
protected P MvpPre;
|
||||||
|
|
||||||
protected abstract P bindPresenter();
|
protected abstract P bindPresenter();
|
||||||
private String city1;
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initView() {
|
protected void initView() {
|
||||||
@@ -77,78 +92,112 @@ public abstract class BaseMvpActivity<P extends IPresenter, VDB extends ViewData
|
|||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
public void logOutEvent(UserBean userBean) {
|
public void logOutEvent(UserBean userBean) {
|
||||||
// 在用户 UI 点击登录的时候调用
|
// 在用户 UI 点击登录的时候调用
|
||||||
TUILogin.login(getBaseContext(), CommonAppContext.getInstance().getCurrentEnvironment().getSdkAppId(), "u"+userBean.getUser_id(), userBean.getTencent_im(), new TUICallback() {
|
TUILogin.login(getBaseContext(), CommonAppContext.getInstance().getCurrentEnvironment().getSdkAppId(), "u" + userBean.getUser_id(), userBean.getTencent_im(), new TUICallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onError(final int code, final String desc) {
|
public void onError(final int code, final String desc) {
|
||||||
LogUtils.e("@@@1",code,"描述:",desc);
|
LogUtils.e("@@@1", code, "描述:", desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
LogUtils.e("@@@","成功");
|
LogUtils.e("@@@", "成功");
|
||||||
// V2TIMUserFullInfo userFullInfo = new V2TIMUserFullInfo();
|
V2TIMManager.getConversationManager().getTotalUnreadMessageCount(new V2TIMValueCallback<Long>() {
|
||||||
// userFullInfo.setNickname(userBean.getNickname());
|
@Override
|
||||||
// userFullInfo.setFaceUrl(userBean.getAvatar());
|
public void onSuccess(Long aLong) {
|
||||||
// userFullInfo.setAllowType(userBean.getSex());
|
// 通知未读数变化
|
||||||
// V2TIMManager.getInstance().setSelfInfo(userFullInfo, new V2TIMCallback() {
|
UnreadCountEvent event =CommonAppContext.getInstance().unreadCountEvent;
|
||||||
// @Override
|
if (event==null){
|
||||||
// public void onSuccess() {
|
event=new UnreadCountEvent();
|
||||||
// LogUtils.e("@@@", "成功");
|
}
|
||||||
// }
|
event.setALong(aLong);
|
||||||
//
|
// 使用EventBus通知
|
||||||
// @Override
|
CommonAppContext.getInstance().setUnreadCountEvent(event);
|
||||||
// public void onError(int code, String desc) {
|
EventBus.getDefault().post(event);
|
||||||
// LogUtils.e("@@@", "描述"+desc);
|
}
|
||||||
// }
|
|
||||||
// });
|
@Override
|
||||||
initLocation();
|
public void onError(int code, String desc) {
|
||||||
|
// 错误处理
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//initLocation();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
V2TIMManager.getInstance().addIMSDKListener(imSdkListener);
|
||||||
|
|
||||||
}
|
|
||||||
private SystemLocationProvider locationProvider;
|
|
||||||
private void initLocation() {
|
|
||||||
if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
|
||||||
|
|
||||||
// 请求定位权限
|
|
||||||
ActivityCompat.requestPermissions(
|
|
||||||
(Activity) this,
|
|
||||||
new String[]{
|
|
||||||
android.Manifest.permission.ACCESS_FINE_LOCATION,
|
|
||||||
Manifest.permission.ACCESS_COARSE_LOCATION
|
|
||||||
},
|
|
||||||
1001 // 自定义常量,比如 1001
|
|
||||||
);
|
|
||||||
}
|
|
||||||
locationProvider = new SystemLocationProvider();
|
|
||||||
|
|
||||||
// 请求一次性的位置信息
|
|
||||||
locationProvider.getLastKnownLocation(this, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final V2TIMSDKListener imSdkListener = new V2TIMSDKListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onLocationReceived(double latitude, double longitude, String city) {
|
public void onConnecting() {
|
||||||
LogUtils.e("当前位置:" + city);
|
|
||||||
city1=city;
|
|
||||||
EventBus.getDefault().post(city1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailed(String errorMessage) {
|
public void onConnectSuccess() {//重连成功
|
||||||
LogUtils.e("定位失败");
|
if (CommonAppContext.getInstance().playId!=null){
|
||||||
|
RetrofitClient.getInstance().roomUserReconnect(CommonAppContext.getInstance().playId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConnectFailed(int code, String error) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onKickedOffline() {
|
||||||
|
// queren1();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUserSigExpired() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSelfInfoUpdated(V2TIMUserFullInfo info) {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private void queren1() {
|
||||||
|
// 创建并显示确认对话框
|
||||||
|
new ConfirmDialog(this,
|
||||||
|
"温馨提示",
|
||||||
|
"您的账号已在别处登录,请确认密码是否已经泄露",
|
||||||
|
"知道了",
|
||||||
|
"",
|
||||||
|
v -> {
|
||||||
|
// 点击“确认”按钮时执行删除操作
|
||||||
|
|
||||||
|
if (CommonAppContext.getInstance().playId!=null){
|
||||||
|
RoomManager.getInstance().exitRoom(CommonAppContext.getInstance().playId);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
CommonAppContext.getInstance().clearLoginInfo();
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
v -> {
|
||||||
|
// 点击“取消”按钮时什么都不做
|
||||||
|
|
||||||
|
}, false, 0).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
public Resources getResources() {
|
||||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
Resources resources = super.getResources();
|
||||||
|
if (resources != null) {
|
||||||
if (requestCode == 1001) {
|
Configuration configuration = resources.getConfiguration();
|
||||||
if (locationProvider==null) {
|
if (configuration != null) {
|
||||||
locationProvider = new SystemLocationProvider();
|
// 设置字体缩放比例不随系统变化
|
||||||
|
configuration.fontScale = 1.0f; // 1.0f表示默认大小
|
||||||
|
resources.updateConfiguration(configuration, resources.getDisplayMetrics());
|
||||||
}
|
}
|
||||||
locationProvider.getLastKnownLocation(this, this);
|
|
||||||
}
|
}
|
||||||
|
return resources;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
@@ -169,10 +218,10 @@ public abstract class BaseMvpActivity<P extends IPresenter, VDB extends ViewData
|
|||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 显示全局飘屏消息(支持任意位置飘过)
|
* 显示全局飘屏消息(支持任意位置飘过)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
// @Subscribe(threadMode = ThreadMode.MAIN)
|
// @Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
// public void showPiaoPingMessage(MqttBean mqttBean) {
|
// public void showPiaoPingMessage(MqttBean mqttBean) {
|
||||||
// WindowManager windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
|
// WindowManager windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
|
||||||
|
|||||||
@@ -10,7 +10,10 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.view.KeyEvent;
|
||||||
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.webkit.GeolocationPermissions;
|
import android.webkit.GeolocationPermissions;
|
||||||
import android.webkit.JavascriptInterface;
|
import android.webkit.JavascriptInterface;
|
||||||
@@ -21,11 +24,16 @@ import android.webkit.WebView;
|
|||||||
import android.webkit.WebViewClient;
|
import android.webkit.WebViewClient;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.alibaba.android.arouter.facade.annotation.Autowired;
|
||||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||||
import com.alibaba.android.arouter.launcher.ARouter;
|
import com.alibaba.android.arouter.launcher.ARouter;
|
||||||
import com.blankj.utilcode.util.LogUtils;
|
import com.blankj.utilcode.util.LogUtils;
|
||||||
|
import com.blankj.utilcode.util.ToastUtils;
|
||||||
import com.xscm.moduleutil.R;
|
import com.xscm.moduleutil.R;
|
||||||
import com.xscm.moduleutil.base.CommonAppContext;
|
import com.xscm.moduleutil.base.CommonAppContext;
|
||||||
|
import com.xscm.moduleutil.base.RoomManager;
|
||||||
import com.xscm.moduleutil.databinding.ActivityWebViewBinding;
|
import com.xscm.moduleutil.databinding.ActivityWebViewBinding;
|
||||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||||
import com.tencent.imsdk.v2.V2TIMConversation;
|
import com.tencent.imsdk.v2.V2TIMConversation;
|
||||||
@@ -46,6 +54,8 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
|||||||
|
|
||||||
public String title;
|
public String title;
|
||||||
public String url;
|
public String url;
|
||||||
|
@Autowired
|
||||||
|
public String type;//type=1:青少年模式
|
||||||
private ValueCallback<Uri> mUploadMessage;
|
private ValueCallback<Uri> mUploadMessage;
|
||||||
private ValueCallback<Uri[]> mUploadCallbackAboveL;
|
private ValueCallback<Uri[]> mUploadCallbackAboveL;
|
||||||
private final int REQUEST_FILE_PICKER = 1;
|
private final int REQUEST_FILE_PICKER = 1;
|
||||||
@@ -53,6 +63,8 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
|||||||
@SuppressLint("SetJavaScriptEnabled")
|
@SuppressLint("SetJavaScriptEnabled")
|
||||||
@Override
|
@Override
|
||||||
protected void initData() {
|
protected void initData() {
|
||||||
|
|
||||||
|
|
||||||
WebSettings webSettings = mBinding.webView.getSettings();
|
WebSettings webSettings = mBinding.webView.getSettings();
|
||||||
|
|
||||||
// 禁用水平滚动
|
// 禁用水平滚动
|
||||||
@@ -61,9 +73,9 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
|||||||
webSettings.setJavaScriptEnabled(true);
|
webSettings.setJavaScriptEnabled(true);
|
||||||
webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); //关闭webview中缓存
|
webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); //关闭webview中缓存
|
||||||
//增加JSBridge
|
//增加JSBridge
|
||||||
mBinding.webView.addJavascriptInterface(new WebAppInterface(this), "Android");
|
mBinding.webView.addJavascriptInterface(new WebAppInterface(this, type), "Android");
|
||||||
|
|
||||||
if (title!=null && !title.isEmpty()){
|
if (title != null && !title.isEmpty()) {
|
||||||
if (title.contains("协议")) {
|
if (title.contains("协议")) {
|
||||||
webSettings.setDisplayZoomControls(false); // 隐藏默认缩放控件
|
webSettings.setDisplayZoomControls(false); // 隐藏默认缩放控件
|
||||||
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL); // 使用正常布局算法
|
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL); // 使用正常布局算法
|
||||||
@@ -75,10 +87,10 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
|||||||
// 设置初始缩放
|
// 设置初始缩放
|
||||||
mBinding.webView.setInitialScale(100);
|
mBinding.webView.setInitialScale(100);
|
||||||
mBinding.webView.getSettings().setUseWideViewPort(false);
|
mBinding.webView.getSettings().setUseWideViewPort(false);
|
||||||
}else {
|
} else {
|
||||||
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
|
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
|
||||||
}
|
}
|
||||||
}else {
|
} else {
|
||||||
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
|
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +106,6 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
|||||||
mBinding.webView.setScrollContainer(true);
|
mBinding.webView.setScrollContainer(true);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
mBinding.webView.setWebViewClient(new WebViewClient());
|
mBinding.webView.setWebViewClient(new WebViewClient());
|
||||||
mBinding.webView.setBackgroundColor(Color.TRANSPARENT);
|
mBinding.webView.setBackgroundColor(Color.TRANSPARENT);
|
||||||
mBinding.webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
mBinding.webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
||||||
@@ -173,6 +184,35 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
|
||||||
|
if (getOnBackPressedDispatcher() != null) {
|
||||||
|
getOnBackPressedDispatcher().addCallback(this, new androidx.activity.OnBackPressedCallback(true) {
|
||||||
|
@Override
|
||||||
|
public void handleOnBackPressed() {
|
||||||
|
// 拦截返回键,显示退出对话框而不是直接退出
|
||||||
|
showExitRoomDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showExitRoomDialog() {
|
||||||
|
if (type != null) {
|
||||||
|
if (type.equals("1")) {
|
||||||
|
ARouter.getInstance().build(ARouteConstants.UNDERAGE_ACTIVITY).withInt("type", 1).navigation();
|
||||||
|
} else {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void showFileChooser() {
|
private void showFileChooser() {
|
||||||
// 这里可以扩展为显示对话框让用户选择“拍照”或“从相册选择”
|
// 这里可以扩展为显示对话框让用户选择“拍照”或“从相册选择”
|
||||||
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||||
@@ -214,12 +254,74 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
// 当type==1时,禁止返回键和手势返回
|
||||||
|
// 不执行任何操作,禁止返回
|
||||||
|
if (type != null) {
|
||||||
|
if (type.equals("1")) {
|
||||||
|
ARouter.getInstance().build(ARouteConstants.UNDERAGE_ACTIVITY).withInt("type", 1).navigation();
|
||||||
|
} else {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 正常处理返回键
|
||||||
|
super.onBackPressed();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||||
|
LogUtils.d("MainActivity", "onKeyDown called, keyCode: " + keyCode);
|
||||||
|
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||||
|
if (type != null) {
|
||||||
|
if (type.equals("1")) {
|
||||||
|
ARouter.getInstance().build(ARouteConstants.UNDERAGE_ACTIVITY).withInt("type", 1).navigation();
|
||||||
|
} else {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
return true; // 消费事件
|
||||||
|
}
|
||||||
|
return super.onKeyDown(keyCode, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
// public boolean dispatchTouchEvent(MotionEvent ev) {
|
||||||
|
// // 当type==1时,禁止手势滑动返回
|
||||||
|
// if (type.equals("1")) {
|
||||||
|
// // 检查是否是边缘滑动返回手势
|
||||||
|
// if (ev.getAction() == MotionEvent.ACTION_DOWN) {
|
||||||
|
// // 如果触摸点在屏幕边缘,拦截事件
|
||||||
|
// if (ev.getX() < 50) { // 左边缘50像素内
|
||||||
|
// return true; // 拦截事件,不传递给子View
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return super.dispatchTouchEvent(ev);
|
||||||
|
// }
|
||||||
@Override
|
@Override
|
||||||
protected void initView() {
|
protected void initView() {
|
||||||
getWindow().getDecorView().setBackgroundResource(com.xscm.moduleutil.R.color.white);
|
getWindow().getDecorView().setBackgroundResource(com.xscm.moduleutil.R.color.white);
|
||||||
title = getIntent().getStringExtra("title");
|
title = getIntent().getStringExtra("title");
|
||||||
url = getIntent().getStringExtra("url");
|
url = getIntent().getStringExtra("url");
|
||||||
if (title!=null) {
|
type = getIntent().getStringExtra("type");
|
||||||
|
if (type != null) {
|
||||||
|
// 当type==1时,禁用返回手势滑动
|
||||||
|
if (type.equals("1")) {
|
||||||
|
// 禁用边缘滑动返回
|
||||||
|
if (getSupportActionBar() != null) {
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (title != null) {
|
||||||
if (title.equals("举报") || title.equals("等级") || title.equals("公会") || title.equals("邀请") || title.equals("反馈")) {
|
if (title.equals("举报") || title.equals("等级") || title.equals("公会") || title.equals("邀请") || title.equals("反馈")) {
|
||||||
mBinding.topBar.setVisibility(GONE);
|
mBinding.topBar.setVisibility(GONE);
|
||||||
// mBinding.webView.setPadding(0,20,0,0);
|
// mBinding.webView.setPadding(0,20,0,0);
|
||||||
@@ -227,20 +329,18 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
|||||||
mBinding.topBar.setVisibility(VISIBLE);
|
mBinding.topBar.setVisibility(VISIBLE);
|
||||||
mBinding.topBar.setTitle(title);
|
mBinding.topBar.setTitle(title);
|
||||||
}
|
}
|
||||||
}else {
|
} else {
|
||||||
if (url.equals(CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=6")){
|
if (url.equals(CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl() + "/api/Page/page_show?id=6")) {
|
||||||
mBinding.topBar.setVisibility(VISIBLE);
|
mBinding.topBar.setVisibility(VISIBLE);
|
||||||
mBinding.topBar.setTitle("用户协议");
|
mBinding.topBar.setTitle("用户协议");
|
||||||
}else if (url.equals(CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=4")){
|
} else if (url.equals(CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl() + "/api/Page/page_show?id=4")) {
|
||||||
mBinding.topBar.setVisibility(VISIBLE);
|
mBinding.topBar.setVisibility(VISIBLE);
|
||||||
mBinding.topBar.setTitle("隐私协议");
|
mBinding.topBar.setTitle("隐私协议");
|
||||||
}else {
|
} else {
|
||||||
mBinding.topBar.setVisibility(GONE);
|
mBinding.topBar.setVisibility(GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -250,9 +350,11 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
|||||||
|
|
||||||
public class WebAppInterface {
|
public class WebAppInterface {
|
||||||
Context mContext;
|
Context mContext;
|
||||||
|
String type;
|
||||||
|
|
||||||
WebAppInterface(Context c) {
|
WebAppInterface(Context c, String type1) {
|
||||||
mContext = c;
|
mContext = c;
|
||||||
|
type = type1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 被 H5 调用的方法
|
// 被 H5 调用的方法
|
||||||
@@ -263,8 +365,15 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
|||||||
|
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
public void closeWeb() {
|
public void closeWeb() {
|
||||||
LogUtils.e("value: ");
|
if (type != null) {
|
||||||
finish();
|
if (type.equals("1")) {
|
||||||
|
ARouter.getInstance().build(ARouteConstants.UNDERAGE_ACTIVITY).withInt("type", 1).navigation();
|
||||||
|
} else {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
@@ -281,8 +390,11 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
|||||||
|
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
public void jumpRoomPage(String room_id) {
|
public void jumpRoomPage(String room_id) {
|
||||||
ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("form", "首页").withString("roomId", room_id).navigation();
|
RoomManager.getInstance().fetchRoomDataAndEnter(getApplicationContext(), room_id,"");
|
||||||
|
|
||||||
|
// ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("form", "首页").withString("roomId", room_id).navigation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
public void jumpWebPage(String objects) {
|
public void jumpWebPage(String objects) {
|
||||||
// ARouter.getInstance().build(ARouteConstants.USER_HOME_PAGE).navigation();
|
// ARouter.getInstance().build(ARouteConstants.USER_HOME_PAGE).navigation();
|
||||||
@@ -290,22 +402,25 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
|||||||
}
|
}
|
||||||
|
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
public void enterGroupChat(String group_id,String cover,String guild_name) {
|
public void enterGroupChat(String group_id, String cover, String guild_name) {
|
||||||
Intent intent = new Intent(mContext, TUIGroupChatActivity.class);
|
Intent intent = new Intent(mContext, TUIGroupChatActivity.class);
|
||||||
intent.putExtra(TUIConstants.TUIChat.CHAT_ID, group_id);
|
intent.putExtra(TUIConstants.TUIChat.CHAT_ID, group_id);
|
||||||
|
intent.putExtra(TUIConstants.TUIChat.CHAT_NAME, guild_name);
|
||||||
intent.putExtra(TUIConstants.TUIChat.CHAT_TYPE, V2TIMConversation.V2TIM_GROUP);
|
intent.putExtra(TUIConstants.TUIChat.CHAT_TYPE, V2TIMConversation.V2TIM_GROUP);
|
||||||
mContext.startActivity(intent);
|
mContext.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
public void chatWithUser(String user_id,String nickname) {
|
public void chatWithUser(String user_id, String nickname) {
|
||||||
Intent intent = new Intent(mContext, TUIC2CChatActivity.class);
|
Intent intent = new Intent(mContext, TUIGroupChatActivity.class);
|
||||||
intent.putExtra(TUIConstants.TUIChat.CHAT_ID, user_id);
|
intent.putExtra(TUIConstants.TUIChat.CHAT_ID, user_id);
|
||||||
|
intent.putExtra(TUIConstants.TUIChat.CHAT_NAME, nickname);
|
||||||
intent.putExtra(TUIConstants.TUIChat.CHAT_TYPE, V2TIMConversation.V2TIM_C2C);
|
intent.putExtra(TUIConstants.TUIChat.CHAT_TYPE, V2TIMConversation.V2TIM_C2C);
|
||||||
mContext.startActivity(intent);
|
mContext.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
public void exchange(){
|
public void exchange() {
|
||||||
ARouter.getInstance().build(ARouteConstants.CURRENCY).navigation();
|
ARouter.getInstance().build(ARouteConstants.CURRENCY).navigation();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -321,7 +436,7 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
|||||||
}
|
}
|
||||||
|
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
public void Recharge(){
|
public void Recharge() {
|
||||||
ARouter.getInstance().build(ARouteConstants.RECHARGE_ACTIVITY).navigation();
|
ARouter.getInstance().build(ARouteConstants.RECHARGE_ACTIVITY).navigation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -333,6 +448,7 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
|||||||
// intent.putExtra("menuName", msg);
|
// intent.putExtra("menuName", msg);
|
||||||
// startActivity(intent);
|
// startActivity(intent);
|
||||||
|
|
||||||
|
|
||||||
LogUtils.e("closeWeb");
|
LogUtils.e("closeWeb");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14,6 +14,7 @@ import com.chad.library.adapter.base.BaseQuickAdapter;
|
|||||||
import com.chad.library.adapter.base.BaseViewHolder;
|
import com.chad.library.adapter.base.BaseViewHolder;
|
||||||
import com.xscm.moduleutil.R;
|
import com.xscm.moduleutil.R;
|
||||||
import com.xscm.moduleutil.activity.BaseMvpActivity;
|
import com.xscm.moduleutil.activity.BaseMvpActivity;
|
||||||
|
import com.xscm.moduleutil.base.RoomManager;
|
||||||
import com.xscm.moduleutil.bean.NewsMessageList;
|
import com.xscm.moduleutil.bean.NewsMessageList;
|
||||||
import com.xscm.moduleutil.databinding.ActivityOfficialNoticeBinding;
|
import com.xscm.moduleutil.databinding.ActivityOfficialNoticeBinding;
|
||||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||||
@@ -75,7 +76,8 @@ public class OfficialNoticeActivity extends BaseMvpActivity<NewsPresenter, Activ
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if (item.getRoom_id()>0){
|
if (item.getRoom_id()>0){
|
||||||
ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("roomId", item.getRoom_id() + "").navigation();
|
RoomManager.getInstance().fetchRoomDataAndEnter(getApplicationContext(), item.getRoom_id()+"","");
|
||||||
|
// ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("roomId", item.getRoom_id() + "").navigation();
|
||||||
}else if (item.getRoom_id() == 0 && item.getUrl() != null && !item.getUrl().isEmpty()){
|
}else if (item.getRoom_id() == 0 && item.getUrl() != null && !item.getUrl().isEmpty()){
|
||||||
ARouter.getInstance().build(ARouteConstants.H5).withString("url", item.getUrl()).navigation();
|
ARouter.getInstance().build(ARouteConstants.H5).withString("url", item.getUrl()).navigation();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import com.xscm.moduleutil.R;
|
|||||||
import com.xscm.moduleutil.base.BaseMvpFragment;
|
import com.xscm.moduleutil.base.BaseMvpFragment;
|
||||||
import com.xscm.moduleutil.bean.GiftLabelBean;
|
import com.xscm.moduleutil.bean.GiftLabelBean;
|
||||||
import com.xscm.moduleutil.bean.GiftPackBean;
|
import com.xscm.moduleutil.bean.GiftPackBean;
|
||||||
|
import com.xscm.moduleutil.bean.GiftPackEvent;
|
||||||
import com.xscm.moduleutil.bean.GiftPackListCount;
|
import com.xscm.moduleutil.bean.GiftPackListCount;
|
||||||
import com.xscm.moduleutil.bean.RewardUserBean;
|
import com.xscm.moduleutil.bean.RewardUserBean;
|
||||||
import com.xscm.moduleutil.bean.RoonGiftModel;
|
import com.xscm.moduleutil.bean.RoonGiftModel;
|
||||||
@@ -79,6 +80,9 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void loadDataIfNeeded(String id, int type, String roomId) {
|
public void loadDataIfNeeded(String id, int type, String roomId) {
|
||||||
|
if (MvpPre==null){
|
||||||
|
MvpPre = new RewardGiftPresenter(this, getActivity());
|
||||||
|
}
|
||||||
if (id.equals("0")) {
|
if (id.equals("0")) {
|
||||||
MvpPre.giftPack();
|
MvpPre.giftPack();
|
||||||
} else {
|
} else {
|
||||||
@@ -95,13 +99,18 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
public void onString(String giftId) {
|
public void onString(GiftPackEvent event) {
|
||||||
bdgiftId = giftId;
|
if (event!=null && event.getBdid()!=null) {
|
||||||
MvpPre.giftPack();
|
bdgiftId = event.getBdid();
|
||||||
|
MvpPre.giftPack();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initData() {
|
protected void initData() {
|
||||||
|
if (type==0){
|
||||||
|
MvpPre.getGiftList("0", type, roomId);
|
||||||
|
}
|
||||||
// if (id.equals("0")) {
|
// if (id.equals("0")) {
|
||||||
// MvpPre.giftPack();
|
// MvpPre.giftPack();
|
||||||
// } else {
|
// } else {
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.xscm.moduleutil.base;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*@author qx
|
||||||
|
*@data 2025/9/20
|
||||||
|
*@description: 模块之间的通讯接口
|
||||||
|
*/
|
||||||
|
public interface AppStateListener {
|
||||||
|
void onAppForeground();
|
||||||
|
void onAppBackground();
|
||||||
|
void onRoomActivityCreated(Activity roomActivity);
|
||||||
|
void onRoomActivityDestroyed();
|
||||||
|
boolean isRoomActivityActive();
|
||||||
|
void setFloatingWindowVisible(boolean visible);
|
||||||
|
boolean isFloatingWindowVisible();
|
||||||
|
|
||||||
|
// 新增方法
|
||||||
|
boolean shouldShowSplash();
|
||||||
|
void setShouldShowSplash(boolean shouldShow);
|
||||||
|
boolean isAppInBackground();
|
||||||
|
void setAppInBackground(boolean inBackground);
|
||||||
|
}
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
package com.xscm.moduleutil.base;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
|
||||||
|
import com.xscm.moduleutil.bean.room.RoomInfoResp;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
|
/**
|
||||||
|
*@author qx
|
||||||
|
*@data 2025/9/20
|
||||||
|
*@description: 应用状态管理的单例类
|
||||||
|
*/
|
||||||
|
// 在 common 模块中
|
||||||
|
public class AppStateManager implements AppStateListener {
|
||||||
|
private static AppStateManager instance;
|
||||||
|
private boolean isAppInBackground = true;
|
||||||
|
private boolean shouldShowSplash = true;
|
||||||
|
private WeakReference<Activity> roomActivityRef;
|
||||||
|
private boolean isFloatingWindowVisible = false;
|
||||||
|
private boolean isRoomActivityMinimized = false;
|
||||||
|
private AppStateManager() {
|
||||||
|
// 私有构造函数
|
||||||
|
}
|
||||||
|
|
||||||
|
public static synchronized AppStateManager getInstance() {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new AppStateManager();
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldShowSplash() {
|
||||||
|
return shouldShowSplash;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setShouldShowSplash(boolean shouldShow) {
|
||||||
|
this.shouldShowSplash = shouldShow;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAppInBackground() {
|
||||||
|
return isAppInBackground;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setAppInBackground(boolean inBackground) {
|
||||||
|
this.isAppInBackground = inBackground;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRoomActivityCreated(Activity roomActivity) {
|
||||||
|
roomActivityRef = new WeakReference<>(roomActivity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRoomActivityDestroyed() {
|
||||||
|
roomActivityRef = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isRoomActivityActive() {
|
||||||
|
Activity activity = getRoomActivity();
|
||||||
|
return activity != null && !activity.isFinishing();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Activity getRoomActivity() {
|
||||||
|
return roomActivityRef != null ? roomActivityRef.get() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFloatingWindowVisible(boolean visible) {
|
||||||
|
this.isFloatingWindowVisible = visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFloatingWindowVisible() {
|
||||||
|
return isFloatingWindowVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAppForeground() {
|
||||||
|
// 应用进入前台时的处理
|
||||||
|
setAppInBackground(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAppBackground() {
|
||||||
|
// 应用进入后台时的处理
|
||||||
|
setAppInBackground(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增方法:设置RoomActivity为最小化状态
|
||||||
|
public void setRoomActivityMinimized(boolean minimized) {
|
||||||
|
this.isRoomActivityMinimized = minimized;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增方法:检查RoomActivity是否处于最小化状态
|
||||||
|
public boolean isRoomActivityMinimized() {
|
||||||
|
return isRoomActivityMinimized;
|
||||||
|
}
|
||||||
|
private RoomInfoResp roomInfoResp;
|
||||||
|
public void setRoomInfo(RoomInfoResp roomInfoResp) {
|
||||||
|
// 处理RoomInfoResp对象
|
||||||
|
this.roomInfoResp = roomInfoResp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RoomInfoResp getRoomInfo() {
|
||||||
|
return roomInfoResp;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,23 +1,27 @@
|
|||||||
package com.xscm.moduleutil.base;
|
package com.xscm.moduleutil.base;
|
||||||
|
|
||||||
import static androidx.core.app.ActivityCompat.startActivityForResult;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
|
import android.content.ComponentCallbacks2;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.Signature;
|
import android.content.pm.Signature;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.os.PowerManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
|
import android.util.DisplayMetrics;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import androidx.multidex.MultiDex;
|
import androidx.multidex.MultiDex;
|
||||||
import androidx.multidex.MultiDexApplication;
|
import androidx.multidex.MultiDexApplication;
|
||||||
|
|
||||||
@@ -26,23 +30,29 @@ import com.blankj.utilcode.util.AppUtils;
|
|||||||
import com.blankj.utilcode.util.FileUtils;
|
import com.blankj.utilcode.util.FileUtils;
|
||||||
import com.blankj.utilcode.util.LogUtils;
|
import com.blankj.utilcode.util.LogUtils;
|
||||||
import com.blankj.utilcode.util.ProcessUtils;
|
import com.blankj.utilcode.util.ProcessUtils;
|
||||||
import com.blankj.utilcode.util.ServiceUtils;
|
|
||||||
import com.lahm.library.EasyProtectorLib;
|
import com.lahm.library.EasyProtectorLib;
|
||||||
import com.lahm.library.EmulatorCheckCallback;
|
import com.lahm.library.EmulatorCheckCallback;
|
||||||
import com.xscm.moduleutil.R;
|
import com.tencent.imsdk.v2.V2TIMAdvancedMsgListener;
|
||||||
|
import com.tencent.imsdk.v2.V2TIMManager;
|
||||||
|
import com.tencent.imsdk.v2.V2TIMMessage;
|
||||||
|
import com.tencent.imsdk.v2.V2TIMMessageManager;
|
||||||
|
import com.tencent.imsdk.v2.V2TIMMessageReceipt;
|
||||||
|
import com.tencent.imsdk.v2.V2TIMValueCallback;
|
||||||
import com.xscm.moduleutil.bean.UserBean;
|
import com.xscm.moduleutil.bean.UserBean;
|
||||||
|
import com.xscm.moduleutil.bean.UserInfo;
|
||||||
import com.xscm.moduleutil.event.AppLifecycleEvent;
|
import com.xscm.moduleutil.event.AppLifecycleEvent;
|
||||||
|
import com.xscm.moduleutil.event.UnreadCountEvent;
|
||||||
import com.xscm.moduleutil.interfaces.AppLifecycleUtil;
|
import com.xscm.moduleutil.interfaces.AppLifecycleUtil;
|
||||||
import com.xscm.moduleutil.listener.MessageListenerSingleton;
|
import com.xscm.moduleutil.listener.MessageListenerSingleton;
|
||||||
import com.xscm.moduleutil.rtc.AgoraManager;
|
import com.xscm.moduleutil.rtc.AgoraManager;
|
||||||
import com.xscm.moduleutil.service.MqttConnect;
|
import com.xscm.moduleutil.service.MqttConnect;
|
||||||
import com.xscm.moduleutil.service.MyMqttService;
|
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||||
|
import com.xscm.moduleutil.utils.CrashHandler;
|
||||||
import com.xscm.moduleutil.utils.SpUtil;
|
import com.xscm.moduleutil.utils.SpUtil;
|
||||||
import com.xscm.moduleutil.utils.UtilConfig;
|
import com.xscm.moduleutil.utils.UtilConfig;
|
||||||
import com.xscm.moduleutil.utils.config.EnvironmentEnum;
|
import com.xscm.moduleutil.utils.config.EnvironmentEnum;
|
||||||
import com.xscm.moduleutil.utils.config.EnvironmentPrefs;
|
import com.xscm.moduleutil.utils.config.EnvironmentPrefs;
|
||||||
import com.xscm.moduleutil.widget.CommonAppConfig;
|
import com.xscm.moduleutil.widget.CommonAppConfig;
|
||||||
import com.xscm.moduleutil.widget.PiaoPingManager;
|
|
||||||
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
|
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
|
||||||
import com.scwang.smartrefresh.layout.api.DefaultRefreshFooterCreator;
|
import com.scwang.smartrefresh.layout.api.DefaultRefreshFooterCreator;
|
||||||
import com.scwang.smartrefresh.layout.api.DefaultRefreshHeaderCreator;
|
import com.scwang.smartrefresh.layout.api.DefaultRefreshHeaderCreator;
|
||||||
@@ -60,17 +70,17 @@ import org.greenrobot.eventbus.EventBus;
|
|||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.List;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by cxf on 2017/8/3.
|
* Created by cxf on 2017/8/3.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class CommonAppContext extends MultiDexApplication {
|
public class CommonAppContext extends MultiDexApplication implements Application.ActivityLifecycleCallbacks {
|
||||||
|
|
||||||
private static CommonAppContext sInstance;
|
private static CommonAppContext sInstance;
|
||||||
private static Handler sMainThreadHandler;
|
private static Handler sMainThreadHandler;
|
||||||
@@ -85,11 +95,16 @@ public class CommonAppContext extends MultiDexApplication {
|
|||||||
public boolean isPlaying;
|
public boolean isPlaying;
|
||||||
|
|
||||||
public String playId;
|
public String playId;
|
||||||
|
public String lable_id;
|
||||||
|
public boolean isMicPlace;
|
||||||
|
|
||||||
|
public boolean isShowAg;
|
||||||
|
|
||||||
|
public boolean isRoomJoininj=false;
|
||||||
|
|
||||||
public String playCover;
|
public String playCover;
|
||||||
public boolean showSelf;//盲盒是否能送自己
|
public boolean showSelf;//盲盒是否能送自己
|
||||||
public String playName;
|
public String playName;
|
||||||
private final ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(1);
|
|
||||||
private ScheduledExecutorService scheduledExecutorServiceRoom = null;
|
|
||||||
private MqttConnect mqttConnect=null;
|
private MqttConnect mqttConnect=null;
|
||||||
|
|
||||||
// 添加后台状态标记
|
// 添加后台状态标记
|
||||||
@@ -107,6 +122,14 @@ public class CommonAppContext extends MultiDexApplication {
|
|||||||
return wasInBackground;
|
return wasInBackground;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int activityCount = 0;
|
||||||
|
|
||||||
|
private AppStateListener appStateListener;
|
||||||
|
private boolean isListeningUnreadCount = false;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
|
public UnreadCountEvent unreadCountEvent;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
@@ -114,22 +137,293 @@ public class CommonAppContext extends MultiDexApplication {
|
|||||||
sInstance = this;
|
sInstance = this;
|
||||||
sMainThreadHandler = new Handler();
|
sMainThreadHandler = new Handler();
|
||||||
EnvironmentPrefs prefs = new EnvironmentPrefs(this);
|
EnvironmentPrefs prefs = new EnvironmentPrefs(this);
|
||||||
|
// 添加内存优化配置
|
||||||
|
optimizeMemorySettings();
|
||||||
currentEnvironment = prefs.getSelectedEnvironment();
|
currentEnvironment = prefs.getSelectedEnvironment();
|
||||||
initialization();
|
initialization();
|
||||||
|
registerActivityLifecycleCallbacks(this);
|
||||||
|
appStateListener = AppStateManager.getInstance();
|
||||||
|
startListeningUnreadMessageCount();
|
||||||
|
// 全局设置字体不缩放
|
||||||
|
adjustFontScale(getResources().getConfiguration());
|
||||||
|
CrashHandler.init(this);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void adjustFontScale(Configuration configuration) {
|
||||||
|
if (configuration.fontScale != 1.0f) {
|
||||||
|
configuration.fontScale = 1.0f;
|
||||||
|
DisplayMetrics metrics = getResources().getDisplayMetrics();
|
||||||
|
getResources().updateConfiguration(configuration, metrics);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConfigurationChanged(Configuration newConfig) {
|
||||||
|
super.onConfigurationChanged(newConfig);
|
||||||
|
// 配置变化时重新应用字体设置
|
||||||
|
adjustFontScale(newConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 在适当的位置(如onCreate或onResume)添加实时监听
|
||||||
|
protected void startListeningUnreadMessageCount() {
|
||||||
|
if (!isListeningUnreadCount) {
|
||||||
|
// 添加未读消息数变化监听器
|
||||||
|
V2TIMMessageManager messageManager = V2TIMManager.getMessageManager();
|
||||||
|
messageManager.addAdvancedMsgListener(new V2TIMAdvancedMsgListener() {
|
||||||
|
@Override
|
||||||
|
public void onRecvNewMessage(V2TIMMessage msg) {
|
||||||
|
// 收到新消息时更新未读数
|
||||||
|
updateUnreadMessageCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRecvC2CReadReceipt(List<V2TIMMessageReceipt> receiptList) {
|
||||||
|
// 收到C2C消息已读回执时更新未读数
|
||||||
|
updateUnreadMessageCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
isListeningUnreadCount = true;
|
||||||
|
// 首次获取未读数
|
||||||
|
updateUnreadMessageCount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新未读消息数的方法
|
||||||
|
private void updateUnreadMessageCount() {
|
||||||
|
V2TIMManager.getConversationManager().getTotalUnreadMessageCount(new V2TIMValueCallback<Long>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Long aLong) {
|
||||||
|
// 通知未读数变化
|
||||||
|
notifyUnreadCountChanged(aLong != null ? aLong : 0L);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(int code, String desc) {
|
||||||
|
// 错误处理
|
||||||
|
notifyUnreadCountChanged(0L);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 通知未读数变化的方法(可以发送广播或EventBus事件)
|
||||||
|
private void notifyUnreadCountChanged(long unreadCount) {
|
||||||
|
UnreadCountEvent event =unreadCountEvent;
|
||||||
|
if (event==null){
|
||||||
|
event=new UnreadCountEvent();
|
||||||
|
}
|
||||||
|
event.setALong(unreadCount);
|
||||||
|
// 使用EventBus通知
|
||||||
|
CommonAppContext.getInstance().setUnreadCountEvent(event);
|
||||||
|
EventBus.getDefault().post(event);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 检查网络是否可用
|
||||||
|
* @return true表示网络可用,false表示网络不可用
|
||||||
|
*/
|
||||||
|
public boolean isNetworkAvailable() {
|
||||||
|
try {
|
||||||
|
// 获取网络连接管理器
|
||||||
|
android.net.ConnectivityManager connectivityManager =
|
||||||
|
(android.net.ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
|
|
||||||
|
if (connectivityManager != null) {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
// Android 6.0及以上版本
|
||||||
|
android.net.Network network = connectivityManager.getActiveNetwork();
|
||||||
|
if (network != null) {
|
||||||
|
android.net.NetworkCapabilities capabilities =
|
||||||
|
connectivityManager.getNetworkCapabilities(network);
|
||||||
|
if (capabilities != null) {
|
||||||
|
// 检查是否有网络连接并且可以访问互联网
|
||||||
|
return capabilities.hasCapability(android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET) &&
|
||||||
|
capabilities.hasCapability(android.net.NetworkCapabilities.NET_CAPABILITY_VALIDATED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Android 6.0以下版本
|
||||||
|
android.net.NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
|
||||||
|
return activeNetworkInfo != null && activeNetworkInfo.isConnected();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtils.e("Network availability check failed: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查网络是否可用(简化版本)
|
||||||
|
* @return true表示网络可用,false表示网络不可用
|
||||||
|
*/
|
||||||
|
public boolean isNetworkConnected() {
|
||||||
|
try {
|
||||||
|
android.net.ConnectivityManager connectivityManager =
|
||||||
|
(android.net.ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
|
|
||||||
|
if (connectivityManager != null) {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
android.net.Network network = connectivityManager.getActiveNetwork();
|
||||||
|
return network != null;
|
||||||
|
} else {
|
||||||
|
android.net.NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
|
||||||
|
return activeNetworkInfo != null && activeNetworkInfo.isConnected();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtils.e("Network connection check failed: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 优化内存设置
|
||||||
|
*/
|
||||||
|
private void optimizeMemorySettings() {
|
||||||
|
try {
|
||||||
|
// 请求降低内存负载
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
// 启用自动内存管理优化
|
||||||
|
registerComponentCallbacks(new ComponentCallbacks2() {
|
||||||
|
@Override
|
||||||
|
public void onTrimMemory(int level) {
|
||||||
|
handleMemoryTrim(level);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConfigurationChanged(@NonNull Configuration newConfig) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLowMemory() {
|
||||||
|
// 内存极低时的处理
|
||||||
|
releaseNonEssentialResources();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtils.e("Memory optimization setup failed: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理内存削减事件
|
||||||
|
* @param level 削减级别
|
||||||
|
*/
|
||||||
|
private void handleMemoryTrim(int level) {
|
||||||
|
switch (level) {
|
||||||
|
case TRIM_MEMORY_RUNNING_MODERATE:
|
||||||
|
// 应用正在运行,内存开始紧张
|
||||||
|
LogUtils.d("Memory trim: moderate");
|
||||||
|
break;
|
||||||
|
case TRIM_MEMORY_RUNNING_LOW:
|
||||||
|
// 应用正在运行,内存更加紧张
|
||||||
|
LogUtils.d("Memory trim: low");
|
||||||
|
releaseNonEssentialResources();
|
||||||
|
break;
|
||||||
|
case TRIM_MEMORY_RUNNING_CRITICAL:
|
||||||
|
// 应用仍在运行,但系统已开始杀死后台进程
|
||||||
|
LogUtils.d("Memory trim: critical");
|
||||||
|
releaseAllNonEssentialResources();
|
||||||
|
break;
|
||||||
|
case TRIM_MEMORY_UI_HIDDEN:
|
||||||
|
// 应用UI已隐藏,可以释放UI相关资源
|
||||||
|
LogUtils.d("Memory trim: UI hidden");
|
||||||
|
releaseUIResources();
|
||||||
|
break;
|
||||||
|
case TRIM_MEMORY_BACKGROUND:
|
||||||
|
// 应用处于LRU列表中较远位置
|
||||||
|
LogUtils.d("Memory trim: background");
|
||||||
|
break;
|
||||||
|
case TRIM_MEMORY_MODERATE:
|
||||||
|
// 应用处于LRU列表中间位置
|
||||||
|
LogUtils.d("Memory trim: moderate background");
|
||||||
|
releaseAllNonEssentialResources();
|
||||||
|
break;
|
||||||
|
case TRIM_MEMORY_COMPLETE:
|
||||||
|
// 应用处于LRU列表中最远位置,即将被杀死
|
||||||
|
LogUtils.d("Memory trim: complete");
|
||||||
|
releaseAllResources();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 释放非必要资源
|
||||||
|
*/
|
||||||
|
private void releaseNonEssentialResources() {
|
||||||
|
try {
|
||||||
|
// 清理图片缓存
|
||||||
|
// Glide.get(this).clearMemory();
|
||||||
|
|
||||||
|
// 释放MQTT资源
|
||||||
|
if (mqttConnect != null) {
|
||||||
|
mqttConnect.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 通知各个组件释放资源
|
||||||
|
// EventBus.getDefault().post(new MemoryTrimEvent());
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtils.e("Error releasing non-essential resources: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 释放所有非必要资源
|
||||||
|
*/
|
||||||
|
private void releaseAllNonEssentialResources() {
|
||||||
|
try {
|
||||||
|
releaseNonEssentialResources();
|
||||||
|
|
||||||
|
// 进行垃圾回收
|
||||||
|
System.gc();
|
||||||
|
System.runFinalization();
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtils.e("Error releasing all non-essential resources: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 释放UI相关资源
|
||||||
|
*/
|
||||||
|
private void releaseUIResources() {
|
||||||
|
try {
|
||||||
|
// 可以在这里通知UI组件释放资源
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtils.e("Error releasing UI resources: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 释放所有资源
|
||||||
|
*/
|
||||||
|
private void releaseAllResources() {
|
||||||
|
try {
|
||||||
|
releaseAllNonEssentialResources();
|
||||||
|
releaseUIResources();
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtils.e("Error releasing all resources: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAppStateListener(AppStateListener listener) {
|
||||||
|
this.appStateListener = listener;
|
||||||
|
}
|
||||||
public void initialization(){
|
public void initialization(){
|
||||||
UtilConfig.init(this);
|
UtilConfig.init(this);
|
||||||
registerActivityLifecycleCallbacks();
|
// registerActivityLifecycleCallbacks();
|
||||||
initWebView();
|
initWebView();
|
||||||
if (ProcessUtils.isMainProcess()) {
|
if (ProcessUtils.isMainProcess()) {
|
||||||
initARouter();
|
initARouter();
|
||||||
if (SpUtil.isAgreePolicy()) {
|
if (SpUtil.isAgreePolicy()) {
|
||||||
checkInEmulator();
|
checkInEmulator();
|
||||||
UtilConfig.checkInEmulator();
|
UtilConfig.checkInEmulator();
|
||||||
AgoraManager.getInstance(this).init(currentEnvironment.getSwSdkAppId());
|
AgoraManager.getInstance(this);
|
||||||
|
AgoraManager.init(currentEnvironment.getSwSdkAppId());
|
||||||
MessageListenerSingleton.getInstance();
|
MessageListenerSingleton.getInstance();
|
||||||
CrashReport.initCrashReport(this, "ac3ed4d89f", true);/*bugly初始化*/
|
CrashReport.initCrashReport(this, "ac3ed4d89f", true);/*bugly初始化*/
|
||||||
// // 启动 MQTT 服务
|
// // 启动 MQTT 服务
|
||||||
@@ -145,6 +439,7 @@ public class CommonAppContext extends MultiDexApplication {
|
|||||||
|
|
||||||
// 每次启动应用时重置状态
|
// 每次启动应用时重置状态
|
||||||
SpUtil.getInstance().setBooleanValue("youth_model_shown", false);
|
SpUtil.getInstance().setBooleanValue("youth_model_shown", false);
|
||||||
|
startInitSdk();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// piaoPingManager = PiaoPingManager.getInstance(this);
|
// piaoPingManager = PiaoPingManager.getInstance(this);
|
||||||
@@ -155,8 +450,26 @@ public class CommonAppContext extends MultiDexApplication {
|
|||||||
startActivityForResult(intent, 100);
|
startActivityForResult(intent, 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
// requestBatteryOptimizationExemption();
|
||||||
|
}
|
||||||
|
private void requestBatteryOptimizationExemption() {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
Intent intent = new Intent();
|
||||||
|
String packageName = getPackageName();
|
||||||
|
PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
|
||||||
|
if (pm != null && !pm.isIgnoringBatteryOptimizations(packageName)) {
|
||||||
|
intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
|
||||||
|
intent.setData(Uri.parse("package:" + packageName));
|
||||||
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
try {
|
||||||
|
startActivity(intent);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtils.e("Failed to request battery optimization exemption: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
private void startActivityForResult(Intent intent, int i) {
|
private void startActivityForResult(Intent intent, int i) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -396,6 +709,11 @@ public class CommonAppContext extends MultiDexApplication {
|
|||||||
return mUserBean;
|
return mUserBean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UserInfo getUserInfo() {
|
||||||
|
UserInfo userInfo = SpUtil.getUserInfo();
|
||||||
|
return userInfo;
|
||||||
|
}
|
||||||
|
|
||||||
public void setUserBean(UserBean bean) {
|
public void setUserBean(UserBean bean) {
|
||||||
mUserBean = bean;
|
mUserBean = bean;
|
||||||
}
|
}
|
||||||
@@ -462,4 +780,109 @@ public class CommonAppContext extends MultiDexApplication {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle savedInstanceState) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityStarted(@NonNull Activity activity) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityResumed(@NonNull Activity activity) {
|
||||||
|
if (activityCount == 0) {
|
||||||
|
// 应用从后台回到前台
|
||||||
|
if (appStateListener != null) {
|
||||||
|
appStateListener.onAppForeground();
|
||||||
|
}
|
||||||
|
// handleAppForeground(activity);
|
||||||
|
// AppStateManager.setRoomActivityMinimized(false);
|
||||||
|
}
|
||||||
|
activityCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityPaused(@NonNull Activity activity) {
|
||||||
|
activityCount--;
|
||||||
|
if (activityCount == 0) {
|
||||||
|
// 应用切换到后台
|
||||||
|
if (appStateListener != null) {
|
||||||
|
appStateListener.onAppBackground();
|
||||||
|
}
|
||||||
|
// handleAppBackground(activity);
|
||||||
|
// AppStateManager.setRoomActivityMinimized( true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleAppBackground(Activity activity) {
|
||||||
|
String className = activity.getClass().getName();
|
||||||
|
if (className.contains("RoomActivity") && appStateListener != null) {
|
||||||
|
// RoomActivity进入后台时显示悬浮窗
|
||||||
|
appStateListener.setFloatingWindowVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void handleAppForeground(Activity activity) {
|
||||||
|
// 获取当前Activity的类名,避免直接引用类
|
||||||
|
String className = activity.getClass().getName();
|
||||||
|
|
||||||
|
if (className.contains("LaunchPageActivity")) {
|
||||||
|
// 对于启动页,我们需要检查是否应该跳转到主页面
|
||||||
|
if (appStateListener != null && appStateListener.isFloatingWindowVisible()) {
|
||||||
|
// 有悬浮窗,直接回到首页
|
||||||
|
ARouter.getInstance().build(ARouteConstants.ME).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP).navigation();
|
||||||
|
} else if (appStateListener != null && appStateListener.shouldShowSplash()) {
|
||||||
|
// 需要显示启动页,但已经在启动页了,不需要额外操作
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
// 默认情况下,跳转到主页面
|
||||||
|
ARouter.getInstance().build(ARouteConstants.ME).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP).navigation();
|
||||||
|
}
|
||||||
|
return; // 启动页或引导页不需要特殊处理
|
||||||
|
}
|
||||||
|
|
||||||
|
if (appStateListener != null && appStateListener.isFloatingWindowVisible()) {
|
||||||
|
// 有悬浮窗,直接回到首页
|
||||||
|
// if (!className.contains("MainActivity")) {
|
||||||
|
ARouter.getInstance().build(ARouteConstants.ME).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP).navigation();
|
||||||
|
// }
|
||||||
|
} else if (appStateListener != null && appStateListener.shouldShowSplash()) {
|
||||||
|
// 需要显示启动页
|
||||||
|
try {
|
||||||
|
Class<?> splashActivityClass = Class.forName("com.xscm.modulemain.activity.LaunchPageActivity");
|
||||||
|
Intent intent = new Intent(activity, splashActivityClass);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
activity.startActivity(intent);
|
||||||
|
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showFloatingWindow(Activity activity) {
|
||||||
|
// 这里实现显示悬浮窗的逻辑
|
||||||
|
AppStateManager.getInstance().setFloatingWindowVisible(true);
|
||||||
|
// 实际显示悬浮窗的代码,已实现
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityStopped(@NonNull Activity activity) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivitySaveInstanceState(@NonNull Activity activity, @NonNull Bundle outState) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityDestroyed(@NonNull Activity activity) {
|
||||||
|
// String className = activity.getClass().getName();
|
||||||
|
// if (className.contains("RoomActivity") && appStateListener != null) {
|
||||||
|
// appStateListener.onRoomActivityDestroyed();
|
||||||
|
// }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,537 @@
|
|||||||
|
package com.xscm.moduleutil.base;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import com.alibaba.android.arouter.launcher.ARouter;
|
||||||
|
import com.blankj.utilcode.util.LogUtils;
|
||||||
|
import com.blankj.utilcode.util.ToastUtils;
|
||||||
|
import com.xscm.moduleutil.bean.room.RoomInfoResp;
|
||||||
|
import com.xscm.moduleutil.bean.room.RoomOnline;
|
||||||
|
import com.xscm.moduleutil.bean.room.RoomOnlineBean;
|
||||||
|
import com.xscm.moduleutil.event.RoomOutEvent;
|
||||||
|
import com.xscm.moduleutil.http.BaseObserver;
|
||||||
|
import com.xscm.moduleutil.http.RetrofitClient;
|
||||||
|
import com.xscm.moduleutil.listener.MessageListenerSingleton;
|
||||||
|
import com.xscm.moduleutil.rtc.AgoraManager;
|
||||||
|
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||||
|
import com.xscm.moduleutil.utils.SpUtil;
|
||||||
|
import com.xscm.moduleutil.utils.logger.Logger;
|
||||||
|
|
||||||
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import io.reactivex.disposables.Disposable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 房间管理器
|
||||||
|
* 统一处理房间数据获取、进入房间和退出房间的逻辑
|
||||||
|
*/
|
||||||
|
public class RoomManager {
|
||||||
|
private static final String TAG = "RoomManager";
|
||||||
|
|
||||||
|
private static RoomManager instance;
|
||||||
|
|
||||||
|
// 房间数据缓存
|
||||||
|
private Map<String, RoomInfoResp> roomDataCache = new ConcurrentHashMap<>();
|
||||||
|
private Map<String, Long> cacheTimestamps = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
// 缓存有效期(5分钟)
|
||||||
|
private static final long CACHE_DURATION = 5 * 60 * 1000;
|
||||||
|
|
||||||
|
private RoomManager() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static synchronized RoomManager getInstance() {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new RoomManager();
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 进入房间 - 自动获取房间数据
|
||||||
|
*
|
||||||
|
* @param context 上下文
|
||||||
|
* @param roomId 房间ID
|
||||||
|
*/
|
||||||
|
public void enterRoom(Context context, String roomId) {
|
||||||
|
enterRoom(context, roomId, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 进入房间 - 使用密码
|
||||||
|
*
|
||||||
|
* @param context 上下文
|
||||||
|
* @param roomId 房间ID
|
||||||
|
* @param password 房间密码
|
||||||
|
*/
|
||||||
|
public void enterRoom(Context context, String roomId, String password) {
|
||||||
|
enterRoom(context, roomId, password, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 进入房间 - 使用缓存数据
|
||||||
|
*
|
||||||
|
* @param context 上下文
|
||||||
|
* @param roomId 房间ID
|
||||||
|
* @param password 房间密码
|
||||||
|
* @param cachedData 缓存的房间数据
|
||||||
|
*/
|
||||||
|
public void enterRoom(Context context, String roomId, String password, RoomInfoResp cachedData) {
|
||||||
|
if (TextUtils.isEmpty(roomId)) {
|
||||||
|
ToastUtils.showShort("房间ID不能为空");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查是否有有效的缓存数据
|
||||||
|
RoomInfoResp roomInfo = cachedData != null ? cachedData : getCachedRoomData(roomId);
|
||||||
|
|
||||||
|
if (roomInfo != null) {
|
||||||
|
// 使用缓存数据直接进入房间
|
||||||
|
navigateToRoom(context, roomId, password, roomInfo, false);
|
||||||
|
} else {
|
||||||
|
// 获取房间数据后进入房间
|
||||||
|
fetchRoomDataAndEnter(context, roomId, password);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取房间数据并进入房间
|
||||||
|
*
|
||||||
|
* @param context 上下文
|
||||||
|
* @param roomId 房间ID
|
||||||
|
* @param password 房间密码
|
||||||
|
*/
|
||||||
|
public void fetchRoomDataAndEnter(Context context, String roomId, String password) {
|
||||||
|
// 显示加载提示
|
||||||
|
// 这里可以根据需要添加加载对话框
|
||||||
|
if (CommonAppContext.getInstance().isRoomJoininj){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
CommonAppContext.getInstance().isRoomJoininj=true;
|
||||||
|
// 检查是否有有效的缓存数据
|
||||||
|
// RoomInfoResp roomInfo = getCachedRoomData(roomId);
|
||||||
|
// 检查是否是当前房间且用户在线
|
||||||
|
// boolean isCurrentRoom = isCurrentRoom(roomId);
|
||||||
|
if (CommonAppContext.getInstance().playId == null) {
|
||||||
|
fetchAndJoinRoom(context, roomId, password);
|
||||||
|
} else {
|
||||||
|
if (!CommonAppContext.getInstance().playId.equals(roomId)) {
|
||||||
|
MessageListenerSingleton.getInstance().joinGroup(roomId);
|
||||||
|
exitRoom(CommonAppContext.getInstance().playId);
|
||||||
|
} else if (CommonAppContext.getInstance().lable_id.equals("6")) {
|
||||||
|
upInfo(context, roomId, password, true, null, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
isUserOnline(context, roomId, password, null);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// try {
|
||||||
|
// Thread.sleep(1000);
|
||||||
|
// } catch (InterruptedException e) {
|
||||||
|
// Thread.currentThread().interrupt();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// 如果是当前房间且用户在线,直接跳转到房间页面,仅更新数据
|
||||||
|
|
||||||
|
|
||||||
|
// // 获取房间数据
|
||||||
|
// MessageListenerSingleton.getInstance().joinGroup(roomId);
|
||||||
|
// // 等待一段时间确保退出完成
|
||||||
|
// try {
|
||||||
|
// Thread.sleep(500);
|
||||||
|
// } catch (InterruptedException e) {
|
||||||
|
// Thread.currentThread().interrupt();
|
||||||
|
// }
|
||||||
|
// RetrofitClient.getInstance().roomGetIn(roomId, password, new BaseObserver<RoomInfoResp>() {
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void onSubscribe(Disposable d) {
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void onNext(RoomInfoResp resp) {
|
||||||
|
// String appId = CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId();
|
||||||
|
// String token = resp.getUser_info().getAgora_token(); // 如果启用了鉴权才需要
|
||||||
|
// String roomId = resp.getRoom_info().getRoom_id(); // 房间 ID
|
||||||
|
// String rtm_token=resp.getUser_info().getAgora_rtm_token();
|
||||||
|
// SpUtil.setRtmToken(rtm_token);
|
||||||
|
// int uid = SpUtil.getUserId(); // 0 表示由 Agora 自动生成 UID
|
||||||
|
// boolean enableMic = false; // 是否开启麦克风
|
||||||
|
// boolean enableJs=false; // 是否开启角色
|
||||||
|
// if (resp.getUser_info().getPit_number()!=0){
|
||||||
|
// enableJs=true;
|
||||||
|
// }
|
||||||
|
// LogUtils.e("token",token);
|
||||||
|
// LogUtils.e("roomId:",roomId);
|
||||||
|
//// 初始化 Agora 并加入房间
|
||||||
|
// AgoraManager.getInstance(context)
|
||||||
|
// .joinRoom(token, roomId, uid, enableMic,enableJs);
|
||||||
|
// cacheRoomData(roomId, resp);
|
||||||
|
// navigateToRoom(context, roomId, password, resp);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
// 临时实现 - 直接跳转(因为缺少具体的网络请求代码)
|
||||||
|
// navigateToRoom(context, roomId, password, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void upInfo(Context context, String roomId, String password, boolean isOnline, RoomInfoResp roomInfo, boolean isCurrentRoom) {
|
||||||
|
|
||||||
|
|
||||||
|
if (isOnline) {
|
||||||
|
navigateToRoom(context, roomId, password, roomInfo, isOnline);
|
||||||
|
} else {
|
||||||
|
// CommonAppContext.getInstance().isShow = false;
|
||||||
|
// CommonAppContext.getInstance().isPlaying = false;
|
||||||
|
// EventBus.getDefault().post(new RoomOutEvent());
|
||||||
|
// try {
|
||||||
|
// Thread.sleep(300);
|
||||||
|
// } catch (InterruptedException e) {
|
||||||
|
// Thread.currentThread().interrupt();
|
||||||
|
// }
|
||||||
|
fetchAndJoinRoom(context, roomId, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// if (isCurrentRoom&& isOnline) {
|
||||||
|
// if (roomInfo != null) {
|
||||||
|
// navigateToRoom(context, roomId, password, roomInfo);
|
||||||
|
// } else {
|
||||||
|
// // 即使在线,如果没有缓存数据,也需要获取数据
|
||||||
|
// fetchAndJoinRoom(context, roomId, password);
|
||||||
|
// }
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// 如果有缓存数据且用户在线,使用缓存数据进入房间
|
||||||
|
// if (roomInfo != null && isOnline) {
|
||||||
|
// RetrofitClient.getInstance().postRoomInfo(roomId, new BaseObserver<RoomInfoResp>() {
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void onSubscribe(Disposable d) {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void onNext(RoomInfoResp roomInfoResp) {
|
||||||
|
//// cacheRoomData(roomId, roomInfo);
|
||||||
|
// navigateToRoom(context, roomId, password, roomInfoResp);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
// cacheRoomData(roomId, roomInfo);
|
||||||
|
// navigateToRoom(context, roomId, password, roomInfo);
|
||||||
|
return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// 其他情况,获取新的房间数据并加入房间
|
||||||
|
// fetchAndJoinRoom(context, roomId, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取新的房间数据并加入房间
|
||||||
|
*
|
||||||
|
* @param context 上下文
|
||||||
|
* @param roomId 房间ID
|
||||||
|
* @param password 房间密码
|
||||||
|
*/
|
||||||
|
private void fetchAndJoinRoom(Context context, String roomId, String password) {
|
||||||
|
// 获取房间数据
|
||||||
|
|
||||||
|
// 等待一段时间确保退出完成
|
||||||
|
try {
|
||||||
|
Thread.sleep(300);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
navigateToRoom(context, roomId, password, null, false);
|
||||||
|
|
||||||
|
// RetrofitClient.getInstance().roomGetIn(roomId, password, new BaseObserver<RoomInfoResp>() {
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void onSubscribe(Disposable d) {
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void onNext(RoomInfoResp resp) {
|
||||||
|
// String appId = CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId();
|
||||||
|
// String token = resp.getUser_info().getAgora_token(); // 如果启用了鉴权才需要
|
||||||
|
// String roomId = resp.getRoom_info().getRoom_id(); // 房间 ID
|
||||||
|
// String rtm_token=resp.getUser_info().getAgora_rtm_token();
|
||||||
|
// SpUtil.setRtmToken(rtm_token);
|
||||||
|
// int uid = SpUtil.getUserId(); // 0 表示由 Agora 自动生成 UID
|
||||||
|
// boolean enableMic = false; // 是否开启麦克风
|
||||||
|
// boolean enableJs=false; // 是否开启角色
|
||||||
|
// if (resp.getUser_info().getPit_number()!=0){
|
||||||
|
// enableJs=true;
|
||||||
|
// }
|
||||||
|
// LogUtils.e("token",token);
|
||||||
|
// LogUtils.e("roomId:",roomId);
|
||||||
|
//// 初始化 Agora 并加入房间
|
||||||
|
// AgoraManager.getInstance(context)
|
||||||
|
// .joinRoom(token, roomId, uid, enableMic,enableJs);
|
||||||
|
// cacheRoomData(roomId, resp);
|
||||||
|
// navigateToRoom(context, roomId, password, resp);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查是否是当前房间
|
||||||
|
*
|
||||||
|
* @param roomId 房间ID
|
||||||
|
* @return true表示是当前房间,false表示不是
|
||||||
|
*/
|
||||||
|
private boolean isCurrentRoom(String roomId) {
|
||||||
|
// 这里应该实现检查是否是当前房间的逻辑
|
||||||
|
// 可以通过检查当前Activity或者通过全局变量等方式实现
|
||||||
|
// 目前返回false,需要根据实际需求实现具体逻辑
|
||||||
|
|
||||||
|
RoomInfoResp roomInfo = getCachedRoomData(roomId);
|
||||||
|
if (roomInfo != null) {
|
||||||
|
if (roomInfo.getRoom_info().getRoom_id().equals(roomId)) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转到房间页面
|
||||||
|
*
|
||||||
|
* @param context 上下文
|
||||||
|
* @param roomId 房间ID
|
||||||
|
* @param password 房间密码
|
||||||
|
* @param roomInfo 房间信息
|
||||||
|
*/
|
||||||
|
private void navigateToRoom(Context context, String roomId, String password, RoomInfoResp roomInfo, boolean isOnline) {
|
||||||
|
try {
|
||||||
|
// 构建跳转参数
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putString("roomId", roomId);
|
||||||
|
bundle.putBoolean("isOnline", isOnline);
|
||||||
|
|
||||||
|
if (!TextUtils.isEmpty(password)) {
|
||||||
|
bundle.putString("password", password);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (roomInfo != null) {
|
||||||
|
// bundle.putSerializable("roomInfo", roomInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 使用ARouter跳转到房间页面
|
||||||
|
ARouter.getInstance()
|
||||||
|
.build(ARouteConstants.ROOM_DETAILS)
|
||||||
|
.with(bundle)
|
||||||
|
.withFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)
|
||||||
|
.navigation(context);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.e(TAG, "跳转房间页面失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缓存房间数据
|
||||||
|
*
|
||||||
|
* @param roomId 房间ID
|
||||||
|
* @param roomInfo 房间信息
|
||||||
|
*/
|
||||||
|
public void cacheRoomData(String roomId, RoomInfoResp roomInfo) {
|
||||||
|
|
||||||
|
if (TextUtils.isEmpty(roomId) || roomInfo == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 清除所有现有的缓存数据
|
||||||
|
roomDataCache.clear();
|
||||||
|
cacheTimestamps.clear();
|
||||||
|
roomDataCache.put(roomId, roomInfo);
|
||||||
|
cacheTimestamps.put(roomId, System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取缓存的房间数据
|
||||||
|
*
|
||||||
|
* @param roomId 房间ID
|
||||||
|
* @return 房间信息,如果缓存无效则返回null
|
||||||
|
*/
|
||||||
|
public RoomInfoResp getCachedRoomData(String roomId) {
|
||||||
|
if (TextUtils.isEmpty(roomId)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Long timestamp = cacheTimestamps.get(roomId);
|
||||||
|
if (timestamp == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查缓存是否过期
|
||||||
|
if (System.currentTimeMillis() - timestamp > CACHE_DURATION) {
|
||||||
|
// 缓存过期,清除数据
|
||||||
|
roomDataCache.remove(roomId);
|
||||||
|
cacheTimestamps.remove(roomId);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return roomDataCache.get(roomId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查用户是否在线
|
||||||
|
*
|
||||||
|
* @param roomId 房间ID
|
||||||
|
* @return true表示用户在线,false表示不在线
|
||||||
|
*/
|
||||||
|
private boolean isUserOnline(Context context, String roomId, String password, RoomInfoResp roomInfo) {
|
||||||
|
// 这里应该实现检查用户是否在线的逻辑
|
||||||
|
// 可以通过检查Agora是否还在房间中,或者通过服务端接口查询用户状态等方式实现
|
||||||
|
// 目前返回false,需要根据实际需求实现具体逻辑
|
||||||
|
// boolean isCurrentRoom=isCurrentRoom(roomId);
|
||||||
|
// try {
|
||||||
|
// Thread.sleep(300);
|
||||||
|
// } catch (InterruptedException e) {
|
||||||
|
// Thread.currentThread().interrupt();
|
||||||
|
// }
|
||||||
|
final boolean[] isOnline = {false};
|
||||||
|
RetrofitClient.getInstance().getRoomOnline(roomId, "1", "50", new BaseObserver<RoomOnline>() {
|
||||||
|
@Override
|
||||||
|
public void onSubscribe(Disposable d) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNext(RoomOnline roomOnline) {
|
||||||
|
try {
|
||||||
|
if (roomOnline != null) {
|
||||||
|
if (roomOnline.getOn_pit() != null) {
|
||||||
|
for (RoomOnlineBean roomOnlineBean : roomOnline.getOn_pit()) {
|
||||||
|
if (roomOnlineBean.getUser_id() == SpUtil.getUserId()) {
|
||||||
|
isOnline[0] = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (roomOnline.getOff_pit() != null) {
|
||||||
|
for (RoomOnlineBean roomOnlineBean : roomOnline.getOff_pit()) {
|
||||||
|
if (roomOnlineBean.getUser_id() == SpUtil.getUserId()) {
|
||||||
|
isOnline[0] = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
upInfo(context, roomId, password, isOnline[0], roomInfo, true);
|
||||||
|
} else {
|
||||||
|
isOnline[0] = false;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 捕获所有可能的异常,避免崩溃
|
||||||
|
e.printStackTrace();
|
||||||
|
isOnline[0] = false;
|
||||||
|
// 即使出现异常也继续执行
|
||||||
|
upInfo(context, roomId, password, isOnline[0], roomInfo, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return isOnline[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清除指定房间的缓存数据
|
||||||
|
*
|
||||||
|
* @param roomId 房间ID
|
||||||
|
*/
|
||||||
|
public void clearRoomCache(String roomId) {
|
||||||
|
if (!TextUtils.isEmpty(roomId)) {
|
||||||
|
roomDataCache.remove(roomId);
|
||||||
|
cacheTimestamps.remove(roomId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清除所有房间缓存数据
|
||||||
|
*/
|
||||||
|
public void clearAllRoomCache() {
|
||||||
|
roomDataCache.clear();
|
||||||
|
cacheTimestamps.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 退出房间
|
||||||
|
*
|
||||||
|
* @param roomId 房间ID
|
||||||
|
*/
|
||||||
|
public void exitRoom(String roomId) {
|
||||||
|
// 清除该房间的缓存数据
|
||||||
|
clearRoomCache(roomId);
|
||||||
|
|
||||||
|
// 可以在这里添加其他退出房间的逻辑
|
||||||
|
// 例如:通知服务器用户已退出、清理房间相关资源等
|
||||||
|
|
||||||
|
RetrofitClient.getInstance().quitRoom(roomId, SpUtil.getUserId() + "", new BaseObserver<String>() {
|
||||||
|
@Override
|
||||||
|
public void onSubscribe(Disposable d) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNext(String s) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Logger.d(TAG, "退出房间: " + roomId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量退出房间
|
||||||
|
*
|
||||||
|
* @param roomIds 房间ID列表
|
||||||
|
*/
|
||||||
|
public void exitRooms(String... roomIds) {
|
||||||
|
if (roomIds != null) {
|
||||||
|
for (String roomId : roomIds) {
|
||||||
|
exitRoom(roomId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取房间缓存状态
|
||||||
|
*
|
||||||
|
* @param roomId 房间ID
|
||||||
|
* @return 缓存状态信息
|
||||||
|
*/
|
||||||
|
public String getRoomCacheStatus(String roomId) {
|
||||||
|
if (TextUtils.isEmpty(roomId)) {
|
||||||
|
return "无效的房间ID";
|
||||||
|
}
|
||||||
|
|
||||||
|
Long timestamp = cacheTimestamps.get(roomId);
|
||||||
|
if (timestamp == null) {
|
||||||
|
return "未缓存";
|
||||||
|
}
|
||||||
|
|
||||||
|
long elapsed = System.currentTimeMillis() - timestamp;
|
||||||
|
if (elapsed > CACHE_DURATION) {
|
||||||
|
return "缓存已过期";
|
||||||
|
}
|
||||||
|
|
||||||
|
RoomInfoResp data = roomDataCache.get(roomId);
|
||||||
|
if (data == null) {
|
||||||
|
return "缓存数据为空";
|
||||||
|
}
|
||||||
|
|
||||||
|
return String.format("已缓存 (%d秒前)", elapsed / 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.xscm.moduleutil.bean;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
/**
|
||||||
|
*@author qx
|
||||||
|
*@data 2025/9/25
|
||||||
|
*@description: 绑定详情
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class BindDetail {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
private String alipay_name;//支付宝姓名
|
||||||
|
private String alipay_account;//支付宝账户
|
||||||
|
|
||||||
|
private String bank_card_number;//银行卡号
|
||||||
|
|
||||||
|
private String bank_user_name;//姓名
|
||||||
|
private String bank_card;//所属行
|
||||||
|
private String open_bank;//开户行
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.xscm.moduleutil.bean;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class GiftPackEvent {
|
||||||
|
private String bdid;
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.xscm.moduleutil.bean;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class MqttXlhEnd {
|
||||||
|
private String message;
|
||||||
|
}
|
||||||
@@ -13,7 +13,7 @@ public class MusicSongBean implements Serializable {
|
|||||||
|
|
||||||
private String did;//歌曲id
|
private String did;//歌曲id
|
||||||
private String room_id;
|
private String room_id;
|
||||||
private String song_code;//歌曲唯一标识
|
private String song_code="";//歌曲唯一标识
|
||||||
private String song_name;//歌曲名称
|
private String song_name;//歌曲名称
|
||||||
private String singer;//歌手
|
private String singer;//歌手
|
||||||
private String poster;//封面
|
private String poster;//封面
|
||||||
|
|||||||
@@ -35,7 +35,9 @@ public class RoomMessageEvent {
|
|||||||
private String jia_jia;
|
private String jia_jia;
|
||||||
private UserInfo FromUserInfo;
|
private UserInfo FromUserInfo;
|
||||||
private UserInfo ToUserInfo;
|
private UserInfo ToUserInfo;
|
||||||
|
private List<UserInfo> ToUserInfos;
|
||||||
private GiftBean GiftInfo;
|
private GiftBean GiftInfo;
|
||||||
|
private List<GiftBean> GiftInfos;
|
||||||
private int room_up_pit_type;
|
private int room_up_pit_type;
|
||||||
private MusicSongBean songInfo;
|
private MusicSongBean songInfo;
|
||||||
private MusicSongBean nextInfo;
|
private MusicSongBean nextInfo;
|
||||||
@@ -52,7 +54,7 @@ public class RoomMessageEvent {
|
|||||||
private String AcceptRoomId;//接收者所在的房间id
|
private String AcceptRoomId;//接收者所在的房间id
|
||||||
private String PkId;
|
private String PkId;
|
||||||
private String room_id;//当type==1的时候。这个roomId是对方的房间id
|
private String room_id;//当type==1的时候。这个roomId是对方的房间id
|
||||||
private String user_id;
|
private String user_id="";
|
||||||
private String pk_end_times;//pk结束时间
|
private String pk_end_times;//pk结束时间
|
||||||
private List<RoomPitBean> userCharmList;
|
private List<RoomPitBean> userCharmList;
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ public class UserBean implements Serializable {
|
|||||||
private String mobile;
|
private String mobile;
|
||||||
private int sex;
|
private int sex;
|
||||||
private int auth;
|
private int auth;
|
||||||
|
private int is_can_chat;//是否可以私聊,1:可以,0:不可以
|
||||||
|
private int can_chat_money;//需要充值的金额
|
||||||
|
|
||||||
private List<MultiUserBean> multi_user;
|
private List<MultiUserBean> multi_user;
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,9 @@ public class UserInfo implements Serializable {
|
|||||||
private String red_status;
|
private String red_status;
|
||||||
private String gift_num;
|
private String gift_num;
|
||||||
|
|
||||||
|
private int is_can_chat;//是否可以私聊,1:可以,0:不可以
|
||||||
|
private int can_chat_money;//需要充值的金额
|
||||||
|
|
||||||
private RelationshipBean qinmi;
|
private RelationshipBean qinmi;
|
||||||
private RelationshipBean zhenai;
|
private RelationshipBean zhenai;
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ public class BlindBoxBean {
|
|||||||
private int is_xlh; ///是否开启巡乐会 0 关闭 1 开启
|
private int is_xlh; ///是否开启巡乐会 0 关闭 1 开启
|
||||||
private Object xlh_data;
|
private Object xlh_data;
|
||||||
private List<GiftBean> gift_list;
|
private List<GiftBean> gift_list;
|
||||||
|
private String end_time;//巡乐会结束时间
|
||||||
|
|
||||||
private GiveGift give_homeowner_gift;//房主礼物
|
private GiveGift give_homeowner_gift;//房主礼物
|
||||||
private GiveGift locking_gift;//锁定礼物
|
private GiveGift locking_gift;//锁定礼物
|
||||||
@@ -95,6 +96,14 @@ public class BlindBoxBean {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Object endTime = map.get("end_time");
|
||||||
|
if (endTime != null) {
|
||||||
|
if (endTime instanceof String){
|
||||||
|
xlhData.setEnd_time(endTime.toString());
|
||||||
|
}else {
|
||||||
|
xlhData.setEnd_time(endTime.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return xlhData;
|
return xlhData;
|
||||||
}
|
}
|
||||||
@@ -118,6 +127,9 @@ public class BlindBoxBean {
|
|||||||
if (jsonObject.has("status")) {
|
if (jsonObject.has("status")) {
|
||||||
xlhData.setStatus(jsonObject.get("status").getAsInt());
|
xlhData.setStatus(jsonObject.get("status").getAsInt());
|
||||||
}
|
}
|
||||||
|
if (jsonObject.has("end_time")){
|
||||||
|
xlhData.setEnd_time(jsonObject.get("end_time").getAsString());
|
||||||
|
}
|
||||||
|
|
||||||
return xlhData;
|
return xlhData;
|
||||||
}
|
}
|
||||||
@@ -130,6 +142,7 @@ public class BlindBoxBean {
|
|||||||
private String start_num;//巡乐会开启需要达到的次数
|
private String start_num;//巡乐会开启需要达到的次数
|
||||||
private int current_num;//当前已抽奖次数
|
private int current_num;//当前已抽奖次数
|
||||||
private int status;
|
private int status;
|
||||||
|
private String end_time;
|
||||||
}
|
}
|
||||||
@Data
|
@Data
|
||||||
public static class GiveGift {
|
public static class GiveGift {
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ public class RoomInfoResp implements Serializable {
|
|||||||
private PkRoomInfo pk_info;
|
private PkRoomInfo pk_info;
|
||||||
private List<RoomPitBean> song_pit_list;
|
private List<RoomPitBean> song_pit_list;
|
||||||
private FriendInfo friend_info;
|
private FriendInfo friend_info;
|
||||||
|
private GiftXlh gift_cycle;
|
||||||
|
|
||||||
|
|
||||||
//弹出麦位操作弹出
|
//弹出麦位操作弹出
|
||||||
@@ -114,4 +115,18 @@ public class RoomInfoResp implements Serializable {
|
|||||||
public boolean isFreedomMode() {
|
public boolean isFreedomMode() {
|
||||||
return "1".equals(room_info.getWheat());
|
return "1".equals(room_info.getWheat());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class GiftXlh implements Serializable{
|
||||||
|
private XlhInfo xlh_info ;
|
||||||
|
}
|
||||||
|
@Data
|
||||||
|
public class XlhInfo implements Serializable{
|
||||||
|
private String activities_name;
|
||||||
|
private String icon;
|
||||||
|
|
||||||
|
private String xlh_status;
|
||||||
|
|
||||||
|
private String end_time;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class RoomPitBean implements Serializable {
|
|||||||
private int is_lock;//0未锁麦 1锁麦
|
private int is_lock;//0未锁麦 1锁麦
|
||||||
private int is_mute;//0未禁麦 1禁麦
|
private int is_mute;//0未禁麦 1禁麦
|
||||||
private int count_down;//麦位倒计时
|
private int count_down;//麦位倒计时
|
||||||
private String user_id;//麦位上用户id
|
private String user_id="";//麦位上用户id
|
||||||
private String nickname;//麦位上用户昵称
|
private String nickname;//麦位上用户昵称
|
||||||
private String avatar;//用户头像
|
private String avatar;//用户头像
|
||||||
private String sex;//性别
|
private String sex;//性别
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ public class RoomSettingBean implements MultiItemEntity {
|
|||||||
public static final int QXRoomSettingTypeRoomTypeGirl = 13;
|
public static final int QXRoomSettingTypeRoomTypeGirl = 13;
|
||||||
///交友 房
|
///交友 房
|
||||||
public static final int QXRoomSettingTypeRoomTypeJiaoy = 27;
|
public static final int QXRoomSettingTypeRoomTypeJiaoy = 27;
|
||||||
|
public static final int QXRoomSettingTypeRoomTypeHUYU = 28;
|
||||||
|
|
||||||
/// 常用工具
|
/// 常用工具
|
||||||
/// 房间补贴
|
/// 房间补贴
|
||||||
@@ -48,6 +49,7 @@ public class RoomSettingBean implements MultiItemEntity {
|
|||||||
public static final int QXRoomSettingTypeRoomCloseEffects = 25;
|
public static final int QXRoomSettingTypeRoomCloseEffects = 25;
|
||||||
/// 意见反馈
|
/// 意见反馈
|
||||||
public static final int QXRoomSettingTypeRoomReport = 26;
|
public static final int QXRoomSettingTypeRoomReport = 26;
|
||||||
|
public static final int QXRoomSettingTypeRoomFloatingScreen = 29;
|
||||||
|
|
||||||
public static final int ITEM_TYPE_DEFAULT = 0;
|
public static final int ITEM_TYPE_DEFAULT = 0;
|
||||||
public static final int ITEM_TYPE_WITH_ICON = 1;
|
public static final int ITEM_TYPE_WITH_ICON = 1;
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ public class ConfirmDialog extends Dialog {
|
|||||||
|
|
||||||
// 设置点击监听器
|
// 设置点击监听器
|
||||||
btnPositive.setOnClickListener(v -> {
|
btnPositive.setOnClickListener(v -> {
|
||||||
|
isCountdownCancelled = true; // 标记倒计时被取消
|
||||||
if (countDownTimer != null) {
|
if (countDownTimer != null) {
|
||||||
countDownTimer.cancel(); // 取消倒计时
|
countDownTimer.cancel(); // 取消倒计时
|
||||||
countDownTimer = null;
|
countDownTimer = null;
|
||||||
@@ -130,7 +131,7 @@ public class ConfirmDialog extends Dialog {
|
|||||||
// rootView.startAnimation(shake);
|
// rootView.startAnimation(shake);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
private boolean isCountdownCancelled = false; // 添加标志位
|
||||||
private void startCountdown(Button btnNegative) {
|
private void startCountdown(Button btnNegative) {
|
||||||
countDownTimer = new CountDownTimer(countdownSeconds * 1000L, 1000) {
|
countDownTimer = new CountDownTimer(countdownSeconds * 1000L, 1000) {
|
||||||
@Override
|
@Override
|
||||||
@@ -141,11 +142,14 @@ public class ConfirmDialog extends Dialog {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFinish() {
|
public void onFinish() {
|
||||||
btnNegative.setText(negativeButtonText);
|
// 检查是否被主动取消
|
||||||
if (negativeButtonClickListener != null) {
|
if (!isCountdownCancelled) {
|
||||||
negativeButtonClickListener.onClick(btnNegative); // 自动触发取消
|
btnNegative.setText(negativeButtonText);
|
||||||
|
if (negativeButtonClickListener != null) {
|
||||||
|
negativeButtonClickListener.onClick(btnNegative); // 自动触发取消
|
||||||
|
}
|
||||||
|
dismiss();
|
||||||
}
|
}
|
||||||
dismiss();
|
|
||||||
}
|
}
|
||||||
}.start();
|
}.start();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import androidx.annotation.NonNull;
|
|||||||
|
|
||||||
import com.blankj.utilcode.util.ScreenUtils;
|
import com.blankj.utilcode.util.ScreenUtils;
|
||||||
import com.xscm.moduleutil.R;
|
import com.xscm.moduleutil.R;
|
||||||
|
import com.xscm.moduleutil.bean.FirstChargeGiftBean;
|
||||||
import com.xscm.moduleutil.color.ThemeableDrawableUtils;
|
import com.xscm.moduleutil.color.ThemeableDrawableUtils;
|
||||||
import com.xscm.moduleutil.databinding.DialogRealNameBinding;
|
import com.xscm.moduleutil.databinding.DialogRealNameBinding;
|
||||||
import com.xscm.moduleutil.databinding.IndexDialogYouthModelBinding;
|
import com.xscm.moduleutil.databinding.IndexDialogYouthModelBinding;
|
||||||
@@ -20,6 +21,18 @@ import com.xscm.moduleutil.widget.dialog.BaseDialog;
|
|||||||
*/
|
*/
|
||||||
public class RealNameDialog extends BaseDialog<DialogRealNameBinding> {
|
public class RealNameDialog extends BaseDialog<DialogRealNameBinding> {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public interface OnFirstChargeListener {
|
||||||
|
void onFirstChargeConfirmed(String giftBean, int type);
|
||||||
|
void onFirstChargeCancelled();
|
||||||
|
}
|
||||||
|
private OnFirstChargeListener listener;
|
||||||
|
// 设置监听器的方法
|
||||||
|
public void setOnFirstChargeListener(OnFirstChargeListener listener) {
|
||||||
|
this.listener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
public RealNameDialog(@NonNull Context context) {
|
public RealNameDialog(@NonNull Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
}
|
}
|
||||||
@@ -36,8 +49,19 @@ public class RealNameDialog extends BaseDialog<DialogRealNameBinding> {
|
|||||||
Window window = getWindow();
|
Window window = getWindow();
|
||||||
window.setLayout((int) (ScreenUtils.getScreenWidth() * 315.f / 375), WindowManager.LayoutParams.WRAP_CONTENT);
|
window.setLayout((int) (ScreenUtils.getScreenWidth() * 315.f / 375), WindowManager.LayoutParams.WRAP_CONTENT);
|
||||||
|
|
||||||
mBinding.tvIKnow.setOnClickListener(v -> dismiss());
|
// mBinding.tvIKnow.setOnClickListener(v -> dismiss());
|
||||||
mBinding.ivClose.setOnClickListener(v -> dismiss());
|
// mBinding.ivClose.setOnClickListener(v -> dismiss());
|
||||||
|
|
||||||
|
mBinding.tvIKnow.setOnClickListener(v -> {
|
||||||
|
if (listener != null) {
|
||||||
|
listener.onFirstChargeConfirmed(null, 0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mBinding.ivClose.setOnClickListener(v -> {
|
||||||
|
if (listener != null) {
|
||||||
|
listener.onFirstChargeCancelled();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
ThemeableDrawableUtils.setThemeableRoundedBackground(mBinding.tvIKnow, ColorManager.getInstance().getPrimaryColorInt(), 53);
|
ThemeableDrawableUtils.setThemeableRoundedBackground(mBinding.tvIKnow, ColorManager.getInstance().getPrimaryColorInt(), 53);
|
||||||
mBinding.tvIKnow.setTextColor(ColorManager.getInstance().getButtonColorInt());
|
mBinding.tvIKnow.setTextColor(ColorManager.getInstance().getButtonColorInt());
|
||||||
|
|||||||
@@ -0,0 +1,228 @@
|
|||||||
|
package com.xscm.moduleutil.dialog;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.res.Resources;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.Gravity;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.webkit.JavascriptInterface;
|
||||||
|
import android.webkit.WebSettings;
|
||||||
|
import android.webkit.WebViewClient;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.alibaba.android.arouter.launcher.ARouter;
|
||||||
|
import com.blankj.utilcode.util.LogUtils;
|
||||||
|
import com.blankj.utilcode.util.ScreenUtils;
|
||||||
|
import com.tencent.imsdk.v2.V2TIMConversation;
|
||||||
|
import com.tencent.mm.opensdk.modelbiz.WXOpenCustomerServiceChat;
|
||||||
|
import com.tencent.mm.opensdk.openapi.IWXAPI;
|
||||||
|
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
|
||||||
|
import com.tencent.qcloud.tuicore.TUIConstants;
|
||||||
|
import com.tencent.qcloud.tuikit.tuichat.classicui.page.TUIC2CChatActivity;
|
||||||
|
import com.tencent.qcloud.tuikit.tuichat.classicui.page.TUIGroupChatActivity;
|
||||||
|
import com.xscm.moduleutil.R;
|
||||||
|
import com.xscm.moduleutil.base.CommonAppContext;
|
||||||
|
import com.xscm.moduleutil.base.RoomManager;
|
||||||
|
import com.xscm.moduleutil.databinding.DialogRoomAuctionWebviewBinding;
|
||||||
|
import com.xscm.moduleutil.databinding.WebViewDialogBinding;
|
||||||
|
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||||
|
import com.xscm.moduleutil.widget.dialog.BaseDialog;
|
||||||
|
/**
|
||||||
|
*@author qx
|
||||||
|
*@data 2025/9/24
|
||||||
|
*@description: 这是拍卖房的规则界面
|
||||||
|
*/
|
||||||
|
public class RoomAuctionWebViewDialog extends BaseDialog<DialogRoomAuctionWebviewBinding> {
|
||||||
|
|
||||||
|
String mUrl;
|
||||||
|
int type;//10:天空之境 11:岁月之城 12:时空之巅
|
||||||
|
|
||||||
|
public RoomAuctionWebViewDialog(@NonNull Context context, Bundle args) {
|
||||||
|
super(context, R.style.BaseDialogStyleH);
|
||||||
|
this.mUrl = args.getString("url");
|
||||||
|
this.type = args.getInt("type");
|
||||||
|
initData1();
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onStart() {
|
||||||
|
super.onStart();
|
||||||
|
if (getWindow() != null) {
|
||||||
|
// 获取屏幕尺寸
|
||||||
|
android.util.DisplayMetrics displayMetrics = getContext().getResources().getDisplayMetrics();
|
||||||
|
// 设置高度为屏幕高度的80%
|
||||||
|
android.view.WindowManager.LayoutParams params = getWindow().getAttributes();
|
||||||
|
params.height = (int) (displayMetrics.heightPixels * 0.9);
|
||||||
|
params.width = android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
||||||
|
getWindow().setAttributes(params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public int getLayoutId() {
|
||||||
|
return R.layout.dialog_room_auction_webview;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initView() {
|
||||||
|
setCancelable(true);
|
||||||
|
setCanceledOnTouchOutside(true);
|
||||||
|
Window window = getWindow();
|
||||||
|
assert window != null;
|
||||||
|
window.setGravity(Gravity.BOTTOM);
|
||||||
|
window.setLayout((int) (ScreenUtils.getScreenWidth() * 320.f / 375), WindowManager.LayoutParams.MATCH_PARENT);
|
||||||
|
mBinding.topBar.setTitle("规则");
|
||||||
|
mBinding.topBar.getIvBack().setOnClickListener(v -> dismiss());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initData() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void initData1() {
|
||||||
|
// WebSettings webSettings = mBinding.webView.getSettings();
|
||||||
|
// webSettings.setUseWideViewPort(true);
|
||||||
|
// webSettings.setLoadWithOverviewMode(true);
|
||||||
|
// webSettings.setJavaScriptEnabled(true);
|
||||||
|
// webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); //关闭webview中缓存
|
||||||
|
// //增加JSBridge
|
||||||
|
// mBinding.webView.addJavascriptInterface(new WebAppInterface(getContext()), "Android");
|
||||||
|
//// mBinding.webView.addJavascriptInterface(new WebViewBridgeConfig(title), WebViewBridgeConfig.NAME);
|
||||||
|
// webSettings.setBuiltInZoomControls(false);
|
||||||
|
// webSettings.setSupportZoom(false);
|
||||||
|
// webSettings.setDomStorageEnabled(true);
|
||||||
|
// webSettings.setBlockNetworkImage(false);//解决图片不显示
|
||||||
|
// // 启用 WebView 内容的滚动
|
||||||
|
// mBinding.webView.setVerticalScrollBarEnabled(true);
|
||||||
|
// mBinding.webView.setScrollbarFadingEnabled(true);
|
||||||
|
// webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||||
|
// webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
|
||||||
|
// mBinding.webView.setHorizontalScrollBarEnabled(false);//水平不显示
|
||||||
|
// mBinding.webView.setVerticalScrollBarEnabled(false); //垂直不显示
|
||||||
|
// mBinding.webView.setWebViewClient(new WebViewClient());
|
||||||
|
// mBinding.webView.setBackgroundColor(Color.TRANSPARENT);
|
||||||
|
// mBinding.webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
||||||
|
//
|
||||||
|
// mBinding.webView.requestFocus();
|
||||||
|
// mBinding.webView.loadUrl(mUrl);
|
||||||
|
|
||||||
|
WebSettings webSettings = mBinding.webView.getSettings();
|
||||||
|
webSettings.setUseWideViewPort(true);
|
||||||
|
webSettings.setLoadWithOverviewMode(true);
|
||||||
|
webSettings.setJavaScriptEnabled(true);
|
||||||
|
webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); //关闭webview中缓存
|
||||||
|
//增加JSBridge
|
||||||
|
mBinding.webView.addJavascriptInterface(new WebAppInterface(getContext()), "Android");
|
||||||
|
// mBinding.webView.addJavascriptInterface(new WebViewBridgeConfig(title), WebViewBridgeConfig.NAME);
|
||||||
|
webSettings.setBuiltInZoomControls(false);
|
||||||
|
webSettings.setSupportZoom(false);
|
||||||
|
webSettings.setDomStorageEnabled(true);
|
||||||
|
webSettings.setBlockNetworkImage(false);//解决图片不显示
|
||||||
|
webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||||
|
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
|
||||||
|
// 启用 WebView 内容的滚动,但隐藏滚动条
|
||||||
|
mBinding.webView.setHorizontalScrollBarEnabled(false);//水平不显示
|
||||||
|
mBinding.webView.setVerticalScrollBarEnabled(false); //垂直不显示滚动条
|
||||||
|
mBinding.webView.setWebViewClient(new WebViewClient());
|
||||||
|
mBinding.webView.setBackgroundColor(Color.TRANSPARENT);
|
||||||
|
mBinding.webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
||||||
|
|
||||||
|
// 确保内容可以滚动
|
||||||
|
webSettings.setDomStorageEnabled(true);
|
||||||
|
|
||||||
|
mBinding.webView.requestFocus();
|
||||||
|
mBinding.webView.loadUrl(mUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Resources getResources() {
|
||||||
|
return getContext().getResources();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class WebAppInterface {
|
||||||
|
Context mContext;
|
||||||
|
|
||||||
|
WebAppInterface(Context c) {
|
||||||
|
mContext = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 被 H5 调用的方法
|
||||||
|
@JavascriptInterface
|
||||||
|
public void showToast(String toast) {
|
||||||
|
Toast.makeText(mContext, toast, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@JavascriptInterface
|
||||||
|
public void closeWeb() {
|
||||||
|
LogUtils.e("value: ");
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
|
@JavascriptInterface
|
||||||
|
public void customerService() {
|
||||||
|
String appId = CommonAppContext.getInstance().getCurrentEnvironment().getWxAppId(); // 填移动应用(App)的 AppId
|
||||||
|
IWXAPI api = WXAPIFactory.createWXAPI(mContext, appId);
|
||||||
|
|
||||||
|
// 判断当前版本是否支持拉起客服会话
|
||||||
|
WXOpenCustomerServiceChat.Req req = new WXOpenCustomerServiceChat.Req();
|
||||||
|
req.corpId = "ww1de4300858c0b461"; // 企业ID
|
||||||
|
req.url = "https://work.weixin.qq.com/kfid/kfcb3d23a59c188a0e7"; // 客服URL
|
||||||
|
api.sendReq(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JavascriptInterface
|
||||||
|
public void jumpRoomPage(String room_id) {
|
||||||
|
RoomManager.getInstance().fetchRoomDataAndEnter(getContext(), room_id,"");
|
||||||
|
|
||||||
|
// ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("form", "首页").withString("roomId", room_id).navigation();
|
||||||
|
}
|
||||||
|
@JavascriptInterface
|
||||||
|
public void jumpWebPage(String objects) {
|
||||||
|
// ARouter.getInstance().build(ARouteConstants.USER_HOME_PAGE).navigation();
|
||||||
|
ARouter.getInstance().build(ARouteConstants.USER_HOME_PAGE).withString("userId", objects).navigation();
|
||||||
|
}
|
||||||
|
|
||||||
|
@JavascriptInterface
|
||||||
|
public void enterGroupChat(String group_id,String cover,String guild_name) {
|
||||||
|
Intent intent = new Intent(mContext, TUIGroupChatActivity.class);
|
||||||
|
intent.putExtra(TUIConstants.TUIChat.CHAT_ID, group_id);
|
||||||
|
intent.putExtra(TUIConstants.TUIChat.CHAT_TYPE, V2TIMConversation.V2TIM_GROUP);
|
||||||
|
mContext.startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JavascriptInterface
|
||||||
|
public void chatWithUser(String user_id,String nickname) {
|
||||||
|
Intent intent = new Intent(mContext, TUIC2CChatActivity.class);
|
||||||
|
intent.putExtra(TUIConstants.TUIChat.CHAT_ID, user_id);
|
||||||
|
intent.putExtra(TUIConstants.TUIChat.CHAT_TYPE, V2TIMConversation.V2TIM_C2C);
|
||||||
|
mContext.startActivity(intent);
|
||||||
|
}
|
||||||
|
@JavascriptInterface
|
||||||
|
public void exchange(){
|
||||||
|
ARouter.getInstance().build(ARouteConstants.CURRENCY).navigation();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@JavascriptInterface
|
||||||
|
public void Withdrawal() {
|
||||||
|
ARouter.getInstance().build(ARouteConstants.WITHDRAWAL_ACTIVITY).navigation();
|
||||||
|
}
|
||||||
|
|
||||||
|
@JavascriptInterface
|
||||||
|
public void enterAuthent() {//实名认证
|
||||||
|
ARouter.getInstance().build(ARouteConstants.REAL_NAME_ACTIVITY2).navigation();
|
||||||
|
}
|
||||||
|
|
||||||
|
@JavascriptInterface
|
||||||
|
public void Recharge(){
|
||||||
|
ARouter.getInstance().build(ARouteConstants.RECHARGE_ACTIVITY).navigation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -22,6 +22,7 @@ import com.blankj.utilcode.util.LogUtils;
|
|||||||
import com.blankj.utilcode.util.ScreenUtils;
|
import com.blankj.utilcode.util.ScreenUtils;
|
||||||
import com.xscm.moduleutil.R;
|
import com.xscm.moduleutil.R;
|
||||||
import com.xscm.moduleutil.base.CommonAppContext;
|
import com.xscm.moduleutil.base.CommonAppContext;
|
||||||
|
import com.xscm.moduleutil.base.RoomManager;
|
||||||
import com.xscm.moduleutil.databinding.WebViewDialogBinding;
|
import com.xscm.moduleutil.databinding.WebViewDialogBinding;
|
||||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||||
import com.xscm.moduleutil.widget.dialog.BaseDialog;
|
import com.xscm.moduleutil.widget.dialog.BaseDialog;
|
||||||
@@ -57,7 +58,7 @@ public class WebViewDialog extends BaseDialog<WebViewDialogBinding> {
|
|||||||
android.util.DisplayMetrics displayMetrics = getContext().getResources().getDisplayMetrics();
|
android.util.DisplayMetrics displayMetrics = getContext().getResources().getDisplayMetrics();
|
||||||
// 设置高度为屏幕高度的80%
|
// 设置高度为屏幕高度的80%
|
||||||
android.view.WindowManager.LayoutParams params = getWindow().getAttributes();
|
android.view.WindowManager.LayoutParams params = getWindow().getAttributes();
|
||||||
params.height = (int) (displayMetrics.heightPixels * 0.7);
|
params.height = (int) (displayMetrics.heightPixels * 0.9);
|
||||||
params.width = android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
params.width = android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
||||||
getWindow().setAttributes(params);
|
getWindow().setAttributes(params);
|
||||||
}
|
}
|
||||||
@@ -80,6 +81,7 @@ public class WebViewDialog extends BaseDialog<WebViewDialogBinding> {
|
|||||||
if (type==10){
|
if (type==10){
|
||||||
mBinding.gzCl.setBackgroundResource(R.mipmap.tkzj);
|
mBinding.gzCl.setBackgroundResource(R.mipmap.tkzj);
|
||||||
mBinding.imGz.setImageResource(R.mipmap.tkzj_gz);
|
mBinding.imGz.setImageResource(R.mipmap.tkzj_gz);
|
||||||
|
mBinding.webView.setPadding(16, 0, 16, 0);
|
||||||
}else if (type==11){
|
}else if (type==11){
|
||||||
mBinding.gzCl.setBackgroundResource(R.mipmap.syzc);
|
mBinding.gzCl.setBackgroundResource(R.mipmap.syzc);
|
||||||
mBinding.imGz.setImageResource(R.mipmap.syzc_gz);
|
mBinding.imGz.setImageResource(R.mipmap.syzc_gz);
|
||||||
@@ -100,6 +102,32 @@ public class WebViewDialog extends BaseDialog<WebViewDialogBinding> {
|
|||||||
|
|
||||||
|
|
||||||
public void initData1() {
|
public void initData1() {
|
||||||
|
// WebSettings webSettings = mBinding.webView.getSettings();
|
||||||
|
// webSettings.setUseWideViewPort(true);
|
||||||
|
// webSettings.setLoadWithOverviewMode(true);
|
||||||
|
// webSettings.setJavaScriptEnabled(true);
|
||||||
|
// webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); //关闭webview中缓存
|
||||||
|
// //增加JSBridge
|
||||||
|
// mBinding.webView.addJavascriptInterface(new WebAppInterface(getContext()), "Android");
|
||||||
|
//// mBinding.webView.addJavascriptInterface(new WebViewBridgeConfig(title), WebViewBridgeConfig.NAME);
|
||||||
|
// webSettings.setBuiltInZoomControls(false);
|
||||||
|
// webSettings.setSupportZoom(false);
|
||||||
|
// webSettings.setDomStorageEnabled(true);
|
||||||
|
// webSettings.setBlockNetworkImage(false);//解决图片不显示
|
||||||
|
// // 启用 WebView 内容的滚动
|
||||||
|
// mBinding.webView.setVerticalScrollBarEnabled(true);
|
||||||
|
// mBinding.webView.setScrollbarFadingEnabled(true);
|
||||||
|
// webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||||
|
// webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
|
||||||
|
// mBinding.webView.setHorizontalScrollBarEnabled(false);//水平不显示
|
||||||
|
// mBinding.webView.setVerticalScrollBarEnabled(false); //垂直不显示
|
||||||
|
// mBinding.webView.setWebViewClient(new WebViewClient());
|
||||||
|
// mBinding.webView.setBackgroundColor(Color.TRANSPARENT);
|
||||||
|
// mBinding.webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
||||||
|
//
|
||||||
|
// mBinding.webView.requestFocus();
|
||||||
|
// mBinding.webView.loadUrl(mUrl);
|
||||||
|
|
||||||
WebSettings webSettings = mBinding.webView.getSettings();
|
WebSettings webSettings = mBinding.webView.getSettings();
|
||||||
webSettings.setUseWideViewPort(true);
|
webSettings.setUseWideViewPort(true);
|
||||||
webSettings.setLoadWithOverviewMode(true);
|
webSettings.setLoadWithOverviewMode(true);
|
||||||
@@ -114,12 +142,16 @@ public class WebViewDialog extends BaseDialog<WebViewDialogBinding> {
|
|||||||
webSettings.setBlockNetworkImage(false);//解决图片不显示
|
webSettings.setBlockNetworkImage(false);//解决图片不显示
|
||||||
webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||||
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
|
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
|
||||||
|
// 启用 WebView 内容的滚动,但隐藏滚动条
|
||||||
mBinding.webView.setHorizontalScrollBarEnabled(false);//水平不显示
|
mBinding.webView.setHorizontalScrollBarEnabled(false);//水平不显示
|
||||||
mBinding.webView.setVerticalScrollBarEnabled(false); //垂直不显示
|
mBinding.webView.setVerticalScrollBarEnabled(false); //垂直不显示滚动条
|
||||||
mBinding.webView.setWebViewClient(new WebViewClient());
|
mBinding.webView.setWebViewClient(new WebViewClient());
|
||||||
mBinding.webView.setBackgroundColor(Color.TRANSPARENT);
|
mBinding.webView.setBackgroundColor(Color.TRANSPARENT);
|
||||||
mBinding.webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
mBinding.webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
||||||
|
|
||||||
|
// 确保内容可以滚动
|
||||||
|
webSettings.setDomStorageEnabled(true);
|
||||||
|
|
||||||
mBinding.webView.requestFocus();
|
mBinding.webView.requestFocus();
|
||||||
mBinding.webView.loadUrl(mUrl);
|
mBinding.webView.loadUrl(mUrl);
|
||||||
}
|
}
|
||||||
@@ -161,7 +193,9 @@ public class WebViewDialog extends BaseDialog<WebViewDialogBinding> {
|
|||||||
|
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
public void jumpRoomPage(String room_id) {
|
public void jumpRoomPage(String room_id) {
|
||||||
ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("form", "首页").withString("roomId", room_id).navigation();
|
RoomManager.getInstance().fetchRoomDataAndEnter(getContext(), room_id,"");
|
||||||
|
|
||||||
|
// ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("form", "首页").withString("roomId", room_id).navigation();
|
||||||
}
|
}
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
public void jumpWebPage(String objects) {
|
public void jumpWebPage(String objects) {
|
||||||
|
|||||||
@@ -41,7 +41,13 @@ public class YouthModelDialog extends BaseDialog<IndexDialogYouthModelBinding> {
|
|||||||
Window window = getWindow();
|
Window window = getWindow();
|
||||||
window.setLayout((int) (ScreenUtils.getScreenWidth() * 315.f / 375), WindowManager.LayoutParams.WRAP_CONTENT);
|
window.setLayout((int) (ScreenUtils.getScreenWidth() * 315.f / 375), WindowManager.LayoutParams.WRAP_CONTENT);
|
||||||
mBinding.ivClose.setOnClickListener(v -> dismiss());
|
mBinding.ivClose.setOnClickListener(v -> dismiss());
|
||||||
mBinding.tvIKnow.setOnClickListener(v -> dismiss());
|
mBinding.tvIKnow.setOnClickListener(v -> {
|
||||||
|
|
||||||
|
ARouter.getInstance().build(ARouteConstants.UNDERAGE_ACTIVITY).withInt("type", 0).navigation();
|
||||||
|
|
||||||
|
// ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url() + "/web/index.html#/pages/feedback/teenage?id=" + SpUtil.getToken()).navigation();
|
||||||
|
// dismiss();
|
||||||
|
});
|
||||||
mBinding.tvOpen.setOnClickListener(v -> {
|
mBinding.tvOpen.setOnClickListener(v -> {
|
||||||
// if (teenagerInfo.getHad_password() == 1) {
|
// if (teenagerInfo.getHad_password() == 1) {
|
||||||
|
|
||||||
@@ -49,7 +55,7 @@ public class YouthModelDialog extends BaseDialog<IndexDialogYouthModelBinding> {
|
|||||||
// } else {
|
// } else {
|
||||||
// ARouter.getInstance().build(ARouteConstants.SET_YOUTH_PWD_ACTIVITY).withInt("type", SetYouthPasswordActivity.SET_TYPE).navigation();
|
// ARouter.getInstance().build(ARouteConstants.SET_YOUTH_PWD_ACTIVITY).withInt("type", SetYouthPasswordActivity.SET_TYPE).navigation();
|
||||||
// }
|
// }
|
||||||
ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url()+ "/web/index.html#/pages/feedback/teenage?id="+ SpUtil.getToken()).navigation();
|
ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url() + "/web/index.html#/pages/feedback/teenage?id=" + SpUtil.getToken()).navigation();
|
||||||
dismiss();
|
dismiss();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -22,20 +22,26 @@ import androidx.core.content.ContextCompat;
|
|||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
|
||||||
import com.alibaba.android.arouter.launcher.ARouter;
|
import com.alibaba.android.arouter.launcher.ARouter;
|
||||||
|
import com.blankj.utilcode.util.GsonUtils;
|
||||||
|
import com.blankj.utilcode.util.ToastUtils;
|
||||||
import com.xscm.moduleutil.R;
|
import com.xscm.moduleutil.R;
|
||||||
import com.xscm.moduleutil.base.BaseMvpDialogFragment;
|
import com.xscm.moduleutil.base.BaseMvpDialogFragment;
|
||||||
import com.xscm.moduleutil.bean.GiftBean;
|
import com.xscm.moduleutil.bean.GiftBean;
|
||||||
|
import com.xscm.moduleutil.bean.MqttXlhEnd;
|
||||||
import com.xscm.moduleutil.bean.RoomMessageEvent;
|
import com.xscm.moduleutil.bean.RoomMessageEvent;
|
||||||
import com.xscm.moduleutil.bean.WalletBean;
|
import com.xscm.moduleutil.bean.WalletBean;
|
||||||
|
import com.xscm.moduleutil.bean.XLHBean;
|
||||||
import com.xscm.moduleutil.bean.blindboxwheel.BlindBoxBean;
|
import com.xscm.moduleutil.bean.blindboxwheel.BlindBoxBean;
|
||||||
import com.xscm.moduleutil.bean.blindboxwheel.BlindReslutBean;
|
import com.xscm.moduleutil.bean.blindboxwheel.BlindReslutBean;
|
||||||
import com.xscm.moduleutil.bean.blindboxwheel.XlhDrawBean;
|
import com.xscm.moduleutil.bean.blindboxwheel.XlhDrawBean;
|
||||||
import com.xscm.moduleutil.databinding.DialogGiftLotteryBinding;
|
import com.xscm.moduleutil.databinding.DialogGiftLotteryBinding;
|
||||||
|
import com.xscm.moduleutil.dialog.RechargeDialogFragment;
|
||||||
import com.xscm.moduleutil.dialog.WebViewDialog;
|
import com.xscm.moduleutil.dialog.WebViewDialog;
|
||||||
import com.xscm.moduleutil.event.LotteryEvent;
|
import com.xscm.moduleutil.event.LotteryEvent;
|
||||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||||
import com.xscm.moduleutil.widget.CircularProgressView;
|
import com.xscm.moduleutil.widget.CircularProgressView;
|
||||||
import com.xscm.moduleutil.widget.GiftCardView;
|
import com.xscm.moduleutil.widget.GiftCardView;
|
||||||
|
import com.xscm.moduleutil.widget.floatingView.IFloatingView;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.greenrobot.eventbus.Subscribe;
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
@@ -79,8 +85,8 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
|||||||
private GiftCardView currentGiftCardView;
|
private GiftCardView currentGiftCardView;
|
||||||
private boolean isDrawing;//是否正在抽奖
|
private boolean isDrawing;//是否正在抽奖
|
||||||
private boolean isOpenSound;//是否开启音效
|
private boolean isOpenSound;//是否开启音效
|
||||||
private boolean isOpenSpecial;//是否开启特效
|
|
||||||
|
|
||||||
|
private boolean isOpenSpecial;//是否开启特效
|
||||||
private Handler handler;
|
private Handler handler;
|
||||||
private Runnable timerRunnable;//定时器
|
private Runnable timerRunnable;//定时器
|
||||||
private int startType;//类型,点击的事抽奖1次还是10次还是100次
|
private int startType;//类型,点击的事抽奖1次还是10次还是100次
|
||||||
@@ -131,7 +137,9 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
|||||||
userIdType = LotteryEvent.fromLotteryEvent(giftBagId);
|
userIdType = LotteryEvent.fromLotteryEvent(giftBagId);
|
||||||
heart_id=getArguments().getString("heart_id");
|
heart_id=getArguments().getString("heart_id");
|
||||||
|
|
||||||
|
if (!EventBus.getDefault().isRegistered( this)){
|
||||||
|
EventBus.getDefault().register(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -141,7 +149,7 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
|||||||
mBinding.mirroeSky.swLockYx.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
mBinding.mirroeSky.swLockYx.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton compoundButton, boolean check) {
|
public void onCheckedChanged(CompoundButton compoundButton, boolean check) {
|
||||||
isOpenSound= check;
|
isOpenSound= check;//音效
|
||||||
if(!check){
|
if(!check){
|
||||||
stopPlay();
|
stopPlay();
|
||||||
}
|
}
|
||||||
@@ -150,7 +158,7 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
|||||||
mBinding.cityTime.swLockYx.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
mBinding.cityTime.swLockYx.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton compoundButton, boolean check) {
|
public void onCheckedChanged(CompoundButton compoundButton, boolean check) {
|
||||||
isOpenSound= check;
|
isOpenSound= check;//音效
|
||||||
if(!check){
|
if(!check){
|
||||||
stopPlay();
|
stopPlay();
|
||||||
}
|
}
|
||||||
@@ -159,7 +167,7 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
|||||||
mBinding.pinnacleTime.swLockYx.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
mBinding.pinnacleTime.swLockYx.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton compoundButton, boolean check) {
|
public void onCheckedChanged(CompoundButton compoundButton, boolean check) {
|
||||||
isOpenSound= check;
|
isOpenSound= check;//音效
|
||||||
if(!check){
|
if(!check){
|
||||||
stopPlay();
|
stopPlay();
|
||||||
}
|
}
|
||||||
@@ -373,7 +381,7 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
|||||||
startType = 1;
|
startType = 1;
|
||||||
MvpPre.drawGiftList(giftBagId, userIds, roomId, "1",heart_id);
|
MvpPre.drawGiftList(giftBagId, userIds, roomId, "1",heart_id);
|
||||||
} else {
|
} else {
|
||||||
com.hjq.toast.ToastUtils.show("正在抽奖中...");
|
// com.hjq.toast.ToastUtils.show("正在抽奖中...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (id == R.id.ll_ten) {
|
} else if (id == R.id.ll_ten) {
|
||||||
@@ -384,7 +392,7 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
|||||||
MvpPre.drawGiftList(giftBagId, userIds, roomId, "6",heart_id);
|
MvpPre.drawGiftList(giftBagId, userIds, roomId, "6",heart_id);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
com.hjq.toast.ToastUtils.show("正在抽奖中...");
|
// com.hjq.toast.ToastUtils.show("正在抽奖中...");
|
||||||
}
|
}
|
||||||
} else if (id == R.id.ll_hundred) {//抽奖100次
|
} else if (id == R.id.ll_hundred) {//抽奖100次
|
||||||
if (!isDrawing) {
|
if (!isDrawing) {
|
||||||
@@ -393,7 +401,7 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
|||||||
startType = 3;
|
startType = 3;
|
||||||
MvpPre.drawGiftList(giftBagId, userIds, roomId, "9",heart_id);
|
MvpPre.drawGiftList(giftBagId, userIds, roomId, "9",heart_id);
|
||||||
} else {
|
} else {
|
||||||
com.hjq.toast.ToastUtils.show("正在抽奖中...");
|
// com.hjq.toast.ToastUtils.show("正在抽奖中...");
|
||||||
}
|
}
|
||||||
} else if (id == R.id.tv_gz) {//规则
|
} else if (id == R.id.tv_gz) {//规则
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
@@ -433,7 +441,8 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (id == R.id.exchange_layout) {
|
} else if (id == R.id.exchange_layout) {
|
||||||
ARouter.getInstance().build(ARouteConstants.CURRENCY).navigation();
|
// ARouter.getInstance().build(ARouteConstants.CURRENCY).navigation();
|
||||||
|
RechargeDialogFragment.show(roomId, null, getActivity().getSupportFragmentManager());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -444,17 +453,17 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
|||||||
|
|
||||||
if (icon > 0 && box_price > 0) {
|
if (icon > 0 && box_price > 0) {
|
||||||
if (type == 10) {
|
if (type == 10) {
|
||||||
updateBackground(mBinding.mirroeSky.llOne, icon > box_price, drawableX, drawableW);
|
updateBackground(mBinding.mirroeSky.llOne, icon >= box_price, drawableX, drawableW);
|
||||||
updateBackground(mBinding.mirroeSky.llTen, icon > box_price * 6, drawableX, drawableW);
|
updateBackground(mBinding.mirroeSky.llTen, icon >= box_price * 6, drawableX, drawableW);
|
||||||
updateBackground(mBinding.mirroeSky.llHundred, icon > box_price * 9, drawableX, drawableW);
|
updateBackground(mBinding.mirroeSky.llHundred, icon >= box_price * 9, drawableX, drawableW);
|
||||||
} else if (type == 11) {
|
} else if (type == 11) {
|
||||||
updateBackground(mBinding.cityTime.llOne, icon > box_price, drawableX, drawableW);
|
updateBackground(mBinding.cityTime.llOne, icon >= box_price, drawableX, drawableW);
|
||||||
updateBackground(mBinding.cityTime.llTen, icon > box_price * 6, drawableX, drawableW);
|
updateBackground(mBinding.cityTime.llTen, icon >= box_price * 6, drawableX, drawableW);
|
||||||
updateBackground(mBinding.cityTime.llHundred, icon > box_price * 9, drawableX, drawableW);
|
updateBackground(mBinding.cityTime.llHundred, icon > box_price * 9, drawableX, drawableW);
|
||||||
} else if (type == 12) {
|
} else if (type == 12) {
|
||||||
updateBackground(mBinding.pinnacleTime.llOne, icon > box_price, drawableX, drawableW);
|
updateBackground(mBinding.pinnacleTime.llOne, icon >= box_price, drawableX, drawableW);
|
||||||
updateBackground(mBinding.pinnacleTime.llTen, icon > box_price * 6, drawableX, drawableW);
|
updateBackground(mBinding.pinnacleTime.llTen, icon >= box_price * 6, drawableX, drawableW);
|
||||||
updateBackground(mBinding.pinnacleTime.llHundred, icon > box_price * 9, drawableX, drawableW);
|
updateBackground(mBinding.pinnacleTime.llHundred, icon >= box_price * 9, drawableX, drawableW);
|
||||||
} else {
|
} else {
|
||||||
// 兜底处理:未知 type 时全部设为不可点击 + 默认背景
|
// 兜底处理:未知 type 时全部设为不可点击 + 默认背景
|
||||||
setAllBackgroundToDefault(drawableW);
|
setAllBackgroundToDefault(drawableW);
|
||||||
@@ -568,6 +577,19 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
|
public void onMessageReceived(MqttXlhEnd event) {
|
||||||
|
XLHBean xlhBean= GsonUtils.fromJson(event.getMessage(), XLHBean.class);
|
||||||
|
// if (xlhBean.getFrom_type()==3) {
|
||||||
|
// dismiss();
|
||||||
|
// }
|
||||||
|
// BlindBoxBean.XlhData xlhData =new BlindBoxBean.XlhData();
|
||||||
|
if (xlhBean.getFrom_type()==3) {
|
||||||
|
xlhData.setCurrent_num(0);
|
||||||
|
xlhData.setStatus(0);
|
||||||
|
UpView(xlhData);
|
||||||
|
}
|
||||||
|
}
|
||||||
/// 定时器
|
/// 定时器
|
||||||
public void startFastAnimate() {
|
public void startFastAnimate() {
|
||||||
if (allViewsArray.isEmpty()) {
|
if (allViewsArray.isEmpty()) {
|
||||||
@@ -650,6 +672,7 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
|||||||
MvpPre.giftSend(blind_box_turntable_id);
|
MvpPre.giftSend(blind_box_turntable_id);
|
||||||
MvpPre.wallet();
|
MvpPre.wallet();
|
||||||
isDrawing = false;
|
isDrawing = false;
|
||||||
|
playSound("xuanz.mp3");
|
||||||
stopFastAnimate();
|
stopFastAnimate();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -792,6 +815,11 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
|
public void onMessageReceived(BlindBoxBean.XlhData xlhData) {
|
||||||
|
UpView(xlhData);
|
||||||
|
}
|
||||||
|
|
||||||
public void UpView(BlindBoxBean.XlhData xlhData) {
|
public void UpView(BlindBoxBean.XlhData xlhData) {
|
||||||
if (xlhData != null) {
|
if (xlhData != null) {
|
||||||
this.xlhData = xlhData;
|
this.xlhData = xlhData;
|
||||||
@@ -855,42 +883,53 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
|||||||
if (blindReslutBean.getBlind_box_turntable_id() != null) {
|
if (blindReslutBean.getBlind_box_turntable_id() != null) {
|
||||||
blind_box_turntable_id = blindReslutBean.getBlind_box_turntable_id();
|
blind_box_turntable_id = blindReslutBean.getBlind_box_turntable_id();
|
||||||
}
|
}
|
||||||
for (int i = 0; i < blindReslutBean.getReslut_list().size(); i++) {
|
if (allViewsArray.size()>0) {
|
||||||
BlindReslutBean.ReslutList reslutList = blindReslutBean.getReslut_list().get(i);
|
for (int i = 0; i < blindReslutBean.getReslut_list().size(); i++) {
|
||||||
|
BlindReslutBean.ReslutList reslutList = blindReslutBean.getReslut_list().get(i);
|
||||||
|
|
||||||
|
|
||||||
for (int j = 0; j < giftLists.size(); j++) {
|
for (int j = 0; j < giftLists.size(); j++) {
|
||||||
if (giftLists.get(j).getGift_id().equals(reslutList.getGift_id() + "")) {
|
if (giftLists.get(j).getGift_id().equals(reslutList.getGift_id() + "")) {
|
||||||
targetArrayIndex.add(j);
|
targetArrayIndex.add(j);
|
||||||
if (j < giftMaxCount) {
|
if (j < giftMaxCount) {
|
||||||
GiftCardView giftCardView = allViewsArray.get(j);
|
|
||||||
GiftBean giftBean = giftLists.get(j);
|
GiftCardView giftCardView = allViewsArray.get(j);
|
||||||
giftBean.setCount(reslutList.getCount());
|
GiftBean giftBean = giftLists.get(j);
|
||||||
giftCardView.setVisibilitymResultTextView(true);
|
giftBean.setCount(reslutList.getCount());
|
||||||
giftCardView.setSelected(true);
|
giftCardView.setVisibilitymResultTextView(true);
|
||||||
// 不要设置isDrawing=true,这会影响动画控制
|
giftCardView.setSelected(true);
|
||||||
|
// 不要设置isDrawing=true,这会影响动画控制
|
||||||
// MvpPre.wallet();
|
// MvpPre.wallet();
|
||||||
// isDrawing = false;
|
// isDrawing = false;
|
||||||
// MvpPre.giftSend(blind_box_turntable_id);
|
// MvpPre.giftSend(blind_box_turntable_id);
|
||||||
|
|
||||||
giftCardView.bindGiftData(giftBean);
|
giftCardView.bindGiftData(giftBean);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (MvpPre==null){
|
||||||
|
MvpPre = new GiftLotteryPresenter(this, getActivity());
|
||||||
|
}
|
||||||
MvpPre.wallet();
|
MvpPre.wallet();
|
||||||
isDrawing = false;
|
|
||||||
MvpPre.giftSend(blind_box_turntable_id);
|
MvpPre.giftSend(blind_box_turntable_id);
|
||||||
Log.e("isOpenSound===","isOpenSound1222"+isOpenSound);
|
Log.e("isOpenSound===","isOpenSound1222"+isOpenSound);
|
||||||
if (isOpenSpecial) {
|
if (isOpenSpecial) {//特效
|
||||||
Log.e("isOpenSound===","isOpenSound333"+isOpenSound);
|
Log.e("isOpenSound===","isOpenSound333"+isOpenSound);
|
||||||
startFastAnimate();
|
startFastAnimate();
|
||||||
}else{
|
}else{
|
||||||
if(isOpenSound){
|
if(isOpenSound){//音效
|
||||||
|
isDrawing = false;
|
||||||
playSound("xuanz.mp3");
|
playSound("xuanz.mp3");
|
||||||
|
}else {
|
||||||
|
isDrawing = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}else {
|
||||||
|
isDrawing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -918,12 +957,23 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
|||||||
? walletBean.getCoin()
|
? walletBean.getCoin()
|
||||||
: "0"
|
: "0"
|
||||||
);
|
);
|
||||||
if (type == 10) {
|
if (isAdded() && getActivity() != null && !getActivity().isFinishing() &&
|
||||||
mBinding.mirroeSky.tvIcon.setText(walletBean.getCoin());
|
getDialog() != null && getDialog().isShowing()) {
|
||||||
} else if (type == 11) {
|
if (type == 10) {
|
||||||
mBinding.cityTime.tvIcon.setText(walletBean.getCoin());
|
mBinding.mirroeSky.tvIcon.setText(walletBean.getCoin());
|
||||||
} else if (type == 12) {
|
} else if (type == 11) {
|
||||||
mBinding.pinnacleTime.tvIcon.setText(walletBean.getCoin());
|
mBinding.cityTime.tvIcon.setText(walletBean.getCoin());
|
||||||
|
} else if (type == 12) {
|
||||||
|
mBinding.pinnacleTime.tvIcon.setText(walletBean.getCoin());
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
// dialog 已关闭,不进行 UI 更新
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// walletBean 为空时也关闭 dialog
|
||||||
|
if (getActivity() != null && !getActivity().isFinishing()) {
|
||||||
|
dismiss();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setBackground();
|
setBackground();
|
||||||
@@ -999,6 +1049,11 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
|||||||
player.release();
|
player.release();
|
||||||
player = null;
|
player = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (EventBus.getDefault().isRegistered( this)){
|
||||||
|
EventBus.getDefault().unregister(this);
|
||||||
|
}
|
||||||
|
|
||||||
// 建议进行垃圾回收
|
// 建议进行垃圾回收
|
||||||
System.gc();
|
System.gc();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import com.xscm.moduleutil.bean.blindboxwheel.BlindBoxBean;
|
|||||||
import com.xscm.moduleutil.bean.blindboxwheel.BlindReslutBean;
|
import com.xscm.moduleutil.bean.blindboxwheel.BlindReslutBean;
|
||||||
import com.xscm.moduleutil.bean.blindboxwheel.XlhDrawBean;
|
import com.xscm.moduleutil.bean.blindboxwheel.XlhDrawBean;
|
||||||
import com.xscm.moduleutil.http.BaseObserver;
|
import com.xscm.moduleutil.http.BaseObserver;
|
||||||
|
import com.xscm.moduleutil.http.RetrofitClient;
|
||||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
@@ -148,6 +149,9 @@ public class GiftLotteryPresenter extends BasePresenter<GiftLotteryContacts.View
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void xlhChou(String room_id, String num) {
|
public void xlhChou(String room_id, String num) {
|
||||||
|
if (api==null){
|
||||||
|
api= RetrofitClient.getInstance();
|
||||||
|
}
|
||||||
api.xlhChou(room_id,num, new BaseObserver<List<XlhDrawBean>>() {
|
api.xlhChou(room_id,num, new BaseObserver<List<XlhDrawBean>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,46 +1,42 @@
|
|||||||
package com.xscm.moduleutil.dialog.giftLottery;
|
package com.xscm.moduleutil.dialog.giftLottery;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.CountDownTimer;
|
import android.os.CountDownTimer;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.widget.HorizontalScrollView;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.recyclerview.widget.GridLayoutManager;
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.LinearSnapHelper;
|
import androidx.recyclerview.widget.LinearSnapHelper;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.alibaba.android.arouter.launcher.ARouter;
|
import com.alibaba.android.arouter.launcher.ARouter;
|
||||||
import com.blankj.utilcode.util.TimeUtils;
|
import com.blankj.utilcode.util.GsonUtils;
|
||||||
import com.xscm.moduleutil.R;
|
import com.xscm.moduleutil.R;
|
||||||
import com.xscm.moduleutil.base.BaseMvpDialogFragment;
|
import com.xscm.moduleutil.base.BaseMvpDialogFragment;
|
||||||
import com.xscm.moduleutil.bean.GiftBean;
|
import com.xscm.moduleutil.bean.GiftBean;
|
||||||
|
import com.xscm.moduleutil.bean.MqttXlhEnd;
|
||||||
import com.xscm.moduleutil.bean.RoomMessageEvent;
|
import com.xscm.moduleutil.bean.RoomMessageEvent;
|
||||||
import com.xscm.moduleutil.bean.WalletBean;
|
import com.xscm.moduleutil.bean.WalletBean;
|
||||||
|
import com.xscm.moduleutil.bean.XLHBean;
|
||||||
import com.xscm.moduleutil.bean.blindboxwheel.BlindBoxBean;
|
import com.xscm.moduleutil.bean.blindboxwheel.BlindBoxBean;
|
||||||
import com.xscm.moduleutil.bean.blindboxwheel.BlindReslutBean;
|
import com.xscm.moduleutil.bean.blindboxwheel.BlindReslutBean;
|
||||||
import com.xscm.moduleutil.bean.blindboxwheel.XlhDrawBean;
|
import com.xscm.moduleutil.bean.blindboxwheel.XlhDrawBean;
|
||||||
import com.xscm.moduleutil.databinding.FragmentTourClubDialogBinding;
|
import com.xscm.moduleutil.databinding.FragmentTourClubDialogBinding;
|
||||||
|
import com.xscm.moduleutil.dialog.RechargeDialogFragment;
|
||||||
import com.xscm.moduleutil.dialog.WebViewDialog;
|
import com.xscm.moduleutil.dialog.WebViewDialog;
|
||||||
|
import com.xscm.moduleutil.event.MqttBean;
|
||||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||||
import com.xscm.moduleutil.utils.ImageUtils;
|
import com.xscm.moduleutil.utils.ImageUtils;
|
||||||
import com.xscm.moduleutil.widget.CenterScrollHelper;
|
import com.xscm.moduleutil.widget.CenterScrollHelper;
|
||||||
import com.xscm.moduleutil.widget.EqualSpaceItemDecoration;
|
import com.xscm.moduleutil.widget.EqualSpaceItemDecoration;
|
||||||
import com.xscm.moduleutil.widget.InfintLinearLayoutManager;
|
|
||||||
import com.xscm.moduleutil.widget.pagerecyclerview.PagerGridSnapHelper;
|
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.greenrobot.eventbus.Subscribe;
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
@@ -48,11 +44,11 @@ import org.greenrobot.eventbus.ThreadMode;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
|
||||||
/**
|
/**
|
||||||
*@author qx
|
* @author qx
|
||||||
*@data 2025/9/15
|
* @data 2025/9/15
|
||||||
*@description: 玄镜之旅
|
* @description: 玄镜之旅
|
||||||
*/
|
*/
|
||||||
public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPresenter, FragmentTourClubDialogBinding> implements GiftLotteryContacts.View {
|
public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPresenter, FragmentTourClubDialogBinding> implements GiftLotteryContacts.View {
|
||||||
private String roomId;
|
private String roomId;
|
||||||
@@ -63,6 +59,7 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
|
|||||||
private String num;
|
private String num;
|
||||||
private XlhRankingDialog xlhRankingDialog;
|
private XlhRankingDialog xlhRankingDialog;
|
||||||
private XlhRecordDialog xlhRecordDialog;
|
private XlhRecordDialog xlhRecordDialog;
|
||||||
|
private XlhObtainDialog xlhObtainDialog;
|
||||||
|
|
||||||
private GiftXlhChouAdapter giftXlhChouAdapter;
|
private GiftXlhChouAdapter giftXlhChouAdapter;
|
||||||
private CenterScrollHelper scrollHelper;
|
private CenterScrollHelper scrollHelper;
|
||||||
@@ -79,6 +76,14 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
|
|||||||
|
|
||||||
private boolean isDrawing;//是否正在抽奖
|
private boolean isDrawing;//是否正在抽奖
|
||||||
|
|
||||||
|
|
||||||
|
// 添加自动滚动相关的成员变量
|
||||||
|
private Handler autoScrollHandler = new Handler();
|
||||||
|
private Runnable autoScrollRunnable;
|
||||||
|
private boolean isAutoScrolling = false;
|
||||||
|
private static final int AUTO_SCROLL_DELAY = 1000; // 1秒滚动一个item
|
||||||
|
private boolean vCheckbox=false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected GiftLotteryPresenter bindPresenter() {
|
protected GiftLotteryPresenter bindPresenter() {
|
||||||
return new GiftLotteryPresenter(this, getActivity());
|
return new GiftLotteryPresenter(this, getActivity());
|
||||||
@@ -98,8 +103,8 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
|
|||||||
Dialog dialog = super.onCreateDialog(savedInstanceState);
|
Dialog dialog = super.onCreateDialog(savedInstanceState);
|
||||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
dialog.setCancelable(true);
|
dialog.setCancelable(true);
|
||||||
// if (!EventBus.getDefault().isRegistered(this))
|
if (!EventBus.getDefault().isRegistered(this))
|
||||||
// EventBus.getDefault().register(this);
|
EventBus.getDefault().register(this);
|
||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,8 +155,7 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
|
|||||||
mBinding.tvBd.setOnClickListener(this::onClick);
|
mBinding.tvBd.setOnClickListener(this::onClick);
|
||||||
mBinding.tvJl.setOnClickListener(this::onClick);
|
mBinding.tvJl.setOnClickListener(this::onClick);
|
||||||
mBinding.exchangeLayout.setOnClickListener(this::onClick);
|
mBinding.exchangeLayout.setOnClickListener(this::onClick);
|
||||||
|
mBinding.vCheckbox.setOnClickListener(this::onClick);
|
||||||
|
|
||||||
giftXlhChouAdapter = new GiftXlhChouAdapter();
|
giftXlhChouAdapter = new GiftXlhChouAdapter();
|
||||||
// 使用 LinearLayoutManager 横向滚动
|
// 使用 LinearLayoutManager 横向滚动
|
||||||
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false);
|
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false);
|
||||||
@@ -177,10 +181,75 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
|
|||||||
mBinding.recycleView.scrollToPosition(middlePosition);
|
mBinding.recycleView.scrollToPosition(middlePosition);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 添加自动滚动相关的方法
|
||||||
|
private void startAutoScroll() {
|
||||||
|
// 如果已经在自动滚动或数据为空,则不启动
|
||||||
|
if (isAutoScrolling || giftLists == null || giftLists.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
isAutoScrolling = true;
|
||||||
|
autoScrollRunnable = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (isAutoScrolling && mBinding != null && mBinding.recycleView != null) {
|
||||||
|
// 获取当前显示的第一个可见item位置
|
||||||
|
LinearLayoutManager layoutManager = (LinearLayoutManager) mBinding.recycleView.getLayoutManager();
|
||||||
|
if (layoutManager != null) {
|
||||||
|
int currentPosition = layoutManager.findFirstVisibleItemPosition();
|
||||||
|
|
||||||
|
// 如果没有完全可见的item,使用第一个可见item
|
||||||
|
if (currentPosition == RecyclerView.NO_POSITION) {
|
||||||
|
currentPosition = layoutManager.findFirstVisibleItemPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果还是没有有效的position,从0开始
|
||||||
|
if (currentPosition == RecyclerView.NO_POSITION) {
|
||||||
|
currentPosition = 0;
|
||||||
|
}
|
||||||
|
// 计算下一个位置
|
||||||
|
int nextPosition = currentPosition + 1;
|
||||||
|
|
||||||
|
// 如果到达末尾,回到开始位置
|
||||||
|
if (nextPosition >= giftXlhChouAdapter.getItemCount()) {
|
||||||
|
nextPosition = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 平滑滚动到下一个位置
|
||||||
|
mBinding.recycleView.smoothScrollToPosition(nextPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1秒后继续滚动
|
||||||
|
autoScrollHandler.postDelayed(this, AUTO_SCROLL_DELAY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 开始自动滚动
|
||||||
|
autoScrollHandler.postDelayed(autoScrollRunnable, AUTO_SCROLL_DELAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void stopAutoScroll() {
|
||||||
|
isAutoScrolling = false;
|
||||||
|
if (autoScrollRunnable != null) {
|
||||||
|
autoScrollHandler.removeCallbacks(autoScrollRunnable);
|
||||||
|
autoScrollRunnable = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 在抽奖结束后重新启动自动滚动
|
||||||
|
private void resumeAutoScrollAfterLottery() {
|
||||||
|
// 延迟一段时间后再启动自动滚动,让用户看到抽奖结果
|
||||||
|
mBinding.recycleView.postDelayed(() -> {
|
||||||
|
if (isVisible() && !isDrawing) {
|
||||||
|
startAutoScroll();
|
||||||
|
}
|
||||||
|
}, 3000); // 3秒后重新开始自动滚动
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void onClick(View view) {
|
private void onClick(View view) {
|
||||||
int id = view.getId();
|
int id = view.getId();
|
||||||
if (id == R.id.tv_jc) {
|
if (id == R.id.tv_jc) {
|
||||||
@@ -198,7 +267,7 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
|
|||||||
num = "1";
|
num = "1";
|
||||||
MvpPre.xlhChou(roomId, num);
|
MvpPre.xlhChou(roomId, num);
|
||||||
} else {
|
} else {
|
||||||
com.hjq.toast.ToastUtils.show("正在抽奖中...");
|
// com.hjq.toast.ToastUtils.show("正在抽奖中...");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (id == R.id.ll_ten) {
|
} else if (id == R.id.ll_ten) {
|
||||||
@@ -208,7 +277,7 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
|
|||||||
num = "10";
|
num = "10";
|
||||||
MvpPre.xlhChou(roomId, num);
|
MvpPre.xlhChou(roomId, num);
|
||||||
} else {
|
} else {
|
||||||
com.hjq.toast.ToastUtils.show("正在抽奖中...");
|
// com.hjq.toast.ToastUtils.show("正在抽奖中...");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (id == R.id.ll_hundred) {
|
} else if (id == R.id.ll_hundred) {
|
||||||
@@ -218,7 +287,7 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
|
|||||||
num = "100";
|
num = "100";
|
||||||
MvpPre.xlhChou(roomId, num);
|
MvpPre.xlhChou(roomId, num);
|
||||||
} else {
|
} else {
|
||||||
com.hjq.toast.ToastUtils.show("正在抽奖中...");
|
// com.hjq.toast.ToastUtils.show("正在抽奖中...");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (id == R.id.tv_gz) {
|
} else if (id == R.id.tv_gz) {
|
||||||
@@ -244,7 +313,11 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
|
|||||||
xlhRecordDialog = XlhRecordDialog.newInstance(roomId);
|
xlhRecordDialog = XlhRecordDialog.newInstance(roomId);
|
||||||
xlhRecordDialog.show(getChildFragmentManager(), "XlhRecordDialog");
|
xlhRecordDialog.show(getChildFragmentManager(), "XlhRecordDialog");
|
||||||
} else if (id == R.id.exchange_layout) {//钻石兑换
|
} else if (id == R.id.exchange_layout) {//钻石兑换
|
||||||
ARouter.getInstance().build(ARouteConstants.CURRENCY).navigation();
|
// ARouter.getInstance().build(ARouteConstants.CURRENCY).navigation();
|
||||||
|
RechargeDialogFragment.show(roomId, null, getActivity().getSupportFragmentManager());
|
||||||
|
}else if (id==R.id.v_checkbox){
|
||||||
|
mBinding.vCheckbox.setSelected(!mBinding.vCheckbox.isSelected());
|
||||||
|
vCheckbox=mBinding.vCheckbox.isSelected();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,12 +365,24 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
|
|||||||
}
|
}
|
||||||
|
|
||||||
giftXlhChouAdapter.setNewData(giftLists);
|
giftXlhChouAdapter.setNewData(giftLists);
|
||||||
|
// // 数据加载完成后启动自动滚动
|
||||||
|
// if (giftLists != null && !giftLists.isEmpty()) {
|
||||||
|
// mBinding.recycleView.post(() -> {
|
||||||
|
// // 确保在UI线程中启动自动滚动
|
||||||
|
// startAutoScroll();
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
}else {
|
||||||
|
isDrawing = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int mboxPrice;
|
||||||
|
|
||||||
// TODO: 2025/9/4 设置底部按钮文字
|
// TODO: 2025/9/4 设置底部按钮文字
|
||||||
private void upTitle(int boxPrice) {
|
private void upTitle(int boxPrice) {
|
||||||
|
this.mboxPrice = boxPrice;
|
||||||
mBinding.tvOne.setText(boxPrice + "币一次");
|
mBinding.tvOne.setText(boxPrice + "币一次");
|
||||||
mBinding.tvTen.setText((boxPrice * 10) + "币十次");
|
mBinding.tvTen.setText((boxPrice * 10) + "币十次");
|
||||||
mBinding.tvHundred.setText((boxPrice * 100) + "币百次");
|
mBinding.tvHundred.setText((boxPrice * 100) + "币百次");
|
||||||
@@ -308,14 +393,25 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
|
|||||||
public void onMusicPlay(RoomMessageEvent message) {
|
public void onMusicPlay(RoomMessageEvent message) {
|
||||||
if (message.getMsgType() == 1057) {
|
if (message.getMsgType() == 1057) {
|
||||||
// UpView(message.getText().getXlh_data());
|
// UpView(message.getText().getXlh_data());
|
||||||
endTime = Long.parseLong(message.getText().getEnd_time());
|
endTime = Long.parseLong(message.getText().getEnd_time() != null ? message.getText().getEnd_time() : "0");
|
||||||
startCountdown();
|
startCountdown();
|
||||||
mBinding.tvGiftCount.setText(message.getText().getGift_num());
|
mBinding.tvGiftCount.setText(message.getText().getGift_num() != null ? message.getText().getGift_num() : "0");
|
||||||
mBinding.userName.setText(message.getText().getFromUserInfo().getNickname());
|
mBinding.userName.setText(message.getText().getFromUserInfo().getNickname() != null ? message.getText().getFromUserInfo().getNickname() : "");
|
||||||
ImageUtils.loadHeadCC(message.getText().getFromUserInfo().getAvatar(), mBinding.userPic);
|
ImageUtils.loadHeadCC(message.getText().getFromUserInfo().getAvatar(), mBinding.userPic);
|
||||||
|
isDrawing=false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
|
public void onMessageReceived(RoomMessageEvent event) {
|
||||||
|
onMusicPlay( event);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
|
public void onMessageReceived(MqttXlhEnd event) {
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 启动倒计时
|
* 启动倒计时
|
||||||
*/
|
*/
|
||||||
@@ -411,6 +507,26 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
|
|||||||
if (giftXlhChouAdapter != null) {
|
if (giftXlhChouAdapter != null) {
|
||||||
giftXlhChouAdapter = null;
|
giftXlhChouAdapter = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (EventBus.getDefault().isRegistered(this)) {
|
||||||
|
EventBus.getDefault().unregister(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xlhRecordDialog != null && xlhRecordDialog.isVisible()) {
|
||||||
|
xlhRecordDialog.dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果当前dialog存在且正在显示,先关闭
|
||||||
|
if (xlhRankingDialog != null && xlhRankingDialog.isVisible()) {
|
||||||
|
xlhRankingDialog.dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xlhObtainDialog != null && xlhObtainDialog.isShowing()) {
|
||||||
|
xlhObtainDialog.dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
|
stopAutoScroll();
|
||||||
|
autoScrollHandler.removeCallbacksAndMessages(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -434,10 +550,37 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int icon;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void wallet(WalletBean walletBean) {
|
public void wallet(WalletBean walletBean) {
|
||||||
if (walletBean != null) {
|
if (walletBean != null) {
|
||||||
mBinding.tvIcon.setText(walletBean.getCoin());
|
icon = (int) Double.parseDouble(
|
||||||
|
(walletBean.getCoin() != null && !walletBean.getCoin().isEmpty())
|
||||||
|
? walletBean.getCoin()
|
||||||
|
: "0"
|
||||||
|
);
|
||||||
|
mBinding.tvIcon.setText(walletBean.getCoin()!=null && !walletBean.getCoin().isEmpty() ?walletBean.getCoin():"0");
|
||||||
|
showView();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showView() {
|
||||||
|
if (icon>=mboxPrice){
|
||||||
|
mBinding.llOne.setClickable( true);
|
||||||
|
}else {
|
||||||
|
mBinding.llOne.setClickable( false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (icon>=mboxPrice*10){
|
||||||
|
mBinding.llTen.setClickable( true);
|
||||||
|
}else {
|
||||||
|
mBinding.llTen.setClickable( false);
|
||||||
|
}
|
||||||
|
if (icon>=mboxPrice*100){
|
||||||
|
mBinding.llHundred.setClickable( true);
|
||||||
|
}else {
|
||||||
|
mBinding.llHundred.setClickable( false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -447,74 +590,85 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
|
|||||||
@Override
|
@Override
|
||||||
public void xlhChouSuccess(List<XlhDrawBean> data) {
|
public void xlhChouSuccess(List<XlhDrawBean> data) {
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
|
if (vCheckbox){
|
||||||
|
showResultDialog(data);
|
||||||
|
}else {
|
||||||
|
// showResultDialog(data);
|
||||||
|
|
||||||
showResultDialog(data);
|
// 取消之前可能存在的任务
|
||||||
|
clearPendingTasks();
|
||||||
|
// 抽奖完成后执行动画滚动
|
||||||
|
pendingLotteryRunnable = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// 清理之前的状态
|
||||||
|
if (giftXlhChouAdapter != null) {
|
||||||
|
giftXlhChouAdapter.clearSelection();
|
||||||
|
}
|
||||||
|
int winningPosition = findHighestValueWinningPosition(data);//这是获取到的中奖位置下标
|
||||||
|
if (winningPosition != -1) {
|
||||||
|
if (scrollHelper == null) {
|
||||||
|
scrollHelper = new CenterScrollHelper(mBinding.recycleView);
|
||||||
|
}
|
||||||
|
|
||||||
// 取消之前可能存在的任务
|
// 计算在循环列表中的目标位置(滚动几圈后停在目标位置)
|
||||||
// clearPendingTasks();
|
int loopCount = 4; // 滚动4圈
|
||||||
// // 抽奖完成后执行动画滚动
|
int originalSize = giftLists.size();///这是列表的总大小
|
||||||
// pendingLotteryRunnable = new Runnable() {
|
// 计算目标在循环列表中的位置(确保在中间区域)
|
||||||
// @Override
|
///这是计算总圈数的大小
|
||||||
// public void run() {
|
int middleBaseIndex = (loopCount * originalSize);
|
||||||
// // 清理之前的状态
|
///这里是展示在中奖的位置,加上总圈数的大小,
|
||||||
// if (giftXlhChouAdapter != null) {
|
int targetLoopIndex = middleBaseIndex + (winningPosition % originalSize);
|
||||||
// giftXlhChouAdapter.clearSelection();
|
|
||||||
// }
|
|
||||||
// int winningPosition = findHighestValueWinningPosition(data);//这是获取到的中奖位置下标
|
|
||||||
// if (winningPosition != -1) {
|
|
||||||
// if (scrollHelper == null) {
|
|
||||||
// scrollHelper = new CenterScrollHelper(mBinding.recycleView);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // 计算在循环列表中的目标位置(滚动几圈后停在目标位置)
|
|
||||||
// int loopCount = 4; // 滚动4圈
|
|
||||||
// int originalSize = giftLists.size();///这是列表的总大小
|
|
||||||
// // 计算目标在循环列表中的位置(确保在中间区域)
|
|
||||||
// ///这是计算总圈数的大小
|
|
||||||
// int middleBaseIndex = (loopCount * originalSize);
|
|
||||||
// ///这里是展示在中奖的位置,加上总圈数的大小,
|
|
||||||
// int targetLoopIndex = middleBaseIndex + (winningPosition % originalSize);
|
|
||||||
//
|
|
||||||
// // 使用scrollWithCircles方法执行带动画的滚动(带完成回调)
|
|
||||||
// scrollHelper.scrollWithCircles(
|
|
||||||
// targetLoopIndex, // 在循环列表中的位置
|
|
||||||
// loopCount, // 滚动圈数
|
|
||||||
// 200, // 每个item滚动时间200ms(控制速度)
|
|
||||||
// originalSize, // 原始数据大小
|
|
||||||
// () -> { // 滚动完成回调
|
|
||||||
// // 滚动完成后更新选中状态(使用原始位置)
|
|
||||||
// if (giftXlhChouAdapter != null) {
|
|
||||||
// giftXlhChouAdapter.setSelectedPosition(winningPosition);
|
|
||||||
// }
|
|
||||||
// // 滚动完成后延迟一小段时间再居中,确保UI更新完成
|
|
||||||
// pendingCenteringRunnable = new Runnable() {
|
|
||||||
// @Override
|
|
||||||
// public void run() {
|
|
||||||
// // 手动将选中项居中
|
|
||||||
// centerSelectedItem(winningPosition, originalSize);
|
|
||||||
//
|
|
||||||
// // 显示结果对话框
|
|
||||||
// getActivity().runOnUiThread(() -> {
|
|
||||||
// scrollHelper = null;
|
|
||||||
// showResultDialog(data);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
// mBinding.recycleView.postDelayed(pendingCenteringRunnable, 100);
|
|
||||||
// }
|
|
||||||
// );
|
|
||||||
//
|
|
||||||
// } else {
|
|
||||||
// // 如果没有找到中奖位置,直接显示对话框
|
|
||||||
// showResultDialog(data);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
// mBinding.recycleView.postDelayed(pendingLotteryRunnable, 300);
|
|
||||||
|
|
||||||
|
// 使用scrollWithCircles方法执行带动画的滚动(带完成回调)
|
||||||
|
scrollHelper.scrollWithCircles(
|
||||||
|
targetLoopIndex, // 在循环列表中的位置
|
||||||
|
loopCount, // 滚动圈数
|
||||||
|
1000, // 每个item滚动时间200ms(控制速度)
|
||||||
|
originalSize, // 原始数据大小
|
||||||
|
() -> { // 滚动完成回调
|
||||||
|
// 滚动完成后更新选中状态(使用原始位置)
|
||||||
|
if (giftXlhChouAdapter != null) {
|
||||||
|
giftXlhChouAdapter.setSelectedPosition(winningPosition);
|
||||||
|
}
|
||||||
|
// 滚动完成后延迟一小段时间再居中,确保UI更新完成
|
||||||
|
pendingCenteringRunnable = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// 手动将选中项居中
|
||||||
|
centerSelectedItem(winningPosition, originalSize);
|
||||||
|
|
||||||
|
// 显示结果对话框
|
||||||
|
getActivity().runOnUiThread(() -> {
|
||||||
|
scrollHelper = null;
|
||||||
|
showResultDialog(data);
|
||||||
|
// 抽奖结束后重新启动自动滚动
|
||||||
|
// resumeAutoScrollAfterLottery();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
mBinding.recycleView.postDelayed(pendingCenteringRunnable, 1000);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// 如果没有找到中奖位置,直接显示对话框
|
||||||
|
showResultDialog(data);
|
||||||
|
// 抽奖结束后重新启动自动滚动
|
||||||
|
// resumeAutoScrollAfterLottery();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
mBinding.recycleView.postDelayed(pendingLotteryRunnable, 1000);
|
||||||
|
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
isDrawing=false;
|
||||||
|
// 抽奖失败也重新启动自动滚动
|
||||||
|
// resumeAutoScrollAfterLottery();
|
||||||
}
|
}
|
||||||
MvpPre.wallet();
|
MvpPre.wallet();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -522,6 +676,10 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
|
|||||||
* 为新的抽奖做准备,清理之前的状态
|
* 为新的抽奖做准备,清理之前的状态
|
||||||
*/
|
*/
|
||||||
private void prepareForNewLottery() {
|
private void prepareForNewLottery() {
|
||||||
|
|
||||||
|
// 停止自动滚动
|
||||||
|
stopAutoScroll();
|
||||||
|
|
||||||
// 取消之前可能存在的任务
|
// 取消之前可能存在的任务
|
||||||
clearPendingTasks();
|
clearPendingTasks();
|
||||||
|
|
||||||
@@ -684,7 +842,6 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将指定的原始位置item居中显示
|
* 将指定的原始位置item居中显示
|
||||||
*
|
*
|
||||||
@@ -805,14 +962,19 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
|
|||||||
* @param data 中奖数据
|
* @param data 中奖数据
|
||||||
*/
|
*/
|
||||||
private void showResultDialog(List<XlhDrawBean> data) {
|
private void showResultDialog(List<XlhDrawBean> data) {
|
||||||
isDrawing=false;
|
isDrawing = false;
|
||||||
// 创建并显示对话框
|
// 创建并显示对话框
|
||||||
XlhObtainDialog dialog = new XlhObtainDialog(getActivity());
|
// 关闭之前可能存在的对话框
|
||||||
dialog.setOnGiftItemClickListener(new XlhObtainDialog.OnGiftItemClickListener() {
|
// if (xlhObtainDialog != null && xlhObtainDialog.isShowing()) {
|
||||||
|
// xlhObtainDialog.dismiss();
|
||||||
|
// }
|
||||||
|
// 创建并显示对话框
|
||||||
|
xlhObtainDialog = new XlhObtainDialog(getActivity());
|
||||||
|
xlhObtainDialog.setOnGiftItemClickListener(new XlhObtainDialog.OnGiftItemClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayAgainClick() {
|
public void onPlayAgainClick() {
|
||||||
isDrawing=true;
|
isDrawing = true;
|
||||||
// 处理再玩一次点击事件
|
// 处理再玩一次点击事件
|
||||||
MvpPre.xlhChou(roomId, num);
|
MvpPre.xlhChou(roomId, num);
|
||||||
}
|
}
|
||||||
@@ -820,12 +982,16 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
|
|||||||
@Override
|
@Override
|
||||||
public void onCloseClick() {
|
public void onCloseClick() {
|
||||||
// 处理关闭点击事件
|
// 处理关闭点击事件
|
||||||
dialog.dismiss();
|
if (xlhObtainDialog != null && xlhObtainDialog.isShowing()) {
|
||||||
|
isDrawing = false;
|
||||||
|
xlhObtainDialog.dismiss();
|
||||||
|
}
|
||||||
|
xlhObtainDialog = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
dialog.show();
|
xlhObtainDialog.show();
|
||||||
dialog.setGiftList(data);
|
xlhObtainDialog.setGiftList(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.xscm.moduleutil.dialog.giftLottery;
|
package com.xscm.moduleutil.dialog.giftLottery;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.view.Gravity;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
@@ -53,6 +54,13 @@ public class XlhObtainDialog extends BaseDialog<DialogXlhObtainBinding> {
|
|||||||
setCancelable(false);
|
setCancelable(false);
|
||||||
setCanceledOnTouchOutside(false);
|
setCanceledOnTouchOutside(false);
|
||||||
Window window = getWindow();
|
Window window = getWindow();
|
||||||
|
// 设置对话框在屏幕中央显示
|
||||||
|
window.setGravity(Gravity.CENTER);
|
||||||
|
// 去掉背景阴影
|
||||||
|
window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
|
||||||
|
|
||||||
|
// 设置窗口背景为透明
|
||||||
|
window.setBackgroundDrawableResource(android.R.color.transparent);
|
||||||
window.setLayout((int) (ScreenUtils.getScreenWidth() * 375.f / 375), WindowManager.LayoutParams.WRAP_CONTENT);
|
window.setLayout((int) (ScreenUtils.getScreenWidth() * 375.f / 375), WindowManager.LayoutParams.WRAP_CONTENT);
|
||||||
// 设置点击事件
|
// 设置点击事件
|
||||||
mBinding.xlhClose.setOnClickListener(v -> {
|
mBinding.xlhClose.setOnClickListener(v -> {
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.xscm.moduleutil.event;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*@author qx
|
||||||
|
*@data 2025/9/22
|
||||||
|
*@description: 关闭飘屏
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class FloatingScreenEvent {
|
||||||
|
private boolean floatingScreen;
|
||||||
|
}
|
||||||
@@ -1,5 +1,16 @@
|
|||||||
package com.xscm.moduleutil.event;
|
package com.xscm.moduleutil.event;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.annotations.JsonAdapter;
|
||||||
|
import com.google.gson.stream.JsonReader;
|
||||||
|
import com.google.gson.stream.JsonToken;
|
||||||
|
import com.google.gson.stream.JsonWriter;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -10,7 +21,8 @@ import lombok.Data;
|
|||||||
@Data
|
@Data
|
||||||
public class MqttBean {
|
public class MqttBean {
|
||||||
private String room_id;
|
private String room_id;
|
||||||
private ListBean list;
|
@JsonAdapter(ListBeanListAdapter.class)
|
||||||
|
private List<ListBean> list;
|
||||||
|
|
||||||
public String getRoom_id() {
|
public String getRoom_id() {
|
||||||
return room_id == null ? "" : room_id;
|
return room_id == null ? "" : room_id;
|
||||||
@@ -20,14 +32,58 @@ public class MqttBean {
|
|||||||
this.room_id = room_id == null ? "" : room_id;
|
this.room_id = room_id == null ? "" : room_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ListBean getList() {
|
public List<ListBean> getList() {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setList(ListBean list) {
|
public void setList(List<ListBean> list) {
|
||||||
this.list = list;
|
this.list = list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 自定义TypeAdapter来处理有时是对象有时是数组的情况
|
||||||
|
public static class ListBeanListAdapter extends TypeAdapter<List<ListBean>> {
|
||||||
|
@Override
|
||||||
|
public void write(JsonWriter out, List<ListBean> value) throws IOException {
|
||||||
|
if (value == null) {
|
||||||
|
out.nullValue();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Gson gson = new Gson();
|
||||||
|
out.beginArray();
|
||||||
|
for (ListBean item : value) {
|
||||||
|
gson.toJson(item, ListBean.class, out);
|
||||||
|
}
|
||||||
|
out.endArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ListBean> read(JsonReader in) throws IOException {
|
||||||
|
List<ListBean> list = new ArrayList<>();
|
||||||
|
Gson gson = new Gson();
|
||||||
|
|
||||||
|
JsonToken token = in.peek();
|
||||||
|
if (token == JsonToken.BEGIN_ARRAY) {
|
||||||
|
// 正常的数组情况
|
||||||
|
in.beginArray();
|
||||||
|
while (in.hasNext()) {
|
||||||
|
ListBean item = gson.fromJson(in, ListBean.class);
|
||||||
|
list.add(item);
|
||||||
|
}
|
||||||
|
in.endArray();
|
||||||
|
} else if (token == JsonToken.BEGIN_OBJECT) {
|
||||||
|
// 单个对象的情况,转换为包含一个元素的列表
|
||||||
|
ListBean item = gson.fromJson(in, ListBean.class);
|
||||||
|
list.add(item);
|
||||||
|
} else if (token == JsonToken.NULL) {
|
||||||
|
in.nextNull();
|
||||||
|
}
|
||||||
|
// 其他情况(如字符串、数字等)直接跳过
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class ListBean {
|
public static class ListBean {
|
||||||
private String text;
|
private String text;
|
||||||
|
|||||||
@@ -9,8 +9,18 @@ import lombok.Data;
|
|||||||
@Data
|
@Data
|
||||||
public class UnreadCountEvent {
|
public class UnreadCountEvent {
|
||||||
private long aLong;
|
private long aLong;
|
||||||
|
private long bLong;
|
||||||
|
|
||||||
public UnreadCountEvent(long aLong) {
|
|
||||||
this.aLong = aLong;
|
|
||||||
}
|
// public UnreadCountEvent(long aLong, long bLong) {
|
||||||
|
// this.aLong = aLong;
|
||||||
|
// this.bLong = bLong;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public UnreadCountEvent() {
|
||||||
|
// }
|
||||||
|
// public UnreadCountEvent(long aLong) {
|
||||||
|
// this.aLong = aLong;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.xscm.moduleutil.bean.AlbumBean;
|
|||||||
import com.xscm.moduleutil.bean.AppPay;
|
import com.xscm.moduleutil.bean.AppPay;
|
||||||
import com.xscm.moduleutil.bean.AppUpdateModel;
|
import com.xscm.moduleutil.bean.AppUpdateModel;
|
||||||
import com.xscm.moduleutil.bean.BannerModel;
|
import com.xscm.moduleutil.bean.BannerModel;
|
||||||
|
import com.xscm.moduleutil.bean.BindDetail;
|
||||||
import com.xscm.moduleutil.bean.BindType;
|
import com.xscm.moduleutil.bean.BindType;
|
||||||
import com.xscm.moduleutil.bean.BlackUserBean;
|
import com.xscm.moduleutil.bean.BlackUserBean;
|
||||||
import com.xscm.moduleutil.bean.CharmRankingResp;
|
import com.xscm.moduleutil.bean.CharmRankingResp;
|
||||||
@@ -91,7 +92,7 @@ public interface ApiServer {
|
|||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.LOGIN)
|
@POST(Constants.LOGIN)
|
||||||
Observable<BaseModel<List<UserBean>>> login(@Field("user_login") String user_login, @Field("sms_code") String sms_code);
|
Call<BaseModel<List<UserBean>>> login(@Field("user_login") String user_login, @Field("sms_code") String sms_code);
|
||||||
|
|
||||||
@FormUrlEncoded //手机换绑
|
@FormUrlEncoded //手机换绑
|
||||||
@POST(Constants.MODIFY_MOBILE)
|
@POST(Constants.MODIFY_MOBILE)
|
||||||
@@ -165,13 +166,17 @@ public interface ApiServer {
|
|||||||
@GET(Constants.GET_WITHDRAWAL_LIST)
|
@GET(Constants.GET_WITHDRAWAL_LIST)
|
||||||
Observable<BaseModel<List<WithdrawalBean>>> withdrawalList(@Query("page") String page, @Query("page_limit") String page_limit, @Query("search_stime") String search_stime, @Query("search_etime") String search_etime);
|
Observable<BaseModel<List<WithdrawalBean>>> withdrawalList(@Query("page") String page, @Query("page_limit") String page_limit, @Query("search_stime") String search_stime, @Query("search_etime") String search_etime);
|
||||||
|
|
||||||
|
@FormUrlEncoded
|
||||||
|
@POST(Constants.POST_BIND_DETAIL)
|
||||||
|
Call<BaseModel<BindDetail>> bindDetai(@Field("user_id") String user_id, @Field("type") String type);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.POST_MESSAGE_LIST)
|
@POST(Constants.POST_MESSAGE_LIST)
|
||||||
Observable<BaseModel<List<NewsMessageList>>> getMessagetitle(@Field("type") String type, @Field("page") String page, @Field("page_limit") String page_limit);
|
Call<BaseModel<List<NewsMessageList>>> getMessagetitle(@Field("type") String type, @Field("page") String page, @Field("page_limit") String page_limit);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.POST_ROOM_RANK)
|
@POST(Constants.POST_ROOM_RANK)
|
||||||
Observable<BaseModel<List<CharmRankingResp>>> getRoomRank(@Field("room_id") String room_id, @Field("type") String type, @Field("time_type") String time_type, @Field("page") String page, @Field("page_limit") String page_limit);
|
Call<BaseModel<List<CharmRankingResp>>> getRoomRank(@Field("room_id") String room_id, @Field("type") String type, @Field("time_type") String time_type, @Field("page") String page, @Field("page_limit") String page_limit);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.POST_ROOM_RANKING)
|
@POST(Constants.POST_ROOM_RANKING)
|
||||||
@@ -182,16 +187,16 @@ public interface ApiServer {
|
|||||||
Observable<BaseModel<PlaceholderBean>> loveRanking(@Field("type") String type);
|
Observable<BaseModel<PlaceholderBean>> loveRanking(@Field("type") String type);
|
||||||
|
|
||||||
@GET(Constants.GET_REAL_NAME)
|
@GET(Constants.GET_REAL_NAME)
|
||||||
Observable<BaseModel<RealNameBean>> realNameInfo();
|
Call<BaseModel<RealNameBean>> realNameInfo();
|
||||||
|
|
||||||
@GET(Constants.GET_DAILY_TASK_BOX)
|
@GET(Constants.GET_DAILY_TASK_BOX)
|
||||||
Observable<BaseModel<List<GiftBoxRecordBean>>> dailyTasksBoxRecord();
|
Call<BaseModel<List<GiftBoxRecordBean>>> dailyTasksBoxRecord();
|
||||||
|
|
||||||
@GET(Constants.GET_MY_BAG_DATA)
|
@GET(Constants.GET_MY_BAG_DATA)
|
||||||
Observable<BaseModel<List<MyBagDataBean>>> packIncome(@Query("page") String page, @Query("page_limit") String page_size);
|
Call<BaseModel<List<MyBagDataBean>>> packIncome(@Query("page") String page, @Query("page_limit") String page_size);
|
||||||
|
|
||||||
@GET(Constants.GET_MY_BAG_OUTCOME)
|
@GET(Constants.GET_MY_BAG_OUTCOME)
|
||||||
Observable<BaseModel<List<MyBagDataBean>>> packOutcome(@Query("page") String page, @Query("page_limit") String page_size);
|
Call<BaseModel<List<MyBagDataBean>>> packOutcome(@Query("page") String page, @Query("page_limit") String page_size);
|
||||||
|
|
||||||
@GET(Constants.GET_GIFT_PACK)
|
@GET(Constants.GET_GIFT_PACK)
|
||||||
Call<BaseModel<List<GiftPackBean>>> giftPack();
|
Call<BaseModel<List<GiftPackBean>>> giftPack();
|
||||||
@@ -213,7 +218,7 @@ public interface ApiServer {
|
|||||||
Call<ResponseBody> endPk(@Field("pk_id") String is_pk, @Field("type") String type, @Field("user_id") String user_id);
|
Call<ResponseBody> endPk(@Field("pk_id") String is_pk, @Field("type") String type, @Field("user_id") String user_id);
|
||||||
|
|
||||||
@GET(Constants.GET_RECHARGE)
|
@GET(Constants.GET_RECHARGE)
|
||||||
Observable<BaseModel<List<RechargeBean>>> recharge();
|
Call<BaseModel<List<RechargeBean>>> recharge();
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.POST_START_PK)
|
@POST(Constants.POST_START_PK)
|
||||||
@@ -221,11 +226,11 @@ public interface ApiServer {
|
|||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.UPLOAD_USER_PIC)
|
@POST(Constants.UPLOAD_USER_PIC)
|
||||||
Call<BaseModel<String>> upUserPic(@Field("sex") String sex);
|
Call<ResponseBody> upUserPic(@Field("sex") String sex);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.SWITCH_ACCOUNTS)
|
@POST(Constants.SWITCH_ACCOUNTS)
|
||||||
Observable<BaseModel<List<UserBean>>> switchAccounts(@Field("user_login") String user_id);
|
Call<BaseModel<List<UserBean>>> switchAccounts(@Field("user_login") String user_id);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.FORGOT_PASSWORD)
|
@POST(Constants.FORGOT_PASSWORD)
|
||||||
@@ -233,7 +238,7 @@ public interface ApiServer {
|
|||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.USER_UPDATE)
|
@POST(Constants.USER_UPDATE)
|
||||||
Observable<BaseModel<UserBean>> userUpdate(@Field("nickname") String nickname, @Field("birthday") String birthday, @Field("sex") String sex, @Field("avatar") String avatar, @Field("init_code") String init_code, @Field("user_id") String user_id);
|
Call<BaseModel<UserBean>> userUpdate(@Field("nickname") String nickname, @Field("birthday") String birthday, @Field("sex") String sex, @Field("avatar") String avatar, @Field("init_code") String init_code, @Field("user_id") String user_id);
|
||||||
|
|
||||||
@GET(Constants.AUTHORIZATION)
|
@GET(Constants.AUTHORIZATION)
|
||||||
Call<ResponseBody> authorization();
|
Call<ResponseBody> authorization();
|
||||||
@@ -263,18 +268,18 @@ public interface ApiServer {
|
|||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.REAL_NAME)
|
@POST(Constants.REAL_NAME)
|
||||||
Observable<BaseModel<RealNameBean>> realName(@Field("real_name") String real_name, @Field("card_number") String card_number);
|
Call<BaseModel<RealNameBean>> realName(@Field("real_name") String real_name, @Field("card_number") String card_number);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.GET_EXPAND_COLUMN)
|
@POST(Constants.GET_EXPAND_COLUMN)
|
||||||
Observable<BaseModel<List<ExpandColumnBean>>> getExpandColumn(@Field("type") String type, @Field("page") String page, @Field("page_limit") String page_limit);
|
Call<BaseModel<List<ExpandColumnBean>>> getExpandColumn(@Field("type") String type, @Field("page") String page, @Field("page_limit") String page_limit);
|
||||||
|
|
||||||
@GET(Constants.GET_OFFICIAL_NOTICE)
|
@GET(Constants.GET_OFFICIAL_NOTICE)
|
||||||
Observable<BaseModel<NewsDataBean>> getOfficialNotice();
|
Call<BaseModel<NewsDataBean>> getOfficialNotice();
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.GET_ALBUM_LIST)
|
@POST(Constants.GET_ALBUM_LIST)
|
||||||
Observable<BaseModel<List<AlbumBean>>> getAlbumList(@Field("page") String page, @Field("page_limit") String page_limit, @Field("user_id") String user_id);
|
Call<BaseModel<List<AlbumBean>>> getAlbumList(@Field("page") String page, @Field("page_limit") String page_limit, @Field("user_id") String user_id);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.CREATE_ALBUM)
|
@POST(Constants.CREATE_ALBUM)
|
||||||
@@ -289,19 +294,19 @@ public interface ApiServer {
|
|||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.POST_FOLLOW_LIST)
|
@POST(Constants.POST_FOLLOW_LIST)
|
||||||
Observable<BaseModel<List<BlackUserBean>>> getUserFollowList(@Field("page") String page, @Field("page_limit") String page_limit);
|
Call<BaseModel<List<BlackUserBean>>> getUserFollowList(@Field("page") String page, @Field("page_limit") String page_limit);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.POST_FANS_LIST)
|
@POST(Constants.POST_FANS_LIST)
|
||||||
Observable<BaseModel<List<BlackUserBean>>> getUserFansList(@Field("page") String page, @Field("page_limit") String page_limit);
|
Call<BaseModel<List<BlackUserBean>>> getUserFansList(@Field("page") String page, @Field("page_limit") String page_limit);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.POST_BLACK_LIST)
|
@POST(Constants.POST_BLACK_LIST)
|
||||||
Observable<BaseModel<List<BlackUserBean>>> getBlacklist(@Field("page") String page, @Field("page_limit") String page_limit);
|
Call<BaseModel<List<BlackUserBean>>> getBlacklist(@Field("page") String page, @Field("page_limit") String page_limit);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.POST_LOCK_MI_LIST)
|
@POST(Constants.POST_LOCK_MI_LIST)
|
||||||
Observable<BaseModel<List<BlackUserBean>>> getLockMiniList(@Field("page") String page, @Field("page_limit") String page_limit);
|
Call<BaseModel<List<BlackUserBean>>> getLockMiniList(@Field("page") String page, @Field("page_limit") String page_limit);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.GET_MY_ROOM)
|
@POST(Constants.GET_MY_ROOM)
|
||||||
@@ -316,7 +321,7 @@ public interface ApiServer {
|
|||||||
Call<BaseModel<List<TopRoom>>> getTopRooms(@Field("page") String page, @Field("page_limit") String page_limit, @Field("is_top") String is_top, @Field("label_id") String label_id);
|
Call<BaseModel<List<TopRoom>>> getTopRooms(@Field("page") String page, @Field("page_limit") String page_limit, @Field("is_top") String is_top, @Field("label_id") String label_id);
|
||||||
|
|
||||||
@GET(Constants.GET_ROOM_TYPE)
|
@GET(Constants.GET_ROOM_TYPE)
|
||||||
Observable<BaseModel<List<RoomTypeModel>>> getRoomCategories();
|
Call<BaseModel<List<RoomTypeModel>>> getRoomCategories();
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.CHECK_TXT)
|
@POST(Constants.CHECK_TXT)
|
||||||
@@ -324,35 +329,35 @@ public interface ApiServer {
|
|||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.GET_REWARD_LIST)
|
@POST(Constants.GET_REWARD_LIST)
|
||||||
Observable<BaseModel<List<RewardUserBean>>> getRewardList(@Field("id") String id, @Field("page") String page, @Field("page_limit") String page_limit);
|
Call<BaseModel<List<RewardUserBean>>> getRewardList(@Field("id") String id, @Field("page") String page, @Field("page_limit") String page_limit);
|
||||||
|
|
||||||
@GET(Constants.GET_GIFT_LABEL)
|
@GET(Constants.GET_GIFT_LABEL)
|
||||||
Observable<BaseModel<List<GiftLabelBean>>> getGiftLabel(@Query("have_hot") String have_hot);
|
Call<BaseModel<List<GiftLabelBean>>> getGiftLabel(@Query("have_hot") String have_hot);
|
||||||
|
|
||||||
@GET(Constants.GIFT_LIST)
|
@GET(Constants.GIFT_LIST)
|
||||||
//获取礼物列表
|
//获取礼物列表
|
||||||
Observable<BaseModel<List<RoonGiftModel>>> getGiftList(@Query("label") int label,@Query("room_id")String room_id);
|
Call<BaseModel<List<RoonGiftModel>>> getGiftList(@Query("label") int label,@Query("room_id")String room_id);
|
||||||
|
|
||||||
@GET(Constants.TOPIC_LIST)
|
@GET(Constants.TOPIC_LIST)
|
||||||
//获取话题
|
//获取话题
|
||||||
Observable<BaseModel<List<HeatedBean>>> topicList(@Query("page") String page, @Query("page_limit") String page_limit);
|
Call<BaseModel<List<HeatedBean>>> topicList(@Query("page") String page, @Query("page_limit") String page_limit);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.PUBLISH_ZONE)
|
@POST(Constants.PUBLISH_ZONE)
|
||||||
Call<BaseModel<String>> publishZone(@Field("images") String images, @Field("content") String content, @Field("topic_id") String topic_id, @Field("room_id") String room_id, @Field("ip") String ip);
|
Call<BaseModel<String>> publishZone(@Field("images") String images, @Field("content") String content, @Field("topic_id") String topic_id, @Field("room_id") String room_id, @Field("ip") String ip);
|
||||||
|
|
||||||
@GET(Constants.GET_CATEGORIES)
|
@GET(Constants.GET_CATEGORIES)
|
||||||
Observable<BaseModel<List<HeatedBean>>> getCategories();
|
Call<BaseModel<List<HeatedBean>>> getCategories();
|
||||||
|
|
||||||
@GET(Constants.GET_CIRCLE_LIST)
|
@GET(Constants.GET_CIRCLE_LIST)
|
||||||
Call<BaseModel<List<CircleListBean>>> getCircleList(@Query("page") String page, @Query("page_limit") String page_limit);
|
Call<BaseModel<List<CircleListBean>>> getCircleList(@Query("page") String page, @Query("page_limit") String page_limit);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.GET_USER_HOME_ZONE)
|
@POST(Constants.GET_USER_HOME_ZONE)
|
||||||
Observable<BaseModel<List<CircleListBean>>> getCircleUserList(@Field("user_id") String user_id, @Field("page") String page, @Field("page_limit") String page_limit);
|
Call<BaseModel<List<CircleListBean>>> getCircleUserList(@Field("user_id") String user_id, @Field("page") String page, @Field("page_limit") String page_limit);
|
||||||
|
|
||||||
@GET(Constants.GET_MY_FOOT)
|
@GET(Constants.GET_MY_FOOT)
|
||||||
Observable<BaseModel<List<MyFootResp>>> getMyFoot(@Query("page") String page, @Query("page_limit") String page_limit);
|
Call<BaseModel<List<MyFootResp>>> getMyFoot(@Query("page") String page, @Query("page_limit") String page_limit);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.LIKE_ZONE)
|
@POST(Constants.LIKE_ZONE)
|
||||||
@@ -360,15 +365,15 @@ public interface ApiServer {
|
|||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.TOPIC_ID)
|
@POST(Constants.TOPIC_ID)
|
||||||
Observable<BaseModel<List<CircleListBean>>> topicId(@Field("topic_id") String topic_id);
|
Call<BaseModel<List<CircleListBean>>> topicId(@Field("topic_id") String topic_id);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.ZONE_DETAIL)
|
@POST(Constants.ZONE_DETAIL)
|
||||||
Observable<BaseModel<CircleListBean>> zoneDetail(@Field("id") String topic_id);
|
Call<BaseModel<CircleListBean>> zoneDetail(@Field("id") String topic_id);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.GET_USER_HOME)
|
@POST(Constants.GET_USER_HOME)
|
||||||
Observable<BaseModel<UserInfo>> getUserHome(@Field("user_id") String user_id);
|
Call<BaseModel<UserInfo>> getUserHome(@Field("user_id") String user_id);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.DELETE_COMMENT)
|
@POST(Constants.DELETE_COMMENT)
|
||||||
@@ -376,11 +381,11 @@ public interface ApiServer {
|
|||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.GET_COMMENT_LIST)
|
@POST(Constants.GET_COMMENT_LIST)
|
||||||
Observable<BaseModel<CommentBean>> getCommentList(@Field("id") String id, @Field("page") String page, @Field("page_limit") String page_limit);
|
Call<BaseModel<CommentBean>> getCommentList(@Field("id") String id, @Field("page") String page, @Field("page_limit") String page_limit);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.POST_SONG)
|
@POST(Constants.POST_SONG)
|
||||||
Observable<BaseModel<List<SongMusicBean>>> song(@Field("room_id") String roomId, @Field("user_id") String userId, @Field("song_code") String songCode, @Field("song_name") String songName, @Field("singer") String singer, @Field("poster") String poster, @Field("duration") String duration);
|
Call<BaseModel<List<SongMusicBean>>> song(@Field("room_id") String roomId, @Field("user_id") String userId, @Field("song_code") String songCode, @Field("song_name") String songName, @Field("singer") String singer, @Field("poster") String poster, @Field("duration") String duration);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.COMMENT_ZONE)
|
@POST(Constants.COMMENT_ZONE)
|
||||||
@@ -403,7 +408,7 @@ public interface ApiServer {
|
|||||||
Call<BaseModel<String>> deleteZone(@Field("id") String id);
|
Call<BaseModel<String>> deleteZone(@Field("id") String id);
|
||||||
|
|
||||||
@GET(Constants.GET_MY_INFO)
|
@GET(Constants.GET_MY_INFO)
|
||||||
Observable<BaseModel<UserInfo>> getMyInfo();
|
Call<BaseModel<UserInfo>> getMyInfo();
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.ED_USER_INFO)
|
@POST(Constants.ED_USER_INFO)
|
||||||
@@ -414,25 +419,25 @@ public interface ApiServer {
|
|||||||
Call<BaseModel<String>> editUserBg(@Field("images") String images);
|
Call<BaseModel<String>> editUserBg(@Field("images") String images);
|
||||||
|
|
||||||
@GET(Constants.GET_USER_TAG_LIST)
|
@GET(Constants.GET_USER_TAG_LIST)
|
||||||
Observable<BaseModel<List<UserTagBean>>> getUserTagList();
|
Call<BaseModel<List<UserTagBean>>> getUserTagList();
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.GET_LIKE_LIST)
|
@POST(Constants.GET_LIKE_LIST)
|
||||||
Observable<BaseModel<List<CircleListBean.LikeList>>> getLikeList(@Field("id") String id);
|
Call<BaseModel<List<CircleListBean.LikeList>>> getLikeList(@Field("id") String id);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.GET_ALBUM_DETAIL)
|
@POST(Constants.GET_ALBUM_DETAIL)
|
||||||
Observable<BaseModel<AlbumBean>> getAlbumDetail(@Field("album_id") String albumId, @Field("pwd") String pwd, @Field("page") String page, @Field("page_limit") String page_limit);
|
Call<BaseModel<AlbumBean>> getAlbumDetail(@Field("album_id") String albumId, @Field("pwd") String pwd, @Field("page") String page, @Field("page_limit") String page_limit);
|
||||||
|
|
||||||
@GET(Constants.GET_PERSONALTY)
|
@GET(Constants.GET_PERSONALTY)
|
||||||
Observable<BaseModel<List<PersonaltyBean>>> getPersonaltyList();
|
Call<BaseModel<List<PersonaltyBean>>> getPersonaltyList();
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.GET_SUBSIDY)
|
@POST(Constants.GET_SUBSIDY)
|
||||||
Observable<BaseModel<RoomSubsidy>> getSubsidy(@Field("room_id") String roomId);
|
Call<BaseModel<RoomSubsidy>> getSubsidy(@Field("room_id") String roomId);
|
||||||
|
|
||||||
@GET(Constants.GET_DECORATE)
|
@GET(Constants.GET_DECORATE)
|
||||||
Observable<BaseModel<List<ZhuangBanShangChengBean>>> getDecorateList(@Query("type") String type);
|
Call<BaseModel<List<ZhuangBanShangChengBean>>> getDecorateList(@Query("type") String type);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.POST_GZ)
|
@POST(Constants.POST_GZ)
|
||||||
@@ -477,7 +482,7 @@ public interface ApiServer {
|
|||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.JOIN_ROOM)
|
@POST(Constants.JOIN_ROOM)
|
||||||
Observable<BaseModel<RoomInfoResp>> roomGetIn(@Field("room_id") String roomId, @Field("password") String password);
|
Call<BaseModel<RoomInfoResp>> roomGetIn(@Field("room_id") String roomId, @Field("password") String password);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.DELETE_ALBUM_IMAGE)
|
@POST(Constants.DELETE_ALBUM_IMAGE)
|
||||||
@@ -497,11 +502,11 @@ public interface ApiServer {
|
|||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.UPDATEPASSWORD)
|
@POST(Constants.UPDATEPASSWORD)
|
||||||
Observable<BaseModel<String>> updatePassword(@Field("room_id") String roomId, @Field("password") String password);
|
Call<BaseModel<String>> updatePassword(@Field("room_id") String roomId, @Field("password") String password);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.GET_ROOM_ONLINE)
|
@POST(Constants.GET_ROOM_ONLINE)
|
||||||
Observable<BaseModel<RoomOnline>> getRoomOnline(@Field("room_id") String roomId, @Field("page") String page, @Field("page_limit") String page_limit);
|
Call<BaseModel<RoomOnline>> getRoomOnline(@Field("room_id") String roomId, @Field("page") String page, @Field("page_limit") String page_limit);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.GET_GIVE_GIFT)
|
@POST(Constants.GET_GIVE_GIFT)
|
||||||
@@ -512,29 +517,29 @@ public interface ApiServer {
|
|||||||
Call<BaseModel<String>> roomGift(@Field("room_id") String room_id, @Field("gift_id") String gift_id, @Field("gift_num") String num, @Field("to_uid") String to_uid, @Field("type") String gift_type, @Field("pit_number") String pit_number, @Field("heart_id") String heat_id);
|
Call<BaseModel<String>> roomGift(@Field("room_id") String room_id, @Field("gift_id") String gift_id, @Field("gift_num") String num, @Field("to_uid") String to_uid, @Field("type") String gift_type, @Field("pit_number") String pit_number, @Field("heart_id") String heat_id);
|
||||||
|
|
||||||
@GET(Constants.GET_FIRST_CHARGE_GIFT)
|
@GET(Constants.GET_FIRST_CHARGE_GIFT)
|
||||||
Observable<BaseModel<FirstChargeGiftBean>> firstChargeGift();
|
Call<BaseModel<FirstChargeGiftBean>> firstChargeGift();
|
||||||
|
|
||||||
@GET(Constants.GET_WALLET)
|
@GET(Constants.GET_WALLET)
|
||||||
Observable<BaseModel<WalletBean>> wallet();
|
Call<BaseModel<WalletBean>> wallet();
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.POST_APPLY_Pay)
|
@POST(Constants.POST_APPLY_Pay)
|
||||||
Observable<BaseModel<AppPay>> appPay(@Field("user_id") String user_id, @Field("money") String money, @Field("coin") String coin, @Field("type") String type);
|
Call<BaseModel<AppPay>> appPay(@Field("user_id") String user_id, @Field("money") String money, @Field("coin") String coin, @Field("type") String type);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.POST_APPLY_LIST)
|
@POST(Constants.POST_APPLY_LIST)
|
||||||
Observable<BaseModel<RoomApplyListBean>> roomApplyListBean(@Field("room_id") String room_id);
|
Call<BaseModel<RoomApplyListBean>> roomApplyListBean(@Field("room_id") String room_id);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.GET_ROOM_USER)
|
@POST(Constants.GET_ROOM_USER)
|
||||||
Observable<BaseModel<UserInfo>> getRoomUserInfo(@Field("room_id") String roomId, @Field("user_id") String userId);
|
Call<BaseModel<UserInfo>> getRoomUserInfo(@Field("room_id") String roomId, @Field("user_id") String userId);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.POST_BIND_TYPE)
|
@POST(Constants.POST_BIND_TYPE)
|
||||||
Observable<BaseModel<BindType>> bindType(@Field("user_id") String userId);
|
Call<BaseModel<BindType>> bindType(@Field("user_id") String userId);
|
||||||
|
|
||||||
@GET(Constants.GET_WALLET_CONFIG)
|
@GET(Constants.GET_WALLET_CONFIG)
|
||||||
Observable<BaseModel<WalletConfig>> getWalletConfig();
|
Call<BaseModel<WalletConfig>> getWalletConfig();
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.POST_BIND)
|
@POST(Constants.POST_BIND)
|
||||||
@@ -542,7 +547,7 @@ public interface ApiServer {
|
|||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.POST_SONG_LIST)
|
@POST(Constants.POST_SONG_LIST)
|
||||||
Observable<BaseModel<List<MusicSongBean>>> songList(@Field("room_id") String room_id);
|
Call<BaseModel<List<MusicSongBean>>> songList(@Field("room_id") String room_id);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.APPLY_PIT)
|
@POST(Constants.APPLY_PIT)
|
||||||
@@ -626,23 +631,23 @@ public interface ApiServer {
|
|||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.POST_HOST_LIST)
|
@POST(Constants.POST_HOST_LIST)
|
||||||
Observable<BaseModel<List<HostBean>>> getHostList(@Query("room_id") String room_id, @Field("type") String type);
|
Call<BaseModel<List<HostBean>>> getHostList(@Query("room_id") String room_id, @Field("type") String type);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.GET_CHARM_RANK)
|
@POST(Constants.GET_CHARM_RANK)
|
||||||
Observable<BaseModel<List<RoomCharmRankBean>>> getCharmRank(@Field("room_id") String roomId);
|
Call<BaseModel<List<RoomCharmRankBean>>> getCharmRank(@Field("room_id") String roomId);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.POST_ROOM_RELATION_LIST)
|
@POST(Constants.POST_ROOM_RELATION_LIST)
|
||||||
Observable<BaseModel<List<RoomRelationBean>>> roomRelationList(@Field("type") String type);
|
Call<BaseModel<List<RoomRelationBean>>> roomRelationList(@Field("type") String type);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.POST_ROOM_AUCTION_LIST)
|
@POST(Constants.POST_ROOM_AUCTION_LIST)
|
||||||
Observable<BaseModel<List<RoomAuction.AuctionListBean>>> roomAuctionList(@Field("auction_id") String auction_id);
|
Call<BaseModel<List<RoomAuction.AuctionListBean>>> roomAuctionList(@Field("auction_id") String auction_id);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.POST_SEARCH)
|
@POST(Constants.POST_SEARCH)
|
||||||
Observable<BaseModel<List<RoomSearchResp>>> getSearch(@Query("search") String room_id, @Field("type") String type);
|
Call<BaseModel<List<RoomSearchResp>>> getSearch(@Query("search") String room_id, @Field("type") String type);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.SET_PRESIDED_RATIO)
|
@POST(Constants.SET_PRESIDED_RATIO)
|
||||||
@@ -670,11 +675,11 @@ public interface ApiServer {
|
|||||||
Call<BaseModel<String>> setLockPit(@Field("room_id") String room_id, @Field("pit_number") String pit_number, @Field("is_lock") String is_lock);
|
Call<BaseModel<String>> setLockPit(@Field("room_id") String room_id, @Field("pit_number") String pit_number, @Field("is_lock") String is_lock);
|
||||||
|
|
||||||
@GET(Constants.GET_ROOM_BJ)
|
@GET(Constants.GET_ROOM_BJ)
|
||||||
Observable<BaseModel<RoomBgBean>> getBackgroundList();
|
Call<BaseModel<RoomBgBean>> getBackgroundList();
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.POST_CHARM_LIST)
|
@POST(Constants.POST_CHARM_LIST)
|
||||||
Observable<BaseModel<RoomDetails>> getCharmList(@Field("room_id") String room_id, @Field("start_time") String start_time, @Field("end_time") String end_time, @Field("page") String page);
|
Call<BaseModel<RoomDetails>> getCharmList(@Field("room_id") String room_id, @Field("start_time") String start_time, @Field("end_time") String end_time, @Field("page") String page);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.POST_SET_UPLOAD_BG_IMG)
|
@POST(Constants.POST_SET_UPLOAD_BG_IMG)
|
||||||
@@ -707,7 +712,7 @@ public interface ApiServer {
|
|||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.POST_RELATION_CARD)
|
@POST(Constants.POST_RELATION_CARD)
|
||||||
Observable<BaseModel<RelationCardBean>> relationCard(@Field("user_id") String user_id);
|
Call<BaseModel<RelationCardBean>> relationCard(@Field("user_id") String user_id);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.POST_TOP_RELATION_CARD)
|
@POST(Constants.POST_TOP_RELATION_CARD)
|
||||||
@@ -720,11 +725,11 @@ public interface ApiServer {
|
|||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.POST_ROOM_AUCTION)
|
@POST(Constants.POST_ROOM_AUCTION)
|
||||||
Observable<BaseModel<AuctionBean>> roomAuction(@Field("room_id") String room_id, @Field("user_id") String user_id, @Field("gift_id") String gift_id, @Field("relation_id") String relation_id, @Field("auction_type") String auction_type, @Field("time_day") String time_day);
|
Call<BaseModel<AuctionBean>> roomAuction(@Field("room_id") String room_id, @Field("user_id") String user_id, @Field("gift_id") String gift_id, @Field("relation_id") String relation_id, @Field("auction_type") String auction_type, @Field("time_day") String time_day);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.POST_ROOM_AUCTION_TIME)
|
@POST(Constants.POST_ROOM_AUCTION_TIME)
|
||||||
Observable<BaseModel<RoomTime>> roomAuctionTime(@Field("gift_id") String gift_id);
|
Call<BaseModel<RoomTime>> roomAuctionTime(@Field("gift_id") String gift_id);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.POST_ROOM_AUCTION_JOIN)
|
@POST(Constants.POST_ROOM_AUCTION_JOIN)
|
||||||
@@ -733,7 +738,7 @@ public interface ApiServer {
|
|||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST(Constants.POST_SEARCH_PK_ROOM)
|
@POST(Constants.POST_SEARCH_PK_ROOM)
|
||||||
Observable<BaseModel<List<RoomBean>>> searchPkRoom(@Field("room_id") String room_id, @Field("page") String page, @Field("limit") String limit);
|
Call<BaseModel<List<RoomBean>>> searchPkRoom(@Field("room_id") String room_id, @Field("page") String page, @Field("limit") String limit);
|
||||||
|
|
||||||
@GET(Constants.GET_BOX_GIFT_LIST)
|
@GET(Constants.GET_BOX_GIFT_LIST)
|
||||||
Call<BaseModel<BlindBoxBean>> getBoxGiftList(@Query("gift_bag_id") String gift_bag_id, @Query("room_id") String room_id);
|
Call<BaseModel<BlindBoxBean>> getBoxGiftList(@Query("gift_bag_id") String gift_bag_id, @Query("room_id") String room_id);
|
||||||
@@ -777,4 +782,8 @@ public interface ApiServer {
|
|||||||
@GET(Constants.GET_GIFT_PACK_LIST_COUNT)
|
@GET(Constants.GET_GIFT_PACK_LIST_COUNT)
|
||||||
Call<BaseModel<GiftPackListCount>> getGiftPackListCount();
|
Call<BaseModel<GiftPackListCount>> getGiftPackListCount();
|
||||||
|
|
||||||
|
@FormUrlEncoded
|
||||||
|
@POST(Constants.ROOM_USER_RECONNECT)
|
||||||
|
Call<BaseModel<String>> roomUserReconnect(@Field("room_id") String room_id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,8 +53,11 @@ public abstract class BaseObserver<T> implements Observer<T> {
|
|||||||
} else if (e instanceof APIException) {
|
} else if (e instanceof APIException) {
|
||||||
APIException apiException = (APIException) e;
|
APIException apiException = (APIException) e;
|
||||||
if (apiException.getCode() == 301) {
|
if (apiException.getCode() == 301) {
|
||||||
EventBus.getDefault().post(new LogOutEvent());
|
|
||||||
try {
|
try {
|
||||||
|
ToastUtils.show(extractChinese(apiException.getMessage()));
|
||||||
|
// com.blankj.utilcode.util.ToastUtils.showShort("提示当前账号已在别的地方登陆,如果不是本人操作请修改密码");
|
||||||
|
EventBus.getDefault().post(new LogOutEvent());
|
||||||
CommonAppContext.getInstance().clearLoginInfo();
|
CommonAppContext.getInstance().clearLoginInfo();
|
||||||
} catch (ClassNotFoundException ex) {
|
} catch (ClassNotFoundException ex) {
|
||||||
throw new RuntimeException(ex);
|
throw new RuntimeException(ex);
|
||||||
|
|||||||
@@ -2,8 +2,12 @@ package com.xscm.moduleutil.http;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import com.blankj.utilcode.util.ToastUtils;
|
||||||
import com.xscm.moduleutil.base.CommonAppContext;
|
import com.xscm.moduleutil.base.CommonAppContext;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import io.reactivex.Observable;
|
import io.reactivex.Observable;
|
||||||
import io.reactivex.ObservableSource;
|
import io.reactivex.ObservableSource;
|
||||||
import io.reactivex.ObservableTransformer;
|
import io.reactivex.ObservableTransformer;
|
||||||
@@ -23,16 +27,27 @@ public class DefaultTransformer<T> implements ObservableTransformer<BaseModel<T>
|
|||||||
return upstream
|
return upstream
|
||||||
.map(response -> {
|
.map(response -> {
|
||||||
if (response.isTokenExpired()) {
|
if (response.isTokenExpired()) {
|
||||||
// 触发登出事件(EventBus)
|
if (response.getCode()==301){
|
||||||
CommonAppContext.getInstance().clearLoginInfo();
|
CommonAppContext.getInstance().clearLoginInfo();
|
||||||
throw new APIException(-1, "登录已过期");
|
ToastUtils.showShort(response.getMsg());
|
||||||
|
}else {
|
||||||
|
// 触发登出事件(EventBus)
|
||||||
|
// com.blankj.utilcode.util.ToastUtils.showShort("提示当前账号已在别的地方登陆,如果不是本人操作请修改密码");
|
||||||
|
CommonAppContext.getInstance().clearLoginInfo();
|
||||||
|
}
|
||||||
|
throw new APIException(response.getCode(), response.getMsg());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!response.isSuccess()) {
|
if (!response.isSuccess()) {
|
||||||
throw new APIException(response.getCode(), response.getMsg());
|
throw new APIException(response.getCode(), response.getMsg());
|
||||||
}
|
}
|
||||||
|
// 确保不会返回null值
|
||||||
return response.getData();
|
T data = response.getData();
|
||||||
|
if (data == null) {
|
||||||
|
return getDefaultValue();
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
// return response.getData();
|
||||||
})
|
})
|
||||||
.onErrorResumeNext(throwable -> {
|
.onErrorResumeNext(throwable -> {
|
||||||
// 可以在这里统一处理异常
|
// 可以在这里统一处理异常
|
||||||
@@ -44,4 +59,32 @@ public class DefaultTransformer<T> implements ObservableTransformer<BaseModel<T>
|
|||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread());
|
.observeOn(AndroidSchedulers.mainThread());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private T getDefaultValue() {
|
||||||
|
try {
|
||||||
|
// 根据类型返回合理的默认值
|
||||||
|
Class<T> type = (Class<T>) Object.class;
|
||||||
|
if (String.class.isAssignableFrom(type)) {
|
||||||
|
return (T) "";
|
||||||
|
} else if (List.class.isAssignableFrom(type)) {
|
||||||
|
return (T) new ArrayList<>();
|
||||||
|
} else if (Integer.class.isAssignableFrom(type) || int.class.isAssignableFrom(type)) {
|
||||||
|
return (T) Integer.valueOf(0);
|
||||||
|
} else if (Long.class.isAssignableFrom(type) || long.class.isAssignableFrom(type)) {
|
||||||
|
return (T) Long.valueOf(0L);
|
||||||
|
} else if (Double.class.isAssignableFrom(type) || double.class.isAssignableFrom(type)) {
|
||||||
|
return (T) Double.valueOf(0.0);
|
||||||
|
} else if (Float.class.isAssignableFrom(type) || float.class.isAssignableFrom(type)) {
|
||||||
|
return (T) Float.valueOf(0.0f);
|
||||||
|
} else if (Boolean.class.isAssignableFrom(type) || boolean.class.isAssignableFrom(type)) {
|
||||||
|
return (T) Boolean.FALSE;
|
||||||
|
} else {
|
||||||
|
// 对于其他对象类型,返回一个新的Object实例
|
||||||
|
return (T) new Object();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,7 @@ package com.xscm.moduleutil.http;
|
|||||||
|
|
||||||
import com.blankj.utilcode.util.ToastUtils;
|
import com.blankj.utilcode.util.ToastUtils;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.JsonParseException;
|
||||||
import com.google.gson.TypeAdapter;
|
import com.google.gson.TypeAdapter;
|
||||||
import com.xscm.moduleutil.utils.GsonUtils;
|
import com.xscm.moduleutil.utils.GsonUtils;
|
||||||
|
|
||||||
@@ -25,21 +26,76 @@ public class ResponseBodyConverter<T> implements Converter<ResponseBody, T> {
|
|||||||
@Override
|
@Override
|
||||||
public T convert(@NonNull ResponseBody value) throws IOException {
|
public T convert(@NonNull ResponseBody value) throws IOException {
|
||||||
String json = value.string();
|
String json = value.string();
|
||||||
BaseModel obj = GsonUtils.GsonToBean(json, BaseModel.class);
|
try {
|
||||||
if (obj.getCode() != 1) {
|
BaseModel obj = GsonUtils.GsonToBean(json, BaseModel.class);
|
||||||
String info = obj.getMsg();
|
if (obj.getCode() != 1) {
|
||||||
if ("当前余额不足".equals(info)) {
|
String info = obj.getMsg();
|
||||||
value.close();
|
if ("当前余额不足".equals(info)) {
|
||||||
return adapter.fromJson(json);
|
value.close();
|
||||||
} else {
|
return parseDataSafely(json);
|
||||||
if(!info.contains("更新失败")) {
|
} else {
|
||||||
ToastUtils.showShort(info);
|
if (!info.contains("更新失败")) {
|
||||||
}
|
// ToastUtils.showShort(info);
|
||||||
|
}
|
||||||
// throw new APIException(obj.getCode(), info);
|
// throw new APIException(obj.getCode(), info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
value.close();
|
||||||
|
return parseDataSafely(json);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 处理解析异常,避免崩溃
|
||||||
|
value.close();
|
||||||
|
try {
|
||||||
|
// 尝试返回默认值
|
||||||
|
return createDefaultInstance();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 安全地解析数据,处理各种可能的返回类型
|
||||||
|
*/
|
||||||
|
private T parseDataSafely(String json) {
|
||||||
|
try {
|
||||||
|
return adapter.fromJson(json);
|
||||||
|
} catch (IOException | JsonParseException e) {
|
||||||
|
// 当解析失败时,尝试其他方式处理
|
||||||
|
try {
|
||||||
|
// 尝试返回默认值
|
||||||
|
return createDefaultInstance();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
value.close();
|
|
||||||
return adapter.fromJson(json);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建默认实例以避免null返回
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private T createDefaultInstance() {
|
||||||
|
try {
|
||||||
|
// 对于基本类型和常见集合类型,返回默认值
|
||||||
|
Class<?> rawType = adapter.getClass();
|
||||||
|
if (rawType.isAssignableFrom(String.class)) {
|
||||||
|
return (T) "";
|
||||||
|
} else if (rawType.isAssignableFrom(Boolean.class) || rawType.isAssignableFrom(boolean.class)) {
|
||||||
|
return (T) Boolean.FALSE;
|
||||||
|
} else if (rawType.isAssignableFrom(Integer.class) || rawType.isAssignableFrom(int.class)) {
|
||||||
|
return (T) Integer.valueOf(0);
|
||||||
|
} else if (rawType.isAssignableFrom(Long.class) || rawType.isAssignableFrom(long.class)) {
|
||||||
|
return (T) Long.valueOf(0L);
|
||||||
|
} else if (rawType.isAssignableFrom(Double.class) || rawType.isAssignableFrom(double.class)) {
|
||||||
|
return (T) Double.valueOf(0.0);
|
||||||
|
} else if (rawType.isAssignableFrom(Float.class) || rawType.isAssignableFrom(float.class)) {
|
||||||
|
return (T) Float.valueOf(0.0f);
|
||||||
|
} else {
|
||||||
|
// 对于其他类型,返回null而不是抛出异常
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
package com.xscm.moduleutil.listener;
|
package com.xscm.moduleutil.listener;
|
||||||
|
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.blankj.utilcode.util.GsonUtils;
|
import com.blankj.utilcode.util.GsonUtils;
|
||||||
import com.blankj.utilcode.util.LogUtils;
|
import com.blankj.utilcode.util.LogUtils;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
|
import com.xscm.moduleutil.base.CommonAppContext;
|
||||||
import com.xscm.moduleutil.bean.HeadlineBean;
|
import com.xscm.moduleutil.bean.HeadlineBean;
|
||||||
import com.xscm.moduleutil.bean.RoomMessageEvent;
|
import com.xscm.moduleutil.bean.RoomMessageEvent;
|
||||||
import com.xscm.moduleutil.bean.room.EMMessageInfo;
|
import com.xscm.moduleutil.bean.room.EMMessageInfo;
|
||||||
@@ -29,6 +33,10 @@ import org.greenrobot.eventbus.EventBus;
|
|||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author qx
|
* @author qx
|
||||||
@@ -42,9 +50,20 @@ public class MessageListenerSingleton {
|
|||||||
private V2TIMSimpleMsgListener simpleMsgListener;
|
private V2TIMSimpleMsgListener simpleMsgListener;
|
||||||
private V2TIMAdvancedMsgListener v2TIMAdvancedMsgListener;
|
private V2TIMAdvancedMsgListener v2TIMAdvancedMsgListener;
|
||||||
private static String mRoomId = "";
|
private static String mRoomId = "";
|
||||||
|
public static String groupId;
|
||||||
private V2TIMGroupListener groupListener;
|
private V2TIMGroupListener groupListener;
|
||||||
private V2TIMConversationListener conversationListener; // 需要保存引用
|
private V2TIMConversationListener conversationListener; // 需要保存引用
|
||||||
|
|
||||||
|
// 添加操作状态标记
|
||||||
|
private volatile boolean isGroupOperationInProgress = false;
|
||||||
|
private final Object groupOperationLock = new Object();
|
||||||
|
private Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||||
|
|
||||||
|
// 添加消息缓存机制
|
||||||
|
private static final int MAX_CACHED_MESSAGES = 20;
|
||||||
|
private final Map<String, List<RoomMessageEvent>> cachedMessages = new ConcurrentHashMap<>();
|
||||||
|
private final Set<String> joinedRooms = ConcurrentHashMap.newKeySet();
|
||||||
|
|
||||||
// private boolean listenersAdded = false; // 标记监听器是否已添加
|
// private boolean listenersAdded = false; // 标记监听器是否已添加
|
||||||
// 1. 添加新的监听器接口
|
// 1. 添加新的监听器接口
|
||||||
public interface PublicScreenMessageListener {
|
public interface PublicScreenMessageListener {
|
||||||
@@ -78,39 +97,293 @@ public class MessageListenerSingleton {
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改 joinGroup 方法
|
/**
|
||||||
public void joinGroup(String roomId) {
|
* 缓存消息(用于在Fragment未准备好时存储消息)
|
||||||
mRoomId = roomId;
|
*/
|
||||||
LogUtils.e("@@@", "加入房间的"+roomId);
|
private void cacheMessage(String roomId, RoomMessageEvent message) {
|
||||||
// 确保监听器已初始化并添加
|
if (TextUtils.isEmpty(roomId) || message == null) {
|
||||||
ensureListenersAdded();
|
return;
|
||||||
// RoomMessageEvent.T t = new RoomMessageEvent.T();
|
}
|
||||||
// t.setText("羽声严禁未成年人进行直播或打赏,官方将24小时在线巡查。我们提倡绿色直播,直播间严禁出现涉政、涉恐、涉黄、涉赌等违法违规内容,严禁宣传封建迷信、宗教极端思想、出现低俗色情、吸烟酗酒等内容,严禁违反社会主义核心价值观、践踏社会道德底线、诱导打赏、低俗 PK 、买卖金币等行为,请大家共同遵守、监督并及时举报。请勿相信各类刷钻、购买礼包、游戏币及电商贩卖等非官方广告信息,谨防网络诈骗。");
|
// 标记该房间有待处理的消息
|
||||||
// notifyMessageReceived(new RoomMessageEvent(1000, mRoomId, t));
|
List<RoomMessageEvent> roomMessages = cachedMessages.computeIfAbsent(roomId, k -> new ArrayList<>());
|
||||||
V2TIMManager.getInstance().joinGroup("room" + mRoomId, "申请加入", new V2TIMCallback() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess() {
|
|
||||||
Log.d("@@@", "加入im群组成功:");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
// 限制每个房间的缓存消息数量
|
||||||
public void onError(int code, String desc) {
|
if (roomMessages.size() >= MAX_CACHED_MESSAGES) {
|
||||||
Log.d("@@@", "加入群组失败:" + code + "=" + desc);
|
roomMessages.remove(0); // 移除最旧的消息
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
if (tempGroupJoinListener == null) {
|
roomMessages.add(message);
|
||||||
tempGroupJoinListener = new OnMessageReceivedListener() {
|
LogUtils.d("MessageListener", "缓存消息: roomId=" + roomId + ", msgType=" + message.getMsgType());
|
||||||
@Override
|
}
|
||||||
public void onMessageReceived(RoomMessageEvent message) {
|
|
||||||
// 处理消息
|
|
||||||
|
|
||||||
}
|
/**
|
||||||
};
|
* 获取并清除指定房间的缓存消息
|
||||||
addOnMessageReceivedListener(tempGroupJoinListener);
|
*/
|
||||||
|
public List<RoomMessageEvent> getAndClearCachedMessages(String roomId) {
|
||||||
|
if (TextUtils.isEmpty(roomId)) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<RoomMessageEvent> messages = cachedMessages.remove(roomId);
|
||||||
|
if (messages == null) {
|
||||||
|
messages = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
LogUtils.d("MessageListener", "获取并清除缓存消息: roomId=" + roomId + ", count=" + messages.size());
|
||||||
|
return messages;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标记房间已加入
|
||||||
|
*/
|
||||||
|
public void markRoomJoined(String roomId) {
|
||||||
|
if (!TextUtils.isEmpty(roomId)) {
|
||||||
|
joinedRooms.add(roomId);
|
||||||
|
LogUtils.d("MessageListener", "标记房间已加入: " + roomId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查房间是否已加入
|
||||||
|
*/
|
||||||
|
public boolean isRoomJoined(String roomId) {
|
||||||
|
return !TextUtils.isEmpty(roomId) && joinedRooms.contains(roomId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清除房间加入标记
|
||||||
|
*/
|
||||||
|
public void clearRoomJoined(String roomId) {
|
||||||
|
if (!TextUtils.isEmpty(roomId)) {
|
||||||
|
joinedRooms.remove(roomId);
|
||||||
|
LogUtils.d("MessageListener", "清除房间加入标记: " + roomId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 修改 joinGroup 方法
|
||||||
|
// public void joinGroup(String roomId) {
|
||||||
|
// if (TextUtils.isEmpty(roomId)) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // 使用同步块确保操作的原子性
|
||||||
|
// synchronized (groupOperationLock) {
|
||||||
|
// if (isGroupOperationInProgress) {
|
||||||
|
// // 如果有操作正在进行,延迟执行
|
||||||
|
// mainHandler.removeCallbacksAndMessages(null);
|
||||||
|
// mainHandler.postDelayed(() -> joinGroup(roomId), 100);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// isGroupOperationInProgress = true;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// // 在新线程中执行操作
|
||||||
|
// new Thread(() -> {
|
||||||
|
// try {
|
||||||
|
// // 先退出当前群组
|
||||||
|
// if (groupId != null && !groupId.equals(roomId)) {
|
||||||
|
// try {
|
||||||
|
// quitGroup(groupId);
|
||||||
|
// // 执行退出操作
|
||||||
|
// // TIMGroupManager.getInstance().quitGroup(groupId);
|
||||||
|
// LogUtils.d("MessageListener", "退出群组: " + groupId);
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// LogUtils.e("MessageListener", "退出群组失败: " + e.getMessage());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // 等待一小段时间确保退出完成
|
||||||
|
// Thread.sleep(500);
|
||||||
|
//
|
||||||
|
// // 加入新群组
|
||||||
|
// try {
|
||||||
|
// // 执行加入操作
|
||||||
|
//
|
||||||
|
// ensureListenersAdded();
|
||||||
|
// V2TIMManager.getInstance().joinGroup("room" + roomId, "申请加入", new V2TIMCallback() {
|
||||||
|
// @Override
|
||||||
|
// public void onSuccess() {
|
||||||
|
// Log.d("@@@", "加入im群组成功:");
|
||||||
|
//
|
||||||
|
// groupId = roomId;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void onError(int code, String desc) {
|
||||||
|
// Log.d("@@@", "加入群组失败:" + code + "=" + desc);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// groupId = roomId;
|
||||||
|
// LogUtils.d("MessageListener", "加入群组: " + roomId);
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// LogUtils.e("MessageListener", "加入群组失败: " + e.getMessage());
|
||||||
|
// }
|
||||||
|
// } catch (InterruptedException e) {
|
||||||
|
// Thread.currentThread().interrupt();
|
||||||
|
// } finally {
|
||||||
|
// synchronized (groupOperationLock) {
|
||||||
|
// isGroupOperationInProgress = false;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }).start();
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//// LogUtils.e("@@@", "加入房间的"+roomId);
|
||||||
|
//// if (groupId!=null){
|
||||||
|
//// quitGroup(groupId);
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// // 确保监听器已初始化并添加
|
||||||
|
//// ensureListenersAdded();
|
||||||
|
//// V2TIMManager.getInstance().joinGroup("room" + roomId, "申请加入", new V2TIMCallback() {
|
||||||
|
//// @Override
|
||||||
|
//// public void onSuccess() {
|
||||||
|
//// Log.d("@@@", "加入im群组成功:");
|
||||||
|
////
|
||||||
|
//// groupId = roomId;
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// @Override
|
||||||
|
//// public void onError(int code, String desc) {
|
||||||
|
//// Log.d("@@@", "加入群组失败:" + code + "=" + desc);
|
||||||
|
//// }
|
||||||
|
//// });
|
||||||
|
//
|
||||||
|
// if (tempGroupJoinListener == null) {
|
||||||
|
// tempGroupJoinListener = new OnMessageReceivedListener() {
|
||||||
|
// @Override
|
||||||
|
// public void onMessageReceived(RoomMessageEvent message) {
|
||||||
|
// // 处理消息
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
// addOnMessageReceivedListener(tempGroupJoinListener);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// 修改 joinGroup 方法,确保先退出再加入
|
||||||
|
public void joinGroup(String roomId) {
|
||||||
|
if (TextUtils.isEmpty(roomId)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized (groupOperationLock) {
|
||||||
|
if (isGroupOperationInProgress) {
|
||||||
|
// 如果有操作正在进行,延迟执行
|
||||||
|
mainHandler.removeCallbacksAndMessages(null);
|
||||||
|
mainHandler.postDelayed(() -> joinGroup(roomId), 100);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
isGroupOperationInProgress = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
// 先退出当前群组(如果需要)
|
||||||
|
if (groupId != null && !groupId.equals(roomId)) {
|
||||||
|
LogUtils.d("MessageListener", "开始退出群组: " + groupId);
|
||||||
|
CountDownLatch quitLatch = new CountDownLatch(1);
|
||||||
|
boolean[] quitSuccess = {false};
|
||||||
|
|
||||||
|
try {
|
||||||
|
V2TIMManager.getInstance().quitGroup("room" + groupId, new V2TIMCallback() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess() {
|
||||||
|
LogUtils.d("MessageListener", "退出群组成功: " + groupId);
|
||||||
|
quitSuccess[0] = true;
|
||||||
|
quitLatch.countDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(int code, String desc) {
|
||||||
|
LogUtils.e("MessageListener", "退出群组失败: " + groupId + ", code=" + code + ", desc=" + desc);
|
||||||
|
quitSuccess[0] = false;
|
||||||
|
quitLatch.countDown();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 等待退出操作完成,最多等待3秒
|
||||||
|
try {
|
||||||
|
quitLatch.await(3, java.util.concurrent.TimeUnit.SECONDS);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtils.e("MessageListener", "退出群组异常: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 等待一段时间确保退出完成
|
||||||
|
try {
|
||||||
|
Thread.sleep(200);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加入新群组
|
||||||
|
LogUtils.d("MessageListener", "开始加入群组: " + roomId);
|
||||||
|
CountDownLatch joinLatch = new CountDownLatch(1);
|
||||||
|
boolean[] joinSuccess = {false};
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 确保监听器已添加
|
||||||
|
ensureListenersAdded();
|
||||||
|
|
||||||
|
V2TIMManager.getInstance().joinGroup("room" + roomId, "申请加入", new V2TIMCallback() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess() {
|
||||||
|
LogUtils.d("MessageListener", "加入im群组成功: " + roomId);
|
||||||
|
joinSuccess[0] = true;
|
||||||
|
groupId = roomId;
|
||||||
|
joinLatch.countDown();
|
||||||
|
// 标记房间已加入
|
||||||
|
markRoomJoined(roomId);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// // 发送加入成功的事件
|
||||||
|
// mainHandler.post(() -> {
|
||||||
|
// RoomMessageEvent.T t = new RoomMessageEvent.T();
|
||||||
|
// t.setText("成功加入房间");
|
||||||
|
// notifyMessageReceived(new RoomMessageEvent(1000, roomId, t));
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(int code, String desc) {
|
||||||
|
LogUtils.e("MessageListener", "加入群组失败: " + roomId + ", code=" + code + ", desc=" + desc);
|
||||||
|
joinSuccess[0] = false;
|
||||||
|
joinLatch.countDown();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 等待加入操作完成,最多等待3秒
|
||||||
|
try {
|
||||||
|
joinLatch.await(3, java.util.concurrent.TimeUnit.SECONDS);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtils.e("MessageListener", "加入群组异常: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
LogUtils.d("MessageListener", "群组操作完成 - 退出成功: " + (groupId == null || !groupId.equals(roomId)) + ", 加入成功: " + joinSuccess[0]);
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
synchronized (groupOperationLock) {
|
||||||
|
isGroupOperationInProgress = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void initListeners() {
|
private void initListeners() {
|
||||||
// 简单消息监听器
|
// 简单消息监听器
|
||||||
if (simpleMsgListener == null) {
|
if (simpleMsgListener == null) {
|
||||||
@@ -240,7 +513,15 @@ public class MessageListenerSingleton {
|
|||||||
@Override
|
@Override
|
||||||
public void onTotalUnreadMessageCountChanged(long totalUnreadCount) {
|
public void onTotalUnreadMessageCountChanged(long totalUnreadCount) {
|
||||||
super.onTotalUnreadMessageCountChanged(totalUnreadCount);
|
super.onTotalUnreadMessageCountChanged(totalUnreadCount);
|
||||||
EventBus.getDefault().post(new UnreadCountEvent(totalUnreadCount));
|
|
||||||
|
UnreadCountEvent event = CommonAppContext.getInstance().getUnreadCountEvent();
|
||||||
|
if (event== null){
|
||||||
|
event = new UnreadCountEvent();
|
||||||
|
event.setBLong(0);
|
||||||
|
}
|
||||||
|
event.setALong( totalUnreadCount);
|
||||||
|
CommonAppContext.getInstance().setUnreadCountEvent(event);
|
||||||
|
EventBus.getDefault().post(event);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -290,19 +571,28 @@ public class MessageListenerSingleton {
|
|||||||
|
|
||||||
// 修改 quitGroup 方法
|
// 修改 quitGroup 方法
|
||||||
public static void quitGroup(String mRoomId) {
|
public static void quitGroup(String mRoomId) {
|
||||||
|
|
||||||
V2TIMManager.getInstance().quitGroup("room" + mRoomId, new V2TIMCallback() {
|
V2TIMManager.getInstance().quitGroup("room" + mRoomId, new V2TIMCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
LogUtils.d("@@@","退出群组成功"+mRoomId);
|
LogUtils.d("@@@", "退出群组成功" + mRoomId);
|
||||||
// removeAllListeners(); // 移除所有监听器
|
// removeAllListeners(); // 移除所有监听器
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(int code, String desc) {
|
public void onError(int code, String desc) {
|
||||||
LogUtils.d("@@@","退出群组失败"+mRoomId, code, desc);
|
LogUtils.d("@@@", "退出群组失败" + mRoomId, code, desc);
|
||||||
// removeAllListeners(); // 即使失败也移除监听器
|
// removeAllListeners(); // 即使失败也移除监听器
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (instance != null) {
|
||||||
|
instance.listeners.clear();
|
||||||
|
removeAllListeners();
|
||||||
|
isInitialized = false;
|
||||||
|
groupId = null;
|
||||||
|
LogUtils.e("@@@", "重置成功");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改 reset 方法
|
// 修改 reset 方法
|
||||||
@@ -311,9 +601,10 @@ public class MessageListenerSingleton {
|
|||||||
instance.listeners.clear();
|
instance.listeners.clear();
|
||||||
removeAllListeners();
|
removeAllListeners();
|
||||||
isInitialized = false;
|
isInitialized = false;
|
||||||
|
groupId = null;
|
||||||
// instance = null;
|
// instance = null;
|
||||||
quitGroup(roomId);
|
quitGroup(roomId);
|
||||||
LogUtils.e("@@@","重置成功");
|
LogUtils.e("@@@", "重置成功");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -634,6 +925,11 @@ public class MessageListenerSingleton {
|
|||||||
// for (OnMessageReceivedListener listener : listeners) {
|
// for (OnMessageReceivedListener listener : listeners) {
|
||||||
// listener.onMessageReceived(message);
|
// listener.onMessageReceived(message);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
if (message.getMsgType() == 1001 && publicScreenListeners.isEmpty()) {
|
||||||
|
cacheMessage(message.getRoomId(), message);
|
||||||
|
}
|
||||||
|
|
||||||
// 通知原有的监听器
|
// 通知原有的监听器
|
||||||
for (OnMessageReceivedListener listener : listeners) {
|
for (OnMessageReceivedListener listener : listeners) {
|
||||||
listener.onMessageReceived(message);
|
listener.onMessageReceived(message);
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.xscm.moduleutil.rtc;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*@author qx
|
||||||
|
*@data 2025/9/18
|
||||||
|
*@description: 加入声网返回
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class AgoraIsOPen {
|
||||||
|
private boolean isOpen;
|
||||||
|
}
|
||||||
@@ -1,138 +0,0 @@
|
|||||||
package com.xscm.moduleutil.service;
|
|
||||||
|
|
||||||
|
|
||||||
import android.animation.Animator;
|
|
||||||
import android.animation.AnimatorListenerAdapter;
|
|
||||||
import android.animation.ObjectAnimator;
|
|
||||||
import android.app.Service;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.graphics.PixelFormat;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.IBinder;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewTreeObserver;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
|
|
||||||
import com.xscm.moduleutil.R;
|
|
||||||
import com.xscm.moduleutil.event.MqttBean;
|
|
||||||
import com.xscm.moduleutil.utils.ImageUtils;
|
|
||||||
|
|
||||||
|
|
||||||
public class EMqttService extends Service {
|
|
||||||
private WindowManager windowManager;
|
|
||||||
private View piaoPingView;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate() {
|
|
||||||
super.onCreate();
|
|
||||||
windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
|
||||||
if (intent != null && intent.hasExtra("mqttBean")) {
|
|
||||||
MqttBean mqttBean = (MqttBean) intent.getSerializableExtra("mqttBean");
|
|
||||||
showPiaoPingMessage(mqttBean);//全局飘屏
|
|
||||||
}
|
|
||||||
return START_NOT_STICKY;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
if (piaoPingView != null) {
|
|
||||||
windowManager.removeView(piaoPingView);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IBinder onBind(Intent intent) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void showPiaoPingMessage(MqttBean mqttBean) {
|
|
||||||
|
|
||||||
int screenWidth = getResources().getDisplayMetrics().widthPixels;
|
|
||||||
int screenHeight = getResources().getDisplayMetrics().heightPixels;
|
|
||||||
//
|
|
||||||
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(
|
|
||||||
WindowManager.LayoutParams.MATCH_PARENT,
|
|
||||||
WindowManager.LayoutParams.WRAP_CONTENT,
|
|
||||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ?
|
|
||||||
WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY :
|
|
||||||
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
|
|
||||||
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
|
|
||||||
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
|
|
||||||
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
|
|
||||||
PixelFormat.TRANSLUCENT);
|
|
||||||
//
|
|
||||||
// // 设置 Gravity 为左上角
|
|
||||||
// layoutParams.gravity = Gravity.TOP | Gravity.START;
|
|
||||||
//
|
|
||||||
// // Y 轴随机位置
|
|
||||||
// layoutParams.y = (int) ((Math.random() * (screenHeight - 200)));
|
|
||||||
//
|
|
||||||
// // 初始 X 设为负值,确保 View 在屏幕左侧外
|
|
||||||
// layoutParams.x = -screenWidth;
|
|
||||||
|
|
||||||
// FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
|
|
||||||
// FrameLayout.LayoutParams.MATCH_PARENT,
|
|
||||||
// FrameLayout.LayoutParams.WRAP_CONTENT);
|
|
||||||
//
|
|
||||||
|
|
||||||
// 设置随机 Y 轴位置
|
|
||||||
// layoutParams.topMargin = (int) (Math.random() * (screenHeight - 200));
|
|
||||||
|
|
||||||
|
|
||||||
piaoPingView = LayoutInflater.from(this).inflate(R.layout.item_piaoping, null);
|
|
||||||
TextView textView = piaoPingView.findViewById(R.id.tv_name);
|
|
||||||
textView.setText(mqttBean.getList().getText());
|
|
||||||
ImageUtils.loadHeadCC(mqttBean.getList().getGift_picture(), piaoPingView.findViewById(R.id.iv_piaoping));
|
|
||||||
TextView tv_time = piaoPingView.findViewById(R.id.tv_num);
|
|
||||||
tv_time.setText(mqttBean.getList().getNumber());
|
|
||||||
windowManager.addView(piaoPingView, layoutParams);
|
|
||||||
|
|
||||||
piaoPingView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
|
||||||
@Override
|
|
||||||
public void onGlobalLayout() {
|
|
||||||
piaoPingView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
|
||||||
|
|
||||||
// 设置锚点为左上角,避免偏移干扰
|
|
||||||
piaoPingView.setPivotX(0);
|
|
||||||
piaoPingView.setPivotY(0);
|
|
||||||
|
|
||||||
// 启动动画:从左外滑入 -> 右外滑出
|
|
||||||
ObjectAnimator animator = ObjectAnimator.ofFloat(
|
|
||||||
piaoPingView,
|
|
||||||
"translationX",
|
|
||||||
0f, // 初始偏移为 0(此时 View 在左侧外)
|
|
||||||
screenWidth // 向右移动整个屏幕宽度
|
|
||||||
);
|
|
||||||
animator.setDuration(2000); // 整个动画的时长为2秒
|
|
||||||
|
|
||||||
// 强制 GPU 渲染
|
|
||||||
piaoPingView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
|
||||||
|
|
||||||
// 延迟显示2秒后开始滑出屏幕的动画
|
|
||||||
piaoPingView.postDelayed(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
animator.start();
|
|
||||||
}
|
|
||||||
}, 2000);
|
|
||||||
|
|
||||||
animator.addListener(new AnimatorListenerAdapter() {
|
|
||||||
@Override
|
|
||||||
public void onAnimationEnd(Animator animation) {
|
|
||||||
windowManager.removeView(piaoPingView);
|
|
||||||
stopSelf();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,156 +0,0 @@
|
|||||||
package com.xscm.moduleutil.service;
|
|
||||||
|
|
||||||
import android.animation.Animator;
|
|
||||||
import android.animation.AnimatorListenerAdapter;
|
|
||||||
import android.animation.ObjectAnimator;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.PixelFormat;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewTreeObserver;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import com.xscm.moduleutil.R;
|
|
||||||
import com.xscm.moduleutil.event.MqttBean;
|
|
||||||
import com.xscm.moduleutil.utils.ImageUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*@author qx
|
|
||||||
*@data 2025/8/8
|
|
||||||
*@description: 全局悬浮框管理类
|
|
||||||
*/
|
|
||||||
public class FloatingWindow {
|
|
||||||
private WindowManager windowManager;
|
|
||||||
private View piaoPingView;
|
|
||||||
|
|
||||||
public FloatingWindow(Context context, MqttBean mqttBean){
|
|
||||||
int screenWidth =context.getResources().getDisplayMetrics().widthPixels;
|
|
||||||
windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
|
||||||
piaoPingView = LayoutInflater.from(context).inflate(R.layout.item_piaoping, null);
|
|
||||||
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(
|
|
||||||
WindowManager.LayoutParams.WRAP_CONTENT,
|
|
||||||
WindowManager.LayoutParams.WRAP_CONTENT,
|
|
||||||
|
|
||||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ?
|
|
||||||
WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY :
|
|
||||||
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
|
|
||||||
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
|
|
||||||
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
|
|
||||||
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
|
|
||||||
|
|
||||||
PixelFormat.TRANSLUCENT);
|
|
||||||
|
|
||||||
|
|
||||||
TextView textView = piaoPingView.findViewById(R.id.tv_name);
|
|
||||||
textView.setText(mqttBean.getList().getText());
|
|
||||||
ImageUtils.loadHeadCC(mqttBean.getList().getGift_picture(), piaoPingView.findViewById(R.id.iv_piaoping));
|
|
||||||
TextView tv_time = piaoPingView.findViewById(R.id.tv_num);
|
|
||||||
tv_time.setText(mqttBean.getList().getNumber());
|
|
||||||
windowManager.addView(piaoPingView, layoutParams);
|
|
||||||
|
|
||||||
// piaoPingView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
|
||||||
// @Override
|
|
||||||
// public void onGlobalLayout() {
|
|
||||||
// piaoPingView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
|
||||||
//
|
|
||||||
// // 设置锚点为左上角,避免偏移干扰
|
|
||||||
// piaoPingView.setPivotX(0);
|
|
||||||
// piaoPingView.setPivotY(0);
|
|
||||||
//
|
|
||||||
// // 启动动画:从左外滑入 -> 右外滑出
|
|
||||||
// ObjectAnimator animator = ObjectAnimator.ofFloat(
|
|
||||||
// piaoPingView,
|
|
||||||
// "translationX",
|
|
||||||
// 0f, // 初始偏移为 0(此时 View 在左侧外)
|
|
||||||
// screenWidth // 向右移动整个屏幕宽度
|
|
||||||
// );
|
|
||||||
// animator.setDuration(2000); // 整个动画的时长为2秒
|
|
||||||
//
|
|
||||||
// // 强制 GPU 渲染
|
|
||||||
// piaoPingView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
|
||||||
//
|
|
||||||
// // 延迟显示2秒后开始滑出屏幕的动画
|
|
||||||
// piaoPingView.postDelayed(new Runnable() {
|
|
||||||
// @Override
|
|
||||||
// public void run() {
|
|
||||||
// animator.start();
|
|
||||||
// }
|
|
||||||
// }, 2000);
|
|
||||||
//
|
|
||||||
// animator.addListener(new AnimatorListenerAdapter() {
|
|
||||||
// @Override
|
|
||||||
// public void onAnimationEnd(Animator animation) {
|
|
||||||
// windowManager.removeView(piaoPingView);
|
|
||||||
// stopSelf();
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
|
|
||||||
piaoPingView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
|
||||||
@Override
|
|
||||||
public void onGlobalLayout() {
|
|
||||||
piaoPingView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
|
||||||
|
|
||||||
// 获取视图宽度
|
|
||||||
int viewWidth = piaoPingView.getWidth();
|
|
||||||
|
|
||||||
// 设置锚点为左上角
|
|
||||||
piaoPingView.setPivotX(0);
|
|
||||||
piaoPingView.setPivotY(0);
|
|
||||||
|
|
||||||
// 强制 GPU 渲染
|
|
||||||
piaoPingView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
|
||||||
|
|
||||||
// 创建滑入动画:从左外滑入到屏幕左侧
|
|
||||||
ObjectAnimator slideInAnimator = ObjectAnimator.ofFloat(
|
|
||||||
piaoPingView,
|
|
||||||
"translationX",
|
|
||||||
-viewWidth, // 起始位置:屏幕左外
|
|
||||||
0f // 结束位置:屏幕左边缘
|
|
||||||
);
|
|
||||||
slideInAnimator.setDuration(500); // 滑入动画时长0.5秒
|
|
||||||
|
|
||||||
// 创建滑出动画:从当前位置滑出到屏幕右侧外
|
|
||||||
ObjectAnimator slideOutAnimator = ObjectAnimator.ofFloat(
|
|
||||||
piaoPingView,
|
|
||||||
"translationX",
|
|
||||||
0f, // 起始位置:屏幕左边缘
|
|
||||||
screenWidth // 结束位置:屏幕右外
|
|
||||||
);
|
|
||||||
slideOutAnimator.setDuration(500); // 滑出动画时长0.5秒
|
|
||||||
|
|
||||||
// 设置滑出动画监听器
|
|
||||||
slideOutAnimator.addListener(new AnimatorListenerAdapter() {
|
|
||||||
@Override
|
|
||||||
public void onAnimationEnd(Animator animation) {
|
|
||||||
windowManager.removeView(piaoPingView);
|
|
||||||
stopSelf();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// 开始执行动画序列
|
|
||||||
slideInAnimator.start();
|
|
||||||
|
|
||||||
// 滑入完成后延迟2秒执行滑出动画
|
|
||||||
piaoPingView.postDelayed(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
slideOutAnimator.start();
|
|
||||||
}
|
|
||||||
}, 2000);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void stopSelf(){
|
|
||||||
if (piaoPingView != null) {
|
|
||||||
windowManager.removeView(piaoPingView);
|
|
||||||
piaoPingView = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,10 +7,13 @@ import android.util.Log;
|
|||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.blankj.utilcode.util.GsonUtils;
|
||||||
import com.hjq.toast.ToastUtils;
|
import com.hjq.toast.ToastUtils;
|
||||||
import com.orhanobut.logger.Logger;
|
import com.orhanobut.logger.Logger;
|
||||||
|
import com.xscm.moduleutil.bean.MqttXlhEnd;
|
||||||
import com.xscm.moduleutil.bean.XLHBean;
|
import com.xscm.moduleutil.bean.XLHBean;
|
||||||
import com.xscm.moduleutil.event.RoomGiftRunable;
|
import com.xscm.moduleutil.event.RoomGiftRunable;
|
||||||
|
import com.xscm.moduleutil.utils.SpUtil;
|
||||||
|
|
||||||
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
|
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
|
||||||
import org.eclipse.paho.client.mqttv3.MqttCallback;
|
import org.eclipse.paho.client.mqttv3.MqttCallback;
|
||||||
@@ -78,6 +81,20 @@ public class MqttInitCallback implements MqttCallback {
|
|||||||
case 5019://推送所有人-横幅礼物通知
|
case 5019://推送所有人-横幅礼物通知
|
||||||
new RoomGiftRunable(message).run();
|
new RoomGiftRunable(message).run();
|
||||||
break;
|
break;
|
||||||
|
case 8000:
|
||||||
|
XLHBean xlhBean= GsonUtils.fromJson(message, XLHBean.class);
|
||||||
|
if (xlhBean!=null && xlhBean.getRoom_id()!=null && SpUtil.getMyRoomId()!=null) {
|
||||||
|
if (xlhBean.getRoom_id().equals(SpUtil.getMyRoomId())) {
|
||||||
|
if (xlhBean.getFrom_type()==3) {
|
||||||
|
MqttXlhEnd mqttXlhEnd = new MqttXlhEnd();
|
||||||
|
mqttXlhEnd.setMessage(message);
|
||||||
|
EventBus.getDefault().post(mqttXlhEnd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,7 +106,7 @@ public class MqttInitCallback implements MqttCallback {
|
|||||||
XLHBean xlhBean=JSON.parseObject(message, XLHBean.class);
|
XLHBean xlhBean=JSON.parseObject(message, XLHBean.class);
|
||||||
// 将事件处理放到主线程执行
|
// 将事件处理放到主线程执行
|
||||||
new Handler(Looper.getMainLooper()).post(() -> {
|
new Handler(Looper.getMainLooper()).post(() -> {
|
||||||
// processMessageType(type, message);
|
processMessageType(type, message);
|
||||||
EventBus.getDefault().post(xlhBean);
|
EventBus.getDefault().post(xlhBean);
|
||||||
});
|
});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ public class ARouteConstants {
|
|||||||
public static final String USER_ALBUM_DETAIL = "/modulevocal/AlbumDetailActivity";
|
public static final String USER_ALBUM_DETAIL = "/modulevocal/AlbumDetailActivity";
|
||||||
public static final String CREATE_ALBUM = "/modulevocal/CreateAlbumActivity";
|
public static final String CREATE_ALBUM = "/modulevocal/CreateAlbumActivity";
|
||||||
public static final String ROOM_DETAILS = "/moduleroom/RoomActivity";
|
public static final String ROOM_DETAILS = "/moduleroom/RoomActivity";
|
||||||
|
public static final String UNDERAGE_ACTIVITY = "/modulevocal/UnderageActivity";
|
||||||
|
|
||||||
public static final String MY_ROOM = "/modulevocal/MyRoomActivity";
|
public static final String MY_ROOM = "/modulevocal/MyRoomActivity";
|
||||||
public static final String MY_ROOM_DETAILS = "/modulevocal/RoomDetailsActivity";
|
public static final String MY_ROOM_DETAILS = "/modulevocal/RoomDetailsActivity";
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ package com.xscm.moduleutil.utils;
|
|||||||
*@description: 防止重复点击的工具类
|
*@description: 防止重复点击的工具类
|
||||||
*/
|
*/
|
||||||
public class ClickUtils {
|
public class ClickUtils {
|
||||||
private static final long CLICK_INTERVAL = 500; // 500ms内不允许重复点击
|
private static final long CLICK_INTERVAL = 1000; // 1000ms内不允许重复点击
|
||||||
private static long lastClickTime = 0;
|
private static long lastClickTime = 0;
|
||||||
|
|
||||||
public static boolean isFastDoubleClick() {
|
public static boolean isFastDoubleClick() {
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package com.xscm.moduleutil.utils;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.alibaba.android.arouter.launcher.ARouter;
|
||||||
|
|
||||||
|
public class CrashHandler implements Thread.UncaughtExceptionHandler {
|
||||||
|
private static CrashHandler instance;
|
||||||
|
private Thread.UncaughtExceptionHandler defaultHandler;
|
||||||
|
|
||||||
|
private CrashHandler(Context context) {
|
||||||
|
defaultHandler = Thread.getDefaultUncaughtExceptionHandler();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void init(Context context) {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new CrashHandler(context);
|
||||||
|
Thread.setDefaultUncaughtExceptionHandler(instance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void uncaughtException(Thread t, Throwable e) {
|
||||||
|
// 记录崩溃日志
|
||||||
|
Log.e("CrashHandler", "未捕获异常: " + e.getMessage());
|
||||||
|
// 简单处理空指针
|
||||||
|
if (e instanceof NullPointerException) {
|
||||||
|
// 重启应用或跳转错误页
|
||||||
|
restartApp();
|
||||||
|
} else {
|
||||||
|
// 交给系统默认处理
|
||||||
|
defaultHandler.uncaughtException(t, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void restartApp() {
|
||||||
|
// 实现应用重启逻辑
|
||||||
|
ARouter.getInstance().build(ARouteConstants.ME).navigation();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -30,4 +30,6 @@ public class SPConstants {
|
|||||||
public static final String REAL_NAME = "realName";//是否实名认证
|
public static final String REAL_NAME = "realName";//是否实名认证
|
||||||
|
|
||||||
public static final String USER_INFO = "userInfo";
|
public static final String USER_INFO = "userInfo";
|
||||||
|
|
||||||
|
public static final String FLOATING_SCREEN = "floatingScreen";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,6 +123,8 @@ public class SpUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存一个布尔值
|
* 保存一个布尔值
|
||||||
*/
|
*/
|
||||||
@@ -251,6 +253,14 @@ public class SpUtil {
|
|||||||
SPUtils.getInstance(SPConstants.PREFERENCE_NAME).put("musicVolume", musicVolume, true);
|
SPUtils.getInstance(SPConstants.PREFERENCE_NAME).put("musicVolume", musicVolume, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setUnderagePassword(String password){
|
||||||
|
SPUtils.getInstance(SPConstants.PREFERENCE_NAME).put("underagePassword", password, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getUnderagePassword(){
|
||||||
|
return SPUtils.getInstance(SPConstants.PREFERENCE_NAME).getString("underagePassword");
|
||||||
|
}
|
||||||
|
|
||||||
public static Integer getMusicVolume() {
|
public static Integer getMusicVolume() {
|
||||||
return SPUtils.getInstance(SPConstants.PREFERENCE_NAME).getInt("musicVolume", 50);
|
return SPUtils.getInstance(SPConstants.PREFERENCE_NAME).getInt("musicVolume", 50);
|
||||||
}
|
}
|
||||||
@@ -359,6 +369,14 @@ public class SpUtil {
|
|||||||
return SPUtils.getInstance(SPConstants.PREFERENCE_NAME).getInt(SPConstants.OPEN_EFFECT, 1);
|
return SPUtils.getInstance(SPConstants.PREFERENCE_NAME).getInt(SPConstants.OPEN_EFFECT, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setFloatingScreen(int i){
|
||||||
|
SPUtils.getInstance(SPConstants.PREFERENCE_NAME).put(SPConstants.FLOATING_SCREEN, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getFloatingScreen(){
|
||||||
|
return SPUtils.getInstance(SPConstants.PREFERENCE_NAME).getInt(SPConstants.FLOATING_SCREEN, 1);
|
||||||
|
}
|
||||||
|
|
||||||
//设置耳返
|
//设置耳返
|
||||||
public static void setAuricularBack(int i) {
|
public static void setAuricularBack(int i) {
|
||||||
SPUtils.getInstance(SPConstants.PREFERENCE_NAME).put(SPConstants.OPEN_AU_BACK, i);
|
SPUtils.getInstance(SPConstants.PREFERENCE_NAME).put(SPConstants.OPEN_AU_BACK, i);
|
||||||
|
|||||||
@@ -15,20 +15,20 @@ public enum EnvironmentEnum {
|
|||||||
"tcp://81.70.45.221",
|
"tcp://81.70.45.221",
|
||||||
"https://md.xscmmidi.site/h5"),
|
"https://md.xscmmidi.site/h5"),
|
||||||
TEST(//测试环境
|
TEST(//测试环境
|
||||||
"http://md.qxmier.com/",
|
"http://tmd.xscmmidi.site/",
|
||||||
"6rdWuz058oq5OahdbFiGEybUcdahd12J83L34Uc7MrPIrxtFG+rXiwDvRcqNvjwbClbbmvMrmxKVkIysFByBsl0Qe9kqd2w8T/nhK5G6eXXlk2V9AjYCieIU+jRnjZBB+Cfechr6rCGJ2aeBARIsXcRPW7wm9WFK9euh5T+v6Pyte68yNaNdcYCll3+U4/uCEog7HygCnMIbAU+kqoPdmn2H+51YOHW+VsnsHd4w1+I3f8Tt0xLIXGM4GWnQueZ5GR46GTWiSYMy8dCIh9SPIMRyC91GosVcfGPMJSdcXqc=",
|
"6rdWuz058oq5OahdbFiGEybUcdahd12J83L34Uc7MrPIrxtFG+rXiwDvRcqNvjwbClbbmvMrmxKVkIysFByBsl0Qe9kqd2w8T/nhK5G6eXXlk2V9AjYCieIU+jRnjZBB+Cfechr6rCGJ2aeBARIsXcRPW7wm9WFK9euh5T+v6Pyte68yNaNdcYCll3+U4/uCEog7HygCnMIbAU+kqoPdmn2H+51YOHW+VsnsHd4w1+I3f8Tt0xLIXGM4GWnQueZ5GR46GTWiSYMy8dCIh9SPIMRyC91GosVcfGPMJSdcXqc=",
|
||||||
"https://oss-cn-hangzhou.aliyuncs.com/",
|
"https://oss-cn-beijing.aliyuncs.com/",
|
||||||
"LTAI5tJ2UYfFNF7K3F4e1siv",
|
"LTAI5tKgrfcFQxH46ZwWYgFW",
|
||||||
"DhpCS82gaigZljYqsWsUWUAZ20dREz",
|
"ZOjTqAJmUL563EKFKySrUwAHtx4hKt",
|
||||||
"qx-yusheng",
|
"midi01",
|
||||||
"https://qx-yusheng.oss-cn-hangzhou.aliyuncs.com/",
|
"https://midi01.oss-cn-beijing.aliyuncs.com/",
|
||||||
"wxc7681513be9f926b",
|
"wxc7681513be9f926b",
|
||||||
1600101474,
|
1600106397,
|
||||||
"05b406b4541e413887d8d2bf9be8642c",
|
"05b406b4541e413887d8d2bf9be8642c",
|
||||||
"tcp://47.120.21.132",
|
"tcp://1.13.181.248",
|
||||||
"https://chatvespa.qxmier.com");
|
"https://chatvespa.qxmier.com");
|
||||||
|
|
||||||
private final String serverUrl;
|
private final String serverUrl;//服务器地址
|
||||||
private final String ALI_AUTH_KEY;//阿里云授权key
|
private final String ALI_AUTH_KEY;//阿里云授权key
|
||||||
|
|
||||||
private final String ossEndPoint;
|
private final String ossEndPoint;
|
||||||
@@ -37,15 +37,15 @@ public enum EnvironmentEnum {
|
|||||||
private final String ossBucketName;
|
private final String ossBucketName;
|
||||||
private final String ossBaseUrl;
|
private final String ossBaseUrl;
|
||||||
|
|
||||||
private final String wxAppId;
|
private final String wxAppId;//微信appId
|
||||||
|
|
||||||
private final int sdkAppId;//腾讯云sdkAppId im
|
private final int sdkAppId;//腾讯云sdkAppId im
|
||||||
|
|
||||||
private final String swSdkAppId;
|
private final String swSdkAppId;//声网sdkAppId
|
||||||
|
|
||||||
private final String mqttUrl;
|
private final String mqttUrl;//MQTT服务器地址
|
||||||
|
|
||||||
private final String H5Url;
|
private final String H5Url;//h5地址
|
||||||
|
|
||||||
EnvironmentEnum(String serverUrl, String ALI_AUTH_KEY, String ossEndPoint, String ossaAcessKeyId,
|
EnvironmentEnum(String serverUrl, String ALI_AUTH_KEY, String ossEndPoint, String ossaAcessKeyId,
|
||||||
String ossAccessKeySecret, String ossBucketName, String ossBaseUrl, String wxAppId,
|
String ossAccessKeySecret, String ossBucketName, String ossBaseUrl, String wxAppId,
|
||||||
|
|||||||
@@ -27,11 +27,11 @@ public class EnvironmentPrefs {
|
|||||||
|
|
||||||
// 获取当前选择的环境,默认为 PRODUCTION
|
// 获取当前选择的环境,默认为 PRODUCTION
|
||||||
public EnvironmentEnum getSelectedEnvironment() {
|
public EnvironmentEnum getSelectedEnvironment() {
|
||||||
String envName = sharedPreferences.getString(KEY_ENV, EnvironmentEnum.PRODUCTION.name());
|
String envName = sharedPreferences.getString(KEY_ENV, EnvironmentEnum.TEST.name());
|
||||||
try {
|
try {
|
||||||
return EnvironmentEnum.valueOf(envName);
|
return EnvironmentEnum.valueOf(envName);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
return EnvironmentEnum.PRODUCTION; // 出错时默认返回生产环境
|
return EnvironmentEnum.TEST; // 出错时默认返回生产环境
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,119 @@
|
|||||||
|
package com.xscm.moduleutil.view;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.res.TypedArray;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import androidx.appcompat.widget.AppCompatImageView;
|
||||||
|
|
||||||
|
import com.xscm.moduleutil.R;
|
||||||
|
|
||||||
|
public class AvatarWithDecoration extends AppCompatImageView {
|
||||||
|
// 挂件图片
|
||||||
|
private Drawable decoration;
|
||||||
|
// 挂件位置偏移量
|
||||||
|
private int decorationOffsetX = 0;
|
||||||
|
private int decorationOffsetY = 0;
|
||||||
|
// 挂件大小比例(相对于头像)
|
||||||
|
private float decorationScale = 0.3f;
|
||||||
|
|
||||||
|
public AvatarWithDecoration(Context context) {
|
||||||
|
super(context);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public AvatarWithDecoration(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public AvatarWithDecoration(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
init();
|
||||||
|
|
||||||
|
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AvatarWithDecoration);
|
||||||
|
decoration = a.getDrawable(R.styleable.AvatarWithDecoration_decoration);
|
||||||
|
decorationScale = a.getFloat(R.styleable.AvatarWithDecoration_decorationScale, 0.3f);
|
||||||
|
decorationOffsetX = a.getInt(R.styleable.AvatarWithDecoration_decorationOffsetX, 0);
|
||||||
|
decorationOffsetY = a.getInt(R.styleable.AvatarWithDecoration_decorationOffsetY, 0);
|
||||||
|
a.recycle();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
// 可以在这里设置默认的挂件
|
||||||
|
decoration = getResources().getDrawable(R.mipmap.xlh_image);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDraw(Canvas canvas) {
|
||||||
|
super.onDraw(canvas);
|
||||||
|
|
||||||
|
// 如果有挂件,则绘制挂件
|
||||||
|
if (decoration != null) {
|
||||||
|
drawDecoration(canvas);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawDecoration(Canvas canvas) {
|
||||||
|
// 获取头像的宽高
|
||||||
|
int avatarWidth = getWidth();
|
||||||
|
int avatarHeight = getHeight();
|
||||||
|
|
||||||
|
// 计算挂件的大小
|
||||||
|
int decorationWidth = (int) (avatarWidth * decorationScale);
|
||||||
|
int decorationHeight = (int) (avatarHeight * decorationScale);
|
||||||
|
|
||||||
|
// 计算挂件的位置(右下角)
|
||||||
|
int left = avatarWidth - decorationWidth + decorationOffsetX;
|
||||||
|
int top = avatarHeight - decorationHeight + decorationOffsetY;
|
||||||
|
int right = left + decorationWidth;
|
||||||
|
int bottom = top + decorationHeight;
|
||||||
|
|
||||||
|
// 设置挂件的绘制边界
|
||||||
|
decoration.setBounds(left, top, right, bottom);
|
||||||
|
|
||||||
|
// 绘制挂件
|
||||||
|
decoration.draw(canvas);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置挂件图片
|
||||||
|
*/
|
||||||
|
public void setDecoration(Drawable decoration) {
|
||||||
|
this.decoration = decoration;
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置挂件图片(通过Bitmap)
|
||||||
|
*/
|
||||||
|
public void setDecoration(Bitmap bitmap) {
|
||||||
|
if (bitmap != null) {
|
||||||
|
this.decoration = new BitmapDrawable(getResources(), bitmap);
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置挂件位置偏移量
|
||||||
|
*/
|
||||||
|
public void setDecorationOffset(int offsetX, int offsetY) {
|
||||||
|
this.decorationOffsetX = offsetX;
|
||||||
|
this.decorationOffsetY = offsetY;
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置挂件大小比例
|
||||||
|
*/
|
||||||
|
public void setDecorationScale(float scale) {
|
||||||
|
if (scale > 0 && scale <= 1) {
|
||||||
|
this.decorationScale = scale;
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,373 @@
|
|||||||
|
package com.xscm.moduleutil.view;
|
||||||
|
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.res.TypedArray;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapShader;
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.Paint;
|
||||||
|
import android.graphics.PointF;
|
||||||
|
import android.graphics.RectF;
|
||||||
|
import android.graphics.Shader;
|
||||||
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.util.TypedValue;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
|
import com.bumptech.glide.request.target.SimpleTarget;
|
||||||
|
import com.bumptech.glide.request.transition.Transition;
|
||||||
|
import com.xscm.moduleutil.R;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class FashionAvatarView extends View {
|
||||||
|
// 头像相关属性
|
||||||
|
private Bitmap mAvatarBitmap;
|
||||||
|
private String mAvatarUrl;
|
||||||
|
private Drawable mPlaceholderAvatar;
|
||||||
|
private int mAvatarRadius;
|
||||||
|
private int mAvatarBorderWidth;
|
||||||
|
private int mAvatarBorderColor;
|
||||||
|
|
||||||
|
// 顶部标签属性
|
||||||
|
private String mTagText;
|
||||||
|
private int mTagTextColor;
|
||||||
|
private float mTagTextSize;
|
||||||
|
private int mTagBackgroundColor;
|
||||||
|
private float mTagCornerRadius;
|
||||||
|
private int mTagPadding;
|
||||||
|
private int mTagOffsetY; // 标签Y轴偏移量
|
||||||
|
|
||||||
|
// 底部文字属性
|
||||||
|
private String mBottomText;
|
||||||
|
private int mBottomTextColor;
|
||||||
|
private float mBottomTextSize;
|
||||||
|
private int mBottomTextOffsetY; // 底部文字Y轴偏移量
|
||||||
|
|
||||||
|
// 爱心装饰属性
|
||||||
|
private Drawable mHeartIcon;
|
||||||
|
private int mHeartCount;
|
||||||
|
private int mHeartSize;
|
||||||
|
private List<PointF> mHeartPositions = new ArrayList<>();
|
||||||
|
private Random mRandom = new Random();
|
||||||
|
|
||||||
|
// 画笔
|
||||||
|
private Paint mAvatarPaint;
|
||||||
|
private Paint mTextPaint;
|
||||||
|
private Paint mTagBgPaint;
|
||||||
|
|
||||||
|
public FashionAvatarView(Context context) {
|
||||||
|
this(context, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FashionAvatarView(Context context, @Nullable AttributeSet attrs) {
|
||||||
|
this(context, attrs, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FashionAvatarView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
initAttrs(context, attrs);
|
||||||
|
initPaints();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initAttrs(Context context, AttributeSet attrs) {
|
||||||
|
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.FashionAvatarView);
|
||||||
|
|
||||||
|
// 头像属性
|
||||||
|
mAvatarUrl = ta.getString(R.styleable.FashionAvatarView_avatarUrl);
|
||||||
|
mPlaceholderAvatar = ta.getDrawable(R.styleable.FashionAvatarView_placeholderAvatar);
|
||||||
|
mAvatarRadius = ta.getDimensionPixelSize(R.styleable.FashionAvatarView_avatarRadius, dp2px(60));
|
||||||
|
mAvatarBorderWidth = ta.getDimensionPixelSize(R.styleable.FashionAvatarView_avatarBorderWidth, dp2px(2));
|
||||||
|
mAvatarBorderColor = ta.getColor(R.styleable.FashionAvatarView_avatarBorderColor, Color.parseColor("#FFD700"));
|
||||||
|
|
||||||
|
// 顶部标签属性
|
||||||
|
mTagText = ta.getString(R.styleable.FashionAvatarView_tagText);
|
||||||
|
mTagTextColor = ta.getColor(R.styleable.FashionAvatarView_tagTextColor, Color.WHITE);
|
||||||
|
mTagTextSize = ta.getDimension(R.styleable.FashionAvatarView_tagTextSize, sp2px(12));
|
||||||
|
mTagBackgroundColor = ta.getColor(R.styleable.FashionAvatarView_tagBackgroundColor, Color.parseColor("#FFA500"));
|
||||||
|
mTagCornerRadius = ta.getDimension(R.styleable.FashionAvatarView_tagCornerRadius, dp2px(4));
|
||||||
|
mTagPadding = ta.getDimensionPixelSize(R.styleable.FashionAvatarView_tagPadding, dp2px(4));
|
||||||
|
mTagOffsetY = ta.getDimensionPixelSize(R.styleable.FashionAvatarView_tagOffsetY, 0);
|
||||||
|
|
||||||
|
// 底部文字属性
|
||||||
|
mBottomText = ta.getString(R.styleable.FashionAvatarView_bottomText);
|
||||||
|
mBottomTextColor = ta.getColor(R.styleable.FashionAvatarView_bottomTextColor, Color.WHITE);
|
||||||
|
mBottomTextSize = ta.getDimension(R.styleable.FashionAvatarView_bottomTextSize, sp2px(14));
|
||||||
|
mBottomTextOffsetY = ta.getDimensionPixelSize(R.styleable.FashionAvatarView_bottomTextOffsetY, dp2px(10));
|
||||||
|
|
||||||
|
// 爱心装饰属性
|
||||||
|
mHeartIcon = ta.getDrawable(R.styleable.FashionAvatarView_heartIcon);
|
||||||
|
if (mHeartIcon == null) {
|
||||||
|
try {
|
||||||
|
mHeartIcon = context.getResources().getDrawable(R.mipmap.xlh_image);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mHeartCount = ta.getInt(R.styleable.FashionAvatarView_heartCount, 6);
|
||||||
|
mHeartSize = ta.getDimensionPixelSize(R.styleable.FashionAvatarView_heartSize, dp2px(16));
|
||||||
|
|
||||||
|
ta.recycle();
|
||||||
|
|
||||||
|
// 加载头像
|
||||||
|
if (mAvatarUrl != null && !mAvatarUrl.isEmpty()) {
|
||||||
|
loadAvatarFromNetwork();
|
||||||
|
} else if (mPlaceholderAvatar != null) {
|
||||||
|
mAvatarBitmap = drawableToBitmap(mPlaceholderAvatar);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initPaints() {
|
||||||
|
// 头像画笔
|
||||||
|
mAvatarPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||||
|
mAvatarPaint.setDither(true);
|
||||||
|
|
||||||
|
// 文字画笔
|
||||||
|
mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||||
|
mTextPaint.setTextAlign(Paint.Align.CENTER);
|
||||||
|
|
||||||
|
// 标签背景画笔
|
||||||
|
mTagBgPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||||
|
mTagBgPaint.setColor(mTagBackgroundColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadAvatarFromNetwork() {
|
||||||
|
Glide.with(this)
|
||||||
|
.asBitmap()
|
||||||
|
.load(mAvatarUrl)
|
||||||
|
.into(new SimpleTarget<Bitmap>() {
|
||||||
|
@Override
|
||||||
|
public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition) {
|
||||||
|
mAvatarBitmap = resource;
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoadFailed(@Nullable Drawable errorDrawable) {
|
||||||
|
super.onLoadFailed(errorDrawable);
|
||||||
|
if (mPlaceholderAvatar != null) {
|
||||||
|
mAvatarBitmap = drawableToBitmap(mPlaceholderAvatar);
|
||||||
|
}
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private Bitmap drawableToBitmap(Drawable drawable) {
|
||||||
|
if (drawable instanceof BitmapDrawable) {
|
||||||
|
return ((BitmapDrawable) drawable).getBitmap();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (drawable == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
int width = drawable.getIntrinsicWidth();
|
||||||
|
int height = drawable.getIntrinsicHeight();
|
||||||
|
|
||||||
|
if (width <= 0) width = mAvatarRadius * 2;
|
||||||
|
if (height <= 0) height = mAvatarRadius * 2;
|
||||||
|
|
||||||
|
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||||
|
Canvas canvas = new Canvas(bitmap);
|
||||||
|
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
|
||||||
|
drawable.draw(canvas);
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initHeartPositions() {
|
||||||
|
mHeartPositions.clear();
|
||||||
|
|
||||||
|
if (mHeartIcon == null || mHeartCount <= 0 || mHeartSize <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int centerX = getWidth() / 2;
|
||||||
|
int centerY = getAvatarCenterY();
|
||||||
|
// 爱心围绕的半径,比头像大一些
|
||||||
|
int radius = mAvatarRadius + mAvatarBorderWidth + mHeartSize / 2;
|
||||||
|
|
||||||
|
for (int i = 0; i < mHeartCount; i++) {
|
||||||
|
// 随机分布在头像周围
|
||||||
|
double angle = 2 * Math.PI * mRandom.nextDouble();
|
||||||
|
// 稍微随机调整距离,让分布更自然
|
||||||
|
float distanceFactor = 0.8f + mRandom.nextFloat() * 0.4f;
|
||||||
|
|
||||||
|
float x = (float) (centerX + radius * distanceFactor * Math.cos(angle));
|
||||||
|
float y = (float) (centerY + radius * distanceFactor * Math.sin(angle));
|
||||||
|
mHeartPositions.add(new PointF(x, y));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
|
// 计算宽度:直径 + 左右可能的爱心空间
|
||||||
|
int width = 2 * (mAvatarRadius + mAvatarBorderWidth + mHeartSize / 2);
|
||||||
|
|
||||||
|
// 计算高度:头像直径 + 标签高度 + 底部文字高度 + 间距
|
||||||
|
int tagHeight = (int) (mTagTextSize + mTagPadding * 2);
|
||||||
|
int bottomTextHeight = (int) mBottomTextSize;
|
||||||
|
int height = 2 * (mAvatarRadius + mAvatarBorderWidth)
|
||||||
|
+ tagHeight / 2 // 标签一半在头像内
|
||||||
|
+ bottomTextHeight + mBottomTextOffsetY
|
||||||
|
+ dp2px(10);
|
||||||
|
|
||||||
|
setMeasuredDimension(resolveSize(width, widthMeasureSpec),
|
||||||
|
resolveSize(height, heightMeasureSpec));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||||
|
super.onSizeChanged(w, h, oldw, oldh);
|
||||||
|
// 视图大小确定后计算爱心位置
|
||||||
|
initHeartPositions();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDraw(Canvas canvas) {
|
||||||
|
super.onDraw(canvas);
|
||||||
|
|
||||||
|
if (getWidth() == 0 || getHeight() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int centerX = getWidth() / 2;
|
||||||
|
int avatarCenterY = getAvatarCenterY();
|
||||||
|
|
||||||
|
// 1. 绘制爱心装饰
|
||||||
|
drawHearts(canvas);
|
||||||
|
|
||||||
|
// 2. 绘制头像边框
|
||||||
|
mAvatarPaint.setColor(mAvatarBorderColor);
|
||||||
|
mAvatarPaint.setStyle(Paint.Style.FILL);
|
||||||
|
canvas.drawCircle(centerX, avatarCenterY, mAvatarRadius + mAvatarBorderWidth, mAvatarPaint);
|
||||||
|
|
||||||
|
// 3. 绘制头像
|
||||||
|
if (mAvatarBitmap != null) {
|
||||||
|
mAvatarPaint.setShader(new BitmapShader(mAvatarBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP));
|
||||||
|
canvas.drawCircle(centerX, avatarCenterY, mAvatarRadius, mAvatarPaint);
|
||||||
|
mAvatarPaint.setShader(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. 绘制顶部标签
|
||||||
|
drawTag(canvas, centerX, avatarCenterY);
|
||||||
|
|
||||||
|
// 5. 绘制底部文字
|
||||||
|
drawBottomText(canvas, centerX);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getAvatarCenterY() {
|
||||||
|
// 计算头像中心Y坐标,考虑标签的高度
|
||||||
|
int tagHeight = (int) (mTagTextSize + mTagPadding * 2);
|
||||||
|
return mAvatarRadius + mAvatarBorderWidth + tagHeight / 2 + mTagOffsetY;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawHearts(Canvas canvas) {
|
||||||
|
if (mHeartIcon == null || mHeartPositions.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
canvas.save();
|
||||||
|
for (PointF point : mHeartPositions) {
|
||||||
|
int left = (int) (point.x - mHeartSize / 2);
|
||||||
|
int top = (int) (point.y - mHeartSize / 2);
|
||||||
|
int right = left + mHeartSize;
|
||||||
|
int bottom = top + mHeartSize;
|
||||||
|
|
||||||
|
// 只绘制在视图范围内的爱心
|
||||||
|
if (right > 0 && bottom > 0 && left < getWidth() && top < getHeight()) {
|
||||||
|
mHeartIcon.setBounds(left, top, right, bottom);
|
||||||
|
mHeartIcon.draw(canvas);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
canvas.restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawTag(Canvas canvas, int centerX, int avatarCenterY) {
|
||||||
|
if (mTagText == null || mTagText.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算标签文字宽度
|
||||||
|
mTextPaint.setTextSize(mTagTextSize);
|
||||||
|
float textWidth = mTextPaint.measureText(mTagText);
|
||||||
|
|
||||||
|
// 计算标签背景矩形
|
||||||
|
float tagLeft = centerX - textWidth / 2 - mTagPadding;
|
||||||
|
float tagRight = centerX + textWidth / 2 + mTagPadding;
|
||||||
|
// 标签底部与头像顶部对齐
|
||||||
|
float tagBottom = avatarCenterY - mAvatarRadius - mAvatarBorderWidth;
|
||||||
|
float tagTop = tagBottom - mTagTextSize - mTagPadding * 2;
|
||||||
|
|
||||||
|
RectF tagRect = new RectF(tagLeft, tagTop, tagRight, tagBottom);
|
||||||
|
|
||||||
|
// 绘制标签背景
|
||||||
|
canvas.drawRoundRect(tagRect, mTagCornerRadius, mTagCornerRadius, mTagBgPaint);
|
||||||
|
|
||||||
|
// 绘制标签文字
|
||||||
|
mTextPaint.setColor(mTagTextColor);
|
||||||
|
Paint.FontMetrics fontMetrics = mTextPaint.getFontMetrics();
|
||||||
|
float baseLineY = tagBottom - mTagPadding - fontMetrics.bottom;
|
||||||
|
canvas.drawText(mTagText, centerX, baseLineY, mTextPaint);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawBottomText(Canvas canvas, int centerX) {
|
||||||
|
if (mBottomText == null || mBottomText.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算文字位置:头像底部下方
|
||||||
|
int textY = getAvatarCenterY() + mAvatarRadius + mAvatarBorderWidth + mBottomTextOffsetY;
|
||||||
|
|
||||||
|
mTextPaint.setColor(mBottomTextColor);
|
||||||
|
mTextPaint.setTextSize(mBottomTextSize);
|
||||||
|
|
||||||
|
Paint.FontMetrics fontMetrics = mTextPaint.getFontMetrics();
|
||||||
|
float baseLineY = textY - fontMetrics.top;
|
||||||
|
|
||||||
|
canvas.drawText(mBottomText, centerX, baseLineY, mTextPaint);
|
||||||
|
}
|
||||||
|
|
||||||
|
// dp转px
|
||||||
|
private int dp2px(float dp) {
|
||||||
|
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp,
|
||||||
|
getResources().getDisplayMetrics());
|
||||||
|
}
|
||||||
|
|
||||||
|
// sp转px
|
||||||
|
private float sp2px(float sp) {
|
||||||
|
return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, sp,
|
||||||
|
getResources().getDisplayMetrics());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置器方法
|
||||||
|
public void setAvatarUrl(String url) {
|
||||||
|
this.mAvatarUrl = url;
|
||||||
|
loadAvatarFromNetwork();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTagText(String text) {
|
||||||
|
this.mTagText = text;
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBottomText(String text) {
|
||||||
|
this.mBottomText = text;
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHeartIcon(Drawable heartIcon) {
|
||||||
|
this.mHeartIcon = heartIcon;
|
||||||
|
initHeartPositions();
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -235,10 +235,10 @@ public class AvatarFrameView extends FrameLayout {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// 检查特效是否开启
|
// 检查特效是否开启
|
||||||
if (SpUtil.getOpenEffect() != 1) {
|
// if (SpUtil.getOpenEffect() != 1) {
|
||||||
clearQueue();
|
// clearQueue();
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
// 检查是否可以开始新的播放
|
// 检查是否可以开始新的播放
|
||||||
// if (!playbackManager.canStartNewPlayback()) {
|
// if (!playbackManager.canStartNewPlayback()) {
|
||||||
// Logger.d("AvatarFrameView", "Max concurrent playbacks reached, waiting...");
|
// Logger.d("AvatarFrameView", "Max concurrent playbacks reached, waiting...");
|
||||||
@@ -299,14 +299,21 @@ public class AvatarFrameView extends FrameLayout {
|
|||||||
mBinding.playView.setVisibility(View.GONE);
|
mBinding.playView.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
loadSVGA(item.url);
|
loadSVGA(item.url);
|
||||||
} );
|
});
|
||||||
} else if ("mp4".equalsIgnoreCase(ext)) {
|
} else if ("mp4".equalsIgnoreCase(ext)) {
|
||||||
mainHandler.post(() -> {
|
mainHandler.post(() -> {
|
||||||
renderType = RenderType.MP4;
|
renderType = RenderType.MP4;
|
||||||
mType = item.type;
|
mType = item.type;
|
||||||
mBinding.playView.setVisibility(View.VISIBLE);
|
if (mBinding != null && mBinding.playView != null) {
|
||||||
downloadAndPlayMp4(item.url);
|
mBinding.playView.setVisibility(View.VISIBLE);
|
||||||
} );
|
|
||||||
|
downloadAndPlayMp4(item.url);
|
||||||
|
}else {
|
||||||
|
mBinding = DataBindingUtil.inflate(LayoutInflater.from(getContext()), R.layout.room_view_svga_anim, this, true);
|
||||||
|
mBinding.playView.setVisibility(View.VISIBLE);
|
||||||
|
downloadAndPlayMp4(item.url);
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
// 不支持的格式,直接完成
|
// 不支持的格式,直接完成
|
||||||
handlePlaybackComplete();
|
handlePlaybackComplete();
|
||||||
@@ -329,7 +336,7 @@ public class AvatarFrameView extends FrameLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPlaying() {
|
public boolean isPlaying() {
|
||||||
if (mBinding!=null && mBinding.playView!=null) {
|
if (mBinding != null && mBinding.playView != null) {
|
||||||
return mBinding.playView.isRunning();
|
return mBinding.playView.isRunning();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -557,7 +564,7 @@ public class AvatarFrameView extends FrameLayout {
|
|||||||
LogUtils.e("有缓存");
|
LogUtils.e("有缓存");
|
||||||
mainHandler.post(() -> {
|
mainHandler.post(() -> {
|
||||||
// 检查是否已销毁
|
// 检查是否已销毁
|
||||||
if ( file.exists()) {
|
if (file.exists()) {
|
||||||
playMp4File(file);
|
playMp4File(file);
|
||||||
} else {
|
} else {
|
||||||
LogUtils.w(TAG, "有缓存2222222222222");
|
LogUtils.w(TAG, "有缓存2222222222222");
|
||||||
@@ -813,18 +820,18 @@ public class AvatarFrameView extends FrameLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopAll(){
|
public void stopAll() {
|
||||||
if (svgaSurface != null){
|
if (svgaSurface != null) {
|
||||||
svgaSurface.stopAnimation();
|
svgaSurface.stopAnimation();
|
||||||
svgaSurface.clearAnimation();
|
svgaSurface.clearAnimation();
|
||||||
svgaSurface.setImageDrawable( null);
|
svgaSurface.setImageDrawable(null);
|
||||||
}
|
}
|
||||||
if (svgaSurface2 != null){
|
if (svgaSurface2 != null) {
|
||||||
svgaSurface2.stopAnimation();
|
svgaSurface2.stopAnimation();
|
||||||
svgaSurface2.clearAnimation();
|
svgaSurface2.clearAnimation();
|
||||||
svgaSurface.setImageDrawable( null);
|
svgaSurface.setImageDrawable(null);
|
||||||
}
|
}
|
||||||
if (mBinding.playView!=null){
|
if (mBinding.playView != null) {
|
||||||
mBinding.playView.stopPlay();
|
mBinding.playView.stopPlay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1215,7 +1222,7 @@ public class AvatarFrameView extends FrameLayout {
|
|||||||
svgaSurface.stopAnimation(true);
|
svgaSurface.stopAnimation(true);
|
||||||
svgaSurface.clear();
|
svgaSurface.clear();
|
||||||
svgaSurface.clearAnimation();
|
svgaSurface.clearAnimation();
|
||||||
svgaSurface.setImageDrawable( null);
|
svgaSurface.setImageDrawable(null);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.e(TAG, "Error releasing SVGA resources: " + e.getMessage());
|
Logger.e(TAG, "Error releasing SVGA resources: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,6 +143,8 @@ public abstract class BaseWheatView extends ConstraintLayout implements IBaseWhe
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置麦位数据
|
* 设置麦位数据
|
||||||
*
|
*
|
||||||
@@ -248,7 +250,7 @@ public abstract class BaseWheatView extends ConstraintLayout implements IBaseWhe
|
|||||||
if (!mIvRipple.isAnimating()) {
|
if (!mIvRipple.isAnimating()) {
|
||||||
mIvRipple.startAnimation();
|
mIvRipple.startAnimation();
|
||||||
}
|
}
|
||||||
// iv_on_line.setVisibility(GONE);
|
iv_on_line.setVisibility(GONE);
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -268,7 +270,7 @@ public abstract class BaseWheatView extends ConstraintLayout implements IBaseWhe
|
|||||||
if (!mIvRipple.isAnimating()) {
|
if (!mIvRipple.isAnimating()) {
|
||||||
mIvRipple.startAnimation();
|
mIvRipple.startAnimation();
|
||||||
}
|
}
|
||||||
// iv_on_line.setVisibility(GONE);
|
iv_on_line.setVisibility(GONE);
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,19 +48,25 @@ public class CenterScrollHelper {
|
|||||||
|
|
||||||
// 使用LinearSmoothScroller进行平滑滚动
|
// 使用LinearSmoothScroller进行平滑滚动
|
||||||
LinearSmoothScroller smoothScroller = new LinearSmoothScroller(recyclerView.getContext()) {
|
LinearSmoothScroller smoothScroller = new LinearSmoothScroller(recyclerView.getContext()) {
|
||||||
|
private static final float ACCELERATION = 0.5f; // 加速度
|
||||||
|
private static final float DECELERATION = 0.8f; // 减速度
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int calculateTimeForScrolling(int dx) {
|
protected int calculateTimeForScrolling(int dx) {
|
||||||
// 使用缓动函数计算时间,实现从慢到快再到慢的效果
|
// 使用缓动函数计算时间,实现从慢到快再到慢的效果
|
||||||
// return calculateEasingTime(dx, durationPerItem);
|
// return calculateEasingTime(dx, durationPerItem);
|
||||||
|
|
||||||
// 简单线性时间计算,确保滚动速度一致
|
// // 简单线性时间计算,确保滚动速度一致
|
||||||
int screenWidth = recyclerView.getWidth();
|
// int screenWidth = recyclerView.getWidth();
|
||||||
if (screenWidth <= 0) {
|
// if (screenWidth <= 0) {
|
||||||
return durationPerItem * 3;
|
// return durationPerItem * 3;
|
||||||
}
|
// }
|
||||||
int itemWidth = screenWidth / 3;
|
// int itemWidth = screenWidth / 3;
|
||||||
int items = Math.max(1, dx / itemWidth);
|
// int items = Math.max(1, dx / itemWidth);
|
||||||
return durationPerItem * items;
|
// return durationPerItem * items;
|
||||||
|
|
||||||
|
// 使用缓动函数计算时间,实现从慢到快再到慢的效果
|
||||||
|
return calculateEasingTime(dx, durationPerItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -120,8 +126,8 @@ public class CenterScrollHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 计算时间:开始慢(500ms),后来快(50ms)
|
// 计算时间:开始慢(500ms),后来快(50ms)
|
||||||
int minDuration = 50; // 最快速度
|
int minDuration = 1000; // 最快速度
|
||||||
int maxDuration = 500; // 最慢速度
|
int maxDuration = 2000; // 最慢速度
|
||||||
int calculatedTime = (int) (maxDuration - (maxDuration - minDuration) * easeProgress);
|
int calculatedTime = (int) (maxDuration - (maxDuration - minDuration) * easeProgress);
|
||||||
|
|
||||||
return Math.max(minDuration, calculatedTime);
|
return Math.max(minDuration, calculatedTime);
|
||||||
|
|||||||