Compare commits

...

23 Commits

Author SHA1 Message Date
abed908e70 Merge remote-tracking branch 'origin/master' 2025-09-26 23:51:15 +08:00
f68f6721e9 1.修改代码 2025-09-26 23:49:52 +08:00
062fc7b0ed 修改巡乐会动画 2025-09-26 22:25:22 +08:00
4a21c866f4 修改动画 2025-09-26 21:19:01 +08:00
4e06c6742d 修改动画 2025-09-26 21:05:11 +08:00
e5a7b480c3 1.添加幸运榜单
2.显示跳过动画
2025-09-26 21:03:14 +08:00
888c04ce11 1.自定view 2025-09-26 16:27:38 +08:00
903ea22dfd Merge remote-tracking branch 'origin/master' 2025-09-26 16:17:41 +08:00
9f54c26d0e 1.合并分支 2025-09-26 16:15:56 +08:00
3d54880dc0 Merge remote-tracking branch 'origin/master' 2025-09-26 16:00:16 +08:00
5c5d2550bd 1.合并分支 2025-09-26 16:00:01 +08:00
c96d41ccd7 1:修改测试H5的地址 2025-09-26 15:55:08 +08:00
3b6df9ec66 Merge remote-tracking branch 'origin/master' 2025-09-26 15:44:49 +08:00
77a1d910f0 1.定位的修改 2025-09-26 15:43:31 +08:00
393c59dd1b 1.定位的问题 2025-09-26 15:43:23 +08:00
a883aa86e5 1.定位的问题 2025-09-26 15:43:10 +08:00
7e14ba3fcb 添加ignore文件 2025-09-26 15:15:16 +08:00
43c431cc8f Remove .idea directory from version control 2025-09-26 15:09:18 +08:00
bd4a769347 Add .gitignore file to exclude Android Studio configs 2025-09-26 15:09:07 +08:00
2673835fc6 Merge branch 'dev_lxj' 2025-09-26 14:43:12 +08:00
a4caa9b078 1:修改页面,更换room变成kotlin,
2:在所有的跳转到WEBview的时候,使用Intent的方式
3:优化网络请求
2025-09-26 14:32:35 +08:00
2f06d60fec Rename .java to .kt 2025-09-26 14:32:34 +08:00
7a084b6b2b 1.定位的修改 2025-09-26 14:22:48 +08:00
111 changed files with 7188 additions and 5779 deletions

25
.gitignore vendored
View File

@@ -1,20 +1,9 @@
.idea/
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
build/
local.properties
# ProGuard files
/app/proguard/
/seeds.txt
/usage.txt
/mapping.txt
.gradle/
.externalNativeBuild/
.DS_Store
*.dm
*.log

3
.idea/.gitignore generated vendored
View File

@@ -1,3 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml

1
.idea/.name generated
View File

@@ -1 +0,0 @@
秘地

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AppInsightsSettings">
<option name="selectedTabId" value="Android Vitals" />
</component>
</project>

View File

@@ -1,117 +0,0 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<codeStyleSettings language="XML">
<option name="FORCE_REARRANGE_MODE" value="1" />
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions>
<arrangement>
<rules>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:android</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:id</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>style</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
<order>ANDROID_ATTRIBUTE_ORDER</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>.*</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
</rules>
</arrangement>
</codeStyleSettings>
</code_scheme>
</component>

6
.idea/compiler.xml generated
View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="17" />
</component>
</project>

View File

@@ -15,4 +15,4 @@
</SelectionState>
</selectionStates>
</component>
</project>
</project>

6
.idea/encodings.xml generated
View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" defaultCharsetForPropertiesFiles="UTF-8">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>

33
.idea/gradle.xml generated
View File

@@ -1,33 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="CHOOSE_PER_TEST" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="jbr-17" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
<option value="$PROJECT_DIR$/moduleLogin" />
<option value="$PROJECT_DIR$/moduleUtil" />
<option value="$PROJECT_DIR$/modulecircle" />
<option value="$PROJECT_DIR$/modulemain" />
<option value="$PROJECT_DIR$/modulenews" />
<option value="$PROJECT_DIR$/moduleroom" />
<option value="$PROJECT_DIR$/moduletablayout" />
<option value="$PROJECT_DIR$/modulevocal" />
<option value="$PROJECT_DIR$/modulevoice" />
<option value="$PROJECT_DIR$/timcommon" />
<option value="$PROJECT_DIR$/tuichat" />
<option value="$PROJECT_DIR$/tuiconversation" />
<option value="$PROJECT_DIR$/tuicore" />
</set>
</option>
<option name="resolveExternalAnnotations" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>

View File

@@ -1,63 +0,0 @@
<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" />
</inspection_tool>
<inspection_tool class="ComposePreviewMustBeTopLevelFunction" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
<option name="previewFile" value="true" />
</inspection_tool>
<inspection_tool class="ComposePreviewNeedsComposableAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
<option name="previewFile" value="true" />
</inspection_tool>
<inspection_tool class="ComposePreviewNotSupportedInUnitTestFiles" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
<option name="previewFile" value="true" />
</inspection_tool>
<inspection_tool class="GlancePreviewDimensionRespectsLimit" enabled="true" level="WARNING" enabled_by_default="true">
<option name="composableFile" value="true" />
</inspection_tool>
<inspection_tool class="GlancePreviewMustBeTopLevelFunction" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
</inspection_tool>
<inspection_tool class="GlancePreviewNeedsComposableAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
</inspection_tool>
<inspection_tool class="GlancePreviewNotSupportedInUnitTestFiles" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
</inspection_tool>
<inspection_tool class="JavadocDeclaration" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ADDITIONAL_TAGS" value="data,description:" />
</inspection_tool>
<inspection_tool class="PreviewAnnotationInFunctionWithParameters" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
<option name="previewFile" value="true" />
</inspection_tool>
<inspection_tool class="PreviewApiLevelMustBeValid" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
<option name="previewFile" value="true" />
</inspection_tool>
<inspection_tool class="PreviewDeviceShouldUseNewSpec" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="composableFile" value="true" />
<option name="previewFile" value="true" />
</inspection_tool>
<inspection_tool class="PreviewFontScaleMustBeGreaterThanZero" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
<option name="previewFile" value="true" />
</inspection_tool>
<inspection_tool class="PreviewMultipleParameterProviders" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
<option name="previewFile" value="true" />
</inspection_tool>
<inspection_tool class="PreviewPickerAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
<option name="previewFile" value="true" />
</inspection_tool>
</profile>
</component>

6
.idea/kotlinc.xml generated
View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="KotlinJpsPluginSettings">
<option name="version" value="1.9.24" />
</component>
</project>

10
.idea/migrations.xml generated
View File

@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectMigrations">
<option name="MigrateToGradleLocalJavaHome">
<set>
<option value="$PROJECT_DIR$" />
</set>
</option>
</component>
</project>

55
.idea/misc.xml generated
View File

@@ -1,55 +0,0 @@
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="androidx.annotation.Nullable" />
<option name="myDefaultNotNull" value="androidx.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="15">
<item index="0" class="java.lang.String" itemvalue="org.jspecify.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="com.android.annotations.Nullable" />
<item index="2" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNullable" />
<item index="3" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableDecl" />
<item index="4" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.Nullable" />
<item index="6" class="java.lang.String" itemvalue="org.eclipse.jdt.annotation.Nullable" />
<item index="7" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="8" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
<item index="9" class="java.lang.String" itemvalue="jakarta.annotation.Nullable" />
<item index="10" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
<item index="11" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="12" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.Nullable" />
<item index="13" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableType" />
<item index="14" class="java.lang.String" itemvalue="android.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="15">
<item index="0" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNonNull" />
<item index="1" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.NonNull" />
<item index="2" class="java.lang.String" itemvalue="org.jspecify.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="jakarta.annotation.Nonnull" />
<item index="4" class="java.lang.String" itemvalue="androidx.annotation.NonNull" />
<item index="5" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullType" />
<item index="6" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
<item index="7" class="java.lang.String" itemvalue="com.android.annotations.NonNull" />
<item index="8" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullDecl" />
<item index="10" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="11" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="12" class="java.lang.String" itemvalue="org.eclipse.jdt.annotation.NonNull" />
<item index="13" class="java.lang.String" itemvalue="android.annotation.NonNull" />
<item index="14" class="java.lang.String" itemvalue="lombok.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>

View File

@@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="com.intellij.execution.junit.AbstractAllInDirectoryConfigurationProducer" />
<option value="com.intellij.execution.junit.AllInPackageConfigurationProducer" />
<option value="com.intellij.execution.junit.PatternConfigurationProducer" />
<option value="com.intellij.execution.junit.TestInClassConfigurationProducer" />
<option value="com.intellij.execution.junit.UniqueIdConfigurationProducer" />
<option value="com.intellij.execution.junit.testDiscovery.JUnitTestDiscoveryConfigurationProducer" />
<option value="org.jetbrains.kotlin.idea.junit.KotlinJUnitRunConfigurationProducer" />
<option value="org.jetbrains.kotlin.idea.junit.KotlinPatternConfigurationProducer" />
</set>
</option>
</component>
</project>

