Compare commits
44 Commits
41c9e9d5d6
...
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 | |||
| 5ddf6fc638 | |||
| ea599bb63a | |||
| 748912d3d1 | |||
| 1157e8a545 | |||
| c7d4c447dd | |||
| c54cc692e0 | |||
| 6d3f67e53c | |||
| 54014fe0f6 | |||
| 77b801cca6 | |||
| 0db678d6a6 | |||
| e47bcfb8ab | |||
| 3b31ba1dea | |||
| 60e2980d89 | |||
| f387e05286 | |||
| 7217a9e38e | |||
| cb3b7aa183 | |||
| c8adbbc590 | |||
| 1b8af0e733 |
4
.idea/deploymentTargetSelector.xml
generated
@@ -4,10 +4,10 @@
|
||||
<selectionStates>
|
||||
<SelectionState runConfigName="app">
|
||||
<option name="selectionMode" value="DROPDOWN" />
|
||||
<DropdownSelection timestamp="2025-09-03T02:25:58.699909400Z">
|
||||
<DropdownSelection timestamp="2025-09-18T12:45:46.137835600Z">
|
||||
<Target type="DEFAULT_BOOT">
|
||||
<handle>
|
||||
<DeviceId pluginId="Default" identifier="serial=emulator-5554;connection=da0b71f9" />
|
||||
<DeviceId pluginId="PhysicalDevice" identifier="serial=6705124a" />
|
||||
</handle>
|
||||
</Target>
|
||||
</DropdownSelection>
|
||||
|
||||
3
.idea/inspectionProfiles/Project_Default.xml
generated
@@ -1,6 +1,9 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="AutoCloseableResource" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="METHOD_MATCHER_CONFIG" value="java.util.Formatter,format,java.io.Writer,append,com.google.common.base.Preconditions,checkNotNull,org.hibernate.Session,close,java.io.PrintWriter,printf,java.io.PrintStream,printf,java.lang.foreign.Arena,ofAuto,java.lang.foreign.Arena,global,android.content.Context,obtainStyledAttributes" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="ComposePreviewDimensionRespectsLimit" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
<option name="previewFile" value="true" />
|
||||
|
||||
@@ -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 {
|
||||
@@ -55,7 +55,7 @@ android {
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled true
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
signingConfig signingConfigs.release
|
||||
|
||||
@@ -77,7 +77,7 @@ android {
|
||||
|
||||
debug {
|
||||
debuggable true
|
||||
minifyEnabled true
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
signingConfig signingConfigs.debug
|
||||
|
||||
@@ -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') // 必须
|
||||
|
||||
34
app/proguard-rules.pro
vendored
@@ -898,3 +898,37 @@ public static java.lang.String TABLENAME;
|
||||
|
||||
-keep class com.xscm.moduleutil.utils.location.** { *; }
|
||||
-keep class io.agora.**{*;}
|
||||
|
||||
|
||||
# 在proguard-rules.pro中添加
|
||||
-keep class your.package.name.** {
|
||||
public protected *;
|
||||
}
|
||||
# 或者针对特定方法
|
||||
-keepclassmembers class * {
|
||||
public void displayMessage();
|
||||
}
|
||||
|
||||
|
||||
# 在 proguard-rules.pro 中添加混淆规则
|
||||
-keep class com.petterp.floatingx.** { *; }
|
||||
-keep class com.petterp.floatingx.* { *; }
|
||||
-dontwarn com.petterp.floatingx.**
|
||||
|
||||
|
||||
# 保持MqttBean类不被混淆
|
||||
-keep class com.xscm.moduleutil.event.MqttBean** {*;}
|
||||
-keepclassmembers class com.xscm.moduleutil.event.MqttBean** {
|
||||
*;
|
||||
}
|
||||
|
||||
-keep class com.xscm.moduleutil.bean.XLHBean** {*;}
|
||||
-keepclassmembers class com.xscm.moduleutil.bean.XLHBean** {
|
||||
*;
|
||||
}
|
||||
|
||||
# 保持EventBus相关类不被混淆
|
||||
-keepclassmembers class * {
|
||||
@org.greenrobot.eventbus.Subscribe <methods>;
|
||||
}
|
||||
-keep enum org.greenrobot.eventbus.ThreadMode { *; }
|
||||
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
@@ -115,7 +115,7 @@
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CAMERA" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
|
||||
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
|
||||
<application
|
||||
android:name=".AppContext"
|
||||
android:allowBackup="true"
|
||||
@@ -124,34 +124,34 @@
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:fullBackupContent="@xml/backup_rules"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:resizeableActivity="false"
|
||||
android:icon="@mipmap/ic_launcher_app"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:roundIcon="@mipmap/ic_launcher_round_app"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme"
|
||||
android:theme="@style/AppTheme_MAIN"
|
||||
android:networkSecurityConfig="@xml/network_security_config"
|
||||
android:usesCleartextTraffic="true"
|
||||
tools:targetApi="tiramisu"
|
||||
tools:ignore="SelectedPhotoAccess"
|
||||
tools:replace="android:theme,android:allowBackup"
|
||||
android:enableOnBackInvokedCallback="true"
|
||||
android:requestRawExternalStorageAccess="true"
|
||||
tools:targetApi="tiramisu"
|
||||
>
|
||||
<activity
|
||||
android:name=".LaunchPageActivity"
|
||||
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" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
<!-- <intent-filter>-->
|
||||
<!-- <action android:name="com.xscm.action.LAUNCH_PAGE" />-->
|
||||
<!-- <category android:name="android.intent.category.DEFAULT" />-->
|
||||
<!-- </intent-filter>-->
|
||||
<intent-filter>
|
||||
<action android:name="com.xscm.action.LAUNCH_PAGE" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<!-- 配置APP ID -->
|
||||
<meta-data
|
||||
|
||||
|
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=110
|
||||
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
|
||||
@@ -49,3 +49,6 @@ beta=false
|
||||
org.gradle.caching=false
|
||||
# ??APT????
|
||||
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>
|
||||
|
||||
|
||||
@@ -156,6 +156,9 @@ dependencies {
|
||||
api(libs.zcw.togglebutton.library)
|
||||
//图片模糊
|
||||
api(libs.com.github.mmin18.realtimeblurview)
|
||||
|
||||
api 'com.baoyz.actionsheet:library:1.1.7'
|
||||
|
||||
//播放器
|
||||
//腾讯直播sdk
|
||||
api('com.tencent.liteav:LiteAVSDK_Professional:10.9.0.13102')
|
||||
@@ -204,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'
|
||||
|
||||
@@ -1,18 +1,41 @@
|
||||
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.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.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;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.databinding.ViewDataBinding;
|
||||
@@ -20,15 +43,22 @@ import androidx.databinding.ViewDataBinding;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.blankj.utilcode.util.ActivityUtils;
|
||||
import com.blankj.utilcode.util.BarUtils;
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
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.DisplayUtil;
|
||||
import com.xscm.moduleutil.utils.LanguageUtil;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
import com.xscm.moduleutil.utils.SystemUtils;
|
||||
import com.xscm.moduleutil.widget.QXGiftDriftView;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
@@ -44,7 +74,8 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context newBase) {
|
||||
super.attachBaseContext(LanguageUtil.attachBaseContext(newBase));
|
||||
// 设置字体缩放比例为1.0f,即不跟随系统字体大小变化
|
||||
super.attachBaseContext(DisplayUtil.attachBaseContext(newBase, 1.0f));
|
||||
}
|
||||
|
||||
protected VDB mBinding;
|
||||
@@ -73,6 +104,7 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
ActivityUtils.finishAllActivities();
|
||||
}
|
||||
|
||||
QXGiftDriftView qxGiftDriftView;
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -115,17 +147,40 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// // 设置全屏模式,隐藏状态栏和导航栏
|
||||
// View decorView = getWindow().getDecorView();
|
||||
// decorView.setSystemUiVisibility(
|
||||
// View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||
// | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||
// | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||
// | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
||||
// | View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||
// | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
|
||||
// 在Activity中
|
||||
private static final int REQUEST_OVERLAY_PERMISSION = 1001;
|
||||
|
||||
private void checkAndRequestOverlayPermission() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (!Settings.canDrawOverlays(this)) {
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle("需要悬浮窗权限")
|
||||
.setMessage("应用需要悬浮窗权限才能显示飘屏效果")
|
||||
.setPositiveButton("去设置", (dialog, which) -> {
|
||||
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
|
||||
Uri.parse("package:" + getPackageName()));
|
||||
startActivityForResult(intent, REQUEST_OVERLAY_PERMISSION);
|
||||
})
|
||||
.setNegativeButton("取消", null)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == REQUEST_OVERLAY_PERMISSION) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (Settings.canDrawOverlays(this)) {
|
||||
ToastUtils.show("已获得悬浮窗权限");
|
||||
} else {
|
||||
ToastUtils.show("未获得悬浮窗权限");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void finishAll() {
|
||||
@@ -226,6 +281,36 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
|
||||
// 清理MQTT相关资源
|
||||
synchronized (mqttQueueLock) {
|
||||
mqttMessageQueue.clear();
|
||||
isMqttPlaying = false;
|
||||
}
|
||||
|
||||
// 清理XLH相关资源
|
||||
synchronized (xlhQueueLock) {
|
||||
xlhMessageQueue.clear();
|
||||
isXlhPlaying = false;
|
||||
}
|
||||
|
||||
// 移除当前显示的视图
|
||||
try {
|
||||
if (currentMqttView != null && currentMqttView.getParent() != null) {
|
||||
ViewGroup parent = (ViewGroup) currentMqttView.getParent();
|
||||
parent.removeView(currentMqttView);
|
||||
}
|
||||
currentMqttView = null;
|
||||
|
||||
if (currentXlhView != null && currentXlhView.getParent() != null) {
|
||||
ViewGroup parent = (ViewGroup) currentXlhView.getParent();
|
||||
parent.removeView(currentXlhView);
|
||||
}
|
||||
currentXlhView = null;
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("清理飘屏视图失败", e);
|
||||
}
|
||||
|
||||
// 移除背景更新监听器
|
||||
BackgroundManager.getInstance().removeListener(this);
|
||||
// 移除颜色变化监听器
|
||||
@@ -236,6 +321,12 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
if (EventBus.getDefault().isRegistered(this)) {
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
try {
|
||||
unregisterReceiver(mLogoutReceiver);
|
||||
} catch (Exception e) {
|
||||
// 忽略异常
|
||||
}
|
||||
|
||||
try {
|
||||
unregisterReceiver(mLogoutReceiver);
|
||||
} catch (Exception e) {
|
||||
@@ -307,16 +398,376 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
return false;
|
||||
}
|
||||
|
||||
// @Subscribe(threadMode = ThreadMode.MAIN)
|
||||
// public void onMessageReceived(MqttBean mqttBean) {
|
||||
//// PiaoPingManager.getInstance(this).showPiaoPingMessage(mqttBean);
|
||||
// FxAppHelper fxAppHelper = FxAppHelper.builder().setContext(this).setLayout(R.layout.item_piaoping).build();
|
||||
// FloatingX.install(fxAppHelper).show();
|
||||
// }
|
||||
|
||||
/// 礼物特效
|
||||
// 在类中添加以下成员变量
|
||||
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播放状态标志
|
||||
private final Object mqttQueueLock = new Object(); // MQTT队列同步锁
|
||||
private final Object xlhQueueLock = new Object(); // XLH队列同步锁
|
||||
private View currentMqttView = null; // 当前正在播放的MQTT视图
|
||||
private View currentXlhView = null; // 当前正在播放的XLH视图
|
||||
|
||||
/// 礼物特效 - MQTT消息处理
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onMessageReceived(MqttBean mqttBean) {
|
||||
LogUtils.e("收到MQTT", mqttBean);
|
||||
if (mqttBean == null) return;
|
||||
if (SpUtil.getFloatingScreen() == 1) {
|
||||
synchronized (mqttQueueLock) {
|
||||
|
||||
mqttMessageQueue.addAll(mqttBean.getList());
|
||||
// if (!isMqttPlaying) {
|
||||
// isMqttPlaying = true;
|
||||
processNextMqttMessage();
|
||||
// }
|
||||
}
|
||||
}else {
|
||||
mqttMessageQueue.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/// XLH消息处理
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onEvent(XLHBean event) {
|
||||
LogUtils.e("收到XLH", event);
|
||||
if (event == null) return;
|
||||
if (SpUtil.getFloatingScreen() == 1) {
|
||||
synchronized (xlhQueueLock) {
|
||||
xlhMessageQueue.add(event);
|
||||
if (!isXlhPlaying) {
|
||||
isXlhPlaying = true;
|
||||
processNextXlhMessage();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
xlhMessageQueue.clear();
|
||||
}
|
||||
}
|
||||
|
||||
// 处理下一个MQTT消息
|
||||
private void processNextMqttMessage() {
|
||||
MqttBean.ListBean mqttBean;
|
||||
synchronized (mqttQueueLock) {
|
||||
if (mqttMessageQueue.isEmpty()) {
|
||||
isMqttPlaying = false;
|
||||
return;
|
||||
}
|
||||
mqttBean = mqttMessageQueue.remove(0);
|
||||
}
|
||||
showFloatingMessage(mqttBean);
|
||||
}
|
||||
|
||||
// 处理下一个XLH消息
|
||||
private void processNextXlhMessage() {
|
||||
XLHBean xlhBean;
|
||||
synchronized (xlhQueueLock) {
|
||||
if (xlhMessageQueue.isEmpty()) {
|
||||
isXlhPlaying = false;
|
||||
return;
|
||||
}
|
||||
xlhBean = xlhMessageQueue.remove(0);
|
||||
}
|
||||
showPiaoPingMessageXlh(xlhBean);
|
||||
}
|
||||
|
||||
ViewGroup decorView;
|
||||
ViewGroup decorView1;
|
||||
|
||||
private void showFloatingMessage(MqttBean.ListBean mqttBean) {
|
||||
|
||||
// QXGiftDriftView.getInstance( this).addGiftModel(mqttBean);
|
||||
|
||||
|
||||
|
||||
try {
|
||||
// 清理之前的视图(如果存在)
|
||||
if (currentMqttView != null && currentMqttView.getParent() != null) {
|
||||
ViewGroup parent = (ViewGroup) currentMqttView.getParent();
|
||||
parent.removeView(currentMqttView);
|
||||
}
|
||||
|
||||
if (decorView == null) {
|
||||
decorView = (ViewGroup) getWindow().getDecorView();
|
||||
}
|
||||
|
||||
currentMqttView = LayoutInflater.from(this).inflate(R.layout.item_piaoping, null);
|
||||
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
|
||||
FrameLayout.LayoutParams.MATCH_PARENT,
|
||||
FrameLayout.LayoutParams.WRAP_CONTENT);
|
||||
layoutParams.topMargin = com.sunfusheng.marqueeview.DisplayUtil.dip2px(this, 70);
|
||||
layoutParams.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;
|
||||
currentMqttView.setLayoutParams(layoutParams);
|
||||
decorView.addView(currentMqttView);
|
||||
|
||||
updateFloatingViewData(currentMqttView, mqttBean);
|
||||
resetAndStartMqttAnimation(currentMqttView, () -> {
|
||||
// 清理当前视图
|
||||
if (currentMqttView != null && currentMqttView.getParent() != null) {
|
||||
ViewGroup parent = (ViewGroup) currentMqttView.getParent();
|
||||
parent.removeView(currentMqttView);
|
||||
}
|
||||
currentMqttView = null;
|
||||
|
||||
// 处理队列中的下一条消息
|
||||
synchronized (mqttQueueLock) {
|
||||
isMqttPlaying = false;
|
||||
processNextMqttMessage();
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("显示MQTT飘屏失败", e);
|
||||
// 出现异常时继续处理队列
|
||||
synchronized (mqttQueueLock) {
|
||||
isMqttPlaying = false;
|
||||
processNextMqttMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void showPiaoPingMessageXlh(XLHBean event) {
|
||||
try {
|
||||
// 清理之前的视图(如果存在)
|
||||
if (currentXlhView != null && currentXlhView.getParent() != null) {
|
||||
ViewGroup parent = (ViewGroup) currentXlhView.getParent();
|
||||
parent.removeView(currentXlhView);
|
||||
}
|
||||
|
||||
if (decorView1 == null) {
|
||||
decorView1 = (ViewGroup) getWindow().getDecorView();
|
||||
}
|
||||
|
||||
currentXlhView = LayoutInflater.from(this).inflate(R.layout.item_piaoping_xlh, null);
|
||||
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
|
||||
FrameLayout.LayoutParams.MATCH_PARENT,
|
||||
FrameLayout.LayoutParams.WRAP_CONTENT);
|
||||
layoutParams.topMargin = com.sunfusheng.marqueeview.DisplayUtil.dip2px(this, 100);
|
||||
layoutParams.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;
|
||||
currentXlhView.setLayoutParams(layoutParams);
|
||||
decorView1.addView(currentXlhView);
|
||||
|
||||
updateXlhFloatingViewData(currentXlhView, event);
|
||||
resetAndStartXlhAnimation(currentXlhView, () -> {
|
||||
// 清理当前视图
|
||||
if (currentXlhView != null && currentXlhView.getParent() != null) {
|
||||
ViewGroup parent = (ViewGroup) currentXlhView.getParent();
|
||||
parent.removeView(currentXlhView);
|
||||
}
|
||||
currentXlhView = null;
|
||||
|
||||
// 处理队列中的下一条消息
|
||||
synchronized (xlhQueueLock) {
|
||||
isXlhPlaying = false;
|
||||
processNextXlhMessage();
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("显示XLH飘屏失败", e);
|
||||
// 出现异常时继续处理队列
|
||||
synchronized (xlhQueueLock) {
|
||||
isXlhPlaying = false;
|
||||
processNextXlhMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
private void resetAndStartMqttAnimation(View view, Runnable onAnimationEnd) {
|
||||
try {
|
||||
int screenWidth = getScreenWidth();
|
||||
// 设置初始位置:在屏幕右侧外部(完全不可见)
|
||||
view.setTranslationX(screenWidth);
|
||||
|
||||
|
||||
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秒
|
||||
}
|
||||
|
||||
@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());
|
||||
ObjectAnimator animator1 = ObjectAnimator.ofFloat(view, "translationX", view.getWidth(), 0f);
|
||||
animator1.setDuration(1500);
|
||||
animator1.setInterpolator(new DecelerateInterpolator(2.0f));
|
||||
animator1.start();
|
||||
|
||||
view.postDelayed(() -> {
|
||||
try {
|
||||
ObjectAnimator animator2 = ObjectAnimator.ofFloat(view, "translationX", 0f, -view.getWidth());
|
||||
animator2.setDuration(1500);
|
||||
animator2.setInterpolator(new DecelerateInterpolator(2.0f));
|
||||
animator2.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
onAnimationEnd.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
onAnimationEnd.run();
|
||||
}
|
||||
});
|
||||
animator2.start();
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("XLH动画执行失败", e);
|
||||
onAnimationEnd.run();
|
||||
}
|
||||
}, 3000);
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("XLH动画启动失败", e);
|
||||
onAnimationEnd.run();
|
||||
}
|
||||
}
|
||||
|
||||
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 != 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.getNumber() != null ? mqttBean.getNumber() : "1"));
|
||||
} else {
|
||||
textView2.setText("送给");
|
||||
textView.setText("");
|
||||
tv_time.setText("x1");
|
||||
}
|
||||
}
|
||||
|
||||
private void updateXlhFloatingViewData(View view, XLHBean xlhBean) {
|
||||
TextView textView = view.findViewById(R.id.tv_name);
|
||||
ImageView xlh_image = view.findViewById(R.id.im_xlh);
|
||||
|
||||
if (xlhBean != null) {
|
||||
xlh_image.setImageDrawable(xlhBean.getFrom_type() == 1 ?
|
||||
getResources().getDrawable(R.mipmap.xlh_jjks) :
|
||||
getResources().getDrawable(R.mipmap.xlh_zsks));
|
||||
textView.setText(xlhBean.getText());
|
||||
} else {
|
||||
textView.setText("");
|
||||
}
|
||||
|
||||
view.setOnClickListener(v -> {
|
||||
// 点击时执行跳转操作
|
||||
handleItemClick(xlhBean);
|
||||
});
|
||||
}
|
||||
|
||||
private void handleItemClick(XLHBean xlhBean) {
|
||||
// 这里可以根据实际需求实现跳转逻辑
|
||||
// 例如:跳转到礼物详情页面、用户主页等
|
||||
// 使用缓存数据进入房间
|
||||
RoomManager.getInstance().fetchRoomDataAndEnter(getApplicationContext(), xlhBean.getRoom_id(), "");
|
||||
// ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("from", "我的界面").withString("roomId", xlhBean.getRoom_id()).navigation();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onEvent(ChatInfo event) {
|
||||
String id = event.getId().replace("g", "");
|
||||
ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url() + "/web/index.html#/pages/union/setGroup?id=" + SpUtil.getToken() + "&guildId=" + 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();
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public class AppUpdateDialog extends BaseDialog<DialogAppUpdateBinding> implemen
|
||||
};
|
||||
mProgressDialog.setMax(100);//设置最大值
|
||||
mProgressDialog.setTitle("安装包下载");//设置标题
|
||||
mProgressDialog.setIcon(R.mipmap.ic_launcher);//设置标题小图标
|
||||
mProgressDialog.setIcon(R.mipmap.ic_launcher_app);//设置标题小图标
|
||||
mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);//设置样式为横向显示进度的样式
|
||||
mProgressDialog.incrementProgressBy(0);//设置初始值为0,其实可以不用设置,默认就是0
|
||||
mProgressDialog.setIndeterminate(false);//是否精确显示对话框,flase为是,反之为否
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -121,7 +121,7 @@ public class GiftPackAdapter extends BaseAdapter {
|
||||
viewHolder.item_layout = (ConstraintLayout) convertView.findViewById(R.id.cl_gift);
|
||||
viewHolder.ivDownOn = (ImageView) convertView.findViewById(R.id.iv_down_on);
|
||||
viewHolder.cl_iv_down_on = (ConstraintLayout) convertView.findViewById(R.id.cl_iv_down_on);
|
||||
|
||||
viewHolder.integral = (TextView) convertView.findViewById(R.id.integral);
|
||||
convertView.setTag(viewHolder);
|
||||
} else {
|
||||
viewHolder = (GiftPackAdapter.ViewHolder) convertView.getTag();
|
||||
@@ -129,10 +129,11 @@ public class GiftPackAdapter extends BaseAdapter {
|
||||
|
||||
viewHolder.item_layout.setOnClickListener(v -> {
|
||||
// RoonGiftModel clickedModel = (RoonGiftModel) v.getTag();
|
||||
EventBus.getDefault().post(new RoomGiftPackToEvent(this, giftModel, 1));
|
||||
EventBus.getDefault().post(new RoomGiftPackToEvent(this, giftModel, 2));
|
||||
|
||||
});
|
||||
|
||||
viewHolder.integral.setVisibility(View.VISIBLE);
|
||||
viewHolder.integral.setText("x"+giftModel.getNum());
|
||||
//设置礼物名字
|
||||
viewHolder.tv_gift_name.setText(giftModel.getGift_name());
|
||||
//设置礼物价格
|
||||
@@ -162,7 +163,7 @@ public class GiftPackAdapter extends BaseAdapter {
|
||||
|
||||
static class ViewHolder {
|
||||
public ConstraintLayout item_layout;
|
||||
public TextView tv_gift_name, tv_gift_price, tv_gift_num;
|
||||
public TextView tv_gift_name, tv_gift_price, integral;
|
||||
public ImageView iv_gift_pic;
|
||||
public TextView tv_gift_change_love_values;
|
||||
public ImageView ivDownOn;
|
||||
|
||||
@@ -100,6 +100,16 @@ public class GiftRoomAdapter extends BaseAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
public void updateData(List<RoonGiftModel> newData) {
|
||||
this.mDatas.clear();
|
||||
// 确保新数据都不处于选中状态
|
||||
for (RoonGiftModel model : newData) {
|
||||
model.setChecked(false);
|
||||
}
|
||||
this.mDatas.addAll(newData);
|
||||
}
|
||||
|
||||
|
||||
// private static class MyGestureDetector extends GestureDetector {
|
||||
// private GiftRoomAdapter mAdapter;
|
||||
// private RoonGiftModel mGiftModel;
|
||||
@@ -146,18 +156,6 @@ public class GiftRoomAdapter extends BaseAdapter {
|
||||
viewHolder.item_layout = (ConstraintLayout) convertView.findViewById(R.id.cl_gift);
|
||||
viewHolder.ivDownOn = (ImageView) convertView.findViewById(R.id.iv_down_on);
|
||||
viewHolder.cl_iv_down_on = (ConstraintLayout) convertView.findViewById(R.id.cl_iv_down_on);
|
||||
// viewHolder.tv_gift_num = convertView.findViewById(R.id.tv_gift_num);
|
||||
|
||||
// viewHolder.tv_gift_change_love_values = convertView.findViewById(R.id.tv_gift_change_love_values);
|
||||
// viewHolder.item_layout.setOnTouchListener((v, event) -> {
|
||||
// gestureDetector.setGiftModel(GiftRoomAdapter.this, giftModel);
|
||||
// gestureDetector.onTouchEvent(event);
|
||||
//
|
||||
// return true;
|
||||
// });
|
||||
|
||||
|
||||
|
||||
|
||||
convertView.setTag(viewHolder);
|
||||
} else {
|
||||
|
||||
@@ -158,7 +158,10 @@ public class GiftTwoAdapter extends BaseAdapter {
|
||||
viewHolder.ivDownOn.setVisibility(View.GONE);
|
||||
viewHolder.cl_iv_down_on.setBackgroundResource(0);
|
||||
}
|
||||
viewHolder.tv_gift_num.setText(String.format("x%s", giftModel.getNum()));
|
||||
if (giftModel.getNum()==0){
|
||||
viewHolder.tv_gift_num.setVisibility(View.GONE);
|
||||
}
|
||||
viewHolder.tv_gift_num.setText(String.format("x%s", (giftModel.getNum()!=0?giftModel.getNum():"")));
|
||||
|
||||
|
||||
//设置
|
||||
|
||||
@@ -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;
|
||||
@@ -41,11 +43,12 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
||||
private int pageSize = 100;//一页显示的礼物个数
|
||||
private int pageCount;//页数
|
||||
private int type;//1:房间点击进入的;2:打赏进入的
|
||||
private List<RoonGiftModel> giftList=new ArrayList<>();
|
||||
private List<GiftPackBean> giftPackList=new ArrayList<>();
|
||||
private List<RoonGiftModel> giftList = new ArrayList<>();
|
||||
private List<GiftPackBean> giftPackList = new ArrayList<>();
|
||||
private String roomId;
|
||||
private String bdgiftId;
|
||||
|
||||
public static GiftTwoDetailsFragment newInstance(String id,int type,String roomId) {
|
||||
public static GiftTwoDetailsFragment newInstance(String id, int type, String roomId) {
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putString("id", id);
|
||||
@@ -64,6 +67,7 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
||||
roomId = arguments.getString("roomId");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
@@ -75,20 +79,50 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
||||
return new RewardGiftPresenter(this, getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
if (id.equals("0")){
|
||||
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) {
|
||||
} else {
|
||||
if (type == 0) {
|
||||
MvpPre.getGiftList("0", type, roomId);
|
||||
}else {
|
||||
} else {
|
||||
if (id == null) {
|
||||
id = "0";
|
||||
}
|
||||
MvpPre.getGiftList(id, type, roomId);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onString(GiftPackEvent event) {
|
||||
if (event!=null && event.getBdid()!=null) {
|
||||
bdgiftId = event.getBdid();
|
||||
MvpPre.giftPack();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
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
|
||||
protected void initView() {
|
||||
|
||||
@@ -121,30 +155,21 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGiftList(List<RoonGiftModel> data,int type) {
|
||||
if (type == 1){
|
||||
giftList=new ArrayList<>();
|
||||
giftList.addAll(data);
|
||||
pageCount = (int) Math.ceil(data.size() * 1.0 / pageSize);
|
||||
for (int j = 0; j < pageCount; j++) {
|
||||
roomAdapter = new GiftRoomAdapter(getActivity(), data, j, "0");
|
||||
mBinding.rvGift.setAdapter(roomAdapter);
|
||||
}
|
||||
}else {
|
||||
giftList=new ArrayList<>();
|
||||
giftList.addAll(data);
|
||||
pageCount = (int) Math.ceil(data.size() * 1.0 / pageSize);
|
||||
for (int j = 0; j < pageCount; j++) {
|
||||
// mAdapter = new GiftTwoAdapter(getActivity(), data, j, "0");
|
||||
// mBinding.rvGift.setAdapter(mAdapter);
|
||||
roomAdapter = new GiftRoomAdapter(getActivity(), data, j, "0");
|
||||
mBinding.rvGift.setAdapter(roomAdapter);
|
||||
}
|
||||
public void setGiftList(List<RoonGiftModel> data, int type) {
|
||||
giftList = new ArrayList<>();
|
||||
giftList.addAll(data);
|
||||
pageCount = (int) Math.ceil(data.size() * 1.0 / pageSize);
|
||||
|
||||
// 只需要创建一次Adapter并设置,循环设置没有意义
|
||||
if (pageCount > 0) {
|
||||
roomAdapter = new GiftRoomAdapter(getActivity(), data, 0, "0");
|
||||
mBinding.rvGift.setAdapter(roomAdapter);
|
||||
}
|
||||
// EventBus.getDefault().post(new RoomGiftEvent(data));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void giveGift() {
|
||||
|
||||
@@ -167,15 +192,44 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
||||
|
||||
@Override
|
||||
public void giftPack(List<GiftPackBean> giftPackBean) {
|
||||
giftPackList=new ArrayList<>();
|
||||
giftPackList.addAll(giftPackBean);
|
||||
pageCount = (int) Math.ceil(giftPackBean.size() * 1.0 / pageSize);
|
||||
for (int j = 0; j < pageCount; j++) {
|
||||
giftPackList = new ArrayList<>();
|
||||
|
||||
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++) {
|
||||
// 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
|
||||
public void getGiftPack(String s) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGiftPackListCount(GiftPackListCount giftPackListCount) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -190,7 +244,7 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onGiftClicRoomkEvent(RoomGiftClickEvent event) {
|
||||
if (giftList == null){
|
||||
if (giftList == null) {
|
||||
giftList = new ArrayList<>();
|
||||
giftList.add(event.gift);
|
||||
}
|
||||
@@ -200,7 +254,7 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
||||
RoonGiftModel giftModel = giftList.get(i);
|
||||
if (giftModel.getGift_id().equals(id)) {
|
||||
if (!giftModel.isChecked()) {
|
||||
EventBus.getDefault().post(new GiftUserRefreshEvent(giftModel.isCan_send_self(), event.type,event.gift));
|
||||
EventBus.getDefault().post(new GiftUserRefreshEvent(giftModel.isCan_send_self(), event.type, event.gift));
|
||||
giftModel.setChecked(true);
|
||||
}
|
||||
} else {
|
||||
@@ -218,7 +272,7 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
||||
if (giftModel.getGift_id().equals(id)) {
|
||||
selGift = giftModel;
|
||||
if (!giftModel.isChecked()) {
|
||||
EventBus.getDefault().post(new GiftUserRefreshEvent(giftModel.isCan_send_self(), event.type,event.gift));
|
||||
EventBus.getDefault().post(new GiftUserRefreshEvent(giftModel.isCan_send_self(), event.type, event.gift));
|
||||
giftModel.setChecked(true);
|
||||
}
|
||||
} else {
|
||||
@@ -240,7 +294,7 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
||||
giftPackList = new ArrayList<>();
|
||||
giftPackList.add(event.gift);
|
||||
}
|
||||
if (event.type == 1){
|
||||
if (event.type == 1) {
|
||||
String id = event.gift.getGift_id();
|
||||
for (int i = 0; i < giftPackList.size(); i++) {
|
||||
GiftPackBean giftModel = giftPackList.get(i);
|
||||
@@ -252,7 +306,7 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
||||
roonGiftModel.setNum(Integer.parseInt(giftModel.getNum()));
|
||||
if (giftModel.getGift_id().equals(id)) {
|
||||
if (!giftModel.isChecked()) {
|
||||
EventBus.getDefault().post(new GiftUserRefreshEvent(true, event.type,roonGiftModel));
|
||||
EventBus.getDefault().post(new GiftUserRefreshEvent(true, event.type, roonGiftModel));
|
||||
giftModel.setChecked(true);
|
||||
}
|
||||
} else {
|
||||
@@ -262,7 +316,7 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
||||
if (event.adapter != null && event.adapter.get() != null) {
|
||||
event.adapter.get().notifyDataSetChanged();
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
String id = event.gift.getGift_id();
|
||||
GiftPackBean selGift = null;
|
||||
for (int i = 0; i < giftPackList.size(); i++) {
|
||||
@@ -276,12 +330,12 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
||||
if (giftModel.getGift_id().equals(id)) {
|
||||
selGift = giftModel;
|
||||
if (!giftModel.isChecked()) {
|
||||
EventBus.getDefault().post(new GiftUserRefreshEvent(true, event.type,roonGiftModel));
|
||||
EventBus.getDefault().post(new GiftUserRefreshEvent(true, event.type, roonGiftModel));
|
||||
giftModel.setChecked(true);
|
||||
}
|
||||
} else {
|
||||
giftModel.setChecked(false);
|
||||
EventBus.getDefault().post(new GiftUserRefreshEvent(false, event.type,null));
|
||||
EventBus.getDefault().post(new GiftUserRefreshEvent(false, event.type, null));
|
||||
}
|
||||
}
|
||||
if (event.adapter != null && event.adapter.get() != null) {
|
||||
@@ -296,7 +350,7 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onGiftClicRoomkTEvent(RoomGiftClickToEvent event) {
|
||||
if (giftList == null){
|
||||
if (giftList == null) {
|
||||
giftList = new ArrayList<>();
|
||||
giftList.add(event.gift);
|
||||
}
|
||||
@@ -307,10 +361,10 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
||||
if (giftModel.getGift_id().equals(id)) {
|
||||
if (giftModel.isChecked()) {
|
||||
giftModel.setChecked(false);
|
||||
EventBus.getDefault().post(new GiftUserRefreshEvent(false, event.type,null));
|
||||
}else {
|
||||
EventBus.getDefault().post(new GiftUserRefreshEvent(false, event.type, null));
|
||||
} else {
|
||||
giftModel.setChecked(true);
|
||||
EventBus.getDefault().post(new GiftUserRefreshEvent(true, event.type,event.gift));
|
||||
EventBus.getDefault().post(new GiftUserRefreshEvent(true, event.type, event.gift));
|
||||
}
|
||||
} else {
|
||||
giftModel.setChecked(false);
|
||||
@@ -328,10 +382,10 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
||||
selGift = giftModel;
|
||||
if (giftModel.isChecked()) {
|
||||
giftModel.setChecked(false);
|
||||
EventBus.getDefault().post(new GiftUserRefreshEvent(false, event.type,null));
|
||||
}else {
|
||||
EventBus.getDefault().post(new GiftUserRefreshEvent(false, event.type, null));
|
||||
} else {
|
||||
giftModel.setChecked(true);
|
||||
EventBus.getDefault().post(new GiftUserRefreshEvent(giftModel.isCan_send_self(), event.type,event.gift));
|
||||
EventBus.getDefault().post(new GiftUserRefreshEvent(giftModel.isCan_send_self(), event.type, event.gift));
|
||||
}
|
||||
} else {
|
||||
giftModel.setChecked(false);
|
||||
|
||||
@@ -18,9 +18,11 @@ public class UserPhotoWallAdapter extends BaseQuickAdapter<String, BaseViewHolde
|
||||
protected void convert(BaseViewHolder helper, String item) {
|
||||
helper.setGone(R.id.iv_close, false);
|
||||
if (item.equals(ADD_PHOTO)) {
|
||||
helper.setVisible(R.id.iv_close, false);
|
||||
// 显示加号图片
|
||||
helper.setImageResource(R.id.riv_user_head, com.xscm.moduleutil.R.mipmap.add_img);
|
||||
} else {
|
||||
helper.setVisible(R.id.iv_close, true);
|
||||
ImageUtils.loadCenterCrop(item, helper.getView(R.id.riv_user_head));
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -3,17 +3,25 @@ package com.xscm.moduleutil.base;
|
||||
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;
|
||||
|
||||
@@ -22,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;
|
||||
@@ -56,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;
|
||||
@@ -81,34 +95,335 @@ 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;
|
||||
|
||||
// 添加后台状态标记
|
||||
private boolean wasInBackground = false;
|
||||
|
||||
public void onAppBackground() {
|
||||
wasInBackground = true;
|
||||
}
|
||||
|
||||
public void onAppForeground() {
|
||||
wasInBackground = false;
|
||||
}
|
||||
|
||||
public boolean wasInBackground() {
|
||||
return wasInBackground;
|
||||
}
|
||||
|
||||
private int activityCount = 0;
|
||||
|
||||
private AppStateListener appStateListener;
|
||||
private boolean isListeningUnreadCount = false;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public UnreadCountEvent unreadCountEvent;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
sInstance = this;
|
||||
sMainThreadHandler = new Handler();
|
||||
EnvironmentPrefs prefs = new EnvironmentPrefs(this);
|
||||
// 添加内存优化配置
|
||||
optimizeMemorySettings();
|
||||
currentEnvironment = prefs.getSelectedEnvironment();
|
||||
initialization();
|
||||
piaoPingManager = PiaoPingManager.getInstance(this);
|
||||
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 服务
|
||||
@@ -124,14 +439,42 @@ public class CommonAppContext extends MultiDexApplication {
|
||||
|
||||
// 每次启动应用时重置状态
|
||||
SpUtil.getInstance().setBooleanValue("youth_model_shown", false);
|
||||
startInitSdk();
|
||||
}
|
||||
}
|
||||
// piaoPingManager = PiaoPingManager.getInstance(this);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (!Settings.canDrawOverlays(this)) {
|
||||
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName()));
|
||||
startActivityForResult(intent, 100);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// requestBatteryOptimizationExemption();
|
||||
}
|
||||
private void requestBatteryOptimizationExemption() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
Intent intent = new Intent();
|
||||
String packageName = getPackageName();
|
||||
PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
|
||||
if (pm != null && !pm.isIgnoringBatteryOptimizations(packageName)) {
|
||||
intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
|
||||
intent.setData(Uri.parse("package:" + packageName));
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
try {
|
||||
startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("Failed to request battery optimization exemption: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void startActivityForResult(Intent intent, int i) {
|
||||
}
|
||||
|
||||
private PiaoPingManager piaoPingManager;
|
||||
|
||||
// private PiaoPingManager piaoPingManager;
|
||||
|
||||
private void initARouter() {
|
||||
if (true) {
|
||||
@@ -230,9 +573,9 @@ public class CommonAppContext extends MultiDexApplication {
|
||||
// 确保在主线程中订阅
|
||||
if (activity != null && !activity.isFinishing()) {
|
||||
activity.runOnUiThread(() -> {
|
||||
if (piaoPingManager != null) {
|
||||
piaoPingManager.subscribe();
|
||||
}
|
||||
// if (piaoPingManager != null) {
|
||||
// piaoPingManager.subscribe();
|
||||
// }
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -260,9 +603,9 @@ public class CommonAppContext extends MultiDexApplication {
|
||||
AppLifecycleUtil.onAppBackGround();
|
||||
if (activity != null && !activity.isFinishing()) {
|
||||
activity.runOnUiThread(() -> {
|
||||
if (piaoPingManager != null) {
|
||||
piaoPingManager.unsubscribe();
|
||||
}
|
||||
// if (piaoPingManager != null) {
|
||||
// piaoPingManager.unsubscribe();
|
||||
// }
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -366,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;
|
||||
}
|
||||
@@ -382,9 +730,7 @@ public class CommonAppContext extends MultiDexApplication {
|
||||
SpUtil.saveUserId(-1);
|
||||
SpUtil.saveUserBean(new UserBean());
|
||||
SpUtil.putToken("");
|
||||
Intent intent = new Intent("com.xscm.action.LAUNCH_PAGE");
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
getApplicationContext().startActivity(intent);
|
||||
|
||||
// piaoPingManager.unsubscribe();
|
||||
FileUtils.deleteAllInDir(getCacheDir());
|
||||
FileUtils.deleteAllInDir(getExternalCacheDir());
|
||||
@@ -395,7 +741,9 @@ public class CommonAppContext extends MultiDexApplication {
|
||||
// 发送广播通知所有Activity刷新状态
|
||||
Intent refreshIntent = new Intent("com.xscm.moduleutil.ACTION_USER_LOGOUT");
|
||||
sendBroadcast(refreshIntent);
|
||||
|
||||
Intent intent = new Intent("com.xscm.action.LAUNCH_PAGE");
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
getApplicationContext().startActivity(intent);
|
||||
}
|
||||
|
||||
public static boolean isAlipayInstalled(Context context) {
|
||||
@@ -432,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,4 @@
|
||||
package com.xscm.moduleutil.bean;
|
||||
|
||||
public class GiftAvatarBean {
|
||||
}
|
||||
@@ -23,4 +23,6 @@ public class GiftBean {
|
||||
private String nickname;
|
||||
private int count;
|
||||
private String user_id;
|
||||
private int num;
|
||||
private boolean is_paly =false;
|
||||
}
|
||||
|
||||
@@ -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;//封面
|
||||
|
||||
@@ -4,9 +4,10 @@ import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MyBagDataBean {
|
||||
private String title;
|
||||
private String giftName;
|
||||
private String time;
|
||||
private String base_image;
|
||||
private String remarks; //收入说明
|
||||
private String gift_num;//礼物数量
|
||||
private String gift_name;//礼物名称
|
||||
private String gift_image;//礼物图片
|
||||
private String time;//时间
|
||||
|
||||
}
|
||||
|
||||
@@ -53,13 +53,16 @@ public class PlaceholderBean {
|
||||
@Data
|
||||
public static class ListsBean {
|
||||
private String user_id;
|
||||
private String user_code;
|
||||
private String nickname;
|
||||
private String nickname1;
|
||||
private String avatar;
|
||||
private String total;
|
||||
private String rank;
|
||||
private List<String> icon;
|
||||
private String room_name;
|
||||
private String room_id;
|
||||
private String room_number;
|
||||
private String room_cover;
|
||||
|
||||
private int id;//公会id
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -91,6 +93,9 @@ public class RoomMessageEvent {
|
||||
private BlindBoxBean.XlhData xlh_data;
|
||||
private String from_pit_number;
|
||||
private String to_pit_number;
|
||||
|
||||
private String gift_num;
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.xscm.moduleutil.bean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/9/10
|
||||
*@description: 魅力详情列表
|
||||
*/
|
||||
@Data
|
||||
public class RoomUserCharmListBean {
|
||||
private int user_id;
|
||||
private String total_price;
|
||||
private String nickname;
|
||||
private String avatar;
|
||||
private String user_code;
|
||||
private int charm;
|
||||
private List<String> icon ;
|
||||
}
|
||||
@@ -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 {
|
||||
@@ -137,6 +150,7 @@ public class BlindBoxBean {
|
||||
private String gift_name;
|
||||
private String base_image;
|
||||
private String gift_num;
|
||||
private String gift_price;
|
||||
}
|
||||
|
||||
@Data
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.xscm.moduleutil.bean.blindboxwheel;
|
||||
|
||||
import lombok.Data;
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/9/4
|
||||
*@description: 巡乐会抽奖
|
||||
*/
|
||||
@Data
|
||||
public class XlhDrawBean {
|
||||
private int gift_id;
|
||||
private String gift_name;
|
||||
private String base_image;
|
||||
private String gift_price;
|
||||
private int count ;
|
||||
}
|
||||
@@ -100,8 +100,12 @@ public class EMMessageInfo implements MultiItemEntity {
|
||||
public static final int QXRoomMessageTypeMangH = 1056;
|
||||
///巡乐会
|
||||
public static final int QXRoomMessageTypeXlh = 1057;
|
||||
///在离线
|
||||
public static final int QXRoomMessageTypezailx = 1058;
|
||||
///清除个人魅力值
|
||||
public static final int QXRoomMessageTypeQingGRMl = 1059;
|
||||
|
||||
///
|
||||
///房间内换麦
|
||||
public static final int QXRoomMessageTypehm = 1039;
|
||||
private RoomMessageEvent emMessage;
|
||||
|
||||
@@ -154,11 +158,11 @@ public class EMMessageInfo implements MultiItemEntity {
|
||||
case QXRoomMessageTypeRoomDress:
|
||||
case QXRoomMessageTypeRoomOnline:
|
||||
case QXRoomMessageTypeRoomOPK:
|
||||
case QXRoomMessageTypeRoomOMh:
|
||||
case QXRoomMessageTypeRoomFriendPartDidChanged:
|
||||
case QXRoomMessageTypeSeatDidChanged:
|
||||
case QXRoomMessageTypehm:
|
||||
return 1;
|
||||
case QXRoomMessageTypeRoomOMh:
|
||||
case QXRoomMessageTypeGift:
|
||||
return 3;
|
||||
case 1:
|
||||
|
||||
@@ -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,12 +81,16 @@ 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);
|
||||
}else if (type==12){
|
||||
mBinding.gzCl.setBackgroundResource(R.mipmap.skzj);
|
||||
mBinding.imGz.setImageResource(R.mipmap.skzj_gz);
|
||||
}else if (type==13){
|
||||
mBinding.gzCl.setBackgroundResource(R.mipmap.xlh);
|
||||
mBinding.imGz.setImageResource(R.mipmap.xlh_gz);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -97,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);
|
||||
@@ -111,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);
|
||||
}
|
||||
@@ -158,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();
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.xscm.moduleutil.dialog.giftLottery;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.XlhDrawBean;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
|
||||
public class GiftItemAdapter extends BaseQuickAdapter<XlhDrawBean, BaseViewHolder> {
|
||||
public GiftItemAdapter() {
|
||||
super(R.layout.item_xlh_gift);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, XlhDrawBean item) {
|
||||
|
||||
helper.setText(R.id.tv_gift_name, item.getGift_name()+"x"+item.getCount());
|
||||
ImageUtils.loadHeadCC(item.getBase_image(),helper.getView(R.id.gift_img));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import com.xscm.moduleutil.bean.GiftBean;
|
||||
import com.xscm.moduleutil.bean.WalletBean;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.BlindBoxBean;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.BlindReslutBean;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.XlhDrawBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -22,12 +23,14 @@ public class GiftLotteryContacts {
|
||||
|
||||
void finishRefreshLoadMore();
|
||||
void wallet(WalletBean walletBean);
|
||||
|
||||
void xlhChouSuccess(List<XlhDrawBean> data);
|
||||
}
|
||||
|
||||
public interface IRoomPre extends IPresenter {
|
||||
void getGiftList(String giftBagId,String roomId);
|
||||
|
||||
void drawGiftList(String giftBagId,String gift_user_ids,String roomId,String num);
|
||||
void drawGiftList(String giftBagId,String gift_user_ids,String roomId,String num,String heart_id);
|
||||
|
||||
void getMyRecord(String giftBagId,String page,String pageSize,int type);//我的抽奖记录 type: 1:我的抽奖 2:全服抽奖
|
||||
|
||||
@@ -36,5 +39,11 @@ public class GiftLotteryContacts {
|
||||
void wallet();
|
||||
|
||||
void xlh(String room_id);
|
||||
|
||||
void xlhChou(String room_id,String num);
|
||||
|
||||
void xlhAllRecord(String room_id,String page,String pageSize);
|
||||
|
||||
void xlhMyRecord(String room_id,String page,String pageSize);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,39 +4,44 @@ import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.res.AssetFileDescriptor;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.media.MediaPlayer;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.widget.GridView;
|
||||
import android.widget.CompoundButton;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
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.activity.IPresenter;
|
||||
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.http.RetrofitClient;
|
||||
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;
|
||||
@@ -46,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
|
||||
@@ -79,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次
|
||||
@@ -91,18 +97,22 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
||||
private int type;//10:对应天空之境 11:对应岁月之城 12:对应时空之巅
|
||||
private GiftLotteryDialogFragment giftLotteryDialogFragment;
|
||||
private String blind_box_turntable_id = "";//本次抽奖标识id
|
||||
private BlindBoxBean.XlhData xlhData;
|
||||
private int icon;//金币金额
|
||||
private String heart_id="";
|
||||
|
||||
@Override
|
||||
protected GiftLotteryPresenter bindPresenter() {
|
||||
return new GiftLotteryPresenter(this, getActivity());
|
||||
}
|
||||
|
||||
public static GiftLotteryDialog newInstance(String giftBagId, String roomId, String userIds) {
|
||||
public static GiftLotteryDialog newInstance(String giftBagId, String roomId, String userIds,String heart_id) {
|
||||
GiftLotteryDialog dialog = new GiftLotteryDialog();
|
||||
Bundle args = new Bundle();
|
||||
args.putString("giftBagId", giftBagId);
|
||||
args.putString("roomId", roomId);
|
||||
args.putString("userIds", userIds);
|
||||
args.putString("heart_id", heart_id);
|
||||
dialog.setArguments(args);
|
||||
return dialog;
|
||||
}
|
||||
@@ -113,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;
|
||||
}
|
||||
|
||||
@@ -127,16 +135,77 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
||||
userIds = getArguments().getString("userIds");
|
||||
// 根据userIds确定类型
|
||||
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() {
|
||||
// 根据不同的用户类型显示不同的界面
|
||||
@@ -160,8 +229,8 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
||||
int screenHeight = displayMetrics.heightPixels;
|
||||
// 设置高度为屏幕高度的100%(全屏)
|
||||
int heightInPx = (int) (screenHeight * 0.79);
|
||||
;
|
||||
window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, heightInPx);
|
||||
|
||||
window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
window.setBackgroundDrawableResource(android.R.color.transparent);
|
||||
|
||||
// 可选:设置动画样式(从底部弹出)
|
||||
@@ -215,6 +284,7 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
||||
mBinding.mirroeSky.tvJc.setOnClickListener(this::onClisk);
|
||||
mBinding.mirroeSky.tvJl.setOnClickListener(this::onClisk);
|
||||
mBinding.mirroeSky.tvStart.setOnClickListener(this::onClisk);
|
||||
mBinding.mirroeSky.exchangeLayout.setOnClickListener(this::onClisk);
|
||||
init(0);
|
||||
mBinding.mirroeSky.swLockYx.setChecked(true);
|
||||
mBinding.mirroeSky.swTex.setChecked(true);
|
||||
@@ -253,6 +323,7 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
||||
mBinding.cityTime.tvJc.setOnClickListener(this::onClisk);
|
||||
mBinding.cityTime.tvJl.setOnClickListener(this::onClisk);
|
||||
mBinding.cityTime.tvStart.setOnClickListener(this::onClisk);
|
||||
mBinding.cityTime.exchangeLayout.setOnClickListener(this::onClisk);
|
||||
init2(0);
|
||||
mBinding.cityTime.swLockYx.setChecked(true);
|
||||
mBinding.cityTime.swTex.setChecked(true);
|
||||
@@ -290,6 +361,7 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
||||
mBinding.pinnacleTime.tvJc.setOnClickListener(this::onClisk);
|
||||
mBinding.pinnacleTime.tvJl.setOnClickListener(this::onClisk);
|
||||
mBinding.pinnacleTime.tvStart.setOnClickListener(this::onClisk);
|
||||
mBinding.pinnacleTime.exchangeLayout.setOnClickListener(this::onClisk);
|
||||
init3(0);
|
||||
mBinding.pinnacleTime.swLockYx.setChecked(true);
|
||||
mBinding.pinnacleTime.swTex.setChecked(true);
|
||||
@@ -304,37 +376,33 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
||||
int id = view.getId();
|
||||
if (id == R.id.ll_one) {
|
||||
if (!isDrawing) {
|
||||
isDrawing=true;
|
||||
init(1);
|
||||
isDrawing = true;
|
||||
// init(1);
|
||||
startType = 1;
|
||||
MvpPre.drawGiftList(giftBagId, userIds, roomId, "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) {
|
||||
if (!isDrawing) {
|
||||
isDrawing=true;
|
||||
init(2);
|
||||
isDrawing = true;
|
||||
// init(2);
|
||||
startType = 2;
|
||||
MvpPre.drawGiftList(giftBagId, userIds, roomId, "10");
|
||||
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) {
|
||||
isDrawing=true;
|
||||
init(3);
|
||||
isDrawing = true;
|
||||
// init(3);
|
||||
startType = 3;
|
||||
MvpPre.drawGiftList(giftBagId, userIds, roomId, "100");
|
||||
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);
|
||||
@@ -360,11 +428,95 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
||||
|
||||
giftLotteryDialogFragment = GiftLotteryDialogFragment.newInstance(giftBagId);
|
||||
giftLotteryDialogFragment.show(getChildFragmentManager(), "GiftLotteryDialogFragment");
|
||||
}else if (id == R.id.tv_start){
|
||||
|
||||
} else if (id == R.id.tv_start) {
|
||||
if (xlhData != null) {
|
||||
if (xlhData.getStatus() == 1) {
|
||||
FragmentManager fm = getParentFragmentManager();
|
||||
if (fm != null && !fm.isDestroyed()) {
|
||||
TourClubDialogFragment newDialog = TourClubDialogFragment.newInstance(
|
||||
roomId);
|
||||
newDialog.show(fm, "TourClubDialogFragment");
|
||||
}
|
||||
this.dismissAllowingStateLoss();
|
||||
}
|
||||
}
|
||||
} else if (id == R.id.exchange_layout) {
|
||||
// ARouter.getInstance().build(ARouteConstants.CURRENCY).navigation();
|
||||
RechargeDialogFragment.show(roomId, null, getActivity().getSupportFragmentManager());
|
||||
}
|
||||
}
|
||||
|
||||
private void setBackground() {
|
||||
// 预加载资源
|
||||
Drawable drawableX = ContextCompat.getDrawable(getContext(), R.mipmap.chou_x);
|
||||
Drawable drawableW = ContextCompat.getDrawable(getContext(), R.mipmap.chou_w);
|
||||
|
||||
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);
|
||||
} 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.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);
|
||||
} else {
|
||||
// 兜底处理:未知 type 时全部设为不可点击 + 默认背景
|
||||
setAllBackgroundToDefault(drawableW);
|
||||
}
|
||||
} else {
|
||||
// icon 或 box_price <= 0 时全部置灰不可点击
|
||||
setAllBackgroundToDefault(drawableW);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateBackground(View view, boolean clickable, Drawable drawableX, Drawable drawableW) {
|
||||
if (clickable) {
|
||||
view.setBackground(drawableX);
|
||||
view.setClickable(true);
|
||||
} else {
|
||||
view.setBackground(drawableW);
|
||||
view.setClickable(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void setAllBackgroundToDefault(Drawable defaultDrawable) {
|
||||
switch (type) {
|
||||
case 10:
|
||||
mBinding.mirroeSky.llOne.setBackground(defaultDrawable);
|
||||
mBinding.mirroeSky.llTen.setBackground(defaultDrawable);
|
||||
mBinding.mirroeSky.llHundred.setBackground(defaultDrawable);
|
||||
mBinding.mirroeSky.llOne.setClickable(false);
|
||||
mBinding.mirroeSky.llTen.setClickable(false);
|
||||
mBinding.mirroeSky.llHundred.setClickable(false);
|
||||
break;
|
||||
case 11:
|
||||
mBinding.cityTime.llOne.setBackground(defaultDrawable);
|
||||
mBinding.cityTime.llTen.setBackground(defaultDrawable);
|
||||
mBinding.cityTime.llHundred.setBackground(defaultDrawable);
|
||||
mBinding.cityTime.llOne.setClickable(false);
|
||||
mBinding.cityTime.llTen.setClickable(false);
|
||||
mBinding.cityTime.llHundred.setClickable(false);
|
||||
break;
|
||||
case 12:
|
||||
mBinding.pinnacleTime.llOne.setBackground(defaultDrawable);
|
||||
mBinding.pinnacleTime.llTen.setBackground(defaultDrawable);
|
||||
mBinding.pinnacleTime.llHundred.setBackground(defaultDrawable);
|
||||
mBinding.pinnacleTime.llOne.setClickable(false);
|
||||
mBinding.pinnacleTime.llTen.setClickable(false);
|
||||
mBinding.pinnacleTime.llHundred.setClickable(false);
|
||||
break;
|
||||
default:
|
||||
// 忽略未知类型
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void init(int type) {
|
||||
if (type == 1) {
|
||||
mBinding.mirroeSky.llOne.setBackground(getResources().getDrawable(R.mipmap.chou_x));
|
||||
@@ -425,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()) {
|
||||
@@ -441,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;
|
||||
}
|
||||
@@ -496,19 +662,17 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
||||
iterator.remove(); // 安全地移除元素
|
||||
finishTargetArrayIndex.add(index);
|
||||
foundTarget = true;
|
||||
if (!isOpenSpecial || !isOpenSound) {
|
||||
playSound("draw.mp3");
|
||||
stopPlay();
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
delayTime = 0.03;
|
||||
if (targetArrayIndex.isEmpty()) {
|
||||
|
||||
MvpPre.giftSend(blind_box_turntable_id);
|
||||
MvpPre.wallet();
|
||||
isDrawing = false;
|
||||
playSound("xuanz.mp3");
|
||||
stopFastAnimate();
|
||||
return;
|
||||
}
|
||||
@@ -544,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);
|
||||
@@ -587,11 +751,12 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
||||
}
|
||||
|
||||
private String getRule_url;
|
||||
private int box_price;//服务器返回的单次抽奖价格
|
||||
|
||||
@Override
|
||||
public void getGiftListSuccess(BlindBoxBean blindBoxBean) {
|
||||
if (blindBoxBean != null && blindBoxBean.getGift_list() != null) {
|
||||
|
||||
box_price = blindBoxBean.getBox_price();
|
||||
upTitle(blindBoxBean.getBox_price());
|
||||
giftLists = blindBoxBean.getGift_list();
|
||||
getRule_url = blindBoxBean.getRule_url();
|
||||
@@ -629,29 +794,35 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
||||
}
|
||||
}
|
||||
}
|
||||
setBackground();
|
||||
}
|
||||
|
||||
|
||||
private void upTitle(int boxPrice){
|
||||
if (type==10){
|
||||
mBinding.mirroeSky.oneTitle.setText(boxPrice+"币一次");
|
||||
mBinding.mirroeSky.tenTitle.setText((boxPrice*10)+"币十次");
|
||||
mBinding.mirroeSky.hundredTitle.setText((boxPrice*100)+"币十次");
|
||||
}else if (type==11){
|
||||
mBinding.cityTime.oneTitle.setText(boxPrice+"币一次");
|
||||
mBinding.cityTime.tenTitle.setText((boxPrice*10)+"币十次");
|
||||
mBinding.cityTime.hundredTitle.setText((boxPrice*100)+"币十次");
|
||||
private void upTitle(int boxPrice) {
|
||||
if (type == 10) {
|
||||
mBinding.mirroeSky.oneTitle.setText(boxPrice + "币一次");
|
||||
mBinding.mirroeSky.tenTitle.setText((boxPrice * 6) + "币六次");
|
||||
mBinding.mirroeSky.hundredTitle.setText((boxPrice * 9) + "币九次");
|
||||
} else if (type == 11) {
|
||||
mBinding.cityTime.oneTitle.setText(boxPrice + "币一次");
|
||||
mBinding.cityTime.tenTitle.setText((boxPrice * 6) + "币六次");
|
||||
mBinding.cityTime.hundredTitle.setText((boxPrice * 9) + "币九次");
|
||||
|
||||
}else if (type==12){
|
||||
mBinding.pinnacleTime.oneTitle.setText(boxPrice+"币一次");
|
||||
mBinding.pinnacleTime.tenTitle.setText((boxPrice*10)+"币十次");
|
||||
mBinding.pinnacleTime.hundredTitle.setText((boxPrice*100)+"币十次");
|
||||
} else if (type == 12) {
|
||||
mBinding.pinnacleTime.oneTitle.setText(boxPrice + "币一次");
|
||||
mBinding.pinnacleTime.tenTitle.setText((boxPrice * 6) + "币六次");
|
||||
mBinding.pinnacleTime.hundredTitle.setText((boxPrice * 9) + "币九次");
|
||||
}
|
||||
}
|
||||
|
||||
private void UpView(BlindBoxBean.XlhData xlhData) {
|
||||
if (xlhData != null) {
|
||||
@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();
|
||||
int startNum = Integer.parseInt(xlhData.getStart_num());
|
||||
int waitingStartNum = Integer.parseInt(xlhData.getWaiting_start_num());
|
||||
@@ -689,52 +860,76 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
||||
mBinding.pinnacleTime.tvStart.setBackgroundResource(R.mipmap.zhensgh);
|
||||
} else if (xlhData.getStatus() == 2) {
|
||||
mBinding.mirroeSky.tvStart.setBackgroundResource(R.mipmap.jijang);
|
||||
mBinding.cityTime.tvStart.setBackgroundResource(R.mipmap.zhensgh);
|
||||
mBinding.pinnacleTime.tvStart.setBackgroundResource(R.mipmap.zhensgh);
|
||||
mBinding.cityTime.tvStart.setBackgroundResource(R.mipmap.jijang);
|
||||
mBinding.pinnacleTime.tvStart.setBackgroundResource(R.mipmap.jijang);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void drawGiftListSuccess(BlindReslutBean blindReslutBean) {
|
||||
if (blindReslutBean != null && blindReslutBean.getReslut_list() != null &&
|
||||
!blindReslutBean.getReslut_list().isEmpty()) {
|
||||
|
||||
for (GiftCardView gridView : allViewsArray) {
|
||||
gridView.setSelected(false);
|
||||
gridView.stopPulseAnimationWithLayer();
|
||||
gridView.setVisibilitymResultTextView(false);
|
||||
}
|
||||
// 清空之前的数据
|
||||
targetArrayIndex.clear();
|
||||
finishTargetArrayIndex.clear();
|
||||
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) {
|
||||
GiftCardView giftCardView = allViewsArray.get(j);
|
||||
GiftBean giftBean = giftLists.get(j);
|
||||
giftBean.setCount(reslutList.getCount());
|
||||
giftCardView.setVisibilitymResultTextView(true);
|
||||
giftCardView.setSelected(true);
|
||||
playSound("draw.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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -757,24 +952,46 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
||||
@Override
|
||||
public void wallet(WalletBean walletBean) {
|
||||
if (walletBean != null) {
|
||||
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());
|
||||
icon = (int) Double.parseDouble(
|
||||
(walletBean.getCoin() != null && !walletBean.getCoin().isEmpty())
|
||||
? walletBean.getCoin()
|
||||
: "0"
|
||||
);
|
||||
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();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void xlhChouSuccess(List<XlhDrawBean> data) {
|
||||
|
||||
}
|
||||
|
||||
// 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() {
|
||||
@@ -785,19 +1002,19 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
||||
@Override
|
||||
public void onDismiss(@NonNull DialogInterface dialog) {
|
||||
super.onDismiss(dialog);
|
||||
releaseResources();
|
||||
// releaseResources();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel(@NonNull DialogInterface dialog) {
|
||||
super.onCancel(dialog);
|
||||
releaseResources();
|
||||
// releaseResources();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
releaseResources();
|
||||
// releaseResources();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -832,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();
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.xscm.moduleutil.bean.GiftBean;
|
||||
import com.xscm.moduleutil.bean.WalletBean;
|
||||
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.DialogGiftLotteryFragmentBinding;
|
||||
import com.xscm.moduleutil.widget.pagerecyclerview.PagerGridSnapHelper;
|
||||
|
||||
@@ -134,20 +135,6 @@ public class GiftLotteryDialogFragment extends BaseMvpDialogFragment<GiftLottery
|
||||
mBinding.textView1.setOnClickListener(this::onClick);
|
||||
mBinding.textView2.setOnClickListener(this::onClick);
|
||||
|
||||
// 根据屏幕密度调整行数和列数
|
||||
int rows, columns;
|
||||
float density = this.getResources().getDisplayMetrics().density;
|
||||
|
||||
if (density <= 2.0) { // 低密度屏幕(如mdpi, hdpi)
|
||||
rows = 3;
|
||||
columns = 3;
|
||||
} else if (density <= 3.0) { // 中密度屏幕(如xhdpi)
|
||||
rows = 4;
|
||||
columns = 3;
|
||||
} else { // 高密度屏幕(如xxhdpi, xxxhdpi)
|
||||
rows = 5;
|
||||
columns = 3;
|
||||
}
|
||||
adapter=new GiftLotteryAdapter();
|
||||
giftRecordAdapte=new GiftRecordAdapte();
|
||||
|
||||
@@ -258,4 +245,9 @@ public class GiftLotteryDialogFragment extends BaseMvpDialogFragment<GiftLottery
|
||||
public void wallet(WalletBean walletBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void xlhChouSuccess(List<XlhDrawBean> data) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,9 @@ import com.xscm.moduleutil.bean.GiftBean;
|
||||
import com.xscm.moduleutil.bean.WalletBean;
|
||||
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;
|
||||
@@ -40,8 +42,8 @@ public class GiftLotteryPresenter extends BasePresenter<GiftLotteryContacts.View
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawGiftList(String giftBagId, String gift_user_ids, String roomId, String num) {
|
||||
api.drawGiftList(giftBagId, gift_user_ids, roomId, num, new BaseObserver<BlindReslutBean>() {
|
||||
public void drawGiftList(String giftBagId, String gift_user_ids, String roomId, String num,String heart_id) {
|
||||
api.drawGiftList(giftBagId, gift_user_ids, roomId, num,heart_id, new BaseObserver<BlindReslutBean>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
@@ -124,10 +126,85 @@ public class GiftLotteryPresenter extends BasePresenter<GiftLotteryContacts.View
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
///巡乐会
|
||||
@Override
|
||||
public void xlh(String room_id) {
|
||||
// api.xlh(room_id, new BaseObserver<String>() {)
|
||||
|
||||
api.getBoxGiftListXLH(room_id, new BaseObserver<BlindBoxBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable( d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BlindBoxBean blindBoxBeans) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().getGiftListSuccess(blindBoxBeans);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@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
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<XlhDrawBean> xlhDrawBeans) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().xlhChouSuccess(xlhDrawBeans);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void xlhAllRecord(String room_id, String page, String pageSize) {
|
||||
api.xlhAllRecord(room_id,page,pageSize,new BaseObserver<List<GiftBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<GiftBean> giftBean) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().getAllRecordSuccess(giftBean);
|
||||
MvpRef.get().finishRefreshLoadMore();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void xlhMyRecord(String room_id, String page, String pageSize) {
|
||||
api.xlhMyRecord(room_id,page,pageSize,new BaseObserver<List<GiftBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<GiftBean> giftBeans) {
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().getMyRecordSuccess(giftBeans);
|
||||
MvpRef.get().finishRefreshLoadMore();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.xscm.moduleutil.dialog.giftLottery;
|
||||
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.bean.GiftBean;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
|
||||
public class GiftRecordAdapter extends BaseQuickAdapter<GiftBean, BaseViewHolder> {
|
||||
|
||||
|
||||
public GiftRecordAdapter() {
|
||||
super(R.layout.item_my_record);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, GiftBean item) {
|
||||
helper.setText(R.id.tv_gift_time, item.getCreatetime());
|
||||
ImageUtils.loadHeadCC(item.getBase_image(),helper.getView(R.id.iv_gift_image));
|
||||
// 使用 SpannableString 给 "x4" 设置不同颜色
|
||||
TextView giftNameTextView = helper.getView(R.id.tv_gift_name);
|
||||
if (giftNameTextView != null) {
|
||||
String baseName = item.getGift_name();
|
||||
String countText = "x"+item.getCount();
|
||||
String fullText = baseName + countText;
|
||||
|
||||
SpannableStringBuilder spannable = new SpannableStringBuilder(fullText);
|
||||
|
||||
// 给 "x4" 部分设置颜色
|
||||
spannable.setSpan(
|
||||
new ForegroundColorSpan(mContext.getResources().getColor(R.color.color_C7BF62)), // 替换为实际颜色
|
||||
baseName.length(),
|
||||
fullText.length(),
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
);
|
||||
|
||||
giftNameTextView.setText(spannable);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
package com.xscm.moduleutil.dialog.giftLottery;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.bean.GiftBean;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public class GiftXlhChouAdapter extends BaseQuickAdapter<GiftBean, BaseViewHolder> {
|
||||
private List<GiftBean> giftLists = new ArrayList<>();
|
||||
private int selectedPosition = -1;
|
||||
private static final int LOOP_COUNT = 8; // 循环倍数
|
||||
|
||||
|
||||
public GiftXlhChouAdapter() {
|
||||
super(R.layout.item_xlh);
|
||||
}
|
||||
// 设置数据时创建循环数据
|
||||
@Override
|
||||
public void setNewData(List<GiftBean> data) {
|
||||
this.giftLists = data != null ? data : new ArrayList<>();
|
||||
super.setNewData(createLoopData());
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建循环数据
|
||||
* @return 循环数据列表
|
||||
*/
|
||||
private List<GiftBean> createLoopData() {
|
||||
List<GiftBean> loopData = new ArrayList<>();
|
||||
if (giftLists.isEmpty()) {
|
||||
return loopData;
|
||||
}
|
||||
|
||||
// 创建足够多的循环数据以实现循环效果
|
||||
for (int i = 0; i < LOOP_COUNT; i++) {
|
||||
loopData.addAll(giftLists);
|
||||
}
|
||||
return loopData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
// 如果原始数据为空,返回0
|
||||
if (giftLists.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
// 返回循环数据的数量
|
||||
return super.getItemCount();
|
||||
}
|
||||
/**
|
||||
* 获取实际位置(将循环位置映射到原始数据位置)
|
||||
* @param position 循环列表中的位置
|
||||
* @return 原始数据中的实际位置
|
||||
*/
|
||||
private int getActualPosition(int position) {
|
||||
if (giftLists.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
return position % giftLists.size();
|
||||
}
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, GiftBean item) {
|
||||
// 获取实际位置
|
||||
int actualPosition = getActualPosition(helper.getAdapterPosition());
|
||||
GiftBean actualItem = giftLists.get(actualPosition);
|
||||
|
||||
helper.setText(R.id.tv_gift_name, actualItem.getGift_name());
|
||||
helper.setText(R.id.tv_gift_pic, actualItem.getGift_price());
|
||||
ImageUtils.loadHeadCC(actualItem.getBase_image(), helper.getView(R.id.iv_gift_image));
|
||||
// 处理选中状态
|
||||
View selectedIcon = helper.getView(R.id.selected_icon);
|
||||
// 处理选中状态
|
||||
if (selectedIcon != null) {
|
||||
// 检查当前item是否为选中位置
|
||||
if (actualPosition == selectedPosition) {
|
||||
selectedIcon.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
selectedIcon.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 设置选中位置并更新UI
|
||||
* @param position 选中的位置
|
||||
*/
|
||||
public void setSelectedPosition(int position) {
|
||||
int previousPosition = selectedPosition;
|
||||
selectedPosition = position;
|
||||
|
||||
if (previousPosition >= 0) {
|
||||
notifyItemsByActualPosition(previousPosition, false);
|
||||
}
|
||||
|
||||
if (selectedPosition >= 0) {
|
||||
notifyItemsByActualPosition(selectedPosition, true);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 根据实际位置通知所有匹配的item更新
|
||||
* @param actualPosition 原始数据中的位置
|
||||
* @param isSelected 是否选中
|
||||
*/
|
||||
private void notifyItemsByActualPosition(int actualPosition, boolean isSelected) {
|
||||
if (giftLists.isEmpty() || actualPosition >= giftLists.size()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 通知所有匹配该实际位置的item更新
|
||||
for (int i = 0; i < getItemCount(); i++) {
|
||||
if (getActualPosition(i) == actualPosition) {
|
||||
notifyItemChanged(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 清除选中状态
|
||||
*/
|
||||
public void clearSelection() {
|
||||
int previousPosition = selectedPosition;
|
||||
selectedPosition = -1;
|
||||
|
||||
if (previousPosition >= 0) {
|
||||
notifyItemsByActualPosition(previousPosition, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取原始数据大小
|
||||
* @return 原始数据大小
|
||||
*/
|
||||
public int getOriginalDataSize() {
|
||||
List<GiftBean> loopData = new ArrayList<>();
|
||||
for (int i = 0; i < LOOP_COUNT; i++) {
|
||||
loopData.addAll(giftLists);
|
||||
}
|
||||
return loopData.size();
|
||||
}
|
||||
}
|
||||
@@ -21,10 +21,11 @@ import com.xscm.moduleutil.utils.ImageUtils;
|
||||
*/
|
||||
public class PrizePoolAdapter extends BaseQuickAdapter<GiftBean, BaseViewHolder> {
|
||||
private Context context;
|
||||
private int type;
|
||||
|
||||
public PrizePoolAdapter() {
|
||||
public PrizePoolAdapter(int type) {
|
||||
super(R.layout.item_prize_pool);
|
||||
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +33,13 @@ public class PrizePoolAdapter extends BaseQuickAdapter<GiftBean, BaseViewHolder>
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, GiftBean item) {
|
||||
|
||||
if (type == 10 || type == 12){
|
||||
helper.setImageResource(R.id.iv_prize_pool,R.mipmap.tkzj_z);
|
||||
}else {
|
||||
helper.setImageResource(R.id.iv_prize_pool,R.mipmap.xlh_hd);
|
||||
}
|
||||
|
||||
helper.setText(R.id.tv_gift_name, item.getGift_name());
|
||||
helper.setText(R.id.tv_gift_pic, item.getGift_price());
|
||||
ImageUtils.loadHeadCC(item.getBase_image(),helper.getView(R.id.iv_gift_image));
|
||||
|
||||
@@ -88,6 +88,9 @@ public class PrizePoolDialog extends BaseDialog<DialogPrizePoolBinding> {
|
||||
} else if (type == 12) {
|
||||
mBinding.clPrize.setBackgroundResource(R.mipmap.skzj);
|
||||
mBinding.imJc.setImageResource(R.mipmap.skzl_jc);
|
||||
}else if (type == 13){
|
||||
mBinding.clPrize.setBackgroundResource(R.mipmap.xlh);
|
||||
mBinding.imJc.setImageResource(R.mipmap.xlh_jc);
|
||||
}
|
||||
|
||||
// 根据屏幕密度调整行数和列数
|
||||
@@ -108,7 +111,7 @@ public class PrizePoolDialog extends BaseDialog<DialogPrizePoolBinding> {
|
||||
if (newData != null && !newData.isEmpty()) {
|
||||
this.gift_list = newData;
|
||||
if (mBinding != null && mContext != null) {
|
||||
PrizePoolAdapter prizePoolAdapter = new PrizePoolAdapter();
|
||||
PrizePoolAdapter prizePoolAdapter = new PrizePoolAdapter(type);
|
||||
GridLayoutManager layoutManager = new GridLayoutManager(getContext(), 3);
|
||||
// PagerGridLayoutManager layoutManager = new PagerGridLayoutManager(rows, columns, PagerGridLayoutManager.VERTICAL);
|
||||
mBinding.gvGift.setLayoutManager(layoutManager);
|
||||
|
||||
@@ -1,24 +1,47 @@
|
||||
package com.xscm.moduleutil.dialog.giftLottery;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.Gravity;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
|
||||
import com.blankj.utilcode.util.ScreenUtils;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.XlhDrawBean;
|
||||
import com.xscm.moduleutil.databinding.DialogHeavenGiftBinding;
|
||||
import com.xscm.moduleutil.databinding.DialogXlhObtainBinding;
|
||||
import com.xscm.moduleutil.widget.dialog.BaseDialog;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/9/2
|
||||
*@description: 巡乐会恭喜或得礼弹窗
|
||||
* @author qx
|
||||
* @data 2025/9/2
|
||||
* @description: 巡乐会恭喜或得礼弹窗
|
||||
*/
|
||||
public class XlhObtainDialog extends BaseDialog<DialogXlhObtainBinding> {
|
||||
|
||||
public interface OnGiftItemClickListener {
|
||||
|
||||
void onPlayAgainClick();
|
||||
|
||||
void onCloseClick();
|
||||
}
|
||||
|
||||
private GiftItemAdapter mAdapter;
|
||||
private OnGiftItemClickListener mListener;
|
||||
private List<XlhDrawBean> mGiftList;
|
||||
|
||||
public XlhObtainDialog(@NonNull Context context) {
|
||||
super(context,R.style.BaseDialogStyleH);
|
||||
super(context, R.style.BaseDialogStyleH);
|
||||
}
|
||||
|
||||
public XlhObtainDialog(@NonNull Context context, List<XlhDrawBean> giftList) {
|
||||
super(context, R.style.BaseDialogStyleH);
|
||||
this.mGiftList = giftList;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -31,9 +54,52 @@ 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 -> dismiss());
|
||||
mBinding.ivAgain.setOnClickListener(v -> dismiss());///在玩一次
|
||||
// 设置点击事件
|
||||
mBinding.xlhClose.setOnClickListener(v -> {
|
||||
if (mListener != null) {
|
||||
mListener.onCloseClick();
|
||||
}
|
||||
dismiss();
|
||||
});
|
||||
|
||||
mBinding.ivAgain.setOnClickListener(v -> {
|
||||
if (mListener != null) {
|
||||
mListener.onPlayAgainClick();
|
||||
}
|
||||
dismiss();
|
||||
});
|
||||
initRecyclerView();
|
||||
}
|
||||
private void initRecyclerView() {
|
||||
mAdapter = new GiftItemAdapter();
|
||||
mBinding.rvHead.setLayoutManager(new GridLayoutManager(getContext(), 3));
|
||||
mBinding.rvHead.setAdapter(mAdapter);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置礼物数据
|
||||
*/
|
||||
public void setGiftList(List<XlhDrawBean> giftList) {
|
||||
this.mGiftList = giftList;
|
||||
if (mAdapter != null) {
|
||||
mAdapter.setNewData(giftList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置点击回调监听器
|
||||
*/
|
||||
public void setOnGiftItemClickListener(OnGiftItemClickListener listener) {
|
||||
this.mListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,176 @@
|
||||
package com.xscm.moduleutil.dialog.giftLottery;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.base.BaseMvpDialogFragment;
|
||||
import com.xscm.moduleutil.bean.GiftBean;
|
||||
import com.xscm.moduleutil.bean.WalletBean;
|
||||
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.DialogGiftLotteryFragmentBinding;
|
||||
import com.xscm.moduleutil.databinding.DialogRankingXlhFragmentBinding;
|
||||
import com.xscm.moduleutil.widget.pagerecyclerview.PagerGridSnapHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/9/4
|
||||
*@description:巡乐会榜单
|
||||
*/
|
||||
public class XlhRankingDialog extends BaseMvpDialogFragment<GiftLotteryPresenter, DialogRankingXlhFragmentBinding> implements GiftLotteryContacts.View{
|
||||
private int page=1;
|
||||
private String roomId;
|
||||
private GiftRecordAdapte giftRecordAdapte;
|
||||
|
||||
@Override
|
||||
protected GiftLotteryPresenter bindPresenter() {
|
||||
return new GiftLotteryPresenter(this,getSelfActivity());
|
||||
}
|
||||
|
||||
public static XlhRankingDialog newInstance(String giftBagId) {
|
||||
Bundle args = new Bundle();
|
||||
XlhRankingDialog fragment = new XlhRankingDialog();
|
||||
args.putString("roomId", giftBagId);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
@Nullable
|
||||
@Override
|
||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||
Dialog dialog = super.onCreateDialog(savedInstanceState);
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setCancelable(true);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
Window window = getDialog().getWindow();
|
||||
if (window != null) {
|
||||
// 获取屏幕高度
|
||||
android.util.DisplayMetrics displayMetrics = new android.util.DisplayMetrics();
|
||||
requireActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
|
||||
int screenHeight = displayMetrics.heightPixels;
|
||||
// 设置高度为屏幕高度的100%(全屏)
|
||||
int heightInPx = (int) (screenHeight * 0.8);;
|
||||
window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, heightInPx);
|
||||
window.setBackgroundDrawableResource(android.R.color.transparent);
|
||||
|
||||
// 可选:设置动画样式(从底部弹出)
|
||||
window.setWindowAnimations(R.style.CommonShowDialogBottom);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDialogStyle(Window window) {
|
||||
super.initDialogStyle(window);
|
||||
window.setGravity(Gravity.BOTTOM);
|
||||
}
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
roomId = getArguments().getString("roomId");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
MvpPre.xlhAllRecord(roomId, "1", "20");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
|
||||
mBinding.smartRefreshLayout.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
|
||||
@Override
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
page = 1;
|
||||
MvpPre.xlhAllRecord(roomId, page+"", "20");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
page++;
|
||||
MvpPre.xlhAllRecord(roomId, page+"", "20");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
giftRecordAdapte=new GiftRecordAdapte();
|
||||
mBinding.recyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
|
||||
mBinding.recyclerView.setAdapter(giftRecordAdapte);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.dialog_ranking_xlh_fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGiftListSuccess(BlindBoxBean blindBoxBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawGiftListSuccess(BlindReslutBean blindReslutBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMyRecordSuccess(List<GiftBean> data) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getAllRecordSuccess(List<GiftBean> data) {
|
||||
|
||||
if (data != null){
|
||||
if (page==1){
|
||||
giftRecordAdapte.setNewData(data);
|
||||
}else {
|
||||
giftRecordAdapte.addData(data);
|
||||
}
|
||||
}else {
|
||||
if (page == 1) {
|
||||
giftRecordAdapte.setNewData(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishRefreshLoadMore() {
|
||||
mBinding.smartRefreshLayout.finishRefresh();
|
||||
mBinding.smartRefreshLayout.finishLoadMore();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wallet(WalletBean walletBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void xlhChouSuccess(List<XlhDrawBean> data) {
|
||||
|
||||
}
|
||||
}
|
||||