修改名称。
This commit is contained in:
1
MainModule/.gitignore
vendored
Normal file
1
MainModule/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
||||
77
MainModule/build.gradle
Normal file
77
MainModule/build.gradle
Normal file
@@ -0,0 +1,77 @@
|
||||
plugins {
|
||||
alias(libs.plugins.android.library)
|
||||
alias(libs.plugins.kotlin.android)
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'com.xscm.modulemain'
|
||||
compileSdk 35
|
||||
|
||||
defaultConfig {
|
||||
minSdk 24
|
||||
targetSdk 35
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
arguments = [
|
||||
AROUTER_MODULE_NAME: project.getName()
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_17
|
||||
targetCompatibility JavaVersion.VERSION_17
|
||||
}
|
||||
dataBinding {
|
||||
enabled = true
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = '11'
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
viewBinding true
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
implementation libs.appcompat
|
||||
implementation libs.material
|
||||
implementation libs.activity
|
||||
implementation libs.constraintlayout
|
||||
// implementation project(':modulevoice')
|
||||
// implementation project(':modulecircle')
|
||||
// implementation project(':modulevocal')
|
||||
// implementation project(':modulenews')
|
||||
// implementation project(':moduleroom')
|
||||
|
||||
testImplementation libs.junit
|
||||
androidTestImplementation libs.ext.junit
|
||||
androidTestImplementation libs.espresso.core
|
||||
implementation project(':BaseModule')
|
||||
|
||||
implementation (libs.arouter.api.v150)
|
||||
//annotationProcessor
|
||||
annotationProcessor libs.arouter.compiler
|
||||
implementation libs.permissionx
|
||||
|
||||
implementation files('libs/WbCloudFaceLiveSdk-face-v6.6.2-8e4718fc.aar')
|
||||
implementation files('libs/WbCloudNormal-v5.1.10-4e3e198.aar')
|
||||
api project(':tuiconversation')
|
||||
api project(':tuichat')
|
||||
api project(':BaseModule')
|
||||
|
||||
|
||||
}
|
||||
apply plugin: 'com.alibaba.arouter' // ⚠️ 添加这一行
|
||||
BIN
MainModule/libs/WbCloudFaceLiveSdk-face-v6.6.2-8e4718fc.aar
Normal file
BIN
MainModule/libs/WbCloudFaceLiveSdk-face-v6.6.2-8e4718fc.aar
Normal file
Binary file not shown.
BIN
MainModule/libs/WbCloudNormal-v5.1.10-4e3e198.aar
Normal file
BIN
MainModule/libs/WbCloudNormal-v5.1.10-4e3e198.aar
Normal file
Binary file not shown.
21
MainModule/proguard-rules.pro
vendored
Normal file
21
MainModule/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
200
MainModule/src/main/AndroidManifest.xml
Normal file
200
MainModule/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,200 @@
|
||||
<?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" />
|
||||
|
||||
<uses-permission android:name="android.permission.REORDER_TASKS" />
|
||||
|
||||
<application
|
||||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name=".activity.login.activity.SwitchAccountsActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.login.activity.ImproveInfoActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.login.activity.ForgetPasswordActivity"
|
||||
android:exported="false" />
|
||||
|
||||
<activity
|
||||
android:name=".activity.login.activity.LoginActivity"
|
||||
android:exported="false" />
|
||||
|
||||
<activity
|
||||
android:name=".activity.main.activity.MainActivity"
|
||||
android:configChanges="fontScale" />
|
||||
|
||||
|
||||
<activity
|
||||
android:name=".activity.room.activity.RoomActivity"
|
||||
android:alwaysRetainTaskState="true"
|
||||
android:configChanges="orientation|screenSize|keyboardHidden"
|
||||
android:enableOnBackInvokedCallback="false"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
|
||||
<activity
|
||||
android:name=".activity.room.activity.RedResultActivity"
|
||||
android:exported="true" />
|
||||
|
||||
|
||||
<activity
|
||||
android:name=".activity.room.activity.SearchActivity"
|
||||
android:exported="false" />
|
||||
|
||||
<activity
|
||||
android:name=".activity.room.activity.RankingListActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.room.activity.PopularRoomActivity"
|
||||
android:exported="false" />
|
||||
|
||||
<activity
|
||||
android:name=".activity.plaza.activity.DynamicDetailActivity"
|
||||
android:exported="false"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
<activity
|
||||
android:name=".activity.plaza.activity.DynamicListActivity"
|
||||
android:exported="false"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
<activity
|
||||
android:name=".activity.plaza.activity.ReleaseActivity"
|
||||
android:exported="false" />
|
||||
|
||||
|
||||
<activity
|
||||
android:name=".activity.user.activity.AboutUsActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.user.activity.WithdrawalListActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.user.activity.GiftBoxRecordActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.user.activity.BindCardDetailsActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.user.activity.BindCardActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.user.activity.AlbumDetailActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.user.activity.SettingActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.user.activity.CreateAlbumActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.user.activity.RevenueActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.user.activity.DailyTasksActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.user.activity.UserHomepageActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.user.activity.MyBagActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.user.activity.BriefIntroductionActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.user.activity.ChangeNicknameActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.user.activity.CurrencyExchangeActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.user.activity.WithdrawalActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.user.activity.RechargeActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.user.activity.MyMoneyActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.user.activity.EditUserInfoActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.user.activity.ChangPassActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.user.activity.PersonalityActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.user.activity.RealDetailActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.user.activity.RoomAllowanceDetailActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.user.activity.RoomAllowanceActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.user.activity.RoomDetailsActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.user.activity.CreatedRoomActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.user.activity.MyRoomActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.user.activity.PhoneReplacementActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.user.activity.BlacklistActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.user.activity.MessageReminderActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.user.activity.NotificationActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.user.activity.UnderageActivity"
|
||||
android:exported="true" />
|
||||
<activity
|
||||
android:name=".activity.user.activity.RealNameActivity"
|
||||
android:exported="false" />
|
||||
|
||||
|
||||
<activity
|
||||
android:name=".activity.WebViewActivity"
|
||||
android:exported="true">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="com.qxcm.qxlive.PROTOCOL_WEBVIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.msg.OfficialNoticeActivity"
|
||||
android:exported="false" />
|
||||
|
||||
<service
|
||||
android:name=".service.MediaProjectionService"
|
||||
android:foregroundServiceType="mediaProjection" />
|
||||
|
||||
<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>
|
||||
52
MainModule/src/main/java/com/xscm/modulemain/Application.kt
Normal file
52
MainModule/src/main/java/com/xscm/modulemain/Application.kt
Normal file
@@ -0,0 +1,52 @@
|
||||
package com.xscm.modulemain
|
||||
|
||||
import android.content.Context
|
||||
import com.blankj.utilcode.util.LogUtils
|
||||
import com.opensource.svgaplayer.utils.log.SVGALogger
|
||||
import com.scwang.smartrefresh.layout.SmartRefreshLayout
|
||||
import com.scwang.smartrefresh.layout.api.DefaultRefreshFooterCreator
|
||||
import com.scwang.smartrefresh.layout.api.DefaultRefreshHeaderCreator
|
||||
import com.scwang.smartrefresh.layout.api.RefreshFooter
|
||||
import com.scwang.smartrefresh.layout.api.RefreshHeader
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout
|
||||
import com.scwang.smartrefresh.layout.footer.ClassicsFooter
|
||||
import com.scwang.smartrefresh.layout.header.ClassicsHeader
|
||||
import com.xscm.modulemain.widget.WheatLayoutSingManager
|
||||
import com.xscm.moduleutil.base.CommonAppContext
|
||||
|
||||
|
||||
open class Application : CommonAppContext() {
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
// 初始化并预绘制视图 二卡八列
|
||||
WheatLayoutSingManager.init(this)
|
||||
WheatLayoutSingManager.getInstance().setWheatData( null)
|
||||
|
||||
// 默认情况下,SVGA 内部不会输出任何 log,所以需要手动设置为 true
|
||||
SVGALogger.setLogEnabled(false)
|
||||
LogUtils.getConfig().isLogSwitch = true
|
||||
|
||||
|
||||
//设置全局的Header构建器
|
||||
SmartRefreshLayout.setDefaultRefreshHeaderCreator { context, _ ->
|
||||
val header = ClassicsHeader(context)
|
||||
header.setDrawableSize(20f)
|
||||
// header.setFinishDuration(0)
|
||||
header.setTextSizeTitle(12f)
|
||||
header.setTextSizeTime(10f)
|
||||
header
|
||||
}
|
||||
|
||||
//设置全局的Footer构建器
|
||||
SmartRefreshLayout.setDefaultRefreshFooterCreator { context, _ ->
|
||||
val classicsFooter = ClassicsFooter(context)
|
||||
classicsFooter.setDrawableSize(20f)
|
||||
// classicsFooter.setFinishDuration(0)
|
||||
classicsFooter.setTextSizeTitle(12f)
|
||||
//指定为经典Footer,默认是 BallPulseFooter
|
||||
classicsFooter
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
1026
MainModule/src/main/java/com/xscm/modulemain/BaseMvpActivity.java
Normal file
1026
MainModule/src/main/java/com/xscm/modulemain/BaseMvpActivity.java
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,459 @@
|
||||
package com.xscm.modulemain.activity;
|
||||
|
||||
import static android.view.View.GONE;
|
||||
import static android.view.View.VISIBLE;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.ClipData;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.webkit.GeolocationPermissions;
|
||||
import android.webkit.JavascriptInterface;
|
||||
import android.webkit.ValueCallback;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Autowired;
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.tencent.imsdk.v2.V2TIMConversation;
|
||||
import com.tencent.mm.opensdk.modelbiz.WXOpenCustomerServiceChat;
|
||||
import com.tencent.mm.opensdk.openapi.IWXAPI;
|
||||
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
|
||||
import com.tencent.qcloud.tuicore.TUIConstants;
|
||||
import com.tencent.qcloud.tuikit.tuichat.classicui.page.TUIGroupChatActivity;
|
||||
import com.xscm.modulemain.BaseMvpActivity;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.databinding.ActivityWebViewBinding;
|
||||
import com.xscm.modulemain.manager.RoomManager;
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
|
||||
/**
|
||||
* @author qx
|
||||
* @data 2025/6/3
|
||||
* @description: webview公共方法
|
||||
*/
|
||||
@Route(path = ARouteConstants.H5)
|
||||
public class WebViewActivity extends BaseMvpActivity<IPresenter,ActivityWebViewBinding> implements IView<Activity> {
|
||||
|
||||
public String title;
|
||||
public String url;
|
||||
@Autowired
|
||||
public String type;//type=1:青少年模式
|
||||
private ValueCallback<Uri> mUploadMessage;
|
||||
private ValueCallback<Uri[]> mUploadCallbackAboveL;
|
||||
private final int REQUEST_FILE_PICKER = 1;
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
@Override
|
||||
protected void initData() {
|
||||
|
||||
|
||||
WebSettings webSettings = mBinding.webView.getSettings();
|
||||
|
||||
// 禁用水平滚动
|
||||
webSettings.setUseWideViewPort(true);
|
||||
webSettings.setLoadWithOverviewMode(true);
|
||||
webSettings.setJavaScriptEnabled(true);
|
||||
webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); //关闭webview中缓存
|
||||
//增加JSBridge
|
||||
mBinding.webView.addJavascriptInterface(new WebAppInterface(this, type), "Android");
|
||||
|
||||
if (title != null && !title.isEmpty()) {
|
||||
if (title.contains("协议")) {
|
||||
webSettings.setDisplayZoomControls(false); // 隐藏默认缩放控件
|
||||
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL); // 使用正常布局算法
|
||||
webSettings.setBuiltInZoomControls(false);
|
||||
webSettings.setSupportZoom(false);
|
||||
|
||||
// 重要:设置布局算法为适应屏幕
|
||||
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING);
|
||||
// 设置初始缩放
|
||||
mBinding.webView.setInitialScale(100);
|
||||
mBinding.webView.getSettings().setUseWideViewPort(false);
|
||||
} else {
|
||||
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
|
||||
}
|
||||
} else {
|
||||
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
|
||||
}
|
||||
|
||||
webSettings.setBuiltInZoomControls(true);
|
||||
webSettings.setSupportZoom(true);
|
||||
webSettings.setDomStorageEnabled(true);
|
||||
webSettings.setBlockNetworkImage(false);//解决图片不显示
|
||||
webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
|
||||
mBinding.webView.setHorizontalScrollBarEnabled(false);//水平不显示
|
||||
mBinding.webView.setVerticalScrollBarEnabled(false); //垂直不显示
|
||||
mBinding.webView.setScrollbarFadingEnabled(false);
|
||||
mBinding.webView.setScrollContainer(true);
|
||||
|
||||
|
||||
mBinding.webView.setWebViewClient(new WebViewClient());
|
||||
mBinding.webView.setBackgroundColor(Color.TRANSPARENT);
|
||||
mBinding.webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
||||
|
||||
mBinding.webView.requestFocus();
|
||||
mBinding.webView.loadUrl(url);
|
||||
|
||||
mBinding.webView.setWebChromeClient(new WebChromeClient() {
|
||||
|
||||
//配置权限(同样在WebChromeClient中实现)
|
||||
@Override
|
||||
public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
|
||||
callback.invoke(origin, true, false);
|
||||
super.onGeolocationPermissionsShowPrompt(origin, callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgressChanged(WebView view, int newProgress) {
|
||||
if (title != null && !title.isEmpty()) {
|
||||
if (title.contains("协议")) {
|
||||
|
||||
if (newProgress >= 100) {
|
||||
// 页面加载完成后调整文本换行
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// 注入CSS确保文字自动换行
|
||||
mBinding.webView.loadUrl("javascript:(function() {" +
|
||||
"var sheets = document.styleSheets;" +
|
||||
"for (var i = 0; i < sheets.length; i++) {" +
|
||||
" try {" +
|
||||
" sheets[i].addRule('*', 'word-wrap: break-word !important; white-space: normal !important; overflow-x: hidden !important;', 0);" +
|
||||
" } catch(e) {" +
|
||||
" try {" +
|
||||
" sheets[i].insertRule('* { word-wrap: break-word !important; white-space: normal !important; overflow-x: hidden !important; }', 0);" +
|
||||
" } catch(e2) {}" +
|
||||
" }" +
|
||||
"}" +
|
||||
"})()");
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// For Android < 3.0
|
||||
public void openFileChooser(ValueCallback<Uri> uploadMsg) {
|
||||
mUploadMessage = uploadMsg;
|
||||
// showFileChooser();
|
||||
|
||||
}
|
||||
|
||||
// For Android > 4.1.1
|
||||
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
|
||||
mUploadMessage = uploadMsg;
|
||||
// showFileChooser();
|
||||
}
|
||||
|
||||
// For Android > 5.0支持多张上传
|
||||
@Override
|
||||
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> uploadMsg, WebChromeClient.FileChooserParams
|
||||
fileChooserParams) {
|
||||
mUploadCallbackAboveL = uploadMsg;
|
||||
showFileChooser();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivedTitle(WebView view, String title) {
|
||||
super.onReceivedTitle(view, title);
|
||||
// tvTitle.setText(title);
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
|
||||
if (getOnBackPressedDispatcher() != null) {
|
||||
getOnBackPressedDispatcher().addCallback(this, new androidx.activity.OnBackPressedCallback(true) {
|
||||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
// 拦截返回键,显示退出对话框而不是直接退出
|
||||
showExitRoomDialog();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void showExitRoomDialog() {
|
||||
if (type != null) {
|
||||
if (type.equals("1")) {
|
||||
ARouter.getInstance().build(ARouteConstants.UNDERAGE_ACTIVITY).withInt("type", 1).navigation();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
private void showFileChooser() {
|
||||
// 这里可以扩展为显示对话框让用户选择“拍照”或“从相册选择”
|
||||
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
intent.setType("image/*");
|
||||
startActivityForResult(Intent.createChooser(intent, "选择图片"), REQUEST_FILE_PICKER);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
||||
if (requestCode == REQUEST_FILE_PICKER) {
|
||||
if (mUploadMessage != null) {
|
||||
Uri result = data == null || resultCode != RESULT_OK ? null : data.getData();
|
||||
mUploadMessage.onReceiveValue(result);
|
||||
mUploadMessage = null;
|
||||
} else if (mUploadCallbackAboveL != null) {
|
||||
Uri[] results = null;
|
||||
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||
String dataString = data.getDataString();
|
||||
ClipData clipData = data.getClipData();
|
||||
|
||||
if (clipData != null) {
|
||||
results = new Uri[clipData.getItemCount()];
|
||||
for (int i = 0; i < clipData.getItemCount(); i++) {
|
||||
ClipData.Item item = clipData.getItemAt(i);
|
||||
results[i] = item.getUri();
|
||||
}
|
||||
}
|
||||
|
||||
if (dataString != null)
|
||||
results = new Uri[]{Uri.parse(dataString)};
|
||||
}
|
||||
|
||||
mUploadCallbackAboveL.onReceiveValue(results);
|
||||
mUploadCallbackAboveL = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
// 当type==1时,禁止返回键和手势返回
|
||||
// 不执行任何操作,禁止返回
|
||||
if (type != null) {
|
||||
if (type.equals("1")) {
|
||||
ARouter.getInstance().build(ARouteConstants.UNDERAGE_ACTIVITY).withInt("type", 1).navigation();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
|
||||
// 正常处理返回键
|
||||
super.onBackPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
LogUtils.d("MainActivity", "onKeyDown called, keyCode: " + keyCode);
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
if (type != null) {
|
||||
if (type.equals("1")) {
|
||||
ARouter.getInstance().build(ARouteConstants.UNDERAGE_ACTIVITY).withInt("type", 1).navigation();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
return true; // 消费事件
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IPresenter bindPresenter() {
|
||||
return null;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public boolean dispatchTouchEvent(MotionEvent ev) {
|
||||
// // 当type==1时,禁止手势滑动返回
|
||||
// if (type.equals("1")) {
|
||||
// // 检查是否是边缘滑动返回手势
|
||||
// if (ev.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
// // 如果触摸点在屏幕边缘,拦截事件
|
||||
// if (ev.getX() < 50) { // 左边缘50像素内
|
||||
// return true; // 拦截事件,不传递给子View
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return super.dispatchTouchEvent(ev);
|
||||
// }
|
||||
@Override
|
||||
protected void initView() {
|
||||
getWindow().getDecorView().setBackgroundResource(com.xscm.moduleutil.R.color.white);
|
||||
title = getIntent().getStringExtra("title");
|
||||
url = getIntent().getStringExtra("url");
|
||||
type = getIntent().getStringExtra("type");
|
||||
if (type != null) {
|
||||
// 当type==1时,禁用返回手势滑动
|
||||
if (type.equals("1")) {
|
||||
// 禁用边缘滑动返回
|
||||
if (getSupportActionBar() != null) {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (title != null) {
|
||||
if (title.equals("举报") || title.equals("等级") || title.equals("公会") || title.equals("邀请") || title.equals("反馈")) {
|
||||
mBinding.topBar.setVisibility(GONE);
|
||||
// mBinding.webView.setPadding(0,20,0,0);
|
||||
} else {
|
||||
mBinding.topBar.setVisibility(VISIBLE);
|
||||
mBinding.topBar.setTitle(title);
|
||||
}
|
||||
} else {
|
||||
if (url.equals(CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl() + "/api/Page/page_show?id=6")) {
|
||||
mBinding.topBar.setVisibility(VISIBLE);
|
||||
mBinding.topBar.setTitle("用户协议");
|
||||
} else if (url.equals(CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl() + "/api/Page/page_show?id=4")) {
|
||||
mBinding.topBar.setVisibility(VISIBLE);
|
||||
mBinding.topBar.setTitle("隐私协议");
|
||||
} else {
|
||||
mBinding.topBar.setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_web_view;
|
||||
}
|
||||
|
||||
public class WebAppInterface {
|
||||
Context mContext;
|
||||
String type;
|
||||
|
||||
WebAppInterface(Context c, String type1) {
|
||||
mContext = c;
|
||||
type = type1;
|
||||
}
|
||||
|
||||
// 被 H5 调用的方法
|
||||
@JavascriptInterface
|
||||
public void showToast(String toast) {
|
||||
Toast.makeText(mContext, toast, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void closeWeb() {
|
||||
if (type != null) {
|
||||
if (type.equals("1")) {
|
||||
ARouter.getInstance().build(ARouteConstants.UNDERAGE_ACTIVITY).withInt("type", 1).navigation();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void customerService() {
|
||||
String appId = CommonAppContext.getInstance().getCurrentEnvironment().getWxAppId(); // 填移动应用(App)的 AppId
|
||||
IWXAPI api = WXAPIFactory.createWXAPI(mContext, appId);
|
||||
|
||||
// 判断当前版本是否支持拉起客服会话
|
||||
WXOpenCustomerServiceChat.Req req = new WXOpenCustomerServiceChat.Req();
|
||||
req.corpId = "ww1de4300858c0b461"; // 企业ID
|
||||
req.url = "https://work.weixin.qq.com/kfid/kfcb3d23a59c188a0e7"; // 客服URL
|
||||
api.sendReq(req);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void jumpRoomPage(String room_id) {
|
||||
RoomManager.getInstance().fetchRoomDataAndEnter(getApplicationContext(), room_id,"",null);
|
||||
|
||||
// ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("form", "首页").withString("roomId", room_id).navigation();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void jumpWebPage(String objects) {
|
||||
// ARouter.getInstance().build(ARouteConstants.USER_HOME_PAGE).navigation();
|
||||
ARouter.getInstance().build(ARouteConstants.USER_HOME_PAGE).withString("userId", objects).navigation();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void enterGroupChat(String group_id, String cover, String guild_name) {
|
||||
Intent intent = new Intent(mContext, TUIGroupChatActivity.class);
|
||||
intent.putExtra(TUIConstants.TUIChat.CHAT_ID, group_id);
|
||||
intent.putExtra(TUIConstants.TUIChat.CHAT_NAME, guild_name);
|
||||
intent.putExtra(TUIConstants.TUIChat.CHAT_TYPE, V2TIMConversation.V2TIM_GROUP);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void chatWithUser(String user_id, String nickname) {
|
||||
Intent intent = new Intent(mContext, TUIGroupChatActivity.class);
|
||||
intent.putExtra(TUIConstants.TUIChat.CHAT_ID, user_id);
|
||||
intent.putExtra(TUIConstants.TUIChat.CHAT_NAME, nickname);
|
||||
intent.putExtra(TUIConstants.TUIChat.CHAT_TYPE, V2TIMConversation.V2TIM_C2C);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void exchange() {
|
||||
ARouter.getInstance().build(ARouteConstants.CURRENCY).navigation();
|
||||
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void Withdrawal() {
|
||||
ARouter.getInstance().build(ARouteConstants.WITHDRAWAL_ACTIVITY).navigation();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void enterAuthent() {//实名认证
|
||||
ARouter.getInstance().build(ARouteConstants.REAL_NAME_ACTIVITY2).navigation();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void Recharge() {
|
||||
ARouter.getInstance().build(ARouteConstants.RECHARGE_ACTIVITY).navigation();
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void closeWeb() {
|
||||
//做原生操作
|
||||
// Intent intent = new Intent(mContext, ListActivity.class);
|
||||
// intent.putExtra("menuName", msg);
|
||||
// startActivity(intent);
|
||||
|
||||
|
||||
LogUtils.e("closeWeb");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
package com.xscm.modulemain.activity.login.activity;
|
||||
|
||||
import android.os.CountDownTimer;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.activity.login.present.LoginContacter;
|
||||
import com.xscm.modulemain.activity.login.present.LoginPresenter;
|
||||
import com.xscm.modulemain.databinding.ActivityForgetPasswordBinding;
|
||||
import com.xscm.modulemain.BaseMvpActivity;
|
||||
import com.xscm.moduleutil.bean.ThemeBean;
|
||||
import com.xscm.moduleutil.bean.UserBean;
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/6/3
|
||||
*@description: 忘记密码重新修改密码
|
||||
*/
|
||||
public class ForgetPasswordActivity extends BaseMvpActivity<LoginPresenter, ActivityForgetPasswordBinding> implements LoginContacter.View, View.OnClickListener {
|
||||
|
||||
private CountDownTimer mTimer;
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
mBinding.tvSendCode.setOnClickListener(this::onClick);
|
||||
mBinding.btnSubmit.setOnClickListener(this::onClick);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_forget_password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v.getId() == R.id.tv_send_code) {
|
||||
String phone = mBinding.edPhone.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(phone)) {
|
||||
ToastUtils.showShort("请输入手机号");
|
||||
return;
|
||||
}
|
||||
sendCodeSuccess(phone);
|
||||
MvpPre.sendCode(phone, 3);
|
||||
}
|
||||
else if (v.getId() == R.id.btnSubmit){
|
||||
String phone = mBinding.edPhone.getText().toString().trim();
|
||||
String code = mBinding.edPassword.getText().toString().trim();
|
||||
String password = mBinding.editTextNewPassword.getText().toString().trim();
|
||||
String confirmPassword = mBinding.editTextConfirmPassword.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(phone)){
|
||||
ToastUtils.showShort("请输入手机号");
|
||||
return;
|
||||
}
|
||||
if (TextUtils.isEmpty(code)){
|
||||
ToastUtils.showShort("请输入验证码");
|
||||
return;
|
||||
}
|
||||
if (TextUtils.isEmpty(password)){
|
||||
ToastUtils.showShort("请输入密码");
|
||||
return;
|
||||
}
|
||||
if (TextUtils.isEmpty(confirmPassword)){
|
||||
ToastUtils.showShort("两次密码不一致");
|
||||
return;
|
||||
}
|
||||
if (!password.equals(confirmPassword)){
|
||||
ToastUtils.showShort("两次密码不一致");
|
||||
return;
|
||||
}
|
||||
MvpPre.forgotPassword(password,phone,code);
|
||||
|
||||
}
|
||||
}
|
||||
private void releaseTimer() {
|
||||
if (mTimer != null) {
|
||||
mTimer.cancel();
|
||||
mTimer = null;
|
||||
}
|
||||
}
|
||||
public void sendCodeSuccess(String phoneNumber) {
|
||||
ToastUtils.showShort("短信验证码发送成功请注意查收");
|
||||
mBinding.tvSendCode.setEnabled(false);
|
||||
mBinding.tvSendCode.setAlpha(0.5f);
|
||||
releaseTimer();
|
||||
if (mTimer != null) {
|
||||
mTimer.cancel();
|
||||
}
|
||||
mTimer = new CountDownTimer(60000L, 1000L) {
|
||||
@Override
|
||||
public void onTick(long millisUntilFinished) {
|
||||
if (mBinding.tvSendCode != null) {
|
||||
mBinding.tvSendCode.setText(String.format("重新发送(%s)", millisUntilFinished / 1000));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
mBinding.tvSendCode.setAlpha(1f);
|
||||
mBinding.tvSendCode.setEnabled(true);
|
||||
mBinding.tvSendCode.setText("重新发送");
|
||||
}
|
||||
};
|
||||
mTimer.start();
|
||||
}
|
||||
@Override
|
||||
public void sendCodeSuccess1(String phoneNumber) {
|
||||
LogUtils.e(phoneNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loginSuccess(UserBean userBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void authorizationSuccess(String s) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ysxlSuccess(String s) {
|
||||
ToastUtils.showShort(s);
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getThemeData(ThemeBean themeBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LoginPresenter bindPresenter() {
|
||||
return new LoginPresenter(this, this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,307 @@
|
||||
package com.xscm.modulemain.activity.login.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.luck.picture.lib.basic.PictureSelector;
|
||||
import com.luck.picture.lib.config.PictureConfig;
|
||||
import com.luck.picture.lib.entity.LocalMedia;
|
||||
import com.luck.picture.lib.style.PictureSelectorStyle;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.activity.login.contacts.ImproveInfoContacts;
|
||||
import com.xscm.modulemain.activity.login.contacts.ImproveInfoPresenter;
|
||||
import com.xscm.modulemain.activity.main.activity.MainActivity;
|
||||
import com.xscm.modulemain.databinding.ActivityImproveInfoBinding;
|
||||
import com.xscm.modulemain.BaseMvpActivity;
|
||||
import com.xscm.moduleutil.bean.UserBean;
|
||||
import com.xscm.moduleutil.utils.DateSelectDialog;
|
||||
import com.xscm.moduleutil.utils.GlideEngine;
|
||||
import com.xscm.moduleutil.utils.ImageLoader;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
import com.xscm.moduleutil.utils.PermissionDescriptionHelper;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
import com.xscm.moduleutil.widget.Constants;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class ImproveInfoActivity extends BaseMvpActivity<ImproveInfoPresenter, ActivityImproveInfoBinding> implements
|
||||
ImproveInfoContacts.View, View.OnClickListener, DateSelectDialog.OnSelectDate {
|
||||
private String sex;
|
||||
|
||||
public String nickname;
|
||||
public String user_no_parent;
|
||||
|
||||
private long startTime = 0;//开始时间
|
||||
private long stayTime = 0;//停留时间
|
||||
private boolean isGirlSelected = false;
|
||||
private boolean isBoySelected = false;
|
||||
private DateSelectDialog mDateSelectDialog;
|
||||
private boolean isFirst = false;
|
||||
UserBean userBean;
|
||||
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
|
||||
private String avatar;
|
||||
private String birthdy;
|
||||
private String init_code;
|
||||
@Override
|
||||
protected void initData() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
super.initView();
|
||||
Bundle extras = getIntent().getExtras();
|
||||
userBean= extras != null ? (UserBean) extras.getSerializable("userBean") : null;
|
||||
assert userBean != null;
|
||||
if (userBean.getNickname()!=null&&!"".equals(userBean.getNickname())){
|
||||
MvpPre.updateNickname();
|
||||
}else {
|
||||
mBinding.edNickName.setText(userBean.getNickname());
|
||||
}
|
||||
mBinding.edNickName.setClearIconVisible(true);
|
||||
// ImageUtils.loadHeadCC(userBean.getAvatar(), mBinding.rvUserHead);
|
||||
if (!TextUtils.isEmpty(user_no_parent) && !"0".equals(user_no_parent)) {
|
||||
mBinding.etInviteCode.setText(user_no_parent);
|
||||
mBinding.etInviteCode.setKeyListener(null);
|
||||
mBinding.etInviteCode.setFocusable(false);
|
||||
mBinding.etInviteCode.setFocusableInTouchMode(false);
|
||||
}
|
||||
startTime = System.currentTimeMillis();
|
||||
mBinding.flCommit.setOnClickListener(this::onClick);
|
||||
mBinding.rlNv.setOnClickListener(this::onClick);
|
||||
mBinding.rlNan.setOnClickListener(this::onClick);
|
||||
mBinding.rvUserHead.setOnClickListener(this::onClick);
|
||||
mBinding.tvUserName.setOnClickListener(this::onClick);
|
||||
mBinding.ivGirl.setOnClickListener(this::onClick);
|
||||
mBinding.ivBoy.setOnClickListener(this::onClick);
|
||||
mBinding.tvDay.setOnClickListener(this::onClick);
|
||||
mBinding.tvMonth.setOnClickListener(this::onClick);
|
||||
mBinding.tvYear.setOnClickListener(this::onClick);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_improve_info;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ImproveInfoPresenter bindPresenter() {
|
||||
return new ImproveInfoPresenter(this, this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
stayTime = (System.currentTimeMillis() - startTime) / 1000;
|
||||
// AppLogUtil.reportAppLog(AppLogEvent.A0301, "stend_time", String.valueOf(stayTime));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int id = v.getId();
|
||||
if (id == R.id.fl_commit) {
|
||||
nickname = mBinding.edNickName.getText().toString().trim();
|
||||
String inviteCode = mBinding.etInviteCode.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(nickname)) {
|
||||
com.hjq.toast.ToastUtils.show("请输入昵称");
|
||||
// ToastUtils.showShort("请输入昵称");
|
||||
return;
|
||||
}
|
||||
if (sex==null||TextUtils.isEmpty(sex)) {
|
||||
com.hjq.toast.ToastUtils.show("请选择性别");
|
||||
// ToastUtils.showShort("请选择性别");
|
||||
return;
|
||||
}
|
||||
if (!inviteCode.isEmpty() || inviteCode != null) {
|
||||
// map.put("user_no", inviteCode);
|
||||
init_code = inviteCode;
|
||||
}
|
||||
map.put("sex", sex);
|
||||
String user_id="";
|
||||
if (userBean!=null){
|
||||
user_id = userBean.getUser_id() + "";
|
||||
}
|
||||
assert userBean != null;
|
||||
userBean.setSex(Integer.parseInt(sex));
|
||||
userBean.setNickname(nickname);
|
||||
userBean.setAvatar(avatar);
|
||||
SpUtil.saveUserBean(userBean);
|
||||
MvpPre.upDateUserInfo(nickname, birthdy, sex, avatar, init_code, user_id);
|
||||
// MvpPre.fill(inviteCode, nickname, sex);
|
||||
|
||||
// try {
|
||||
// AppLogUtil.reportAppLog(AppLogEvent.A0302, new JSONObject()
|
||||
// .put("sex", sex).put("nick_name", nickname)
|
||||
// .put("invitation_code", mBinding.etInviteCode.getText().toString()));
|
||||
// } catch (JSONException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
} else if (id == R.id.rl_nv) {
|
||||
mBinding.flCommit.setEnabled(true);
|
||||
mBinding.rlNan.setSelected(false);
|
||||
mBinding.rlNv.setSelected(true);
|
||||
sex = "2";
|
||||
} else if (id == R.id.rl_nan) {
|
||||
mBinding.flCommit.setEnabled(true);
|
||||
mBinding.rlNan.setSelected(true);
|
||||
mBinding.rlNv.setSelected(false);
|
||||
sex = "1";
|
||||
} else if (id == R.id.rv_user_head) {
|
||||
startChoosePhoto(1, PictureConfig.CHOOSE_REQUEST);
|
||||
} else if (id == R.id.tv_user_name) {
|
||||
MvpPre.updateNickname();
|
||||
} else if (id == R.id.iv_girl) {
|
||||
if (!isGirlSelected) {
|
||||
mBinding.ivGirl.setImageResource(com.xscm.moduleutil.R.mipmap.check_girl1);
|
||||
mBinding.ivBoy.setImageResource(com.xscm.moduleutil.R.mipmap.check_boy);
|
||||
isGirlSelected = true;
|
||||
isBoySelected = false;
|
||||
if (!isFirst) {
|
||||
MvpPre.getSexTrue("2");
|
||||
}
|
||||
sex = "2";
|
||||
}
|
||||
} else if (id == R.id.iv_boy) {
|
||||
if (!isBoySelected) {
|
||||
mBinding.ivGirl.setImageResource(com.xscm.moduleutil.R.mipmap.check_girl);
|
||||
mBinding.ivBoy.setImageResource(com.xscm.moduleutil.R.mipmap.check_boy1);
|
||||
isBoySelected = true;
|
||||
isGirlSelected = false;
|
||||
if (!isFirst) {
|
||||
MvpPre.getSexTrue("1");
|
||||
}
|
||||
sex = "1";
|
||||
}
|
||||
} else if (id == R.id.tv_day || id == R.id.tv_month || id == R.id.tv_year) {
|
||||
if (mDateSelectDialog == null) {
|
||||
mDateSelectDialog = new DateSelectDialog(this);
|
||||
mDateSelectDialog.setmOnSelectDate(this);
|
||||
}
|
||||
mDateSelectDialog.show();
|
||||
}
|
||||
}
|
||||
|
||||
private void startChoosePhoto(int mimeType, int requestCode) {
|
||||
|
||||
|
||||
PictureSelector.create(this)
|
||||
.openGallery(mimeType)
|
||||
.setSelectorUIStyle(new PictureSelectorStyle())
|
||||
.isGif(false)
|
||||
.setImageEngine(GlideEngine.createGlideEngine())
|
||||
.setPermissionDescriptionListener(PermissionDescriptionHelper.createListener())
|
||||
.setMaxSelectNum(1)
|
||||
.isPreviewImage(true)
|
||||
.isDisplayCamera(false)
|
||||
.setOutputCameraDir(Constants.FILE_PATH)
|
||||
.isOriginalSkipCompress(true)
|
||||
.forResult(requestCode); //结果回调onActivityResult code
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (resultCode == RESULT_OK && data != null) {
|
||||
switch (requestCode) {
|
||||
case PictureConfig.CHOOSE_REQUEST:
|
||||
List<LocalMedia> localMedia = PictureSelector.obtainSelectorList(data);
|
||||
if (localMedia != null && localMedia.size() != 0) {
|
||||
LocalMedia imgMedia = localMedia.get(0);
|
||||
String url;
|
||||
if (imgMedia.isCompressed()) {
|
||||
url = imgMedia.getCompressPath();
|
||||
} else {
|
||||
url = imgMedia.getRealPath();
|
||||
}
|
||||
MvpPre.uploadFile(new File(url), 0);
|
||||
}
|
||||
break;
|
||||
case PictureConfig.REQUEST_CAMERA:
|
||||
List<LocalMedia> localMedia1 = PictureSelector.obtainSelectorList(data);
|
||||
if (localMedia1 != null && localMedia1.size() != 0) {
|
||||
LocalMedia imgMedia = localMedia1.get(0);
|
||||
MvpPre.uploadFile(new File(imgMedia.getRealPath()), 3);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upLoadSuccess(String url, int type) {
|
||||
// MvpPre.updateAvatar(url);
|
||||
ImageUtils.loadHeadCC(url, mBinding.rvUserHead);
|
||||
map.put("avatar", url);
|
||||
avatar=url;
|
||||
isFirst = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAvatarSuccess(String headPicture) {
|
||||
ImageLoader.loadHead(this, mBinding.rvUserHead, headPicture);
|
||||
map.put("avatar", headPicture);
|
||||
avatar=headPicture;
|
||||
isFirst = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateNicknameSuccess(String nickname) {
|
||||
mBinding.edNickName.setText(nickname);
|
||||
map.put("nickname", nickname);
|
||||
this.nickname=nickname;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSexTrue(String sex1) {
|
||||
ImageLoader.loadHead(this, mBinding.rvUserHead,sex1);
|
||||
map.put("avatar", sex1);
|
||||
// sex=sex1;
|
||||
avatar=sex1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSuccess(UserBean userBean) {
|
||||
// SpUtil.saveUserBean(userBean);
|
||||
EventBus.getDefault().post(SpUtil.getUserBean());
|
||||
|
||||
// TUILogin.login(ImproveInfoActivity.this, CommonAppContext.getInstance().getCurrentEnvironment().getSdkAppId(), String.valueOf(userBean.getUser_code()), userBean.getTencent_im(), new TUICallback() {
|
||||
// @Override
|
||||
// public void onError(final int code, final String desc) {
|
||||
// LogUtils.e("@@@",code,"描述:",desc);
|
||||
// }
|
||||
// @Override
|
||||
// public void onSuccess() {
|
||||
// LogUtils.e("@@@","成功");
|
||||
// }
|
||||
// });
|
||||
|
||||
Intent intent = new Intent(this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void selectDate(String year, String month, String day) {
|
||||
mBinding.tvDay.setText(day);
|
||||
mBinding.tvMonth.setText(month);
|
||||
mBinding.tvYear.setText(year);
|
||||
map.put("birthday", year + "-" + month + "-" + day);
|
||||
birthdy=year + "-" + month + "-" + day;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,328 @@
|
||||
package com.xscm.modulemain.activity.login.activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.text.method.PasswordTransformationMethod;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.alipay.sdk.app.AuthTask;
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.tencent.mm.opensdk.modelbase.BaseResp;
|
||||
import com.tencent.mm.opensdk.modelmsg.SendAuth;
|
||||
import com.tencent.mm.opensdk.openapi.IWXAPI;
|
||||
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.activity.login.present.LoginContacter;
|
||||
import com.xscm.modulemain.activity.login.present.LoginPresenter;
|
||||
import com.xscm.modulemain.databinding.ActivityLoginBinding;
|
||||
import com.xscm.modulemain.BaseMvpActivity;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.bean.ThemeBean;
|
||||
import com.xscm.moduleutil.bean.UserBean;
|
||||
import com.xscm.moduleutil.utils.BarUtils;
|
||||
import com.xscm.moduleutil.utils.PreferencesUtils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @data
|
||||
* @description: 密码登录
|
||||
*/
|
||||
public class LoginActivity extends BaseMvpActivity<LoginPresenter, ActivityLoginBinding> implements LoginContacter.View, View.OnClickListener {
|
||||
|
||||
|
||||
public String mobile;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_login;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void finishEvent() {
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
super.initView();
|
||||
BarUtils.setStatusBarAlpha(this, 0);
|
||||
mBinding.edPhone.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
setUpLoginBtn();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
mBinding.edPhone.setOnFocusChangeListener(new View.
|
||||
OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View v, boolean hasFocus) {
|
||||
if (mBinding.edPhone == null) {
|
||||
return;
|
||||
}
|
||||
if (hasFocus) {
|
||||
mBinding.relPhone.setSelected(true);
|
||||
} else {
|
||||
// 此处为失去焦点时的处理内容
|
||||
mBinding.relPhone.setSelected(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
mBinding.edPassword.setOnFocusChangeListener(new View.
|
||||
OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View v, boolean hasFocus) {
|
||||
if (mBinding.relPhone == null) {
|
||||
return;
|
||||
}
|
||||
if (hasFocus) {
|
||||
// 此处为得到焦点时的处理内容
|
||||
mBinding.rlCode.setSelected(true);
|
||||
} else {
|
||||
// 此处为失去焦点时的处理内容
|
||||
mBinding.rlCode.setSelected(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
mBinding.edPhone.setText(PreferencesUtils.getString(CommonAppContext.getInstance(), "mobile"));
|
||||
if (!TextUtils.isEmpty(mobile)) {
|
||||
mBinding.edPhone.setText(mobile);
|
||||
}
|
||||
mBinding.tvCodeText.setOnClickListener(this::onClick);
|
||||
mBinding.flLogin.setOnClickListener(this::onClick);
|
||||
mBinding.ivZfb.setOnClickListener(this::onClick);
|
||||
mBinding.ivWeixin.setOnClickListener(this::onClick);
|
||||
mBinding.tvYhxy.setOnClickListener(this::onClick);
|
||||
mBinding.tvYsxy.setOnClickListener(this::onClick);
|
||||
mBinding.ivEye.setOnClickListener(this::onClick);
|
||||
mBinding.tvForgetPassword.setOnClickListener(this::onClick);
|
||||
}
|
||||
|
||||
private void setUpLoginBtn() {
|
||||
String text = mBinding.edPhone.getText().toString();
|
||||
if (text.length() == 11) {
|
||||
mBinding.flLogin.setEnabled(true);
|
||||
mBinding.ivLoginBg.setAlpha(1f);
|
||||
} else {
|
||||
mBinding.ivLoginBg.setAlpha(0.3f);
|
||||
mBinding.flLogin.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LoginPresenter bindPresenter() {
|
||||
return new LoginPresenter(this, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Activity getSelfActivity() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showLoadings() {
|
||||
showLoading();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showLoadings(String content) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disLoadings() {
|
||||
disLoading();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void sendCodeSuccess1(String phoneNumber) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loginSuccess(UserBean userBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void authorizationSuccess(String s) {
|
||||
zfbLogin(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ysxlSuccess(String s) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getThemeData(ThemeBean themeBean) {
|
||||
|
||||
}
|
||||
|
||||
boolean isPasswordVisible = false;
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
int id = view.getId();
|
||||
if (id == R.id.tv_code_text) {
|
||||
// Intent intent = new Intent(this, PasswordLoginActivity.class);
|
||||
// intent.putExtra("mobile", mBinding.edPhone.getText().toString());
|
||||
// startActivity(intent);
|
||||
// finish();
|
||||
} else if (id == R.id.fl_login) {
|
||||
if (!mBinding.cbPrivacy.isChecked()) {
|
||||
com.hjq.toast.ToastUtils.show("请先勾选服务条款");
|
||||
return;
|
||||
}
|
||||
String phoneNumber = mBinding.edPhone.getText().toString().trim();
|
||||
String password = mBinding.edPassword.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(phoneNumber)) {
|
||||
ToastUtils.showShort("请输入手机号");
|
||||
return;
|
||||
}
|
||||
if (TextUtils.isEmpty(password)) {
|
||||
ToastUtils.showShort("请输入登录密码");
|
||||
return;
|
||||
}
|
||||
MvpPre.login(phoneNumber, password, "", 2);
|
||||
// Intent intent = new Intent(this, MainActivity.class);
|
||||
// startActivity(intent);
|
||||
// finish();
|
||||
} else if (id == R.id.iv_zfb) {
|
||||
if (!mBinding.cbPrivacy.isChecked()) {
|
||||
com.hjq.toast.ToastUtils.show("请先勾选服务条款");
|
||||
return;
|
||||
}
|
||||
MvpPre.authorization("zfb");
|
||||
// zfbLogin();
|
||||
} else if (id == R.id.iv_weixin) {
|
||||
|
||||
if (!mBinding.cbPrivacy.isChecked()) {
|
||||
com.hjq.toast.ToastUtils.show("请先勾选服务条款");
|
||||
return;
|
||||
}
|
||||
wcLogin();
|
||||
} else if (id == R.id.tv_yhxy) {
|
||||
MvpPre.ysxl();
|
||||
} else if (id == R.id.tv_ysxy) {
|
||||
MvpPre.yhxy();
|
||||
} else if (id == R.id.iv_eye) {
|
||||
|
||||
if (!isPasswordVisible) {
|
||||
mBinding.edPassword.setInputType(android.text.InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
|
||||
mBinding.ivEye.setImageResource(com.xscm.moduleutil.R.mipmap.eye_visible); // 设置按钮文本为隐藏密码
|
||||
} else {
|
||||
mBinding.edPassword.setInputType(android.text.InputType.TYPE_CLASS_TEXT | android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
||||
mBinding.edPassword.setTransformationMethod(PasswordTransformationMethod.getInstance());
|
||||
mBinding.ivEye.setImageResource(com.xscm.moduleutil.R.mipmap.eye_close); // 设置按钮文本为显示密码
|
||||
}
|
||||
mBinding.edPassword.setSelection(mBinding.edPassword.getText().length()); // 将光标移动到文字末尾
|
||||
isPasswordVisible = !isPasswordVisible; // 切换状态
|
||||
} else if (id == R.id.tv_forget_password) {
|
||||
Intent intent = new Intent(this, ForgetPasswordActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("UnspecifiedRegisterReceiverFlag")
|
||||
private void wcLogin() {
|
||||
//发起登陆请求前先注册微信api
|
||||
IWXAPI api = WXAPIFactory.createWXAPI(this, CommonAppContext.getInstance().getCurrentEnvironment().getWxAppId(), true);
|
||||
api.registerApp(CommonAppContext.getInstance().getCurrentEnvironment().getWxAppId());
|
||||
if (!api.isWXAppInstalled()) {
|
||||
//todo 提醒未安装微信
|
||||
ToastUtils.showShort("请安装微信客户端");
|
||||
return;
|
||||
}
|
||||
//开始发起登陆请求
|
||||
final SendAuth.Req req = new SendAuth.Req();
|
||||
req.scope = "snsapi_userinfo";
|
||||
req.state = "wechat_sdk_demo_test";
|
||||
api.sendReq(req);
|
||||
}
|
||||
|
||||
private void zfbLogin(String s) {
|
||||
LogUtils.e("@@@",s);
|
||||
CommonAppContext.getInstance();
|
||||
if (!CommonAppContext.isAlipayInstalled(this)){
|
||||
ToastUtils.showShort("请安装支付宝客户端");
|
||||
return;
|
||||
}
|
||||
String authInfo = s;
|
||||
// String authInfo = "apiname=com.alipay.account.auth&app_id=2021005152631691&app_name=yusheng&auth_type=AUTHACCOUNT&biz_type=openservice&method=alipay.open.auth.sdk.code.get&pid=2088170624624316&product_id=APP_FAST_LOGIN&scope=kuaijie&sign_type=RSA2&target_id=20141225xxxx&sign=fMcp4GtiM6rxSIeFnJCVePJKV43eXrUP86CQgiLhDHH2u%2FdN75eEvmywc2ulkm7qKRetkU9fbVZtJIqFdMJcJ9Yp%2BJI%2FF%2FpESafFR6rB2fRjiQQLGXvxmDGVMjPSxHxVtIqpZy5FDoKUSjQ2%2FILDKpu3%2F%2BtAtm2jRw1rUoMhgt0%3D";
|
||||
Runnable authRunnable = new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// 构造AuthTask 对象
|
||||
AuthTask authTask = new AuthTask(LoginActivity.this);
|
||||
// 调用授权接口,获取授权结果
|
||||
Map<String, String> result = authTask.authV2(authInfo, true);
|
||||
LogUtils.e(result);
|
||||
if (result.get("resultStatus").equals("9000")){
|
||||
Pattern pattern = Pattern.compile("auth_code=([^&]*)");
|
||||
Matcher matcher = pattern.matcher(result.get("result"));
|
||||
|
||||
if (matcher.find()) {
|
||||
String authCode = matcher.group(1);
|
||||
LogUtils.e("AuthCode", authCode);
|
||||
MvpPre.oauthLogin(authCode,2);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Thread authThread = new Thread(authRunnable);
|
||||
authThread.start();
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void loginEvent(BaseResp event) {
|
||||
if (event.errCode ==BaseResp.ErrCode.ERR_OK){
|
||||
SendAuth.Resp authResp = (SendAuth.Resp)event;
|
||||
LogUtils.e("@@@",authResp.code);
|
||||
MvpPre.oauthLogin(authResp.code,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.xscm.modulemain.activity.login.activity;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.activity.login.present.LoginContacter;
|
||||
import com.xscm.modulemain.activity.login.present.LoginPresenter;
|
||||
import com.xscm.modulemain.adapter.SwitchAccountsAdapter;
|
||||
import com.xscm.modulemain.databinding.ActivitySwitchAccountsBinding;
|
||||
import com.xscm.modulemain.BaseMvpActivity;
|
||||
import com.xscm.moduleutil.bean.ThemeBean;
|
||||
import com.xscm.moduleutil.bean.UserBean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/5/19
|
||||
*@description: 选择账号
|
||||
*/
|
||||
public class SwitchAccountsActivity extends BaseMvpActivity<LoginPresenter, ActivitySwitchAccountsBinding> implements LoginContacter.View {
|
||||
|
||||
private List<UserBean> userBeanList=new ArrayList<>();
|
||||
private SwitchAccountsAdapter switchAccountsAdapter;
|
||||
@Override
|
||||
protected void initData() {
|
||||
mBinding.topBar.setTitle("选择账号");
|
||||
Bundle bundle = getIntent().getExtras();
|
||||
if (bundle != null) {
|
||||
try {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
// 使用正确的类引用
|
||||
userBeanList = (List<UserBean>) bundle.getSerializable("userBean");
|
||||
} else {
|
||||
Object serializable = bundle.getSerializable("userBean");
|
||||
if (serializable instanceof List<?>) {
|
||||
// 进一步检查列表元素类型(可选但更安全)
|
||||
List<?> tempList = (List<?>) serializable;
|
||||
if (tempList.isEmpty() || tempList.get(0) instanceof UserBean) {
|
||||
userBeanList = (List<UserBean>) tempList;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e("UserBeanError", "Failed to deserialize userBean list", e);
|
||||
}
|
||||
}
|
||||
if (userBeanList!=null&&userBeanList.size()>0){
|
||||
switchAccountsAdapter=new SwitchAccountsAdapter();
|
||||
mBinding.rvList.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
|
||||
mBinding.rvList.setAdapter(switchAccountsAdapter);
|
||||
switchAccountsAdapter.setNewData(userBeanList);
|
||||
switchAccountsAdapter.setOnItemClickListener(item -> {
|
||||
MvpPre.switchAccounts(String.valueOf(item.getUser_id()));
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_switch_accounts;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LoginPresenter bindPresenter() {
|
||||
return new LoginPresenter(this, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCodeSuccess1(String phoneNumber) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loginSuccess(UserBean userBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void authorizationSuccess(String s) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ysxlSuccess(String s) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getThemeData(ThemeBean themeBean) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.xscm.modulemain.activity.login.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.UserBean;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public final class ImproveInfoContacts {
|
||||
|
||||
|
||||
public interface View extends IView<Activity> {
|
||||
|
||||
void upLoadSuccess(String url, int type);
|
||||
|
||||
void updateAvatarSuccess(String url);
|
||||
|
||||
void updateNicknameSuccess(String nickname);
|
||||
|
||||
void updateSexTrue(String sex);
|
||||
|
||||
void updateSuccess(UserBean userBean);
|
||||
}
|
||||
|
||||
public interface IImproveInfoPre extends IPresenter {
|
||||
|
||||
void uploadFile(File file, int type);
|
||||
|
||||
void updateAvatar(String headPicture);
|
||||
|
||||
void updateNickname();
|
||||
|
||||
void getSexTrue(String sex);
|
||||
|
||||
void upDateUserInfo(String nickname,String birthday,String sex,String avatar,String init_code,String user_id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package com.xscm.modulemain.activity.login.contacts;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.bean.UserBean;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
import com.xscm.moduleutil.utils.cos.CosUploadManager;
|
||||
import com.xscm.moduleutil.utils.oss.OSSOperUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class ImproveInfoPresenter extends BasePresenter<ImproveInfoContacts.View> implements ImproveInfoContacts.IImproveInfoPre {
|
||||
ImproveInfoContacts.View mView;
|
||||
public ImproveInfoPresenter(ImproveInfoContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
mView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadFile(File file, int type) {
|
||||
MvpRef.get().showLoadings("上传中...");
|
||||
String url = OSSOperUtils.getPath(file, type);
|
||||
CosUploadManager.getInstance(CommonAppContext.getInstance()).upParameters(url,file.getPath(), new CosUploadManager.UploadCallback() {
|
||||
@Override
|
||||
public void onSuccess(String url) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().disLoadings();
|
||||
MvpRef.get().upLoadSuccess(url, type);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Exception e) {
|
||||
ToastUtils.show("上传失败");
|
||||
MvpRef.get().disLoadings();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure1(IllegalStateException e) {
|
||||
ToastUtils.show("上传失败");
|
||||
MvpRef.get().disLoadings();
|
||||
}
|
||||
});
|
||||
|
||||
// OSSOperUtils.newInstance().putObjectMethod(url, file.getPath(), new OSSOperUtils.OssCallback() {
|
||||
// @Override
|
||||
// public void onSuccess() {
|
||||
// if (isViewAttach()) {
|
||||
// MvpRef.get().disLoadings();
|
||||
// MvpRef.get().upLoadSuccess(OSSOperUtils.AliYunOSSURLFile + url, type);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onFail() {
|
||||
// if (isViewAttach()) {
|
||||
// MvpRef.get().disLoadings();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAvatar(String headPicture) {
|
||||
// MvpRef.get().showLoadings();
|
||||
// ApiClient.getInstance().updateAvatar(headPicture, new BaseObserver<String>() {
|
||||
// @Override
|
||||
// public void onSubscribe(Disposable d) {
|
||||
// addDisposable(d);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(String s) {
|
||||
// MvpRef.get().updateAvatarSuccess(headPicture);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
// MvpRef.get().disLoadings();
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateNickname() {
|
||||
// TODO: 2019/1/15 完善昵称修改功能
|
||||
api.upUserNickname(new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
MvpRef.get().updateNicknameSuccess(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSexTrue(String sex) {
|
||||
// TODO: 2019/1/15 完善性别获取头像信息
|
||||
api.upUserPic(sex, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String userPictrue) {
|
||||
MvpRef.get().updateSexTrue(userPictrue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upDateUserInfo(String nickname, String birthday, String sex, String avatar, String init_code, String user_id) {
|
||||
api.userUpdate(nickname, birthday, sex, avatar, init_code, user_id, new BaseObserver<UserBean>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(UserBean userBean) {
|
||||
MvpRef.get().updateSuccess(userBean);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.xscm.modulemain.activity.login.present;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.ThemeBean;
|
||||
import com.xscm.moduleutil.bean.UserBean;
|
||||
|
||||
public final class LoginContacter {
|
||||
public interface View extends IView<Activity> {
|
||||
void sendCodeSuccess1(String phoneNumber);
|
||||
void loginSuccess(UserBean userBean);
|
||||
|
||||
void authorizationSuccess(String s);
|
||||
|
||||
void ysxlSuccess(String s);
|
||||
|
||||
void getThemeData(ThemeBean themeBean);
|
||||
}
|
||||
|
||||
public interface ILoginPre extends IPresenter {
|
||||
void sendCode(String phoneNumber, int type);
|
||||
|
||||
void login(String mobile, String password, String code, int type);
|
||||
|
||||
|
||||
void oauthLogin(String auth_code,int type);//阿里登录
|
||||
|
||||
void switchAccounts(String loginId);//切换账号
|
||||
|
||||
|
||||
void forgotPassword(String new_password,String mobile, String sms_code );
|
||||
|
||||
void oauthLoginLogin(String auth_code);
|
||||
|
||||
void getThemeData();//主题接口
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,282 @@
|
||||
package com.xscm.modulemain.activity.login.present;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.blankj.utilcode.util.AppUtils;
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.xscm.modulemain.activity.login.activity.ImproveInfoActivity;
|
||||
import com.xscm.modulemain.activity.login.activity.SwitchAccountsActivity;
|
||||
import com.xscm.modulemain.activity.main.activity.MainActivity;
|
||||
import com.xscm.modulemain.activity.WebViewActivity;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.bean.ThemeBean;
|
||||
import com.xscm.moduleutil.bean.UserBean;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class LoginPresenter extends BasePresenter<LoginContacter.View> implements LoginContacter.ILoginPre {
|
||||
public LoginPresenter(LoginContacter.View view, Context context) {
|
||||
super(view, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCode(String phoneNumber, int type) {
|
||||
api.sendCode(phoneNumber, "default", new BaseObserver<Object>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(Object o) {
|
||||
MvpRef.get().sendCodeSuccess1(o + "");
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录
|
||||
*
|
||||
* @param mobile 手机号
|
||||
* @param password 密码
|
||||
* @param code 验证码
|
||||
* @param type 1:手机号登录 2:密码登录
|
||||
*/
|
||||
@Override
|
||||
public void login(String mobile, String password, String code, int type) {
|
||||
if (type == 1) {
|
||||
api.login(mobile, code, new BaseObserver<List<UserBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<UserBean> userBeans) {
|
||||
loginSuccess(userBeans);
|
||||
}
|
||||
|
||||
});
|
||||
} else if (type == 2) {
|
||||
api.userLogin(mobile, password, new BaseObserver<List<UserBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<UserBean> userBeans) {
|
||||
loginSuccess(userBeans);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 支付宝登录
|
||||
*
|
||||
* @param auth_code
|
||||
* @param type type=1:微信登录;type=2:支付宝登录
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void oauthLogin(String auth_code, int type) {
|
||||
api.authCode(auth_code, type, new BaseObserver<List<UserBean>>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<UserBean> userBeans) {
|
||||
loginSuccess(userBeans);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void switchAccounts(String loginId) {
|
||||
api.switchAccounts(loginId, new BaseObserver<List<UserBean>>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<UserBean> userBeans) {
|
||||
loginSuccess(userBeans);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forgotPassword(String new_password, String mobile, String sms_code) {
|
||||
api.forgotPassword(new_password, mobile, sms_code, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
MvpRef.get().ysxlSuccess(s);
|
||||
}
|
||||
});
|
||||
}
|
||||
//一键登陆
|
||||
@Override
|
||||
public void oauthLoginLogin(String auth_code) {
|
||||
api.oauthLogin(auth_code, new BaseObserver<List<UserBean>>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<UserBean> userBeans) {
|
||||
loginSuccess(userBeans);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getThemeData() {
|
||||
api.getThemeData(new BaseObserver<ThemeBean>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(ThemeBean themeBean) {
|
||||
MvpRef.get().getThemeData(themeBean);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detachView() {
|
||||
|
||||
}
|
||||
|
||||
public void loginSuccess(List<UserBean> userBean) {
|
||||
if (userBean == null) {
|
||||
// ToastUtils.showShort("登录失败请重试");
|
||||
return;
|
||||
}
|
||||
if (userBean.size() == 1) {
|
||||
|
||||
CommonAppContext.getInstance().setUser(userBean.get(0));
|
||||
if (userBean.get(0).getAuth() == 1) {
|
||||
SpUtil.setRealName(true);
|
||||
} else {
|
||||
SpUtil.setRealName(false);
|
||||
}
|
||||
|
||||
// PreferencesUtils.putString( CommonAppContext.getInstance(), "mobile", userBean.get());
|
||||
|
||||
if (isViewAttach()) {
|
||||
// MvpRef.get().disLoadings();
|
||||
}
|
||||
if (userBean.get(0).getSex() == 0) {
|
||||
try {
|
||||
Intent intent = new Intent(com.blankj.utilcode.util.ActivityUtils.getTopActivity(), ImproveInfoActivity.class);
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable("userBean", userBean.get(0));
|
||||
intent.putExtras(bundle);
|
||||
com.blankj.utilcode.util.ActivityUtils.startActivity(intent);
|
||||
com.blankj.utilcode.util.ActivityUtils.getTopActivity().finish();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
EventBus.getDefault().post(userBean.get(0));
|
||||
com.blankj.utilcode.util.ActivityUtils.startActivity(MainActivity.class);
|
||||
com.blankj.utilcode.util.ActivityUtils.getTopActivity().finish();
|
||||
}
|
||||
} else {
|
||||
Intent intent = new Intent(com.blankj.utilcode.util.ActivityUtils.getTopActivity(), SwitchAccountsActivity.class);
|
||||
Bundle bundle = new Bundle();
|
||||
// bundle.putSerializable("userBean", (Serializable) userBean);
|
||||
intent.putExtra("userBean", (ArrayList<UserBean>) userBean);
|
||||
intent.putExtras(bundle);
|
||||
com.blankj.utilcode.util.ActivityUtils.startActivity(intent);
|
||||
com.blankj.utilcode.util.ActivityUtils.getTopActivity().finish();
|
||||
|
||||
}
|
||||
// EventBus.getDefault().post(new LoginFinishEvent());
|
||||
// EventBus.getDefault().post(new SplashFinishEvent());
|
||||
// AppLog.setUserUniqueID(userBean.getUser_id()); // 设置您自己的账号体系ID, 并保证其唯一性 !
|
||||
}
|
||||
|
||||
public void authorization(String type) {
|
||||
|
||||
if (type.equals("wx")) {
|
||||
if (!AppUtils.isAppInstalled("com.tencent.mm")) {
|
||||
ToastUtils.showShort("请安装微信客户端");
|
||||
return;
|
||||
}
|
||||
// IWXAPI api = WXEntryActivity.getWXAPI();
|
||||
// final SendAuth.Req req = new SendAuth.Req();
|
||||
// req.scope = "snsapi_userinfo"; // 只能填 snsapi_userinfo
|
||||
// req.state = "wechat_sdk_demo_test";
|
||||
// api.sendReq(req);
|
||||
} else if (type.equals("zfb")) {
|
||||
// Map<String, String> result = authTask.authV2(authInfo, true);
|
||||
api.authorization(new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
MvpRef.get().authorizationSuccess(s);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void ysxl() {
|
||||
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() {
|
||||
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();
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,66 @@
|
||||
package com.xscm.modulemain.activity.main.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.*;
|
||||
import com.xscm.moduleutil.bean.room.RoomOnline;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public final class HomeContacts {
|
||||
|
||||
|
||||
public interface View extends IView<Activity> {
|
||||
|
||||
|
||||
void appUpdate(AppUpdateModel appUpdateModel);
|
||||
|
||||
void setRandomHotRoom(String roomId);
|
||||
|
||||
void setUnReadCount(int unreadMessageCount);
|
||||
|
||||
// void UserFilesSuccess(UserBean userBean);
|
||||
|
||||
void quitSuccess(String roomId);
|
||||
void myInfoSuccess(FirstChargeBean data);
|
||||
|
||||
void getThemeData(ThemeBean themeBean);
|
||||
|
||||
void getRoomOnline(RoomOnline onlineBean);
|
||||
|
||||
void activitiesPermissionSuccess(ActivitiesPermission activitiesPermission);
|
||||
|
||||
}
|
||||
|
||||
public interface IHomePre extends IPresenter {
|
||||
void initData();
|
||||
|
||||
void loginIm();
|
||||
|
||||
void quitRoom(String roomId);
|
||||
|
||||
void appUpdate();
|
||||
|
||||
void randomHotRoom();
|
||||
|
||||
void userNews();
|
||||
|
||||
void signSwitch();
|
||||
|
||||
void userFiles();
|
||||
|
||||
void address_ip(String ip);
|
||||
|
||||
void getMyInfo(String userId);
|
||||
|
||||
void getThemeData();//主题接口
|
||||
|
||||
void getRoomOnline(String roomId, String page, String page_limit);//在线列表
|
||||
|
||||
void activitiesPermission();//活动弹框权限
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,417 @@
|
||||
package com.xscm.modulemain.activity.main.presenter;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.PowerManager;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.xscm.modulemain.activity.main.contacts.HomeContacts;
|
||||
import com.xscm.moduleutil.bean.*;
|
||||
import com.xscm.moduleutil.bean.room.RoomOnline;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class HomePresenter extends BasePresenter<HomeContacts.View> implements HomeContacts.IHomePre {
|
||||
|
||||
HomeContacts.View mView;
|
||||
|
||||
public HomePresenter(HomeContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
mView=view;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void appUpdate() {
|
||||
api.appUpdate(new BaseObserver<AppUpdateModel>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(AppUpdateModel appUpdataModel) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().appUpdate(appUpdataModel);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomHotRoom() {
|
||||
// NewApi.getInstance().getRandomRecommendRoom(new com.qpyy.libcommon.api.BaseObserver<RandomRecommendRoomResp>() {
|
||||
// @Override
|
||||
// public void onSubscribe(Disposable d) {
|
||||
// addDisposable(d);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(RandomRecommendRoomResp randomRecommendRoomResp) {
|
||||
// if (randomRecommendRoomResp != null && !TextUtils.isEmpty(randomRecommendRoomResp.getRoom_id()) && !"0".equals(randomRecommendRoomResp.getRoom_id())) {
|
||||
// MvpRef.get().setRandomHotRoom(randomRecommendRoomResp.getRoom_id());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
//
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
@Override
|
||||
public void userNews() {
|
||||
// NewApi.getInstance().getMessageCount(new com.qpyy.libcommon.api.BaseObserver<UserMsgCountResp>() {
|
||||
// @Override
|
||||
// public void onSubscribe(Disposable d) {
|
||||
// addDisposable(d);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(UserMsgCountResp userMsgCountResp) {
|
||||
// int unreadMessageCount = EMClient.getInstance().chatManager().getUnreadMessageCount() + userMsgCountResp.getUnReadCount();
|
||||
// MvpRef.get().setUnReadCount(unreadMessageCount);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
//
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
@Override
|
||||
public void signSwitch() {
|
||||
// getApi().signSwitch(new BaseObserver<SignSwitchModel>() {
|
||||
// @Override
|
||||
// public void onSubscribe(Disposable d) {
|
||||
// addDisposable(d);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(SignSwitchModel signSwitchModel) {
|
||||
// MyApplication.getInstance().labor = signSwitchModel.getLabor() == 1;
|
||||
// MyApplication.getInstance().chat_min_level = signSwitchModel.getChat_min_level();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
//
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
@Override
|
||||
public void userFiles() {
|
||||
// getApi().userFiles(new BaseObserver<UserBean>() {
|
||||
// @Override
|
||||
// public void onSubscribe(Disposable d) {
|
||||
// addDisposable(d);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(UserBean userBean) {
|
||||
// MvpRef.get().UserFilesSuccess(userBean);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
//
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
@Override
|
||||
public void address_ip(String ip) {
|
||||
api.address_ip(ip, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
// GrabMarblesManager.INSTANCE.setToken(SpUtils.getToken());
|
||||
// GrabMarblesManager.INSTANCE.setUserId(SpUtils.getUserId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loginIm() {
|
||||
UserBean user = SpUtil.getUserBean();
|
||||
EventBus.getDefault().post(user);
|
||||
|
||||
// boolean connected = EMClient.getInstance().isConnected();
|
||||
// if (NetworkUtils.isConnected() && !connected) {
|
||||
// UserBean user = MyApplication.getInstance().getUser();
|
||||
// if (TextUtils.isEmpty(user.getEmchat_username()) || TextUtils.isEmpty(user.getEmchat_password())) {
|
||||
// ToastUtils.showShort("无环信账号或密码,请重新登录");
|
||||
// MyApplication.getInstance().reLogin();
|
||||
// return;
|
||||
// }
|
||||
// EMClient.getInstance().login(user.getEmchat_username(), user.getEmchat_password(), new EMCallBack() {
|
||||
// @Override
|
||||
// public void onSuccess() {
|
||||
// EChartHelper.getInstance().setCurrentUserName(user.getEmchat_username());
|
||||
// EChartHelper.getInstance().getUserProfileManager().updateCurrentUserNickName(user.getNickname());
|
||||
// EChartHelper.getInstance().getUserProfileManager().setCurrentUserAvatar(user.getHead_picture());
|
||||
// EMClient.getInstance().groupManager().loadAllGroups();
|
||||
// EMClient.getInstance().chatManager().loadAllConversations();
|
||||
// EMClient.getInstance().pushManager().asyncUpdatePushNickname(user.getEmchat_username(), new EMCallBack() {
|
||||
// @Override
|
||||
// public void onSuccess() {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError(int i, String s) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onProgress(int i, String s) {
|
||||
//
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError(int i, String s) {
|
||||
//// ToastUtils.showShort("登录失败:" + i + " " + s);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onProgress(int i, String s) {
|
||||
//
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public void quitRoom(String roomId) {
|
||||
// MvpRef.get().showLoadings();
|
||||
// NewApi.getInstance().quit(roomId, new com.qpyy.libcommon.api.BaseObserver<String>() {
|
||||
// @Override
|
||||
// public void onSubscribe(Disposable d) {
|
||||
// addDisposable(d);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(String s) {
|
||||
// MvpRef.get().quitSuccess(roomId);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
//
|
||||
//// MvpRef.get().disLoadings();
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
private boolean isIgnoringBatteryOptimizations() {
|
||||
boolean isIgnoring = false;
|
||||
PowerManager powerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
|
||||
if (powerManager != null) {
|
||||
isIgnoring = powerManager.isIgnoringBatteryOptimizations(mContext.getPackageName());
|
||||
}
|
||||
return isIgnoring;
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
public void requestIgnoreBatteryOptimizations() {
|
||||
Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
|
||||
intent.setData(Uri.parse("package:" + mContext.getPackageName()));
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 跳转到指定应用的首页
|
||||
*/
|
||||
private void showActivity(@NonNull String packageName) {
|
||||
Intent intent = mContext.getPackageManager().getLaunchIntentForPackage(packageName);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到指定应用的指定页面
|
||||
*/
|
||||
private void showActivity(@NonNull String packageName, @NonNull String activityDir) {
|
||||
Intent intent = new Intent();
|
||||
intent.setComponent(new ComponentName(packageName, activityDir));
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
|
||||
|
||||
private void goXiaomiSetting() {
|
||||
showActivity("com.miui.securitycenter",
|
||||
"com.miui.permcenter.autostart.AutoStartManagementActivity");
|
||||
}
|
||||
|
||||
private void goHuaweiSetting() {
|
||||
try {
|
||||
showActivity("com.huawei.systemmanager",
|
||||
"com.huawei.systemmanager.startupmgr.ui.StartupNormalAppListActivity");
|
||||
} catch (Exception e) {
|
||||
showActivity("com.huawei.systemmanager",
|
||||
"com.huawei.systemmanager.optimize.bootstart.BootStartActivity");
|
||||
}
|
||||
}
|
||||
|
||||
private void goOPPOSetting() {
|
||||
try {
|
||||
showActivity("com.coloros.phonemanager");
|
||||
} catch (Exception e1) {
|
||||
try {
|
||||
showActivity("com.oppo.safe");
|
||||
} catch (Exception e2) {
|
||||
try {
|
||||
showActivity("com.coloros.oppoguardelf");
|
||||
} catch (Exception e3) {
|
||||
showActivity("com.coloros.safecenter");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void goVIVOSetting() {
|
||||
showActivity("com.iqoo.secure");
|
||||
}
|
||||
|
||||
private void goMeizuSetting() {
|
||||
showActivity("com.meizu.safe");
|
||||
}
|
||||
|
||||
private void goSamsungSetting() {
|
||||
try {
|
||||
showActivity("com.samsung.android.sm_cn");
|
||||
} catch (Exception e) {
|
||||
showActivity("com.samsung.android.sm");
|
||||
}
|
||||
}
|
||||
|
||||
private void goLetvSetting() {
|
||||
showActivity("com.letv.android.letvsafe",
|
||||
"com.letv.android.letvsafe.AutobootManageActivity");
|
||||
}
|
||||
|
||||
private void goSmartisanSetting() {
|
||||
showActivity("com.smartisanos.security");
|
||||
}
|
||||
|
||||
public void delayPreloadImage() {
|
||||
// ThreadUtils.runOnUiThreadDelayed(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// ImageUtils.preloadImgConstants();
|
||||
// }
|
||||
// }, 6 * 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMyInfo(String userId) {
|
||||
api.firstCharge( userId,new BaseObserver<FirstChargeBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(FirstChargeBean myInfoResp) {
|
||||
if (MvpRef==null){
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().myInfoSuccess(myInfoResp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getThemeData() {
|
||||
api.getThemeData(new BaseObserver<ThemeBean>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(ThemeBean themeBean) {
|
||||
if (MvpRef==null){
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().getThemeData(themeBean);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getRoomOnline(String roomId, String page, String page_limit) {
|
||||
api.getRoomOnline(roomId, page, page_limit, new BaseObserver<RoomOnline>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(RoomOnline roomOnlineBeans) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().getRoomOnline(roomOnlineBeans);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activitiesPermission() {
|
||||
api.activitiesPermission(new BaseObserver<ActivitiesPermission>() {
|
||||
@Override
|
||||
public void onSubscribe(@NotNull Disposable d) {
|
||||
addDisposable( d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NotNull ActivitiesPermission activitiesPermission) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().activitiesPermissionSuccess(activitiesPermission);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.xscm.modulemain.activity.msg;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.NewsMessageList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class NewsContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
void showNews(List<NewsMessageList> newsList);
|
||||
void finishRefresh();
|
||||
}
|
||||
public interface IHomePre extends IPresenter {
|
||||
|
||||
void getMessagetitle(String type,String page,String pageLimit);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.xscm.modulemain.activity.msg;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.xscm.moduleutil.bean.NewsMessageList;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class NewsPresenter extends BasePresenter<NewsContacts.View> implements NewsContacts.IHomePre {
|
||||
public NewsPresenter(NewsContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void getMessagetitle(String type, String page, String pageLimit) {
|
||||
api.getMessagetitle(type, page, pageLimit, new BaseObserver<List<NewsMessageList>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<NewsMessageList> newsMessageLists) {
|
||||
MvpRef.get().showNews(newsMessageLists);
|
||||
MvpRef.get().finishRefresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
package com.xscm.modulemain.activity.msg;
|
||||
|
||||
import static android.view.View.GONE;
|
||||
import static android.view.View.VISIBLE;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.text.Html;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
|
||||
import com.xscm.modulemain.BaseMvpActivity;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.databinding.ActivityOfficialNoticeBinding;
|
||||
import com.xscm.modulemain.manager.RoomManager;
|
||||
import com.xscm.modulemain.activity.WebViewActivity;
|
||||
import com.xscm.moduleutil.bean.NewsMessageList;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
import com.xscm.moduleutil.utils.TimeUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class OfficialNoticeActivity extends BaseMvpActivity<NewsPresenter, ActivityOfficialNoticeBinding> implements NewsContacts.View {
|
||||
|
||||
private int page = 1;
|
||||
private BaseQuickAdapter<NewsMessageList, BaseViewHolder> mAdapter;
|
||||
private String type;
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
type = getIntent().getStringExtra("type");
|
||||
if (type.equals("1")) {
|
||||
mBinding.topBar.setTitle("系统消息");
|
||||
} else {
|
||||
mBinding.topBar.setTitle("官方公告");
|
||||
}
|
||||
// mBinding.smartRefreshLayout.autoRefresh();
|
||||
|
||||
|
||||
mBinding.smartRefreshLayout.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
|
||||
@Override
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
page++;
|
||||
MvpPre.getMessagetitle(type, page + "", "10");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
page = 1;
|
||||
MvpPre.getMessagetitle(type, page + "", "10");
|
||||
}
|
||||
});
|
||||
mBinding.recycleView.setLayoutManager(new LinearLayoutManager(this));
|
||||
mAdapter = new BaseQuickAdapter<NewsMessageList, BaseViewHolder>(R.layout.news_rv_item_system_news) {
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, NewsMessageList item) {
|
||||
String time = TimeUtils.getDateToStringNoZ(Long.parseLong(item.getCreatetime()) * 1000L);
|
||||
helper.setText(R.id.tv_sys_time, time);
|
||||
if (item.getImage()==null || item.getImage().isEmpty()){
|
||||
helper.getView(R.id.tv_sys_con).setVisibility(VISIBLE);
|
||||
helper.setText(R.id.tv_sys_con, item.getContent());
|
||||
helper.getView(R.id.ll_system_official).setVisibility(GONE);
|
||||
}else {
|
||||
helper.getView(R.id.tv_sys_con).setVisibility(GONE);
|
||||
helper.getView(R.id.ll_system_official).setVisibility(VISIBLE);
|
||||
ImageUtils.loadHeadCC(item.getImage(), helper.getView(R.id.image));
|
||||
helper.setText(R.id.tv_cont, Html.fromHtml(item.getContent()));
|
||||
}
|
||||
helper.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (item.getRoom_id()>0){
|
||||
RoomManager.getInstance().fetchRoomDataAndEnter(getApplicationContext(), item.getRoom_id()+"","",null);
|
||||
// ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("roomId", item.getRoom_id() + "").navigation();
|
||||
}else if (item.getRoom_id() == 0 && item.getUrl() != null && !item.getUrl().isEmpty()){
|
||||
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();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// if (item.getType().equals("1")) {
|
||||
// helper.getView(R.id.ll_system_official).setVisibility(GONE);
|
||||
// } else if (item.getType().equals("2")) {
|
||||
// helper.getView(R.id.tv_sys_con).setVisibility(GONE);
|
||||
// helper.getView(R.id.ll_system_official).setVisibility(VISIBLE);
|
||||
// } else {
|
||||
// helper.getView(R.id.ll_system_official).setVisibility(GONE);
|
||||
// }
|
||||
|
||||
// helper.getView(R.id.image).setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
//
|
||||
// }
|
||||
// });
|
||||
}
|
||||
};
|
||||
mBinding.recycleView.setAdapter(mAdapter);
|
||||
MvpPre.getMessagetitle(type, "1", "10");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_official_notice;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NewsPresenter bindPresenter() {
|
||||
return new NewsPresenter(this, this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void showNews(List<NewsMessageList> newsList) {
|
||||
mAdapter.setNewData(newsList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishRefresh() {
|
||||
mBinding.smartRefreshLayout.finishRefresh();
|
||||
mBinding.smartRefreshLayout.finishLoadMore();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.xscm.modulemain.activity.msg.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.NewsDataBean;
|
||||
import com.xscm.moduleutil.bean.UserInfo;
|
||||
|
||||
public class NewsContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
|
||||
void getOfficialNoticeList(NewsDataBean newsDataBeans);
|
||||
void myInfoSuccess(UserInfo data);
|
||||
}
|
||||
public interface IHomePre extends IPresenter {
|
||||
|
||||
void getOfficialNotice();
|
||||
void getMyInfo();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
package com.xscm.modulemain.activity.msg.fragment;
|
||||
|
||||
|
||||
import android.content.Intent;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.xscm.modulemain.R;
|
||||
import com.tencent.imsdk.v2.V2TIMConversation;
|
||||
import com.tencent.qcloud.tuicore.TUIConstants;
|
||||
import com.tencent.qcloud.tuikit.tuichat.classicui.page.TUIC2CChatActivity;
|
||||
import com.tencent.qcloud.tuikit.tuiconversation.classicui.page.TUIConversationFragment;
|
||||
import com.xscm.modulemain.activity.msg.OfficialNoticeActivity;
|
||||
import com.xscm.modulemain.activity.msg.contacts.NewsContacts;
|
||||
import com.xscm.modulemain.activity.msg.presenter.NewsPresenter;
|
||||
import com.xscm.modulemain.databinding.FragmentNewsBinding;
|
||||
import com.xscm.moduleutil.adapter.MyFragmentPagerAdapter;
|
||||
import com.xscm.moduleutil.base.BaseMvpFragment;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.bean.NewsDataBean;
|
||||
import com.xscm.moduleutil.bean.UserInfo;
|
||||
import com.xscm.moduleutil.event.UnreadCountEvent;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/5/26
|
||||
*@description: 音域
|
||||
*/
|
||||
public class NewsFragment extends BaseMvpFragment<NewsPresenter, FragmentNewsBinding> implements NewsContacts.View {
|
||||
private Long messageCount;
|
||||
public static NewsFragment newInstance () {
|
||||
return new NewsFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData () {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
MvpPre.getOfficialNotice();
|
||||
MvpPre.getMyInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHiddenChanged(boolean hidden) {
|
||||
super.onHiddenChanged(hidden);
|
||||
if (!hidden){
|
||||
MvpPre.getOfficialNotice();
|
||||
MvpPre.getMyInfo();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView () {
|
||||
|
||||
List<Fragment> fragments = new ArrayList<>();
|
||||
// 添加 tuiconversation 组件提供的经典版会话界面
|
||||
fragments.add(new TUIConversationFragment());
|
||||
|
||||
// 添加 tuicontact 组件提供的经典版联系人界面
|
||||
// fragments.add(new TUIContactFragment());
|
||||
|
||||
// FragmentAdapter fragmentAdapter = new FragmentAdapter(this);
|
||||
// fragmentAdapter.setFragmentList(fragments);
|
||||
// mBinding.viewPager.setOffscreenPageLimit(2);
|
||||
|
||||
mBinding.viewPager.setAdapter(new MyFragmentPagerAdapter(fragments, getChildFragmentManager()));
|
||||
mBinding.viewPager.setCurrentItem(0, false);
|
||||
|
||||
mBinding.ivRoom2.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent=new Intent(getActivity(), TUIC2CChatActivity.class);
|
||||
intent.putExtra(TUIConstants.TUIChat.CHAT_ID, "10010");
|
||||
intent.putExtra(TUIConstants.TUIChat.CHAT_TYPE, V2TIMConversation.V2TIM_C2C);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
mBinding.rlSystem.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent=new Intent(getActivity(), OfficialNoticeActivity.class);
|
||||
intent.putExtra("type", "1");
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
mBinding.rlOfficial.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent=new Intent(getActivity(), OfficialNoticeActivity.class);
|
||||
intent.putExtra("type", "2");
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initListener () {
|
||||
super.initListener();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId () {
|
||||
return R.layout.fragment_news;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NewsPresenter bindPresenter () {
|
||||
return new NewsPresenter(this, getContext());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void getOfficialNoticeList(NewsDataBean newsDataBeans) {
|
||||
if (newsDataBeans.getAnnouncement_last_message()!=null){
|
||||
mBinding.tvNr.setText(newsDataBeans.getAnnouncement_last_message().getContent()!=null?newsDataBeans.getAnnouncement_last_message().getContent():"");
|
||||
}else {
|
||||
mBinding.tvNr.setText("");
|
||||
}
|
||||
if (newsDataBeans.getSystem_last_message()!=null){
|
||||
mBinding.tvXtNr.setText(newsDataBeans.getSystem_last_message().getContent()!=null?newsDataBeans.getSystem_last_message().getContent():"");
|
||||
}else {
|
||||
mBinding.tvXtNr.setText("");
|
||||
}
|
||||
if (newsDataBeans.getSystem_no_read_count()>0) {
|
||||
mBinding.tvXtCount.setText(newsDataBeans.getSystem_no_read_count()+"");
|
||||
}else {
|
||||
mBinding.tvXtCount.setVisibility(View.GONE);
|
||||
}
|
||||
if (newsDataBeans.getAnnouncement_read_count()>0) {
|
||||
mBinding.tvOfficialCount.setText(newsDataBeans.getAnnouncement_read_count()+"");
|
||||
}else {
|
||||
mBinding.tvOfficialCount.setVisibility(View.GONE);
|
||||
}
|
||||
int count = newsDataBeans.getSystem_no_read_count()+newsDataBeans.getAnnouncement_read_count();
|
||||
UnreadCountEvent event = CommonAppContext.getInstance().getUnreadCountEvent();
|
||||
if (event== null){
|
||||
event = new UnreadCountEvent();
|
||||
event.setALong(0);
|
||||
}
|
||||
event.setBLong( (long)count);
|
||||
CommonAppContext.getInstance().setUnreadCountEvent(event);
|
||||
EventBus.getDefault().post(event);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void myInfoSuccess(UserInfo data) {
|
||||
SpUtil.saveUserInfo(data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.xscm.modulemain.activity.msg.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.xscm.modulemain.activity.msg.contacts.NewsContacts;
|
||||
import com.xscm.moduleutil.bean.NewsDataBean;
|
||||
import com.xscm.moduleutil.bean.UserInfo;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class NewsPresenter extends BasePresenter<NewsContacts.View> implements NewsContacts.IHomePre {
|
||||
public NewsPresenter(NewsContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getOfficialNotice() {
|
||||
api.getOfficialNotice( new BaseObserver<NewsDataBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(NewsDataBean newsDataBeans) {
|
||||
MvpRef.get().getOfficialNoticeList(newsDataBeans);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMyInfo() {
|
||||
api.getMyInfo(new BaseObserver<UserInfo>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(UserInfo userInfo) {
|
||||
MvpRef.get().myInfoSuccess(userInfo);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,496 @@
|
||||
package com.xscm.modulemain.activity.plaza.activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import androidx.recyclerview.widget.DiffUtil;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.blankj.utilcode.util.ActivityUtils;
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.databinding.ActivityDynamicDetailBinding;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import com.xscm.modulemain.activity.plaza.contacts.CircleContacts;
|
||||
import com.xscm.modulemain.activity.plaza.presenter.CirclePresenter;
|
||||
import com.xscm.modulemain.BaseMvpActivity;
|
||||
import com.xscm.modulemain.manager.RoomManager;
|
||||
import com.xscm.moduleutil.BaseEvent;
|
||||
import com.xscm.moduleutil.adapter.CirleListAdapter;
|
||||
import com.xscm.moduleutil.adapter.CommentAdapter;
|
||||
import com.xscm.moduleutil.bean.CircleListBean;
|
||||
import com.xscm.moduleutil.bean.CommentBean;
|
||||
import com.xscm.moduleutil.bean.ExpandColumnBean;
|
||||
import com.xscm.moduleutil.bean.HeatedBean;
|
||||
import com.xscm.moduleutil.dialog.ConfirmDialog;
|
||||
import com.xscm.moduleutil.diff.CircleListDiffCallback;
|
||||
import com.xscm.moduleutil.event.GiftRewardEvent;
|
||||
import com.xscm.moduleutil.event.PlazaEvent;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.utils.ChatLauncher;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
import com.xscm.moduleutil.widget.dialog.CommentDialogFragment;
|
||||
import com.xscm.moduleutil.widget.dialog.RewardGiftDialogFragment;
|
||||
import com.xscm.modulemain.dialog.ShareDialog;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
|
||||
/**
|
||||
* @author qx
|
||||
* @data 2025/6/3
|
||||
* @description: 语圈详情
|
||||
*/
|
||||
@Route(path = ARouteConstants.DYNAMIC_DETAIL)
|
||||
public class DynamicDetailActivity extends BaseMvpActivity<CirclePresenter, ActivityDynamicDetailBinding> implements
|
||||
CircleContacts.View, CommentAdapter.OnCommentInteractionListener {
|
||||
private String zone_id;
|
||||
CirleListAdapter cirleListAdapter;
|
||||
private CommentAdapter commentAdapter;
|
||||
private int currentReplyId = 0; // 记录当前正在回复的评论ID
|
||||
private String TreplyTo = "";
|
||||
|
||||
List<CircleListBean> circleList = new ArrayList<>();
|
||||
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
mBinding.topBar.setTitle("动态详情");
|
||||
zone_id = getIntent().getStringExtra("zone_id");
|
||||
|
||||
mBinding.tvSend.setOnClickListener(this::onClick);
|
||||
mBinding.recycleView.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
|
||||
cirleListAdapter = new CirleListAdapter(CirleListAdapter.PAGE_HOME);
|
||||
mBinding.recycleView.setAdapter(cirleListAdapter);
|
||||
cirleListAdapter.setOnItemClickListener(new CirleListAdapter.OnItemClickListener() {
|
||||
@Override
|
||||
public void onDianzanClick(int index, CircleListBean item) {
|
||||
MvpPre.likeZone(index, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHeadImageClick(CircleListBean item) {
|
||||
// Toast.makeText(getApplicationContext(), "查看主页:" + item.getNickname(), Toast.LENGTH_SHORT).show();
|
||||
ARouter.getInstance().build(ARouteConstants.USER_HOME_PAGE).withString("userId", item.getUser_id() + "").navigation();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onZsClick(int position, CircleListBean item) {
|
||||
RewardGiftDialogFragment.show(String.valueOf(item.getId()), item.getUser_id() + "", position, getSupportFragmentManager());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMoreClick(int idx, CircleListBean item) {
|
||||
ShareDialog shareDialog = new ShareDialog(DynamicDetailActivity.this, item.getContent(), item.getShare_url(), item.getId() + "", 3, item.getUser_id() + "", item);
|
||||
shareDialog.setOnShareDataListener(new ShareDialog.OnShareDataListener() {
|
||||
|
||||
@Override
|
||||
public void onShareDataLoaded(String id) {
|
||||
MvpPre.deleteZone(idx, item);
|
||||
}
|
||||
});
|
||||
shareDialog.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPinglunClick(CircleListBean item) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRelaClick(CircleListBean item) {
|
||||
CommentDialogFragment.show(String.valueOf(item.getId()), getSupportFragmentManager());
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
@Override
|
||||
public void onGensui(CircleListBean item) {
|
||||
if (item.getRoom_id() != null && !item.getRoom_id().equals("0")) {
|
||||
RoomManager.getInstance().fetchRoomDataAndEnter(getApplicationContext(), item.getRoom_id(), "", null);
|
||||
|
||||
Observable.timer(1000, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe(aLong -> {
|
||||
for (int i = 0; i < ActivityUtils.getActivityList().size(); i++) {
|
||||
if (ActivityUtils.getActivityList().get(i) instanceof DynamicDetailActivity || ActivityUtils.getActivityList().get(i) instanceof DynamicListActivity) {
|
||||
ActivityUtils.getActivityList().get(i).finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
// ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("form", "首页热门列表").withString("roomId", item.getRoom_id()).navigation();
|
||||
} else {
|
||||
ChatLauncher.getInstance().launchC2CChat(DynamicDetailActivity.this, item.getUser_id() + "");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mBinding.rvComment.setLayoutManager(new LinearLayoutManager(this));
|
||||
commentAdapter = new CommentAdapter(new ArrayList<>());
|
||||
mBinding.rvComment.setAdapter(commentAdapter);
|
||||
commentAdapter.setOnCommentInteractionListener(this);
|
||||
|
||||
|
||||
// 在 initData() 中添加:
|
||||
final View rootView = findViewById(android.R.id.content);
|
||||
final View inputBar = mBinding.clInput;
|
||||
|
||||
ViewCompat.setOnApplyWindowInsetsListener(rootView, (v, insets) -> {
|
||||
int keyboardHeight = insets.getInsets(WindowInsetsCompat.Type.ime()).bottom;
|
||||
|
||||
if (keyboardHeight > 0) {
|
||||
// 键盘弹出时,将输入栏上移
|
||||
inputBar.setTranslationY(-keyboardHeight);
|
||||
|
||||
// 安全地滚动列表(添加空列表检查)
|
||||
if (commentAdapter.getItemCount() > 0) {
|
||||
try {
|
||||
mBinding.rvComment.smoothScrollToPosition(commentAdapter.getItemCount() - 1);
|
||||
} catch (IllegalArgumentException e) {
|
||||
// 防止意外情况
|
||||
mBinding.rvComment.scrollToPosition(commentAdapter.getItemCount() - 1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 键盘收起时复位
|
||||
inputBar.setTranslationY(0);
|
||||
}
|
||||
return insets;
|
||||
});
|
||||
|
||||
|
||||
// 点击输入框自动弹出键盘
|
||||
mBinding.etInput.setOnClickListener(v -> {
|
||||
mBinding.etInput.requestFocus();
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
|
||||
imm.showSoftInput(mBinding.etInput, InputMethodManager.SHOW_IMPLICIT);
|
||||
});
|
||||
MvpPre.topicId(zone_id, 2);
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onEvent(BaseEvent event) {
|
||||
if (event instanceof GiftRewardEvent) {
|
||||
MvpPre.getCircleDetail(((GiftRewardEvent) event).getPoints(),
|
||||
circleList.get(((GiftRewardEvent) event).getPoints()));
|
||||
EventBus.getDefault().post(new PlazaEvent(circleList.get(((GiftRewardEvent) event).getPoints()).id, PlazaEvent.MODIFY_ZONE));
|
||||
}
|
||||
}
|
||||
|
||||
private void onClick(View view) {
|
||||
if (view.getId() == R.id.tv_send) {
|
||||
if (mBinding.etInput.getText().toString().isEmpty()) {
|
||||
ToastUtils.showShort("请输入评论内容");
|
||||
return;
|
||||
}
|
||||
// 判断是回复还是普通评论
|
||||
if (currentReplyId != 0) {
|
||||
// 回复某条评论
|
||||
comZone(zone_id, mBinding.etInput.getText().toString(), String.valueOf(currentReplyId), TreplyTo);
|
||||
} else {
|
||||
// 普通评论
|
||||
comZone(zone_id, mBinding.etInput.getText().toString(), "0", TreplyTo);
|
||||
}
|
||||
// 清空输入框但不清除焦点,保留软键盘
|
||||
mBinding.etInput.setText("");
|
||||
mBinding.etInput.requestFocus(); // 保持焦点
|
||||
}
|
||||
}
|
||||
|
||||
private void comZone(String zoneId, String content, String pid, String replyTo) {
|
||||
MvpPre.commentZone(zoneId, content, pid, replyTo);
|
||||
mBinding.etInput.setText("");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_dynamic_detail;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CirclePresenter bindPresenter() {
|
||||
return new CirclePresenter(this, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCategories(List<HeatedBean> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCircleList(List<CircleListBean> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExpandColumn(List<ExpandColumnBean> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLikeZone(int idx, CircleListBean item, int type) {
|
||||
MvpPre.getCircleDetail(idx, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCircleDetail(int idx, CircleListBean item, CircleListBean newItem) {
|
||||
List<CircleListBean> oldList = new ArrayList<>(cirleListAdapter.getData());
|
||||
circleList.set(idx, newItem);
|
||||
DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(new CircleListDiffCallback(oldList, circleList), false);
|
||||
cirleListAdapter.setNewDiffData(diffResult, circleList);
|
||||
|
||||
EventBus.getDefault().post(new PlazaEvent(circleList.get(idx).id, PlazaEvent.MODIFY_ZONE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteZone(int index) {
|
||||
EventBus.getDefault().post(new PlazaEvent(circleList.get(index).id, PlazaEvent.DELETE_ZONE));
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCircleDetail(CircleListBean bean) {
|
||||
circleList.add(bean);
|
||||
cirleListAdapter.setNewData(circleList);
|
||||
MvpPre.getCommentList(zone_id, "1", "30");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCommentList(CommentBean commentBean) {
|
||||
if (commentBean != null) {
|
||||
mBinding.tvNum.setText("全部评论(" + commentBean.getTotal() + ")");
|
||||
commentAdapter.updateData(commentBean.getList()); // 假设 CommentBean 包含评论列表
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commentZone() {
|
||||
MvpPre.getCommentList(zone_id, "1", "30");
|
||||
MvpPre.getCircleDetail(0, circleList.get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishComment() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onInputBoxShow(int id, String s, int position, String replyTo) {
|
||||
mBinding.etInput.requestFocus();
|
||||
|
||||
// 2. 自动弹出软键盘
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
|
||||
if (imm != null) {
|
||||
imm.showSoftInput(mBinding.etInput, InputMethodManager.SHOW_IMPLICIT);
|
||||
}
|
||||
}, 200);
|
||||
|
||||
// 3. 可选:预填回复内容(如@用户)
|
||||
if (!TextUtils.isEmpty(s)) {
|
||||
mBinding.etInput.setText(s);
|
||||
mBinding.etInput.setSelection(s.length()); // 光标移至末尾
|
||||
}
|
||||
|
||||
// 4. 记录被回复的评论ID(用于后续提交)
|
||||
currentReplyId = id; // 需要在Activity中声明这个字段
|
||||
TreplyTo = replyTo;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetaleClick(int id, int position) {
|
||||
deleteComment1(id, position);
|
||||
// MvpPre.deleteComment(id+"");
|
||||
}
|
||||
|
||||
private void deleteComment1(int commentId, int position) {
|
||||
// 创建并显示确认对话框
|
||||
new ConfirmDialog(this,
|
||||
"提示",
|
||||
"确定要删除此评论吗?",
|
||||
"确认",
|
||||
"取消",
|
||||
v -> {
|
||||
// 点击“确认”按钮时执行删除操作
|
||||
MvpPre.deleteComment(String.valueOf(commentId));
|
||||
// 移除数据(假设 commentAdapter 是你的 RecyclerView 适配器)
|
||||
// commentAdapter.removeItem(position);
|
||||
},
|
||||
v -> {
|
||||
// 点击“取消”按钮时什么都不做
|
||||
}, false, 0).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommentLongClick(CommentBean.CommentDetailsBean comment, CommentBean.CommentDetailsBean.Replies reply, int position) {
|
||||
String[] options;
|
||||
if (comment.getUser_id() == SpUtil.getUserId()) {
|
||||
options = new String[]{"复制", "删除", "回复", "取消"};
|
||||
} else {
|
||||
if (reply != null) {
|
||||
if (reply.getUser_id() == SpUtil.getUserId()) {
|
||||
options = new String[]{"复制", "删除", "回复", "取消"};
|
||||
} else {
|
||||
options = new String[]{"复制", "回复", "取消"};
|
||||
}
|
||||
} else {
|
||||
options = new String[]{"复制", "回复", "取消"};
|
||||
}
|
||||
}
|
||||
|
||||
// new AlertDialog.Builder(this)
|
||||
// .setItems(options, (dialog, which) -> {
|
||||
// switch (which) {
|
||||
// case 0: // 复制
|
||||
// copyComment(comment.getContent());
|
||||
// break;
|
||||
// case 1: // 删除
|
||||
// deleteComment(comment.getId(), position);
|
||||
// break;
|
||||
// case 2: // 回复
|
||||
// onInputBoxShow(comment.getId(), "", position,"");
|
||||
// break;
|
||||
// case 3: // 取消
|
||||
// dialog.dismiss();
|
||||
// break;
|
||||
// }
|
||||
// })
|
||||
// .setCancelable(true)
|
||||
// .create()
|
||||
// .show();
|
||||
|
||||
// 创建底部对话框
|
||||
BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(this);
|
||||
View dialogView = getLayoutInflater().inflate(com.xscm.moduleutil.R.layout.dialog_bottom_sheet_actions, null);
|
||||
|
||||
// 初始化视图
|
||||
LinearLayout container = dialogView.findViewById(com.xscm.moduleutil.R.id.ll_options_container);
|
||||
|
||||
// 动态添加选项
|
||||
for (int i = 0; i < options.length; i++) {
|
||||
TextView textView = new TextView(this);
|
||||
textView.setText(options[i]);
|
||||
textView.setTextSize(16);
|
||||
textView.setPadding(
|
||||
getResources().getDimensionPixelSize(com.xscm.moduleutil.R.dimen.dp_16),
|
||||
getResources().getDimensionPixelSize(com.xscm.moduleutil.R.dimen.dp_14),
|
||||
getResources().getDimensionPixelSize(com.xscm.moduleutil.R.dimen.dp_16),
|
||||
getResources().getDimensionPixelSize(com.xscm.moduleutil.R.dimen.dp_14)
|
||||
);
|
||||
|
||||
// 设置点击效果
|
||||
textView.setBackgroundResource(com.xscm.moduleutil.R.drawable.bg_bottom_sheet_item);
|
||||
final int optionIndex = i;
|
||||
textView.setOnClickListener(v -> {
|
||||
handleOptionClick(optionIndex, comment, reply, position);
|
||||
bottomSheetDialog.dismiss();
|
||||
});
|
||||
|
||||
container.addView(textView);
|
||||
|
||||
// 添加分割线(除了最后一个)
|
||||
if (i < options.length - 1) {
|
||||
View divider = new View(this);
|
||||
divider.setBackgroundColor(ContextCompat.getColor(this, com.xscm.moduleutil.R.color.color_FFEEEEEE));
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
getResources().getDimensionPixelSize(com.xscm.moduleutil.R.dimen.dp_1)
|
||||
);
|
||||
divider.setLayoutParams(params);
|
||||
container.addView(divider);
|
||||
}
|
||||
}
|
||||
|
||||
bottomSheetDialog.setContentView(dialogView);
|
||||
bottomSheetDialog.show();
|
||||
}
|
||||
|
||||
private void handleOptionClick(int optionIndex, CommentBean.CommentDetailsBean comment, CommentBean.CommentDetailsBean.Replies reply, int position) {
|
||||
if (comment.getUser_id() == SpUtil.getUserId() || reply != null) {
|
||||
// 当前用户的评论选项
|
||||
switch (optionIndex) {
|
||||
case 0: // 复制
|
||||
if (reply != null) {
|
||||
copyComment(reply.getContent());
|
||||
} else {
|
||||
copyComment(comment.getContent());
|
||||
}
|
||||
break;
|
||||
case 1: // 删除
|
||||
if (reply != null) {
|
||||
// deleteComment(reply.getId(), position);
|
||||
deleteComment1(reply.getId(), position);
|
||||
} else {
|
||||
// deleteComment(comment.getId(), position);
|
||||
deleteComment1(comment.getId(), position);
|
||||
}
|
||||
break;
|
||||
case 2: // 回复
|
||||
if (reply != null) {
|
||||
onInputBoxShow(reply.getPid(), "", position, reply.getReply_to_user() + "");
|
||||
} else {
|
||||
onInputBoxShow(comment.getId(), "", position, "");
|
||||
}
|
||||
break;
|
||||
// 取消选项不需要处理
|
||||
}
|
||||
} else {
|
||||
// 其他用户的评论选项
|
||||
switch (optionIndex) {
|
||||
case 0: // 复制
|
||||
if (reply != null) {
|
||||
copyComment(reply.getContent());
|
||||
} else {
|
||||
copyComment(comment.getContent());
|
||||
}
|
||||
break;
|
||||
case 1: // 回复
|
||||
if (reply != null) {
|
||||
onInputBoxShow(reply.getPid(), "", position, reply.getReply_to_user() + "");
|
||||
} else {
|
||||
onInputBoxShow(comment.getId(), "", position, "");
|
||||
}
|
||||
break;
|
||||
// 取消选项不需要处理
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 具体操作方法
|
||||
private void copyComment(String content) {
|
||||
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("comment", content);
|
||||
clipboard.setPrimaryClip(clip);
|
||||
Toast.makeText(this, "已复制", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
private void deleteComment(int commentId, int position) {
|
||||
// 调用删除API
|
||||
MvpPre.deleteComment(String.valueOf(commentId));
|
||||
// 临时移除数据
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,267 @@
|
||||
package com.xscm.modulemain.activity.plaza.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.text.SpannableString;
|
||||
import android.text.Spanned;
|
||||
import android.text.style.LeadingMarginSpan;
|
||||
|
||||
import androidx.recyclerview.widget.DiffUtil;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.blankj.utilcode.util.ActivityUtils;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.databinding.ActivityDynamicListBinding;
|
||||
import com.xscm.modulemain.activity.user.activity.UserHomepageActivity;
|
||||
import com.xscm.modulemain.activity.plaza.contacts.CircleContacts;
|
||||
import com.xscm.modulemain.activity.plaza.presenter.CirclePresenter;
|
||||
import com.xscm.modulemain.BaseMvpActivity;
|
||||
import com.xscm.modulemain.manager.RoomManager;
|
||||
import com.xscm.moduleutil.BaseEvent;
|
||||
import com.xscm.moduleutil.adapter.CirleListAdapter;
|
||||
import com.xscm.moduleutil.bean.CircleListBean;
|
||||
import com.xscm.moduleutil.bean.CommentBean;
|
||||
import com.xscm.moduleutil.bean.ExpandColumnBean;
|
||||
import com.xscm.moduleutil.bean.HeatedBean;
|
||||
import com.xscm.moduleutil.diff.CircleListDiffCallback;
|
||||
import com.xscm.moduleutil.event.GiftRewardEvent;
|
||||
import com.xscm.moduleutil.event.PlazaEvent;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.utils.ChatLauncher;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
import com.xscm.moduleutil.widget.dialog.RewardGiftDialogFragment;
|
||||
import com.xscm.modulemain.dialog.ShareDialog;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author qx
|
||||
* @data 2025/6/3
|
||||
* @description: 广场中顶部的热议点击进入的列表展示
|
||||
*/
|
||||
@Route(path = ARouteConstants.CIRCLE_LIST)
|
||||
public class DynamicListActivity extends BaseMvpActivity<CirclePresenter, ActivityDynamicListBinding> implements CircleContacts.View {
|
||||
|
||||
private HeatedBean heatedBean;
|
||||
CirleListAdapter cirleListAdapter;
|
||||
private List<CircleListBean> circleList = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
heatedBean = getIntent().getParcelableExtra("heatedBean");
|
||||
mBinding.topBar.setTitle(heatedBean.getTitle());
|
||||
|
||||
MvpPre.topicId(heatedBean.getTopic_id(), 1);
|
||||
|
||||
|
||||
ImageUtils.loadHeadCC(heatedBean.getPic(), mBinding.ivAvatar);
|
||||
mBinding.tvTitle.setText(heatedBean.getTitle());
|
||||
mBinding.tvDescription.setText(heatedBean.getCount() + "条动态");
|
||||
SpannableString spannableString = new SpannableString(heatedBean.getContent());
|
||||
spannableString.setSpan(new LeadingMarginSpan.Standard(36), 0, heatedBean.getContent().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
mBinding.tvContent.setText(spannableString);
|
||||
|
||||
mBinding.recycleView.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
|
||||
cirleListAdapter = new CirleListAdapter(CirleListAdapter.PAGE_HOME);
|
||||
mBinding.recycleView.setAdapter(cirleListAdapter);
|
||||
cirleListAdapter.setOnItemClickListener(new CirleListAdapter.OnItemClickListener() {
|
||||
@Override
|
||||
public void onDianzanClick(int index, CircleListBean item) {
|
||||
MvpPre.likeZone(index, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHeadImageClick(CircleListBean item) {
|
||||
Intent intent = new Intent(DynamicListActivity.this, UserHomepageActivity.class);
|
||||
intent.putExtra("userId", item.getUser_id() + "");
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onZsClick(int position, CircleListBean item) {
|
||||
RewardGiftDialogFragment.show(String.valueOf(item.getId()), item.getUser_id() + "", position, getSupportFragmentManager());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMoreClick(int idx, CircleListBean item) {
|
||||
ShareDialog shareDialog = new ShareDialog(DynamicListActivity.this, item.getContent(), item.getShare_url(), item.getId() + "", 3, item.getUser_id() + "", item);
|
||||
shareDialog.setOnShareDataListener(new ShareDialog.OnShareDataListener() {
|
||||
|
||||
@Override
|
||||
public void onShareDataLoaded(String id) {
|
||||
MvpPre.deleteZone(idx, item);
|
||||
}
|
||||
});
|
||||
shareDialog.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPinglunClick(CircleListBean item) {
|
||||
Intent intent = new Intent(DynamicListActivity.this, DynamicDetailActivity.class);
|
||||
intent.putExtra("zone_id", item.getId() + "");
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRelaClick(CircleListBean item) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGensui(CircleListBean item) {
|
||||
if (item.getRoom_id() != null && !item.getRoom_id().equals("0")) {
|
||||
RoomManager.getInstance().fetchRoomDataAndEnter(getApplicationContext(), item.getRoom_id(), "", null);
|
||||
} else {
|
||||
ChatLauncher.getInstance().launchC2CChat(DynamicListActivity.this, item.getUser_id() + "");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_dynamic_list;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CirclePresenter bindPresenter() {
|
||||
return new CirclePresenter(this, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCategories(List<HeatedBean> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCircleList(List<CircleListBean> list) {
|
||||
if (list == null || list.isEmpty())
|
||||
return;
|
||||
// if (page == 1){
|
||||
// circleList.clear();
|
||||
// }
|
||||
//
|
||||
// List<CircleListBean> oldList = new ArrayList<>(cirleListAdapter.getData());
|
||||
// circleList.addAll(list);
|
||||
//
|
||||
// DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(new CircleListDiffCallback(oldList, circleList), false);
|
||||
// cirleListAdapter.setNewDiffData(diffResult,circleList);
|
||||
circleList.addAll(list);
|
||||
cirleListAdapter.setNewData(circleList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExpandColumn(List<ExpandColumnBean> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLikeZone(int index, CircleListBean item, int type) {
|
||||
MvpPre.getCircleDetail(index, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCircleDetail(CircleListBean bean) {
|
||||
// 更新列表中的单个数据项(仅更新特定字段)
|
||||
if (cirleListAdapter != null && bean != null) {
|
||||
List<CircleListBean> dataList = cirleListAdapter.getData();
|
||||
if (dataList != null) {
|
||||
// 查找并更新对应的项
|
||||
for (int i = 0; i < dataList.size(); i++) {
|
||||
CircleListBean item = dataList.get(i);
|
||||
// 根据ID匹配需要更新的项
|
||||
if (item.getId() == bean.getId()) {
|
||||
// 只更新特定字段
|
||||
item.setRewards_num(bean.getRewards_num());
|
||||
// 可以继续更新其他需要的字段
|
||||
// 局部刷新该位置的数据
|
||||
cirleListAdapter.notifyItemChanged(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onEvent(BaseEvent event) {
|
||||
if (event instanceof GiftRewardEvent) {
|
||||
MvpPre.getCircleDetail(((GiftRewardEvent) event).getPoints(),
|
||||
circleList.get(((GiftRewardEvent) event).getPoints()));
|
||||
if (ActivityUtils.getTopActivity() instanceof DynamicListActivity){
|
||||
EventBus.getDefault().post(new PlazaEvent(circleList.get(((GiftRewardEvent) event).getPoints()).id, PlazaEvent.MODIFY_ZONE));
|
||||
}
|
||||
} else if (event instanceof PlazaEvent) {
|
||||
CircleListBean item = null;
|
||||
int index = 0;
|
||||
for (int i = 0; i < circleList.size(); i++) {
|
||||
if (circleList.get(i).getId() == ((PlazaEvent) event).getMsgId()) {
|
||||
item = circleList.get(i);
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (item == null || ActivityUtils.getTopActivity() instanceof DynamicListActivity)
|
||||
return;
|
||||
|
||||
switch (((PlazaEvent) event).getType()) {
|
||||
case PlazaEvent.MODIFY_ZONE:
|
||||
MvpPre.getCircleDetail(index, item);
|
||||
break;
|
||||
case PlazaEvent.DELETE_ZONE:
|
||||
circleList.remove(index);
|
||||
cirleListAdapter.notifyItemRemoved(index);
|
||||
if (index != 0) {
|
||||
cirleListAdapter.notifyItemRangeChanged(index, circleList.size() - index); // 修正后续索引
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCommentList(CommentBean commentBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commentZone() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishComment() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCircleDetail(int index, CircleListBean item, CircleListBean newItem) {
|
||||
if (ActivityUtils.getTopActivity() instanceof DynamicListActivity){
|
||||
EventBus.getDefault().post(new PlazaEvent(circleList.get(index).id, PlazaEvent.MODIFY_ZONE));
|
||||
}
|
||||
|
||||
List<CircleListBean> oldList = new ArrayList<>(cirleListAdapter.getData());
|
||||
circleList.set(index, newItem);
|
||||
DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(new CircleListDiffCallback(oldList, circleList), false);
|
||||
cirleListAdapter.setNewDiffData(diffResult, circleList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteZone(int index) {
|
||||
if (ActivityUtils.getTopActivity() instanceof DynamicListActivity){
|
||||
EventBus.getDefault().post(new PlazaEvent(circleList.get(index).id, PlazaEvent.DELETE_ZONE));
|
||||
}
|
||||
circleList.remove(index);
|
||||
cirleListAdapter.notifyItemRemoved(index);
|
||||
if (index != 0) {
|
||||
cirleListAdapter.notifyItemRangeChanged(index, circleList.size() - index); // 修正后续索引
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,364 @@
|
||||
package com.xscm.modulemain.activity.plaza.activity;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.adapter.MultiSelectAdapter;
|
||||
import com.xscm.modulemain.databinding.ActivityReleaseBinding;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import com.luck.picture.lib.basic.PictureSelector;
|
||||
import com.luck.picture.lib.config.PictureConfig;
|
||||
import com.luck.picture.lib.entity.LocalMedia;
|
||||
import com.xscm.modulemain.activity.plaza.contacts.ReleaseContract;
|
||||
import com.xscm.modulemain.activity.plaza.presenter.ReleasePresenter;
|
||||
import com.xscm.modulemain.BaseMvpActivity;
|
||||
import com.xscm.moduleutil.adapter.UserPhotoWallAdapter;
|
||||
import com.xscm.moduleutil.bean.HeatedBean;
|
||||
import com.xscm.moduleutil.color.ThemeableDrawableUtils;
|
||||
import com.xscm.moduleutil.utils.ColorManager;
|
||||
import com.xscm.moduleutil.utils.GlideEngine;
|
||||
import com.xscm.moduleutil.utils.PermissionDescriptionHelper;
|
||||
import com.xscm.moduleutil.utils.location.LocationProvider;
|
||||
import com.xscm.moduleutil.utils.location.LocationServiceFactory;
|
||||
import com.xscm.moduleutil.widget.Constants;
|
||||
import com.xscm.moduleutil.widget.img.FullScreenUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author qx
|
||||
* @data 2025/5/28
|
||||
* @description: 发布动态
|
||||
*/
|
||||
public class ReleaseActivity extends BaseMvpActivity<ReleasePresenter, ActivityReleaseBinding> implements ReleaseContract.View {
|
||||
UserPhotoWallAdapter mUserPhotoWallAdapter;
|
||||
List<String> list=new ArrayList<>();
|
||||
private List<String> uploadedUrls = new ArrayList<>();//真实图片地址
|
||||
final int maxNum = 1200;
|
||||
private List<String> topicId=new ArrayList<>();
|
||||
private String city1;
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
mBinding.topBar.setTitle("动态发布");
|
||||
|
||||
mBinding.tvSz.setText("0/" + maxNum);
|
||||
mBinding.etG.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
if (s.length() == maxNum) {
|
||||
mBinding.tvSz.setText("您输入的字数已超过限制");
|
||||
} else {
|
||||
mBinding.tvSz.setText((maxNum - s.length()) + "/" + maxNum);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mBinding.rvPhotoWall.setLayoutManager(new GridLayoutManager(this, 3));
|
||||
mBinding.rvPhotoWall.setAdapter(mUserPhotoWallAdapter = new UserPhotoWallAdapter());
|
||||
mUserPhotoWallAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
|
||||
@Override
|
||||
public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
|
||||
String item = list.get(position);
|
||||
int id = view.getId();
|
||||
if (id == R.id.iv_close) {
|
||||
uploadedUrls.remove(item);
|
||||
updateAdapterData();
|
||||
} else {
|
||||
if (item.equals(UserPhotoWallAdapter.ADD_PHOTO)) {
|
||||
int maxSelectable = 9 - uploadedUrls.size();
|
||||
if (maxSelectable > 0) {
|
||||
// 点击的是"+"'号,启动图片选择
|
||||
startChoosePhoto(1, PictureConfig.CHOOSE_REQUEST, false, maxSelectable);
|
||||
} else {
|
||||
ToastUtils.showShort("最多只能选择9张图片");
|
||||
}
|
||||
// 点击的是“+”号,启动图片选择
|
||||
// startChoosePhoto(1, PictureConfig.CHOOSE_REQUEST, false, 9);
|
||||
} else {
|
||||
// 查看大图或其他操作
|
||||
// 查看大图或其他操作
|
||||
FullScreenUtil.showFullScreenDialog(ReleaseActivity.this, position, list);
|
||||
}
|
||||
}
|
||||
|
||||
// int id = view.getId();
|
||||
// UserImgList item = mUserPhotoWallAdapter.getItem(position);
|
||||
// if (id == com.qxcm.moduleutil.R.id.iv_close) {
|
||||
//// MvpPre.deletePhoto(item.getId(), position);
|
||||
// } else {
|
||||
// if ("0".equals(item.getId())) {
|
||||
// startChoosePhoto(PictureMimeType.ofImage(), PictureConfig.REQUEST_CAMERA, true, 9);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
});
|
||||
mUserPhotoWallAdapter.setOnItemChildLongClickListener(new BaseQuickAdapter.OnItemChildLongClickListener() {
|
||||
@Override
|
||||
public boolean onItemChildLongClick(BaseQuickAdapter adapter, View view, int position) {
|
||||
mUserPhotoWallAdapter.setLongClickPos(position);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
updateAdapterData(); // 初始化时更新适配器数据
|
||||
list = new ArrayList<>();
|
||||
list.add("ADD_PHOTO"); // 最后一项是“添加图片”
|
||||
mUserPhotoWallAdapter.setNewData(list);
|
||||
mUserPhotoWallAdapter.setDelete(true);
|
||||
|
||||
mBinding.rl1.setOnClickListener(this::onClick);
|
||||
mBinding.tvFb.setOnClickListener(this::onClick);
|
||||
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
PermissionDescriptionHelper.addPermissionDescription(false, (ViewGroup) mBinding.getRoot(), new String[]{Manifest.permission.ACCESS_FINE_LOCATION});
|
||||
// 请求定位权限
|
||||
ActivityCompat.requestPermissions(
|
||||
(Activity) this,
|
||||
new String[]{
|
||||
Manifest.permission.ACCESS_FINE_LOCATION,
|
||||
Manifest.permission.ACCESS_COARSE_LOCATION
|
||||
},
|
||||
1001 // 自定义常量,比如 1001
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
LocationProvider provider = LocationServiceFactory.createBestProvider(this);
|
||||
provider.getLastKnownLocation(this, new LocationProvider.LocationCallback() {
|
||||
@Override
|
||||
public void onLocationReceived(double latitude, double longitude, String city) {
|
||||
city1=city;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(String errorMessage) {
|
||||
Toast.makeText(ReleaseActivity.this, "定位失败:" + errorMessage, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
ThemeableDrawableUtils.setThemeableRoundedBackground(mBinding.tvFb, ColorManager.getInstance().getPrimaryColorInt(), 53);
|
||||
mBinding.tvFb.setTextColor(ColorManager.getInstance().getButtonColorInt());
|
||||
}
|
||||
//更新适配器数据的方法
|
||||
private void updateAdapterData() {
|
||||
list.clear();
|
||||
list.addAll(uploadedUrls); // 添加真实图片
|
||||
list.add(UserPhotoWallAdapter.ADD_PHOTO); // 最后加上 ADD_PHOTO
|
||||
mUserPhotoWallAdapter.setNewData(list);
|
||||
}
|
||||
private void onClick(View view) {
|
||||
if (view.getId() == R.id.rl_1) {
|
||||
dialog();
|
||||
}else if (view.getId()==R.id.tv_fb){
|
||||
if (mBinding.tvFb.getText().toString().equals("正在发布...")){
|
||||
ToastUtils.showShort("请勿重复发布");
|
||||
return;
|
||||
}
|
||||
if (mBinding.etG.getText().toString().isEmpty()){
|
||||
ToastUtils.showShort("请输入发布内容");
|
||||
return;
|
||||
}
|
||||
mBinding.tvFb.setText( "正在发布...");
|
||||
MvpPre.publishZone(TextUtils.join(",", uploadedUrls),mBinding.etG.getText().toString(),TextUtils.join(",", topicId),"",city1);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void dialog() {
|
||||
MvpPre.topicList("1","30");
|
||||
}
|
||||
|
||||
private void startChoosePhoto(int mimeType, int requestCode, boolean isVideo, int type) {
|
||||
|
||||
PictureSelector.create(this)
|
||||
.openGallery(mimeType)
|
||||
.isGif(isVideo)
|
||||
.setImageEngine(GlideEngine.createGlideEngine())
|
||||
.setPermissionDescriptionListener(PermissionDescriptionHelper.createListener())
|
||||
.setMaxSelectNum(type)
|
||||
.isPreviewImage(true)
|
||||
.isDisplayCamera(false)
|
||||
.setOutputCameraDir(Constants.FILE_PATH)
|
||||
.isOriginalSkipCompress(true)
|
||||
|
||||
.forResult(requestCode); //结果回调onActivityResult code
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (resultCode == RESULT_OK && data != null) {
|
||||
switch (requestCode) {
|
||||
case PictureConfig.CHOOSE_REQUEST:
|
||||
List<LocalMedia> localMediaList = PictureSelector.obtainSelectorList(data);
|
||||
|
||||
if (localMediaList != null && !localMediaList.isEmpty()) {
|
||||
List<File> imageFiles = new ArrayList<>();
|
||||
for (LocalMedia media : localMediaList) {
|
||||
String path = media.isCompressed() ? media.getCompressPath() : media.getRealPath();
|
||||
imageFiles.add(new File(path));
|
||||
}
|
||||
size = uploadedUrls.size();
|
||||
// 开始批量上传
|
||||
MvpPre.batchUploadFiles(imageFiles, 0); // 第二个参数是你原来的 type
|
||||
|
||||
}
|
||||
// if (localMedia != null && localMedia.size() != 0) {
|
||||
// LocalMedia imgMedia = localMedia.get(0);
|
||||
// String url;
|
||||
// if (imgMedia.isCompressed()) {
|
||||
// url = imgMedia.getCompressPath();
|
||||
// } else {
|
||||
// url = imgMedia.getRealPath();
|
||||
// }
|
||||
// MvpPre.uploadFile(new File(url), 0);
|
||||
// }
|
||||
break;
|
||||
case PictureConfig.REQUEST_CAMERA:
|
||||
List<LocalMedia> localMedia1 = PictureSelector.obtainSelectorList(data);
|
||||
if (localMedia1 != null && localMedia1.size() != 0) {
|
||||
LocalMedia imgMedia = localMedia1.get(0);
|
||||
// MvpPre.uploadFile(new File(imgMedia.getRealPath()), 3);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_release;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReleasePresenter bindPresenter() {
|
||||
return new ReleasePresenter(this, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void topicList(List<HeatedBean> list) {
|
||||
// 示例数据
|
||||
// List<String> topics = Arrays.asList("话题1", "话题2", "话题3", "话题4");
|
||||
|
||||
List<String> topics = new ArrayList<>();
|
||||
for (HeatedBean bean : list) {
|
||||
topics.add(bean.getTitle());
|
||||
}
|
||||
|
||||
|
||||
BottomSheetDialog dialog = new BottomSheetDialog(this);
|
||||
dialog.setContentView(R.layout.bottom_sheet_recyclerview);
|
||||
View bottomSheet = dialog.findViewById(com.google.android.material.R.id.design_bottom_sheet);
|
||||
if (bottomSheet != null) {
|
||||
bottomSheet.setBackgroundResource(android.R.color.transparent); // 设置为透明
|
||||
}
|
||||
RecyclerView recyclerView = dialog.findViewById(R.id.rv_options);
|
||||
TextView btnCancel = dialog.findViewById(R.id.btn_cancel);
|
||||
TextView btnConfirm = dialog.findViewById(R.id.btn_confirm);
|
||||
btnConfirm.setTextColor(ColorManager.getInstance().getPrimaryColorInt());
|
||||
|
||||
assert recyclerView != null;
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
MultiSelectAdapter adapter = new MultiSelectAdapter(list);
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
btnCancel.setOnClickListener(v -> dialog.dismiss());
|
||||
|
||||
btnConfirm.setOnClickListener(v -> {
|
||||
topicId=new ArrayList<>();
|
||||
List<HeatedBean> selectedTopics = adapter.getSelectedItems();
|
||||
// 返回结果给调用页面(可使用接口或 onActivityResult 等方式)
|
||||
Log.d("Selected Topics", selectedTopics.toString());
|
||||
List<String> selectedTopicIds = new ArrayList<>();
|
||||
for (HeatedBean topic : selectedTopics) {
|
||||
selectedTopicIds.add(topic.getTitle());
|
||||
}
|
||||
|
||||
for (HeatedBean topic : selectedTopics){
|
||||
topicId.add(topic.getTopic_id());
|
||||
}
|
||||
// 示例:更新 UI
|
||||
((TextView)findViewById(R.id.tv_ht)).setText("已选:" + TextUtils.join(",", selectedTopicIds));
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
dialog.show();
|
||||
}
|
||||
int size=0;
|
||||
@Override
|
||||
public void upLoadSuccess(String url, int type, int index, int total) {
|
||||
if (index >= 0 && index < uploadedUrls.size()) {
|
||||
uploadedUrls.add(index, url); // 插入到对应位置
|
||||
} else {
|
||||
uploadedUrls.add(url); // 添加到最后
|
||||
}
|
||||
|
||||
if (uploadedUrls.size() == total+size) {
|
||||
updateAdapterData(); // 所有图片上传完成,更新适配器数据
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publishSuccess() {
|
||||
mBinding.etG.setText( "立即发布");
|
||||
ToastUtils.showShort("发布成功");
|
||||
setResult(RESULT_OK);
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
PermissionDescriptionHelper.removePermissionDescription((ViewGroup) mBinding.getRoot());
|
||||
if (requestCode == 1001) {
|
||||
LocationProvider provider = LocationServiceFactory.createBestProvider(this);
|
||||
provider.getLastKnownLocation(this, new LocationProvider.LocationCallback() {
|
||||
@Override
|
||||
public void onLocationReceived(double latitude, double longitude, String city) {
|
||||
Toast.makeText(ReleaseActivity.this, "当前位置:" + city, Toast.LENGTH_SHORT).show();
|
||||
city1=city;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(String errorMessage) {
|
||||
Toast.makeText(ReleaseActivity.this, "定位失败:", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.xscm.modulemain.activity.plaza.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.CircleListBean;
|
||||
import com.xscm.moduleutil.bean.CommentBean;
|
||||
import com.xscm.moduleutil.bean.ExpandColumnBean;
|
||||
import com.xscm.moduleutil.bean.HeatedBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CircleContacts {
|
||||
|
||||
public interface View extends IView<Activity> {
|
||||
|
||||
|
||||
void setCategories(List<HeatedBean> list);
|
||||
|
||||
void getCircleList(List<CircleListBean> list);
|
||||
|
||||
void setExpandColumn(List<ExpandColumnBean> list);
|
||||
|
||||
void setLikeZone(int index,CircleListBean item,int type);
|
||||
|
||||
void setCircleDetail(CircleListBean bean);
|
||||
|
||||
void getCommentList(CommentBean commentBean);
|
||||
void commentZone();
|
||||
void finishComment();
|
||||
|
||||
void getCircleDetail(int index,CircleListBean item,CircleListBean newItem);
|
||||
|
||||
void deleteZone(int index);
|
||||
}
|
||||
|
||||
public interface IIndexPre extends IPresenter {
|
||||
void getCategories();
|
||||
|
||||
void getCircleList(String page,String page_limit);
|
||||
|
||||
void getExpandColumn(String type,String page,String page_limit);//获取扩列数据
|
||||
|
||||
void likeZone(int index,CircleListBean item);
|
||||
|
||||
void getCircleDetail(int index,CircleListBean item);
|
||||
|
||||
void topicId(String topic_id,int type);//type:这是让区分是什么地方获得数据,type=1:动态列表,type=2:动态详情
|
||||
|
||||
void deleteZone(int index,CircleListBean item);
|
||||
|
||||
void getCommentList(String id,String page,String page_limit);
|
||||
void commentZone(String id,String content,String pid,String reply_to);
|
||||
|
||||
void deleteComment(String id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.xscm.modulemain.activity.plaza.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.HeatedBean;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public class ReleaseContract {
|
||||
public interface View extends IView<Activity> {
|
||||
void topicList(List<HeatedBean> list);
|
||||
void upLoadSuccess(String url, int type, int index, int total);
|
||||
|
||||
void publishSuccess();
|
||||
}
|
||||
|
||||
public interface IIndexPre extends IPresenter {
|
||||
void topicList(String page, String page_limit);
|
||||
|
||||
void uploadFile(File file, int type,int index,int sice);
|
||||
|
||||
void publishZone(String images,String content,String topic_id,String room_id,String ip);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,353 @@
|
||||
package com.xscm.modulemain.activity.plaza.fragment;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.DiffUtil;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.activity.main.activity.MainActivity;
|
||||
import com.xscm.modulemain.activity.plaza.activity.DynamicListActivity;
|
||||
import com.xscm.modulemain.activity.plaza.contacts.CircleContacts;
|
||||
import com.xscm.modulemain.activity.plaza.presenter.CirclePresenter;
|
||||
import com.xscm.modulemain.adapter.CirleCategoryBannerAdapter;
|
||||
import com.xscm.modulemain.databinding.FragmentCircleCategoryBinding;
|
||||
import com.xscm.modulemain.dialog.ShareDialog;
|
||||
import com.xscm.modulemain.manager.RoomManager;
|
||||
import com.xscm.moduleutil.BaseEvent;
|
||||
import com.xscm.moduleutil.adapter.CirleListAdapter;
|
||||
import com.xscm.moduleutil.base.BaseMvpFragment;
|
||||
import com.xscm.moduleutil.bean.BaseListData;
|
||||
import com.xscm.moduleutil.bean.CircleListBean;
|
||||
import com.xscm.moduleutil.bean.CommentBean;
|
||||
import com.xscm.moduleutil.bean.ExpandColumnBean;
|
||||
import com.xscm.moduleutil.bean.HeatedBean;
|
||||
import com.xscm.moduleutil.diff.CircleListDiffCallback;
|
||||
import com.xscm.moduleutil.event.GiftRewardEvent;
|
||||
import com.xscm.moduleutil.event.PlazaEvent;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.utils.ChatLauncher;
|
||||
import com.xscm.moduleutil.widget.dialog.RewardGiftDialogFragment;
|
||||
import com.zhpan.bannerview.indicator.DrawableIndicator;
|
||||
import com.zhpan.indicator.base.IIndicator;
|
||||
import com.zhpan.indicator.enums.IndicatorSlideMode;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 语圈中的发现界面
|
||||
*/
|
||||
public class CircleCategoryFragment extends BaseMvpFragment<CirclePresenter, FragmentCircleCategoryBinding> implements CircleContacts.View {
|
||||
CirleCategoryBannerAdapter cirleCategoryBannerAdapter;
|
||||
CirleListAdapter cirleListAdapter;
|
||||
private int page = 1;
|
||||
private String pageLimit = "10";
|
||||
|
||||
private List<CircleListBean> circleList = new ArrayList<>();
|
||||
|
||||
public static CircleCategoryFragment newInstance() {
|
||||
return new CircleCategoryFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
page = 1;
|
||||
MvpPre.getCategories();
|
||||
MvpPre.getCircleList("1", pageLimit);
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("WrongConstant")
|
||||
@Override
|
||||
protected void initView() {
|
||||
cirleCategoryBannerAdapter = new CirleCategoryBannerAdapter();
|
||||
mBinding.bannerViewPager
|
||||
.setPageMargin(1)
|
||||
.setScrollDuration(0)
|
||||
.setRevealWidth(0, 0)
|
||||
.setIndicatorVisibility(View.VISIBLE)
|
||||
.setIndicatorView(getVectorDrawableIndicator())
|
||||
.setIndicatorSlideMode(IndicatorSlideMode.NORMAL)
|
||||
.setAdapter(cirleCategoryBannerAdapter)
|
||||
.setAutoPlay(false);
|
||||
|
||||
mBinding.constraintLayout.setVisibility(View.GONE);
|
||||
cirleCategoryBannerAdapter.setOnItemClickListener((view, data, position) -> {
|
||||
// 示例:跳转到房间详情页
|
||||
if (data != null) {
|
||||
Intent intent = new Intent(getActivity(), DynamicListActivity.class);
|
||||
intent.putExtra("heatedBean", data);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mBinding.recycleView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
|
||||
cirleListAdapter = new CirleListAdapter(CirleListAdapter.PAGE_HOME);
|
||||
mBinding.recycleView.setAdapter(cirleListAdapter);
|
||||
cirleListAdapter.setOnItemClickListener(new CirleListAdapter.OnItemClickListener() {
|
||||
@Override
|
||||
public void onDianzanClick(int position, CircleListBean item) {
|
||||
MvpPre.likeZone(position, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHeadImageClick(CircleListBean item) {
|
||||
ARouter.getInstance().build(ARouteConstants.USER_HOME_PAGE).withString("userId", item.getUser_id() + "").navigation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onZsClick(int position, CircleListBean item) {//打赏
|
||||
RewardGiftDialogFragment.show(String.valueOf(item.getId()), item.getUser_id() + "", position, getChildFragmentManager());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMoreClick(int idx, CircleListBean item) {//点击点点,分享等
|
||||
ShareDialog shareDialog = new ShareDialog(getContext(), item.getContent(), item.getShare_url(), item.getId() + "", 3, item.getUser_id() + "", item);
|
||||
shareDialog.setOnShareDataListener(new ShareDialog.OnShareDataListener() {
|
||||
|
||||
@Override
|
||||
public void onShareDataLoaded(String id) {
|
||||
MvpPre.deleteZone(idx, item);
|
||||
}
|
||||
});
|
||||
shareDialog.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPinglunClick(CircleListBean item) {
|
||||
ARouter.getInstance().build(ARouteConstants.DYNAMIC_DETAIL).withString("zone_id", item.getId() + "").navigation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRelaClick(CircleListBean item) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGensui(CircleListBean item) {
|
||||
if (item.getRoom_id() != null && !item.getRoom_id().equals("0")) {
|
||||
if (getActivity() instanceof MainActivity) {
|
||||
((MainActivity) getActivity()).isShowLoading(true);
|
||||
}
|
||||
RoomManager.getInstance().fetchRoomDataAndEnter(getActivity(), item.getRoom_id(), "", null);
|
||||
} else {
|
||||
ChatLauncher.getInstance().launchC2CChat(getActivity(), item.getUser_id() + "");
|
||||
}
|
||||
}
|
||||
});
|
||||
mBinding.smartRefreshLayout.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
|
||||
@Override
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
page++;
|
||||
MvpPre.getCircleList(page + "", pageLimit);
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
@Override
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
page = 1;
|
||||
circleList.clear();
|
||||
cirleListAdapter.notifyDataSetChanged();
|
||||
MvpPre.getCircleList(page + "", pageLimit);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onEvent(BaseEvent event) {
|
||||
if (event instanceof GiftRewardEvent) {
|
||||
MvpPre.getCircleDetail(((GiftRewardEvent) event).getPoints(),
|
||||
circleList.get(((GiftRewardEvent) event).getPoints()));
|
||||
} else if (event instanceof PlazaEvent) {
|
||||
CircleListBean item = null;
|
||||
int index = 0;
|
||||
for (int i = 0; i < circleList.size(); i++) {
|
||||
if (circleList.get(i).getId() == ((PlazaEvent) event).getMsgId()) {
|
||||
item = circleList.get(i);
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (item == null)
|
||||
return;
|
||||
switch (((PlazaEvent) event).getType()) {
|
||||
case PlazaEvent.MODIFY_ZONE:
|
||||
MvpPre.getCircleDetail(index, item);
|
||||
break;
|
||||
case PlazaEvent.DELETE_ZONE:
|
||||
if (circleList.size() == 1) {
|
||||
circleList.clear();
|
||||
cirleListAdapter.notifyDataSetChanged();
|
||||
} else {
|
||||
circleList.remove(index);
|
||||
cirleListAdapter.notifyItemRemoved(index);
|
||||
cirleListAdapter.notifyItemRangeChanged(index, circleList.size() - index); // 修正后续索引
|
||||
}
|
||||
MvpPre.getCategories();
|
||||
break;
|
||||
case PlazaEvent.ADD_ZONE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IIndicator getVectorDrawableIndicator() {
|
||||
int dp6 = getResources().getDimensionPixelOffset(com.xscm.moduleutil.R.dimen.dp_6);
|
||||
return new DrawableIndicator(getContext())
|
||||
.setIndicatorGap(getResources().getDimensionPixelOffset(com.xscm.moduleutil.R.dimen.dp_2_5))
|
||||
.setIndicatorDrawable(com.xscm.moduleutil.R.drawable.banner_indicator_nornal, com.xscm.moduleutil.R.drawable.banner_indicator_focus)
|
||||
.setIndicatorSize(getResources().getDimensionPixelOffset(com.xscm.moduleutil.R.dimen.dp_13), dp6, getResources().getDimensionPixelOffset(com.xscm.moduleutil.R.dimen.dp_13), dp6);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initListener() {
|
||||
super.initListener();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fragment_circle_category;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CirclePresenter bindPresenter() {
|
||||
return new CirclePresenter(this, getContext());
|
||||
}
|
||||
|
||||
|
||||
public void newAddRefresh() {
|
||||
page = 1;
|
||||
circleList.clear();
|
||||
MvpPre.getCircleList(page + "", pageLimit);
|
||||
MvpPre.getCategories();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCategories(List<HeatedBean> list) {
|
||||
// 将原始数据拆分为多个子列表,每个子列表最多包含4个元素
|
||||
mBinding.constraintLayout.setVisibility(View.VISIBLE);
|
||||
// 添加到 bannerViewPager 的是分页后的列表
|
||||
mBinding.bannerViewPager.create(baseListData(list, 4));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCircleList(List<CircleListBean> list) {
|
||||
if (list == null || list.isEmpty())
|
||||
return;
|
||||
if (page == 1) {
|
||||
circleList.addAll(list);
|
||||
cirleListAdapter.setNewData(circleList);
|
||||
} else {
|
||||
List<CircleListBean> oldList = new ArrayList<>(cirleListAdapter.getData());
|
||||
circleList.addAll(list);
|
||||
|
||||
DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(new CircleListDiffCallback(oldList, circleList), false);
|
||||
cirleListAdapter.setNewDiffData(diffResult, circleList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExpandColumn(List<ExpandColumnBean> list) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLikeZone(int index, CircleListBean item, int type) {
|
||||
MvpPre.getCircleDetail(index, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCircleDetail(int index, CircleListBean item, CircleListBean newItem) {
|
||||
List<CircleListBean> oldList = new ArrayList<>(cirleListAdapter.getData());
|
||||
circleList.set(index, newItem);
|
||||
DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(new CircleListDiffCallback(oldList, circleList), false);
|
||||
cirleListAdapter.setNewDiffData(diffResult, circleList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCircleDetail(CircleListBean bean) {
|
||||
// 更新列表中的单个数据项(仅更新特定字段)
|
||||
if (cirleListAdapter != null && bean != null) {
|
||||
List<CircleListBean> dataList = cirleListAdapter.getData();
|
||||
if (dataList != null) {
|
||||
// 查找并更新对应的项
|
||||
for (int i = 0; i < dataList.size(); i++) {
|
||||
CircleListBean item = dataList.get(i);
|
||||
// 根据ID匹配需要更新的项
|
||||
if (item.getId() == bean.getId()) {
|
||||
// 只更新特定字段
|
||||
item.setRewards_num(bean.getRewards_num());
|
||||
// 可以继续更新其他需要的字段
|
||||
// 局部刷新该位置的数据
|
||||
cirleListAdapter.notifyItemChanged(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
@Override
|
||||
public void deleteZone(int index) {
|
||||
if (circleList.size() == 1) {
|
||||
circleList.clear();
|
||||
cirleListAdapter.notifyDataSetChanged();
|
||||
} else {
|
||||
circleList.remove(index);
|
||||
cirleListAdapter.notifyItemRemoved(index);
|
||||
cirleListAdapter.notifyItemRangeChanged(index, circleList.size() - index); // 修正后续索引
|
||||
}
|
||||
|
||||
MvpPre.getCategories();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCommentList(CommentBean commentBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commentZone() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishComment() {
|
||||
mBinding.smartRefreshLayout.finishRefresh();
|
||||
mBinding.smartRefreshLayout.finishLoadMore();
|
||||
}
|
||||
|
||||
// 拆分函数
|
||||
private <T> List<List<T>> splitListIntoChunks(List<T> list, int chunkSize) {
|
||||
List<List<T>> chunks = new ArrayList<>();
|
||||
for (int i = 0; i < list.size(); i += chunkSize) {
|
||||
chunks.add(list.subList(i, Math.min(i + chunkSize, list.size())));
|
||||
}
|
||||
return chunks;
|
||||
}
|
||||
|
||||
private List<BaseListData<HeatedBean>> baseListData(List<HeatedBean> list, int chunkSize) {
|
||||
List<BaseListData<HeatedBean>> baseListData = new ArrayList<>();
|
||||
for (int i = 0; i < list.size(); i += chunkSize) {
|
||||
BaseListData<HeatedBean> baseListData1 = new BaseListData<>();
|
||||
baseListData1.setData(list.subList(i, Math.min(i + chunkSize, list.size())));
|
||||
baseListData.add(baseListData1);
|
||||
}
|
||||
return baseListData;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
package com.xscm.modulemain.activity.plaza.fragment;
|
||||
|
||||
|
||||
import android.content.Intent;
|
||||
import android.util.SparseArray;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentStatePagerAdapter;
|
||||
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.activity.plaza.activity.ReleaseActivity;
|
||||
import com.xscm.modulemain.activity.plaza.contacts.CircleContacts;
|
||||
import com.xscm.modulemain.activity.plaza.presenter.CirclePresenter;
|
||||
import com.xscm.modulemain.databinding.FragmentCircleBinding;
|
||||
import com.xscm.moduleutil.base.BaseMvpFragment;
|
||||
import com.xscm.moduleutil.bean.CircleListBean;
|
||||
import com.xscm.moduleutil.bean.CommentBean;
|
||||
import com.xscm.moduleutil.bean.ExpandColumnBean;
|
||||
import com.xscm.moduleutil.bean.HeatedBean;
|
||||
import com.xscm.moduleutil.bean.MyBagBean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
*语圈
|
||||
*/
|
||||
public class CircleFragment extends BaseMvpFragment<CirclePresenter, FragmentCircleBinding> implements CircleContacts.View {
|
||||
private List<MyBagBean> list;
|
||||
|
||||
public static final int RELEASE_CODE = 1010;
|
||||
private MyFragmentPagerAdapter adapter;
|
||||
|
||||
public static CircleFragment newInstance () {
|
||||
return new CircleFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData () {
|
||||
list=new ArrayList<>();
|
||||
list.add(new MyBagBean("发现", "1"));
|
||||
list.add(new MyBagBean("扩列", "2"));
|
||||
adapter = new MyFragmentPagerAdapter(getChildFragmentManager(), list);
|
||||
mBinding.viewPager.setAdapter(adapter);
|
||||
mBinding.tabLayout.setViewPager(mBinding.viewPager);
|
||||
mBinding.tabLayout.setCurrentTab(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView () {
|
||||
mBinding.ivRelease.setOnClickListener(this::onClick);
|
||||
}
|
||||
|
||||
private void onClick(View view) {
|
||||
if (view.getId()==R.id.iv_release){//发布
|
||||
startActivityForResult(new Intent(getContext(), ReleaseActivity.class),RELEASE_CODE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode==RELEASE_CODE){
|
||||
adapter.refreshCircleCategoryData();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initListener () {
|
||||
super.initListener();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId () {
|
||||
return R.layout.fragment_circle;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CirclePresenter bindPresenter () {
|
||||
return new CirclePresenter(this, getContext());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setCategories(List<HeatedBean> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCircleList(List<CircleListBean> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExpandColumn(List<ExpandColumnBean> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLikeZone(int idx,CircleListBean item,int type) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCircleDetail(int idx,CircleListBean item, CircleListBean newItem) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteZone(int index) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCircleDetail(CircleListBean bean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCommentList(CommentBean commentBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commentZone() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishComment() {
|
||||
|
||||
}
|
||||
|
||||
private static class MyFragmentPagerAdapter extends FragmentStatePagerAdapter {
|
||||
|
||||
private List<MyBagBean> list;
|
||||
private SparseArray<Fragment> fragments = new SparseArray<>();
|
||||
|
||||
public MyFragmentPagerAdapter(FragmentManager fm, List<MyBagBean> list) {
|
||||
super(fm);
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
MyBagBean model = list.get(position);
|
||||
Fragment fragment = fragments.get(position);
|
||||
if (fragment == null) {
|
||||
if (model.getMyBagType().equals("1")) {
|
||||
fragment = CircleCategoryFragment.newInstance();
|
||||
} else {
|
||||
fragment = ExpandColumnFragment.newInstance();
|
||||
}
|
||||
fragments.put(position, fragment);
|
||||
}
|
||||
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public void refreshCircleCategoryData() {
|
||||
CircleCategoryFragment circleCategoryFragments = (CircleCategoryFragment) fragments.get(0);
|
||||
circleCategoryFragments.newAddRefresh();
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public CharSequence getPageTitle(int position) {
|
||||
MyBagBean model = list.get(position);
|
||||
return model.getMyBagTitle();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,239 @@
|
||||
package com.xscm.modulemain.activity.plaza.fragment;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.activity.main.activity.MainActivity;
|
||||
import com.xscm.modulemain.adapter.ExpandColumnAdapter;
|
||||
import com.xscm.modulemain.databinding.FragmentExpandColumnBinding;
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
|
||||
import com.xscm.modulemain.activity.plaza.contacts.CircleContacts;
|
||||
import com.xscm.modulemain.activity.plaza.presenter.CirclePresenter;
|
||||
import com.xscm.modulemain.manager.RoomManager;
|
||||
import com.xscm.moduleutil.base.BaseMvpFragment;
|
||||
import com.xscm.moduleutil.bean.CircleListBean;
|
||||
import com.xscm.moduleutil.bean.CommentBean;
|
||||
import com.xscm.moduleutil.bean.ExpandColumnBean;
|
||||
import com.xscm.moduleutil.bean.HeatedBean;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.utils.ChatLauncher;
|
||||
|
||||
import org.angmarch.views.NiceSpinner;
|
||||
import org.angmarch.views.OnSpinnerItemSelectedListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/5/28
|
||||
*@description: 动态中的扩列fragemnt
|
||||
*/
|
||||
public class ExpandColumnFragment extends BaseMvpFragment<CirclePresenter, FragmentExpandColumnBinding> implements CircleContacts.View {
|
||||
|
||||
private ExpandColumnAdapter expandColumnAdapter;
|
||||
private String type="2";
|
||||
private int page;
|
||||
@Override
|
||||
protected CirclePresenter bindPresenter() {
|
||||
return new CirclePresenter(this,getActivity());
|
||||
}
|
||||
|
||||
public static ExpandColumnFragment newInstance() {
|
||||
return new ExpandColumnFragment();
|
||||
}
|
||||
@Override
|
||||
protected void initData() {
|
||||
|
||||
List<String> dataset = new LinkedList<>(Arrays.asList("只看女生", "只看男生", "查看全部"));
|
||||
mBinding.niceSpinner.attachDataSource(dataset);
|
||||
mBinding.niceSpinner.setOnSpinnerItemSelectedListener(new OnSpinnerItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(NiceSpinner parent, View view, int position, long id) {
|
||||
// 示例使用的是 String 类型,但你的数据类型可以是任意的
|
||||
String item = (String) parent.getItemAtPosition(position);
|
||||
LogUtils.e("@@@",item);
|
||||
mBinding.niceSpinner.setText(item);
|
||||
if (item.equals("只看女生")){
|
||||
type="2";
|
||||
page=1;
|
||||
}else if (item.equals("只看男生")){
|
||||
type="1";
|
||||
page=1;
|
||||
}else {
|
||||
type="0";
|
||||
page=1;
|
||||
}
|
||||
MvpPre.getExpandColumn(type,"1", "10");
|
||||
// mBinding.niceSpinner.getItemAtPosition(position);
|
||||
}
|
||||
});
|
||||
mBinding.niceSpinner.setText("只看女生");
|
||||
mBinding.niceSpinner.setBackground(null);
|
||||
|
||||
mBinding.recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
expandColumnAdapter = new ExpandColumnAdapter();
|
||||
mBinding.recyclerView.setAdapter(expandColumnAdapter);
|
||||
|
||||
mBinding.smartRefreshLayout.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
|
||||
@Override
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
page++;
|
||||
MvpPre.getExpandColumn(type,page + "", "10");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
// EventBus.getDefault().post(new BannerRefreshEvent());
|
||||
page = 1;
|
||||
MvpPre.getExpandColumn(type,page+"", "10");
|
||||
}
|
||||
});
|
||||
|
||||
expandColumnAdapter.setOnItemClickListener(new ExpandColumnAdapter.OnItemClickListener() {
|
||||
@Override
|
||||
public void onDianzanClick(ExpandColumnBean item) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHeadImageClick(ExpandColumnBean item) {
|
||||
ARouter.getInstance().build(ARouteConstants.USER_HOME_PAGE).withString("userId", item.getUser_id()).navigation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onZsClick(ExpandColumnBean item) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDiandianClick(ExpandColumnBean item) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPinglunClick(ExpandColumnBean item) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRelaClick(ExpandColumnBean item) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGnsClick(ExpandColumnBean item) {
|
||||
if ( item.getRoom_id()!=0){
|
||||
if (getActivity() instanceof MainActivity){
|
||||
((MainActivity)getActivity()).isShowLoading(true);
|
||||
}
|
||||
RoomManager.getInstance().fetchRoomDataAndEnter(getActivity(), item.getRoom_id()+"","",null);
|
||||
}else {
|
||||
ChatLauncher.getInstance().launchC2CChat(getActivity(), item.getUser_id()+"");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
page=1;
|
||||
MvpPre.getExpandColumn(type,"1", "10");
|
||||
}
|
||||
@Override
|
||||
protected void initView() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fragment_expand_column;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCategories(List<HeatedBean> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCircleList(List<CircleListBean> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExpandColumn(List<ExpandColumnBean> list) {
|
||||
if (type.equals("2")) {
|
||||
if (page == 1) {
|
||||
expandColumnAdapter.setNewData(new ArrayList<>());
|
||||
expandColumnAdapter.setNewData(list);
|
||||
} else {
|
||||
if (list != null && list.size() > 0) {
|
||||
expandColumnAdapter.addData(list);
|
||||
}
|
||||
}
|
||||
}else if (type.equals("1")){
|
||||
if (page == 1) {
|
||||
expandColumnAdapter.setNewData(new ArrayList<>());
|
||||
expandColumnAdapter.setNewData(list);
|
||||
} else {
|
||||
if (list != null && list.size() > 0) {
|
||||
expandColumnAdapter.addData(list);
|
||||
}
|
||||
}
|
||||
|
||||
}else if (type.equals("0")){
|
||||
if (page == 1) {
|
||||
expandColumnAdapter.setNewData(new ArrayList<>());
|
||||
expandColumnAdapter.setNewData(list);
|
||||
} else {
|
||||
if (list != null && list.size() > 0) {
|
||||
expandColumnAdapter.addData(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLikeZone(int idx,CircleListBean item,int type) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCircleDetail(int idx,CircleListBean item, CircleListBean newItem) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteZone(int index) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCircleDetail(CircleListBean bean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCommentList(CommentBean commentBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commentZone() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishComment() {
|
||||
mBinding.smartRefreshLayout.finishRefresh();
|
||||
mBinding.smartRefreshLayout.finishLoadMore();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
package com.xscm.modulemain.activity.plaza.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.xscm.modulemain.activity.plaza.contacts.CircleContacts;
|
||||
import com.xscm.moduleutil.bean.CircleListBean;
|
||||
import com.xscm.moduleutil.bean.CommentBean;
|
||||
import com.xscm.moduleutil.bean.ExpandColumnBean;
|
||||
import com.xscm.moduleutil.bean.HeatedBean;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class CirclePresenter extends BasePresenter<CircleContacts.View> implements CircleContacts.IIndexPre {
|
||||
|
||||
CircleContacts.View mView;
|
||||
|
||||
public CirclePresenter(CircleContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
this.mView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCategories() {
|
||||
|
||||
api.getCategories(new BaseObserver<List<HeatedBean>>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<HeatedBean> heatedBeanList) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().setCategories(heatedBeanList);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCircleList(String page, String page_limit) {
|
||||
api.getCircleList(page,page_limit,new BaseObserver<List<CircleListBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<CircleListBean> circleListBeans) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().getCircleList(circleListBeans);
|
||||
MvpRef.get().finishComment();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//获取扩列数据
|
||||
@Override
|
||||
public void getExpandColumn(String type, String page, String page_limit) {
|
||||
api.getExpandColumn(type, page, page_limit, new BaseObserver<List<ExpandColumnBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<ExpandColumnBean> expandColumnBeans) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().setExpandColumn(expandColumnBeans);
|
||||
MvpRef.get().finishComment();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void likeZone(int index,CircleListBean item) {
|
||||
api.likeZone(item.getId()+"", new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().setLikeZone(index,item,2);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void getCircleDetail(int index,CircleListBean item) {
|
||||
api.zoneDetail(item.getId()+"", new BaseObserver<CircleListBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(CircleListBean circleListBeans) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().getCircleDetail(index,item,circleListBeans);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void topicId(String topic_id,int type) {
|
||||
if (type == 1) {//这是获取动态列表
|
||||
api.topicId(topic_id, new BaseObserver<List<CircleListBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<CircleListBean> circleListBeans) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().getCircleList(circleListBeans);
|
||||
}
|
||||
});
|
||||
}else if (type == 2){//这是获取动态详情
|
||||
api.zoneDetail(topic_id, new BaseObserver<CircleListBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(CircleListBean circleListBeans) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().setCircleDetail(circleListBeans);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteZone(int index,CircleListBean bean) {
|
||||
api.deleteZone(bean.getId()+"", new BaseObserver<String>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().deleteZone(index);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCommentList(String id, String page, String page_limit) {
|
||||
api.getCommentList(id, page, page_limit, new BaseObserver<CommentBean>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(CommentBean commentBean) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().getCommentList(commentBean);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commentZone(String id, String content, String pid, String reply_to) {
|
||||
api.commentZone(id, content, pid, reply_to, new BaseObserver<String>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().commentZone();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteComment(String id) {
|
||||
api.deleteComment(id, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().commentZone();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package com.xscm.modulemain.activity.plaza.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.xscm.modulemain.activity.plaza.contacts.ReleaseContract;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.bean.HeatedBean;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
import com.xscm.moduleutil.utils.cos.CosUploadManager;
|
||||
import com.xscm.moduleutil.utils.oss.OSSOperUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class ReleasePresenter extends BasePresenter<ReleaseContract.View> implements ReleaseContract.IIndexPre {
|
||||
ReleaseContract.View mView;
|
||||
public ReleasePresenter(ReleaseContract.View view, Context context) {
|
||||
super(view, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void topicList(String page, String page_limit) {
|
||||
api.topicList(page, page_limit, new BaseObserver<List<HeatedBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<HeatedBean> heatedBeanList) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().topicList(heatedBeanList);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void batchUploadFiles(List<File> files, int type) {
|
||||
for (int i = 0; i < files.size(); i++) {
|
||||
uploadFile(files.get(i), type, i, files.size());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadFile(File file, int type,int index,int size) {
|
||||
// MvpRef.get().showLoadings("上传中...");
|
||||
|
||||
|
||||
|
||||
String url = OSSOperUtils.getPath(file, type);
|
||||
CosUploadManager.getInstance(CommonAppContext.getInstance()).upParameters(url,file.getPath(), new CosUploadManager.UploadCallback() {
|
||||
@Override
|
||||
public void onSuccess(String url) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().upLoadSuccess(url, type, index, size);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Exception e) {
|
||||
ToastUtils.show("上传失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure1(IllegalStateException e) {
|
||||
ToastUtils.show("上传失败");
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
// OSSOperUtils.newInstance().putObjectMethod(url, file.getPath(), new OSSOperUtils.OssCallback() {
|
||||
// @Override
|
||||
// public void onSuccess() {
|
||||
// if (isViewAttach()) {
|
||||
// if (MvpRef==null){
|
||||
// MvpRef=new WeakReference<>(mView);
|
||||
// }
|
||||
// MvpRef.get().upLoadSuccess(OSSOperUtils.AliYunOSSURLFile + url, type, index, size);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onFail() {
|
||||
// if (isViewAttach()) {
|
||||
// ToastUtils.show("上传失败");
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publishZone(String images, String content, String topic_id, String room_id,String ip) {
|
||||
api.publishZone(images, content, topic_id, room_id,ip, new BaseObserver<String>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().publishSuccess();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
package com.xscm.modulemain.activity.room.activity;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.activity.room.contacts.VoiceCategoryContacts;
|
||||
import com.xscm.modulemain.activity.room.presenter.VoiceCategoryPresenter;
|
||||
import com.xscm.modulemain.adapter.PopularRoomAdapter;
|
||||
import com.xscm.modulemain.databinding.ActivityPopularRoomBinding;
|
||||
import com.xscm.modulemain.BaseMvpActivity;
|
||||
import com.xscm.modulemain.manager.RoomManager;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.bean.BannerModel;
|
||||
import com.xscm.moduleutil.bean.RoomTypeModel;
|
||||
import com.xscm.moduleutil.bean.TopRoom;
|
||||
import com.xscm.moduleutil.listener.MessageListenerSingleton;
|
||||
import com.xscm.moduleutil.utils.ClickUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
|
||||
/**
|
||||
* @Description: 热门房间
|
||||
* @Author: Xue
|
||||
* @CreateDate: 2021/4/7 11:05
|
||||
*/
|
||||
public class PopularRoomActivity extends BaseMvpActivity<VoiceCategoryPresenter, ActivityPopularRoomBinding> implements VoiceCategoryContacts.View {
|
||||
|
||||
PopularRoomAdapter mAdapter;
|
||||
private int page = 1;
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
super.initView();
|
||||
mBinding.topBar.setColor(getResources().getColor(R.color.white));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
mAdapter = new PopularRoomAdapter();
|
||||
mBinding.rvPopularRoom.setAdapter(mAdapter);
|
||||
GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 2);
|
||||
gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
|
||||
@Override
|
||||
public int getSpanSize(int position) {
|
||||
switch (position) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
return 1;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
});
|
||||
mBinding.rvPopularRoom.setLayoutManager(gridLayoutManager);
|
||||
mBinding.smartRefreshLayout.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
|
||||
@Override
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
page++;
|
||||
MvpPre.getCarousels(1, page, "20", "2", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
page = 1;
|
||||
mAdapter.setNewData(new ArrayList<>());
|
||||
MvpPre.getCarousels(1, page, "20", "2", "");
|
||||
}
|
||||
});
|
||||
|
||||
mAdapter.setOnRoomClickListener((room, position) -> {
|
||||
if ( ClickUtils.isFastDoubleClick()){
|
||||
return;
|
||||
}
|
||||
|
||||
// 添加索引有效性检查
|
||||
if (position < 0 || position >= mAdapter.getData().size()) {
|
||||
return;
|
||||
}
|
||||
TopRoom item = mAdapter.getItem(position);
|
||||
if (item != null ) {
|
||||
mBinding.coolWaitView.setVisibility(View.VISIBLE);
|
||||
MessageListenerSingleton.getInstance().joinGroup(item.getRoom_id());
|
||||
RoomManager.getInstance().fetchRoomDataAndEnter(getApplicationContext(), item.getRoom_id(), "",null);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
Observable.timer(5, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe(aLong -> {
|
||||
mBinding.coolWaitView.setVisibility(View.GONE);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
page=1;
|
||||
MvpPre.getCarousels(1, page, "10", "2", "");//顶部推荐
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_popular_room;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected VoiceCategoryPresenter bindPresenter() {
|
||||
return new VoiceCategoryPresenter(this, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishRefreshLoadMore() {
|
||||
mBinding.smartRefreshLayout.finishRefresh();
|
||||
mBinding.smartRefreshLayout.finishLoadMore();
|
||||
CommonAppContext.getInstance().isRoomJoininj=false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCategories(List<RoomTypeModel> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBanners(List<BannerModel> bannerModels) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRoomId(String roomId) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTopRoom(List<TopRoom> topRooms, int type) {
|
||||
if (topRooms != null && topRooms.size() > 0) {
|
||||
if (page == 1) {
|
||||
mAdapter.setNewData(topRooms); // 刷新时替换数据
|
||||
} else {
|
||||
// 检查是否有重复数据
|
||||
boolean hasDuplicate = false;
|
||||
List<TopRoom> currentData = mAdapter.getData();
|
||||
if (!currentData.isEmpty() && topRooms.size() > 0) {
|
||||
// 检查第一条数据是否已经存在
|
||||
TopRoom firstNewData = topRooms.get(0);
|
||||
for (TopRoom item : currentData) {
|
||||
if (item.getRoom_id().equals(firstNewData.getRoom_id())) {
|
||||
hasDuplicate = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasDuplicate) {
|
||||
mAdapter.addData(topRooms); // 加载更多时添加数据
|
||||
}
|
||||
}
|
||||
} else if (page == 1) {
|
||||
// 如果是刷新且没有数据,清空列表
|
||||
mAdapter.setNewData(new ArrayList<>());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.xscm.modulemain.activity.room.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.Color;
|
||||
import android.text.TextUtils;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import com.xscm.modulemain.BaseMvpActivity;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.adapter.SectionsPagerAdapter;
|
||||
import com.xscm.modulemain.databinding.ActivityRankingListBinding;
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
|
||||
/**
|
||||
*@author lxj
|
||||
*@data 2025/5/15
|
||||
*@description: 排行榜
|
||||
*/
|
||||
public class RankingListActivity extends BaseMvpActivity<IPresenter,ActivityRankingListBinding> implements IView<Activity> {
|
||||
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IPresenter bindPresenter() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
mBinding.topBar.setTitle("排行榜");
|
||||
mBinding.topBar.setColor(getResources().getColor(R.color.white));
|
||||
SectionsPagerAdapter sectionsPagerAdapter = new SectionsPagerAdapter(this, getSupportFragmentManager());
|
||||
mBinding.viewPager.setAdapter(sectionsPagerAdapter);
|
||||
mBinding.tabs.setupWithViewPager( mBinding.viewPager);
|
||||
setupCustomTabs();
|
||||
}
|
||||
private void setupCustomTabs() {
|
||||
TabLayout tabs = findViewById(R.id.tabs);
|
||||
|
||||
// 为每个tab创建自定义视图
|
||||
for (int i = 0; i < tabs.getTabCount(); i++) {
|
||||
TabLayout.Tab tab = tabs.getTabAt(i);
|
||||
if (tab != null) {
|
||||
TextView customView = new TextView(this);
|
||||
customView.setText(tab.getText());
|
||||
customView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12); // 未选中时的字体大小
|
||||
customView.setTextColor(Color.parseColor("#ffffff")); // 未选中时的灰色
|
||||
customView.setGravity(Gravity.CENTER);
|
||||
customView.setSingleLine(true); // 确保不换行显示
|
||||
customView.setEllipsize(TextUtils.TruncateAt.END); // 超出部分显示省略号
|
||||
|
||||
tab.setCustomView(customView);
|
||||
}
|
||||
}
|
||||
|
||||
// 设置选中监听器
|
||||
tabs.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
||||
@Override
|
||||
public void onTabSelected(TabLayout.Tab tab) {
|
||||
if (tab.getCustomView() != null) {
|
||||
TextView textView = (TextView) tab.getCustomView();
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14); // 选中时的字体大小
|
||||
textView.setTextColor(Color.WHITE); // 选中时的黑色
|
||||
textView.setSingleLine(true); // 确保不换行显示
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabUnselected(TabLayout.Tab tab) {
|
||||
if (tab.getCustomView() != null) {
|
||||
TextView textView = (TextView) tab.getCustomView();
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12); // 未选中时的字体大小
|
||||
textView.setTextColor(Color.parseColor("#ffffff")); // 未选中时的灰色
|
||||
textView.setSingleLine(true); // 确保不换行显示
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabReselected(TabLayout.Tab tab) {
|
||||
}
|
||||
});
|
||||
|
||||
// 设置初始选中tab的样式(如果有的话)
|
||||
if (tabs.getTabCount() > 0 && tabs.getSelectedTabPosition() >= 0) {
|
||||
TabLayout.Tab selectedTab = tabs.getTabAt(tabs.getSelectedTabPosition());
|
||||
if (selectedTab != null && selectedTab.getCustomView() != null) {
|
||||
TextView textView = (TextView) selectedTab.getCustomView();
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
|
||||
textView.setTextColor(Color.WHITE);
|
||||
textView.setSingleLine(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_ranking_list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.xscm.modulemain.activity.room.activity;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
|
||||
import com.xscm.modulemain.BaseMvpActivity;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.activity.room.contacts.RedEnvelopesContacts;
|
||||
import com.xscm.modulemain.activity.room.presenter.RedEnvelopesPresenter;
|
||||
import com.xscm.modulemain.adapter.RedAdapter;
|
||||
import com.xscm.modulemain.databinding.FragmentRedBinding;
|
||||
import com.xscm.moduleutil.bean.RedpacketDetail;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author qx
|
||||
* @data 2025/9/29
|
||||
* @description:红包最终的展示页面
|
||||
*/
|
||||
@Route(path = ARouteConstants.ROOM_RED_RESULT)
|
||||
public class RedResultActivity extends BaseMvpActivity<RedEnvelopesPresenter, FragmentRedBinding> implements RedEnvelopesContacts.View {
|
||||
|
||||
private RedAdapter redAdapter;
|
||||
private String redpacketId;
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
redpacketId = getIntent().getStringExtra("redpacketId");
|
||||
if (redpacketId == null || redpacketId.isEmpty()) {
|
||||
// 处理红包ID为空的情况
|
||||
return;
|
||||
}
|
||||
if (MvpPre==null){
|
||||
MvpPre = new RedEnvelopesPresenter(this, this);
|
||||
}
|
||||
MvpPre.getRedpacketDetail(redpacketId);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RedEnvelopesPresenter bindPresenter() {
|
||||
return new RedEnvelopesPresenter(this, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
mBinding.recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
redAdapter = new RedAdapter();
|
||||
mBinding.recyclerView.setAdapter(redAdapter);
|
||||
// 确保最后一项完全可见
|
||||
mBinding.recyclerView.setClipToPadding(false);
|
||||
mBinding.recyclerView.setPadding(
|
||||
0,
|
||||
getResources().getDimensionPixelSize(com.xscm.moduleutil.R.dimen.dp_12),
|
||||
0,
|
||||
getResources().getDimensionPixelSize(com.xscm.moduleutil.R.dimen.dp_12)
|
||||
);
|
||||
mBinding.smartRefreshLayout.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
|
||||
|
||||
@Override
|
||||
public void onRefresh(@NonNull @NotNull RefreshLayout refreshLayout) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadMore(@NonNull @NotNull RefreshLayout refreshLayout) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fragment_red;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void redPacketDetail(RedpacketDetail redpacketDetail) {
|
||||
// 检查 Activity 是否已经销毁
|
||||
if (isFinishing() || isDestroyed()) {
|
||||
return;
|
||||
}
|
||||
if (redpacketDetail != null) {
|
||||
ImageUtils.loadHeadCC(redpacketDetail.getRedpacket_info().getAvatar(), mBinding.userAvatar);
|
||||
mBinding.userName.setText(redpacketDetail.getRedpacket_info().getNickname());
|
||||
mBinding.tvRedTitle.setText(redpacketDetail.getRedpacket_info().getRemark());
|
||||
mBinding.tvJb.setText(redpacketDetail.getRedpacket_info().getCoin_type() == 1 ? "金币" : "钻石");
|
||||
if (redpacketDetail.getMy_record() != null) {
|
||||
mBinding.tvRedJb.setText(redpacketDetail.getMy_record().getAmount());
|
||||
}else {
|
||||
mBinding.tvRedJb.setText("0.00");
|
||||
}
|
||||
mBinding.tvLq.setText("已领取"+redpacketDetail.getRecords().size() + "/" + redpacketDetail.getRedpacket_info().getTotal_count());
|
||||
redAdapter.setNewData(redpacketDetail.getRecords());
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,283 @@
|
||||
package com.xscm.modulemain.activity.room.activity;
|
||||
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.blankj.utilcode.util.StringUtils;
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.adapter.SearchHistoryAdapter;
|
||||
import com.xscm.modulemain.adapter.SearchRecordAdapter;
|
||||
import com.xscm.modulemain.adapter.SearchRoomResultAdapter;
|
||||
import com.xscm.modulemain.adapter.SearchUserResultAdapter;
|
||||
import com.xscm.modulemain.activity.room.contacts.SearchContacts;
|
||||
import com.xscm.modulemain.databinding.ActivitySearchBinding;
|
||||
import com.xscm.modulemain.activity.room.presenter.SearchPresenter;
|
||||
import com.google.android.flexbox.FlexDirection;
|
||||
import com.google.android.flexbox.FlexWrap;
|
||||
import com.google.android.flexbox.FlexboxLayoutManager;
|
||||
import com.xscm.modulemain.BaseMvpActivity;
|
||||
import com.xscm.modulemain.manager.RoomManager;
|
||||
import com.xscm.moduleutil.bean.RecordSection;
|
||||
import com.xscm.moduleutil.bean.RoomSearchResp;
|
||||
import com.xscm.moduleutil.bean.SearchAll;
|
||||
import com.xscm.moduleutil.bean.UserResultResp;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.utils.ChatLauncher;
|
||||
import com.xscm.moduleutil.widget.dialog.CommonDialog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/*
|
||||
* 搜索页面
|
||||
*/
|
||||
public class SearchActivity extends BaseMvpActivity<SearchPresenter, ActivitySearchBinding> implements SearchContacts.View, CommonDialog.OnClickListener {
|
||||
private String keyWord;
|
||||
private List<RoomSearchResp> roomResultInfoList = new ArrayList<>();
|
||||
|
||||
|
||||
private SearchHistoryAdapter mSearchHistoryAdapter;
|
||||
private SearchRecordAdapter mSearchRecordAdapter;
|
||||
private SearchRoomResultAdapter mSearchRoomResultAdapter;
|
||||
private SearchUserResultAdapter mSearchUserResultAdapter;
|
||||
private CommonDialog commonDialog;
|
||||
|
||||
@Override
|
||||
protected SearchPresenter bindPresenter() {
|
||||
return new SearchPresenter(this, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
|
||||
//搜索记录
|
||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
|
||||
mBinding.recycleViewRecord.setLayoutManager(linearLayoutManager);
|
||||
mBinding.recycleViewRecord.setAdapter(mSearchRecordAdapter = new SearchRecordAdapter());
|
||||
mSearchRecordAdapter.bindToRecyclerView(mBinding.recycleViewRecord);
|
||||
mSearchRecordAdapter.setEmptyView(R.layout.index_view_empty);
|
||||
//搜索历史
|
||||
FlexboxLayoutManager flexboxLayoutManager = new FlexboxLayoutManager(this);
|
||||
flexboxLayoutManager.setFlexDirection(FlexDirection.ROW);
|
||||
flexboxLayoutManager.setFlexWrap(FlexWrap.WRAP);
|
||||
mBinding.recycleViewHistory.setLayoutManager(flexboxLayoutManager);
|
||||
mBinding.recycleViewHistory.setAdapter(mSearchHistoryAdapter = new SearchHistoryAdapter());
|
||||
|
||||
//搜索到用户数据
|
||||
mBinding.recycleViewUser.setLayoutManager(new LinearLayoutManager(this));
|
||||
mBinding.recycleViewUser.setAdapter(mSearchUserResultAdapter = new SearchUserResultAdapter());
|
||||
//搜索到房间信息
|
||||
GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 2);
|
||||
mBinding.recycleViewRoom.setLayoutManager(gridLayoutManager);
|
||||
mBinding.recycleViewRoom.setAdapter(mSearchRoomResultAdapter = new SearchRoomResultAdapter());
|
||||
|
||||
mBinding.editQuery.addTextChangedListener(new TextWatcher() {
|
||||
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
keyWord = mBinding.editQuery.getText().toString();
|
||||
MvpPre.saveSearchHistory(keyWord);
|
||||
if (StringUtils.isEmpty(keyWord)) {
|
||||
mBinding.ivClose.setImageLevel(1);
|
||||
mBinding.ivClose.performClick();
|
||||
} else {
|
||||
mSearchUserResultAdapter.setKeyWord(keyWord);
|
||||
mSearchRecordAdapter.setKeyWord(keyWord);
|
||||
mBinding.ivClose.setImageLevel(2);
|
||||
mBinding.llHistory.setVisibility(View.GONE);
|
||||
MvpPre.getSearchHistory();
|
||||
MvpPre.fuzzyQuery(keyWord);
|
||||
MvpPre.search(keyWord);
|
||||
}
|
||||
}
|
||||
});
|
||||
MvpPre.getSearchHistory();
|
||||
|
||||
//快捷搜索列表点击
|
||||
mSearchRecordAdapter.setOnItemChildClickListener((adapter, view, position) -> {
|
||||
MvpPre.saveSearchHistory(Objects.requireNonNull(mSearchRecordAdapter.getItem(position)).t);
|
||||
MvpPre.search(Objects.requireNonNull(mSearchRecordAdapter.getItem(position)).t);
|
||||
});
|
||||
//搜索历史点击
|
||||
mSearchHistoryAdapter.setOnItemClickListener((adapter, view, position) -> {
|
||||
mBinding.editQuery.setText(mSearchHistoryAdapter.getItem(position));
|
||||
try {
|
||||
mBinding.editQuery.setSelection(mSearchHistoryAdapter.getItem(position).length());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
//关注或取消关注
|
||||
mSearchUserResultAdapter.setOnItemChildClickListener((adapter, view, position) -> {
|
||||
UserResultResp item = mSearchUserResultAdapter.getItem(position);
|
||||
MvpPre.followUser(item.getUser_id(), item.getFollow().equals("0") ? 1 : 2, position);
|
||||
});
|
||||
//用户列表点击事件
|
||||
mSearchUserResultAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
|
||||
UserResultResp item = mSearchUserResultAdapter.getItem(position);
|
||||
}
|
||||
});
|
||||
|
||||
mSearchUserResultAdapter.setOnItemClickListener(new SearchUserResultAdapter.OnItemClickListener() {
|
||||
@Override
|
||||
public void onGnsClick(UserResultResp item) {
|
||||
if (item.getRoom_id() != null && !item.getRoom_id().isEmpty() && !"0".equals(item.getRoom_id())) {
|
||||
|
||||
RoomManager.getInstance().fetchRoomDataAndEnter(SearchActivity.this, item.getRoom_id(), "",null);
|
||||
|
||||
} else {
|
||||
ChatLauncher.getInstance().launchC2CChat(SearchActivity.this, item.getUser_id());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHeadImageClick(UserResultResp item) {
|
||||
ARouter.getInstance().build(ARouteConstants.USER_HOME_PAGE).withString("userId", item.getUser_id()).navigation();
|
||||
//
|
||||
}
|
||||
});
|
||||
//房间列表点击时事件
|
||||
mSearchRoomResultAdapter.setOnItemClickListener((adapter, view, position) -> {
|
||||
RoomSearchResp item = mSearchRoomResultAdapter.getItem(position);
|
||||
if (item != null) {
|
||||
RoomManager.getInstance().fetchRoomDataAndEnter(getApplicationContext(), item.getRoom_id(), "",null);
|
||||
}
|
||||
});
|
||||
mBinding.ivDelete.setOnClickListener(v -> {
|
||||
if (commonDialog == null) {
|
||||
commonDialog = new CommonDialog(SearchActivity.this);
|
||||
commonDialog.setmOnClickListener(SearchActivity.this);
|
||||
}
|
||||
commonDialog.show();
|
||||
});
|
||||
mBinding.ivClose.setOnClickListener(v -> {
|
||||
if (!StringUtils.isEmpty(keyWord)) {
|
||||
mBinding.editQuery.setText("");
|
||||
}
|
||||
mBinding.recycleViewRecord.setVisibility(View.GONE);
|
||||
mBinding.llHistory.setVisibility(View.VISIBLE);
|
||||
mBinding.rlResult.setVisibility(View.GONE);
|
||||
});
|
||||
mBinding.tvRoomCount.setOnClickListener(v -> {
|
||||
mSearchRoomResultAdapter.setNewData(roomResultInfoList);
|
||||
mBinding.rlRoom.setVisibility(View.GONE);
|
||||
mBinding.rlUser.setVisibility(View.GONE);
|
||||
mBinding.recycleViewUser.setVisibility(View.GONE);
|
||||
});
|
||||
mBinding.tvCancel.setOnClickListener(v -> finish());
|
||||
mBinding.editQuery.requestFocus();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_search;
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索历史
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
@Override
|
||||
public void setSearchHistory(List<String> data) {
|
||||
mSearchHistoryAdapter.setNewData(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索的结果
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
@Override
|
||||
public void setSearch(SearchAll data) {
|
||||
mBinding.recycleViewRecord.setVisibility(View.GONE);
|
||||
mBinding.llHistory.setVisibility(View.GONE);
|
||||
mBinding.rlResult.setVisibility(View.VISIBLE);
|
||||
if (data == null || (data.getRooms() == null && data.getUsers() == null)) {
|
||||
mBinding.rlNull.setVisibility(View.VISIBLE);
|
||||
mBinding.nestedscrollview.setVisibility(View.GONE);
|
||||
} else {
|
||||
mBinding.rlNull.setVisibility(View.GONE);
|
||||
mBinding.nestedscrollview.setVisibility(View.VISIBLE);
|
||||
if (data.getRooms()==null) {
|
||||
mBinding.recycleViewRoom.setVisibility(View.GONE);
|
||||
mBinding.rlRoom.setVisibility(View.GONE);
|
||||
} else {
|
||||
mBinding.recycleViewRoom.setVisibility(View.VISIBLE);
|
||||
mBinding.rlRoom.setVisibility(View.VISIBLE);
|
||||
if (data.getRooms().size() > 2) {
|
||||
mSearchRoomResultAdapter.setNewData(data.getRooms().subList(0, 2));
|
||||
} else {
|
||||
mSearchRoomResultAdapter.setNewData(data.getRooms());
|
||||
}
|
||||
mBinding.tvRoomCount.setText("全部 " + data.getRooms().size());
|
||||
}
|
||||
if (data.getUsers() != null && data.getUsers().size() != 0) {
|
||||
mBinding.rlUser.setVisibility(View.VISIBLE);
|
||||
mBinding.recycleViewUser.setVisibility(View.VISIBLE);
|
||||
mSearchUserResultAdapter.setNewData(data.getUsers());
|
||||
} else {
|
||||
mBinding.rlUser.setVisibility(View.GONE);
|
||||
mBinding.recycleViewUser.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 模糊快捷查询
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
@Override
|
||||
public void setFuzzyQuery(List<RecordSection> data) {
|
||||
mBinding.recycleViewRecord.setVisibility(View.VISIBLE);
|
||||
mBinding.llHistory.setVisibility(View.GONE);
|
||||
mBinding.rlResult.setVisibility(View.GONE);
|
||||
mSearchRecordAdapter.setNewData(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关注成功
|
||||
*
|
||||
* @param type
|
||||
* @param postion
|
||||
*/
|
||||
@Override
|
||||
public void followUserSuccess(int type, int postion) {
|
||||
UserResultResp item = mSearchUserResultAdapter.getItem(postion);
|
||||
item.setFollow(type == 1 ? "1" : "0");
|
||||
mSearchUserResultAdapter.notifyItemChanged(postion, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLeftClick() {
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onRightClick() {
|
||||
MvpPre.deleteSearchHistory();
|
||||
MvpPre.getSearchHistory();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.room.RoomAuction;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BidListContacts {
|
||||
|
||||
public interface View extends IView<Activity> {
|
||||
void roomAuctionList(List<RoomAuction.AuctionListBean> auctionListBean);
|
||||
void setNo1(RoomAuction.AuctionListBean listsBean);
|
||||
void setNo2(RoomAuction.AuctionListBean listsBean);
|
||||
void setNo3(RoomAuction.AuctionListBean listsBean);
|
||||
void setCharmEmpty();
|
||||
|
||||
}
|
||||
|
||||
public interface IRoomPre extends IPresenter {
|
||||
void roomAuctionList(String auction_id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.RoomRelationBean;
|
||||
import com.xscm.moduleutil.bean.RoomTime;
|
||||
import com.xscm.moduleutil.bean.RoonGiftModel;
|
||||
import com.xscm.moduleutil.bean.room.AuctionBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CardRelationshipContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
void roomRelationList(List<RoomRelationBean> roomRelationBeans);
|
||||
void setGiftList(List<RoonGiftModel> roonGiftModels);
|
||||
void roomAuction(AuctionBean auctionBean);
|
||||
void roomAuctionTime(RoomTime roomTime);
|
||||
}
|
||||
public interface IRoomPre extends IPresenter {
|
||||
void roomRelationList(String type);
|
||||
|
||||
void getGiftList(String id);
|
||||
|
||||
void roomAuction(String roomId, String userId,String giftId, String relation_id, String auction_type, String time_day);
|
||||
void roomAuctionTime(String gift_id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
|
||||
|
||||
public final class ChatRoomContacts {
|
||||
|
||||
|
||||
public interface View extends IView<Activity> {
|
||||
|
||||
}
|
||||
|
||||
public interface IPublicScreenEaseChatPre extends IPresenter {
|
||||
void logEmchat(int code,String msg,String toChatUsername);
|
||||
|
||||
void switchPublicScreen(String room_id,String status);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.CharmRankingResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/6/10
|
||||
*@description: 排行榜对应的接口
|
||||
*/
|
||||
public class DataListContacts {
|
||||
|
||||
public interface View extends IView<Activity> {
|
||||
|
||||
//榜一更新
|
||||
void setNo1(CharmRankingResp listsBean);
|
||||
//榜二更新
|
||||
void setNo2(CharmRankingResp listsBean);
|
||||
//榜三更新
|
||||
void setNo3(CharmRankingResp listsBean);
|
||||
//魅力榜和魅力榜界面更新
|
||||
|
||||
void setCharmEmpty( List<CharmRankingResp> list);
|
||||
|
||||
void setWealthEmpty(List<CharmRankingResp> list);
|
||||
}
|
||||
public interface IRoomDataListPre extends IPresenter {
|
||||
|
||||
//定义魅力榜数据访问接口
|
||||
void getCharmListInfo(String roomId,String type, String time_type, String page, String page_limit);
|
||||
|
||||
//定义财富榜数据访问接口
|
||||
void getWealthListInfo(String roomId, String type, String time_type, String page, String page_limit);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.UserOnlineStatusBean;
|
||||
import com.xscm.moduleutil.bean.room.FriendUserBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FriendshipRoomContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
void applyPit();
|
||||
|
||||
void endFriend(FriendUserBean friendUserBean);
|
||||
|
||||
void createRelation();
|
||||
|
||||
void userOnlineStatus(List<UserOnlineStatusBean> list);
|
||||
}
|
||||
|
||||
public interface IRoomPre extends IPresenter {
|
||||
void applyPit(String roomId, String pitNumber);
|
||||
|
||||
void startFriend(String roomId);
|
||||
|
||||
void delay(String friend_id,String room_id,String delay_times);
|
||||
|
||||
void endFriend(String friend_id,String room_id);
|
||||
|
||||
void createRelation(String room_id,String friend_id,String user1_id,String user2_id,String relation_id);
|
||||
|
||||
void userOnlineStatus(String userId, String roomid);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.HomeBean;
|
||||
import com.xscm.moduleutil.bean.TopRoom;
|
||||
import com.xscm.moduleutil.bean.room.RoomInfoResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class HotListContacts {
|
||||
|
||||
|
||||
public interface View extends IView<Activity> {
|
||||
void roomList(List<TopRoom> data, int type);
|
||||
|
||||
void finishRefreshLoadMore();
|
||||
|
||||
void getMoreRoomList(List<HomeBean> data);
|
||||
|
||||
void roomInfo(RoomInfoResp resp);
|
||||
|
||||
void showPasswordDialog();
|
||||
|
||||
void enterFail();
|
||||
}
|
||||
|
||||
public interface IHotListPre extends IPresenter {
|
||||
void getRoomList(int type,String page,String page_limit,String is_top,String label_id);
|
||||
|
||||
void getMoreRoomList(String userId);
|
||||
|
||||
void getRoomListTow();
|
||||
|
||||
void getRoomIn(String roomId, String password);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.room.RoomHourBean;
|
||||
|
||||
public class HourlyChartContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
void getRoomHourRanking(RoomHourBean roomHourBean);
|
||||
|
||||
void findView();
|
||||
}
|
||||
|
||||
public interface IRoomPre extends IPresenter {
|
||||
void getRoomHourRanking(String page,String page_limit);// 房间小时榜
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
|
||||
public class PkTimeContract {
|
||||
public interface View extends IView<Activity> {
|
||||
void startPk();
|
||||
}
|
||||
|
||||
public interface IRoomPre extends IPresenter {
|
||||
void startPk(String pk_id,String pk_times);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.PlaceholderBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PlaceholderContacts {
|
||||
|
||||
public interface View extends IView<Activity> {
|
||||
void wealthRanking(PlaceholderBean.MyRanking data);
|
||||
void setNo1(PlaceholderBean.ListsBean data,String type);
|
||||
void setNo2(PlaceholderBean.ListsBean data,String type);
|
||||
void setNo3(PlaceholderBean.ListsBean data,String type);
|
||||
void setList(List<PlaceholderBean.ListsBean > list);
|
||||
}
|
||||
|
||||
public interface IPres extends IPresenter {
|
||||
void wealthRanking(String ranking_type,String type);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.HeadlineBean;
|
||||
|
||||
public class PublishCommentContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
void sendHeadine();
|
||||
void currentHeadline(HeadlineBean headlineBean);
|
||||
}
|
||||
public interface IRoomPre extends IPresenter {
|
||||
void sendHeadine(String content,String money,String roomId);
|
||||
|
||||
void currentHeadline();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.RedpacketDetail;
|
||||
|
||||
public class RedEnvelopesContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
void redPacketDetail(RedpacketDetail redpacketDetail);
|
||||
}
|
||||
|
||||
public interface IRoomPre extends IPresenter {
|
||||
void getRedpacketDetail(String redpacketId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.MusicSongBean;
|
||||
import com.xscm.moduleutil.bean.SongMusicBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RequestContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
void songList(List<MusicSongBean> musicSongBeans);
|
||||
|
||||
void upSong(String s);
|
||||
|
||||
void song(List<SongMusicBean> music);
|
||||
|
||||
}
|
||||
public interface IRoomPre extends IPresenter {
|
||||
void songList(String roomId);
|
||||
|
||||
void upSong(String did,String type);
|
||||
|
||||
void song(String roomId,String user_id,String song_code,String song_name,String singer,String poster,String duration);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.UserOnlineStatusBean;
|
||||
import com.xscm.moduleutil.bean.room.AuctionBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RoomAuctionContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
void applyPit();
|
||||
|
||||
void roomAuction(AuctionBean auctionBean);
|
||||
|
||||
void auctionDelay();
|
||||
void auctionEnd();
|
||||
void auctionMode();
|
||||
void userOnlineStatus(List<UserOnlineStatusBean> list);
|
||||
|
||||
}
|
||||
|
||||
public interface IRoomDataListPre extends IPresenter {
|
||||
void applyPit(String roomId, String pitNumber);
|
||||
|
||||
void roomAuction(String roomId, String userId,String giftId, String relation_id, String auction_type, String time_day);
|
||||
|
||||
void auctionDelay(String auctionId);
|
||||
void auctionEnd(String auctionId,String roomId);
|
||||
|
||||
void auctionMode(String roomId,String labelId);
|
||||
void userOnlineStatus(String userId, String roomid);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.RoomBgBean;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class RoomBackgroundContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
void getBackgroundList(RoomBgBean list);
|
||||
void upLoadSuccess(String url, int type, int index, int total);
|
||||
void uploadBgImage();
|
||||
void editRoom();
|
||||
}
|
||||
|
||||
public interface RoomBackgroudPre extends IPresenter {
|
||||
void getBackgroundList();
|
||||
|
||||
void uploadFile(File file, int type, int index, int sice);
|
||||
|
||||
void uploadBgImage(String id, String image_url);
|
||||
|
||||
void editRoom(String room_id, String room_name, String room_cover, String room_intro,String room_background_id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
|
||||
public class RoomCabinContacts {
|
||||
|
||||
public interface View extends IView<Activity> {
|
||||
void quitRoom();
|
||||
}
|
||||
|
||||
public interface IRoomPre extends IPresenter {
|
||||
void quitRoom(String roomId, String userId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.RoomUserCharmListBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RoomCharmDialogContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
void roomUserCharmList(List<RoomUserCharmListBean> roomUserCharmListBeans);
|
||||
}
|
||||
|
||||
public interface IRoomPre extends IPresenter {
|
||||
|
||||
void roomUserCharmList(String room_id, String user_id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
|
||||
public class RoomChartsContacts {
|
||||
|
||||
public interface View extends IView<Activity> {
|
||||
|
||||
}
|
||||
|
||||
public interface IRoomPre extends IPresenter {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.RoomRelationBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RoomCloseContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
// TODO: 2025/3/10 获取亲密关系
|
||||
void roomRelationList(List<RoomRelationBean> list);
|
||||
|
||||
}
|
||||
|
||||
public interface IRoomToolPre extends IPresenter {
|
||||
// TODO: 2025/3/10 获取亲密关系
|
||||
void roomRelationList(String type);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.RedPacketInfo;
|
||||
import com.xscm.moduleutil.bean.RoomCharmRankBean;
|
||||
import com.xscm.moduleutil.bean.UserOnlineStatusBean;
|
||||
import com.xscm.moduleutil.bean.room.RoomInfoResp;
|
||||
import com.xscm.moduleutil.bean.room.RoomOnline;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RoomContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
void roomInfo(RoomInfoResp resp);
|
||||
|
||||
void showPasswordDialog();
|
||||
|
||||
void enterFail();
|
||||
|
||||
void getRoomOnline(RoomOnline onlineBean);
|
||||
|
||||
void applyPit();
|
||||
|
||||
void downPit();
|
||||
|
||||
void applySong();
|
||||
|
||||
void agreeSong();
|
||||
|
||||
void postRoomInfo(RoomInfoResp resp);
|
||||
|
||||
void getCharmRank(List<RoomCharmRankBean> list);
|
||||
|
||||
void changeSong();
|
||||
|
||||
void hostUserPit();
|
||||
|
||||
void quitRoom();
|
||||
void quitRoom2(String roomId);
|
||||
|
||||
void userGuanzSuccess(String s);
|
||||
|
||||
void acceptPk();
|
||||
|
||||
void clearUserCharm();
|
||||
|
||||
void userOnlineStatus(List<UserOnlineStatusBean> list);
|
||||
|
||||
void findRoom();
|
||||
|
||||
void roomRedPackets(List<RedPacketInfo> list);
|
||||
}
|
||||
|
||||
public interface IRoomPre extends IPresenter {
|
||||
void getRoomIn(String roomId, String password);//加入房间
|
||||
|
||||
void getRoomOnline(String roomId, String page, String page_limit);
|
||||
|
||||
void applyPit(String roomId, String pitNumber);
|
||||
|
||||
void downPit(String roomId, String pitNumber);
|
||||
|
||||
void applySong(String roomId);
|
||||
|
||||
void agreeSong(String roomId, String type);//申请点唱模式 type:1同意 2拒绝
|
||||
|
||||
void endSong(String roomId);
|
||||
|
||||
void postRoomInfo(String roomId);
|
||||
|
||||
void getCharmRank(String roomId);
|
||||
|
||||
void changeSong(String roomId, String now_did);
|
||||
|
||||
void hostUserPit(String roomId, String pitNumber, String userId, String type);
|
||||
|
||||
void quitRoom(String roomId, String userId);
|
||||
void quitRoom2(String roomId, String userId);
|
||||
|
||||
void userGuanz(String userId, String type);
|
||||
|
||||
void acceptPk(String pkId, String type);
|
||||
|
||||
void clearUserCharm(String roomId, String userId);//清除魅力值
|
||||
|
||||
void userOnlineStatus(String userId, String roomid);
|
||||
|
||||
void auctionEnd(String auctionId,String roomId);
|
||||
|
||||
void auctionDelay(String auctionId);
|
||||
|
||||
void roomRedPackets(String roomId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.HostBean;
|
||||
import com.xscm.moduleutil.bean.RoomSearchResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RoomHostContacts {
|
||||
|
||||
public interface View extends IView<Activity> {
|
||||
void setHostrList(List<HostBean> list);
|
||||
|
||||
void getUserHostList(List<RoomSearchResp> list);
|
||||
|
||||
void postHostAdd(String s,String type,String is_add);
|
||||
|
||||
void postPresidedRatio(String s);
|
||||
|
||||
void postPresidedDel(String s);
|
||||
void doDismiss();
|
||||
}
|
||||
|
||||
public interface IRoomToolPre extends IPresenter {
|
||||
void clearHostList(String roomId,String type);
|
||||
|
||||
void setUserHostList(String roomId,String type);
|
||||
void setPresidedRatio(String room_id,String id, String ratio);
|
||||
|
||||
void postHostAdd(String roomId, String userId,String type,String is_add);
|
||||
|
||||
// void presidedDel(String id);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
|
||||
|
||||
public final class RoomPasswordSetContacts {
|
||||
|
||||
|
||||
public interface View extends IView<Activity> {
|
||||
void roomPasswordSettingSuccess();
|
||||
}
|
||||
|
||||
public interface IRoomPasswordSetPre extends IPresenter {
|
||||
void setRoomPassword(String roomId, String password);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.room.RoomBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RoomPkContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
void searchPkRoom(List<RoomBean> roomBeans);
|
||||
|
||||
void sendPk();
|
||||
void refusePk();
|
||||
|
||||
void finishLoading();
|
||||
}
|
||||
public interface IRoomPre extends IPresenter {
|
||||
void searchPkRoom(String roomId,String page,String limit);
|
||||
|
||||
void sendPk(String roomIda,String createUserId, String roomIdb);
|
||||
|
||||
void refusePk(String roomId,String is_pk);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.room.RoomSettingBean;
|
||||
|
||||
public class RoomSettingContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
void changeRoomSuccess(String s,int position,RoomSettingBean bean);
|
||||
|
||||
void changeRoomType(String s);
|
||||
|
||||
void agreeSong(String s);
|
||||
}
|
||||
|
||||
public interface IRoomPre extends IPresenter {
|
||||
|
||||
void changeRoom(String roomId, String userId, int position, RoomSettingBean bean);
|
||||
|
||||
void changeRoomType(String roomId,String type);//修改房间类型 type:1点唱、2拍卖、3男神、4女神
|
||||
|
||||
void agreeSong(String roomId, String type);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.RelationCardBean;
|
||||
import com.xscm.moduleutil.bean.UserInfo;
|
||||
|
||||
public class RoomUserContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
void getRoomUserInfo(UserInfo userInfo);
|
||||
|
||||
void downPit();
|
||||
|
||||
void kickOutRoom();
|
||||
void postHostAdd(String s,String type,String is_add);
|
||||
void setMutePit(String pitNumber, String is_mute);
|
||||
void addBlackList();
|
||||
void userGuanzSuccess(String s);
|
||||
void hostUserPit();
|
||||
void giveCoin();
|
||||
void relationCard(RelationCardBean list);
|
||||
|
||||
void topRelationCard(String s);
|
||||
void deleteRelationCard(String s);
|
||||
void clearUserCharm();
|
||||
|
||||
void applyPit();
|
||||
}
|
||||
|
||||
public interface ViewGx extends IView<Activity> {
|
||||
}
|
||||
|
||||
public interface IEmotionRoomPre extends IPresenter {
|
||||
void getRoomUserInfo(String roomId,String userId);
|
||||
|
||||
void downPit(String roomId, String pitNumber);//下麦
|
||||
|
||||
void kickOutRoom(String roomId, String userId);
|
||||
|
||||
void postHostAdd(String roomId, String userId,String type,String is_add);
|
||||
|
||||
void setMutePit(String roomId, String pitNumber,String is_mute);// 禁言 禁麦 \解禁
|
||||
|
||||
void addBlackList(String userId);
|
||||
void userGuanz(String userId,String type);
|
||||
|
||||
void hostUserPit(String roomId,String pitNumber,String userId,String type);
|
||||
|
||||
void giveCoin(String user_id,String coin);
|
||||
|
||||
void relationCard(String user_id);
|
||||
|
||||
void topRelationCard(String id);
|
||||
void deleteRelationCard(String id);
|
||||
|
||||
void clearUserCharm(String roomId,String userId);
|
||||
|
||||
void applyPit(String roomId,String pitNumber);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.RecordSection;
|
||||
import com.xscm.moduleutil.bean.SearchAll;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public final class SearchContacts {
|
||||
|
||||
public interface View extends IView<Activity> {
|
||||
void setSearchHistory(List<String> data);
|
||||
|
||||
void setSearch(SearchAll data);
|
||||
|
||||
void setFuzzyQuery(List<RecordSection> data);
|
||||
|
||||
void followUserSuccess(int type, int postion);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public interface ISearchPre extends IPresenter {
|
||||
void getSearchHistory();
|
||||
|
||||
void saveSearchHistory(String keyWord);
|
||||
|
||||
void deleteSearchHistory();
|
||||
|
||||
void search(String keyWord);
|
||||
|
||||
void fuzzyQuery(String keyWord);
|
||||
|
||||
void followUser(String userId, int type, int postion);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.PkSwTokenBean;
|
||||
import com.xscm.moduleutil.bean.UserOnlineStatusBean;
|
||||
import com.xscm.moduleutil.bean.room.RoomInfoResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SingSongContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
void applyPit();
|
||||
void setMutePit(String pitNumber, String is_mute);
|
||||
void setLockPit(String pitNumber, String is_lock);
|
||||
|
||||
void postRoomInfo(RoomInfoResp resp);
|
||||
void postRoomInfoPk(RoomInfoResp resp);
|
||||
void postRoomInfoUp(RoomInfoResp resp);
|
||||
|
||||
void endPk();
|
||||
|
||||
void userOnlineStatus(List<UserOnlineStatusBean> list);
|
||||
|
||||
void postAgora(PkSwTokenBean pkSwTokenBean);
|
||||
}
|
||||
|
||||
public interface IEmotionRoomPre extends IPresenter {
|
||||
void applyPit(String roomId, String pitNumber);
|
||||
|
||||
void setMutePit(String roomId, String pitNumber,String is_mute);//禁麦
|
||||
|
||||
void setLockPit(String roomId, String pitNumber, String is_lock);
|
||||
|
||||
void postRoomInfo(String roomId,String number,int type);
|
||||
|
||||
void endPk(String pk_id,String type,String user_id);
|
||||
void userOnlineStatus(String userId, String roomid);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.GiftUserWallBean;
|
||||
|
||||
public final class UserGiftWallConacts {
|
||||
|
||||
|
||||
public interface View extends IView<Activity> {
|
||||
void setGiftWall(GiftUserWallBean data);
|
||||
}
|
||||
|
||||
|
||||
public interface IUserGiftWallPre extends IPresenter {
|
||||
void giftWall(String userId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.BannerModel;
|
||||
import com.xscm.moduleutil.bean.RoomTypeModel;
|
||||
import com.xscm.moduleutil.bean.TopRoom;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public final class VoiceCategoryContacts {
|
||||
|
||||
|
||||
public interface View extends IView<Activity> {
|
||||
void setCategories(List<RoomTypeModel> list);
|
||||
|
||||
|
||||
void setBanners(List<BannerModel> bannerModels);
|
||||
|
||||
void setRoomId(String roomId);
|
||||
|
||||
void setTopRoom(List<TopRoom> topRooms,int type);
|
||||
|
||||
void finishRefreshLoadMore();
|
||||
}
|
||||
|
||||
public interface IIndexCategoryPre extends IPresenter {
|
||||
void getCategories();
|
||||
|
||||
void getMediaRoom(String type);
|
||||
|
||||
void getCarousels(int type, int page,String page_limit,String is_top,String label_id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.ActivitiesPermission;
|
||||
|
||||
|
||||
public final class VoiceContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
|
||||
// void setBanners(List<BannerResp> list);
|
||||
|
||||
void hideRecommend(boolean hideRecommend,boolean hideGame);
|
||||
void activitiesPermissionSuccess(ActivitiesPermission activitiesPermission);
|
||||
|
||||
}
|
||||
|
||||
public interface IIndexPre extends IPresenter {
|
||||
|
||||
void getBanners();
|
||||
|
||||
void getNameAuthResult(int type);
|
||||
|
||||
void activitiesPermission();//活动弹框权限
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.room.RoomApplyListBean;
|
||||
|
||||
public class WheatContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
void roomApplyListBean(RoomApplyListBean roomApplyListBeans);
|
||||
void clearApply();
|
||||
void agreePit();
|
||||
void applyPit();
|
||||
|
||||
void giveGift();
|
||||
}
|
||||
|
||||
public interface IRoomPre extends IPresenter {
|
||||
void roomApplyListBean(String roomId);
|
||||
|
||||
void clearApply(String roomId);//清空申请上面列表
|
||||
|
||||
void agreePit(String roomId,String userId);//同意上麦
|
||||
|
||||
void refusePit(String roomId,String userId);//拒绝上麦
|
||||
|
||||
void helpApply(String roomId,String userId);
|
||||
|
||||
void applyPit(String roomId, String pitNumber);
|
||||
|
||||
void roomGift(String room_id, String gift_id, String gift_num, String to_uid, String type, String pit_number);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,709 @@
|
||||
package com.xscm.modulemain.activity.room.fragment;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.os.CountDownTimer;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.blankj.utilcode.util.GsonUtils;
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.tencent.imsdk.v2.V2TIMManager;
|
||||
import com.tencent.imsdk.v2.V2TIMMessage;
|
||||
import com.tencent.imsdk.v2.V2TIMSendCallback;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.activity.room.activity.RoomActivity;
|
||||
import com.xscm.modulemain.activity.room.contacts.ChatRoomContacts;
|
||||
import com.xscm.modulemain.activity.room.presenter.ChatRoomPresenter;
|
||||
import com.xscm.modulemain.adapter.EaseChatAdapter;
|
||||
import com.xscm.modulemain.databinding.RoomFragementTransEaseChatBinding;
|
||||
import com.xscm.modulemain.dialog.RoomUserInfoFragment;
|
||||
import com.xscm.moduleutil.base.BaseMvpFragment;
|
||||
import com.xscm.moduleutil.bean.RoomInputEvent;
|
||||
import com.xscm.moduleutil.bean.RoomMessageEvent;
|
||||
import com.xscm.moduleutil.bean.RoomSettingEvent;
|
||||
import com.xscm.moduleutil.bean.UserInfo;
|
||||
import com.xscm.moduleutil.bean.room.Children;
|
||||
import com.xscm.moduleutil.bean.room.EMMessageInfo;
|
||||
import com.xscm.moduleutil.bean.room.EmotionDeatils;
|
||||
import com.xscm.moduleutil.bean.room.RoomInfoResp;
|
||||
import com.xscm.moduleutil.bean.room.RoomUserBean;
|
||||
import com.xscm.moduleutil.event.RoomJoinMountModel;
|
||||
import com.xscm.moduleutil.event.RoomTaskEvent;
|
||||
import com.xscm.moduleutil.listener.MessageListenerSingleton;
|
||||
import com.xscm.moduleutil.rtc.MusicPlayBean;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
import com.xscm.moduleutil.utils.logger.Logger;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* @author qx
|
||||
* @data 2025/6/17
|
||||
* @description: 聊天室
|
||||
*/
|
||||
public class ChatRoomFragment extends BaseMvpFragment<ChatRoomPresenter, RoomFragementTransEaseChatBinding>
|
||||
implements ChatRoomContacts.View {
|
||||
private final static String TAG = "聊天室";
|
||||
private boolean isBottom = true;
|
||||
private int count = 0;
|
||||
private RoomInfoResp roomInfoResp;
|
||||
private EaseChatAdapter easeChatAdapter;
|
||||
private String roomId;
|
||||
private MessageListenerSingleton.PublicScreenMessageListener messageListener;
|
||||
|
||||
// 在需要的地方调用 Activity 的方法
|
||||
public void someMethod() {
|
||||
easeChatAdapter.clearData();
|
||||
}
|
||||
|
||||
public ChatRoomFragment(){}
|
||||
public ChatRoomFragment(RoomInfoResp resp){
|
||||
roomInfoResp = resp;
|
||||
|
||||
roomId = resp.getRoom_info().getRoom_id();
|
||||
}
|
||||
|
||||
public static ChatRoomFragment newInstance(RoomInfoResp resp) {
|
||||
return new ChatRoomFragment(resp);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ChatRoomPresenter bindPresenter() {
|
||||
return new ChatRoomPresenter(this, getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
onFragmentShowDestroy();
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
public void onFragmentShowDestroy() {
|
||||
if (messageListener != null) {
|
||||
LogUtils.e("移除监听器");
|
||||
MessageListenerSingleton.getInstance().removePublicScreenMessageListener(messageListener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
// 确保适配器已初始化
|
||||
if (easeChatAdapter == null) {
|
||||
initChatAdapter();
|
||||
}
|
||||
if (easeChatAdapter != null) {
|
||||
easeChatAdapter.clearData();
|
||||
}
|
||||
this.roomId = roomInfoResp.getRoom_info().getRoom_id();
|
||||
|
||||
RoomMessageEvent.T t = new RoomMessageEvent.T();
|
||||
t.setText("羽声严禁未成年人进行直播或打赏,官方将24小时在线巡查。我们提倡绿色直播,直播间严禁出现涉政、涉恐、涉黄、涉赌等违法违规内容,严禁宣传封建迷信、宗教极端思想、出现低俗色情、吸烟酗酒等内容,严禁违反社会主义核心价值观、践踏社会道德底线、诱导打赏、低俗 PK 、买卖金币等行为,请大家共同遵守、监督并及时举报。请勿相信各类刷钻、购买礼包、游戏币及电商贩卖等非官方广告信息,谨防网络诈骗。");
|
||||
// 加入群组成功
|
||||
handleRoomMessage(new RoomMessageEvent(1000, roomId, t));
|
||||
onChatRoomViewCreation();
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录聊天室
|
||||
*/
|
||||
public void onChatRoomViewCreation() {
|
||||
// 先移除旧的监听器
|
||||
if (messageListener != null) {
|
||||
MessageListenerSingleton.getInstance().removePublicScreenMessageListener(messageListener);
|
||||
messageListener = null;
|
||||
}
|
||||
// 设置消息监听器
|
||||
setupMessageListener();
|
||||
|
||||
// 检查是否有缓存的消息需要处理
|
||||
checkAndProcessCachedMessages();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置消息监听器
|
||||
*/
|
||||
private void setupMessageListener() {
|
||||
// 创建并添加监听器
|
||||
messageListener = message -> {
|
||||
// 确保在主线程更新 UI
|
||||
if (getActivity() != null) {
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
handleRoomMessage(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
MessageListenerSingleton.getInstance().addPublicScreenMessageListener(messageListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查并处理缓存的消息
|
||||
*/
|
||||
private void checkAndProcessCachedMessages() {
|
||||
if (roomId == null || roomId.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 延迟一小段时间,确保监听器已注册
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// 获取并处理缓存的消息
|
||||
List<RoomMessageEvent> cachedMessages = MessageListenerSingleton.getInstance().getAndClearCachedMessages(roomId);
|
||||
if (!cachedMessages.isEmpty()) {
|
||||
LogUtils.d("PublicScreenEaseChatFragment", "处理缓存消息数量: " + cachedMessages.size());
|
||||
for (RoomMessageEvent message : cachedMessages) {
|
||||
handleRoomMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 300); // 延迟300ms确保监听器已注册
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void initListener() {
|
||||
mBinding.recycleViewPublic.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
|
||||
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
|
||||
LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
|
||||
//屏幕中最后一个可见子项的position
|
||||
int lastVisibleItemPosition = layoutManager.findLastVisibleItemPosition();
|
||||
//当前屏幕所看到的子项个数
|
||||
int visibleItemCount = layoutManager.getChildCount();
|
||||
//当前RecyclerView的所有子项个数
|
||||
int totalItemCount = layoutManager.getItemCount();
|
||||
//RecyclerView的滑动状态
|
||||
if (visibleItemCount > 0 && lastVisibleItemPosition == totalItemCount - 1) {
|
||||
if (mBinding.tvCount != null) {
|
||||
mBinding.tvCount.setVisibility(View.GONE);
|
||||
}
|
||||
isBottom = true;
|
||||
count = 0;
|
||||
} else {
|
||||
isBottom = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void upRoomInfo(RoomInfoResp resp){
|
||||
if (resp == null)
|
||||
return;
|
||||
roomInfoResp = resp;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
|
||||
mBinding.recycleViewPublic.setLayoutManager(linearLayoutManager);
|
||||
initChatAdapter();
|
||||
easeChatAdapter.setOnItemClickListener((adapter, view, position) -> {
|
||||
EMMessageInfo item = easeChatAdapter.getItem(position);
|
||||
RoomMessageEvent emMessage = item.getEmMessage();
|
||||
if (emMessage.getText().getFromUserInfo() != null) {
|
||||
RoomUserInfoFragment.show(roomInfoResp.getRoom_info().getRoom_id(), emMessage.getText().getFromUserInfo().getUser_id() != 0 ? emMessage.getText().getFromUserInfo().getUser_id() + "" : emMessage.getText().getFromUserInfo().getId() + "", emMessage.getText().getFromUserInfo().getPit_number(), getHostUser(roomInfoResp.getUser_info()), false, 5, isNumberWhether(), getChildFragmentManager());
|
||||
}
|
||||
|
||||
});
|
||||
// //判断是否开启公屏
|
||||
setUpPublicScreen();
|
||||
mBinding.tvCount.setOnClickListener(this::onClick);
|
||||
mBinding.tvTabAll.setOnClickListener(this::onClick);
|
||||
mBinding.tvTabUser.setOnClickListener(this::onClick);
|
||||
mBinding.tvTabSystem.setOnClickListener(this::onClick);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化聊天适配器
|
||||
*/
|
||||
private void initChatAdapter() {
|
||||
if (easeChatAdapter == null) {
|
||||
easeChatAdapter = new EaseChatAdapter();
|
||||
// 添加空值检查,确保mBinding和recycleViewPublic都不为null
|
||||
if (mBinding != null) {
|
||||
mBinding.recycleViewPublic.setAdapter(easeChatAdapter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int isNumberWhether() {
|
||||
if (roomInfoResp.getUser_info().getPit_number() == 9) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int getHostUser(RoomUserBean item) {
|
||||
if (item.getPit_number() != 0) {
|
||||
if (item.getIs_room_owner() == 1) {
|
||||
return 1;
|
||||
} else if (item.getIs_management() == 1) {
|
||||
return 2;
|
||||
} else if (item.getIs_host() == 1) {
|
||||
return 3;
|
||||
} else {
|
||||
return 4;
|
||||
}
|
||||
} else {
|
||||
if (item.getIs_room_owner() == 1) {
|
||||
return 1;
|
||||
} else if (item.getIs_management() == 1) {
|
||||
return 2;
|
||||
} else if (item.getIs_host() == 1) {
|
||||
return 3;
|
||||
}
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void setUpPublicScreen() {
|
||||
//如果有数据或者recycle view有item view就删除;否则程序崩溃,找不到item
|
||||
if (mBinding.recycleViewPublic.getChildCount() > 0) {
|
||||
mBinding.recycleViewPublic.removeAllViews();
|
||||
}
|
||||
mBinding.recycleViewPublic.setVisibility(View.VISIBLE);//开启消息列表
|
||||
mBinding.llHeadTab.setVisibility(View.GONE);
|
||||
mBinding.tvClose.setVisibility(View.GONE);
|
||||
count = 0;//未读数0
|
||||
isBottom = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.room_fragement_trans_ease_chat;
|
||||
}
|
||||
|
||||
|
||||
public void onClick(View view) {
|
||||
int view_id = view.getId();
|
||||
|
||||
if (view_id == R.id.tv_tab_all) {
|
||||
easeChatAdapter.setShowType(EaseChatAdapter.SHOW_TYPE_ALL);
|
||||
mBinding.tvTabAll.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
mBinding.tvTabAll.setTextSize(14);
|
||||
|
||||
mBinding.tvTabUser.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
mBinding.tvTabSystem.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
mBinding.tvTabSystem.setBackgroundResource(0);
|
||||
mBinding.tvTabUser.setBackgroundResource(0);
|
||||
mBinding.tvTabUser.setTextSize(12);
|
||||
mBinding.tvTabSystem.setTextSize(12);
|
||||
|
||||
} else if (view_id == R.id.tv_tab_user) {
|
||||
easeChatAdapter.setShowType(EaseChatAdapter.SHOW_TYPE_USER);
|
||||
mBinding.tvTabUser.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
mBinding.tvTabUser.setTextSize(14);
|
||||
|
||||
mBinding.tvTabAll.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
mBinding.tvTabSystem.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
mBinding.tvTabSystem.setBackgroundResource(0);
|
||||
mBinding.tvTabAll.setBackgroundResource(0);
|
||||
mBinding.tvTabAll.setTextSize(12);
|
||||
mBinding.tvTabSystem.setTextSize(12);
|
||||
} else if (view_id == R.id.tv_tab_system) {
|
||||
easeChatAdapter.setShowType(EaseChatAdapter.SHOW_TYPE_SYSTEM);
|
||||
|
||||
mBinding.tvTabSystem.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
mBinding.tvTabSystem.setTextSize(14);
|
||||
|
||||
mBinding.tvTabAll.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
mBinding.tvTabUser.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
mBinding.tvTabUser.setBackgroundResource(0);
|
||||
mBinding.tvTabAll.setBackgroundResource(0);
|
||||
mBinding.tvTabAll.setTextSize(12);
|
||||
mBinding.tvTabUser.setTextSize(12);
|
||||
} else if (view_id == R.id.tv_count) {
|
||||
mBinding.recycleViewPublic.scrollToPosition(easeChatAdapter.getItemCount() - 1);
|
||||
mBinding.tvCount.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
}
|
||||
public void fasong(RoomInputEvent roomInputEvent) {
|
||||
String message = roomInputEvent.text;
|
||||
RoomMessageEvent.T t = new RoomMessageEvent.T();
|
||||
t.setText(message);
|
||||
t.setFromUserInfo(SpUtil.getUserInfo());
|
||||
RoomMessageEvent roomMessageEvent = new RoomMessageEvent(1, roomInfoResp.getRoom_info().getRoom_id(), t);
|
||||
handleRoomMessage(roomMessageEvent);
|
||||
String json = GsonUtils.toJson(roomMessageEvent);
|
||||
// 转换为 byte[]
|
||||
byte[] binaryData = json.getBytes(StandardCharsets.UTF_8);
|
||||
// 创建自定义消息
|
||||
V2TIMMessage v2TIMMessage = V2TIMManager.getMessageManager().createCustomMessage(binaryData);
|
||||
// 发送消息
|
||||
V2TIMManager.getMessageManager().sendMessage(v2TIMMessage, null, "room" + roomInfoResp.getRoom_info().getRoom_id(), V2TIMMessage.V2TIM_PRIORITY_NORMAL, false, null, new V2TIMSendCallback<V2TIMMessage>() {
|
||||
@Override
|
||||
public void onProgress(int progress) {
|
||||
// 自定义消息不会回调进度
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(V2TIMMessage message) {
|
||||
// 发送群聊自定义消息成功
|
||||
EventBus.getDefault().post(new RoomTaskEvent());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
// 发送群聊自定义消息失败
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void sendChatEmoji(EmotionDeatils emotionDeatils) {
|
||||
EmotionDeatils event = new EmotionDeatils();
|
||||
if (emotionDeatils != null && emotionDeatils.getChildren() != null && !emotionDeatils.getChildren().isEmpty() && emotionDeatils.getChildren().size() > 0) {
|
||||
int position = new Random().nextInt(emotionDeatils.getChildren().size());
|
||||
Children children = emotionDeatils.getChildren().get(position);
|
||||
event.setImage(children.getImage());
|
||||
event.setAnimate_image(emotionDeatils.getAnimate_image());
|
||||
} else {
|
||||
event = emotionDeatils;
|
||||
}
|
||||
RoomMessageEvent roomMessageEvent = new RoomMessageEvent();
|
||||
roomMessageEvent.setRoomId(roomId);
|
||||
roomMessageEvent.setMsgType(2);//这是表情类型,1:单发文本消息 2:单发表情消息
|
||||
UserInfo userInfo = SpUtil.getUserInfo();
|
||||
RoomMessageEvent.T t = new RoomMessageEvent.T();
|
||||
t.setFromUserInfo(userInfo);
|
||||
t.setEmoji(event);
|
||||
roomMessageEvent.setText(t);
|
||||
handleRoomMessage(roomMessageEvent);
|
||||
String json = GsonUtils.toJson(roomMessageEvent);
|
||||
// 转换为 byte[]
|
||||
byte[] binaryData = json.getBytes(StandardCharsets.UTF_8);
|
||||
// 创建自定义消息
|
||||
V2TIMMessage v2TIMMessage = V2TIMManager.getMessageManager().createCustomMessage(binaryData);
|
||||
// 发送消息
|
||||
V2TIMManager.getMessageManager().sendMessage(v2TIMMessage, null, "room" + roomId, V2TIMMessage.V2TIM_PRIORITY_NORMAL, false, null, new V2TIMSendCallback<V2TIMMessage>() {
|
||||
@Override
|
||||
public void onProgress(int progress) {
|
||||
// 自定义消息不会回调进度
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(V2TIMMessage message) {
|
||||
// 发送群聊自定义消息成功
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
// 发送群聊自定义消息失败
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void handleRoomMessage(RoomMessageEvent message) {
|
||||
if (message == null) return;
|
||||
|
||||
if (easeChatAdapter == null) {
|
||||
easeChatAdapter = new EaseChatAdapter();
|
||||
}
|
||||
|
||||
if (message.getRoomId() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (roomId == null ||(!message.getRoomId().contains(roomId)&&message.getMsgType()!=125)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 使用Handler将消息处理放到消息队列中,避免阻塞
|
||||
if (messageHandler.hasMessages(MSG_HANDLE_ROOM_MESSAGE)) {
|
||||
// 如果队列中已有待处理消息,将当前消息加入队列
|
||||
Message msg = Message.obtain();
|
||||
msg.what = MSG_HANDLE_ROOM_MESSAGE;
|
||||
msg.obj = message;
|
||||
messageHandler.sendMessage(msg);
|
||||
} else {
|
||||
// 立即处理第一条消息
|
||||
processRoomMessage(message);
|
||||
// 标记有待处理消息
|
||||
messageHandler.sendEmptyMessageDelayed(MSG_HANDLE_ROOM_MESSAGE, 100);
|
||||
}
|
||||
}
|
||||
|
||||
private static final int MSG_HANDLE_ROOM_MESSAGE = 1001;
|
||||
private final Handler messageHandler = new Handler(Looper.getMainLooper()) {
|
||||
private List<RoomMessageEvent> messageQueue = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void handleMessage(@NonNull Message msg) {
|
||||
if (msg.what == MSG_HANDLE_ROOM_MESSAGE) {
|
||||
if (!messageQueue.isEmpty()) {
|
||||
// 批量处理消息
|
||||
processBatchMessages(messageQueue);
|
||||
messageQueue.clear();
|
||||
} else if (msg.obj instanceof RoomMessageEvent) {
|
||||
// 处理单条消息
|
||||
processRoomMessage((RoomMessageEvent) msg.obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private void processBatchMessages(List<RoomMessageEvent> messages) {
|
||||
if (messages.isEmpty() || easeChatAdapter == null) return;
|
||||
|
||||
List<EMMessageInfo> messageInfos = new ArrayList<>();
|
||||
for (RoomMessageEvent message : messages) {
|
||||
EMMessageInfo info = createMessageInfoIfNeeded(message);
|
||||
if (info != null) {
|
||||
messageInfos.add(info);
|
||||
}
|
||||
if (getActivity() instanceof RoomActivity) {
|
||||
((RoomActivity) getActivity()).roomInfoEvent(message);
|
||||
}
|
||||
}
|
||||
|
||||
if (!messageInfos.isEmpty()) {
|
||||
easeChatAdapter.addData(messageInfos);
|
||||
scrollToBottomIfNeed();
|
||||
}
|
||||
}
|
||||
|
||||
private void processRoomMessage(RoomMessageEvent message) {
|
||||
if (message == null) return;
|
||||
|
||||
int msgType = message.getMsgType();
|
||||
RoomMessageEvent.T text = message.getText();
|
||||
|
||||
switch (msgType) {
|
||||
case 1001:
|
||||
if (text != null) {
|
||||
RoomJoinMountModel roomJoinMountModel = new RoomJoinMountModel(
|
||||
message.getRoomId(), text.getJia_jia(), 2);
|
||||
EventBus.getDefault().post(roomJoinMountModel);
|
||||
}
|
||||
postAndAddMessage(message);
|
||||
break;
|
||||
case 123:
|
||||
easeChatAdapter.clearData();
|
||||
postAndAddMessage(message);
|
||||
break;
|
||||
case 1002:
|
||||
case 1012:
|
||||
case 1011:
|
||||
case 1014:
|
||||
case 1013:
|
||||
case 1026:
|
||||
case 1015:
|
||||
case 1021:
|
||||
case 1034:
|
||||
case 1035:
|
||||
case 1050:
|
||||
case 1054:
|
||||
case 1051:
|
||||
case 1052:
|
||||
case 1053:
|
||||
case 1055:
|
||||
case 1056:
|
||||
case 1057:
|
||||
case 1059:
|
||||
case 1060:
|
||||
case 1061:
|
||||
case 1025:
|
||||
case 1058:
|
||||
case 125:
|
||||
if (getActivity() instanceof RoomActivity) {
|
||||
((RoomActivity) getActivity()).roomInfoEvent(message);
|
||||
}
|
||||
break;
|
||||
|
||||
case 124:
|
||||
if (text != null && text.getText() != null) {
|
||||
try {
|
||||
RoomMessageEvent.text parsedText = GsonUtils.fromJson(
|
||||
text.getText(), RoomMessageEvent.text.class);
|
||||
if (parsedText != null) {
|
||||
MusicPlayBean musicPlayBean = new MusicPlayBean();
|
||||
musicPlayBean.setPosition(parsedText.getPosition());
|
||||
EventBus.getDefault().post(musicPlayBean);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("解析音乐播放消息失败", e);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 1007:
|
||||
case 1018:
|
||||
case 1006:
|
||||
case 1017:
|
||||
case 1016:
|
||||
if (text != null && text.getFromUserInfo() != null &&
|
||||
text.getFromUserInfo().getUser_id() == SpUtil.getUserId()) {
|
||||
EMMessageInfo info = new EMMessageInfo(message);
|
||||
easeChatAdapter.addData(info);
|
||||
scrollToBottomIfNeed();
|
||||
}
|
||||
if (getActivity() instanceof RoomActivity) {
|
||||
((RoomActivity) getActivity()).roomInfoEvent(message);
|
||||
}
|
||||
break;
|
||||
|
||||
case 1003:
|
||||
case 1004:
|
||||
case 1000:
|
||||
case 1:
|
||||
case 2:
|
||||
case 1030:
|
||||
case 1033:
|
||||
case 1032:
|
||||
case 1039:
|
||||
postAndAddMessage(message);
|
||||
break;
|
||||
|
||||
case 1038:
|
||||
addSingleMessage(message);
|
||||
break;
|
||||
|
||||
case 1049:
|
||||
postAndAddMessage(message);
|
||||
break;
|
||||
|
||||
case 1005:
|
||||
if (getActivity() instanceof RoomActivity) {
|
||||
((RoomActivity) getActivity()).roomInfoEvent(message);
|
||||
}
|
||||
if (text != null && text.getText() != null) {
|
||||
addSingleMessage(message);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (getActivity() instanceof RoomActivity) {
|
||||
((RoomActivity) getActivity()).roomInfoEvent(message);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private EMMessageInfo createMessageInfoIfNeeded(RoomMessageEvent message) {
|
||||
int msgType = message.getMsgType();
|
||||
RoomMessageEvent.T text = message.getText();
|
||||
if (text.getIs_pk()!=null&&text.getIs_pk().equals("1")){
|
||||
return null;
|
||||
}
|
||||
|
||||
switch (msgType) {
|
||||
case 1001:
|
||||
case 1002:
|
||||
case 123:
|
||||
case 1003:
|
||||
case 1004:
|
||||
case 1000:
|
||||
case 1:
|
||||
case 2:
|
||||
case 1030:
|
||||
case 1033:
|
||||
case 1032:
|
||||
case 1039:
|
||||
case 1049:
|
||||
return new EMMessageInfo(message);
|
||||
|
||||
case 1005:
|
||||
if (text.getText() != null) {
|
||||
return new EMMessageInfo(message);
|
||||
}
|
||||
break;
|
||||
|
||||
case 1038:
|
||||
return new EMMessageInfo(message);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void addSingleMessage(RoomMessageEvent message) {
|
||||
if (message.getText().getIs_pk()!=null&&message.getText().getIs_pk().equals("1")){
|
||||
return;
|
||||
}
|
||||
if (easeChatAdapter != null) {
|
||||
if (message.getMsgType() == 1049) {
|
||||
if (message.getText().getStep() != 3) {
|
||||
easeChatAdapter.addData(new EMMessageInfo(message));
|
||||
scrollToBottomIfNeed();
|
||||
}
|
||||
} else {
|
||||
easeChatAdapter.addData(new EMMessageInfo(message));
|
||||
scrollToBottomIfNeed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void postAndAddMessage(RoomMessageEvent message) {
|
||||
if (getActivity() instanceof RoomActivity) {
|
||||
((RoomActivity) getActivity()).roomInfoEvent(message);
|
||||
}
|
||||
addSingleMessage(message);
|
||||
}
|
||||
|
||||
|
||||
// 优化 scrollToBottomIfNeed 方法
|
||||
private void scrollToBottomIfNeed() {
|
||||
if (isBottom && easeChatAdapter != null) {
|
||||
int itemCount = easeChatAdapter.getItemCount();
|
||||
if (itemCount > 0) {
|
||||
mBinding.recycleViewPublic.scrollToPosition(itemCount - 1);
|
||||
}
|
||||
} else {
|
||||
count++;
|
||||
mBinding.tvCount.setText(count + "条新消息");
|
||||
mBinding.tvCount.setVisibility(View.VISIBLE);
|
||||
|
||||
// 当未读消息过多时,限制数量显示
|
||||
if (count > 99) {
|
||||
mBinding.tvCount.setText("99+条新消息");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void roomJoinMount(RoomSettingEvent roomSetting) {
|
||||
if (roomSetting == null) {
|
||||
easeChatAdapter.clearData();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 房间信息
|
||||
*
|
||||
* @param resp
|
||||
*/
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void roomInfo(RoomInfoResp resp) {
|
||||
this.roomInfoResp = resp;
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,194 @@
|
||||
package com.xscm.modulemain.activity.room.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.adapter.HotAdapter;
|
||||
import com.xscm.modulemain.activity.room.contacts.HotListContacts;
|
||||
import com.xscm.modulemain.databinding.FragmentHotListBinding;
|
||||
import com.xscm.modulemain.activity.room.presenter.HotListPresenter;
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
|
||||
import com.xscm.modulemain.manager.RoomManager;
|
||||
import com.xscm.moduleutil.base.BaseMvpFragment;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.bean.HomeBean;
|
||||
import com.xscm.moduleutil.bean.TopRoom;
|
||||
import com.xscm.moduleutil.bean.room.RoomInfoResp;
|
||||
import com.xscm.moduleutil.listener.MessageListenerSingleton;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.utils.ClickUtils;
|
||||
import com.xscm.moduleutil.utils.TimeUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class HotListFragment extends BaseMvpFragment<HotListPresenter, FragmentHotListBinding> implements HotListContacts.View {
|
||||
private String label_id;
|
||||
private HotAdapter mAdapter;
|
||||
private String tag;
|
||||
private int page;
|
||||
|
||||
private VoiceCategoryFragment voiceCategoryFragment;
|
||||
public HotListFragment(){}
|
||||
public HotListFragment(VoiceCategoryFragment voiceCategoryFragment){
|
||||
this.voiceCategoryFragment = voiceCategoryFragment;
|
||||
}
|
||||
public static HotListFragment newInstance(VoiceCategoryFragment voiceCategoryFragment, String type, String tag) {
|
||||
Bundle args = new Bundle();
|
||||
args.putString("label_id", type);
|
||||
args.putString("tag", tag);
|
||||
HotListFragment fragment = new HotListFragment(voiceCategoryFragment);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initArgs(Bundle arguments) {
|
||||
super.initArgs(arguments);
|
||||
label_id = arguments.getString("label_id");
|
||||
tag = arguments.getString("tag");
|
||||
page = 1; // 重置page
|
||||
}
|
||||
|
||||
@Override
|
||||
protected HotListPresenter bindPresenter() {
|
||||
return new HotListPresenter(this, getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
MvpPre.getRoomList(2, "1", "20", "1", label_id);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
if (tag.equals(VoiceCategoryFragment.TYPE_HOT)) {
|
||||
mBinding.tvHot.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mBinding.tvHot.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
mAdapter = new HotAdapter(null);
|
||||
// mAdapter.openLoadAnimation(BaseQuickAdapter.SCALEIN);
|
||||
mBinding.recycleView.setAdapter(mAdapter);
|
||||
GridLayoutManager gridLayoutManager = new GridLayoutManager(getActivity(), 2);
|
||||
gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
|
||||
@Override
|
||||
public int getSpanSize(int position) {
|
||||
switch (position) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
return 1;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
});
|
||||
mBinding.recycleView.setLayoutManager(gridLayoutManager);
|
||||
mBinding.smartRefreshLayout.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
|
||||
@Override
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
page++;
|
||||
MvpPre.getRoomList(2, page+"", "20", "1", label_id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
page = 1;
|
||||
mAdapter.setNewData(new ArrayList<>());
|
||||
MvpPre.getRoomList(2, page+"", "20", "1", label_id);
|
||||
}
|
||||
});
|
||||
|
||||
mAdapter.setOnRoomClickListener((room, position) -> {
|
||||
if ( ClickUtils.isFastDoubleClick()){
|
||||
return;
|
||||
}
|
||||
voiceCategoryFragment.showLoading();
|
||||
// 添加索引有效性检查
|
||||
if (position < 0 || position >= mAdapter.getData().size()) {
|
||||
return;
|
||||
}
|
||||
TopRoom item = mAdapter.getItem(position);
|
||||
if (item != null ) {
|
||||
RoomManager.getInstance().fetchRoomDataAndEnter(getActivity(), item.getRoom_id(), "",null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fragment_hot_list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void roomList(List<TopRoom> data, int type) {
|
||||
if (data != null && !data.isEmpty()) {
|
||||
if (page == 1) {
|
||||
mAdapter.setNewData(data); // 刷新时替换数据
|
||||
} else {
|
||||
// 检查是否有重复数据
|
||||
boolean hasDuplicate = false;
|
||||
List<TopRoom> currentData = mAdapter.getData();
|
||||
if (!currentData.isEmpty() && !data.isEmpty()) {
|
||||
// 检查第一条数据是否已经存在
|
||||
TopRoom firstNewData = data.get(0);
|
||||
for (TopRoom item : currentData) {
|
||||
if (item.getRoom_id().equals(firstNewData.getRoom_id())) {
|
||||
hasDuplicate = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasDuplicate) {
|
||||
mAdapter.addData(data); // 加载更多时添加数据
|
||||
}
|
||||
}
|
||||
} else if (page == 1) {
|
||||
// 如果是刷新且没有数据,清空列表
|
||||
mAdapter.setNewData(new ArrayList<>());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishRefreshLoadMore() {
|
||||
mBinding.smartRefreshLayout.finishRefresh();
|
||||
mBinding.smartRefreshLayout.finishLoadMore();
|
||||
CommonAppContext.getInstance().isRoomJoininj=false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMoreRoomList(List<HomeBean> data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void roomInfo(RoomInfoResp resp) {
|
||||
ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("form", "首页热门列表").withSerializable("roomInfo", resp).withString("roomId", resp.getRoom_info().getRoom_id()).navigation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showPasswordDialog() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterFail() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,253 @@
|
||||
package com.xscm.modulemain.activity.room.fragment;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.databinding.FragmentMuiscSongBinding;
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
|
||||
import com.xscm.modulemain.activity.room.contacts.RequestContacts;
|
||||
import com.xscm.modulemain.activity.room.presenter.RequestPresenter;
|
||||
import com.xscm.moduleutil.base.BaseMvpFragment;
|
||||
import com.xscm.moduleutil.bean.MusicSongBean;
|
||||
import com.xscm.moduleutil.bean.SongMusicBean;
|
||||
import com.xscm.moduleutil.bean.room.RoomInfoResp;
|
||||
import com.xscm.moduleutil.color.ThemeableDrawableUtils;
|
||||
import com.xscm.moduleutil.rtc.AgoraManager;
|
||||
import com.xscm.moduleutil.utils.ColorManager;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
import com.xscm.moduleutil.utils.TimeUtils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.agora.musiccontentcenter.Music;
|
||||
|
||||
/**
|
||||
* @author qx
|
||||
* @data 2025/6/19
|
||||
* @description: 点唱已点歌曲
|
||||
*/
|
||||
public class MusicSongListFragment extends BaseMvpFragment<RequestPresenter, FragmentMuiscSongBinding> implements RequestContacts.View {
|
||||
private String roomId;
|
||||
private RoomInfoResp roomInfoResp;
|
||||
BaseQuickAdapter<MusicSongBean, BaseViewHolder> adapter;
|
||||
private int page = 1;
|
||||
int status;
|
||||
|
||||
@Override
|
||||
public void songList(List<MusicSongBean> musicSongBeans) {
|
||||
|
||||
|
||||
if (roomInfoResp.getUser_info().getUser_id().equals(SpUtil.getUserId() + "") && roomInfoResp.getUser_info().getPit_number() == 9) {
|
||||
status = 1;
|
||||
}
|
||||
if (musicSongBeans != null) {
|
||||
for (MusicSongBean musicSongBean : musicSongBeans) {
|
||||
musicSongBean.setIs_hot(status);
|
||||
}
|
||||
}
|
||||
|
||||
// if (page==1){
|
||||
adapter.setNewData(musicSongBeans);
|
||||
|
||||
// }else {
|
||||
// adapter.addData(musicSongBeans);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void upSong(String S) {
|
||||
ToastUtils.showShort(S);
|
||||
MvpPre.songList(roomId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void song(List<SongMusicBean> music) {
|
||||
com.hjq.toast.ToastUtils.show("操作成功");
|
||||
}
|
||||
|
||||
public interface OnRequestFragmentListener {
|
||||
void onCloseDialog();
|
||||
}
|
||||
|
||||
private OnRequestFragmentListener listener;
|
||||
|
||||
// 绑定监听器
|
||||
public void setOnRequestFragmentListener(OnRequestFragmentListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public static MusicSongListFragment newInstance(String roomId, RoomInfoResp roomInfoResp, int type) {
|
||||
Bundle args = new Bundle();
|
||||
MusicSongListFragment fragment = new MusicSongListFragment();
|
||||
args.putString("roomId", roomId);
|
||||
args.putInt("type", type);
|
||||
args.putSerializable("roomInfoResp", roomInfoResp);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RequestPresenter bindPresenter() {
|
||||
return new RequestPresenter(this, getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
roomId = getArguments().getString("roomId");
|
||||
roomInfoResp = (RoomInfoResp) getArguments().getSerializable("roomInfoResp");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
boolean b = AgoraManager.getInstance(getContext()).isBjMusic();
|
||||
if (b) {
|
||||
List<MusicSongBean> musicSongBeans = new ArrayList<>();
|
||||
List<Music> music = AgoraManager.getInstance(getContext()).getMusicList();
|
||||
if (music != null && music.size() > 0) {
|
||||
for (int i = 0; i < music.size(); i++) {
|
||||
MusicSongBean musicSongBean = new MusicSongBean();
|
||||
musicSongBean.setSong_code(String.valueOf(music.get(i).getSongCode()));
|
||||
musicSongBean.setSong_name(music.get(i).getName());
|
||||
musicSongBean.setSinger(music.get(i).getSinger());
|
||||
musicSongBean.setPoster(music.get(i).getPoster());
|
||||
musicSongBean.setDuration(music.get(i).getDurationS() + "");
|
||||
musicSongBeans.add(musicSongBean);
|
||||
}
|
||||
adapter.setNewData(musicSongBeans);
|
||||
}
|
||||
} else {
|
||||
MvpPre.songList(roomId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
mBinding.smartRefreshLayout.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
|
||||
@Override
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
page++;
|
||||
MvpPre.songList(roomId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
page = 1;
|
||||
MvpPre.songList(roomId);
|
||||
}
|
||||
});
|
||||
|
||||
mBinding.recycleView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
|
||||
adapter = new BaseQuickAdapter<MusicSongBean, BaseViewHolder>(R.layout.item_song_list, null) {
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, MusicSongBean item) {
|
||||
|
||||
LogUtils.e("@@@", item);
|
||||
// 获取当前 item 的 position
|
||||
int position = helper.getLayoutPosition();
|
||||
ImageView muisSy = helper.getView(R.id.muis_sy);
|
||||
TextView muisPrice = helper.getView(R.id.muis_price);
|
||||
if (position == 0) {
|
||||
helper.setText(R.id.muis_price, "结束");
|
||||
|
||||
muisSy.setVisibility(View.GONE);
|
||||
} else if (position == 1) {
|
||||
|
||||
muisSy.setVisibility(View.GONE);
|
||||
muisPrice.setVisibility(View.GONE);
|
||||
} else {
|
||||
muisPrice.setVisibility(View.VISIBLE);
|
||||
helper.setText(R.id.muis_price, "置顶");
|
||||
muisSy.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
helper.setText(R.id.muis_name, item.getSong_name());
|
||||
if (item.getDuration().isEmpty()) {
|
||||
helper.setText(R.id.muis_desc, "00:00");
|
||||
} else {
|
||||
helper.setText(R.id.muis_desc, TimeUtils.formatDuration(Long.parseLong(item.getDuration()) * 1000));
|
||||
}
|
||||
helper.setText(R.id.muis_set, "\t" + item.getSinger());
|
||||
helper.setText(R.id.muis_nickname, item.getNickname());
|
||||
|
||||
ImageUtils.loadHeadCC(item.getPoster(), helper.getView(R.id.muis_avatar));
|
||||
|
||||
helper.getView(R.id.muis_price).setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
TextView textView = helper.getView(R.id.muis_price);
|
||||
if (textView.getText().toString().equals("置顶")) {
|
||||
MvpPre.upSong(item.getDid(), "2");
|
||||
} else {
|
||||
|
||||
}
|
||||
if (listener != null) {
|
||||
listener.onCloseDialog(); // 触发关闭 DialogFragment
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
helper.getView(R.id.muis_sy).setOnClickListener(v -> MvpPre.upSong(item.getDid(), "1"));
|
||||
|
||||
if (item.getIs_hot() == 1) {
|
||||
helper.setVisible(R.id.muis_sy, true);
|
||||
helper.setVisible(R.id.muis_price, true);
|
||||
} else {
|
||||
helper.setVisible(R.id.muis_sy, false);
|
||||
helper.setVisible(R.id.muis_price, false);
|
||||
}
|
||||
|
||||
TextView muis_price=helper.getView(R.id.muis_price);
|
||||
ThemeableDrawableUtils.setThemeableRoundedBackground(muis_price, ColorManager.getInstance().getPrimaryColorInt(), 34);
|
||||
muis_price.setTextColor(ColorManager.getInstance().getButtonColorInt());
|
||||
}
|
||||
};
|
||||
mBinding.recycleView.setAdapter(adapter);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fragment_muisc_song;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,261 @@
|
||||
package com.xscm.modulemain.activity.room.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.adapter.RankingCharmListAdapter;
|
||||
import com.xscm.modulemain.databinding.RoomRankingChildBinding;
|
||||
import com.xscm.modulemain.dialog.RoomUserInfoFragment;
|
||||
import com.xscm.modulemain.activity.room.contacts.DataListContacts;
|
||||
import com.xscm.modulemain.activity.room.presenter.DataListPresenter;
|
||||
import com.xscm.moduleutil.base.BaseMvpFragment;
|
||||
import com.xscm.moduleutil.bean.CharmRankingResp;
|
||||
import com.xscm.moduleutil.bean.room.RoomInfoResp;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
import com.xscm.moduleutil.utils.StringUtil;
|
||||
import com.xscm.moduleutil.widget.CommonEmptyView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author qx
|
||||
* @data 2025/6/10
|
||||
* @description:
|
||||
*/
|
||||
public class RankingChildFragment extends BaseMvpFragment<DataListPresenter, RoomRankingChildBinding> implements DataListContacts.View {
|
||||
|
||||
private static final String TAG = "RankingChildFragment";
|
||||
|
||||
public static final int TYPE_DATA = 1;//日榜
|
||||
private String roomId;
|
||||
private int dataType;
|
||||
private int rankType = 1;
|
||||
private RankingCharmListAdapter cAdapter;//魅力适配器
|
||||
private RankingCharmListAdapter wAdapter;//财富适配器
|
||||
private CommonEmptyView commonEmptyView;
|
||||
private RoomInfoResp roomInfoResp;
|
||||
|
||||
/**
|
||||
* newInstance 初始化fragment
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static RankingChildFragment newInstance(String roomId, int dataType, int rankType, RoomInfoResp roomInfoResp) {
|
||||
RankingChildFragment rankingChildFragment = new RankingChildFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("roomId", roomId);
|
||||
bundle.putInt("dataType", dataType);
|
||||
bundle.putInt("rankType", rankType);
|
||||
bundle.putSerializable("roomInfoResp", roomInfoResp);
|
||||
rankingChildFragment.setArguments(bundle);
|
||||
return rankingChildFragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DataListPresenter bindPresenter() {
|
||||
return new DataListPresenter(this, getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initArgs(Bundle arguments) {
|
||||
super.initArgs(arguments);
|
||||
roomId = getArguments().getString("roomId");
|
||||
dataType = getArguments().getInt("dataType");
|
||||
rankType = getArguments().getInt("rankType");
|
||||
roomInfoResp = (RoomInfoResp) getArguments().getSerializable("roomInfoResp");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
if (rankType == 1) {
|
||||
cAdapter = new RankingCharmListAdapter();
|
||||
mBinding.rankRecycleView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
mBinding.rankRecycleView.setAdapter(cAdapter);
|
||||
cAdapter.bindToRecyclerView(mBinding.rankRecycleView);
|
||||
MvpPre.getCharmListInfo(roomId, rankType + "", dataType + "", "1", "20");
|
||||
} else {
|
||||
wAdapter = new RankingCharmListAdapter();
|
||||
mBinding.rankRecycleView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
mBinding.rankRecycleView.setAdapter(wAdapter);
|
||||
wAdapter.bindToRecyclerView(mBinding.rankRecycleView);
|
||||
MvpPre.getWealthListInfo(roomId, rankType + "", dataType + "", "1", "20");
|
||||
}
|
||||
// onRefreshEvent(null);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
commonEmptyView = new CommonEmptyView(getContext());
|
||||
commonEmptyView.setEmptyText("暂无上榜");
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化监听
|
||||
*/
|
||||
@Override
|
||||
protected void initListener() {
|
||||
super.initListener();
|
||||
if (rankType == 1) {
|
||||
cAdapter.setOnItemChildClickListener((adapter, view, position) -> {
|
||||
if (view.getId() == R.id.room_item_head) {
|
||||
CharmRankingResp item = cAdapter.getItem(position);
|
||||
RoomUserInfoFragment.show(roomId,item.getUser_id(), "", getHostUser(), true, 3, 0, getChildFragmentManager());
|
||||
}
|
||||
});
|
||||
} else {
|
||||
wAdapter.setOnItemChildClickListener((adapter, view, position) -> {
|
||||
if (view.getId() == R.id.room_item_head) {
|
||||
CharmRankingResp item = wAdapter.getItem(position);
|
||||
RoomUserInfoFragment.show(roomId,item.getUser_id(), "", getHostUser(), true, 3, 0, getChildFragmentManager());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 这是判断当前用户是否是麦上房主、管理员、主持,不在主持麦的都是不同用户
|
||||
* 2025-7-31 10:42:37,新添加的要求:根据角色不同,显示不同的按钮
|
||||
* 房主不论麦上麦下,有全部权限 管理员、主持:不论麦上麦下,有部分权限 用户:只有举报拉黑权限
|
||||
* 所有的是从下往上看数据的时候,只有举报和拉黑
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private int getHostUser() {
|
||||
if (roomInfoResp.getUser_info().getPit_number() == 9) {
|
||||
if (roomInfoResp.getUser_info().getIs_room_owner() == 1) {
|
||||
return 1;
|
||||
} else if (roomInfoResp.getUser_info().getIs_management() == 1) {
|
||||
return 2;
|
||||
} else if (roomInfoResp.getUser_info().getIs_host() == 1) {
|
||||
return 3;
|
||||
} else {
|
||||
return 4;
|
||||
}
|
||||
} else {
|
||||
if (roomInfoResp.getUser_info().getIs_room_owner() == 1) {
|
||||
return 1;
|
||||
}
|
||||
if (roomInfoResp.getUser_info().getIs_management() == 1) {
|
||||
return 2;
|
||||
}
|
||||
if (roomInfoResp.getUser_info().getIs_host() == 1) {
|
||||
return 3;
|
||||
}
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
Log.d(TAG, "(Start)启动了===========================RankingChildFragment");
|
||||
return R.layout.room_ranking_child;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setNo1(CharmRankingResp listsBean) {
|
||||
ImageUtils.loadHeadCC(listsBean.getAvatar(), mBinding.roomRankTop1HeadIcon);
|
||||
mBinding.roomTop1Name.setText(listsBean.getNickname());
|
||||
mBinding.roomHeadTop1Label.setText(StringUtil.toWan2(listsBean.getTotal(), 2));
|
||||
setview(listsBean.getIcon(), mBinding.llVip1);
|
||||
mBinding.roomRankTop1HeadIcon.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
RoomUserInfoFragment.show(roomId,listsBean.getUser_id(), "", getHostUser(), false, 3, 0, getChildFragmentManager());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNo2(CharmRankingResp listsBean) {
|
||||
ImageUtils.loadHeadCC(listsBean.getAvatar(), mBinding.roomRankTop2HeadIcon);
|
||||
mBinding.roomTop2Name.setText(listsBean.getNickname());
|
||||
mBinding.roomHeadTop2Label.setText(StringUtil.toWan2(listsBean.getTotal(), 2));
|
||||
setview(listsBean.getIcon(), mBinding.llVip2);
|
||||
mBinding.roomRankTop2HeadIcon.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
RoomUserInfoFragment.show(roomId,listsBean.getUser_id(), "", getHostUser(), false, 3, 0, getChildFragmentManager());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setview(List<String> item, LinearLayout llContainer) {
|
||||
List<String> images = item; // 获取图片列表
|
||||
|
||||
for (String url : images) {
|
||||
if (url.contains("http")) {
|
||||
ImageView imageView1 = new ImageView(getContext());
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
||||
getContext().getResources().getDimensionPixelSize(com.xscm.moduleutil.R.dimen.dp_57),
|
||||
getContext().getResources().getDimensionPixelSize(com.xscm.moduleutil.R.dimen.dp_15)
|
||||
);
|
||||
params.setMargins(0, 0, getContext().getResources().getDimensionPixelSize(com.xscm.moduleutil.R.dimen.dp_5), 0); // 右边距
|
||||
imageView1.setLayoutParams(params);
|
||||
imageView1.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||||
|
||||
// 使用 Glide 加载图片
|
||||
ImageUtils.loadHeadCC(url, imageView1);
|
||||
|
||||
llContainer.addView(imageView1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNo3(CharmRankingResp listsBean) {
|
||||
ImageUtils.loadHeadCC(listsBean.getAvatar(), mBinding.roomRankTop3HeadIcon);
|
||||
mBinding.roomTop3Name.setText(listsBean.getNickname());
|
||||
mBinding.roomHeadTop3Label.setText(StringUtil.toWan2(listsBean.getTotal(), 2));
|
||||
setview(listsBean.getIcon(), mBinding.llVip3);
|
||||
mBinding.roomRankTop3HeadIcon.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
RoomUserInfoFragment.show(roomId,listsBean.getUser_id(), "", getHostUser(), false, 3, 0, getChildFragmentManager());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCharmEmpty(List<CharmRankingResp> list) {
|
||||
if (list != null) {
|
||||
if (cAdapter==null){
|
||||
wAdapter.setNewData(list);
|
||||
}else {
|
||||
cAdapter.setNewData(list);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWealthEmpty(List<CharmRankingResp> list) {
|
||||
if (list != null){
|
||||
wAdapter.setNewData(list);
|
||||
}else {
|
||||
wAdapter.setEmptyView(commonEmptyView);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.xscm.modulemain.activity.room.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.databinding.RoomRankingParentBinding;
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.adapter.MyFragmentPagerAdapter;
|
||||
import com.xscm.moduleutil.base.BaseMvpFragment;
|
||||
import com.xscm.moduleutil.bean.room.RoomInfoResp;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/6/10
|
||||
*@description:
|
||||
*/
|
||||
public class RankingParentFragment extends BaseMvpFragment<IPresenter, RoomRankingParentBinding> {
|
||||
|
||||
//成员变量 + 全局变量
|
||||
public static final int TYPE_DATA = 1;//日榜
|
||||
public static final int TYPE_WEEK = 2;//周榜
|
||||
public static final int TYPE_MON = 3;//月榜
|
||||
private static String mRoomId;//房间ID
|
||||
private static int rankType = 1;//统计类型(魅力 / 财富)
|
||||
private RoomInfoResp roomInfoResp;
|
||||
|
||||
public static RankingParentFragment newInstance(String roomId,int rankType,RoomInfoResp roomInfoResp) {
|
||||
Bundle args = new Bundle();
|
||||
args.putString("roomId", roomId);
|
||||
args.putInt("rankType", rankType);
|
||||
args.putSerializable("roomInfoResp", roomInfoResp);
|
||||
RankingParentFragment fragment = new RankingParentFragment();
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initArgs(Bundle arguments) {
|
||||
super.initArgs(arguments);
|
||||
mRoomId = arguments.getString("roomId");
|
||||
rankType = arguments.getInt("rankType");
|
||||
roomInfoResp = (RoomInfoResp) arguments.getSerializable("roomInfoResp");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IPresenter bindPresenter() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
List<Fragment> fragments = new ArrayList<>();
|
||||
fragments.add(RankingChildFragment.newInstance(mRoomId, TYPE_DATA, rankType, roomInfoResp));
|
||||
fragments.add(RankingChildFragment.newInstance(mRoomId, TYPE_WEEK, rankType, roomInfoResp));
|
||||
fragments.add(RankingChildFragment.newInstance(mRoomId, TYPE_MON, rankType, roomInfoResp));
|
||||
MyFragmentPagerAdapter myFragmentPagerAdapter = new MyFragmentPagerAdapter(fragments, getChildFragmentManager());
|
||||
mBinding.vpRankChild.setAdapter(myFragmentPagerAdapter);
|
||||
String[] title = new String[]{"日榜", "周榜", "月榜"};
|
||||
mBinding.slidingTabLayout.setViewPager(mBinding.vpRankChild, title);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.room_ranking_parent;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,342 @@
|
||||
package com.xscm.modulemain.activity.room.fragment;
|
||||
|
||||
import static com.xscm.moduleutil.enumType.RedEnvelopeStatus.QXRedBagDrawTypeCollect;
|
||||
import static com.xscm.moduleutil.enumType.RedEnvelopeStatus.QXRedBagDrawTypeOpen;
|
||||
import static com.xscm.moduleutil.enumType.RedEnvelopeStatus.QXRedBagDrawTypePwdSend;
|
||||
import static com.xscm.moduleutil.enumType.RedEnvelopeStatus.QXRedBagDrawTypeTimeDown;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.os.CountDownTimer;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.blankj.utilcode.util.ScreenUtils;
|
||||
import com.blankj.utilcode.util.TimeUtils;
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.activity.room.activity.RoomActivity;
|
||||
import com.xscm.modulemain.databinding.FragmentRedEnvelopesBinding;
|
||||
import com.xscm.moduleutil.bean.RedPackGrab;
|
||||
import com.xscm.moduleutil.bean.RedPacketInfo;
|
||||
import com.xscm.moduleutil.bean.UserInfo;
|
||||
import com.xscm.moduleutil.enumType.RedEnvelopeStatus;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.http.RetrofitClient;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
import com.xscm.moduleutil.view.QXRedBagSendView;
|
||||
import com.xscm.moduleutil.widget.dialog.BaseDialog;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
/**
|
||||
* @author xscm
|
||||
* @ClassName RedEnvelopesFragment
|
||||
* @Description 抢红包的dialog
|
||||
* @Date 2021/12/28 10:09
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class RedEnvelopesFragment extends BaseDialog<FragmentRedEnvelopesBinding> {
|
||||
private RedEnvelopeStatus drawType;
|
||||
public RedPacketInfo mRedPacketInfo;
|
||||
public boolean isCollectedRoom;//是否收藏房间
|
||||
|
||||
public long needTime;// 倒计时
|
||||
public boolean isFromToComment;//是否是发送评论地方过来
|
||||
|
||||
private CountDownTimer countDownTimer;
|
||||
private Context mContext;
|
||||
|
||||
public RedEnvelopesFragment(@NonNull @NotNull Context context) {
|
||||
super(context, com.xscm.moduleutil.R.style.BaseDialogStyleH);
|
||||
mContext=context;
|
||||
}
|
||||
|
||||
//是否收藏方法
|
||||
public void setIsCollectedRoom(boolean isCollectedRoom) {
|
||||
this.isCollectedRoom = isCollectedRoom;
|
||||
}
|
||||
|
||||
public void setFromToComment(boolean isFromToComment) {
|
||||
this.isFromToComment = isFromToComment;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
setCancelable(false);
|
||||
setCanceledOnTouchOutside(false);
|
||||
Window window = getWindow();
|
||||
window.setLayout((int) (ScreenUtils.getScreenWidth() * 0.8), WindowManager.LayoutParams.WRAP_CONTENT);
|
||||
mBinding.imRedClose.setOnClickListener(v -> {
|
||||
QXRedBagSendView redBagView = new QXRedBagSendView(getContext());
|
||||
redBagView.showInView((ViewGroup) getWindow().getDecorView());
|
||||
dismiss();
|
||||
});
|
||||
|
||||
|
||||
mBinding.imRedK.setOnClickListener(v -> {
|
||||
RetrofitClient.getInstance().grab(mRedPacketInfo.getRedpacket_id(), new BaseObserver<RedPackGrab>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(@NotNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NotNull RedPackGrab redPackGrab) {
|
||||
if (redPackGrab.getCode() == 1) {
|
||||
mRedPacketInfo.setIs_qiang(1);
|
||||
ARouter.getInstance().build(ARouteConstants.ROOM_RED_RESULT).withString("redpacketId", mRedPacketInfo.getRedpacket_id()).navigation();
|
||||
dismiss();
|
||||
} else if (redPackGrab.getCode() == 2) {
|
||||
ToastUtils.showShort("您已经抢过红包了");
|
||||
ARouter.getInstance().build(ARouteConstants.ROOM_RED_RESULT).withString("redpacketId", mRedPacketInfo.getRedpacket_id()).navigation();
|
||||
dismiss();
|
||||
} else {
|
||||
snatched();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
mBinding.tvCk.setOnClickListener(v -> ARouter.getInstance().build(ARouteConstants.ROOM_RED_RESULT).withString("redpacketId", mRedPacketInfo.getRedpacket_id()).navigation());
|
||||
mBinding.textPl.setOnClickListener(v -> {
|
||||
if (drawType == RedEnvelopeStatus.QXRedBagDrawTypeCollect){
|
||||
RetrofitClient.getInstance().followRoom(mRedPacketInfo.getRoom_id()+"","1", new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(@NotNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NotNull String s) {
|
||||
if (mContext instanceof RoomActivity) {
|
||||
((RoomActivity) mContext).setUserInfo();
|
||||
}
|
||||
|
||||
if (mRedPacketInfo.canOpenNow()){
|
||||
setType(QXRedBagDrawTypeOpen);
|
||||
}else {
|
||||
setType(QXRedBagDrawTypeTimeDown);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}else if (drawType == RedEnvelopeStatus.QXRedBagDrawTypePwdSend){
|
||||
UserInfo userInfo = new UserInfo();
|
||||
userInfo.setRed_num(mRedPacketInfo.getPassword());
|
||||
EventBus.getDefault().post(userInfo);
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void snatched() {
|
||||
mBinding.tvRedCount.setText("手慢,没有抢到");
|
||||
mBinding.imRedK.setVisibility(View.GONE);
|
||||
mBinding.textPl.setVisibility(View.GONE);
|
||||
mBinding.tvTitle.setVisibility(View.GONE);
|
||||
mBinding.tvPinl.setVisibility(View.GONE);
|
||||
mBinding.tvKl.setVisibility(View.GONE);
|
||||
mBinding.tvCk.setVisibility(View.VISIBLE);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.fragment_red_envelopes;
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
public void setRedPacket(RedPacketInfo redPacketInfo) {
|
||||
this.mRedPacketInfo = redPacketInfo;
|
||||
setType(getDrawTypeWithRedpacktModel(redPacketInfo));
|
||||
if (redPacketInfo.getType() == 2) {
|
||||
mBinding.imKlB.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mBinding.imKlB.setVisibility(View.GONE);
|
||||
}
|
||||
ImageUtils.loadHeadCC(redPacketInfo.getAvatar(), mBinding.userAvatar);
|
||||
mBinding.tvUserName.setText(redPacketInfo.getNickname() + "的红包");
|
||||
mBinding.tvRedCount.setText(redPacketInfo.getRemark());
|
||||
if (drawType == RedEnvelopeStatus.QXRedBagDrawTypeOpen) {
|
||||
mBinding.clPwd.setVisibility(View.GONE);
|
||||
mBinding.textShare.setVisibility(View.GONE);
|
||||
} else {
|
||||
mBinding.clPwd.setVisibility(View.VISIBLE);
|
||||
mBinding.textShare.setVisibility(View.VISIBLE);
|
||||
if (redPacketInfo.getType() == 2) {
|
||||
mBinding.tvKl.setVisibility(View.VISIBLE);
|
||||
mBinding.imKlB.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mBinding.tvKl.setVisibility(View.GONE);
|
||||
mBinding.imKlB.setVisibility(View.GONE);
|
||||
}
|
||||
if (redPacketInfo.getConditions() == null || redPacketInfo.getConditions().equals("0")) {
|
||||
mBinding.clPwd.setVisibility(View.GONE);
|
||||
} else {
|
||||
mBinding.clPwd.setVisibility(View.VISIBLE);
|
||||
mBinding.tvKl.setVisibility(View.VISIBLE);
|
||||
if (redPacketInfo.getConditions().equals("1")) {
|
||||
mBinding.tvKl.setText("收藏房间");
|
||||
} else if (redPacketInfo.getConditions().equals("2")) {
|
||||
mBinding.tvKl.setText("仅麦上用户");
|
||||
} else {
|
||||
mBinding.tvKl.setText("收藏房间,进麦上用户");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
public void setNeedTime(long needTimes){
|
||||
this.needTime = needTimes;
|
||||
if (needTime > 0) {
|
||||
mBinding.textPl.setText(TimeUtils.millis2String(needTime*1000, "mm:ss")+"后开启红包");
|
||||
}
|
||||
}
|
||||
|
||||
private RedEnvelopeStatus getDrawTypeWithRedpacktModel(RedPacketInfo redPacketInfo) {
|
||||
if (redPacketInfo.getType() == 1) {//普通红包
|
||||
drawType = QXRedBagDrawTypeOpen;
|
||||
if (redPacketInfo.getCountdown() > 0) {
|
||||
if (redPacketInfo.remainingTime() > 0) {
|
||||
drawType = QXRedBagDrawTypeTimeDown;
|
||||
}
|
||||
}
|
||||
//收藏房间在先
|
||||
if (redPacketInfo.getConditions().contains("1") && !isCollectedRoom) {
|
||||
drawType = QXRedBagDrawTypeCollect;
|
||||
}
|
||||
} else {//口令红包
|
||||
drawType = QXRedBagDrawTypePwdSend;
|
||||
if (isFromToComment) {
|
||||
if (redPacketInfo.getConditions().contains("1") && !isCollectedRoom) {
|
||||
drawType = QXRedBagDrawTypeCollect;
|
||||
} else {
|
||||
if (redPacketInfo.canOpenNow()) {
|
||||
drawType = QXRedBagDrawTypeOpen;
|
||||
} else {
|
||||
drawType = QXRedBagDrawTypeTimeDown;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return drawType;
|
||||
}
|
||||
|
||||
private void setType(RedEnvelopeStatus type) {
|
||||
this.drawType = type;
|
||||
switch (type) {
|
||||
case QXRedBagDrawTypeOpen:
|
||||
handleReadyToOpen();
|
||||
break;
|
||||
case QXRedBagDrawTypeFinished:
|
||||
qXRedBagDrawTypeFinished();
|
||||
break;
|
||||
case QXRedBagDrawTypeCollect:
|
||||
qXRedBagDrawTypeCollect();
|
||||
break;
|
||||
case QXRedBagDrawTypeTimeDown:
|
||||
qXRedBagDrawTypeTimeDown();
|
||||
break;
|
||||
|
||||
case QXRedBagDrawTypePwdSend:
|
||||
qXRedBagDrawTypePwdSend();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void qXRedBagDrawTypePwdSend() {
|
||||
mBinding.imRedK.setVisibility(View.GONE);
|
||||
mBinding.tvRedCount.setText(mRedPacketInfo.getRemark());
|
||||
mBinding.tvCk.setVisibility(View.GONE);
|
||||
mBinding.textPl.setVisibility(View.VISIBLE);
|
||||
mBinding.textPl.setText(setValue(QXRedBagDrawTypePwdSend));
|
||||
|
||||
}
|
||||
|
||||
private void qXRedBagDrawTypeTimeDown() {
|
||||
mBinding.imRedK.setVisibility(View.GONE);
|
||||
mBinding.tvRedCount.setText(mRedPacketInfo.getRemark());
|
||||
mBinding.tvCk.setVisibility(View.GONE);
|
||||
mBinding.textPl.setVisibility(View.VISIBLE);
|
||||
mBinding.textPl.setText(setValue(QXRedBagDrawTypeTimeDown));
|
||||
}
|
||||
|
||||
private void qXRedBagDrawTypeCollect() {
|
||||
mBinding.imRedK.setVisibility(View.GONE);
|
||||
mBinding.tvRedCount.setText(mRedPacketInfo.getRemark());
|
||||
mBinding.tvCk.setVisibility(View.GONE);
|
||||
mBinding.textPl.setVisibility(View.VISIBLE);
|
||||
mBinding.textPl.setText(setValue(QXRedBagDrawTypeCollect));
|
||||
mBinding.textShare.setVisibility(View.VISIBLE);
|
||||
mBinding.clPwd.setVisibility(View.VISIBLE);
|
||||
mBinding.tvPinl.setVisibility(View.GONE);
|
||||
mBinding.tvKl.setVisibility(View.VISIBLE);
|
||||
mBinding.tvKl.setText("收藏房间");
|
||||
|
||||
}
|
||||
|
||||
private String setValue(RedEnvelopeStatus type) {
|
||||
switch (type) {
|
||||
|
||||
case QXRedBagDrawTypeCollect:
|
||||
return "收藏房间抢红包";
|
||||
case QXRedBagDrawTypeTimeDown:
|
||||
return "00:00后开启红包";
|
||||
case QXRedBagDrawTypePwdSend:
|
||||
return "发送评论抢红包";
|
||||
default:
|
||||
return "点击打开红包";
|
||||
}
|
||||
}
|
||||
|
||||
private void qXRedBagDrawTypeFinished() {
|
||||
mBinding.textPl.setVisibility(View.GONE);
|
||||
mBinding.tvTitle.setVisibility(View.GONE);
|
||||
mBinding.tvPinl.setVisibility(View.GONE);
|
||||
mBinding.tvKl.setVisibility(View.GONE);
|
||||
mBinding.tvCk.setVisibility(View.VISIBLE);
|
||||
mBinding.tvRedCount.setText("手慢了,红包被领完了");
|
||||
mBinding.imRedK.setVisibility(View.GONE);
|
||||
mBinding.clPwd.setVisibility(View.GONE);
|
||||
mBinding.textShare.setVisibility(View.GONE);
|
||||
}
|
||||
private void handleReadyToOpen() {
|
||||
mBinding.textPl.setVisibility(View.GONE);
|
||||
mBinding.tvTitle.setVisibility(View.GONE);
|
||||
mBinding.tvPinl.setVisibility(View.GONE);
|
||||
mBinding.tvKl.setVisibility(View.GONE);
|
||||
mBinding.imRedK.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
// 取消倒计时,避免内存泄漏
|
||||
if (countDownTimer != null) {
|
||||
countDownTimer.cancel();
|
||||
countDownTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void changeViewType(RedEnvelopeStatus type) {
|
||||
setType(type);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
package com.xscm.modulemain.activity.room.fragment;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.adapter.RelationshipAdapter;
|
||||
import com.xscm.modulemain.databinding.FragmentRelationshipBinding;
|
||||
import com.xscm.modulemain.activity.room.contacts.RoomUserContacts;
|
||||
import com.xscm.modulemain.activity.room.presenter.RoomUserPresenter;
|
||||
import com.xscm.moduleutil.base.BaseMvpDialogFragment;
|
||||
import com.xscm.moduleutil.bean.RelationCardBean;
|
||||
import com.xscm.moduleutil.bean.RelationshipBean;
|
||||
import com.xscm.moduleutil.bean.UserInfo;
|
||||
import com.xscm.moduleutil.dialog.ConfirmDialog;
|
||||
|
||||
/**
|
||||
* @author qx
|
||||
* @data 2025/6/13
|
||||
* @description: 关系卡和关系位的fragemnt
|
||||
*/
|
||||
public class RelationshipFragment extends BaseMvpDialogFragment<RoomUserPresenter, FragmentRelationshipBinding> implements RoomUserContacts.View {
|
||||
|
||||
RelationshipAdapter adapter;
|
||||
private String userId;
|
||||
private int type;
|
||||
|
||||
public static void show(String user_id, int type, FragmentManager fragmentManager) {
|
||||
RelationshipFragment dialogFragment = new RelationshipFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString("userId", user_id);
|
||||
args.putInt("type", type);
|
||||
dialogFragment.setArguments(args);
|
||||
dialogFragment.show(fragmentManager, "RelationshipFragment");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
userId = getArguments().getString("userId");
|
||||
type = getArguments().getInt("type");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDialogStyle(Window window) {
|
||||
super.initDialogStyle(window);
|
||||
window.setGravity(Gravity.BOTTOM);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RoomUserPresenter bindPresenter() {
|
||||
return new RoomUserPresenter(this, getContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
MvpPre.relationCard(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
mBinding.rvHostList.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
|
||||
adapter = new RelationshipAdapter();
|
||||
mBinding.rvHostList.setAdapter(adapter);
|
||||
adapter.setOnItemClickListener((RelationshipAdapter.OnItemClickListener) (view, data, position) -> {
|
||||
if (view.getId() == R.id.im_zhid) {
|
||||
queren(1, data.getId(), "");
|
||||
} else if (view.getId() == R.id.im_shanchu) {
|
||||
queren(2, data.getId(), data.getDelete_me_coin());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void queren(int type, int id, String num) {
|
||||
if (type == 1) {
|
||||
// 创建并显示确认对话框
|
||||
new ConfirmDialog(getActivity(),
|
||||
"提示",
|
||||
"您确定要置顶本关系吗?",
|
||||
"确认",
|
||||
"取消",
|
||||
v -> {
|
||||
// 点击“确认”按钮时执行删除操作
|
||||
MvpPre.topRelationCard(id + "");
|
||||
dismiss();
|
||||
},
|
||||
v -> {
|
||||
// 点击“取消”按钮时什么都不做
|
||||
}, false, 0).show();
|
||||
} else if (type == 2) {
|
||||
// 创建并显示确认对话框
|
||||
new ConfirmDialog(getActivity(),
|
||||
"提示",
|
||||
"您确定要删除本关系吗?解除关系需要" + num + "金币",
|
||||
"确认",
|
||||
"取消",
|
||||
v -> {
|
||||
// 点击“确认”按钮时执行删除操作
|
||||
MvpPre.deleteRelationCard(id + "");
|
||||
dismiss();
|
||||
},
|
||||
v -> {
|
||||
// 点击“取消”按钮时什么都不做
|
||||
}, false, 0).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fragment_relationship;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getRoomUserInfo(UserInfo userInfo) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downPit() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kickOutRoom() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postHostAdd(String s, String type, String is_add) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMutePit(String pitNumber, String is_mute) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBlackList() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void userGuanzSuccess(String s) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hostUserPit() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveCoin() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void relationCard(RelationCardBean list) {
|
||||
if (list !=null) {
|
||||
if (type == 1) {
|
||||
if (list != null && list.getQinmi() != null) {
|
||||
for (int i = 0; i < list.getQinmi().size(); i++) {
|
||||
list.getQinmi().get(i).setType(1);
|
||||
}
|
||||
adapter.setNewData(list.getQinmi());
|
||||
}
|
||||
} else if (type == 2) {
|
||||
if (list != null && list.getZhenai() != null) {
|
||||
for (int i = 0; i < list.getZhenai().size(); i++) {
|
||||
list.getZhenai().get(i).setType(2);
|
||||
}
|
||||
adapter.setNewData(list.getZhenai());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void topRelationCard(String s) {
|
||||
MvpPre.relationCard(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRelationCard(String s) {
|
||||
MvpPre.relationCard(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearUserCharm() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyPit() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
package com.xscm.modulemain.activity.room.fragment;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.databinding.FragmentRequestBinding;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
|
||||
import com.xscm.modulemain.activity.room.contacts.RequestContacts;
|
||||
import com.xscm.modulemain.activity.room.presenter.RequestPresenter;
|
||||
import com.xscm.moduleutil.base.BaseMvpFragment;
|
||||
import com.xscm.moduleutil.bean.MusicSongBean;
|
||||
import com.xscm.moduleutil.bean.SongMusicBean;
|
||||
import com.xscm.moduleutil.color.ThemeableDrawableUtils;
|
||||
import com.xscm.moduleutil.rtc.AgoraManager;
|
||||
import com.xscm.moduleutil.rtc.MusicBean;
|
||||
import com.xscm.moduleutil.utils.ColorManager;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
import com.xscm.moduleutil.utils.TimeUtils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.agora.musiccontentcenter.Music;
|
||||
|
||||
/**
|
||||
* @author qx
|
||||
* @data 2025/6/10
|
||||
* @description: 点唱viwPage的fragment
|
||||
*/
|
||||
public class RequestFragment extends BaseMvpFragment<RequestPresenter, FragmentRequestBinding> implements RequestContacts.View {
|
||||
|
||||
public static final int TYPE_DATA = 1;//点歌
|
||||
public static final int TYPE_WEEK = 2;//已点
|
||||
private String roomId;
|
||||
BaseQuickAdapter<Music, BaseViewHolder> adapter;
|
||||
private int page = 1;
|
||||
String input="";
|
||||
private int status;
|
||||
@Override
|
||||
public void songList(List<MusicSongBean> musicSongBeans) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upSong(String S) {
|
||||
ToastUtils.show(S);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void song(List<SongMusicBean> music) {
|
||||
ToastUtils.show("操作成功");
|
||||
}
|
||||
|
||||
public interface OnRequestFragmentListener {
|
||||
void onCloseDialog(Music musicSongBean);
|
||||
}
|
||||
|
||||
private OnRequestFragmentListener listener;
|
||||
|
||||
// 绑定监听器
|
||||
public void setOnRequestFragmentListener(OnRequestFragmentListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public static RequestFragment newInstance(String roomId, int type,int status) {
|
||||
Bundle args = new Bundle();
|
||||
RequestFragment fragment = new RequestFragment();
|
||||
args.putString("roomId", roomId);
|
||||
args.putInt("type", type);
|
||||
args.putInt("status", status);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RequestPresenter bindPresenter() {
|
||||
return new RequestPresenter(this, getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
roomId = getArguments().getString("roomId");
|
||||
status = getArguments().getInt("status");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
mBinding.editQuery.setText(SpUtil.getMusicName());
|
||||
|
||||
mBinding.editQuery.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
input = s.toString();
|
||||
SpUtil.setMusicName( input);
|
||||
AgoraManager.getInstance(getContext()).searchMusic(input, 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
mBinding.smartRefreshLayout.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
|
||||
@Override
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
page++;
|
||||
AgoraManager.getInstance(getContext()).searchMusic(mBinding.editQuery.getText().toString(), page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
page = 1;
|
||||
AgoraManager.getInstance(getContext()).searchMusic(mBinding.editQuery.getText().toString(), page);
|
||||
}
|
||||
});
|
||||
|
||||
mBinding.recycleView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
|
||||
adapter = new BaseQuickAdapter<Music, BaseViewHolder>(R.layout.item_reward, null) {
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, Music item) {
|
||||
LogUtils.e("@@@", item);
|
||||
helper.setText(R.id.muis_name, item.getName());
|
||||
helper.setText(R.id.muis_desc, TimeUtils.formatDuration(item.getReleaseTime().isEmpty() ? 0 : Long.parseLong(item.getReleaseTime())));
|
||||
helper.setText(R.id.muis_desc, "\t" + item.getSinger());
|
||||
ImageUtils.loadHeadCC(item.getPoster(), helper.getView(R.id.muis_avatar));
|
||||
|
||||
helper.getView(R.id.muis_price).setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (status==1) {
|
||||
MvpPre.song(roomId, SpUtil.getUserId() + "", item.getSongCode() + "", item.getName(), item.getSinger(), item.getPoster(), String.valueOf(item.getDurationS()));
|
||||
} else {
|
||||
if (AgoraManager.getInstance(getContext()).getMusicList()==null) {
|
||||
// AgoraManager.getInstance(getContext()).isPreload2(item.getSongCode(), 1);
|
||||
List<Music> music = new ArrayList<>();
|
||||
music.add(item);
|
||||
AgoraManager.getInstance(getContext()).setMusicList(music);
|
||||
EventBus.getDefault().post(item);
|
||||
AgoraManager.getInstance(getContext()).nextSong();
|
||||
} else {
|
||||
|
||||
List<Music> music = AgoraManager.getInstance(getContext()).getMusicList();
|
||||
music.add(item);
|
||||
AgoraManager.getInstance(getContext()).setMusicList(music);
|
||||
}
|
||||
|
||||
}
|
||||
ToastUtils.show("添加成功");
|
||||
}
|
||||
});
|
||||
TextView muis_price=helper.getView(R.id.muis_price);
|
||||
ThemeableDrawableUtils.setThemeableRoundedBackground(muis_price, ColorManager.getInstance().getPrimaryColorInt(), 34);
|
||||
muis_price.setTextColor(ColorManager.getInstance().getButtonColorInt());
|
||||
}
|
||||
};
|
||||
mBinding.recycleView.setAdapter(adapter);
|
||||
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onMusicSearchResultEvent(MusicBean music) {
|
||||
if (music.getMusicList() != null) {
|
||||
if (music.getPage() == 1) {
|
||||
adapter.setNewData(music.getMusicList());
|
||||
} else {
|
||||
adapter.addData(music.getMusicList());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fragment_request;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,321 @@
|
||||
package com.xscm.modulemain.activity.room.fragment;
|
||||
|
||||
import static android.app.Activity.RESULT_OK;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.databinding.RoomFragementDialogRoomBackgroundBinding;
|
||||
import com.luck.picture.lib.basic.PictureSelector;
|
||||
import com.luck.picture.lib.config.PictureConfig;
|
||||
import com.luck.picture.lib.entity.LocalMedia;
|
||||
import com.xscm.modulemain.activity.room.contacts.RoomBackgroundContacts;
|
||||
import com.xscm.modulemain.activity.room.presenter.RoomBackgroundPresenter;
|
||||
import com.xscm.moduleutil.base.BaseMvpDialogFragment;
|
||||
import com.xscm.moduleutil.bean.RoomBgBean;
|
||||
import com.xscm.moduleutil.dialog.ConfirmDialog;
|
||||
import com.xscm.moduleutil.utils.GlideEngine;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
import com.xscm.moduleutil.utils.PermissionDescriptionHelper;
|
||||
import com.xscm.moduleutil.widget.Constants;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/6/24
|
||||
*@description: 更换房间背景
|
||||
*/
|
||||
public class RoomBackgroundDialogFragment extends BaseMvpDialogFragment<RoomBackgroundPresenter, RoomFragementDialogRoomBackgroundBinding> implements RoomBackgroundContacts.View {
|
||||
|
||||
|
||||
private MyAdapter mAdapter;
|
||||
|
||||
private String roomId;
|
||||
private String picture;
|
||||
private boolean pictureChanged;
|
||||
private List<RoomBgBean.RoomBg> publicBgList = new ArrayList<>();
|
||||
private List<RoomBgBean.RoomBg> myBgList = new ArrayList<>();
|
||||
|
||||
|
||||
public static RoomBackgroundDialogFragment newInstance(String roomId) {
|
||||
RoomBackgroundDialogFragment fragment = new RoomBackgroundDialogFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("roomId", roomId);
|
||||
fragment.setArguments(bundle);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
mBinding.recyclerView.setLayoutManager(new GridLayoutManager(getContext(), 3));
|
||||
mAdapter = new MyAdapter();
|
||||
mBinding.recyclerView.setAdapter(mAdapter);
|
||||
|
||||
mAdapter.setOnItemClickListener(new MyAdapter.OnItemClickListener() {
|
||||
@Override
|
||||
public void onAddImageClick() {
|
||||
// 处理“添加图片”点击逻辑(例如打开相册)
|
||||
startChoosePhoto(1, PictureConfig.REQUEST_CAMERA, false, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackgroundClick(RoomBgBean.RoomBg item) {
|
||||
|
||||
queren1(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void queren1(RoomBgBean.RoomBg item) {
|
||||
// 创建并显示确认对话框
|
||||
new ConfirmDialog(getContext(),
|
||||
"温馨提示",
|
||||
"是否选择当前图片为背景图片",
|
||||
"确认",
|
||||
"取消",
|
||||
v -> {
|
||||
// 点击“确认”按钮时执行删除操作
|
||||
MvpPre.editRoom(roomId, "", "", "", item.getImage_url());
|
||||
|
||||
},
|
||||
v -> {
|
||||
// 点击“取消”按钮时什么都不做
|
||||
|
||||
},false,0).show();
|
||||
}
|
||||
|
||||
private void startChoosePhoto(int mimeType, int requestCode, boolean isVideo, int type) {
|
||||
PictureSelector.create(this)
|
||||
.openGallery(mimeType)
|
||||
.isGif(isVideo)
|
||||
.setImageEngine(GlideEngine.createGlideEngine())
|
||||
.setPermissionDescriptionListener(PermissionDescriptionHelper.createListener())
|
||||
.setMaxSelectNum(type)
|
||||
.isPreviewImage(true)
|
||||
.isDisplayCamera(false)
|
||||
.setOutputCameraDir(Constants.FILE_PATH)
|
||||
.isOriginalSkipCompress(true)
|
||||
.forResult(requestCode); //结果回调onActivityResult code
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (resultCode == RESULT_OK && data != null) {
|
||||
switch (requestCode) {
|
||||
|
||||
case PictureConfig.REQUEST_CAMERA:
|
||||
List<LocalMedia> localMediaList = PictureSelector.obtainSelectorList(data);
|
||||
|
||||
List<LocalMedia> localMedia1 = PictureSelector.obtainSelectorList(data);
|
||||
if (localMedia1 != null && localMedia1.size() != 0) {
|
||||
LocalMedia imgMedia = localMedia1.get(0);
|
||||
String url;
|
||||
if (imgMedia.isCompressed()) {
|
||||
url = imgMedia.getCompressPath();
|
||||
} else {
|
||||
url = imgMedia.getRealPath();
|
||||
}
|
||||
MvpPre.uploadFile(new File(url), 1, 1, 1);
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upLoadSuccess(String url, int type, int index, int total) {
|
||||
MvpPre.uploadBgImage("", url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadBgImage() {
|
||||
MvpPre.getBackgroundList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void editRoom() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
mBinding.tvTitle.setOnClickListener(this::onViewClicked);
|
||||
mBinding.tvTitle2.setOnClickListener(this::onViewClicked);
|
||||
// 设置默认样式(可选)
|
||||
resetBackgroundTextStyles();
|
||||
}
|
||||
|
||||
private void setTextViewStyle(TextView tv, String colorHex, int textSizeSp) {
|
||||
tv.setTextColor(Color.parseColor(colorHex));
|
||||
tv.setTextSize(textSizeSp);
|
||||
}
|
||||
|
||||
private void resetBackgroundTextStyles() {
|
||||
setTextViewStyle(mBinding.tvTitle, "#333333", 16);
|
||||
setTextViewStyle(mBinding.tvTitle2, "#999999", 12);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void initArgs(Bundle arguments) {
|
||||
super.initArgs(arguments);
|
||||
roomId = arguments.getString("roomId");
|
||||
picture = arguments.getString("picture");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
Window window = getDialog().getWindow();
|
||||
if (window != null) {
|
||||
// 设置固定高度为 500dp
|
||||
int screenHeight = getResources().getDisplayMetrics().heightPixels;
|
||||
int heightInDp = (int) (screenHeight * 0.6f);
|
||||
window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, heightInDp);
|
||||
|
||||
// 可选:设置动画样式(从底部弹出)
|
||||
window.setWindowAnimations(com.xscm.moduleutil.R.style.CommonShowDialogBottom);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDialogStyle(Window window) {
|
||||
super.initDialogStyle(window);
|
||||
window.setGravity(Gravity.BOTTOM);
|
||||
setCancelable(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.room_fragement_dialog_room_background;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RoomBackgroundPresenter bindPresenter() {
|
||||
return new RoomBackgroundPresenter(this, getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
pictureChanged = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetach() {
|
||||
if (!pictureChanged) {
|
||||
EventBus.getDefault().post(new RoomBgBean());
|
||||
}
|
||||
super.onDetach();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
MvpPre.getBackgroundList();
|
||||
}
|
||||
|
||||
|
||||
public void onViewClicked(View view) {
|
||||
if (view.getId() == R.id.tv_title2) {
|
||||
// 点击“我的背景”
|
||||
setTextViewStyle(mBinding.tvTitle2, "#333333", 16);
|
||||
setTextViewStyle(mBinding.tvTitle, "#999999", 12);
|
||||
List<RoomBgBean.RoomBg> listWithAddBtn = new ArrayList<>();
|
||||
RoomBgBean.RoomBg addBg = new RoomBgBean.RoomBg();
|
||||
addBg.setAddButton(true);
|
||||
addBg.setImage_url(null); // 可选:设为空图 URL
|
||||
|
||||
// 插入到顶部
|
||||
listWithAddBtn.add(addBg);
|
||||
listWithAddBtn.addAll(myBgList);
|
||||
mAdapter.setNewData(listWithAddBtn);
|
||||
} else if (view.getId() == R.id.tv_title) {
|
||||
// 点击“公共背景”
|
||||
setTextViewStyle(mBinding.tvTitle, "#333333", 16); // 当前项大字体、深色
|
||||
setTextViewStyle(mBinding.tvTitle2, "#999999", 12);
|
||||
mAdapter.setNewData(publicBgList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showLoadings(String content) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBackgroundList(RoomBgBean list) {
|
||||
publicBgList = list.getPublic_bg();
|
||||
myBgList = list.getPrivate_bg();
|
||||
|
||||
// 如果当前正在显示“我的背景”,则刷新 RecyclerView
|
||||
if (mBinding.tvTitle2.getCurrentTextColor() == Color.parseColor("#333333")) {
|
||||
List<RoomBgBean.RoomBg> listWithAddBtn = new ArrayList<>();
|
||||
RoomBgBean.RoomBg addBg = new RoomBgBean.RoomBg();
|
||||
addBg.setAddButton(true);
|
||||
listWithAddBtn.add(addBg);
|
||||
listWithAddBtn.addAll(myBgList);
|
||||
mAdapter.setNewData(listWithAddBtn); // 更新 adapter 数据并刷新
|
||||
}
|
||||
mAdapter.setNewData(publicBgList);
|
||||
}
|
||||
|
||||
private static class MyAdapter extends BaseQuickAdapter<RoomBgBean.RoomBg, BaseViewHolder> {
|
||||
public interface OnItemClickListener {
|
||||
void onAddImageClick(); // 点击“添加图片”按钮时触发
|
||||
void onBackgroundClick(RoomBgBean.RoomBg item); // 点击普通背景项时触发
|
||||
}
|
||||
private OnItemClickListener onItemClickListener;
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener listener) {
|
||||
this.onItemClickListener = listener;
|
||||
}
|
||||
MyAdapter() {
|
||||
super(R.layout.room_rv_item_room_bg);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, RoomBgBean.RoomBg item) {
|
||||
if (item.isAddButton()) {
|
||||
// “添加图片”按钮样式
|
||||
helper.setImageResource(R.id.iv_bg, com.xscm.moduleutil.R.mipmap.add_img); // 添加图片图标
|
||||
helper.itemView.setOnClickListener(v -> {
|
||||
if (onItemClickListener != null) {
|
||||
onItemClickListener.onAddImageClick();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 普通图片项
|
||||
ImageUtils.loadHeadCC(item.getImage_url(), helper.getView(R.id.iv_bg));
|
||||
helper.itemView.setOnClickListener(v -> {
|
||||
if (onItemClickListener != null) {
|
||||
onItemClickListener.onBackgroundClick(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,759 @@
|
||||
package com.xscm.modulemain.activity.room.fragment;
|
||||
|
||||
import static android.view.View.GONE;
|
||||
import static android.view.View.VISIBLE;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.CountDownTimer;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.core.app.NotificationManagerCompat;
|
||||
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.blankj.utilcode.util.TimeUtils;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.orhanobut.logger.Logger;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.activity.room.activity.RoomActivity;
|
||||
import com.xscm.modulemain.activity.room.contacts.RoomCabinContacts;
|
||||
import com.xscm.modulemain.activity.room.presenter.RoomCabinPresenter;
|
||||
import com.xscm.modulemain.databinding.RoomCabinFragmentBinding;
|
||||
import com.xscm.modulemain.dialog.ExitRoomBottomSheet;
|
||||
import com.xscm.modulemain.dialog.RoomGiftDialogFragment;
|
||||
import com.xscm.moduleutil.base.BaseRoomFragment;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.bean.RoomMessageEvent;
|
||||
import com.xscm.moduleutil.bean.UserInfo;
|
||||
import com.xscm.moduleutil.bean.room.RoomCpUserBean;
|
||||
import com.xscm.moduleutil.bean.room.RoomInfoResp;
|
||||
import com.xscm.moduleutil.bean.room.RoomPitBean;
|
||||
import com.xscm.moduleutil.event.CabinEvent;
|
||||
import com.xscm.moduleutil.listener.MessageListenerSingleton;
|
||||
import com.xscm.moduleutil.rtc.AgoraManager;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
import com.xscm.moduleutil.widget.dialog.CommonDialog;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Date;
|
||||
|
||||
import io.agora.rtc2.Constants;
|
||||
import io.agora.rtc2.IRtcEngineEventHandler;
|
||||
import io.agora.rtc2.RtcEngine;
|
||||
import io.agora.rtc2.RtcEngineEx;
|
||||
import io.agora.rtc2.video.VideoCanvas;
|
||||
|
||||
/**
|
||||
* @author qx
|
||||
* @data 2025/7/1
|
||||
* @description: 电影房
|
||||
*/
|
||||
public class RoomCabinFragment extends BaseRoomFragment<RoomCabinPresenter, RoomCabinFragmentBinding> implements RoomCabinContacts.View {
|
||||
private static final String LABEL_ID_MOVIE = "5";
|
||||
protected String roomId;
|
||||
protected String pitNumber;//当前点击的麦序
|
||||
protected CommonDialog commonDialog;
|
||||
CountDownTimer mCountDownTimer;
|
||||
private RoomInfoResp roomInfoResp;
|
||||
private int remainingTime;
|
||||
private boolean isShow = false;
|
||||
private RoomCpUserBean cpUserBean;
|
||||
private boolean isMicPlace = false;
|
||||
private RtcEngineEx engine;
|
||||
private String label_id="";
|
||||
|
||||
private int remoteUid = -1;
|
||||
|
||||
|
||||
public RoomCabinFragment(){}
|
||||
public RoomCabinFragment(RoomInfoResp roomInfoResp){
|
||||
this.roomInfoResp = roomInfoResp;
|
||||
}
|
||||
public static RoomCabinFragment newInstance(RoomInfoResp roomInfoResp) {
|
||||
Bundle args = new Bundle();
|
||||
RoomCabinFragment fragment = new RoomCabinFragment(roomInfoResp);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
if (CommonAppContext.getInstance().lable_id.equals("6") && CommonAppContext.getInstance().isMicPlace){
|
||||
joinChannel();
|
||||
isMicPlace = true;
|
||||
mBinding.im3.setImageResource(com.xscm.moduleutil.R.mipmap.clogs_car);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void enableNotifications() {
|
||||
if (NotificationManagerCompat.from(requireContext()).areNotificationsEnabled()) {
|
||||
Log.d("RoomCabinFragment", "Notifications enable!");
|
||||
return;
|
||||
}
|
||||
Log.d("RoomCabinFragment", "Notifications not enable!");
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setTitle("提示")
|
||||
.setMessage("请打开通知权限,防止后台共享屏幕中断")
|
||||
.setPositiveButton("设置", (dialog, which) -> {
|
||||
Intent intent = new Intent();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
intent.setAction(Settings.ACTION_APP_NOTIFICATION_SETTINGS);
|
||||
intent.putExtra(Settings.EXTRA_APP_PACKAGE, getActivity().getPackageName());
|
||||
intent.putExtra(Settings.EXTRA_CHANNEL_ID, getActivity().getApplicationInfo().uid);
|
||||
} else {
|
||||
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
}
|
||||
startActivity(intent);
|
||||
dialog.dismiss();
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RoomCabinPresenter bindPresenter() {
|
||||
return new RoomCabinPresenter(this, getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
if (roomInfoResp == null) return;
|
||||
|
||||
if (roomInfoResp != null) {
|
||||
roomId = roomInfoResp.getRoom_info().getRoom_id();
|
||||
cpUserBean = roomInfoResp.getCp_user();
|
||||
label_id = roomInfoResp.getRoom_info().getLabel_id();
|
||||
}
|
||||
if (roomInfoResp != null && roomInfoResp.getRoom_owner().getUser_id().equals(SpUtil.getUserId()+"")){
|
||||
mBinding.im3.setVisibility(VISIBLE);
|
||||
}else {
|
||||
mBinding.im3.setVisibility(GONE);
|
||||
}
|
||||
|
||||
mBinding.ivExit.setOnClickListener(this::onHeartLineClicked);
|
||||
|
||||
// 获取当前用户 ID
|
||||
String currentUserId = SpUtil.getUserId() + "";
|
||||
|
||||
// 定义两个 RoomPitBean 对象,分别用于显示在 roomMakeWheat1 和 roomMakeWheat2
|
||||
RoomPitBean selfBean = new RoomPitBean(); // 自己的 bean
|
||||
RoomPitBean otherBean = new RoomPitBean(); // 另一个用户的 bean
|
||||
|
||||
boolean isSelfFirst = false;
|
||||
|
||||
// 判断当前用户是 user_id 还是 user_id1
|
||||
if (cpUserBean != null) {
|
||||
if (currentUserId.equals(cpUserBean.getUser_id())) {
|
||||
// 当前用户是 user_id
|
||||
selfBean.setUser_id(cpUserBean.getUser_id());
|
||||
selfBean.setUser_code(cpUserBean.getUser_code());
|
||||
selfBean.setNickname(cpUserBean.getNickname());
|
||||
selfBean.setAvatar(cpUserBean.getAvatar());
|
||||
selfBean.setDress(cpUserBean.getDress());
|
||||
selfBean.setPit_number("000");
|
||||
|
||||
otherBean.setUser_id(cpUserBean.getUser_id1());
|
||||
otherBean.setUser_code(cpUserBean.getUser_code1());
|
||||
otherBean.setNickname(cpUserBean.getNickname1());
|
||||
otherBean.setAvatar(cpUserBean.getAvatar1());
|
||||
otherBean.setDress(cpUserBean.getDress1());
|
||||
otherBean.setPit_number("000");
|
||||
|
||||
|
||||
} else if (currentUserId.equals(cpUserBean.getUser_id1())) {
|
||||
// 当前用户是 user_id1,则交换位置
|
||||
selfBean.setUser_id(cpUserBean.getUser_id1());
|
||||
selfBean.setUser_code(cpUserBean.getUser_code1());
|
||||
selfBean.setNickname(cpUserBean.getNickname1());
|
||||
selfBean.setAvatar(cpUserBean.getAvatar1());
|
||||
selfBean.setDress(cpUserBean.getDress1());
|
||||
selfBean.setPit_number("000");
|
||||
|
||||
otherBean.setUser_id(cpUserBean.getUser_id());
|
||||
otherBean.setUser_code(cpUserBean.getUser_code());
|
||||
otherBean.setNickname(cpUserBean.getNickname());
|
||||
otherBean.setAvatar(cpUserBean.getAvatar());
|
||||
otherBean.setDress(cpUserBean.getDress());
|
||||
otherBean.setPit_number("000");
|
||||
}
|
||||
}
|
||||
// 不论谁是自己,始终将自己放在 roomMakeWheat1
|
||||
mBinding.roomMakeWheat1.setData(selfBean);
|
||||
// 将另一个用户的数据放在 roomMakeWheat2
|
||||
mBinding.roomMakeWheat2.setData(otherBean);
|
||||
mBinding.tvMainTitle.setText(roomInfoResp.getRoom_info().getRoom_name());
|
||||
mBinding.tvHeartValue2.setText(roomInfoResp.getRoom_info().getHot_value());
|
||||
if (cpUserBean != null) {
|
||||
countDownTime(Long.parseLong(cpUserBean.getTime_day()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
super.initView();
|
||||
|
||||
mBinding.im1.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (!isShow) {
|
||||
switchMic(2);
|
||||
isMute(1);
|
||||
} else {
|
||||
switchMic(1);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
mBinding.im2.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
RoomPitBean roomPitBean = mBinding.roomMakeWheat2.pitBean;
|
||||
UserInfo userInfo = new UserInfo();
|
||||
userInfo.setUser_id(Integer.parseInt(roomPitBean.getUser_id()!=null ? roomPitBean.getUser_id() : "0"));
|
||||
userInfo.setNickname(roomPitBean.getNickname());
|
||||
userInfo.setAvatar(roomPitBean.getAvatar());
|
||||
userInfo.setPit_number("");
|
||||
RoomGiftDialogFragment.show(null, userInfo, roomInfoResp.getRoom_info().getRoom_id(),0,"", getParentFragmentManager());
|
||||
|
||||
}
|
||||
});
|
||||
if (!CommonAppContext.getInstance().isShowAg){
|
||||
switchMic(2);
|
||||
}else {
|
||||
isShow = true;
|
||||
switchMic(2);
|
||||
}
|
||||
|
||||
mBinding.im3.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// requestScreenCapture();
|
||||
if (!isMicPlace) {
|
||||
joinChannel();
|
||||
isMicPlace = true;
|
||||
mBinding.im3.setImageResource(com.xscm.moduleutil.R.mipmap.clogs_car);
|
||||
CommonAppContext.getInstance().isMicPlace = true;
|
||||
} else {
|
||||
isMicPlace = false;
|
||||
ToastUtils.show("将停止屏幕共享");
|
||||
AgoraManager.getInstance(getActivity()).stopScreenCapture();
|
||||
mBinding.im3.setImageResource(com.xscm.moduleutil.R.mipmap.gongxiang);
|
||||
CommonAppContext.getInstance().isMicPlace = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (roomInfoResp != null && roomInfoResp.getRoom_owner().getUser_id().equals(SpUtil.getUserId()+"")){
|
||||
mBinding.im3.setVisibility(VISIBLE);
|
||||
}else {
|
||||
mBinding.im3.setVisibility(GONE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void handleMsgType1028(RoomMessageEvent messageEvent){
|
||||
if (messageEvent.getMsgType()==1028){
|
||||
mBinding.tvHeartValue2.setText(messageEvent.getText().getHot_value());
|
||||
}
|
||||
}
|
||||
|
||||
public void upCabinFragment(long time){
|
||||
countDownTime( time);
|
||||
}
|
||||
|
||||
public void switchMic(int type) {
|
||||
|
||||
if (type == 1) {
|
||||
mBinding.im1.setImageResource(com.xscm.moduleutil.R.mipmap.close_m);
|
||||
AgoraManager.getInstance(getActivity()).ClientRole(true);
|
||||
AgoraManager.getInstance(getActivity()).muteLocalAudioStream(false);
|
||||
AgoraManager.getInstance(getActivity()).setLocalAudioEnabled(true,SpUtil.getUserId()+"");
|
||||
isShow = false;
|
||||
CommonAppContext.getInstance().isShowAg=false;
|
||||
|
||||
} else {
|
||||
mBinding.im1.setImageResource(com.xscm.moduleutil.R.mipmap.op_m);
|
||||
AgoraManager.getInstance(getActivity()).ClientRole(true);
|
||||
AgoraManager.getInstance(getActivity()).muteLocalAudioStream(true);
|
||||
AgoraManager.getInstance(getActivity()).setLocalAudioEnabled(false,SpUtil.getUserId()+"");
|
||||
isShow = true;
|
||||
CommonAppContext.getInstance().isShowAg=true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void isMute(int is_mute) {
|
||||
RoomMessageEvent.text text = new RoomMessageEvent.text();
|
||||
text.setIs_mute(is_mute);
|
||||
String s = com.blankj.utilcode.util.GsonUtils.toJson(text);
|
||||
RoomMessageEvent.T t = new RoomMessageEvent.T();
|
||||
t.setFromUserInfo(SpUtil.getUserInfo());
|
||||
t.setText(s);
|
||||
RoomMessageEvent roomMessageEvent = new RoomMessageEvent(126, roomInfoResp.getRoom_info().getRoom_id(), t);
|
||||
String json = com.blankj.utilcode.util.GsonUtils.toJson(roomMessageEvent);
|
||||
// 转换为 byte[]
|
||||
byte[] binaryData = json.getBytes(StandardCharsets.UTF_8);
|
||||
// 创建自定义消息
|
||||
MessageListenerSingleton.getInstance().sendCustomRoomMessage(
|
||||
roomId + "",
|
||||
binaryData
|
||||
);
|
||||
}
|
||||
|
||||
public void roomInfoEvent(RoomMessageEvent messageEvent) {
|
||||
if (messageEvent.getMsgType() == 1028) {
|
||||
mBinding.tvHeartValue2.setText(messageEvent.getText().getHot_value());
|
||||
}
|
||||
}
|
||||
|
||||
private void onHeartLineClicked(View view) {
|
||||
if (view.getId() == R.id.iv_exit) {
|
||||
// EventBus.getDefault().post(new RoomOutEvent());
|
||||
// ARouter.getInstance().build(ARouteConstants.LIVE_ROOM).withString("form","首页热门列表").withString("roomId", item.getRoom_id()).navigation();
|
||||
ExitRoomBottomSheet bottomSheet = ExitRoomBottomSheet.newInstance(false,true,true);
|
||||
|
||||
bottomSheet.setOnOptionSelectedListener(new ExitRoomBottomSheet.OnOptionSelectedListener() {
|
||||
@Override
|
||||
public void onMinimize() {
|
||||
// 处理最小化逻辑,比如不销毁 Activity,仅移至后台
|
||||
// CommonAppContext.getInstance().isShow = false;
|
||||
// ARouter.getInstance().build(ARouteConstants.ME).navigation();//栈顶复用
|
||||
// if (getActivity() instanceof RoomActivity) {
|
||||
// ((RoomActivity) getActivity()).moveTaskToBack(true);
|
||||
// }
|
||||
|
||||
// 在Activity中
|
||||
// Intent serviceIntent = new Intent(getContext(), FloatingWindowService.class);
|
||||
|
||||
// 判断是否已有浮窗正在显示
|
||||
// if (!EasyFloat.isShow("testFloat")) {
|
||||
// // 启动前台服务以维持浮窗
|
||||
// Context context = requireContext();
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
// // Android 12+ 需要指定 foregroundServiceType
|
||||
// Intent serviceIntent = new Intent(context, FloatingWindowService.class);
|
||||
// serviceIntent.setAction("ACTION_START_FLOAT");
|
||||
// context.startForegroundService(serviceIntent);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExitRoom() {
|
||||
CommonAppContext.getInstance().isMicPlace = false;
|
||||
// 调用退出房间方法
|
||||
if (label_id!=null && label_id.equals(LABEL_ID_MOVIE)){
|
||||
MvpPre.quitRoom(roomId, SpUtil.getUserId() + "");
|
||||
// ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("from", "我的界面").withString("roomId", AgoraManager.getInstance(getActivity()).getLastRoomId()).navigation();
|
||||
return;
|
||||
}
|
||||
if (roomInfoResp != null) {
|
||||
MvpPre.quitRoom(roomInfoResp.getRoom_info().getRoom_id(), SpUtil.getUserId() + "");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
// 用户点击取消,不做任何事
|
||||
}
|
||||
});
|
||||
bottomSheet.show(getChildFragmentManager(), "ExitRoomBottomSheet");
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: 2025/3/12 倒计时
|
||||
public void countDownTime(long time) {
|
||||
try {
|
||||
if (time <= 0) {
|
||||
setTime(0);
|
||||
releaseCountDownTimer();
|
||||
return;
|
||||
}
|
||||
releaseCountDownTimer();
|
||||
// 获取当前时间的毫秒值
|
||||
long currentTime = System.currentTimeMillis() / 1000L;
|
||||
// 计算倒计时的总秒数
|
||||
long countDownTime = (time - currentTime);
|
||||
Logger.d("小黑屋", "countDownTime = " + countDownTime);
|
||||
if (countDownTime <= 0) {
|
||||
setTime(0);
|
||||
releaseCountDownTimer();
|
||||
return;
|
||||
}
|
||||
mCountDownTimer = new CountDownTimer(countDownTime * 1000L, 1000L) {
|
||||
@Override
|
||||
public void onTick(long millisUntilFinished) {
|
||||
int time1 = (int) (millisUntilFinished / 1000);
|
||||
// pitBean.setCount_down(time1);
|
||||
setTime(time1);
|
||||
remainingTime = time1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
setTime(0);
|
||||
remainingTime = 0;
|
||||
}
|
||||
};
|
||||
mCountDownTimer.start();
|
||||
} catch (Exception e) {
|
||||
Logger.e("countDownTime", e);
|
||||
}
|
||||
}
|
||||
|
||||
private String formatTime(int totalSeconds) {
|
||||
int days = totalSeconds / (24 * 3600);
|
||||
int remaining = totalSeconds % (24 * 3600);
|
||||
|
||||
int hours = remaining / 3600;
|
||||
remaining %= 3600;
|
||||
|
||||
int minutes = remaining / 60;
|
||||
int seconds = remaining % 60;
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
if (days > 0) {
|
||||
sb.append(days).append("天");
|
||||
}
|
||||
|
||||
if (hours > 0 || days > 0) {
|
||||
sb.append(hours).append("小时");
|
||||
}
|
||||
|
||||
if (minutes > 0 || hours > 0 || days > 0) {
|
||||
sb.append(minutes).append("分");
|
||||
}
|
||||
|
||||
sb.append(seconds).append("秒");
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("DefaultLocale")
|
||||
public void setTime(int time) {
|
||||
if (time == 0) {
|
||||
mBinding.datingTime.setText("00:00:00");
|
||||
}
|
||||
String formattedTime = formatTime(time);
|
||||
if (label_id!=null && label_id.equals(LABEL_ID_MOVIE)){
|
||||
mBinding.datingTime.setText("倒计时:" + formattedTime);
|
||||
}else {
|
||||
mBinding.datingTime.setText("到期时间:" + formattedTime);
|
||||
}
|
||||
mBinding.datingTime.setVisibility(VISIBLE);
|
||||
}
|
||||
|
||||
private void releaseCountDownTimer() {
|
||||
if (mCountDownTimer != null) {
|
||||
mCountDownTimer.cancel();
|
||||
mCountDownTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.room_cabin_fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void roomInfoUpdate(RoomInfoResp resp) {
|
||||
roomInfoResp = resp;
|
||||
// updateWheatData();
|
||||
|
||||
if (roomInfoResp != null) {
|
||||
roomId = roomInfoResp.getRoom_info().getRoom_id();
|
||||
cpUserBean = roomInfoResp.getCp_user();
|
||||
label_id = roomInfoResp.getRoom_info().getLabel_id();
|
||||
}
|
||||
if (roomInfoResp != null && roomInfoResp.getRoom_owner().getUser_id().equals(SpUtil.getUserId()+"")){
|
||||
mBinding.im3.setVisibility(VISIBLE);
|
||||
// setvkk(false);
|
||||
}else {
|
||||
mBinding.im3.setVisibility(GONE);
|
||||
}
|
||||
|
||||
mBinding.ivExit.setOnClickListener(this::onHeartLineClicked);
|
||||
|
||||
// 获取当前用户 ID
|
||||
String currentUserId = SpUtil.getUserId() + "";
|
||||
|
||||
// 定义两个 RoomPitBean 对象,分别用于显示在 roomMakeWheat1 和 roomMakeWheat2
|
||||
RoomPitBean selfBean = new RoomPitBean(); // 自己的 bean
|
||||
RoomPitBean otherBean = new RoomPitBean(); // 另一个用户的 bean
|
||||
|
||||
boolean isSelfFirst = false;
|
||||
|
||||
// 判断当前用户是 user_id 还是 user_id1
|
||||
if (cpUserBean != null) {
|
||||
if (currentUserId.equals(cpUserBean.getUser_id())) {
|
||||
// 当前用户是 user_id
|
||||
selfBean.setUser_id(cpUserBean.getUser_id());
|
||||
selfBean.setUser_code(cpUserBean.getUser_code());
|
||||
selfBean.setNickname(cpUserBean.getNickname());
|
||||
selfBean.setAvatar(cpUserBean.getAvatar());
|
||||
selfBean.setDress(cpUserBean.getDress());
|
||||
selfBean.setPit_number("000");
|
||||
|
||||
otherBean.setUser_id(cpUserBean.getUser_id1());
|
||||
otherBean.setUser_code(cpUserBean.getUser_code1());
|
||||
otherBean.setNickname(cpUserBean.getNickname1());
|
||||
otherBean.setAvatar(cpUserBean.getAvatar1());
|
||||
otherBean.setDress(cpUserBean.getDress1());
|
||||
otherBean.setPit_number("000");
|
||||
|
||||
|
||||
} else if (currentUserId.equals(cpUserBean.getUser_id1())) {
|
||||
// 当前用户是 user_id1,则交换位置
|
||||
selfBean.setUser_id(cpUserBean.getUser_id1());
|
||||
selfBean.setUser_code(cpUserBean.getUser_code1());
|
||||
selfBean.setNickname(cpUserBean.getNickname1());
|
||||
selfBean.setAvatar(cpUserBean.getAvatar1());
|
||||
selfBean.setDress(cpUserBean.getDress1());
|
||||
selfBean.setPit_number("000");
|
||||
|
||||
otherBean.setUser_id(cpUserBean.getUser_id());
|
||||
otherBean.setUser_code(cpUserBean.getUser_code());
|
||||
otherBean.setNickname(cpUserBean.getNickname());
|
||||
otherBean.setAvatar(cpUserBean.getAvatar());
|
||||
otherBean.setDress(cpUserBean.getDress());
|
||||
otherBean.setPit_number("000");
|
||||
}
|
||||
}
|
||||
// 不论谁是自己,始终将自己放在 roomMakeWheat1
|
||||
mBinding.roomMakeWheat1.setData(selfBean);
|
||||
// 将另一个用户的数据放在 roomMakeWheat2
|
||||
mBinding.roomMakeWheat2.setData(otherBean);
|
||||
mBinding.tvMainTitle.setText(roomInfoResp.getRoom_info().getRoom_name());
|
||||
mBinding.tvHeartValue2.setText(roomInfoResp.getRoom_info().getHot_value());
|
||||
if (cpUserBean != null) {
|
||||
countDownTime(Long.parseLong(cpUserBean.getTime_day()));
|
||||
}
|
||||
// mediaProjectionManager = (MediaProjectionManager) getContext().getSystemService(Context.MEDIA_PROJECTION_SERVICE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerWheatViews() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unRegisterWheatViews() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initListener() {
|
||||
super.initListener();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] collectCurrentCardiacValues() {
|
||||
int[] cvs = new int[8];
|
||||
return cvs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void quitRoom() {
|
||||
if (getActivity() instanceof RoomActivity) {
|
||||
LogUtils.e("lxj", "退出房间时间:" + TimeUtils.date2String(new Date())+":退出的roomId"+roomId);
|
||||
MessageListenerSingleton.getInstance().quitGroup(roomId);
|
||||
((RoomActivity) getActivity()).quit();
|
||||
((RoomActivity) getActivity()).quitRoom2(roomId);
|
||||
if (label_id!=null && label_id.equals(LABEL_ID_MOVIE)){
|
||||
((RoomActivity) getActivity()).jiaR();
|
||||
//// ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("from", "我的界面").withString("roomId", AgoraManager.getInstance(getActivity()).getLastRoomId()).navigation();
|
||||
return;
|
||||
}else {
|
||||
((RoomActivity) getActivity()).performExitRoom(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// private MediaProjection[] mediaProjection = new MediaProjection[1];
|
||||
// private MediaProjectionManager mediaProjectionManager;
|
||||
// private final ActivityResultLauncher<Intent> mediaProjectionLauncher = registerForActivityResult(
|
||||
// new ActivityResultContracts.StartActivityForResult(),
|
||||
// result -> {
|
||||
// if (result.getResultCode() == Activity.RESULT_OK) {
|
||||
// try {
|
||||
// mediaProjection[0] = mediaProjectionManager
|
||||
// .getMediaProjection(result.getResultCode(), result.getData());
|
||||
// joinChannel();
|
||||
// } catch (Exception e) {
|
||||
// Log.e("RoomCabinFragment", "error msg: " + e.getMessage());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// );
|
||||
|
||||
private void isConfig() {
|
||||
|
||||
enableNotifications();
|
||||
}
|
||||
|
||||
|
||||
private void joinChannel() {
|
||||
|
||||
AgoraManager.getInstance(getActivity()).updateChannelMediaOptions();
|
||||
AgoraManager.getInstance(getActivity()).post();
|
||||
}
|
||||
|
||||
/**
|
||||
* IRtcEngineEventHandler is an abstract class providing default implementation.
|
||||
* The SDK uses this class to report to the app on SDK runtime events.
|
||||
*/
|
||||
private final IRtcEngineEventHandler iRtcEngineEventHandler = new IRtcEngineEventHandler() {
|
||||
/**
|
||||
* Error code description can be found at:
|
||||
* en: https://api-ref.agora.io/en/video-sdk/android/4.x/API/class_irtcengineeventhandler.html#callback_irtcengineeventhandler_onerror
|
||||
* cn: https://docs.agora.io/cn/video-call-4.x/API%20Reference/java_ng/API/class_irtcengineeventhandler.html#callback_irtcengineeventhandler_onerror
|
||||
*/
|
||||
@Override
|
||||
public void onError(int err) {
|
||||
Log.e("RoomCabinFragment", String.format("onError code %d message %s", err, RtcEngine.getErrorDescription(err)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJoinChannelSuccess(String channel, int uid, int elapsed) {
|
||||
Log.i("RoomCabinFragment", String.format("onJoinChannelSuccess channel %s uid %d", channel, uid));
|
||||
}
|
||||
|
||||
/// 本地视频状态回调
|
||||
@Override
|
||||
public void onLocalVideoStateChanged(Constants.VideoSourceType source, int state, int error) {
|
||||
super.onLocalVideoStateChanged(source, state, error);
|
||||
Log.i("RoomCabinFragment", "onLocalVideoStateChanged source=" + source + ", state=" + state + ", error=" + error);
|
||||
if (source == Constants.VideoSourceType.VIDEO_SOURCE_SCREEN_PRIMARY) {
|
||||
if (state == Constants.LOCAL_VIDEO_STREAM_STATE_ENCODING) {
|
||||
if (error == Constants.ERR_OK) {
|
||||
Logger.d("onLocalVideoStateChanged", "Screen sharing start successfully.");
|
||||
}
|
||||
} else if (state == Constants.LOCAL_VIDEO_STREAM_STATE_FAILED) {
|
||||
if (error == Constants.ERR_SCREEN_CAPTURE_SYSTEM_NOT_SUPPORTED) {
|
||||
Logger.e("onLocalVideoStateChanged", "Screen sharing has been cancelled");
|
||||
} else {
|
||||
Logger.e("onLocalVideoStateChanged", "Screen sharing failed. Error code: " + error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///报告远端视频状态
|
||||
@Override
|
||||
public void onRemoteVideoStateChanged(int uid, int state, int reason, int elapsed) {
|
||||
super.onRemoteVideoStateChanged(uid, state, reason, elapsed);
|
||||
Log.i("RoomCabinFragment", "onRemoteVideoStateChanged:uid->" + uid + ", state->" + state);
|
||||
}
|
||||
|
||||
///远端视频统计
|
||||
@Override
|
||||
public void onRemoteVideoStats(RemoteVideoStats stats) {
|
||||
super.onRemoteVideoStats(stats);
|
||||
Log.d("RoomCabinFragment", "onRemoteVideoStats: width:" + stats.width + " x height:" + stats.height);
|
||||
}
|
||||
///加入频道
|
||||
@Override
|
||||
public void onUserJoined(int uid, int elapsed) {
|
||||
super.onUserJoined(uid, elapsed);
|
||||
Log.i("RoomCabinFragment", "onUserJoined->" + uid);
|
||||
if (remoteUid > 0) {
|
||||
return;
|
||||
}
|
||||
remoteUid = uid;
|
||||
requireActivity().runOnUiThread(() -> {
|
||||
SurfaceView renderView = new SurfaceView(getContext());
|
||||
engine.setupRemoteVideo(new VideoCanvas(renderView, Constants.RENDER_MODE_FIT, uid));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 当远程用户(通信)/主机(直播)离开频道时触发。
|
||||
* *@参数 uid 要更改音频状态的用户的ID。
|
||||
* @参数 reason 用户离线的原因:
|
||||
* 用户离线退出(0):用户离开了当前频道。USER OFFLINE DROPPED(1):SDK超时,用户在一定时间内未接收到数据包,因此被标记为离线状态。如果用户在通话中退出,且消息未传递到SDK(因为信道不可靠),SDK 将假定用户已离线。
|
||||
* 用户离线成为观众(仅限直播)。客户端角色从主持人变为观众。
|
||||
* @param uid
|
||||
* @param reason
|
||||
*/
|
||||
@Override
|
||||
public void onUserOffline(int uid, int reason) {
|
||||
Log.i("RoomCabinFragment", String.format("user %d offline! reason:%d", uid, reason));
|
||||
// showLongToast(String.format("user %d offline! reason:%d", uid, reason));
|
||||
if (remoteUid == uid) {
|
||||
remoteUid = -1;
|
||||
requireActivity().runOnUiThread(() -> {
|
||||
engine.setupRemoteVideo(new VideoCanvas(null, Constants.RENDER_MODE_FIT, uid));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocalAudioStats(LocalAudioStats stats) {
|
||||
super.onLocalAudioStats(stats);
|
||||
Log.d("RoomCabinFragment", "onLocalAudioStats: " + stats.numChannels + " x " + stats.sentSampleRate + " Hz");
|
||||
}
|
||||
|
||||
///报告远端视频流状态监护
|
||||
@Override
|
||||
public void onRemoteAudioStateChanged(int uid, int state, int reason, int elapsed) {
|
||||
super.onRemoteAudioStateChanged(uid, state, reason, elapsed);
|
||||
Log.i("RoomCabinFragment", "onRemoteAudioStateChanged: uid->" + uid + ", state->" + state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFirstRemoteAudioFrame(int uid, int elapsed) {
|
||||
super.onFirstRemoteAudioFrame(uid, elapsed);
|
||||
Log.i("RoomCabinFragment", "onFirstRemoteAudioFrame: uid->" + uid);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
@Subscribe (threadMode = ThreadMode.MAIN)
|
||||
public void roomInfoEvent(CabinEvent messageEvent) {
|
||||
if (messageEvent.isJoined()){
|
||||
if (CommonAppContext.getInstance().isMicPlace) {
|
||||
isMicPlace = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
releaseResources();
|
||||
}
|
||||
|
||||
public void releaseResources(){
|
||||
releaseCountDownTimer();
|
||||
// ImageUtils.clearDiskCache(getActivity());
|
||||
// if (mediaProjection[0] != null) {
|
||||
// mediaProjection[0].stop();
|
||||
// mediaProjection[0] = null;
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
package com.xscm.modulemain.activity.room.fragment;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.blankj.utilcode.util.FragmentUtils;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.databinding.FragmentRoomChartsBinding;
|
||||
import com.example.moduletablayout.listener.CustomTabEntity;
|
||||
import com.example.moduletablayout.listener.OnTabSelectListener;
|
||||
import com.xscm.modulemain.activity.room.contacts.RoomChartsContacts;
|
||||
import com.xscm.modulemain.activity.room.presenter.RoomChartsPresenter;
|
||||
import com.xscm.moduleutil.base.BaseMvpDialogFragment;
|
||||
import com.xscm.moduleutil.bean.room.RoomInfoResp;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/6/10
|
||||
*@description: 房间排行榜
|
||||
*/
|
||||
public class RoomChartsFragment extends BaseMvpDialogFragment<RoomChartsPresenter, FragmentRoomChartsBinding> implements RoomChartsContacts.View {
|
||||
private String mRoomId;
|
||||
public static final int TYPE_CHARM = 1;//财富榜
|
||||
public static final int TYPE_WEALTH = 2;//魅力榜
|
||||
private int type = TYPE_CHARM;
|
||||
private int childType = RankingChildFragment.TYPE_DATA;
|
||||
private RoomInfoResp mRoomInfoResp;
|
||||
|
||||
public static RoomChartsFragment newInstance(String roomId,RoomInfoResp roomInfoResp) {
|
||||
RoomChartsFragment roomRankingFragment = new RoomChartsFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("roomId", roomId);
|
||||
bundle.putSerializable("roomInfoResp", roomInfoResp);
|
||||
roomRankingFragment.setArguments(bundle);
|
||||
return roomRankingFragment;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected RoomChartsPresenter bindPresenter() {
|
||||
return new RoomChartsPresenter( this,getActivity());
|
||||
}
|
||||
@Override
|
||||
protected void initDialogStyle(Window window) {
|
||||
super.initDialogStyle(window);
|
||||
window.setGravity(Gravity.BOTTOM);
|
||||
WindowManager.LayoutParams lp = window.getAttributes();
|
||||
lp.dimAmount = 0.4f;
|
||||
int screenHeight = getResources().getDisplayMetrics().heightPixels;
|
||||
lp.height = (int) (screenHeight * 0.8f); // 80% 高度
|
||||
lp.width = WindowManager.LayoutParams.MATCH_PARENT; // 宽度撑满
|
||||
window.setAttributes(lp);
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
mRoomId = getArguments().getString("roomId");
|
||||
mRoomInfoResp = (RoomInfoResp) getArguments().getSerializable("roomInfoResp");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
|
||||
FragmentUtils.add(getChildFragmentManager(), RankingChildFragment.newInstance(mRoomId, childType, type, mRoomInfoResp), R.id.fl_content);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
mBinding.slidingTabLayout.setOnTabSelectListener(new OnTabSelectListener() {
|
||||
@Override
|
||||
public void onTabSelect(int position) {
|
||||
childType = ++position;
|
||||
refresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabReselect(int position) {
|
||||
|
||||
}
|
||||
});
|
||||
ArrayList<CustomTabEntity> tabItems = new ArrayList<>();
|
||||
tabItems.add(new TabItem("小时榜"));
|
||||
tabItems.add(new TabItem("日榜"));
|
||||
tabItems.add(new TabItem("周榜"));
|
||||
mBinding.slidingTabLayout.setTabData(tabItems);
|
||||
|
||||
mBinding.tvCharm.setOnClickListener(this::onViewClicked);
|
||||
mBinding.tvWealth.setOnClickListener(this::onViewClicked);
|
||||
}
|
||||
private void refresh() {
|
||||
FragmentUtils.replace(getChildFragmentManager(), RankingChildFragment.newInstance(mRoomId, childType, type, mRoomInfoResp), R.id.fl_content);
|
||||
}
|
||||
|
||||
public static class TabItem implements CustomTabEntity {
|
||||
private String title;
|
||||
|
||||
public TabItem(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTabTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTabSelectedIcon() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTabUnselectedIcon() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
public void onViewClicked(View view) {
|
||||
int id = view.getId();
|
||||
if (id == R.id.tv_charm) {
|
||||
type = TYPE_WEALTH;//魅力
|
||||
mBinding.tvCharm.setTextColor(getResources().getColor(com.xscm.moduleutil.R.color.white));
|
||||
mBinding.tvWealth.setTextColor(getResources().getColor(com.xscm.moduleutil.R.color.color_DADADA));
|
||||
mBinding.tvCharm.setTextSize(18);
|
||||
mBinding.tvWealth.setTextSize(16);
|
||||
} else {
|
||||
type = TYPE_CHARM;//财富
|
||||
mBinding.tvWealth.setTextColor(getResources().getColor(com.xscm.moduleutil.R.color.white));
|
||||
mBinding.tvCharm.setTextColor(getResources().getColor(com.xscm.moduleutil.R.color.color_DADADA));
|
||||
mBinding.tvWealth.setTextSize(18);
|
||||
mBinding.tvCharm.setTextSize(16);
|
||||
}
|
||||
refresh();
|
||||
}
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fragment_room_charts;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,67 @@
|
||||
package com.xscm.modulemain.activity.room.fragment;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.blankj.utilcode.util.ScreenUtils;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.moduleutil.widget.dialog.BaseDialog;
|
||||
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/6/10
|
||||
*@description: 房间公告展示
|
||||
*/
|
||||
public class RoomNoticeDialogFragment extends BaseDialog {
|
||||
private Context mContext;
|
||||
private TextView tvTile;
|
||||
private TextView tvContent;
|
||||
private ImageView ivClose;
|
||||
String title, content;
|
||||
|
||||
public RoomNoticeDialogFragment(@NonNull Context context) {
|
||||
super(context);
|
||||
this.mContext = context;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.fragment_room_notice_dialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
getWindow().setLayout((int) (ScreenUtils.getScreenWidth() * 0.86), ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
tvTile=findViewById(R.id.tv_title);
|
||||
tvContent=findViewById(R.id.tv_content);
|
||||
ivClose=findViewById(R.id.iv_close);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
|
||||
|
||||
ivClose.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
tvContent.setText(content);
|
||||
}
|
||||
public void setTitle(String title) {
|
||||
tvTile.setText(title);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package com.xscm.modulemain.activity.room.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import com.blankj.utilcode.util.ScreenUtils;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.databinding.RoomDialogRoomPwSettingBinding;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.xscm.modulemain.activity.room.contacts.RoomPasswordSetContacts;
|
||||
import com.xscm.modulemain.activity.room.presenter.RoomPasswordSetPresenter;
|
||||
import com.xscm.moduleutil.base.BaseMvpDialogFragment;
|
||||
import com.xscm.moduleutil.event.PasswordInputEvent;
|
||||
import com.xscm.moduleutil.event.RoomOutEvent;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/6/9
|
||||
*@description: 输入密码弹窗
|
||||
*/
|
||||
public class RoomPasswordSetDialogFragment extends BaseMvpDialogFragment<RoomPasswordSetPresenter, RoomDialogRoomPwSettingBinding> implements RoomPasswordSetContacts.View {
|
||||
|
||||
private static final String TAG = "RoomPasswordSetDialogFragment";
|
||||
|
||||
|
||||
private boolean hidePwd;
|
||||
private String roomId;
|
||||
|
||||
public static RoomPasswordSetDialogFragment newInstance(boolean hidePwd, String roomId) {
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean("hidePwd", hidePwd);
|
||||
args.putString("roomId", roomId);
|
||||
RoomPasswordSetDialogFragment fragment = new RoomPasswordSetDialogFragment();
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initArgs(Bundle arguments) {
|
||||
super.initArgs(arguments);
|
||||
this.hidePwd = arguments.getBoolean("hidePwd");
|
||||
this.roomId = arguments.getString("roomId");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.room_dialog_room_pw_setting;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
//是否隐藏密码
|
||||
if (hidePwd) {
|
||||
mBinding.txTitle.setText("请输入房间密码");
|
||||
mBinding.useHintTxt.setVisibility(View.INVISIBLE);
|
||||
mBinding.gpvPswView.setPasswordVisibility(false);
|
||||
} else {
|
||||
mBinding.txTitle.setText("请设置房间密码");
|
||||
mBinding.useHintTxt.setVisibility(View.VISIBLE);
|
||||
mBinding.gpvPswView.setPasswordVisibility(true);
|
||||
}
|
||||
mBinding.btPw.setOnClickListener(this::onViewClicked);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDialogStyle(Window window) {
|
||||
super.initDialogStyle(window);
|
||||
int width = (int) (ScreenUtils.getScreenWidth() * 341.0 / 375);
|
||||
window.setLayout(width, WindowManager.LayoutParams.WRAP_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RoomPasswordSetPresenter bindPresenter() {
|
||||
return new RoomPasswordSetPresenter(this, getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
if (hidePwd) {
|
||||
EventBus.getDefault().post(new RoomOutEvent());
|
||||
}
|
||||
}
|
||||
|
||||
public void onViewClicked(View view) {
|
||||
String passWord = mBinding.gpvPswView.getPassWord();
|
||||
if (passWord.length() != 4 && passWord.length() > 0) {
|
||||
ToastUtils.show("请输入完整的密码");
|
||||
return;
|
||||
}
|
||||
if (hidePwd) {
|
||||
EventBus.getDefault().post(new PasswordInputEvent(passWord));
|
||||
hidePwd = false;
|
||||
dismiss();
|
||||
} else {
|
||||
MvpPre.setRoomPassword(roomId, passWord);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void roomPasswordSettingSuccess() {
|
||||
ToastUtils.show("密码设置成功");
|
||||
dismiss();
|
||||
}
|
||||
|
||||
public void show(FragmentManager manager) {
|
||||
show(manager, TAG);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,401 @@
|
||||
package com.xscm.modulemain.activity.room.fragment;
|
||||
|
||||
import static android.view.View.GONE;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import com.google.android.material.tabs.TabLayoutMediator;
|
||||
import com.stx.xhb.xbanner.XBanner;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.activity.msg.OfficialNoticeActivity;
|
||||
import com.xscm.modulemain.activity.room.activity.PopularRoomActivity;
|
||||
import com.xscm.modulemain.activity.room.activity.RankingListActivity;
|
||||
import com.xscm.modulemain.activity.room.contacts.VoiceCategoryContacts;
|
||||
import com.xscm.modulemain.activity.room.presenter.VoiceCategoryPresenter;
|
||||
import com.xscm.modulemain.adapter.CarouselBannerAdapter;
|
||||
import com.xscm.modulemain.databinding.FragmentVoiceCategoryBinding;
|
||||
import com.xscm.modulemain.activity.WebViewActivity;
|
||||
import com.xscm.modulemain.manager.RoomManager;
|
||||
import com.xscm.moduleutil.base.BaseMvpFragment;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.bean.BannerModel;
|
||||
import com.xscm.moduleutil.bean.RoomTypeModel;
|
||||
import com.xscm.moduleutil.bean.TopRoom;
|
||||
import com.xscm.moduleutil.event.MqttBean;
|
||||
import com.xscm.moduleutil.event.RoomGiftRunable;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
import com.xscm.moduleutil.utils.logger.DataLogger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 声播
|
||||
*/
|
||||
public class VoiceCategoryFragment extends BaseMvpFragment<VoiceCategoryPresenter, FragmentVoiceCategoryBinding> implements VoiceCategoryContacts.View {
|
||||
|
||||
public static final String TYPE_ME = "-1";
|
||||
public static final String TYPE_RECOMMEND = "-2";
|
||||
public static final String TYPE_HOT = "-3";
|
||||
public static final String TYPE_ORDER = "-4";
|
||||
public static final String TYPE_INDEX = "index";
|
||||
|
||||
private List<TopRoom> roomList;
|
||||
|
||||
private List<MqttBean.ListBean> mqttList;
|
||||
private List<String> info;
|
||||
CarouselBannerAdapter carouselBannerAdapter;
|
||||
|
||||
private VoiceFragment voiceFragment;
|
||||
|
||||
public VoiceCategoryFragment () {
|
||||
}
|
||||
|
||||
|
||||
public VoiceCategoryFragment (VoiceFragment voiceFragment){
|
||||
this.voiceFragment = voiceFragment;
|
||||
}
|
||||
|
||||
public static VoiceCategoryFragment newInstance(VoiceFragment voiceFragment) {
|
||||
return new VoiceCategoryFragment(voiceFragment);
|
||||
}
|
||||
|
||||
public void showLoading(){
|
||||
voiceFragment.isShowLoading(true);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
return super.onCreateView(inflater, container, savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected VoiceCategoryPresenter bindPresenter() {
|
||||
return new VoiceCategoryPresenter(this, getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
MvpPre.getBanners();
|
||||
MvpPre.getCarousels(1, 1, "10", "2", "");//顶部推荐
|
||||
MvpPre.getCategories();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
|
||||
|
||||
mBinding.banner.loadImage(new XBanner.XBannerAdapter() {
|
||||
@Override
|
||||
public void loadBanner(XBanner banner, Object model, View view, int position) {
|
||||
BannerModel bannerModel = (BannerModel) model;
|
||||
ImageUtils.loadCenterCrop((String) bannerModel.getXBannerUrl(), (ImageView) view);
|
||||
}
|
||||
});
|
||||
mBinding.banner.setOnItemClickListener(new XBanner.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(XBanner banner, Object model, View view, int position) {
|
||||
/**
|
||||
* 1房间2文章3链接 其他详情图
|
||||
*
|
||||
* type=1时,该值表示房间id;type=2时,表示文章id
|
||||
*/
|
||||
BannerModel bannerModel = (BannerModel) model;
|
||||
Intent intent=new Intent(getActivity(), WebViewActivity.class);
|
||||
intent.putExtra("url", bannerModel.getUrl());
|
||||
intent.putExtra("title", "首页横幅");
|
||||
startActivity(intent);
|
||||
// ARouter.getInstance().build(ARouteConstants.H5).withString("url", bannerModel.getUrl()).withString("title", "首页横幅").navigation();
|
||||
}
|
||||
});
|
||||
DisplayMetrics displayMetrics = new DisplayMetrics();
|
||||
requireActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
|
||||
|
||||
carouselBannerAdapter = new CarouselBannerAdapter();
|
||||
mBinding.bannerViewPager
|
||||
.setAdapter(carouselBannerAdapter)
|
||||
.create();
|
||||
|
||||
mBinding.bannerViewPager.setIndicatorVisibility(GONE);
|
||||
mBinding.constraintLayout.setVisibility(GONE);
|
||||
|
||||
carouselBannerAdapter.setOnItemClickListener((view, data, position) -> {
|
||||
// 示例:跳转到房间 详情页
|
||||
if (data != null) {
|
||||
showLoading();
|
||||
RoomManager.getInstance().fetchRoomDataAndEnter(getActivity(), data.getRoom_id() ,"",null);
|
||||
}
|
||||
});
|
||||
|
||||
mBinding.tvWg.setOnClickListener(v -> {
|
||||
if (mBinding.marqueeView == null || mqttList == null || mqttList.isEmpty()) {
|
||||
// 可以选择在这里添加日志或提示
|
||||
// Log.w(TAG, "MarqueeView or mqttList is null/empty, cannot handle click.");
|
||||
return; // 直接返回,不执行后续操作
|
||||
}
|
||||
try {
|
||||
int position = mBinding.marqueeView.getPosition();
|
||||
// 检查 position 是否有效
|
||||
if (position < 0 || position >= mqttList.size()) {
|
||||
// Log.w(TAG, "Invalid position from MarqueeView: " + position);
|
||||
return; // 位置无效,直接返回
|
||||
}
|
||||
// 获取对应的 MqttBean.ListBean 对象
|
||||
MqttBean.ListBean item = mqttList.get(position);
|
||||
if (item != null) { // 再次检查 item 是否为 null
|
||||
String roomId = item.getRoom_id(); // 或者 item.getRoomId(); 确保方法名正确
|
||||
if (roomId != null && !roomId.isEmpty()) { // 检查 roomId 是否有效
|
||||
showLoading();
|
||||
RoomManager.getInstance().fetchRoomDataAndEnter(getActivity(), roomId,"",null);
|
||||
} else {
|
||||
// Log.d(TAG, "Room ID is null or empty for item at position: " + position);
|
||||
}
|
||||
} else {
|
||||
// Log.w(TAG, "Item at position " + position + " is null in mqttList.");
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
});
|
||||
|
||||
mBinding.homePhb.setOnClickListener(v -> {
|
||||
startActivity(new Intent(getContext(), RankingListActivity.class));
|
||||
});
|
||||
|
||||
mBinding.myHome.setOnClickListener(v -> {
|
||||
ARouter.getInstance().build(ARouteConstants.MY_ROOM).navigation();
|
||||
});
|
||||
|
||||
mBinding.homeGg.setOnClickListener(v -> {
|
||||
Intent intent=new Intent(getActivity(), OfficialNoticeActivity.class);
|
||||
intent.putExtra("type", "2");
|
||||
startActivity(intent);
|
||||
});
|
||||
|
||||
mBinding.imX.setOnClickListener(v -> {
|
||||
Intent intent=new Intent(getActivity(), PopularRoomActivity.class);
|
||||
startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
||||
public void onEvent1() {
|
||||
try {
|
||||
List<MqttBean> cachedMqttBeans = RoomGiftRunable.getMqttCache();
|
||||
if (cachedMqttBeans == null || cachedMqttBeans.isEmpty()) {
|
||||
mBinding.rl.setVisibility(GONE);
|
||||
} else {
|
||||
mBinding.rl.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if (mqttList == null) {
|
||||
mqttList = new ArrayList<>();
|
||||
info = new ArrayList<>();
|
||||
}
|
||||
mqttList.clear();
|
||||
info.clear();
|
||||
// 处理缓存数据
|
||||
|
||||
// 处理每一条 mqttBean 数据
|
||||
// for (MqttBean mqttBean : cachedMqttBeans) {
|
||||
// mqttList.addAll(mqttBean.getList());
|
||||
// info.add(mqttBean.getList().getFromUserName() + "送给" + mqttBean.getList().getToUserName() + "\n" + mqttBean.getList().getGiftName());
|
||||
//// info.add(mqttBean.getList().getFromUserName() + "送给" + mqttBean.getList().getToUserName() + "\n" + mqttBean.getList().getGiftName());
|
||||
// }
|
||||
|
||||
for (int i=0;i<cachedMqttBeans.size();i++){
|
||||
mqttList.addAll(cachedMqttBeans.get(i).getList());
|
||||
}
|
||||
for (int i=0;i<mqttList.size();i++){
|
||||
info.add(mqttList.get(i).getFromUserName() + "送给" + mqttList.get(i).getToUserName() + "\n" + mqttList.get(i).getGiftName());
|
||||
}
|
||||
|
||||
|
||||
mBinding.marqueeView.startWithList(info);
|
||||
} catch (Exception e) {
|
||||
DataLogger.LogUtil.d("onEvent1");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fragment_voice_category;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
onEvent1();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCategories(List<RoomTypeModel> list) {
|
||||
// // 数据有效性检查
|
||||
if (list == null || list.isEmpty() || getActivity() == null) {
|
||||
try {
|
||||
ToastUtils.showLong("登录已过期,请重新登录");
|
||||
CommonAppContext.getInstance().clearLoginInfo();
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 创建适配器
|
||||
MyFragmentPagerAdapter adapter = new MyFragmentPagerAdapter(getActivity(), list);
|
||||
mBinding.viewPager.setAdapter(adapter);
|
||||
|
||||
// 设置 TabLayout 与 ViewPager2 的关联
|
||||
new TabLayoutMediator(mBinding.slidingTabLayout, mBinding.viewPager,
|
||||
(tab, position) -> {
|
||||
// 边界检查
|
||||
if (position >= 0 && position < list.size() && list.get(position) != null) {
|
||||
// 创建自定义布局
|
||||
View customView = LayoutInflater.from(requireContext())
|
||||
.inflate(R.layout.custom_tab_layout, null);
|
||||
TextView textView = customView.findViewById(R.id.tab_text);
|
||||
textView.setText(list.get(position).getLabel_name());
|
||||
|
||||
// 设置初始状态
|
||||
if (position == 0) {
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
|
||||
textView.setTextColor(getResources().getColor(android.R.color.white));
|
||||
// customView.setBackgroundResource(com.xscm.moduleutil.R.drawable.tab_indicator);
|
||||
} else {
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
|
||||
textView.setTextColor(Color.parseColor("#F1ECFF"));
|
||||
// customView.setBackgroundResource(com.xscm.moduleutil.R.drawable.tab_unselected_background);
|
||||
}
|
||||
|
||||
tab.setCustomView(customView);
|
||||
}
|
||||
}
|
||||
).attach();
|
||||
|
||||
mBinding.slidingTabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
||||
@Override
|
||||
public void onTabSelected(TabLayout.Tab tab) {
|
||||
int position = tab.getPosition();
|
||||
// 边界检查
|
||||
if (position >= 0 && position < list.size()) {
|
||||
View customView = tab.getCustomView();
|
||||
if (customView != null) {
|
||||
TextView textView = customView.findViewById(R.id.tab_text);
|
||||
if (textView != null) {
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
|
||||
textView.setTextColor(getResources().getColor(android.R.color.white));
|
||||
}
|
||||
// customView.setBackgroundResource(com.xscm.moduleutil.R.drawable.tab_indicator);
|
||||
}
|
||||
|
||||
RoomTypeModel roomTypeModel = list.get(position);
|
||||
String categoryId = roomTypeModel.getId();
|
||||
HotListFragment.newInstance(VoiceCategoryFragment.this,categoryId, TYPE_INDEX);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabUnselected(TabLayout.Tab tab) {
|
||||
// 直接通过 TabLayout 设置未选中状态的文字大小
|
||||
View customView = tab.getCustomView();
|
||||
if (customView != null) {
|
||||
TextView textView = customView.findViewById(R.id.tab_text);
|
||||
if (textView != null) {
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
|
||||
textView.setTextColor(Color.parseColor("#F1ECFF"));
|
||||
}
|
||||
customView.setBackgroundResource(com.xscm.moduleutil.R.drawable.tab_unselected_background);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabReselected(TabLayout.Tab tab) {
|
||||
}
|
||||
});
|
||||
|
||||
// 设置默认选中的标签
|
||||
if (mBinding.slidingTabLayout.getTabCount() > 0) {
|
||||
mBinding.slidingTabLayout.selectTab(mBinding.slidingTabLayout.getTabAt(0));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBanners(List<BannerModel> bannerModels) {
|
||||
mBinding.banner.setBannerData(R.layout.index_image_banner, bannerModels);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setRoomId(String roomId) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTopRoom(List<TopRoom> topRooms, int type) {
|
||||
// if (topRooms == null || topRooms.isEmpty() || topRooms.size() < 1) {
|
||||
// mBinding.constraintLayout.setVisibility(View.GONE);
|
||||
// return;
|
||||
// }else {
|
||||
mBinding.constraintLayout.setVisibility(View.VISIBLE);
|
||||
// }
|
||||
roomList = topRooms;
|
||||
mBinding.bannerViewPager.create(topRooms); // 刷新数据并启动自动播放
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishRefreshLoadMore() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
private class MyFragmentPagerAdapter extends FragmentStateAdapter {
|
||||
|
||||
private List<RoomTypeModel> list;
|
||||
|
||||
public MyFragmentPagerAdapter(@NonNull FragmentActivity fragmentActivity, List<RoomTypeModel> list) {
|
||||
super(fragmentActivity);
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment createFragment(int position) {
|
||||
RoomTypeModel roomTypeModel = list.get(position);
|
||||
String categoryId = roomTypeModel.getId();
|
||||
return HotListFragment.newInstance(VoiceCategoryFragment.this,categoryId, TYPE_INDEX);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
package com.xscm.modulemain.activity.room.fragment;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.activity.room.activity.RankingListActivity;
|
||||
import com.xscm.modulemain.activity.room.activity.SearchActivity;
|
||||
import com.xscm.modulemain.activity.room.contacts.VoiceContacts;
|
||||
import com.xscm.modulemain.databinding.FragmentVoiceBinding;
|
||||
import com.xscm.modulemain.activity.room.presenter.VoicePresenter;
|
||||
import com.xscm.moduleutil.adapter.MyFragmentPagerAdapter;
|
||||
import com.xscm.moduleutil.base.BaseMvpFragment;
|
||||
import com.xscm.moduleutil.bean.ActivitiesPermission;
|
||||
import com.xscm.moduleutil.bean.FirstChargeGiftBean;
|
||||
import com.xscm.moduleutil.dialog.FirstChargeDialog;
|
||||
import com.xscm.moduleutil.dialog.RechargeDialogFragment;
|
||||
import com.xscm.modulemain.dialog.YouthModelDialog;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
|
||||
|
||||
public class VoiceFragment extends BaseMvpFragment<VoicePresenter, FragmentVoiceBinding> implements VoiceContacts.View {
|
||||
// private MyInfoResp mMyInfoResp;
|
||||
|
||||
public static VoiceFragment newInstance () {
|
||||
return new VoiceFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData () {
|
||||
MvpPre.getConfig();//
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
isShowLoading(false);
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
public void isShowLoading(boolean isShowLoading){
|
||||
if (isShowLoading) {
|
||||
mBinding.coolWaitView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
Observable.timer(5, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe(aLong -> {
|
||||
mBinding.coolWaitView.setVisibility(View.GONE);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView () {
|
||||
|
||||
|
||||
mBinding.llSearch.setOnClickListener(v -> {
|
||||
// ARouter.getInstance().build(ARouteConstants.INDEX_SEARCH).navigation();
|
||||
|
||||
});
|
||||
|
||||
mBinding.ivRoom.setOnClickListener(v -> {
|
||||
//我的房间
|
||||
ARouter.getInstance().build(ARouteConstants.MY_ROOM).withFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT).navigation();
|
||||
});
|
||||
|
||||
|
||||
mBinding.ivRoom3.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(getContext(), SearchActivity.class);
|
||||
startActivity(intent);
|
||||
});
|
||||
|
||||
mBinding.ivRankingList.setOnClickListener(v -> {
|
||||
startActivity(new Intent(getContext(), RankingListActivity.class));
|
||||
});
|
||||
// 检查是否需要显示青少年模式弹窗
|
||||
if (!shouldShowYouthModelDialog()) {
|
||||
showYouthModelDialog();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean shouldShowYouthModelDialog() {
|
||||
// 从 SharedPreferences 中获取是否已经显示过青少年模式弹窗
|
||||
boolean isYouthModelShown = SpUtil.getBooleanValue("youth_model_shown",false);
|
||||
return isYouthModelShown;
|
||||
}
|
||||
private void showYouthModelDialog() {
|
||||
YouthModelDialog youthModelDialog = new YouthModelDialog(getContext(), null);
|
||||
youthModelDialog.show();
|
||||
youthModelDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
// 记录已经显示过青少年模式弹窗
|
||||
SpUtil.setBooleanValue("youth_model_shown", true);
|
||||
dialog.dismiss();
|
||||
MvpPre.activitiesPermission();
|
||||
|
||||
// 在这里可以继续显示其他弹窗,如首充弹窗
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: 2025/10/12 首充好礼
|
||||
private void firstCharge(){
|
||||
FirstChargeDialog firstChargeDialog = new FirstChargeDialog(getActivity());
|
||||
firstChargeDialog.show();
|
||||
firstChargeDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
//首充弹窗关闭后,弹首充
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
firstChargeDialog.setOnFirstChargeListener(new FirstChargeDialog.OnFirstChargeListener() {
|
||||
@Override
|
||||
public void onFirstChargeConfirmed(FirstChargeGiftBean giftBean, int type) {
|
||||
String s = "";
|
||||
String gift_bag_id= "";
|
||||
if (giftBean.getGift_bag().size()!=0) {
|
||||
gift_bag_id = giftBean.getGift_bag().get(0).getGift_bag_id();
|
||||
s = giftBean.getGift_bag().get(0).getMoney();
|
||||
}
|
||||
if (s == null) {
|
||||
ToastUtils.showShort("暂无礼物");
|
||||
return;
|
||||
}
|
||||
|
||||
RechargeDialogFragment.show(null, s, getChildFragmentManager(),gift_bag_id,"1");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFirstChargeCancelled() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initListener () {
|
||||
super.initListener();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId () {
|
||||
return R.layout.fragment_voice;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected VoicePresenter bindPresenter () {
|
||||
return new VoicePresenter(this, getContext());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void hideRecommend ( boolean hideRecommend, boolean hideGame){
|
||||
List<Fragment> fragments = new ArrayList<>();
|
||||
fragments.add(VoiceCategoryFragment.newInstance(VoiceFragment.this));
|
||||
mBinding.viewPager.setAdapter(new MyFragmentPagerAdapter(fragments, getChildFragmentManager()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activitiesPermissionSuccess(ActivitiesPermission activitiesPermission) {
|
||||
if (activitiesPermission != null) {
|
||||
if (activitiesPermission.getFirst_charge_permission() == 1) {
|
||||
firstCharge();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.blankj.utilcode.util.ObjectUtils;
|
||||
import com.xscm.modulemain.activity.room.contacts.BidListContacts;
|
||||
import com.xscm.moduleutil.bean.room.RoomAuction;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class BidListPresenter extends BasePresenter<BidListContacts.View> implements BidListContacts.IRoomPre {
|
||||
public BidListPresenter(BidListContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void roomAuctionList(String auction_id) {
|
||||
api.roomAuctionList(auction_id, new BaseObserver<List<RoomAuction.AuctionListBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<RoomAuction.AuctionListBean> auctionListBeans) {
|
||||
List<RoomAuction.AuctionListBean> lists = auctionListBeans;
|
||||
if (!ObjectUtils.isEmpty(lists)) {//lists判空
|
||||
//榜一
|
||||
if (lists.size() > 0) {
|
||||
MvpRef.get().setNo1(lists.get(0));
|
||||
}
|
||||
//榜二
|
||||
if (lists.size() > 1) {
|
||||
MvpRef.get().setNo2(lists.get(1));
|
||||
}
|
||||
//榜三
|
||||
if (lists.size() > 2) {
|
||||
MvpRef.get().setNo3(lists.get(2));
|
||||
}
|
||||
//第四名及后
|
||||
if (lists.size() > 3) {
|
||||
MvpRef.get().roomAuctionList(lists.subList(3, lists.size()));
|
||||
}
|
||||
}else {
|
||||
MvpRef.get().setCharmEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.xscm.modulemain.activity.room.contacts.CardRelationshipContacts;
|
||||
import com.xscm.moduleutil.bean.RoomRelationBean;
|
||||
import com.xscm.moduleutil.bean.RoomTime;
|
||||
import com.xscm.moduleutil.bean.RoonGiftModel;
|
||||
import com.xscm.moduleutil.bean.room.AuctionBean;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class CardRelationshipPresenter extends BasePresenter<CardRelationshipContacts.View> implements CardRelationshipContacts.IRoomPre{
|
||||
public CardRelationshipPresenter(CardRelationshipContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void roomRelationList(String type) {
|
||||
api.roomRelationList(type, new BaseObserver<List<RoomRelationBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<RoomRelationBean> roomRelationBeans) {
|
||||
MvpRef.get().roomRelationList(roomRelationBeans);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGiftList(String id) {
|
||||
api.getGiftList(Integer.parseInt(id),"", new BaseObserver<List<RoonGiftModel>>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<RoonGiftModel> roonGiftModels) {
|
||||
MvpRef.get().setGiftList(roonGiftModels);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void roomAuction(String roomId, String userId, String giftId, String relation_id, String auction_type, String time_day) {
|
||||
api.roomAuction(roomId,userId,giftId,relation_id,auction_type,time_day, new BaseObserver<AuctionBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable( d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(AuctionBean auctionBean) {
|
||||
MvpRef.get().roomAuction(auctionBean);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void roomAuctionTime(String gift_id) {
|
||||
api.roomAuctionTime(gift_id, new BaseObserver<RoomTime>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(RoomTime roomTime) {
|
||||
MvpRef.get().roomAuctionTime(roomTime);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.xscm.modulemain.activity.room.contacts.ChatRoomContacts;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
|
||||
public class ChatRoomPresenter extends BasePresenter<ChatRoomContacts.View> implements ChatRoomContacts.IPublicScreenEaseChatPre {
|
||||
public ChatRoomPresenter(ChatRoomContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logEmchat(int code, String msg, String toChatUsername) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void switchPublicScreen(String room_id, String status) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.blankj.utilcode.util.ObjectUtils;
|
||||
import com.xscm.modulemain.activity.room.contacts.DataListContacts;
|
||||
import com.xscm.moduleutil.base.BaseRoomPresenter;
|
||||
import com.xscm.moduleutil.bean.CharmRankingResp;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/6/10
|
||||
*@description: 排行榜
|
||||
*/
|
||||
public class DataListPresenter extends BaseRoomPresenter<DataListContacts.View> implements DataListContacts.IRoomDataListPre {
|
||||
private static final String TAG = "DataListPresenter";
|
||||
|
||||
public DataListPresenter(DataListContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void getCharmListInfo(String roomId, String type, String time_type, String page, String page_limit) {
|
||||
|
||||
api.getRoomRank(roomId, type,time_type,page,page_limit, new BaseObserver<List<CharmRankingResp>>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<CharmRankingResp> charmRankingResp) {
|
||||
if (!ObjectUtils.isEmpty(charmRankingResp)){
|
||||
if (charmRankingResp.size()>0){
|
||||
MvpRef.get().setNo1(charmRankingResp.get(0));
|
||||
}
|
||||
if (charmRankingResp.size()>1){
|
||||
MvpRef.get().setNo2(charmRankingResp.get(1));
|
||||
}
|
||||
if (charmRankingResp.size()>2){
|
||||
MvpRef.get().setNo3(charmRankingResp.get(2));
|
||||
}
|
||||
if (charmRankingResp.size()>3) {
|
||||
MvpRef.get().setCharmEmpty(charmRankingResp.subList(3, charmRankingResp.size()));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getWealthListInfo(String roomId, String type, String time_type, String page, String page_limit) {
|
||||
api.getRoomRank(roomId, type,time_type,page,page_limit, new BaseObserver<List<CharmRankingResp>>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<CharmRankingResp> charmRankingResp) {
|
||||
if (!ObjectUtils.isEmpty(charmRankingResp)){
|
||||
if (charmRankingResp.size()>0){
|
||||
MvpRef.get().setNo1(charmRankingResp.get(0));
|
||||
}
|
||||
if (charmRankingResp.size()>1){
|
||||
MvpRef.get().setNo2(charmRankingResp.get(1));
|
||||
}
|
||||
if (charmRankingResp.size()>2){
|
||||
MvpRef.get().setNo3(charmRankingResp.get(2));
|
||||
}
|
||||
if (charmRankingResp.size()>3) {
|
||||
MvpRef.get().setWealthEmpty(charmRankingResp.subList(3, charmRankingResp.size()));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.xscm.modulemain.activity.room.contacts.FriendshipRoomContacts;
|
||||
import com.xscm.moduleutil.base.BaseRoomPresenter;
|
||||
import com.xscm.moduleutil.bean.UserOnlineStatusBean;
|
||||
import com.xscm.moduleutil.bean.room.FriendUserBean;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.http.RetrofitClient;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class FriendshipRoomPresenter extends BaseRoomPresenter<FriendshipRoomContacts.View> implements FriendshipRoomContacts.IRoomPre{
|
||||
FriendshipRoomContacts.View mView;
|
||||
|
||||
public FriendshipRoomPresenter(FriendshipRoomContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
mView = view;
|
||||
}
|
||||
@Override
|
||||
public void applyPit(String roomId, String pitNumber) {
|
||||
api.applyPit(roomId, pitNumber, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
MvpRef.get().applyPit();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startFriend(String roomId) {
|
||||
api.startFriend(roomId, new BaseObserver<String>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable( d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delay(String friend_id, String room_id, String delay_times) {
|
||||
api.delay(friend_id, room_id, delay_times, new BaseObserver<String>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endFriend(String friend_id, String room_id) {
|
||||
api.endFriend(friend_id, room_id, new BaseObserver<FriendUserBean>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(FriendUserBean friendUserBean) {
|
||||
MvpRef.get().endFriend(friendUserBean);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: 2025/8/24 交友房选择关系
|
||||
@Override
|
||||
public void createRelation(String room_id, String friend_id, String user1_id, String user2_id, String relation_id) {
|
||||
api.createRelation(room_id,friend_id,user1_id,user2_id,relation_id, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
MvpRef.get().createRelation();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void userOnlineStatus(String userId, String roomid) {
|
||||
RetrofitClient.getInstance().userOnlineStatus(userId, roomid, new BaseObserver<List<UserOnlineStatusBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<UserOnlineStatusBean> userOnlineStatusBean) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().userOnlineStatus(userOnlineStatusBean);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,235 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.xscm.modulemain.activity.room.contacts.HotListContacts;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.bean.TopRoom;
|
||||
import com.xscm.moduleutil.bean.room.RoomInfoResp;
|
||||
import com.xscm.moduleutil.http.APIException;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
import com.xscm.moduleutil.rtc.AgoraManager;
|
||||
import com.xscm.moduleutil.utils.GsonUtils;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class HotListPresenter extends BasePresenter<HotListContacts.View> implements HotListContacts.IHotListPre {
|
||||
HotListContacts.View mView;
|
||||
|
||||
public HotListPresenter(HotListContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
mView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getRoomList(int type, String page, String page_limit, String is_top, String label_id) {
|
||||
Type listType = new TypeToken<List<TopRoom>>() {}.getType();
|
||||
List<TopRoom> restoredRoomModels = GsonUtils.getGSON().fromJson(SpUtil.getTopRoom(), listType);
|
||||
if (restoredRoomModels!= null && restoredRoomModels.size() > 0 ) {
|
||||
// MvpRef.get().roomList(restoredRoomModels, type);
|
||||
}
|
||||
api.getTopRooms(page+"",page_limit,is_top,label_id,new BaseObserver<List<TopRoom>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<TopRoom> topRooms) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
HotListContacts.View view = MvpRef.get();
|
||||
if (view != null) {
|
||||
if (topRooms != null) {
|
||||
SpUtil.setTopRoom("");
|
||||
SpUtil.setTopRoom(GsonUtils.getGSON().toJson(topRooms));
|
||||
view.roomList(topRooms, type);
|
||||
} else {
|
||||
view.roomList(new ArrayList<>(), type);
|
||||
}
|
||||
view.finishRefreshLoadMore();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: 2025/6/10 加入房间
|
||||
@Override
|
||||
public void getRoomIn(String roomId, String password) {
|
||||
|
||||
// Type listType = new TypeToken<RoomInfoResp>() {}.getType();
|
||||
// RoomInfoResp restoredRoomModels = GsonUtils.getGSON().fromJson(SpUtil.getRoomInfoResp(), listType);
|
||||
// if (restoredRoomModels!= null ) {
|
||||
// MvpRef.get().roomInfo(restoredRoomModels);
|
||||
// }
|
||||
|
||||
api.roomGetIn(roomId, password, new BaseObserver<RoomInfoResp>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(RoomInfoResp resp) {
|
||||
String appId = CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId();
|
||||
String token = resp.getUser_info().getAgora_token(); // 如果启用了鉴权才需要
|
||||
String roomId = resp.getRoom_info().getRoom_id(); // 房间 ID
|
||||
String rtm_token=resp.getUser_info().getAgora_rtm_token();
|
||||
SpUtil.setRtmToken(rtm_token);
|
||||
int uid = SpUtil.getUserId(); // 0 表示由 Agora 自动生成 UID
|
||||
boolean enableMic = false; // 是否开启麦克风
|
||||
boolean enableJs=false; // 是否开启角色
|
||||
if (resp.getUser_info().getPit_number()!=0){
|
||||
enableJs=true;
|
||||
}
|
||||
LogUtils.e("token",token);
|
||||
LogUtils.e("roomId:",roomId);
|
||||
// 初始化 Agora 并加入房间
|
||||
AgoraManager.getInstance(getView().getSelfActivity())
|
||||
.joinRoom(token, roomId, uid, enableMic,enableJs);
|
||||
// 2. 加入房间
|
||||
// rtcCore.joinRoom(token, roomId, uid, enableMic);
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().roomInfo(resp);
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
super.onError(e);
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
if (e instanceof APIException) {
|
||||
APIException apiException = (APIException) e;
|
||||
if (apiException.getCode() == 10000) {
|
||||
MvpRef.get().showPasswordDialog();
|
||||
} else {
|
||||
MvpRef.get().enterFail();
|
||||
}
|
||||
} else {
|
||||
MvpRef.get().enterFail();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMoreRoomList(String userId) {
|
||||
// Type listType = new TypeToken<List<HomeBean>>() {}.getType();
|
||||
// List<HomeBean> restoredRoomModels = GsonUtils.getGSON().fromJson(SpUtils.getHomeBean(), listType);
|
||||
// if (restoredRoomModels != null && restoredRoomModels.size() > 0) {
|
||||
// MvpRef.get().getMoreRoomList(restoredRoomModels);
|
||||
// }
|
||||
// ApiClient.getInstance().homepageBend(userId, new BaseObserver<List<HomeBean>>() {
|
||||
// @Override
|
||||
// public void onSubscribe(Disposable d) {
|
||||
// addDisposable(d);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(List<HomeBean> roomModels) {
|
||||
//// MvpRef.get().roomList(roomModels);
|
||||
//
|
||||
//// SpUtils.setHomeBean(GsonUtils.getGSON().toJson(roomModels));
|
||||
//// MvpRef.get().getMoreRoomList(roomModels);
|
||||
//
|
||||
// String newHomeBeanJson = GsonUtils.getGSON().toJson(roomModels);
|
||||
// // 从本地缓存中读取现有的数据
|
||||
// String existingHomeBeanJson = SpUtils.getHomeBean();
|
||||
// // 比较新获取的数据和缓存中的数据是否一致
|
||||
// if (!newHomeBeanJson.equals(existingHomeBeanJson)) {
|
||||
// // 如果不一致,保存新数据到本地缓存
|
||||
// SpUtils.setHomeBean(newHomeBeanJson);
|
||||
// // 并调用方法处理新数据
|
||||
// MvpRef.get().getMoreRoomList(roomModels);
|
||||
// }else {
|
||||
// MvpRef.get().finishRefreshLoadMore();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
// MvpRef.get().finishRefreshLoadMore();
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
// TODO: 2025/4/23 推荐
|
||||
@Override
|
||||
public void getRoomListTow() {
|
||||
// Type listType = new TypeToken<List<RoomModel>>() {}.getType();
|
||||
// List<RoomModel> restoredRoomModels = GsonUtils.getGSON().fromJson(SpUtils.getRoomModel(), listType);
|
||||
// if (restoredRoomModels != null && restoredRoomModels.size() > 0) {
|
||||
// MvpRef.get().roomList(restoredRoomModels);
|
||||
// }
|
||||
// ApiClient.getInstance().getNewRoomList(new BaseObserver<List<RoomModel>>() {
|
||||
// @Override
|
||||
// public void onSubscribe(Disposable d) {
|
||||
// addDisposable(d);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(List<RoomModel> roomModels) {
|
||||
//
|
||||
//// MvpRef.get().roomList(roomModels);
|
||||
// String newHomeBeanJson = GsonUtils.getGSON().toJson(roomModels);
|
||||
// // 从本地缓存中读取现有的数据
|
||||
// String existingHomeBeanJson = SpUtils.getRoomModel();
|
||||
// // 比较新获取的数据和缓存中的数据是否一致
|
||||
// if (!newHomeBeanJson.equals(existingHomeBeanJson)) {
|
||||
// // 如果不一致,保存新数据到本地缓存
|
||||
// SpUtils.setRoomModel(newHomeBeanJson);
|
||||
// // 并调用方法处理新数据
|
||||
// MvpRef.get().roomList(roomModels);
|
||||
// }else {
|
||||
// MvpRef.get().finishRefreshLoadMore();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
// MvpRef.get().finishRefreshLoadMore();
|
||||
// }
|
||||
// });
|
||||
|
||||
// List<RoomModel> roomModels = new ArrayList<RoomModel>();
|
||||
// for (int i = 0; i < 5; i++) {
|
||||
// RoomModel roomModel = new RoomModel();
|
||||
// roomModel.setRoom_id("1");
|
||||
// roomModel.setRoom_code("1");
|
||||
// roomModel.setUser_id("1");
|
||||
// roomModel.setRoom_name("房间名称"+i);
|
||||
// roomModel.setLabel_id("23");
|
||||
// roomModel.setType_id("1");
|
||||
// roomModel.setPopularity("1");
|
||||
// roomModel.setLabel_name("1");
|
||||
// roomModel.setOwner_picture("1");
|
||||
// roomModel.setOwner_sex("1");
|
||||
// roomModel.setHolder("1");
|
||||
// roomModel.setHolder_picture("1");
|
||||
// roomModel.setHolder_sex("1");
|
||||
// roomModel.setOwner_nickname("名称"+i);
|
||||
// roomModel.setHolder_nickname("h名称"+i);
|
||||
// roomModel.setIs_owner(1);
|
||||
// roomModel.setLocked(1);
|
||||
//
|
||||
// roomModels.add(roomModel);
|
||||
// }
|
||||
//
|
||||
// MvpRef.get().roomList(roomModels);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.xscm.modulemain.activity.room.contacts.HourlyChartContacts;
|
||||
import com.xscm.moduleutil.bean.room.RoomHourBean;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class HourlyChartPresenter extends BasePresenter<HourlyChartContacts.View> implements HourlyChartContacts.IRoomPre{
|
||||
|
||||
HourlyChartContacts.View mView;
|
||||
public HourlyChartPresenter(HourlyChartContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
this.mView=view;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void getRoomHourRanking(String page, String page_limit) {
|
||||
api.getRoomHourRanking(page, page_limit, new BaseObserver<RoomHourBean>() {
|
||||
@Override
|
||||
public void onSubscribe(@NotNull Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NotNull RoomHourBean roomHourBean) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().getRoomHourRanking(roomHourBean);
|
||||
MvpRef.get().findView();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.xscm.modulemain.activity.room.contacts.PkTimeContract;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class PkTimePresenter extends BasePresenter<PkTimeContract.View> implements PkTimeContract.IRoomPre{
|
||||
public PkTimePresenter(PkTimeContract.View view, Context context) {
|
||||
super(view, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startPk(String pk_id, String pk_times) {
|
||||
api.startPk(pk_id, pk_times, new BaseObserver<String>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
// MvpRef.get().startPk();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.blankj.utilcode.util.ObjectUtils;
|
||||
import com.xscm.modulemain.activity.room.contacts.PlaceholderContacts;
|
||||
import com.xscm.moduleutil.bean.PlaceholderBean;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class PlaceholderPresenter extends BasePresenter<PlaceholderContacts.View> implements PlaceholderContacts.IPres {
|
||||
public PlaceholderPresenter(PlaceholderContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wealthRanking(String ranking_type, String type) {
|
||||
api.wealthRanking(ranking_type, type, new BaseObserver<PlaceholderBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(PlaceholderBean placeholderBean) {
|
||||
MvpRef.get().wealthRanking(placeholderBean.getMy_ranking());
|
||||
|
||||
if (!ObjectUtils.isEmpty(placeholderBean.getLists())) {
|
||||
List<PlaceholderBean.ListsBean> lists = placeholderBean.getLists();
|
||||
MvpRef.get().setNo1(lists.get(0),ranking_type);
|
||||
if (lists.size() > 1) {
|
||||
MvpRef.get().setNo2(lists.get(1),ranking_type);
|
||||
}else {
|
||||
MvpRef.get().setNo2(null,ranking_type);
|
||||
}
|
||||
if (lists.size() > 2) {
|
||||
MvpRef.get().setNo3(lists.get(2),ranking_type);
|
||||
}else {
|
||||
MvpRef.get().setNo3(null,ranking_type);
|
||||
}
|
||||
if (lists.size() > 3) {
|
||||
MvpRef.get().setList(lists.subList(3, lists.size()));
|
||||
}else {
|
||||
MvpRef.get().setList(null);
|
||||
}
|
||||
}else {
|
||||
MvpRef.get().setNo1(null,ranking_type);
|
||||
MvpRef.get().setNo2(null,ranking_type);
|
||||
MvpRef.get().setNo3(null,ranking_type);
|
||||
MvpRef.get().setList(null);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user