添加礼物飘屏功能
This commit is contained in:
4
.idea/deploymentTargetSelector.xml
generated
4
.idea/deploymentTargetSelector.xml
generated
@@ -4,10 +4,10 @@
|
|||||||
<selectionStates>
|
<selectionStates>
|
||||||
<SelectionState runConfigName="app">
|
<SelectionState runConfigName="app">
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
<option name="selectionMode" value="DROPDOWN" />
|
||||||
<DropdownSelection timestamp="2025-07-15T14:54:48.221182200Z">
|
<DropdownSelection timestamp="2025-07-19T03:34:24.516702300Z">
|
||||||
<Target type="DEFAULT_BOOT">
|
<Target type="DEFAULT_BOOT">
|
||||||
<handle>
|
<handle>
|
||||||
<DeviceId pluginId="Default" identifier="serial=emulator-5554;connection=9cfa89a5" />
|
<DeviceId pluginId="PhysicalDevice" identifier="serial=6705124a" />
|
||||||
</handle>
|
</handle>
|
||||||
</Target>
|
</Target>
|
||||||
</DropdownSelection>
|
</DropdownSelection>
|
||||||
|
|||||||
3
.idea/misc.xml
generated
3
.idea/misc.xml
generated
@@ -1,3 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="NullableNotNullManager">
|
<component name="NullableNotNullManager">
|
||||||
@@ -46,7 +47,7 @@
|
|||||||
</value>
|
</value>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class AppContext extends CommonAppContext {
|
|||||||
super.onCreate();
|
super.onCreate();
|
||||||
ToastUtils.init(this);
|
ToastUtils.init(this);
|
||||||
ARouter.init(this);
|
ARouter.init(this);
|
||||||
// ServiceUtils.startService(MyMqttService.class);/**/
|
ServiceUtils.startService(MyMqttService.class);/**/
|
||||||
|
|
||||||
/* mqttClient = MyMQTTClient.getInstance(this);
|
/* mqttClient = MyMQTTClient.getInstance(this);
|
||||||
mqttClient.initialize("tcp://81.70.45.221:1883");
|
mqttClient.initialize("tcp://81.70.45.221:1883");
|
||||||
|
|||||||
@@ -197,13 +197,13 @@ dependencies {
|
|||||||
api 'com.github.princekin-f:EasyFloat:2.0.4'
|
api 'com.github.princekin-f:EasyFloat:2.0.4'
|
||||||
//MQTT
|
//MQTT
|
||||||
// api 'org.eclipse.paho:org.eclipse.paho.mqttv5.client:1.2.5'
|
// api 'org.eclipse.paho:org.eclipse.paho.mqttv5.client:1.2.5'
|
||||||
api 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.1.1'
|
// api 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.1.1'
|
||||||
api 'org.eclipse.paho:org.eclipse.paho.android.service:1.1.1'
|
// api 'org.eclipse.paho:org.eclipse.paho.android.service:1.1.1'
|
||||||
// api 'com.github.hannesa2:paho.mqtt.android:3.3.5'
|
// api 'com.github.hannesa2:paho.mqtt.android:3.3.5'
|
||||||
// api 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.5'
|
// api 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.5'
|
||||||
|
|
||||||
api 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.5'
|
api 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.5'
|
||||||
// api 'io.github.mayzs:paho.mqtt.android:1.1.2'
|
api 'io.github.mayzs:paho.mqtt.android:1.2.1'
|
||||||
|
|
||||||
|
|
||||||
//2. 云normal SDK,
|
//2. 云normal SDK,
|
||||||
|
|||||||
@@ -1,19 +1,22 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:tools="http://schemas.android.com/tools"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<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_SPECIAL_USE" />
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
|
|
||||||
|
|
||||||
<application android:allowBackup="true">
|
<application android:allowBackup="true">
|
||||||
|
<activity
|
||||||
|
android:name=".activity.QxActivity"
|
||||||
|
android:exported="false" />
|
||||||
|
|
||||||
<service
|
<service
|
||||||
android:name=".http.FloatingWindowService"
|
android:name=".http.FloatingWindowService"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:foregroundServiceType="specialUse"/>
|
android:foregroundServiceType="specialUse" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.WebViewActivity"
|
android:name=".activity.WebViewActivity"
|
||||||
@@ -21,15 +24,17 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name=".activity.news.OfficialNoticeActivity"
|
android:name=".activity.news.OfficialNoticeActivity"
|
||||||
android:exported="false" />
|
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" /> <!-- <receiver android:name="org.eclipse.paho.android.service.AlarmPingSender$AlarmReceiver" -->
|
||||||
<!-- android:enabled="true"-->
|
<!-- android:enabled="true" -->
|
||||||
<!-- android:exported="true"-->
|
<!-- android:exported="true" -->
|
||||||
<!-- tools:ignore="Instantiatable" />-->
|
<!-- tools:ignore="Instantiatable" /> -->
|
||||||
<!-- <service android:name=".service.EMqttService"-->
|
<service
|
||||||
<!-- android:foregroundServiceType="dataSync"/>-->
|
android:name=".service.EMqttService"
|
||||||
<service android:name=".service.MyMqttService"
|
/>
|
||||||
android:foregroundServiceType="dataSync"/>
|
<service
|
||||||
|
android:name=".service.MyMqttService"
|
||||||
|
android:foregroundServiceType="dataSync" />
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
@@ -29,11 +29,14 @@ import com.qxcm.moduleutil.R;
|
|||||||
import com.qxcm.moduleutil.base.CommonAppContext;
|
import com.qxcm.moduleutil.base.CommonAppContext;
|
||||||
import com.qxcm.moduleutil.bean.UserBean;
|
import com.qxcm.moduleutil.bean.UserBean;
|
||||||
import com.qxcm.moduleutil.bean.UserInfo;
|
import com.qxcm.moduleutil.bean.UserInfo;
|
||||||
|
import com.qxcm.moduleutil.event.MqttBean;
|
||||||
import com.qxcm.moduleutil.event.UnreadCountEvent;
|
import com.qxcm.moduleutil.event.UnreadCountEvent;
|
||||||
|
import com.qxcm.moduleutil.utils.ImageUtils;
|
||||||
import com.qxcm.moduleutil.utils.LanguageUtil;
|
import com.qxcm.moduleutil.utils.LanguageUtil;
|
||||||
import com.qxcm.moduleutil.utils.location.LocationProvider;
|
import com.qxcm.moduleutil.utils.location.LocationProvider;
|
||||||
import com.qxcm.moduleutil.utils.location.LocationServiceFactory;
|
import com.qxcm.moduleutil.utils.location.LocationServiceFactory;
|
||||||
import com.qxcm.moduleutil.utils.location.SystemLocationProvider;
|
import com.qxcm.moduleutil.utils.location.SystemLocationProvider;
|
||||||
|
import com.qxcm.moduleutil.widget.PiaoPingManager;
|
||||||
import com.tencent.imsdk.v2.V2TIMCallback;
|
import com.tencent.imsdk.v2.V2TIMCallback;
|
||||||
import com.tencent.imsdk.v2.V2TIMManager;
|
import com.tencent.imsdk.v2.V2TIMManager;
|
||||||
import com.tencent.imsdk.v2.V2TIMUserFullInfo;
|
import com.tencent.imsdk.v2.V2TIMUserFullInfo;
|
||||||
@@ -202,85 +205,86 @@ public abstract class BaseMvpActivity<P extends IPresenter, VDB extends ViewData
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 显示全局飘屏消息(支持任意位置飘过)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
// @Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
|
// public void showPiaoPingMessage(MqttBean mqttBean) {
|
||||||
|
// WindowManager windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
|
||||||
|
// if (windowManager == null) return;
|
||||||
|
//
|
||||||
|
// 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;
|
||||||
|
//
|
||||||
|
// View piaoPingView = LayoutInflater.from(this).inflate(R.layout.item_piaoping, null);
|
||||||
|
// TextView textView = piaoPingView.findViewById(R.id.tv_name);
|
||||||
|
// TextView textView2 = piaoPingView.findViewById(R.id.tv_to_name);
|
||||||
|
// textView2.setText("送给"+mqttBean.getList().getToUserName());
|
||||||
|
// textView.setText(mqttBean.getList().getFromUserName());
|
||||||
|
// 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();
|
||||||
|
// }
|
||||||
|
// }, 3000);
|
||||||
|
//
|
||||||
|
// animator.addListener(new AnimatorListenerAdapter() {
|
||||||
|
// @Override
|
||||||
|
// public void onAnimationEnd(Animator animation) {
|
||||||
|
// windowManager.removeView(piaoPingView);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
/**
|
|
||||||
* 显示全局飘屏消息(支持任意位置飘过)
|
|
||||||
*
|
|
||||||
* @param message 漂浮内容
|
|
||||||
* @param duration 动画时间(毫秒)
|
|
||||||
*/
|
|
||||||
public void showPiaoPingMessage(String message, long duration) {
|
|
||||||
WindowManager windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
|
|
||||||
if (windowManager == null) return;
|
|
||||||
|
|
||||||
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 = -200;
|
|
||||||
|
|
||||||
View piaoPingView = LayoutInflater.from(this).inflate(R.layout.item_piaoping, null);
|
|
||||||
TextView textView = piaoPingView.findViewById(R.id.tv_content);
|
|
||||||
textView.setText(message);
|
|
||||||
|
|
||||||
windowManager.addView(piaoPingView, layoutParams);
|
|
||||||
|
|
||||||
piaoPingView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
|
||||||
@Override
|
|
||||||
public void onGlobalLayout() {
|
|
||||||
piaoPingView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
|
||||||
|
|
||||||
int viewWidth = piaoPingView.getWidth();
|
|
||||||
|
|
||||||
// 设置锚点为左上角,避免偏移干扰
|
|
||||||
piaoPingView.setPivotX(0);
|
|
||||||
piaoPingView.setPivotY(0);
|
|
||||||
|
|
||||||
// 更新 x 坐标为 -screenWidth,确保 View 完全在屏幕左侧外
|
|
||||||
layoutParams.x = -screenWidth;
|
|
||||||
windowManager.updateViewLayout(piaoPingView, layoutParams);
|
|
||||||
|
|
||||||
// 启动动画:从左外滑入 -> 右外滑出
|
|
||||||
ObjectAnimator animator = ObjectAnimator.ofFloat(
|
|
||||||
piaoPingView,
|
|
||||||
"translationX",
|
|
||||||
0f, // 初始偏移为 0(此时 View 在左侧外)
|
|
||||||
screenWidth + viewWidth // 向右移动整个屏幕宽度 + View 宽度
|
|
||||||
);
|
|
||||||
animator.setDuration(duration);
|
|
||||||
animator.addUpdateListener(animation -> {
|
|
||||||
float value = (float) animation.getAnimatedValue();
|
|
||||||
});
|
|
||||||
animator.addListener(new AnimatorListenerAdapter() {
|
|
||||||
@Override
|
|
||||||
public void onAnimationEnd(Animator animation) {
|
|
||||||
windowManager.removeView(piaoPingView);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// 强制 GPU 渲染
|
|
||||||
piaoPingView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
|
||||||
|
|
||||||
animator.start();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package com.qxcm.moduleutil.base;
|
package com.qxcm.moduleutil.base;
|
||||||
|
|
||||||
|
import android.animation.Animator;
|
||||||
|
import android.animation.AnimatorListenerAdapter;
|
||||||
|
import android.animation.ObjectAnimator;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
@@ -9,6 +12,7 @@ import android.content.Intent;
|
|||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.Signature;
|
import android.content.pm.Signature;
|
||||||
|
import android.graphics.PixelFormat;
|
||||||
import android.media.MediaRouter;
|
import android.media.MediaRouter;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -16,7 +20,13 @@ import android.os.Handler;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.Gravity;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewTreeObserver;
|
||||||
|
import android.view.WindowManager;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.multidex.MultiDex;
|
import androidx.multidex.MultiDex;
|
||||||
import androidx.multidex.MultiDexApplication;
|
import androidx.multidex.MultiDexApplication;
|
||||||
@@ -31,19 +41,19 @@ import com.blankj.utilcode.util.ProcessUtils;
|
|||||||
import com.blankj.utilcode.util.ServiceUtils;
|
import com.blankj.utilcode.util.ServiceUtils;
|
||||||
import com.lahm.library.EasyProtectorLib;
|
import com.lahm.library.EasyProtectorLib;
|
||||||
import com.lahm.library.EmulatorCheckCallback;
|
import com.lahm.library.EmulatorCheckCallback;
|
||||||
|
import com.qxcm.moduleutil.R;
|
||||||
import com.qxcm.moduleutil.bean.UserBean;
|
import com.qxcm.moduleutil.bean.UserBean;
|
||||||
import com.qxcm.moduleutil.event.AppLifecycleEvent;
|
import com.qxcm.moduleutil.event.AppLifecycleEvent;
|
||||||
import com.qxcm.moduleutil.interfaces.AppLifecycleUtil;
|
import com.qxcm.moduleutil.interfaces.AppLifecycleUtil;
|
||||||
import com.qxcm.moduleutil.rtc.RtcManager;
|
|
||||||
import com.qxcm.moduleutil.service.EMqttService;
|
|
||||||
import com.qxcm.moduleutil.service.MyMqttService;
|
|
||||||
import com.qxcm.moduleutil.utils.FloatWindowHelper;
|
import com.qxcm.moduleutil.utils.FloatWindowHelper;
|
||||||
|
import com.qxcm.moduleutil.utils.ImageUtils;
|
||||||
import com.qxcm.moduleutil.utils.SpUtil;
|
import com.qxcm.moduleutil.utils.SpUtil;
|
||||||
import com.qxcm.moduleutil.utils.UtilConfig;
|
import com.qxcm.moduleutil.utils.UtilConfig;
|
||||||
import com.qxcm.moduleutil.utils.config.EnvironmentEnum;
|
import com.qxcm.moduleutil.utils.config.EnvironmentEnum;
|
||||||
import com.qxcm.moduleutil.utils.config.EnvironmentPrefs;
|
import com.qxcm.moduleutil.utils.config.EnvironmentPrefs;
|
||||||
import com.qxcm.moduleutil.widget.CommonAppConfig;
|
import com.qxcm.moduleutil.widget.CommonAppConfig;
|
||||||
import com.qxcm.moduleutil.widget.CustomRefreshHeader;
|
import com.qxcm.moduleutil.widget.CustomRefreshHeader;
|
||||||
|
import com.qxcm.moduleutil.widget.PiaoPingManager;
|
||||||
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
|
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
|
||||||
import com.scwang.smartrefresh.layout.api.DefaultRefreshFooterCreator;
|
import com.scwang.smartrefresh.layout.api.DefaultRefreshFooterCreator;
|
||||||
import com.scwang.smartrefresh.layout.api.DefaultRefreshHeaderCreator;
|
import com.scwang.smartrefresh.layout.api.DefaultRefreshHeaderCreator;
|
||||||
@@ -55,6 +65,8 @@ import com.tencent.qcloud.tuicore.TUILogin;
|
|||||||
import com.tencent.qcloud.tuicore.interfaces.TUICallback;
|
import com.tencent.qcloud.tuicore.interfaces.TUICallback;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
|
import org.greenrobot.eventbus.ThreadMode;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
@@ -111,9 +123,11 @@ public class CommonAppContext extends MultiDexApplication {
|
|||||||
// RtcManager.instance(this);
|
// RtcManager.instance(this);
|
||||||
EnvironmentPrefs prefs = new EnvironmentPrefs(this);
|
EnvironmentPrefs prefs = new EnvironmentPrefs(this);
|
||||||
currentEnvironment = prefs.getSelectedEnvironment();
|
currentEnvironment = prefs.getSelectedEnvironment();
|
||||||
|
piaoPingManager = PiaoPingManager.getInstance(this);
|
||||||
|
piaoPingManager.subscribe();
|
||||||
// startInitSdk();
|
// startInitSdk();
|
||||||
}
|
}
|
||||||
|
private PiaoPingManager piaoPingManager;
|
||||||
private void initARouter() {
|
private void initARouter() {
|
||||||
if(true) {
|
if(true) {
|
||||||
ARouter.openDebug();
|
ARouter.openDebug();
|
||||||
@@ -349,9 +363,7 @@ public class CommonAppContext extends MultiDexApplication {
|
|||||||
Intent intent = new Intent("com.example.action.LAUNCH_PAGE");
|
Intent intent = new Intent("com.example.action.LAUNCH_PAGE");
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
getApplicationContext().startActivity(intent);
|
getApplicationContext().startActivity(intent);
|
||||||
// ServiceUtils.stopService(MyMqttService.class);
|
piaoPingManager.unsubscribe();
|
||||||
ServiceUtils.stopService(EMqttService.class);
|
|
||||||
// MyMqttService.stopService(getApplicationContext());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isAlipayInstalled(Context context) {
|
public static boolean isAlipayInstalled(Context context) {
|
||||||
@@ -384,5 +396,4 @@ public class CommonAppContext extends MultiDexApplication {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public class RoomInfoResp implements Serializable {
|
|||||||
private RoomAuction room_auction;//拍卖房信息
|
private RoomAuction room_auction;//拍卖房信息
|
||||||
private RoomCpUserBean cp_user;
|
private RoomCpUserBean cp_user;
|
||||||
private PkRoomInfo pk_info;
|
private PkRoomInfo pk_info;
|
||||||
|
private List<RoomPitBean> song_pit_list;
|
||||||
|
|
||||||
|
|
||||||
//弹出麦位操作弹出
|
//弹出麦位操作弹出
|
||||||
|
|||||||
106
moduleUtil/src/main/java/com/qxcm/moduleutil/event/MqttBean.java
Normal file
106
moduleUtil/src/main/java/com/qxcm/moduleutil/event/MqttBean.java
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
package com.qxcm.moduleutil.event;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author lxj$
|
||||||
|
* @Time $ $
|
||||||
|
* @Description 从声望获取到的参数$
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class MqttBean {
|
||||||
|
private String room_id;
|
||||||
|
private ListBean list;
|
||||||
|
|
||||||
|
public String getRoom_id() {
|
||||||
|
return room_id == null ? "" : room_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRoom_id(String room_id) {
|
||||||
|
this.room_id = room_id == null ? "" : room_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ListBean getList() {
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setList(ListBean list) {
|
||||||
|
this.list = list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class ListBean {
|
||||||
|
private String text;
|
||||||
|
private String gift_picture;
|
||||||
|
private String room_id;
|
||||||
|
private String fromUserName;
|
||||||
|
private String toUserName;
|
||||||
|
private String giftName;
|
||||||
|
private String roomId;
|
||||||
|
private String number;
|
||||||
|
|
||||||
|
public String getText() {
|
||||||
|
return text == null ? "" : text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setText(String text) {
|
||||||
|
this.text = text == null ? "" : text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGift_picture() {
|
||||||
|
return gift_picture == null ? "" : gift_picture;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGift_picture(String gift_picture) {
|
||||||
|
this.gift_picture = gift_picture == null ? "" : gift_picture;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRoom_id() {
|
||||||
|
return room_id == null ? "" : room_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRoom_id(String room_id) {
|
||||||
|
this.room_id = room_id == null ? "" : room_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFromUserName() {
|
||||||
|
return fromUserName == null ? "" : fromUserName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFromUserName(String fromUserName) {
|
||||||
|
this.fromUserName = fromUserName == null ? "" : fromUserName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getToUserName() {
|
||||||
|
return toUserName == null ? "" : toUserName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setToUserName(String toUserName) {
|
||||||
|
this.toUserName = toUserName == null ? "" : toUserName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGiftName() {
|
||||||
|
return giftName == null ? "" : giftName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGiftName(String giftName) {
|
||||||
|
this.giftName = giftName == null ? "" : giftName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRoomId() {
|
||||||
|
return roomId == null ? "" : roomId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRoomId(String roomId) {
|
||||||
|
this.roomId = roomId == null ? "" : roomId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNumber() {
|
||||||
|
return number == null ? "" : number;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNumber(String number) {
|
||||||
|
this.number = number == null ? "" : number;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,9 @@ package com.qxcm.moduleutil.event;
|
|||||||
|
|
||||||
import com.qxcm.moduleutil.bean.RoonGiftModel;
|
import com.qxcm.moduleutil.bean.RoonGiftModel;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
public class RoomGiftGiveEvent {
|
public class RoomGiftGiveEvent {
|
||||||
public String userId;
|
public String userId;
|
||||||
public String room_id;
|
public String room_id;
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package com.qxcm.moduleutil.event;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.provider.Settings;
|
||||||
|
|
||||||
|
import com.blankj.utilcode.util.GsonUtils;
|
||||||
|
import com.blankj.utilcode.util.ServiceUtils;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.qxcm.moduleutil.base.CommonAppContext;
|
||||||
|
import com.qxcm.moduleutil.service.EMqttService;
|
||||||
|
|
||||||
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author $
|
||||||
|
* @Time $ $
|
||||||
|
* @Description $
|
||||||
|
*/
|
||||||
|
public class RoomGiftRunable implements Runnable {
|
||||||
|
|
||||||
|
private String data;
|
||||||
|
private static final List<MqttBean> mqttCache = new ArrayList<>();
|
||||||
|
private static final int MAX_CACHE_SIZE = 6;
|
||||||
|
private static final Object lock = new Object();
|
||||||
|
public RoomGiftRunable(String data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
MqttBean mqttBean= GsonUtils.fromJson(data, MqttBean.class);
|
||||||
|
// 线程安全地添加到缓存
|
||||||
|
synchronized (lock) {
|
||||||
|
if (mqttCache.size() >= MAX_CACHE_SIZE) {
|
||||||
|
mqttCache.remove(0); // 移除第一条数据
|
||||||
|
}
|
||||||
|
mqttCache.add(mqttBean); // 添加新数据
|
||||||
|
}
|
||||||
|
EventBus.getDefault().post(mqttBean);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 提供方法获取缓存数据
|
||||||
|
public static List<MqttBean> getMqttCache() {
|
||||||
|
synchronized (lock) {
|
||||||
|
return new ArrayList<>(mqttCache);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,78 +1,52 @@
|
|||||||
package com.qxcm.moduleutil.service;
|
package com.qxcm.moduleutil.service;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
|
import android.animation.Animator;
|
||||||
|
import android.animation.AnimatorListenerAdapter;
|
||||||
|
import android.animation.ObjectAnimator;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
import android.content.BroadcastReceiver;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.graphics.PixelFormat;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.util.Log;
|
import android.view.Gravity;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewTreeObserver;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.qxcm.moduleutil.R;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.qxcm.moduleutil.event.MqttBean;
|
||||||
import com.blankj.utilcode.util.NetworkUtils;
|
import com.qxcm.moduleutil.utils.ImageUtils;
|
||||||
import com.blankj.utilcode.util.ThreadUtils;
|
|
||||||
import com.blankj.utilcode.util.ToastUtils;
|
|
||||||
import com.orhanobut.logger.Logger;
|
|
||||||
import com.qxcm.moduleutil.base.CommonAppContext;
|
|
||||||
import com.qxcm.moduleutil.bean.UserBean;
|
|
||||||
import com.qxcm.moduleutil.event.BossMsgEvent;
|
|
||||||
import com.qxcm.moduleutil.event.QDZMqttEvent;
|
|
||||||
import com.qxcm.moduleutil.utils.GsonUtils;
|
|
||||||
import com.qxcm.moduleutil.utils.SpUtil;
|
|
||||||
import com.tencent.qcloud.tuicore.TUIConstants;
|
|
||||||
|
|
||||||
import org.eclipse.paho.android.service.MqttAndroidClient;
|
|
||||||
import org.eclipse.paho.client.mqttv3.IMqttActionListener;
|
|
||||||
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
|
|
||||||
import org.eclipse.paho.client.mqttv3.IMqttToken;
|
|
||||||
import org.eclipse.paho.client.mqttv3.MqttCallback;
|
|
||||||
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.greenrobot.eventbus.EventBus;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
|
|
||||||
public class EMqttService extends Service implements NetworkUtils.OnNetworkStatusChangedListener {
|
public class EMqttService extends Service {
|
||||||
private final static String TAG = "EMQTT消息";
|
private WindowManager windowManager;
|
||||||
|
private View piaoPingView;
|
||||||
private static final int qos = 2;
|
|
||||||
private static final String HOST = "tcp://81.70.45.221";
|
|
||||||
@SuppressLint("StaticFieldLeak")
|
|
||||||
private static MqttAndroidClient mqttAndroidClient;
|
|
||||||
private MqttConnectOptions mMqttConnectOptions;
|
|
||||||
|
|
||||||
private ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(1);
|
|
||||||
|
|
||||||
private static final String TOPIC_BOSS = "boss";
|
|
||||||
private static final String TOPIC_ROOM = "qx_room_topic";
|
|
||||||
private static final String TOPIC_QIANG_TANG_GUO = "red_envelope_single_room_real_time_data"; // 抢糖果
|
|
||||||
|
|
||||||
public static String sRoomId = "qx_room_topic";
|
|
||||||
public static String sUserId;
|
|
||||||
private BroadcastReceiver unreadCountReceiver;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
Logger.e(TAG, "服务创建成功");
|
windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
|
||||||
NetworkUtils.registerNetworkStatusChangedListener(this);
|
|
||||||
// scheduledExecutorService.scheduleWithFixedDelay(connectTask, 0, 10, TimeUnit.SECONDS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// private final Runnable connectTask = this::doClientConnection;
|
|
||||||
@Override
|
@Override
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
return super.onStartCommand(intent, flags, 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
|
@Override
|
||||||
@@ -80,304 +54,76 @@ public class EMqttService extends Service implements NetworkUtils.OnNetworkStatu
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void subscribeRoom(String roomId) {
|
public void showPiaoPingMessage(MqttBean mqttBean) {
|
||||||
subscribe("qx_room_topic");
|
int screenWidth = getResources().getDisplayMetrics().widthPixels;
|
||||||
}
|
int screenHeight = getResources().getDisplayMetrics().heightPixels;
|
||||||
|
|
||||||
public static void cleanSubscribeRoom(String roomId) {
|
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(
|
||||||
cleanSubscribe("qx_room_topic");
|
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);
|
||||||
|
|
||||||
public static void subscribeUser(String userId) {
|
// 设置 Gravity 为左上角
|
||||||
sUserId = userId;
|
layoutParams.gravity = Gravity.TOP | Gravity.START;
|
||||||
subscribe("user_" + userId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void cleanSubscribeUser() {
|
// Y 轴随机位置
|
||||||
cleanSubscribe("user_" + sUserId);
|
layoutParams.y = (int) ((Math.random() * (screenHeight - 200)));
|
||||||
sUserId = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
// 初始 X 设为负值,确保 View 在屏幕左侧外
|
||||||
* 订阅主题
|
layoutParams.x = -screenWidth;
|
||||||
*/
|
|
||||||
public static void subscribe(String topic) {
|
piaoPingView = LayoutInflater.from(this).inflate(R.layout.item_piaoping, null);
|
||||||
try {
|
TextView textView = piaoPingView.findViewById(R.id.tv_name);
|
||||||
if (isAlreadyConnected()) {
|
textView.setText(mqttBean.getList().getText());
|
||||||
IMqttToken subToken = mqttAndroidClient.subscribe(topic, qos);
|
ImageUtils.loadHeadCC(mqttBean.getList().getGift_picture(), piaoPingView.findViewById(R.id.iv_piaoping));
|
||||||
subToken.setActionCallback(new IMqttActionListener() {
|
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
|
@Override
|
||||||
public void onSuccess(IMqttToken asyncActionToken) {
|
public void run() {
|
||||||
Logger.e(TAG, "主题订阅成功", topic);
|
animator.start();
|
||||||
}
|
}
|
||||||
|
}, 2000);
|
||||||
|
|
||||||
|
animator.addListener(new AnimatorListenerAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(IMqttToken asyncActionToken, Throwable exception) {
|
public void onAnimationEnd(Animator animation) {
|
||||||
Logger.e(TAG, "主题订阅失败");
|
windowManager.removeView(piaoPingView);
|
||||||
ThreadUtils.runOnUiThreadDelayed(() -> subscribe(topic), 1000);
|
stopSelf();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
});
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void cleanSubscribe(String topic) {
|
|
||||||
try {
|
|
||||||
if (isAlreadyConnected()) {
|
|
||||||
IMqttToken subToken = mqttAndroidClient.unsubscribe(topic);
|
|
||||||
subToken.setActionCallback(new IMqttActionListener() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(IMqttToken asyncActionToken) {
|
|
||||||
Logger.e(TAG, "取消主题成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(IMqttToken asyncActionToken, Throwable exception) {
|
|
||||||
Logger.e(TAG, "取消主题失败");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 初始化客户端连接
|
|
||||||
*/
|
|
||||||
private String clientId = "";
|
|
||||||
|
|
||||||
private void init() throws MqttException {
|
|
||||||
UserBean user = CommonAppContext.getInstance().getUser();
|
|
||||||
if (mqttAndroidClient == null) {
|
|
||||||
clientId = "android-" + user.getUser_id() + "-" + MqttClient.generateClientId();
|
|
||||||
mqttAndroidClient = new MqttAndroidClient(this, HOST, clientId, MqttAndroidClient.Ack.AUTO_ACK);
|
|
||||||
}
|
|
||||||
mMqttConnectOptions = new MqttConnectOptions();
|
|
||||||
mMqttConnectOptions.setCleanSession(true);
|
|
||||||
mMqttConnectOptions.setConnectionTimeout(10);
|
|
||||||
mMqttConnectOptions.setKeepAliveInterval(60);
|
|
||||||
mMqttConnectOptions.setUserName("public");
|
|
||||||
mMqttConnectOptions.setMqttVersion(MqttConnectOptions.MQTT_VERSION_3_1_1);
|
|
||||||
|
|
||||||
mqttAndroidClient.connect(mMqttConnectOptions, null, iMqttActionListener);
|
|
||||||
mqttAndroidClient.setCallback(mqttCallback);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private synchronized void doClientConnection() throws MqttException {
|
|
||||||
Logger.e("doClientConnection", "doClientConnection");
|
|
||||||
if (!isAlreadyConnected() && isConnectIsNomarl()) {
|
|
||||||
releaseMQTT();
|
|
||||||
init();
|
|
||||||
} else {
|
|
||||||
releaseMQTT();
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否已连接
|
|
||||||
*/
|
|
||||||
public static boolean isAlreadyConnected() {
|
|
||||||
return mqttAndroidClient != null && mqttAndroidClient.isConnected();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 网络是否可用
|
|
||||||
*/
|
|
||||||
private boolean isConnectIsNomarl() {
|
|
||||||
if (NetworkUtils.isConnected()) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
Log.i(TAG, "没有可用网络");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 连接状态监听
|
|
||||||
*/
|
|
||||||
private final IMqttActionListener iMqttActionListener = new IMqttActionListener() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(IMqttToken arg0) {
|
|
||||||
long time = 0;
|
|
||||||
Logger.e(TAG, "链接状态成功");
|
|
||||||
EventBus.getDefault().post(EmqttState.CONNECTED);
|
|
||||||
if (sRoomId != null) {
|
|
||||||
subscribeRoom(sRoomId);
|
|
||||||
}
|
|
||||||
subscribe(TOPIC_BOSS);
|
|
||||||
subscribe(TOPIC_ROOM);
|
|
||||||
subscribe(TOPIC_QIANG_TANG_GUO);
|
|
||||||
subscribeUser(CommonAppContext.getInstance().getUser().getUser_id() + "");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(IMqttToken arg0, Throwable arg1) {
|
|
||||||
arg1.printStackTrace();
|
|
||||||
if (arg1 instanceof MqttException) {
|
|
||||||
MqttException mqttException = (MqttException) arg1;
|
|
||||||
Logger.e(TAG, "链接状态失败:" + mqttException.getMessage());
|
|
||||||
}
|
|
||||||
// ThreadUtils.runOnUiThreadDelayed(connectTask, 1000);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 消息回调
|
|
||||||
*/
|
|
||||||
private final MqttCallback mqttCallback = new MqttCallback() {
|
|
||||||
@Override
|
|
||||||
public void connectionLost(Throwable cause) {
|
|
||||||
Logger.e(TAG, "链接断开,请检查网络");
|
|
||||||
try {
|
|
||||||
doClientConnection();
|
|
||||||
} catch (MqttException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void messageArrived(String topic, MqttMessage message) {
|
|
||||||
Logger.e(TAG, "收到的消息", "主题:" + topic + " 内容:" + message.toString());
|
|
||||||
if (TOPIC_BOSS.equals(topic)) {
|
|
||||||
if (EventBus.getDefault().hasSubscriberForEvent(BossMsgEvent.class)) {
|
|
||||||
EventBus.getDefault().post(new BossMsgEvent(message.toString()));
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (TOPIC_QIANG_TANG_GUO.equals(topic)) {
|
|
||||||
if (EventBus.getDefault().hasSubscriberForEvent(QDZMqttEvent.class)) {
|
|
||||||
EventBus.getDefault().post(new QDZMqttEvent(message.toString()));
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
receiveMessage(topic, message.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deliveryComplete(IMqttDeliveryToken token) {
|
|
||||||
// 发送完成回调
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroy() {
|
|
||||||
try {
|
|
||||||
NetworkUtils.unregisterNetworkStatusChangedListener(this);
|
|
||||||
scheduledExecutorService.shutdownNow();
|
|
||||||
scheduledExecutorService = null;
|
|
||||||
|
|
||||||
cleanSubscribeRoom(sRoomId);
|
|
||||||
cleanSubscribeUser();
|
|
||||||
cleanSubscribe(TOPIC_BOSS);
|
|
||||||
cleanSubscribe(TOPIC_ROOM);
|
|
||||||
cleanSubscribe(TOPIC_QIANG_TANG_GUO);
|
|
||||||
|
|
||||||
releaseMQTT();
|
|
||||||
|
|
||||||
if (mqttAndroidClient != null) {
|
|
||||||
mqttAndroidClient.setCallback(null);
|
|
||||||
mqttAndroidClient.disconnect();
|
|
||||||
mqttAndroidClient = null;
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
super.onDestroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void releaseMQTT() {
|
|
||||||
if (mqttAndroidClient != null) {
|
|
||||||
try {
|
|
||||||
// stopAlarmPingSender(mqttAndroidClient); // 防止BroadcastReceiver泄漏
|
|
||||||
mqttAndroidClient.disconnect();
|
|
||||||
mqttAndroidClient.unregisterResources();
|
|
||||||
mqttAndroidClient = null;
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
mqttAndroidClient = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 停止 Paho SDK 的 AlarmPingSender
|
|
||||||
*/
|
|
||||||
private void stopAlarmPingSender(MqttAndroidClient client) {
|
|
||||||
try {
|
|
||||||
Field field = MqttAndroidClient.class.getDeclaredField("client");
|
|
||||||
field.setAccessible(true);
|
|
||||||
Object internalClient = field.get(client);
|
|
||||||
|
|
||||||
Field pingSenderField = internalClient.getClass().getDeclaredField("pingSender");
|
|
||||||
pingSenderField.setAccessible(true);
|
|
||||||
Object pingSender = pingSenderField.get(internalClient);
|
|
||||||
|
|
||||||
// if (pingSender instanceof AlarmpingSender) {
|
|
||||||
// ((AlarmPingSender) pingSender).stop();
|
|
||||||
// }
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void receiveMessage(String topic, String data) {
|
|
||||||
JSONObject jsonObject;
|
|
||||||
try {
|
|
||||||
jsonObject = JSON.parseObject(data);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int type = jsonObject.getIntValue("type");
|
|
||||||
String message = jsonObject.getString("msg");
|
|
||||||
|
|
||||||
if (TOPIC_ROOM.equals(topic)) {
|
|
||||||
if (type == 10000) {
|
|
||||||
// 全服红包
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (type) {
|
|
||||||
// 根据业务逻辑处理不同的消息类型
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T> void sendEvent(String message, Class<T> tClass) {
|
|
||||||
EventBus.getDefault().post(JSON.parseObject(message, tClass));
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T> void sendEventList(String message, Class<T> tClass) {
|
|
||||||
List<T> list = JSON.parseArray(message, tClass);
|
|
||||||
EventBus.getDefault().post(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T> void sendKtEvent(String message, Class<T> tClass) {
|
|
||||||
EventBus.getDefault().post(GsonUtils.GsonToBean(message, tClass));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onConnected(NetworkUtils.NetworkType networkType) {
|
|
||||||
try {
|
|
||||||
doClientConnection();
|
|
||||||
} catch (MqttException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDisconnected() {
|
|
||||||
// 可选:做网络断开后的清理工作
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum EmqttState {
|
|
||||||
CONNECTED,
|
|
||||||
DISCONNECTED
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.qxcm.moduleutil.service;
|
package com.qxcm.moduleutil.service;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
import android.app.NotificationChannel;
|
import android.app.NotificationChannel;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
@@ -15,12 +16,15 @@ import android.os.IBinder;
|
|||||||
import android.util.Log;
|
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.LogUtils;
|
||||||
import com.blankj.utilcode.util.ServiceUtils;
|
import com.blankj.utilcode.util.ServiceUtils;
|
||||||
import com.orhanobut.logger.Logger;
|
import com.orhanobut.logger.Logger;
|
||||||
import com.qxcm.moduleutil.R;
|
import com.qxcm.moduleutil.R;
|
||||||
import com.qxcm.moduleutil.base.CommonAppContext;
|
import com.qxcm.moduleutil.base.CommonAppContext;
|
||||||
import com.qxcm.moduleutil.event.BossMsgEvent;
|
import com.qxcm.moduleutil.event.BossMsgEvent;
|
||||||
|
import com.qxcm.moduleutil.event.RoomGiftRunable;
|
||||||
|
|
||||||
import org.eclipse.paho.android.service.MqttAndroidClient;
|
import org.eclipse.paho.android.service.MqttAndroidClient;
|
||||||
import org.eclipse.paho.client.mqttv3.IMqttActionListener;
|
import org.eclipse.paho.client.mqttv3.IMqttActionListener;
|
||||||
@@ -35,7 +39,7 @@ import org.greenrobot.eventbus.EventBus;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
|
||||||
public class MyMqttService extends Service {
|
public class MyMqttService extends Service implements MyEmqttConnectListener,MyEmqttMesgListener,MyEmqttSubscribeListener{
|
||||||
|
|
||||||
private final static String TAG = "lxj";
|
private final static String TAG = "lxj";
|
||||||
|
|
||||||
@@ -57,13 +61,13 @@ public class MyMqttService extends Service {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { // API 31+
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { // API 31+
|
||||||
// // 设置前台服务类型为 "connectedDevice" 或其他合适类型
|
// 设置前台服务类型为 "connectedDevice" 或其他合适类型
|
||||||
// setForegroundServiceBehavior(ServiceInfo.FOREGROUND_SERVICE_TYPE_MANIFEST);
|
setForegroundServiceBehavior(ServiceInfo.FOREGROUND_SERVICE_TYPE_MANIFEST);
|
||||||
// }
|
}
|
||||||
// // ⚠️ 必须在这个方法开始就调用 startForeground()
|
// ⚠️ 必须在这个方法开始就调用 startForeground()
|
||||||
// Notification notification = createNotification();
|
Notification notification = createNotification();
|
||||||
// startForeground(NOTIFICATION_ID, notification);
|
startForeground(NOTIFICATION_ID, notification);
|
||||||
|
|
||||||
return super.onStartCommand(intent, flags, startId);
|
return super.onStartCommand(intent, flags, startId);
|
||||||
}
|
}
|
||||||
@@ -82,23 +86,23 @@ public class MyMqttService extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// private Notification createNotification() {
|
private Notification createNotification() {
|
||||||
// // 创建你的前台通知
|
// 创建你的前台通知
|
||||||
// Notification.Builder builder = null;
|
Notification.Builder builder = null;
|
||||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
// builder = new Notification.Builder(this, "channel_id")
|
builder = new Notification.Builder(this, "channel_id")
|
||||||
// .setContentTitle("MQTT Service")
|
.setContentTitle("MQTT Service")
|
||||||
// .setSmallIcon(R.mipmap.default_avatar);
|
.setSmallIcon(R.mipmap.default_avatar);
|
||||||
// }
|
}
|
||||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
// NotificationChannel channel = new NotificationChannel(
|
NotificationChannel channel = new NotificationChannel(
|
||||||
// "channel_id", "MQTT Channel",
|
"channel_id", "MQTT Channel",
|
||||||
// NotificationManager.IMPORTANCE_LOW);
|
NotificationManager.IMPORTANCE_LOW);
|
||||||
// NotificationManager manager = getSystemService(NotificationManager.class);
|
NotificationManager manager = getSystemService(NotificationManager.class);
|
||||||
// manager.createNotificationChannel(channel);
|
manager.createNotificationChannel(channel);
|
||||||
// }
|
}
|
||||||
// return builder.build();
|
return builder.build();
|
||||||
// }
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 开启服务
|
* 开启服务
|
||||||
@@ -208,16 +212,17 @@ public class MyMqttService extends Service {
|
|||||||
* 初始化
|
* 初始化
|
||||||
*/
|
*/
|
||||||
private void init() throws MqttException {
|
private void init() throws MqttException {
|
||||||
String CLIENTID = "android-" + CommonAppContext.getInstance().getUser().getUser_id() + "-" + MqttClient.generateClientId();
|
String CLIENTID = "android-" + MqttClient.generateClientId();
|
||||||
mqttAndroidClient = new MqttAndroidClient(this, HOST, CLIENTID, MqttAndroidClient.Ack.AUTO_ACK);
|
mqttAndroidClient = new MqttAndroidClient(this, HOST, CLIENTID);
|
||||||
mqttAndroidClient.setCallback(mqttCallback); //设置监听订阅消息的回调
|
mqttAndroidClient.setCallback(mqttCallback); //设置监听订阅消息的回调
|
||||||
mMqttConnectOptions = new MqttConnectOptions();
|
mMqttConnectOptions = new MqttConnectOptions();
|
||||||
mMqttConnectOptions.setCleanSession(false); //设置是否清除缓存
|
mMqttConnectOptions.setCleanSession(true); //设置是否清除缓存
|
||||||
mMqttConnectOptions.setConnectionTimeout(10); //设置超时时间,单位:秒
|
mMqttConnectOptions.setConnectionTimeout(10); //设置超时时间,单位:秒
|
||||||
mMqttConnectOptions.setKeepAliveInterval(10); //设置心跳包发送间隔,单位:秒
|
mMqttConnectOptions.setKeepAliveInterval(10); //设置心跳包发送间隔,单位:秒
|
||||||
mMqttConnectOptions.setUserName("public"); //设置用户名
|
mMqttConnectOptions.setUserName("public"); //设置用户名
|
||||||
// mMqttConnectOptions.setPassword(new char[0]); //设置密码
|
// mMqttConnectOptions.setPassword(new char[0]); //设置密码
|
||||||
mMqttConnectOptions.setMqttVersion(MqttConnectOptions.MQTT_VERSION_3_1);
|
mMqttConnectOptions.setMqttVersion(MqttConnectOptions.MQTT_VERSION_3_1);
|
||||||
|
|
||||||
if (!mqttAndroidClient.isConnected()) {
|
if (!mqttAndroidClient.isConnected()) {
|
||||||
doClientConnection();
|
doClientConnection();
|
||||||
}
|
}
|
||||||
@@ -320,9 +325,11 @@ public class MyMqttService extends Service {
|
|||||||
}
|
}
|
||||||
Logger.e(TAG, "收到的消息", "主题:" + topic + " 收到的消息:" + message.toString());
|
Logger.e(TAG, "收到的消息", "主题:" + topic + " 收到的消息:" + message.toString());
|
||||||
//收到其他客户端的消息后,响应给对方告知消息已到达或者消息有问题等
|
//收到其他客户端的消息后,响应给对方告知消息已到达或者消息有问题等
|
||||||
if (TOPIC_BOSS.equals(topic)) {
|
receiveMessage(topic,message.toString());
|
||||||
EventBus.getDefault().post(new BossMsgEvent(message.toString()));
|
// if (TOPIC_BOSS.equals(topic)) {
|
||||||
}
|
// EventBus.getDefault().post(new BossMsgEvent(message.toString()));
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -352,7 +359,165 @@ public class MyMqttService extends Service {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private void receiveMessage(String topic, String data) {
|
||||||
|
JSONObject jsonObject = null;
|
||||||
|
try {
|
||||||
|
String newdata = data;//TextLengthUtil.decode(data);
|
||||||
|
jsonObject = JSON.parseObject(newdata);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
try {
|
try {
|
||||||
@@ -384,6 +549,30 @@ public class MyMqttService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConnectSuccess() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConnectFailure() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void messageArrived(String topic, String mesg) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSubscribeSuccess(String topic) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSubscribeFailure() {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,100 @@
|
|||||||
|
package com.qxcm.moduleutil.widget;
|
||||||
|
|
||||||
|
import static com.liulishuo.okdownload.OkDownloadProvider.context;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.PixelFormat;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.view.Gravity;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.qxcm.moduleutil.R;
|
||||||
|
import com.qxcm.moduleutil.event.MqttBean;
|
||||||
|
import com.qxcm.moduleutil.utils.ImageUtils;
|
||||||
|
|
||||||
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
|
import org.greenrobot.eventbus.ThreadMode;
|
||||||
|
/**
|
||||||
|
* @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 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) {
|
||||||
|
if (isPiaoPingShown || piaoPingView == null || windowManager == null) return;
|
||||||
|
|
||||||
|
// 设置布局参数
|
||||||
|
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_PHONE,
|
||||||
|
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
|
||||||
|
PixelFormat.TRANSLUCENT);
|
||||||
|
|
||||||
|
layoutParams.gravity = Gravity.TOP;
|
||||||
|
layoutParams.y = 100; // 设置垂直位置
|
||||||
|
|
||||||
|
// 设置消息内容
|
||||||
|
View piaoPingView = LayoutInflater.from(context.getApplicationContext()).inflate(R.layout.item_piaoping, null);
|
||||||
|
TextView textView = piaoPingView.findViewById(R.id.tv_name);
|
||||||
|
TextView textView2 = piaoPingView.findViewById(R.id.tv_to_name);
|
||||||
|
textView2.setText("送给"+mqttBean.getList().getToUserName());
|
||||||
|
textView.setText(mqttBean.getList().getFromUserName());
|
||||||
|
ImageUtils.loadHeadCC(mqttBean.getList().getGift_picture(), piaoPingView.findViewById(R.id.iv_piaoping));
|
||||||
|
TextView tv_time = piaoPingView.findViewById(R.id.tv_num);
|
||||||
|
tv_time.setText("x"+mqttBean.getList().getNumber());
|
||||||
|
|
||||||
|
// 添加到窗口管理器
|
||||||
|
windowManager.addView(piaoPingView, layoutParams);
|
||||||
|
isPiaoPingShown = true;
|
||||||
|
|
||||||
|
// 设置定时任务,一段时间后移除飘屏消息
|
||||||
|
piaoPingView.postDelayed(() -> {
|
||||||
|
if (piaoPingView != null) {
|
||||||
|
windowManager.removeView(piaoPingView);
|
||||||
|
isPiaoPingShown = false;
|
||||||
|
}
|
||||||
|
}, 3000); // 3秒后移除
|
||||||
|
}
|
||||||
|
|
||||||
|
public void subscribe() {
|
||||||
|
EventBus.getDefault().register(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unsubscribe() {
|
||||||
|
EventBus.getDefault().unregister(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
|
public void onMessageReceived(MqttBean mqttBean) {
|
||||||
|
showPiaoPingMessage(mqttBean);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,13 +1,67 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<TextView
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:id="@+id/tv_content"
|
android:layout_width="@dimen/dp_316"
|
||||||
android:layout_width="match_parent"
|
android:layout_height="@dimen/dp_50">
|
||||||
android:layout_height="40dp"
|
|
||||||
android:minWidth="200dp"
|
<ImageView
|
||||||
android:padding="8dp"
|
android:layout_width="match_parent"
|
||||||
android:singleLine="true"
|
android:layout_height="@dimen/dp_50"
|
||||||
android:ellipsize="none"
|
android:scaleType="fitXY"
|
||||||
android:textColor="#FF0000"
|
android:src="@mipmap/gift_p_b"
|
||||||
android:textSize="16sp"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
android:background="@color/color_FF999999"/>
|
app:layout_constraintEnd_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_name"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="60dp"
|
||||||
|
android:layout_marginEnd="@dimen/dp_2"
|
||||||
|
android:ellipsize="start"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:text="礼品"
|
||||||
|
android:textColor="#FFDE77"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_to_name"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="@dimen/dp_8"
|
||||||
|
android:text="...."
|
||||||
|
android:textColor="#FFDE77"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintStart_toEndOf="@id/tv_name"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/iv_piaoping"
|
||||||
|
android:layout_width="@dimen/dp_20"
|
||||||
|
android:layout_height="@dimen/dp_20"
|
||||||
|
android:layout_marginEnd="@dimen/dp_4"
|
||||||
|
android:src="@mipmap/default_avatar"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/tv_num"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_num"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="@dimen/dp_47"
|
||||||
|
android:text="x1"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textSize="@dimen/sp_12"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
BIN
moduleUtil/src/main/res/mipmap-xxxhdpi/gift_p_b.png
Normal file
BIN
moduleUtil/src/main/res/mipmap-xxxhdpi/gift_p_b.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 289 KiB |
@@ -74,16 +74,16 @@ public class MainActivity extends BaseMvpActivity<HomePresenter, ActivityMainBin
|
|||||||
FragmentUtils.add(getSupportFragmentManager(), fragments, R.id.frame_layout, 0);
|
FragmentUtils.add(getSupportFragmentManager(), fragments, R.id.frame_layout, 0);
|
||||||
MvpPre.initData();
|
MvpPre.initData();
|
||||||
MvpPre.userFiles();
|
MvpPre.userFiles();
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
if (!Settings.canDrawOverlays(this)) {
|
// if (!Settings.canDrawOverlays(this)) {
|
||||||
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
|
// Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
|
||||||
Uri.parse("package:" + getPackageName()));
|
// Uri.parse("package:" + getPackageName()));
|
||||||
startActivityForResult(intent, 100);
|
// startActivityForResult(intent, 100);
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
// 对于低于 Android 6.0 的设备,无需请求悬浮窗权限
|
// // 对于低于 Android 6.0 的设备,无需请求悬浮窗权限
|
||||||
// 可在此处添加针对旧版本的处理逻辑(如果需要)
|
// // 可在此处添加针对旧版本的处理逻辑(如果需要)
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
// 每11秒执行一次飘屏消息
|
// 每11秒执行一次飘屏消息
|
||||||
@@ -97,21 +97,20 @@ public class MainActivity extends BaseMvpActivity<HomePresenter, ActivityMainBin
|
|||||||
// }, 1000);
|
// }, 1000);
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
@Override
|
// @Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
// protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
// super.onActivityResult(requestCode, resultCode, data);
|
||||||
if (requestCode == 100) {
|
// if (requestCode == 100) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
if (Settings.canDrawOverlays(this)) {
|
// if (Settings.canDrawOverlays(this)) {
|
||||||
ToastUtils.showShort("已获得悬浮窗权限");
|
// ToastUtils.showShort("已获得悬浮窗权限");
|
||||||
// showPiaoPingMessage("测试飘屏", 3000);
|
//// showPiaoPingMessage("测试飘屏", 3000);
|
||||||
showPiaoPingMessage("这是一个飘屏消息", 10000); // 5秒飘过
|
// } else {
|
||||||
} else {
|
// ToastUtils.showShort("未获得悬浮窗权限,功能无法使用");
|
||||||
ToastUtils.showShort("未获得悬浮窗权限,功能无法使用");
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
public void onUserInfoEvent(String event) {
|
public void onUserInfoEvent(String event) {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import android.content.res.Configuration;
|
|||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.CountDownTimer;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -35,6 +36,8 @@ import com.alibaba.android.arouter.facade.annotation.Autowired;
|
|||||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||||
import com.alibaba.android.arouter.launcher.ARouter;
|
import com.alibaba.android.arouter.launcher.ARouter;
|
||||||
import com.blankj.utilcode.util.GsonUtils;
|
import com.blankj.utilcode.util.GsonUtils;
|
||||||
|
import com.blankj.utilcode.util.LogUtils;
|
||||||
|
import com.blankj.utilcode.util.ThreadUtils;
|
||||||
import com.blankj.utilcode.util.ToastUtils;
|
import com.blankj.utilcode.util.ToastUtils;
|
||||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||||
import com.example.moduleroom.R;
|
import com.example.moduleroom.R;
|
||||||
@@ -54,13 +57,18 @@ import com.qxcm.moduleutil.base.CommonAppContext;
|
|||||||
import com.qxcm.moduleutil.bean.HeadlineBean;
|
import com.qxcm.moduleutil.bean.HeadlineBean;
|
||||||
import com.qxcm.moduleutil.bean.HeadlineEvent;
|
import com.qxcm.moduleutil.bean.HeadlineEvent;
|
||||||
import com.qxcm.moduleutil.bean.UserInfo;
|
import com.qxcm.moduleutil.bean.UserInfo;
|
||||||
|
import com.qxcm.moduleutil.bean.room.RankInfo;
|
||||||
import com.qxcm.moduleutil.bean.room.RoomOnline;
|
import com.qxcm.moduleutil.bean.room.RoomOnline;
|
||||||
import com.qxcm.moduleutil.databinding.RoomDialogMusicWindowOpenBinding;
|
import com.qxcm.moduleutil.databinding.RoomDialogMusicWindowOpenBinding;
|
||||||
|
import com.qxcm.moduleutil.dialog.RechargeDialogFragment;
|
||||||
import com.qxcm.moduleutil.event.ColoseCardEvent;
|
import com.qxcm.moduleutil.event.ColoseCardEvent;
|
||||||
import com.qxcm.moduleutil.event.EffectEvent;
|
import com.qxcm.moduleutil.event.EffectEvent;
|
||||||
import com.qxcm.moduleutil.event.MusicEvent;
|
import com.qxcm.moduleutil.event.MusicEvent;
|
||||||
|
import com.qxcm.moduleutil.event.RoomGiftGiveEvent;
|
||||||
import com.qxcm.moduleutil.event.RoomOutEvent;
|
import com.qxcm.moduleutil.event.RoomOutEvent;
|
||||||
import com.qxcm.moduleutil.event.RoomWheatEvent;
|
import com.qxcm.moduleutil.event.RoomWheatEvent;
|
||||||
|
import com.qxcm.moduleutil.http.BaseObserver;
|
||||||
|
import com.qxcm.moduleutil.http.RetrofitClient;
|
||||||
import com.qxcm.moduleutil.interfaces.OnMusicItemClickListener;
|
import com.qxcm.moduleutil.interfaces.OnMusicItemClickListener;
|
||||||
import com.qxcm.moduleutil.listener.MessageListenerSingleton;
|
import com.qxcm.moduleutil.listener.MessageListenerSingleton;
|
||||||
import com.qxcm.moduleutil.adapter.LikeUserAdapter;
|
import com.qxcm.moduleutil.adapter.LikeUserAdapter;
|
||||||
@@ -84,8 +92,11 @@ import com.qxcm.moduleutil.rtc.AgoraManager;
|
|||||||
import com.qxcm.moduleutil.rtc.MusicPlayBean;
|
import com.qxcm.moduleutil.rtc.MusicPlayBean;
|
||||||
import com.qxcm.moduleutil.rtc.RtcCore;
|
import com.qxcm.moduleutil.rtc.RtcCore;
|
||||||
import com.qxcm.moduleutil.utils.ARouteConstants;
|
import com.qxcm.moduleutil.utils.ARouteConstants;
|
||||||
|
import com.qxcm.moduleutil.utils.DialogUtils;
|
||||||
import com.qxcm.moduleutil.utils.ImageUtils;
|
import com.qxcm.moduleutil.utils.ImageUtils;
|
||||||
import com.qxcm.moduleutil.utils.SpUtil;
|
import com.qxcm.moduleutil.utils.SpUtil;
|
||||||
|
import com.qxcm.moduleutil.utils.logger.DataLogger;
|
||||||
|
import com.qxcm.moduleutil.widget.CircularProgressView;
|
||||||
import com.qxcm.moduleutil.widget.CustomMusicFloatingView;
|
import com.qxcm.moduleutil.widget.CustomMusicFloatingView;
|
||||||
import com.qxcm.moduleutil.widget.MusicView;
|
import com.qxcm.moduleutil.widget.MusicView;
|
||||||
import com.qxcm.moduleutil.widget.SilentCountDownTimer;
|
import com.qxcm.moduleutil.widget.SilentCountDownTimer;
|
||||||
@@ -102,6 +113,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import io.agora.musiccontentcenter.Music;
|
import io.agora.musiccontentcenter.Music;
|
||||||
|
import io.reactivex.disposables.Disposable;
|
||||||
import pub.devrel.easypermissions.AppSettingsDialog;
|
import pub.devrel.easypermissions.AppSettingsDialog;
|
||||||
import pub.devrel.easypermissions.EasyPermissions;
|
import pub.devrel.easypermissions.EasyPermissions;
|
||||||
|
|
||||||
@@ -139,6 +151,7 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
|
|||||||
private boolean imYc;
|
private boolean imYc;
|
||||||
|
|
||||||
private SilentCountDownTimer silentCountDownTimer;
|
private SilentCountDownTimer silentCountDownTimer;
|
||||||
|
private CircularProgressView circularProgress;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNewIntent(Intent intent) {
|
protected void onNewIntent(Intent intent) {
|
||||||
@@ -238,7 +251,112 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
|
|||||||
ivQuan.setOnClickListener(v -> toggleFullScreen());
|
ivQuan.setOnClickListener(v -> toggleFullScreen());
|
||||||
ivExitFullscreen.setOnClickListener(v -> exitFullScreen());
|
ivExitFullscreen.setOnClickListener(v -> exitFullScreen());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initView() {
|
||||||
|
super.initView();
|
||||||
|
circularProgress = mBinding.giftShowProgress;
|
||||||
|
circularProgress.setProgress(0);
|
||||||
|
mBinding.giftShowLayout.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
onGiftGiveProgressClcik();
|
||||||
|
LogUtils.e("xj", "onSubscribe2222");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onGiftGiveProgressClcik() {
|
||||||
|
if (giftGiveEvent == null || giftGiveEvent.roonGiftModel == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// if (giftCountTimer != null) {
|
||||||
|
// giftCountTimer.cancel();
|
||||||
|
// giftCountTimer = null;
|
||||||
|
// }
|
||||||
|
RetrofitClient.getInstance().roomGift(giftGiveEvent.getRoom_id(), giftGiveEvent.getRoonGiftModel().getGift_id(), giftGiveEvent.getNum(), giftGiveEvent.getUserId(),"1",giftGiveEvent.getPit(), new BaseObserver<String>(){
|
||||||
|
@Override
|
||||||
|
public void onSubscribe(Disposable d) {
|
||||||
|
// showGiftGiveProgress();
|
||||||
|
// LogUtils.e("xj", "onSubscribe");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNext(String s) {
|
||||||
|
showGiftGiveProgress();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(Throwable e) {
|
||||||
|
super.onError(e);
|
||||||
|
String msg = e.getMessage();
|
||||||
|
if (!TextUtils.isEmpty(msg) && msg.contains("当前余额不足")) {
|
||||||
|
com.hjq.toast.ToastUtils.show("当前余额不足,请充值");
|
||||||
|
ThreadUtils.runOnUiThreadDelayed(() -> {
|
||||||
|
RechargeDialogFragment.show(roomId, getSupportFragmentManager());
|
||||||
|
// DialogUtils.showDialogFragment(ARouter.getInstance().build(ARouteConstants.RECHARGE_DIALOG).navigation());
|
||||||
|
}, 1400);
|
||||||
|
}
|
||||||
|
hideGiftGiveProgress();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private RoomGiftGiveEvent giftGiveEvent;
|
||||||
|
|
||||||
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
|
public void roomGiveGiftEvent(RoomGiftGiveEvent event) {
|
||||||
|
if (isFinishing() || event == null || event.roonGiftModel == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
giftGiveEvent = event;
|
||||||
|
showGiftGiveProgress();
|
||||||
|
}
|
||||||
|
private int giftProgress=0;
|
||||||
|
private CountDownTimer giftCountTimer;
|
||||||
|
|
||||||
|
private void startGiftProgressTime() {
|
||||||
|
giftProgress = 0;
|
||||||
|
if (giftCountTimer != null) {
|
||||||
|
giftCountTimer.cancel();
|
||||||
|
}
|
||||||
|
LogUtils.e("xj2", "onSubscribe");
|
||||||
|
giftCountTimer = new CountDownTimer(1000 * 10, 50) {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTick(long millisUntilFinished) {
|
||||||
|
if (!isFinishing()) {
|
||||||
|
circularProgress.setProgress(1000 - (int) (millisUntilFinished / 10));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFinish() {
|
||||||
|
circularProgress.setProgress(1000);
|
||||||
|
hideGiftGiveProgress();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
giftCountTimer.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showGiftGiveProgress() {
|
||||||
|
ImageUtils.loadImageView(giftGiveEvent.roonGiftModel.getBase_image(), mBinding.giftShowProgressImg);
|
||||||
|
circularProgress.setProgress(1000);// 显示进度条,2025年7月19日11:23:37将这个从下面的方法提起到这里,
|
||||||
|
startGiftProgressTime();
|
||||||
|
mBinding.giftShowLayout.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void hideGiftGiveProgress() {
|
||||||
|
mBinding.giftShowLayout.setVisibility(View.GONE);
|
||||||
|
if (giftCountTimer != null) {
|
||||||
|
giftCountTimer.cancel();
|
||||||
|
giftCountTimer = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void toggleFullScreen() {
|
private void toggleFullScreen() {
|
||||||
if (isFullScreen) {
|
if (isFullScreen) {
|
||||||
exitFullScreen();
|
exitFullScreen();
|
||||||
@@ -276,11 +394,9 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
|
|||||||
|
|
||||||
private void exitFullScreen() {
|
private void exitFullScreen() {
|
||||||
isFullScreen = false;
|
isFullScreen = false;
|
||||||
|
|
||||||
// 恢复系统UI
|
// 恢复系统UI
|
||||||
View decorView = getWindow().getDecorView();
|
View decorView = getWindow().getDecorView();
|
||||||
decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
|
decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
|
||||||
|
|
||||||
// 设置回竖屏
|
// 设置回竖屏
|
||||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||||
// 找到 fl_screenshare 并移回原父容器
|
// 找到 fl_screenshare 并移回原父容器
|
||||||
@@ -299,8 +415,6 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
|
|||||||
|
|
||||||
floatingMagnetView.addView(fl_screenshare);
|
floatingMagnetView.addView(fl_screenshare);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 恢复界面
|
// 恢复界面
|
||||||
fullScreenContainer.setVisibility(View.GONE);
|
fullScreenContainer.setVisibility(View.GONE);
|
||||||
floatingMagnetView.setVisibility(View.VISIBLE);
|
floatingMagnetView.setVisibility(View.VISIBLE);
|
||||||
@@ -342,6 +456,7 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
public void roomInfoEvent(RoomMessageEvent messageEvent) {
|
public void roomInfoEvent(RoomMessageEvent messageEvent) {
|
||||||
if (messageEvent.getMsgType() == 1005) {
|
if (messageEvent.getMsgType() == 1005) {
|
||||||
|
|||||||
@@ -407,6 +407,11 @@ public class RoomGiftDialogFragment extends BaseMvpDialogFragment<RewardGiftPres
|
|||||||
@Override
|
@Override
|
||||||
public void giveGift() {
|
public void giveGift() {
|
||||||
// dismiss();
|
// dismiss();
|
||||||
|
if (roomGiftGiveEvent != null){
|
||||||
|
EventBus.getDefault().post(roomGiftGiveEvent);
|
||||||
|
roomGiftGiveEvent = null;
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public class RoomKtvFragment extends BaseMvpFragment<RoomPresenter, FragmentRoom
|
|||||||
private String duration;
|
private String duration;
|
||||||
private MusicSongBean musicSongBean;
|
private MusicSongBean musicSongBean;
|
||||||
|
|
||||||
BaseQuickAdapter<RoomCharmRankBean, BaseViewHolder> adapter;
|
BaseQuickAdapter<RoomPitBean, BaseViewHolder> adapter;
|
||||||
private RoomOnline online;
|
private RoomOnline online;
|
||||||
|
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ public class RoomKtvFragment extends BaseMvpFragment<RoomPresenter, FragmentRoom
|
|||||||
if (getActivity() instanceof RoomActivity) {
|
if (getActivity() instanceof RoomActivity) {
|
||||||
((RoomActivity) getActivity()).setvisibTop(true);
|
((RoomActivity) getActivity()).setvisibTop(true);
|
||||||
}
|
}
|
||||||
MvpPre.getCharmRank(roomInfoResp.getRoom_info().getRoom_id());
|
// MvpPre.getCharmRank(roomInfoResp.getRoom_info().getRoom_id());
|
||||||
mKaraokeView = new KaraokeView(mBinding.lyricsView, null);
|
mKaraokeView = new KaraokeView(mBinding.lyricsView, null);
|
||||||
mKaraokeView.setKaraokeEvent(new KaraokeEvent() {
|
mKaraokeView.setKaraokeEvent(new KaraokeEvent() {
|
||||||
@Override
|
@Override
|
||||||
@@ -144,7 +144,6 @@ public class RoomKtvFragment extends BaseMvpFragment<RoomPresenter, FragmentRoom
|
|||||||
did = roomInfoResp.getSong_user_info().getDid();
|
did = roomInfoResp.getSong_user_info().getDid();
|
||||||
AgoraManager.getInstance(getActivity()).isPreload(Long.parseLong(roomInfoResp.getSong_user_info().getSong_code()), 1);
|
AgoraManager.getInstance(getActivity()).isPreload(Long.parseLong(roomInfoResp.getSong_user_info().getSong_code()), 1);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
AgoraManager.getInstance(getActivity()).isPreload(Long.parseLong(roomInfoResp.getSong_user_info().getSong_code()), 2);
|
AgoraManager.getInstance(getActivity()).isPreload(Long.parseLong(roomInfoResp.getSong_user_info().getSong_code()), 2);
|
||||||
}
|
}
|
||||||
musicSongBean = roomInfoResp.getSong_user_info();
|
musicSongBean = roomInfoResp.getSong_user_info();
|
||||||
@@ -234,20 +233,20 @@ public class RoomKtvFragment extends BaseMvpFragment<RoomPresenter, FragmentRoom
|
|||||||
mBinding.llJs.setOnClickListener(this::onClick);
|
mBinding.llJs.setOnClickListener(this::onClick);
|
||||||
mBinding.llQg.setOnClickListener(this::onClick);
|
mBinding.llQg.setOnClickListener(this::onClick);
|
||||||
mBinding.llSz.setOnClickListener(this::onClick);
|
mBinding.llSz.setOnClickListener(this::onClick);
|
||||||
adapter = new BaseQuickAdapter<RoomCharmRankBean, BaseViewHolder>(R.layout.item_room_charm_rank) {
|
adapter = new BaseQuickAdapter<RoomPitBean, BaseViewHolder>(R.layout.item_room_charm_rank) {
|
||||||
@Override
|
@Override
|
||||||
protected void convert(BaseViewHolder helper, RoomCharmRankBean item) {
|
protected void convert(BaseViewHolder helper, RoomPitBean item) {
|
||||||
|
|
||||||
RoomPitBean bean = new RoomPitBean();
|
// RoomPitBean bean = new RoomPitBean();
|
||||||
bean.setUser_id(item.getUser_id());
|
// bean.setUser_id(item.getUser_id());
|
||||||
bean.setRoom_id(roomInfoResp.getRoom_info().getRoom_id());
|
// bean.setRoom_id(roomInfoResp.getRoom_info().getRoom_id());
|
||||||
bean.setNickname(item.getNickname());
|
// bean.setNickname(item.getNickname());
|
||||||
bean.setAvatar(item.getAvatar());
|
// bean.setAvatar(item.getAvatar());
|
||||||
bean.setDress(item.getDress());
|
// bean.setDress(item.getDress());
|
||||||
bean.setCharm(item.getCharm());
|
// bean.setCharm(item.getCharm());
|
||||||
bean.setPit_number("0");
|
// bean.setPit_number("0");
|
||||||
RoomDefaultWheatView mu_rank = helper.getView(R.id.mu_rank);
|
RoomDefaultWheatView mu_rank = helper.getView(R.id.mu_rank);
|
||||||
mu_rank.setData(bean);
|
mu_rank.setData(item);
|
||||||
mu_rank.setOnClickListener(new View.OnClickListener() {
|
mu_rank.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
@@ -258,6 +257,9 @@ public class RoomKtvFragment extends BaseMvpFragment<RoomPresenter, FragmentRoom
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
mBinding.recyclerView.setAdapter(adapter);
|
mBinding.recyclerView.setAdapter(adapter);
|
||||||
|
if (roomInfoResp.getSong_pit_list() != null && roomInfoResp.getSong_pit_list().size() > 0){
|
||||||
|
adapter.setNewData(roomInfoResp.getSong_pit_list());
|
||||||
|
}
|
||||||
AgoraManager.getInstance(getActivity()).selectAudioTrack(0);
|
AgoraManager.getInstance(getActivity()).selectAudioTrack(0);
|
||||||
isRotate = true;
|
isRotate = true;
|
||||||
RoomDefaultWheatView muYc = mBinding.muYc;
|
RoomDefaultWheatView muYc = mBinding.muYc;
|
||||||
@@ -520,6 +522,7 @@ public class RoomKtvFragment extends BaseMvpFragment<RoomPresenter, FragmentRoom
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
} else if (messageEvent.getMsgType() == 1003) {
|
} else if (messageEvent.getMsgType() == 1003) {
|
||||||
|
|
||||||
if (messageEvent.getText().getPit_number().equals("9") || messageEvent.getText().getPit_number().equals("10")) {
|
if (messageEvent.getText().getPit_number().equals("9") || messageEvent.getText().getPit_number().equals("10")) {
|
||||||
|
|
||||||
RoomPitBean pitBean = new RoomPitBean();
|
RoomPitBean pitBean = new RoomPitBean();
|
||||||
@@ -537,9 +540,21 @@ public class RoomKtvFragment extends BaseMvpFragment<RoomPresenter, FragmentRoom
|
|||||||
RoomDefaultWheatView roomDefaultWheatView = mBinding.muJb;
|
RoomDefaultWheatView roomDefaultWheatView = mBinding.muJb;
|
||||||
roomDefaultWheatView.setData(pitBean);
|
roomDefaultWheatView.setData(pitBean);
|
||||||
}
|
}
|
||||||
|
}else {
|
||||||
|
RoomPitBean pitBean = new RoomPitBean();
|
||||||
|
pitBean.setPit_number(messageEvent.getText().getPit_number());
|
||||||
|
pitBean.setUser_id(messageEvent.getText().getFromUserInfo().getUser_id() + "");
|
||||||
|
pitBean.setAvatar(messageEvent.getText().getFromUserInfo().getAvatar());
|
||||||
|
pitBean.setNickname(messageEvent.getText().getFromUserInfo().getNickname());
|
||||||
|
pitBean.setSex(messageEvent.getText().getFromUserInfo().getSex() + "");
|
||||||
|
pitBean.setCharm(messageEvent.getText().getFromUserInfo().getCharm());
|
||||||
|
|
||||||
|
roomInfoResp.getSong_pit_list().add(pitBean);
|
||||||
}
|
}
|
||||||
|
adapter.setNewData(roomInfoResp.getSong_pit_list());
|
||||||
sv();
|
sv();
|
||||||
} else if (messageEvent.getMsgType() == 1004) {
|
} else if (messageEvent.getMsgType() == 1004) {
|
||||||
|
|
||||||
if (messageEvent.getText().getPit_number().equals("9") || messageEvent.getText().getPit_number().equals("10")) {
|
if (messageEvent.getText().getPit_number().equals("9") || messageEvent.getText().getPit_number().equals("10")) {
|
||||||
RoomPitBean pitBean = new RoomPitBean();
|
RoomPitBean pitBean = new RoomPitBean();
|
||||||
pitBean.setPit_number(messageEvent.getText().getPit_number());
|
pitBean.setPit_number(messageEvent.getText().getPit_number());
|
||||||
@@ -555,6 +570,14 @@ public class RoomKtvFragment extends BaseMvpFragment<RoomPresenter, FragmentRoom
|
|||||||
RoomDefaultWheatView roomDefaultWheatView = mBinding.muJb;
|
RoomDefaultWheatView roomDefaultWheatView = mBinding.muJb;
|
||||||
roomDefaultWheatView.setData(pitBean);
|
roomDefaultWheatView.setData(pitBean);
|
||||||
}
|
}
|
||||||
|
}else {
|
||||||
|
for (int i = 0; i < roomInfoResp.getSong_pit_list().size(); i++){
|
||||||
|
if (roomInfoResp.getSong_pit_list().get(i).getUser_id().equals(messageEvent.getText().getFromUserInfo().getUser_id() + "")){
|
||||||
|
roomInfoResp.getSong_pit_list().remove(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
adapter.setNewData(roomInfoResp.getSong_pit_list());
|
||||||
}
|
}
|
||||||
sv();
|
sv();
|
||||||
} else if (messageEvent.getMsgType() == 1019) {
|
} else if (messageEvent.getMsgType() == 1019) {
|
||||||
@@ -611,7 +634,7 @@ public class RoomKtvFragment extends BaseMvpFragment<RoomPresenter, FragmentRoom
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getCharmRank(List<RoomCharmRankBean> list) {
|
public void getCharmRank(List<RoomCharmRankBean> list) {
|
||||||
adapter.setNewData(list);
|
// adapter.setNewData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -13,6 +13,6 @@
|
|||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:room_wheat_number="0"/>
|
app:room_wheat_number="9999"/>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@@ -9,6 +9,7 @@ import androidx.annotation.Nullable;
|
|||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.fragment.app.FragmentStatePagerAdapter;
|
import androidx.fragment.app.FragmentStatePagerAdapter;
|
||||||
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -27,6 +28,8 @@ import com.qxcm.moduleutil.base.BaseMvpFragment;
|
|||||||
import com.qxcm.moduleutil.bean.BannerModel;
|
import com.qxcm.moduleutil.bean.BannerModel;
|
||||||
import com.qxcm.moduleutil.bean.RoomTypeModel;
|
import com.qxcm.moduleutil.bean.RoomTypeModel;
|
||||||
import com.qxcm.moduleutil.bean.TopRoom;
|
import com.qxcm.moduleutil.bean.TopRoom;
|
||||||
|
import com.qxcm.moduleutil.event.MqttBean;
|
||||||
|
import com.qxcm.moduleutil.event.RoomGiftRunable;
|
||||||
import com.qxcm.moduleutil.utils.ARouteConstants;
|
import com.qxcm.moduleutil.utils.ARouteConstants;
|
||||||
import com.qxcm.moduleutil.utils.ImageUtils;
|
import com.qxcm.moduleutil.utils.ImageUtils;
|
||||||
import com.stx.xhb.xbanner.XBanner;
|
import com.stx.xhb.xbanner.XBanner;
|
||||||
@@ -34,12 +37,14 @@ import com.sunfusheng.marqueeview.MarqueeView;
|
|||||||
import com.zhpan.bannerview.constants.PageStyle;
|
import com.zhpan.bannerview.constants.PageStyle;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
|
import org.greenrobot.eventbus.ThreadMode;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*声播
|
* 声播
|
||||||
*/
|
*/
|
||||||
public class VoiceCategoryFragment extends BaseMvpFragment<VoiceCategoryPresenter, FragmentVoiceCategoryBinding> implements VoiceCategoryContacts.View {
|
public class VoiceCategoryFragment extends BaseMvpFragment<VoiceCategoryPresenter, FragmentVoiceCategoryBinding> implements VoiceCategoryContacts.View {
|
||||||
|
|
||||||
@@ -51,7 +56,9 @@ public class VoiceCategoryFragment extends BaseMvpFragment<VoiceCategoryPresente
|
|||||||
|
|
||||||
private List<TopRoom> roomList;
|
private List<TopRoom> roomList;
|
||||||
|
|
||||||
CarouselBannerAdapter carouselBannerAdapter ;
|
private List<MqttBean.ListBean> mqttList;
|
||||||
|
private List<String> info;
|
||||||
|
CarouselBannerAdapter carouselBannerAdapter;
|
||||||
|
|
||||||
public static VoiceCategoryFragment newInstance() {
|
public static VoiceCategoryFragment newInstance() {
|
||||||
return new VoiceCategoryFragment();
|
return new VoiceCategoryFragment();
|
||||||
@@ -84,7 +91,7 @@ public class VoiceCategoryFragment extends BaseMvpFragment<VoiceCategoryPresente
|
|||||||
@Override
|
@Override
|
||||||
protected void initData() {
|
protected void initData() {
|
||||||
MvpPre.getBanners();
|
MvpPre.getBanners();
|
||||||
MvpPre.getCarousels(1,1,"10","2","");//顶部推荐
|
MvpPre.getCarousels(1, 1, "10", "2", "");//顶部推荐
|
||||||
MvpPre.getCategories();
|
MvpPre.getCategories();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,27 +166,55 @@ public class VoiceCategoryFragment extends BaseMvpFragment<VoiceCategoryPresente
|
|||||||
.navigation();
|
.navigation();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
List<String> info = new ArrayList<>();
|
// mBinding.marqueeView.setOnItemClickListener(new MarqueeView.OnItemClickListener() {
|
||||||
info.add("1. 大家好,我是孙福生。");
|
// @Override
|
||||||
info.add("2. 欢迎大家关注我哦!");
|
// public void onItemClick(int position, TextView textView) {
|
||||||
info.add("3. GitHub帐号:sfsheng0322");
|
//
|
||||||
info.add("4. 新浪微博:孙福生微博");
|
// ToastUtils.show("点击了第 " + position + " 个 item");
|
||||||
info.add("5. 个人博客:sunfusheng.com");
|
// }
|
||||||
info.add("6. 微信公众号:孙福生");
|
// });
|
||||||
mBinding.marqueeView.startWithList(info);
|
|
||||||
mBinding.marqueeView.setOnItemClickListener(new MarqueeView.OnItemClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onItemClick(int position, TextView textView) {
|
|
||||||
|
|
||||||
ToastUtils.show("点击了第 " + position + " 个 item");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
mBinding.tvWg.setOnClickListener(v -> {
|
mBinding.tvWg.setOnClickListener(v -> {
|
||||||
ToastUtils.show("点击了第 " + mBinding.marqueeView.getPosition() + " 个 item");
|
ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("form", "首页热门列表").withString("roomId", mqttList.get(mBinding.marqueeView.getPosition()).getRoomId()).navigation();
|
||||||
});
|
});
|
||||||
|
|
||||||
mBinding.rl.setVisibility(GONE);
|
}
|
||||||
|
|
||||||
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
|
public void onEvent(MqttBean event) {
|
||||||
|
|
||||||
|
List<MqttBean> cachedMqttBeans = RoomGiftRunable.getMqttCache();
|
||||||
|
if (cachedMqttBeans == null || cachedMqttBeans.isEmpty()){
|
||||||
|
mBinding.rl.setVisibility(GONE);
|
||||||
|
}else {
|
||||||
|
mBinding.rl.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
if (mqttList == null){
|
||||||
|
mqttList = new ArrayList<>();
|
||||||
|
info = new ArrayList<>();
|
||||||
|
}
|
||||||
|
mqttList.clear();
|
||||||
|
info.clear();
|
||||||
|
// 处理缓存数据
|
||||||
|
for (MqttBean mqttBean : cachedMqttBeans) {
|
||||||
|
// 处理每一条 mqttBean 数据
|
||||||
|
mqttList.add(mqttBean.getList());
|
||||||
|
info.add(mqttBean.getList().getFromUserName()+"送给"+mqttBean.getList().getToUserName()+"\n"+mqttBean.getList().getGiftName());
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (mqttList == null) {
|
||||||
|
// info = new ArrayList<>();
|
||||||
|
// mqttList = new ArrayList<>();
|
||||||
|
// }
|
||||||
|
// if (mqttList.size() < 6) {
|
||||||
|
//// info.add(event.getList().getFromUserName()+"送给"+event.getList().getToUserName()+"\n"+event.getList().getGiftName());
|
||||||
|
// mqttList.add(event.getList());
|
||||||
|
// } else {
|
||||||
|
// mqttList.remove(0); // 移除第一条数据
|
||||||
|
// info.remove(0); // 移除第一条数据
|
||||||
|
// mqttList.add(event.getList());
|
||||||
|
// }
|
||||||
|
// info.add(event.getList().getFromUserName()+"送给"+event.getList().getToUserName()+"\n"+event.getList().getGiftName());
|
||||||
|
mBinding.marqueeView.startWithList(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -188,6 +223,11 @@ public class VoiceCategoryFragment extends BaseMvpFragment<VoiceCategoryPresente
|
|||||||
return R.layout.fragment_voice_category;
|
return R.layout.fragment_voice_category;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
onEvent(null);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCategories(List<RoomTypeModel> list) {
|
public void setCategories(List<RoomTypeModel> list) {
|
||||||
@@ -208,14 +248,14 @@ public class VoiceCategoryFragment extends BaseMvpFragment<VoiceCategoryPresente
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTopRoom(List<TopRoom> topRooms,int type) {
|
public void setTopRoom(List<TopRoom> topRooms, int type) {
|
||||||
// if (topRooms == null || topRooms.isEmpty() || topRooms.size() < 1) {
|
// if (topRooms == null || topRooms.isEmpty() || topRooms.size() < 1) {
|
||||||
// mBinding.constraintLayout.setVisibility(View.GONE);
|
// mBinding.constraintLayout.setVisibility(View.GONE);
|
||||||
// return;
|
// return;
|
||||||
// }else {
|
// }else {
|
||||||
mBinding.constraintLayout.setVisibility(View.VISIBLE);
|
mBinding.constraintLayout.setVisibility(View.VISIBLE);
|
||||||
// }
|
// }
|
||||||
roomList= topRooms;
|
roomList = topRooms;
|
||||||
mBinding.bannerViewPager.create(topRooms); // 刷新数据并启动自动播放
|
mBinding.bannerViewPager.create(topRooms); // 刷新数据并启动自动播放
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,21 +7,9 @@ pluginManagement {
|
|||||||
includeGroupByRegex("androidx.*")
|
includeGroupByRegex("androidx.*")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
maven { url "https://maven.aliyun.com/repository/public/" }
|
|
||||||
maven { url "https://maven.aliyun.com/repository/central" }
|
|
||||||
maven { url "https://maven.aliyun.com/repository/gradle-plugin" }
|
|
||||||
maven { url 'https://maven.aliyun.com/repository/google' } // Google专属库
|
|
||||||
maven { url "https://jitpack.io" }
|
|
||||||
maven { url "https://mvn.mob.com/android" }
|
|
||||||
maven { url 'https://mirrors.cloud.tencent.com/nexus/repository/maven' }
|
maven { url 'https://mirrors.cloud.tencent.com/nexus/repository/maven' }
|
||||||
maven { url "https://mirrors.tencent.com/nexus/repository/maven-public/" }
|
maven { url "https://mirrors.tencent.com/nexus/repository/maven-public/" }
|
||||||
mavenCentral()
|
maven { url 'https://mirrors.cloud.tencent.com/nexus/repository/maven_public/' }
|
||||||
gradlePluginPortal()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dependencyResolutionManagement {
|
|
||||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
|
||||||
repositories {
|
|
||||||
|
|
||||||
maven { url "https://maven.aliyun.com/repository/public/" }
|
maven { url "https://maven.aliyun.com/repository/public/" }
|
||||||
maven { url "https://maven.aliyun.com/repository/central" }
|
maven { url "https://maven.aliyun.com/repository/central" }
|
||||||
@@ -29,9 +17,24 @@ dependencyResolutionManagement {
|
|||||||
maven { url 'https://maven.aliyun.com/repository/google' } // Google专属库
|
maven { url 'https://maven.aliyun.com/repository/google' } // Google专属库
|
||||||
maven { url "https://jitpack.io" }
|
maven { url "https://jitpack.io" }
|
||||||
maven { url "https://mvn.mob.com/android" }
|
maven { url "https://mvn.mob.com/android" }
|
||||||
|
mavenCentral()
|
||||||
|
gradlePluginPortal()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dependencyResolutionManagement {
|
||||||
|
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||||
|
repositories {
|
||||||
maven { url 'https://mirrors.cloud.tencent.com/nexus/repository/maven' }
|
maven { url 'https://mirrors.cloud.tencent.com/nexus/repository/maven' }
|
||||||
maven { url "https://mirrors.tencent.com/nexus/repository/maven-public/" }
|
maven { url "https://mirrors.tencent.com/nexus/repository/maven-public/" }
|
||||||
flatDir { dirs 'libs' } // 如果需要 flatDir,放在这里
|
maven { url 'https://mirrors.cloud.tencent.com/nexus/repository/maven_public/' }
|
||||||
|
|
||||||
|
maven { url "https://maven.aliyun.com/repository/public/" }
|
||||||
|
maven { url "https://maven.aliyun.com/repository/central" }
|
||||||
|
maven { url "https://maven.aliyun.com/repository/gradle-plugin" }
|
||||||
|
maven { url 'https://maven.aliyun.com/repository/google' } // Google专属库
|
||||||
|
maven { url "https://jitpack.io" }
|
||||||
|
maven { url "https://mvn.mob.com/android" }
|
||||||
|
flatDir { dirs 'libs' } // 如果需要 flatDir,放在这里
|
||||||
google()
|
google()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user