6
.idea/vcs.xml generated
View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@@ -116,7 +116,7 @@ android {
}
kotlinOptions {
jvmTarget = '17'
jvmTarget = '11'
}
dexOptions {
dexInProcess true
@@ -144,13 +144,9 @@ dependencies {
implementation files('libs/logger-2.2.2-release.aar')
implementation files('libs/main-2.2.3-release.aar')
implementation files('libs/WbCloudFaceLiveSdk-face-v6.6.2-8e4718fc.aar')
implementation files('libs/WbCloudNormal-v5.1.10-4e3e198.aar')
implementation(libs.arouter.api.v150)
//annotationProcessor
annotationProcessor libs.arouter.compiler
implementation project(':modulevocal') // 必须
annotationProcessor project(':modulevocal') // 关键!
@@ -158,6 +154,10 @@ dependencies {
api project(":moduleLogin")
implementation project(':modulemain')
implementation(libs.arouter.api.v150)
//annotationProcessor
annotationProcessor libs.arouter.compiler
//aar的名称例如WbCloudFaceLiveSdk-v6.0.0-1234567.aar填入'WbCloudFaceLiveSdk-v6.0.0-1234567'
// implementation(name: 'WbCloudFaceLiveSdk-face-v6.6.2-8e4718fc', ext: 'aar')
////2. 云normal SDK

View File

@@ -200,7 +200,7 @@
android:launchMode="singleTask">
</activity>
<activity
android:name=".RealNameActivity"
android:name="com.example.modulevocal.activity.RealNameActivity"
android:exported="false" />
<activity

View File

@@ -12,6 +12,7 @@ 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.activity.WebViewActivity;
import com.xscm.moduleutil.base.AppStateListener;
import com.xscm.moduleutil.base.AppStateManager;
import com.xscm.moduleutil.base.CommonAppContext;
@@ -69,8 +70,13 @@ public class LaunchPageActivity extends BaseAppCompatActivity<ActivityLaunchPage
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青少年模式
// 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青少年模式
Intent intent = new Intent(this, WebViewActivity.class);
intent.putExtra("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url() + "/web/index.html#/pages/feedback/teenage?id=" + SpUtil.getToken());
intent.putExtra("title", "1");
startActivity(intent);
} else {
// 如果没有设置青少年模式,应该导航到首页
try {

View File

@@ -3,8 +3,6 @@
// build.gradle (Project-level)
buildscript {
ext.kotlin_version = '1.9.24' // 根据你使用的 Kotlin 版本调整
repositories {
google()
mavenCentral()
@@ -15,7 +13,6 @@ buildscript {
dependencies {
classpath libs.gradle // 或你使用的 Android Gradle 插件版本
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// ✅ 添加 ARouter 插件依赖
classpath 'com.alibaba:arouter-register:1.0.2'
@@ -28,6 +25,14 @@ plugins {
alias(libs.plugins.android.library) apply false
alias(libs.plugins.kotlin.android) apply false
}
subprojects {
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions {
jvmTarget = "11"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

View File

@@ -6,7 +6,7 @@
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx3072m -XX:MaxPermsize=512m -Xx:+HeapDumponOutofMemoryError -Dfile.encoding=UTF-8
org.gradle.jvmargs=-Xmx3072m -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. For more details, visit
# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
@@ -22,28 +22,27 @@ android.enableJetifier=true
android.nonTransitiveRClass=true
arouter.register.auto=true
isBuildModule=false
#org.gradle.parallel=false
#org.gradle.deamon=false
android.injected.testOnly=false
APP_VERSION_NAME=1.1.0
APP_VERSION_CODE=163
APP_VERSION_NAME=1.1.1
APP_VERSION_CODE=164
org.gradle.jvm.toolchain.useLegacyAdapters=false
#org.gradle.java.home=C\:\\Users\\qx\\.jdks\\ms-17.0.15
org.gradle.parallel=true
org.gradel.daemon=true
org.gradel.configureondemand=true
org.gradle.daemon=true
org.gradle.configureondemand=true
aaptOptions.cruncherEnabled false
aaptOptions.useNewCruncher false
#android.enableR8=true
#isModule
modulevoice=false
# <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
# ʽʱ
beta=false
org.gradle.caching=false
@@ -51,4 +50,7 @@ org.gradle.caching=false
kapt.incremental.apt=false
# 或者禁用特定模块的增量编译
#org.gradle.configureondemand=false
#org.gradle.configureondemand=false
# 统一 Kotlin JVM 目标版本
kotlin.jvm.target.validation.mode=warning

View File

@@ -47,6 +47,7 @@ logger = "2.2.0"
loggingInterceptorVersion = "3.10.0"
multidex = "2.0.1"
ossAndroidSdkVersion = "2.9.21"
permissionx = "1.7.1"
persistentcookiejar = "v1.0.1"
picture_libraryVersion = "v2.6.0"
reactivexRxjava = "2.2.21"
@@ -125,6 +126,7 @@ logger = { module = "com.orhanobut:logger", version.ref = "logger" }
multidex = { module = "androidx.multidex:multidex", version.ref = "multidex" }
#numberprogressbar-library = { module = "com.daimajia.numberprogressbar:library", version.ref = "libraryVersion" }
okhttp3-logging-interceptor = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "loggingInterceptorVersion" }
permissionx = { module = "com.guolindev.permissionx:permissionx", version.ref = "permissionx" }
persistentcookiejar = { module = "com.github.franmontiel:PersistentCookieJar", version.ref = "persistentcookiejar" }
#pictureselector-picture_library = { module = "com.github.LuckSiege.PictureSelector:picture_library", version.ref = "picture_libraryVersion" }
reactivex-rxjava = { module = "io.reactivex.rxjava2:rxjava", version.ref = "reactivexRxjava" }
@@ -164,4 +166,6 @@ kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlinVer
#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" }
kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlinVersion" }
kotlin-android-extensions = { id = "org.jetbrains.kotlin.android.extensions", version.ref = "kotlinVersion" }

View File

@@ -10,6 +10,7 @@ import com.blankj.utilcode.util.ToastUtils;
import com.xscm.modulelogin.activity.ImproveInfoActivity;
import com.xscm.modulelogin.activity.SwitchAccountsActivity;
import com.xscm.modulemain.activity.MainActivity;
import com.xscm.moduleutil.activity.WebViewActivity;
import com.xscm.moduleutil.base.CommonAppContext;
import com.xscm.moduleutil.bean.ThemeBean;
import com.xscm.moduleutil.bean.UserBean;
@@ -264,10 +265,20 @@ public class LoginPresenter extends BasePresenter<LoginContacter.View> implement
}
public void ysxl() {
ARouter.getInstance().build(ARouteConstants.H5).withString("url",CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl() + "/api/Page/page_show?id=4").withString("title", "隐私协议").navigation();
Intent intent = new Intent(com.blankj.utilcode.util.ActivityUtils.getTopActivity(), WebViewActivity.class);
intent.putExtra("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl() + "/api/Page/page_show?id=4");
intent.putExtra("title", "隐私协议");
com.blankj.utilcode.util.ActivityUtils.startActivity(intent);
// ARouter.getInstance().build(ARouteConstants.H5).withString("url",CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl() + "/api/Page/page_show?id=4").withString("title", "隐私协议").navigation();
}
public void yhxy() {
ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl() + "/api/Page/page_show?id=6").withString("title", "用户协议").navigation();
Intent intent = new Intent(com.blankj.utilcode.util.ActivityUtils.getTopActivity(), WebViewActivity.class);
intent.putExtra("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl() + "/api/Page/page_show?id=6");
intent.putExtra("title", "用户协议");
com.blankj.utilcode.util.ActivityUtils.startActivity(intent);
// ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl() + "/api/Page/page_show?id=6").withString("title", "用户协议").navigation();
}
}

View File

@@ -2,7 +2,7 @@ plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
}
//apply plugin: 'kotlin-kapt' // 关键Kotlin 注解处理器
android {
namespace 'com.xscm.moduleutil'
compileSdk 35
@@ -35,14 +35,14 @@ android {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
dataBinding {
enabled = true
}
kotlinOptions {
jvmTarget = '17'
jvmTarget = '11'
}
packagingOptions {
@@ -50,6 +50,13 @@ android {
}
}
// Kotlin 注解处理器参数(针对 Kotlin 代码)
//kapt {
// arguments {
// arg("AROUTER_MODULE_NAME", project.getName())
// }
//}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
@@ -139,8 +146,9 @@ dependencies {
api(libs.alipay.alipaysdk.android)
api(libs.arouter.api.v150)
annotationProcessor libs.arouter.annotation
annotationProcessor libs.arouter.compiler
// implementation 'com.alibaba:arouter-api:1.5.2'
// kapt 'com.alibaba:arouter-compiler:1.5.2'/**/
api(libs.easypermissions)
api(libs.xbanner)
@@ -207,6 +215,8 @@ dependencies {
api 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.5'
api 'io.github.mayzs:paho.mqtt.android:1.2.1'
// room数据库
// def room_version = "2.5.0"
// implementation "androidx.room:room-runtime:$room_version"
@@ -219,4 +229,4 @@ dependencies {
//aar的名称例如WbCloudNormal-v5.1.10-123456789.aar填入 'WbCloudNormal-v5.1.10-123456789.aar'
}
apply plugin: 'com.alibaba.arouter' //
//apply plugin: 'com.alibaba.arouter' //

View File

@@ -766,7 +766,10 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
@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();
Intent intent = new Intent(this, WebViewActivity.class);
intent.putExtra("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url() + "/web/index.html#/pages/union/setGroup?id=" + SpUtil.getToken() + "&guildId=" + id);
startActivity( intent);
// ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url() + "/web/index.html#/pages/union/setGroup?id=" + SpUtil.getToken() + "&guildId=" + id).navigation();
}

View File

@@ -3,6 +3,7 @@ package com.xscm.moduleutil.activity.news;
import static android.view.View.GONE;
import static android.view.View.VISIBLE;
import android.content.Intent;
import android.text.Html;
import android.view.View;
@@ -14,6 +15,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.activity.WebViewActivity;
import com.xscm.moduleutil.base.RoomManager;
import com.xscm.moduleutil.bean.NewsMessageList;
import com.xscm.moduleutil.databinding.ActivityOfficialNoticeBinding;
@@ -79,7 +81,10 @@ public class OfficialNoticeActivity extends BaseMvpActivity<NewsPresenter, Activ
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();
Intent intent = new Intent(OfficialNoticeActivity.this, WebViewActivity.class);
intent.putExtra("url", item.getUrl());
startActivity(intent);
// ARouter.getInstance().build(ARouteConstants.H5).withString("url", item.getUrl()).navigation();
}
}
});

View File

@@ -434,7 +434,8 @@ public class CommonAppContext extends MultiDexApplication implements Applicatio
// startService(mqttServiceIntent);
// }
mqttConnect=MqttConnect.getInstance(this,"tcp://62.234.12.147","android-"+ MqttClient.generateClientId());
mqttConnect=MqttConnect.getInstance(this,"tcp://1.13.181.248","android-"+ MqttClient.generateClientId());
// mqttConnect=MqttConnect.getInstance(this,"tcp://62.234.12.147","android-"+ MqttClient.generateClientId());
mqttConnect.mqttClient();
// 每次启动应用时重置状态

View File

@@ -1,11 +1,14 @@
package com.xscm.moduleutil.base;
import static android.app.PendingIntent.getActivity;
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.ActivityUtils;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.xscm.moduleutil.bean.room.RoomInfoResp;
@@ -124,6 +127,9 @@ public class RoomManager {
if (!CommonAppContext.getInstance().playId.equals(roomId)) {
MessageListenerSingleton.getInstance().joinGroup(roomId);
exitRoom(CommonAppContext.getInstance().playId);
CommonAppContext.getInstance().isShow = false;
CommonAppContext.getInstance().isPlaying = false;
EventBus.getDefault().post(new RoomOutEvent());
} else if (CommonAppContext.getInstance().lable_id.equals("6")) {
upInfo(context, roomId, password, true, null, true);
return;
@@ -334,7 +340,6 @@ public class RoomManager {
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) {

View File

@@ -12,6 +12,7 @@ import lombok.Data;
public class GiftBean {
private String gift_id;
private String periods;
private String gift_name;
private String gift_price;
private int file_type;

View File

@@ -31,7 +31,9 @@ public class BlindBoxBean {
private GiveGift give_homeowner_gift;//房主礼物
private GiveGift locking_gift;//锁定礼物
private xlhUser xlh_user;//巡乐会中奖用户
private xlhUser homeowner_user;//房主信息
public boolean isXlhDataArray() {
return xlh_data instanceof JsonArray || xlh_data instanceof List;

View File

@@ -0,0 +1,130 @@
package com.xscm.moduleutil.dialog;
import android.os.Bundle;
import android.view.Choreographer;
import androidx.annotation.NonNull;
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.DialogNewRankingXlhFragmentBinding;
import com.xscm.moduleutil.databinding.FframentDataBinding;
import com.xscm.moduleutil.dialog.giftLottery.GiftLotteryContacts;
import com.xscm.moduleutil.dialog.giftLottery.GiftLotteryPresenter;
import com.xscm.moduleutil.dialog.giftLottery.GiftRecordAdapte;
import com.xscm.moduleutil.dialog.giftLottery.NewGiftRecordAdapte;
import java.util.List;
public class LotteryFragment extends BaseMvpDialogFragment<GiftLotteryPresenter, FframentDataBinding> implements GiftLotteryContacts.View {
private int page=1;
private String roomId;
private int type=-1;
private GiftRecordAdapte giftRecordAdapte;
@Override
protected GiftLotteryPresenter bindPresenter() {
return new GiftLotteryPresenter(this,getSelfActivity());
}
public static LotteryFragment newInstance(String giftBagId,int type) {
Bundle args = new Bundle();
LotteryFragment fragment = new LotteryFragment();
args.putString("roomId", giftBagId);
args.putInt("type",type);
fragment.setArguments(args);
return fragment;
}
@Override
protected void initData() {
roomId = getArguments().getString("roomId");
type = getArguments().getInt("type");
MvpPre.xlhAllRecord(roomId, "1", "20",type);
}
@Override
protected void initView() {
mBinding.smartRefreshLayout.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
@Override
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
page = 1;
MvpPre.xlhAllRecord(roomId, page+"", "20",type);
}
@Override
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
page++;
MvpPre.xlhAllRecord(roomId, page+"", "20",type);
}
});
giftRecordAdapte=new GiftRecordAdapte();
mBinding.recyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
mBinding.recyclerView.setAdapter(giftRecordAdapte);
}
@Override
protected int getLayoutId() {
return R.layout.fframent_data;
}
@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) {
}
}

View File

@@ -1,7 +1,10 @@
package com.xscm.moduleutil.dialog;
import static com.blankj.utilcode.util.ActivityUtils.startActivity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.text.TextPaint;
@@ -16,6 +19,7 @@ import androidx.databinding.DataBindingUtil;
import com.alibaba.android.arouter.launcher.ARouter;
import com.blankj.utilcode.util.SpanUtils;
import com.xscm.moduleutil.R;
import com.xscm.moduleutil.activity.WebViewActivity;
import com.xscm.moduleutil.base.CommonAppContext;
import com.xscm.moduleutil.databinding.DialogPolicBinding;
import com.xscm.moduleutil.utils.ARouteConstants;
@@ -42,7 +46,12 @@ public class PolicyDialog extends Dialog {
ClickableSpan clickSpan = new ClickableSpan() {
@Override
public void onClick(@NonNull View widget) {
ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=6" ).withString("title", "用户协议").navigation();
Intent intent = new Intent(getContext(), WebViewActivity.class);
intent.putExtra("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=6");
intent.putExtra("title", "用户协议");
startActivity(intent);
// ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=6" ).withString("title", "用户协议").navigation();
}
@Override
@@ -54,7 +63,12 @@ public class PolicyDialog extends Dialog {
ClickableSpan ysClickSpan = new ClickableSpan() {
@Override
public void onClick(@NonNull View widget) {
ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=4").withString("title", "隐私协议").navigation();
Intent intent = new Intent(getContext(), WebViewActivity.class);
intent.putExtra("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=4");
intent.putExtra("title", "隐私协议");
startActivity(intent);
// ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=4").withString("title", "隐私协议").navigation();
}
@Override

View File

@@ -1,6 +1,7 @@
package com.xscm.moduleutil.dialog;
import android.content.Context;
import android.content.Intent;
import android.view.Window;
import android.view.WindowManager;
@@ -9,6 +10,7 @@ import androidx.annotation.NonNull;
import com.alibaba.android.arouter.launcher.ARouter;
import com.blankj.utilcode.util.ScreenUtils;
import com.xscm.moduleutil.R;
import com.xscm.moduleutil.activity.WebViewActivity;
import com.xscm.moduleutil.base.CommonAppContext;
import com.xscm.moduleutil.bean.TeenagerInfo;
import com.xscm.moduleutil.color.ThemeableDrawableUtils;
@@ -55,7 +57,11 @@ 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();
Intent intent = new Intent(getContext(), WebViewActivity.class);
intent.putExtra("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url() + "/web/index.html#/pages/feedback/teenage?id=" + SpUtil.getToken());
getContext().startActivity(intent);
// ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url() + "/web/index.html#/pages/feedback/teenage?id=" + SpUtil.getToken()).navigation();
dismiss();
});

View File

@@ -42,7 +42,7 @@ public class GiftLotteryContacts {
void xlhChou(String room_id,String num);
void xlhAllRecord(String room_id,String page,String pageSize);
void xlhAllRecord(String room_id,String page,String pageSize,int type);
void xlhMyRecord(String room_id,String page,String pageSize);
}

View File

@@ -99,14 +99,14 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
private String blind_box_turntable_id = "";//本次抽奖标识id
private BlindBoxBean.XlhData xlhData;
private int icon;//金币金额
private String heart_id="";
private String heart_id = "";
@Override
protected GiftLotteryPresenter bindPresenter() {
return new GiftLotteryPresenter(this, getActivity());
}
public static GiftLotteryDialog newInstance(String giftBagId, String roomId, String userIds,String heart_id) {
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);
@@ -135,9 +135,9 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
userIds = getArguments().getString("userIds");
// 根据userIds确定类型
userIdType = LotteryEvent.fromLotteryEvent(giftBagId);
heart_id=getArguments().getString("heart_id");
heart_id = getArguments().getString("heart_id");
if (!EventBus.getDefault().isRegistered( this)){
if (!EventBus.getDefault().isRegistered(this)) {
EventBus.getDefault().register(this);
}
}
@@ -149,8 +149,8 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
mBinding.mirroeSky.swLockYx.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean check) {
isOpenSound= check;//音效
if(!check){
isOpenSound = check;//音效
if (!check) {
stopPlay();
}
}
@@ -158,8 +158,8 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
mBinding.cityTime.swLockYx.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean check) {
isOpenSound= check;//音效
if(!check){
isOpenSound = check;//音效
if (!check) {
stopPlay();
}
}
@@ -167,8 +167,8 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
mBinding.pinnacleTime.swLockYx.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean check) {
isOpenSound= check;//音效
if(!check){
isOpenSound = check;//音效
if (!check) {
stopPlay();
}
}
@@ -176,36 +176,36 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
mBinding.mirroeSky.swTex.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean check) {
isOpenSpecial= check;
isOpenSpecial = check;
}
});
mBinding.cityTime.swTex.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean check) {
isOpenSpecial= check;
isOpenSpecial = check;
}
});
mBinding.pinnacleTime.swTex.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean check) {
isOpenSpecial= check;
isOpenSpecial = check;
}
});
}
private void stopPlay(){
if(mediaPlayer!=null&&player!=null){
private void stopPlay() {
if (mediaPlayer != null && player != null) {
player.stop();
player.reset();
player=null;
player = null;
mediaPlayer.stop();
mediaPlayer.reset();
mediaPlayer=null;
mediaPlayer = null;
}
}
@Override
protected void initView() {
// 根据不同的用户类型显示不同的界面
@@ -379,7 +379,7 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
isDrawing = true;
// init(1);
startType = 1;
MvpPre.drawGiftList(giftBagId, userIds, roomId, "1",heart_id);
MvpPre.drawGiftList(giftBagId, userIds, roomId, "1", heart_id);
} else {
// com.hjq.toast.ToastUtils.show("正在抽奖中...");
return;
@@ -389,7 +389,7 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
isDrawing = true;
// init(2);
startType = 2;
MvpPre.drawGiftList(giftBagId, userIds, roomId, "6",heart_id);
MvpPre.drawGiftList(giftBagId, userIds, roomId, "6", heart_id);
} else {
// com.hjq.toast.ToastUtils.show("正在抽奖中...");
@@ -399,7 +399,7 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
isDrawing = true;
// init(3);
startType = 3;
MvpPre.drawGiftList(giftBagId, userIds, roomId, "9",heart_id);
MvpPre.drawGiftList(giftBagId, userIds, roomId, "9", heart_id);
} else {
// com.hjq.toast.ToastUtils.show("正在抽奖中...");
}
@@ -579,17 +579,18 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
@Subscribe(threadMode = ThreadMode.MAIN)
public void onMessageReceived(MqttXlhEnd event) {
XLHBean xlhBean= GsonUtils.fromJson(event.getMessage(), XLHBean.class);
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) {
if (xlhBean.getFrom_type() == 3) {
xlhData.setCurrent_num(0);
xlhData.setStatus(0);
UpView(xlhData);
}
}
/// 定时器
public void startFastAnimate() {
if (allViewsArray.isEmpty()) {
@@ -606,10 +607,10 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
// 停止之前的定时器
stopFastAnimate();
Log.e("isOpenSound===","isOpenSound111"+isOpenSound);
Log.e("isOpenSound===", "isOpenSound111" + isOpenSound);
if (isOpenSound) {
// 假设此处有播放音乐的逻辑
Log.e("isOpenSound===","raw_music.mp");
Log.e("isOpenSound===", "raw_music.mp");
playSound("draw_music.mp3");
// isOpenSound=false;
}
@@ -708,7 +709,8 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
}
private MediaPlayer player;
MediaPlayer mediaPlayer ;
MediaPlayer mediaPlayer;
// 播放音频的方法
private void playSound(String fileName) {
try {
@@ -734,12 +736,14 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
player.prepare();
} catch (IOException e) {
e.printStackTrace();
// 如果assets中没有找到文件尝试从raw资源目录加载
// try {
// player = MediaPlayer.create(getContext(), R.raw.draw_music);
// } catch (Exception ex) {
// ex.printStackTrace();
// }
}
} else {
try {
AssetFileDescriptor afd = getContext().getAssets().openFd(fileName);
player.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
player.prepare();
} catch (IOException e) {
e.printStackTrace();
}
}
return player;
@@ -883,7 +887,7 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
if (blindReslutBean.getBlind_box_turntable_id() != null) {
blind_box_turntable_id = blindReslutBean.getBlind_box_turntable_id();
}
if (allViewsArray.size()>0) {
if (allViewsArray.size() > 0) {
for (int i = 0; i < blindReslutBean.getReslut_list().size(); i++) {
BlindReslutBean.ReslutList reslutList = blindReslutBean.getReslut_list().get(i);
@@ -910,25 +914,25 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
}
}
}
if (MvpPre==null){
if (MvpPre == null) {
MvpPre = new GiftLotteryPresenter(this, getActivity());
}
MvpPre.wallet();
MvpPre.giftSend(blind_box_turntable_id);
Log.e("isOpenSound===","isOpenSound1222"+isOpenSound);
Log.e("isOpenSound===", "isOpenSound1222" + isOpenSound);
if (isOpenSpecial) {//特效
Log.e("isOpenSound===","isOpenSound333"+isOpenSound);
Log.e("isOpenSound===", "isOpenSound333" + isOpenSound);
startFastAnimate();
}else{
if(isOpenSound){//音效
} else {
if (isOpenSound) {//音效
isDrawing = false;
playSound("xuanz.mp3");
}else {
} else {
isDrawing = false;
}
}
}else {
} else {
isDrawing = false;
}
@@ -966,7 +970,7 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
} else if (type == 12) {
mBinding.pinnacleTime.tvIcon.setText(walletBean.getCoin());
}
}else {
} else {
// dialog 已关闭,不进行 UI 更新
return;
}
@@ -1050,7 +1054,7 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
player = null;
}
if (EventBus.getDefault().isRegistered( this)){
if (EventBus.getDefault().isRegistered(this)) {
EventBus.getDefault().unregister(this);
}

View File

@@ -122,6 +122,9 @@ public class GiftLotteryPresenter extends BasePresenter<GiftLotteryContacts.View
@Override
public void onNext(WalletBean walletBean) {
if (MvpRef == null) {
MvpRef = new WeakReference<>(mView);
}
MvpRef.get().wallet(walletBean);
}
});
@@ -170,22 +173,26 @@ public class GiftLotteryPresenter extends BasePresenter<GiftLotteryContacts.View
}
@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);
}
public void xlhAllRecord(String room_id, String page, String pageSize,int type) {
@Override
public void onNext(List<GiftBean> giftBean) {
if (MvpRef==null){
MvpRef=new WeakReference<>(mView);
api.xlhAllRecord(room_id, page, pageSize,type, new BaseObserver<List<GiftBean>>() {
@Override
public void onSubscribe(Disposable d) {
addDisposable(d);
}
MvpRef.get().getAllRecordSuccess(giftBean);
MvpRef.get().finishRefreshLoadMore();
}
});
@Override
public void onNext(List<GiftBean> giftBean) {
if (MvpRef == null) {
MvpRef = new WeakReference<>(mView);
}
MvpRef.get().getAllRecordSuccess(giftBean);
MvpRef.get().finishRefreshLoadMore();
}
});
}
@Override

View File

@@ -13,6 +13,7 @@ public class GiftRecordAdapte extends BaseQuickAdapter<GiftBean, BaseViewHolder>
@Override
protected void convert(BaseViewHolder helper, GiftBean item) {
helper.setText(R.id.tv_user_name, item.getNickname());
helper.setText(R.id.tv_gift_count_name,"x"+item.getCount()+" "+ item.getGift_name());
helper.setText(R.id.tv_time, item.getCreatetime());

View File

@@ -82,8 +82,11 @@ public class GiftXlhChouAdapter extends BaseQuickAdapter<GiftBean, BaseViewHolde
if (selectedIcon != null) {
// 检查当前item是否为选中位置
if (actualPosition == selectedPosition) {
selectedIcon.setVisibility(View.VISIBLE);
selectedIcon.setVisibility(View.GONE);
helper.setBackgroundRes(R.id.ll_bg,R.mipmap.ke_bg);
} else {
helper.setBackgroundRes(R.id.ll_bg,R.mipmap.xlh_cj_item);
selectedIcon.setVisibility(View.GONE);
}
}

View File

@@ -0,0 +1,124 @@
package com.xscm.moduleutil.dialog.giftLottery;
import android.os.Bundle;
import androidx.annotation.NonNull;
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.FframentDataBinding;
import java.util.List;
public class LuckyFragment extends BaseMvpDialogFragment<GiftLotteryPresenter, FframentDataBinding> implements GiftLotteryContacts.View {
private int page=1;
private String roomId;
private int type=-1;
private NewGiftRecordAdapte giftRecordAdapte;
@Override
protected GiftLotteryPresenter bindPresenter() {
return new GiftLotteryPresenter(this,getSelfActivity());
}
public static LuckyFragment newInstance(String giftBagId, int type) {
Bundle args = new Bundle();
LuckyFragment fragment = new LuckyFragment();
args.putString("roomId", giftBagId);
args.putInt("type",type);
fragment.setArguments(args);
return fragment;
}
@Override
protected void initData() {
roomId = getArguments().getString("roomId");
type = getArguments().getInt("type");
MvpPre.xlhAllRecord(roomId, "1", "20",type);
}
@Override
protected void initView() {
mBinding.smartRefreshLayout.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
@Override
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
page = 1;
MvpPre.xlhAllRecord(roomId, page+"", "20",type);
}
@Override
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
page++;
MvpPre.xlhAllRecord(roomId, page+"", "20",type);
}
});
giftRecordAdapte=new NewGiftRecordAdapte();
mBinding.recyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
mBinding.recyclerView.setAdapter(giftRecordAdapte);
}
@Override
protected int getLayoutId() {
return R.layout.fframent_data;
}
@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) {
}
}

View File

@@ -0,0 +1,23 @@
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.GiftBean;
import com.xscm.moduleutil.utils.ImageUtils;
public class NewGiftRecordAdapte extends BaseQuickAdapter<GiftBean, BaseViewHolder> {
public NewGiftRecordAdapte() {
super(R.layout.item_gift_record_new);
}
@Override
protected void convert(BaseViewHolder helper, GiftBean item) {
helper.setText(R.id.tv_issue,item.getPeriods());
helper.setText(R.id.tv_user_name, item.getNickname());
helper.setText(R.id.tv_gift_count_name, item.getGift_name());
helper.setText(R.id.tv_time, item.getCreatetime());
ImageUtils.loadHeadCC(item.getBase_image(),helper.getView(R.id.iv_gift_icon));
}
}

View File

@@ -0,0 +1,174 @@
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.ViewGroup;
import android.view.Window;
import android.widget.RadioGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import com.xscm.moduleutil.R;
import com.xscm.moduleutil.adapter.MyPagerAdapter;
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.DialogNewRankingXlhFragmentBinding;
import com.xscm.moduleutil.dialog.LotteryFragment;
import java.util.ArrayList;
import java.util.List;
/**
*@author qx
*@data 2025/9/4
*@description:巡乐会榜单
*/
public class NewXlhRankingDialog extends BaseMvpDialogFragment<GiftLotteryPresenter, DialogNewRankingXlhFragmentBinding> implements GiftLotteryContacts.View{
private String roomId;
private MyPagerAdapter pagerAdapter;
private List<Fragment> fragmentList;
private List<String> titleList = new ArrayList();
@Override
protected GiftLotteryPresenter bindPresenter() {
return new GiftLotteryPresenter(this,getSelfActivity());
}
public static NewXlhRankingDialog newInstance(String giftBagId) {
Bundle args = new Bundle();
NewXlhRankingDialog fragment = new NewXlhRankingDialog();
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);
}
@Override
protected void initData() {
roomId = getArguments().getString("roomId");
// MvpPre.xlhAllRecord(roomId, "1", "20");
// 初始化Fragment列表
initFragments();
initViewPager();
}
// 初始化Fragment列表
private void initFragments() {
fragmentList = new ArrayList<>();
fragmentList.add(new LotteryFragment().newInstance(roomId,1)); // 第1页抽奖榜单
fragmentList.add(new LuckyFragment().newInstance(roomId,2)); // 第1页抽奖榜单
}
// 初始化ViewPager
private void initViewPager() {
titleList.add("");
titleList.add("");
FragmentManager childFragmentManager = getChildFragmentManager();
pagerAdapter = new MyPagerAdapter(childFragmentManager, fragmentList,titleList );
mBinding.ivViewPager.setAdapter(pagerAdapter);
mBinding.ivViewPager.setCurrentItem(0); // 默认显示第1页
}
@Override
protected void initView() {
mBinding.rbBtn.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
if (checkedId==R.id.radio_all){
mBinding.ivViewPager.setCurrentItem(0);
}else {
mBinding.ivViewPager.setCurrentItem(1);
}
}
});
}
@Override
protected int getLayoutId() {
return R.layout.dialog_new_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) {
}
@Override
public void finishRefreshLoadMore() {
}
@Override
public void wallet(WalletBean walletBean) {
}
@Override
public void xlhChouSuccess(List<XlhDrawBean> data) {
}
}

