1:羽声新版本
This commit is contained in:
@@ -2,7 +2,7 @@ plugins {
|
||||
alias(libs.plugins.android.library)
|
||||
alias(libs.plugins.kotlin.android)
|
||||
}
|
||||
|
||||
//apply plugin: 'kotlin-kapt' // 关键:Kotlin 注解处理器
|
||||
android {
|
||||
namespace 'com.xscm.moduleutil'
|
||||
compileSdk 35
|
||||
@@ -35,14 +35,14 @@ android {
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_17
|
||||
targetCompatibility JavaVersion.VERSION_17
|
||||
sourceCompatibility JavaVersion.VERSION_11
|
||||
targetCompatibility JavaVersion.VERSION_11
|
||||
}
|
||||
dataBinding {
|
||||
enabled = true
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = '17'
|
||||
jvmTarget = '11'
|
||||
}
|
||||
|
||||
packagingOptions {
|
||||
@@ -50,6 +50,13 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
// Kotlin 注解处理器参数(针对 Kotlin 代码)
|
||||
//kapt {
|
||||
// arguments {
|
||||
// arg("AROUTER_MODULE_NAME", project.getName())
|
||||
// }
|
||||
//}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
|
||||
|
||||
@@ -139,8 +146,9 @@ dependencies {
|
||||
api(libs.alipay.alipaysdk.android)
|
||||
|
||||
api(libs.arouter.api.v150)
|
||||
annotationProcessor libs.arouter.annotation
|
||||
annotationProcessor libs.arouter.compiler
|
||||
// implementation 'com.alibaba:arouter-api:1.5.2'
|
||||
// kapt 'com.alibaba:arouter-compiler:1.5.2'/**/
|
||||
|
||||
api(libs.easypermissions)
|
||||
api(libs.xbanner)
|
||||
@@ -156,6 +164,9 @@ dependencies {
|
||||
api(libs.zcw.togglebutton.library)
|
||||
//图片模糊
|
||||
api(libs.com.github.mmin18.realtimeblurview)
|
||||
|
||||
api 'com.baoyz.actionsheet:library:1.1.7'
|
||||
|
||||
//播放器
|
||||
//腾讯直播sdk
|
||||
api('com.tencent.liteav:LiteAVSDK_Professional:10.9.0.13102')
|
||||
@@ -173,7 +184,7 @@ dependencies {
|
||||
// api( 'io.agora.rtc:agora-special-full:4.1.1.29')
|
||||
api('com.github.AgoraIO-Community:LyricsView:1.1.3')
|
||||
//声网集成屏幕共享
|
||||
def agora_sdk_version = "4.5.2"
|
||||
def agora_sdk_version = "4.6.0"
|
||||
api "io.agora.rtc:full-sdk:${agora_sdk_version}"
|
||||
// api("io.agora.rtc:lite-sdk:${agora_sdk_version}")
|
||||
// api ("io.agora.rtc:voice-sdk:${agora_sdk_version}")
|
||||
@@ -204,10 +215,21 @@ dependencies {
|
||||
|
||||
api 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.5'
|
||||
api 'io.github.mayzs:paho.mqtt.android:1.2.1'
|
||||
// api project(':LocalAar')
|
||||
|
||||
// ShapeView:https://github.com/getActivity/ShapeView
|
||||
// api 'com.github.getActivity:ShapeView:10.0'
|
||||
// 腾讯cos云储存
|
||||
api 'com.qcloud.cos:cos-android:5.9.+'
|
||||
|
||||
// room数据库
|
||||
// def room_version = "2.5.0"
|
||||
// implementation "androidx.room:room-runtime:$room_version"
|
||||
// implementation "androidx.room:room-ktx:$room_version"
|
||||
// annotationProcessor "androidx.room:room-compiler:$room_version"
|
||||
|
||||
|
||||
//2. 云normal SDK,
|
||||
//aar的名称,例如:WbCloudNormal-v5.1.10-123456789.aar,填入 'WbCloudNormal-v5.1.10-123456789.aar'
|
||||
}
|
||||
|
||||
apply plugin: 'com.alibaba.arouter' // ⚠️ 添加这一行
|
||||
//apply plugin: 'com.alibaba.arouter' // ⚠️ 添加这一行
|
||||
@@ -6,16 +6,9 @@
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
|
||||
|
||||
<application android:allowBackup="true">
|
||||
<service
|
||||
android:name=".service.MyRoomService"
|
||||
android:enabled="true"
|
||||
android:exported="true"/>
|
||||
|
||||
<activity
|
||||
android:name=".activity.QxActivity"
|
||||
android:exported="false" />
|
||||
|
||||
<service
|
||||
android:name=".http.FloatingWindowService"
|
||||
@@ -25,10 +18,10 @@
|
||||
|
||||
<activity
|
||||
android:name=".activity.WebViewActivity"
|
||||
android:exported="false">
|
||||
android:exported="true">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="com.xscm.qxlive.PROTOCOL_WEBVIEW" />
|
||||
<action android:name="com.qxcm.qxlive.PROTOCOL_WEBVIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
@@ -36,14 +29,17 @@
|
||||
android:name=".activity.news.OfficialNoticeActivity"
|
||||
android:exported="false" />
|
||||
|
||||
<service android:name="org.eclipse.paho.android.service.MqttService" /> <!-- <receiver android:name="org.eclipse.paho.android.service.AlarmPingSender$AlarmReceiver" -->
|
||||
<!-- <service android:name="org.eclipse.paho.android.service.MqttService"-->
|
||||
<!-- android:exported="false"/> <!– <receiver android:name="org.eclipse.paho.android.service.AlarmPingSender$AlarmReceiver" –>-->
|
||||
<!-- android:enabled="true" -->
|
||||
<!-- android:exported="true" -->
|
||||
<!-- tools:ignore="Instantiatable" /> -->
|
||||
<!-- <service android:name=".service.EMqttService" />-->
|
||||
<service
|
||||
android:name=".service.MyMqttService"
|
||||
android:foregroundServiceType="dataSync" />
|
||||
<!-- <service-->
|
||||
<!-- android:name=".service.MyMqttService"-->
|
||||
<!-- android:enabled="true"-->
|
||||
<!-- android:exported="false"-->
|
||||
<!-- android:foregroundServiceType="dataSync" />-->
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -1,34 +1,72 @@
|
||||
package com.xscm.moduleutil.activity;
|
||||
|
||||
import static androidx.core.content.ContextCompat.getSystemService;
|
||||
|
||||
import static com.xscm.moduleutil.base.CommonAppContext.postDelayed;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.media.MediaPlayer;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.provider.Settings;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.AccelerateInterpolator;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.view.animation.TranslateAnimation;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.databinding.ViewDataBinding;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.blankj.utilcode.util.ActivityUtils;
|
||||
import com.blankj.utilcode.util.BarUtils;
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.tencent.qcloud.tuikit.tuichat.bean.ChatInfo;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.base.RoomManager;
|
||||
import com.xscm.moduleutil.bean.XLHBean;
|
||||
import com.xscm.moduleutil.event.HourlyBean;
|
||||
import com.xscm.moduleutil.event.MqttBean;
|
||||
import com.xscm.moduleutil.event.RedBean;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.utils.BackgroundManager;
|
||||
import com.xscm.moduleutil.utils.ColorManager;
|
||||
import com.xscm.moduleutil.utils.DisplayUtil;
|
||||
import com.xscm.moduleutil.utils.LanguageUtil;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
import com.xscm.moduleutil.utils.SystemUtils;
|
||||
import com.xscm.moduleutil.widget.QXGiftDriftView;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
@@ -36,6 +74,7 @@ import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -44,7 +83,8 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context newBase) {
|
||||
super.attachBaseContext(LanguageUtil.attachBaseContext(newBase));
|
||||
// 设置字体缩放比例为1.0f,即不跟随系统字体大小变化
|
||||
super.attachBaseContext(DisplayUtil.attachBaseContext(newBase, 1.0f));
|
||||
}
|
||||
|
||||
protected VDB mBinding;
|
||||
@@ -73,6 +113,8 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
ActivityUtils.finishAllActivities();
|
||||
}
|
||||
|
||||
QXGiftDriftView qxGiftDriftView;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -97,6 +139,7 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
loadNetworkBackground();
|
||||
// 注册颜色变化监听器
|
||||
ColorManager.getInstance().addColorChangeListener(this);
|
||||
|
||||
// 注册登出广播接收器
|
||||
IntentFilter filter = new IntentFilter("com.xscm.moduleutil.ACTION_USER_LOGOUT");
|
||||
registerReceiver(mLogoutReceiver, filter);
|
||||
@@ -115,18 +158,45 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
}
|
||||
|
||||
|
||||
// // 设置全屏模式,隐藏状态栏和导航栏
|
||||
// View decorView = getWindow().getDecorView();
|
||||
// decorView.setSystemUiVisibility(
|
||||
// View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||
// | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||
// | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||
// | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
||||
// | View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||
// | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
|
||||
// 启动定时器
|
||||
// startTimer();
|
||||
|
||||
}
|
||||
|
||||
// 在Activity中
|
||||
private static final int REQUEST_OVERLAY_PERMISSION = 1001;
|
||||
|
||||
private void checkAndRequestOverlayPermission() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (!Settings.canDrawOverlays(this)) {
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle("需要悬浮窗权限")
|
||||
.setMessage("应用需要悬浮窗权限才能显示飘屏效果")
|
||||
.setPositiveButton("去设置", (dialog, which) -> {
|
||||
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
|
||||
Uri.parse("package:" + getPackageName()));
|
||||
startActivityForResult(intent, REQUEST_OVERLAY_PERMISSION);
|
||||
})
|
||||
.setNegativeButton("取消", null)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == REQUEST_OVERLAY_PERMISSION) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (Settings.canDrawOverlays(this)) {
|
||||
ToastUtils.show("已获得悬浮窗权限");
|
||||
} else {
|
||||
ToastUtils.show("未获得悬浮窗权限");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void finishAll() {
|
||||
for (BaseMvpActivity activity : activityList) {
|
||||
if (!activity.isFinishing()) {
|
||||
@@ -146,6 +216,37 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
// 默认实现,子类可以覆盖
|
||||
}
|
||||
|
||||
//在类中添加以下成员变量
|
||||
private Handler timerHandler = new Handler();
|
||||
private Runnable timerRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// 调用你要执行的方法
|
||||
// executePeriodicTask();
|
||||
|
||||
// 每10秒执行一次
|
||||
timerHandler.postDelayed(this, 10000);
|
||||
}
|
||||
};
|
||||
|
||||
// 启动定时器的方法
|
||||
private void startTimer() {
|
||||
timerHandler.postDelayed(timerRunnable, 10000);
|
||||
}
|
||||
|
||||
// 你需要定期执行的方法
|
||||
private void executePeriodicTask() {
|
||||
// 在这里实现你的业务逻辑
|
||||
LogUtils.d("定时任务执行中...");
|
||||
List<HourlyBean> hourlyBeans = new ArrayList<>();
|
||||
HourlyBean hourlyBean = new HourlyBean();
|
||||
hourlyBean.setText("nihao");
|
||||
hourlyBean.setRank_number("1");
|
||||
hourlyBean.setRoom_name("夏末");
|
||||
hourlyBean.setRoom_id("1");
|
||||
hourlyBeans.add(hourlyBean);
|
||||
onMessageReceived(hourlyBeans);
|
||||
}
|
||||
|
||||
protected void loadNetworkBackground() {
|
||||
// 只有当已经有背景URL时才加载
|
||||
@@ -225,6 +326,36 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
|
||||
// 清理MQTT相关资源
|
||||
synchronized (mqttQueueLock) {
|
||||
mqttMessageQueue.clear();
|
||||
isMqttPlaying = false;
|
||||
}
|
||||
|
||||
// 清理XLH相关资源
|
||||
synchronized (xlhQueueLock) {
|
||||
xlhMessageQueue.clear();
|
||||
isXlhPlaying = false;
|
||||
}
|
||||
|
||||
// 移除当前显示的视图
|
||||
try {
|
||||
if (currentMqttView != null && currentMqttView.getParent() != null) {
|
||||
ViewGroup parent = (ViewGroup) currentMqttView.getParent();
|
||||
parent.removeView(currentMqttView);
|
||||
}
|
||||
currentMqttView = null;
|
||||
|
||||
if (currentXlhView != null && currentXlhView.getParent() != null) {
|
||||
ViewGroup parent = (ViewGroup) currentXlhView.getParent();
|
||||
parent.removeView(currentXlhView);
|
||||
}
|
||||
currentXlhView = null;
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("清理飘屏视图失败", e);
|
||||
}
|
||||
|
||||
// 移除背景更新监听器
|
||||
BackgroundManager.getInstance().removeListener(this);
|
||||
// 移除颜色变化监听器
|
||||
@@ -235,6 +366,12 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
if (EventBus.getDefault().isRegistered(this)) {
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
try {
|
||||
unregisterReceiver(mLogoutReceiver);
|
||||
} catch (Exception e) {
|
||||
// 忽略异常
|
||||
}
|
||||
|
||||
try {
|
||||
unregisterReceiver(mLogoutReceiver);
|
||||
} catch (Exception e) {
|
||||
@@ -306,16 +443,742 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
|
||||
return false;
|
||||
}
|
||||
|
||||
// @Subscribe(threadMode = ThreadMode.MAIN)
|
||||
// public void onMessageReceived(MqttBean mqttBean) {
|
||||
//// PiaoPingManager.getInstance(this).showPiaoPingMessage(mqttBean);
|
||||
// FxAppHelper fxAppHelper = FxAppHelper.builder().setContext(this).setLayout(R.layout.item_piaoping).build();
|
||||
// FloatingX.install(fxAppHelper).show();
|
||||
// }
|
||||
|
||||
/// 礼物特效
|
||||
// 在类中添加以下成员变量
|
||||
private final List<MqttBean.ListBean> mqttMessageQueue = new ArrayList<>(); // MQTT消息队列
|
||||
private final List<XLHBean> xlhMessageQueue = new ArrayList<>(); // XLH消息队列
|
||||
private final List<RedBean> redMessageQueue = new ArrayList<>(); // 红包队列
|
||||
private boolean isMqttPlaying = false; // MQTT播放状态标志
|
||||
private boolean isXlhPlaying = false; // XLH播放状态标志
|
||||
private boolean isRedPlaying = false; // XLH播放状态标志
|
||||
private final Object mqttQueueLock = new Object(); // MQTT队列同步锁
|
||||
private final Object xlhQueueLock = new Object(); // XLH队列同步锁
|
||||
private final Object RedQueueLock = new Object(); // XLH队列同步锁
|
||||
private View currentMqttView = null; // 当前正在播放的MQTT视图
|
||||
private View currentXlhView = null; // 当前正在播放的XLH视图
|
||||
private View currentRedView = null; // 当前正在播放的XLH视图
|
||||
|
||||
private final List<HourlyBean> hourlyMessageQueue = new ArrayList<>(); // 小时榜消息队列
|
||||
private final Map<Integer, View> currentHourlyViews = new HashMap<>(); // 当前显示的小时榜视图
|
||||
private final Object hourlyQueueLock = new Object(); // 小时榜队列同步锁
|
||||
private boolean isHourlyProcessing = false; // 小时榜处理状态标志
|
||||
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onMessageReceived(List<HourlyBean> hourlyBean) {
|
||||
LogUtils.e("收到小时榜", hourlyBean);
|
||||
if (hourlyBean == null) return;
|
||||
if (SpUtil.getFloatingScreen() == 1) {
|
||||
synchronized (hourlyQueueLock) {
|
||||
hourlyMessageQueue.addAll(hourlyBean);
|
||||
if (!isHourlyProcessing) {
|
||||
isHourlyProcessing = true;
|
||||
processHourlyMessages();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
hourlyMessageQueue.clear();
|
||||
clearAllHourlyViews();
|
||||
}
|
||||
}
|
||||
|
||||
private void processHourlyMessages() {
|
||||
List<HourlyBean> messagesToProcess;
|
||||
synchronized (hourlyQueueLock) {
|
||||
if (hourlyMessageQueue.isEmpty()) {
|
||||
isHourlyProcessing = false;
|
||||
return;
|
||||
}
|
||||
// 每次只处理1条数据
|
||||
messagesToProcess = new ArrayList<>();
|
||||
messagesToProcess.add(hourlyMessageQueue.remove(0));
|
||||
}
|
||||
|
||||
// 只展示一条数据
|
||||
HourlyBean bean = messagesToProcess.get(0);
|
||||
showHourlyFloatingMessage(bean, 0);
|
||||
}
|
||||
|
||||
private void showHourlyFloatingMessage(HourlyBean hourlyBean, int positionIndex) {
|
||||
try {
|
||||
ViewGroup decorView = (ViewGroup) getWindow().getDecorView();
|
||||
|
||||
// 创建新的视图
|
||||
View hourlyView = LayoutInflater.from(this).inflate(R.layout.item_hourly_floating, null);
|
||||
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
|
||||
FrameLayout.LayoutParams.MATCH_PARENT,
|
||||
FrameLayout.LayoutParams.WRAP_CONTENT);
|
||||
|
||||
// 设置固定的垂直位置
|
||||
int baseMargin = com.sunfusheng.marqueeview.DisplayUtil.dip2px(this, 70);
|
||||
layoutParams.topMargin = baseMargin;
|
||||
layoutParams.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;
|
||||
hourlyView.setLayoutParams(layoutParams);
|
||||
|
||||
decorView.addView(hourlyView);
|
||||
|
||||
// 保存视图引用
|
||||
currentHourlyViews.put(positionIndex, hourlyView);
|
||||
|
||||
// 更新视图数据
|
||||
updateHourlyFloatingViewData(hourlyView, hourlyBean);
|
||||
|
||||
// 根据类型获取展示时间
|
||||
long displayDuration = getDisplayDurationByType(Integer.parseInt(hourlyBean.getRank_number()));
|
||||
|
||||
// 启动动画
|
||||
resetAndStartHourlyAnimation(hourlyView, displayDuration, () -> {
|
||||
// 动画结束后清理视图
|
||||
if (hourlyView.getParent() != null) {
|
||||
decorView.removeView(hourlyView);
|
||||
}
|
||||
currentHourlyViews.remove(positionIndex);
|
||||
|
||||
// 检查是否还有更多消息需要处理
|
||||
synchronized (hourlyQueueLock) {
|
||||
if (hourlyMessageQueue.isEmpty()) {
|
||||
isHourlyProcessing = false;
|
||||
} else {
|
||||
// 当前视图消失后处理下一条消息
|
||||
processHourlyMessages();
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("显示小时榜飘屏失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
private long getDisplayDurationByType(int type) {
|
||||
// 根据不同类型设置不同的展示时间(毫秒)
|
||||
switch (type) {
|
||||
case 1: // 第一名
|
||||
return 5000; // 5秒
|
||||
case 2: // 第二名
|
||||
return 4000; // 4秒
|
||||
case 3: // 第三名
|
||||
return 3000; // 3秒
|
||||
default:
|
||||
return 3000; // 默认3秒
|
||||
}
|
||||
}
|
||||
|
||||
private void updateHourlyFloatingViewData(View view, HourlyBean hourlyBean) {
|
||||
TextView tvName = view.findViewById(R.id.tv_name);
|
||||
ImageView ivAvatar = view.findViewById(R.id.im_h_t);
|
||||
|
||||
if (hourlyBean != null) {
|
||||
// 根据排名设置不同的显示
|
||||
switch (hourlyBean.getRank_number()) {
|
||||
case "1":
|
||||
// tvName.setText("新科状元! ["+hourlyBean.getRoom_name()+"] 独占鳌头!");
|
||||
setColoredText(tvName, "新科状元! [", hourlyBean.getRoom_name(), "] 独占鳌头!", R.color.color_FFFA63);
|
||||
ivAvatar.setImageResource(R.mipmap.hourl_top1);
|
||||
break;
|
||||
case "2":
|
||||
// tvName.setText("金榜榜眼! ["+hourlyBean.getRoom_name()+"] 才气逼人!");
|
||||
setColoredText(tvName, "金榜榜眼! [", hourlyBean.getRoom_name(), "] 才气逼人!", R.color.color_FFFA63);
|
||||
|
||||
ivAvatar.setImageResource(R.mipmap.hourl_top2);
|
||||
break;
|
||||
case "3":
|
||||
setColoredText(tvName, "风采探花! [", hourlyBean.getRoom_name(), "] 实力绽放!", R.color.color_1FFFE5);
|
||||
// tvName.setText("风采探花! ["+hourlyBean.getRoom_name()+"] 实力绽放!");
|
||||
|
||||
ivAvatar.setImageResource(R.mipmap.hourl_top3);
|
||||
break;
|
||||
default:
|
||||
tvName.setVisibility(View.GONE);
|
||||
ivAvatar.setVisibility(View.GONE);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// 设置带颜色的文本
|
||||
// 设置带颜色的文本
|
||||
private void setColoredText(TextView textView, String prefix, String roomName, String suffix, int colorRes) {
|
||||
String fullText = prefix + roomName + suffix;
|
||||
SpannableStringBuilder builder = new SpannableStringBuilder(fullText);
|
||||
|
||||
// 先为整个文本设置白色
|
||||
builder.setSpan(
|
||||
new ForegroundColorSpan(ContextCompat.getColor(this, R.color.white)),
|
||||
0,
|
||||
fullText.length(),
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
);
|
||||
|
||||
// 查找房间名在文本中的位置
|
||||
int start = fullText.indexOf("[");
|
||||
int end = fullText.indexOf("]") + 1;
|
||||
|
||||
if (start >= 0 && end > start) {
|
||||
// 为房间名部分设置指定颜色
|
||||
builder.setSpan(
|
||||
new ForegroundColorSpan(ContextCompat.getColor(this, colorRes)),
|
||||
start,
|
||||
end,
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
);
|
||||
}
|
||||
|
||||
textView.setText(builder);
|
||||
}
|
||||
|
||||
private void resetAndStartHourlyAnimation(View view, long displayDuration, Runnable onAnimationEnd) {
|
||||
try {
|
||||
int screenWidth = getScreenWidth();
|
||||
// 设置初始位置:在屏幕右侧外部
|
||||
view.setTranslationX(screenWidth);
|
||||
|
||||
// 进入动画
|
||||
ObjectAnimator enterAnimator = ObjectAnimator.ofFloat(view, "translationX", screenWidth, 0f);
|
||||
enterAnimator.setDuration(500);
|
||||
enterAnimator.setInterpolator(new DecelerateInterpolator());
|
||||
enterAnimator.start();
|
||||
|
||||
// 停留后退出动画
|
||||
view.postDelayed(() -> {
|
||||
try {
|
||||
ObjectAnimator exitAnimator = ObjectAnimator.ofFloat(view, "translationX", 0f, -screenWidth);
|
||||
exitAnimator.setDuration(500);
|
||||
exitAnimator.setInterpolator(new AccelerateInterpolator());
|
||||
exitAnimator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
onAnimationEnd.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
onAnimationEnd.run();
|
||||
}
|
||||
});
|
||||
exitAnimator.start();
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("小时榜退出动画执行失败", e);
|
||||
onAnimationEnd.run();
|
||||
}
|
||||
}, displayDuration); // 根据类型设置的展示时间
|
||||
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("小时榜动画启动失败", e);
|
||||
onAnimationEnd.run();
|
||||
}
|
||||
}
|
||||
|
||||
private void clearAllHourlyViews() {
|
||||
ViewGroup decorView = (ViewGroup) getWindow().getDecorView();
|
||||
for (View view : currentHourlyViews.values()) {
|
||||
if (view.getParent() != null) {
|
||||
decorView.removeView(view);
|
||||
}
|
||||
}
|
||||
currentHourlyViews.clear();
|
||||
}
|
||||
|
||||
/// 礼物特效 - MQTT消息处理
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onMessageReceived(MqttBean mqttBean) {
|
||||
LogUtils.e("收到MQTT", mqttBean);
|
||||
if (mqttBean == null) return;
|
||||
if (SpUtil.getFloatingScreen() == 1) {
|
||||
synchronized (mqttQueueLock) {
|
||||
|
||||
mqttMessageQueue.addAll(mqttBean.getList());
|
||||
// if (!isMqttPlaying) {
|
||||
// isMqttPlaying = true;
|
||||
processNextMqttMessage();
|
||||
// }
|
||||
}
|
||||
} else {
|
||||
mqttMessageQueue.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/// XLH消息处理
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onEvent(XLHBean event) {
|
||||
LogUtils.e("收到XLH", event);
|
||||
if (event == null) return;
|
||||
if (event.getText()==null || event.getText().isEmpty()) return;
|
||||
if (SpUtil.getFloatingScreen() == 1) {
|
||||
synchronized (xlhQueueLock) {
|
||||
xlhMessageQueue.add(event);
|
||||
if (!isXlhPlaying) {
|
||||
isXlhPlaying = true;
|
||||
processNextXlhMessage();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
xlhMessageQueue.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onEvent(RedBean event){
|
||||
LogUtils.e("收到红包", event);
|
||||
if (event==null) return;
|
||||
if (SpUtil.getFloatingScreen()==1){
|
||||
|
||||
synchronized (RedQueueLock) {
|
||||
redMessageQueue.add(event);
|
||||
if (!isRedPlaying) {
|
||||
isRedPlaying = true;
|
||||
processNextRedMessage();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
redMessageQueue.clear();
|
||||
}
|
||||
}
|
||||
|
||||
private void processNextRedMessage() {
|
||||
RedBean redBean;
|
||||
synchronized (RedQueueLock) {
|
||||
if (redMessageQueue.isEmpty()) {
|
||||
isRedPlaying = false;
|
||||
return;
|
||||
}
|
||||
redBean = redMessageQueue.remove(0);
|
||||
}
|
||||
showPiaoPingMessageRed(redBean);
|
||||
}
|
||||
|
||||
private void showPiaoPingMessageRed(RedBean redBean){
|
||||
try {
|
||||
// 清理之前的视图(如果存在)
|
||||
if (currentRedView != null && currentRedView.getParent() != null) {
|
||||
ViewGroup parent = (ViewGroup) currentRedView.getParent();
|
||||
parent.removeView(currentRedView);
|
||||
}
|
||||
|
||||
if (decorView2 == null) {
|
||||
decorView2 = (ViewGroup) getWindow().getDecorView();
|
||||
}
|
||||
|
||||
currentRedView = LayoutInflater.from(this).inflate(R.layout.item_piaoping_red, null);
|
||||
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
|
||||
FrameLayout.LayoutParams.MATCH_PARENT,
|
||||
FrameLayout.LayoutParams.WRAP_CONTENT);
|
||||
layoutParams.topMargin = com.sunfusheng.marqueeview.DisplayUtil.dip2px(this, 140);
|
||||
layoutParams.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;
|
||||
currentRedView.setLayoutParams(layoutParams);
|
||||
decorView2.addView(currentRedView);
|
||||
|
||||
updateRedFloatingViewData(currentRedView, redBean);
|
||||
// 播放红包音效
|
||||
playRedPacketSound();
|
||||
resetAndStartXlhAnimation(currentRedView, () -> {
|
||||
// 清理当前视图
|
||||
if (currentRedView != null && currentRedView.getParent() != null) {
|
||||
ViewGroup parent = (ViewGroup) currentRedView.getParent();
|
||||
parent.removeView(currentRedView);
|
||||
}
|
||||
currentRedView = null;
|
||||
|
||||
// 处理队列中的下一条消息
|
||||
synchronized (RedQueueLock) {
|
||||
isRedPlaying = false;
|
||||
processNextRedMessage();
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("显示红包飘屏失败", e);
|
||||
// 出现异常时继续处理队列
|
||||
synchronized (RedQueueLock) {
|
||||
isRedPlaying = false;
|
||||
processNextRedMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
// 在类中添加成员变量
|
||||
private MediaPlayer redPacketMediaPlayer = null;
|
||||
private boolean isRedPacketMediaPrepared = false;
|
||||
// 添加播放红包音效的方法
|
||||
private void playRedPacketSound() {
|
||||
try {
|
||||
if (!isRedPacketMediaPrepared) {
|
||||
// 第一次初始化MediaPlayer
|
||||
if (redPacketMediaPlayer == null) {
|
||||
redPacketMediaPlayer = MediaPlayer.create(this, R.raw.red_packet_come); // 假设音效文件名为red_packet_sound.mp3
|
||||
redPacketMediaPlayer.setOnPreparedListener(mp -> {
|
||||
isRedPacketMediaPrepared = true;
|
||||
mp.start();
|
||||
});
|
||||
redPacketMediaPlayer.setOnCompletionListener(mp -> {
|
||||
// 播放完成后重置,以便下次重新播放
|
||||
try {
|
||||
mp.seekTo(0);
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("MediaPlayer重置失败", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (redPacketMediaPlayer != null) {
|
||||
redPacketMediaPlayer.prepareAsync(); // 异步准备
|
||||
}
|
||||
} else {
|
||||
// 已经准备好了,直接重新播放
|
||||
if (redPacketMediaPlayer != null && !redPacketMediaPlayer.isPlaying()) {
|
||||
redPacketMediaPlayer.seekTo(0);
|
||||
redPacketMediaPlayer.start();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("播放红包音效失败", e);
|
||||
isRedPacketMediaPrepared=false;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateRedFloatingViewData(View view, RedBean redBean){
|
||||
TextView textView = view.findViewById(R.id.tv_name);
|
||||
|
||||
if (redBean != null) {
|
||||
String fullText = redBean.getText();
|
||||
if (redBean.getNickname() != null && redBean.getRoom_name() != null) {
|
||||
SpannableStringBuilder builder = new SpannableStringBuilder(fullText);
|
||||
|
||||
// 为用户名设置蓝色
|
||||
int userNameStart = fullText.indexOf(redBean.getNickname());
|
||||
if (userNameStart >= 0) {
|
||||
builder.setSpan(
|
||||
new ForegroundColorSpan(ContextCompat.getColor(this, R.color.colorPrimary)),
|
||||
userNameStart,
|
||||
userNameStart + redBean.getNickname().length(),
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
);
|
||||
}
|
||||
|
||||
// 为房间名设置蓝色
|
||||
int roomNameStart = fullText.indexOf(redBean.getRoom_name());
|
||||
if (roomNameStart >= 0) {
|
||||
builder.setSpan(
|
||||
new ForegroundColorSpan(ContextCompat.getColor(this, R.color.colorPrimary)),
|
||||
roomNameStart,
|
||||
roomNameStart + redBean.getRoom_name().length(),
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
);
|
||||
}
|
||||
|
||||
textView.setText(builder);
|
||||
} else {
|
||||
textView.setText(fullText);
|
||||
}
|
||||
} else {
|
||||
textView.setText("");
|
||||
}
|
||||
|
||||
view.setOnClickListener(v -> {
|
||||
// 点击时执行跳转操作
|
||||
handleRedItemClick(redBean);
|
||||
});
|
||||
}
|
||||
|
||||
// 处理下一个MQTT消息
|
||||
private void processNextMqttMessage() {
|
||||
MqttBean.ListBean mqttBean;
|
||||
synchronized (mqttQueueLock) {
|
||||
if (mqttMessageQueue.isEmpty()) {
|
||||
isMqttPlaying = false;
|
||||
return;
|
||||
}
|
||||
mqttBean = mqttMessageQueue.remove(0);
|
||||
}
|
||||
showFloatingMessage(mqttBean);
|
||||
}
|
||||
|
||||
// 处理下一个XLH消息
|
||||
private void processNextXlhMessage() {
|
||||
XLHBean xlhBean;
|
||||
synchronized (xlhQueueLock) {
|
||||
if (xlhMessageQueue.isEmpty()) {
|
||||
isXlhPlaying = false;
|
||||
return;
|
||||
}
|
||||
xlhBean = xlhMessageQueue.remove(0);
|
||||
}
|
||||
showPiaoPingMessageXlh(xlhBean);
|
||||
}
|
||||
|
||||
ViewGroup decorView;//礼物的
|
||||
ViewGroup decorView1;//巡乐会的
|
||||
ViewGroup decorView2;//红包的
|
||||
|
||||
private void showFloatingMessage(MqttBean.ListBean mqttBean) {
|
||||
|
||||
// QXGiftDriftView.getInstance( this).addGiftModel(mqttBean);
|
||||
|
||||
|
||||
try {
|
||||
// 清理之前的视图(如果存在)
|
||||
if (currentMqttView != null && currentMqttView.getParent() != null) {
|
||||
ViewGroup parent = (ViewGroup) currentMqttView.getParent();
|
||||
parent.removeView(currentMqttView);
|
||||
}
|
||||
|
||||
if (decorView == null) {
|
||||
decorView = (ViewGroup) getWindow().getDecorView();
|
||||
}
|
||||
|
||||
currentMqttView = LayoutInflater.from(this).inflate(R.layout.item_piaoping, null);
|
||||
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
|
||||
FrameLayout.LayoutParams.MATCH_PARENT,
|
||||
FrameLayout.LayoutParams.WRAP_CONTENT);
|
||||
layoutParams.topMargin = com.sunfusheng.marqueeview.DisplayUtil.dip2px(this, 70);
|
||||
layoutParams.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;
|
||||
currentMqttView.setLayoutParams(layoutParams);
|
||||
decorView.addView(currentMqttView);
|
||||
|
||||
updateFloatingViewData(currentMqttView, mqttBean);
|
||||
resetAndStartMqttAnimation(currentMqttView, () -> {
|
||||
// 清理当前视图
|
||||
if (currentMqttView != null && currentMqttView.getParent() != null) {
|
||||
ViewGroup parent = (ViewGroup) currentMqttView.getParent();
|
||||
parent.removeView(currentMqttView);
|
||||
}
|
||||
currentMqttView = null;
|
||||
|
||||
// 处理队列中的下一条消息
|
||||
synchronized (mqttQueueLock) {
|
||||
isMqttPlaying = false;
|
||||
processNextMqttMessage();
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("显示MQTT飘屏失败", e);
|
||||
// 出现异常时继续处理队列
|
||||
synchronized (mqttQueueLock) {
|
||||
isMqttPlaying = false;
|
||||
processNextMqttMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void showPiaoPingMessageXlh(XLHBean event) {
|
||||
try {
|
||||
// 清理之前的视图(如果存在)
|
||||
if (currentXlhView != null && currentXlhView.getParent() != null) {
|
||||
ViewGroup parent = (ViewGroup) currentXlhView.getParent();
|
||||
parent.removeView(currentXlhView);
|
||||
}
|
||||
|
||||
if (decorView1 == null) {
|
||||
decorView1 = (ViewGroup) getWindow().getDecorView();
|
||||
}
|
||||
|
||||
currentXlhView = LayoutInflater.from(this).inflate(R.layout.item_piaoping_xlh, null);
|
||||
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
|
||||
FrameLayout.LayoutParams.MATCH_PARENT,
|
||||
FrameLayout.LayoutParams.WRAP_CONTENT);
|
||||
layoutParams.topMargin = com.sunfusheng.marqueeview.DisplayUtil.dip2px(this, 100);
|
||||
layoutParams.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;
|
||||
currentXlhView.setLayoutParams(layoutParams);
|
||||
decorView1.addView(currentXlhView);
|
||||
|
||||
updateXlhFloatingViewData(currentXlhView, event);
|
||||
resetAndStartXlhAnimation(currentXlhView, () -> {
|
||||
// 清理当前视图
|
||||
if (currentXlhView != null && currentXlhView.getParent() != null) {
|
||||
ViewGroup parent = (ViewGroup) currentXlhView.getParent();
|
||||
parent.removeView(currentXlhView);
|
||||
}
|
||||
currentXlhView = null;
|
||||
|
||||
// 处理队列中的下一条消息
|
||||
synchronized (xlhQueueLock) {
|
||||
isXlhPlaying = false;
|
||||
processNextXlhMessage();
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("显示XLH飘屏失败", e);
|
||||
// 出现异常时继续处理队列
|
||||
synchronized (xlhQueueLock) {
|
||||
isXlhPlaying = false;
|
||||
processNextXlhMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void resetAndStartMqttAnimation(View view, Runnable onAnimationEnd) {
|
||||
try {
|
||||
int screenWidth = getScreenWidth();
|
||||
// 设置初始位置:在屏幕右侧外部(完全不可见)
|
||||
view.setTranslationX(screenWidth);
|
||||
|
||||
|
||||
TranslateAnimation enterAnim = new TranslateAnimation(
|
||||
Animation.ABSOLUTE, screenWidth,
|
||||
Animation.ABSOLUTE, (screenWidth - SystemUtils.getWidth(316)) / 2,
|
||||
Animation.ABSOLUTE, 0,
|
||||
Animation.ABSOLUTE, 0
|
||||
);
|
||||
enterAnim.setDuration(1500);
|
||||
enterAnim.setInterpolator(new DecelerateInterpolator(2.0f));
|
||||
enterAnim.setAnimationListener(new Animation.AnimationListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
// 停留后退出
|
||||
postDelayed(() -> {
|
||||
TranslateAnimation exitAnim = new TranslateAnimation(
|
||||
Animation.ABSOLUTE, (screenWidth - SystemUtils.getWidth(316)) / 2,
|
||||
Animation.ABSOLUTE, -screenWidth,
|
||||
Animation.ABSOLUTE, 0,
|
||||
Animation.ABSOLUTE, 0
|
||||
);
|
||||
exitAnim.setDuration(3000);
|
||||
exitAnim.setInterpolator(new DecelerateInterpolator(2f));
|
||||
exitAnim.setAnimationListener(new Animation.AnimationListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
// 移除视图并处理下一个
|
||||
onAnimationEnd.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation animation) {
|
||||
}
|
||||
});
|
||||
view.startAnimation(exitAnim);
|
||||
}, 5000); // 停留1秒
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation animation) {
|
||||
}
|
||||
});
|
||||
view.startAnimation(enterAnim);
|
||||
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("MQTT动画启动失败", e);
|
||||
onAnimationEnd.run();
|
||||
}
|
||||
}
|
||||
|
||||
// 添加获取屏幕宽度的方法
|
||||
private int getScreenWidth() {
|
||||
DisplayMetrics displayMetrics = new DisplayMetrics();
|
||||
if (getWindowManager() != null) {
|
||||
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
|
||||
return displayMetrics.widthPixels;
|
||||
}
|
||||
return getResources().getDisplayMetrics().widthPixels;
|
||||
}
|
||||
|
||||
private void resetAndStartXlhAnimation(View view, Runnable onAnimationEnd) {
|
||||
try {
|
||||
view.setTranslationX(view.getWidth());
|
||||
ObjectAnimator animator1 = ObjectAnimator.ofFloat(view, "translationX", view.getWidth(), 0f);
|
||||
animator1.setDuration(1500);
|
||||
animator1.setInterpolator(new DecelerateInterpolator(2.0f));
|
||||
animator1.start();
|
||||
|
||||
view.postDelayed(() -> {
|
||||
try {
|
||||
ObjectAnimator animator2 = ObjectAnimator.ofFloat(view, "translationX", 0f, -view.getWidth());
|
||||
animator2.setDuration(1500);
|
||||
animator2.setInterpolator(new DecelerateInterpolator(2.0f));
|
||||
animator2.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
onAnimationEnd.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
onAnimationEnd.run();
|
||||
}
|
||||
});
|
||||
animator2.start();
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("XLH动画执行失败", e);
|
||||
onAnimationEnd.run();
|
||||
}
|
||||
}, 5000);
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("XLH动画启动失败", e);
|
||||
onAnimationEnd.run();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateFloatingViewData(View view, MqttBean.ListBean mqttBean) {
|
||||
TextView textView = view.findViewById(R.id.tv_name);
|
||||
TextView textView2 = view.findViewById(R.id.tv_to_name);
|
||||
TextView tv_time = view.findViewById(R.id.tv_num);
|
||||
|
||||
if (mqttBean != null) {
|
||||
textView2.setText("送给" + (mqttBean.getToUserName() != null ? mqttBean.getToUserName() : ""));
|
||||
textView.setText(mqttBean.getFromUserName() != null ? mqttBean.getFromUserName() : "");
|
||||
if (mqttBean.getGift_picture() != null) {
|
||||
ImageUtils.loadHeadCC(mqttBean.getGift_picture(), view.findViewById(R.id.iv_piaoping));
|
||||
}
|
||||
tv_time.setText("x" + (mqttBean.getNumber() != null ? mqttBean.getNumber() : "1"));
|
||||
} else {
|
||||
textView2.setText("送给");
|
||||
textView.setText("");
|
||||
tv_time.setText("x1");
|
||||
}
|
||||
}
|
||||
|
||||
private void updateXlhFloatingViewData(View view, XLHBean xlhBean) {
|
||||
TextView textView = view.findViewById(R.id.tv_name);
|
||||
ImageView xlh_image = view.findViewById(R.id.im_xlh);
|
||||
|
||||
if (xlhBean != null) {
|
||||
xlh_image.setImageDrawable(xlhBean.getFrom_type() == 1 ?
|
||||
getResources().getDrawable(R.mipmap.xlh_jjks) :
|
||||
getResources().getDrawable(R.mipmap.xlh_zsks));
|
||||
textView.setText(xlhBean.getText());
|
||||
} else {
|
||||
textView.setText("");
|
||||
}
|
||||
|
||||
view.setOnClickListener(v -> {
|
||||
// 点击时执行跳转操作
|
||||
handleItemClick(xlhBean);
|
||||
});
|
||||
}
|
||||
|
||||
private void handleItemClick(XLHBean xlhBean) {
|
||||
// 这里可以根据实际需求实现跳转逻辑
|
||||
// 例如:跳转到礼物详情页面、用户主页等
|
||||
// 使用缓存数据进入房间
|
||||
RoomManager.getInstance().fetchRoomDataAndEnter(getApplicationContext(), xlhBean.getRoom_id(), "");
|
||||
// ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("from", "我的界面").withString("roomId", xlhBean.getRoom_id()).navigation();
|
||||
|
||||
}
|
||||
|
||||
private void handleRedItemClick(RedBean redBean) {
|
||||
// 这里可以根据实际需求实现跳转逻辑
|
||||
// 例如:跳转到礼物详情页面、用户主页等
|
||||
// 使用缓存数据进入房间
|
||||
RoomManager.getInstance().fetchRoomDataAndEnter(getApplicationContext(), redBean.getRoom_id(), "");
|
||||
// ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("from", "我的界面").withString("roomId", xlhBean.getRoom_id()).navigation();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onEvent(ChatInfo event) {
|
||||
String id = event.getId().replace("g", "");
|
||||
ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url() + "/web/index.html#/pages/union/setGroup?id=" + SpUtil.getToken() + "&guildId=" + id).navigation();
|
||||
Intent intent = new Intent(this, WebViewActivity.class);
|
||||
intent.putExtra("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url() + "/web/index.html#/pages/union/setGroup?id=" + SpUtil.getToken() + "&guildId=" + id);
|
||||
startActivity(intent);
|
||||
// ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url() + "/web/index.html#/pages/union/setGroup?id=" + SpUtil.getToken() + "&guildId=" + id).navigation();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,9 @@ import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
@@ -11,9 +14,22 @@ import androidx.core.content.ContextCompat;
|
||||
import androidx.databinding.ViewDataBinding;
|
||||
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.tencent.imsdk.v2.V2TIMConversationListener;
|
||||
import com.tencent.imsdk.v2.V2TIMConversationManager;
|
||||
import com.tencent.imsdk.v2.V2TIMSDKListener;
|
||||
import com.tencent.imsdk.v2.V2TIMValueCallback;
|
||||
import com.tencent.qcloud.tuicore.TUIConfig;
|
||||
import com.tencent.qcloud.tuicore.TUIConstants;
|
||||
import com.tencent.qcloud.tuicore.TUICore;
|
||||
import com.tencent.qcloud.tuicore.interfaces.TUILoginListener;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.base.RoomManager;
|
||||
import com.xscm.moduleutil.bean.UserBean;
|
||||
import com.xscm.moduleutil.bean.UserInfo;
|
||||
import com.xscm.moduleutil.dialog.ConfirmDialog;
|
||||
import com.xscm.moduleutil.event.UnreadCountEvent;
|
||||
import com.xscm.moduleutil.http.RetrofitClient;
|
||||
import com.xscm.moduleutil.utils.LanguageUtil;
|
||||
import com.xscm.moduleutil.utils.location.LocationProvider;
|
||||
import com.xscm.moduleutil.utils.location.SystemLocationProvider;
|
||||
@@ -28,13 +44,13 @@ import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
public abstract class BaseMvpActivity<P extends IPresenter, VDB extends ViewDataBinding> extends BaseAppCompatActivity<VDB> implements
|
||||
IView<Activity> , LocationProvider.LocationCallback
|
||||
{
|
||||
IView<Activity> {
|
||||
|
||||
protected P MvpPre;
|
||||
|
||||
protected abstract P bindPresenter();
|
||||
private String city1;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
@@ -77,102 +93,130 @@ public abstract class BaseMvpActivity<P extends IPresenter, VDB extends ViewData
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void logOutEvent(UserBean userBean) {
|
||||
// 在用户 UI 点击登录的时候调用
|
||||
TUILogin.login(getBaseContext(), CommonAppContext.getInstance().getCurrentEnvironment().getSdkAppId(), "u"+userBean.getUser_id(), userBean.getTencent_im(), new TUICallback() {
|
||||
TUILogin.login(getBaseContext(), CommonAppContext.getInstance().getCurrentEnvironment().getSdkAppId(), "u" + userBean.getUser_id(), userBean.getTencent_im(), new TUICallback() {
|
||||
@Override
|
||||
public void onError(final int code, final String desc) {
|
||||
LogUtils.e("@@@1",code,"描述:",desc);
|
||||
LogUtils.e("@@@1", code, "描述:", desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
LogUtils.e("@@@","成功");
|
||||
V2TIMUserFullInfo userFullInfo = new V2TIMUserFullInfo();
|
||||
userFullInfo.setNickname(userBean.getNickname());
|
||||
userFullInfo.setFaceUrl(userBean.getAvatar());
|
||||
userFullInfo.setAllowType(userBean.getSex());
|
||||
V2TIMManager.getInstance().setSelfInfo(userFullInfo, new V2TIMCallback() {
|
||||
LogUtils.e("@@@", "成功");
|
||||
V2TIMManager.getConversationManager().getTotalUnreadMessageCount(new V2TIMValueCallback<Long>() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
LogUtils.e("@@@", "成功");
|
||||
public void onSuccess(Long aLong) {
|
||||
// 通知未读数变化
|
||||
UnreadCountEvent event =CommonAppContext.getInstance().unreadCountEvent;
|
||||
if (event==null){
|
||||
event=new UnreadCountEvent();
|
||||
}
|
||||
event.setALong(aLong);
|
||||
// 使用EventBus通知
|
||||
CommonAppContext.getInstance().setUnreadCountEvent(event);
|
||||
EventBus.getDefault().post(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
LogUtils.e("@@@", "描述"+desc);
|
||||
// 错误处理
|
||||
}
|
||||
});
|
||||
initLocation();
|
||||
//initLocation();
|
||||
}
|
||||
});
|
||||
|
||||
// V2TIMManager.getInstance().addIMSDKListener(imSdkListener);
|
||||
|
||||
}
|
||||
private SystemLocationProvider locationProvider;
|
||||
private void initLocation() {
|
||||
if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
|
||||
// 请求定位权限
|
||||
ActivityCompat.requestPermissions(
|
||||
(Activity) this,
|
||||
new String[]{
|
||||
android.Manifest.permission.ACCESS_FINE_LOCATION,
|
||||
Manifest.permission.ACCESS_COARSE_LOCATION
|
||||
},
|
||||
1001 // 自定义常量,比如 1001
|
||||
);
|
||||
}
|
||||
locationProvider = new SystemLocationProvider();
|
||||
|
||||
// 请求一次性的位置信息
|
||||
locationProvider.getLastKnownLocation(this, this);
|
||||
}
|
||||
|
||||
private final V2TIMSDKListener imSdkListener = new V2TIMSDKListener() {
|
||||
@Override
|
||||
public void onLocationReceived(double latitude, double longitude, String city) {
|
||||
LogUtils.e("当前位置:" + city);
|
||||
city1=city;
|
||||
EventBus.getDefault().post(city1);
|
||||
public void onConnecting() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(String errorMessage) {
|
||||
LogUtils.e("定位失败");
|
||||
public void onConnectSuccess() {//重连成功
|
||||
if (CommonAppContext.getInstance().playId!=null){
|
||||
LogUtils.e("@@@", "重连成功");
|
||||
LogUtils.e("@@@", ""+CommonAppContext.getInstance().playId);
|
||||
RetrofitClient.getInstance().roomUserReconnect(CommonAppContext.getInstance().playId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectFailed(int code, String error) {
|
||||
LogUtils.e("@@@", "断开连接");
|
||||
CommonAppContext.getInstance().onConnectFailed=true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKickedOffline() {
|
||||
// queren1();
|
||||
if (CommonAppContext.getInstance().playId!=null){
|
||||
ToastUtils.showShort("您的账号已被挤下线");
|
||||
try {
|
||||
CommonAppContext.getInstance().clearLoginInfo();
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUserSigExpired() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSelfInfoUpdated(V2TIMUserFullInfo info) {
|
||||
}
|
||||
};
|
||||
|
||||
private void queren1() {
|
||||
// 创建并显示确认对话框
|
||||
new ConfirmDialog(this,
|
||||
"温馨提示",
|
||||
"您的账号已在别处登录,请确认密码是否已经泄露",
|
||||
"知道了",
|
||||
"",
|
||||
v -> {
|
||||
// 点击“确认”按钮时执行删除操作
|
||||
|
||||
if (CommonAppContext.getInstance().playId!=null){
|
||||
RoomManager.getInstance().exitRoom(CommonAppContext.getInstance().playId);
|
||||
}
|
||||
try {
|
||||
CommonAppContext.getInstance().clearLoginInfo();
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
},
|
||||
v -> {
|
||||
// 点击“取消”按钮时什么都不做
|
||||
|
||||
}, false, 0).show();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
|
||||
if (requestCode == 1001) {
|
||||
if (locationProvider==null) {
|
||||
locationProvider = new SystemLocationProvider();
|
||||
public Resources getResources() {
|
||||
Resources resources = super.getResources();
|
||||
if (resources != null) {
|
||||
Configuration configuration = resources.getConfiguration();
|
||||
if (configuration != null) {
|
||||
// 设置字体缩放比例不随系统变化
|
||||
configuration.fontScale = 1.0f; // 1.0f表示默认大小
|
||||
resources.updateConfiguration(configuration, resources.getDisplayMetrics());
|
||||
}
|
||||
locationProvider.getLastKnownLocation(this, this);
|
||||
}
|
||||
|
||||
return resources;
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void userInfoEvent(UserInfo event) {
|
||||
V2TIMUserFullInfo userFullInfo = new V2TIMUserFullInfo();
|
||||
userFullInfo.setNickname(event.getNickname());
|
||||
userFullInfo.setFaceUrl(event.getAvatar());
|
||||
userFullInfo.setAllowType(event.getSex());
|
||||
V2TIMManager.getInstance().setSelfInfo(userFullInfo, new V2TIMCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
LogUtils.e("@@@", "成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
LogUtils.e("@@@", "描述"+desc);
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 显示全局飘屏消息(支持任意位置飘过)
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* 显示全局飘屏消息(支持任意位置飘过)
|
||||
*
|
||||
*/
|
||||
// @Subscribe(threadMode = ThreadMode.MAIN)
|
||||
// public void showPiaoPingMessage(MqttBean mqttBean) {
|
||||
// WindowManager windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
|
||||
|
||||
@@ -10,7 +10,10 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.webkit.GeolocationPermissions;
|
||||
import android.webkit.JavascriptInterface;
|
||||
@@ -21,11 +24,16 @@ import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Autowired;
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.base.RoomManager;
|
||||
import com.xscm.moduleutil.databinding.ActivityWebViewBinding;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.tencent.imsdk.v2.V2TIMConversation;
|
||||
@@ -46,6 +54,8 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
||||
|
||||
public String title;
|
||||
public String url;
|
||||
@Autowired
|
||||
public String type;//type=1:青少年模式
|
||||
private ValueCallback<Uri> mUploadMessage;
|
||||
private ValueCallback<Uri[]> mUploadCallbackAboveL;
|
||||
private final int REQUEST_FILE_PICKER = 1;
|
||||
@@ -53,6 +63,8 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
@Override
|
||||
protected void initData() {
|
||||
|
||||
|
||||
WebSettings webSettings = mBinding.webView.getSettings();
|
||||
|
||||
// 禁用水平滚动
|
||||
@@ -61,9 +73,9 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
||||
webSettings.setJavaScriptEnabled(true);
|
||||
webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); //关闭webview中缓存
|
||||
//增加JSBridge
|
||||
mBinding.webView.addJavascriptInterface(new WebAppInterface(this), "Android");
|
||||
mBinding.webView.addJavascriptInterface(new WebAppInterface(this, type), "Android");
|
||||
|
||||
if (title!=null && !title.isEmpty()){
|
||||
if (title != null && !title.isEmpty()) {
|
||||
if (title.contains("协议")) {
|
||||
webSettings.setDisplayZoomControls(false); // 隐藏默认缩放控件
|
||||
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL); // 使用正常布局算法
|
||||
@@ -75,10 +87,10 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
||||
// 设置初始缩放
|
||||
mBinding.webView.setInitialScale(100);
|
||||
mBinding.webView.getSettings().setUseWideViewPort(false);
|
||||
}else {
|
||||
} else {
|
||||
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
|
||||
}
|
||||
|
||||
@@ -94,7 +106,6 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
||||
mBinding.webView.setScrollContainer(true);
|
||||
|
||||
|
||||
|
||||
mBinding.webView.setWebViewClient(new WebViewClient());
|
||||
mBinding.webView.setBackgroundColor(Color.TRANSPARENT);
|
||||
mBinding.webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
||||
@@ -173,6 +184,35 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
|
||||
if (getOnBackPressedDispatcher() != null) {
|
||||
getOnBackPressedDispatcher().addCallback(this, new androidx.activity.OnBackPressedCallback(true) {
|
||||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
// 拦截返回键,显示退出对话框而不是直接退出
|
||||
showExitRoomDialog();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void showExitRoomDialog() {
|
||||
if (type != null) {
|
||||
if (type.equals("1")) {
|
||||
ARouter.getInstance().build(ARouteConstants.UNDERAGE_ACTIVITY).withInt("type", 1).navigation();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
private void showFileChooser() {
|
||||
// 这里可以扩展为显示对话框让用户选择“拍照”或“从相册选择”
|
||||
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
@@ -214,12 +254,74 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
// 当type==1时,禁止返回键和手势返回
|
||||
// 不执行任何操作,禁止返回
|
||||
if (type != null) {
|
||||
if (type.equals("1")) {
|
||||
ARouter.getInstance().build(ARouteConstants.UNDERAGE_ACTIVITY).withInt("type", 1).navigation();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
|
||||
// 正常处理返回键
|
||||
super.onBackPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
LogUtils.d("MainActivity", "onKeyDown called, keyCode: " + keyCode);
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
if (type != null) {
|
||||
if (type.equals("1")) {
|
||||
ARouter.getInstance().build(ARouteConstants.UNDERAGE_ACTIVITY).withInt("type", 1).navigation();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
return true; // 消费事件
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public boolean dispatchTouchEvent(MotionEvent ev) {
|
||||
// // 当type==1时,禁止手势滑动返回
|
||||
// if (type.equals("1")) {
|
||||
// // 检查是否是边缘滑动返回手势
|
||||
// if (ev.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
// // 如果触摸点在屏幕边缘,拦截事件
|
||||
// if (ev.getX() < 50) { // 左边缘50像素内
|
||||
// return true; // 拦截事件,不传递给子View
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return super.dispatchTouchEvent(ev);
|
||||
// }
|
||||
@Override
|
||||
protected void initView() {
|
||||
getWindow().getDecorView().setBackgroundResource(com.xscm.moduleutil.R.color.white);
|
||||
title = getIntent().getStringExtra("title");
|
||||
url = getIntent().getStringExtra("url");
|
||||
if (title!=null) {
|
||||
type = getIntent().getStringExtra("type");
|
||||
if (type != null) {
|
||||
// 当type==1时,禁用返回手势滑动
|
||||
if (type.equals("1")) {
|
||||
// 禁用边缘滑动返回
|
||||
if (getSupportActionBar() != null) {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (title != null) {
|
||||
if (title.equals("举报") || title.equals("等级") || title.equals("公会") || title.equals("邀请") || title.equals("反馈")) {
|
||||
mBinding.topBar.setVisibility(GONE);
|
||||
// mBinding.webView.setPadding(0,20,0,0);
|
||||
@@ -227,20 +329,18 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
||||
mBinding.topBar.setVisibility(VISIBLE);
|
||||
mBinding.topBar.setTitle(title);
|
||||
}
|
||||
}else {
|
||||
if (url.equals(CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=6")){
|
||||
} else {
|
||||
if (url.equals(CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl() + "/api/Page/page_show?id=6")) {
|
||||
mBinding.topBar.setVisibility(VISIBLE);
|
||||
mBinding.topBar.setTitle("用户协议");
|
||||
}else if (url.equals(CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=4")){
|
||||
} else if (url.equals(CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl() + "/api/Page/page_show?id=4")) {
|
||||
mBinding.topBar.setVisibility(VISIBLE);
|
||||
mBinding.topBar.setTitle("隐私协议");
|
||||
}else {
|
||||
} else {
|
||||
mBinding.topBar.setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -250,9 +350,11 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
||||
|
||||
public class WebAppInterface {
|
||||
Context mContext;
|
||||
String type;
|
||||
|
||||
WebAppInterface(Context c) {
|
||||
WebAppInterface(Context c, String type1) {
|
||||
mContext = c;
|
||||
type = type1;
|
||||
}
|
||||
|
||||
// 被 H5 调用的方法
|
||||
@@ -263,8 +365,15 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
||||
|
||||
@JavascriptInterface
|
||||
public void closeWeb() {
|
||||
LogUtils.e("value: ");
|
||||
finish();
|
||||
if (type != null) {
|
||||
if (type.equals("1")) {
|
||||
ARouter.getInstance().build(ARouteConstants.UNDERAGE_ACTIVITY).withInt("type", 1).navigation();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
@@ -281,8 +390,11 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
||||
|
||||
@JavascriptInterface
|
||||
public void jumpRoomPage(String room_id) {
|
||||
ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("form", "首页").withString("roomId", room_id).navigation();
|
||||
RoomManager.getInstance().fetchRoomDataAndEnter(getApplicationContext(), room_id,"");
|
||||
|
||||
// ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("form", "首页").withString("roomId", room_id).navigation();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void jumpWebPage(String objects) {
|
||||
// ARouter.getInstance().build(ARouteConstants.USER_HOME_PAGE).navigation();
|
||||
@@ -290,22 +402,25 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void enterGroupChat(String group_id,String cover,String guild_name) {
|
||||
public void enterGroupChat(String group_id, String cover, String guild_name) {
|
||||
Intent intent = new Intent(mContext, TUIGroupChatActivity.class);
|
||||
intent.putExtra(TUIConstants.TUIChat.CHAT_ID, group_id);
|
||||
intent.putExtra(TUIConstants.TUIChat.CHAT_NAME, guild_name);
|
||||
intent.putExtra(TUIConstants.TUIChat.CHAT_TYPE, V2TIMConversation.V2TIM_GROUP);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void chatWithUser(String user_id,String nickname) {
|
||||
Intent intent = new Intent(mContext, TUIC2CChatActivity.class);
|
||||
public void chatWithUser(String user_id, String nickname) {
|
||||
Intent intent = new Intent(mContext, TUIGroupChatActivity.class);
|
||||
intent.putExtra(TUIConstants.TUIChat.CHAT_ID, user_id);
|
||||
intent.putExtra(TUIConstants.TUIChat.CHAT_NAME, nickname);
|
||||
intent.putExtra(TUIConstants.TUIChat.CHAT_TYPE, V2TIMConversation.V2TIM_C2C);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void exchange(){
|
||||
public void exchange() {
|
||||
ARouter.getInstance().build(ARouteConstants.CURRENCY).navigation();
|
||||
|
||||
}
|
||||
@@ -321,7 +436,7 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void Recharge(){
|
||||
public void Recharge() {
|
||||
ARouter.getInstance().build(ARouteConstants.RECHARGE_ACTIVITY).navigation();
|
||||
}
|
||||
}
|
||||
@@ -333,6 +448,7 @@ public class WebViewActivity extends BaseAppCompatActivity<ActivityWebViewBindin
|
||||
// intent.putExtra("menuName", msg);
|
||||
// startActivity(intent);
|
||||
|
||||
|
||||
LogUtils.e("closeWeb");
|
||||
}
|
||||
}
|
||||
@@ -22,13 +22,13 @@ public class NewsPresenter extends BasePresenter<NewsContacts.View> implements N
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
MvpRef.get().finishRefresh();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<NewsMessageList> newsMessageLists) {
|
||||
MvpRef.get().showNews(newsMessageLists);
|
||||
|
||||
MvpRef.get().finishRefresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.xscm.moduleutil.activity.news;
|
||||
import static android.view.View.GONE;
|
||||
import static android.view.View.VISIBLE;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.text.Html;
|
||||
import android.view.View;
|
||||
|
||||
@@ -14,6 +15,8 @@ import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.activity.BaseMvpActivity;
|
||||
import com.xscm.moduleutil.activity.WebViewActivity;
|
||||
import com.xscm.moduleutil.base.RoomManager;
|
||||
import com.xscm.moduleutil.bean.NewsMessageList;
|
||||
import com.xscm.moduleutil.databinding.ActivityOfficialNoticeBinding;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
@@ -75,9 +78,13 @@ public class OfficialNoticeActivity extends BaseMvpActivity<NewsPresenter, Activ
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (item.getRoom_id()>0){
|
||||
ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("room_id", item.getRoom_id() + "").navigation();
|
||||
RoomManager.getInstance().fetchRoomDataAndEnter(getApplicationContext(), item.getRoom_id()+"","");
|
||||
// ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("roomId", item.getRoom_id() + "").navigation();
|
||||
}else if (item.getRoom_id() == 0 && item.getUrl() != null && !item.getUrl().isEmpty()){
|
||||
ARouter.getInstance().build(ARouteConstants.H5).withString("url", item.getUrl()).navigation();
|
||||
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();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -9,19 +9,23 @@ import androidx.annotation.NonNull;
|
||||
import android.text.Html;
|
||||
import android.text.TextUtils;
|
||||
import android.text.method.ScrollingMovementMethod;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.blankj.utilcode.util.AppUtils;
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.blankj.utilcode.util.ScreenUtils;
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.bean.AppUpdateModel;
|
||||
import com.xscm.moduleutil.databinding.DialogAppUpdateBinding;
|
||||
import com.xscm.moduleutil.utils.DownloadListener;
|
||||
import com.xscm.moduleutil.utils.DownloadUtil;
|
||||
import com.xscm.moduleutil.utils.TextViewUtils;
|
||||
import com.xscm.moduleutil.utils.logger.Logger;
|
||||
import com.xscm.moduleutil.widget.dialog.BaseDialog;
|
||||
|
||||
@@ -77,7 +81,11 @@ public class AppUpdateDialog extends BaseDialog<DialogAppUpdateBinding> implemen
|
||||
|
||||
public void setAppUpdateModel(AppUpdateModel appUpdateModel) {
|
||||
this.appUpdateModel = appUpdateModel;
|
||||
mBinding.tvContent.setText(TextUtils.isEmpty(appUpdateModel.getContent()) ? "修复旧版本已知bug" : Html.fromHtml(appUpdateModel.getContent()));
|
||||
TextViewUtils.setHtmlText(mBinding.tvContent,appUpdateModel.getContent(),false);
|
||||
//mBinding.tvContent.setText(TextUtils.isEmpty(appUpdateModel.getContent()) ? "修复旧版本已知bug" : Html.fromHtml(appUpdateModel.getContent()));
|
||||
LogUtils.d("AppUpdateDialog", "setAppUpdateModel " + appUpdateModel.getContent().toString());
|
||||
// mBinding.tvContent.setHtmlText(appUpdateModel.getContent());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
package com.xscm.moduleutil.adapter;
|
||||
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.bean.RechargeBean;
|
||||
import com.xscm.moduleutil.utils.SystemUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -36,7 +41,10 @@ public class BalanceRechargeAdapter extends BaseMultiItemQuickAdapter<RechargeBe
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, RechargeBean item) {
|
||||
int type = helper.getItemViewType();
|
||||
|
||||
// ConstraintLayout constraintLayout = helper.getView(R.id.cl_item);
|
||||
// ViewGroup.LayoutParams layoutParams =constraintLayout.getLayoutParams();
|
||||
// layoutParams.width = ( com.blankj.utilcode.util.ScreenUtils.getScreenWidth()-32-24)/3-24; // 使用你定义的getWidth方法
|
||||
// constraintLayout.setLayoutParams(layoutParams);
|
||||
if (type == ITEM_TYPE_NORMAL) {
|
||||
// 正常 item 显示逻辑
|
||||
helper.setText(R.id.tv_gold_num, item.getCoins());
|
||||
|
||||
@@ -26,15 +26,15 @@ public class GiftAdapter extends BaseQuickAdapter<HeavenGiftBean, BaseViewHolder
|
||||
protected void convert(BaseViewHolder helper, HeavenGiftBean item) {
|
||||
ImageUtils.loadHeadCC(item.getPicture(), helper.getView(R.id.iv_head));
|
||||
helper.getView(R.id.im_jb).setVisibility(View.VISIBLE);
|
||||
if (item.getType() == COIN_TYPE) {
|
||||
helper.setText(R.id.tv_gift_time, String.format("%s", item.getGold()));
|
||||
} else if (item.getType() == GIFT_TYPE) {
|
||||
helper.getView(R.id.im_jb).setVisibility(View.GONE);
|
||||
helper.setText(R.id.tv_gift_time, String.format("*%s", item.getQuantity()));
|
||||
} else {
|
||||
helper.getView(R.id.im_jb).setVisibility(View.GONE);
|
||||
helper.setText(R.id.tv_gift_time, String.format("%s天", item.getDays()));
|
||||
}
|
||||
// if (item.getType() == COIN_TYPE) {
|
||||
// helper.setText(R.id.tv_gift_time, String.format("%s", item.getGold()));
|
||||
// } else if (item.getType() == GIFT_TYPE) {
|
||||
// helper.getView(R.id.im_jb).setVisibility(View.GONE);
|
||||
// helper.setText(R.id.tv_gift_time, String.format("*%s", item.getQuantity()));
|
||||
// } else {
|
||||
// helper.getView(R.id.im_jb).setVisibility(View.GONE);
|
||||
// helper.setText(R.id.tv_gift_time, String.format("%s天", item.getDays()));
|
||||
// }
|
||||
helper.setText(R.id.tv_head_name, item.getTitle());
|
||||
ViewGroup.LayoutParams layoutParams = helper.itemView.getLayoutParams();
|
||||
layoutParams.width = ((ScreenUtils.getScreenWidth() - ConvertUtils.dp2px(140)) / 4);
|
||||
|
||||
@@ -121,7 +121,7 @@ public class GiftPackAdapter extends BaseAdapter {
|
||||
viewHolder.item_layout = (ConstraintLayout) convertView.findViewById(R.id.cl_gift);
|
||||
viewHolder.ivDownOn = (ImageView) convertView.findViewById(R.id.iv_down_on);
|
||||
viewHolder.cl_iv_down_on = (ConstraintLayout) convertView.findViewById(R.id.cl_iv_down_on);
|
||||
|
||||
viewHolder.integral = (TextView) convertView.findViewById(R.id.integral);
|
||||
convertView.setTag(viewHolder);
|
||||
} else {
|
||||
viewHolder = (GiftPackAdapter.ViewHolder) convertView.getTag();
|
||||
@@ -129,10 +129,11 @@ public class GiftPackAdapter extends BaseAdapter {
|
||||
|
||||
viewHolder.item_layout.setOnClickListener(v -> {
|
||||
// RoonGiftModel clickedModel = (RoonGiftModel) v.getTag();
|
||||
EventBus.getDefault().post(new RoomGiftPackToEvent(this, giftModel, 1));
|
||||
EventBus.getDefault().post(new RoomGiftPackToEvent(this, giftModel, 2));
|
||||
|
||||
});
|
||||
|
||||
viewHolder.integral.setVisibility(View.VISIBLE);
|
||||
viewHolder.integral.setText("x"+giftModel.getNum());
|
||||
//设置礼物名字
|
||||
viewHolder.tv_gift_name.setText(giftModel.getGift_name());
|
||||
//设置礼物价格
|
||||
@@ -162,7 +163,7 @@ public class GiftPackAdapter extends BaseAdapter {
|
||||
|
||||
static class ViewHolder {
|
||||
public ConstraintLayout item_layout;
|
||||
public TextView tv_gift_name, tv_gift_price, tv_gift_num;
|
||||
public TextView tv_gift_name, tv_gift_price, integral;
|
||||
public ImageView iv_gift_pic;
|
||||
public TextView tv_gift_change_love_values;
|
||||
public ImageView ivDownOn;
|
||||
|
||||
@@ -42,12 +42,13 @@ public class GiftRoomAdapter extends BaseAdapter {
|
||||
private final int pageSize = 100;
|
||||
|
||||
public GiftRoomAdapter(Context context, List<RoonGiftModel> mDatas, int curIndex, String type) {
|
||||
inflater = LayoutInflater.from(context);
|
||||
|
||||
this.mDatas = mDatas;
|
||||
this.curIndex = curIndex;
|
||||
this.mContext = context;
|
||||
this.type = type;
|
||||
this.gestureDetector = new MyGestureDetector(mContext);
|
||||
inflater = LayoutInflater.from(mContext);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,6 +101,16 @@ public class GiftRoomAdapter extends BaseAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
public void updateData(List<RoonGiftModel> newData) {
|
||||
this.mDatas.clear();
|
||||
// 确保新数据都不处于选中状态
|
||||
for (RoonGiftModel model : newData) {
|
||||
model.setChecked(false);
|
||||
}
|
||||
this.mDatas.addAll(newData);
|
||||
}
|
||||
|
||||
|
||||
// private static class MyGestureDetector extends GestureDetector {
|
||||
// private GiftRoomAdapter mAdapter;
|
||||
// private RoonGiftModel mGiftModel;
|
||||
@@ -146,18 +157,6 @@ public class GiftRoomAdapter extends BaseAdapter {
|
||||
viewHolder.item_layout = (ConstraintLayout) convertView.findViewById(R.id.cl_gift);
|
||||
viewHolder.ivDownOn = (ImageView) convertView.findViewById(R.id.iv_down_on);
|
||||
viewHolder.cl_iv_down_on = (ConstraintLayout) convertView.findViewById(R.id.cl_iv_down_on);
|
||||
// viewHolder.tv_gift_num = convertView.findViewById(R.id.tv_gift_num);
|
||||
|
||||
// viewHolder.tv_gift_change_love_values = convertView.findViewById(R.id.tv_gift_change_love_values);
|
||||
// viewHolder.item_layout.setOnTouchListener((v, event) -> {
|
||||
// gestureDetector.setGiftModel(GiftRoomAdapter.this, giftModel);
|
||||
// gestureDetector.onTouchEvent(event);
|
||||
//
|
||||
// return true;
|
||||
// });
|
||||
|
||||
|
||||
|
||||
|
||||
convertView.setTag(viewHolder);
|
||||
} else {
|
||||
@@ -211,7 +210,20 @@ public class GiftRoomAdapter extends BaseAdapter {
|
||||
// if (giftModel.isManghe()) {
|
||||
// viewHolder.tv_gift_change_love_values.setVisibility(View.GONE);
|
||||
// }
|
||||
if (giftModel.getGift_bag() == 10) {
|
||||
|
||||
viewHolder.item_layout.setBackgroundResource(R.mipmap.gift_tkzj);
|
||||
viewHolder.tv_gift_name.setText("");
|
||||
viewHolder.tv_gift_name.setBackgroundResource(R.mipmap.gift_name_tkzj);
|
||||
} else if (giftModel.getGift_bag() == 11) {
|
||||
viewHolder.tv_gift_name.setText("");
|
||||
viewHolder.item_layout.setBackgroundResource(R.mipmap.gift_syzc);
|
||||
viewHolder.tv_gift_name.setBackgroundResource(R.mipmap.gift_name_syzc);
|
||||
} else if (giftModel.getGift_bag() == 12) {
|
||||
viewHolder.tv_gift_name.setText("");
|
||||
viewHolder.item_layout.setBackgroundResource(R.mipmap.gift_sjzd);
|
||||
viewHolder.tv_gift_name.setBackgroundResource(R.mipmap.gift_name_skzd);
|
||||
}
|
||||
return convertView;
|
||||
}
|
||||
|
||||
|
||||
@@ -158,7 +158,10 @@ public class GiftTwoAdapter extends BaseAdapter {
|
||||
viewHolder.ivDownOn.setVisibility(View.GONE);
|
||||
viewHolder.cl_iv_down_on.setBackgroundResource(0);
|
||||
}
|
||||
viewHolder.tv_gift_num.setText(String.format("x%s", giftModel.getNum()));
|
||||
if (giftModel.getNum()==0){
|
||||
viewHolder.tv_gift_num.setVisibility(View.GONE);
|
||||
}
|
||||
viewHolder.tv_gift_num.setText(String.format("x%s", (giftModel.getNum()!=0?giftModel.getNum():"")));
|
||||
|
||||
|
||||
//设置
|
||||
|
||||
@@ -12,6 +12,8 @@ import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.base.BaseMvpFragment;
|
||||
import com.xscm.moduleutil.bean.GiftLabelBean;
|
||||
import com.xscm.moduleutil.bean.GiftPackBean;
|
||||
import com.xscm.moduleutil.bean.GiftPackEvent;
|
||||
import com.xscm.moduleutil.bean.GiftPackListCount;
|
||||
import com.xscm.moduleutil.bean.RewardUserBean;
|
||||
import com.xscm.moduleutil.bean.RoonGiftModel;
|
||||
import com.xscm.moduleutil.bean.WalletBean;
|
||||
@@ -34,21 +36,23 @@ import java.util.List;
|
||||
|
||||
public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter, RoomVpGiftBinding> implements RewardGiftContacts.View {
|
||||
private String id;
|
||||
private GiftTwoAdapter mAdapter;
|
||||
private GiftRoomAdapter roomAdapter;
|
||||
private GiftPackAdapter packAdapter;
|
||||
private String tag;
|
||||
private int pageSize = 100;//一页显示的礼物个数
|
||||
private int pageCount;//页数
|
||||
private int type;//1:房间点击进入的;2:打赏进入的
|
||||
private List<RoonGiftModel> giftList=new ArrayList<>();
|
||||
private List<GiftPackBean> giftPackList=new ArrayList<>();
|
||||
private List<RoonGiftModel> giftList = new ArrayList<>();
|
||||
private List<GiftPackBean> giftPackList = new ArrayList<>();
|
||||
private String roomId;
|
||||
private String bdgiftId;
|
||||
|
||||
public static GiftTwoDetailsFragment newInstance(String id,int type) {
|
||||
public static GiftTwoDetailsFragment newInstance(String id, int type, String roomId) {
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putString("id", id);
|
||||
args.putInt("type", type);
|
||||
args.putString("roomId", roomId);
|
||||
GiftTwoDetailsFragment fragment = new GiftTwoDetailsFragment();
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
@@ -59,8 +63,10 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
||||
super.initArgs(arguments);
|
||||
id = arguments.getString("id");
|
||||
type = arguments.getInt("type");
|
||||
roomId = arguments.getString("roomId");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
@@ -72,20 +78,50 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
||||
return new RewardGiftPresenter(this, getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
if (id.equals("0")){
|
||||
public void loadDataIfNeeded(String id, int type, String roomId) {
|
||||
if (MvpPre==null){
|
||||
MvpPre = new RewardGiftPresenter(this, getActivity());
|
||||
}
|
||||
if (id.equals("0")) {
|
||||
MvpPre.giftPack();
|
||||
}else {
|
||||
if (type==0) {
|
||||
MvpPre.getGiftList("0", type);
|
||||
}else {
|
||||
MvpPre.getGiftList(id, type);
|
||||
} else {
|
||||
if (type == 0) {
|
||||
MvpPre.getGiftList("0", type, roomId);
|
||||
} else {
|
||||
if (id == null) {
|
||||
id = "0";
|
||||
}
|
||||
MvpPre.getGiftList(id, type, roomId);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onString(GiftPackEvent event) {
|
||||
if (event!=null && event.getBdid()!=null) {
|
||||
bdgiftId = event.getBdid();
|
||||
MvpPre.giftPack();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
if (type==0){
|
||||
MvpPre.getGiftList("0", type, roomId);
|
||||
}
|
||||
// if (id.equals("0")) {
|
||||
// MvpPre.giftPack();
|
||||
// } else {
|
||||
// if (type == 0) {
|
||||
// MvpPre.getGiftList("0", type, roomId);
|
||||
// } else {
|
||||
// MvpPre.getGiftList(id, type, roomId);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
|
||||
@@ -118,30 +154,21 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGiftList(List<RoonGiftModel> data,int type) {
|
||||
if (type == 1){
|
||||
giftList=new ArrayList<>();
|
||||
giftList.addAll(data);
|
||||
pageCount = (int) Math.ceil(data.size() * 1.0 / pageSize);
|
||||
for (int j = 0; j < pageCount; j++) {
|
||||
roomAdapter = new GiftRoomAdapter(getActivity(), data, j, "0");
|
||||
mBinding.rvGift.setAdapter(roomAdapter);
|
||||
}
|
||||
}else {
|
||||
giftList=new ArrayList<>();
|
||||
giftList.addAll(data);
|
||||
pageCount = (int) Math.ceil(data.size() * 1.0 / pageSize);
|
||||
for (int j = 0; j < pageCount; j++) {
|
||||
// mAdapter = new GiftTwoAdapter(getActivity(), data, j, "0");
|
||||
// mBinding.rvGift.setAdapter(mAdapter);
|
||||
roomAdapter = new GiftRoomAdapter(getActivity(), data, j, "0");
|
||||
mBinding.rvGift.setAdapter(roomAdapter);
|
||||
}
|
||||
public void setGiftList(List<RoonGiftModel> data, int type) {
|
||||
giftList = new ArrayList<>();
|
||||
giftList.addAll(data);
|
||||
pageCount = (int) Math.ceil(data.size() * 1.0 / pageSize);
|
||||
|
||||
// 只需要创建一次Adapter并设置,循环设置没有意义
|
||||
if (pageCount > 0) {
|
||||
roomAdapter = new GiftRoomAdapter(getActivity(), data, 0, "0");
|
||||
mBinding.rvGift.setAdapter(roomAdapter);
|
||||
}
|
||||
// EventBus.getDefault().post(new RoomGiftEvent(data));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void giveGift() {
|
||||
|
||||
@@ -164,15 +191,44 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
||||
|
||||
@Override
|
||||
public void giftPack(List<GiftPackBean> giftPackBean) {
|
||||
giftPackList=new ArrayList<>();
|
||||
giftPackList.addAll(giftPackBean);
|
||||
pageCount = (int) Math.ceil(giftPackBean.size() * 1.0 / pageSize);
|
||||
for (int j = 0; j < pageCount; j++) {
|
||||
giftPackList = new ArrayList<>();
|
||||
|
||||
if (giftPackBean != null && giftPackBean.size() > 0) {
|
||||
|
||||
if (bdgiftId != null) {
|
||||
for (GiftPackBean item : giftPackBean) {
|
||||
if (item.getGift_id().equals(bdgiftId)) {
|
||||
item.setChecked(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
giftPackList.addAll(giftPackBean);
|
||||
pageCount = (int) Math.ceil(giftPackBean.size() * 1.0 / pageSize);
|
||||
for (int j = 0; j < pageCount; j++) {
|
||||
// mAdapter = new GiftTwoAdapter(getActivity(), data, j, "0");
|
||||
// mBinding.rvGift.setAdapter(mAdapter);
|
||||
packAdapter = new GiftPackAdapter(getActivity(), giftPackBean, j, "0");
|
||||
packAdapter = new GiftPackAdapter(getActivity(), giftPackBean, j, "0");
|
||||
mBinding.rvGift.setAdapter(packAdapter);
|
||||
}
|
||||
} else {
|
||||
giftPackBean = new ArrayList<>();
|
||||
pageCount = (int) Math.ceil(giftPackBean.size() * 1.0 / pageSize);
|
||||
packAdapter = new GiftPackAdapter(getActivity(), giftPackBean, 0, "0");
|
||||
mBinding.rvGift.setAdapter(packAdapter);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGiftPack(String s) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGiftPackListCount(GiftPackListCount giftPackListCount) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -187,7 +243,7 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onGiftClicRoomkEvent(RoomGiftClickEvent event) {
|
||||
if (giftList == null){
|
||||
if (giftList == null) {
|
||||
giftList = new ArrayList<>();
|
||||
giftList.add(event.gift);
|
||||
}
|
||||
@@ -197,7 +253,7 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
||||
RoonGiftModel giftModel = giftList.get(i);
|
||||
if (giftModel.getGift_id().equals(id)) {
|
||||
if (!giftModel.isChecked()) {
|
||||
EventBus.getDefault().post(new GiftUserRefreshEvent(giftModel.isCan_send_self(), event.type,event.gift));
|
||||
EventBus.getDefault().post(new GiftUserRefreshEvent(giftModel.isCan_send_self(), event.type, event.gift));
|
||||
giftModel.setChecked(true);
|
||||
}
|
||||
} else {
|
||||
@@ -215,7 +271,7 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
||||
if (giftModel.getGift_id().equals(id)) {
|
||||
selGift = giftModel;
|
||||
if (!giftModel.isChecked()) {
|
||||
EventBus.getDefault().post(new GiftUserRefreshEvent(giftModel.isCan_send_self(), event.type,event.gift));
|
||||
EventBus.getDefault().post(new GiftUserRefreshEvent(giftModel.isCan_send_self(), event.type, event.gift));
|
||||
giftModel.setChecked(true);
|
||||
}
|
||||
} else {
|
||||
@@ -237,7 +293,7 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
||||
giftPackList = new ArrayList<>();
|
||||
giftPackList.add(event.gift);
|
||||
}
|
||||
if (event.type == 1){
|
||||
if (event.type == 1) {
|
||||
String id = event.gift.getGift_id();
|
||||
for (int i = 0; i < giftPackList.size(); i++) {
|
||||
GiftPackBean giftModel = giftPackList.get(i);
|
||||
@@ -249,7 +305,7 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
||||
roonGiftModel.setNum(Integer.parseInt(giftModel.getNum()));
|
||||
if (giftModel.getGift_id().equals(id)) {
|
||||
if (!giftModel.isChecked()) {
|
||||
EventBus.getDefault().post(new GiftUserRefreshEvent(true, event.type,roonGiftModel));
|
||||
EventBus.getDefault().post(new GiftUserRefreshEvent(true, event.type, roonGiftModel));
|
||||
giftModel.setChecked(true);
|
||||
}
|
||||
} else {
|
||||
@@ -259,7 +315,7 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
||||
if (event.adapter != null && event.adapter.get() != null) {
|
||||
event.adapter.get().notifyDataSetChanged();
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
String id = event.gift.getGift_id();
|
||||
GiftPackBean selGift = null;
|
||||
for (int i = 0; i < giftPackList.size(); i++) {
|
||||
@@ -273,12 +329,12 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
||||
if (giftModel.getGift_id().equals(id)) {
|
||||
selGift = giftModel;
|
||||
if (!giftModel.isChecked()) {
|
||||
EventBus.getDefault().post(new GiftUserRefreshEvent(true, event.type,roonGiftModel));
|
||||
EventBus.getDefault().post(new GiftUserRefreshEvent(true, event.type, roonGiftModel));
|
||||
giftModel.setChecked(true);
|
||||
}
|
||||
} else {
|
||||
giftModel.setChecked(false);
|
||||
EventBus.getDefault().post(new GiftUserRefreshEvent(false, event.type,null));
|
||||
EventBus.getDefault().post(new GiftUserRefreshEvent(false, event.type, null));
|
||||
}
|
||||
}
|
||||
if (event.adapter != null && event.adapter.get() != null) {
|
||||
@@ -293,7 +349,7 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onGiftClicRoomkTEvent(RoomGiftClickToEvent event) {
|
||||
if (giftList == null){
|
||||
if (giftList == null) {
|
||||
giftList = new ArrayList<>();
|
||||
giftList.add(event.gift);
|
||||
}
|
||||
@@ -304,10 +360,10 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
||||
if (giftModel.getGift_id().equals(id)) {
|
||||
if (giftModel.isChecked()) {
|
||||
giftModel.setChecked(false);
|
||||
EventBus.getDefault().post(new GiftUserRefreshEvent(false, event.type,null));
|
||||
}else {
|
||||
EventBus.getDefault().post(new GiftUserRefreshEvent(false, event.type, null));
|
||||
} else {
|
||||
giftModel.setChecked(true);
|
||||
EventBus.getDefault().post(new GiftUserRefreshEvent(true, event.type,event.gift));
|
||||
EventBus.getDefault().post(new GiftUserRefreshEvent(true, event.type, event.gift));
|
||||
}
|
||||
} else {
|
||||
giftModel.setChecked(false);
|
||||
@@ -325,10 +381,10 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
||||
selGift = giftModel;
|
||||
if (giftModel.isChecked()) {
|
||||
giftModel.setChecked(false);
|
||||
EventBus.getDefault().post(new GiftUserRefreshEvent(false, event.type,null));
|
||||
}else {
|
||||
EventBus.getDefault().post(new GiftUserRefreshEvent(false, event.type, null));
|
||||
} else {
|
||||
giftModel.setChecked(true);
|
||||
EventBus.getDefault().post(new GiftUserRefreshEvent(giftModel.isCan_send_self(), event.type,event.gift));
|
||||
EventBus.getDefault().post(new GiftUserRefreshEvent(giftModel.isCan_send_self(), event.type, event.gift));
|
||||
}
|
||||
} else {
|
||||
giftModel.setChecked(false);
|
||||
|
||||
@@ -18,9 +18,11 @@ public class UserPhotoWallAdapter extends BaseQuickAdapter<String, BaseViewHolde
|
||||
protected void convert(BaseViewHolder helper, String item) {
|
||||
helper.setGone(R.id.iv_close, false);
|
||||
if (item.equals(ADD_PHOTO)) {
|
||||
helper.setVisible(R.id.iv_close, false);
|
||||
// 显示加号图片
|
||||
helper.setImageResource(R.id.riv_user_head, com.xscm.moduleutil.R.mipmap.add_img);
|
||||
} else {
|
||||
helper.setVisible(R.id.iv_close, true);
|
||||
ImageUtils.loadCenterCrop(item, helper.getView(R.id.riv_user_head));
|
||||
}
|
||||
|
||||
|
||||
@@ -3,17 +3,25 @@ package com.xscm.moduleutil.base;
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.Application;
|
||||
import android.content.ComponentCallbacks2;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.Signature;
|
||||
import android.content.res.Configuration;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.PowerManager;
|
||||
import android.provider.Settings;
|
||||
import android.util.Base64;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.webkit.WebView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.multidex.MultiDex;
|
||||
import androidx.multidex.MultiDexApplication;
|
||||
|
||||
@@ -22,22 +30,31 @@ import com.blankj.utilcode.util.AppUtils;
|
||||
import com.blankj.utilcode.util.FileUtils;
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.blankj.utilcode.util.ProcessUtils;
|
||||
import com.blankj.utilcode.util.ServiceUtils;
|
||||
import com.lahm.library.EasyProtectorLib;
|
||||
import com.lahm.library.EmulatorCheckCallback;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.tencent.imsdk.v2.V2TIMAdvancedMsgListener;
|
||||
import com.tencent.imsdk.v2.V2TIMManager;
|
||||
import com.tencent.imsdk.v2.V2TIMMessage;
|
||||
import com.tencent.imsdk.v2.V2TIMMessageManager;
|
||||
import com.tencent.imsdk.v2.V2TIMMessageReceipt;
|
||||
import com.tencent.imsdk.v2.V2TIMValueCallback;
|
||||
import com.xscm.moduleutil.bean.UserBean;
|
||||
import com.xscm.moduleutil.bean.UserInfo;
|
||||
import com.xscm.moduleutil.event.AppLifecycleEvent;
|
||||
import com.xscm.moduleutil.event.UnreadCountEvent;
|
||||
import com.xscm.moduleutil.http.RetrofitClient;
|
||||
import com.xscm.moduleutil.interfaces.AppLifecycleUtil;
|
||||
import com.xscm.moduleutil.listener.MessageListenerSingleton;
|
||||
import com.xscm.moduleutil.rtc.AgoraManager;
|
||||
import com.xscm.moduleutil.service.MyMqttService;
|
||||
import com.xscm.moduleutil.service.MqttConnect;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.utils.CrashHandler;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
import com.xscm.moduleutil.utils.UtilConfig;
|
||||
import com.xscm.moduleutil.utils.config.EnvironmentEnum;
|
||||
import com.xscm.moduleutil.utils.config.EnvironmentPrefs;
|
||||
import com.xscm.moduleutil.utils.cos.CosUploadManager;
|
||||
import com.xscm.moduleutil.widget.CommonAppConfig;
|
||||
import com.xscm.moduleutil.widget.PiaoPingManager;
|
||||
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.api.DefaultRefreshFooterCreator;
|
||||
import com.scwang.smartrefresh.layout.api.DefaultRefreshHeaderCreator;
|
||||
@@ -50,21 +67,24 @@ import com.tencent.bugly.crashreport.CrashReport;
|
||||
import com.tencent.qcloud.tuicore.TUILogin;
|
||||
import com.tencent.qcloud.tuicore.interfaces.TUICallback;
|
||||
|
||||
import org.eclipse.paho.client.mqttv3.MqttClient;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
|
||||
/**
|
||||
* Created by cxf on 2017/8/3.
|
||||
*/
|
||||
|
||||
public class CommonAppContext extends MultiDexApplication {
|
||||
public class CommonAppContext extends MultiDexApplication implements Application.ActivityLifecycleCallbacks {
|
||||
|
||||
private static CommonAppContext sInstance;
|
||||
private static Handler sMainThreadHandler;
|
||||
@@ -79,11 +99,54 @@ public class CommonAppContext extends MultiDexApplication {
|
||||
public boolean isPlaying;
|
||||
|
||||
public String playId;
|
||||
public String lable_id;
|
||||
public boolean isMicPlace;
|
||||
|
||||
public boolean isShowAg;
|
||||
|
||||
public boolean isRoomJoininj=false;
|
||||
|
||||
public String playCover;
|
||||
public boolean showSelf;//盲盒是否能送自己
|
||||
public String playName;
|
||||
private final ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(1);
|
||||
private ScheduledExecutorService scheduledExecutorServiceRoom = null;
|
||||
private MqttConnect mqttConnect=null;
|
||||
|
||||
// 添加后台状态标记
|
||||
private boolean wasInBackground = false;
|
||||
|
||||
public boolean isMai=false;
|
||||
|
||||
public void onAppBackground() {
|
||||
wasInBackground = true;
|
||||
}
|
||||
|
||||
public void onAppForeground() {
|
||||
wasInBackground = false;
|
||||
}
|
||||
|
||||
public boolean wasInBackground() {
|
||||
return wasInBackground;
|
||||
}
|
||||
|
||||
private int activityCount = 0;
|
||||
|
||||
private AppStateListener appStateListener;
|
||||
private boolean isListeningUnreadCount = false;
|
||||
public boolean onConnectFailed=false;//是否重连
|
||||
|
||||
public Map<String, Integer> onlineMap=new HashMap<>();
|
||||
|
||||
public void setOnlineMap(Map<String, Integer> onlineMap) {
|
||||
this.onlineMap = onlineMap;
|
||||
}
|
||||
|
||||
public Map<String, Integer> getOnlineMap() {
|
||||
return onlineMap;
|
||||
}
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public UnreadCountEvent unreadCountEvent;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
@@ -91,37 +154,352 @@ public class CommonAppContext extends MultiDexApplication {
|
||||
sInstance = this;
|
||||
sMainThreadHandler = new Handler();
|
||||
EnvironmentPrefs prefs = new EnvironmentPrefs(this);
|
||||
// 添加内存优化配置
|
||||
optimizeMemorySettings();
|
||||
currentEnvironment = prefs.getSelectedEnvironment();
|
||||
initialization();
|
||||
piaoPingManager = PiaoPingManager.getInstance(this);
|
||||
registerActivityLifecycleCallbacks(this);
|
||||
appStateListener = AppStateManager.getInstance();
|
||||
startListeningUnreadMessageCount();
|
||||
// 全局设置字体不缩放
|
||||
adjustFontScale(getResources().getConfiguration());
|
||||
CrashHandler.init(this);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void adjustFontScale(Configuration configuration) {
|
||||
if (configuration.fontScale != 1.0f) {
|
||||
configuration.fontScale = 1.0f;
|
||||
DisplayMetrics metrics = getResources().getDisplayMetrics();
|
||||
getResources().updateConfiguration(configuration, metrics);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
// 配置变化时重新应用字体设置
|
||||
adjustFontScale(newConfig);
|
||||
}
|
||||
|
||||
// 在适当的位置(如onCreate或onResume)添加实时监听
|
||||
protected void startListeningUnreadMessageCount() {
|
||||
if (!isListeningUnreadCount) {
|
||||
// 添加未读消息数变化监听器
|
||||
V2TIMMessageManager messageManager = V2TIMManager.getMessageManager();
|
||||
messageManager.addAdvancedMsgListener(new V2TIMAdvancedMsgListener() {
|
||||
@Override
|
||||
public void onRecvNewMessage(V2TIMMessage msg) {
|
||||
// 收到新消息时更新未读数
|
||||
updateUnreadMessageCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRecvC2CReadReceipt(List<V2TIMMessageReceipt> receiptList) {
|
||||
// 收到C2C消息已读回执时更新未读数
|
||||
updateUnreadMessageCount();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
isListeningUnreadCount = true;
|
||||
// 首次获取未读数
|
||||
updateUnreadMessageCount();
|
||||
}
|
||||
}
|
||||
|
||||
// 更新未读消息数的方法
|
||||
private void updateUnreadMessageCount() {
|
||||
V2TIMManager.getConversationManager().getTotalUnreadMessageCount(new V2TIMValueCallback<Long>() {
|
||||
@Override
|
||||
public void onSuccess(Long aLong) {
|
||||
// 通知未读数变化
|
||||
notifyUnreadCountChanged(aLong != null ? aLong : 0L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
// 错误处理
|
||||
notifyUnreadCountChanged(0L);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 通知未读数变化的方法(可以发送广播或EventBus事件)
|
||||
private void notifyUnreadCountChanged(long unreadCount) {
|
||||
UnreadCountEvent event =unreadCountEvent;
|
||||
if (event==null){
|
||||
event=new UnreadCountEvent();
|
||||
}
|
||||
event.setALong(unreadCount);
|
||||
// 使用EventBus通知
|
||||
CommonAppContext.getInstance().setUnreadCountEvent(event);
|
||||
EventBus.getDefault().post(event);
|
||||
}
|
||||
/**
|
||||
* 检查网络是否可用
|
||||
* @return true表示网络可用,false表示网络不可用
|
||||
*/
|
||||
public boolean isNetworkAvailable() {
|
||||
try {
|
||||
// 获取网络连接管理器
|
||||
android.net.ConnectivityManager connectivityManager =
|
||||
(android.net.ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
|
||||
if (connectivityManager != null) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
// Android 6.0及以上版本
|
||||
android.net.Network network = connectivityManager.getActiveNetwork();
|
||||
if (network != null) {
|
||||
android.net.NetworkCapabilities capabilities =
|
||||
connectivityManager.getNetworkCapabilities(network);
|
||||
if (capabilities != null) {
|
||||
// 检查是否有网络连接并且可以访问互联网
|
||||
return capabilities.hasCapability(android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET) &&
|
||||
capabilities.hasCapability(android.net.NetworkCapabilities.NET_CAPABILITY_VALIDATED);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Android 6.0以下版本
|
||||
android.net.NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
|
||||
return activeNetworkInfo != null && activeNetworkInfo.isConnected();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("Network availability check failed: " + e.getMessage());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查网络是否可用(简化版本)
|
||||
* @return true表示网络可用,false表示网络不可用
|
||||
*/
|
||||
public boolean isNetworkConnected() {
|
||||
try {
|
||||
android.net.ConnectivityManager connectivityManager =
|
||||
(android.net.ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
|
||||
if (connectivityManager != null) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
android.net.Network network = connectivityManager.getActiveNetwork();
|
||||
return network != null;
|
||||
} else {
|
||||
android.net.NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
|
||||
return activeNetworkInfo != null && activeNetworkInfo.isConnected();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("Network connection check failed: " + e.getMessage());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 优化内存设置
|
||||
*/
|
||||
private void optimizeMemorySettings() {
|
||||
try {
|
||||
// 请求降低内存负载
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
// 启用自动内存管理优化
|
||||
registerComponentCallbacks(new ComponentCallbacks2() {
|
||||
@Override
|
||||
public void onTrimMemory(int level) {
|
||||
handleMemoryTrim(level);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(@NonNull Configuration newConfig) {}
|
||||
|
||||
@Override
|
||||
public void onLowMemory() {
|
||||
// 内存极低时的处理
|
||||
releaseNonEssentialResources();
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("Memory optimization setup failed: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理内存削减事件
|
||||
* @param level 削减级别
|
||||
*/
|
||||
private void handleMemoryTrim(int level) {
|
||||
switch (level) {
|
||||
case TRIM_MEMORY_RUNNING_MODERATE:
|
||||
// 应用正在运行,内存开始紧张
|
||||
LogUtils.d("Memory trim: moderate");
|
||||
break;
|
||||
case TRIM_MEMORY_RUNNING_LOW:
|
||||
// 应用正在运行,内存更加紧张
|
||||
LogUtils.d("Memory trim: low");
|
||||
releaseNonEssentialResources();
|
||||
break;
|
||||
case TRIM_MEMORY_RUNNING_CRITICAL:
|
||||
// 应用仍在运行,但系统已开始杀死后台进程
|
||||
LogUtils.d("Memory trim: critical");
|
||||
// releaseAllNonEssentialResources();
|
||||
break;
|
||||
case TRIM_MEMORY_UI_HIDDEN:
|
||||
// 应用UI已隐藏,可以释放UI相关资源
|
||||
LogUtils.d("Memory trim: UI hidden");
|
||||
releaseUIResources();
|
||||
break;
|
||||
case TRIM_MEMORY_BACKGROUND:
|
||||
// 应用处于LRU列表中较远位置
|
||||
LogUtils.d("Memory trim: background");
|
||||
break;
|
||||
case TRIM_MEMORY_MODERATE:
|
||||
// 应用处于LRU列表中间位置
|
||||
LogUtils.d("Memory trim: moderate background");
|
||||
releaseAllNonEssentialResources();
|
||||
break;
|
||||
case TRIM_MEMORY_COMPLETE:
|
||||
// 应用处于LRU列表中最远位置,即将被杀死
|
||||
LogUtils.d("Memory trim: complete");
|
||||
releaseAllResources();
|
||||
break;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 释放非必要资源
|
||||
*/
|
||||
private void releaseNonEssentialResources() {
|
||||
try {
|
||||
// 清理图片缓存
|
||||
// Glide.get(this).clearMemory();
|
||||
|
||||
// 释放MQTT资源
|
||||
// if (mqttConnect != null) {
|
||||
// mqttConnect.close();
|
||||
// }
|
||||
|
||||
// 通知各个组件释放资源
|
||||
// EventBus.getDefault().post(new MemoryTrimEvent());
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("Error releasing non-essential resources: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 释放所有非必要资源
|
||||
*/
|
||||
private void releaseAllNonEssentialResources() {
|
||||
try {
|
||||
releaseNonEssentialResources();
|
||||
|
||||
// 进行垃圾回收
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("Error releasing all non-essential resources: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 释放UI相关资源
|
||||
*/
|
||||
private void releaseUIResources() {
|
||||
try {
|
||||
// 可以在这里通知UI组件释放资源
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("Error releasing UI resources: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 释放所有资源
|
||||
*/
|
||||
private void releaseAllResources() {
|
||||
try {
|
||||
releaseAllNonEssentialResources();
|
||||
releaseUIResources();
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("Error releasing all resources: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void setAppStateListener(AppStateListener listener) {
|
||||
this.appStateListener = listener;
|
||||
}
|
||||
public void initialization(){
|
||||
UtilConfig.init(this);
|
||||
registerActivityLifecycleCallbacks();
|
||||
// registerActivityLifecycleCallbacks();
|
||||
initWebView();
|
||||
if (ProcessUtils.isMainProcess()) {
|
||||
initARouter();
|
||||
if (SpUtil.isAgreePolicy()) {
|
||||
checkInEmulator();
|
||||
UtilConfig.checkInEmulator();
|
||||
AgoraManager.getInstance(this).init(currentEnvironment.getSwSdkAppId());
|
||||
AgoraManager.getInstance(this);
|
||||
AgoraManager.init(currentEnvironment.getSwSdkAppId());
|
||||
MessageListenerSingleton.getInstance();
|
||||
CrashReport.initCrashReport(this, "865cfe9555", true);/*bugly初始化*/
|
||||
ServiceUtils.startService(MyMqttService.class);/*Mqtt初始化*/
|
||||
CrashReport.initCrashReport(this, "b45883f58f", true);/*bugly初始化*/
|
||||
// // 启动 MQTT 服务
|
||||
// Intent mqttServiceIntent = new Intent(this, MyMqttService.class);
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
// startForegroundService(mqttServiceIntent);
|
||||
// } else {
|
||||
// startService(mqttServiceIntent);
|
||||
// }
|
||||
|
||||
// mqttConnect=MqttConnect.getInstance(this,"tcp://1.13.181.248","android-"+ MqttClient.generateClientId());
|
||||
mqttConnect=MqttConnect.getInstance(this,"tcp://1.13.101.98","android-"+ MqttClient.generateClientId());
|
||||
mqttConnect.mqttClient();
|
||||
|
||||
// 每次启动应用时重置状态
|
||||
SpUtil.getInstance().setBooleanValue("youth_model_shown", false);
|
||||
startInitSdk();
|
||||
// 初始化(通常在Application或Activity的onCreate中)
|
||||
CosUploadManager.getInstance().init(this);
|
||||
// 启动IM连接服务
|
||||
// IMServiceManager.getInstance().startIMService(this);
|
||||
}
|
||||
}
|
||||
// piaoPingManager = PiaoPingManager.getInstance(this);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (!Settings.canDrawOverlays(this)) {
|
||||
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName()));
|
||||
startActivityForResult(intent, 100);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// requestBatteryOptimizationExemption();
|
||||
}
|
||||
private void requestBatteryOptimizationExemption() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
Intent intent = new Intent();
|
||||
String packageName = getPackageName();
|
||||
PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
|
||||
if (pm != null && !pm.isIgnoringBatteryOptimizations(packageName)) {
|
||||
intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
|
||||
intent.setData(Uri.parse("package:" + packageName));
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
try {
|
||||
startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("Failed to request battery optimization exemption: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void startActivityForResult(Intent intent, int i) {
|
||||
}
|
||||
|
||||
private PiaoPingManager piaoPingManager;
|
||||
|
||||
// private PiaoPingManager piaoPingManager;
|
||||
|
||||
private void initARouter() {
|
||||
// 在ARouter初始化之前添加这行
|
||||
if (true) {
|
||||
ARouter.openDebug();
|
||||
ARouter.openLog();
|
||||
@@ -151,6 +529,14 @@ public class CommonAppContext extends MultiDexApplication {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void upMqtt(){
|
||||
if (mqttConnect==null){
|
||||
// mqttConnect=MqttConnect.getInstance(this,"tcp://1.13.181.248","android-"+ MqttClient.generateClientId());
|
||||
mqttConnect=MqttConnect.getInstance(this,"tcp://1.13.101.98","android-"+ MqttClient.generateClientId());
|
||||
mqttConnect.mqttClient();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context base) {
|
||||
MultiDex.install(this);
|
||||
@@ -218,9 +604,9 @@ public class CommonAppContext extends MultiDexApplication {
|
||||
// 确保在主线程中订阅
|
||||
if (activity != null && !activity.isFinishing()) {
|
||||
activity.runOnUiThread(() -> {
|
||||
if (piaoPingManager != null) {
|
||||
piaoPingManager.subscribe();
|
||||
}
|
||||
// if (piaoPingManager != null) {
|
||||
// piaoPingManager.subscribe();
|
||||
// }
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -248,9 +634,9 @@ public class CommonAppContext extends MultiDexApplication {
|
||||
AppLifecycleUtil.onAppBackGround();
|
||||
if (activity != null && !activity.isFinishing()) {
|
||||
activity.runOnUiThread(() -> {
|
||||
if (piaoPingManager != null) {
|
||||
piaoPingManager.unsubscribe();
|
||||
}
|
||||
// if (piaoPingManager != null) {
|
||||
// piaoPingManager.unsubscribe();
|
||||
// }
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -354,6 +740,11 @@ public class CommonAppContext extends MultiDexApplication {
|
||||
return mUserBean;
|
||||
}
|
||||
|
||||
public UserInfo getUserInfo() {
|
||||
UserInfo userInfo = SpUtil.getUserInfo();
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
public void setUserBean(UserBean bean) {
|
||||
mUserBean = bean;
|
||||
}
|
||||
@@ -370,9 +761,7 @@ public class CommonAppContext extends MultiDexApplication {
|
||||
SpUtil.saveUserId(-1);
|
||||
SpUtil.saveUserBean(new UserBean());
|
||||
SpUtil.putToken("");
|
||||
Intent intent = new Intent("com.example.action.LAUNCH_PAGE");
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
getApplicationContext().startActivity(intent);
|
||||
|
||||
// piaoPingManager.unsubscribe();
|
||||
FileUtils.deleteAllInDir(getCacheDir());
|
||||
FileUtils.deleteAllInDir(getExternalCacheDir());
|
||||
@@ -383,7 +772,9 @@ public class CommonAppContext extends MultiDexApplication {
|
||||
// 发送广播通知所有Activity刷新状态
|
||||
Intent refreshIntent = new Intent("com.xscm.moduleutil.ACTION_USER_LOGOUT");
|
||||
sendBroadcast(refreshIntent);
|
||||
|
||||
Intent intent = new Intent("com.qxcm.qxlive.LAUNCH_PAGE");
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
getApplicationContext().startActivity(intent);
|
||||
}
|
||||
|
||||
public static boolean isAlipayInstalled(Context context) {
|
||||
@@ -420,4 +811,129 @@ public class CommonAppContext extends MultiDexApplication {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle savedInstanceState) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityStarted(@NonNull Activity activity) {
|
||||
AppLifecycleUtil.onAppFrontGround();
|
||||
|
||||
// if (playId!=null && !playId.equals("")){
|
||||
// RetrofitClient.getInstance().userRoomBack(playId, "1");
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResumed(@NonNull Activity activity) {
|
||||
if (activityCount == 0) {
|
||||
// 应用从后台回到前台
|
||||
if (appStateListener != null) {
|
||||
appStateListener.onAppForeground();
|
||||
}
|
||||
// handleAppForeground(activity);
|
||||
// AppStateManager.setRoomActivityMinimized(false);
|
||||
AppLifecycleUtil.onAppFrontGround();
|
||||
}
|
||||
if (playId!=null && !playId.equals("")){
|
||||
RetrofitClient.getInstance().userRoomBack(playId, "2");
|
||||
}
|
||||
activityCount++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityPaused(@NonNull Activity activity) {
|
||||
activityCount--;
|
||||
if (activityCount == 0) {
|
||||
// 应用切换到后台
|
||||
if (appStateListener != null) {
|
||||
appStateListener.onAppBackground();
|
||||
}
|
||||
|
||||
if (playId!=null && !playId.equals("")){
|
||||
RetrofitClient.getInstance().userRoomBack(playId, "1");
|
||||
}
|
||||
|
||||
AppLifecycleUtil.onAppBackGround();
|
||||
// handleAppBackground(activity);
|
||||
// AppStateManager.setRoomActivityMinimized( true);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleAppBackground(Activity activity) {
|
||||
String className = activity.getClass().getName();
|
||||
if (className.contains("RoomActivity") && appStateListener != null) {
|
||||
// RoomActivity进入后台时显示悬浮窗
|
||||
appStateListener.setFloatingWindowVisible(true);
|
||||
}
|
||||
}
|
||||
private void handleAppForeground(Activity activity) {
|
||||
// 获取当前Activity的类名,避免直接引用类
|
||||
String className = activity.getClass().getName();
|
||||
|
||||
if (className.contains("LaunchPageActivity")) {
|
||||
// 对于启动页,我们需要检查是否应该跳转到主页面
|
||||
if (appStateListener != null && appStateListener.isFloatingWindowVisible()) {
|
||||
// 有悬浮窗,直接回到首页
|
||||
ARouter.getInstance().build(ARouteConstants.ME).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP).navigation();
|
||||
} else if (appStateListener != null && appStateListener.shouldShowSplash()) {
|
||||
// 需要显示启动页,但已经在启动页了,不需要额外操作
|
||||
return;
|
||||
} else {
|
||||
// 默认情况下,跳转到主页面
|
||||
ARouter.getInstance().build(ARouteConstants.ME).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP).navigation();
|
||||
}
|
||||
return; // 启动页或引导页不需要特殊处理
|
||||
}
|
||||
|
||||
if (appStateListener != null && appStateListener.isFloatingWindowVisible()) {
|
||||
// 有悬浮窗,直接回到首页
|
||||
// if (!className.contains("MainActivity")) {
|
||||
ARouter.getInstance().build(ARouteConstants.ME).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP).navigation();
|
||||
// }
|
||||
} else if (appStateListener != null && appStateListener.shouldShowSplash()) {
|
||||
// 需要显示启动页
|
||||
try {
|
||||
Class<?> splashActivityClass = Class.forName("com.xscm.modulemain.activity.LaunchPageActivity");
|
||||
Intent intent = new Intent(activity, splashActivityClass);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
activity.startActivity(intent);
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void showFloatingWindow(Activity activity) {
|
||||
// 这里实现显示悬浮窗的逻辑
|
||||
AppStateManager.getInstance().setFloatingWindowVisible(true);
|
||||
// 实际显示悬浮窗的代码,已实现
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityStopped(@NonNull Activity activity) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivitySaveInstanceState(@NonNull Activity activity, @NonNull Bundle outState) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityDestroyed(@NonNull Activity activity) {
|
||||
// String className = activity.getClass().getName();
|
||||
// if (className.contains("RoomActivity") && appStateListener != null) {
|
||||
// appStateListener.onRoomActivityDestroyed();
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTerminate() {
|
||||
super.onTerminate();
|
||||
LogUtils.e("@@@", "onTerminate");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import lombok.Data;
|
||||
public class AppPay {
|
||||
private String ali;
|
||||
private WxBean wx;
|
||||
private BeanPayData tl;
|
||||
|
||||
@Data
|
||||
public static class WxBean {
|
||||
@@ -20,4 +21,20 @@ public class AppPay {
|
||||
private String timestamp;
|
||||
private String sign;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class BeanPayData {
|
||||
private String appid;
|
||||
private String body;
|
||||
private String cusid;
|
||||
private String notify_url;
|
||||
private String paytype;
|
||||
private String randomstr;
|
||||
private String remark;
|
||||
private String reqsn;
|
||||
private String sign;
|
||||
private String signtype;
|
||||
private String trxamt;
|
||||
private String version;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,11 +15,13 @@ public class FirstChargeGiftBean {
|
||||
private List<GiftBag> gift_bag;
|
||||
@Data
|
||||
public static class GiftBag {
|
||||
private String gift_bag_id;
|
||||
private String name;
|
||||
private String title1;
|
||||
private String title2;
|
||||
private String money;
|
||||
private List<RoonGiftModel> gift_list;
|
||||
private int status;
|
||||
|
||||
// @Data
|
||||
// public static class GiftList {
|
||||
|
||||
@@ -1,15 +1,66 @@
|
||||
package com.xscm.moduleutil.bean;
|
||||
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
import lombok.Data;
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/8/27
|
||||
*@description: 推送过来的礼物信息,复用在盲盒活动获取礼物信息中
|
||||
*/
|
||||
@Data
|
||||
public class GiftBean {
|
||||
|
||||
private String gift_id;
|
||||
private String periods;
|
||||
private String gift_name;
|
||||
private String gift_price;
|
||||
private int file_type;
|
||||
private String play_image;
|
||||
private String base_image;
|
||||
private String gift_type;
|
||||
private int number;
|
||||
private String createtime;
|
||||
private String nickname;
|
||||
private int count;
|
||||
private String user_id;
|
||||
private int num;
|
||||
private boolean is_paly =false;
|
||||
|
||||
private long timestamp;
|
||||
//谁送的
|
||||
private String userAvatar;
|
||||
|
||||
// 发送者名称
|
||||
private String senderName;
|
||||
// 发送者头像URL
|
||||
private String senderAvatarUrl;
|
||||
|
||||
// 判断两个礼物是否相同(同一人送同一礼物)
|
||||
public boolean isSameGiftFromSameSender(GiftBean other) {
|
||||
if (other == null) return false;
|
||||
return Objects.equals(gift_id, other.gift_id) &&
|
||||
Objects.equals(senderName, other.senderName);
|
||||
}
|
||||
|
||||
// 生成礼物唯一键
|
||||
public String getGiftKey() {
|
||||
return (senderName != null ? senderName : "unknown") + "_" +
|
||||
(gift_id != null ? gift_id : "unknown");
|
||||
}
|
||||
|
||||
@Override
|
||||
public GiftBean clone() {
|
||||
GiftBean clone = new GiftBean();
|
||||
clone.gift_id = this.gift_id;
|
||||
clone.gift_name = this.gift_name;
|
||||
clone.base_image = this.base_image;
|
||||
clone.senderName = this.senderName;
|
||||
clone.userAvatar = this.userAvatar;
|
||||
clone.senderAvatarUrl = this.senderAvatarUrl;
|
||||
clone.number = this.number;
|
||||
clone.timestamp = this.timestamp;
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,23 @@ package com.xscm.moduleutil.bean;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class HeavenGiftBean {
|
||||
private String title;
|
||||
private String picture;
|
||||
private int type;
|
||||
private String quantity;
|
||||
private String gold;
|
||||
private String days;
|
||||
|
||||
private int gift_bag_id;
|
||||
private String name; //活动名称
|
||||
private String bag_name;//礼包名称
|
||||
private String effective_time;//倒计时时间 秒
|
||||
private String rule;//规则地址
|
||||
private String counter;
|
||||
private String money;
|
||||
private String diamond;
|
||||
private List<RoonGiftModel> gift_list;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ public class MusicSongBean implements Serializable {
|
||||
|
||||
private String did;//歌曲id
|
||||
private String room_id;
|
||||
private String song_code;//歌曲唯一标识
|
||||
private String song_code="";//歌曲唯一标识
|
||||
private String song_name;//歌曲名称
|
||||
private String singer;//歌手
|
||||
private String poster;//封面
|
||||
|
||||
@@ -4,9 +4,10 @@ import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MyBagDataBean {
|
||||
private String title;
|
||||
private String giftName;
|
||||
private String time;
|
||||
private String base_image;
|
||||
private String remarks; //收入说明
|
||||
private String gift_num;//礼物数量
|
||||
private String gift_name;//礼物名称
|
||||
private String gift_image;//礼物图片
|
||||
private String time;//时间
|
||||
|
||||
}
|
||||
|
||||
@@ -53,13 +53,16 @@ public class PlaceholderBean {
|
||||
@Data
|
||||
public static class ListsBean {
|
||||
private String user_id;
|
||||
private String user_code;
|
||||
private String nickname;
|
||||
private String nickname1;
|
||||
private String avatar;
|
||||
private String total;
|
||||
private String rank;
|
||||
private List<String> icon;
|
||||
private String room_name;
|
||||
private String room_id;
|
||||
private String room_number;
|
||||
private String room_cover;
|
||||
|
||||
private int id;//公会id
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package com.xscm.moduleutil.bean;
|
||||
|
||||
import com.xscm.moduleutil.bean.room.FriendInfo;
|
||||
import com.xscm.moduleutil.bean.room.RoomAuction;
|
||||
import com.xscm.moduleutil.bean.room.RoomBean;
|
||||
import com.xscm.moduleutil.bean.room.RoomPitBean;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.BlindBoxBean;
|
||||
import com.xscm.moduleutil.bean.room.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -15,6 +13,9 @@ public class RoomMessageEvent {
|
||||
private String RoomId; // 房间 ID
|
||||
private T Text; // 携带的数据对象
|
||||
|
||||
public RoomMessageEvent() {
|
||||
}
|
||||
|
||||
public RoomMessageEvent(int msgType, String roomId, T text) {
|
||||
MsgType = msgType;
|
||||
RoomId = roomId;
|
||||
@@ -30,7 +31,9 @@ public class RoomMessageEvent {
|
||||
private String jia_jia;
|
||||
private UserInfo FromUserInfo;
|
||||
private UserInfo ToUserInfo;
|
||||
private List<UserInfo> ToUserInfos;
|
||||
private GiftBean GiftInfo;
|
||||
private List<GiftBean> GiftInfos;
|
||||
private int room_up_pit_type;
|
||||
private MusicSongBean songInfo;
|
||||
private MusicSongBean nextInfo;
|
||||
@@ -47,7 +50,7 @@ public class RoomMessageEvent {
|
||||
private String AcceptRoomId;//接收者所在的房间id
|
||||
private String PkId;
|
||||
private String room_id;//当type==1的时候。这个roomId是对方的房间id
|
||||
private String user_id;
|
||||
private String user_id="";
|
||||
private String pk_end_times;//pk结束时间
|
||||
private List<RoomPitBean> userCharmList;
|
||||
|
||||
@@ -67,10 +70,32 @@ public class RoomMessageEvent {
|
||||
private int count;//排麦模式下的人数
|
||||
private int step ; //1:等待邂逅 2:心动连线 3:牵手良缘
|
||||
private int friend_id; //场次id
|
||||
private List<FriendInfo.HeartList> heart_list;//交友心动值发生变化
|
||||
// private List<FriendInfo.HeartList> list;//交友心动值发生变化
|
||||
private List<UserInfo> list;//交友房麦位发生变化 //推送的事麦上用户信息,这里使用了userinfo接收的
|
||||
|
||||
private FriendUserBean friend_user;//这是推送过来需要卡关系的数据
|
||||
|
||||
private String relation_name;
|
||||
private String user1_id;
|
||||
private String user2_id;
|
||||
private String user1_avatar;
|
||||
private String user1_nickname;
|
||||
private String user2_nickname;
|
||||
private String user2_avatar;
|
||||
private long time_day;
|
||||
|
||||
private int online_number;//在线人数
|
||||
|
||||
private BlindBoxBean.XlhData xlh_data;
|
||||
private String from_pit_number;
|
||||
private String to_pit_number;
|
||||
|
||||
private String gift_num;
|
||||
|
||||
private RedPacketInfo redpacketInfo;
|
||||
private String redpacket_id;
|
||||
|
||||
private EmotionDeatils emoji;
|
||||
}
|
||||
|
||||
@Data
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.xscm.moduleutil.bean;
|
||||
|
||||
import lombok.Data;
|
||||
@Data
|
||||
public class RoomMessageEvent1 {
|
||||
private int MsgType; // 消息类型,如 QXRoomMessageTypeJoin
|
||||
private String RoomId; // 房间 ID
|
||||
private RoomMessageEvent.T Text; // 携带的数据对象
|
||||
|
||||
public RoomMessageEvent1(int msgType, String roomId, RoomMessageEvent.T text) {
|
||||
MsgType = msgType;
|
||||
RoomId = roomId;
|
||||
Text = text;
|
||||
}
|
||||
|
||||
|
||||
@Data
|
||||
public static class T {
|
||||
private String text;
|
||||
private String GiftNum;
|
||||
|
||||
private UserInfo FromUserInfo;
|
||||
private UserInfo ToUserInfo;
|
||||
private GiftBean GiftInfo;
|
||||
}
|
||||
}
|
||||
@@ -1,41 +1,84 @@
|
||||
package com.xscm.moduleutil.bean;
|
||||
|
||||
import com.blankj.utilcode.util.GsonUtils;
|
||||
import com.tencent.imsdk.v2.V2TIMManager;
|
||||
import com.tencent.imsdk.v2.V2TIMMessage;
|
||||
import com.tencent.imsdk.v2.V2TIMSendCallback;
|
||||
import com.xscm.moduleutil.bean.room.Children;
|
||||
import com.xscm.moduleutil.bean.room.EmotionDeatils;
|
||||
import com.xscm.moduleutil.event.RoomTaskEvent;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Random;
|
||||
|
||||
public class RoomMessageManager {
|
||||
public String roomId;
|
||||
private static RoomMessageManager instance ;
|
||||
|
||||
private static final RoomMessageManager instance = new RoomMessageManager();
|
||||
public String getRoomId() {
|
||||
return roomId;
|
||||
}
|
||||
|
||||
private RoomMessageManager() {}
|
||||
public void setRoomId(String roomId) {
|
||||
this.roomId = roomId;
|
||||
}
|
||||
|
||||
public static RoomMessageManager getInstance() {
|
||||
if (instance == null){
|
||||
instance = new RoomMessageManager();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收原始消息,转换后发送到 EventBus
|
||||
*/
|
||||
public void onNewMessage(String roomId, int msgType, RoomMessageEvent.T data) {
|
||||
RoomMessageEvent event = new RoomMessageEvent(msgType, roomId, data);
|
||||
EventBus.getDefault().post(event);
|
||||
|
||||
|
||||
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);
|
||||
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) {
|
||||
// 发送群聊自定义消息成功
|
||||
// EventBus.getDefault().post(new RoomTaskEvent());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
// 发送群聊自定义消息失败
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册监听器(如 Fragment 或 Activity)
|
||||
*/
|
||||
public void register(Object subscriber) {
|
||||
if (!EventBus.getDefault().isRegistered(subscriber)) {
|
||||
EventBus.getDefault().register(subscriber);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 反注册监听器
|
||||
*/
|
||||
public void unregister(Object subscriber) {
|
||||
if (EventBus.getDefault().isRegistered(subscriber)) {
|
||||
EventBus.getDefault().unregister(subscriber);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,4 +19,14 @@ public class RoomSearchResp {
|
||||
private String hot_value;
|
||||
|
||||
|
||||
private String room_id;
|
||||
private String room_name;
|
||||
private String room_cover;
|
||||
private String room_number;
|
||||
private int label_id;
|
||||
private String today_hot_value;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -31,7 +31,8 @@ public class RoonGiftModel {
|
||||
private boolean isSelected;
|
||||
private boolean can_send_self;//是否能送自己
|
||||
private int num;//礼物数量
|
||||
|
||||
private int activities_id;//4:盲盒 ;5:天空之境;
|
||||
private int gift_bag;//10:天空之境 11:岁月之城 12:时空之巅
|
||||
public boolean isCan_send_self() {
|
||||
if ( isManghe()) {
|
||||
return true;
|
||||
|
||||
@@ -19,6 +19,10 @@ public class UserBean implements Serializable {
|
||||
private String mobile;
|
||||
private int sex;
|
||||
private int auth;
|
||||
private int is_can_chat;//是否可以私聊,1:可以,0:不可以
|
||||
private int can_chat_money;//需要充值的金额
|
||||
private String dress;//头像框
|
||||
private String chat_bubble;//聊天气泡
|
||||
|
||||
private List<MultiUserBean> multi_user;
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.xscm.moduleutil.bean;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.xscm.moduleutil.bean.room.FriendInfo;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@@ -14,7 +17,7 @@ public class UserInfo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
public static final String FEMALE = "2";
|
||||
public static final String MALE = "1";
|
||||
// @SerializedName(value = "id", alternate = "user_id")
|
||||
private int id;
|
||||
private int user_id; //用户id
|
||||
private String user_code;//用户id码
|
||||
private String avatar;//头像
|
||||
@@ -39,6 +42,7 @@ public class UserInfo implements Serializable {
|
||||
private int age;//年龄
|
||||
private String is_room;
|
||||
private String dress;//头像框
|
||||
private String chat_bubble;//聊天气泡
|
||||
private String charm;//魅力值
|
||||
private String room_id;
|
||||
private String guild;//公会名称
|
||||
@@ -53,9 +57,16 @@ public class UserInfo implements Serializable {
|
||||
private String red_status;
|
||||
private String gift_num;
|
||||
|
||||
private int is_can_chat;//是否可以私聊,1:可以,0:不可以
|
||||
private int can_chat_money;//需要充值的金额
|
||||
|
||||
private RelationshipBean qinmi;
|
||||
private RelationshipBean zhenai;
|
||||
|
||||
private int heartId; // "heartId": 4,
|
||||
private int heartNum; //
|
||||
private String red_num;
|
||||
private String ta;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package com.xscm.moduleutil.bean;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UserResultResp {
|
||||
|
||||
|
||||
private String room_id;
|
||||
private String user_id;
|
||||
private String user_code;
|
||||
private String nickname;
|
||||
@@ -14,83 +17,4 @@ public class UserResultResp {
|
||||
private String good_number;
|
||||
private String id_color;
|
||||
|
||||
public String getUser_id() {
|
||||
return user_id;
|
||||
}
|
||||
|
||||
public void setUser_id(String user_id) {
|
||||
this.user_id = user_id;
|
||||
}
|
||||
|
||||
public String getUser_code() {
|
||||
return user_code;
|
||||
}
|
||||
|
||||
public void setUser_code(String user_code) {
|
||||
this.user_code = user_code;
|
||||
}
|
||||
|
||||
public String getNickname() {
|
||||
return nickname;
|
||||
}
|
||||
|
||||
public void setNickname(String nickname) {
|
||||
this.nickname = nickname;
|
||||
}
|
||||
|
||||
public String getHead_picture() {
|
||||
return head_picture;
|
||||
}
|
||||
|
||||
public void setHead_picture(String head_picture) {
|
||||
this.head_picture = head_picture;
|
||||
}
|
||||
|
||||
public String getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
public void setSex(String sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
public String getFollow() {
|
||||
return follow;
|
||||
}
|
||||
|
||||
public void setFollow(String follow) {
|
||||
this.follow = follow;
|
||||
}
|
||||
|
||||
public String getFans_count() {
|
||||
return fans_count;
|
||||
}
|
||||
|
||||
public void setFans_count(String fans_count) {
|
||||
this.fans_count = fans_count;
|
||||
}
|
||||
|
||||
public String getOnline_text() {
|
||||
return online_text;
|
||||
}
|
||||
|
||||
public void setOnline_text(String online_text) {
|
||||
this.online_text = online_text;
|
||||
}
|
||||
|
||||
public String getGood_number() {
|
||||
return good_number;
|
||||
}
|
||||
|
||||
public void setGood_number(String good_number) {
|
||||
this.good_number = good_number;
|
||||
}
|
||||
|
||||
public String getId_color() {
|
||||
return id_color;
|
||||
}
|
||||
|
||||
public void setId_color(String id_color) {
|
||||
this.id_color = id_color;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,11 @@ import lombok.Data;
|
||||
public class WithdrawalBean {
|
||||
private String name;
|
||||
private String money;
|
||||
private String status;
|
||||
private int status;
|
||||
private String status_str;
|
||||
private String createtime;
|
||||
private String withdraw_fee;
|
||||
private String surplus_money;
|
||||
private String received_tax_amount;
|
||||
|
||||
}
|
||||
|
||||
@@ -94,6 +94,22 @@ public class EMMessageInfo implements MultiItemEntity {
|
||||
public static final int QXRoomMessageTypeSeatDidChanged = 1053;
|
||||
/// 心动值发生变化
|
||||
public static final int QXRoomMessageTypeHeartDidChanged = 1054;
|
||||
/// 小黑屋有人退出房间
|
||||
public static final int QXRoomMessageTypeHeartDid = 1055;
|
||||
///盲盒抽奖进度条
|
||||
public static final int QXRoomMessageTypeMangH = 1056;
|
||||
///巡乐会
|
||||
public static final int QXRoomMessageTypeXlh = 1057;
|
||||
///在离线
|
||||
public static final int QXRoomMessageTypezailx = 1058;
|
||||
///清除个人魅力值
|
||||
public static final int QXRoomMessageTypeQingGRMl = 1059;
|
||||
//有红包列表
|
||||
public static final int QXRoomMessageTypeQXRoomMessageRed = 1060;
|
||||
public static final int QXRoomMessageTypeQXRoomMessageRedRemove = 1061;
|
||||
|
||||
///房间内换麦
|
||||
public static final int QXRoomMessageTypehm = 1039;
|
||||
private RoomMessageEvent emMessage;
|
||||
|
||||
private int custom = 0;
|
||||
@@ -145,13 +161,15 @@ public class EMMessageInfo implements MultiItemEntity {
|
||||
case QXRoomMessageTypeRoomDress:
|
||||
case QXRoomMessageTypeRoomOnline:
|
||||
case QXRoomMessageTypeRoomOPK:
|
||||
case QXRoomMessageTypeRoomOMh:
|
||||
case QXRoomMessageTypeRoomFriendPartDidChanged:
|
||||
case QXRoomMessageTypeSeatDidChanged:
|
||||
case QXRoomMessageTypehm:
|
||||
return 1;
|
||||
case QXRoomMessageTypeRoomOMh:
|
||||
case QXRoomMessageTypeGift:
|
||||
return 3;
|
||||
case 1:
|
||||
case 2:
|
||||
return 2;
|
||||
case QXRoomMessageTypeRoomTypeChanged://房间类型发生变化
|
||||
return 4;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.xscm.moduleutil.bean.room;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
@@ -10,14 +11,14 @@ import lombok.Data;
|
||||
* @description: 交友房的实体类
|
||||
*/
|
||||
@Data
|
||||
public class FriendInfo {
|
||||
public class FriendInfo implements Serializable {
|
||||
private int friend_id;
|
||||
private long end_time;
|
||||
private int step;
|
||||
private List<HeartList> heart_list;
|
||||
|
||||
@Data
|
||||
public static class HeartList {
|
||||
public static class HeartList implements Serializable {
|
||||
private int heartId; // "heartId": 4,
|
||||
private int heartNum; // "heartNum": 10510
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class RoomAuction implements Serializable {
|
||||
}
|
||||
|
||||
@Data
|
||||
public class AuctionListBean implements Serializable {
|
||||
public static class AuctionListBean implements Serializable {
|
||||
private String user_id;
|
||||
private String user_code;
|
||||
private String nickname;
|
||||
|
||||
@@ -29,6 +29,8 @@ public class RoomInfoResp implements Serializable {
|
||||
private PkRoomInfo pk_info;
|
||||
private List<RoomPitBean> song_pit_list;
|
||||
private FriendInfo friend_info;
|
||||
private GiftXlh gift_cycle;
|
||||
private int hour_ranking_open;//1:开启 0:关闭
|
||||
|
||||
|
||||
//弹出麦位操作弹出
|
||||
@@ -114,4 +116,18 @@ public class RoomInfoResp implements Serializable {
|
||||
public boolean isFreedomMode() {
|
||||
return "1".equals(room_info.getWheat());
|
||||
}
|
||||
|
||||
@Data
|
||||
public class GiftXlh implements Serializable{
|
||||
private XlhInfo xlh_info ;
|
||||
}
|
||||
@Data
|
||||
public class XlhInfo implements Serializable{
|
||||
private String activities_name;
|
||||
private String icon;
|
||||
|
||||
private String xlh_status;
|
||||
|
||||
private String end_time;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class RoomPitBean implements Serializable {
|
||||
private int is_lock;//0未锁麦 1锁麦
|
||||
private int is_mute;//0未禁麦 1禁麦
|
||||
private int count_down;//麦位倒计时
|
||||
private String user_id;//麦位上用户id
|
||||
private String user_id="";//麦位上用户id
|
||||
private String nickname;//麦位上用户昵称
|
||||
private String avatar;//用户头像
|
||||
private String sex;//性别
|
||||
|
||||
@@ -18,6 +18,7 @@ public class RoomSettingBean implements MultiItemEntity {
|
||||
public static final int QXRoomSettingTypeRoomTypeGirl = 13;
|
||||
///交友 房
|
||||
public static final int QXRoomSettingTypeRoomTypeJiaoy = 27;
|
||||
public static final int QXRoomSettingTypeRoomTypeHUYU = 28;
|
||||
|
||||
/// 常用工具
|
||||
/// 房间补贴
|
||||
@@ -48,6 +49,8 @@ public class RoomSettingBean implements MultiItemEntity {
|
||||
public static final int QXRoomSettingTypeRoomCloseEffects = 25;
|
||||
/// 意见反馈
|
||||
public static final int QXRoomSettingTypeRoomReport = 26;
|
||||
public static final int QXRoomSettingTypeRoomFloatingScreen = 29;//关闭飘屏
|
||||
public static final int QXRoomSettingTypeRoomFloatingRed = 30;//红包
|
||||
|
||||
public static final int ITEM_TYPE_DEFAULT = 0;
|
||||
public static final int ITEM_TYPE_WITH_ICON = 1;
|
||||
|
||||
@@ -82,6 +82,11 @@ public class ConfirmDialog extends Dialog {
|
||||
|
||||
// 设置点击监听器
|
||||
btnPositive.setOnClickListener(v -> {
|
||||
isCountdownCancelled = true; // 标记倒计时被取消
|
||||
if (countDownTimer != null) {
|
||||
countDownTimer.cancel(); // 取消倒计时
|
||||
countDownTimer = null;
|
||||
}
|
||||
if (positiveButtonClickListener != null) {
|
||||
positiveButtonClickListener.onClick(v);
|
||||
}
|
||||
@@ -126,7 +131,7 @@ public class ConfirmDialog extends Dialog {
|
||||
// rootView.startAnimation(shake);
|
||||
// }
|
||||
}
|
||||
|
||||
private boolean isCountdownCancelled = false; // 添加标志位
|
||||
private void startCountdown(Button btnNegative) {
|
||||
countDownTimer = new CountDownTimer(countdownSeconds * 1000L, 1000) {
|
||||
@Override
|
||||
@@ -137,11 +142,14 @@ public class ConfirmDialog extends Dialog {
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
btnNegative.setText(negativeButtonText);
|
||||
if (negativeButtonClickListener != null) {
|
||||
negativeButtonClickListener.onClick(btnNegative); // 自动触发取消
|
||||
// 检查是否被主动取消
|
||||
if (!isCountdownCancelled) {
|
||||
btnNegative.setText(negativeButtonText);
|
||||
if (negativeButtonClickListener != null) {
|
||||
negativeButtonClickListener.onClick(btnNegative); // 自动触发取消
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
|
||||
@@ -14,14 +14,12 @@ import androidx.annotation.NonNull;
|
||||
import com.blankj.utilcode.util.ScreenUtils;
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.adapter.GiftAdapter;
|
||||
import com.xscm.moduleutil.adapter.HeavenGiftAdapter;
|
||||
import com.xscm.moduleutil.bean.BaseListData;
|
||||
import com.xscm.moduleutil.bean.FirstChargeGiftBean;
|
||||
import com.xscm.moduleutil.bean.RoonGiftModel;
|
||||
import com.xscm.moduleutil.color.ThemeableDrawableUtils;
|
||||
import com.xscm.moduleutil.databinding.DialogFirstChargeBinding;
|
||||
import com.xscm.moduleutil.databinding.DialogHeavenGiftBinding;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.http.RetrofitClient;
|
||||
import com.xscm.moduleutil.utils.ColorManager;
|
||||
@@ -42,7 +40,6 @@ import io.reactivex.disposables.Disposable;
|
||||
*/
|
||||
public class FirstChargeDialog extends BaseDialog<DialogFirstChargeBinding> {
|
||||
|
||||
GiftAdapter giftAdapter;
|
||||
HeavenGiftAdapter heavenGiftAdapter;
|
||||
FirstChargeGiftBean firstChargeGiftBean;
|
||||
private int type;
|
||||
@@ -66,7 +63,6 @@ public class FirstChargeDialog extends BaseDialog<DialogFirstChargeBinding> {
|
||||
mBinding.tvTitle2.setPaintFlags(Paint.STRIKE_THRU_TEXT_FLAG);
|
||||
heavenGiftAdapter = new HeavenGiftAdapter();
|
||||
mBinding.bannerViewPager
|
||||
.setPageMargin(15)
|
||||
.setAutoPlay(false)
|
||||
.setRevealWidth(0, 0)
|
||||
.setIndicatorVisibility(View.VISIBLE)
|
||||
@@ -160,18 +156,6 @@ public class FirstChargeDialog extends BaseDialog<DialogFirstChargeBinding> {
|
||||
}
|
||||
});
|
||||
|
||||
// List<HeavenGiftBean> list = new ArrayList<>();
|
||||
// for (int i = 0; i < 7; i++) {
|
||||
// HeavenGiftBean bean = new HeavenGiftBean();
|
||||
// bean.setTitle("礼物" + i);
|
||||
// bean.setPicture("");
|
||||
// bean.setType(1);
|
||||
// bean.setQuantity("x" + i);
|
||||
// bean.setGold(i + "");
|
||||
// bean.setDays(i + "天");
|
||||
// list.add(bean);
|
||||
// }
|
||||
// mBinding.bannerViewPager.create(baseListData(list, 4));
|
||||
}
|
||||
|
||||
private List<BaseListData<RoonGiftModel>> baseListData(List<RoonGiftModel> list, int chunkSize) {
|
||||
@@ -203,14 +187,15 @@ public class FirstChargeDialog extends BaseDialog<DialogFirstChargeBinding> {
|
||||
if (firstChargeGiftBean.getGift_bag().size() > 0) {
|
||||
type=1;
|
||||
List<RoonGiftModel> list = new ArrayList<>();
|
||||
mBinding.tvTitle1.setText(firstChargeGiftBean.getGift_bag().get(0).getTitle1());
|
||||
mBinding.tvTitle2.setText(firstChargeGiftBean.getGift_bag().get(0).getTitle2());
|
||||
mBinding.btn0.setText(firstChargeGiftBean.getGift_bag().get(0).getName());
|
||||
// mBinding.tvTitle1.setText(firstChargeGiftBean.getGift_bag().get(0).getTitle1());
|
||||
// mBinding.tvTitle2.setText(firstChargeGiftBean.getGift_bag().get(0).getTitle2());
|
||||
// mBinding.btn0.setText(firstChargeGiftBean.getGift_bag().get(0).getName());
|
||||
list.addAll(firstChargeGiftBean.getGift_bag().get(0).getGift_list());
|
||||
mBinding.tvTitle22.setText("充值"+firstChargeGiftBean.getGift_bag().get(0).getName()+"即可获得"+firstChargeGiftBean.getGift_bag().get(0).getTitle2()+"的道具或装扮");
|
||||
mBinding.bannerViewPager.create(baseListData(list, 4));
|
||||
|
||||
mBinding.btn1.setText(firstChargeGiftBean.getGift_bag().get(1).getName());
|
||||
mBinding.btn2.setText(firstChargeGiftBean.getGift_bag().get(2).getName());
|
||||
// mBinding.btn1.setText(firstChargeGiftBean.getGift_bag().get(1).getName());
|
||||
// mBinding.btn2.setText(firstChargeGiftBean.getGift_bag().get(2).getName());
|
||||
} else if (firstChargeGiftBean.getGift_bag().size() == 2) {
|
||||
// mBinding.rg.check(R.id.btn_0);
|
||||
// mBinding.btn1.setVisibility(View.VISIBLE);
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.xscm.moduleutil.dialog;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.os.CountDownTimer;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
@@ -11,15 +12,21 @@ import androidx.annotation.NonNull;
|
||||
|
||||
import com.blankj.utilcode.util.ScreenUtils;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.adapter.GiftAdapter;
|
||||
import com.xscm.moduleutil.adapter.HeavenGiftAdapter;
|
||||
import com.xscm.moduleutil.bean.BaseListData;
|
||||
import com.xscm.moduleutil.bean.FirstChargeGiftBean;
|
||||
import com.xscm.moduleutil.bean.HeavenGiftBean;
|
||||
import com.xscm.moduleutil.bean.RoonGiftModel;
|
||||
import com.xscm.moduleutil.color.ThemeableDrawableUtils;
|
||||
import com.xscm.moduleutil.databinding.DialogHeavenGiftBinding;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.http.RetrofitClient;
|
||||
import com.xscm.moduleutil.utils.ColorManager;
|
||||
import com.xscm.moduleutil.widget.dialog.BaseDialog;
|
||||
import com.zhpan.bannerview.indicator.DrawableIndicator;
|
||||
import com.zhpan.indicator.base.IIndicator;
|
||||
import com.zhpan.indicator.enums.IndicatorSlideMode;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -30,17 +37,27 @@ import java.util.List;
|
||||
*/
|
||||
public class HeavenGiftDialog extends BaseDialog<DialogHeavenGiftBinding> {
|
||||
|
||||
GiftAdapter giftAdapter;
|
||||
HeavenGiftAdapter heavenGiftAdapter;
|
||||
|
||||
private CountDownTimer countDownTimer;
|
||||
public HeavenGiftDialog(@NonNull Context context) {
|
||||
super(context,R.style.BaseDialogStyleH);
|
||||
}
|
||||
|
||||
HeavenGiftBean heavenGiftBea;
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.dialog_heaven_gift;
|
||||
}
|
||||
private OnFirstChargeListener listener;
|
||||
public interface OnFirstChargeListener {
|
||||
void onFirstChargeConfirmed(HeavenGiftBean giftBean, int type);
|
||||
void onFirstChargeCancelled();
|
||||
}
|
||||
|
||||
// 设置监听器的方法
|
||||
public void setOnFirstChargeListener(OnFirstChargeListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
@Override
|
||||
public void initView() {
|
||||
setCancelable(false);
|
||||
@@ -64,29 +81,98 @@ public class HeavenGiftDialog extends BaseDialog<DialogHeavenGiftBinding> {
|
||||
.setIndicatorSlideMode(IndicatorSlideMode.NORMAL)
|
||||
.setAdapter(heavenGiftAdapter)
|
||||
.create();
|
||||
|
||||
ThemeableDrawableUtils.setThemeableRoundedBackground(mBinding.tvInvite, ColorManager.getInstance().getPrimaryColorInt(), 53);
|
||||
mBinding.tvInvite.setTextColor(ColorManager.getInstance().getButtonColorInt());
|
||||
mBinding.tvInvite.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (listener != null) {
|
||||
listener.onFirstChargeConfirmed(heavenGiftBea,2);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
List<HeavenGiftBean> list=new ArrayList<>();
|
||||
for (int i = 0; i < 7; i++){
|
||||
HeavenGiftBean bean=new HeavenGiftBean();
|
||||
bean.setTitle("礼物"+i);
|
||||
bean.setPicture("");
|
||||
bean.setType(1);
|
||||
bean.setQuantity("x"+i);
|
||||
bean.setGold(i+"");
|
||||
bean.setDays(i+"天");
|
||||
list.add(bean);
|
||||
|
||||
RetrofitClient.getInstance().getDayDropGift(new BaseObserver<HeavenGiftBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(HeavenGiftBean heavenGiftBean) {
|
||||
if (heavenGiftBean != null){
|
||||
heavenGiftBea=heavenGiftBean;
|
||||
mBinding.tvTitle.setText(heavenGiftBean.getCounter());
|
||||
// 示例:假设从 HeavenGiftBean 中获取倒计时时间(单位:秒)
|
||||
// long countdownTime =Integer.parseInt(heavenGiftBean.getEffective_time()) * 1000L; // 转换为毫秒
|
||||
// startCountdown(countdownTime);
|
||||
mBinding.tvSj.setText("截止时间:"+heavenGiftBean.getEffective_time());
|
||||
mBinding.bannerViewPager.create(baseListData(heavenGiftBean.getGift_list(),4));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// List<HeavenGiftBean> list=new ArrayList<>();
|
||||
// for (int i = 0; i < 7; i++){
|
||||
// HeavenGiftBean bean=new HeavenGiftBean();
|
||||
// bean.setTitle("礼物"+i);
|
||||
// bean.setPicture("");
|
||||
// bean.setQuantity("x"+i);
|
||||
// bean.setGold(i+"");
|
||||
// bean.setDays(i+"天");
|
||||
// list.add(bean);
|
||||
// }
|
||||
//// giftAdapter.setNewData(list);
|
||||
// mBinding.bannerViewPager.create(baseListData(list,4));
|
||||
}
|
||||
private void startCountdown(long millisInFuture) {
|
||||
if (countDownTimer != null) {
|
||||
countDownTimer.cancel();
|
||||
}
|
||||
// giftAdapter.setNewData(list);
|
||||
mBinding.bannerViewPager.create(baseListData(list,4));
|
||||
|
||||
countDownTimer = new CountDownTimer(millisInFuture, 1000) {
|
||||
@Override
|
||||
public void onTick(long millisUntilFinished) {
|
||||
updateCountdownDisplay(millisUntilFinished);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
// 倒计时结束时的处理
|
||||
mBinding.tvSj.setText("00:00:00");
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
|
||||
private List<BaseListData<HeavenGiftBean>> baseListData(List<HeavenGiftBean> list, int chunkSize){
|
||||
List<BaseListData<HeavenGiftBean>> baseListData = new ArrayList<>();
|
||||
private void updateCountdownDisplay(long millisUntilFinished) {
|
||||
long totalSeconds = millisUntilFinished / 1000;
|
||||
long hours = totalSeconds / 3600;
|
||||
long minutes = (totalSeconds % 3600) / 60;
|
||||
long seconds = totalSeconds % 60;
|
||||
|
||||
String timeFormatted = String.format("%02d:%02d:%02d", hours, minutes, seconds);
|
||||
mBinding.tvSj.setText(timeFormatted);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void dismiss() {
|
||||
super.dismiss();
|
||||
if (countDownTimer != null) {
|
||||
countDownTimer.cancel();
|
||||
countDownTimer = null;
|
||||
}
|
||||
}
|
||||
private List<BaseListData<RoonGiftModel>> baseListData(List<RoonGiftModel> list, int chunkSize) {
|
||||
List<BaseListData<RoonGiftModel>> baseListData = new ArrayList<>();
|
||||
for (int i = 0; i < list.size(); i += chunkSize) {
|
||||
BaseListData<HeavenGiftBean> baseListData1 = new BaseListData<>();
|
||||
BaseListData<RoonGiftModel> baseListData1 = new BaseListData<>();
|
||||
baseListData1.setData(list.subList(i, Math.min(i + chunkSize, list.size())));
|
||||
baseListData.add(baseListData1);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.xscm.moduleutil.dialog;
|
||||
|
||||
import static com.blankj.utilcode.util.ActivityUtils.startActivity;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.text.TextPaint;
|
||||
@@ -16,6 +19,7 @@ import androidx.databinding.DataBindingUtil;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.blankj.utilcode.util.SpanUtils;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.activity.WebViewActivity;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.databinding.DialogPolicBinding;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
@@ -42,7 +46,12 @@ public class PolicyDialog extends Dialog {
|
||||
ClickableSpan clickSpan = new ClickableSpan() {
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=6" ).withString("title", "用户协议").navigation();
|
||||
Intent intent = new Intent(getContext(), WebViewActivity.class);
|
||||
intent.putExtra("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=6");
|
||||
intent.putExtra("title", "用户协议");
|
||||
startActivity(intent);
|
||||
|
||||
// ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=6" ).withString("title", "用户协议").navigation();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -54,7 +63,12 @@ public class PolicyDialog extends Dialog {
|
||||
ClickableSpan ysClickSpan = new ClickableSpan() {
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=4").withString("title", "隐私协议").navigation();
|
||||
Intent intent = new Intent(getContext(), WebViewActivity.class);
|
||||
intent.putExtra("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=4");
|
||||
intent.putExtra("title", "隐私协议");
|
||||
startActivity(intent);
|
||||
|
||||
// ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=4").withString("title", "隐私协议").navigation();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -63,7 +77,7 @@ public class PolicyDialog extends Dialog {
|
||||
ds.setUnderlineText(true);
|
||||
}
|
||||
};
|
||||
spanUtils.append("欢迎使用羽声!\n").append("在使用我们的产品和服务之前,请您先阅读并了解").append("《用户协议》").setClickSpan(clickSpan).append("和").append("《隐私协议》").setClickSpan(ysClickSpan).append("。我们将严格按照上述协议为" +
|
||||
spanUtils.append("欢迎使用羽声语音!\n").append("在使用我们的产品和服务之前,请您先阅读并了解").append("《用户协议》").setClickSpan(clickSpan).append("和").append("《隐私协议》").setClickSpan(ysClickSpan).append("。我们将严格按照上述协议为" +
|
||||
"您提供服务,保护您的信息安全,点" +
|
||||
"击“同意”即表示您已阅读并同意全部" +
|
||||
"条款,可以继续使用我们的产品和服" +
|
||||
|
||||
@@ -8,6 +8,7 @@ import androidx.annotation.NonNull;
|
||||
|
||||
import com.blankj.utilcode.util.ScreenUtils;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.bean.FirstChargeGiftBean;
|
||||
import com.xscm.moduleutil.color.ThemeableDrawableUtils;
|
||||
import com.xscm.moduleutil.databinding.DialogRealNameBinding;
|
||||
import com.xscm.moduleutil.databinding.IndexDialogYouthModelBinding;
|
||||
@@ -20,6 +21,18 @@ import com.xscm.moduleutil.widget.dialog.BaseDialog;
|
||||
*/
|
||||
public class RealNameDialog extends BaseDialog<DialogRealNameBinding> {
|
||||
|
||||
|
||||
|
||||
public interface OnFirstChargeListener {
|
||||
void onFirstChargeConfirmed(String giftBean, int type);
|
||||
void onFirstChargeCancelled();
|
||||
}
|
||||
private OnFirstChargeListener listener;
|
||||
// 设置监听器的方法
|
||||
public void setOnFirstChargeListener(OnFirstChargeListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public RealNameDialog(@NonNull Context context) {
|
||||
super(context);
|
||||
}
|
||||
@@ -36,8 +49,19 @@ public class RealNameDialog extends BaseDialog<DialogRealNameBinding> {
|
||||
Window window = getWindow();
|
||||
window.setLayout((int) (ScreenUtils.getScreenWidth() * 315.f / 375), WindowManager.LayoutParams.WRAP_CONTENT);
|
||||
|
||||
mBinding.tvIKnow.setOnClickListener(v -> dismiss());
|
||||
mBinding.ivClose.setOnClickListener(v -> dismiss());
|
||||
// mBinding.tvIKnow.setOnClickListener(v -> dismiss());
|
||||
// mBinding.ivClose.setOnClickListener(v -> dismiss());
|
||||
|
||||
mBinding.tvIKnow.setOnClickListener(v -> {
|
||||
if (listener != null) {
|
||||
listener.onFirstChargeConfirmed(null, 0);
|
||||
}
|
||||
});
|
||||
mBinding.ivClose.setOnClickListener(v -> {
|
||||
if (listener != null) {
|
||||
listener.onFirstChargeCancelled();
|
||||
}
|
||||
});
|
||||
|
||||
ThemeableDrawableUtils.setThemeableRoundedBackground(mBinding.tvIKnow, ColorManager.getInstance().getPrimaryColorInt(), 53);
|
||||
mBinding.tvIKnow.setTextColor(ColorManager.getInstance().getButtonColorInt());
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.xscm.moduleutil.dialog;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -13,6 +15,7 @@ import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.adapter.BalanceRechargeAdapter;
|
||||
@@ -30,8 +33,12 @@ import com.xscm.moduleutil.widget.PaymentUtil;
|
||||
import com.tencent.mm.opensdk.openapi.IWXAPI;
|
||||
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/**
|
||||
*@author qx
|
||||
@@ -46,14 +53,19 @@ public class RechargeDialogFragment extends BaseMvpDialogFragment<RechargeDialog
|
||||
private BindType.AllData selectedItem;
|
||||
private PayMethodAdapter bindTypeAdapter;
|
||||
private String roomId;
|
||||
private String gift_bag_id="0";//默认0 类型id 传 gift_bag_id
|
||||
private String type_params="0"; //默认0 类型参数 1首充 2天降好礼 3新人好礼
|
||||
|
||||
public static void show(String id, String type,FragmentManager fragmentManager) {
|
||||
public static RechargeDialogFragment show(String id, String type, FragmentManager fragmentManager,String gift_bag_id,String type_params) {
|
||||
RechargeDialogFragment dialogFragment = new RechargeDialogFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString("roomId", id); //// 可选:传递参数
|
||||
args.putString("type", type);
|
||||
args.putString("gift_bag_id", gift_bag_id);
|
||||
args.putString("type_params", type_params);
|
||||
dialogFragment.setArguments(args);
|
||||
dialogFragment.show(fragmentManager, "RoomOnlineDialogFragment");
|
||||
return dialogFragment;
|
||||
}
|
||||
@Override
|
||||
protected void initDialogStyle(Window window) {
|
||||
@@ -66,8 +78,11 @@ public class RechargeDialogFragment extends BaseMvpDialogFragment<RechargeDialog
|
||||
super.onAttach(context);
|
||||
roomId = getArguments().getString("roomId");
|
||||
type = getArguments().getString("type");
|
||||
gift_bag_id = getArguments().getString("gift_bag_id");
|
||||
type_params = getArguments().getString("type_params");
|
||||
if(type!=null){
|
||||
money=type;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +118,7 @@ public class RechargeDialogFragment extends BaseMvpDialogFragment<RechargeDialog
|
||||
ToastUtils.showShort("请选择支付方式");
|
||||
return;
|
||||
}
|
||||
MvpPre.appPay(SpUtil.getUserId() + "", money, coin, selectedItem.getType());
|
||||
MvpPre.appPay(SpUtil.getUserId() + "", money, coin, selectedItem.getType(),type_params,gift_bag_id);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
@@ -125,7 +140,7 @@ public class RechargeDialogFragment extends BaseMvpDialogFragment<RechargeDialog
|
||||
if (type!=null){
|
||||
mBinding.r4.setVisibility(View.GONE);
|
||||
}else{
|
||||
mBinding.r4.setVisibility(View.VISIBLE);
|
||||
mBinding.r4.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,11 +151,11 @@ public class RechargeDialogFragment extends BaseMvpDialogFragment<RechargeDialog
|
||||
|
||||
@Override
|
||||
public void setRechargeData(List<RechargeBean> rechargeData) {
|
||||
RechargeBean customItem = new RechargeBean();
|
||||
customItem.setCoins("自定义");
|
||||
customItem.setMoney("");
|
||||
customItem.setItemViewType(1);
|
||||
rechargeData.add(customItem);
|
||||
// RechargeBean customItem = new RechargeBean();
|
||||
// customItem.setCoins("自定义");
|
||||
// customItem.setMoney("");
|
||||
// customItem.setItemViewType(1);
|
||||
// rechargeData.add(customItem);
|
||||
rechargeAdapter = new BalanceRechargeAdapter(rechargeData);
|
||||
rechargeAdapter.setNewData(rechargeData);
|
||||
rechargeAdapter.setListener(new BalanceRechargeAdapter.OnRechargeItemClickListener() {
|
||||
@@ -155,6 +170,9 @@ public class RechargeDialogFragment extends BaseMvpDialogFragment<RechargeDialog
|
||||
public void onInputBoxVisibilityChanged(boolean isVisible) {
|
||||
// 根据 isVisible 的值来显示或隐藏输入框
|
||||
mBinding.r4.setVisibility(isVisible ? View.VISIBLE : View.GONE);
|
||||
if (isVisible){
|
||||
money="0";
|
||||
}
|
||||
}
|
||||
});
|
||||
mBinding.rvComment.setLayoutManager(new GridLayoutManager(getContext(), 3));
|
||||
@@ -194,7 +212,56 @@ public class RechargeDialogFragment extends BaseMvpDialogFragment<RechargeDialog
|
||||
IWXAPI wxapi = WXAPIFactory.createWXAPI(getContext(), CommonAppContext.getInstance().getCurrentEnvironment().getWxAppId());
|
||||
PaymentUtil.payWxMiniProgram2(wxapi,appPay);
|
||||
|
||||
}else if (appPay.getTl()!=null){
|
||||
if (appPay.getTl().getRemark().equals("5")) {//微信
|
||||
IWXAPI wxapi = WXAPIFactory.createWXAPI(getContext(), CommonAppContext.getInstance().getCurrentEnvironment().getWxAppId());
|
||||
try {
|
||||
String paramString = buildParamString(appPay.getTl());
|
||||
PaymentUtil.payWxMiniProgramWx(wxapi,paramString);
|
||||
android.util.Log.d("RequestParams", paramString); // 输出拼接后的参数
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if (appPay.getTl().getRemark().equals("4")) {//支付宝
|
||||
String s= JSON.toJSONString(appPay.getTl());
|
||||
try {
|
||||
String query = URLEncoder.encode("payinfo=" + URLEncoder.encode(s, "UTF-8"), "UTF-8");
|
||||
String url = "alipays://platformapi/startapp?appId=2021001104615521&page=pages/orderDetail/orderDetail&thirdPartSchema="
|
||||
+ URLEncoder.encode("myziroom://myziroom/", "UTF-8") + "&query=" + query;
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
||||
startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public static String buildParamString(Object obj) throws IllegalAccessException {
|
||||
Class<?> clazz = obj.getClass();
|
||||
Field[] fields = clazz.getDeclaredFields();
|
||||
TreeMap<String, String> paramMap = new TreeMap<>();
|
||||
|
||||
// 遍历字段并填充 TreeMap
|
||||
for (Field field : fields) {
|
||||
field.setAccessible(true); // 允许访问私有字段
|
||||
Object value = field.get(obj);
|
||||
if (value != null && !String.valueOf(value).isEmpty()) {
|
||||
paramMap.put(field.getName(), String.valueOf(value));
|
||||
}
|
||||
}
|
||||
|
||||
// 使用 StringBuilder 拼接参数字符串
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (Map.Entry<String, String> entry : paramMap.entrySet()) {
|
||||
if (builder.length() > 0) {
|
||||
builder.append("&");
|
||||
}
|
||||
builder.append(entry.getKey())
|
||||
.append("=")
|
||||
.append(entry.getValue());
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,8 +4,10 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.webkit.JavascriptInterface;
|
||||
@@ -20,6 +22,7 @@ import com.blankj.utilcode.util.LogUtils;
|
||||
import com.blankj.utilcode.util.ScreenUtils;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.base.RoomManager;
|
||||
import com.xscm.moduleutil.databinding.WebViewDialogBinding;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.widget.dialog.BaseDialog;
|
||||
@@ -39,12 +42,27 @@ import com.tencent.qcloud.tuikit.tuichat.classicui.page.TUIGroupChatActivity;
|
||||
public class WebViewDialog extends BaseDialog<WebViewDialogBinding> {
|
||||
|
||||
String mUrl;
|
||||
int type;//10:天空之境 11:岁月之城 12:时空之巅
|
||||
|
||||
public WebViewDialog(@NonNull Context context,String url) {
|
||||
public WebViewDialog(@NonNull Context context, Bundle args) {
|
||||
super(context, R.style.BaseDialogStyleH);
|
||||
this.mUrl=url;
|
||||
this.mUrl = args.getString("url");
|
||||
this.type = args.getInt("type");
|
||||
initData1();
|
||||
}
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
if (getWindow() != null) {
|
||||
// 获取屏幕尺寸
|
||||
android.util.DisplayMetrics displayMetrics = getContext().getResources().getDisplayMetrics();
|
||||
// 设置高度为屏幕高度的80%
|
||||
android.view.WindowManager.LayoutParams params = getWindow().getAttributes();
|
||||
params.height = (int) (displayMetrics.heightPixels * 0.9);
|
||||
params.width = android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
getWindow().setAttributes(params);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.web_view_dialog;
|
||||
@@ -52,19 +70,64 @@ public class WebViewDialog extends BaseDialog<WebViewDialogBinding> {
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
setCancelable(false);
|
||||
setCanceledOnTouchOutside(false);
|
||||
setCancelable(true);
|
||||
setCanceledOnTouchOutside(true);
|
||||
Window window = getWindow();
|
||||
assert window != null;
|
||||
window.setGravity(Gravity.BOTTOM);
|
||||
window.setLayout((int) (ScreenUtils.getScreenWidth() * 320.f / 375), WindowManager.LayoutParams.MATCH_PARENT);
|
||||
mBinding.ivClose.setOnClickListener(v -> dismiss());
|
||||
//
|
||||
}
|
||||
|
||||
if (type==10){
|
||||
mBinding.gzCl.setBackgroundResource(R.mipmap.tkzj);
|
||||
mBinding.imGz.setImageResource(R.mipmap.tkzj_gz);
|
||||
mBinding.webView.setPadding(16, 0, 16, 0);
|
||||
}else if (type==11){
|
||||
mBinding.gzCl.setBackgroundResource(R.mipmap.syzc);
|
||||
mBinding.imGz.setImageResource(R.mipmap.syzc_gz);
|
||||
}else if (type==12){
|
||||
mBinding.gzCl.setBackgroundResource(R.mipmap.skzj);
|
||||
mBinding.imGz.setImageResource(R.mipmap.skzj_gz);
|
||||
}else if (type==13){
|
||||
mBinding.gzCl.setBackgroundResource(R.mipmap.xlh);
|
||||
mBinding.imGz.setImageResource(R.mipmap.xlh_gz);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void initData1() {
|
||||
// WebSettings webSettings = mBinding.webView.getSettings();
|
||||
// webSettings.setUseWideViewPort(true);
|
||||
// webSettings.setLoadWithOverviewMode(true);
|
||||
// webSettings.setJavaScriptEnabled(true);
|
||||
// webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); //关闭webview中缓存
|
||||
// //增加JSBridge
|
||||
// mBinding.webView.addJavascriptInterface(new WebAppInterface(getContext()), "Android");
|
||||
//// mBinding.webView.addJavascriptInterface(new WebViewBridgeConfig(title), WebViewBridgeConfig.NAME);
|
||||
// webSettings.setBuiltInZoomControls(false);
|
||||
// webSettings.setSupportZoom(false);
|
||||
// webSettings.setDomStorageEnabled(true);
|
||||
// webSettings.setBlockNetworkImage(false);//解决图片不显示
|
||||
// // 启用 WebView 内容的滚动
|
||||
// mBinding.webView.setVerticalScrollBarEnabled(true);
|
||||
// mBinding.webView.setScrollbarFadingEnabled(true);
|
||||
// webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
// webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
|
||||
// mBinding.webView.setHorizontalScrollBarEnabled(false);//水平不显示
|
||||
// mBinding.webView.setVerticalScrollBarEnabled(false); //垂直不显示
|
||||
// mBinding.webView.setWebViewClient(new WebViewClient());
|
||||
// mBinding.webView.setBackgroundColor(Color.TRANSPARENT);
|
||||
// mBinding.webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
||||
//
|
||||
// mBinding.webView.requestFocus();
|
||||
// mBinding.webView.loadUrl(mUrl);
|
||||
|
||||
WebSettings webSettings = mBinding.webView.getSettings();
|
||||
webSettings.setUseWideViewPort(true);
|
||||
webSettings.setLoadWithOverviewMode(true);
|
||||
@@ -79,14 +142,18 @@ public class WebViewDialog extends BaseDialog<WebViewDialogBinding> {
|
||||
webSettings.setBlockNetworkImage(false);//解决图片不显示
|
||||
webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
|
||||
// 启用 WebView 内容的滚动,但隐藏滚动条
|
||||
mBinding.webView.setHorizontalScrollBarEnabled(false);//水平不显示
|
||||
mBinding.webView.setVerticalScrollBarEnabled(false); //垂直不显示
|
||||
mBinding.webView.setVerticalScrollBarEnabled(false); //垂直不显示滚动条
|
||||
mBinding.webView.setWebViewClient(new WebViewClient());
|
||||
mBinding.webView.setBackgroundColor(Color.TRANSPARENT);
|
||||
mBinding.webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
||||
|
||||
// 确保内容可以滚动
|
||||
webSettings.setDomStorageEnabled(true);
|
||||
|
||||
mBinding.webView.requestFocus();
|
||||
mBinding.webView.loadUrl("https://vespa.qxmier.com/web/index.html#/pages/other/taskDesc");
|
||||
mBinding.webView.loadUrl(mUrl);
|
||||
}
|
||||
|
||||
private Resources getResources() {
|
||||
@@ -126,7 +193,9 @@ public class WebViewDialog extends BaseDialog<WebViewDialogBinding> {
|
||||
|
||||
@JavascriptInterface
|
||||
public void jumpRoomPage(String room_id) {
|
||||
ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("form", "首页").withString("roomId", room_id).navigation();
|
||||
RoomManager.getInstance().fetchRoomDataAndEnter(getContext(), room_id,"");
|
||||
|
||||
// ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("form", "首页").withString("roomId", room_id).navigation();
|
||||
}
|
||||
@JavascriptInterface
|
||||
public void jumpWebPage(String objects) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.xscm.moduleutil.dialog;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
@@ -9,6 +10,7 @@ import androidx.annotation.NonNull;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.blankj.utilcode.util.ScreenUtils;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.activity.WebViewActivity;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.bean.TeenagerInfo;
|
||||
import com.xscm.moduleutil.color.ThemeableDrawableUtils;
|
||||
@@ -41,7 +43,13 @@ public class YouthModelDialog extends BaseDialog<IndexDialogYouthModelBinding> {
|
||||
Window window = getWindow();
|
||||
window.setLayout((int) (ScreenUtils.getScreenWidth() * 315.f / 375), WindowManager.LayoutParams.WRAP_CONTENT);
|
||||
mBinding.ivClose.setOnClickListener(v -> dismiss());
|
||||
mBinding.tvIKnow.setOnClickListener(v -> dismiss());
|
||||
mBinding.tvIKnow.setOnClickListener(v -> {
|
||||
|
||||
ARouter.getInstance().build(ARouteConstants.UNDERAGE_ACTIVITY).withInt("type", 0).navigation();
|
||||
|
||||
// ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url() + "/web/index.html#/pages/feedback/teenage?id=" + SpUtil.getToken()).navigation();
|
||||
// dismiss();
|
||||
});
|
||||
mBinding.tvOpen.setOnClickListener(v -> {
|
||||
// if (teenagerInfo.getHad_password() == 1) {
|
||||
|
||||
@@ -49,7 +57,11 @@ public class YouthModelDialog extends BaseDialog<IndexDialogYouthModelBinding> {
|
||||
// } else {
|
||||
// ARouter.getInstance().build(ARouteConstants.SET_YOUTH_PWD_ACTIVITY).withInt("type", SetYouthPasswordActivity.SET_TYPE).navigation();
|
||||
// }
|
||||
ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url()+ "/web/index.html#/pages/feedback/teenage?id="+ SpUtil.getToken()).navigation();
|
||||
|
||||
Intent intent = new Intent(getContext(), WebViewActivity.class);
|
||||
intent.putExtra("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url() + "/web/index.html#/pages/feedback/teenage?id=" + SpUtil.getToken());
|
||||
getContext().startActivity(intent);
|
||||
// ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url() + "/web/index.html#/pages/feedback/teenage?id=" + SpUtil.getToken()).navigation();
|
||||
dismiss();
|
||||
});
|
||||
|
||||
|
||||
@@ -4,13 +4,46 @@ import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.GiftBean;
|
||||
import com.xscm.moduleutil.bean.WalletBean;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.BlindBoxBean;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.BlindReslutBean;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.XlhDrawBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GiftLotteryContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
void getGiftListSuccess(BlindBoxBean blindBoxBean);
|
||||
|
||||
void drawGiftListSuccess(BlindReslutBean blindReslutBean);
|
||||
|
||||
void getMyRecordSuccess(List<GiftBean> data);
|
||||
void getAllRecordSuccess(List<GiftBean> data);
|
||||
|
||||
void finishRefreshLoadMore();
|
||||
void wallet(WalletBean walletBean);
|
||||
|
||||
void xlhChouSuccess(List<XlhDrawBean> data);
|
||||
}
|
||||
|
||||
public interface IRoomPre extends IPresenter {
|
||||
void getGiftList(String giftBagId,String roomId);
|
||||
|
||||
void drawGiftList(String giftBagId,String gift_user_ids,String roomId,String num,String heart_id,String auction_id);
|
||||
|
||||
void getMyRecord(String giftBagId,String page,String pageSize,int type);//我的抽奖记录 type: 1:我的抽奖 2:全服抽奖
|
||||
|
||||
void giftSend(String send_id);
|
||||
|
||||
void wallet();
|
||||
|
||||
void xlh(String room_id);
|
||||
|
||||
void xlhChou(String room_id,String num);
|
||||
|
||||
void xlhAllRecord(String room_id,String page,String pageSize,int type);
|
||||
|
||||
void xlhMyRecord(String room_id,String page,String pageSize);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,12 +2,216 @@ package com.xscm.moduleutil.dialog.giftLottery;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.xscm.moduleutil.bean.GiftBean;
|
||||
import com.xscm.moduleutil.bean.WalletBean;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.BlindBoxBean;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.BlindReslutBean;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.XlhDrawBean;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.http.RetrofitClient;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class GiftLotteryPresenter extends BasePresenter<GiftLotteryContacts.View> implements GiftLotteryContacts.IRoomPre {
|
||||
GiftLotteryContacts.View mView;
|
||||
public GiftLotteryPresenter(GiftLotteryContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
mView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGiftList(String giftBagId, String roomId) {
|
||||
api.getBoxGiftList(giftBagId, roomId, new BaseObserver<BlindBoxBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable( d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BlindBoxBean blindBoxBeans) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().getGiftListSuccess(blindBoxBeans);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawGiftList(String giftBagId, String gift_user_ids, String roomId, String num,String heart_id,String auction_id) {
|
||||
api.drawGiftList(giftBagId, gift_user_ids, roomId, num,heart_id,auction_id, new BaseObserver<BlindReslutBean>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BlindReslutBean blindReslutBean) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().drawGiftListSuccess(blindReslutBean);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMyRecord(String giftBagId, String page, String pageSize,int type) {
|
||||
if (type==1) {
|
||||
api.getMyRecord(giftBagId, page, pageSize, new BaseObserver<List<GiftBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<GiftBean> giftBean) {
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().getMyRecordSuccess(giftBean);
|
||||
MvpRef.get().finishRefreshLoadMore();
|
||||
}
|
||||
});
|
||||
}else {
|
||||
api.getAllRecord(giftBagId,page,pageSize,new BaseObserver<List<GiftBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<GiftBean> giftBean) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().getAllRecordSuccess(giftBean);
|
||||
MvpRef.get().finishRefreshLoadMore();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giftSend(String send_id) {
|
||||
api.giftSend(send_id, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wallet() {
|
||||
api.wallet(new BaseObserver<WalletBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(WalletBean walletBean) {
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().wallet(walletBean);
|
||||
}
|
||||
});
|
||||
}
|
||||
///巡乐会
|
||||
@Override
|
||||
public void xlh(String room_id) {
|
||||
// api.xlh(room_id, new BaseObserver<String>() {)
|
||||
|
||||
api.getBoxGiftListXLH(room_id, new BaseObserver<BlindBoxBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable( d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BlindBoxBean blindBoxBeans) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().getGiftListSuccess(blindBoxBeans);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void xlhChou(String room_id, String num) {
|
||||
if (api==null){
|
||||
api= RetrofitClient.getInstance();
|
||||
}
|
||||
api.xlhChou(room_id,num, new BaseObserver<List<XlhDrawBean>>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<XlhDrawBean> xlhDrawBeans) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().xlhChouSuccess(xlhDrawBeans);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void xlhAllRecord(String room_id, String page, String pageSize,int type) {
|
||||
|
||||
|
||||
api.xlhAllRecord(room_id, page, pageSize,type, new BaseObserver<List<GiftBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<GiftBean> giftBean) {
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().getAllRecordSuccess(giftBean);
|
||||
MvpRef.get().finishRefreshLoadMore();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void xlhMyRecord(String room_id, String page, String pageSize) {
|
||||
api.xlhMyRecord(room_id,page,pageSize,new BaseObserver<List<GiftBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<GiftBean> giftBeans) {
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().getMyRecordSuccess(giftBeans);
|
||||
MvpRef.get().finishRefreshLoadMore();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,8 +10,10 @@ import lombok.Data;
|
||||
@Data
|
||||
public class GiftRewardEvent {
|
||||
private int points;
|
||||
private String zone_id;
|
||||
|
||||
public GiftRewardEvent(int points) {
|
||||
public GiftRewardEvent(int points, String zone_id) {
|
||||
this.points = points;
|
||||
this.zone_id = zone_id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
package com.xscm.moduleutil.event;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.annotations.JsonAdapter;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonToken;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
@@ -10,7 +21,8 @@ import lombok.Data;
|
||||
@Data
|
||||
public class MqttBean {
|
||||
private String room_id;
|
||||
private ListBean list;
|
||||
@JsonAdapter(ListBeanListAdapter.class)
|
||||
private List<ListBean> list;
|
||||
|
||||
public String getRoom_id() {
|
||||
return room_id == null ? "" : room_id;
|
||||
@@ -20,14 +32,58 @@ public class MqttBean {
|
||||
this.room_id = room_id == null ? "" : room_id;
|
||||
}
|
||||
|
||||
public ListBean getList() {
|
||||
public List<ListBean> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
public void setList(ListBean list) {
|
||||
public void setList(List<ListBean> list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
|
||||
// 自定义TypeAdapter来处理有时是对象有时是数组的情况
|
||||
public static class ListBeanListAdapter extends TypeAdapter<List<ListBean>> {
|
||||
@Override
|
||||
public void write(JsonWriter out, List<ListBean> value) throws IOException {
|
||||
if (value == null) {
|
||||
out.nullValue();
|
||||
return;
|
||||
}
|
||||
Gson gson = new Gson();
|
||||
out.beginArray();
|
||||
for (ListBean item : value) {
|
||||
gson.toJson(item, ListBean.class, out);
|
||||
}
|
||||
out.endArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ListBean> read(JsonReader in) throws IOException {
|
||||
List<ListBean> list = new ArrayList<>();
|
||||
Gson gson = new Gson();
|
||||
|
||||
JsonToken token = in.peek();
|
||||
if (token == JsonToken.BEGIN_ARRAY) {
|
||||
// 正常的数组情况
|
||||
in.beginArray();
|
||||
while (in.hasNext()) {
|
||||
ListBean item = gson.fromJson(in, ListBean.class);
|
||||
list.add(item);
|
||||
}
|
||||
in.endArray();
|
||||
} else if (token == JsonToken.BEGIN_OBJECT) {
|
||||
// 单个对象的情况,转换为包含一个元素的列表
|
||||
ListBean item = gson.fromJson(in, ListBean.class);
|
||||
list.add(item);
|
||||
} else if (token == JsonToken.NULL) {
|
||||
in.nextNull();
|
||||
}
|
||||
// 其他情况(如字符串、数字等)直接跳过
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class ListBean {
|
||||
private String text;
|
||||
|
||||
@@ -14,7 +14,10 @@ public class RoomGiftGiveEvent {
|
||||
public RoonGiftModel giftModel;
|
||||
public RoonGiftModel roonGiftModel;
|
||||
public int send_type;
|
||||
public RoomGiftGiveEvent(String userId, String room_id, String pit, String num, int send_type, RoonGiftModel giftModel, RoonGiftModel roonGiftModel){
|
||||
public String heart_id;
|
||||
public String auction_id;
|
||||
public RoomGiftGiveEvent(String userId, String room_id, String pit, String num, int send_type,
|
||||
RoonGiftModel giftModel, RoonGiftModel roonGiftModel,String heart_id,String auction_id){
|
||||
this.userId = userId;
|
||||
this.room_id = room_id;
|
||||
this.pit = pit;
|
||||
@@ -22,6 +25,8 @@ public class RoomGiftGiveEvent {
|
||||
this.send_type = send_type;
|
||||
this.giftModel = giftModel;
|
||||
this.roonGiftModel = roonGiftModel;
|
||||
this.heart_id = heart_id;
|
||||
this.auction_id = auction_id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -9,8 +9,18 @@ import lombok.Data;
|
||||
@Data
|
||||
public class UnreadCountEvent {
|
||||
private long aLong;
|
||||
private long bLong;
|
||||
|
||||
public UnreadCountEvent(long aLong) {
|
||||
this.aLong = aLong;
|
||||
}
|
||||
|
||||
|
||||
// public UnreadCountEvent(long aLong, long bLong) {
|
||||
// this.aLong = aLong;
|
||||
// this.bLong = bLong;
|
||||
// }
|
||||
//
|
||||
// public UnreadCountEvent() {
|
||||
// }
|
||||
// public UnreadCountEvent(long aLong) {
|
||||
// this.aLong = aLong;
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package com.xscm.moduleutil.http;
|
||||
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.bean.UserBean;
|
||||
import com.xscm.moduleutil.utils.Sha1Util;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
|
||||
@@ -34,13 +38,59 @@ public class AccessTokenInterceptor implements Interceptor {
|
||||
@Override
|
||||
public Response intercept(Chain chain) throws IOException {
|
||||
Request request = chain.request();
|
||||
mHeaderMap.put("X-Token", SpUtil.getToken());
|
||||
mHeaderMap.put("token", SpUtil.getToken());
|
||||
|
||||
// 确保所有 put 到 mHeaderMap 的值都不为 null
|
||||
String xToken = getTokenSafely();
|
||||
mHeaderMap.put("X-Token", xToken != null ? xToken : "");
|
||||
|
||||
String token = getTokenSafely();
|
||||
mHeaderMap.put("token", token != null ? token : "");
|
||||
Log.e(TAG, "intercept: "+token);
|
||||
long timestamp = System.currentTimeMillis() / 1000;
|
||||
mHeaderMap.put("timestamp", String.valueOf(timestamp));
|
||||
mHeaderMap.put("sign", Sha1Util.shaEncode(timestamp));
|
||||
Request newRequest = request.newBuilder().headers(Headers.of(mHeaderMap)).build();
|
||||
Response response = chain.proceed(newRequest);
|
||||
return response;
|
||||
|
||||
Request newRequest = request.newBuilder()
|
||||
.headers(Headers.of(mHeaderMap))
|
||||
.build();
|
||||
return chain.proceed(newRequest);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private String getTokenSafely() {
|
||||
try {
|
||||
String token = SpUtil.getToken();
|
||||
if (isNotEmpty(token)) {
|
||||
return token;
|
||||
}
|
||||
|
||||
CommonAppContext appContext = CommonAppContext.getInstance();
|
||||
if (appContext != null) {
|
||||
token = appContext.getToken();
|
||||
if (isNotEmpty(token)) {
|
||||
return token;
|
||||
}
|
||||
}
|
||||
|
||||
UserBean userBean = SpUtil.getUserBean();
|
||||
if (userBean != null) {
|
||||
token = userBean.getToken();
|
||||
if (isNotEmpty(token)) {
|
||||
return token;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 添加异常处理,避免因获取 token 异常导致整个应用崩溃
|
||||
return "";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
private boolean isNotEmpty(String str) {
|
||||
return str != null && !str.equals("");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,67 +1,13 @@
|
||||
package com.xscm.moduleutil.http;
|
||||
|
||||
|
||||
import com.xscm.moduleutil.bean.AlbumBean;
|
||||
import com.xscm.moduleutil.bean.AppPay;
|
||||
import com.xscm.moduleutil.bean.AppUpdateModel;
|
||||
import com.xscm.moduleutil.bean.BannerModel;
|
||||
import com.xscm.moduleutil.bean.BindType;
|
||||
import com.xscm.moduleutil.bean.BlackUserBean;
|
||||
import com.xscm.moduleutil.bean.CharmRankingResp;
|
||||
import com.xscm.moduleutil.bean.CircleListBean;
|
||||
import com.xscm.moduleutil.bean.CommentBean;
|
||||
import com.xscm.moduleutil.bean.ExpandColumnBean;
|
||||
import com.xscm.moduleutil.bean.FirstChargeBean;
|
||||
import com.xscm.moduleutil.bean.FirstChargeGiftBean;
|
||||
import com.xscm.moduleutil.bean.GiftBoxRecordBean;
|
||||
import com.xscm.moduleutil.bean.GiftLabelBean;
|
||||
import com.xscm.moduleutil.bean.GiftName;
|
||||
import com.xscm.moduleutil.bean.GiftPackBean;
|
||||
import com.xscm.moduleutil.bean.GiftUserWallBean;
|
||||
import com.xscm.moduleutil.bean.HeadlineBean;
|
||||
import com.xscm.moduleutil.bean.HeatedBean;
|
||||
import com.xscm.moduleutil.bean.HostBean;
|
||||
import com.xscm.moduleutil.bean.MusicSongBean;
|
||||
import com.xscm.moduleutil.bean.MyBagDataBean;
|
||||
import com.xscm.moduleutil.bean.MyCpRoom;
|
||||
import com.xscm.moduleutil.bean.MyFootResp;
|
||||
import com.xscm.moduleutil.bean.MyRoomBean;
|
||||
import com.xscm.moduleutil.bean.NewsDataBean;
|
||||
import com.xscm.moduleutil.bean.NewsMessageList;
|
||||
import com.xscm.moduleutil.bean.PersonaltyBean;
|
||||
import com.xscm.moduleutil.bean.PkSwTokenBean;
|
||||
import com.xscm.moduleutil.bean.PlaceholderBean;
|
||||
import com.xscm.moduleutil.bean.RealNameBean;
|
||||
import com.xscm.moduleutil.bean.RechargeBean;
|
||||
import com.xscm.moduleutil.bean.RelationCardBean;
|
||||
import com.xscm.moduleutil.bean.RevenueBean;
|
||||
import com.xscm.moduleutil.bean.RewardUserBean;
|
||||
import com.xscm.moduleutil.bean.RoomBgBean;
|
||||
import com.xscm.moduleutil.bean.RoomCharmRankBean;
|
||||
import com.xscm.moduleutil.bean.RoomDetails;
|
||||
import com.xscm.moduleutil.bean.RoomRelationBean;
|
||||
import com.xscm.moduleutil.bean.RoomSearchResp;
|
||||
import com.xscm.moduleutil.bean.RoomSubsidy;
|
||||
import com.xscm.moduleutil.bean.RoomTime;
|
||||
import com.xscm.moduleutil.bean.RoomTypeModel;
|
||||
import com.xscm.moduleutil.bean.RoonGiftModel;
|
||||
import com.xscm.moduleutil.bean.SongMusicBean;
|
||||
import com.xscm.moduleutil.bean.ThemeBean;
|
||||
import com.xscm.moduleutil.bean.TopRoom;
|
||||
import com.xscm.moduleutil.bean.UserBean;
|
||||
import com.xscm.moduleutil.bean.UserInfo;
|
||||
import com.xscm.moduleutil.bean.UserOnlineStatusBean;
|
||||
import com.xscm.moduleutil.bean.UserTagBean;
|
||||
import com.xscm.moduleutil.bean.WalletBean;
|
||||
import com.xscm.moduleutil.bean.WalletConfig;
|
||||
import com.xscm.moduleutil.bean.WithdrawalBean;
|
||||
import com.xscm.moduleutil.bean.room.AuctionBean;
|
||||
import com.xscm.moduleutil.bean.room.RoomApplyListBean;
|
||||
import com.xscm.moduleutil.bean.room.RoomAuction;
|
||||
import com.xscm.moduleutil.bean.room.RoomBean;
|
||||
import com.xscm.moduleutil.bean.room.RoomInfoResp;
|
||||
import com.xscm.moduleutil.bean.room.RoomOnline;
|
||||
import com.xscm.moduleutil.bean.*;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.BlindBoxBean;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.BlindReslutBean;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.XlhDrawBean;
|
||||
import com.xscm.moduleutil.bean.room.*;
|
||||
import com.xscm.moduleutil.bean.zhuangb.ZhuangBanShangChengBean;
|
||||
import com.xscm.moduleutil.utils.cos.TempKeyBean;
|
||||
import com.xscm.moduleutil.widget.Constants;
|
||||
|
||||
import java.util.List;
|
||||
@@ -84,13 +30,28 @@ public interface ApiServer {
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.LOGIN)
|
||||
Observable<BaseModel<List<UserBean>>> login(@Field("user_login") String user_login, @Field("sms_code") String sms_code);
|
||||
Call<BaseModel<List<UserBean>>> login(@Field("user_login") String user_login, @Field("sms_code") String sms_code);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.ROOM_HOUR_BEAN)
|
||||
Call<BaseModel<RoomHourBean>> getRoomHourRanking(@Field("page") String page,@Field("page_limit")String page_limit);
|
||||
@FormUrlEncoded //手机换绑
|
||||
@POST(Constants.MODIFY_MOBILE)
|
||||
Call<BaseModel<String>> mobileView(@Field("mobile") String mobile, @Field("new_mobile") String new_mobile,@Field("sms_code") String sms_code);
|
||||
Call<BaseModel<String>> mobileView(@Field("mobile") String mobile, @Field("new_mobile") String new_mobile, @Field("sms_code") String sms_code);
|
||||
|
||||
@GET(Constants.GET_EMOTION)
|
||||
Call<BaseModel<List<Emotion>>> upEmotion();
|
||||
|
||||
@GET(Constants.GET_EMOTION_DEATILS)
|
||||
Call<BaseModel<List<EmotionDeatils>>> getEmotionDeatils(@Query("type_id") String type_id,@Query("pid") String pid);
|
||||
|
||||
@FormUrlEncoded //手机绑定
|
||||
@POST(Constants.BIND_MOBILE)
|
||||
Call<BaseModel<String>> mobileView2( @Field("new_mobile") String new_mobile,@Field("sms_code") String sms_code);
|
||||
Call<BaseModel<String>> mobileView2(@Field("new_mobile") String new_mobile, @Field("sms_code") String sms_code);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.USER_ROOM_BACK)
|
||||
Call<ResponseBody> userRoomBack(@Field("room_id")String room_id,@Field("type")String type);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.USER_LOGIN)
|
||||
@@ -134,7 +95,7 @@ public interface ApiServer {
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_USER_WALL)
|
||||
Observable<BaseModel<GiftUserWallBean>> giftWall(@Field("user_id")String userId);
|
||||
Observable<BaseModel<GiftUserWallBean>> giftWall(@Field("user_id") String userId);
|
||||
|
||||
@GET(Constants.CURRENT_HEADLINE)
|
||||
Observable<BaseModel<HeadlineBean>> currentHeadline();
|
||||
@@ -154,15 +115,22 @@ public interface ApiServer {
|
||||
Observable<BaseModel<PlaceholderBean>> guildRanking();
|
||||
|
||||
@GET(Constants.GET_WITHDRAWAL_LIST)
|
||||
Observable<BaseModel<List<WithdrawalBean>>> withdrawalList(@Query("page") String page, @Query("page_limit") String page_limit, @Query("search_stime") String search_stime, @Query("search_etime") String search_etime);
|
||||
Call<BaseModel<List<WithdrawalBean>>> withdrawalList(@Query("page") String page, @Query("page_limit") String page_limit, @Query("search_stime") String search_stime, @Query("search_etime") String search_etime);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_BIND_DETAIL)
|
||||
Call<BaseModel<BindDetail>> bindDetai(@Field("user_id") String user_id, @Field("type") String type);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_MESSAGE_LIST)
|
||||
Observable<BaseModel<List<NewsMessageList>>> getMessagetitle(@Field("type")String type, @Field("page")String page, @Field("page_limit")String page_limit);
|
||||
Call<BaseModel<List<NewsMessageList>>> getMessagetitle(@Field("type") String type, @Field("page") String page, @Field("page_limit") String page_limit);
|
||||
|
||||
@GET(Constants.GET_TEMP_KEY)
|
||||
Call<BaseModel<TempKeyBean>> getTempKey();
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_ROOM_RANK)
|
||||
Observable<BaseModel<List<CharmRankingResp>>> getRoomRank(@Field("room_id") String room_id, @Field("type") String type, @Field("time_type") String time_type, @Field("page") String page, @Field("page_limit") String page_limit);
|
||||
Call<BaseModel<List<CharmRankingResp>>> getRoomRank(@Field("room_id") String room_id, @Field("type") String type, @Field("time_type") String time_type, @Field("page") String page, @Field("page_limit") String page_limit);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_ROOM_RANKING)
|
||||
@@ -173,19 +141,19 @@ public interface ApiServer {
|
||||
Observable<BaseModel<PlaceholderBean>> loveRanking(@Field("type") String type);
|
||||
|
||||
@GET(Constants.GET_REAL_NAME)
|
||||
Observable<BaseModel<RealNameBean>> realNameInfo();
|
||||
Call<BaseModel<RealNameBean>> realNameInfo();
|
||||
|
||||
@GET(Constants.GET_DAILY_TASK_BOX)
|
||||
Observable<BaseModel<List<GiftBoxRecordBean>>> dailyTasksBoxRecord();
|
||||
Call<BaseModel<List<GiftBoxRecordBean>>> dailyTasksBoxRecord();
|
||||
|
||||
@GET(Constants.GET_MY_BAG_DATA)
|
||||
Observable<BaseModel<List<MyBagDataBean>>> packIncome(@Query("page") String page, @Query("page_limit") String page_size);
|
||||
Call<BaseModel<List<MyBagDataBean>>> packIncome(@Query("page") String page, @Query("page_limit") String page_size);
|
||||
|
||||
@GET(Constants.GET_MY_BAG_OUTCOME)
|
||||
Observable<BaseModel<List<MyBagDataBean>>> packOutcome(@Query("page") String page, @Query("page_limit") String page_size);
|
||||
Call<BaseModel<List<MyBagDataBean>>> packOutcome(@Query("page") String page, @Query("page_limit") String page_size);
|
||||
|
||||
@GET(Constants.GET_GIFT_PACK)
|
||||
Observable<BaseModel<List<GiftPackBean>>> giftPack();
|
||||
Call<BaseModel<List<GiftPackBean>>> giftPack();
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.ADD_BLACK_LIST)
|
||||
@@ -204,7 +172,7 @@ public interface ApiServer {
|
||||
Call<ResponseBody> endPk(@Field("pk_id") String is_pk, @Field("type") String type, @Field("user_id") String user_id);
|
||||
|
||||
@GET(Constants.GET_RECHARGE)
|
||||
Observable<BaseModel<List<RechargeBean>>> recharge();
|
||||
Call<BaseModel<List<RechargeBean>>> recharge();
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_START_PK)
|
||||
@@ -212,11 +180,11 @@ public interface ApiServer {
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.UPLOAD_USER_PIC)
|
||||
Call<BaseModel<String>> upUserPic(@Field("sex") String sex);
|
||||
Call<ResponseBody> upUserPic(@Field("sex") String sex);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.SWITCH_ACCOUNTS)
|
||||
Observable<BaseModel<List<UserBean>>> switchAccounts(@Field("user_login") String user_id);
|
||||
Call<BaseModel<List<UserBean>>> switchAccounts(@Field("user_login") String user_id);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.FORGOT_PASSWORD)
|
||||
@@ -224,7 +192,7 @@ public interface ApiServer {
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.USER_UPDATE)
|
||||
Observable<BaseModel<UserBean>> userUpdate(@Field("nickname") String nickname, @Field("birthday") String birthday, @Field("sex") String sex, @Field("avatar") String avatar, @Field("init_code") String init_code, @Field("user_id") String user_id);
|
||||
Call<BaseModel<UserBean>> userUpdate(@Field("nickname") String nickname, @Field("birthday") String birthday, @Field("sex") String sex, @Field("avatar") String avatar, @Field("init_code") String init_code, @Field("user_id") String user_id);
|
||||
|
||||
@GET(Constants.AUTHORIZATION)
|
||||
Call<ResponseBody> authorization();
|
||||
@@ -254,18 +222,18 @@ public interface ApiServer {
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.REAL_NAME)
|
||||
Observable<BaseModel<RealNameBean>> realName(@Field("real_name") String real_name, @Field("card_number") String card_number);
|
||||
Call<BaseModel<RealNameBean>> realName(@Field("real_name") String real_name, @Field("card_number") String card_number);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.GET_EXPAND_COLUMN)
|
||||
Observable<BaseModel<List<ExpandColumnBean>>> getExpandColumn(@Field("type") String type,@Field("page") String page, @Field("page_limit") String page_limit);
|
||||
Call<BaseModel<List<ExpandColumnBean>>> getExpandColumn(@Field("type") String type, @Field("page") String page, @Field("page_limit") String page_limit);
|
||||
|
||||
@GET(Constants.GET_OFFICIAL_NOTICE)
|
||||
Observable<BaseModel<NewsDataBean>> getOfficialNotice();
|
||||
Call<BaseModel<NewsDataBean>> getOfficialNotice();
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.GET_ALBUM_LIST)
|
||||
Observable<BaseModel<List<AlbumBean>>> getAlbumList(@Field("page") String page, @Field("page_limit") String page_limit, @Field("user_id") String user_id);
|
||||
Call<BaseModel<List<AlbumBean>>> getAlbumList(@Field("page") String page, @Field("page_limit") String page_limit, @Field("user_id") String user_id);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.CREATE_ALBUM)
|
||||
@@ -280,18 +248,19 @@ public interface ApiServer {
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_FOLLOW_LIST)
|
||||
Observable<BaseModel<List<BlackUserBean>>> getUserFollowList(@Field("page") String page, @Field("page_limit") String page_limit);
|
||||
Call<BaseModel<List<BlackUserBean>>> getUserFollowList(@Field("page") String page, @Field("page_limit") String page_limit);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_FANS_LIST)
|
||||
Observable<BaseModel<List<BlackUserBean>>> getUserFansList(@Field("page") String page, @Field("page_limit") String page_limit);
|
||||
Call<BaseModel<List<BlackUserBean>>> getUserFansList(@Field("page") String page, @Field("page_limit") String page_limit);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_BLACK_LIST)
|
||||
Observable<BaseModel<List<BlackUserBean>>> getBlacklist(@Field("page") String page, @Field("page_limit") String page_limit);
|
||||
Call<BaseModel<List<BlackUserBean>>> getBlacklist(@Field("page") String page, @Field("page_limit") String page_limit);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_LOCK_MI_LIST)
|
||||
Observable<BaseModel<List<BlackUserBean>>> getLockMiniList(@Field("page") String page, @Field("page_limit") String page_limit);
|
||||
Call<BaseModel<List<BlackUserBean>>> getLockMiniList(@Field("page") String page, @Field("page_limit") String page_limit);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.GET_MY_ROOM)
|
||||
@@ -306,7 +275,7 @@ public interface ApiServer {
|
||||
Call<BaseModel<List<TopRoom>>> getTopRooms(@Field("page") String page, @Field("page_limit") String page_limit, @Field("is_top") String is_top, @Field("label_id") String label_id);
|
||||
|
||||
@GET(Constants.GET_ROOM_TYPE)
|
||||
Observable<BaseModel<List<RoomTypeModel>>> getRoomCategories();
|
||||
Call<BaseModel<List<RoomTypeModel>>> getRoomCategories();
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.CHECK_TXT)
|
||||
@@ -314,35 +283,35 @@ public interface ApiServer {
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.GET_REWARD_LIST)
|
||||
Observable<BaseModel<List<RewardUserBean>>> getRewardList(@Field("id") String id, @Field("page") String page, @Field("page_limit") String page_limit);
|
||||
Call<BaseModel<List<RewardUserBean>>> getRewardList(@Field("id") String id, @Field("page") String page, @Field("page_limit") String page_limit);
|
||||
|
||||
@GET(Constants.GET_GIFT_LABEL)
|
||||
Observable<BaseModel<List<GiftLabelBean>>> getGiftLabel(@Query("have_hot") String have_hot);
|
||||
Call<BaseModel<List<GiftLabelBean>>> getGiftLabel(@Query("have_hot") String have_hot);
|
||||
|
||||
@GET(Constants.GIFT_LIST)
|
||||
//获取礼物列表
|
||||
Observable<BaseModel<List<RoonGiftModel>>> getGiftList(@Query("label") int label);
|
||||
Call<BaseModel<List<RoonGiftModel>>> getGiftList(@Query("label") int label,@Query("room_id")String room_id);
|
||||
|
||||
@GET(Constants.TOPIC_LIST)
|
||||
//获取话题
|
||||
Observable<BaseModel<List<HeatedBean>>> topicList(@Query("page") String page, @Query("page_limit") String page_limit);
|
||||
Call<BaseModel<List<HeatedBean>>> topicList(@Query("page") String page, @Query("page_limit") String page_limit);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.PUBLISH_ZONE)
|
||||
Call<BaseModel<String>> publishZone(@Field("images") String images, @Field("content") String content, @Field("topic_id") String topic_id, @Field("room_id") String room_id, @Field("ip") String ip);
|
||||
|
||||
@GET(Constants.GET_CATEGORIES)
|
||||
Observable<BaseModel<List<HeatedBean>>> getCategories();
|
||||
Call<BaseModel<List<HeatedBean>>> getCategories();
|
||||
|
||||
@GET(Constants.GET_CIRCLE_LIST)
|
||||
Observable<BaseModel<List<CircleListBean>>> getCircleList(@Query("page") String page, @Query("page_limit") String page_limit);
|
||||
Call<BaseModel<List<CircleListBean>>> getCircleList(@Query("page") String page, @Query("page_limit") String page_limit);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.GET_USER_HOME_ZONE)
|
||||
Observable<BaseModel<List<CircleListBean>>> getCircleUserList(@Field("user_id") String user_id, @Field("page") String page, @Field("page_limit") String page_limit);
|
||||
Call<BaseModel<List<CircleListBean>>> getCircleUserList(@Field("user_id") String user_id, @Field("page") String page, @Field("page_limit") String page_limit);
|
||||
|
||||
@GET(Constants.GET_MY_FOOT)
|
||||
Observable<BaseModel<List<MyFootResp>>> getMyFoot(@Query("page") String page, @Query("page_limit") String page_limit);
|
||||
Call<BaseModel<List<MyFootResp>>> getMyFoot(@Query("page") String page, @Query("page_limit") String page_limit);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.LIKE_ZONE)
|
||||
@@ -350,15 +319,15 @@ public interface ApiServer {
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.TOPIC_ID)
|
||||
Observable<BaseModel<List<CircleListBean>>> topicId(@Field("topic_id") String topic_id);
|
||||
Call<BaseModel<List<CircleListBean>>> topicId(@Field("topic_id") String topic_id);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.ZONE_DETAIL)
|
||||
Observable<BaseModel<CircleListBean>> zoneDetail(@Field("id") String topic_id);
|
||||
Call<BaseModel<CircleListBean>> zoneDetail(@Field("id") String topic_id);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.GET_USER_HOME)
|
||||
Observable<BaseModel<UserInfo>> getUserHome(@Field("user_id") String user_id);
|
||||
Call<BaseModel<UserInfo>> getUserHome(@Field("user_id") String user_id);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.DELETE_COMMENT)
|
||||
@@ -366,11 +335,11 @@ public interface ApiServer {
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.GET_COMMENT_LIST)
|
||||
Observable<BaseModel<CommentBean>> getCommentList(@Field("id") String id, @Field("page") String page, @Field("page_limit") String page_limit);
|
||||
Call<BaseModel<CommentBean>> getCommentList(@Field("id") String id, @Field("page") String page, @Field("page_limit") String page_limit);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_SONG)
|
||||
Observable<BaseModel<List<SongMusicBean>>> song(@Field("room_id") String roomId, @Field("user_id") String userId, @Field("song_code") String songCode, @Field("song_name") String songName, @Field("singer") String singer, @Field("poster") String poster, @Field("duration") String duration);
|
||||
Call<BaseModel<List<SongMusicBean>>> song(@Field("room_id") String roomId, @Field("user_id") String userId, @Field("song_code") String songCode, @Field("song_name") String songName, @Field("singer") String singer, @Field("poster") String poster, @Field("duration") String duration);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.COMMENT_ZONE)
|
||||
@@ -393,7 +362,7 @@ public interface ApiServer {
|
||||
Call<BaseModel<String>> deleteZone(@Field("id") String id);
|
||||
|
||||
@GET(Constants.GET_MY_INFO)
|
||||
Observable<BaseModel<UserInfo>> getMyInfo();
|
||||
Call<BaseModel<UserInfo>> getMyInfo();
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.ED_USER_INFO)
|
||||
@@ -404,37 +373,41 @@ public interface ApiServer {
|
||||
Call<BaseModel<String>> editUserBg(@Field("images") String images);
|
||||
|
||||
@GET(Constants.GET_USER_TAG_LIST)
|
||||
Observable<BaseModel<List<UserTagBean>>> getUserTagList();
|
||||
Call<BaseModel<List<UserTagBean>>> getUserTagList();
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.GET_LIKE_LIST)
|
||||
Observable<BaseModel<List<CircleListBean.LikeList>>> getLikeList(@Field("id") String id);
|
||||
Call<BaseModel<List<CircleListBean.LikeList>>> getLikeList(@Field("id") String id);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.GET_ALBUM_DETAIL)
|
||||
Observable<BaseModel<AlbumBean>> getAlbumDetail(@Field("album_id") String albumId, @Field("pwd") String pwd, @Field("page") String page, @Field("page_limit") String page_limit);
|
||||
Call<BaseModel<AlbumBean>> getAlbumDetail(@Field("album_id") String albumId, @Field("pwd") String pwd, @Field("page") String page, @Field("page_limit") String page_limit);
|
||||
|
||||
@GET(Constants.GET_PERSONALTY)
|
||||
Observable<BaseModel<List<PersonaltyBean>>> getPersonaltyList();
|
||||
Call<BaseModel<List<PersonaltyBean>>> getPersonaltyList();
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.GET_SUBSIDY)
|
||||
Observable<BaseModel<RoomSubsidy>> getSubsidy(@Field("room_id") String roomId);
|
||||
Call<BaseModel<RoomSubsidy>> getSubsidy(@Field("room_id") String roomId);
|
||||
|
||||
@GET(Constants.GET_DECORATE)
|
||||
Observable<BaseModel<List<ZhuangBanShangChengBean>>> getDecorateList(@Query("type") String type);
|
||||
Call<BaseModel<List<ZhuangBanShangChengBean>>> getDecorateList(@Query("type") String type);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_GZ)
|
||||
Call<BaseModel<String>> userGuanz(@Field("user_id") String userId, @Field("type") String type);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_FOLLOW_ROOM)
|
||||
Call<BaseModel<String>> followRoom(@Field("room_id") String roomId, @Field("type") String type);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.ACCEPT_PK)
|
||||
Call<BaseModel<String>> acceptPk(@Field("pk_id") String pk_id, @Field("type") String type);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_CLEAR_USER_CHARM)
|
||||
Call<BaseModel<String>> clearUserCharm(@Field("room_id") String roomId,@Field("user_id") String userId);
|
||||
Call<BaseModel<String>> clearUserCharm(@Field("room_id") String roomId, @Field("user_id") String userId);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.REMOVE_BLACK_LIST)
|
||||
@@ -442,7 +415,7 @@ public interface ApiServer {
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_USER_OLINE_STATUS)
|
||||
Call<BaseModel<List<UserOnlineStatusBean>>> userOnlineStatus(@Field("user_id") String userId,@Field("room_id")String roomId);
|
||||
Call<BaseModel<List<UserOnlineStatusBean>>> userOnlineStatus(@Field("user_id") String userId, @Field("room_id") String roomId);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.postRoomSwToken)
|
||||
@@ -467,7 +440,7 @@ public interface ApiServer {
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.JOIN_ROOM)
|
||||
Observable<BaseModel<RoomInfoResp>> roomGetIn(@Field("room_id") String roomId, @Field("password") String password);
|
||||
Call<BaseModel<RoomInfoResp>> roomGetIn(@Field("room_id") String roomId, @Field("password") String password);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.DELETE_ALBUM_IMAGE)
|
||||
@@ -487,11 +460,11 @@ public interface ApiServer {
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.UPDATEPASSWORD)
|
||||
Observable<BaseModel<String>> updatePassword(@Field("room_id") String roomId, @Field("password") String password);
|
||||
Call<BaseModel<String>> updatePassword(@Field("room_id") String roomId, @Field("password") String password);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.GET_ROOM_ONLINE)
|
||||
Observable<BaseModel<RoomOnline>> getRoomOnline(@Field("room_id") String roomId, @Field("page") String page, @Field("page_limit") String page_limit);
|
||||
Call<BaseModel<RoomOnline>> getRoomOnline(@Field("room_id") String roomId, @Field("page") String page, @Field("page_limit") String page_limit);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.GET_GIVE_GIFT)
|
||||
@@ -499,32 +472,63 @@ public interface ApiServer {
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.GET_ROOM_GIFT)
|
||||
Call<BaseModel<String>> roomGift(@Field("room_id") String room_id, @Field("gift_id") String gift_id, @Field("gift_num") String num, @Field("to_uid") String to_uid, @Field("type") String gift_type, @Field("pit_number") String pit_number);
|
||||
Call<BaseModel<String>> roomGift(@Field("room_id") String room_id, @Field("gift_id") String gift_id, @Field("gift_num") String num, @Field("to_uid") String to_uid, @Field("type") String gift_type, @Field("pit_number") String pit_number, @Field("heart_id") String heat_id);
|
||||
|
||||
@GET(Constants.GET_FIRST_CHARGE_GIFT)
|
||||
Observable<BaseModel<FirstChargeGiftBean>> firstChargeGift();
|
||||
Call<BaseModel<FirstChargeGiftBean>> firstChargeGift();
|
||||
@GET(Constants.GET_NEW_CHARGE_GIFT)
|
||||
Call<BaseModel<FirstChargeGiftBean>> getNewChargeGift();
|
||||
|
||||
@GET(Constants.GET_ACTIVITIES_PERMISSION)
|
||||
Call<BaseModel<ActivitiesPermission>> activitiesPermission();
|
||||
|
||||
@GET(Constants.GET_DAY_DROP_GIFT)
|
||||
Call<BaseModel<HeavenGiftBean>> getDayDropGift();
|
||||
|
||||
@GET(Constants.GET_WALLET)
|
||||
Observable<BaseModel<WalletBean>> wallet();
|
||||
Call<BaseModel<WalletBean>> wallet();
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.REDPACKET_CREATE)
|
||||
Call<ResponseBody> redPacketCreate(@Field("type") int type, @Field("password") String password, @Field("coin_type") int coin_type, @Field("total_amount") String total_amount,
|
||||
@Field("total_count")String total_count, @Field("conditions") String conditions, @Field("countdown") String countdown, @Field("room_id") String room_id,
|
||||
@Field("remark") String remark);
|
||||
|
||||
@GET(Constants.ROOM_REDPACKET)
|
||||
Call<BaseModel<List<RedPacketInfo>>> roomRedPackets(@Query("room_id") String roomId);
|
||||
|
||||
@GET(Constants.GET_REDPACKET_DETAIL)
|
||||
Call<BaseModel<RedpacketDetail>> redPacketDetail(@Query("redpacket_id") String redpacket_id);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_GRAB)
|
||||
Call<BaseModel<RedPackGrab>> grab(@Field("redpacket_id") String redpacket_id);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_APPLY_Pay)
|
||||
Observable<BaseModel<AppPay>> appPay(@Field("user_id") String user_id, @Field("money") String money, @Field("coin") String coin, @Field("type") String type);
|
||||
Call<BaseModel<AppPay>> appPay
|
||||
(@Field("user_id") String user_id,
|
||||
@Field("money") String money,
|
||||
@Field("coin") String coin,
|
||||
@Field("type") String type,
|
||||
@Field("type_params") String type_params,
|
||||
@Field("type_id") String type_id
|
||||
);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_APPLY_LIST)
|
||||
Observable<BaseModel<RoomApplyListBean>> roomApplyListBean(@Field("room_id") String room_id);
|
||||
Call<BaseModel<RoomApplyListBean>> roomApplyListBean(@Field("room_id") String room_id);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.GET_ROOM_USER)
|
||||
Observable<BaseModel<UserInfo>> getRoomUserInfo(@Field("room_id") String roomId, @Field("user_id") String userId);
|
||||
Call<BaseModel<UserInfo>> getRoomUserInfo(@Field("room_id") String roomId, @Field("user_id") String userId);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_BIND_TYPE)
|
||||
Observable<BaseModel<BindType>> bindType(@Field("user_id") String userId);
|
||||
Call<BaseModel<BindType>> bindType(@Field("user_id") String userId);
|
||||
|
||||
@GET(Constants.GET_WALLET_CONFIG)
|
||||
Observable<BaseModel<WalletConfig>> getWalletConfig();
|
||||
Call<BaseModel<WalletConfig>> getWalletConfig();
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_BIND)
|
||||
@@ -532,7 +536,7 @@ public interface ApiServer {
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_SONG_LIST)
|
||||
Observable<BaseModel<List<MusicSongBean>>> songList(@Field("room_id") String room_id);
|
||||
Call<BaseModel<List<MusicSongBean>>> songList(@Field("room_id") String room_id);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.APPLY_PIT)
|
||||
@@ -542,6 +546,21 @@ public interface ApiServer {
|
||||
@POST(Constants.START_FRIEND)
|
||||
Call<BaseModel<String>> startFriend(@Field("room_id") String room_id);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.END_FRIEND)
|
||||
Call<BaseModel<FriendUserBean>> endFriend(@Field("friend_id") String friend_id, @Field("room_id") String room_id);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.CREATE_RELATION)
|
||||
Call<BaseModel<String>> createRelation(@Field("room_id") String room_id, @Field("friend_id") String friend_id, @Field("user1_id") String user1_id, @Field("user2_id") String user2_id, @Field("relation_id") String relation_id);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.DELAY)
|
||||
Call<BaseModel<String>> delay(@Field("friend_id") String friend_id, @Field("room_id") String room_id, @Field("delay_times") String delay_times);
|
||||
|
||||
@POST(Constants.POST_KEEP_XINTIAO)
|
||||
Call<ResponseBody> keepXintiao();
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.DOWN_PIT)
|
||||
Call<BaseModel<String>> downPit(@Field("room_id") String room_id, @Field("pit_number") String pit_number);
|
||||
@@ -596,7 +615,7 @@ public interface ApiServer {
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_ROOM_INFO)
|
||||
Observable<BaseModel<RoomInfoResp>> postRoomInfo(@Field("room_id") String roomId);
|
||||
Call<BaseModel<RoomInfoResp>> postRoomInfo(@Field("room_id") String roomId);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.CHANGE_SONG)
|
||||
@@ -604,23 +623,27 @@ public interface ApiServer {
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_HOST_LIST)
|
||||
Observable<BaseModel<List<HostBean>>> getHostList(@Query("room_id") String room_id, @Field("type") String type);
|
||||
Call<BaseModel<List<HostBean>>> getHostList(@Query("room_id") String room_id, @Field("type") String type);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.GET_CHARM_RANK)
|
||||
Observable<BaseModel<List<RoomCharmRankBean>>> getCharmRank(@Field("room_id") String roomId);
|
||||
Call<BaseModel<List<RoomCharmRankBean>>> getCharmRank(@Field("room_id") String roomId);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_ROOM_RELATION_LIST)
|
||||
Observable<BaseModel<List<RoomRelationBean>>> roomRelationList(@Field("type") String type);
|
||||
Call<BaseModel<List<RoomRelationBean>>> roomRelationList(@Field("type") String type);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_ROOM_AUCTION_LIST)
|
||||
Observable<BaseModel<List<RoomAuction.AuctionListBean>>> roomAuctionList(@Field("auction_id") String auction_id);
|
||||
Call<BaseModel<List<RoomAuction.AuctionListBean>>> roomAuctionList(@Field("auction_id") String auction_id);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_SEARCH)
|
||||
Observable<BaseModel<List<RoomSearchResp>>> getSearch(@Query("search") String room_id, @Field("type") String type);
|
||||
Call<BaseModel<List<RoomSearchResp>>> getSearch(@Field("search") String room_id, @Field("type") String type);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_SEARCH_ALL)
|
||||
Call<BaseModel<SearchAll>> getSearchAll(@Field("search") String search);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.SET_PRESIDED_RATIO)
|
||||
@@ -637,7 +660,7 @@ public interface ApiServer {
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_GIVE_COIN)
|
||||
Call<BaseModel<String>> giveCoin(@Field("user_id") String user_id,@Field("coin") String coin);
|
||||
Call<BaseModel<String>> giveCoin(@Field("user_id") String user_id, @Field("coin") String coin);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_SET_MUTE_PIT)
|
||||
@@ -648,11 +671,11 @@ public interface ApiServer {
|
||||
Call<BaseModel<String>> setLockPit(@Field("room_id") String room_id, @Field("pit_number") String pit_number, @Field("is_lock") String is_lock);
|
||||
|
||||
@GET(Constants.GET_ROOM_BJ)
|
||||
Observable<BaseModel<RoomBgBean>> getBackgroundList();
|
||||
Call<BaseModel<RoomBgBean>> getBackgroundList();
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_CHARM_LIST)
|
||||
Observable<BaseModel<RoomDetails>> getCharmList(@Field("room_id") String room_id, @Field("start_time") String start_time, @Field("end_time") String end_time,@Field("page") String page);
|
||||
Call<BaseModel<RoomDetails>> getCharmList(@Field("room_id") String room_id, @Field("start_time") String start_time, @Field("end_time") String end_time, @Field("page") String page);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_SET_UPLOAD_BG_IMG)
|
||||
@@ -664,7 +687,7 @@ public interface ApiServer {
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_AUCTION_END)
|
||||
Call<BaseModel<String>> auctionEnd(@Field("auction_id") String auction_id,@Field("room_id") String room_id);
|
||||
Call<BaseModel<String>> auctionEnd(@Field("auction_id") String auction_id, @Field("room_id") String room_id);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_AUCTION_MODE)
|
||||
@@ -685,7 +708,7 @@ public interface ApiServer {
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_RELATION_CARD)
|
||||
Observable<BaseModel<RelationCardBean>> relationCard(@Field("user_id") String user_id);
|
||||
Call<BaseModel<RelationCardBean>> relationCard(@Field("user_id") String user_id);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_TOP_RELATION_CARD)
|
||||
@@ -698,18 +721,68 @@ public interface ApiServer {
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_ROOM_AUCTION)
|
||||
Observable<BaseModel<AuctionBean>> roomAuction(@Field("room_id") String room_id, @Field("user_id") String user_id, @Field("gift_id") String gift_id, @Field("relation_id") String relation_id, @Field("auction_type") String auction_type, @Field("time_day") String time_day);
|
||||
Call<BaseModel<AuctionBean>> roomAuction(@Field("room_id") String room_id, @Field("user_id") String user_id, @Field("gift_id") String gift_id, @Field("relation_id") String relation_id, @Field("auction_type") String auction_type, @Field("time_day") String time_day);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_ROOM_AUCTION_TIME)
|
||||
Observable<BaseModel<RoomTime>> roomAuctionTime(@Field("gift_id") String gift_id);
|
||||
Call<BaseModel<RoomTime>> roomAuctionTime(@Field("gift_id") String gift_id);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_ROOM_AUCTION_JOIN)
|
||||
Observable<BaseModel<RoomAuction.AuctionListBean>> roomAuctionJoin(@Field("auction_id") String auction_id, @Field("user_id") String user_id, @Field("gift_id") String gift_id, @Field("num") String num, @Field("type") String type);
|
||||
Call<BaseModel<RoomAuction.AuctionListBean>> roomAuctionJoin(@Field("auction_id") String auction_id, @Field("user_id") String user_id, @Field("gift_id") String gift_id, @Field("num") String num, @Field("type") String type);
|
||||
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_SEARCH_PK_ROOM)
|
||||
Observable<BaseModel<List<RoomBean>>> searchPkRoom(@Field("room_id") String room_id, @Field("page") String page, @Field("limit") String limit);
|
||||
Call<BaseModel<List<RoomBean>>> searchPkRoom(@Field("room_id") String room_id, @Field("page") String page, @Field("limit") String limit);
|
||||
|
||||
@GET(Constants.GET_BOX_GIFT_LIST)
|
||||
Call<BaseModel<BlindBoxBean>> getBoxGiftList(@Query("gift_bag_id") String gift_bag_id, @Query("room_id") String room_id);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_DRAW_GIFT_LIST)
|
||||
Call<BaseModel<BlindReslutBean>> drawGiftList(@Field("gift_bag_id") String gift_bag_id, @Field("gift_user_ids") String gift_user_ids,@Field("room_id")String room_id,@Field("num")String num,@Field("heart_id") String heart_id,@Field("auction_id") String auction_id);
|
||||
|
||||
@GET(Constants.GET_MY_RECORD)
|
||||
Call<BaseModel<List<GiftBean>>> getMyRecord(@Query("gift_bag_id")String gift_bag_id,@Query("page")String page,@Query("page_size")String page_size);
|
||||
|
||||
@GET(Constants.GET_ALL_RECORD)
|
||||
Call<BaseModel<List<GiftBean>>> getAllRecord(@Query("gift_bag_id")String gift_bag_id,@Query("page")String page,@Query("page_size")String page_size);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.GIFT_SEND)
|
||||
Call<BaseModel<String>> giftSend(@Field("send_id")String send_id);
|
||||
|
||||
@GET(Constants.GET_BOX_GIFT_LIST_XLH)
|
||||
Call<BaseModel<BlindBoxBean>> getBoxGiftListXLH( @Query("room_id") String room_id);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_DRAW_GIFT_LIST_XLH)
|
||||
Call<BaseModel<List<XlhDrawBean>>> xlhChou(@Field("room_id") String room_id, @Field("num") String num);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_XLH_ALL_RECORD)
|
||||
Call<BaseModel<List<GiftBean>>> xlhAllRecord(@Field("room_id") String room_id, @Field("page") String page, @Field("page_size") String page_size);
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.Get_XH_RANking)
|
||||
Call<BaseModel<List<GiftBean>>> xlXH_RANking(@Field("room_id") String room_id, @Field("page") String page, @Field("page_size") String page_size);
|
||||
|
||||
@GET(Constants.GET_XLH_MY_RECORD)
|
||||
Call<BaseModel<List<GiftBean>>> xlhMyRecord(@Query("room_id") String room_id, @Query("page") String page, @Query("page_size") String page_size);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_GIFT_ALL_CLEAR)
|
||||
Call<BaseModel<String>> getGiftPack(@Field("room_id") String roomId,@Field("to_uid") String user_id,@Field("heart_id") String heart_id,@Field("auction_id") String auction_id);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.POST_ROOM_USER_CHARM_LIST)
|
||||
Call<BaseModel<List<RoomUserCharmListBean>>> roomUserCharmList(@Field("room_id") String roomId,@Field("user_id") String user_id);
|
||||
|
||||
@GET(Constants.GET_GIFT_PACK_LIST_COUNT)
|
||||
Call<BaseModel<GiftPackListCount>> getGiftPackListCount();
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(Constants.ROOM_USER_RECONNECT)
|
||||
Call<BaseModel<String>> roomUserReconnect(@Field("room_id") String room_id);
|
||||
|
||||
}
|
||||
|
||||
@@ -53,8 +53,11 @@ public abstract class BaseObserver<T> implements Observer<T> {
|
||||
} else if (e instanceof APIException) {
|
||||
APIException apiException = (APIException) e;
|
||||
if (apiException.getCode() == 301) {
|
||||
EventBus.getDefault().post(new LogOutEvent());
|
||||
|
||||
try {
|
||||
ToastUtils.show(extractChinese(apiException.getMessage()));
|
||||
// com.blankj.utilcode.util.ToastUtils.showShort("提示当前账号已在别的地方登陆,如果不是本人操作请修改密码");
|
||||
EventBus.getDefault().post(new LogOutEvent());
|
||||
CommonAppContext.getInstance().clearLoginInfo();
|
||||
} catch (ClassNotFoundException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
|
||||
@@ -2,8 +2,13 @@ package com.xscm.moduleutil.http;
|
||||
|
||||
|
||||
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.ObservableSource;
|
||||
import io.reactivex.ObservableTransformer;
|
||||
@@ -23,16 +28,27 @@ public class DefaultTransformer<T> implements ObservableTransformer<BaseModel<T>
|
||||
return upstream
|
||||
.map(response -> {
|
||||
if (response.isTokenExpired()) {
|
||||
// 触发登出事件(EventBus)
|
||||
CommonAppContext.getInstance().clearLoginInfo();
|
||||
throw new APIException(-1, "登录已过期");
|
||||
if (response.getCode()==301){
|
||||
CommonAppContext.getInstance().clearLoginInfo();
|
||||
ToastUtils.showShort(response.getMsg());
|
||||
}else {
|
||||
// 触发登出事件(EventBus)
|
||||
// com.blankj.utilcode.util.ToastUtils.showShort("提示当前账号已在别的地方登陆,如果不是本人操作请修改密码");
|
||||
// CommonAppContext.getInstance().clearLoginInfo();
|
||||
}
|
||||
throw new APIException(response.getCode(), response.getMsg());
|
||||
}
|
||||
|
||||
if (!response.isSuccess()) {
|
||||
throw new APIException(response.getCode(), response.getMsg());
|
||||
}
|
||||
|
||||
return response.getData();
|
||||
// 确保不会返回null值
|
||||
T data = response.getData();
|
||||
if (data == null) {
|
||||
return getDefaultValue();
|
||||
}
|
||||
return data;
|
||||
// return response.getData();
|
||||
})
|
||||
.onErrorResumeNext(throwable -> {
|
||||
// 可以在这里统一处理异常
|
||||
@@ -44,4 +60,32 @@ public class DefaultTransformer<T> implements ObservableTransformer<BaseModel<T>
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private T getDefaultValue() {
|
||||
try {
|
||||
// 根据类型返回合理的默认值
|
||||
Class<T> type = (Class<T>) Object.class;
|
||||
if (String.class.isAssignableFrom(type)) {
|
||||
return (T) "";
|
||||
} else if (List.class.isAssignableFrom(type)) {
|
||||
return (T) new ArrayList<>();
|
||||
} else if (Integer.class.isAssignableFrom(type) || int.class.isAssignableFrom(type)) {
|
||||
return (T) Integer.valueOf(0);
|
||||
} else if (Long.class.isAssignableFrom(type) || long.class.isAssignableFrom(type)) {
|
||||
return (T) Long.valueOf(0L);
|
||||
} else if (Double.class.isAssignableFrom(type) || double.class.isAssignableFrom(type)) {
|
||||
return (T) Double.valueOf(0.0);
|
||||
} else if (Float.class.isAssignableFrom(type) || float.class.isAssignableFrom(type)) {
|
||||
return (T) Float.valueOf(0.0f);
|
||||
} else if (Boolean.class.isAssignableFrom(type) || boolean.class.isAssignableFrom(type)) {
|
||||
return (T) Boolean.FALSE;
|
||||
} else {
|
||||
// 对于其他对象类型,返回一个新的Object实例
|
||||
return (T) new Object();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.xscm.moduleutil.http;
|
||||
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.xscm.moduleutil.utils.GsonUtils;
|
||||
|
||||
@@ -25,21 +26,76 @@ public class ResponseBodyConverter<T> implements Converter<ResponseBody, T> {
|
||||
@Override
|
||||
public T convert(@NonNull ResponseBody value) throws IOException {
|
||||
String json = value.string();
|
||||
BaseModel obj = GsonUtils.GsonToBean(json, BaseModel.class);
|
||||
if (obj.getCode() != 1) {
|
||||
String info = obj.getMsg();
|
||||
if ("当前余额不足".equals(info)) {
|
||||
value.close();
|
||||
return adapter.fromJson(json);
|
||||
} else {
|
||||
if(!info.contains("更新失败")) {
|
||||
ToastUtils.showShort(info);
|
||||
}
|
||||
try {
|
||||
BaseModel obj = GsonUtils.GsonToBean(json, BaseModel.class);
|
||||
if (obj.getCode() != 1) {
|
||||
String info = obj.getMsg();
|
||||
if ("当前余额不足".equals(info)) {
|
||||
value.close();
|
||||
return parseDataSafely(json);
|
||||
} else {
|
||||
if (!info.contains("更新失败")) {
|
||||
// ToastUtils.showShort(info);
|
||||
}
|
||||
// throw new APIException(obj.getCode(), info);
|
||||
}
|
||||
}
|
||||
value.close();
|
||||
return parseDataSafely(json);
|
||||
} catch (Exception e) {
|
||||
// 处理解析异常,避免崩溃
|
||||
value.close();
|
||||
try {
|
||||
// 尝试返回默认值
|
||||
return createDefaultInstance();
|
||||
} catch (Exception ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 安全地解析数据,处理各种可能的返回类型
|
||||
*/
|
||||
private T parseDataSafely(String json) {
|
||||
try {
|
||||
return adapter.fromJson(json);
|
||||
} catch (IOException | JsonParseException e) {
|
||||
// 当解析失败时,尝试其他方式处理
|
||||
try {
|
||||
// 尝试返回默认值
|
||||
return createDefaultInstance();
|
||||
} catch (Exception ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
value.close();
|
||||
return adapter.fromJson(json);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建默认实例以避免null返回
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private T createDefaultInstance() {
|
||||
try {
|
||||
// 对于基本类型和常见集合类型,返回默认值
|
||||
Class<?> rawType = adapter.getClass();
|
||||
if (rawType.isAssignableFrom(String.class)) {
|
||||
return (T) "";
|
||||
} else if (rawType.isAssignableFrom(Boolean.class) || rawType.isAssignableFrom(boolean.class)) {
|
||||
return (T) Boolean.FALSE;
|
||||
} else if (rawType.isAssignableFrom(Integer.class) || rawType.isAssignableFrom(int.class)) {
|
||||
return (T) Integer.valueOf(0);
|
||||
} else if (rawType.isAssignableFrom(Long.class) || rawType.isAssignableFrom(long.class)) {
|
||||
return (T) Long.valueOf(0L);
|
||||
} else if (rawType.isAssignableFrom(Double.class) || rawType.isAssignableFrom(double.class)) {
|
||||
return (T) Double.valueOf(0.0);
|
||||
} else if (rawType.isAssignableFrom(Float.class) || rawType.isAssignableFrom(float.class)) {
|
||||
return (T) Float.valueOf(0.0f);
|
||||
} else {
|
||||
// 对于其他类型,返回null而不是抛出异常
|
||||
return null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -78,6 +78,9 @@ public abstract class BasePresenter<V extends IView> implements IPresenter {
|
||||
* @param disposable
|
||||
*/
|
||||
public void addDisposable(Disposable disposable) {
|
||||
if (mDisposables == null){
|
||||
mDisposables = new CompositeDisposable();
|
||||
}
|
||||
mDisposables.add(disposable);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,8 @@ public class RechargeDialogContacts {
|
||||
public interface IRechargePre extends IPresenter {
|
||||
void recharge();//可选充值金额列表
|
||||
void bindType(String userId);
|
||||
void appPay(String user_id,String money,String coin,String type);
|
||||
|
||||
void appPay(String user_id,String money,String coin,String type,String type_params,String type_id);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,8 +47,8 @@ public class RechargeDialogPresenter extends BasePresenter<RechargeDialogContact
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appPay(String user_id, String money, String coin, String type) {
|
||||
api.appPay(user_id, money, coin, type, new BaseObserver<AppPay>() {
|
||||
public void appPay(String user_id, String money, String coin, String type, String type_params, String type_id) {
|
||||
api.appPay(user_id, money, coin, type,type_params,type_id, new BaseObserver<AppPay>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
@@ -61,4 +61,6 @@ public class RechargeDialogPresenter extends BasePresenter<RechargeDialogContact
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.GiftLabelBean;
|
||||
import com.xscm.moduleutil.bean.GiftPackBean;
|
||||
import com.xscm.moduleutil.bean.GiftPackListCount;
|
||||
import com.xscm.moduleutil.bean.RewardUserBean;
|
||||
import com.xscm.moduleutil.bean.RoonGiftModel;
|
||||
import com.xscm.moduleutil.bean.WalletBean;
|
||||
@@ -27,6 +28,10 @@ public class RewardGiftContacts {
|
||||
void reward_zone();
|
||||
void roomAuctionJoin(RoomAuction.AuctionListBean auctionListBean);
|
||||
void giftPack(List<GiftPackBean> giftPackBean);
|
||||
|
||||
void getGiftPack(String s);
|
||||
|
||||
void getGiftPackListCount(GiftPackListCount giftPackListCount);
|
||||
}
|
||||
|
||||
public interface IIndexPre extends IPresenter {
|
||||
@@ -34,11 +39,11 @@ public class RewardGiftContacts {
|
||||
|
||||
void getGiftLabel(String have_hot);
|
||||
|
||||
void getGiftList(String id, int type);
|
||||
void getGiftList(String id, int type,String roomId);
|
||||
|
||||
void giveGift(String user_id, String gid, String num, String to_uid, String gift_type);
|
||||
|
||||
void roomGift(String room_id, String gift_id, String gift_num, String to_uid, String type, String pit_number);
|
||||
void roomGift(String room_id, String gift_id, String gift_num, String to_uid, String type, String pit_number,String heart_id);
|
||||
|
||||
void wallet();
|
||||
|
||||
@@ -48,5 +53,9 @@ public class RewardGiftContacts {
|
||||
|
||||
void roomAuctionJoin(String auction_id,String user_id, String gift_id, String num,String type);
|
||||
void giftPack();
|
||||
|
||||
void getGiftPack(String roomId,String userId,String heart_id,String auction_id );
|
||||
|
||||
void getGiftPackListCount();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.content.Context;
|
||||
|
||||
import com.xscm.moduleutil.bean.GiftLabelBean;
|
||||
import com.xscm.moduleutil.bean.GiftPackBean;
|
||||
import com.xscm.moduleutil.bean.GiftPackListCount;
|
||||
import com.xscm.moduleutil.bean.RewardUserBean;
|
||||
import com.xscm.moduleutil.bean.RoonGiftModel;
|
||||
import com.xscm.moduleutil.bean.WalletBean;
|
||||
@@ -17,6 +18,7 @@ import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class RewardGiftPresenter extends BasePresenter<RewardGiftContacts.View> implements RewardGiftContacts.IIndexPre {
|
||||
RewardGiftContacts.View mView;
|
||||
|
||||
public RewardGiftPresenter(RewardGiftContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
mView = view;
|
||||
@@ -32,6 +34,9 @@ public class RewardGiftPresenter extends BasePresenter<RewardGiftContacts.View>
|
||||
|
||||
@Override
|
||||
public void onNext(List<RewardUserBean> rewardUserBeans) {
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().getRewardList(rewardUserBeans);
|
||||
}
|
||||
});
|
||||
@@ -48,6 +53,9 @@ public class RewardGiftPresenter extends BasePresenter<RewardGiftContacts.View>
|
||||
|
||||
@Override
|
||||
public void onNext(List<GiftLabelBean> giftLabelBeans) {
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().getGiftLabel(giftLabelBeans);
|
||||
}
|
||||
});
|
||||
@@ -55,8 +63,8 @@ public class RewardGiftPresenter extends BasePresenter<RewardGiftContacts.View>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGiftList(String id, int type) {
|
||||
api.getGiftList(Integer.parseInt(id), new BaseObserver<List<RoonGiftModel>>() {
|
||||
public void getGiftList(String id, int type, String roomId) {
|
||||
api.getGiftList(Integer.parseInt(id), roomId, new BaseObserver<List<RoonGiftModel>>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
@@ -65,6 +73,9 @@ public class RewardGiftPresenter extends BasePresenter<RewardGiftContacts.View>
|
||||
|
||||
@Override
|
||||
public void onNext(List<RoonGiftModel> roonGiftModels) {
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().setGiftList(roonGiftModels, type);
|
||||
}
|
||||
});
|
||||
@@ -81,14 +92,17 @@ public class RewardGiftPresenter extends BasePresenter<RewardGiftContacts.View>
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().giveGift();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void roomGift(String room_id, String gift_id, String gift_num, String to_uid, String type, String pit_number) {
|
||||
api.roomGift(room_id, gift_id, gift_num, to_uid, type, pit_number, new BaseObserver<String>() {
|
||||
public void roomGift(String room_id, String gift_id, String gift_num, String to_uid, String type, String pit_number, String heart_id) {
|
||||
api.roomGift(room_id, gift_id, gift_num, to_uid, type, pit_number, heart_id, new BaseObserver<String>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
@@ -97,7 +111,7 @@ public class RewardGiftPresenter extends BasePresenter<RewardGiftContacts.View>
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().giveGift();
|
||||
@@ -115,6 +129,9 @@ public class RewardGiftPresenter extends BasePresenter<RewardGiftContacts.View>
|
||||
|
||||
@Override
|
||||
public void onNext(WalletBean walletBean) {
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().wallet(walletBean);
|
||||
}
|
||||
});
|
||||
@@ -131,6 +148,9 @@ public class RewardGiftPresenter extends BasePresenter<RewardGiftContacts.View>
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().reward_zone();
|
||||
}
|
||||
});
|
||||
@@ -146,6 +166,9 @@ public class RewardGiftPresenter extends BasePresenter<RewardGiftContacts.View>
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().reward_zone();
|
||||
}
|
||||
});
|
||||
@@ -161,6 +184,9 @@ public class RewardGiftPresenter extends BasePresenter<RewardGiftContacts.View>
|
||||
|
||||
@Override
|
||||
public void onNext(RoomAuction.AuctionListBean auctionListBean) {
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().roomAuctionJoin(auctionListBean);
|
||||
}
|
||||
});
|
||||
@@ -177,8 +203,51 @@ public class RewardGiftPresenter extends BasePresenter<RewardGiftContacts.View>
|
||||
|
||||
@Override
|
||||
public void onNext(List<GiftPackBean> giftPackBeans) {
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().giftPack(giftPackBeans);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGiftPack(String roomId, String userId, String heart_id, String auction_id) {
|
||||
api.getGiftPack(roomId, userId, heart_id, auction_id, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
if (s == null) {
|
||||
MvpRef.get().getGiftPack(null);
|
||||
} else {
|
||||
MvpRef.get().getGiftPack(s);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGiftPackListCount() {
|
||||
api.getGiftPackListCount(new BaseObserver<GiftPackListCount>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(GiftPackListCount giftPackListCount) {
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().getGiftPackListCount(giftPackListCount);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,138 +0,0 @@
|
||||
package com.xscm.moduleutil.service;
|
||||
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.os.Build;
|
||||
import android.os.IBinder;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.event.MqttBean;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
|
||||
|
||||
public class EMqttService extends Service {
|
||||
private WindowManager windowManager;
|
||||
private View piaoPingView;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
if (intent != null && intent.hasExtra("mqttBean")) {
|
||||
MqttBean mqttBean = (MqttBean) intent.getSerializableExtra("mqttBean");
|
||||
showPiaoPingMessage(mqttBean);//全局飘屏
|
||||
}
|
||||
return START_NOT_STICKY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (piaoPingView != null) {
|
||||
windowManager.removeView(piaoPingView);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void showPiaoPingMessage(MqttBean mqttBean) {
|
||||
|
||||
int screenWidth = getResources().getDisplayMetrics().widthPixels;
|
||||
int screenHeight = getResources().getDisplayMetrics().heightPixels;
|
||||
//
|
||||
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(
|
||||
WindowManager.LayoutParams.MATCH_PARENT,
|
||||
WindowManager.LayoutParams.WRAP_CONTENT,
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ?
|
||||
WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY :
|
||||
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
|
||||
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
|
||||
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
|
||||
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
|
||||
PixelFormat.TRANSLUCENT);
|
||||
//
|
||||
// // 设置 Gravity 为左上角
|
||||
// layoutParams.gravity = Gravity.TOP | Gravity.START;
|
||||
//
|
||||
// // Y 轴随机位置
|
||||
// layoutParams.y = (int) ((Math.random() * (screenHeight - 200)));
|
||||
//
|
||||
// // 初始 X 设为负值,确保 View 在屏幕左侧外
|
||||
// layoutParams.x = -screenWidth;
|
||||
|
||||
// FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
|
||||
// FrameLayout.LayoutParams.MATCH_PARENT,
|
||||
// FrameLayout.LayoutParams.WRAP_CONTENT);
|
||||
//
|
||||
|
||||
// 设置随机 Y 轴位置
|
||||
// layoutParams.topMargin = (int) (Math.random() * (screenHeight - 200));
|
||||
|
||||
|
||||
piaoPingView = LayoutInflater.from(this).inflate(R.layout.item_piaoping, null);
|
||||
TextView textView = piaoPingView.findViewById(R.id.tv_name);
|
||||
textView.setText(mqttBean.getList().getText());
|
||||
ImageUtils.loadHeadCC(mqttBean.getList().getGift_picture(), piaoPingView.findViewById(R.id.iv_piaoping));
|
||||
TextView tv_time = piaoPingView.findViewById(R.id.tv_num);
|
||||
tv_time.setText(mqttBean.getList().getNumber());
|
||||
windowManager.addView(piaoPingView, layoutParams);
|
||||
|
||||
piaoPingView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
piaoPingView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||
|
||||
// 设置锚点为左上角,避免偏移干扰
|
||||
piaoPingView.setPivotX(0);
|
||||
piaoPingView.setPivotY(0);
|
||||
|
||||
// 启动动画:从左外滑入 -> 右外滑出
|
||||
ObjectAnimator animator = ObjectAnimator.ofFloat(
|
||||
piaoPingView,
|
||||
"translationX",
|
||||
0f, // 初始偏移为 0(此时 View 在左侧外)
|
||||
screenWidth // 向右移动整个屏幕宽度
|
||||
);
|
||||
animator.setDuration(2000); // 整个动画的时长为2秒
|
||||
|
||||
// 强制 GPU 渲染
|
||||
piaoPingView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
||||
|
||||
// 延迟显示2秒后开始滑出屏幕的动画
|
||||
piaoPingView.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
animator.start();
|
||||
}
|
||||
}, 2000);
|
||||
|
||||
animator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
windowManager.removeView(piaoPingView);
|
||||
stopSelf();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,156 +0,0 @@
|
||||
package com.xscm.moduleutil.service;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.content.Context;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.os.Build;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.event.MqttBean;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/8/8
|
||||
*@description: 全局悬浮框管理类
|
||||
*/
|
||||
public class FloatingWindow {
|
||||
private WindowManager windowManager;
|
||||
private View piaoPingView;
|
||||
|
||||
public FloatingWindow(Context context, MqttBean mqttBean){
|
||||
int screenWidth =context.getResources().getDisplayMetrics().widthPixels;
|
||||
windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||
piaoPingView = LayoutInflater.from(context).inflate(R.layout.item_piaoping, null);
|
||||
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(
|
||||
WindowManager.LayoutParams.WRAP_CONTENT,
|
||||
WindowManager.LayoutParams.WRAP_CONTENT,
|
||||
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ?
|
||||
WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY :
|
||||
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
|
||||
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
|
||||
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
|
||||
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
|
||||
|
||||
PixelFormat.TRANSLUCENT);
|
||||
|
||||
|
||||
TextView textView = piaoPingView.findViewById(R.id.tv_name);
|
||||
textView.setText(mqttBean.getList().getText());
|
||||
ImageUtils.loadHeadCC(mqttBean.getList().getGift_picture(), piaoPingView.findViewById(R.id.iv_piaoping));
|
||||
TextView tv_time = piaoPingView.findViewById(R.id.tv_num);
|
||||
tv_time.setText(mqttBean.getList().getNumber());
|
||||
windowManager.addView(piaoPingView, layoutParams);
|
||||
|
||||
// piaoPingView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
// @Override
|
||||
// public void onGlobalLayout() {
|
||||
// piaoPingView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||
//
|
||||
// // 设置锚点为左上角,避免偏移干扰
|
||||
// piaoPingView.setPivotX(0);
|
||||
// piaoPingView.setPivotY(0);
|
||||
//
|
||||
// // 启动动画:从左外滑入 -> 右外滑出
|
||||
// ObjectAnimator animator = ObjectAnimator.ofFloat(
|
||||
// piaoPingView,
|
||||
// "translationX",
|
||||
// 0f, // 初始偏移为 0(此时 View 在左侧外)
|
||||
// screenWidth // 向右移动整个屏幕宽度
|
||||
// );
|
||||
// animator.setDuration(2000); // 整个动画的时长为2秒
|
||||
//
|
||||
// // 强制 GPU 渲染
|
||||
// piaoPingView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
||||
//
|
||||
// // 延迟显示2秒后开始滑出屏幕的动画
|
||||
// piaoPingView.postDelayed(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// animator.start();
|
||||
// }
|
||||
// }, 2000);
|
||||
//
|
||||
// animator.addListener(new AnimatorListenerAdapter() {
|
||||
// @Override
|
||||
// public void onAnimationEnd(Animator animation) {
|
||||
// windowManager.removeView(piaoPingView);
|
||||
// stopSelf();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
|
||||
|
||||
piaoPingView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
piaoPingView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||
|
||||
// 获取视图宽度
|
||||
int viewWidth = piaoPingView.getWidth();
|
||||
|
||||
// 设置锚点为左上角
|
||||
piaoPingView.setPivotX(0);
|
||||
piaoPingView.setPivotY(0);
|
||||
|
||||
// 强制 GPU 渲染
|
||||
piaoPingView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
||||
|
||||
// 创建滑入动画:从左外滑入到屏幕左侧
|
||||
ObjectAnimator slideInAnimator = ObjectAnimator.ofFloat(
|
||||
piaoPingView,
|
||||
"translationX",
|
||||
-viewWidth, // 起始位置:屏幕左外
|
||||
0f // 结束位置:屏幕左边缘
|
||||
);
|
||||
slideInAnimator.setDuration(500); // 滑入动画时长0.5秒
|
||||
|
||||
// 创建滑出动画:从当前位置滑出到屏幕右侧外
|
||||
ObjectAnimator slideOutAnimator = ObjectAnimator.ofFloat(
|
||||
piaoPingView,
|
||||
"translationX",
|
||||
0f, // 起始位置:屏幕左边缘
|
||||
screenWidth // 结束位置:屏幕右外
|
||||
);
|
||||
slideOutAnimator.setDuration(500); // 滑出动画时长0.5秒
|
||||
|
||||
// 设置滑出动画监听器
|
||||
slideOutAnimator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
windowManager.removeView(piaoPingView);
|
||||
stopSelf();
|
||||
}
|
||||
});
|
||||
|
||||
// 开始执行动画序列
|
||||
slideInAnimator.start();
|
||||
|
||||
// 滑入完成后延迟2秒执行滑出动画
|
||||
piaoPingView.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
slideOutAnimator.start();
|
||||
}
|
||||
}, 2000);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void stopSelf(){
|
||||
if (piaoPingView != null) {
|
||||
windowManager.removeView(piaoPingView);
|
||||
piaoPingView = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,27 +1,27 @@
|
||||
package com.xscm.moduleutil.service;
|
||||
|
||||
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ServiceInfo;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.os.IBinder;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.blankj.utilcode.util.ServiceUtils;
|
||||
import com.orhanobut.logger.Logger;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.bean.XLHBean;
|
||||
import com.xscm.moduleutil.event.MqttBean;
|
||||
import com.xscm.moduleutil.event.RoomGiftRunable;
|
||||
|
||||
import org.eclipse.paho.android.service.MqttAndroidClient;
|
||||
@@ -33,217 +33,153 @@ import org.eclipse.paho.client.mqttv3.MqttClient;
|
||||
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
|
||||
import org.eclipse.paho.client.mqttv3.MqttException;
|
||||
import org.eclipse.paho.client.mqttv3.MqttMessage;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class MyMqttService extends Service implements MyEmqttConnectListener,MyEmqttMesgListener,MyEmqttSubscribeListener{
|
||||
public class MyMqttService extends Service implements MyEmqttConnectListener, MyEmqttMesgListener, MyEmqttSubscribeListener {
|
||||
|
||||
private final static String TAG = "lxj";
|
||||
|
||||
private static int qos = 2;
|
||||
private static String HOST ="tcp://81.70.45.221";//正式
|
||||
// private static String HOST ="tcp://47.120.21.132";//测试
|
||||
// private static String HOST = "tcp://1.13.181.248";//测试
|
||||
private static String HOST = "tcp://62.234.12.147";//正式
|
||||
private static MqttAndroidClient mqttAndroidClient;
|
||||
private MqttConnectOptions mMqttConnectOptions;
|
||||
private static boolean b = true;
|
||||
|
||||
|
||||
private static MyEmqttConnectListener mMyEmqttConnectListener;
|
||||
private static MyEmqttMesgListener mMyEmqttMesgListener;
|
||||
private static MyEmqttSubscribeListener mMyEmqttSubscribeListener;
|
||||
// 使用线程安全的集合存储监听器
|
||||
private static final CopyOnWriteArrayList<MyEmqttMesgListener> messageListeners = new CopyOnWriteArrayList<>();
|
||||
private static final CopyOnWriteArrayList<MyEmqttConnectListener> connectListeners = new CopyOnWriteArrayList<>();
|
||||
private static final CopyOnWriteArrayList<MyEmqttSubscribeListener> subscribeListeners = new CopyOnWriteArrayList<>();
|
||||
|
||||
private static final String TOPIC_BOSS = "qx_room_topic";
|
||||
private static final String TOPIC_XLH = "qx_xunlehui";
|
||||
|
||||
// 添加后台线程处理
|
||||
private HandlerThread mqttHandlerThread;
|
||||
private Handler mqttHandler;
|
||||
private ExecutorService messageExecutorService;
|
||||
|
||||
// 添加连接重试限制
|
||||
private static final int MAX_RETRY_ATTEMPTS = 5;
|
||||
private int retryCount = 0;
|
||||
|
||||
// 服务状态
|
||||
private static boolean isServiceRunning = false;
|
||||
|
||||
private static final int NOTIFICATION_ID = 1;
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { // API 31+
|
||||
// 设置前台服务类型为 "connectedDevice" 或其他合适类型
|
||||
setForegroundServiceBehavior(ServiceInfo.FOREGROUND_SERVICE_TYPE_MANIFEST);
|
||||
}
|
||||
// ⚠️ 必须在这个方法开始就调用 startForeground()
|
||||
Notification notification = createNotification();
|
||||
startForeground(NOTIFICATION_ID, notification);
|
||||
|
||||
return super.onStartCommand(intent, flags, startId);
|
||||
}
|
||||
|
||||
private void setForegroundServiceBehavior(int foregroundServiceTypeManifest) {
|
||||
}
|
||||
|
||||
private static final String CHANNEL_ID = "mqtt_channel";
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
isServiceRunning = true;
|
||||
|
||||
// 创建专用的HandlerThread处理MQTT操作
|
||||
mqttHandlerThread = new HandlerThread("MqttServiceThread");
|
||||
mqttHandlerThread.start();
|
||||
mqttHandler = new Handler(mqttHandlerThread.getLooper());
|
||||
|
||||
// 创建线程池处理消息
|
||||
messageExecutorService = Executors.newCachedThreadPool();
|
||||
|
||||
// 启动前台服务
|
||||
startForegroundService();
|
||||
|
||||
try {
|
||||
init();
|
||||
} catch (MqttException e) {
|
||||
throw new RuntimeException(e);
|
||||
Log.e(TAG, "MQTT初始化异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
private Notification createNotification() {
|
||||
// 创建你的前台通知
|
||||
Notification.Builder builder = null;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
builder = new Notification.Builder(this, "channel_id")
|
||||
.setContentTitle("MQTT Service")
|
||||
.setSmallIcon(R.mipmap.default_avatar);
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationChannel channel = new NotificationChannel(
|
||||
"channel_id", "MQTT Channel",
|
||||
NotificationManager.IMPORTANCE_LOW);
|
||||
NotificationManager manager = getSystemService(NotificationManager.class);
|
||||
manager.createNotificationChannel(channel);
|
||||
}
|
||||
return builder.build();
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
return START_STICKY;
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启服务
|
||||
*/
|
||||
public static void startService(Context mContext) {
|
||||
b = true;
|
||||
boolean serviceRunning = ServiceUtils.isServiceRunning(MyMqttService.class.getCanonicalName());
|
||||
if (!serviceRunning) {
|
||||
mContext.startService(new Intent(mContext, MyMqttService.class));
|
||||
}
|
||||
}
|
||||
|
||||
public static void stopService(Context context) {
|
||||
b = false;
|
||||
boolean serviceRunning = ServiceUtils.isServiceRunning(MyMqttService.class.getCanonicalName());
|
||||
if (serviceRunning) {
|
||||
context.stopService(new Intent(context, MyMqttService.class));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发布 (模拟其他客户端发布消息)
|
||||
*
|
||||
* @param message 消息
|
||||
*/
|
||||
public static void publish(String topic, String message) throws MqttException {
|
||||
if (mqttAndroidClient == null) {
|
||||
Logger.e(TAG, "mqttAndroidClient is null", "发送失败");
|
||||
return;
|
||||
}
|
||||
//参数分别为:主题、消息的字节数组、服务质量、是否在服务器保留断开连接后的最后一条消息
|
||||
IMqttDeliveryToken publish = mqttAndroidClient.publish(topic, message.getBytes(), qos, false);
|
||||
publish.setActionCallback(new IMqttActionListener() {
|
||||
@Override
|
||||
public void onSuccess(IMqttToken asyncActionToken) {
|
||||
Logger.e(TAG, "发送消息", "发送成功");
|
||||
private void startForegroundService() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
// 创建通知渠道
|
||||
NotificationChannel channel = new NotificationChannel(
|
||||
CHANNEL_ID,
|
||||
"MQTT Service",
|
||||
NotificationManager.IMPORTANCE_LOW
|
||||
);
|
||||
NotificationManager manager = getSystemService(NotificationManager.class);
|
||||
if (manager != null) {
|
||||
manager.createNotificationChannel(channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(IMqttToken asyncActionToken, Throwable exception) {
|
||||
Logger.e(TAG, "发送消息", "发送失败");
|
||||
}
|
||||
});
|
||||
}
|
||||
// 创建通知
|
||||
Notification notification = new Notification.Builder(this, CHANNEL_ID)
|
||||
.setContentTitle("消息服务")
|
||||
.setContentText("正在接收实时消息")
|
||||
.setSmallIcon(R.mipmap.default_avatar)
|
||||
.setOngoing(true)
|
||||
.build();
|
||||
|
||||
|
||||
public static void subscribe(String topic) {
|
||||
try {
|
||||
if (mqttAndroidClient.isConnected()) {
|
||||
IMqttToken subToken = mqttAndroidClient.subscribe(topic, qos);
|
||||
subToken.setActionCallback(new IMqttActionListener() {
|
||||
@Override
|
||||
public void onSuccess(IMqttToken asyncActionToken) {
|
||||
if (mMyEmqttSubscribeListener != null) {
|
||||
mMyEmqttSubscribeListener.onSubscribeSuccess(topic);
|
||||
}
|
||||
Logger.e(TAG, "订阅成功:" + topic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(IMqttToken asyncActionToken,
|
||||
Throwable exception) {
|
||||
if (!TOPIC_BOSS.equals(topic) && mMyEmqttSubscribeListener != null) {
|
||||
mMyEmqttSubscribeListener.onSubscribeFailure();
|
||||
}
|
||||
Logger.e(TAG, "订阅失败:" + topic);
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
startForeground(NOTIFICATION_ID, notification);
|
||||
}
|
||||
}
|
||||
|
||||
public static void cleanSubscribe(String topic) {
|
||||
try {
|
||||
if (mqttAndroidClient.isConnected()) {
|
||||
IMqttToken subToken = mqttAndroidClient.unsubscribe(topic);
|
||||
subToken.setActionCallback(new IMqttActionListener() {
|
||||
@Override
|
||||
public void onSuccess(IMqttToken asyncActionToken) {
|
||||
Logger.e(TAG, "取消成功" + topic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(IMqttToken asyncActionToken,
|
||||
Throwable exception) {
|
||||
Logger.e(TAG, "取消失败" + topic);
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
*/
|
||||
private void init() throws MqttException {
|
||||
String CLIENTID = "android-" + MqttClient.generateClientId();
|
||||
mqttAndroidClient = new MqttAndroidClient(this, HOST, CLIENTID);
|
||||
mqttAndroidClient.setCallback(mqttCallback); //设置监听订阅消息的回调
|
||||
mqttAndroidClient.setCallback(mqttCallback);
|
||||
mMqttConnectOptions = new MqttConnectOptions();
|
||||
mMqttConnectOptions.setCleanSession(true); //设置是否清除缓存
|
||||
mMqttConnectOptions.setConnectionTimeout(10); //设置超时时间,单位:秒
|
||||
mMqttConnectOptions.setKeepAliveInterval(10); //设置心跳包发送间隔,单位:秒
|
||||
mMqttConnectOptions.setUserName("public"); //设置用户名
|
||||
// mMqttConnectOptions.setPassword(new char[0]); //设置密码
|
||||
mMqttConnectOptions.setCleanSession(true);
|
||||
mMqttConnectOptions.setConnectionTimeout(10);
|
||||
mMqttConnectOptions.setKeepAliveInterval(10);
|
||||
mMqttConnectOptions.setUserName("public");
|
||||
mMqttConnectOptions.setMqttVersion(MqttConnectOptions.MQTT_VERSION_3_1);
|
||||
|
||||
if (!mqttAndroidClient.isConnected()) {
|
||||
if (mqttAndroidClient != null && !mqttAndroidClient.isConnected()) {
|
||||
doClientConnection();
|
||||
}
|
||||
}
|
||||
|
||||
private void doClientConnection() throws MqttException {
|
||||
if (mqttAndroidClient != null && !mqttAndroidClient.isConnected() && isConnectIsNomarl() && b) {
|
||||
mqttAndroidClient.connect(mMqttConnectOptions, null, iMqttActionListener);
|
||||
}
|
||||
// 在后台线程执行连接操作
|
||||
mqttHandler.post(() -> {
|
||||
if (mqttAndroidClient != null && !mqttAndroidClient.isConnected() && isConnectIsNomarl() && b) {
|
||||
try {
|
||||
mqttAndroidClient.connect(mMqttConnectOptions, null, iMqttActionListener);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "MQTT连接异常", e);
|
||||
handleConnectionFailure();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void closeConnection() throws MqttException {
|
||||
if (mqttAndroidClient.isConnected()) {
|
||||
IMqttToken disconnect = mqttAndroidClient.disconnect();
|
||||
disconnect.setActionCallback(new IMqttActionListener() {
|
||||
@Override
|
||||
public void onSuccess(IMqttToken asyncActionToken) {
|
||||
Logger.e(TAG, "断开链接", "断开链接成功");
|
||||
private void handleConnectionFailure() {
|
||||
retryCount++;
|
||||
if (retryCount < MAX_RETRY_ATTEMPTS) {
|
||||
// 延迟重试
|
||||
mqttHandler.postDelayed(() -> {
|
||||
if (b) {
|
||||
try {
|
||||
doClientConnection();
|
||||
} catch (MqttException e) {
|
||||
Log.e(TAG, "MQTT连接异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(IMqttToken asyncActionToken, Throwable exception) {
|
||||
Logger.e(TAG, "断开链接", "断开链接失败" + exception.getMessage());
|
||||
}
|
||||
});
|
||||
}, 5000);
|
||||
} else {
|
||||
Log.w(TAG, "达到最大重试次数,停止重试");
|
||||
retryCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,81 +187,81 @@ public class MyMqttService extends Service implements MyEmqttConnectListener,MyE
|
||||
* 判断网络是否连接
|
||||
*/
|
||||
private boolean isConnectIsNomarl() {
|
||||
ConnectivityManager connectivityManager = (ConnectivityManager) this.getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo info = connectivityManager.getActiveNetworkInfo();
|
||||
if (info != null && info.isAvailable()) {
|
||||
String name = info.getTypeName();
|
||||
Log.i(TAG, "当前网络名称:" + name);
|
||||
return true;
|
||||
} else {
|
||||
Log.i(TAG, "没有可用网络");
|
||||
/*没有可用网络的时候,延迟3秒再尝试重连*/
|
||||
HandlerUtil.getInstance(this).postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
doClientConnection();
|
||||
} catch (MqttException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
try {
|
||||
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
if (connectivityManager != null) {
|
||||
NetworkInfo info = connectivityManager.getActiveNetworkInfo();
|
||||
if (info != null && info.isAvailable()) {
|
||||
String name = info.getTypeName();
|
||||
Log.i(TAG, "当前网络名称:" + name);
|
||||
return true;
|
||||
} else {
|
||||
Log.i(TAG, "没有可用网络");
|
||||
return false;
|
||||
}
|
||||
}, 3000);
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "检查网络状态异常", e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//MQTT是否连接成功的监听
|
||||
private IMqttActionListener iMqttActionListener = new IMqttActionListener() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(IMqttToken arg0) {
|
||||
if (mMyEmqttConnectListener != null) {
|
||||
mMyEmqttConnectListener.onConnectSuccess();
|
||||
retryCount = 0;
|
||||
|
||||
// 通知所有连接监听器
|
||||
for (MyEmqttConnectListener listener : connectListeners) {
|
||||
if (listener != null) {
|
||||
listener.onConnectSuccess();
|
||||
}
|
||||
}
|
||||
|
||||
Logger.e(TAG, "链接状态:", "链接成功");
|
||||
subscribe(TOPIC_BOSS);
|
||||
subscribe(TOPIC_XLH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(IMqttToken arg0, Throwable arg1) {
|
||||
if (mMyEmqttConnectListener != null) {
|
||||
mMyEmqttConnectListener.onConnectFailure();
|
||||
}
|
||||
// if (arg0 instanceof MqttException) {
|
||||
//// Logger.e(TAG, "链接状态:", "链接失败" + ((MqttException) arg1).getMessage());
|
||||
// }
|
||||
HandlerUtil.getInstance(getApplicationContext()).postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (b) {
|
||||
try {
|
||||
doClientConnection();
|
||||
} catch (MqttException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
// 通知所有连接监听器
|
||||
for (MyEmqttConnectListener listener : connectListeners) {
|
||||
if (listener != null) {
|
||||
listener.onConnectFailure();
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
Logger.e(TAG, "链接状态:", "链接失败: " + arg1.getMessage());
|
||||
|
||||
// 在后台线程处理重连
|
||||
mqttHandler.postDelayed(() -> {
|
||||
if (b) {
|
||||
handleConnectionFailure();
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//订阅主题的回调
|
||||
private MqttCallback mqttCallback = new MqttCallback() {
|
||||
|
||||
@Override
|
||||
public void messageArrived(String topic, MqttMessage message) throws Exception {
|
||||
if (mMyEmqttMesgListener != null) {
|
||||
mMyEmqttMesgListener.messageArrived(topic, message.toString());
|
||||
}
|
||||
Logger.e(TAG, "收到的消息", "主题:" + topic + " 收到的消息:" + message.toString());
|
||||
//收到其他客户端的消息后,响应给对方告知消息已到达或者消息有问题等
|
||||
receiveMessage(topic,message.toString());
|
||||
// if (TOPIC_BOSS.equals(topic)) {
|
||||
// EventBus.getDefault().post(new BossMsgEvent(message.toString()));
|
||||
// }
|
||||
|
||||
// 将消息处理放到后台线程执行
|
||||
messageExecutorService.execute(() -> {
|
||||
try {
|
||||
String messageStr = message.toString();
|
||||
Logger.e(TAG, "收到的消息", "主题:" + topic + " 收到的消息:" + messageStr);
|
||||
if (topic.equals(TOPIC_BOSS)) {
|
||||
receiveMessage(topic, messageStr);
|
||||
} else if (topic.equals(TOPIC_XLH)) {
|
||||
receiveXlhMessage(messageStr);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "处理MQTT消息异常", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -335,241 +271,275 @@ public class MyMqttService extends Service implements MyEmqttConnectListener,MyE
|
||||
|
||||
@Override
|
||||
public void connectionLost(Throwable arg0) {
|
||||
if (mMyEmqttConnectListener != null) {
|
||||
mMyEmqttConnectListener.onConnectFailure();
|
||||
// 通知所有连接监听器
|
||||
for (MyEmqttConnectListener listener : connectListeners) {
|
||||
if (listener != null) {
|
||||
listener.onConnectFailure();
|
||||
}
|
||||
}
|
||||
Logger.e(TAG, "链接状态:", "链接断开");
|
||||
|
||||
HandlerUtil.getInstance(getApplicationContext()).postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (b) {
|
||||
try {
|
||||
doClientConnection();
|
||||
} catch (MqttException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
Logger.e(TAG, "链接状态:", "链接断开: " + arg0.getMessage());
|
||||
|
||||
// 在后台线程处理重连
|
||||
mqttHandler.postDelayed(() -> {
|
||||
if (b) {
|
||||
try {
|
||||
doClientConnection();
|
||||
} catch (MqttException e) {
|
||||
Log.e(TAG, "MQTT连接异常", e);
|
||||
}
|
||||
}
|
||||
}, 300);
|
||||
}, 1000);
|
||||
}
|
||||
};
|
||||
|
||||
private void receiveMessage(String topic, String data) {
|
||||
JSONObject jsonObject = null;
|
||||
private void receiveXlhMessage(String messageStr) {
|
||||
try {
|
||||
String newdata = data;//TextLengthUtil.decode(data);
|
||||
jsonObject = JSON.parseObject(newdata);
|
||||
JSONObject jsonObject = JSON.parseObject(messageStr);
|
||||
int type = jsonObject.getIntValue("type");
|
||||
String message = jsonObject.getString("msg");
|
||||
XLHBean xlhBean=JSON.parseObject(message, XLHBean.class);
|
||||
// 将事件处理放到主线程执行
|
||||
new Handler(Looper.getMainLooper()).post(() -> {
|
||||
// processMessageType(type, message);
|
||||
EventBus.getDefault().post(xlhBean);
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "解析MQTT消息异常", e);
|
||||
}
|
||||
}
|
||||
private void receiveMessage(String topic, String data) {
|
||||
try {
|
||||
JSONObject jsonObject = JSON.parseObject(data);
|
||||
int type = jsonObject.getIntValue("type");
|
||||
String message = jsonObject.getString("msg");
|
||||
|
||||
// 将事件处理放到主线程执行
|
||||
new Handler(Looper.getMainLooper()).post(() -> {
|
||||
processMessageType(type, message);
|
||||
});
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "解析MQTT消息异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void processMessageType(int type, String message) {
|
||||
switch (type) {
|
||||
case 5019://推送所有人-横幅礼物通知
|
||||
new RoomGiftRunable(message).run();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发布 (模拟其他客户端发布消息)
|
||||
*/
|
||||
public static void publish(String topic, String message) {
|
||||
if (mqttAndroidClient == null) {
|
||||
Logger.e(TAG, "mqttAndroidClient is null", "发送失败");
|
||||
return;
|
||||
}
|
||||
|
||||
int type = jsonObject.getIntValue("type");
|
||||
String message = jsonObject.getString("msg");
|
||||
switch (type) {
|
||||
case 3001://抢糖果游戏
|
||||
break;
|
||||
case 5001://延时一秒推送房间-人气变化
|
||||
break;
|
||||
case 5003://延时一秒推送房间-坐骑进场特效
|
||||
break;
|
||||
case 5004://延时一秒推送房间-爵位用户进场特效
|
||||
break;
|
||||
case 5005://推送房间-上麦申请人数变化
|
||||
Logger.e("环信5005", message);
|
||||
break;
|
||||
case 5007://推送房间-用户是否禁言 1禁言2解禁
|
||||
break;
|
||||
case 5011://推送房间-是否封麦 1封麦2解封
|
||||
break;
|
||||
case 5013://推送房间-清空单个麦位心动值
|
||||
case 5014://推送房间-清空所有麦位心动值
|
||||
break;
|
||||
case 5015://推送房间-设置房间管理员
|
||||
break;
|
||||
case 5016://推送房间-删除房间管理员
|
||||
break;
|
||||
case 5017://用户开关麦
|
||||
// EventBus.getDefault().post(JSON.parseObject(message, WheatVoiceModel.class));
|
||||
break;
|
||||
case 5019://推送所有人-横幅礼物通知c
|
||||
new RoomGiftRunable(message).run();
|
||||
break;
|
||||
case 5020://推送房间-聊天室礼物通知
|
||||
Logger.e("环信5020", message);
|
||||
break;
|
||||
case 5030:
|
||||
case 5021://推送所有人-小猫钓鱼钓到大礼物时通知
|
||||
break;
|
||||
case 5022://推送房间-房间密码变化通知 0取消密码1设置或修改密码
|
||||
break;
|
||||
case 5023://推送房间-房间心动值开关变化通知 1开2关
|
||||
break;
|
||||
case 5024://推送房间-上麦模式变化通知 1自由2排麦
|
||||
break;
|
||||
case 5025://推送房间-修改房间名称
|
||||
break;
|
||||
case 5027://推送房间-周星用户进场特效
|
||||
break;
|
||||
case 5028://推送房间-修改房间背景
|
||||
break;
|
||||
case 5029://推送房间-修改房间公告
|
||||
break;
|
||||
case 5032://推送房间-上麦
|
||||
Logger.e("环信5032", message);
|
||||
break;
|
||||
case 5033://推送房间-下麦
|
||||
Logger.e("环信5033", message);
|
||||
break;
|
||||
case 5034://踢出房间
|
||||
Logger.e("环信5034", message);
|
||||
break;
|
||||
case 5035://推送单独用户-定向推向给上麦的用户
|
||||
break;
|
||||
case 5036://推送房间-用户禁麦 1禁麦2解禁
|
||||
break;
|
||||
case 5037://推送房间-用户进入房间
|
||||
break;
|
||||
case 5038://麦位倒计时
|
||||
break;
|
||||
case 5039://扔骰子
|
||||
break;
|
||||
case 5040://开通守护推送
|
||||
break;
|
||||
case 5041://发送表情
|
||||
break;
|
||||
case 5042://上传即构日志
|
||||
break;
|
||||
case 5043://公屏状态
|
||||
break;
|
||||
case 5044://开球
|
||||
break;
|
||||
case 5045://弃球
|
||||
break;
|
||||
case 5046://亮球
|
||||
break;
|
||||
case 5047://调音
|
||||
break;
|
||||
case 5050://推送
|
||||
break;
|
||||
case 5051://需求变化
|
||||
break;
|
||||
case 5054://房主模式切换
|
||||
break;
|
||||
case 5055://离开房间
|
||||
Logger.e("环信5055", message);
|
||||
break;
|
||||
case 5056://房主加入
|
||||
break;
|
||||
case 5057://房间浇水礼物推送
|
||||
break;
|
||||
case 5058://切换相亲房状态
|
||||
break;
|
||||
case 5059://相亲房礼物动画
|
||||
break;
|
||||
case 5060://房间玫瑰爱神礼物推送
|
||||
break;
|
||||
case 5061://交友房心动值变化
|
||||
Logger.e("环信5061", message);
|
||||
break;
|
||||
case 5062://交友房换麦
|
||||
Logger.e("环信5062", message);
|
||||
// sendEventList(message, RoomPitBean.class);
|
||||
break;
|
||||
case 5063://进入小黑屋
|
||||
Logger.e("环信5063", message);
|
||||
break;
|
||||
case 5064://退出小黑屋
|
||||
Logger.e("环信5064", message);
|
||||
break;
|
||||
case 5065://点击开始后进行提示弹框
|
||||
Logger.e("环信5065", message);
|
||||
break;
|
||||
case 5066://cp对数
|
||||
Logger.e("环信5066", message);
|
||||
break;
|
||||
case 5067://延迟时间
|
||||
Logger.e("环信5067", message);
|
||||
break;
|
||||
case 5068://房间内广播
|
||||
Logger.e("环信5068", message);
|
||||
break;
|
||||
case 5069://房间内换麦
|
||||
Logger.e("环信5069", message);
|
||||
break;
|
||||
case 10001: //房间红包
|
||||
break;
|
||||
case 10002: //雨开始
|
||||
break;
|
||||
case 10003: //打开红包
|
||||
break;
|
||||
case 7001: //奖池进度更新
|
||||
break;
|
||||
case 7002://cp时间到
|
||||
Logger.e("环信7002", message);
|
||||
break;
|
||||
case 5070:
|
||||
Logger.e("环信5070", message);
|
||||
break;
|
||||
}
|
||||
// 在后台线程执行发布操作
|
||||
new Handler(Looper.getMainLooper()).post(() -> {
|
||||
try {
|
||||
IMqttDeliveryToken publish = mqttAndroidClient.publish(topic, message.getBytes(), qos, false);
|
||||
publish.setActionCallback(new IMqttActionListener() {
|
||||
@Override
|
||||
public void onSuccess(IMqttToken asyncActionToken) {
|
||||
Logger.e(TAG, "发送消息", "发送成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(IMqttToken asyncActionToken, Throwable exception) {
|
||||
Logger.e(TAG, "发送消息", "发送失败: " + exception.getMessage());
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
Logger.e(TAG, "发送消息", "发送异常: " + e.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void subscribe(String topic) {
|
||||
// 在后台线程执行订阅操作
|
||||
new Handler(Looper.getMainLooper()).post(() -> {
|
||||
try {
|
||||
if (mqttAndroidClient != null && mqttAndroidClient.isConnected()) {
|
||||
IMqttToken subToken = mqttAndroidClient.subscribe(topic, qos);
|
||||
subToken.setActionCallback(new IMqttActionListener() {
|
||||
@Override
|
||||
public void onSuccess(IMqttToken asyncActionToken) {
|
||||
for (MyEmqttSubscribeListener listener : subscribeListeners) {
|
||||
if (listener != null) {
|
||||
listener.onSubscribeSuccess(topic);
|
||||
}
|
||||
}
|
||||
Logger.e(TAG, "订阅成功:" + topic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(IMqttToken asyncActionToken, Throwable exception) {
|
||||
for (MyEmqttSubscribeListener listener : subscribeListeners) {
|
||||
if (listener != null &&
|
||||
!TOPIC_BOSS.equals(topic) &&
|
||||
!TOPIC_XLH.equals(topic)) {
|
||||
listener.onSubscribeFailure();
|
||||
}
|
||||
}
|
||||
Logger.e(TAG, "订阅失败:" + topic + ", error: " + exception.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "订阅异常:" + topic, e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void cleanSubscribe(String topic) {
|
||||
// 在后台线程执行取消订阅操作
|
||||
new Handler(Looper.getMainLooper()).post(() -> {
|
||||
try {
|
||||
if (mqttAndroidClient != null && mqttAndroidClient.isConnected()) {
|
||||
IMqttToken subToken = mqttAndroidClient.unsubscribe(topic);
|
||||
subToken.setActionCallback(new IMqttActionListener() {
|
||||
@Override
|
||||
public void onSuccess(IMqttToken asyncActionToken) {
|
||||
Logger.e(TAG, "取消成功" + topic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(IMqttToken asyncActionToken, Throwable exception) {
|
||||
Logger.e(TAG, "取消失败" + topic + ", error: " + exception.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "取消订阅异常:" + topic, e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void closeConnection() {
|
||||
new Handler(Looper.getMainLooper()).post(() -> {
|
||||
try {
|
||||
if (mqttAndroidClient != null && mqttAndroidClient.isConnected()) {
|
||||
IMqttToken disconnect = mqttAndroidClient.disconnect();
|
||||
disconnect.setActionCallback(new IMqttActionListener() {
|
||||
@Override
|
||||
public void onSuccess(IMqttToken asyncActionToken) {
|
||||
Logger.e(TAG, "断开链接", "断开链接成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(IMqttToken asyncActionToken, Throwable exception) {
|
||||
Logger.e(TAG, "断开链接", "断开链接失败" + exception.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "关闭连接异常", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理资源
|
||||
*/
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
b = false;
|
||||
isServiceRunning = false;
|
||||
|
||||
try {
|
||||
// 清理资源
|
||||
if (messageExecutorService != null) {
|
||||
messageExecutorService.shutdown();
|
||||
try {
|
||||
if (!messageExecutorService.awaitTermination(5, TimeUnit.SECONDS)) {
|
||||
messageExecutorService.shutdownNow();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
messageExecutorService.shutdownNow();
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
if (mqttHandlerThread != null) {
|
||||
mqttHandlerThread.quitSafely();
|
||||
}
|
||||
|
||||
cleanSubscribe(TOPIC_BOSS);
|
||||
cleanSubscribe(TOPIC_XLH);
|
||||
if (mqttAndroidClient != null) {
|
||||
mqttAndroidClient.disconnect(); //断开连接
|
||||
mqttAndroidClient.disconnect();
|
||||
mqttAndroidClient.unregisterResources();
|
||||
mqttAndroidClient = null;
|
||||
stopForeground(true); // 停止前台服务
|
||||
}
|
||||
|
||||
// 停止前台服务
|
||||
stopForeground(true);
|
||||
Logger.e(TAG, "服务关闭", "资源释放成功");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "服务关闭异常", e);
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
|
||||
// 修改监听器管理方法
|
||||
public static void addMyEmqttMesgListener(MyEmqttMesgListener myEmqttMesgListener) {
|
||||
mMyEmqttMesgListener = myEmqttMesgListener;
|
||||
if (myEmqttMesgListener != null && !messageListeners.contains(myEmqttMesgListener)) {
|
||||
messageListeners.add(myEmqttMesgListener);
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeMyEmqttMesgListener(MyEmqttMesgListener myEmqttMesgListener) {
|
||||
messageListeners.remove(myEmqttMesgListener);
|
||||
}
|
||||
|
||||
public static void addMyEmqttConnectListener(MyEmqttConnectListener myEmqttConnectListener) {
|
||||
mMyEmqttConnectListener = myEmqttConnectListener;
|
||||
if (myEmqttConnectListener != null && !connectListeners.contains(myEmqttConnectListener)) {
|
||||
connectListeners.add(myEmqttConnectListener);
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeMyEmqttConnectListener(MyEmqttConnectListener myEmqttConnectListener) {
|
||||
connectListeners.remove(myEmqttConnectListener);
|
||||
}
|
||||
|
||||
public static void addMyEmqttSubscribeListener(MyEmqttSubscribeListener myEmqttSubscribeListener) {
|
||||
mMyEmqttSubscribeListener = myEmqttSubscribeListener;
|
||||
if (myEmqttSubscribeListener != null && !subscribeListeners.contains(myEmqttSubscribeListener)) {
|
||||
subscribeListeners.add(myEmqttSubscribeListener);
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeMyEmqttSubscribeListener(MyEmqttSubscribeListener myEmqttSubscribeListener) {
|
||||
subscribeListeners.remove(myEmqttSubscribeListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectSuccess() {
|
||||
|
||||
// 实现接口方法
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectFailure() {
|
||||
|
||||
// 实现接口方法
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageArrived(String topic, String mesg) {
|
||||
|
||||
LogUtils.e("lxj", "messageArrived:" + mesg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSubscribeSuccess(String topic) {
|
||||
|
||||
LogUtils.e("lxj", "onSubscribeSuccess:" + topic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSubscribeFailure() {
|
||||
|
||||
LogUtils.e("lxj", "onSubscribeFailure");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ public class ARouteConstants {
|
||||
public static final String USER_ALBUM_DETAIL = "/modulevocal/AlbumDetailActivity";
|
||||
public static final String CREATE_ALBUM = "/modulevocal/CreateAlbumActivity";
|
||||
public static final String ROOM_DETAILS = "/moduleroom/RoomActivity";
|
||||
public static final String ROOM_RED_RESULT = "/moduleroom/RedResultActivity";//红包结果展示页面
|
||||
public static final String UNDERAGE_ACTIVITY = "/modulevocal/UnderageActivity";
|
||||
|
||||
public static final String MY_ROOM = "/modulevocal/MyRoomActivity";
|
||||
public static final String MY_ROOM_DETAILS = "/modulevocal/RoomDetailsActivity";
|
||||
@@ -20,9 +22,9 @@ public class ARouteConstants {
|
||||
public static final String CREATED_ROOM = "/modulevocal/CreatedRoomActivity"; //创建房间
|
||||
public static final String WITHDRAWAL_ACTIVITY = "/modulevocal/WithdrawalActivity"; //提现
|
||||
public static final String REAL_NAME_ACTIVITY ="/modulevocal/RealNameActivity"; //实名认证
|
||||
public static final String REAL_NAME_ACTIVITY2 ="/app/RealNameActivity"; //实名认证
|
||||
public static final String H5 ="/moduleutil/WebViewActivity"; //网页
|
||||
public static final String GIFT_WALL ="/moduleroom/UserGiftWallFragment"; //实名认证
|
||||
public static final String REAL_NAME_ACTIVITY2 ="/modulevocal/RealNameActivity"; //实名认证
|
||||
public static final String H5 ="/moduleUtil/WebViewActivity"; //网页
|
||||
// public static final String GIFT_WALL ="/moduleroom/UserGiftWallFragment"; //实名认证
|
||||
public static final String RECHARGE_ACTIVITY ="/modulevocal/RechargeActivity"; //实名认证
|
||||
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ import java.util.Map;
|
||||
*/
|
||||
public class ColorManager {
|
||||
private static ColorManager instance;
|
||||
private String primaryColor = "#6C49E4"; // 默认主题色
|
||||
private String buttonColor = "#FFFFFF"; // 默认按钮色
|
||||
private String primaryColor = "#3ABC6D"; // 默认主题色
|
||||
private String buttonColor = "#6D6D6D"; // 默认按钮色
|
||||
|
||||
// 监听器列表,用于通知颜色变化
|
||||
private List<ColorChangeListener> listeners = new ArrayList<>();
|
||||
@@ -71,7 +71,7 @@ public class ColorManager {
|
||||
try {
|
||||
return Color.parseColor(primaryColor);
|
||||
} catch (Exception e) {
|
||||
return Color.parseColor("#6C49E4"); // 默认颜色
|
||||
return Color.parseColor("#3ABC6D"); // 默认颜色
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ public class ColorManager {
|
||||
try {
|
||||
return Color.parseColor(buttonColor);
|
||||
} catch (Exception e) {
|
||||
return Color.parseColor("#FFFFFF"); // 默认颜色
|
||||
return Color.parseColor("#6D6D6D"); // 默认颜色
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -150,25 +150,30 @@ public class ImageUtils {
|
||||
return;
|
||||
}
|
||||
|
||||
// 没有缓存,正常加载
|
||||
SVGAParser parser = SVGAParser.Companion.shareParser();
|
||||
parser.decodeFromInputStream(mImageView.getContext().getResources().openRawResource(resourceId), "", new SVGAParser.ParseCompletion() {
|
||||
@Override
|
||||
public void onComplete(@NotNull SVGAVideoEntity svgaVideoEntity) {
|
||||
if (mImageView != null) {
|
||||
// 缓存实体
|
||||
svgaCache.put(resourceId, svgaVideoEntity);
|
||||
SVGADrawable svgaDrawable = new SVGADrawable(svgaVideoEntity);
|
||||
mImageView.setImageDrawable(svgaDrawable);
|
||||
mImageView.startAnimation();
|
||||
try {
|
||||
// 没有缓存,正常加载
|
||||
SVGAParser parser = SVGAParser.Companion.shareParser();
|
||||
InputStream inputStream = mImageView.getContext().getResources().openRawResource(resourceId);
|
||||
parser.decodeFromAssets("heart_line_31.svga", new SVGAParser.ParseCompletion() {
|
||||
@Override
|
||||
public void onComplete(@NotNull SVGAVideoEntity svgaVideoEntity) {
|
||||
if (mImageView != null) {
|
||||
// 缓存实体
|
||||
svgaCache.put(resourceId, svgaVideoEntity);
|
||||
SVGADrawable svgaDrawable = new SVGADrawable(svgaVideoEntity);
|
||||
mImageView.setImageDrawable(svgaDrawable);
|
||||
mImageView.startAnimation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
Logger.e("loadDecorationAvatar2 error");
|
||||
}
|
||||
}, true);
|
||||
@Override
|
||||
public void onError() {
|
||||
Logger.e("loadDecorationAvatar2 error, resourceId: " + resourceId);
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
Logger.e("loadDecorationAvatar2 exception, resourceId: " + resourceId, e);
|
||||
}
|
||||
} else {
|
||||
Logger.e("Resource ID is 0 or invalid");
|
||||
}
|
||||
@@ -176,6 +181,7 @@ public class ImageUtils {
|
||||
|
||||
|
||||
|
||||
|
||||
public static void loadHeadCC(String path, ImageView mImageView) {
|
||||
Glide.with(mImageView).load(path).error(R.mipmap.default_avatar).placeholder(R.mipmap.default_avatar).centerCrop().diskCacheStrategy(DiskCacheStrategy.ALL).into(mImageView);
|
||||
|
||||
@@ -195,6 +201,7 @@ public class ImageUtils {
|
||||
|
||||
public static void loadRes(int path, ImageView mImageView) {
|
||||
Glide.with(mImageView).load(path).diskCacheStrategy(DiskCacheStrategy.ALL).into(mImageView);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -561,5 +568,8 @@ public class ImageUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void clearDiskCache(Context context){
|
||||
Glide.get(context).clearDiskCache();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,4 +30,6 @@ public class SPConstants {
|
||||
public static final String REAL_NAME = "realName";//是否实名认证
|
||||
|
||||
public static final String USER_INFO = "userInfo";
|
||||
|
||||
public static final String FLOATING_SCREEN = "floatingScreen";
|
||||
}
|
||||
|
||||
@@ -123,6 +123,8 @@ public class SpUtil {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 保存一个布尔值
|
||||
*/
|
||||
@@ -251,6 +253,14 @@ public class SpUtil {
|
||||
SPUtils.getInstance(SPConstants.PREFERENCE_NAME).put("musicVolume", musicVolume, true);
|
||||
}
|
||||
|
||||
public static void setUnderagePassword(String password){
|
||||
SPUtils.getInstance(SPConstants.PREFERENCE_NAME).put("underagePassword", password, true);
|
||||
}
|
||||
|
||||
public static String getUnderagePassword(){
|
||||
return SPUtils.getInstance(SPConstants.PREFERENCE_NAME).getString("underagePassword");
|
||||
}
|
||||
|
||||
public static Integer getMusicVolume() {
|
||||
return SPUtils.getInstance(SPConstants.PREFERENCE_NAME).getInt("musicVolume", 50);
|
||||
}
|
||||
@@ -359,6 +369,14 @@ public class SpUtil {
|
||||
return SPUtils.getInstance(SPConstants.PREFERENCE_NAME).getInt(SPConstants.OPEN_EFFECT, 1);
|
||||
}
|
||||
|
||||
public static void setFloatingScreen(int i){
|
||||
SPUtils.getInstance(SPConstants.PREFERENCE_NAME).put(SPConstants.FLOATING_SCREEN, i);
|
||||
}
|
||||
|
||||
public static int getFloatingScreen(){
|
||||
return SPUtils.getInstance(SPConstants.PREFERENCE_NAME).getInt(SPConstants.FLOATING_SCREEN, 1);
|
||||
}
|
||||
|
||||
//设置耳返
|
||||
public static void setAuricularBack(int i) {
|
||||
SPUtils.getInstance(SPConstants.PREFERENCE_NAME).put(SPConstants.OPEN_AU_BACK, i);
|
||||
|
||||
@@ -122,16 +122,23 @@ public class SystemUtils {
|
||||
return headers;
|
||||
}
|
||||
|
||||
private static String encodeHeadInfo( String headInfo ) {
|
||||
private static String encodeHeadInfo(String headInfo) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
for (int i = 0, length = headInfo.length(); i < length; i++) {
|
||||
char c = headInfo.charAt(i);
|
||||
if (c <= '\u001f' || c >= '\u007f') {
|
||||
stringBuffer.append( String.format ("\\u%04x", (int)c) );
|
||||
stringBuffer.append(String.format("\\u%04x", (int) c));
|
||||
} else {
|
||||
stringBuffer.append(c);
|
||||
}
|
||||
}
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
public static int getWidth(int value) {
|
||||
// 获取屏幕宽度
|
||||
int screenWidth = com.blankj.utilcode.util.ScreenUtils.getScreenWidth();
|
||||
// 按照公式计算:value / 375 * screenWidth
|
||||
return (int) ((value / 375.0) * screenWidth);
|
||||
}
|
||||
}
|
||||
@@ -2,33 +2,33 @@ package com.xscm.moduleutil.utils.config;
|
||||
|
||||
public enum EnvironmentEnum {
|
||||
PRODUCTION(//生产环境
|
||||
"http://chat.qxmier.com/",
|
||||
"6rdWuz058oq5OahdbFiGEybUcdahd12J83L34Uc7MrPIrxtFG+rXiwDvRcqNvjwbClbbmvMrmxKVkIysFByBsl0Qe9kqd2w8T/nhK5G6eXXlk2V9AjYCieIU+jRnjZBB+Cfechr6rCGJ2aeBARIsXcRPW7wm9WFK9euh5T+v6Pyte68yNaNdcYCll3+U4/uCEog7HygCnMIbAU+kqoPdmn2H+51YOHW+VsnsHd4w1+I3f8Tt0xLIXGM4GWnQueZ5GR46GTWiSYMy8dCIh9SPIMRyC91GosVcfGPMJSdcXqc=",
|
||||
"https://oss-cn-hangzhou.aliyuncs.com/",
|
||||
"LTAI5tJ2UYfFNF7K3F4e1siv",
|
||||
"DhpCS82gaigZljYqsWsUWUAZ20dREz",
|
||||
"qx-yusheng",
|
||||
"https://qx-yusheng.oss-cn-hangzhou.aliyuncs.com/",
|
||||
"https://vespa.qxyushen.top/",
|
||||
"KvNmqZc+VMzO4CfGMd5zmG6w6OFwpFO/19TwXUWfHDOBgmnl9DgIuE+kbrjNNnxqhtP3pH7bBrnSaSeFtunr72q6sgpLsfuswcUroMvz2slaTBcNzCaLi+GSnM3gB/GdO47mwLdk+iYBTvPUOCIuT608Z29z09w+vPeUDoMCHJBGXu6uh7Nj6PtV1dfGoUvByk1ZF0WYVjIqKDcb3tXY4jonFh3XAWhzMy8xKwN6F2nuK2IcdIwaSPsvuMZmhatP6f9kOE+vnfweyCHS3RxiG474WIoZGJM8omrl3/pOVqE=",
|
||||
"https://oss-cn-beijing.aliyuncs.com/",
|
||||
"LTAI5tKgrfcFQxH46ZwWYgFW",
|
||||
"ZOjTqAJmUL563EKFKySrUwAHtx4hKt",
|
||||
"midi01",
|
||||
"https://midi01.oss-cn-beijing.aliyuncs.com/",
|
||||
"wxc7681513be9f926b",
|
||||
1600096860,
|
||||
"4a521d6f1c6343998b1c8fd425dea02a",
|
||||
"3e8f3add448d4692bc1d04c75ffe801b",
|
||||
"tcp://81.70.45.221",
|
||||
"https://vespa.qxmier.com"),
|
||||
"https://vespa.qxyushen.top/h5"),
|
||||
TEST(//测试环境
|
||||
"http://tmd.qixing2.top/",
|
||||
"http://tmd.xscmmidi.site/",
|
||||
"6rdWuz058oq5OahdbFiGEybUcdahd12J83L34Uc7MrPIrxtFG+rXiwDvRcqNvjwbClbbmvMrmxKVkIysFByBsl0Qe9kqd2w8T/nhK5G6eXXlk2V9AjYCieIU+jRnjZBB+Cfechr6rCGJ2aeBARIsXcRPW7wm9WFK9euh5T+v6Pyte68yNaNdcYCll3+U4/uCEog7HygCnMIbAU+kqoPdmn2H+51YOHW+VsnsHd4w1+I3f8Tt0xLIXGM4GWnQueZ5GR46GTWiSYMy8dCIh9SPIMRyC91GosVcfGPMJSdcXqc=",
|
||||
"https://oss-cn-hangzhou.aliyuncs.com/",
|
||||
"LTAI5tJ2UYfFNF7K3F4e1siv",
|
||||
"DhpCS82gaigZljYqsWsUWUAZ20dREz",
|
||||
"qx-yusheng",
|
||||
"https://qx-yusheng.oss-cn-hangzhou.aliyuncs.com/",
|
||||
"https://oss-cn-beijing.aliyuncs.com/",
|
||||
"LTAI5tKgrfcFQxH46ZwWYgFW",
|
||||
"ZOjTqAJmUL563EKFKySrUwAHtx4hKt",
|
||||
"midi01",
|
||||
"https://midi01.oss-cn-beijing.aliyuncs.com/",
|
||||
"wxc7681513be9f926b",
|
||||
1600096890,
|
||||
"05b406b4541e413887d8d2bf9be8642c",
|
||||
"tcp://47.120.21.132",
|
||||
"https://chatvespa.qxmier.com");
|
||||
"02f7339ec98947deaeab173599891932",
|
||||
"tcp://1.13.181.248",
|
||||
"https://tmd.xscmmidi.site/h5");
|
||||
|
||||
private final String serverUrl;
|
||||
private final String serverUrl;//服务器地址
|
||||
private final String ALI_AUTH_KEY;//阿里云授权key
|
||||
|
||||
private final String ossEndPoint;
|
||||
@@ -37,15 +37,15 @@ public enum EnvironmentEnum {
|
||||
private final String ossBucketName;
|
||||
private final String ossBaseUrl;
|
||||
|
||||
private final String wxAppId;
|
||||
private final String wxAppId;//微信appId
|
||||
|
||||
private final int sdkAppId;//腾讯云sdkAppId im
|
||||
|
||||
private final String swSdkAppId;
|
||||
private final String swSdkAppId;//声网sdkAppId
|
||||
|
||||
private final String mqttUrl;
|
||||
private final String mqttUrl;//MQTT服务器地址
|
||||
|
||||
private final String H5Url;
|
||||
private final String H5Url;//h5地址
|
||||
|
||||
EnvironmentEnum(String serverUrl, String ALI_AUTH_KEY, String ossEndPoint, String ossaAcessKeyId,
|
||||
String ossAccessKeySecret, String ossBucketName, String ossBaseUrl, String wxAppId,
|
||||
|
||||
@@ -3,6 +3,9 @@ package com.xscm.moduleutil.utils.config;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import com.blankj.utilcode.BuildConfig;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
|
||||
/**
|
||||
*@author
|
||||
*@data
|
||||
@@ -25,13 +28,34 @@ public class EnvironmentPrefs {
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
// 获取当前选择的环境,默认为 PRODUCTION
|
||||
// 获取当前选择的环境,默认根据构建变体决定
|
||||
public EnvironmentEnum getSelectedEnvironment() {
|
||||
String envName = sharedPreferences.getString(KEY_ENV, EnvironmentEnum.TEST.name());
|
||||
// // 检查是否是debug版本(开发版本)
|
||||
// if (BuildConfig.DEBUG) {
|
||||
// return EnvironmentEnum.TEST;
|
||||
// }
|
||||
//
|
||||
// // 检查flavor类型
|
||||
// if ("dev".equals(BuildConfig.FLAVOR)) {
|
||||
// return EnvironmentEnum.TEST;
|
||||
// }
|
||||
//
|
||||
// // 检查包名判断是否为开发版本
|
||||
// try {
|
||||
// String packageName = CommonAppContext.getInstance().getPackageName();
|
||||
// if (packageName.contains(".test") || packageName.contains(".dev")) {
|
||||
// return EnvironmentEnum.TEST;
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// // 忽略异常
|
||||
// }
|
||||
|
||||
// 默认使用生产环境
|
||||
String envName = sharedPreferences.getString(KEY_ENV, EnvironmentEnum.PRODUCTION.name());
|
||||
try {
|
||||
return EnvironmentEnum.valueOf(envName);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return EnvironmentEnum.TEST; // 出错时默认返回生产环境
|
||||
return EnvironmentEnum.PRODUCTION; // 出错时默认返回生产环境
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@ public class OSSOperUtils {
|
||||
private static final String accessKeySecret = CommonAppContext.getInstance().getCurrentEnvironment().getOssAccessKeySecret();
|
||||
private static final String bucketName = CommonAppContext.getInstance().getCurrentEnvironment().getOssBucketName();
|
||||
public static final String AliYunOSSURLFile = CommonAppContext.getInstance().getCurrentEnvironment().getOssBaseUrl();
|
||||
public static final String img = "img/";
|
||||
public static final String img = "images/android_images/";
|
||||
public static final String video = "video/";
|
||||
public static final String audio = "audio/";
|
||||
|
||||
@@ -68,13 +68,13 @@ public class OSSOperUtils {
|
||||
if (file.getName().contains(".")) {
|
||||
suffix = file.getName().substring(file.getName().lastIndexOf("."));
|
||||
}
|
||||
if (type == 0) {
|
||||
// if (type == 0) {
|
||||
return img + fileMD5 + suffix;
|
||||
} else if (type == 1) {
|
||||
return audio + fileMD5 + suffix;
|
||||
} else {
|
||||
return video + fileMD5 + suffix;
|
||||
}
|
||||
// } else if (type == 1) {
|
||||
// return audio + fileMD5 + suffix;
|
||||
// } else {
|
||||
// return video + fileMD5 + suffix;
|
||||
// }
|
||||
}
|
||||
|
||||
public static OSSOperUtils newInstance() {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -13,8 +13,10 @@ import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.opensource.svgaplayer.SVGAImageView;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.base.RoomRollModel;
|
||||
import com.xscm.moduleutil.bean.FaceBean;
|
||||
import com.xscm.moduleutil.bean.RoomMessageEvent;
|
||||
import com.xscm.moduleutil.bean.UserOnlineStatusBean;
|
||||
import com.xscm.moduleutil.bean.room.ClosePhone;
|
||||
import com.xscm.moduleutil.bean.room.RoomClearCardiacAllModel;
|
||||
@@ -27,7 +29,6 @@ import com.xscm.moduleutil.bean.room.RoomPitBean;
|
||||
import com.xscm.moduleutil.bean.room.RoomWheatModel;
|
||||
import com.xscm.moduleutil.event.RoomBanWheatEvent;
|
||||
import com.xscm.moduleutil.event.RoomBeckoningEvent;
|
||||
import com.xscm.moduleutil.event.RoomCardiacValueChangedEvent;
|
||||
import com.xscm.moduleutil.event.RoomFaceEvent;
|
||||
import com.xscm.moduleutil.interfaces.IBaseWheat;
|
||||
import com.xscm.moduleutil.interfaces.SoundLevelUpdateListener;
|
||||
@@ -39,6 +40,8 @@ import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class BaseWheatView extends ConstraintLayout implements IBaseWheat {
|
||||
public ImageView mRiv;
|
||||
public ImageView mIvGift;
|
||||
@@ -100,7 +103,7 @@ public abstract class BaseWheatView extends ConstraintLayout implements IBaseWhe
|
||||
tvTime = findViewById(R.id.tv_time);
|
||||
tv_time_pk = findViewById(R.id.tv_time_pk);
|
||||
mTvNo = findViewById(R.id.tv_no);
|
||||
iv_on_line = findViewById(R.id.iv_online);
|
||||
iv_on_line = findViewById(R.id.iv_online);/**/
|
||||
iv_tag_type = findViewById(R.id.iv_tag_type);
|
||||
tv_zhul=findViewById(R.id.tv_zhul);
|
||||
setClipChildren(false);
|
||||
@@ -108,6 +111,9 @@ public abstract class BaseWheatView extends ConstraintLayout implements IBaseWhe
|
||||
oX = mIvGift.getX();
|
||||
oY = mIvGift.getY();
|
||||
initPit(context, attrs);
|
||||
if (!EventBus.getDefault().isRegistered( this)){
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void initPit(Context context, AttributeSet attrs);
|
||||
@@ -143,6 +149,8 @@ public abstract class BaseWheatView extends ConstraintLayout implements IBaseWhe
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 设置麦位数据
|
||||
*
|
||||
@@ -159,7 +167,25 @@ public abstract class BaseWheatView extends ConstraintLayout implements IBaseWhe
|
||||
countDownTime(bean.getCount_down());
|
||||
|
||||
setCardiac(pitBean.getCharm(), getTzbl());
|
||||
|
||||
|
||||
if (bean.getUser_id()!=null && !bean.getUser_id().equals("0") && !bean.getUser_id().isEmpty()) {
|
||||
if (CommonAppContext.getInstance().getOnlineMap()!=null&&CommonAppContext.getInstance().getOnlineMap().get(bean.getUser_id())!=null) {
|
||||
iv_on_line.setVisibility(CommonAppContext.getInstance().getOnlineMap().get(bean.getUser_id()) == 1 ? GONE : VISIBLE);
|
||||
}else {
|
||||
iv_on_line.setVisibility(GONE);
|
||||
}
|
||||
}else {
|
||||
iv_on_line.setVisibility(GONE);
|
||||
}
|
||||
|
||||
setPitData(bean);
|
||||
|
||||
// if (bean.getIs_online() == 2 && bean.getUser_id()!=null && !bean.getUser_id().equals("0") && !bean.getUser_id().isEmpty()){
|
||||
// iv_on_line.setVisibility(VISIBLE);
|
||||
// }else {
|
||||
// iv_on_line.setVisibility(GONE);
|
||||
// }
|
||||
// if (bean.getIs_online() == 0 &&bean.getUser_id() != null && !bean.getUser_id().equals("0") && !bean.getUser_id().isEmpty()) {
|
||||
// iv_on_line.setVisibility(VISIBLE);
|
||||
// } else {
|
||||
@@ -233,28 +259,23 @@ public abstract class BaseWheatView extends ConstraintLayout implements IBaseWhe
|
||||
if (userId.equals(pitBean.getUser_id())) {
|
||||
if (soundLevel == 0) {
|
||||
mIvRipple.post(() -> {
|
||||
mIvRipple.stopAnimation();
|
||||
mIvRipple.stopAnimation(true);
|
||||
CommonAppContext.getInstance().onlineMap.put(pitBean.getUser_id(),1);
|
||||
mIvRipple.setVisibility(GONE);
|
||||
});
|
||||
mIvRipple.setVisibility(GONE);
|
||||
} else {
|
||||
mIvRipple.setVisibility(VISIBLE);
|
||||
mIvRipple.post(() -> {
|
||||
mIvRipple.startAnimation();
|
||||
// mIvRipple.setSource(getResources().getResourceName(R.raw.ripple3695), 2);
|
||||
if (!mIvRipple.isAnimating()) {
|
||||
mIvRipple.startAnimation();
|
||||
CommonAppContext.getInstance().onlineMap.put(pitBean.getUser_id(),1);
|
||||
iv_on_line.setVisibility(GONE);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
// if (pitBean.getUser_id().equals(SpUtil.getUserId()) && closePhone) {
|
||||
// mIvRipple.post(() -> {
|
||||
// mIvRipple.setVisibility(GONE);
|
||||
// });
|
||||
// }
|
||||
}
|
||||
// else {
|
||||
// mIvRipple.post(() -> {
|
||||
// mIvRipple.setVisibility(GONE);
|
||||
// });
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -267,8 +288,11 @@ public abstract class BaseWheatView extends ConstraintLayout implements IBaseWhe
|
||||
} else {
|
||||
mIvRipple.setVisibility(VISIBLE);
|
||||
mIvRipple.post(() -> {
|
||||
mIvRipple.startAnimation();
|
||||
// mIvRipple.setSource(getResources().getResourceName(R.raw.ripple3695), 2);
|
||||
if (!mIvRipple.isAnimating()) {
|
||||
mIvRipple.startAnimation();
|
||||
CommonAppContext.getInstance().onlineMap.put(pitBean.getUser_id(),1);
|
||||
iv_on_line.setVisibility(GONE);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
@@ -278,29 +302,32 @@ public abstract class BaseWheatView extends ConstraintLayout implements IBaseWhe
|
||||
public void userJoined(int userId, int elapsd) {
|
||||
if (pitBean != null && pitBean.getUser_id() != null && !pitBean.getUser_id().equals("0")) {
|
||||
if (pitBean.getUser_id().equals(userId + "")) {
|
||||
iv_on_line.setVisibility(GONE);
|
||||
// iv_on_line.setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void userOffline(int userId, int reason) {
|
||||
if (pitBean != null && pitBean.getUser_id() != null && !pitBean.getUser_id().equals("0")) {
|
||||
if (pitBean.getUser_id().equals(userId + "")) {
|
||||
iv_on_line.setVisibility(VISIBLE);
|
||||
}
|
||||
}else if (pitBean.getUser_id()==null || pitBean.getUser_id().equals("0") || pitBean.getUser_id().equals("")){
|
||||
iv_on_line.setVisibility(GONE);
|
||||
}
|
||||
// if (pitBean != null && pitBean.getUser_id() != null && !pitBean.getUser_id().equals("0")) {
|
||||
// if (pitBean.getUser_id().equals(userId + "")) {
|
||||
//// iv_on_line.setVisibility(VISIBLE);
|
||||
// }
|
||||
// }else if (pitBean.getUser_id()==null || pitBean.getUser_id().equals("0") || pitBean.getUser_id().equals("")){
|
||||
//// iv_on_line.setVisibility(GONE);
|
||||
// }
|
||||
}
|
||||
|
||||
});
|
||||
if (pitBean.getUser_id()==null || pitBean.getUser_id().equals("0") || pitBean.getUser_id().equals("") ){
|
||||
iv_on_line.setVisibility(GONE);
|
||||
// iv_on_line.setVisibility(GONE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setCharm(String charm){
|
||||
mCharmView.setSex(pitBean.getSex(), pitBean.getUser_id(), charm, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始倒计时
|
||||
@@ -346,20 +373,27 @@ public abstract class BaseWheatView extends ConstraintLayout implements IBaseWhe
|
||||
}
|
||||
|
||||
// @Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void setOnlineStatus() {
|
||||
// if (pitBean!=null) {
|
||||
// if (pitBean.getUser_id() != null && !pitBean.getUser_id().equals("0") && !pitBean.getUser_id().isEmpty()) {
|
||||
// if (pitBean.getUser_id().equals(isOnline.getUser_id())) {
|
||||
// if (isOnline.getIs_online() == 1) {
|
||||
// iv_on_line.setVisibility(GONE);
|
||||
// } else {
|
||||
// iv_on_line.setVisibility(VISIBLE);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
public void setOnlineStatus(UserOnlineStatusBean isOnline) {
|
||||
// iv_on_line.setVisibility(isOnline ? GONE : VISIBLE);
|
||||
|
||||
if (pitBean.getUser_id() != null && !pitBean.getUser_id().equals("0") && !pitBean.getUser_id().isEmpty()) {
|
||||
//// for (UserOnlineStatusBean userOnlineStatus : userOnlineStatusBean) {
|
||||
if (pitBean.getUser_id().equals(isOnline.getUser_id())) {
|
||||
if (isOnline.getIs_online() == 1) {
|
||||
iv_on_line.setVisibility(GONE);
|
||||
} else {
|
||||
iv_on_line.setVisibility(VISIBLE);
|
||||
}
|
||||
//// }
|
||||
if (pitBean.getUser_id()!=null && !pitBean.getUser_id().equals("0") && !pitBean.getUser_id().isEmpty()) {
|
||||
if (CommonAppContext.getInstance().getOnlineMap()!=null&&CommonAppContext.getInstance().getOnlineMap().get(pitBean.getUser_id())!=null) {
|
||||
iv_on_line.setVisibility(CommonAppContext.getInstance().getOnlineMap().get(pitBean.getUser_id()) == 1 ? GONE : VISIBLE);
|
||||
}else {
|
||||
iv_on_line.setVisibility(GONE);
|
||||
}
|
||||
}else {
|
||||
iv_on_line.setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -450,7 +484,7 @@ public abstract class BaseWheatView extends ConstraintLayout implements IBaseWhe
|
||||
// mCharmView.setSex(pitBean.getSex(), pitBean.getUser_id(), pitBean.getXin_dong(), false);
|
||||
// }
|
||||
// }
|
||||
EventBus.getDefault().post(new RoomCardiacValueChangedEvent(pitNumber, pitBean.getCharm()));
|
||||
// EventBus.getDefault().post(new RoomCardiacValueChangedEvent(pitNumber, pitBean.getCharm()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -462,7 +496,7 @@ public abstract class BaseWheatView extends ConstraintLayout implements IBaseWhe
|
||||
if (mCharmView != null) {
|
||||
pitBean.setCharm("0");
|
||||
mCharmView.setSex(pitBean.getSex(), pitBean.getUser_id(), pitBean.getCharm(), true);
|
||||
EventBus.getDefault().post(new RoomCardiacValueChangedEvent(pitNumber, pitBean.getCharm()));
|
||||
// EventBus.getDefault().post(new RoomCardiacValueChangedEvent(pitNumber, pitBean.getCharm()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -506,7 +540,7 @@ public abstract class BaseWheatView extends ConstraintLayout implements IBaseWhe
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
@Override
|
||||
public void subscribeMessages(RoomBeckoningEvent roomBeckoningEvent) {
|
||||
if (roomId.equals(roomBeckoningEvent.getRoomId())) {
|
||||
if (roomId != null && roomId.equals(roomBeckoningEvent.getRoomId())) {
|
||||
mCharmView.setVisibility(roomBeckoningEvent.isOpen() ? VISIBLE : INVISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,122 +0,0 @@
|
||||
package com.xscm.moduleutil.widget
|
||||
|
||||
|
||||
import android.graphics.SurfaceTexture
|
||||
import android.opengl.GLES20
|
||||
import android.opengl.Matrix
|
||||
|
||||
class ChannelSplitRenderer {
|
||||
|
||||
private val vertexShaderCode = """
|
||||
attribute vec4 aPosition;
|
||||
attribute vec2 aTexCoord;
|
||||
varying vec2 vTexCoord;
|
||||
void main() {
|
||||
gl_Position = aPosition;
|
||||
vTexCoord = aTexCoord;
|
||||
}
|
||||
"""
|
||||
|
||||
private val fragmentShaderCode = """
|
||||
precision mediump float;
|
||||
uniform sampler2D uTexture;
|
||||
varying vec2 vTexCoord;
|
||||
void main() {
|
||||
// 只使用左半部分作为最终颜色
|
||||
vec2 leftCoord = vec2(vTexCoord.x * 0.5, vTexCoord.y);
|
||||
vec4 color = texture2D(uTexture, leftCoord);
|
||||
|
||||
// 设置 alpha 为 1.0 表示完全不透明,或根据需求设为 0.0 表示全透明
|
||||
gl_FragColor = vec4(color.rgb, 0.0); // 左通道颜色 + 不透明
|
||||
}"""
|
||||
|
||||
private var program = 0
|
||||
private var positionHandle = 0
|
||||
private var texCoordHandle = 0
|
||||
private var textureHandle = 0
|
||||
private val projectionMatrix = FloatArray(16)
|
||||
private val modelMatrix = FloatArray(16)
|
||||
|
||||
fun onSurfaceCreated(surface: SurfaceTexture, width: Int, height: Int) {
|
||||
// 初始化着色器
|
||||
val vertexShader = ShaderUtils.loadShader(GLES20.GL_VERTEX_SHADER, vertexShaderCode)
|
||||
val fragmentShader = ShaderUtils.loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentShaderCode)
|
||||
|
||||
program = GLES20.glCreateProgram().also {
|
||||
GLES20.glAttachShader(it, vertexShader)
|
||||
GLES20.glAttachShader(it, fragmentShader)
|
||||
GLES20.glLinkProgram(it)
|
||||
}
|
||||
|
||||
positionHandle = GLES20.glGetAttribLocation(program, "aPosition")
|
||||
texCoordHandle = GLES20.glGetAttribLocation(program, "aTexCoord")
|
||||
textureHandle = GLES20.glGetUniformLocation(program, "uTexture")
|
||||
|
||||
// 初始化矩阵
|
||||
Matrix.setIdentityM(projectionMatrix, 0)
|
||||
Matrix.setIdentityM(modelMatrix, 0)
|
||||
|
||||
GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f)
|
||||
GLES20.glEnable(GLES20.GL_BLEND)
|
||||
GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA)
|
||||
}
|
||||
|
||||
fun onSurfaceChanged(width: Int, height: Int) {
|
||||
GLES20.glViewport(0, 0, width, height)
|
||||
}
|
||||
|
||||
fun onDrawFrame(textureId: Int) {
|
||||
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT)
|
||||
GLES20.glUseProgram(program)
|
||||
|
||||
// 定义顶点坐标(全屏)
|
||||
val vertices = floatArrayOf(
|
||||
-1.0f, -1.0f, 0.0f,
|
||||
1.0f, -1.0f, 0.0f,
|
||||
-1.0f, 1.0f, 0.0f,
|
||||
1.0f, 1.0f, 0.0f
|
||||
)
|
||||
|
||||
// 修改纹理坐标,只映射左半部分视频内容到左侧屏幕
|
||||
val texCoords = floatArrayOf(
|
||||
0.0f, 1.0f, // 左下角
|
||||
0.5f, 1.0f, // 右下角(对应视频中间)
|
||||
0.0f, 0.0f, // 左上角
|
||||
0.5f, 0.0f // 右上角
|
||||
)
|
||||
|
||||
val vertexBuffer = ShaderUtils.createFloatBuffer(vertices)
|
||||
val texBuffer = ShaderUtils.createFloatBuffer(texCoords)
|
||||
|
||||
GLES20.glEnableVertexAttribArray(positionHandle)
|
||||
GLES20.glVertexAttribPointer(
|
||||
positionHandle, 3,
|
||||
GLES20.GL_FLOAT, false,
|
||||
0, vertexBuffer
|
||||
)
|
||||
|
||||
GLES20.glEnableVertexAttribArray(texCoordHandle)
|
||||
GLES20.glVertexAttribPointer(
|
||||
texCoordHandle, 2,
|
||||
GLES20.GL_FLOAT, false,
|
||||
0, texBuffer
|
||||
)
|
||||
|
||||
// 绑定纹理
|
||||
GLES20.glActiveTexture(GLES20.GL_TEXTURE0)
|
||||
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureId)
|
||||
GLES20.glUniform1i(textureHandle, 0)
|
||||
|
||||
// 绘制
|
||||
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4)
|
||||
|
||||
// 清理
|
||||
GLES20.glDisableVertexAttribArray(positionHandle)
|
||||
GLES20.glDisableVertexAttribArray(texCoordHandle)
|
||||
}
|
||||
|
||||
|
||||
fun release() {
|
||||
GLES20.glDeleteProgram(program)
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ public class ClearEditText extends AppCompatEditText implements View.OnFocusChan
|
||||
//获取EditText的DrawableRight,假如没有设置我们就使用默认的图片
|
||||
mClearDrawable = getCompoundDrawables()[2];
|
||||
if (mClearDrawable == null) {
|
||||
mClearDrawable = getResources().getDrawable(R.mipmap.common_et_clear_icon);
|
||||
mClearDrawable = getResources().getDrawable(R.mipmap.index_icon_close);
|
||||
}
|
||||
mClearDrawable.setBounds(0, 0, mClearDrawable.getIntrinsicWidth(),
|
||||
mClearDrawable.getIntrinsicHeight());
|
||||
|
||||
@@ -248,6 +248,7 @@ public class Constants {
|
||||
public static final String GET_USER_HOME_ZONE = "/api/User/user_home_zone";//获取用户动态
|
||||
public static final String GET_LIKE_LIST = "/api/UserZone/like_list";//获取点赞列表
|
||||
public static final String POST_GZ = "/api/User/follow";//关注、回关、取关
|
||||
public static final String POST_FOLLOW_ROOM = "/api/User/follow_room";//收藏
|
||||
public static final String GET_ALBUM_DETAIL = "/api/User/get_album_detail";//相册详情
|
||||
public static final String UP_ALBUM = "/api/User/add_album_content";//添加相册图片
|
||||
public static final String MOVE_ALBUM = "/api/User/move_album_images";//移动相册图片
|
||||
@@ -269,6 +270,12 @@ public class Constants {
|
||||
public static final String GET_ROOM_TYPE = "/api/Index/room_type_list";//房间分类列表
|
||||
public static final String GET_GIVE_GIFT = "/api/Gift/chat_gift_send";//聊天送礼物
|
||||
public static final String GET_WALLET = "/api/UserWallet/wallet";//钱包
|
||||
public static final String REDPACKET_CREATE = "/api/Redpacket/create";//创建红包
|
||||
public static final String ROOM_REDPACKET = "/api/Redpacket/roomRedPackets";//红包列表
|
||||
|
||||
public static final String GET_REDPACKET_DETAIL = "/api/Redpacket/detail";//红包详情
|
||||
public static final String POST_GRAB = "/api/Redpacket/grab";//抢红包
|
||||
|
||||
public static final String GET_ROOM_GIFT = "/api/Room/room_give_gift";//直播间送礼
|
||||
public static final String GET_ROOM_USER = "/api/Room/room_user_home";//房间内点击头像
|
||||
public static final String APPLY_PIT = "/api/RoomPit/apply_pit";//申请上麦
|
||||
@@ -294,6 +301,7 @@ public class Constants {
|
||||
public static final String CHANGE_SONG = "/api/RoomSong/change_song";//切歌
|
||||
public static final String POST_HOST_LIST = "/api/Room/host_list";//主持人、管理员列表
|
||||
public static final String POST_SEARCH = "/api/Search/search";//搜索, type:1用户,2房间,3公会
|
||||
public static final String POST_SEARCH_ALL = "/api/Search/search_list";//搜索, 全部搜索
|
||||
public static final String SET_PRESIDED_RATIO = "/api/Room/set_host_profit";//设置主持人收益
|
||||
public static final String GET_PRESIDED_RATIO = "/api/Room/set_host";//操作主持、管理,type:1主持。2管理 is_add:1添加,2删除
|
||||
public static final String POST_ROOM_HOST_PIT = "/api/RoomPit/host_user_pit";//抱麦/踢麦 type:1抱麦,2踢麦 当在在线列表中,点击抱麦的时候,是没有
|
||||
@@ -356,6 +364,7 @@ public class Constants {
|
||||
public static final String GET_APP_UPDATE = "/api/Version/get_app_version";//版本更新
|
||||
public static final String POST_CLEAR_USER_CHARM = "/api/Room/clear_user_charm";//清除魅力值
|
||||
public static final String POST_MESSAGE_LIST = "/api/UserMessage/get_user_message_list";//消息列表
|
||||
public static final String POST_BIND_DETAIL = "/api/Bind/bind_detail";//绑定详情
|
||||
public static final String POST_USER_WALL = "/api/User/user_gift_wall";//礼物墙
|
||||
public static final String POST_USER_OLINE_STATUS = "/api/Room/user_online_status";//用户在线状态
|
||||
public static final String DELETE_ROOM_HISTORY = "/api/Room/delete_room_history";//删除历史足迹
|
||||
@@ -365,12 +374,40 @@ public class Constants {
|
||||
public static final String POST_DELETE_RELATION_CARD = "/api/Room/delete_relation_card";//删除关系
|
||||
public static final String GET_FIRST_CHARGE = "/api/Activities/first_charge_gift_permission";//首充好礼弹框权限
|
||||
public static final String GET_FIRST_CHARGE_GIFT = "/api/Activities/first_charge_gift";//首充好礼列表接口
|
||||
public static final String GET_NEW_CHARGE_GIFT = "/api/Activities/new_charge_gift";//新人好礼列表接口(弹框)
|
||||
public static final String GET_ACTIVITIES_PERMISSION = "/api/Activities/activities_permission";//活动弹框权限
|
||||
public static final String GET_DAY_DROP_GIFT = "/api/Activities/day_drop_gift";//天降好礼列表接口(弹框)
|
||||
public static final String dailyTasksReceive = "/api/Dailytasks/dailyTasksReceive";//领取每日任务奖励
|
||||
public static final String postRoomSwToken = "/api/Room/update_user_sw_token";//获取用户声网token
|
||||
public static final String dailyTasksComplete = "/api/Dailytasks/dailyTasksComplete";//领取每日任务奖励
|
||||
public static final String POST_CANCEL_USER_DECORATE = "/api/Decorate/cancel_user_decorate";//取消装扮
|
||||
public static final String GET_THEME_DATA = "/api/Theme/get_theme_data";//主题接口
|
||||
public static final String START_FRIEND = "/api/Friend/start_friend";//点击开始按钮 交友房
|
||||
public static final String DELAY = "/api/Friend/delay";//点击延时 交友房
|
||||
public static final String POST_KEEP_XINTIAO = "/api/Xintiao/keep_xintiao";//心跳
|
||||
public static final String END_FRIEND = "/api/Friend/end_friend";//点击结束 交友房
|
||||
public static final String CREATE_RELATION = "/api/Friend/create_relation";//卡关系 (创建关系) 交友房
|
||||
public static final String GET_BOX_GIFT_LIST = "/api/BlindBoxTurntable/get_gift_list";//获取活动礼物列表
|
||||
public static final String POST_DRAW_GIFT_LIST = "/api/BlindBoxTurntable/draw_gift";//盲盒转盘抽奖
|
||||
public static final String GET_MY_RECORD = "/api/BlindBoxTurntable/get_my_record";//获取我的抽奖记录
|
||||
public static final String GET_ALL_RECORD = "/api/BlindBoxTurntable/get_all_record";//获取全服抽奖记录
|
||||
public static final String GIFT_SEND = "/api/BlindBoxTurntable/gift_send";//礼物发放
|
||||
|
||||
public static final String GET_BOX_GIFT_LIST_XLH = "/api/BlindBoxTurntable/xlh";//巡乐会
|
||||
public static final String POST_DRAW_GIFT_LIST_XLH = "/api/BlindBoxTurntable/xlh_draw_gift";//巡乐会抽奖
|
||||
public static final String POST_XLH_ALL_RECORD = "/api/BlindBoxTurntable/get_xlh_all_record";//巡乐会榜单
|
||||
public static final String Get_XH_RANking = "/api/BlindBoxTurntable/get_xlh_ranking";//巡乐会幸运
|
||||
public static final String GET_XLH_MY_RECORD = "/api/BlindBoxTurntable/get_xlh_my_record";//巡乐会记录
|
||||
public static final String POST_GIFT_ALL_CLEAR = "/api/Room/room_gift_all_clear";//背包礼物全清
|
||||
public static final String POST_ROOM_USER_CHARM_LIST = "/api/Room/room_user_charm_list";//房间用户当前魅力值列表
|
||||
public static final String GET_GIFT_PACK_LIST_COUNT = "/api/UserGiftPack/get_gift_pack_list_count";//背包礼物总价值
|
||||
public static final String ROOM_USER_RECONNECT = "/api/Room/user_reconnect";//用户重连
|
||||
public static final String USER_ROOM_BACK = "/api/Room/user_in_room_background";//用户在房间内切后台保留数据操作
|
||||
public static final String ROOM_HOUR_BEAN = "/api/RoomHourRanking/room_hour_ranking";//房间小时榜
|
||||
public static final String GET_EMOTION = "/api/RoomEmoji/type_list";//表情类型列表
|
||||
public static final String GET_EMOTION_DEATILS = "/api/RoomEmoji/emoji_list";//表情列表
|
||||
public static final String GET_TEMP_KEY = "/api/Upload/getTempKeys";//获取上传cos的临时秘钥
|
||||
|
||||
|
||||
|
||||
public static final String MODIFY_MOBILE = "/api/UserData/modify_mobile";//手机换绑
|
||||
|
||||
@@ -256,6 +256,10 @@ public class PKProgressBar extends View {
|
||||
getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
|
||||
@Override
|
||||
public boolean onPreDraw() {
|
||||
// 添加视图是否已附加到窗口的检查
|
||||
if (getWindowToken() == null) {
|
||||
return true; // 视图尚未附加到窗口,稍后再试
|
||||
}
|
||||
getViewTreeObserver().removeOnPreDrawListener(this);
|
||||
// 是否需要渐变器
|
||||
if (isGradient) {
|
||||
|
||||
@@ -12,6 +12,7 @@ import android.text.TextUtils;
|
||||
import com.alipay.sdk.app.PayTask;
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.orhanobut.logger.Logger;
|
||||
import com.tencent.mm.opensdk.modelbiz.WXLaunchMiniProgram;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.bean.AppPay;
|
||||
import com.xscm.moduleutil.event.PayEvent;
|
||||
@@ -67,6 +68,20 @@ public class PaymentUtil {
|
||||
|
||||
}
|
||||
|
||||
public static void payWxMiniProgramWx(IWXAPI api, String path) {
|
||||
if (!api.isWXAppInstalled()) {
|
||||
ToastUtils.showShort("请安装微信");
|
||||
return;
|
||||
}
|
||||
WXLaunchMiniProgram.Req req = new WXLaunchMiniProgram.Req();
|
||||
req.userName = "gh_e64a1a89a0ad"; // 填小程序原始id
|
||||
req.path = "pages/orderDetail/orderDetail?"+path; ////拉起小程序页面的可带参路径,不填默认拉起小程序首页,对于小游戏,可以只传入 query 部分,来实现传参效果,如:传入 "?foo=bar"。
|
||||
// req.path="pages/orderDetail/orderDetail?appid=00344656&body=user_Recharge_to_chumeng_App&version=12&trxamt=1¬ify_url=http://tapp.qxcms.com/api/payment/allinpayNotify&paytype=W06&randomstr=67e6671866f0e&cusid=5647950737575ZK&remark=1&reqsn=20250328529202885800&signtype=RSA&sign=O+DT6XMstf+0F8P3li/PM3lZGgam3fBqs2L6pKXUUVadd9kYiuIrbKxzrGVJ47uPWEIGV2W903nKJY+wqAnoKWvGTMMmuEsU+2gOWnDmp7X58Rw7eDDLjy0TGDxheIlMHwJmg0gOCiHGYoiJB61WQlyX4vvKZy9DOuepqnNPvC2ByeL2Vi8eRi1eqoA9PqmePzhFDz5l/EB1UOm8/XmXv4FKO7b/Im7M9cRNX3tXqbKURr5P7ohj42VF8DoYJYp7eAa3ql1GlYDJIbG+D7NGbPkp8AEKUrAShkMgNpLCnIcAGGlEhW1la8qn+/WVazH7CjUrJvqWcKMafSZcLxmMFA==";
|
||||
req.miniprogramType = WXLaunchMiniProgram.Req.MINIPTOGRAM_TYPE_RELEASE;// 可选打开 开发版,体验版和正式版
|
||||
api.sendReq(req);
|
||||
|
||||
}
|
||||
|
||||
public void onResp(BaseResp resp){
|
||||
if(resp.getType()== ConstantsAPI.COMMAND_PAY_BY_WX){
|
||||
Log.d(TAG,"onPayFinish,errCode="+resp.errCode);
|
||||
|
||||
@@ -1,153 +0,0 @@
|
||||
package com.xscm.moduleutil.widget;
|
||||
|
||||
import static com.liulishuo.okdownload.OkDownloadProvider.context;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.petterp.floatingx.FloatingX;
|
||||
import com.petterp.floatingx.assist.FxGravity;
|
||||
import com.petterp.floatingx.assist.helper.FxAppHelper;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.event.MqttBean;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
/**
|
||||
* @Author
|
||||
* @Time 2025/7/18 21:52
|
||||
* @Description 飘屏管理器
|
||||
*/
|
||||
public class PiaoPingManager {
|
||||
private static PiaoPingManager instance;
|
||||
private WindowManager windowManager;
|
||||
private View piaoPingView;
|
||||
private boolean isPiaoPingShown = false;
|
||||
private Queue<MqttBean> messageQueue = new ConcurrentLinkedQueue<>(); // 消息队列
|
||||
private boolean isAnimating = false; // 动画状态标记
|
||||
private PiaoPingManager(Context context) {
|
||||
windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||
if (windowManager == null) return;
|
||||
|
||||
// 创建飘屏消息的布局
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
piaoPingView = inflater.inflate(R.layout.item_piaoping, null);
|
||||
}
|
||||
|
||||
public static synchronized PiaoPingManager getInstance(Context context) {
|
||||
if (instance == null) {
|
||||
instance = new PiaoPingManager(context.getApplicationContext());
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void showPiaoPingMessage(MqttBean mqttBean) {
|
||||
// 创建 FloatingX 配置
|
||||
// 添加到队列
|
||||
messageQueue.offer(mqttBean);
|
||||
// 如果当前没有动画正在进行,则开始处理
|
||||
if (!isAnimating) {
|
||||
processNextMessage();
|
||||
}
|
||||
|
||||
}
|
||||
private void processNextMessage() {
|
||||
if (messageQueue.isEmpty()) {
|
||||
isAnimating = false;
|
||||
return;
|
||||
}
|
||||
|
||||
isAnimating = true;
|
||||
MqttBean mqttBean = messageQueue.poll();
|
||||
displayMessage(mqttBean);
|
||||
}
|
||||
|
||||
private void displayMessage(MqttBean mqttBean) {
|
||||
// 获取悬浮窗视图并设置内容
|
||||
View floatingView = LayoutInflater.from(context).inflate(R.layout.item_piaoping, new FrameLayout(context), false);
|
||||
TextView textView = floatingView.findViewById(R.id.tv_name);
|
||||
TextView textView2 = floatingView.findViewById(R.id.tv_to_name);
|
||||
textView2.setText("送给" + mqttBean.getList().getToUserName());
|
||||
textView.setText(mqttBean.getList().getFromUserName());
|
||||
ImageUtils.loadHeadCC(mqttBean.getList().getGift_picture(), floatingView.findViewById(R.id.iv_piaoping));
|
||||
TextView tv_time = floatingView.findViewById(R.id.tv_num);
|
||||
tv_time.setText("x" + mqttBean.getList().getNumber());
|
||||
|
||||
// 先将视图放置在屏幕右侧外部,避免闪现问题
|
||||
floatingView.setTranslationX(10000); // 先放到屏幕外
|
||||
|
||||
FxAppHelper fxAppHelper = FxAppHelper.builder()
|
||||
.setContext(context)
|
||||
.setLayoutView(floatingView)
|
||||
.setGravity(FxGravity.RIGHT_OR_TOP)
|
||||
.setX(0)
|
||||
.setY(100)
|
||||
.build();
|
||||
|
||||
FloatingX.install(fxAppHelper).show();
|
||||
|
||||
// 首先从右侧滑入到屏幕中央
|
||||
floatingView.post(() -> {
|
||||
// 确保初始位置在屏幕右侧外部
|
||||
floatingView.setTranslationX(floatingView.getWidth());
|
||||
|
||||
// 第一阶段:从右到屏幕右侧边缘(缓慢进入)
|
||||
ObjectAnimator animator1 = ObjectAnimator.ofFloat(floatingView, "translationX",
|
||||
floatingView.getWidth(), 0f);
|
||||
animator1.setDuration(1500); // 延长动画时间到1.5秒
|
||||
animator1.setInterpolator(new DecelerateInterpolator(2.0f)); // 更平缓的减速效果
|
||||
animator1.start();
|
||||
|
||||
// 第二阶段:延迟1秒后从当前位置向左滑出
|
||||
floatingView.postDelayed(() -> {
|
||||
ObjectAnimator animator2 = ObjectAnimator.ofFloat(floatingView, "translationX",
|
||||
0f, -floatingView.getWidth());
|
||||
animator2.setDuration(1500); // 延长动画时间到1.5秒
|
||||
animator2.setInterpolator(new DecelerateInterpolator(2.0f)); // 更平缓的减速效果
|
||||
animator2.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
// 动画结束后移除悬浮窗
|
||||
FloatingX.uninstallAll();
|
||||
// 处理下一个消息
|
||||
processNextMessage();
|
||||
}
|
||||
});
|
||||
animator2.start();
|
||||
}, 1000); // 停留1秒
|
||||
});
|
||||
}
|
||||
|
||||
public void subscribe() {
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
|
||||
public void unsubscribe() {
|
||||
EventBus.getDefault().unregister(this);
|
||||
messageQueue.clear();
|
||||
isAnimating = false; // 重置动画状态
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onMessageReceived(MqttBean mqttBean) {
|
||||
showPiaoPingMessage(mqttBean);
|
||||
|
||||
// FxAppHelper fxAppHelper = FxAppHelper.builder().setContext( context).setLayout(R.layout.item_piaoping).build();
|
||||
// FloatingX.install(fxAppHelper).show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public class RoomDefaultWheatView extends BaseWheatView {
|
||||
sex = bean.getSex();
|
||||
if (isOn()) {
|
||||
//开启声浪
|
||||
mIvRipple.stopAnimation();
|
||||
mIvRipple.stopAnimation(true);
|
||||
mIvRipple.setVisibility(VISIBLE);
|
||||
mTvName.setText(bean.getNickname());
|
||||
ImageUtils.loadHeadCC(bean.getAvatar(), mRiv);
|
||||
@@ -69,7 +69,7 @@ public class RoomDefaultWheatView extends BaseWheatView {
|
||||
mIvFrame.setVisibility(INVISIBLE);
|
||||
} else {
|
||||
mIvFrame.setVisibility(VISIBLE);
|
||||
mIvFrame.setSource(pitBean.getDress(), 1);
|
||||
mIvFrame.setSource(pitBean.getDress(), 3);
|
||||
// ImageUtils.loadDecorationAvatar(pitBean.getDress_picture(), mIvFrame);
|
||||
}
|
||||
if (showBoss && WHEAT_BOSS.equals(pitNumber)) {
|
||||
@@ -100,7 +100,7 @@ public class RoomDefaultWheatView extends BaseWheatView {
|
||||
mIvFrame.setVisibility(INVISIBLE);
|
||||
mIvFace.remove();
|
||||
//停止声浪
|
||||
mIvRipple.stopAnimation();
|
||||
mIvRipple.stopAnimation( true);
|
||||
mIvRipple.setVisibility(GONE);
|
||||
}
|
||||
if (showSexIcon) {
|
||||
@@ -112,19 +112,19 @@ public class RoomDefaultWheatView extends BaseWheatView {
|
||||
mCharmView.setVisibility(VISIBLE);
|
||||
}
|
||||
|
||||
if (pitBean.is_pk() ){
|
||||
if (pitBean.getUser_id()!=null && !pitBean.getUser_id().equals("0") && !pitBean.getUser_id().isEmpty()) {
|
||||
if (pitBean.is_pk()) {
|
||||
if (pitBean.getUser_id() != null && !pitBean.getUser_id().equals("0") && !pitBean.getUser_id().isEmpty()) {
|
||||
tv_time_pk.setVisibility(VISIBLE);
|
||||
setSex(pitBean.getCharm(),false);
|
||||
setSex(pitBean.getCharm(), false);
|
||||
mCharmView.setVisibility(GONE);
|
||||
}else {
|
||||
} else {
|
||||
tv_time_pk.setVisibility(GONE);
|
||||
}
|
||||
// ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) mCharmView.getLayoutParams();
|
||||
// params.width = 35;
|
||||
// mCharmView.setLayoutParams(params);
|
||||
|
||||
}else {
|
||||
} else {
|
||||
tv_time_pk.setVisibility(GONE);
|
||||
mCharmView.setVisibility(VISIBLE);
|
||||
// ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) mCharmView.getLayoutParams();
|
||||
@@ -134,7 +134,8 @@ public class RoomDefaultWheatView extends BaseWheatView {
|
||||
|
||||
// setCardiac(pitBean.getPit_number(), 0.0f);
|
||||
}
|
||||
public void setSex( String value, boolean format) {
|
||||
|
||||
public void setSex(String value, boolean format) {
|
||||
if (format) {
|
||||
tv_time_pk.setText(value);
|
||||
} else {
|
||||
@@ -221,17 +222,18 @@ public class RoomDefaultWheatView extends BaseWheatView {
|
||||
|
||||
@Override
|
||||
public void onLocalSoundLevelUpdate(int volume) {
|
||||
if (volume==0){
|
||||
mIvRipple.stopAnimation();
|
||||
if (volume == 0) {
|
||||
mIvRipple.stopAnimation( true);
|
||||
} else {
|
||||
if (pitBean.getUser_id().equals(SpUtil.getUserId()) && closePhone) {
|
||||
mIvRipple.stopAnimation();
|
||||
}else {
|
||||
mIvRipple.stopAnimation( true);
|
||||
} else {
|
||||
mIvRipple.post(() -> {
|
||||
mIvRipple.setVisibility(VISIBLE);
|
||||
if (!mIvRipple.isAnimating()) {
|
||||
mIvRipple.startAnimation();
|
||||
}
|
||||
mIvRipple.setVisibility(VISIBLE);
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -247,4 +249,8 @@ public class RoomDefaultWheatView extends BaseWheatView {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unRegister(Object obj) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,11 @@ import com.xscm.moduleutil.bean.room.RoomPitBean;
|
||||
import com.xscm.moduleutil.color.ThemeableDrawableUtils;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
|
||||
public class RoomFriendshipWheatView extends BaseWheatView{
|
||||
public class RoomFriendshipWheatView extends BaseWheatView {
|
||||
|
||||
public ImageView mIvTagBoss;
|
||||
public TextView mTvTime;
|
||||
public ImageView iv_on_line;
|
||||
// public ImageView iv_on_line;
|
||||
private ImageView iv_tag_type;
|
||||
public WheatCharmView mCharmView;
|
||||
public TextView tv_zhul;
|
||||
@@ -47,15 +47,38 @@ public class RoomFriendshipWheatView extends BaseWheatView{
|
||||
protected void initPit(Context context, AttributeSet attrs) {
|
||||
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RoomMakeWheatView);
|
||||
pitNumber = typedArray.getString(R.styleable.RoomMakeWheatView_room_make_wheat_number);
|
||||
pitImageVId=typedArray.getResourceId(R.styleable.RoomMakeWheatView_room_make_pic, 0);
|
||||
pitImageVId = typedArray.getResourceId(R.styleable.RoomMakeWheatView_room_make_pic, 0);
|
||||
typedArray.recycle();
|
||||
mIvTagBoss = findViewById(R.id.iv_tag_boos);
|
||||
mTvTime = findViewById(R.id.tv_time);
|
||||
iv_on_line=findViewById(R.id.iv_online);
|
||||
iv_tag_type=findViewById(R.id.iv_tag_type);
|
||||
// iv_on_line = findViewById(R.id.iv_online);
|
||||
iv_tag_type = findViewById(R.id.iv_tag_type);
|
||||
mCharmView = findViewById(R.id.charm_view);
|
||||
mRiv.setImageResource(pitImageVId);
|
||||
tv_zhul=findViewById(R.id.tv_zhul);
|
||||
tv_zhul = findViewById(R.id.tv_zhul);
|
||||
|
||||
// 为 tv_zhul 设置点击监听
|
||||
if (tv_zhul != null) {
|
||||
tv_zhul.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mOnZhulClickListener != null && pitBean != null) {
|
||||
mOnZhulClickListener.onZhulClick(RoomFriendshipWheatView.this, pitBean);
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
mCharmView.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mOnCharmClickListener != null && pitBean != null){
|
||||
mOnCharmClickListener.onCharmClick(RoomFriendshipWheatView.this, pitBean);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -68,54 +91,65 @@ public class RoomFriendshipWheatView extends BaseWheatView{
|
||||
sex = bean.getSex();
|
||||
if (isOn()) {
|
||||
//开启声浪
|
||||
mIvRipple.stopAnimation();
|
||||
mIvRipple.stopAnimation(true);
|
||||
mIvRipple.setVisibility(VISIBLE);
|
||||
mTvName.setText(bean.getNickname());
|
||||
ImageUtils.loadCenterCrop(bean.getAvatar(), mRiv);
|
||||
if (TextUtils.isEmpty(pitBean.getDress_picture())) {
|
||||
ImageUtils.loadHeadCC(bean.getAvatar(), mRiv);
|
||||
if (TextUtils.isEmpty(pitBean.getDress())) {
|
||||
mIvFrame.stopAll();
|
||||
mIvFrame.setVisibility(INVISIBLE);
|
||||
} else {
|
||||
mIvFrame.setVisibility(VISIBLE);
|
||||
mIvFrame.stopAll();
|
||||
mIvFrame.setSource(pitBean.getDress(), 3);
|
||||
}
|
||||
if (showBoss && WHEAT_BOSS.equals(pitNumber)) {
|
||||
mIvTagBoss.setVisibility(GONE);
|
||||
}
|
||||
mCharmView.setVisibility(VISIBLE);
|
||||
} else {
|
||||
mTvName.setText((!"10".equals(pitBean.getPit_number()) && !"9".equals(pitBean.getPit_number())) ? pitBean.getPit_number() : "");
|
||||
//麦位上锁
|
||||
//麦位上锁
|
||||
if (showBoss && WHEAT_BOSS.equals(pitNumber)) {
|
||||
mIvTagBoss.setVisibility(VISIBLE);
|
||||
ImageUtils.loadRes(isLocked() ? R.mipmap.room_ic_wheat_default_suo : R.mipmap.jiaoy, mRiv);
|
||||
// if (showBoss && WHEAT_BOSS.equals(pitNumber)) {
|
||||
// mIvTagBoss.setVisibility(VISIBLE);
|
||||
// ImageUtils.loadRes(isLocked() ? R.mipmap.room_ic_wheat_default_suo : R.mipmap.jiaoy, mRiv);
|
||||
// } else {
|
||||
// mRiv.setImageResource(bean.getIs_lock() == 1 ? R.mipmap.room_ic_wheat_default_suo : R.mipmap.jiaoy);
|
||||
// }
|
||||
if (pitBean.getPit_number().equals("4") || pitBean.getPit_number().equals("5") || pitBean.getPit_number().equals("6")) {
|
||||
ImageUtils.loadRes(R.mipmap.jiaoy_n, mRiv);
|
||||
} else {
|
||||
mRiv.setImageResource(bean.getIs_lock() == 1 ? R.mipmap.room_ic_wheat_default_suo : R.mipmap.jiaoy);
|
||||
ImageUtils.loadRes(R.mipmap.jiaoy, mRiv);
|
||||
}
|
||||
if (isMute()) {
|
||||
ImageUtils.loadRes(R.mipmap.room_microphone_off, mIvSex);
|
||||
}
|
||||
mIvFrame.stopAll();
|
||||
mIvFrame.setVisibility(INVISIBLE);
|
||||
mIvFace.remove();
|
||||
//停止声浪
|
||||
mIvRipple.stopAnimation();
|
||||
mIvRipple.stopAnimation( true);
|
||||
mIvRipple.setVisibility(GONE);
|
||||
mCharmView.setVisibility(GONE);
|
||||
}
|
||||
if (showSexIcon) {
|
||||
checkSex();
|
||||
}
|
||||
if (pitBean.getPit_number().equals("9")){
|
||||
if (pitBean.getPit_number().equals("9")) {
|
||||
iv_tag_type.setVisibility(VISIBLE);
|
||||
iv_tag_type.setImageResource(R.mipmap.zc);
|
||||
switchCharmViewPosition(false);
|
||||
tv_zhul.setVisibility(GONE);
|
||||
}else if (pitBean.getPit_number().equals("10")){
|
||||
} else if (pitBean.getPit_number().equals("10")) {
|
||||
iv_tag_type.setVisibility(VISIBLE);
|
||||
iv_tag_type.setImageResource(R.mipmap.jb);
|
||||
switchCharmViewPosition(false);
|
||||
tv_zhul.setVisibility(GONE);
|
||||
}else {
|
||||
} else {
|
||||
iv_tag_type.setVisibility(GONE);
|
||||
switchCharmViewPosition(true);
|
||||
tv_zhul.setVisibility(VISIBLE);
|
||||
// tv_zhul.setVisibility(VISIBLE);
|
||||
}
|
||||
|
||||
if (pitBean.getPit_number().equals("1") || pitBean.getPit_number().equals("2") || pitBean.getPit_number().equals("3")) {
|
||||
@@ -126,6 +160,7 @@ public class RoomFriendshipWheatView extends BaseWheatView{
|
||||
tv_zhul.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
}
|
||||
}
|
||||
|
||||
public void checkSex() {
|
||||
if (isOn()) {
|
||||
mIvSex.setVisibility(VISIBLE);
|
||||
@@ -134,14 +169,13 @@ public class RoomFriendshipWheatView extends BaseWheatView{
|
||||
if (mTvNo != null) mTvNo.setBackgroundResource(getOriginNoImage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换 charm_view 的显示位置
|
||||
*
|
||||
* @param showAtTagTypePosition true-显示在 iv_tag_type 位置,false-显示在原始位置
|
||||
*/
|
||||
/**
|
||||
* 切换 charm_view 的显示位置
|
||||
* @param showAtTagTypePosition true-显示在 iv_tag_type 位置,false-显示在原始位置
|
||||
*/
|
||||
|
||||
public void switchCharmViewPosition(boolean showAtTagTypePosition) {
|
||||
if (mCharmView == null) return;
|
||||
|
||||
@@ -170,7 +204,7 @@ public class RoomFriendshipWheatView extends BaseWheatView{
|
||||
constraintSet.connect(
|
||||
R.id.charm_view, ConstraintSet.TOP,
|
||||
R.id.riv, ConstraintSet.BOTTOM,
|
||||
- dip2px(15) // 与 iv_tag_type 相同的 margin
|
||||
-dip2px(12) // 与 iv_tag_type 相同的 margin
|
||||
);
|
||||
|
||||
// constraintSet.connect(
|
||||
@@ -225,8 +259,11 @@ public class RoomFriendshipWheatView extends BaseWheatView{
|
||||
final float scale = getContext().getResources().getDisplayMetrics().density;
|
||||
return (int) (dpValue * scale + 0.5f);
|
||||
}
|
||||
|
||||
|
||||
// public void setmCharmView(String charm){
|
||||
// if (mCharmView!=null){
|
||||
// mCharmView.setSex(pitBean.getSex(),pitBean.getUser_id(), charm,false);
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 开启计时
|
||||
@@ -261,19 +298,46 @@ public class RoomFriendshipWheatView extends BaseWheatView{
|
||||
|
||||
}
|
||||
|
||||
public void setOnlineStatus(UserOnlineStatusBean isOnline) {
|
||||
if (pitBean.getUser_id() != null && !pitBean.getUser_id().equals("0") && !pitBean.getUser_id().isEmpty()) {
|
||||
if (pitBean.getUser_id().equals(isOnline.getUser_id())) {
|
||||
if (isOnline.getIs_online() == 1) {
|
||||
iv_on_line.setVisibility(GONE);
|
||||
} else {
|
||||
iv_on_line.setVisibility(VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
///设置是否显示助力按钮
|
||||
public void setLockZl(boolean lock){
|
||||
// public void setOnlineStatus(UserOnlineStatusBean isOnline) {
|
||||
// if (pitBean.getUser_id() != null && !pitBean.getUser_id().equals("0") && !pitBean.getUser_id().isEmpty()) {
|
||||
// if (pitBean.getUser_id().equals(isOnline.getUser_id())) {
|
||||
// if (isOnline.getIs_online() == 1) {
|
||||
//// iv_on_line.setVisibility(GONE);
|
||||
// } else {
|
||||
//// iv_on_line.setVisibility(VISIBLE);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
/// 设置是否显示助力按钮
|
||||
public void setLockZl(boolean lock) {
|
||||
tv_zhul.setVisibility(lock ? VISIBLE : INVISIBLE);
|
||||
}
|
||||
|
||||
private OnZhulClickListener mOnZhulClickListener;
|
||||
|
||||
// 设置监听器的方法
|
||||
public void setOnZhulClickListener(OnZhulClickListener listener) {
|
||||
this.mOnZhulClickListener = listener;
|
||||
}
|
||||
|
||||
private onCharmClickListener mOnCharmClickListener;
|
||||
|
||||
public void setmOnCharmClickListener(onCharmClickListener mOnCharmClickListener) {
|
||||
this.mOnCharmClickListener = mOnCharmClickListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unRegister(Object obj) {
|
||||
|
||||
}
|
||||
|
||||
public interface OnZhulClickListener {
|
||||
void onZhulClick(RoomFriendshipWheatView view, RoomPitBean pitBean);
|
||||
}
|
||||
|
||||
public interface onCharmClickListener{
|
||||
void onCharmClick(RoomFriendshipWheatView view, RoomPitBean pitBean);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,14 @@ public class RoomKtvWheatView extends BaseWheatView {
|
||||
public RoomKtvWheatView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
private onCharmClickListener mOnCharmClickListener;
|
||||
|
||||
public void setmOnCharmClickListener(onCharmClickListener mOnCharmClickListener) {
|
||||
this.mOnCharmClickListener = mOnCharmClickListener;
|
||||
}
|
||||
public interface onCharmClickListener{
|
||||
void onCharmClick(RoomKtvWheatView view, RoomPitBean pitBean);
|
||||
}
|
||||
@Override
|
||||
protected void initPit(Context context, AttributeSet attrs) {
|
||||
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RoomDefaultWheatView);
|
||||
@@ -45,6 +52,16 @@ public class RoomKtvWheatView extends BaseWheatView {
|
||||
mIvTagBoss = findViewById(R.id.iv_tag_boos);
|
||||
mTvTime = findViewById(R.id.tv_time);
|
||||
tv_time_pk = findViewById(R.id.tv_time_pk);
|
||||
|
||||
mCharmView.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mOnCharmClickListener != null && pitBean != null){
|
||||
mOnCharmClickListener.onCharmClick(RoomKtvWheatView.this, pitBean);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -57,15 +74,16 @@ public class RoomKtvWheatView extends BaseWheatView {
|
||||
sex = bean.getSex();
|
||||
if (isOn()) {
|
||||
//开启声浪
|
||||
mIvRipple.stopAnimation();
|
||||
mIvRipple.stopAnimation(true);
|
||||
mIvRipple.setVisibility(VISIBLE);
|
||||
mTvName.setText(bean.getNickname());
|
||||
ImageUtils.loadHeadCC(bean.getAvatar(), mRiv);
|
||||
if (TextUtils.isEmpty(pitBean.getDress())) {
|
||||
mIvFrame.stopAll();
|
||||
mIvFrame.setVisibility(INVISIBLE);
|
||||
} else {
|
||||
mIvFrame.setVisibility(VISIBLE);
|
||||
mIvFrame.setSource(pitBean.getDress(), 1);
|
||||
mIvFrame.setSource(pitBean.getDress(), 3);
|
||||
// ImageUtils.loadDecorationAvatar(pitBean.getDress_picture(), mIvFrame);
|
||||
}
|
||||
if (showBoss && WHEAT_BOSS.equals(pitNumber)) {
|
||||
@@ -93,10 +111,11 @@ public class RoomKtvWheatView extends BaseWheatView {
|
||||
if (isMute()) {
|
||||
ImageUtils.loadRes(R.mipmap.room_microphone_off, mIvSex);
|
||||
}
|
||||
mIvFrame.stopAll();
|
||||
mIvFrame.setVisibility(INVISIBLE);
|
||||
mIvFace.remove();
|
||||
//停止声浪
|
||||
mIvRipple.stopAnimation();
|
||||
mIvRipple.stopAnimation(true);
|
||||
mIvRipple.setVisibility(GONE);
|
||||
}
|
||||
if (showSexIcon) {
|
||||
@@ -218,10 +237,10 @@ public class RoomKtvWheatView extends BaseWheatView {
|
||||
@Override
|
||||
public void onLocalSoundLevelUpdate(int volume) {
|
||||
if (volume==0){
|
||||
mIvRipple.stopAnimation();
|
||||
mIvRipple.stopAnimation(true);
|
||||
} else {
|
||||
if (pitBean.getUser_id().equals(SpUtil.getUserId()) && closePhone) {
|
||||
mIvRipple.stopAnimation();
|
||||
mIvRipple.stopAnimation(true);
|
||||
}else {
|
||||
mIvRipple.post(() -> {
|
||||
if (!mIvRipple.isAnimating()) {
|
||||
@@ -237,7 +256,7 @@ public class RoomKtvWheatView extends BaseWheatView {
|
||||
public void userJoined(int userId, int elapsd) {
|
||||
if (pitBean != null && pitBean.getUser_id() != null && !pitBean.getUser_id().equals("0")) {
|
||||
if (pitBean.getUser_id().equals(userId + "")) {
|
||||
iv_on_line.setVisibility(GONE);
|
||||
// iv_on_line.setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -246,9 +265,13 @@ public class RoomKtvWheatView extends BaseWheatView {
|
||||
public void userOffline(int userId, int reason) {
|
||||
if (pitBean != null && pitBean.getUser_id() != null && !pitBean.getUser_id().equals("0")) {
|
||||
if (pitBean.getUser_id().equals(userId + "")) {
|
||||
iv_on_line.setVisibility(VISIBLE);
|
||||
// iv_on_line.setVisibility(VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unRegister(Object obj) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.bean.UserOnlineStatusBean;
|
||||
import com.xscm.moduleutil.bean.room.RoomPitBean;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
import com.xscm.moduleutil.utils.StringUtil;
|
||||
|
||||
|
||||
public class RoomMakeWheatView extends BaseWheatView {
|
||||
@@ -19,7 +20,7 @@ public class RoomMakeWheatView extends BaseWheatView {
|
||||
public ImageView mIvTagBoss;
|
||||
public TextView mTvTime;
|
||||
public ImageView iv_zhul;
|
||||
public ImageView iv_on_line;
|
||||
// public ImageView iv_on_line;
|
||||
private ImageView iv_tag_type;
|
||||
public WheatCharmView mCharmView;
|
||||
private boolean showBoss;//显示老板标识
|
||||
@@ -47,12 +48,42 @@ public class RoomMakeWheatView extends BaseWheatView {
|
||||
typedArray.recycle();
|
||||
mIvTagBoss = findViewById(R.id.iv_tag_boos);
|
||||
mTvTime = findViewById(R.id.tv_time);
|
||||
iv_on_line=findViewById(R.id.iv_online);
|
||||
// iv_on_line=findViewById(R.id.iv_online);
|
||||
iv_tag_type=findViewById(R.id.iv_tag_type);
|
||||
mCharmView = findViewById(R.id.charm_view);
|
||||
mRiv.setImageResource(pitImageVId);
|
||||
|
||||
if (mTvTime != null) {
|
||||
mTvTime.setOnClickListener(v -> {
|
||||
// 处理魅力值点击
|
||||
if (mOnCharmClickListener != null && pitBean != null) {
|
||||
mOnCharmClickListener.onCharmClick(this, pitBean);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void setOnClickListener(OnClickListener l) {
|
||||
// // 保存外部设置的点击监听器
|
||||
// this.onWholeViewClickListener = l;
|
||||
// super.setOnClickListener(l);
|
||||
// }
|
||||
|
||||
// 为子组件设置点击监听器时,确保不会拦截父容器的点击事件
|
||||
public void setupChildClickListeners() {
|
||||
if (mRiv != null) {
|
||||
mRiv.setOnClickListener(v -> {
|
||||
// 处理头像点击
|
||||
if (onWholeViewClickListener != null) {
|
||||
onWholeViewClickListener.onClick(this);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
private OnClickListener onWholeViewClickListener;
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.room_view_make_wheat;
|
||||
@@ -68,14 +99,16 @@ public class RoomMakeWheatView extends BaseWheatView {
|
||||
sex = bean.getSex();
|
||||
if (isOn()) {
|
||||
//开启声浪
|
||||
mIvRipple.stopAnimation();
|
||||
mIvRipple.stopAnimation(true);
|
||||
mIvRipple.setVisibility(VISIBLE);
|
||||
mTvName.setText(bean.getNickname());
|
||||
ImageUtils.loadCenterCrop(bean.getAvatar(), mRiv);
|
||||
if (TextUtils.isEmpty(pitBean.getDress_picture())) {
|
||||
ImageUtils.loadHeadCC(bean.getAvatar(), mRiv);
|
||||
if (TextUtils.isEmpty(pitBean.getDress())) {
|
||||
mIvFrame.stopAll();
|
||||
mIvFrame.setVisibility(INVISIBLE);
|
||||
} else {
|
||||
mIvFrame.setVisibility(VISIBLE);
|
||||
mIvFrame.setSource(pitBean.getDress(), 3);
|
||||
}
|
||||
if (showBoss && WHEAT_BOSS.equals(pitNumber)) {
|
||||
mIvTagBoss.setVisibility(GONE);
|
||||
@@ -93,10 +126,11 @@ public class RoomMakeWheatView extends BaseWheatView {
|
||||
if (isMute()){
|
||||
ImageUtils.loadRes(R.mipmap.room_microphone_off, mIvSex);
|
||||
}
|
||||
mIvFrame.stopAll();
|
||||
mIvFrame.setVisibility(INVISIBLE);
|
||||
mIvFace.remove();
|
||||
//停止声浪
|
||||
mIvRipple.stopAnimation();
|
||||
mIvRipple.stopAnimation(true);
|
||||
mIvRipple.setVisibility(GONE);
|
||||
}
|
||||
if (showSexIcon) {
|
||||
@@ -111,6 +145,7 @@ public class RoomMakeWheatView extends BaseWheatView {
|
||||
iv_tag_type.setVisibility(GONE);
|
||||
mCharmView.setVisibility(GONE);
|
||||
mTvName.setText(pitBean.getNickname()!=null && !pitBean.getNickname().equals("")?pitBean.getNickname():"拍卖者");
|
||||
mTvName.setBackgroundResource(com.xscm.moduleutil.R.mipmap.za_maiw_b);
|
||||
}else if (pitBean.getPit_number().equals("9")){
|
||||
iv_tag_type.setVisibility(VISIBLE);
|
||||
mCharmView.setVisibility(GONE);
|
||||
@@ -123,13 +158,37 @@ public class RoomMakeWheatView extends BaseWheatView {
|
||||
}else {
|
||||
mTvTime.setVisibility(VISIBLE);
|
||||
}
|
||||
mTvTime.setText(pitBean.getCharm());
|
||||
mTvTime.setText(StringUtil.toWan2(pitBean.getCharm(),1));
|
||||
}else if (pitBean.getPit_number().equals("000")){
|
||||
iv_tag_type.setVisibility(GONE);
|
||||
mCharmView.setVisibility(GONE);
|
||||
}
|
||||
|
||||
// mCharmView.setOnClickListener(new OnClickListener() {
|
||||
//
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// if (mOnCharmClickListener != null && pitBean != null){
|
||||
// mOnCharmClickListener.onCharmClick(RoomMakeWheatView.this, pitBean);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
|
||||
}
|
||||
|
||||
public void setmTvTime(String charm){
|
||||
mTvTime.setText(StringUtil.toWan2(pitBean.getCharm(),1));
|
||||
}
|
||||
|
||||
private onCharmClickListener mOnCharmClickListener;
|
||||
//
|
||||
public void setmOnCharmClickListener(onCharmClickListener mOnCharmClickListener) {
|
||||
this.mOnCharmClickListener = mOnCharmClickListener;
|
||||
}
|
||||
//
|
||||
public interface onCharmClickListener{
|
||||
void onCharmClick(RoomMakeWheatView view, RoomPitBean pitBean);
|
||||
}
|
||||
public void setChe(String che){
|
||||
|
||||
}
|
||||
@@ -204,11 +263,16 @@ public class RoomMakeWheatView extends BaseWheatView {
|
||||
if (pitBean.getUser_id() != null && !pitBean.getUser_id().equals("0") && !pitBean.getUser_id().isEmpty()) {
|
||||
if (pitBean.getUser_id().equals(isOnline.getUser_id())) {
|
||||
if (isOnline.getIs_online() == 1) {
|
||||
iv_on_line.setVisibility(GONE);
|
||||
// iv_on_line.setVisibility(GONE);
|
||||
} else {
|
||||
iv_on_line.setVisibility(VISIBLE);
|
||||
// iv_on_line.setVisibility(VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unRegister(Object obj) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class RoomMessageInputMenu extends ConstraintLayout {
|
||||
}
|
||||
String text = etContent.getText().toString();
|
||||
if (TextUtils.isEmpty(text)) {
|
||||
ToastUtils.show("请输入评论内容");
|
||||
ToastUtils.show("请输入内容");
|
||||
return;
|
||||
}
|
||||
// ApiClient.getInstance().sendTxtFilter(text,new BaseObserver<String>() {
|
||||
|
||||
@@ -23,7 +23,7 @@ public class RoomSingSongWheatView extends BaseWheatView {
|
||||
public ImageView mIvTagBoss;
|
||||
public TextView mTvTime;
|
||||
public TextView tv_time_pk;
|
||||
|
||||
public boolean isClickListenerSet = false;
|
||||
private boolean showBoss;//显示老板标识
|
||||
|
||||
public RoomSingSongWheatView(Context context) {
|
||||
@@ -40,9 +40,15 @@ public class RoomSingSongWheatView extends BaseWheatView {
|
||||
|
||||
@Override
|
||||
protected void initPit(Context context, AttributeSet attrs) {
|
||||
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RoomDefaultWheatView);
|
||||
pitNumber = typedArray.getString(R.styleable.RoomDefaultWheatView_room_wheat_number);
|
||||
typedArray.recycle();
|
||||
TypedArray typedArray = null;
|
||||
try {
|
||||
typedArray = context.obtainStyledAttributes(attrs, R.styleable.RoomDefaultWheatView);
|
||||
pitNumber = typedArray.getString(R.styleable.RoomDefaultWheatView_room_wheat_number);
|
||||
} finally {
|
||||
if (typedArray != null) {
|
||||
typedArray.recycle();
|
||||
}
|
||||
}
|
||||
mIvTagBoss = findViewById(R.id.iv_tag_boos);
|
||||
mTvTime = findViewById(R.id.tv_time);
|
||||
tv_time_pk = findViewById(R.id.tv_time_pk);
|
||||
@@ -55,83 +61,101 @@ public class RoomSingSongWheatView extends BaseWheatView {
|
||||
|
||||
@Override
|
||||
protected void setPitData(RoomPitBean bean) {
|
||||
if (bean == null) return;
|
||||
|
||||
sex = bean.getSex();
|
||||
pitBean = bean; // 统一使用参数 bean
|
||||
stopAndClearAnimation(); // 清理之前的动画资源
|
||||
if (isOn()) {
|
||||
//开启声浪
|
||||
mIvRipple.stopAnimation();
|
||||
mIvRipple.setVisibility(VISIBLE);
|
||||
mTvName.setText(bean.getNickname());
|
||||
ImageUtils.loadHeadCC(bean.getAvatar(), mRiv);
|
||||
if (TextUtils.isEmpty(pitBean.getDress())) {
|
||||
mIvFrame.setVisibility(INVISIBLE);
|
||||
} else {
|
||||
mIvFrame.setVisibility(VISIBLE);
|
||||
mIvFrame.setSource(pitBean.getDress(), 1);
|
||||
// ImageUtils.loadDecorationAvatar(pitBean.getDress_picture(), mIvFrame);
|
||||
}
|
||||
if (showBoss && WHEAT_BOSS.equals(pitNumber)) {
|
||||
mIvTagBoss.setVisibility(GONE);
|
||||
}
|
||||
handleOnState(bean);
|
||||
} else {
|
||||
mTvName.setText(
|
||||
"-1".equals(pitNumber) ? "" :
|
||||
"9".equals(pitNumber) ? "主持位" :
|
||||
"10".equals(pitNumber) ? "嘉宾位" :
|
||||
pitNumber + "号麦位"
|
||||
);
|
||||
//麦位上锁
|
||||
if (showBoss && WHEAT_BOSS.equals(pitNumber)) {
|
||||
mIvTagBoss.setVisibility(VISIBLE);
|
||||
ImageUtils.loadRes(isLocked() ? R.mipmap.room_ic_wheat_default_suo : R.mipmap.room_ic_wheat_default, mRiv);
|
||||
} else {
|
||||
// mIvTagBoss.setVisibility(GONE);
|
||||
// @DrawableRes int origin = getOriginImage();
|
||||
// ImageUtils.loadRes(isLocked() ? R.mipmap.room_ic_wheat_default_suo :
|
||||
// (origin == 0 ? R.mipmap.room_ic_wheat_default : origin), mRiv);
|
||||
mRiv.setImageResource(bean.getIs_lock() == 1 ? R.mipmap.room_ic_wheat_default_suo : R.mipmap.room_ic_wheat_default);
|
||||
// ImageUtils.loadRes(isLocked() ? R.mipmap.room_ic_wheat_default_suo : R.mipmap.room_ic_wheat_default, mRiv);
|
||||
}
|
||||
if (isMute()) {
|
||||
ImageUtils.loadRes(R.mipmap.room_microphone_off, mIvSex);
|
||||
}
|
||||
mIvFrame.setVisibility(INVISIBLE);
|
||||
mIvFace.remove();
|
||||
//停止声浪
|
||||
mIvRipple.stopAnimation();
|
||||
mIvRipple.setVisibility(GONE);
|
||||
handleOffState(bean);
|
||||
}
|
||||
|
||||
updateSexIcon();
|
||||
// updateCharmViewVisibility(bean);
|
||||
updatePkState(bean);
|
||||
iv_on_line.setVisibility(GONE);
|
||||
}
|
||||
|
||||
private void handleOnState(RoomPitBean bean) {
|
||||
|
||||
mIvRipple.setVisibility(VISIBLE);
|
||||
mTvName.setText(bean.getNickname());
|
||||
ImageUtils.loadHeadCC(bean.getAvatar(), mRiv);
|
||||
mCharmView.setVisibility(VISIBLE);
|
||||
if (TextUtils.isEmpty(bean.getDress())) {
|
||||
mIvFrame.stopAll();
|
||||
mIvFrame.setVisibility(INVISIBLE);
|
||||
} else {
|
||||
mIvFrame.setVisibility(VISIBLE);
|
||||
mIvFrame.setSource(bean.getDress(), 3);
|
||||
}
|
||||
|
||||
if (showBoss && TextUtils.equals(WHEAT_BOSS, pitNumber)) {
|
||||
mIvTagBoss.setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleOffState(RoomPitBean bean) {
|
||||
mTvName.setText(getPitNumberText());
|
||||
mCharmView.setVisibility(GONE);
|
||||
if (showBoss && TextUtils.equals(WHEAT_BOSS, pitNumber)) {
|
||||
mIvTagBoss.setVisibility(VISIBLE);
|
||||
int resId = bean.getIs_lock() == 1 ? R.mipmap.index_img_room_mask : R.drawable.room_ic_wheat_default;
|
||||
mRiv.setImageResource(resId);
|
||||
} else {
|
||||
mRiv.setImageResource(bean.getIs_lock() == 1 ? R.mipmap.index_img_room_mask : R.drawable.room_ic_wheat_default);
|
||||
}
|
||||
|
||||
if (isMute()) {
|
||||
ImageUtils.loadRes(R.mipmap.room_microphone_off, mIvSex);
|
||||
}
|
||||
mIvFrame.stopAll();
|
||||
mIvFrame.setVisibility(INVISIBLE);
|
||||
mIvFace.remove();
|
||||
mIvRipple.setVisibility(GONE);
|
||||
}
|
||||
|
||||
private String getPitNumberText() {
|
||||
if ("-1".equals(pitNumber)) return "";
|
||||
if ("9".equals(pitNumber)) return "主持位";
|
||||
if ("10".equals(pitNumber)) return "嘉宾位";
|
||||
return pitNumber + "号麦位";
|
||||
}
|
||||
|
||||
private void updateSexIcon() {
|
||||
if (showSexIcon) {
|
||||
checkSex();
|
||||
}
|
||||
if (pitBean.getNickname() == null || pitBean.getNickname().isEmpty()) {
|
||||
mCharmView.setVisibility(GONE);
|
||||
} else {
|
||||
mCharmView.setVisibility(VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
if (pitBean.is_pk() ){
|
||||
if (pitBean.getUser_id()!=null && !pitBean.getUser_id().equals("0") && !pitBean.getUser_id().isEmpty()) {
|
||||
private void updateCharmViewVisibility(RoomPitBean bean) {
|
||||
boolean isEmptyNickname = bean.getNickname() == null || bean.getNickname().isEmpty();
|
||||
mCharmView.setVisibility(isEmptyNickname ? GONE : VISIBLE);
|
||||
}
|
||||
|
||||
private void updatePkState(RoomPitBean bean) {
|
||||
if (bean.is_pk()) {
|
||||
String userId = bean.getUser_id();
|
||||
if (userId != null && !userId.equals("0") && !userId.isEmpty()) {
|
||||
tv_time_pk.setVisibility(VISIBLE);
|
||||
setSex(pitBean.getCharm(),false);
|
||||
setSex(bean.getCharm(), false);
|
||||
mCharmView.setVisibility(GONE);
|
||||
}else {
|
||||
} else {
|
||||
tv_time_pk.setVisibility(GONE);
|
||||
}
|
||||
// ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) mCharmView.getLayoutParams();
|
||||
// params.width = 35;
|
||||
// mCharmView.setLayoutParams(params);
|
||||
|
||||
}else {
|
||||
} else {
|
||||
tv_time_pk.setVisibility(GONE);
|
||||
mCharmView.setVisibility(VISIBLE);
|
||||
// ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) mCharmView.getLayoutParams();
|
||||
// params.width = 52;
|
||||
// mCharmView.setLayoutParams(params);
|
||||
if (isOn()) {
|
||||
mCharmView.setVisibility(VISIBLE);
|
||||
}else {
|
||||
mCharmView.setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
|
||||
// setCardiac(pitBean.getPit_number(), 0.0f);
|
||||
}
|
||||
public void setSex( String value, boolean format) {
|
||||
|
||||
public void setSex(String value, boolean format) {
|
||||
if (format) {
|
||||
tv_time_pk.setText(value);
|
||||
} else {
|
||||
@@ -139,12 +163,12 @@ public class RoomSingSongWheatView extends BaseWheatView {
|
||||
long xd = Long.parseLong(value);
|
||||
if (xd > 9999 || xd < -9999) {
|
||||
tv_time_pk.setText(String.format("%.2fw", xd / 10000.0f));
|
||||
// mBinding.tvValue.setText(String.valueOf(xd));
|
||||
} else {
|
||||
tv_time_pk.setText(value);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
tv_time_pk.setText("0"); // 设置默认值防止UI异常
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -210,25 +234,75 @@ public class RoomSingSongWheatView extends BaseWheatView {
|
||||
if (maozi != null) maozi.setVisibility(GONE);
|
||||
}
|
||||
|
||||
// 添加内存释放方法
|
||||
public void releaseResources() {
|
||||
stopAndClearAnimation();
|
||||
|
||||
// 清理头像加载
|
||||
if (mRiv != null) {
|
||||
mRiv.setImageBitmap(null);
|
||||
}
|
||||
|
||||
// 清理框架视图
|
||||
if (mIvFrame != null) {
|
||||
mIvFrame.release(); // 清理SVGA资源
|
||||
}
|
||||
|
||||
// 清理表情视图
|
||||
if (mIvFace != null) {
|
||||
mIvFace.remove();
|
||||
}
|
||||
|
||||
// 清理其他图片资源
|
||||
if (mIvSex != null) {
|
||||
mIvSex.setImageBitmap(null);
|
||||
}
|
||||
|
||||
if (mIvTagBoss != null) {
|
||||
mIvTagBoss.setImageBitmap(null);
|
||||
}
|
||||
}
|
||||
|
||||
// 停止并清理动画资源
|
||||
private void stopAndClearAnimation() {
|
||||
if (mIvRipple != null) {
|
||||
// mIvRipple.stopAnimation();
|
||||
mIvRipple.stopAnimation(true);
|
||||
// 清理SVGA资源,避免内存泄漏
|
||||
// mIvRipple.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
// 视图从窗口分离时释放资源
|
||||
releaseResources();
|
||||
super.onDetachedFromWindow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoteSoundLevelUpdate(String userId, int soundLevel) {
|
||||
|
||||
// 暂无实现
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocalSoundLevelUpdate(int volume) {
|
||||
if (volume==0){
|
||||
mIvRipple.stopAnimation();
|
||||
if (mIvRipple == null) {
|
||||
return;
|
||||
}
|
||||
if (volume == 0) {
|
||||
mIvRipple.setVisibility(GONE);
|
||||
mIvRipple.stopAnimation(true);
|
||||
} else {
|
||||
if (pitBean.getUser_id().equals(SpUtil.getUserId()) && closePhone) {
|
||||
mIvRipple.stopAnimation();
|
||||
}else {
|
||||
// 增加空指针检查
|
||||
if (pitBean != null && pitBean.getUser_id() != null &&
|
||||
pitBean.getUser_id().equals(SpUtil.getUserId()) && closePhone) {
|
||||
mIvRipple.stopAnimation(true);
|
||||
} else {
|
||||
mIvRipple.post(() -> {
|
||||
if (!mIvRipple.isAnimating()) {
|
||||
mIvRipple.startAnimation();
|
||||
}
|
||||
mIvRipple.setVisibility(VISIBLE);
|
||||
mIvRipple.startAnimation();
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -236,12 +310,16 @@ public class RoomSingSongWheatView extends BaseWheatView {
|
||||
|
||||
@Override
|
||||
public void userJoined(int userId, int elapsd) {
|
||||
|
||||
// 暂无实现
|
||||
}
|
||||
|
||||
@Override
|
||||
public void userOffline(int userId, int reason) {
|
||||
|
||||
// 暂无实现
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unRegister(Object obj) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,13 +22,12 @@ public class WheatLayoutManager {
|
||||
private int currentSinglePit = -1;
|
||||
private RoomDefaultWheatView singleWheatView;
|
||||
|
||||
// 麦位索引映射:9,10,1~8
|
||||
private final int[] pitIndexMap = {9, 10, 1, 2, 3, 4, 5, 6, 7, 8};
|
||||
|
||||
public interface OnWheatClickListener {
|
||||
void onWheatClick(RoomDefaultWheatView view, int pitNumber);
|
||||
|
||||
void onMakeWheatClick(RoomDefaultWheatView view, int pitNumber);
|
||||
|
||||
}
|
||||
|
||||
private @Nullable OnWheatClickListener wheatClickListener;
|
||||
@@ -39,11 +38,13 @@ public class WheatLayoutManager {
|
||||
}
|
||||
|
||||
public void setWheatData(List<RoomPitBean> pitList) {
|
||||
if (pitList == null || pitList.size() < 10) return;
|
||||
this.pitList = pitList;
|
||||
restoreMultiWheat();
|
||||
}
|
||||
|
||||
public void setWheatDataPk(List<RoomPitBean> pitList, int layoutType) {
|
||||
if (pitList == null || pitList.size() < 10) return;
|
||||
this.pitList = pitList;
|
||||
restoreMultiWheatPk(layoutType);
|
||||
}
|
||||
@@ -54,19 +55,15 @@ public class WheatLayoutManager {
|
||||
|
||||
public void showSingleWheat(int pitNumber) {
|
||||
if (isSingleMode && this.currentSinglePit == pitNumber) return;
|
||||
if (pitNumber < 1 || pitNumber > 10 || pitList == null || pitList.size() < 10) return;
|
||||
|
||||
container.removeAllViews();
|
||||
|
||||
if (pitNumber < 1 || pitNumber > 10 || pitList == null || pitList.size() < 10)
|
||||
return;
|
||||
|
||||
RoomPitBean bean = pitList.get(pitNumber - 1);
|
||||
|
||||
singleWheatView = new RoomDefaultWheatView(context);
|
||||
singleWheatView.pitNumber = String.valueOf(pitNumber);
|
||||
singleWheatView.setData(bean);
|
||||
|
||||
// 默认设置为 MATCH_PARENT,也可以自定义
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
@@ -74,7 +71,6 @@ public class WheatLayoutManager {
|
||||
params.setMargins(20, 20, 20, 20);
|
||||
singleWheatView.setLayoutParams(params);
|
||||
|
||||
// 添加点击事件
|
||||
singleWheatView.setOnClickListener(v -> {
|
||||
if (wheatClickListener != null) {
|
||||
wheatClickListener.onWheatClick(singleWheatView, pitNumber);
|
||||
@@ -91,42 +87,24 @@ public class WheatLayoutManager {
|
||||
container.removeAllViews();
|
||||
|
||||
int screenWidth = getScreenWidth();
|
||||
int itemWidth = screenWidth / 4; // 每个控件宽度为屏幕宽度的 1/4
|
||||
int itemWidth = screenWidth / 4;
|
||||
|
||||
LinearLayout row = new LinearLayout(context);
|
||||
row.setOrientation(LinearLayout.HORIZONTAL);
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
int pitNumber = pitIndexMap[i];
|
||||
RoomDefaultWheatView wheatView = new RoomDefaultWheatView(context);
|
||||
wheatView.pitNumber = String.valueOf(pitNumber);
|
||||
wheatView.setData(pitList.get(pitNumber - 1));
|
||||
RoomDefaultWheatView wheatView = createWheatView(pitNumber);
|
||||
|
||||
LinearLayout.LayoutParams params;
|
||||
|
||||
if (i == 0) {
|
||||
int fixedHeightInDp = 110; // 固定高度为 100dp
|
||||
int fixedHeightInPx = dpToPx(fixedHeightInDp); // 调用已有的 dpToPx 方法
|
||||
// 第一个控件:左边距 86dp,右边距 100dp
|
||||
params = new LinearLayout.LayoutParams(itemWidth, fixedHeightInPx);
|
||||
params.rightMargin = dpToPx(50);
|
||||
} else if (i == 1) {
|
||||
int fixedHeightInDp = 110; // 固定高度为 100dp
|
||||
int fixedHeightInPx = dpToPx(fixedHeightInDp); // 调用已有的 dpToPx 方法
|
||||
// 第二个控件:右边距 86dp
|
||||
if (i == 0 || i == 1) {
|
||||
int fixedHeightInPx = dpToPx(110);
|
||||
params = new LinearLayout.LayoutParams(itemWidth, fixedHeightInPx);
|
||||
if (i == 0) params.rightMargin = dpToPx(50);
|
||||
} else {
|
||||
int fixedHeightInDp = 90; // 固定高度为 100dp
|
||||
int fixedHeightInPx = dpToPx(fixedHeightInDp); // 调用已有的 dpToPx 方法
|
||||
int fixedHeightInPx = dpToPx(90);
|
||||
params = new LinearLayout.LayoutParams(itemWidth - 30, fixedHeightInPx + 30);
|
||||
// 其他控件保持原有逻辑
|
||||
|
||||
|
||||
// if (i > 1 && (i - 2) % 4 != 0) {
|
||||
// params.leftMargin = 12;
|
||||
// params.rightMargin = 12;
|
||||
// }
|
||||
params.setMargins(0, 0, 0, 0); // 不设右边距,由 row padding 控制
|
||||
params.setMargins(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
wheatView.setLayoutParams(params);
|
||||
@@ -134,143 +112,48 @@ public class WheatLayoutManager {
|
||||
if (wheatClickListener != null) {
|
||||
wheatClickListener.onWheatClick(wheatView, Integer.parseInt(wheatView.pitNumber));
|
||||
}
|
||||
// showSingleWheat(Integer.parseInt(wheatView.pitNumber));
|
||||
});
|
||||
|
||||
row.addView(wheatView);
|
||||
|
||||
// 第一行添加两个后换行
|
||||
if (i == 1) {
|
||||
container.addView(row);
|
||||
row = new LinearLayout(context);
|
||||
row.setOrientation(LinearLayout.HORIZONTAL);
|
||||
} else if (i > 1 && (i - 2) % 4 == 3) {
|
||||
if (i == 1 || (i > 1 && (i - 2) % 4 == 3)) {
|
||||
container.addView(row);
|
||||
row = new LinearLayout(context);
|
||||
row.setOrientation(LinearLayout.HORIZONTAL);
|
||||
}
|
||||
}
|
||||
|
||||
// 添加最后一行可能存在的剩余 view
|
||||
if (row.getChildCount() > 0) {
|
||||
container.addView(row);
|
||||
}
|
||||
isSingleMode = false;
|
||||
currentSinglePit = -1;
|
||||
|
||||
}
|
||||
// public void restoreMultiWheatPk(int layoutType, int width) {
|
||||
// container.removeAllViews();
|
||||
//
|
||||
// int screenWidth = getScreenWidth();
|
||||
// int itemWidth = screenWidth / 8; // 每个控件宽度为屏幕宽度的 1/4
|
||||
//
|
||||
// LinearLayout row = new LinearLayout(context);
|
||||
// row.setOrientation(LinearLayout.HORIZONTAL);
|
||||
//
|
||||
// for (int i = 0; i < 10; i++) {
|
||||
// int pitNumber = pitIndexMap[i];
|
||||
// RoomDefaultWheatView wheatView = new RoomDefaultWheatView(context);
|
||||
// wheatView.pitNumber = String.valueOf(pitNumber);
|
||||
// wheatView.setData(pitList.get(pitNumber - 1));
|
||||
//
|
||||
// LinearLayout.LayoutParams params;
|
||||
//
|
||||
// if (i == 0) {
|
||||
// int fixedHeightInDp = 110; // 固定高度为 100dp
|
||||
// int fixedHeightInPx =context.getResources().getDimensionPixelSize(R.dimen.dp_80); // 调用已有的 dpToPx 方法
|
||||
// // 第一个控件:左边距 86dp,右边距 100dp
|
||||
// params = new LinearLayout.LayoutParams(itemWidth, fixedHeightInPx);
|
||||
// params.rightMargin = context.getResources().getDimensionPixelSize(R.dimen.dp_50);
|
||||
// } else if (i == 1) {
|
||||
// int fixedHeightInDp = 110; // 固定高度为 100dp
|
||||
// int fixedHeightInPx = context.getResources().getDimensionPixelSize(R.dimen.dp_80); // 调用已有的 dpToPx 方法
|
||||
// // 第二个控件:右边距 86dp
|
||||
// params = new LinearLayout.LayoutParams(itemWidth, fixedHeightInPx);
|
||||
// } else {
|
||||
// int fixedHeightInDp = 90; // 固定高度为 100dp
|
||||
// int fixedHeightInPx = context.getResources().getDimensionPixelSize(R.dimen.dp_60); // 调用已有的 dpToPx 方法
|
||||
// params = new LinearLayout.LayoutParams(itemWidth -10, fixedHeightInPx + 30);
|
||||
// // 其他控件保持原有逻辑
|
||||
//
|
||||
//
|
||||
//// if (i > 1 && (i - 2) % 4 != 0) {
|
||||
//// params.leftMargin = 12;
|
||||
//// params.rightMargin = 12;
|
||||
//// }
|
||||
// params.setMargins(0, 0, 0, 0); // 不设右边距,由 row padding 控制
|
||||
// }
|
||||
//
|
||||
// wheatView.setLayoutParams(params);
|
||||
// wheatView.setOnClickListener(v -> {
|
||||
// if (wheatClickListener != null) {
|
||||
// wheatClickListener.onWheatClick(wheatView, Integer.parseInt(wheatView.pitNumber));
|
||||
// }
|
||||
//// showSingleWheat(Integer.parseInt(wheatView.pitNumber));
|
||||
// });
|
||||
//
|
||||
// row.addView(wheatView);
|
||||
//
|
||||
// // 第一行添加两个后换行
|
||||
// if (i == 1) {
|
||||
// container.addView(row);
|
||||
// row = new LinearLayout(context);
|
||||
// row.setOrientation(LinearLayout.HORIZONTAL);
|
||||
// } else if (i > 1 && (i - 2) % 4 == 3) {
|
||||
// container.addView(row);
|
||||
// row = new LinearLayout(context);
|
||||
// row.setOrientation(LinearLayout.HORIZONTAL);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//// 添加最后一行可能存在的剩余 view
|
||||
// if (row.getChildCount() > 0) {
|
||||
// container.addView(row);
|
||||
// }
|
||||
// isSingleMode = false;
|
||||
// currentSinglePit = -1;
|
||||
// }
|
||||
|
||||
|
||||
public void restoreMultiWheatPk(int layoutType) {
|
||||
if (layoutType == 1) {
|
||||
container.removeAllViews();
|
||||
}
|
||||
container.removeAllViews();
|
||||
|
||||
int screenWidth = getScreenWidth();
|
||||
int itemWidth = screenWidth / 8;
|
||||
|
||||
LinearLayout row = new LinearLayout(context);
|
||||
row.setOrientation(LinearLayout.HORIZONTAL);
|
||||
|
||||
// 根据 layoutType 调整前两个控件的顺序
|
||||
int firstPitNumber, secondPitNumber;
|
||||
if (layoutType == 1) {
|
||||
firstPitNumber = 10; // 第一个显示 10
|
||||
secondPitNumber = 9; // 第二个显示 9
|
||||
} else if (layoutType == 2) {
|
||||
firstPitNumber = 9; // 第一个显示 9
|
||||
secondPitNumber = 10; // 第二个显示 10
|
||||
} else {
|
||||
firstPitNumber = 9;
|
||||
secondPitNumber = 10;
|
||||
}
|
||||
int firstPitNumber = layoutType == 1 ? 10 : 9;
|
||||
int secondPitNumber = layoutType == 1 ? 9 : 10;
|
||||
|
||||
// 添加第一个控件(10 或 9)
|
||||
addWheatViewItem(row, firstPitNumber, itemWidth*2, layoutType);
|
||||
|
||||
// 添加第二个控件(9 或 10)
|
||||
addWheatViewItem(row, secondPitNumber, itemWidth*2, layoutType);
|
||||
addWheatViewItem(row, firstPitNumber, itemWidth * 2, layoutType);
|
||||
addWheatViewItem(row, secondPitNumber, itemWidth * 2, layoutType);
|
||||
|
||||
container.addView(row);
|
||||
row = new LinearLayout(context);
|
||||
row.setOrientation(LinearLayout.HORIZONTAL);
|
||||
|
||||
// 添加其余 8 个控件(1~8)
|
||||
for (int i = 2; i < 10; i++) {
|
||||
int pitNumber = pitIndexMap[i];
|
||||
addWheatViewItem(row, pitNumber, itemWidth, layoutType);
|
||||
|
||||
if (i > 1 && (i - 2) % 4 == 3) {
|
||||
if ((i - 2) % 4 == 3) {
|
||||
container.addView(row);
|
||||
row = new LinearLayout(context);
|
||||
row.setOrientation(LinearLayout.HORIZONTAL);
|
||||
@@ -285,43 +168,29 @@ public class WheatLayoutManager {
|
||||
currentSinglePit = -1;
|
||||
}
|
||||
|
||||
// 抽取公共方法:添加单个控件
|
||||
private void addWheatViewItem(LinearLayout row, int pitNumber, int itemWidth, int layoutType) {
|
||||
RoomDefaultWheatView wheatView = new RoomDefaultWheatView(context);
|
||||
wheatView.pitNumber = String.valueOf(pitNumber);
|
||||
wheatView.setData(pitList.get(pitNumber - 1));
|
||||
RoomDefaultWheatView wheatView = createWheatView(pitNumber);
|
||||
|
||||
LinearLayout.LayoutParams params;
|
||||
|
||||
if (pitNumber == 9 || pitNumber == 10) {
|
||||
int fixedHeightInPx = context.getResources().getDimensionPixelSize(R.dimen.dp_90);
|
||||
|
||||
if (pitNumber == 9) {
|
||||
params = new LinearLayout.LayoutParams(itemWidth-40, fixedHeightInPx);
|
||||
params = new LinearLayout.LayoutParams(itemWidth - 40, fixedHeightInPx);
|
||||
if (layoutType == 1) {
|
||||
// 9号在右边,右边距10dp
|
||||
params.rightMargin = context.getResources().getDimensionPixelSize(R.dimen.dp_1);
|
||||
params.setMargins(20, -30, -20, 0);
|
||||
} else if (layoutType == 2) {
|
||||
// 9号在左边,左边距10dp
|
||||
} else {
|
||||
params.leftMargin = context.getResources().getDimensionPixelSize(R.dimen.dp_1);
|
||||
params.setMargins(-30, -20, 0, 0);
|
||||
}
|
||||
|
||||
} else {
|
||||
params = new LinearLayout.LayoutParams(itemWidth - 80, fixedHeightInPx);
|
||||
if (layoutType == 1) {
|
||||
// 10号在左边,左边距15dp
|
||||
// params.leftMargin = context.getResources().getDimensionPixelSize(R.dimen.dp_5);
|
||||
params.setMargins(-30, 10, 0, 0);
|
||||
} else if (layoutType == 2) {
|
||||
// 10号在右边,右边距15dp
|
||||
// params.rightMargin = context.getResources().getDimensionPixelSize(R.dimen.dp_5);
|
||||
} else {
|
||||
params.setMargins(0, 10, -30, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
int fixedHeightInPx = context.getResources().getDimensionPixelSize(R.dimen.dp_60);
|
||||
params = new LinearLayout.LayoutParams(itemWidth + 15, fixedHeightInPx + 20);
|
||||
@@ -331,9 +200,9 @@ public class WheatLayoutManager {
|
||||
wheatView.setLayoutParams(params);
|
||||
wheatView.setOnClickListener(v -> {
|
||||
if (wheatClickListener != null) {
|
||||
if (layoutType==1) {
|
||||
if (layoutType == 1) {
|
||||
wheatClickListener.onWheatClick(wheatView, Integer.parseInt(wheatView.pitNumber));
|
||||
}else {
|
||||
} else {
|
||||
wheatClickListener.onMakeWheatClick(wheatView, Integer.parseInt(wheatView.pitNumber));
|
||||
}
|
||||
}
|
||||
@@ -342,7 +211,6 @@ public class WheatLayoutManager {
|
||||
row.addView(wheatView);
|
||||
}
|
||||
|
||||
|
||||
private RoomDefaultWheatView createWheatView(int pitNumber) {
|
||||
RoomDefaultWheatView wheatView = new RoomDefaultWheatView(context);
|
||||
wheatView.pitNumber = String.valueOf(pitNumber);
|
||||
@@ -350,14 +218,6 @@ public class WheatLayoutManager {
|
||||
return wheatView;
|
||||
}
|
||||
|
||||
private RoomMakeWheatView createRoomMakeWheatView(int pitNumber) {
|
||||
RoomMakeWheatView wheatView = new RoomMakeWheatView(context);
|
||||
wheatView.pitNumber = String.valueOf(pitNumber);
|
||||
wheatView.setData(pitList.get(pitNumber - 1));
|
||||
return wheatView;
|
||||
}
|
||||
|
||||
|
||||
private int dpToPx(int dp) {
|
||||
return Math.round(dp * context.getResources().getDisplayMetrics().density);
|
||||
}
|
||||
@@ -367,21 +227,24 @@ public class WheatLayoutManager {
|
||||
return metrics.widthPixels;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新指定 pitNumber 的麦位信息(用于局部刷新)
|
||||
*/
|
||||
|
||||
public void updateSingleWheat(RoomPitBean pitBean, int pitNumber) {
|
||||
if (pitList == null || pitList.isEmpty() || pitNumber < 1 || pitNumber > 10) return;
|
||||
|
||||
// 如果是单个展示模式且不是当前麦位,不处理
|
||||
if (isSingleMode && this.currentSinglePit != pitNumber) return;
|
||||
|
||||
RoomDefaultWheatView wheatView = findWheatViewByPitNumber(pitNumber);
|
||||
if (wheatView != null) {
|
||||
wheatView.setData(pitBean);
|
||||
}
|
||||
}
|
||||
|
||||
// RoomPitBean bean = pitList.get(pitNumber - 1);
|
||||
RoomPitBean bean = pitBean;
|
||||
wheatView.setData(bean); // 刷新数据
|
||||
public void updateSingleCharm(RoomPitBean pitBean, int pitNumber) {
|
||||
if (pitList == null || pitList.isEmpty() || pitNumber < 1 || pitNumber > 10) return;
|
||||
if (isSingleMode && this.currentSinglePit != pitNumber) return;
|
||||
|
||||
RoomDefaultWheatView wheatView = findWheatViewByPitNumber(pitNumber);
|
||||
if (wheatView != null) {
|
||||
wheatView.setCharm(pitBean.getCharm());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -410,22 +273,37 @@ public class WheatLayoutManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量刷新多个麦位状态
|
||||
*/
|
||||
public void refreshWheatData(List<RoomPitBean> newPitList, List<Integer> changedPits) {
|
||||
this.pitList = newPitList;
|
||||
for (int pitNumber : changedPits) {
|
||||
// updateSingleWheat(pitNumber);
|
||||
updateSingleWheat(pitList.get(pitNumber - 1), pitNumber);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateSingleOnlineWheat(UserOnlineStatusBean bean) {
|
||||
if (pitList == null || pitList.isEmpty()) return;
|
||||
if (pitList == null || pitList.isEmpty() || bean == null) return;
|
||||
|
||||
for (RoomPitBean pitBean : pitList) {
|
||||
int pitNumber = Integer.parseInt(pitBean.getPit_number());
|
||||
RoomDefaultWheatView wheatView = findWheatViewByPitNumber(pitNumber);
|
||||
wheatView.setOnlineStatus(bean); // 刷新数据
|
||||
if (wheatView != null) {
|
||||
wheatView.setOnlineStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
container.removeAllViews();
|
||||
pitList = null;
|
||||
singleWheatView = null;
|
||||
isSingleMode = false;
|
||||
currentSinglePit = -1;
|
||||
}
|
||||
|
||||
public void clearData() {
|
||||
pitList = null;
|
||||
singleWheatView = null;
|
||||
isSingleMode = false;
|
||||
currentSinglePit = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,10 +8,14 @@ import android.widget.LinearLayout;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.bean.RoomMessageEvent;
|
||||
import com.xscm.moduleutil.bean.UserOnlineStatusBean;
|
||||
import com.xscm.moduleutil.bean.room.RoomPitBean;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -26,6 +30,7 @@ public class WheatLayoutSingManager {
|
||||
private boolean isSingleMode = false;
|
||||
private int currentSinglePit = -1;
|
||||
private RoomSingSongWheatView singleWheatView;
|
||||
private List<RoomSingSongWheatView> multiWheatViews=new ArrayList<>();
|
||||
|
||||
private final int[] pitIndexMap = {9, 10, 1, 2, 3, 4, 5, 6, 7, 8};
|
||||
|
||||
@@ -34,6 +39,8 @@ public class WheatLayoutSingManager {
|
||||
|
||||
void onMakeWheatClick(RoomSingSongWheatView view, int pitNumber);
|
||||
|
||||
void onMeilingClick(RoomSingSongWheatView view, int pitNumber);
|
||||
|
||||
}
|
||||
|
||||
private @Nullable OnWheatClickListener wheatClickListener;
|
||||
@@ -44,11 +51,21 @@ public class WheatLayoutSingManager {
|
||||
}
|
||||
|
||||
public void setWheatData(List<RoomPitBean> pitList) {
|
||||
// 检查容器状态
|
||||
if (container == null || !isContainerValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.pitList = pitList;
|
||||
restoreMultiWheat();
|
||||
}
|
||||
|
||||
public void setWheatDataPk(List<RoomPitBean> pitList, int layoutType) {
|
||||
// 检查容器状态
|
||||
if (container == null || !isContainerValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.pitList = pitList;
|
||||
restoreMultiWheatPk(layoutType);
|
||||
}
|
||||
@@ -58,9 +75,19 @@ public class WheatLayoutSingManager {
|
||||
}
|
||||
|
||||
public void showSingleWheat(int pitNumber) {
|
||||
// 检查容器状态
|
||||
if (container == null || !isContainerValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isSingleMode && this.currentSinglePit == pitNumber) return;
|
||||
|
||||
container.removeAllViews();
|
||||
try {
|
||||
container.removeAllViews();
|
||||
} catch (Exception e) {
|
||||
// 忽略异常,继续执行
|
||||
return;
|
||||
}
|
||||
|
||||
if (pitNumber < 1 || pitNumber > 10 || pitList == null || pitList.size() < 10)
|
||||
return;
|
||||
@@ -79,21 +106,51 @@ public class WheatLayoutSingManager {
|
||||
params.setMargins(20, 20, 20, 20);
|
||||
singleWheatView.setLayoutParams(params);
|
||||
|
||||
// 添加点击事件
|
||||
singleWheatView.setOnClickListener(v -> {
|
||||
GifAvatarOvalView avatarView = (GifAvatarOvalView) singleWheatView.mRiv;
|
||||
avatarView.setOnClickListener(v -> {
|
||||
if (wheatClickListener != null) {
|
||||
wheatClickListener.onWheatClick(singleWheatView, pitNumber);
|
||||
}
|
||||
restoreMultiWheat();
|
||||
});
|
||||
|
||||
WheatCharmView charmView = singleWheatView.mCharmView;
|
||||
charmView.setOnClickListener(v -> {
|
||||
if (wheatClickListener != null) {
|
||||
wheatClickListener.onMeilingClick(singleWheatView, Integer.parseInt(singleWheatView.pitNumber));
|
||||
}
|
||||
});
|
||||
// // 添加点击事件
|
||||
singleWheatView.setOnClickListener(v -> {
|
||||
if (wheatClickListener != null) {
|
||||
wheatClickListener.onMakeWheatClick(singleWheatView, pitNumber);
|
||||
}
|
||||
restoreMultiWheat();
|
||||
});
|
||||
|
||||
container.addView(singleWheatView);
|
||||
isSingleMode = true;
|
||||
currentSinglePit = pitNumber;
|
||||
}
|
||||
|
||||
public void restoreMultiWheat() {
|
||||
container.removeAllViews();
|
||||
// 检查容器状态
|
||||
if (container == null || !isContainerValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
container.removeAllViews();
|
||||
} catch (Exception e) {
|
||||
// 忽略异常,继续执行
|
||||
return;
|
||||
}
|
||||
|
||||
if (pitList == null || pitList.size() < 10) {
|
||||
return;
|
||||
}
|
||||
|
||||
multiWheatViews.clear();
|
||||
|
||||
int screenWidth = getScreenWidth();
|
||||
int itemWidth = screenWidth / 4; // 每个控件宽度为屏幕宽度的 1/4
|
||||
@@ -106,7 +163,7 @@ public class WheatLayoutSingManager {
|
||||
RoomSingSongWheatView wheatView = new RoomSingSongWheatView(context);
|
||||
wheatView.pitNumber = String.valueOf(pitNumber);
|
||||
wheatView.setData(pitList.get(pitNumber - 1));
|
||||
|
||||
multiWheatViews.add(wheatView);
|
||||
LinearLayout.LayoutParams params;
|
||||
|
||||
if (i == 0) {
|
||||
@@ -126,20 +183,31 @@ public class WheatLayoutSingManager {
|
||||
params = new LinearLayout.LayoutParams(itemWidth - 30, fixedHeightInPx + 30);
|
||||
// 其他控件保持原有逻辑
|
||||
|
||||
|
||||
// if (i > 1 && (i - 2) % 4 != 0) {
|
||||
// params.leftMargin = 12;
|
||||
// params.rightMargin = 12;
|
||||
// }
|
||||
params.setMargins(0, 0, 0, 0); // 不设右边距,由 row padding 控制
|
||||
}
|
||||
|
||||
wheatView.setLayoutParams(params);
|
||||
|
||||
|
||||
GifAvatarOvalView avatarView = (GifAvatarOvalView) wheatView.mRiv;
|
||||
avatarView.setOnClickListener(v -> {
|
||||
if (wheatClickListener != null) {
|
||||
wheatClickListener.onWheatClick(wheatView, pitNumber);
|
||||
}
|
||||
});
|
||||
|
||||
WheatCharmView charmView = wheatView.mCharmView;
|
||||
charmView.setOnClickListener(v -> {
|
||||
if (wheatClickListener != null) {
|
||||
ToastUtils.show("点击了麦位");
|
||||
wheatClickListener.onMeilingClick(wheatView, pitNumber);
|
||||
}
|
||||
});
|
||||
|
||||
wheatView.setOnClickListener(v -> {
|
||||
if (wheatClickListener != null) {
|
||||
wheatClickListener.onWheatClick(wheatView, Integer.parseInt(wheatView.pitNumber));
|
||||
wheatClickListener.onMeilingClick(wheatView, Integer.parseInt(wheatView.pitNumber));
|
||||
}
|
||||
// showSingleWheat(Integer.parseInt(wheatView.pitNumber));
|
||||
});
|
||||
|
||||
row.addView(wheatView);
|
||||
@@ -156,91 +224,33 @@ public class WheatLayoutSingManager {
|
||||
}
|
||||
}
|
||||
|
||||
// 添加最后一行可能存在的剩余 view
|
||||
// 添加最后一行可能存在的剩余 view
|
||||
if (row.getChildCount() > 0) {
|
||||
container.addView(row);
|
||||
}
|
||||
isSingleMode = false;
|
||||
currentSinglePit = -1;
|
||||
|
||||
}
|
||||
// public void restoreMultiWheatPk(int layoutType, int width) {
|
||||
// container.removeAllViews();
|
||||
//
|
||||
// int screenWidth = getScreenWidth();
|
||||
// int itemWidth = screenWidth / 8; // 每个控件宽度为屏幕宽度的 1/4
|
||||
//
|
||||
// LinearLayout row = new LinearLayout(context);
|
||||
// row.setOrientation(LinearLayout.HORIZONTAL);
|
||||
//
|
||||
// for (int i = 0; i < 10; i++) {
|
||||
// int pitNumber = pitIndexMap[i];
|
||||
// RoomDefaultWheatView wheatView = new RoomDefaultWheatView(context);
|
||||
// wheatView.pitNumber = String.valueOf(pitNumber);
|
||||
// wheatView.setData(pitList.get(pitNumber - 1));
|
||||
//
|
||||
// LinearLayout.LayoutParams params;
|
||||
//
|
||||
// if (i == 0) {
|
||||
// int fixedHeightInDp = 110; // 固定高度为 100dp
|
||||
// int fixedHeightInPx =context.getResources().getDimensionPixelSize(R.dimen.dp_80); // 调用已有的 dpToPx 方法
|
||||
// // 第一个控件:左边距 86dp,右边距 100dp
|
||||
// params = new LinearLayout.LayoutParams(itemWidth, fixedHeightInPx);
|
||||
// params.rightMargin = context.getResources().getDimensionPixelSize(R.dimen.dp_50);
|
||||
// } else if (i == 1) {
|
||||
// int fixedHeightInDp = 110; // 固定高度为 100dp
|
||||
// int fixedHeightInPx = context.getResources().getDimensionPixelSize(R.dimen.dp_80); // 调用已有的 dpToPx 方法
|
||||
// // 第二个控件:右边距 86dp
|
||||
// params = new LinearLayout.LayoutParams(itemWidth, fixedHeightInPx);
|
||||
// } else {
|
||||
// int fixedHeightInDp = 90; // 固定高度为 100dp
|
||||
// int fixedHeightInPx = context.getResources().getDimensionPixelSize(R.dimen.dp_60); // 调用已有的 dpToPx 方法
|
||||
// params = new LinearLayout.LayoutParams(itemWidth -10, fixedHeightInPx + 30);
|
||||
// // 其他控件保持原有逻辑
|
||||
//
|
||||
//
|
||||
//// if (i > 1 && (i - 2) % 4 != 0) {
|
||||
//// params.leftMargin = 12;
|
||||
//// params.rightMargin = 12;
|
||||
//// }
|
||||
// params.setMargins(0, 0, 0, 0); // 不设右边距,由 row padding 控制
|
||||
// }
|
||||
//
|
||||
// wheatView.setLayoutParams(params);
|
||||
// wheatView.setOnClickListener(v -> {
|
||||
// if (wheatClickListener != null) {
|
||||
// wheatClickListener.onWheatClick(wheatView, Integer.parseInt(wheatView.pitNumber));
|
||||
// }
|
||||
//// showSingleWheat(Integer.parseInt(wheatView.pitNumber));
|
||||
// });
|
||||
//
|
||||
// row.addView(wheatView);
|
||||
//
|
||||
// // 第一行添加两个后换行
|
||||
// if (i == 1) {
|
||||
// container.addView(row);
|
||||
// row = new LinearLayout(context);
|
||||
// row.setOrientation(LinearLayout.HORIZONTAL);
|
||||
// } else if (i > 1 && (i - 2) % 4 == 3) {
|
||||
// container.addView(row);
|
||||
// row = new LinearLayout(context);
|
||||
// row.setOrientation(LinearLayout.HORIZONTAL);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//// 添加最后一行可能存在的剩余 view
|
||||
// if (row.getChildCount() > 0) {
|
||||
// container.addView(row);
|
||||
// }
|
||||
// isSingleMode = false;
|
||||
// currentSinglePit = -1;
|
||||
// }
|
||||
|
||||
|
||||
public void restoreMultiWheatPk(int layoutType) {
|
||||
if (layoutType == 1) {
|
||||
container.removeAllViews();
|
||||
// 检查容器状态
|
||||
if (container == null || !isContainerValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (layoutType == 1) {
|
||||
try {
|
||||
container.removeAllViews();
|
||||
} catch (Exception e) {
|
||||
// 忽略异常,继续执行
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (pitList == null || pitList.size() < 10) {
|
||||
return;
|
||||
}
|
||||
|
||||
int screenWidth = getScreenWidth();
|
||||
int itemWidth = screenWidth / 8;
|
||||
|
||||
@@ -292,6 +302,11 @@ public class WheatLayoutSingManager {
|
||||
|
||||
// 抽取公共方法:添加单个控件
|
||||
private void addWheatViewItem(LinearLayout row, int pitNumber, int itemWidth, int layoutType) {
|
||||
// 检查容器状态
|
||||
if (!isContainerValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
RoomSingSongWheatView wheatView = new RoomSingSongWheatView(context);
|
||||
wheatView.pitNumber = String.valueOf(pitNumber);
|
||||
wheatView.setData(pitList.get(pitNumber - 1));
|
||||
@@ -317,11 +332,9 @@ public class WheatLayoutSingManager {
|
||||
params = new LinearLayout.LayoutParams(itemWidth - 80, fixedHeightInPx);
|
||||
if (layoutType == 1) {
|
||||
// 10号在左边,左边距15dp
|
||||
// params.leftMargin = context.getResources().getDimensionPixelSize(R.dimen.dp_5);
|
||||
params.setMargins(-30, 10, 0, 0);
|
||||
} else if (layoutType == 2) {
|
||||
// 10号在右边,右边距15dp
|
||||
// params.rightMargin = context.getResources().getDimensionPixelSize(R.dimen.dp_5);
|
||||
params.setMargins(0, 10, -30, 0);
|
||||
}
|
||||
|
||||
@@ -347,7 +360,6 @@ public class WheatLayoutSingManager {
|
||||
row.addView(wheatView);
|
||||
}
|
||||
|
||||
|
||||
private RoomSingSongWheatView createWheatView(int pitNumber) {
|
||||
RoomSingSongWheatView wheatView = new RoomSingSongWheatView(context);
|
||||
wheatView.pitNumber = String.valueOf(pitNumber);
|
||||
@@ -362,7 +374,6 @@ public class WheatLayoutSingManager {
|
||||
return wheatView;
|
||||
}
|
||||
|
||||
|
||||
private int dpToPx(int dp) {
|
||||
return Math.round(dp * context.getResources().getDisplayMetrics().density);
|
||||
}
|
||||
@@ -372,10 +383,49 @@ public class WheatLayoutSingManager {
|
||||
return metrics.widthPixels;
|
||||
}
|
||||
|
||||
public void setUpData(RoomMessageEvent event){
|
||||
String fromPit=event.getText().getFrom_pit_number()!=null?event.getText().getFrom_pit_number():"";
|
||||
String toPitNumber=event.getText().getTo_pit_number()!=null?event.getText().getTo_pit_number():"";
|
||||
if (fromPit.equals("") || toPitNumber.equals("")){
|
||||
return;
|
||||
}
|
||||
RoomSingSongWheatView fromWheatView = findWheatViewByPitNumber(Integer.parseInt(fromPit));
|
||||
RoomSingSongWheatView toWheatView = findWheatViewByPitNumber(Integer.parseInt(toPitNumber));
|
||||
RoomPitBean fromPitBean=fromWheatView.pitBean;
|
||||
RoomPitBean toPitBean=toWheatView.pitBean;
|
||||
String tmpNumber=fromPitBean.getPit_number();
|
||||
fromPitBean.setPit_number(toPitBean.getPit_number());
|
||||
toPitBean.setPit_number(tmpNumber);
|
||||
toWheatView.setData(fromPitBean);
|
||||
fromWheatView.setData(toPitBean);
|
||||
for (RoomSingSongWheatView view : multiWheatViews){
|
||||
if (view.pitBean.getUser_id().equals(event.getText().getFromUserInfo().getUser_id()+"")){
|
||||
if (!view.pitBean.getPit_number().equals(toPitNumber)){
|
||||
RoomPitBean bean=view.pitBean;
|
||||
bean.setCharm("");
|
||||
bean.setUser_id("");
|
||||
bean.setDress("");
|
||||
bean.setAvatar("");
|
||||
bean.setNickname("");
|
||||
bean.setSex("");
|
||||
bean.setUser_code("");
|
||||
bean.setDress_picture("");
|
||||
view.setData(bean);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新指定 pitNumber 的麦位信息(用于局部刷新)
|
||||
*/
|
||||
public void updateSingleWheat(RoomPitBean pitBean, int pitNumber) {
|
||||
// 检查容器状态
|
||||
if (container == null || !isContainerValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (pitList == null || pitList.isEmpty() || pitNumber < 1 || pitNumber > 10) return;
|
||||
|
||||
// 如果是单个展示模式且不是当前麦位,不处理
|
||||
@@ -383,15 +433,36 @@ public class WheatLayoutSingManager {
|
||||
|
||||
RoomSingSongWheatView wheatView = findWheatViewByPitNumber(pitNumber);
|
||||
if (wheatView != null) {
|
||||
|
||||
// RoomPitBean bean = pitList.get(pitNumber - 1);
|
||||
RoomPitBean bean = pitBean;
|
||||
wheatView.setData(bean); // 刷新数据
|
||||
}
|
||||
}
|
||||
|
||||
public void upDataCharm(RoomPitBean pitBean, int pitNumber){
|
||||
// 检查容器状态
|
||||
if (container == null || !isContainerValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (pitList == null || pitList.isEmpty() || pitNumber < 1 || pitNumber > 10) return;
|
||||
|
||||
// 如果是单个展示模式且不是当前麦位,不处理
|
||||
if (isSingleMode && this.currentSinglePit != pitNumber) return;
|
||||
|
||||
RoomSingSongWheatView wheatView = findWheatViewByPitNumber(pitNumber);
|
||||
if (wheatView != null) {
|
||||
RoomPitBean bean = pitBean;
|
||||
wheatView.setCharm(bean.getCharm()); // 刷新数据
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private RoomSingSongWheatView findWheatViewByPitNumber(int pitNumber) {
|
||||
// 检查容器状态
|
||||
if (container == null || !isContainerValid()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (int i = 0; i < container.getChildCount(); i++) {
|
||||
View row = container.getChildAt(i);
|
||||
if (row instanceof LinearLayout) {
|
||||
@@ -419,21 +490,81 @@ public class WheatLayoutSingManager {
|
||||
* 批量刷新多个麦位状态
|
||||
*/
|
||||
public void refreshWheatData(List<RoomPitBean> newPitList, List<Integer> changedPits) {
|
||||
this.pitList = newPitList;
|
||||
for (int pitNumber : changedPits) {
|
||||
// updateSingleWheat(pitNumber);
|
||||
// 检查容器状态
|
||||
if (container == null || !isContainerValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.pitList = newPitList;
|
||||
// 注意:原代码中此方法体为空,如果需要实现请取消注释下面的代码
|
||||
// for (int pitNumber : changedPits) {
|
||||
// updateSingleWheat(pitNumber);
|
||||
// }
|
||||
}
|
||||
|
||||
public void updateSingleOnlineWheat(UserOnlineStatusBean bean) {
|
||||
// 检查容器状态
|
||||
if (container == null || !isContainerValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (pitList == null || pitList.isEmpty()) return;
|
||||
|
||||
for (RoomPitBean pitBean : pitList) {
|
||||
int pitNumber = Integer.parseInt(pitBean.getPit_number());
|
||||
RoomSingSongWheatView wheatView = findWheatViewByPitNumber(pitNumber);
|
||||
wheatView.setOnlineStatus(bean); // 刷新数据
|
||||
if (wheatView != null) {
|
||||
wheatView.setOnlineStatus(); // 刷新数据
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 添加容器状态检查方法
|
||||
private boolean isContainerValid() {
|
||||
try {
|
||||
// 检查容器是否已附加到窗口
|
||||
return container != null && container.isAttachedToWindow();
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 添加资源清理方法
|
||||
public void release() {
|
||||
try {
|
||||
|
||||
if (multiWheatViews!=null){
|
||||
for (RoomSingSongWheatView wheatView : multiWheatViews) {
|
||||
wheatView.releaseResources();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (container != null) {
|
||||
// 清理所有子视图的资源
|
||||
// for (int i = 0; i < container.getChildCount(); i++) {
|
||||
// View child = container.getChildAt(i);
|
||||
// if (child instanceof LinearLayout) {
|
||||
// LinearLayout linearLayout = (LinearLayout) child;
|
||||
// for (int j = 0; j < linearLayout.getChildCount(); j++) {
|
||||
// View view = linearLayout.getChildAt(j);
|
||||
// if (view instanceof RoomSingSongWheatView) {
|
||||
// ((RoomSingSongWheatView) view).releaseResources();
|
||||
// }
|
||||
// }
|
||||
// } else if (child instanceof RoomSingSongWheatView) {
|
||||
// ((RoomSingSongWheatView) child).releaseResources();
|
||||
// }
|
||||
// }
|
||||
container.removeAllViews();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 忽略异常
|
||||
}
|
||||
|
||||
// 清理引用
|
||||
pitList = null;
|
||||
singleWheatView = null;
|
||||
wheatClickListener = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.base.BaseMvpDialogFragment;
|
||||
import com.xscm.moduleutil.bean.GiftLabelBean;
|
||||
import com.xscm.moduleutil.bean.GiftPackBean;
|
||||
import com.xscm.moduleutil.bean.GiftPackListCount;
|
||||
import com.xscm.moduleutil.bean.RewardUserBean;
|
||||
import com.xscm.moduleutil.bean.RoonGiftModel;
|
||||
import com.xscm.moduleutil.bean.WalletBean;
|
||||
@@ -191,4 +192,14 @@ public class RewardDialogFragment extends BaseMvpDialogFragment<RewardGiftPresen
|
||||
public void giftPack(List<GiftPackBean> giftPackBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGiftPack(String s) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGiftPackListCount(GiftPackListCount giftPackListCount) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentStatePagerAdapter;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
@@ -25,6 +26,7 @@ import com.xscm.moduleutil.base.BaseMvpDialogFragment;
|
||||
import com.xscm.moduleutil.bean.GiftLabelBean;
|
||||
import com.xscm.moduleutil.bean.GiftNumBean;
|
||||
import com.xscm.moduleutil.bean.GiftPackBean;
|
||||
import com.xscm.moduleutil.bean.GiftPackListCount;
|
||||
import com.xscm.moduleutil.bean.RewardUserBean;
|
||||
import com.xscm.moduleutil.bean.RoonGiftModel;
|
||||
import com.xscm.moduleutil.bean.WalletBean;
|
||||
@@ -33,13 +35,17 @@ import com.xscm.moduleutil.color.ThemeableDrawableUtils;
|
||||
import com.xscm.moduleutil.databinding.FragmentRewardGiftDialogBinding;
|
||||
import com.xscm.moduleutil.dialog.RechargeDialogFragment;
|
||||
import com.xscm.moduleutil.event.GiftRewardEvent;
|
||||
import com.xscm.moduleutil.event.GiftUserRefreshEvent;
|
||||
import com.xscm.moduleutil.presenter.RewardGiftContacts;
|
||||
import com.xscm.moduleutil.presenter.RewardGiftPresenter;
|
||||
import com.xscm.moduleutil.utils.ColorManager;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
import com.xscm.moduleutil.widget.GifAvatarOvalView;
|
||||
import com.xscm.moduleutil.widget.floatingView.IFloatingView;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -100,6 +106,9 @@ public class RewardGiftDialogFragment extends BaseMvpDialogFragment<RewardGiftPr
|
||||
mGiftNumList.add(new GiftNumBean("10", "x10"));
|
||||
mGiftNumList.add(new GiftNumBean("5", "x5"));
|
||||
mGiftNumList.add(new GiftNumBean("1", "x1"));
|
||||
if (!EventBus.getDefault().isRegistered( this)){
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -155,7 +164,7 @@ public class RewardGiftDialogFragment extends BaseMvpDialogFragment<RewardGiftPr
|
||||
}else if (view1.getId()== com.xscm.moduleutil.R.id.tv_reward_num){
|
||||
RewardDialogFragment.show(circle_id,getChildFragmentManager());
|
||||
}else if (view1.getId()== R.id.cz){
|
||||
RechargeDialogFragment.show("",null, getActivity().getSupportFragmentManager());
|
||||
RechargeDialogFragment.show("",null, getActivity().getSupportFragmentManager(),"0","0");
|
||||
}else if (view1.getId()== R.id.tv_give){
|
||||
for (int i=0;i<mGiftNumList.size();i++) {
|
||||
if (mBinding.tvGiveCoinNum.getText().toString().equals(mGiftNumList.get(i).getText())) {
|
||||
@@ -188,46 +197,108 @@ public class RewardGiftDialogFragment extends BaseMvpDialogFragment<RewardGiftPr
|
||||
mBinding.tvRewardTitle.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
private List<GiftLabelBean> giftLabelBeanList;
|
||||
|
||||
@Override
|
||||
public void getGiftLabel(List<GiftLabelBean> giftLabelBeans) {
|
||||
mBinding.viewPager.setAdapter(new MyFragmentPagerAdapter(getChildFragmentManager(), giftLabelBeans,fragmentList));
|
||||
// giftLabelBeanList = new ArrayList<>();
|
||||
// giftLabelBeanList.addAll(giftLabelBeans);
|
||||
// GiftLabelBean giftLabelBean = new GiftLabelBean();
|
||||
// giftLabelBean.setId("0");
|
||||
// giftLabelBean.setName("背包");
|
||||
// giftLabelBeans.add(0, giftLabelBean);
|
||||
mBinding.viewPager.setAdapter(new MyFragmentPagerAdapter(getChildFragmentManager(), giftLabelBeans,fragmentList,""));
|
||||
mBinding.slidingTabLayout.setViewPager(mBinding.viewPager);
|
||||
mBinding.slidingTabLayout.setCurrentTab(0);
|
||||
refreshCurrentGiftFragment(giftLabelBeans.get(0).getId(),2,"");
|
||||
mBinding.viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
// 当页面切换时,控制 tv_bb_qs 按钮的显示
|
||||
refreshCurrentGiftFragment(giftLabelBeans.get(position).getId(),2,"");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged(int state) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
private void refreshCurrentGiftFragment(String id,int type,String roomId) {
|
||||
if (getCurrentGiftFragment()!=null){
|
||||
getCurrentGiftFragment().loadDataIfNeeded(id,type,roomId);
|
||||
}
|
||||
}
|
||||
private GiftTwoDetailsFragment getCurrentGiftFragment() {
|
||||
int currentPosition = mBinding.viewPager.getCurrentItem();
|
||||
// 使用 ViewPager 的 adapter 获取当前 fragment
|
||||
MyFragmentPagerAdapter adapter = (MyFragmentPagerAdapter) mBinding.viewPager.getAdapter();
|
||||
if (adapter != null) {
|
||||
// 直接从 adapter 获取 fragment
|
||||
Fragment fragment = adapter.getItem(currentPosition);
|
||||
if (fragment instanceof GiftTwoDetailsFragment) {
|
||||
return (GiftTwoDetailsFragment) fragment;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private GiftPackBean giftModel = null;
|
||||
private int getSelectedGift() {
|
||||
int currentItem = mBinding.viewPager.getCurrentItem();
|
||||
// if (currentItem < 1) { //比2小是才是礼物
|
||||
GiftTwoDetailsFragment fragment = (GiftTwoDetailsFragment) fragmentList.get(currentItem);
|
||||
roonGiftModel = fragment.getGiftList();
|
||||
// GiftTwoDetailsFragment fragment = (GiftTwoDetailsFragment) fragmentList.get(currentItem);
|
||||
// roonGiftModel = fragment.getGiftList();
|
||||
// }
|
||||
// else {
|
||||
// GiftFragment fragment = (GiftFragment) fragmentList.get(currentItem);
|
||||
// giftModel = fragment.getmData();
|
||||
// }
|
||||
|
||||
// if (currentItem < 1) { //比1小的是背包
|
||||
// GiftTwoDetailsFragment fragment = (GiftTwoDetailsFragment) fragmentList.get(currentItem);
|
||||
// if (fragment != null && giftModel == null) {
|
||||
// giftModel = fragment.mGiftList();
|
||||
// }
|
||||
// } else {
|
||||
// GiftTwoDetailsFragment fragment = (GiftTwoDetailsFragment) fragmentList.get(currentItem);
|
||||
// if (fragment != null && roonGiftModel == null) {
|
||||
// roonGiftModel = fragment.getGiftList();
|
||||
// }
|
||||
// }
|
||||
return currentItem;
|
||||
}
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void userRefresh(GiftUserRefreshEvent event) {
|
||||
if (event.addSelf) {
|
||||
roonGiftModel = event.gift;
|
||||
}
|
||||
}
|
||||
|
||||
private void giveGift(String num) {
|
||||
getSelectedGift();
|
||||
int currentItem = mBinding.viewPager.getCurrentItem();
|
||||
String userId = user_id;
|
||||
if (currentItem < 1) {
|
||||
if (roonGiftModel == null) {
|
||||
ToastUtils.show("请选择礼物");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (TextUtils.isEmpty(num)) {
|
||||
ToastUtils.show("请选择打赏礼物数量");
|
||||
return;
|
||||
}
|
||||
if (Integer.valueOf(num) <= 0) {
|
||||
ToastUtils.show("请选择打赏礼物数量");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// if (currentItem < 1) {
|
||||
// if (roonGiftModel == null) {
|
||||
// ToastUtils.show("请选择礼物");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// if (TextUtils.isEmpty(num)) {
|
||||
// ToastUtils.show("请选择打赏礼物数量");
|
||||
// return;
|
||||
// }
|
||||
// if (Integer.valueOf(num) <= 0) {
|
||||
// ToastUtils.show("请选择打赏礼物数量");
|
||||
// return;
|
||||
// }
|
||||
// } else {
|
||||
if (roonGiftModel == null) {
|
||||
ToastUtils.show("请选择礼物");
|
||||
return;
|
||||
@@ -241,19 +312,19 @@ public class RewardGiftDialogFragment extends BaseMvpDialogFragment<RewardGiftPr
|
||||
ToastUtils.show("请选择打赏礼物数量");
|
||||
return;
|
||||
}
|
||||
}
|
||||
// }
|
||||
|
||||
if (currentItem == 0) {
|
||||
// if (currentItem == 0) {
|
||||
//礼物打赏
|
||||
giftNumber = num;
|
||||
MvpPre.reward_zone(circle_id, roonGiftModel.getGift_id(), num, "1");
|
||||
} else {
|
||||
// } else {
|
||||
//背包礼物打赏
|
||||
// giftNumber = num;
|
||||
// roomGiftGiveEvent = new RoomGiftGiveEvent(userId, roomId, pit, num, 1, giftModel, null);
|
||||
//
|
||||
// MvpPre.giveBackGift(userId, giftModel.getGift_id(), roomId, pit, num, giftModel, 1);
|
||||
}
|
||||
// }
|
||||
}
|
||||
@Override
|
||||
public void setGiftList(List<RoonGiftModel> roonGiftModels,int type) {
|
||||
@@ -273,7 +344,7 @@ public class RewardGiftDialogFragment extends BaseMvpDialogFragment<RewardGiftPr
|
||||
@Override
|
||||
public void reward_zone() {
|
||||
com.blankj.utilcode.util.ToastUtils.showShort("打赏成功");
|
||||
EventBus.getDefault().post(new GiftRewardEvent(point));
|
||||
EventBus.getDefault().post(new GiftRewardEvent(point,circle_id));
|
||||
dismiss();
|
||||
}
|
||||
|
||||
@@ -287,22 +358,71 @@ public class RewardGiftDialogFragment extends BaseMvpDialogFragment<RewardGiftPr
|
||||
|
||||
}
|
||||
|
||||
private static class MyFragmentPagerAdapter extends FragmentStatePagerAdapter {
|
||||
@Override
|
||||
public void getGiftPack(String s) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGiftPackListCount(GiftPackListCount giftPackListCount) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
if (!EventBus.getDefault().isRegistered( this)){
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (!EventBus.getDefault().isRegistered( this)){
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
}
|
||||
|
||||
private class MyFragmentPagerAdapter extends FragmentStatePagerAdapter {
|
||||
|
||||
private List<GiftLabelBean> list;
|
||||
private List<Fragment> fragmentList ;
|
||||
private List<Fragment> fragmentList;
|
||||
private String roomId;
|
||||
|
||||
public MyFragmentPagerAdapter(FragmentManager fm, List<GiftLabelBean> list,List<Fragment> fragmentList) {
|
||||
public MyFragmentPagerAdapter(FragmentManager fm, List<GiftLabelBean> list, List<Fragment> fragmentList, String roomId) {
|
||||
super(fm);
|
||||
this.list = list;
|
||||
this.fragmentList = fragmentList;
|
||||
this.list = list != null ? list : new ArrayList<>();
|
||||
// 不直接使用传入的 fragmentList,而是创建一个新的列表
|
||||
this.fragmentList = new ArrayList<>();
|
||||
// 初始化 fragmentList 的大小,用 null 填充
|
||||
for (int i = 0; i < this.list.size(); i++) {
|
||||
this.fragmentList.add(null);
|
||||
}
|
||||
this.roomId = roomId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
// 边界检查
|
||||
if (position < 0 || list == null || position >= list.size()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 检查该位置是否已经有 Fragment 实例
|
||||
if (position < fragmentList.size() && fragmentList.get(position) != null) {
|
||||
return fragmentList.get(position);
|
||||
}
|
||||
// 创建新的 Fragment
|
||||
GiftLabelBean model = list.get(position);
|
||||
Fragment fragment = GiftTwoDetailsFragment.newInstance(model.getId(), 2);
|
||||
fragmentList.add(fragment); // 保存 Fragment 实例
|
||||
Fragment fragment = GiftTwoDetailsFragment.newInstance(model.getId(), 1, roomId);
|
||||
// 确保 fragmentList 有足够的空间
|
||||
while (fragmentList.size() <= position) {
|
||||
fragmentList.add(null);
|
||||
}
|
||||
|
||||
// 在指定位置设置 Fragment 实例
|
||||
fragmentList.set(position, fragment);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@@ -314,6 +434,9 @@ public class RewardGiftDialogFragment extends BaseMvpDialogFragment<RewardGiftPr
|
||||
@Nullable
|
||||
@Override
|
||||
public CharSequence getPageTitle(int position) {
|
||||
if (list == null || position < 0 || position >= list.size()) {
|
||||
return null;
|
||||
}
|
||||
GiftLabelBean model = list.get(position);
|
||||
return model.getName();
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.blankj.utilcode.util.ImageUtils;
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.activity.WebViewActivity;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.bean.CircleListBean;
|
||||
import com.xscm.moduleutil.databinding.RoomDialogShareBinding;
|
||||
import com.xscm.moduleutil.utils.BaseBottomSheetDialog;
|
||||
@@ -72,6 +73,9 @@ public class ShareDialog extends BaseBottomSheetDialog<RoomDialogShareBinding> {
|
||||
mBinding.tvQq.setVisibility(GONE);
|
||||
mBinding.tvQqq.setVisibility(GONE);
|
||||
mBinding.rl.setVisibility(GONE);
|
||||
}else if (types == 4){
|
||||
mBinding.tvJub.setVisibility(GONE);
|
||||
mBinding.tvCopy.setVisibility(GONE);
|
||||
}
|
||||
if (mUserId.equals(SpUtil.getUserId()+"")){
|
||||
mBinding.shanc.setVisibility(VISIBLE);
|
||||
@@ -142,12 +146,12 @@ public class ShareDialog extends BaseBottomSheetDialog<RoomDialogShareBinding> {
|
||||
} else if (R.id.tv_jub == id) {
|
||||
if (types == 3) {
|
||||
Intent intent = new Intent(getContext(), WebViewActivity.class);
|
||||
intent.putExtra("url", "https://vespa.qxmier.com/web/index.html#/pages/feedback/report?id=" + SpUtil.getToken() + "&fromType=" + types + "&fromId=" + bean.getId());
|
||||
intent.putExtra("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url()+"/web/index.html#/pages/feedback/report?id=" + SpUtil.getToken() + "&fromType=" + types + "&fromId=" + bean.getId());
|
||||
intent.putExtra("title", "举报");
|
||||
startActivity(intent);
|
||||
}else if (types == 1){
|
||||
Intent intent = new Intent(getContext(), WebViewActivity.class);
|
||||
intent.putExtra("url", "https://vespa.qxmier.com/web/index.html#/pages/feedback/report?id=" + SpUtil.getToken() + "&fromType=" + types + "&fromId=" + bean.getUser_id());
|
||||
intent.putExtra("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url()+"/web/index.html#/pages/feedback/report?id=" + SpUtil.getToken() + "&fromType=" + types + "&fromId=" + bean.getUser_id());
|
||||
intent.putExtra("title", "举报");
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 794 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 502 B |
Binary file not shown.
|
Before Width: | Height: | Size: 2.2 KiB |
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user