Compare commits
26 Commits
5ddf6fc638
...
cesi
| Author | SHA1 | Date | |
|---|---|---|---|
| bcdfe106c2 | |||
| e55effea1a | |||
| bba729f5d0 | |||
| 59eeb1415b | |||
| a0ecafbbd7 | |||
| ea82b59b0a | |||
| 407b21c33f | |||
| 5f573e607d | |||
| 1c54f0c072 | |||
| f12ed5ef84 | |||
| c446c7bb49 | |||
| 2551f7cfbc | |||
| 867435ee90 | |||
| fc544229fe | |||
| 4e0ea44f21 | |||
| a3255c39fb | |||
| 72802ef7be | |||
| e87a368862 | |||
|
|
572967ca16 | ||
|
|
ce8f9c57c4 | ||
| 74b3e6c92d | |||
| 1d348784ea | |||
| 5635d0c707 | |||
| d309c10cf7 | |||
| a3b689c17e | |||
| fb2fd4c6f6 |
4
.idea/deploymentTargetSelector.xml
generated
@@ -4,10 +4,10 @@
|
||||
<selectionStates>
|
||||
<SelectionState runConfigName="app">
|
||||
<option name="selectionMode" value="DROPDOWN" />
|
||||
<DropdownSelection timestamp="2025-09-09T08:46:46.893032600Z">
|
||||
<DropdownSelection timestamp="2025-09-18T12:45:46.137835600Z">
|
||||
<Target type="DEFAULT_BOOT">
|
||||
<handle>
|
||||
<DeviceId pluginId="PhysicalDevice" identifier="serial=34V0224723026458" />
|
||||
<DeviceId pluginId="PhysicalDevice" identifier="serial=6705124a" />
|
||||
</handle>
|
||||
</Target>
|
||||
</DropdownSelection>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
plugins {
|
||||
alias(libs.plugins.android.application)
|
||||
alias(libs.plugins.kotlin.android)
|
||||
}
|
||||
|
||||
}
|
||||
android {
|
||||
namespace 'com.xscm.midi'
|
||||
compileSdk 35
|
||||
@@ -18,8 +18,8 @@ android {
|
||||
|
||||
ndk {
|
||||
//设置支持的so库
|
||||
abiFilters 'arm64-v8a' ,'armeabi'
|
||||
// abiFilters 'armeabi-v7a', 'arm64-v8a'
|
||||
// abiFilters 'arm64-v8a', 'armeabi','arm64'
|
||||
abiFilters 'arm64-v8a','armeabi-v7a'
|
||||
}
|
||||
|
||||
javaCompileOptions {
|
||||
@@ -148,7 +148,7 @@ dependencies {
|
||||
implementation files('libs/WbCloudNormal-v5.1.10-4e3e198.aar')
|
||||
|
||||
|
||||
implementation (libs.arouter.api.v150)
|
||||
implementation(libs.arouter.api.v150)
|
||||
//annotationProcessor
|
||||
annotationProcessor libs.arouter.compiler
|
||||
implementation project(':modulevocal') // 必须
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
"type": "SINGLE",
|
||||
"filters": [],
|
||||
"attributes": [],
|
||||
"versionCode": 102,
|
||||
"versionName": "1.0.0",
|
||||
"outputFile": "秘地_1.0.0_102.apk"
|
||||
"versionCode": 158,
|
||||
"versionName": "1.0.5",
|
||||
"outputFile": "秘地_1.0.5_158.apk"
|
||||
}
|
||||
],
|
||||
"elementType": "File",
|
||||
@@ -22,14 +22,14 @@
|
||||
"minApi": 28,
|
||||
"maxApi": 30,
|
||||
"baselineProfiles": [
|
||||
"baselineProfiles/1/秘地_1.0.0_102.dm"
|
||||
"baselineProfiles/1/秘地_1.0.5_158.dm"
|
||||
]
|
||||
},
|
||||
{
|
||||
"minApi": 31,
|
||||
"maxApi": 2147483647,
|
||||
"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:exported="true"
|
||||
android:screenOrientation="behind"
|
||||
android:launchMode="singleTask"
|
||||
android:theme="@style/main_SplashThemeImage">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
|
Before Width: | Height: | Size: 126 KiB After Width: | Height: | Size: 142 KiB |
@@ -5,27 +5,96 @@ import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.PersistableBundle;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.xscm.modulelogin.activity.ImproveInfoActivity;
|
||||
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.dialog.PolicyDialog;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
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 PolicyDialog policyDialog;
|
||||
private AppStateListener appStateListener;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) {
|
||||
super.onCreate(savedInstanceState, persistentState);
|
||||
|
||||
// 获取Application实例并设置监听器
|
||||
CommonAppContext app = (CommonAppContext) getApplication();
|
||||
appStateListener = AppStateManager.getInstance();
|
||||
app.setAppStateListener(appStateListener);
|
||||
|
||||
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();
|
||||
return;
|
||||
}
|
||||
// if (shouldRestoreRoom()) {
|
||||
// ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("form", "首页").withString("roomId", CommonAppContext.getInstance().playId).navigation();
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
private boolean shouldRestoreRoom() {
|
||||
// 检查是否应该恢复房间:
|
||||
// 1. 应用有正在播放的房间
|
||||
// 2. 应用应该显示房间
|
||||
// 3. 应用是从后台恢复的(通过检查 CommonAppContext 状态)
|
||||
return CommonAppContext.getInstance().isPlaying
|
||||
&& CommonAppContext.getInstance().isShow;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -64,6 +133,7 @@ public class LaunchPageActivity extends BaseAppCompatActivity<ActivityLaunchPage
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
// 如果 PolicyDialog 仍在显示,则 dismiss 它
|
||||
@@ -79,6 +149,7 @@ public class LaunchPageActivity extends BaseAppCompatActivity<ActivityLaunchPage
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
|
||||
@@ -96,14 +167,12 @@ public class LaunchPageActivity extends BaseAppCompatActivity<ActivityLaunchPage
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_launch_page;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
@@ -307,11 +307,13 @@ public class PasswordLoginActivity extends BaseMvpActivity<LoginPresenter, Activ
|
||||
bundle.putSerializable("userBean", userBean);
|
||||
intent.putExtras(bundle);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
} else {
|
||||
EventBus.getDefault().post(userBean);
|
||||
startActivity(new Intent(this, MainActivity.class));
|
||||
finish();
|
||||
}
|
||||
finish();
|
||||
// finish();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.example.modulevocal.presenter.RealNamePresenter;
|
||||
import com.xscm.moduleutil.activity.BaseMvpActivity;
|
||||
import com.xscm.moduleutil.bean.RealNameBean;
|
||||
import com.xscm.moduleutil.color.ThemeableDrawableUtils;
|
||||
import com.xscm.moduleutil.dialog.ConfirmDialog;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.utils.ColorManager;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
@@ -112,6 +113,7 @@ public class RealNameActivity extends BaseMvpActivity<RealNamePresenter, Activit
|
||||
|
||||
} else {
|
||||
Log.d("@@@", "刷脸失败!");
|
||||
// queren1();
|
||||
}
|
||||
}
|
||||
//刷脸结束后,及时释放资源
|
||||
@@ -125,15 +127,50 @@ public class RealNameActivity extends BaseMvpActivity<RealNamePresenter, Activit
|
||||
Log.d("@@@", "刷脸失败!");
|
||||
//刷脸结束后,及时释放资源
|
||||
WbCloudFaceVerifySdk.getInstance().release();
|
||||
// queren1();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCodeSuccess() {
|
||||
// queren();
|
||||
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) {
|
||||
if (view.getId()== R.id.btnSubmit){
|
||||
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 插件依赖
|
||||
classpath 'com.alibaba:arouter-register:1.0.2'
|
||||
|
||||
// classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2' // add plugin
|
||||
}
|
||||
}
|
||||
plugins {
|
||||
|
||||
@@ -29,8 +29,8 @@ isBuildModule=false
|
||||
#org.gradle.deamon=false
|
||||
android.injected.testOnly=false
|
||||
|
||||
APP_VERSION_NAME=1.0.0
|
||||
APP_VERSION_CODE=121
|
||||
APP_VERSION_NAME=1.1.0
|
||||
APP_VERSION_CODE=163
|
||||
|
||||
org.gradle.jvm.toolchain.useLegacyAdapters=false
|
||||
#org.gradle.java.home=C\:\\Users\\qx\\.jdks\\ms-17.0.15
|
||||
@@ -48,4 +48,7 @@ beta=false
|
||||
|
||||
org.gradle.caching=false
|
||||
# ??APT????
|
||||
kapt.incremental.apt=false
|
||||
kapt.incremental.apt=false
|
||||
|
||||
# 或者禁用特定模块的增量编译
|
||||
#org.gradle.configureondemand=false
|
||||
@@ -21,6 +21,7 @@ githubRealtimeblurviewVersion = "1.2.1"
|
||||
githubShadowlayout = "3.3.1"
|
||||
gradle = "8.8.0"
|
||||
#gradle = "8.5.0-alpha04"
|
||||
greendaoGradlePlugin = "3.3.0"
|
||||
junit = "4.13.2"
|
||||
junitVersion = "1.1.5"
|
||||
espressoCore = "3.5.1"
|
||||
@@ -97,6 +98,7 @@ github-photoview = { module = "com.github.chrisbanes:PhotoView", version.ref = "
|
||||
github-shadowlayout = { module = "com.github.lihangleo2:ShadowLayout", version.ref = "githubShadowlayout" }
|
||||
#glide-compiler = { module = "com.github.bumptech.glide:compiler", version.ref = "githubGlide" }
|
||||
gradle = { module = "com.android.tools.build:gradle", version.ref = "gradle" }
|
||||
greendao-gradle-plugin = { module = "org.greenrobot:greendao-gradle-plugin", version.ref = "greendaoGradlePlugin" }
|
||||
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
||||
ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
|
||||
espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
|
||||
@@ -161,4 +163,5 @@ android-library = { id = "com.android.library", version.ref = "agp" }
|
||||
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlinVersion" }
|
||||
#kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlinVersion" }
|
||||
#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
|
||||
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
|
||||
zipStorePath=wrapper/dists
|
||||
#distributionUrl=file:///D:/Greadle/gradle-8.10.2-all.zip
|
||||
distributionUrl=file:///D:/Gradle/gradle-8.10.2-bin.zip
|
||||
zipStorePath=wrapper/distsl.
|
||||
|
||||
@@ -69,7 +69,7 @@ public class ImproveInfoActivity extends BaseMvpActivity<ImproveInfoPresenter, A
|
||||
mBinding.edNickName.setText(userBean.getNickname());
|
||||
}
|
||||
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)) {
|
||||
mBinding.etInviteCode.setText(user_no_parent);
|
||||
mBinding.etInviteCode.setKeyListener(null);
|
||||
@@ -203,7 +203,7 @@ public class ImproveInfoActivity extends BaseMvpActivity<ImproveInfoPresenter, A
|
||||
.setImageEngine(GlideEngine.createGlideEngine())
|
||||
.setMaxSelectNum(1)
|
||||
.isPreviewImage(true)
|
||||
.isDisplayCamera(true)
|
||||
.isDisplayCamera(false)
|
||||
.setOutputCameraDir(Constants.FILE_PATH)
|
||||
.isOriginalSkipCompress(true)
|
||||
.forResult(requestCode); //结果回调onActivityResult code
|
||||
|
||||
@@ -184,7 +184,7 @@ public class LoginPresenter extends BasePresenter<LoginContacter.View> implement
|
||||
|
||||
public void loginSuccess(List<UserBean> userBean) {
|
||||
if (userBean == null) {
|
||||
ToastUtils.showShort("登录失败请重试");
|
||||
// ToastUtils.showShort("登录失败请重试");
|
||||
return;
|
||||
}
|
||||
if (userBean.size() == 1) {
|
||||
|
||||
@@ -31,32 +31,51 @@
|
||||
android:textStyle="bold"
|
||||
android:visibility="gone" />
|
||||
|
||||
<com.xscm.moduleutil.widget.GifAvatarOvalView
|
||||
android:id="@+id/rv_user_head"
|
||||
android:layout_width="@dimen/dp_74"
|
||||
android:layout_height="@dimen/dp_74"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="@dimen/dp_10"
|
||||
android:src="@mipmap/me_img_upld_head"
|
||||
app:riv_oval="true" />
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
|
||||
<com.xscm.moduleutil.widget.GifAvatarOvalView
|
||||
android:id="@+id/rv_user_head"
|
||||
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
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/dp_80"
|
||||
android:layout_marginLeft="@dimen/dp_40"
|
||||
android:layout_marginTop="@dimen/dp_54"
|
||||
android:layout_marginRight="@dimen/dp_40"
|
||||
>
|
||||
android:layout_marginTop="@dimen/dp_34"
|
||||
android:layout_marginRight="@dimen/dp_40">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_ts"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:letterSpacing="0.1"
|
||||
android:text="起个好听的名字"
|
||||
android:textColor="#73000000"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
android:letterSpacing="0.1"/>
|
||||
android:textStyle="bold" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll"
|
||||
@@ -69,13 +88,13 @@
|
||||
<com.xscm.moduleutil.widget.ClearEditText
|
||||
android:id="@+id/ed_nick_name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/bg_r100_hui"
|
||||
android:hint="请输入昵称"
|
||||
android:gravity="center|left"
|
||||
android:paddingStart="10dp"
|
||||
android:hint="请输入昵称"
|
||||
android:maxLength="10"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingEnd="@dimen/dp_10"
|
||||
android:singleLine="true"
|
||||
android:text=""
|
||||
@@ -85,13 +104,12 @@
|
||||
<TextView
|
||||
android:id="@+id/tv_user_name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="0.2"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="随机"
|
||||
android:layout_weight="0.2"
|
||||
android:gravity="center"
|
||||
android:text="随机"
|
||||
android:textColor="@color/color_FF6C49E4"
|
||||
android:textSize="14sp"
|
||||
/>
|
||||
android:textSize="14sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -102,6 +120,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/dp_40"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -109,13 +128,13 @@
|
||||
android:textColor="#73000000"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text=" (注册成功,不可更改)"
|
||||
android:textColor="#33000000"
|
||||
android:textSize="12sp"
|
||||
/>
|
||||
android:textSize="12sp" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
@@ -124,27 +143,25 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_72"
|
||||
android:layout_marginStart="@dimen/dp_40"
|
||||
android:layout_marginEnd="@dimen/dp_40"
|
||||
android:layout_marginTop="12dp"
|
||||
android:orientation="horizontal"
|
||||
android:background="@drawable/selector_sex_mm">
|
||||
android:layout_marginEnd="@dimen/dp_40"
|
||||
android:background="@drawable/selector_sex_mm"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_nv"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
>
|
||||
android:gravity="center">
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_boy"
|
||||
android:layout_width="@dimen/dp_137"
|
||||
android:layout_height="@dimen/dp_72"
|
||||
android:src="@mipmap/check_boy"
|
||||
android:scaleType="fitCenter"
|
||||
/>
|
||||
android:src="@mipmap/check_boy" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
@@ -152,16 +169,14 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
>
|
||||
android:gravity="center">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_girl"
|
||||
android:layout_width="@dimen/dp_137"
|
||||
android:layout_height="@dimen/dp_72"
|
||||
android:src="@mipmap/check_girl"
|
||||
android:scaleType="fitCenter"
|
||||
/>
|
||||
android:src="@mipmap/check_girl" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
@@ -174,6 +189,7 @@
|
||||
android:layout_marginStart="@dimen/dp_40"
|
||||
android:layout_marginTop="@dimen/dp_24"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -195,24 +211,24 @@
|
||||
<TextView
|
||||
android:id="@+id/tv_year"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="@dimen/dp_44"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/bg_r100_hui"
|
||||
android:singleLine="true"
|
||||
android:gravity="center"
|
||||
android:singleLine="true"
|
||||
android:text="2001"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold" />
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="@dimen/dp_0"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="@dimen/dp_7"
|
||||
android:layout_marginEnd="@dimen/dp_7"
|
||||
android:layout_weight="0.2"
|
||||
android:gravity="center"
|
||||
android:text="年"
|
||||
android:layout_marginStart="@dimen/dp_7"
|
||||
android:layout_marginEnd="@dimen/dp_7"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold" />
|
||||
@@ -220,49 +236,49 @@
|
||||
<TextView
|
||||
android:id="@+id/tv_month"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="@dimen/dp_44"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/bg_r100_hui"
|
||||
android:gravity="center"
|
||||
android:singleLine="true"
|
||||
android:text="12"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold" />
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="@dimen/dp_0"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.2"
|
||||
android:gravity="center"
|
||||
android:layout_marginStart="@dimen/dp_7"
|
||||
android:layout_marginEnd="@dimen/dp_7"
|
||||
android:layout_weight="0.2"
|
||||
android:gravity="center"
|
||||
android:text="月"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold" />
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_day"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="@dimen/dp_44"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/bg_r100_hui"
|
||||
android:singleLine="true"
|
||||
android:gravity="center"
|
||||
android:singleLine="true"
|
||||
android:text="1"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold" />
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="@dimen/dp_0"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="@dimen/dp_7"
|
||||
android:layout_marginEnd="@dimen/dp_7"
|
||||
android:layout_weight="0.2"
|
||||
android:gravity="center"
|
||||
android:text="日"
|
||||
android:layout_marginStart="@dimen/dp_7"
|
||||
android:layout_marginEnd="@dimen/dp_7"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold" />
|
||||
@@ -301,15 +317,14 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_42"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_centerInParent="true"
|
||||
android:background="@drawable/theme_bg"
|
||||
android:layout_marginLeft="@dimen/dp_40"
|
||||
android:layout_marginRight="@dimen/dp_40"
|
||||
android:layout_marginBottom="@dimen/dp_20"
|
||||
android:gravity="center"
|
||||
>
|
||||
android:background="@drawable/theme_bg"
|
||||
android:gravity="center">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_commit_bg"
|
||||
@@ -317,8 +332,8 @@
|
||||
android:layout_height="@dimen/dp_75"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:visibility="gone"
|
||||
android:src="@drawable/theme_bg" />
|
||||
android:src="@drawable/theme_bg"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
@@ -330,15 +345,14 @@
|
||||
android:textColor="@color/white"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
android:visibility="gone"/>
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="21dp"
|
||||
android:text="进入秘地"
|
||||
android:textColor="@color/color_white"
|
||||
android:textSize="16sp"
|
||||
/>
|
||||
android:textSize="16sp" />
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
@@ -207,7 +207,13 @@ dependencies {
|
||||
|
||||
api 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.5'
|
||||
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,
|
||||
//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 com.xscm.moduleutil.base.CommonAppContext.postDelayed;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.WindowManager;
|
||||
import android.view.animation.AccelerateInterpolator;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.view.animation.TranslateAnimation;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
@@ -44,17 +48,17 @@ import com.hjq.toast.ToastUtils;
|
||||
import com.tencent.qcloud.tuikit.tuichat.bean.ChatInfo;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.base.RoomManager;
|
||||
import com.xscm.moduleutil.bean.XLHBean;
|
||||
import com.xscm.moduleutil.event.MqttBean;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.utils.BackgroundManager;
|
||||
import com.xscm.moduleutil.utils.ColorManager;
|
||||
import com.xscm.moduleutil.utils.DialogUtils;
|
||||
import com.xscm.moduleutil.utils.DisplayUtil;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
import com.xscm.moduleutil.utils.LanguageUtil;
|
||||
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.Subscribe;
|
||||
@@ -68,10 +72,6 @@ import java.util.Map;
|
||||
public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends AppCompatActivity
|
||||
implements BackgroundManager.BackgroundUpdateListener, ColorManager.ColorChangeListener {
|
||||
|
||||
// @Override
|
||||
// protected void attachBaseContext(Context newBase) {
|
||||
// super.attachBaseContext(LanguageUtil.attachBaseContext(newBase));
|
||||
// }
|
||||
@Override
|
||||
protected void attachBaseContext(Context newBase) {
|
||||
// 设置字体缩放比例为1.0f,即不跟随系统字体大小变化
|
||||
@@ -104,7 +104,7 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
ActivityUtils.finishAllActivities();
|
||||
}
|
||||
|
||||
|
||||
QXGiftDriftView qxGiftDriftView;
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -147,7 +147,6 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 在Activity中
|
||||
@@ -399,15 +398,10 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
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 boolean isMqttPlaying = false; // MQTT播放状态标志
|
||||
private boolean isXlhPlaying = false; // XLH播放状态标志
|
||||
@@ -421,13 +415,17 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
public void onMessageReceived(MqttBean mqttBean) {
|
||||
LogUtils.e("收到MQTT", mqttBean);
|
||||
if (mqttBean == null) return;
|
||||
if (SpUtil.getFloatingScreen() == 1) {
|
||||
synchronized (mqttQueueLock) {
|
||||
|
||||
synchronized (mqttQueueLock) {
|
||||
mqttMessageQueue.add(mqttBean);
|
||||
if (!isMqttPlaying) {
|
||||
isMqttPlaying = true;
|
||||
processNextMqttMessage();
|
||||
mqttMessageQueue.addAll(mqttBean.getList());
|
||||
// if (!isMqttPlaying) {
|
||||
// isMqttPlaying = true;
|
||||
processNextMqttMessage();
|
||||
// }
|
||||
}
|
||||
}else {
|
||||
mqttMessageQueue.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -436,19 +434,22 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
public void onEvent(XLHBean event) {
|
||||
LogUtils.e("收到XLH", event);
|
||||
if (event == null) return;
|
||||
|
||||
synchronized (xlhQueueLock) {
|
||||
xlhMessageQueue.add(event);
|
||||
if (!isXlhPlaying) {
|
||||
isXlhPlaying = true;
|
||||
processNextXlhMessage();
|
||||
if (SpUtil.getFloatingScreen() == 1) {
|
||||
synchronized (xlhQueueLock) {
|
||||
xlhMessageQueue.add(event);
|
||||
if (!isXlhPlaying) {
|
||||
isXlhPlaying = true;
|
||||
processNextXlhMessage();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
xlhMessageQueue.clear();
|
||||
}
|
||||
}
|
||||
|
||||
// 处理下一个MQTT消息
|
||||
private void processNextMqttMessage() {
|
||||
MqttBean mqttBean;
|
||||
MqttBean.ListBean mqttBean;
|
||||
synchronized (mqttQueueLock) {
|
||||
if (mqttMessageQueue.isEmpty()) {
|
||||
isMqttPlaying = false;
|
||||
@@ -475,7 +476,12 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
ViewGroup decorView;
|
||||
ViewGroup decorView1;
|
||||
|
||||
private void showFloatingMessage(MqttBean mqttBean) {
|
||||
private void showFloatingMessage(MqttBean.ListBean mqttBean) {
|
||||
|
||||
// QXGiftDriftView.getInstance( this).addGiftModel(mqttBean);
|
||||
|
||||
|
||||
|
||||
try {
|
||||
// 清理之前的视图(如果存在)
|
||||
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) {
|
||||
try {
|
||||
view.setTranslationX(view.getWidth());
|
||||
ObjectAnimator animator1 = ObjectAnimator.ofFloat(view, "translationX", view.getWidth(), 0f);
|
||||
animator1.setDuration(1500);
|
||||
animator1.setInterpolator(new DecelerateInterpolator(2.0f));
|
||||
animator1.start();
|
||||
int screenWidth = getScreenWidth();
|
||||
// 设置初始位置:在屏幕右侧外部(完全不可见)
|
||||
view.setTranslationX(screenWidth);
|
||||
|
||||
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
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
onAnimationEnd.run();
|
||||
}
|
||||
});
|
||||
animator2.start();
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("MQTT动画执行失败", e);
|
||||
onAnimationEnd.run();
|
||||
TranslateAnimation enterAnim = new TranslateAnimation(
|
||||
Animation.ABSOLUTE, screenWidth,
|
||||
Animation.ABSOLUTE, (screenWidth - SystemUtils.getWidth(316)) / 2,
|
||||
Animation.ABSOLUTE, 0,
|
||||
Animation.ABSOLUTE, 0
|
||||
);
|
||||
enterAnim.setDuration(1500);
|
||||
enterAnim.setAnimationListener(new Animation.AnimationListener() {
|
||||
@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) {
|
||||
LogUtils.e("MQTT动画启动失败", e);
|
||||
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) {
|
||||
try {
|
||||
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 textView2 = view.findViewById(R.id.tv_to_name);
|
||||
TextView tv_time = view.findViewById(R.id.tv_num);
|
||||
|
||||
if (mqttBean.getList() != null) {
|
||||
textView2.setText("送给" + (mqttBean.getList().getToUserName() != null ? mqttBean.getList().getToUserName() : ""));
|
||||
textView.setText(mqttBean.getList().getFromUserName() != null ? mqttBean.getList().getFromUserName() : "");
|
||||
if (mqttBean.getList().getGift_picture() != null) {
|
||||
ImageUtils.loadHeadCC(mqttBean.getList().getGift_picture(), view.findViewById(R.id.iv_piaoping));
|
||||
if (mqttBean != null) {
|
||||
textView2.setText("送给" + (mqttBean.getToUserName() != null ? mqttBean.getToUserName() : ""));
|
||||
textView.setText(mqttBean.getFromUserName() != null ? mqttBean.getFromUserName() : "");
|
||||
if (mqttBean.getGift_picture() != null) {
|
||||
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 {
|
||||
textView2.setText("送给");
|
||||
textView.setText("");
|
||||
@@ -680,8 +756,9 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
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.content.Context;
|
||||
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.core.app.ActivityCompat;
|
||||
@@ -11,9 +14,21 @@ import androidx.core.content.ContextCompat;
|
||||
import androidx.databinding.ViewDataBinding;
|
||||
|
||||
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.RoomManager;
|
||||
import com.xscm.moduleutil.bean.UserBean;
|
||||
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.location.LocationProvider;
|
||||
import com.xscm.moduleutil.utils.location.SystemLocationProvider;
|
||||
@@ -28,13 +43,13 @@ import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
public abstract class BaseMvpActivity<P extends IPresenter, VDB extends ViewDataBinding> extends BaseAppCompatActivity<VDB> implements
|
||||
IView<Activity> , LocationProvider.LocationCallback
|
||||
{
|
||||
IView<Activity> {
|
||||
|
||||
protected P MvpPre;
|
||||
|
||||
protected abstract P bindPresenter();
|
||||
private String city1;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
@@ -77,78 +92,112 @@ public abstract class BaseMvpActivity<P extends IPresenter, VDB extends ViewData
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void logOutEvent(UserBean userBean) {
|
||||
// 在用户 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
|
||||
public void onError(final int code, final String desc) {
|
||||
LogUtils.e("@@@1",code,"描述:",desc);
|
||||
LogUtils.e("@@@1", code, "描述:", desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
LogUtils.e("@@@","成功");
|
||||
// V2TIMUserFullInfo userFullInfo = new V2TIMUserFullInfo();
|
||||
// userFullInfo.setNickname(userBean.getNickname());
|
||||
// userFullInfo.setFaceUrl(userBean.getAvatar());
|
||||
// userFullInfo.setAllowType(userBean.getSex());
|
||||
// V2TIMManager.getInstance().setSelfInfo(userFullInfo, new V2TIMCallback() {
|
||||
// @Override
|
||||
// public void onSuccess() {
|
||||
// LogUtils.e("@@@", "成功");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError(int code, String desc) {
|
||||
// LogUtils.e("@@@", "描述"+desc);
|
||||
// }
|
||||
// });
|
||||
initLocation();
|
||||
LogUtils.e("@@@", "成功");
|
||||
V2TIMManager.getConversationManager().getTotalUnreadMessageCount(new V2TIMValueCallback<Long>() {
|
||||
@Override
|
||||
public void onSuccess(Long aLong) {
|
||||
// 通知未读数变化
|
||||
UnreadCountEvent event =CommonAppContext.getInstance().unreadCountEvent;
|
||||
if (event==null){
|
||||
event=new UnreadCountEvent();
|
||||
}
|
||||
event.setALong(aLong);
|
||||
// 使用EventBus通知
|
||||
CommonAppContext.getInstance().setUnreadCountEvent(event);
|
||||
EventBus.getDefault().post(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
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
|
||||
public void onLocationReceived(double latitude, double longitude, String city) {
|
||||
LogUtils.e("当前位置:" + city);
|
||||
city1=city;
|
||||
EventBus.getDefault().post(city1);
|
||||
public void onConnecting() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(String errorMessage) {
|
||||
LogUtils.e("定位失败");
|
||||
public void onConnectSuccess() {//重连成功
|
||||
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
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
|
||||
if (requestCode == 1001) {
|
||||
if (locationProvider==null) {
|
||||
locationProvider = new SystemLocationProvider();
|
||||
public Resources getResources() {
|
||||
Resources resources = super.getResources();
|
||||
if (resources != null) {
|
||||
Configuration configuration = resources.getConfiguration();
|
||||
if (configuration != null) {
|
||||
// 设置字体缩放比例不随系统变化
|
||||
configuration.fontScale = 1.0f; // 1.0f表示默认大小
|
||||
resources.updateConfiguration(configuration, resources.getDisplayMetrics());
|
||||
}
|
||||
locationProvider.getLastKnownLocation(this, this);
|
||||
}
|
||||
|
||||
return resources;
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
@@ -169,10 +218,10 @@ public abstract class BaseMvpActivity<P extends IPresenter, VDB extends ViewData
|
||||
// }
|
||||
// });
|
||||
}
|
||||
/**
|
||||
* 显示全局飘屏消息(支持任意位置飘过)
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* 显示全局飘屏消息(支持任意位置飘过)
|
||||
*
|
||||
*/
|
||||
// @Subscribe(threadMode = ThreadMode.MAIN)
|
||||
// public void showPiaoPingMessage(MqttBean mqttBean) {
|
||||
// WindowManager windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
|
||||
|
||||
@@ -10,7 +10,10 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.webkit.GeolocationPermissions;
|
||||
import android.webkit.JavascriptInterface;
|
||||
@@ -21,11 +24,16 @@ import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
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.launcher.ARouter;
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.base.RoomManager;
|
||||
import com.xscm.moduleutil.databinding.ActivityWebViewBinding;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.tencent.imsdk.v2.V2TIMConversation;
|
||||
@@ -46,6 +54,8 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
||||
|
||||
public String title;
|
||||
public String url;
|
||||
@Autowired
|
||||
public String type;//type=1:青少年模式
|
||||
private ValueCallback<Uri> mUploadMessage;
|
||||
private ValueCallback<Uri[]> mUploadCallbackAboveL;
|
||||
private final int REQUEST_FILE_PICKER = 1;
|
||||
@@ -53,6 +63,8 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
@Override
|
||||
protected void initData() {
|
||||
|
||||
|
||||
WebSettings webSettings = mBinding.webView.getSettings();
|
||||
|
||||
// 禁用水平滚动
|
||||
@@ -61,9 +73,9 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
||||
webSettings.setJavaScriptEnabled(true);
|
||||
webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); //关闭webview中缓存
|
||||
//增加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("协议")) {
|
||||
webSettings.setDisplayZoomControls(false); // 隐藏默认缩放控件
|
||||
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL); // 使用正常布局算法
|
||||
@@ -75,10 +87,10 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
||||
// 设置初始缩放
|
||||
mBinding.webView.setInitialScale(100);
|
||||
mBinding.webView.getSettings().setUseWideViewPort(false);
|
||||
}else {
|
||||
} else {
|
||||
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
|
||||
}
|
||||
|
||||
@@ -94,7 +106,6 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
||||
mBinding.webView.setScrollContainer(true);
|
||||
|
||||
|
||||
|
||||
mBinding.webView.setWebViewClient(new WebViewClient());
|
||||
mBinding.webView.setBackgroundColor(Color.TRANSPARENT);
|
||||
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() {
|
||||
// 这里可以扩展为显示对话框让用户选择“拍照”或“从相册选择”
|
||||
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
|
||||
protected void initView() {
|
||||
getWindow().getDecorView().setBackgroundResource(com.xscm.moduleutil.R.color.white);
|
||||
title = getIntent().getStringExtra("title");
|
||||
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("反馈")) {
|
||||
mBinding.topBar.setVisibility(GONE);
|
||||
// mBinding.webView.setPadding(0,20,0,0);
|
||||
@@ -227,20 +329,18 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
||||
mBinding.topBar.setVisibility(VISIBLE);
|
||||
mBinding.topBar.setTitle(title);
|
||||
}
|
||||
}else {
|
||||
if (url.equals(CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=6")){
|
||||
} else {
|
||||
if (url.equals(CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl() + "/api/Page/page_show?id=6")) {
|
||||
mBinding.topBar.setVisibility(VISIBLE);
|
||||
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.setTitle("隐私协议");
|
||||
}else {
|
||||
} else {
|
||||
mBinding.topBar.setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -250,9 +350,11 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
||||
|
||||
public class WebAppInterface {
|
||||
Context mContext;
|
||||
String type;
|
||||
|
||||
WebAppInterface(Context c) {
|
||||
WebAppInterface(Context c, String type1) {
|
||||
mContext = c;
|
||||
type = type1;
|
||||
}
|
||||
|
||||
// 被 H5 调用的方法
|
||||
@@ -263,8 +365,15 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
||||
|
||||
@JavascriptInterface
|
||||
public void closeWeb() {
|
||||
LogUtils.e("value: ");
|
||||
finish();
|
||||
if (type != null) {
|
||||
if (type.equals("1")) {
|
||||
ARouter.getInstance().build(ARouteConstants.UNDERAGE_ACTIVITY).withInt("type", 1).navigation();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
@@ -281,8 +390,11 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
||||
|
||||
@JavascriptInterface
|
||||
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
|
||||
public void jumpWebPage(String objects) {
|
||||
// ARouter.getInstance().build(ARouteConstants.USER_HOME_PAGE).navigation();
|
||||
@@ -290,22 +402,25 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
||||
}
|
||||
|
||||
@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.putExtra(TUIConstants.TUIChat.CHAT_ID, group_id);
|
||||
intent.putExtra(TUIConstants.TUIChat.CHAT_NAME, guild_name);
|
||||
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);
|
||||
public void chatWithUser(String user_id, String nickname) {
|
||||
Intent intent = new Intent(mContext, TUIGroupChatActivity.class);
|
||||
intent.putExtra(TUIConstants.TUIChat.CHAT_ID, user_id);
|
||||
intent.putExtra(TUIConstants.TUIChat.CHAT_NAME, nickname);
|
||||
intent.putExtra(TUIConstants.TUIChat.CHAT_TYPE, V2TIMConversation.V2TIM_C2C);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void exchange(){
|
||||
public void exchange() {
|
||||
ARouter.getInstance().build(ARouteConstants.CURRENCY).navigation();
|
||||
|
||||
}
|
||||
@@ -321,7 +436,7 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void Recharge(){
|
||||
public void Recharge() {
|
||||
ARouter.getInstance().build(ARouteConstants.RECHARGE_ACTIVITY).navigation();
|
||||
}
|
||||
}
|
||||
@@ -333,6 +448,7 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
||||
// intent.putExtra("menuName", msg);
|
||||
// startActivity(intent);
|
||||
|
||||
|
||||
LogUtils.e("closeWeb");
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.activity.BaseMvpActivity;
|
||||
import com.xscm.moduleutil.base.RoomManager;
|
||||
import com.xscm.moduleutil.bean.NewsMessageList;
|
||||
import com.xscm.moduleutil.databinding.ActivityOfficialNoticeBinding;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
@@ -75,7 +76,8 @@ public class OfficialNoticeActivity extends BaseMvpActivity<NewsPresenter, Activ
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
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()){
|
||||
ARouter.getInstance().build(ARouteConstants.H5).withString("url", item.getUrl()).navigation();
|
||||
}
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
package com.xscm.moduleutil.adapter;
|
||||
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.bean.RechargeBean;
|
||||
import com.xscm.moduleutil.utils.SystemUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -36,7 +41,10 @@ public class BalanceRechargeAdapter extends BaseMultiItemQuickAdapter<RechargeBe
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, RechargeBean item) {
|
||||
int type = helper.getItemViewType();
|
||||
|
||||
// ConstraintLayout constraintLayout = helper.getView(R.id.cl_item);
|
||||
// ViewGroup.LayoutParams layoutParams =constraintLayout.getLayoutParams();
|
||||
// layoutParams.width = ( com.blankj.utilcode.util.ScreenUtils.getScreenWidth()-32-24)/3-24; // 使用你定义的getWidth方法
|
||||
// constraintLayout.setLayoutParams(layoutParams);
|
||||
if (type == ITEM_TYPE_NORMAL) {
|
||||
// 正常 item 显示逻辑
|
||||
helper.setText(R.id.tv_gold_num, item.getCoins());
|
||||
|
||||
@@ -12,6 +12,8 @@ import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.base.BaseMvpFragment;
|
||||
import com.xscm.moduleutil.bean.GiftLabelBean;
|
||||
import com.xscm.moduleutil.bean.GiftPackBean;
|
||||
import com.xscm.moduleutil.bean.GiftPackEvent;
|
||||
import com.xscm.moduleutil.bean.GiftPackListCount;
|
||||
import com.xscm.moduleutil.bean.RewardUserBean;
|
||||
import com.xscm.moduleutil.bean.RoonGiftModel;
|
||||
import com.xscm.moduleutil.bean.WalletBean;
|
||||
@@ -78,14 +80,17 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
||||
}
|
||||
|
||||
public void loadDataIfNeeded(String id, int type, String roomId) {
|
||||
if (MvpPre==null){
|
||||
MvpPre = new RewardGiftPresenter(this, getActivity());
|
||||
}
|
||||
if (id.equals("0")) {
|
||||
MvpPre.giftPack();
|
||||
} else {
|
||||
if (type == 0) {
|
||||
MvpPre.getGiftList("0", type, roomId);
|
||||
} else {
|
||||
if (id==null){
|
||||
id="0";
|
||||
if (id == null) {
|
||||
id = "0";
|
||||
}
|
||||
MvpPre.getGiftList(id, type, roomId);
|
||||
}
|
||||
@@ -94,23 +99,28 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onString(String giftId){
|
||||
bdgiftId=giftId;
|
||||
MvpPre.giftPack();
|
||||
public void onString(GiftPackEvent event) {
|
||||
if (event!=null && event.getBdid()!=null) {
|
||||
bdgiftId = event.getBdid();
|
||||
MvpPre.giftPack();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
if (id.equals("0")) {
|
||||
MvpPre.giftPack();
|
||||
} else {
|
||||
if (type == 0) {
|
||||
MvpPre.getGiftList("0", type, roomId);
|
||||
} else {
|
||||
MvpPre.getGiftList(id, type, roomId);
|
||||
}
|
||||
|
||||
if (type==0){
|
||||
MvpPre.getGiftList("0", type, roomId);
|
||||
}
|
||||
// if (id.equals("0")) {
|
||||
// MvpPre.giftPack();
|
||||
// } else {
|
||||
// if (type == 0) {
|
||||
// MvpPre.getGiftList("0", type, roomId);
|
||||
// } else {
|
||||
// MvpPre.getGiftList(id, type, roomId);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -183,23 +193,33 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
||||
@Override
|
||||
public void giftPack(List<GiftPackBean> giftPackBean) {
|
||||
giftPackList = new ArrayList<>();
|
||||
if (bdgiftId!=null){
|
||||
for (GiftPackBean item : giftPackBean){
|
||||
if (item.getGift_id().equals(bdgiftId)){
|
||||
item.setChecked(true);
|
||||
|
||||
if (giftPackBean != null && giftPackBean.size() > 0) {
|
||||
|
||||
if (bdgiftId != null) {
|
||||
for (GiftPackBean item : giftPackBean) {
|
||||
if (item.getGift_id().equals(bdgiftId)) {
|
||||
item.setChecked(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
giftPackList.addAll(giftPackBean);
|
||||
pageCount = (int) Math.ceil(giftPackBean.size() * 1.0 / pageSize);
|
||||
for (int j = 0; j < pageCount; j++) {
|
||||
giftPackList.addAll(giftPackBean);
|
||||
pageCount = (int) Math.ceil(giftPackBean.size() * 1.0 / pageSize);
|
||||
for (int j = 0; j < pageCount; j++) {
|
||||
// mAdapter = new GiftTwoAdapter(getActivity(), data, j, "0");
|
||||
// mBinding.rvGift.setAdapter(mAdapter);
|
||||
packAdapter = new GiftPackAdapter(getActivity(), giftPackBean, j, "0");
|
||||
packAdapter = new GiftPackAdapter(getActivity(), giftPackBean, j, "0");
|
||||
mBinding.rvGift.setAdapter(packAdapter);
|
||||
}
|
||||
} else {
|
||||
giftPackBean = new ArrayList<>();
|
||||
pageCount = (int) Math.ceil(giftPackBean.size() * 1.0 / pageSize);
|
||||
packAdapter = new GiftPackAdapter(getActivity(), giftPackBean, 0, "0");
|
||||
mBinding.rvGift.setAdapter(packAdapter);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -207,6 +227,11 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGiftPackListCount(GiftPackListCount giftPackListCount) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getRewardList(List<RewardUserBean> rewardUserBeanList) {
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
import static androidx.core.app.ActivityCompat.startActivityForResult;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.Application;
|
||||
import android.content.ComponentCallbacks2;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.Signature;
|
||||
import android.content.res.Configuration;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.PowerManager;
|
||||
import android.provider.Settings;
|
||||
import android.util.Base64;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.webkit.WebView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.multidex.MultiDex;
|
||||
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.LogUtils;
|
||||
import com.blankj.utilcode.util.ProcessUtils;
|
||||
import com.blankj.utilcode.util.ServiceUtils;
|
||||
import com.lahm.library.EasyProtectorLib;
|
||||
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.UserInfo;
|
||||
import com.xscm.moduleutil.event.AppLifecycleEvent;
|
||||
import com.xscm.moduleutil.event.UnreadCountEvent;
|
||||
import com.xscm.moduleutil.interfaces.AppLifecycleUtil;
|
||||
import com.xscm.moduleutil.listener.MessageListenerSingleton;
|
||||
import com.xscm.moduleutil.rtc.AgoraManager;
|
||||
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.UtilConfig;
|
||||
import com.xscm.moduleutil.utils.config.EnvironmentEnum;
|
||||
import com.xscm.moduleutil.utils.config.EnvironmentPrefs;
|
||||
import com.xscm.moduleutil.widget.CommonAppConfig;
|
||||
import com.xscm.moduleutil.widget.PiaoPingManager;
|
||||
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.api.DefaultRefreshFooterCreator;
|
||||
import com.scwang.smartrefresh.layout.api.DefaultRefreshHeaderCreator;
|
||||
@@ -60,17 +70,17 @@ import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
|
||||
/**
|
||||
* 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 Handler sMainThreadHandler;
|
||||
@@ -85,11 +95,16 @@ public class CommonAppContext extends MultiDexApplication {
|
||||
public boolean isPlaying;
|
||||
|
||||
public String playId;
|
||||
public String lable_id;
|
||||
public boolean isMicPlace;
|
||||
|
||||
public boolean isShowAg;
|
||||
|
||||
public boolean isRoomJoininj=false;
|
||||
|
||||
public String playCover;
|
||||
public boolean showSelf;//盲盒是否能送自己
|
||||
public String playName;
|
||||
private final ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(1);
|
||||
private ScheduledExecutorService scheduledExecutorServiceRoom = null;
|
||||
private MqttConnect mqttConnect=null;
|
||||
|
||||
// 添加后台状态标记
|
||||
@@ -107,6 +122,14 @@ public class CommonAppContext extends MultiDexApplication {
|
||||
return wasInBackground;
|
||||
}
|
||||
|
||||
private int activityCount = 0;
|
||||
|
||||
private AppStateListener appStateListener;
|
||||
private boolean isListeningUnreadCount = false;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public UnreadCountEvent unreadCountEvent;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
@@ -114,22 +137,293 @@ public class CommonAppContext extends MultiDexApplication {
|
||||
sInstance = this;
|
||||
sMainThreadHandler = new Handler();
|
||||
EnvironmentPrefs prefs = new EnvironmentPrefs(this);
|
||||
// 添加内存优化配置
|
||||
optimizeMemorySettings();
|
||||
currentEnvironment = prefs.getSelectedEnvironment();
|
||||
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(){
|
||||
UtilConfig.init(this);
|
||||
registerActivityLifecycleCallbacks();
|
||||
// registerActivityLifecycleCallbacks();
|
||||
initWebView();
|
||||
if (ProcessUtils.isMainProcess()) {
|
||||
initARouter();
|
||||
if (SpUtil.isAgreePolicy()) {
|
||||
checkInEmulator();
|
||||
UtilConfig.checkInEmulator();
|
||||
AgoraManager.getInstance(this).init(currentEnvironment.getSwSdkAppId());
|
||||
AgoraManager.getInstance(this);
|
||||
AgoraManager.init(currentEnvironment.getSwSdkAppId());
|
||||
MessageListenerSingleton.getInstance();
|
||||
CrashReport.initCrashReport(this, "ac3ed4d89f", true);/*bugly初始化*/
|
||||
// // 启动 MQTT 服务
|
||||
@@ -145,6 +439,7 @@ public class CommonAppContext extends MultiDexApplication {
|
||||
|
||||
// 每次启动应用时重置状态
|
||||
SpUtil.getInstance().setBooleanValue("youth_model_shown", false);
|
||||
startInitSdk();
|
||||
}
|
||||
}
|
||||
// piaoPingManager = PiaoPingManager.getInstance(this);
|
||||
@@ -155,8 +450,26 @@ public class CommonAppContext extends MultiDexApplication {
|
||||
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) {
|
||||
}
|
||||
|
||||
@@ -396,6 +709,11 @@ public class CommonAppContext extends MultiDexApplication {
|
||||
return mUserBean;
|
||||
}
|
||||
|
||||
public UserInfo getUserInfo() {
|
||||
UserInfo userInfo = SpUtil.getUserInfo();
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
public void setUserBean(UserBean 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,13 @@
|
||||
package com.xscm.moduleutil.bean;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/9/15
|
||||
*@description: 背包礼物总价值
|
||||
*/
|
||||
@Data
|
||||
public class GiftPackListCount {
|
||||
private String count;
|
||||
}
|
||||
@@ -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 room_id;
|
||||
private String song_code;//歌曲唯一标识
|
||||
private String song_code="";//歌曲唯一标识
|
||||
private String song_name;//歌曲名称
|
||||
private String singer;//歌手
|
||||
private String poster;//封面
|
||||
|
||||
@@ -35,7 +35,9 @@ public class RoomMessageEvent {
|
||||
private String jia_jia;
|
||||
private UserInfo FromUserInfo;
|
||||
private UserInfo ToUserInfo;
|
||||
private List<UserInfo> ToUserInfos;
|
||||
private GiftBean GiftInfo;
|
||||
private List<GiftBean> GiftInfos;
|
||||
private int room_up_pit_type;
|
||||
private MusicSongBean songInfo;
|
||||
private MusicSongBean nextInfo;
|
||||
@@ -52,7 +54,7 @@ public class RoomMessageEvent {
|
||||
private String AcceptRoomId;//接收者所在的房间id
|
||||
private String PkId;
|
||||
private String room_id;//当type==1的时候。这个roomId是对方的房间id
|
||||
private String user_id;
|
||||
private String user_id="";
|
||||
private String pk_end_times;//pk结束时间
|
||||
private List<RoomPitBean> userCharmList;
|
||||
|
||||
|
||||
@@ -19,6 +19,8 @@ public class UserBean implements Serializable {
|
||||
private String mobile;
|
||||
private int sex;
|
||||
private int auth;
|
||||
private int is_can_chat;//是否可以私聊,1:可以,0:不可以
|
||||
private int can_chat_money;//需要充值的金额
|
||||
|
||||
private List<MultiUserBean> multi_user;
|
||||
|
||||
|
||||
@@ -55,6 +55,9 @@ public class UserInfo implements Serializable {
|
||||
private String red_status;
|
||||
private String gift_num;
|
||||
|
||||
private int is_can_chat;//是否可以私聊,1:可以,0:不可以
|
||||
private int can_chat_money;//需要充值的金额
|
||||
|
||||
private RelationshipBean qinmi;
|
||||
private RelationshipBean zhenai;
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ public class BlindBoxBean {
|
||||
private int is_xlh; ///是否开启巡乐会 0 关闭 1 开启
|
||||
private Object xlh_data;
|
||||
private List<GiftBean> gift_list;
|
||||
private String end_time;//巡乐会结束时间
|
||||
|
||||
private GiveGift give_homeowner_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;
|
||||
}
|
||||
@@ -118,6 +127,9 @@ public class BlindBoxBean {
|
||||
if (jsonObject.has("status")) {
|
||||
xlhData.setStatus(jsonObject.get("status").getAsInt());
|
||||
}
|
||||
if (jsonObject.has("end_time")){
|
||||
xlhData.setEnd_time(jsonObject.get("end_time").getAsString());
|
||||
}
|
||||
|
||||
return xlhData;
|
||||
}
|
||||
@@ -130,6 +142,7 @@ public class BlindBoxBean {
|
||||
private String start_num;//巡乐会开启需要达到的次数
|
||||
private int current_num;//当前已抽奖次数
|
||||
private int status;
|
||||
private String end_time;
|
||||
}
|
||||
@Data
|
||||
public static class GiveGift {
|
||||
|
||||
@@ -29,6 +29,7 @@ public class RoomInfoResp implements Serializable {
|
||||
private PkRoomInfo pk_info;
|
||||
private List<RoomPitBean> song_pit_list;
|
||||
private FriendInfo friend_info;
|
||||
private GiftXlh gift_cycle;
|
||||
|
||||
|
||||
//弹出麦位操作弹出
|
||||
@@ -114,4 +115,18 @@ public class RoomInfoResp implements Serializable {
|
||||
public boolean isFreedomMode() {
|
||||
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_mute;//0未禁麦 1禁麦
|
||||
private int count_down;//麦位倒计时
|
||||
private String user_id;//麦位上用户id
|
||||
private String user_id="";//麦位上用户id
|
||||
private String nickname;//麦位上用户昵称
|
||||
private String avatar;//用户头像
|
||||
private String sex;//性别
|
||||
|
||||
@@ -18,6 +18,7 @@ public class RoomSettingBean implements MultiItemEntity {
|
||||
public static final int QXRoomSettingTypeRoomTypeGirl = 13;
|
||||
///交友 房
|
||||
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 QXRoomSettingTypeRoomReport = 26;
|
||||
public static final int QXRoomSettingTypeRoomFloatingScreen = 29;
|
||||
|
||||
public static final int ITEM_TYPE_DEFAULT = 0;
|
||||
public static final int ITEM_TYPE_WITH_ICON = 1;
|
||||
|
||||
@@ -82,6 +82,11 @@ public class ConfirmDialog extends Dialog {
|
||||
|
||||
// 设置点击监听器
|
||||
btnPositive.setOnClickListener(v -> {
|
||||
isCountdownCancelled = true; // 标记倒计时被取消
|
||||
if (countDownTimer != null) {
|
||||
countDownTimer.cancel(); // 取消倒计时
|
||||
countDownTimer = null;
|
||||
}
|
||||
if (positiveButtonClickListener != null) {
|
||||
positiveButtonClickListener.onClick(v);
|
||||
}
|
||||
@@ -126,7 +131,7 @@ public class ConfirmDialog extends Dialog {
|
||||
// rootView.startAnimation(shake);
|
||||
// }
|
||||
}
|
||||
|
||||
private boolean isCountdownCancelled = false; // 添加标志位
|
||||
private void startCountdown(Button btnNegative) {
|
||||
countDownTimer = new CountDownTimer(countdownSeconds * 1000L, 1000) {
|
||||
@Override
|
||||
@@ -137,11 +142,14 @@ public class ConfirmDialog extends Dialog {
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
btnNegative.setText(negativeButtonText);
|
||||
if (negativeButtonClickListener != null) {
|
||||
negativeButtonClickListener.onClick(btnNegative); // 自动触发取消
|
||||
// 检查是否被主动取消
|
||||
if (!isCountdownCancelled) {
|
||||
btnNegative.setText(negativeButtonText);
|
||||
if (negativeButtonClickListener != null) {
|
||||
negativeButtonClickListener.onClick(btnNegative); // 自动触发取消
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import androidx.annotation.NonNull;
|
||||
|
||||
import com.blankj.utilcode.util.ScreenUtils;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.bean.FirstChargeGiftBean;
|
||||
import com.xscm.moduleutil.color.ThemeableDrawableUtils;
|
||||
import com.xscm.moduleutil.databinding.DialogRealNameBinding;
|
||||
import com.xscm.moduleutil.databinding.IndexDialogYouthModelBinding;
|
||||
@@ -20,6 +21,18 @@ import com.xscm.moduleutil.widget.dialog.BaseDialog;
|
||||
*/
|
||||
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) {
|
||||
super(context);
|
||||
}
|
||||
@@ -36,8 +49,19 @@ public class RealNameDialog extends BaseDialog<DialogRealNameBinding> {
|
||||
Window window = getWindow();
|
||||
window.setLayout((int) (ScreenUtils.getScreenWidth() * 315.f / 375), WindowManager.LayoutParams.WRAP_CONTENT);
|
||||
|
||||
mBinding.tvIKnow.setOnClickListener(v -> dismiss());
|
||||
mBinding.ivClose.setOnClickListener(v -> dismiss());
|
||||
// mBinding.tvIKnow.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);
|
||||
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.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.base.RoomManager;
|
||||
import com.xscm.moduleutil.databinding.WebViewDialogBinding;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.widget.dialog.BaseDialog;
|
||||
@@ -57,7 +58,7 @@ public class WebViewDialog extends BaseDialog<WebViewDialogBinding> {
|
||||
android.util.DisplayMetrics displayMetrics = getContext().getResources().getDisplayMetrics();
|
||||
// 设置高度为屏幕高度的80%
|
||||
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;
|
||||
getWindow().setAttributes(params);
|
||||
}
|
||||
@@ -80,6 +81,7 @@ public class WebViewDialog extends BaseDialog<WebViewDialogBinding> {
|
||||
if (type==10){
|
||||
mBinding.gzCl.setBackgroundResource(R.mipmap.tkzj);
|
||||
mBinding.imGz.setImageResource(R.mipmap.tkzj_gz);
|
||||
mBinding.webView.setPadding(16, 0, 16, 0);
|
||||
}else if (type==11){
|
||||
mBinding.gzCl.setBackgroundResource(R.mipmap.syzc);
|
||||
mBinding.imGz.setImageResource(R.mipmap.syzc_gz);
|
||||
@@ -100,6 +102,32 @@ public class WebViewDialog extends BaseDialog<WebViewDialogBinding> {
|
||||
|
||||
|
||||
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);
|
||||
@@ -114,12 +142,16 @@ public class WebViewDialog extends BaseDialog<WebViewDialogBinding> {
|
||||
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.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);
|
||||
}
|
||||
@@ -161,7 +193,9 @@ public class WebViewDialog extends BaseDialog<WebViewDialogBinding> {
|
||||
|
||||
@JavascriptInterface
|
||||
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
|
||||
public void jumpWebPage(String objects) {
|
||||
|
||||
@@ -41,7 +41,13 @@ public class YouthModelDialog extends BaseDialog<IndexDialogYouthModelBinding> {
|
||||
Window window = getWindow();
|
||||
window.setLayout((int) (ScreenUtils.getScreenWidth() * 315.f / 375), WindowManager.LayoutParams.WRAP_CONTENT);
|
||||
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 -> {
|
||||
// if (teenagerInfo.getHad_password() == 1) {
|
||||
|
||||
@@ -49,7 +55,7 @@ public class YouthModelDialog extends BaseDialog<IndexDialogYouthModelBinding> {
|
||||
// } else {
|
||||
// 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();
|
||||
});
|
||||
|
||||
|
||||
@@ -9,10 +9,12 @@ import android.media.MediaPlayer;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.widget.CompoundButton;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -20,20 +22,26 @@ import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
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.base.BaseMvpDialogFragment;
|
||||
import com.xscm.moduleutil.bean.GiftBean;
|
||||
import com.xscm.moduleutil.bean.MqttXlhEnd;
|
||||
import com.xscm.moduleutil.bean.RoomMessageEvent;
|
||||
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.BlindReslutBean;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.XlhDrawBean;
|
||||
import com.xscm.moduleutil.databinding.DialogGiftLotteryBinding;
|
||||
import com.xscm.moduleutil.dialog.RechargeDialogFragment;
|
||||
import com.xscm.moduleutil.dialog.WebViewDialog;
|
||||
import com.xscm.moduleutil.event.LotteryEvent;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.widget.CircularProgressView;
|
||||
import com.xscm.moduleutil.widget.GiftCardView;
|
||||
import com.xscm.moduleutil.widget.floatingView.IFloatingView;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
@@ -43,6 +51,7 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
* @author qx
|
||||
@@ -76,8 +85,8 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
||||
private GiftCardView currentGiftCardView;
|
||||
private boolean isDrawing;//是否正在抽奖
|
||||
private boolean isOpenSound;//是否开启音效
|
||||
private boolean isOpenSpecial;//是否开启特效
|
||||
|
||||
private boolean isOpenSpecial;//是否开启特效
|
||||
private Handler handler;
|
||||
private Runnable timerRunnable;//定时器
|
||||
private int startType;//类型,点击的事抽奖1次还是10次还是100次
|
||||
@@ -114,8 +123,6 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
||||
Dialog dialog = super.onCreateDialog(savedInstanceState);
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setCancelable(true);
|
||||
if (!EventBus.getDefault().isRegistered(this))
|
||||
EventBus.getDefault().register(this);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
@@ -130,15 +137,75 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
||||
userIdType = LotteryEvent.fromLotteryEvent(giftBagId);
|
||||
heart_id=getArguments().getString("heart_id");
|
||||
|
||||
|
||||
if (!EventBus.getDefault().isRegistered( this)){
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
MvpPre.getGiftList(giftBagId, roomId);
|
||||
MvpPre.wallet();
|
||||
mBinding.mirroeSky.swLockYx.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean check) {
|
||||
isOpenSound= check;//音效
|
||||
if(!check){
|
||||
stopPlay();
|
||||
}
|
||||
}
|
||||
});
|
||||
mBinding.cityTime.swLockYx.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean check) {
|
||||
isOpenSound= check;//音效
|
||||
if(!check){
|
||||
stopPlay();
|
||||
}
|
||||
}
|
||||
});
|
||||
mBinding.pinnacleTime.swLockYx.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean check) {
|
||||
isOpenSound= check;//音效
|
||||
if(!check){
|
||||
stopPlay();
|
||||
}
|
||||
}
|
||||
});
|
||||
mBinding.mirroeSky.swTex.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean check) {
|
||||
isOpenSpecial= check;
|
||||
}
|
||||
});
|
||||
mBinding.cityTime.swTex.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean check) {
|
||||
isOpenSpecial= check;
|
||||
}
|
||||
});
|
||||
mBinding.pinnacleTime.swTex.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean check) {
|
||||
isOpenSpecial= check;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void stopPlay(){
|
||||
if(mediaPlayer!=null&&player!=null){
|
||||
player.stop();
|
||||
player.reset();
|
||||
player=null;
|
||||
mediaPlayer.stop();
|
||||
mediaPlayer.reset();
|
||||
mediaPlayer=null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void initView() {
|
||||
// 根据不同的用户类型显示不同的界面
|
||||
@@ -314,7 +381,7 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
||||
startType = 1;
|
||||
MvpPre.drawGiftList(giftBagId, userIds, roomId, "1",heart_id);
|
||||
} else {
|
||||
com.hjq.toast.ToastUtils.show("正在抽奖中...");
|
||||
// com.hjq.toast.ToastUtils.show("正在抽奖中...");
|
||||
return;
|
||||
}
|
||||
} else if (id == R.id.ll_ten) {
|
||||
@@ -325,7 +392,7 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
||||
MvpPre.drawGiftList(giftBagId, userIds, roomId, "6",heart_id);
|
||||
|
||||
} else {
|
||||
com.hjq.toast.ToastUtils.show("正在抽奖中...");
|
||||
// com.hjq.toast.ToastUtils.show("正在抽奖中...");
|
||||
}
|
||||
} else if (id == R.id.ll_hundred) {//抽奖100次
|
||||
if (!isDrawing) {
|
||||
@@ -334,12 +401,8 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
||||
startType = 3;
|
||||
MvpPre.drawGiftList(giftBagId, userIds, roomId, "9",heart_id);
|
||||
} else {
|
||||
com.hjq.toast.ToastUtils.show("正在抽奖中...");
|
||||
// com.hjq.toast.ToastUtils.show("正在抽奖中...");
|
||||
}
|
||||
} else if (id == R.id.sw_lock_yx) {//音效
|
||||
isOpenSound = mBinding.mirroeSky.swLockYx.isChecked();
|
||||
} else if (id == R.id.sw_tex) {//特效
|
||||
isOpenSpecial = mBinding.mirroeSky.swTex.isChecked();
|
||||
} else if (id == R.id.tv_gz) {//规则
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", getRule_url);
|
||||
@@ -378,7 +441,8 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
||||
}
|
||||
}
|
||||
} 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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -389,17 +453,17 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
||||
|
||||
if (icon > 0 && box_price > 0) {
|
||||
if (type == 10) {
|
||||
updateBackground(mBinding.mirroeSky.llOne, icon > box_price, 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.llOne, icon >= box_price, drawableX, drawableW);
|
||||
updateBackground(mBinding.mirroeSky.llTen, icon >= box_price * 6, drawableX, drawableW);
|
||||
updateBackground(mBinding.mirroeSky.llHundred, icon >= box_price * 9, drawableX, drawableW);
|
||||
} else if (type == 11) {
|
||||
updateBackground(mBinding.cityTime.llOne, icon > box_price, drawableX, drawableW);
|
||||
updateBackground(mBinding.cityTime.llTen, icon > box_price * 6, drawableX, drawableW);
|
||||
updateBackground(mBinding.cityTime.llOne, icon >= box_price, drawableX, drawableW);
|
||||
updateBackground(mBinding.cityTime.llTen, icon >= box_price * 6, drawableX, drawableW);
|
||||
updateBackground(mBinding.cityTime.llHundred, icon > box_price * 9, drawableX, drawableW);
|
||||
} else if (type == 12) {
|
||||
updateBackground(mBinding.pinnacleTime.llOne, icon > box_price, 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.llOne, icon >= box_price, drawableX, drawableW);
|
||||
updateBackground(mBinding.pinnacleTime.llTen, icon >= box_price * 6, drawableX, drawableW);
|
||||
updateBackground(mBinding.pinnacleTime.llHundred, icon >= box_price * 9, drawableX, drawableW);
|
||||
} else {
|
||||
// 兜底处理:未知 type 时全部设为不可点击 + 默认背景
|
||||
setAllBackgroundToDefault(drawableW);
|
||||
@@ -513,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() {
|
||||
if (allViewsArray.isEmpty()) {
|
||||
@@ -529,9 +606,10 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
||||
|
||||
// 停止之前的定时器
|
||||
stopFastAnimate();
|
||||
|
||||
Log.e("isOpenSound===","isOpenSound111"+isOpenSound);
|
||||
if (isOpenSound) {
|
||||
// 假设此处有播放音乐的逻辑
|
||||
Log.e("isOpenSound===","raw_music.mp");
|
||||
playSound("draw_music.mp3");
|
||||
// isOpenSound=false;
|
||||
}
|
||||
@@ -584,19 +662,17 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
||||
iterator.remove(); // 安全地移除元素
|
||||
finishTargetArrayIndex.add(index);
|
||||
foundTarget = true;
|
||||
if (!isOpenSpecial || !isOpenSound) {
|
||||
playSound("xuanz.mp3");
|
||||
stopPlay();
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
delayTime = 0.03;
|
||||
if (targetArrayIndex.isEmpty()) {
|
||||
|
||||
MvpPre.giftSend(blind_box_turntable_id);
|
||||
MvpPre.wallet();
|
||||
isDrawing = false;
|
||||
playSound("xuanz.mp3");
|
||||
stopFastAnimate();
|
||||
return;
|
||||
}
|
||||
@@ -632,11 +708,11 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
||||
}
|
||||
|
||||
private MediaPlayer player;
|
||||
|
||||
MediaPlayer mediaPlayer ;
|
||||
// 播放音频的方法
|
||||
private void playSound(String fileName) {
|
||||
try {
|
||||
MediaPlayer mediaPlayer = getPlayer(fileName);
|
||||
mediaPlayer = getPlayer(fileName);
|
||||
if (mediaPlayer != null) {
|
||||
if (mediaPlayer.isPlaying()) {
|
||||
mediaPlayer.seekTo(0);
|
||||
@@ -739,7 +815,12 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
||||
}
|
||||
}
|
||||
|
||||
private void UpView(BlindBoxBean.XlhData xlhData) {
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onMessageReceived(BlindBoxBean.XlhData xlhData) {
|
||||
UpView(xlhData);
|
||||
}
|
||||
|
||||
public void UpView(BlindBoxBean.XlhData xlhData) {
|
||||
if (xlhData != null) {
|
||||
this.xlhData = xlhData;
|
||||
int currentNum = xlhData.getCurrent_num();
|
||||
@@ -802,35 +883,53 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
||||
if (blindReslutBean.getBlind_box_turntable_id() != null) {
|
||||
blind_box_turntable_id = blindReslutBean.getBlind_box_turntable_id();
|
||||
}
|
||||
for (int i = 0; i < blindReslutBean.getReslut_list().size(); i++) {
|
||||
BlindReslutBean.ReslutList reslutList = blindReslutBean.getReslut_list().get(i);
|
||||
if (allViewsArray.size()>0) {
|
||||
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++) {
|
||||
if (giftLists.get(j).getGift_id().equals(reslutList.getGift_id() + "")) {
|
||||
targetArrayIndex.add(j);
|
||||
if (j < giftMaxCount) {
|
||||
GiftCardView giftCardView = allViewsArray.get(j);
|
||||
GiftBean giftBean = giftLists.get(j);
|
||||
giftBean.setCount(reslutList.getCount());
|
||||
for (int j = 0; j < giftLists.size(); j++) {
|
||||
if (giftLists.get(j).getGift_id().equals(reslutList.getGift_id() + "")) {
|
||||
targetArrayIndex.add(j);
|
||||
if (j < giftMaxCount) {
|
||||
|
||||
if (!isOpenSpecial || !isOpenSound) {
|
||||
GiftCardView giftCardView = allViewsArray.get(j);
|
||||
GiftBean giftBean = giftLists.get(j);
|
||||
giftBean.setCount(reslutList.getCount());
|
||||
giftCardView.setVisibilitymResultTextView(true);
|
||||
giftCardView.setSelected(true);
|
||||
playSound("xuanz.mp3");
|
||||
// 不要设置isDrawing=true,这会影响动画控制
|
||||
MvpPre.wallet();
|
||||
isDrawing = false;
|
||||
MvpPre.giftSend(blind_box_turntable_id);
|
||||
// MvpPre.wallet();
|
||||
// isDrawing = false;
|
||||
// MvpPre.giftSend(blind_box_turntable_id);
|
||||
|
||||
giftCardView.bindGiftData(giftBean);
|
||||
|
||||
}
|
||||
giftCardView.bindGiftData(giftBean);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isOpenSpecial) {
|
||||
startFastAnimate();
|
||||
if (MvpPre==null){
|
||||
MvpPre = new GiftLotteryPresenter(this, getActivity());
|
||||
}
|
||||
MvpPre.wallet();
|
||||
|
||||
MvpPre.giftSend(blind_box_turntable_id);
|
||||
Log.e("isOpenSound===","isOpenSound1222"+isOpenSound);
|
||||
if (isOpenSpecial) {//特效
|
||||
Log.e("isOpenSound===","isOpenSound333"+isOpenSound);
|
||||
startFastAnimate();
|
||||
}else{
|
||||
if(isOpenSound){//音效
|
||||
isDrawing = false;
|
||||
playSound("xuanz.mp3");
|
||||
}else {
|
||||
isDrawing = false;
|
||||
}
|
||||
}
|
||||
}else {
|
||||
isDrawing = false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -858,12 +957,23 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
||||
? walletBean.getCoin()
|
||||
: "0"
|
||||
);
|
||||
if (type == 10) {
|
||||
mBinding.mirroeSky.tvIcon.setText(walletBean.getCoin());
|
||||
} else if (type == 11) {
|
||||
mBinding.cityTime.tvIcon.setText(walletBean.getCoin());
|
||||
} else if (type == 12) {
|
||||
mBinding.pinnacleTime.tvIcon.setText(walletBean.getCoin());
|
||||
if (isAdded() && getActivity() != null && !getActivity().isFinishing() &&
|
||||
getDialog() != null && getDialog().isShowing()) {
|
||||
if (type == 10) {
|
||||
mBinding.mirroeSky.tvIcon.setText(walletBean.getCoin());
|
||||
} else if (type == 11) {
|
||||
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();
|
||||
@@ -876,17 +986,17 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
||||
}
|
||||
|
||||
// TODO: 2025/8/29 接收im推送过来的消息
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onMusicPlay(RoomMessageEvent message) {
|
||||
if (message.getMsgType() == 1056) {
|
||||
UpView(message.getText().getXlh_data());
|
||||
}
|
||||
}
|
||||
// @Subscribe(threadMode = ThreadMode.MAIN)
|
||||
// public void onMusicPlay(RoomMessageEvent message) {
|
||||
// if (message.getMsgType() == 1056) {
|
||||
// UpView(message.getText().getXlh_data());
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
// releaseResources();
|
||||
releaseResources();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -939,9 +1049,11 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
||||
player.release();
|
||||
player = null;
|
||||
}
|
||||
if (!EventBus.getDefault().isRegistered(this)) {
|
||||
|
||||
if (EventBus.getDefault().isRegistered( this)){
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
|
||||
// 建议进行垃圾回收
|
||||
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.XlhDrawBean;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.http.RetrofitClient;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
@@ -148,6 +149,9 @@ public class GiftLotteryPresenter extends BasePresenter<GiftLotteryContacts.View
|
||||
|
||||
@Override
|
||||
public void xlhChou(String room_id, String num) {
|
||||
if (api==null){
|
||||
api= RetrofitClient.getInstance();
|
||||
}
|
||||
api.xlhChou(room_id,num, new BaseObserver<List<XlhDrawBean>>() {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,46 +1,42 @@
|
||||
package com.xscm.moduleutil.dialog.giftLottery;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.os.CountDownTimer;
|
||||
import android.os.Handler;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
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.Nullable;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearSnapHelper;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
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.base.BaseMvpDialogFragment;
|
||||
import com.xscm.moduleutil.bean.GiftBean;
|
||||
import com.xscm.moduleutil.bean.MqttXlhEnd;
|
||||
import com.xscm.moduleutil.bean.RoomMessageEvent;
|
||||
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.BlindReslutBean;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.XlhDrawBean;
|
||||
import com.xscm.moduleutil.databinding.FragmentTourClubDialogBinding;
|
||||
import com.xscm.moduleutil.dialog.RechargeDialogFragment;
|
||||
import com.xscm.moduleutil.dialog.WebViewDialog;
|
||||
import com.xscm.moduleutil.event.MqttBean;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
import com.xscm.moduleutil.widget.CenterScrollHelper;
|
||||
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.Subscribe;
|
||||
@@ -48,8 +44,12 @@ import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* @author qx
|
||||
* @data 2025/9/15
|
||||
* @description: 玄镜之旅
|
||||
*/
|
||||
public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPresenter, FragmentTourClubDialogBinding> implements GiftLotteryContacts.View {
|
||||
private String roomId;
|
||||
private List<GiftBean> giftLists = new ArrayList<>();
|
||||
@@ -59,6 +59,7 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
|
||||
private String num;
|
||||
private XlhRankingDialog xlhRankingDialog;
|
||||
private XlhRecordDialog xlhRecordDialog;
|
||||
private XlhObtainDialog xlhObtainDialog;
|
||||
|
||||
private GiftXlhChouAdapter giftXlhChouAdapter;
|
||||
private CenterScrollHelper scrollHelper;
|
||||
@@ -75,6 +76,14 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
|
||||
|
||||
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
|
||||
protected GiftLotteryPresenter bindPresenter() {
|
||||
return new GiftLotteryPresenter(this, getActivity());
|
||||
@@ -146,8 +155,7 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
|
||||
mBinding.tvBd.setOnClickListener(this::onClick);
|
||||
mBinding.tvJl.setOnClickListener(this::onClick);
|
||||
mBinding.exchangeLayout.setOnClickListener(this::onClick);
|
||||
|
||||
|
||||
mBinding.vCheckbox.setOnClickListener(this::onClick);
|
||||
giftXlhChouAdapter = new GiftXlhChouAdapter();
|
||||
// 使用 LinearLayoutManager 横向滚动
|
||||
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false);
|
||||
@@ -173,10 +181,75 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
|
||||
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) {
|
||||
int id = view.getId();
|
||||
if (id == R.id.tv_jc) {
|
||||
@@ -194,7 +267,7 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
|
||||
num = "1";
|
||||
MvpPre.xlhChou(roomId, num);
|
||||
} else {
|
||||
com.hjq.toast.ToastUtils.show("正在抽奖中...");
|
||||
// com.hjq.toast.ToastUtils.show("正在抽奖中...");
|
||||
}
|
||||
|
||||
} else if (id == R.id.ll_ten) {
|
||||
@@ -204,7 +277,7 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
|
||||
num = "10";
|
||||
MvpPre.xlhChou(roomId, num);
|
||||
} else {
|
||||
com.hjq.toast.ToastUtils.show("正在抽奖中...");
|
||||
// com.hjq.toast.ToastUtils.show("正在抽奖中...");
|
||||
}
|
||||
|
||||
} else if (id == R.id.ll_hundred) {
|
||||
@@ -214,7 +287,7 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
|
||||
num = "100";
|
||||
MvpPre.xlhChou(roomId, num);
|
||||
} else {
|
||||
com.hjq.toast.ToastUtils.show("正在抽奖中...");
|
||||
// com.hjq.toast.ToastUtils.show("正在抽奖中...");
|
||||
}
|
||||
|
||||
} else if (id == R.id.tv_gz) {
|
||||
@@ -240,7 +313,11 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
|
||||
xlhRecordDialog = XlhRecordDialog.newInstance(roomId);
|
||||
xlhRecordDialog.show(getChildFragmentManager(), "XlhRecordDialog");
|
||||
} 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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,30 +365,53 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
|
||||
}
|
||||
|
||||
giftXlhChouAdapter.setNewData(giftLists);
|
||||
// // 数据加载完成后启动自动滚动
|
||||
// if (giftLists != null && !giftLists.isEmpty()) {
|
||||
// mBinding.recycleView.post(() -> {
|
||||
// // 确保在UI线程中启动自动滚动
|
||||
// startAutoScroll();
|
||||
// });
|
||||
// }
|
||||
|
||||
}else {
|
||||
isDrawing = false;
|
||||
}
|
||||
}
|
||||
|
||||
int mboxPrice;
|
||||
|
||||
// TODO: 2025/9/4 设置底部按钮文字
|
||||
private void upTitle(int boxPrice) {
|
||||
this.mboxPrice = boxPrice;
|
||||
mBinding.tvOne.setText(boxPrice + "币一次");
|
||||
mBinding.tvTen.setText((boxPrice * 10) + "币十次");
|
||||
mBinding.tvHundred.setText((boxPrice * 100) + "币百次");
|
||||
}
|
||||
|
||||
// TODO: 2025/8/29 接收im推送过来的消息
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
// @Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onMusicPlay(RoomMessageEvent message) {
|
||||
if (message.getMsgType() == 1057) {
|
||||
// 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();
|
||||
mBinding.tvGiftCount.setText(message.getText().getGift_num());
|
||||
mBinding.userName.setText(message.getText().getFromUserInfo().getNickname());
|
||||
mBinding.tvGiftCount.setText(message.getText().getGift_num() != null ? message.getText().getGift_num() : "0");
|
||||
mBinding.userName.setText(message.getText().getFromUserInfo().getNickname() != null ? message.getText().getFromUserInfo().getNickname() : "");
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动倒计时
|
||||
*/
|
||||
@@ -407,6 +507,26 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
|
||||
if (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);
|
||||
}
|
||||
|
||||
|
||||
@@ -430,10 +550,37 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
|
||||
|
||||
}
|
||||
|
||||
private int icon;
|
||||
|
||||
@Override
|
||||
public void wallet(WalletBean walletBean) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -443,72 +590,85 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
|
||||
@Override
|
||||
public void xlhChouSuccess(List<XlhDrawBean> data) {
|
||||
if (data != null) {
|
||||
if (vCheckbox){
|
||||
showResultDialog(data);
|
||||
}else {
|
||||
// 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();
|
||||
// 抽奖完成后执行动画滚动
|
||||
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);
|
||||
}
|
||||
|
||||
// 计算在循环列表中的目标位置(滚动几圈后停在目标位置)
|
||||
int loopCount = 4; // 滚动4圈
|
||||
int originalSize = giftLists.size();///这是列表的总大小
|
||||
// 计算目标在循环列表中的位置(确保在中间区域)
|
||||
///这是计算总圈数的大小
|
||||
int middleBaseIndex = (loopCount * originalSize);
|
||||
///这里是展示在中奖的位置,加上总圈数的大小,
|
||||
int targetLoopIndex = middleBaseIndex + (winningPosition % originalSize);
|
||||
// 计算在循环列表中的目标位置(滚动几圈后停在目标位置)
|
||||
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);
|
||||
});
|
||||
// 使用scrollWithCircles方法执行带动画的滚动(带完成回调)
|
||||
scrollHelper.scrollWithCircles(
|
||||
targetLoopIndex, // 在循环列表中的位置
|
||||
loopCount, // 滚动圈数
|
||||
1000, // 每个item滚动时间200ms(控制速度)
|
||||
originalSize, // 原始数据大小
|
||||
() -> { // 滚动完成回调
|
||||
// 滚动完成后更新选中状态(使用原始位置)
|
||||
if (giftXlhChouAdapter != null) {
|
||||
giftXlhChouAdapter.setSelectedPosition(winningPosition);
|
||||
}
|
||||
};
|
||||
mBinding.recycleView.postDelayed(pendingCenteringRunnable, 100);
|
||||
}
|
||||
);
|
||||
// 滚动完成后延迟一小段时间再居中,确保UI更新完成
|
||||
pendingCenteringRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// 手动将选中项居中
|
||||
centerSelectedItem(winningPosition, originalSize);
|
||||
|
||||
} else {
|
||||
// 如果没有找到中奖位置,直接显示对话框
|
||||
showResultDialog(data);
|
||||
// 显示结果对话框
|
||||
getActivity().runOnUiThread(() -> {
|
||||
scrollHelper = null;
|
||||
showResultDialog(data);
|
||||
// 抽奖结束后重新启动自动滚动
|
||||
// resumeAutoScrollAfterLottery();
|
||||
});
|
||||
}
|
||||
};
|
||||
mBinding.recycleView.postDelayed(pendingCenteringRunnable, 1000);
|
||||
}
|
||||
);
|
||||
|
||||
} else {
|
||||
// 如果没有找到中奖位置,直接显示对话框
|
||||
showResultDialog(data);
|
||||
// 抽奖结束后重新启动自动滚动
|
||||
// resumeAutoScrollAfterLottery();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
mBinding.recycleView.postDelayed(pendingLotteryRunnable, 300);
|
||||
|
||||
};
|
||||
mBinding.recycleView.postDelayed(pendingLotteryRunnable, 1000);
|
||||
|
||||
}
|
||||
}else {
|
||||
isDrawing=false;
|
||||
// 抽奖失败也重新启动自动滚动
|
||||
// resumeAutoScrollAfterLottery();
|
||||
}
|
||||
MvpPre.wallet();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -516,6 +676,10 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
|
||||
* 为新的抽奖做准备,清理之前的状态
|
||||
*/
|
||||
private void prepareForNewLottery() {
|
||||
|
||||
// 停止自动滚动
|
||||
stopAutoScroll();
|
||||
|
||||
// 取消之前可能存在的任务
|
||||
clearPendingTasks();
|
||||
|
||||
@@ -678,7 +842,6 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将指定的原始位置item居中显示
|
||||
*
|
||||
@@ -799,14 +962,19 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
|
||||
* @param 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
|
||||
public void onPlayAgainClick() {
|
||||
isDrawing=true;
|
||||
isDrawing = true;
|
||||
// 处理再玩一次点击事件
|
||||
MvpPre.xlhChou(roomId, num);
|
||||
}
|
||||
@@ -814,12 +982,16 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
|
||||
@Override
|
||||
public void onCloseClick() {
|
||||
// 处理关闭点击事件
|
||||
dialog.dismiss();
|
||||
if (xlhObtainDialog != null && xlhObtainDialog.isShowing()) {
|
||||
isDrawing = false;
|
||||
xlhObtainDialog.dismiss();
|
||||
}
|
||||
xlhObtainDialog = null;
|
||||
}
|
||||
});
|
||||
|
||||
dialog.show();
|
||||
dialog.setGiftList(data);
|
||||
xlhObtainDialog.show();
|
||||
xlhObtainDialog.setGiftList(data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.xscm.moduleutil.dialog.giftLottery;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.Gravity;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
@@ -53,6 +54,13 @@ public class XlhObtainDialog extends BaseDialog<DialogXlhObtainBinding> {
|
||||
setCancelable(false);
|
||||
setCanceledOnTouchOutside(false);
|
||||
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);
|
||||
// 设置点击事件
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
@@ -10,7 +21,8 @@ import lombok.Data;
|
||||
@Data
|
||||
public class MqttBean {
|
||||
private String room_id;
|
||||
private ListBean list;
|
||||
@JsonAdapter(ListBeanListAdapter.class)
|
||||
private List<ListBean> list;
|
||||
|
||||
public String getRoom_id() {
|
||||
return room_id == null ? "" : room_id;
|
||||
@@ -20,14 +32,58 @@ public class MqttBean {
|
||||
this.room_id = room_id == null ? "" : room_id;
|
||||
}
|
||||
|
||||
public ListBean getList() {
|
||||
public List<ListBean> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
public void setList(ListBean list) {
|
||||
public void setList(List<ListBean> 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
|
||||
public static class ListBean {
|
||||
private String text;
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.xscm.moduleutil.event;
|
||||
|
||||
public enum QXRoomSeatViewType {
|
||||
/**
|
||||
* 无类型
|
||||
*/
|
||||
NONE(0, "无类型"),
|
||||
|
||||
/**
|
||||
* 普通麦位(二卡八麦)
|
||||
*/
|
||||
NORMAL(1, "点唱"),
|
||||
|
||||
KTV(3,"K歌"),
|
||||
|
||||
/**
|
||||
* 拍卖麦位
|
||||
*/
|
||||
AUCTION(2, "拍卖麦位"),
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 小黑屋麦位
|
||||
*/
|
||||
CABIN(6, "小黑屋麦位"),
|
||||
|
||||
/**
|
||||
* 交友房麦位
|
||||
*/
|
||||
FRIEND(7, "交友房麦位");
|
||||
|
||||
private final int value;
|
||||
private final String description;
|
||||
|
||||
QXRoomSeatViewType(int value, String description) {
|
||||
this.value = value;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public static QXRoomSeatViewType fromLotteryEvent(int value) {
|
||||
if (value==1) {
|
||||
return NORMAL;
|
||||
}
|
||||
if (value==2) {
|
||||
return AUCTION;
|
||||
}
|
||||
if (value==3) {
|
||||
return KTV;
|
||||
}
|
||||
|
||||
if (value==6){
|
||||
return CABIN;
|
||||
}
|
||||
if (value==7){
|
||||
return FRIEND;
|
||||
}
|
||||
return NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "QXRoomSeatViewType{" +
|
||||
"value=" + value +
|
||||
", description='" + description + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,8 +9,18 @@ import lombok.Data;
|
||||
@Data
|
||||
public class UnreadCountEvent {
|
||||
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.AppUpdateModel;
|
||||
import com.xscm.moduleutil.bean.BannerModel;
|
||||
import com.xscm.moduleutil.bean.BindDetail;
|
||||
import com.xscm.moduleutil.bean.BindType;
|
||||
import com.xscm.moduleutil.bean.BlackUserBean;
|
||||
import com.xscm.moduleutil.bean.CharmRankingResp;
|
||||
@@ -18,6 +19,7 @@ import com.xscm.moduleutil.bean.GiftBoxRecordBean;
|
||||
import com.xscm.moduleutil.bean.GiftLabelBean;
|
||||
import com.xscm.moduleutil.bean.GiftName;
|
||||
import com.xscm.moduleutil.bean.GiftPackBean;
|
||||
import com.xscm.moduleutil.bean.GiftPackListCount;
|
||||
import com.xscm.moduleutil.bean.GiftUserWallBean;
|
||||
import com.xscm.moduleutil.bean.HeadlineBean;
|
||||
import com.xscm.moduleutil.bean.HeatedBean;
|
||||
@@ -90,7 +92,7 @@ public interface ApiServer {
|
||||
|
||||
@FormUrlEncoded
|
||||
@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 //手机换绑
|
||||
@POST(Constants.MODIFY_MOBILE)
|
||||
@@ -164,13 +166,17 @@ public interface ApiServer {
|
||||
@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);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_BIND_DETAIL)
|
||||
Call<BaseModel<BindDetail>> bindDetai(@Field("user_id") String user_id, @Field("type") String type);
|
||||
|
||||
@FormUrlEncoded
|
||||
@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
|
||||
@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
|
||||
@POST(Constants.POST_ROOM_RANKING)
|
||||
@@ -181,19 +187,19 @@ public interface ApiServer {
|
||||
Observable<BaseModel<PlaceholderBean>> loveRanking(@Field("type") String type);
|
||||
|
||||
@GET(Constants.GET_REAL_NAME)
|
||||
Observable<BaseModel<RealNameBean>> realNameInfo();
|
||||
Call<BaseModel<RealNameBean>> realNameInfo();
|
||||
|
||||
@GET(Constants.GET_DAILY_TASK_BOX)
|
||||
Observable<BaseModel<List<GiftBoxRecordBean>>> dailyTasksBoxRecord();
|
||||
Call<BaseModel<List<GiftBoxRecordBean>>> dailyTasksBoxRecord();
|
||||
|
||||
@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)
|
||||
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)
|
||||
Observable<BaseModel<List<GiftPackBean>>> giftPack();
|
||||
Call<BaseModel<List<GiftPackBean>>> giftPack();
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.ADD_BLACK_LIST)
|
||||
@@ -212,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);
|
||||
|
||||
@GET(Constants.GET_RECHARGE)
|
||||
Observable<BaseModel<List<RechargeBean>>> recharge();
|
||||
Call<BaseModel<List<RechargeBean>>> recharge();
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_START_PK)
|
||||
@@ -220,11 +226,11 @@ public interface ApiServer {
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.UPLOAD_USER_PIC)
|
||||
Call<BaseModel<String>> upUserPic(@Field("sex") String sex);
|
||||
Call<ResponseBody> upUserPic(@Field("sex") String sex);
|
||||
|
||||
@FormUrlEncoded
|
||||
@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
|
||||
@POST(Constants.FORGOT_PASSWORD)
|
||||
@@ -232,7 +238,7 @@ public interface ApiServer {
|
||||
|
||||
@FormUrlEncoded
|
||||
@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)
|
||||
Call<ResponseBody> authorization();
|
||||
@@ -262,18 +268,18 @@ public interface ApiServer {
|
||||
|
||||
@FormUrlEncoded
|
||||
@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
|
||||
@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)
|
||||
Observable<BaseModel<NewsDataBean>> getOfficialNotice();
|
||||
Call<BaseModel<NewsDataBean>> getOfficialNotice();
|
||||
|
||||
@FormUrlEncoded
|
||||
@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
|
||||
@POST(Constants.CREATE_ALBUM)
|
||||
@@ -288,19 +294,19 @@ public interface ApiServer {
|
||||
|
||||
@FormUrlEncoded
|
||||
@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
|
||||
@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
|
||||
@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
|
||||
@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
|
||||
@POST(Constants.GET_MY_ROOM)
|
||||
@@ -315,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);
|
||||
|
||||
@GET(Constants.GET_ROOM_TYPE)
|
||||
Observable<BaseModel<List<RoomTypeModel>>> getRoomCategories();
|
||||
Call<BaseModel<List<RoomTypeModel>>> getRoomCategories();
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.CHECK_TXT)
|
||||
@@ -323,35 +329,35 @@ public interface ApiServer {
|
||||
|
||||
@FormUrlEncoded
|
||||
@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)
|
||||
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)
|
||||
//获取礼物列表
|
||||
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)
|
||||
//获取话题
|
||||
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
|
||||
@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);
|
||||
|
||||
@GET(Constants.GET_CATEGORIES)
|
||||
Observable<BaseModel<List<HeatedBean>>> getCategories();
|
||||
Call<BaseModel<List<HeatedBean>>> getCategories();
|
||||
|
||||
@GET(Constants.GET_CIRCLE_LIST)
|
||||
Call<BaseModel<List<CircleListBean>>> getCircleList(@Query("page") String page, @Query("page_limit") String page_limit);
|
||||
|
||||
@FormUrlEncoded
|
||||
@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)
|
||||
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
|
||||
@POST(Constants.LIKE_ZONE)
|
||||
@@ -359,15 +365,15 @@ public interface ApiServer {
|
||||
|
||||
@FormUrlEncoded
|
||||
@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
|
||||
@POST(Constants.ZONE_DETAIL)
|
||||
Observable<BaseModel<CircleListBean>> zoneDetail(@Field("id") String topic_id);
|
||||
Call<BaseModel<CircleListBean>> zoneDetail(@Field("id") String topic_id);
|
||||
|
||||
@FormUrlEncoded
|
||||
@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
|
||||
@POST(Constants.DELETE_COMMENT)
|
||||
@@ -375,11 +381,11 @@ public interface ApiServer {
|
||||
|
||||
@FormUrlEncoded
|
||||
@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
|
||||
@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
|
||||
@POST(Constants.COMMENT_ZONE)
|
||||
@@ -402,7 +408,7 @@ public interface ApiServer {
|
||||
Call<BaseModel<String>> deleteZone(@Field("id") String id);
|
||||
|
||||
@GET(Constants.GET_MY_INFO)
|
||||
Observable<BaseModel<UserInfo>> getMyInfo();
|
||||
Call<BaseModel<UserInfo>> getMyInfo();
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.ED_USER_INFO)
|
||||
@@ -413,25 +419,25 @@ public interface ApiServer {
|
||||
Call<BaseModel<String>> editUserBg(@Field("images") String images);
|
||||
|
||||
@GET(Constants.GET_USER_TAG_LIST)
|
||||
Observable<BaseModel<List<UserTagBean>>> getUserTagList();
|
||||
Call<BaseModel<List<UserTagBean>>> getUserTagList();
|
||||
|
||||
@FormUrlEncoded
|
||||
@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
|
||||
@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)
|
||||
Observable<BaseModel<List<PersonaltyBean>>> getPersonaltyList();
|
||||
Call<BaseModel<List<PersonaltyBean>>> getPersonaltyList();
|
||||
|
||||
@FormUrlEncoded
|
||||
@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)
|
||||
Observable<BaseModel<List<ZhuangBanShangChengBean>>> getDecorateList(@Query("type") String type);
|
||||
Call<BaseModel<List<ZhuangBanShangChengBean>>> getDecorateList(@Query("type") String type);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_GZ)
|
||||
@@ -476,7 +482,7 @@ public interface ApiServer {
|
||||
|
||||
@FormUrlEncoded
|
||||
@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
|
||||
@POST(Constants.DELETE_ALBUM_IMAGE)
|
||||
@@ -496,11 +502,11 @@ public interface ApiServer {
|
||||
|
||||
@FormUrlEncoded
|
||||
@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
|
||||
@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
|
||||
@POST(Constants.GET_GIVE_GIFT)
|
||||
@@ -511,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);
|
||||
|
||||
@GET(Constants.GET_FIRST_CHARGE_GIFT)
|
||||
Observable<BaseModel<FirstChargeGiftBean>> firstChargeGift();
|
||||
Call<BaseModel<FirstChargeGiftBean>> firstChargeGift();
|
||||
|
||||
@GET(Constants.GET_WALLET)
|
||||
Observable<BaseModel<WalletBean>> wallet();
|
||||
Call<BaseModel<WalletBean>> wallet();
|
||||
|
||||
@FormUrlEncoded
|
||||
@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
|
||||
@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
|
||||
@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
|
||||
@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)
|
||||
Observable<BaseModel<WalletConfig>> getWalletConfig();
|
||||
Call<BaseModel<WalletConfig>> getWalletConfig();
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_BIND)
|
||||
@@ -541,7 +547,7 @@ public interface ApiServer {
|
||||
|
||||
@FormUrlEncoded
|
||||
@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
|
||||
@POST(Constants.APPLY_PIT)
|
||||
@@ -625,23 +631,23 @@ public interface ApiServer {
|
||||
|
||||
@FormUrlEncoded
|
||||
@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
|
||||
@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
|
||||
@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
|
||||
@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
|
||||
@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
|
||||
@POST(Constants.SET_PRESIDED_RATIO)
|
||||
@@ -669,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);
|
||||
|
||||
@GET(Constants.GET_ROOM_BJ)
|
||||
Observable<BaseModel<RoomBgBean>> getBackgroundList();
|
||||
Call<BaseModel<RoomBgBean>> getBackgroundList();
|
||||
|
||||
@FormUrlEncoded
|
||||
@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
|
||||
@POST(Constants.POST_SET_UPLOAD_BG_IMG)
|
||||
@@ -706,7 +712,7 @@ public interface ApiServer {
|
||||
|
||||
@FormUrlEncoded
|
||||
@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
|
||||
@POST(Constants.POST_TOP_RELATION_CARD)
|
||||
@@ -719,11 +725,11 @@ public interface ApiServer {
|
||||
|
||||
@FormUrlEncoded
|
||||
@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
|
||||
@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
|
||||
@POST(Constants.POST_ROOM_AUCTION_JOIN)
|
||||
@@ -732,7 +738,7 @@ public interface ApiServer {
|
||||
|
||||
@FormUrlEncoded
|
||||
@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)
|
||||
Call<BaseModel<BlindBoxBean>> getBoxGiftList(@Query("gift_bag_id") String gift_bag_id, @Query("room_id") String room_id);
|
||||
@@ -767,10 +773,17 @@ public interface ApiServer {
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_GIFT_ALL_CLEAR)
|
||||
Call<BaseModel<String>> getGiftPack(@Field("room_id") String roomId,@Field("to_uid") String user_id,@Field("heart_id") String heart_id);
|
||||
Call<BaseModel<String>> getGiftPack(@Field("room_id") String roomId,@Field("to_uid") String user_id,@Field("heart_id") String heart_id,@Field("auction_id") String auction_id);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_ROOM_USER_CHARM_LIST)
|
||||
Call<BaseModel<List<RoomUserCharmListBean>>> roomUserCharmList(@Field("room_id") String roomId,@Field("user_id") String user_id);
|
||||
|
||||
@GET(Constants.GET_GIFT_PACK_LIST_COUNT)
|
||||
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) {
|
||||
APIException apiException = (APIException) e;
|
||||
if (apiException.getCode() == 301) {
|
||||
EventBus.getDefault().post(new LogOutEvent());
|
||||
|
||||
try {
|
||||
ToastUtils.show(extractChinese(apiException.getMessage()));
|
||||
// com.blankj.utilcode.util.ToastUtils.showShort("提示当前账号已在别的地方登陆,如果不是本人操作请修改密码");
|
||||
EventBus.getDefault().post(new LogOutEvent());
|
||||
CommonAppContext.getInstance().clearLoginInfo();
|
||||
} catch (ClassNotFoundException 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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.ObservableSource;
|
||||
import io.reactivex.ObservableTransformer;
|
||||
@@ -23,16 +27,27 @@ public class DefaultTransformer<T> implements ObservableTransformer<BaseModel<T>
|
||||
return upstream
|
||||
.map(response -> {
|
||||
if (response.isTokenExpired()) {
|
||||
// 触发登出事件(EventBus)
|
||||
CommonAppContext.getInstance().clearLoginInfo();
|
||||
throw new APIException(-1, "登录已过期");
|
||||
if (response.getCode()==301){
|
||||
CommonAppContext.getInstance().clearLoginInfo();
|
||||
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()) {
|
||||
throw new APIException(response.getCode(), response.getMsg());
|
||||
}
|
||||
|
||||
return response.getData();
|
||||
// 确保不会返回null值
|
||||
T data = response.getData();
|
||||
if (data == null) {
|
||||
return getDefaultValue();
|
||||
}
|
||||
return data;
|
||||
// return response.getData();
|
||||
})
|
||||
.onErrorResumeNext(throwable -> {
|
||||
// 可以在这里统一处理异常
|
||||
@@ -44,4 +59,32 @@ public class DefaultTransformer<T> implements ObservableTransformer<BaseModel<T>
|
||||
.subscribeOn(Schedulers.io())
|
||||
.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.google.gson.Gson;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.xscm.moduleutil.utils.GsonUtils;
|
||||
|
||||
@@ -25,21 +26,76 @@ public class ResponseBodyConverter<T> implements Converter<ResponseBody, T> {
|
||||
@Override
|
||||
public T convert(@NonNull ResponseBody value) throws IOException {
|
||||
String json = value.string();
|
||||
BaseModel obj = GsonUtils.GsonToBean(json, BaseModel.class);
|
||||
if (obj.getCode() != 1) {
|
||||
String info = obj.getMsg();
|
||||
if ("当前余额不足".equals(info)) {
|
||||
value.close();
|
||||
return adapter.fromJson(json);
|
||||
} else {
|
||||
if(!info.contains("更新失败")) {
|
||||
ToastUtils.showShort(info);
|
||||
}
|
||||
try {
|
||||
BaseModel obj = GsonUtils.GsonToBean(json, BaseModel.class);
|
||||
if (obj.getCode() != 1) {
|
||||
String info = obj.getMsg();
|
||||
if ("当前余额不足".equals(info)) {
|
||||
value.close();
|
||||
return parseDataSafely(json);
|
||||
} else {
|
||||
if (!info.contains("更新失败")) {
|
||||
// ToastUtils.showShort(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;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.blankj.utilcode.util.GsonUtils;
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.bean.HeadlineBean;
|
||||
import com.xscm.moduleutil.bean.RoomMessageEvent;
|
||||
import com.xscm.moduleutil.bean.room.EMMessageInfo;
|
||||
@@ -29,6 +33,10 @@ import org.greenrobot.eventbus.EventBus;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
/**
|
||||
* @author qx
|
||||
@@ -42,9 +50,20 @@ public class MessageListenerSingleton {
|
||||
private V2TIMSimpleMsgListener simpleMsgListener;
|
||||
private V2TIMAdvancedMsgListener v2TIMAdvancedMsgListener;
|
||||
private static String mRoomId = "";
|
||||
public static String groupId;
|
||||
private V2TIMGroupListener groupListener;
|
||||
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; // 标记监听器是否已添加
|
||||
// 1. 添加新的监听器接口
|
||||
public interface PublicScreenMessageListener {
|
||||
@@ -78,39 +97,293 @@ public class MessageListenerSingleton {
|
||||
return instance;
|
||||
}
|
||||
|
||||
// 修改 joinGroup 方法
|
||||
public void joinGroup(String roomId) {
|
||||
mRoomId = roomId;
|
||||
LogUtils.e("@@@", "加入房间的"+roomId);
|
||||
// 确保监听器已初始化并添加
|
||||
ensureListenersAdded();
|
||||
// RoomMessageEvent.T t = new RoomMessageEvent.T();
|
||||
// t.setText("羽声严禁未成年人进行直播或打赏,官方将24小时在线巡查。我们提倡绿色直播,直播间严禁出现涉政、涉恐、涉黄、涉赌等违法违规内容,严禁宣传封建迷信、宗教极端思想、出现低俗色情、吸烟酗酒等内容,严禁违反社会主义核心价值观、践踏社会道德底线、诱导打赏、低俗 PK 、买卖金币等行为,请大家共同遵守、监督并及时举报。请勿相信各类刷钻、购买礼包、游戏币及电商贩卖等非官方广告信息,谨防网络诈骗。");
|
||||
// notifyMessageReceived(new RoomMessageEvent(1000, mRoomId, t));
|
||||
V2TIMManager.getInstance().joinGroup("room" + mRoomId, "申请加入", new V2TIMCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
Log.d("@@@", "加入im群组成功:");
|
||||
}
|
||||
/**
|
||||
* 缓存消息(用于在Fragment未准备好时存储消息)
|
||||
*/
|
||||
private void cacheMessage(String roomId, RoomMessageEvent message) {
|
||||
if (TextUtils.isEmpty(roomId) || message == null) {
|
||||
return;
|
||||
}
|
||||
// 标记该房间有待处理的消息
|
||||
List<RoomMessageEvent> roomMessages = cachedMessages.computeIfAbsent(roomId, k -> new ArrayList<>());
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
Log.d("@@@", "加入群组失败:" + code + "=" + desc);
|
||||
}
|
||||
});
|
||||
// 限制每个房间的缓存消息数量
|
||||
if (roomMessages.size() >= MAX_CACHED_MESSAGES) {
|
||||
roomMessages.remove(0); // 移除最旧的消息
|
||||
}
|
||||
|
||||
if (tempGroupJoinListener == null) {
|
||||
tempGroupJoinListener = new OnMessageReceivedListener() {
|
||||
@Override
|
||||
public void onMessageReceived(RoomMessageEvent message) {
|
||||
// 处理消息
|
||||
roomMessages.add(message);
|
||||
LogUtils.d("MessageListener", "缓存消息: roomId=" + roomId + ", msgType=" + message.getMsgType());
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
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() {
|
||||
// 简单消息监听器
|
||||
if (simpleMsgListener == null) {
|
||||
@@ -240,7 +513,15 @@ public class MessageListenerSingleton {
|
||||
@Override
|
||||
public void onTotalUnreadMessageCountChanged(long 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 方法
|
||||
public static void quitGroup(String mRoomId) {
|
||||
|
||||
V2TIMManager.getInstance().quitGroup("room" + mRoomId, new V2TIMCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
LogUtils.d("@@@","退出群组成功"+mRoomId);
|
||||
LogUtils.d("@@@", "退出群组成功" + mRoomId);
|
||||
// removeAllListeners(); // 移除所有监听器
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
LogUtils.d("@@@","退出群组失败"+mRoomId, code, desc);
|
||||
LogUtils.d("@@@", "退出群组失败" + mRoomId, code, desc);
|
||||
// removeAllListeners(); // 即使失败也移除监听器
|
||||
}
|
||||
});
|
||||
|
||||
if (instance != null) {
|
||||
instance.listeners.clear();
|
||||
removeAllListeners();
|
||||
isInitialized = false;
|
||||
groupId = null;
|
||||
LogUtils.e("@@@", "重置成功");
|
||||
}
|
||||
}
|
||||
|
||||
// 修改 reset 方法
|
||||
@@ -311,9 +601,10 @@ public class MessageListenerSingleton {
|
||||
instance.listeners.clear();
|
||||
removeAllListeners();
|
||||
isInitialized = false;
|
||||
groupId = null;
|
||||
// instance = null;
|
||||
quitGroup(roomId);
|
||||
LogUtils.e("@@@","重置成功");
|
||||
LogUtils.e("@@@", "重置成功");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -634,6 +925,11 @@ public class MessageListenerSingleton {
|
||||
// for (OnMessageReceivedListener listener : listeners) {
|
||||
// listener.onMessageReceived(message);
|
||||
// }
|
||||
|
||||
if (message.getMsgType() == 1001 && publicScreenListeners.isEmpty()) {
|
||||
cacheMessage(message.getRoomId(), message);
|
||||
}
|
||||
|
||||
// 通知原有的监听器
|
||||
for (OnMessageReceivedListener listener : listeners) {
|
||||
listener.onMessageReceived(message);
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.GiftLabelBean;
|
||||
import com.xscm.moduleutil.bean.GiftPackBean;
|
||||
import com.xscm.moduleutil.bean.GiftPackListCount;
|
||||
import com.xscm.moduleutil.bean.RewardUserBean;
|
||||
import com.xscm.moduleutil.bean.RoonGiftModel;
|
||||
import com.xscm.moduleutil.bean.WalletBean;
|
||||
@@ -29,6 +30,8 @@ public class RewardGiftContacts {
|
||||
void giftPack(List<GiftPackBean> giftPackBean);
|
||||
|
||||
void getGiftPack(String s);
|
||||
|
||||
void getGiftPackListCount(GiftPackListCount giftPackListCount);
|
||||
}
|
||||
|
||||
public interface IIndexPre extends IPresenter {
|
||||
@@ -51,6 +54,8 @@ public class RewardGiftContacts {
|
||||
void roomAuctionJoin(String auction_id,String user_id, String gift_id, String num,String type);
|
||||
void giftPack();
|
||||
|
||||
void getGiftPack(String roomId,String userId,String heart_id);
|
||||
void getGiftPack(String roomId,String userId,String heart_id,String auction_id );
|
||||
|
||||
void getGiftPackListCount();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.content.Context;
|
||||
|
||||
import com.xscm.moduleutil.bean.GiftLabelBean;
|
||||
import com.xscm.moduleutil.bean.GiftPackBean;
|
||||
import com.xscm.moduleutil.bean.GiftPackListCount;
|
||||
import com.xscm.moduleutil.bean.RewardUserBean;
|
||||
import com.xscm.moduleutil.bean.RoonGiftModel;
|
||||
import com.xscm.moduleutil.bean.WalletBean;
|
||||
@@ -17,6 +18,7 @@ import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class RewardGiftPresenter extends BasePresenter<RewardGiftContacts.View> implements RewardGiftContacts.IIndexPre {
|
||||
RewardGiftContacts.View mView;
|
||||
|
||||
public RewardGiftPresenter(RewardGiftContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
mView = view;
|
||||
@@ -32,7 +34,7 @@ public class RewardGiftPresenter extends BasePresenter<RewardGiftContacts.View>
|
||||
|
||||
@Override
|
||||
public void onNext(List<RewardUserBean> rewardUserBeans) {
|
||||
if (MvpRef==null){
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().getRewardList(rewardUserBeans);
|
||||
@@ -51,7 +53,7 @@ public class RewardGiftPresenter extends BasePresenter<RewardGiftContacts.View>
|
||||
|
||||
@Override
|
||||
public void onNext(List<GiftLabelBean> giftLabelBeans) {
|
||||
if (MvpRef==null){
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().getGiftLabel(giftLabelBeans);
|
||||
@@ -61,8 +63,8 @@ public class RewardGiftPresenter extends BasePresenter<RewardGiftContacts.View>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGiftList(String id, int type,String roomId) {
|
||||
api.getGiftList(Integer.parseInt(id),roomId, new BaseObserver<List<RoonGiftModel>>() {
|
||||
public void getGiftList(String id, int type, String roomId) {
|
||||
api.getGiftList(Integer.parseInt(id), roomId, new BaseObserver<List<RoonGiftModel>>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
@@ -71,7 +73,7 @@ public class RewardGiftPresenter extends BasePresenter<RewardGiftContacts.View>
|
||||
|
||||
@Override
|
||||
public void onNext(List<RoonGiftModel> roonGiftModels) {
|
||||
if (MvpRef==null){
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().setGiftList(roonGiftModels, type);
|
||||
@@ -90,7 +92,7 @@ public class RewardGiftPresenter extends BasePresenter<RewardGiftContacts.View>
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().giveGift();
|
||||
@@ -99,8 +101,8 @@ public class RewardGiftPresenter extends BasePresenter<RewardGiftContacts.View>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void roomGift(String room_id, String gift_id, String gift_num, String to_uid, String type, String pit_number,String heart_id) {
|
||||
api.roomGift(room_id, gift_id, gift_num, to_uid, type, pit_number,heart_id, new BaseObserver<String>() {
|
||||
public void roomGift(String room_id, String gift_id, String gift_num, String to_uid, String type, String pit_number, String heart_id) {
|
||||
api.roomGift(room_id, gift_id, gift_num, to_uid, type, pit_number, heart_id, new BaseObserver<String>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
@@ -109,7 +111,7 @@ public class RewardGiftPresenter extends BasePresenter<RewardGiftContacts.View>
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().giveGift();
|
||||
@@ -127,7 +129,7 @@ public class RewardGiftPresenter extends BasePresenter<RewardGiftContacts.View>
|
||||
|
||||
@Override
|
||||
public void onNext(WalletBean walletBean) {
|
||||
if (MvpRef==null){
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().wallet(walletBean);
|
||||
@@ -146,7 +148,7 @@ public class RewardGiftPresenter extends BasePresenter<RewardGiftContacts.View>
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().reward_zone();
|
||||
@@ -164,7 +166,7 @@ public class RewardGiftPresenter extends BasePresenter<RewardGiftContacts.View>
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().reward_zone();
|
||||
@@ -182,7 +184,7 @@ public class RewardGiftPresenter extends BasePresenter<RewardGiftContacts.View>
|
||||
|
||||
@Override
|
||||
public void onNext(RoomAuction.AuctionListBean auctionListBean) {
|
||||
if (MvpRef==null){
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().roomAuctionJoin(auctionListBean);
|
||||
@@ -201,7 +203,7 @@ public class RewardGiftPresenter extends BasePresenter<RewardGiftContacts.View>
|
||||
|
||||
@Override
|
||||
public void onNext(List<GiftPackBean> giftPackBeans) {
|
||||
if (MvpRef==null){
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().giftPack(giftPackBeans);
|
||||
@@ -210,8 +212,8 @@ public class RewardGiftPresenter extends BasePresenter<RewardGiftContacts.View>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGiftPack(String roomId,String userId,String heart_id) {
|
||||
api.getGiftPack(roomId,userId,heart_id, new BaseObserver<String>() {
|
||||
public void getGiftPack(String roomId, String userId, String heart_id, String auction_id) {
|
||||
api.getGiftPack(roomId, userId, heart_id, auction_id, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
@@ -219,15 +221,33 @@ public class RewardGiftPresenter extends BasePresenter<RewardGiftContacts.View>
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
if (s==null){
|
||||
if (s == null) {
|
||||
MvpRef.get().getGiftPack(null);
|
||||
}else {
|
||||
} else {
|
||||
MvpRef.get().getGiftPack(s);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGiftPackListCount() {
|
||||
api.getGiftPackListCount(new BaseObserver<GiftPackListCount>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(GiftPackListCount giftPackListCount) {
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().getGiftPackListCount(giftPackListCount);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.JSONObject;
|
||||
import com.blankj.utilcode.util.GsonUtils;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.orhanobut.logger.Logger;
|
||||
import com.xscm.moduleutil.bean.MqttXlhEnd;
|
||||
import com.xscm.moduleutil.bean.XLHBean;
|
||||
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.MqttCallback;
|
||||
@@ -78,6 +81,20 @@ public class MqttInitCallback implements MqttCallback {
|
||||
case 5019://推送所有人-横幅礼物通知
|
||||
new RoomGiftRunable(message).run();
|
||||
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);
|
||||
// 将事件处理放到主线程执行
|
||||
new Handler(Looper.getMainLooper()).post(() -> {
|
||||
// processMessageType(type, message);
|
||||
processMessageType(type, message);
|
||||
EventBus.getDefault().post(xlhBean);
|
||||
});
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -9,6 +9,7 @@ public class ARouteConstants {
|
||||
public static final String USER_ALBUM_DETAIL = "/modulevocal/AlbumDetailActivity";
|
||||
public static final String CREATE_ALBUM = "/modulevocal/CreateAlbumActivity";
|
||||
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_DETAILS = "/modulevocal/RoomDetailsActivity";
|
||||
|
||||
@@ -5,7 +5,7 @@ package com.xscm.moduleutil.utils;
|
||||
*@description: 防止重复点击的工具类
|
||||
*/
|
||||
public class ClickUtils {
|
||||
private static final long CLICK_INTERVAL = 500; // 500ms内不允许重复点击
|
||||
private static final long CLICK_INTERVAL = 1000; // 1000ms内不允许重复点击
|
||||
private static long lastClickTime = 0;
|
||||
|
||||
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 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);
|
||||
}
|
||||
|
||||
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() {
|
||||
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);
|
||||
}
|
||||
|
||||
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) {
|
||||
SPUtils.getInstance(SPConstants.PREFERENCE_NAME).put(SPConstants.OPEN_AU_BACK, i);
|
||||
|
||||
@@ -13,22 +13,22 @@ public enum EnvironmentEnum {
|
||||
1600101474,
|
||||
"a3f0f0c78307434fa1c697c3429fbdcf",
|
||||
"tcp://81.70.45.221",
|
||||
"https://mdh.xscmmidi.site"),
|
||||
"https://md.xscmmidi.site/h5"),
|
||||
TEST(//测试环境
|
||||
"http://md.qxmier.com/",
|
||||
"http://tmd.xscmmidi.site/",
|
||||
"6rdWuz058oq5OahdbFiGEybUcdahd12J83L34Uc7MrPIrxtFG+rXiwDvRcqNvjwbClbbmvMrmxKVkIysFByBsl0Qe9kqd2w8T/nhK5G6eXXlk2V9AjYCieIU+jRnjZBB+Cfechr6rCGJ2aeBARIsXcRPW7wm9WFK9euh5T+v6Pyte68yNaNdcYCll3+U4/uCEog7HygCnMIbAU+kqoPdmn2H+51YOHW+VsnsHd4w1+I3f8Tt0xLIXGM4GWnQueZ5GR46GTWiSYMy8dCIh9SPIMRyC91GosVcfGPMJSdcXqc=",
|
||||
"https://oss-cn-hangzhou.aliyuncs.com/",
|
||||
"LTAI5tJ2UYfFNF7K3F4e1siv",
|
||||
"DhpCS82gaigZljYqsWsUWUAZ20dREz",
|
||||
"qx-yusheng",
|
||||
"https://qx-yusheng.oss-cn-hangzhou.aliyuncs.com/",
|
||||
"https://oss-cn-beijing.aliyuncs.com/",
|
||||
"LTAI5tKgrfcFQxH46ZwWYgFW",
|
||||
"ZOjTqAJmUL563EKFKySrUwAHtx4hKt",
|
||||
"midi01",
|
||||
"https://midi01.oss-cn-beijing.aliyuncs.com/",
|
||||
"wxc7681513be9f926b",
|
||||
1600101474,
|
||||
1600106397,
|
||||
"05b406b4541e413887d8d2bf9be8642c",
|
||||
"tcp://47.120.21.132",
|
||||
"tcp://1.13.181.248",
|
||||
"https://chatvespa.qxmier.com");
|
||||
|
||||
private final String serverUrl;
|
||||
private final String serverUrl;//服务器地址
|
||||
private final String ALI_AUTH_KEY;//阿里云授权key
|
||||
|
||||
private final String ossEndPoint;
|
||||
@@ -37,15 +37,15 @@ public enum EnvironmentEnum {
|
||||
private final String ossBucketName;
|
||||
private final String ossBaseUrl;
|
||||
|
||||
private final String wxAppId;
|
||||
private final String wxAppId;//微信appId
|
||||
|
||||
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,
|
||||
String ossAccessKeySecret, String ossBucketName, String ossBaseUrl, String wxAppId,
|
||||
|
||||