View File

@@ -3,6 +3,7 @@ package com.xscm.moduleutil.dialog.giftLottery;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Typeface;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Handler;
@@ -57,7 +58,7 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
private CountDownTimer mCountDownTimer;
private long endTime; // 服务器返回的结束时间戳
private String num;
private XlhRankingDialog xlhRankingDialog;
private NewXlhRankingDialog newXlhRankingDialog;
private XlhRecordDialog xlhRecordDialog;
private XlhObtainDialog xlhObtainDialog;
@@ -136,8 +137,8 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
requireActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
int screenHeight = displayMetrics.heightPixels;
// 设置高度为屏幕高度的100%(全屏)
int heightInPx = (int) (screenHeight * 0.79);
window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
int heightInPx = (int) (screenHeight * 0.85);
window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, heightInPx);
window.setBackgroundDrawableResource(android.R.color.transparent);
// 可选:设置动画样式(从底部弹出)
@@ -181,6 +182,8 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
mBinding.recycleView.scrollToPosition(middlePosition);
}
});
mBinding.tvNumber.setText("x0");
mBinding.tvNumber.setTypeface(android.graphics.Typeface.create("sans-serif-condensed", Typeface.BOLD));
}
// 添加自动滚动相关的方法
@@ -298,12 +301,12 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
dialog.show();
} else if (id == R.id.tv_bd) {
// 如果当前dialog存在且正在显示先关闭
if (xlhRankingDialog != null && xlhRankingDialog.isVisible()) {
xlhRankingDialog.dismiss();
if (newXlhRankingDialog != null && newXlhRankingDialog.isVisible()) {
newXlhRankingDialog.dismiss();
}
xlhRankingDialog = XlhRankingDialog.newInstance(roomId);
xlhRankingDialog.show(getChildFragmentManager(), "XlhRankingDialog");
newXlhRankingDialog = NewXlhRankingDialog.newInstance(roomId);
newXlhRankingDialog.show(getChildFragmentManager(), "newXlhRankingDialog");
} else if (id == R.id.tv_jl) {
// 如果当前dialog存在且正在显示先关闭
if (xlhRecordDialog != null && xlhRecordDialog.isVisible()) {
@@ -329,6 +332,7 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
@Override
public void getGiftListSuccess(BlindBoxBean blindBoxBean) {
if (blindBoxBean != null) {
getRule_url = blindBoxBean.getRule_url();
upTitle(blindBoxBean.getBox_price());
giftLists = blindBoxBean.getGift_list();
@@ -338,9 +342,10 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
// 获取结束时间并启动倒计时
if (blindBoxBean.getXlh_end_time() != null && !blindBoxBean.getXlh_end_time().isEmpty()) {
try {
// 假设 end_time 是时间戳字符串
endTime = Long.parseLong(blindBoxBean.getXlh_end_time());
startCountdown();
mBinding.qxDjs.setEndTime(endTime);
// 假设 end_time 是时间戳字符串
// startCountdown();
} catch (NumberFormatException e) {
// 如果不是时间戳,可能是日期字符串,需要相应解析
// 例如2025-08-26 19:10:47
@@ -350,20 +355,33 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
}
if (blindBoxBean.getGive_homeowner_gift() != null) {
ImageUtils.loadHeadCC(blindBoxBean.getGive_homeowner_gift().getBase_image(), mBinding.giveIm);
// ImageUtils.loadHeadCC(blindBoxBean.getGive_homeowner_gift().getBase_image(), mBinding.giveIm);
mBinding.gvFzlw.setModel(blindBoxBean.getGive_homeowner_gift());
}
if (blindBoxBean.getLocking_gift() != null) {
ImageUtils.loadHeadCC(blindBoxBean.getLocking_gift().getBase_image(), mBinding.giftImg);
mBinding.tvGiftName.setText(blindBoxBean.getLocking_gift().getGift_name());
mBinding.tvGiftPrice.setText(blindBoxBean.getLocking_gift().getGift_price());
mBinding.tvGiftCount.setText(blindBoxBean.getLocking_gift().getGift_num());
// ImageUtils.loadHeadCC(blindBoxBean.getLocking_gift().getBase_image(), mBinding.giftImg);
// mBinding.tvGiftName.setText(blindBoxBean.getLocking_gift().getGift_name());
// mBinding.tvGiftPrice.setText(blindBoxBean.getLocking_gift().getGift_price());
// mBinding.tvGiftCount.setText(blindBoxBean.getLocking_gift().getGift_num());
mBinding.tvNumber.setText("x"+(blindBoxBean.getLocking_gift().getGift_num()!=null ?blindBoxBean.getLocking_gift().getGift_num():"0"));
mBinding.gvSdlw.setModel(blindBoxBean.getLocking_gift());
mBinding.gvSdlw.setIsLockGift(true);
mBinding.gvSdlw.stopAnimation();
mBinding.gvSdlw.startAnimation();
}
if (blindBoxBean.getXlh_user() != null) {
ImageUtils.loadHeadCC(blindBoxBean.getXlh_user().getAvatar(), mBinding.userPic);
mBinding.userName.setText(blindBoxBean.getXlh_user().getNickname());
}
// ImageUtils.loadHeadCC(blindBoxBean.getXlh_user().getAvatar(), mBinding.userPic);
// mBinding.userName.setText(blindBoxBean.getXlh_user().getNickname());
mBinding.gvXyz.setModel(blindBoxBean.getXlh_user());
}
mBinding.gvXyz.setIsLuckUser(true);
if (blindBoxBean.getHomeowner_user()!=null){
mBinding.gvFz.setModel(blindBoxBean.getHomeowner_user());
}
mBinding.gvFz.setIsLuckUser(false);
giftXlhChouAdapter.setNewData(giftLists);
// // 数据加载完成后启动自动滚动
// if (giftLists != null && !giftLists.isEmpty()) {
@@ -394,10 +412,17 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
if (message.getMsgType() == 1057) {
// UpView(message.getText().getXlh_data());
endTime = Long.parseLong(message.getText().getEnd_time() != null ? message.getText().getEnd_time() : "0");
startCountdown();
mBinding.tvGiftCount.setText(message.getText().getGift_num() != null ? message.getText().getGift_num() : "0");
mBinding.userName.setText(message.getText().getFromUserInfo().getNickname() != null ? message.getText().getFromUserInfo().getNickname() : "");
ImageUtils.loadHeadCC(message.getText().getFromUserInfo().getAvatar(), mBinding.userPic);
// startCountdown();
// mBinding.tvGiftCount.setText(message.getText().getGift_num() != null ? message.getText().getGift_num() : "0");
// mBinding.userName.setText(message.getText().getFromUserInfo().getNickname() != null ? message.getText().getFromUserInfo().getNickname() : "");
// ImageUtils.loadHeadCC(message.getText().getFromUserInfo().getAvatar(), mBinding.userPic);
BlindBoxBean.xlhUser xlhUser = new BlindBoxBean.xlhUser();
xlhUser.setAvatar(message.getText().getFromUserInfo().getAvatar());
xlhUser.setNickname(message.getText().getFromUserInfo().getNickname());
mBinding.gvXyz.setModel(xlhUser);
mBinding.qxDjs.setEndTime(endTime);
mBinding.tvNumber.setText("x"+(message.getText().getGift_num() != null ? message.getText().getGift_num() : "0"));
isDrawing=false;
}
}
@@ -517,8 +542,8 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
}
// 如果当前dialog存在且正在显示先关闭
if (xlhRankingDialog != null && xlhRankingDialog.isVisible()) {
xlhRankingDialog.dismiss();
if (newXlhRankingDialog != null && newXlhRankingDialog.isVisible()) {
newXlhRankingDialog.dismiss();
}
if (xlhObtainDialog != null && xlhObtainDialog.isShowing()) {

View File

@@ -44,7 +44,7 @@ public class XlhRankingDialog extends BaseMvpDialogFragment<GiftLotteryPresenter
return new GiftLotteryPresenter(this,getSelfActivity());
}
public static XlhRankingDialog newInstance(String giftBagId) {
public static XlhRankingDialog newInstance(String giftBagId,int type) {
Bundle args = new Bundle();
XlhRankingDialog fragment = new XlhRankingDialog();
args.putString("roomId", giftBagId);
@@ -93,7 +93,7 @@ public class XlhRankingDialog extends BaseMvpDialogFragment<GiftLotteryPresenter
@Override
protected void initData() {
MvpPre.xlhAllRecord(roomId, "1", "20");
MvpPre.xlhAllRecord(roomId, "1", "20",1);
}
@@ -105,14 +105,14 @@ public class XlhRankingDialog extends BaseMvpDialogFragment<GiftLotteryPresenter
@Override
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
page = 1;
MvpPre.xlhAllRecord(roomId, page+"", "20");
MvpPre.xlhAllRecord(roomId, page+"", "20",1);
}
@Override
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
page++;
MvpPre.xlhAllRecord(roomId, page+"", "20");
MvpPre.xlhAllRecord(roomId, page+"", "20",1);
}
});

View File

@@ -0,0 +1,134 @@
package com.xscm.moduleutil.http;
import android.content.Context;
import android.widget.Toast;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.xscm.moduleutil.base.CommonAppContext;
import org.greenrobot.eventbus.EventBus;
import java.io.IOException;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/**
* 通用的API响应处理回调类
* 统一处理所有接口的响应和错误情况
*/
public abstract class ApiResponseCallback<T> implements Callback<BaseModel<T>> {
private Context mContext;
// 构造方法,传入上下文用于显示提示
public ApiResponseCallback(Context context) {
this.mContext = context;
}
@Override
public void onResponse(Call<BaseModel<T>> call, Response<BaseModel<T>> response) {
// 统一处理HTTP响应
if (response.isSuccessful()) {
// 处理200-299范围内的HTTP状态码
BaseModel<T> body = response.body();
if (body != null) {
// 根据code值进行不同处理
switch (body.getCode()) {
case 1: // 接口返回成功
// 业务成功,回调给具体实现
// 即使data为null也调用onSuccess由具体实现决定如何处理null值
onSuccess(body.getData());
break;
case 0: // 接口请求成功但数据错误
// 显示错误信息
// String errorMsg = body.getMsg() != null ? body.getMsg() : "操作失败,请重试";
// showToast(errorMsg);
onFailure(new Exception(body.getMsg()));
break;
case 301: // 登录失效
// 显示错误信息并退出应用
// String loginErrorMsg = body.getMsg() != null ? body.getMsg() : "登录已失效,请重新登录";
showToast(body.getMsg());
try {
// 发送退出登录事件
// EventBus.getDefault().post(new com.xscm.moduleutil.event.LogOutEvent());
// 清除登录信息
CommonAppContext.getInstance().clearLoginInfo();
// 跳转到登录页面
// android.content.Intent intent = new android.content.Intent(CommonAppContext.getInstance(), Class.forName("com.xscm.midi.LaunchPageActivity"));
// intent.addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK | android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK);
// CommonAppContext.getInstance().startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
}
onFailure(new Exception(body.getMsg()));
break;
default:
// 其他错误情况
String defaultErrorMsg = body.getMsg() != null ? body.getMsg() : "未知错误";
showToast(defaultErrorMsg);
onFailure(new Exception(defaultErrorMsg));
break;
}
} else {
// 响应体为空的情况
String errorMsg = "获取数据失败,请重试";
showToast(errorMsg);
onFailure(new Exception(errorMsg));
}
} else {
// 处理HTTP错误状态码
String errorInfo;
try {
if (response.errorBody() != null) {
errorInfo = response.errorBody().string();
// 可以在这里统一解析错误响应体
} else {
errorInfo = "请求失败,状态码:" + response.code();
}
} catch (IOException e) {
errorInfo = "请求失败,状态码:" + response.code();
e.printStackTrace();
}
showToast("");
onFailure(new Exception(errorInfo));
}
}
@Override
public void onFailure(Call<BaseModel<T>> call, Throwable t) {
// 统一处理网络异常
String errorMsg;
if (t instanceof IOException) {
// errorMsg = "网络异常,请检查网络连接";
} else {
// errorMsg = "请求处理失败,请重试";
}
showToast("");
// 回调给具体实现处理
onFailure(t);
}
// 显示提示信息
private void showToast(String message) {
if (mContext != null) {
Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show();
}
}
// 业务成功时的回调,由具体接口实现
public abstract void onSuccess(T data);
// 错误时的回调,可选实现
public void onFailure(Throwable t) {
// 可以留空,由子类选择性实现
LogUtils.e("接口错误:",t);
}
}

View File

@@ -767,6 +767,9 @@ public interface ApiServer {
@FormUrlEncoded
@POST(Constants.POST_XLH_ALL_RECORD)
Call<BaseModel<List<GiftBean>>> xlhAllRecord(@Field("room_id") String room_id, @Field("page") String page, @Field("page_size") String page_size);
@FormUrlEncoded
@POST(Constants.Get_XH_RANking)
Call<BaseModel<List<GiftBean>>> xlXH_RANking(@Field("room_id") String room_id, @Field("page") String page, @Field("page_size") String page_size);
@GET(Constants.GET_XLH_MY_RECORD)
Call<BaseModel<List<GiftBean>>> xlhMyRecord(@Query("room_id") String room_id, @Query("page") String page, @Query("page_size") String page_size);

View File

@@ -0,0 +1,74 @@
package com.xscm.moduleutil.http;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import com.blankj.utilcode.util.ToastUtils;
import com.xscm.moduleutil.base.CommonAppContext;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import okhttp3.ResponseBody;
import retrofit2.Converter;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
public class BusinessAwareConverterFactory extends Converter.Factory {
private final GsonConverterFactory originalFactory;
private final Context context;
public BusinessAwareConverterFactory(Context context) {
this.context = context;
this.originalFactory = GsonConverterFactory.create();
}
@Override
public Converter<ResponseBody, ?> responseBodyConverter(Type type,
Annotation[] annotations,
Retrofit retrofit) {
final Converter<ResponseBody, ?> delegate =
originalFactory.responseBodyConverter(type, annotations, retrofit);
return new Converter<ResponseBody, Object>() {
@Override
public Object convert(ResponseBody value) throws IOException {
// 先读取响应字符串检查业务状态码
String responseString = value.string();
try {
JSONObject jsonObject = new JSONObject(responseString);
int code = jsonObject.getInt("code");
String msg = jsonObject.getString("msg");
if (code == 301) {
handleForceLogout();
ToastUtils.showShort(msg);
}
// 重新构建 ResponseBody 供原始转换器使用
ResponseBody newValue = ResponseBody.create(value.contentType(), responseString);
return delegate.convert(newValue);
} catch (JSONException e) {
throw new IOException("");
}
}
private void handleForceLogout() {
new Handler(Looper.getMainLooper()).post(() -> {
try {
CommonAppContext.getInstance().clearLoginInfo();
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
});
}
};
}
}

View File

@@ -234,7 +234,29 @@ public class RetrofitClient {
}
return INSTANCE;
}
/**
* 检查网络连接状态
* @return true表示网络可用false表示网络不可用
*/
private boolean isNetworkAvailable() {
ConnectivityManager connectivityManager = (ConnectivityManager) CommonAppContext.getInstance()
.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivityManager != null) {
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
return activeNetworkInfo != null && activeNetworkInfo.isConnected();
}
return false;
}
/**
* 网络不可用时的统一处理方法
* @param observer BaseObserver对象
* @param <T> 泛型类型
*/
private <T> void handleNetworkUnavailable(BaseObserver<T> observer) {
ToastUtils.showShort("网络不可用,请检查网络设置");
observer.onError(new Throwable("网络不可用,请检查网络设置"));
}
public <T> T createApiClient(Class<T> apiClientClass) {
return mRetrofit.create(apiClientClass);
}
@@ -1748,6 +1770,11 @@ public class RetrofitClient {
}
public void roomGetIn(String roomId, String password, BaseObserver<RoomInfoResp> observer) {
if (!isNetworkAvailable()) {
handleNetworkUnavailable(observer);
CommonAppContext.getInstance().isRoomJoininj=false;
return;
}
sApiServer.roomGetIn(roomId, password).enqueue(new Callback<BaseModel<RoomInfoResp>>() {
@Override
@@ -2146,28 +2173,33 @@ public class RetrofitClient {
});
}
public void roomAuctionJoin(String auctionId, String userId, String giftId, String
num, String type, BaseObserver<RoomAuction.AuctionListBean> observer) {
sApiServer.roomAuctionJoin(auctionId, userId, giftId, num, type).enqueue(new Callback<BaseModel<RoomAuction.AuctionListBean>>() {
@Override
public void onResponse(Call<BaseModel<RoomAuction.AuctionListBean>> call, Response<BaseModel<RoomAuction.AuctionListBean>> response) {
if (response.code() == 200) {
BaseModel<RoomAuction.AuctionListBean> baseModel = response.body();
if (baseModel.getCode() == 1) {
observer.onNext(baseModel.getData());
} else {
ToastUtils.showShort(baseModel.getMsg());
public void roomAuctionJoin(String auctionId, String userId, String giftId, String num, String type, BaseObserver<RoomAuction.AuctionListBean> observer) {
sApiServer.roomAuctionJoin(auctionId, userId, giftId, num, type).enqueue(new ApiResponseCallback<RoomAuction.AuctionListBean>(CommonAppContext.getInstance()) {
@Override
public void onSuccess(RoomAuction.AuctionListBean data) {
observer.onNext(data);
}
}
}
@Override
public void onFailure(Call<BaseModel<RoomAuction.AuctionListBean>> call, Throwable t) {
t.printStackTrace();
}
});
});
// .enqueue(new Callback<BaseModel<RoomAuction.AuctionListBean>>() {
//
// @Override
// public void onResponse(Call<BaseModel<RoomAuction.AuctionListBean>> call, Response<BaseModel<RoomAuction.AuctionListBean>> response) {
// if (response.code() == 200) {
// BaseModel<RoomAuction.AuctionListBean> baseModel = response.body();
//
// if (baseModel.getCode() == 1) {
// observer.onNext( null);
// } else {
// ToastUtils.showShort(baseModel.getMsg());
// }
// }
// }
//
// @Override
// public void onFailure(Call<BaseModel<RoomAuction.AuctionListBean>> call, Throwable t) {
// t.printStackTrace();
// }
// });
}
public void auctionDelay(String auctionId, BaseObserver<String> observer) {
@@ -3493,23 +3525,45 @@ public class RetrofitClient {
}
public void xlhAllRecord(String roomId, String page, String
pageSize, BaseObserver<List<GiftBean>> observer) {
sApiServer.xlhAllRecord(roomId, page, pageSize).enqueue(new Callback<BaseModel<List<GiftBean>>>() {
@Override
public void onResponse(Call<BaseModel<List<GiftBean>>> call, Response<BaseModel<List<GiftBean>>> response) {
if (response.code() == 200) {
BaseModel<List<GiftBean>> baseModel = response.body();
if (baseModel.getCode() == 1) {
observer.onNext(baseModel.getData());
pageSize,int type, BaseObserver<List<GiftBean>> observer) {
if (type==1) {
sApiServer.xlhAllRecord(roomId, page, pageSize).enqueue(new Callback<BaseModel<List<GiftBean>>>() {
@Override
public void onResponse(Call<BaseModel<List<GiftBean>>> call, Response<BaseModel<List<GiftBean>>> response) {
if (response.code() == 200) {
BaseModel<List<GiftBean>> baseModel = response.body();
if (baseModel.getCode() == 1) {
observer.onNext(baseModel.getData());
}
}
}
}
@Override
public void onFailure(Call<BaseModel<List<GiftBean>>> call, Throwable t) {
t.printStackTrace();
}
});
@Override
public void onFailure(Call<BaseModel<List<GiftBean>>> call, Throwable t) {
t.printStackTrace();
}
});
}else {
sApiServer.xlXH_RANking(roomId,page,pageSize).enqueue(new Callback<BaseModel<List<GiftBean>>>() {
@Override
public void onResponse(Call<BaseModel<List<GiftBean>>> call, Response<BaseModel<List<GiftBean>>> response) {
if (response.code() == 200) {
BaseModel<List<GiftBean>> baseModel = response.body();
if (baseModel.getCode() == 1) {
LogUtils.e("xlXH_RANking", response.body().toString());
observer.onNext(baseModel.getData());
}
}
}
@Override
public void onFailure(Call<BaseModel<List<GiftBean>>> call, Throwable t) {
t.printStackTrace();
}
});
}
}
public void xlhMyRecord(String roomId, String page, String

View File

@@ -21,9 +21,9 @@ public class ARouteConstants {
public static final String CREATED_ROOM = "/modulevocal/CreatedRoomActivity"; //创建房间
public static final String WITHDRAWAL_ACTIVITY = "/modulevocal/WithdrawalActivity"; //提现
public static final String REAL_NAME_ACTIVITY ="/modulevocal/RealNameActivity"; //实名认证
public static final String REAL_NAME_ACTIVITY2 ="/app/RealNameActivity"; //实名认证
public static final String H5 ="/moduleutil/WebViewActivity"; //网页
public static final String GIFT_WALL ="/moduleroom/UserGiftWallFragment"; //实名认证
public static final String REAL_NAME_ACTIVITY2 ="/modulevocal/RealNameActivity"; //实名认证
public static final String H5 ="/moduleUtil/WebViewActivity"; //网页
// public static final String GIFT_WALL ="/moduleroom/UserGiftWallFragment"; //实名认证
public static final String RECHARGE_ACTIVITY ="/modulevocal/RechargeActivity"; //实名认证

View File

@@ -26,7 +26,7 @@ public enum EnvironmentEnum {
1600106397,
"05b406b4541e413887d8d2bf9be8642c",
"tcp://1.13.181.248",
"https://chatvespa.qxmier.com");
"https://tmd.xscmmidi.site/h5");
private final String serverUrl;//服务器地址
private final String ALI_AUTH_KEY;//阿里云授权key

View File

@@ -1,119 +0,0 @@
package com.xscm.moduleutil.view;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import androidx.appcompat.widget.AppCompatImageView;
import com.xscm.moduleutil.R;
public class AvatarWithDecoration extends AppCompatImageView {
// 挂件图片
private Drawable decoration;
// 挂件位置偏移量
private int decorationOffsetX = 0;
private int decorationOffsetY = 0;
// 挂件大小比例(相对于头像)
private float decorationScale = 0.3f;
public AvatarWithDecoration(Context context) {
super(context);
init();
}
public AvatarWithDecoration(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public AvatarWithDecoration(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AvatarWithDecoration);
decoration = a.getDrawable(R.styleable.AvatarWithDecoration_decoration);
decorationScale = a.getFloat(R.styleable.AvatarWithDecoration_decorationScale, 0.3f);
decorationOffsetX = a.getInt(R.styleable.AvatarWithDecoration_decorationOffsetX, 0);
decorationOffsetY = a.getInt(R.styleable.AvatarWithDecoration_decorationOffsetY, 0);
a.recycle();
}
private void init() {
// 可以在这里设置默认的挂件
decoration = getResources().getDrawable(R.mipmap.xlh_image);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
// 如果有挂件,则绘制挂件
if (decoration != null) {
drawDecoration(canvas);
}
}
private void drawDecoration(Canvas canvas) {
// 获取头像的宽高
int avatarWidth = getWidth();
int avatarHeight = getHeight();
// 计算挂件的大小
int decorationWidth = (int) (avatarWidth * decorationScale);
int decorationHeight = (int) (avatarHeight * decorationScale);
// 计算挂件的位置(右下角)
int left = avatarWidth - decorationWidth + decorationOffsetX;
int top = avatarHeight - decorationHeight + decorationOffsetY;
int right = left + decorationWidth;
int bottom = top + decorationHeight;
// 设置挂件的绘制边界
decoration.setBounds(left, top, right, bottom);
// 绘制挂件
decoration.draw(canvas);
}
/**
* 设置挂件图片
*/
public void setDecoration(Drawable decoration) {
this.decoration = decoration;
invalidate();
}
/**
* 设置挂件图片通过Bitmap
*/
public void setDecoration(Bitmap bitmap) {
if (bitmap != null) {
this.decoration = new BitmapDrawable(getResources(), bitmap);
invalidate();
}
}
/**
* 设置挂件位置偏移量
*/
public void setDecorationOffset(int offsetX, int offsetY) {
this.decorationOffsetX = offsetX;
this.decorationOffsetY = offsetY;
invalidate();
}
/**
* 设置挂件大小比例
*/
public void setDecorationScale(float scale) {
if (scale > 0 && scale <= 1) {
this.decorationScale = scale;
invalidate();
}
}
}

View File

@@ -1,373 +0,0 @@
package com.xscm.moduleutil.view;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PointF;
import android.graphics.RectF;
import android.graphics.Shader;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.View;
import androidx.annotation.Nullable;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.transition.Transition;
import com.xscm.moduleutil.R;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class FashionAvatarView extends View {
// 头像相关属性
private Bitmap mAvatarBitmap;
private String mAvatarUrl;
private Drawable mPlaceholderAvatar;
private int mAvatarRadius;
private int mAvatarBorderWidth;
private int mAvatarBorderColor;
// 顶部标签属性
private String mTagText;
private int mTagTextColor;
private float mTagTextSize;
private int mTagBackgroundColor;
private float mTagCornerRadius;
private int mTagPadding;
private int mTagOffsetY; // 标签Y轴偏移量
// 底部文字属性
private String mBottomText;
private int mBottomTextColor;
private float mBottomTextSize;
private int mBottomTextOffsetY; // 底部文字Y轴偏移量
// 爱心装饰属性
private Drawable mHeartIcon;
private int mHeartCount;
private int mHeartSize;
private List<PointF> mHeartPositions = new ArrayList<>();
private Random mRandom = new Random();
// 画笔
private Paint mAvatarPaint;
private Paint mTextPaint;
private Paint mTagBgPaint;
public FashionAvatarView(Context context) {
this(context, null);
}
public FashionAvatarView(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
public FashionAvatarView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initAttrs(context, attrs);
initPaints();
}
private void initAttrs(Context context, AttributeSet attrs) {
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.FashionAvatarView);
// 头像属性
mAvatarUrl = ta.getString(R.styleable.FashionAvatarView_avatarUrl);
mPlaceholderAvatar = ta.getDrawable(R.styleable.FashionAvatarView_placeholderAvatar);
mAvatarRadius = ta.getDimensionPixelSize(R.styleable.FashionAvatarView_avatarRadius, dp2px(60));
mAvatarBorderWidth = ta.getDimensionPixelSize(R.styleable.FashionAvatarView_avatarBorderWidth, dp2px(2));
mAvatarBorderColor = ta.getColor(R.styleable.FashionAvatarView_avatarBorderColor, Color.parseColor("#FFD700"));
// 顶部标签属性
mTagText = ta.getString(R.styleable.FashionAvatarView_tagText);
mTagTextColor = ta.getColor(R.styleable.FashionAvatarView_tagTextColor, Color.WHITE);
mTagTextSize = ta.getDimension(R.styleable.FashionAvatarView_tagTextSize, sp2px(12));
mTagBackgroundColor = ta.getColor(R.styleable.FashionAvatarView_tagBackgroundColor, Color.parseColor("#FFA500"));
mTagCornerRadius = ta.getDimension(R.styleable.FashionAvatarView_tagCornerRadius, dp2px(4));
mTagPadding = ta.getDimensionPixelSize(R.styleable.FashionAvatarView_tagPadding, dp2px(4));
mTagOffsetY = ta.getDimensionPixelSize(R.styleable.FashionAvatarView_tagOffsetY, 0);
// 底部文字属性
mBottomText = ta.getString(R.styleable.FashionAvatarView_bottomText);
mBottomTextColor = ta.getColor(R.styleable.FashionAvatarView_bottomTextColor, Color.WHITE);
mBottomTextSize = ta.getDimension(R.styleable.FashionAvatarView_bottomTextSize, sp2px(14));
mBottomTextOffsetY = ta.getDimensionPixelSize(R.styleable.FashionAvatarView_bottomTextOffsetY, dp2px(10));
// 爱心装饰属性
mHeartIcon = ta.getDrawable(R.styleable.FashionAvatarView_heartIcon);
if (mHeartIcon == null) {
try {
mHeartIcon = context.getResources().getDrawable(R.mipmap.xlh_image);
} catch (Exception e) {
e.printStackTrace();
}
}
mHeartCount = ta.getInt(R.styleable.FashionAvatarView_heartCount, 6);
mHeartSize = ta.getDimensionPixelSize(R.styleable.FashionAvatarView_heartSize, dp2px(16));
ta.recycle();
// 加载头像
if (mAvatarUrl != null && !mAvatarUrl.isEmpty()) {
loadAvatarFromNetwork();
} else if (mPlaceholderAvatar != null) {
mAvatarBitmap = drawableToBitmap(mPlaceholderAvatar);
}
}
private void initPaints() {
// 头像画笔
mAvatarPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mAvatarPaint.setDither(true);
// 文字画笔
mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mTextPaint.setTextAlign(Paint.Align.CENTER);
// 标签背景画笔
mTagBgPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mTagBgPaint.setColor(mTagBackgroundColor);
}
private void loadAvatarFromNetwork() {
Glide.with(this)
.asBitmap()
.load(mAvatarUrl)
.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition) {
mAvatarBitmap = resource;
invalidate();
}
@Override
public void onLoadFailed(@Nullable Drawable errorDrawable) {
super.onLoadFailed(errorDrawable);
if (mPlaceholderAvatar != null) {
mAvatarBitmap = drawableToBitmap(mPlaceholderAvatar);
}
invalidate();
}
});
}
private Bitmap drawableToBitmap(Drawable drawable) {
if (drawable instanceof BitmapDrawable) {
return ((BitmapDrawable) drawable).getBitmap();
}
if (drawable == null) {
return null;
}
int width = drawable.getIntrinsicWidth();
int height = drawable.getIntrinsicHeight();
if (width <= 0) width = mAvatarRadius * 2;
if (height <= 0) height = mAvatarRadius * 2;
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
drawable.draw(canvas);
return bitmap;
}
private void initHeartPositions() {
mHeartPositions.clear();
if (mHeartIcon == null || mHeartCount <= 0 || mHeartSize <= 0) {
return;
}
int centerX = getWidth() / 2;
int centerY = getAvatarCenterY();
// 爱心围绕的半径,比头像大一些
int radius = mAvatarRadius + mAvatarBorderWidth + mHeartSize / 2;
for (int i = 0; i < mHeartCount; i++) {
// 随机分布在头像周围
double angle = 2 * Math.PI * mRandom.nextDouble();
// 稍微随机调整距离,让分布更自然
float distanceFactor = 0.8f + mRandom.nextFloat() * 0.4f;
float x = (float) (centerX + radius * distanceFactor * Math.cos(angle));
float y = (float) (centerY + radius * distanceFactor * Math.sin(angle));
mHeartPositions.add(new PointF(x, y));
}
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// 计算宽度:直径 + 左右可能的爱心空间
int width = 2 * (mAvatarRadius + mAvatarBorderWidth + mHeartSize / 2);
// 计算高度:头像直径 + 标签高度 + 底部文字高度 + 间距
int tagHeight = (int) (mTagTextSize + mTagPadding * 2);
int bottomTextHeight = (int) mBottomTextSize;
int height = 2 * (mAvatarRadius + mAvatarBorderWidth)
+ tagHeight / 2 // 标签一半在头像内
+ bottomTextHeight + mBottomTextOffsetY
+ dp2px(10);
setMeasuredDimension(resolveSize(width, widthMeasureSpec),
resolveSize(height, heightMeasureSpec));
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
// 视图大小确定后计算爱心位置
initHeartPositions();
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (getWidth() == 0 || getHeight() == 0) {
return;
}
int centerX = getWidth() / 2;
int avatarCenterY = getAvatarCenterY();
// 1. 绘制爱心装饰
drawHearts(canvas);
// 2. 绘制头像边框
mAvatarPaint.setColor(mAvatarBorderColor);
mAvatarPaint.setStyle(Paint.Style.FILL);
canvas.drawCircle(centerX, avatarCenterY, mAvatarRadius + mAvatarBorderWidth, mAvatarPaint);
// 3. 绘制头像
if (mAvatarBitmap != null) {
mAvatarPaint.setShader(new BitmapShader(mAvatarBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP));
canvas.drawCircle(centerX, avatarCenterY, mAvatarRadius, mAvatarPaint);
mAvatarPaint.setShader(null);
}
// 4. 绘制顶部标签
drawTag(canvas, centerX, avatarCenterY);
// 5. 绘制底部文字
drawBottomText(canvas, centerX);
}
private int getAvatarCenterY() {
// 计算头像中心Y坐标考虑标签的高度
int tagHeight = (int) (mTagTextSize + mTagPadding * 2);
return mAvatarRadius + mAvatarBorderWidth + tagHeight / 2 + mTagOffsetY;
}
private void drawHearts(Canvas canvas) {
if (mHeartIcon == null || mHeartPositions.isEmpty()) {
return;
}
canvas.save();
for (PointF point : mHeartPositions) {
int left = (int) (point.x - mHeartSize / 2);
int top = (int) (point.y - mHeartSize / 2);
int right = left + mHeartSize;
int bottom = top + mHeartSize;
// 只绘制在视图范围内的爱心
if (right > 0 && bottom > 0 && left < getWidth() && top < getHeight()) {
mHeartIcon.setBounds(left, top, right, bottom);
mHeartIcon.draw(canvas);
}
}
canvas.restore();
}
private void drawTag(Canvas canvas, int centerX, int avatarCenterY) {
if (mTagText == null || mTagText.isEmpty()) {
return;
}
// 计算标签文字宽度
mTextPaint.setTextSize(mTagTextSize);
float textWidth = mTextPaint.measureText(mTagText);
// 计算标签背景矩形
float tagLeft = centerX - textWidth / 2 - mTagPadding;
float tagRight = centerX + textWidth / 2 + mTagPadding;
// 标签底部与头像顶部对齐
float tagBottom = avatarCenterY - mAvatarRadius - mAvatarBorderWidth;
float tagTop = tagBottom - mTagTextSize - mTagPadding * 2;
RectF tagRect = new RectF(tagLeft, tagTop, tagRight, tagBottom);
// 绘制标签背景
canvas.drawRoundRect(tagRect, mTagCornerRadius, mTagCornerRadius, mTagBgPaint);
// 绘制标签文字
mTextPaint.setColor(mTagTextColor);
Paint.FontMetrics fontMetrics = mTextPaint.getFontMetrics();
float baseLineY = tagBottom - mTagPadding - fontMetrics.bottom;
canvas.drawText(mTagText, centerX, baseLineY, mTextPaint);
}
private void drawBottomText(Canvas canvas, int centerX) {
if (mBottomText == null || mBottomText.isEmpty()) {
return;
}
// 计算文字位置:头像底部下方
int textY = getAvatarCenterY() + mAvatarRadius + mAvatarBorderWidth + mBottomTextOffsetY;
mTextPaint.setColor(mBottomTextColor);
mTextPaint.setTextSize(mBottomTextSize);
Paint.FontMetrics fontMetrics = mTextPaint.getFontMetrics();
float baseLineY = textY - fontMetrics.top;
canvas.drawText(mBottomText, centerX, baseLineY, mTextPaint);
}
// dp转px
private int dp2px(float dp) {
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp,
getResources().getDisplayMetrics());
}
// sp转px
private float sp2px(float sp) {
return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, sp,
getResources().getDisplayMetrics());
}
// 设置器方法
public void setAvatarUrl(String url) {
this.mAvatarUrl = url;
loadAvatarFromNetwork();
}
public void setTagText(String text) {
this.mTagText = text;
invalidate();
}
public void setBottomText(String text) {
this.mBottomText = text;
invalidate();
}
public void setHeartIcon(Drawable heartIcon) {
this.mHeartIcon = heartIcon;
initHeartPositions();
invalidate();
}
}

View File

@@ -0,0 +1,262 @@
package com.xscm.moduleutil.view;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.RotateAnimation;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.Nullable;
import com.bumptech.glide.Glide;
import com.xscm.moduleutil.R;
import com.xscm.moduleutil.bean.GiftBean;
import com.xscm.moduleutil.bean.blindboxwheel.BlindBoxBean;
public class QXMeetGiftView extends RelativeLayout {
private TextView giftNameLabel;
private ImageView giftPriceBgView;
private Button giftCoin;
private ImageView bgImageView;
private ImageView giftBgImageView;
private ImageView giftImageView;
private boolean isLockGift;
private Object model; // 这里用 Object 代替 QXDrawGiftModel
public QXMeetGiftView(Context context) {
super(context);
initSubviews(context);
}
public QXMeetGiftView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
initSubviews(context);
}
public QXMeetGiftView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initSubviews(context);
}
private void initSubviews(Context context) {
// 创建背景图片视图
bgImageView = new ImageView(context);
bgImageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
bgImageView.setImageResource(R.drawable.ac_left_gift_bg);
LayoutParams bgParams = new LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT
);
addView(bgImageView, bgParams);
// 创建礼物图片视图(圆形)
giftImageView = new ImageView(context);
giftImageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
LayoutParams giftImageParams = new LayoutParams(
dpToPx(62), // 固定宽度
dpToPx(62) // 固定高度
);
giftImageParams.addRule(CENTER_IN_PARENT);
giftImageParams.topMargin = dpToPx(10);
addView(giftImageView, giftImageParams);
// 创建礼物背景光效视图
giftBgImageView = new ImageView(context);
giftBgImageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
giftBgImageView.setImageResource(R.drawable.ac_lock_gift_light_bg);
giftBgImageView.setVisibility(View.GONE); // 初始隐藏
LayoutParams giftBgParams = new LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT
);
addView(giftBgImageView, giftBgParams);
// 创建价格背景视图
giftPriceBgView = new ImageView(context);
giftPriceBgView.setImageResource(R.drawable.ac_meet_gift_name_bg);
LayoutParams priceBgParams = new LayoutParams(
LayoutParams.MATCH_PARENT,
dpToPx(15)
);
priceBgParams.addRule(CENTER_HORIZONTAL);
priceBgParams.addRule(ALIGN_PARENT_BOTTOM);
priceBgParams.bottomMargin = dpToPx(10); // 在名称标签上方
addView(giftPriceBgView, priceBgParams);
// 创建金币按钮
giftCoin = new Button(context);
giftCoin.setTextColor(0xFFC7BF62); // 使用直接的颜色值
// 设置按钮图标
Drawable coinDrawable = getResources().getDrawable(R.mipmap.jinb);
coinDrawable.setBounds(0, 0, dpToPx(1), dpToPx(1));
giftCoin.setCompoundDrawables(coinDrawable, null, null, null);
giftCoin.setTextSize(10);
giftCoin.setBackgroundColor(0x00000000); // 透明背景
LayoutParams coinParams = new LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT
);
coinParams.addRule(CENTER_HORIZONTAL);
coinParams.addRule(ALIGN_PARENT_BOTTOM);
coinParams.bottomMargin = -dpToPx(2);
addView(giftCoin, coinParams);
// 创建礼物名称标签
giftNameLabel = new TextView(context);
giftNameLabel.setTextColor(0xFFFFFFFF);
giftNameLabel.setTextSize(12);
giftNameLabel.setGravity(android.view.Gravity.CENTER);
giftNameLabel.setSingleLine(true); // 设置为单行显示
giftNameLabel.setEllipsize(android.text.TextUtils.TruncateAt.END); // 超出部分用省略号表示
LayoutParams nameParams = new LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT
);
nameParams.addRule(CENTER_HORIZONTAL);
nameParams.addRule(ALIGN_PARENT_BOTTOM);
nameParams.bottomMargin = dpToPx(1);
addView(giftNameLabel, nameParams);
// 调整视图层级 - 确保正确的层级关系
// 按添加顺序已经确定层级,最晚添加的在最上层
}
public void setIsLockGift(boolean isLockGift) {
this.isLockGift = isLockGift;
// 设置背景图片
int bgResource = isLockGift ?
R.drawable.ac_lock_gift_bg : R.drawable.ac_left_gift_bg;
bgImageView.setImageResource(bgResource);
// 显示/隐藏光效背景
giftBgImageView.setVisibility(isLockGift ? View.VISIBLE : View.GONE);
if (isLockGift) {
// 重新设置礼物图片的约束
LayoutParams params = (LayoutParams) giftImageView.getLayoutParams();
params.width = dpToPx(62);
params.height = dpToPx(62);
params.addRule(CENTER_IN_PARENT);
params.setMargins(0, 0, 0, 0);
giftImageView.setLayoutParams(params);
} else {
// 恢复原始约束
LayoutParams params = (LayoutParams) giftImageView.getLayoutParams();
params.width = LayoutParams.MATCH_PARENT;
params.height = LayoutParams.WRAP_CONTENT;
params.addRule(CENTER_IN_PARENT);
params.setMargins(dpToPx(6), dpToPx(6), dpToPx(6), 0);
giftImageView.setLayoutParams(params);
}
}
public void setModel(BlindBoxBean.GiveGift model) {
this.model = model;
// 这里需要根据您的 QXDrawGiftModel 类来实现具体逻辑
if (model instanceof BlindBoxBean.GiveGift) {
BlindBoxBean.GiveGift giftModel = (BlindBoxBean.GiveGift) model;
// 使用图片加载库加载图片
Glide.with(getContext()).load(giftModel.getBase_image()).into(giftImageView);
giftNameLabel.setText(giftModel.getGift_name());
giftCoin.setText(giftModel.getGift_price());
}
}
public void startAnimation() {
// 礼物图片顺时针旋转动画
RotateAnimation rotateAnimation = new RotateAnimation(
0, 360, // 从 0 度旋转到 360 度
Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f
);
rotateAnimation.setDuration(3000); // 3 秒
rotateAnimation.setRepeatCount(Animation.INFINITE);
rotateAnimation.setRepeatMode(Animation.RESTART);
rotateAnimation.setInterpolator(getContext(), android.R.anim.linear_interpolator);
giftImageView.startAnimation(rotateAnimation);
// 光效背景逆时针旋转动画
RotateAnimation rotateAnimation1 = new RotateAnimation(
0, -360, // 从 0 度旋转到 -360 度
Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f
);
rotateAnimation1.setDuration(3000); // 3 秒
rotateAnimation1.setRepeatCount(Animation.INFINITE);
rotateAnimation1.setRepeatMode(Animation.RESTART);
rotateAnimation1.setInterpolator(getContext(), android.R.anim.linear_interpolator);
giftBgImageView.startAnimation(rotateAnimation1);
}
public void resetAnimation() {
giftImageView.clearAnimation();
giftBgImageView.clearAnimation();
}
public void stopAnimation() {
giftImageView.clearAnimation();
giftBgImageView.clearAnimation();
}
// 辅助方法dp 转 px
private int dpToPx(int dp) {
float density = getResources().getDisplayMetrics().density;
return Math.round(dp * density);
}
// 缩放宽度方法(对应 ScaleWidth
private int scaleWidth(int value) {
// 这里需要根据您的缩放逻辑实现
// 通常可以根据屏幕密度进行缩放
float scale = getResources().getDisplayMetrics().density;
return (int) (value * scale);
}
// Getter 方法
public TextView getGiftNameLabel() {
return giftNameLabel;
}
public ImageView getGiftPriceBgView() {
return giftPriceBgView;
}
public Button getGiftCoin() {
return giftCoin;
}
public ImageView getBgImageView() {
return bgImageView;
}
public ImageView getGiftBgImageView() {
return giftBgImageView;
}
public ImageView getGiftImageView() {
return giftImageView;
}
public boolean isLockGift() {
return isLockGift;
}
public Object getModel() {
return model;
}
}

View File

@@ -0,0 +1,250 @@
package com.xscm.moduleutil.view;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.GradientDrawable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.Nullable;
import com.bumptech.glide.Glide;
import com.xscm.moduleutil.R;
import com.xscm.moduleutil.bean.UserInfo;
import com.xscm.moduleutil.bean.blindboxwheel.BlindBoxBean;
import com.xscm.moduleutil.utils.ImageUtils;
import com.xscm.moduleutil.widget.GifAvatarOvalView;
public class QXMeetUserView extends RelativeLayout {
private GifAvatarOvalView headerImageView;
private ImageView dressImageView;
private TextView tagLabel;
private TextView nameLabel;
private boolean isLuckUser;
private Object model; // 这里用 Object 代替 QXUserModel
public QXMeetUserView(Context context) {
super(context);
initSubviews(context);
}
public QXMeetUserView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
initSubviews(context);
}
public QXMeetUserView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initSubviews(context);
}
private void initSubviews(Context context) {
setClipChildren(false);
setClipToPadding(false);
// 创建装饰图片视图
dressImageView = new ImageView(context);
dressImageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
dressImageView.setImageResource(R.mipmap.xlh_image);
LayoutParams dressParams = new LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT
);
addView(dressImageView, dressParams);
// 创建头像图片视图
headerImageView = new GifAvatarOvalView(context);
headerImageView.setScaleType(ImageView.ScaleType.CENTER_CROP); // 添加这一行
// headerImageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
// headerImageView.setImageResource(R.mipmap.default_avatar);
int headerSize = getMeasuredWidth() - dpToPx(18); // self.width-9*2
LayoutParams headerParams = new LayoutParams(headerSize, headerSize);
headerParams.setMargins(0, 10, 0, 0);
headerParams.addRule(CENTER_IN_PARENT);
// 将头像添加到装饰视图之上
addView(headerImageView, headerParams);
// 创建标签标签
tagLabel = new TextView(context);
tagLabel.setTextColor(0xFFFFE554); // RGB16(0xFFE554)
tagLabel.setTextSize(12);
tagLabel.setGravity(android.view.Gravity.CENTER);
tagLabel.setBackground(getRoundedRectBackground(0xFF8D6F28, dpToPx(8))); // 默认房主背景色
LayoutParams tagParams = new LayoutParams(dpToPx(45), dpToPx(16));
tagParams.addRule(CENTER_HORIZONTAL);
// 需要在测量完成后设置底部位置
addView(tagLabel, tagParams);
// 创建名称标签
nameLabel = new TextView(context);
nameLabel.setTextColor(0xFFFFFFFF); // RGB16(0xffffff)
nameLabel.setTextSize(12);
nameLabel.setText("虚位以待");
nameLabel.setGravity(android.view.Gravity.CENTER);
LayoutParams nameParams = new LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT
);
nameParams.addRule(CENTER_HORIZONTAL);
nameParams.addRule(ALIGN_PARENT_BOTTOM);
addView(nameLabel, nameParams);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
// 确保在测量时设置正确的头像尺寸
if (headerImageView != null) {
int headerSize = getMeasuredWidth() - dpToPx(18); // width - 9dp * 2
LayoutParams headerParams = (LayoutParams) headerImageView.getLayoutParams();
if (headerParams != null) {
headerParams.width = headerSize;
headerParams.height = headerSize;
headerParams.leftMargin = dpToPx(9);
headerParams.topMargin = dpToPx(9);
headerImageView.setLayoutParams(headerParams);
}
}
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
// 在布局完成后设置标签的位置(在头像底部-8的位置
if (changed && headerImageView != null && tagLabel != null) {
int tagTop = headerImageView.getBottom() - dpToPx(8);
int tagLeft = (getWidth() - tagLabel.getWidth()) / 2;
tagLabel.layout(tagLeft, tagTop, tagLeft + tagLabel.getWidth(), tagTop + tagLabel.getHeight());
}
}
public void setIsLuckUser(boolean isLuckUser) {
this.isLuckUser = isLuckUser;
if (isLuckUser) {
tagLabel.setTextColor(0xFFFFFFFF); // RGB16(0xffffff)
tagLabel.setBackground(getRoundedRectBackground(0xFF6C49E4, dpToPx(8))); // RGB16(0x6C49E4)
// tagLabel.setBackgroundColor(getResources().getColor(R.color.color_FF6C49E4)); // RGB16(0x6C49E4)
tagLabel.setText("幸运者");
} else {
tagLabel.setTextColor(0xFFFFE554); // RGB16(0xFFE554)
tagLabel.setBackground(getRoundedRectBackground(0xFF8D6F28, dpToPx(8))); // RGB16(0x8D6F28)
// tagLabel.setBackgroundColor(getResources().getColor(R.color.color_FF8D6F28)); // RGB16(0x6C49E4)
tagLabel.setText("房主");
}
}
public void setModel(BlindBoxBean.xlhUser model) {
this.model = model;
// 这里需要根据您的 QXUserModel 类来实现具体逻辑
if (model instanceof BlindBoxBean.xlhUser) {
BlindBoxBean.xlhUser userModel = (BlindBoxBean.xlhUser) model;
// 使用图片加载库加载头像
// Glide.with(getContext()).load(userModel.getAvatar()).into(headerImageView);
ImageUtils.loadHeadCC(userModel.getAvatar(), headerImageView);
nameLabel.setText(userModel.getNickname());
}
}
public void resetView() {
headerImageView.setImageResource(R.mipmap.default_avatar);
nameLabel.setText("虚位以待");
}
// 创建圆角矩形背景
private android.graphics.drawable.Drawable getRoundedRectBackground(int color, float radius) {
GradientDrawable drawable = new GradientDrawable();
drawable.setColor(color);
drawable.setCornerRadius(radius);
return drawable;
}
// 辅助方法dp 转 px
private int dpToPx(int dp) {
float density = getResources().getDisplayMetrics().density;
return Math.round(dp * density);
}
// Getter 方法
public ImageView getHeaderImageView() {
return headerImageView;
}
public ImageView getDressImageView() {
return dressImageView;
}
public TextView getTagLabel() {
return tagLabel;
}
public TextView getNameLabel() {
return nameLabel;
}
public boolean isLuckUser() {
return isLuckUser;
}
public Object getModel() {
return model;
}
// 自定义圆形 ImageView
private static class RoundImageView extends androidx.appcompat.widget.AppCompatImageView {
public RoundImageView(Context context) {
super(context);
}
public RoundImageView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public RoundImageView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onDraw(Canvas canvas) {
// 创建圆形裁剪区域
int diameter = Math.min(getWidth(), getHeight());
Bitmap bitmap = Bitmap.createBitmap(diameter, diameter, Bitmap.Config.ARGB_8888);
Canvas tempCanvas = new Canvas(bitmap);
// 绘制圆形
Paint paint = new Paint();
paint.setAntiAlias(true);
tempCanvas.drawCircle(diameter / 2f, diameter / 2f, diameter / 2f, paint);
// 设置混合模式
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
// 绘制原始图片
super.onDraw(tempCanvas);
// 将处理后的图片绘制到实际canvas
canvas.drawBitmap(bitmap, 0, 0, null);
}
}
}

View File

@@ -0,0 +1,266 @@
package com.xscm.moduleutil.view;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.ScaleAnimation;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.Nullable;
import com.xscm.moduleutil.R;
public class QXTimeDownView extends FrameLayout {
private ImageView bgImageView;
private TextView titleLabel;
private TextView timeLabel;
private TextView bigTimeLabel;
private long endTime;
private long startTime;
private Handler timerHandler;
private Runnable timerRunnable;
private TimeDownDelegate delegate;
public interface TimeDownDelegate {
void timeDownStartAnimation();
void timeDownUpdateAnimationWithTime(long time);
void timeDownStopAnimation();
void timeDownDidFinished();
}
public QXTimeDownView(Context context) {
super(context);
initSubviews(context);
}
public QXTimeDownView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
initSubviews(context);
}
public QXTimeDownView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initSubviews(context);
}
private void initSubviews(Context context) {
// 背景图片(最大的圆圈)
bgImageView = new ImageView(context);
bgImageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
bgImageView.setImageResource(R.drawable.ac_time_down_bg);
LayoutParams bgParams = new LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT
);
bgParams.gravity = Gravity.CENTER;
addView(bgImageView, bgParams);
// 时间标签(居中显示在背景图上)
timeLabel = new TextView(context);
timeLabel.setTextSize(16);
timeLabel.setTextColor(0xFFFFECA7);
timeLabel.setGravity(Gravity.CENTER);
timeLabel.setTypeface(android.graphics.Typeface.create("sans-serif-condensed", android.graphics.Typeface.NORMAL));
LayoutParams timeParams = new LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT
);
timeParams.gravity = Gravity.CENTER;
timeParams.topMargin = dpToPx(-10);
addView(timeLabel, timeParams);
// 标题标签(显示在时间标签下方)
titleLabel = new TextView(context);
titleLabel.setTextSize(12);
titleLabel.setTextColor(0xFFFFECA7);
titleLabel.setText("倒计时");
titleLabel.setGravity(Gravity.CENTER);
LayoutParams titleParams = new LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT
);
titleParams.gravity = Gravity.CENTER;
titleParams.topMargin = dpToPx(12); // 在timeLabel下方一定距离
addView(titleLabel, titleParams);
// 大时间标签初始隐藏用于最后30秒显示
bigTimeLabel = new TextView(context);
bigTimeLabel.setTextSize(20);
bigTimeLabel.setText("-");
bigTimeLabel.setTextColor(0xFFFFECA7);
bigTimeLabel.setGravity(Gravity.CENTER);
bigTimeLabel.setVisibility(View.GONE);
LayoutParams bigTimeParams = new LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT
);
bigTimeParams.gravity = Gravity.CENTER;
addView(bigTimeLabel, bigTimeParams);
// 初始化定时器
timerHandler = new Handler(Looper.getMainLooper());
}
public void setEndTime(long endTime) {
this.endTime = endTime;
// 获取当前时间(秒)
long currentTime = System.currentTimeMillis() / 1000;
this.startTime = endTime - currentTime;
if (this.startTime <= 0) {
// 时间错误不进行倒计时
showBigTimeLabel("0");
return;
}
stopTimer();
startTimer();
}
private void startTimer() {
timerRunnable = new Runnable() {
@Override
public void run() {
startTime--;
long min = (startTime % 3600) / 60;
long second = startTime % 60;
if (startTime <= 30) {
// 最后30秒显示大数字
showBigTimeLabel(String.valueOf(startTime));
if (startTime == 30) {
if (delegate != null) {
delegate.timeDownStartAnimation();
}
} else {
if (delegate != null) {
delegate.timeDownUpdateAnimationWithTime(startTime);
}
}
// 弹性动画
performScaleAnimation();
} else {
// 正常倒计时显示
showNormalTime(String.format("%02d:%02d", min, second));
if (delegate != null) {
delegate.timeDownStopAnimation();
}
}
if (startTime <= 0) {
stopTimer();
showBigTimeLabel("0");
if (delegate != null) {
delegate.timeDownDidFinished();
delegate.timeDownStopAnimation();
}
} else {
// 继续下一次计时
timerHandler.postDelayed(this, 1000);
}
}
};
// 立即开始第一次执行
timerHandler.post(timerRunnable);
}
public void stopTimer() {
if (timerHandler != null && timerRunnable != null) {
timerHandler.removeCallbacks(timerRunnable);
timerRunnable = null;
}
}
private void showBigTimeLabel(String text) {
bigTimeLabel.setVisibility(View.VISIBLE);
timeLabel.setVisibility(View.GONE);
titleLabel.setVisibility(View.GONE);
bigTimeLabel.setText(text);
}
private void showNormalTime(String timeText) {
bigTimeLabel.setVisibility(View.GONE);
timeLabel.setVisibility(View.VISIBLE);
titleLabel.setVisibility(View.VISIBLE);
timeLabel.setText(timeText);
}
private void performScaleAnimation() {
ScaleAnimation scaleAnimation = new ScaleAnimation(
1.0f, 1.5f, // X轴从1.0缩放到1.5
1.0f, 1.5f, // Y轴从1.0缩放到1.5
ScaleAnimation.RELATIVE_TO_SELF, 0.5f, // 缩放中心X
ScaleAnimation.RELATIVE_TO_SELF, 0.5f // 缩放中心Y
);
scaleAnimation.setDuration(600);
scaleAnimation.setFillAfter(false);
bigTimeLabel.startAnimation(scaleAnimation);
}
public void reset() {
stopTimer();
showNormalTime("00:00");
bigTimeLabel.setVisibility(View.GONE);
timeLabel.setVisibility(View.VISIBLE);
titleLabel.setVisibility(View.VISIBLE);
}
// 辅助方法dp 转 px
private int dpToPx(int dp) {
float density = getResources().getDisplayMetrics().density;
return Math.round(dp * density);
}
// Getter 和 Setter 方法
public void setDelegate(TimeDownDelegate delegate) {
this.delegate = delegate;
}
public long getEndTime() {
return endTime;
}
public long getStartTime() {
return startTime;
}
public TextView getTitleLabel() {
return titleLabel;
}
public TextView getTimeLabel() {
return timeLabel;
}
public TextView getBigTimeLabel() {
return bigTimeLabel;
}
public ImageView getBgImageView() {
return bgImageView;
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
stopTimer();
}
}

View File

@@ -384,6 +384,7 @@ public class Constants {
public static final String GET_BOX_GIFT_LIST_XLH = "/api/BlindBoxTurntable/xlh";//巡乐会
public static final String POST_DRAW_GIFT_LIST_XLH = "/api/BlindBoxTurntable/xlh_draw_gift";//巡乐会抽奖
public static final String POST_XLH_ALL_RECORD = "/api/BlindBoxTurntable/get_xlh_all_record";//巡乐会榜单
public static final String Get_XH_RANking = "/api/BlindBoxTurntable/get_xlh_ranking";//巡乐会幸运
public static final String GET_XLH_MY_RECORD = "/api/BlindBoxTurntable/get_xlh_my_record";//巡乐会记录
public static final String POST_GIFT_ALL_CLEAR = "/api/Room/room_gift_all_clear";//背包礼物全清
public static final String POST_ROOM_USER_CHARM_LIST = "/api/Room/room_user_charm_list";//房间用户当前魅力值列表

View File

@@ -0,0 +1,38 @@
package com.xscm.moduleutil.widget.room
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModel
import com.xscm.moduleutil.bean.room.RoomInfoResp
import com.xscm.moduleutil.http.RetrofitClient
import kotlinx.coroutines.CoroutineScope
open class BaseViewModel : ViewModel(),LifecycleObserver {
val roomInfoData=MutableLiveData<RoomInfoResp>()
private val passRoom by lazy { MutableLiveData<Exception>() }
private val error by lazy { MutableLiveData<Exception>() }
private val finally by lazy { MutableLiveData<Int>() }
//加入房间
fun jiaoRoom(roomId:String, password:String){
}
/**
* 请求失败,出现异常
*/
fun getError(): LiveData<Exception> {
return error
}
/**
* 请求完成,在此处做一些关闭操作
*/
fun getFinally(): LiveData<Int> {
return finally
}
}

View File

@@ -0,0 +1,8 @@
package com.xscm.moduleutil.widget.room
import java.io.IOException
/**
* 自定义异常信息显示
*/
data class PassRoomException(var msg: String,var code: Int) : IOException()

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 KiB

View File

@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 选中状态:深色背景+白色文字背景通过shape绘制 -->
<item android:state_checked="true">
<shape android:shape="rectangle">
<padding
android:bottom="@dimen/dp_9"
android:top="@dimen/dp_9"
android:right="@dimen/dp_16"
android:left="@dimen/dp_16"/>
<!-- 圆角 -->
<corners android:radius="16dp" />
<!-- 选中背景色 -->
<solid android:color="#553BAE" />
</shape>
</item>
<!-- 未选中状态:浅色背景+深色文字 -->
<item android:state_checked="false">
<shape android:shape="rectangle">
<padding
android:bottom="@dimen/dp_9"
android:top="@dimen/dp_9"
android:right="@dimen/dp_16"
android:left="@dimen/dp_16">
</padding>
<corners android:radius="16dp" />
<!-- 未选中背景色 -->
<solid android:color="#A48DB1" />
</shape>
</item>
</selector>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 选中时文字颜色 -->
<item android:state_checked="true" android:color="#E8E8E8" />
<!-- 未选中时文字颜色 -->
<item android:state_checked="false" android:color="#FFFFFF" />
</selector>

View File

@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@mipmap/xlh"
android:orientation="vertical">
<ImageView
android:id="@+id/im_jc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_36"
android:src="@mipmap/xlh_bd"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:id="@+id/custom_tab_layout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginStart="@dimen/dp_16"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginEnd="@dimen/dp_16"
android:background="#80000000"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/im_jc">
<RadioGroup
android:gravity="center"
android:id="@+id/rb_btn"
android:layout_width="wrap_content"
android:layout_marginTop="@dimen/dp_20"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal">
<RadioButton
android:checked="true"
android:id="@+id/radio_all"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/bg_radio_selector"
android:button="@null"
android:gravity="center"
android:text="抽奖榜单"
android:textColor="@drawable/text_color_radio_selector"
android:textSize="@dimen/sp_14" />
<RadioButton
android:layout_marginLeft="@dimen/dp_16"
android:id="@+id/radio_electronics"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/bg_radio_selector"
android:button="@null"
android:gravity="center"
android:text="幸运榜单"
android:textColor="@drawable/text_color_radio_selector"
android:textSize="@dimen/sp_14" />
</RadioGroup>
<androidx.viewpager.widget.ViewPager
android:id="@+id/iv_view_Pager"
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.viewpager.widget.ViewPager>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

View File

@@ -34,48 +34,50 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/im_jc">
<!-- <androidx.constraintlayout.widget.ConstraintLayout-->
<!-- android:id="@+id/cl"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content">-->
<!-- <TextView-->
<!-- android:id="@+id/textView1"-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="@dimen/dp_24"-->
<!-- android:layout_marginStart="@dimen/sp_12"-->
<!-- android:layout_marginTop="@dimen/dp_16"-->
<!-- android:background="@mipmap/tab_dy"-->
<!-- android:gravity="center"-->
<!-- android:text="我的记录"-->
<!-- android:textColor="@color/white"-->
<!-- android:textSize="@dimen/sp_16"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintTop_toTopOf="parent"-->
<!-- app:layout_constraintWidth_default="percent"-->
<!-- app:layout_constraintWidth_percent="0.2" />-->
<!-- <TextView-->
<!-- android:id="@+id/textView2"-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="@dimen/dp_24"-->
<!-- android:layout_marginStart="@dimen/dp_16"-->
<!-- android:gravity="center"-->
<!-- android:text="全服记录"-->
<!-- android:textColor="#5B5B5B"-->
<!-- android:textSize="@dimen/sp_14"-->
<!-- app:layout_constraintStart_toEndOf="@+id/textView1"-->
<!-- app:layout_constraintTop_toTopOf="@+id/textView1"-->
<!-- app:layout_constraintWidth_default="percent"-->
<!-- app:layout_constraintWidth_percent="0.2" />-->
<!-- </androidx.constraintlayout.widget.ConstraintLayout>-->
<!-- <androidx.constraintlayout.widget.ConstraintLayout-->
<!-- android:id="@+id/cl"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content">-->
<!-- <TextView-->
<!-- android:id="@+id/textView1"-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="@dimen/dp_24"-->
<!-- android:layout_marginStart="@dimen/sp_12"-->
<!-- android:layout_marginTop="@dimen/dp_16"-->
<!-- android:background="@mipmap/tab_dy"-->
<!-- android:gravity="center"-->
<!-- android:text="我的记录"-->
<!-- android:textColor="@color/white"-->
<!-- android:textSize="@dimen/sp_16"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintTop_toTopOf="parent"-->
<!-- app:layout_constraintWidth_default="percent"-->
<!-- app:layout_constraintWidth_percent="0.2" />-->
<!-- <TextView-->
<!-- android:id="@+id/textView2"-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="@dimen/dp_24"-->
<!-- android:layout_marginStart="@dimen/dp_16"-->
<!-- android:gravity="center"-->
<!-- android:text="全服记录"-->
<!-- android:textColor="#5B5B5B"-->
<!-- android:textSize="@dimen/sp_14"-->
<!-- app:layout_constraintStart_toEndOf="@+id/textView1"-->
<!-- app:layout_constraintTop_toTopOf="@+id/textView1"-->
<!-- app:layout_constraintWidth_default="percent"-->
<!-- app:layout_constraintWidth_percent="0.2" />-->
<!-- </androidx.constraintlayout.widget.ConstraintLayout>-->
<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/smart_refresh_layout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginTop="@dimen/dp_16"
android:layout_weight="1"
app:srlEnableLoadMore="true"
app:srlEnableRefresh="true">

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.scwang.smartrefresh.layout.SmartRefreshLayout
app:layout_constraintTop_toTopOf="parent"
android:id="@+id/smart_refresh_layout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
app:srlEnableLoadMore="true"
app:srlEnableRefresh="true">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/dp_10"
android:layout_marginEnd="@dimen/dp_10"
android:nestedScrollingEnabled="false"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
tools:listitem="@layout/item_prize_pool" />
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

View File

@@ -61,8 +61,100 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_gz" />
<com.xscm.moduleutil.view.QXMeetUserView
android:id="@+id/gv_fz"
android:layout_width="@dimen/dp_60"
android:layout_height="@dimen/dp_83"
android:layout_marginEnd="@dimen/dp_11"
app:layout_constraintEnd_toStartOf="@+id/iv_zyx"
app:layout_constraintTop_toTopOf="@+id/iv_zyx"
android:translationY="@dimen/dp_78"
/>
<ImageView
android:id="@+id/iv_zyx"
android:layout_width="@dimen/dp_90"
android:layout_height="@dimen/dp_12"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:translationY="@dimen/dp_98"
android:src="@mipmap/zyx"
android:scaleType="fitCenter"
app:layout_constraintTop_toTopOf="parent"
/>
<com.xscm.moduleutil.view.QXTimeDownView
android:id="@+id/qx_djs"
android:layout_width="@dimen/dp_88"
android:layout_height="@dimen/dp_98"
app:layout_constraintStart_toEndOf="@+id/gv_fz"
android:layout_marginStart="@dimen/dp_10"
app:layout_constraintTop_toBottomOf="@+id/iv_zyx"
android:translationY="@dimen/dp_98"
/>
<com.xscm.moduleutil.view.QXMeetUserView
android:id="@+id/gv_xyz"
android:layout_width="@dimen/dp_94"
android:layout_height="@dimen/dp_118"
android:layout_marginTop="@dimen/dp_21"
app:layout_constraintEnd_toStartOf="@+id/iv_zyx"
android:layout_marginEnd="-13dp"
android:translationY="@dimen/dp_78"
app:layout_constraintTop_toBottomOf="@+id/gv_fz"
/>
<ImageView
android:layout_width="0dp"
android:layout_height="@dimen/dp_34"
android:src="@mipmap/xlhxd"
android:scaleType="fitCenter"
app:layout_constraintEnd_toStartOf="@+id/gv_sdlw"
app:layout_constraintStart_toEndOf="@+id/gv_xyz"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:translationY="-70dp"
/>
<com.xscm.moduleutil.view.QXMeetGiftView
android:id="@+id/gv_fzlw"
android:layout_width="@dimen/dp_48"
android:layout_height="@dimen/dp_76"
app:layout_constraintStart_toEndOf="@+id/iv_zyx"
android:layout_marginStart="@dimen/dp_5"
app:layout_constraintTop_toTopOf="@+id/gv_fz"
android:translationY="@dimen/dp_78"
/>
<TextView
android:id="@+id/tv_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="-5dp"
android:layout_marginTop="@dimen/dp_5"
app:layout_constraintStart_toEndOf="@+id/gv_sdlw"
app:layout_constraintEnd_toEndOf="@+id/gv_sdlw"
app:layout_constraintTop_toTopOf="@+id/gv_sdlw"
android:translationY="@dimen/dp_68"
android:textSize="@dimen/dp_28"
android:textColor="#FFBB00"
tools:text="1"
/>
<com.xscm.moduleutil.view.QXMeetGiftView
android:id="@+id/gv_sdlw"
android:layout_width="@dimen/dp_94"
android:layout_height="@dimen/dp_118"
android:layout_marginTop="14dp"
app:layout_constraintTop_toTopOf="@+id/gv_xyz"
app:layout_constraintStart_toStartOf="@+id/gv_fzlw"
android:layout_marginStart="-11dp"
android:translationY="@dimen/dp_68"
/>
<TextView
android:visibility="gone"
android:id="@+id/tv_time1"
android:layout_width="@dimen/dp_18"
android:layout_height="@dimen/dp_28"
@@ -74,10 +166,10 @@
app:layout_constraintBottom_toBottomOf="@+id/tv_bd"
app:layout_constraintStart_toEndOf="@+id/tv_bd"
app:layout_constraintTop_toTopOf="@+id/tv_bd"
tools:text="1" />
tools:text="1"
android:visibility="gone"/>
<TextView
android:visibility="gone"
android:id="@+id/tv_time2"
android:layout_width="@dimen/dp_18"
android:layout_height="@dimen/dp_28"
@@ -89,10 +181,14 @@
app:layout_constraintBottom_toBottomOf="@+id/tv_bd"
app:layout_constraintStart_toEndOf="@+id/tv_time1"
app:layout_constraintTop_toTopOf="@+id/tv_bd"
tools:text="3" />
tools:text="3"
android:visibility="gone"/>
<!-- 自定义礼物视图 -->
<TextView
android:visibility="gone"
android:id="@+id/tv_time_m"
android:layout_width="@dimen/dp_18"
android:layout_height="@dimen/dp_28"
@@ -103,7 +199,8 @@
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@+id/tv_bd"
app:layout_constraintStart_toEndOf="@+id/tv_time2"
app:layout_constraintTop_toTopOf="@+id/tv_bd" />
app:layout_constraintTop_toTopOf="@+id/tv_bd"
android:visibility="gone"/>
<TextView
android:id="@+id/tv_time3"
@@ -112,16 +209,15 @@
android:layout_marginStart="@dimen/dp_5"
android:background="@mipmap/time_b"
android:gravity="center"
android:visibility="gone"
android:textColor="#00F3D3"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@+id/tv_bd"
app:layout_constraintStart_toEndOf="@+id/tv_time_m"
app:layout_constraintTop_toTopOf="@+id/tv_bd"
tools:text="1" />
tools:text="1"
android:visibility="gone"/>
<TextView
android:visibility="gone"
android:id="@+id/tv_time4"
android:layout_width="@dimen/dp_18"
android:layout_height="@dimen/dp_28"
@@ -133,174 +229,30 @@
app:layout_constraintBottom_toBottomOf="@+id/tv_bd"
app:layout_constraintStart_toEndOf="@+id/tv_time3"
app:layout_constraintTop_toTopOf="@+id/tv_bd"
tools:text="8" />
<LinearLayout
android:layout_marginTop="@dimen/dp_5"
android:layout_marginLeft="@dimen/dp_15"
app:layout_constraintTop_toBottomOf="@+id/tv_jc"
app:layout_constraintLeft_toRightOf="@+id/tv_time4"
android:id="@+id/gift_l4"
android:layout_width="@dimen/dp_56"
android:layout_height="@dimen/dp_73"
android:orientation="vertical"
/>
<com.xscm.moduleutil.widget.GifAvatarOvalView
android:id="@+id/iv_homeowner_bg"
android:background="@color/_000000"
android:layout_width="@dimen/dp_40"
android:layout_height="@dimen/dp_58"
app:layout_constraintStart_toStartOf="@+id/gift_l4"
app:layout_constraintEnd_toEndOf="@+id/gift_l4"
app:layout_constraintTop_toTopOf="@+id/gift_l4"
android:layout_marginTop="@dimen/dp_2"
android:scaleType="fitCenter"/>
<ImageView
android:layout_width="@dimen/dp_60"
android:layout_height="@dimen/dp_58"
app:layout_constraintStart_toStartOf="@+id/gift_l4"
app:layout_constraintEnd_toEndOf="@+id/gift_l4"
app:layout_constraintTop_toTopOf="@+id/gift_l4"
android:layout_marginBottom="@dimen/dp_2"
android:src="@mipmap/xlh_image"
android:scaleType="fitCenter"/>
<TextView
android:id="@+id/tv_homeowner_name"
android:layout_width="wrap_content"
android:layout_height="@dimen/dp_14"
app:layout_constraintStart_toStartOf="@+id/gift_l4"
app:layout_constraintEnd_toEndOf="@+id/gift_l4"
app:layout_constraintBottom_toBottomOf="@+id/gift_l4"
tools:text="时尚的金针菇"
android:gravity="center"
android:textColor="@color/white"
android:textSize="@dimen/sp_10"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_35"
android:background="@drawable/bg_round_corner"
android:text="房主"
android:textColor="#FFE554"
android:textSize="@dimen/sp_12"
app:layout_constraintLeft_toLeftOf="@+id/iv_homeowner_bg"
app:layout_constraintRight_toRightOf="@+id/iv_homeowner_bg"
app:layout_constraintTop_toTopOf="@+id/iv_homeowner_bg" />
tools:text="8"
android:visibility="gone"/>
<androidx.constraintlayout.widget.ConstraintLayout
android:visibility="gone"
android:layout_marginTop="@dimen/dp_21"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginLeft="@dimen/dp_40"
app:layout_constraintTop_toBottomOf="@+id/tv_homeowner_name"
android:id="@+id/gift_l5"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<com.xscm.moduleutil.widget.GifAvatarOvalView
app:layout_constraintRight_toRightOf="parent"
android:background="@color/read_dot_bg"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:id="@+id/iv_lucky_person"
android:layout_width="@dimen/dp_64"
android:layout_height="@dimen/dp_80"
android:layout_marginTop="@dimen/dp_2"
android:scaleType="fitCenter"/>
<ImageView
app:layout_constraintRight_toRightOf="@+id/iv_lucky_person"
app:layout_constraintBottom_toBottomOf="@+id/iv_lucky_person"
app:layout_constraintTop_toTopOf="@+id/iv_lucky_person"
app:layout_constraintLeft_toLeftOf="@+id/iv_lucky_person"
android:layout_width="@dimen/dp_94"
android:layout_height="@dimen/dp_90"
android:layout_marginBottom="@dimen/dp_2"
android:src="@mipmap/xlh_image"
android:scaleType="fitCenter"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_65"
android:background="@drawable/bg_round_corner"
android:text="幸运者"
android:textColor="@color/white"
android:textSize="@dimen/sp_12"
app:layout_constraintLeft_toLeftOf="@+id/iv_lucky_person"
app:layout_constraintRight_toRightOf="@+id/iv_lucky_person"
app:layout_constraintTop_toTopOf="@+id/iv_lucky_person" />
<TextView
android:layout_marginTop="@dimen/dp_23"
android:text="烟花易冷"
android:textColor="@color/white"
android:gravity="center"
app:layout_constraintRight_toRightOf="@+id/iv_lucky_person"
app:layout_constraintLeft_toLeftOf="@+id/iv_lucky_person"
app:layout_constraintTop_toBottomOf="@+id/iv_lucky_person"
android:layout_width="0dp"
android:layout_height="wrap_content"/>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
app:layout_constraintRight_toLeftOf="@+id/tv_gz"
app:layout_constraintTop_toTopOf="@+id/iv_homeowner_bg"
android:layout_width="wrap_content"
android:layout_marginRight="@dimen/dp_46"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/iv_iv_bg"
android:layout_width="@dimen/dp_36"
android:layout_height="@dimen/dp_36"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:src="@mipmap/ic_launcher"
android:scaleType="fitCenter"/>
<ImageView
android:id="@+id/iv_bg"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_width="@dimen/dp_48"
android:background="@mipmap/xlh_g_2"
android:layout_height="@dimen/dp_60"/>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:visibility="gone"
android:id="@+id/cl_gift"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_195"
android:layout_marginTop="@dimen/dp_10"
android:background="@mipmap/tour_zj_bj"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_bd">
app:layout_constraintTop_toBottomOf="@+id/tv_bd"
android:visibility="gone">
<!-- <ImageView-->
<!-- android:id="@+id/iv_z_bj"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="@dimen/dp_195"-->
<!-- android:scaleType="fitCenter"-->
<!-- android:src="@mipmap/tour_zj_bj"-->
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
<!-- app:layout_constraintTop_toTopOf="parent" -->
<!-- />-->
<!-- <ImageView-->
<!-- android:id="@+id/iv_z_bj"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="@dimen/dp_195"-->
<!-- android:scaleType="fitCenter"-->
<!-- android:src="@mipmap/tour_zj_bj"-->
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
<!-- app:layout_constraintTop_toTopOf="parent" -->
<!-- />-->
<LinearLayout
android:id="@+id/gift_l"
@@ -311,7 +263,8 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
app:layout_constraintTop_toTopOf="parent"
android:visibility="gone">
<ImageView
android:id="@+id/gift_img"
@@ -327,8 +280,8 @@
android:layout_gravity="center"
android:gravity="center"
android:textColor="@color/black"
android:textStyle="bold"
android:textSize="@dimen/sp_12"
android:textStyle="bold"
tools:text="请选择礼物" />
<TextView
@@ -346,10 +299,10 @@
android:id="@+id/tv_gift_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@mipmap/xlh_num"
android:gravity="center"
android:textColor="@color/color_FF333333"
android:textSize="@dimen/sp_12"
android:background="@mipmap/xlh_num"
tools:text="999" />
</LinearLayout>
@@ -358,70 +311,75 @@
android:id="@+id/gift_l2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginStart="@dimen/dp_25"
android:background="@mipmap/xlh_g_2"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"/>
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:visibility="gone"/>
<ImageView
android:id="@+id/give_im"
android:layout_width="@dimen/dp_40"
android:layout_height="@dimen/dp_40"
app:layout_constraintStart_toStartOf="@+id/gift_l2"
app:layout_constraintEnd_toEndOf="@+id/gift_l2"
app:layout_constraintTop_toTopOf="@+id/gift_l2"
android:layout_marginBottom="@dimen/dp_20"
app:layout_constraintBottom_toBottomOf="@+id/gift_l2"
android:scaleType="fitCenter"
android:src="@mipmap/ic_launcher"
android:scaleType="fitCenter"/>
app:layout_constraintBottom_toBottomOf="@+id/gift_l2"
app:layout_constraintEnd_toEndOf="@+id/gift_l2"
app:layout_constraintStart_toStartOf="@+id/gift_l2"
app:layout_constraintTop_toTopOf="@+id/gift_l2"
android:visibility="gone"/>
<LinearLayout
android:id="@+id/gift_l3"
android:layout_width="@dimen/dp_56"
android:layout_height="@dimen/dp_73"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginEnd="@dimen/dp_25"
android:background="@mipmap/xlh_gift_user"
android:orientation="vertical"
/>
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:visibility="gone"/>
<com.xscm.moduleutil.widget.GifAvatarOvalView
android:id="@+id/user_pic"
android:layout_width="@dimen/dp_36"
android:layout_height="@dimen/dp_36"
app:layout_constraintStart_toStartOf="@+id/gift_l3"
app:layout_constraintEnd_toEndOf="@+id/gift_l3"
app:layout_constraintTop_toTopOf="@+id/gift_l3"
android:layout_marginTop="@dimen/dp_2"
android:scaleType="fitCenter"/>
android:scaleType="fitCenter"
app:layout_constraintEnd_toEndOf="@+id/gift_l3"
app:layout_constraintStart_toStartOf="@+id/gift_l3"
app:layout_constraintTop_toTopOf="@+id/gift_l3"
android:visibility="gone"/>
<ImageView
android:layout_width="@dimen/dp_43"
android:layout_height="@dimen/dp_43"
app:layout_constraintStart_toStartOf="@+id/gift_l3"
app:layout_constraintEnd_toEndOf="@+id/gift_l3"
app:layout_constraintTop_toTopOf="@+id/gift_l3"
android:layout_marginBottom="@dimen/dp_2"
android:scaleType="fitCenter"
android:src="@mipmap/xlh_image"
android:scaleType="fitCenter"/>
app:layout_constraintEnd_toEndOf="@+id/gift_l3"
app:layout_constraintStart_toStartOf="@+id/gift_l3"
app:layout_constraintTop_toTopOf="@+id/gift_l3"
android:visibility="gone"/>
<TextView
android:id="@+id/user_name"
android:layout_width="wrap_content"
android:layout_height="@dimen/dp_14"
app:layout_constraintStart_toStartOf="@+id/gift_l3"
app:layout_constraintEnd_toEndOf="@+id/gift_l3"
app:layout_constraintBottom_toBottomOf="@+id/gift_l3"
android:layout_marginBottom="@dimen/dp_5"
tools:text="请选择礼物"
android:gravity="center"
android:textColor="#FFFFFF"
android:textSize="@dimen/sp_10"/>
android:textSize="@dimen/sp_10"
app:layout_constraintBottom_toBottomOf="@+id/gift_l3"
app:layout_constraintEnd_toEndOf="@+id/gift_l3"
app:layout_constraintStart_toStartOf="@+id/gift_l3"
tools:text="请选择礼物"
android:visibility="gone"/>
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -431,25 +389,25 @@
android:layout_height="@dimen/dp_200"
android:layout_marginBottom="@dimen/dp_15"
android:orientation="horizontal"
android:translationY="@dimen/dp_48"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintTop_toBottomOf="@+id/gift_l5"
app:layout_constraintBottom_toTopOf="@+id/exchange_layout"
/>
app:layout_constraintTop_toBottomOf="@+id/gv_xyz" />
<!-- <HorizontalScrollView-->
<!-- android:id="@+id/horizontalScrollView"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="@dimen/dp_200"-->
<!-- android:scrollbars="none"-->
<!-- app:layout_constraintTop_toBottomOf="@+id/cl_gift"-->
<!-- app:layout_constraintBottom_toTopOf="@+id/exchange_layout">-->
<!-- <HorizontalScrollView-->
<!-- android:id="@+id/horizontalScrollView"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="@dimen/dp_200"-->
<!-- android:scrollbars="none"-->
<!-- app:layout_constraintTop_toBottomOf="@+id/cl_gift"-->
<!-- app:layout_constraintBottom_toTopOf="@+id/exchange_layout">-->
<!-- <LinearLayout-->
<!-- android:id="@+id/prizeContainer"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:orientation="horizontal" />-->
<!-- </HorizontalScrollView>-->
<!-- <LinearLayout-->
<!-- android:id="@+id/prizeContainer"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:orientation="horizontal" />-->
<!-- </HorizontalScrollView>-->
<TextView
@@ -458,40 +416,37 @@
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/dp_10"
android:textSize="@dimen/sp_10"
android:text="跳过动画"
android:textColor="#ABABAB"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/exchange_layout"
android:textSize="@dimen/sp_10"
app:layout_constraintBottom_toBottomOf="@+id/exchange_layout"
/>
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/exchange_layout" />
<View
android:id="@+id/v_checkbox"
android:layout_width="@dimen/dp_20"
android:layout_height="@dimen/dp_20"
android:background="@drawable/selector_custom_checkbox"
android:focusable="false"
android:clickable="true"
app:layout_constraintEnd_toStartOf="@+id/tv_option"
app:layout_constraintTop_toTopOf="@+id/exchange_layout"
android:focusable="false"
app:layout_constraintBottom_toBottomOf="@+id/exchange_layout"
android:visibility="gone"
/>
app:layout_constraintEnd_toStartOf="@+id/tv_option"
app:layout_constraintTop_toTopOf="@+id/exchange_layout" />
<LinearLayout
android:id="@+id/exchange_layout"
android:layout_width="wrap_content"
android:layout_height="@dimen/dp_28"
android:layout_marginBottom="@dimen/dp_20"
android:background="@drawable/bg_r45_2d449f"
android:gravity="center"
android:orientation="horizontal"
android:layout_marginBottom="@dimen/dp_20"
android:paddingStart="@dimen/dp_9"
android:paddingEnd="@dimen/dp_9"
app:layout_constraintBottom_toTopOf="@+id/lottery_buttons_layout"
app:layout_constraintEnd_toEndOf="@+id/lottery_buttons_layout"
app:layout_constraintStart_toStartOf="@+id/lottery_buttons_layout"
>
app:layout_constraintStart_toStartOf="@+id/lottery_buttons_layout">
<TextView
android:id="@+id/tv_icon"
@@ -499,9 +454,9 @@
android:layout_height="wrap_content"
android:drawableLeft="@mipmap/jinb"
android:drawablePadding="@dimen/dp_5"
tools:text="66666"
android:textColor="#F8E837"
android:textSize="@dimen/sp_10" />
android:textSize="@dimen/sp_10"
tools:text="66666" />
<TextView
android:id="@+id/tv_dh"
@@ -514,7 +469,6 @@
</LinearLayout>
<LinearLayout
android:id="@+id/lottery_buttons_layout"
android:layout_width="0dp"
@@ -551,8 +505,8 @@
android:layout_marginBottom="@dimen/dp_5"
android:drawableLeft="@mipmap/jinb"
android:gravity="center"
tools:text="10币一次"
android:textSize="@dimen/sp_10" />
android:textSize="@dimen/sp_10"
tools:text="10币一次" />
</LinearLayout>
<LinearLayout
@@ -582,8 +536,8 @@
android:layout_marginBottom="@dimen/dp_5"
android:drawableLeft="@mipmap/jinb"
android:gravity="center"
tools:text="100币一次"
android:textSize="@dimen/sp_10" />
android:textSize="@dimen/sp_10"
tools:text="100币一次" />
</LinearLayout>
<LinearLayout
@@ -611,8 +565,8 @@
android:layout_marginBottom="@dimen/dp_5"
android:drawableLeft="@mipmap/jinb"
android:gravity="center"
tools:text="1000币一次"
android:textSize="@dimen/sp_10" />
android:textSize="@dimen/sp_10"
tools:text="1000币一次" />
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<!-- 礼物数量 + 名称 -->
<TextView
app:layout_constraintTop_toTopOf="@+id/tv_user_name"
android:id="@+id/tv_gift_count_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="×1娃娃"
android:textColor="@color/white"
android:textSize="@dimen/sp_16"
app:layout_constraintBottom_toBottomOf="@+id/iv_gift_icon"
app:layout_constraintRight_toLeftOf="@+id/iv_gift_icon"
/>
<!-- 用户名 -->
<TextView
android:layout_marginTop="@dimen/dp_10"
android:id="@+id/tv_user_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="夏沫"
android:textColor="@color/white"
android:textSize="@dimen/sp_14"
app:layout_constraintLeft_toLeftOf="@+id/tv_issue"
app:layout_constraintTop_toBottomOf="@+id/tv_issue"
/>
<TextView
android:id="@+id/tv_issue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_12"
android:layout_marginTop="@dimen/dp_12"
android:text="第1期"
android:textColor="#A085FF"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<!-- 时间 -->
<TextView
android:layout_marginRight="@dimen/dp_12"
android:id="@+id/tv_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/dp_12"
android:text="2024.12.14 11:21:45"
android:textColor="#5B5B5B"
android:textSize="@dimen/sp_12"
app:layout_constraintBottom_toBottomOf="@+id/tv_issue"
app:layout_constraintRight_toRightOf="parent" />
<!-- 礼物图标 -->
<ImageView
android:layout_marginRight="@dimen/dp_12"
android:layout_marginTop="@dimen/dp_10"
android:id="@+id/iv_gift_icon"
android:layout_width="@dimen/dp_32"
android:layout_height="@dimen/dp_32"
android:scaleType="centerCrop"
android:src="@mipmap/ic_launcher"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_time"
/>
<!-- 底部分割线 -->
<View
android:id="@+id/divider"
android:layout_width="0dp"
android:layout_height="@dimen/dp_1"
android:layout_marginStart="@dimen/dp_12"
android:layout_marginTop="@dimen/dp_12"
android:layout_marginEnd="@dimen/dp_12"
android:background="@color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/iv_gift_icon"
/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -3,6 +3,7 @@
android:layout_width="@dimen/dp_100"
android:layout_height="@dimen/dp_154"
android:background="@mipmap/xlh_cj_item"
android:id="@+id/ll_bg"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 543 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

View File

@@ -469,4 +469,5 @@
<attr name="selectedBackground" format="reference" />
<attr name="normalBackground" format="reference" />
</declare-styleable>
</resources>

View File

@@ -1,38 +0,0 @@
<resources>
<declare-styleable name="FashionAvatarView">
<!-- 头像相关属性 -->
<attr name="avatarUrl" format="string" />
<attr name="placeholderAvatar" format="reference" />
<attr name="avatarRadius" format="dimension" />
<attr name="avatarBorderWidth" format="dimension" />
<attr name="avatarBorderColor" format="color" />
<!-- 顶部标签相关属性 -->
<attr name="tagText" format="string" />
<attr name="tagTextColor" format="color" />
<attr name="tagTextSize" format="dimension" />
<attr name="tagBackgroundColor" format="color" />
<attr name="tagCornerRadius" format="dimension" />
<attr name="tagPadding" format="dimension" />
<attr name="tagOffsetY" format="dimension" />
<!-- 底部文字相关属性 -->
<attr name="bottomText" format="string" />
<attr name="bottomTextColor" format="color" />
<attr name="bottomTextSize" format="dimension" />
<attr name="bottomTextOffsetY" format="dimension" />
<!-- 爱心装饰相关属性 -->
<attr name="heartIcon" format="reference" />
<attr name="heartCount" format="integer" />
<attr name="heartSize" format="dimension" />
</declare-styleable>
<declare-styleable name="AvatarWithDecoration">
<attr name="decoration" format="reference" />
<attr name="decorationScale" format="float" />
<attr name="decorationOffsetX" format="integer" />
<attr name="decorationOffsetY" format="integer" />
</declare-styleable>
</resources>

View File

@@ -108,6 +108,7 @@
<color name="color_FFB6A2FF">#FFB6A2FF</color>
<color name="color_FFF4F4F4">#FFF4F4F4</color>
<color name="color_FFD0D0FE">#FFD0D0FE</color>
<color name="color_FF8D6F28">#FF8D6F28</color>
<color name="color_FFB8B8B8">#FFB8B8B8</color>
<color name="color_FFA0A0A0">#FFA0A0A0</color>
<color name="color_FFFF9400">#FFFF9400</color>

View File

@@ -244,7 +244,9 @@ public class CircleCategoryFragment extends BaseMvpFragment<CirclePresenter, Fra
@Override
public void setLikeZone(int type) {
// MvpPre.getCircleList(page + "", "10");
if (type == 1) {
MvpPre.getCircleList(page + "", "10");
}
}
@Override

View File

@@ -36,7 +36,7 @@ android {
enabled = true
}
kotlinOptions {
jvmTarget = '17'
jvmTarget = '11'
}
}
@@ -60,5 +60,7 @@ dependencies {
implementation (libs.arouter.api.v150)
//annotationProcessor
annotationProcessor libs.arouter.compiler
implementation libs.permissionx
}
apply plugin: 'com.alibaba.arouter' //

View File

@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 前台定位权限 -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- 后台定位权限Android 10+ -->
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<application
>

View File

@@ -18,6 +18,7 @@ import android.view.KeyEvent;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -36,6 +37,12 @@ import com.example.modulenews.fragment.NewsFragment;
import com.example.moduleroom.activity.RoomActivity;
import com.example.modulevocal.fragment.VocalRangeFragment;
import com.example.modulevoice.fragment.VoiceFragment;
import com.permissionx.guolindev.PermissionX;
import com.permissionx.guolindev.callback.ExplainReasonCallback;
import com.permissionx.guolindev.callback.ForwardToSettingsCallback;
import com.permissionx.guolindev.callback.RequestCallback;
import com.permissionx.guolindev.request.ExplainScope;
import com.permissionx.guolindev.request.ForwardScope;
import com.xscm.modulemain.R;
import com.xscm.modulemain.contacts.HomeContacts;
import com.xscm.modulemain.databinding.ActivityMainBinding;
@@ -325,6 +332,7 @@ public class MainActivity extends BaseMvpActivity<HomePresenter, ActivityMainBin
mBinding.ivGuanbi.setOnClickListener(this);
mBinding.riv.setOnClickListener(this);
mBinding.ivShouchl.setOnClickListener(this);
//requestGpsPermissions();
}
@Override
@@ -553,8 +561,33 @@ public class MainActivity extends BaseMvpActivity<HomePresenter, ActivityMainBin
MvpPre.getMyInfo(SpUtil.getUserId() + "");//获取首充是否需要展示
// mBinding.ivShouchl.setVisibility(View.VISIBLE);
LogUtils.e("@@@1","开始定位", "描述:", "");
initLocation();
// 请求GPS相关权限精确位置+可选的后台权限)
//
}
private void requestGpsPermissions() {
PermissionX.init(this)
// 请求精确位置权限包含GPS定位能力
.permissions(
Manifest.permission.ACCESS_FINE_LOCATION,
// 如需后台使用GPS添加此权限Android 10+
Manifest.permission.ACCESS_BACKGROUND_LOCATION
)
// 权限请求结果回调
.request(new RequestCallback() {
@Override
public void onResult(boolean allGranted, List<String> grantedList, List<String> deniedList) {
if (allGranted) {
// Toast.makeText(MainActivity.this, "GPS权限已授予可开始定位", Toast.LENGTH_SHORT).show();
initLocation(); // 启动GPS定位逻辑
} else {
Toast.makeText(MainActivity.this, "GPS权限被拒绝无法使用定位功能", Toast.LENGTH_SHORT).show();
}
}
});
}
@Subscribe(threadMode = ThreadMode.MAIN)
@@ -629,18 +662,19 @@ public class MainActivity extends BaseMvpActivity<HomePresenter, ActivityMainBin
private String city1;
@Override
public void onLocationReceived(double latitude, double longitude, String city) {
LogUtils.e("当前位置:" + city);
city1 = city;
EventBus.getDefault().post(city1);
LogUtils.e("@@@1","开始定位", "描述:","当前位置"+city);
LogUtils.e("@@@1", "开始定位", "描述:", "当前位置" + city);
}
@Override
public void onFailed(String errorMessage) {
LogUtils.e("@@@1","开始定位", "描述:","失败");
LogUtils.e("@@@1", "开始定位", "描述:", "失败");
}
@@ -874,18 +908,9 @@ public class MainActivity extends BaseMvpActivity<HomePresenter, ActivityMainBin
private SystemLocationProvider locationProvider;
private void initLocation() {
if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// 在Activity或Fragment中调用
// 请求定位权限
ActivityCompat.requestPermissions(
(Activity) this,
new String[]{
android.Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.ACCESS_COARSE_LOCATION
},
1001 // 自定义常量,比如 1001
);
}
locationProvider = new SystemLocationProvider();
// 请求一次性的位置信息

View File

@@ -1,7 +1,8 @@
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
}
apply plugin: 'kotlin-kapt'
android {
namespace 'com.example.moduleroom'
compileSdk 35
@@ -34,7 +35,12 @@ android {
enable = true
}
}
// 与 dependencies 同级别
kapt {
arguments {
arg("AROUTER_MODULE_NAME", project.getName())
}
}
dependencies {
implementation libs.appcompat
@@ -48,9 +54,12 @@ dependencies {
implementation project(':moduleUtil')
implementation project(':moduletablayout')
implementation 'com.alibaba:arouter-api:1.5.2'
// implementation 'com.alibaba:arouter-api:1.5.2'
//annotationProcessor
annotationProcessor 'com.alibaba:arouter-compiler:1.5.2'
// annotationProcessor 'com.alibaba:arouter-compiler:1.5.2'
implementation 'com.alibaba:arouter-api:1.5.2'
kapt 'com.alibaba:arouter-compiler:1.5.2'
implementation 'com.github.JessYanCoding:AndroidAutoSize:v1.2.1'

View File

@@ -39,6 +39,17 @@
android:name=".service.MediaProjectionService"
android:foregroundServiceType="mediaProjection">
</service>
<service
android:name=".service.ForegroundService"
android:enabled="true"
android:exported="true"
android:foregroundServiceType="microphone|camera|mediaPlayback" />
<service
android:name=".service.CancelNoticeService"
android:enabled="true"
android:exported="true" />
</application>
</manifest>

File diff suppressed because it is too large Load Diff

View File

@@ -2,6 +2,7 @@ package com.example.moduleroom.dialog;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.text.TextUtils;
@@ -35,6 +36,7 @@ import com.example.moduletablayout.listener.OnTabSelectListener;
import com.google.android.material.tabs.TabLayout;
import com.google.android.material.tabs.TabLayoutMediator;
import com.hjq.toast.ToastUtils;
import com.xscm.moduleutil.activity.WebViewActivity;
import com.xscm.moduleutil.adapter.GiftTwoDetailsFragment;
import com.xscm.moduleutil.adapter.MyFragmentPagerAdapter;
import com.xscm.moduleutil.base.BaseMvpDialogFragment;
@@ -499,7 +501,14 @@ public class RoomGiftDialogFragment extends BaseMvpDialogFragment<RewardGiftPres
mBinding.ivWf.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ARouter.getInstance().build(ARouteConstants.H5).withString("url", giftDetailResp.getRule_url()).withString("title", "盲盒规则").navigation();
// ARouter.getInstance().build(ARouteConstants.H5).withString("url", giftDetailResp.getRule_url()).withString("title", "盲盒规则").navigation();
Intent intent = new Intent(getActivity(), WebViewActivity.class);
intent.putExtra("url", giftDetailResp.getRule_url());
intent.putExtra("title", "盲盒规则");
startActivity(intent);
}
});

View File

@@ -3,6 +3,7 @@ package com.example.moduleroom.dialog;
import static com.xscm.moduleutil.bean.room.RoomSettingBean.QXRoomSettingTypeRoomOrderMic;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
@@ -24,6 +25,7 @@ import com.example.moduleroom.contacts.RoomSettingContacts;
import com.example.moduleroom.databinding.DialogRoomSettingFragmentBinding;
import com.example.moduleroom.fragment.RoomBackgroundDialogFragment;
import com.hjq.toast.ToastUtils;
import com.xscm.moduleutil.activity.WebViewActivity;
import com.xscm.moduleutil.base.CommonAppContext;
import com.xscm.moduleutil.dialog.ConfirmDialog;
import com.xscm.moduleutil.event.EffectEvent;
@@ -291,7 +293,11 @@ public class RoomSettingFragment extends BaseMvpDialogFragment<RoomSettingPresen
}
} else if (bean.getType() == RoomSettingBean.QXRoomSettingTypeRoomReport) {
if (roomId != null) {
ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url() + "/web/index.html#/pages/feedback/report?id=" + SpUtil.getToken() + "&fromType=" + 2 + "&fromId=" + roomId).navigation();
// ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url() + "/web/index.html#/pages/feedback/report?id=" + SpUtil.getToken() + "&fromType=" + 2 + "&fromId=" + roomId).navigation();
Intent intent = new Intent(getActivity(), WebViewActivity.class);
intent.putExtra("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url() + "/web/index.html#/pages/feedback/report?id=" + SpUtil.getToken() + "&fromType=" + 2 + "&fromId=" + roomId);
startActivity(intent);
}else {
com.blankj.utilcode.util.ToastUtils.showShort("数据错误,请关闭重试");
}

View File

@@ -25,6 +25,7 @@ import com.example.moduleroom.fragment.RelationshipFragment;
import com.example.moduleroom.presenter.RoomUserPresenter;
import com.example.zhouwei.library.CustomPopWindow;
import com.hjq.toast.ToastUtils;
import com.xscm.moduleutil.activity.WebViewActivity;
import com.xscm.moduleutil.base.BaseMvpDialogFragment;
import com.xscm.moduleutil.base.CommonAppContext;
import com.xscm.moduleutil.bean.RelationCardBean;
@@ -202,7 +203,11 @@ public class RoomUserInfoFragment extends BaseMvpDialogFragment<RoomUserPresente
// UserGiftWallRoomFragment.newInstance(Integer.parseInt(user_id)).show(getChildFragmentManager(), "UserGiftWallRoomFragment");
}else if (id == R.id.room_jb){
ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url()+ "/web/index.html#/pages/feedback/report?id="+SpUtil.getToken()+"&fromType=1&fromId="+user_id).withString("title", "举报").navigation();
// ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url()+ "/web/index.html#/pages/feedback/report?id="+SpUtil.getToken()+"&fromType=1&fromId="+user_id).withString("title", "举报").navigation();
Intent intent = new Intent(getActivity(), WebViewActivity.class);
intent.putExtra("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url()+ "/web/index.html#/pages/feedback/report?id="+SpUtil.getToken()+"&fromType=1&fromId="+user_id);
intent.putExtra("title", "举报");
startActivity(intent);
}else if (id==R.id.iv_avatar){
ARouter.getInstance().build(ARouteConstants.USER_HOME_PAGE).withString("userId", userInfo.getUser_id()+"").navigation();
dismiss();
@@ -270,7 +275,12 @@ public class RoomUserInfoFragment extends BaseMvpDialogFragment<RoomUserPresente
} else if (id == R.id.action_report) {
// showContent = "点击 Item菜单6";
//TODO 举报功能
ARouter.getInstance().build(ARouteConstants.H5).withString("url",CommonAppContext.getInstance().getCurrentEnvironment().getH5Url()+ "/web/index.html#/pages/feedback/report?id="+SpUtil.getToken()+"&fromType=1&fromId="+user_id).withString("title", "举报").navigation();
// ARouter.getInstance().build(ARouteConstants.H5).withString("url",CommonAppContext.getInstance().getCurrentEnvironment().getH5Url()+ "/web/index.html#/pages/feedback/report?id="+SpUtil.getToken()+"&fromType=1&fromId="+user_id).withString("title", "举报").navigation();
Intent intent=new Intent(getActivity(), WebViewActivity.class);
intent.putExtra("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url()+ "/web/index.html#/pages/feedback/report?id="+SpUtil.getToken()+"&fromType=1&fromId="+user_id);
intent.putExtra("title", "举报");
startActivity(intent);
dismiss();
} else if (id == R.id.action_blacklist) {
MvpPre.addBlackList(user_id);

View File

@@ -9,8 +9,6 @@ import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import android.os.CountDownTimer;
import android.util.DisplayMetrics;
@@ -18,8 +16,6 @@ import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.PopupWindow;
import android.widget.Switch;
import android.widget.TextView;
@@ -36,9 +32,7 @@ import com.example.moduleroom.dialog.RoomGiftDialogFragment;
import com.example.moduleroom.dialog.RoomOnlineDialogFragment;
import com.example.moduleroom.dialog.RoomUserInfoFragment;
import com.example.moduleroom.presenter.FriendshipRoomPresenter;
import com.opensource.svgaplayer.SVGACallback;
import com.orhanobut.logger.Logger;
import com.xscm.moduleutil.activity.IPresenter;
import com.xscm.moduleutil.base.BaseRoomFragment;
import com.xscm.moduleutil.bean.RoomMessageEvent;
import com.xscm.moduleutil.bean.RoomRelationBean;
@@ -51,15 +45,12 @@ import com.xscm.moduleutil.color.ThemeableDrawableUtils;
import com.xscm.moduleutil.dialog.ConfirmDialog;
import com.xscm.moduleutil.rtc.AgoraManager;
import com.xscm.moduleutil.utils.ClickUtils;
import com.xscm.moduleutil.utils.ImageUtils;
import com.xscm.moduleutil.utils.SpUtil;
import com.xscm.moduleutil.utils.StringUtil;
import com.xscm.moduleutil.widget.RoomFriendshipWheatView;
import com.xscm.moduleutil.widget.SharedViewModel;
import com.xscm.moduleutil.widget.floatingView.IFloatingView;
import java.util.ArrayList;
import java.util.EventListener;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -1005,7 +996,7 @@ public class FriendshipRoomFragment extends BaseRoomFragment<FriendshipRoomPrese
if (getActivity() instanceof RoomActivity) {
((RoomActivity) getActivity()).setrlMic(true);
((RoomActivity) getActivity()).ivWheatFeeding(com.xscm.moduleutil.R.mipmap.room_wheat_feeding_up);
AgoraManager.getInstance(getActivity()).setLocalAudioEnabled( false,SpUtil.getUserId()+"");
// AgoraManager.getInstance(getActivity()).setLocalAudioEnabled( false,SpUtil.getUserId()+"");
}
}
configPowerBtn();

View File

@@ -37,7 +37,6 @@ import com.xscm.moduleutil.event.RoomJoinMountModel;
import com.xscm.moduleutil.rtc.MusicPlayBean;
import com.xscm.moduleutil.utils.SpUtil;
import com.xscm.moduleutil.utils.logger.Logger;
import com.tencent.imsdk.v2.V2TIMCallback;
import com.tencent.imsdk.v2.V2TIMManager;
import com.tencent.imsdk.v2.V2TIMMessage;
import com.tencent.imsdk.v2.V2TIMSendCallback;

View File

@@ -13,20 +13,14 @@ import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewStub;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.lifecycle.ViewModelProvider;
import com.alibaba.android.arouter.launcher.ARouter;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.TimeUtils;
import com.example.moduleroom.R;
import com.example.moduleroom.activity.RoomActivity;
import com.example.moduleroom.contacts.RoomAuctionContacts;
@@ -41,7 +35,6 @@ import com.example.moduleroom.dialog.RoomUserInfoFragment;
import com.example.moduleroom.presenter.RoomAuctionPresenterTow;
import com.hjq.toast.ToastUtils;
import com.orhanobut.logger.Logger;
import com.xscm.moduleutil.activity.WebViewActivity;
import com.xscm.moduleutil.base.BaseMvpFragment;
import com.xscm.moduleutil.base.CommonAppContext;
import com.xscm.moduleutil.bean.RoomMessageEvent;
@@ -54,22 +47,16 @@ import com.xscm.moduleutil.bean.room.RoomInfoResp;
import com.xscm.moduleutil.bean.room.RoomPitBean;
import com.xscm.moduleutil.dialog.ConfirmDialog;
import com.xscm.moduleutil.dialog.RoomAuctionWebViewDialog;
import com.xscm.moduleutil.dialog.WebViewDialog;
import com.xscm.moduleutil.utils.ARouteConstants;
import com.xscm.moduleutil.utils.ClickUtils;
import com.xscm.moduleutil.utils.ColorManager;
import com.xscm.moduleutil.utils.ImageUtils;
import com.xscm.moduleutil.utils.SpUtil;
import com.xscm.moduleutil.utils.StringUtil;
import com.xscm.moduleutil.widget.RoomFriendshipWheatView;
import com.xscm.moduleutil.widget.RoomMakeWheatView;
import com.xscm.moduleutil.widget.SharedViewModel;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.util.Date;
import java.util.List;
/**

View File

@@ -25,9 +25,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.core.app.NotificationManagerCompat;
import androidx.lifecycle.ViewModelProvider;
import com.alibaba.android.arouter.launcher.ARouter;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.ObjectUtils;
import com.blankj.utilcode.util.TimeUtils;
@@ -51,7 +49,6 @@ import com.xscm.moduleutil.event.CabinEvent;
import com.xscm.moduleutil.event.RoomBeckoningEvent;
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.widget.SharedViewModel;
import com.xscm.moduleutil.widget.dialog.CommonDialog;
@@ -60,7 +57,6 @@ import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.io.Serializable;
import java.nio.charset.StandardCharsets;
import java.util.Date;

View File

@@ -1,22 +1,18 @@
package com.example.moduleroom.fragment;
import android.content.Context;
import android.graphics.Rect;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import android.view.LayoutInflater;
import android.view.TouchDelegate;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.LinearInterpolator;
import android.widget.PopupWindow;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.ToastUtils;
@@ -40,7 +36,6 @@ import com.xscm.moduleutil.bean.UserOnlineStatusBean;
import com.xscm.moduleutil.bean.room.RoomInfoResp;
import com.xscm.moduleutil.bean.room.RoomOnline;
import com.xscm.moduleutil.bean.room.RoomPitBean;
import com.xscm.moduleutil.rtc.AgoraIsOPen;
import com.xscm.moduleutil.rtc.AgoraManager;
import com.xscm.moduleutil.rtc.MusicFileBean;
import com.xscm.moduleutil.rtc.MusicPlayBean;

View File

@@ -32,7 +32,6 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.lifecycle.ViewModelProvider;
import com.blankj.utilcode.util.ObjectUtils;
import com.example.moduleroom.R;

View File

@@ -0,0 +1,43 @@
package com.example.moduleroom.service
import android.app.Service
import android.content.Intent
import android.os.IBinder
import android.os.SystemClock
import android.util.Log
// 同时启动两个service共享同一个NotificationID并且将他们同时置为前台状态
// 此时会出现两个前台服务,但通知管理器里只有一个关联的通知。
// 这时我们在其中一个服务中调用 stopForeground(true)
// 这个服务前台状态会被取消,同时状态栏通知也被移除。另外一个服务并没有受到影响,还是前台服务状态,但是此时,状态栏通知已经没了!
// 其oom_adj值还是没变的
class CancelNoticeService : Service() {
override fun onBind(intent: Intent?): IBinder? = null
override fun onCreate() {
super.onCreate()
}
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
if (null == intent) {
//服务被系统kill掉之后重启进来的
return START_NOT_STICKY
}
ForegroundNotification.startForeground(this)
Thread {
SystemClock.sleep(1000)
// stopForeground(true)
Log.d("ForegroundService", "CancelNoticeService onStartCommand: CancelNoticeService" )
ForegroundNotification.stopForeground(this)
// stopSelf()
}.start()
return super.onStartCommand(intent, flags, startId)
}
override fun onDestroy() {
super.onDestroy()
Log.d("ForegroundService", "onDestroy: CancelNoticeService")
}
}

View File

@@ -0,0 +1,63 @@
package com.example.moduleroom.service
import android.app.Activity
import android.app.ActivityManager
import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.provider.Settings
fun Context.startForegroundService() {
Intent(this, ForegroundService::class.java).also { intent ->
if (Build.VERSION.SDK_INT >= 34) {
this.startForegroundService(intent)
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
this.startForegroundService(intent)
} else {
this.startService(intent)
}
}
}
fun Context.hideBackground(hide: Boolean) {
var appTasks: List<ActivityManager.AppTask>? = null
val activityManager = getSystemService(
Context.ACTIVITY_SERVICE
) as? ActivityManager
if (activityManager != null && activityManager.appTasks.also {
appTasks = it
} != null && appTasks?.isNotEmpty() == true) {
appTasks?.get(0)?.setExcludeFromRecents(hide)
}
}
fun Activity.ignoreBattery() {
val intent = Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS)
intent.data = Uri.parse("package:$packageName")
startActivityForResult(intent, 1)
}
fun Activity.startAccessibilitySetting() {
runCatching {
val intent = Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
startActivity(intent)
}
}
fun isServiceRunning(context: Context, serviceName: String="com.voice.module_live.keepalive.ForegroundService"): Boolean {
val activityManager = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
if (activityManager != null) {
for (service in activityManager.getRunningServices(Int.MAX_VALUE)) {
if (serviceName == service.service.className) {
return true
}
}
}
return false
}

View File

@@ -0,0 +1,89 @@
package com.example.moduleroom.service
import android.annotation.SuppressLint
import android.app.*
import android.content.Context
import android.content.Intent
import android.os.Build
import androidx.core.app.NotificationCompat
import androidx.core.content.getSystemService
import com.example.moduleroom.activity.RoomActivity
@SuppressLint("StaticFieldLeak")
object ForegroundNotification {
private const val CHANNEL_FOREGROUND = "foreground-notification"
const val NOTICE_ID = 233
private var service: Service? = null
private fun createChannelIfNeeded(context: Context) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return
val foregroundChannel =
NotificationChannel(CHANNEL_FOREGROUND, "前台服务", NotificationManager.IMPORTANCE_MIN)
.apply {
setShowBadge(false)
enableLights(false)
enableVibration(false)
lockscreenVisibility = Notification.VISIBILITY_SECRET
}
context.getSystemService<NotificationManager>()
?.createNotificationChannel(foregroundChannel)
}
fun startForeground(service: Service) {
ForegroundNotification.service = service
createChannelIfNeeded(service)
val pendingIntent = PendingIntent.getActivity(
service,
0,
Intent(service, RoomActivity::class.java),
PendingIntent.FLAG_IMMUTABLE
)
val notification = NotificationCompat.Builder(service, CHANNEL_FOREGROUND)
.setSmallIcon(com.xscm.moduleutil.R.mipmap.ic_launcher_app)
.setContentText("正在运行")
.setContentIntent(pendingIntent)
.setLocalOnly(true)
.setPriority(NotificationCompat.PRIORITY_MIN)
.setCategory(NotificationCompat.CATEGORY_SERVICE)
.setVisibility(NotificationCompat.VISIBILITY_SECRET)
.setOngoing(true)
.setShowWhen(false)
.build()
service.startForeground(NOTICE_ID, notification)
}
fun stopForeground(service: Service) {
val manager = service.getSystemService(Service.NOTIFICATION_SERVICE) as? NotificationManager
manager?.cancel(NOTICE_ID)
service.stopForeground(true)
}
fun cancelNotice(service: Service) {
val manager = service.getSystemService(Service.NOTIFICATION_SERVICE) as? NotificationManager
manager?.cancel(NOTICE_ID)
}
fun stopForeground() {
val manager =
service?.getSystemService(Service.NOTIFICATION_SERVICE) as? NotificationManager
manager?.cancel(NOTICE_ID)
service?.stopForeground(true)
}
fun startForegroundIfNeed(service: Service) {
val manager = service.getSystemService(Service.NOTIFICATION_SERVICE) as? NotificationManager
var needStart = true
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
manager?.activeNotifications?.forEach {
needStart = (it.id == NOTICE_ID).not()
}
}
if (needStart) {
startForeground(service)
}
}
}

View File

@@ -0,0 +1,49 @@
package com.example.moduleroom.service
import android.app.Service
import android.content.Intent
import android.os.IBinder
import android.util.Log
import java.util.*
//前台服务
class ForegroundService : Service() {
private var logInt = 0
private var timer: Timer? = null
override fun onBind(intent: Intent?): IBinder? = null
override fun onCreate() {
super.onCreate()
ForegroundNotification.startForeground(this)
timer = Timer()
timer?.schedule(object : TimerTask() {
override fun run() {
Log.d("ForegroundService", "Timer task ${logInt++}")
}
}, 0L, 300L)
}
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
if (null == intent) {
//服务被系统kill掉之后重启进来的
return START_NOT_STICKY
}
ForegroundNotification.startForegroundIfNeed(this)
if (ServiceHelper.cancelNotice) {
Log.d("ForegroundService", "onStartCommand: CancelNoticeService")
val intent = Intent(this, CancelNoticeService::class.java)
startService(intent)
}
return super.onStartCommand(intent, flags, startId)
}
override fun onDestroy() {
super.onDestroy()
Log.d("ForegroundService", "onDestroy: $timer")
timer?.cancel()
ForegroundNotification.stopForeground(this)
// 重启自己
startForegroundService()
}
}

View File

@@ -0,0 +1,85 @@
package com.example.moduleroom.service;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.IBinder;
import androidx.annotation.RequiresApi;
import com.xscm.moduleutil.R;
public class RoomPlayService extends Service {
private NotificationManager notificationManager;
private String notificationId = "room_play_channelId";
private String notificationName = "room_play_channelName";
//通知的唯一标识号。
private static final int NOTIFICATION_ID = 11210666;
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
return super.onStartCommand(intent, flags, startId);
}
@Override
public void onCreate() {
super.onCreate();
notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
//创建NotificationChannel
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(notificationId, notificationName, NotificationManager.IMPORTANCE_HIGH);
notificationManager.createNotificationChannel(channel);
}
startForeground(1, getNotification());
}
private Notification getNotification() {
// PendingIntent如果用户选择此通知则启动我们的活动
// PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), 0);
Notification.Builder builder = new Notification.Builder(this)
.setTicker("正在运行")
.setSmallIcon(R.mipmap.ic_launcher_app)
// .setContentIntent(pendingIntent)
.setContentTitle(getString(R.string.app_name))
.setContentText("运行中");
//设置Notification的ChannelID,否则不能正常显示
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
builder.setChannelId(notificationId);
}
Notification notification = builder.build();
//发送通知
// notificationManager.notify(NOTIFICATION_ID,notification);
return notification;
}
@RequiresApi(api = Build.VERSION_CODES.N)
@Override
public void onDestroy() {
super.onDestroy();
if (notificationManager != null) {
notificationManager.cancel(NOTIFICATION_ID);
}
}
}

View File

@@ -0,0 +1,6 @@
package com.example.moduleroom.service
object ServiceHelper {
var cancelNotice = false
}

View File

@@ -483,6 +483,9 @@
app:layout_constraintEnd_toEndOf="parent"
tools:visibility="visible" />
<!--https://tmd.xscmmidi.site/data/avatar/head_pic.png-->
<com.xscm.moduleutil.widget.DropViewRoom
android:id="@+id/xlh_rk"
android:layout_width="wrap_content"
@@ -520,33 +523,6 @@
</com.xscm.moduleutil.widget.DropViewRoom>
<com.xscm.moduleutil.view.FashionAvatarView
android:layout_marginTop="@dimen/dp_200"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:id="@+id/fashionAvatar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:avatarUrl="https://tmd.xscmmidi.site/data/avatar/head_pic.png"
app:avatarRadius="60dp"
app:avatarBorderWidth="3dp"
app:avatarBorderColor="#FFD700"
app:tagText="房主"
app:tagTextColor="#FFFFFF"
app:tagTextSize="12sp"
app:tagBackgroundColor="#FFA500"
app:tagCornerRadius="4dp"
app:tagPadding="4dp"
app:bottomText="时尚的金针菇"
app:bottomTextColor="#FFFFFF"
app:bottomTextSize="14sp"
app:bottomTextOffsetY="10dp"
app:heartIcon="@mipmap/xlh_image"
app:heartCount="6"
app:heartSize="16dp" />
<com.xscm.moduleutil.widget.floatingView.Floa
android:id="@+id/flaoat"
android:layout_width="@dimen/dp_240"

View File

@@ -61,5 +61,9 @@ dependencies {
//annotationProcessor
annotationProcessor 'com.alibaba:arouter-compiler:1.5.2'
implementation files('libs/WbCloudFaceLiveSdk-face-v6.6.2-8e4718fc.aar')
implementation files('libs/WbCloudNormal-v5.1.10-4e3e198.aar')
}
apply plugin: 'com.alibaba.arouter' //

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