Compare commits

...

2 Commits

Author SHA1 Message Date
1d348784ea 1:修改播放礼物特效
2:修改特效按照ios方式更改
2025-09-13 15:38:16 +08:00
5635d0c707 1:修改播放礼物特效
2:修改特效按照ios方式更改
2025-09-13 15:36:44 +08:00
21 changed files with 1153 additions and 189 deletions

View File

@@ -55,7 +55,7 @@ android {
}
buildTypes {
release {
minifyEnabled false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
@@ -77,7 +77,7 @@ android {
debug {
debuggable true
minifyEnabled false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.debug

View File

@@ -30,7 +30,7 @@ isBuildModule=false
android.injected.testOnly=false
APP_VERSION_NAME=1.0.0
APP_VERSION_CODE=121
APP_VERSION_CODE=125
org.gradle.jvm.toolchain.useLegacyAdapters=false
#org.gradle.java.home=C\:\\Users\\qx\\.jdks\\ms-17.0.15

View File

@@ -44,6 +44,8 @@ import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import okhttp3.Call;
import okhttp3.Callback;
@@ -121,7 +123,7 @@ public class AvatarFrameView extends FrameLayout {
private ChannelSplitRenderer1 renderer;
private int mType;//1:循环播放 2:播放一次停止播放
private File mFile;
private final Queue<PlayItem> playQueue = new LinkedList<>();
private final BlockingQueue<PlayItem> playQueue = new LinkedBlockingQueue<>();
private boolean isPlaying = false;
// 添加销毁标记
@@ -224,7 +226,7 @@ public class AvatarFrameView extends FrameLayout {
return "";
}
private void playNextFromQueue() {
public void playNextFromQueue() {
// if (isDestroyed) return;
// 确保在主线程中执行
// if (Looper.myLooper() != Looper.getMainLooper()) {
@@ -238,10 +240,13 @@ public class AvatarFrameView extends FrameLayout {
return;
}
// 检查是否可以开始新的播放
if (!playbackManager.canStartNewPlayback()) {
Logger.d("AvatarFrameView", "Max concurrent playbacks reached, waiting...");
return;
}
// if (!playbackManager.canStartNewPlayback()) {
// Logger.d("AvatarFrameView", "Max concurrent playbacks reached, waiting...");
// return;
// }
if (!isPlaying || !isActuallyPlaying()) {
PlayItem item = playQueue.poll();
if (item != null) {
@@ -257,14 +262,17 @@ public class AvatarFrameView extends FrameLayout {
Logger.d("AvatarFrameView", "Queue is empty, stop playing");
}
}
}
// 添加统一的播放完成处理方法
public void onPlaybackComplete() {
if (isDestroyed) return;
mainHandler.post(() -> {
// 再次检查是否已销毁
if (isDestroyed) return;
// 通知播放管理器播放完成
playbackManager.onFinishPlayback();
// // 通知播放管理器播放完成
// playbackManager.onFinishPlayback();
// 重置播放状态
isPlaying = false;
@@ -280,19 +288,25 @@ public class AvatarFrameView extends FrameLayout {
private void processPlayItem(PlayItem item) {
try {
clearPrevious();
// clearPrevious();
String ext = getFileExtension(item.url);
if ("svga".equalsIgnoreCase(ext)) {
mainHandler.post(() -> {
renderType = RenderType.SVGA;
mType = item.type;
if (mBinding != null) {
mBinding.playView.setVisibility(View.GONE);
}
loadSVGA(item.url);
} );
} else if ("mp4".equalsIgnoreCase(ext)) {
mainHandler.post(() -> {
renderType = RenderType.MP4;
mType = item.type;
mBinding.playView.setVisibility(View.VISIBLE);
downloadAndPlayMp4(item.url);
} );
} else {
// 不支持的格式,直接完成
handlePlaybackComplete();
@@ -315,8 +329,11 @@ public class AvatarFrameView extends FrameLayout {
}
public boolean isPlaying() {
if (mBinding!=null && mBinding.playView!=null) {
return mBinding.playView.isRunning();
}
return true;
}
// 在 AvatarFrameView 类中添加以下代码
private static final int MAX_CONCURRENT_PROCESSING = 3; // 同时处理的最大动画数
@@ -330,24 +347,12 @@ public class AvatarFrameView extends FrameLayout {
mainHandler.post(() -> setSource(url, type2));
return;
}
// // 检查内存状态
// if (isMemoryLow()) {
// LogUtils.w(TAG, "Low memory, skipping animation");
// clearQueue();
// return;
// }
// 检查特效是否开启
// if (SpUtil.getOpenEffect() != 1) {
// // 特效关闭时清空队列并停止播放
// clearQueue();
// return;
// }
// 添加到播放队列
playQueue.add(new PlayItem(url, type2));
Logger.d("AvatarFrameView", "Added to queue, queue size: " + playQueue.size() + ", url: " + url);
if (type2 == 3) {
if (type2 == 3 || type2 == 1) {
// playNextFromQueue();
loadSVGA(url);
} else {
@@ -461,12 +466,22 @@ public class AvatarFrameView extends FrameLayout {
@Override
public void onFailure(Call call, IOException e) {
LogUtils.e("MP4下载失败: " + e.toString());
mainHandler.post(() -> {
// 检查是否已销毁
if (!isDestroyed) {
onPlaybackComplete();
}
});
}
// 更简单的优化版本
@Override
public void onResponse(Call call, Response response) throws IOException {
// 在异步回调中首先检查是否已销毁
if (isDestroyed) {
LogUtils.w(TAG, "View destroyed before download completed");
return;
}
LogUtils.d("@@@@", "onResponse" + Thread.currentThread().getName());
if (response.isSuccessful()) {
try (ResponseBody responseBody = response.body()) {
@@ -493,31 +508,62 @@ public class AvatarFrameView extends FrameLayout {
fos.flush();
isTxk = true;
mainHandler.post(() -> {
// 关键在执行UI操作前再次检查是否已销毁
if (downloadedFile.exists()) {
LogUtils.d("@@@@Thread", Thread.currentThread().getName());
playMp4File(file);
playMp4File(downloadedFile); // 使用正确的文件引用
} else {
LogUtils.w(TAG, "View destroyed or file not exist after download");
onPlaybackComplete();
}
});
} catch (IOException e) {
LogUtils.e("MP4文件保存失败: " + e.getMessage());
mainHandler.post(() -> {
if (!isDestroyed) {
onPlaybackComplete();
}
});
}
} else {
mainHandler.post(() -> onPlaybackComplete());
mainHandler.post(() -> {
if (!isDestroyed) {
onPlaybackComplete();
}
});
}
} catch (Exception e) {
LogUtils.e("MP4文件保存失败: " + e.getMessage());
mainHandler.post(() -> onPlaybackComplete());
mainHandler.post(() -> {
if (!isDestroyed) {
onPlaybackComplete();
}
});
}
} else {
LogUtils.e("MP4下载响应失败");
mainHandler.post(() -> onPlaybackComplete());
mainHandler.post(() -> {
if (!isDestroyed) {
onPlaybackComplete();
}
});
}
}
});
} else {
isTxk = true;
LogUtils.e("有缓存");
mainHandler.post(() -> {
// 检查是否已销毁
if ( file.exists()) {
playMp4File(file);
} else {
LogUtils.w(TAG, "有缓存2222222222222");
// onPlaybackComplete();
}
});
// 直接播放缓存文件
// if (isTxk) {
// mBinding.playView.setLoop(1);
@@ -528,8 +574,20 @@ public class AvatarFrameView extends FrameLayout {
private void playMp4File(File file) {
try {
if (mBinding != null && file != null && file.exists()) {
// mBinding.playView.setAnimListener(new MP4PlaybackCallback());
// 双重检查确保组件未被销毁
if (isDestroyed) {
LogUtils.w(TAG, "Attempt to play MP4 file after view destroyed");
onPlaybackComplete();
return;
}
if (mBinding == null || mBinding.playView == null) {
LogUtils.w(TAG, "PlayView is null");
onPlaybackComplete();
return;
}
if (file != null && file.exists()) {
// 设置循环次数根据mType决定
if (mType == 1) {
mBinding.playView.setLoop(0); // 无限循环
@@ -537,9 +595,15 @@ public class AvatarFrameView extends FrameLayout {
mBinding.playView.setLoop(1); // 播放一次
}
// 开始播放
// 开始播放前检查视图状态
if (!isDestroyed && mBinding != null && mBinding.playView != null) {
mBinding.playView.startPlay(file);
} else {
LogUtils.w(TAG, "View was destroyed before MP4 playback started");
onPlaybackComplete();
}
} else {
LogUtils.e("播放MP4文件出错: 文件不存在或已损坏");
onPlaybackComplete();
}
} catch (Exception e) {
@@ -1265,7 +1329,7 @@ public class AvatarFrameView extends FrameLayout {
}
try {
clearPrevious(); // 清除之前的动画
// clearPrevious(); // 清除之前的动画
svgaSurface.setVisibility(View.VISIBLE);
new SVGAParser(getContext()).decodeFromAssets(assetName, new SVGAParser.ParseCompletion() {
@Override
@@ -1363,7 +1427,7 @@ public class AvatarFrameView extends FrameLayout {
// 内存检查
if (playQueue.size() % 5 == 0) {
performLightMemoryCleanup();
// performLightMemoryCleanup();
}
// 播放下一个

View File

@@ -160,7 +160,7 @@ public abstract class BaseWheatView extends ConstraintLayout implements IBaseWhe
setCardiac(pitBean.getCharm(), getTzbl());
setPitData(bean);
if (bean.getIs_online() == 2){
if (bean.getIs_online() == 2 && bean.getUser_id()!=null && !bean.getUser_id().equals("0") && !bean.getUser_id().isEmpty()){
iv_on_line.setVisibility(VISIBLE);
}else {
iv_on_line.setVisibility(GONE);

View File

@@ -0,0 +1,389 @@
package com.xscm.moduleutil.widget;
import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.FrameLayout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.blankj.utilcode.util.LogUtils;
import com.opensource.svgaplayer.SVGACallback;
import com.opensource.svgaplayer.SVGADrawable;
import com.opensource.svgaplayer.SVGAImageView;
import com.opensource.svgaplayer.SVGAParser;
import com.opensource.svgaplayer.SVGAVideoEntity;
import com.tencent.qgame.animplayer.AnimConfig;
import com.tencent.qgame.animplayer.AnimView;
import com.tencent.qgame.animplayer.inter.IAnimListener;
import com.xscm.moduleutil.bean.GiftBean;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.locks.ReentrantLock;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
public class GiftAnimView extends FrameLayout implements GiftSvgaView.OnAnimationListener {
private AnimView playerMp4View;
private GiftSvgaView svgaView;
private GiftBean playModel;
private boolean isLoadEffect = false;
private boolean isShow = true;//是否开启特效
private ReentrantLock lock = new ReentrantLock();
private List<GiftBean> giftArray = new ArrayList<>();
public ExecutorService queue = Executors.newSingleThreadExecutor();
private Context mContext;
public void setQueue(ExecutorService queue) {
this.queue = queue;
}
public GiftAnimView(Context context) {
super(context);
this.mContext = context;
init();
}
private void init() {
isLoadEffect = false;
// 初始化SVGA视图
svgaView = new GiftSvgaView(getContext());
addView(svgaView);
playerMp4View = new AnimView(getContext());
addView(playerMp4View);
// 设置布局参数 - 在Android中通常使用LayoutParams
LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
playerMp4View.setLoop(1);
playerMp4View.setLayoutParams(params);
playerMp4View.setAnimListener(new IAnimListener() {
@Override
public void onVideoDestroy() {
LogUtils.e("onVideoDestroy");
}
@Override
public void onVideoComplete() {
LogUtils.e("onVideoComplete");
post(() -> {
playerMp4View.setVisibility(View.GONE);
loadStartSVGAPlayer();
});
}
@Override
public void onVideoRender(int i, @Nullable AnimConfig animConfig) {
LogUtils.e("onVideoRender", i, animConfig);
}
@Override
public void onVideoStart() {
LogUtils.e("onVideoStart");
}
@Override
public boolean onVideoConfigReady(@NonNull AnimConfig animConfig) {
LogUtils.e("onVideoConfigReady", animConfig);
return true;
}
@Override
public void onFailed(int i, @Nullable String s) {
LogUtils.e("onFailed", s);
}
});
svgaView.setDidFinishedDisplay(this);
svgaView.setDidStartAnimation(this);
}
/// 礼物特效进来 gift为礼物实体类
public void displayEffectView(final GiftBean gift) {
queue.execute(new Runnable() {
@Override
public void run() {
/// 如果play_image不存在return
if (gift == null || gift.getPlay_image().isEmpty()) {
return;
}
/// 将play_image链接转为小写
String playImage = gift.getPlay_image();
String pathExtension = getFileExtension(playImage).toLowerCase();
/// 判定礼物的后缀是否为svga或者mp4如果非这两种 则return
if (!("svga".equals(pathExtension) || "mp4".equals(pathExtension))) {
return;
}
/// 锁住list
lock.lock();
try {
/// 添加礼物进list
giftArray.add(gift);
/// 如果没有在加载则开始加载
if (!isLoadEffect) {
/// 更改加载状态标记
isLoadEffect = true;
loadStartSVGAPlayer();
}
} finally {
/// 解锁
lock.unlock();
}
}
});
}
public void openOrCloseEffectViewWith(boolean isShow) {
this.isShow = isShow;
removeSvgaQueueData();
playerMp4View.stopPlay();
playerMp4View.setVisibility(View.GONE);
setVisibility(isShow ? View.VISIBLE : View.GONE);
}
public void stopPlay() {
removeSvgaQueueData();
playerMp4View.stopPlay();
playerMp4View.setVisibility(View.GONE);
}
private void loadStartSVGAPlayer() {
if (!isShow) {
/// isshow 为是否开启特效 如果未开启则return
return;
}
GiftBean giftModel = null;
/// list加锁
lock.lock();
try {
/// 如果list长度大于0
if (!giftArray.isEmpty()) {
/// gift的实体类则赋值取list中的第一个数据
giftModel = giftArray.get(0);
/// 移除list的第一条数据
giftArray.remove(0);
isLoadEffect = true;
} else {
isLoadEffect = false;
}
} finally {
/// 解锁
lock.unlock();
}
if (isLoadEffect && giftModel != null && !TextUtils.isEmpty(giftModel.getPlay_image())) {
GiftBean finalGiftModel = giftModel;
post(new Runnable() {
@Override
public void run() {
String playImage = finalGiftModel.getPlay_image();
if (playImage.endsWith("mp4")) {
downloadAndPlay(getContext(), playImage, new DownloadCallback() {
@Override
public void onSuccess(File file) {
post(() -> {
playerMp4View.setVisibility(View.VISIBLE);
svgaView.setVisibility(View.GONE);
playerMp4View.startPlay(file);
});
}
@Override
public void onFailure(Exception e) {
LogUtils.e("MP4下载或播放失败: " + e.getMessage());
// 处理失败情况,继续播放下一个
post(() -> {
lock.lock();
try {
isLoadEffect = false;
} finally {
lock.unlock();
}
loadStartSVGAPlayer();
});
}
});
} else if (playImage.endsWith("svga")) {
// File file = downloadAndPlay(getContext(), playImage);
post(() -> {
playerMp4View.setVisibility(View.GONE);
svgaView.setVisibility(View.VISIBLE);
svgaView.loadSVGAPlayerWith(finalGiftModel.getPlay_image(), false);
});
} else {
lock.lock();
try {
isLoadEffect = false;
} finally {
lock.unlock();
}
// 直接播放缓存文件
}
}
});
}
}
public void downloadAndPlay(Context context, String playImage, DownloadCallback callback) {
String fileName = playImage.substring(playImage.lastIndexOf("/"));
String filePath = context.getCacheDir().getAbsolutePath() + fileName;
LogUtils.e("@@@@@filePath: " + filePath.toString());
File file = new File(filePath);
if (!file.exists()) {
LogUtils.e("无缓存");
// 使用OkHttp进行下载
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url(playImage)
.build();
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
LogUtils.e("MP4下载失败: " + e.toString());
// 在主线程中回调失败
post(() -> {
if (callback != null) {
callback.onFailure(e);
}
});
}
@Override
public void onResponse(Call call, Response response) throws IOException {
if (response.isSuccessful()) {
try (ResponseBody responseBody = response.body()) {
if (responseBody != null) {
File downloadedFile = new File(filePath);
FileOutputStream fos = new FileOutputStream(downloadedFile);
fos.write(responseBody.bytes());
fos.close();
// 在主线程中回调成功
post(() -> {
if (callback != null) {
callback.onSuccess(downloadedFile);
}
});
} else {
// 在主线程中回调失败
post(() -> {
if (callback != null) {
callback.onFailure(new IOException("Response body is null"));
}
});
}
} catch (Exception e) {
LogUtils.e("MP4文件保存失败: " + e.getMessage());
// 在主线程中回调失败
post(() -> {
if (callback != null) {
callback.onFailure(e);
}
});
}
} else {
LogUtils.e("MP4下载响应失败");
// 在主线程中回调失败
post(() -> {
if (callback != null) {
callback.onFailure(new IOException("Response not successful: " + response.code()));
}
});
}
}
});
} else {
// 文件已存在,直接回调成功
if (callback != null) {
callback.onSuccess(file);
}
}
}
// 添加回调接口
public interface DownloadCallback {
void onSuccess(File file);
void onFailure(Exception e);
}
public void destroyEffectView() {
removeSvgaQueueData();
svgaView.stopEffectSvgaPlay();
playerMp4View.stopPlay();
removeView(playerMp4View);
removeView(svgaView);
svgaView = null;
playerMp4View = null;
playModel = null;
if (queue != null) {
queue.shutdown();
queue = null;
}
}
private void removeSvgaQueueData() {
lock.lock();
try {
giftArray.clear();
isLoadEffect = false;
} finally {
lock.unlock();
}
}
private String getFileExtension(String url) {
if (url != null && url.contains(".")) {
return url.substring(url.lastIndexOf(".") + 1);
}
return "";
}
@Override
public void onStartAnimation(GiftSvgaView view) {
}
@Override
public void onFinishedDisplay(GiftSvgaView view) {
post(() -> {
svgaView.setVisibility(View.GONE);
loadStartSVGAPlayer();
});
}
}

View File

@@ -0,0 +1,283 @@
package com.xscm.moduleutil.widget;
import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import android.widget.ImageView;
import com.opensource.svgaplayer.SVGACallback;
import com.opensource.svgaplayer.SVGADrawable;
import com.opensource.svgaplayer.SVGAImageView;
import com.opensource.svgaplayer.SVGAParser;
import com.opensource.svgaplayer.SVGAVideoEntity;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
public class GiftSvgaView extends FrameLayout implements SVGACallback {
private SVGAImageView player;
private SVGAParser parser;
private boolean isAutoPlay = true;
// 回调接口
public interface OnAnimationListener {
void onStartAnimation(GiftSvgaView view);
void onFinishedDisplay(GiftSvgaView view);
}
private OnAnimationListener didStartAnimation;
private OnAnimationListener didFinishedDisplay;
public GiftSvgaView(Context context) {
this(context, null);
}
public GiftSvgaView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public GiftSvgaView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initializeData(true);
}
public GiftSvgaView(Context context, boolean isAutoPlay) {
super(context);
initializeData(isAutoPlay);
}
private void initializeData(boolean isAutoPlay) {
this.isAutoPlay = isAutoPlay;
setBackgroundColor(Color.TRANSPARENT); // clearColor
setClickable(false); // userInteractionEnabled = NO
initPlayer();
}
private void initPlayer() {
player = new SVGAImageView(getContext());
player.setBackgroundColor(Color.TRANSPARENT);
player.setScaleType(ImageView.ScaleType.CENTER_CROP); // UIViewContentModeScaleAspectFill
// 如果需要 ScaleAspectFit使用 ImageView.ScaleType.FIT_CENTER
// 设置布局参数 - 填满父视图
LayoutParams params = new LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT
);
addView(player, params);
// 初始化解析器
parser = new SVGAParser(getContext());
player.setCallback(this);
}
public void loadSVGAPlayerWith(String loadPath) {
loadSVGAPlayerWith(loadPath, false);
}
public void loadSVGAPlayerWith(String loadPath, boolean inBundle) {
loadSVGAPlayerWith(loadPath, inBundle, 1);
}
public void loadSVGAPlayerWith(String loadPath, boolean inBundle, int loop) {
if (loadPath == null || loadPath.isEmpty()) {
if (didFinishedDisplay != null) {
didFinishedDisplay.onFinishedDisplay(this);
}
return;
}
if (player == null) {
initPlayer();
}
stopEffectSvgaPlay();
player.setLoops(loop);
if (loadPath.startsWith("https:") || loadPath.startsWith("http:")) {
// URL加载
try {
parser.parse(new URL(loadPath), new SVGAParser.ParseCompletion() {
@Override
public void onComplete(@NotNull SVGAVideoEntity videoItem) {
SVGADrawable drawable = new SVGADrawable(videoItem);
player.setImageDrawable(drawable);
if (isAutoPlay) {
player.startAnimation();
if (didStartAnimation != null) {
didStartAnimation.onStartAnimation(GiftSvgaView.this);
}
}
}
@Override
public void onError() {
if (didFinishedDisplay != null) {
didFinishedDisplay.onFinishedDisplay(GiftSvgaView.this);
}
}
});
} catch (Exception e) {
e.printStackTrace();
if (didFinishedDisplay != null) {
didFinishedDisplay.onFinishedDisplay(this);
}
}
} else if (inBundle) {
// 从Assets加载
try {
parser.parse(loadPath, new SVGAParser.ParseCompletion() {
@Override
public void onComplete(@NotNull SVGAVideoEntity videoItem) {
SVGADrawable drawable = new SVGADrawable(videoItem);
player.setImageDrawable(drawable);
if (isAutoPlay) {
player.startAnimation();
if (didStartAnimation != null) {
didStartAnimation.onStartAnimation(GiftSvgaView.this);
}
}
}
@Override
public void onError() {
if (didFinishedDisplay != null) {
didFinishedDisplay.onFinishedDisplay(GiftSvgaView.this);
}
}
});
} catch (Exception e) {
e.printStackTrace();
if (didFinishedDisplay != null) {
didFinishedDisplay.onFinishedDisplay(this);
}
}
} else {
// 从文件路径加载
try {
File file = new File(loadPath);
if (!file.exists() || file.length() < 4) {
if (didFinishedDisplay != null) {
didFinishedDisplay.onFinishedDisplay(this);
}
return;
}
InputStream inputStream = new FileInputStream(file);
parser.parse(inputStream, loadPath, new SVGAParser.ParseCompletion() {
@Override
public void onComplete(@NotNull SVGAVideoEntity videoItem) {
SVGADrawable drawable = new SVGADrawable(videoItem);
player.setImageDrawable(drawable);
if (isAutoPlay) {
player.startAnimation();
if (didStartAnimation != null) {
didStartAnimation.onStartAnimation(GiftSvgaView.this);
}
}
}
@Override
public void onError() {
if (didFinishedDisplay != null) {
didFinishedDisplay.onFinishedDisplay(GiftSvgaView.this);
}
}
}, true);
} catch (IOException e) {
e.printStackTrace();
if (didFinishedDisplay != null) {
didFinishedDisplay.onFinishedDisplay(this);
}
}
}
}
// Public方法
public void startEffectSvgaPlay() {
if (player != null && player.getDrawable() != null) {
player.startAnimation();
}
}
public void pauseEffectSvgaPlay() {
if (player != null) {
player.pauseAnimation();
}
}
public void stopEffectSvgaPlay() {
if (player != null) {
player.stopAnimation();
}
}
public void destroySvga() {
stopEffectSvgaPlay();
if (player != null) {
removeView(player);
player = null;
}
parser = null;
}
// SVGACallback接口实现
@Override
public void onPause() {
// 暂停回调
}
@Override
public void onFinished() {
if (didFinishedDisplay != null) {
didFinishedDisplay.onFinishedDisplay(this);
}
}
@Override
public void onRepeat() {
// 重复回调
}
@Override
public void onStep(int frame, double percentage) {
// 步骤回调
}
// Getter和Setter方法
public void setDidStartAnimation(OnAnimationListener listener) {
this.didStartAnimation = listener;
}
public void setDidFinishedDisplay(OnAnimationListener listener) {
this.didFinishedDisplay = listener;
if (player != null) {
player.setCallback(this);
}
}
public boolean isAutoPlay() {
return isAutoPlay;
}
public void setAutoPlay(boolean autoPlay) {
isAutoPlay = autoPlay;
}
public SVGAImageView getPlayer() {
return player;
}
public SVGAParser getParser() {
return parser;
}
}

View File

@@ -0,0 +1,137 @@
package com.xscm.moduleutil.widget;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import com.xscm.moduleutil.bean.GiftBean;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
public class QXGiftPlayerManager {
private static QXGiftPlayerManager instance;
private View bgEffectView;
private GiftAnimView fullEffectView;
private GiftAnimView chatEffectView;
private Context context;
private QXGiftPlayerManager(Context context) {
this.context = context.getApplicationContext();
}
public static synchronized QXGiftPlayerManager getInstance(Context context) {
if (instance == null) {
instance = new QXGiftPlayerManager(context);
}
return instance;
}
public View getDefaultBgEffectView() {
if (bgEffectView == null) {
initBgEffectView();
}
return bgEffectView;
}
public GiftAnimView getDefaultFullEffectView() {
if (fullEffectView == null) {
initFullEffectView();
}
return fullEffectView;
}
public GiftAnimView getDefaultChatEffectView() {
if (chatEffectView == null) {
initChatEffectView();
}
return chatEffectView;
}
private void initBgEffectView() {
bgEffectView = new FrameLayout(context);
bgEffectView.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
));
bgEffectView.setBackgroundColor(0x00000000);
bgEffectView.setClickable(false); // userInteractionEnabled = NO
// 添加全屏特效视图和聊天特效视图
((ViewGroup) bgEffectView).addView(getDefaultFullEffectView());
((ViewGroup) bgEffectView).addView(getDefaultChatEffectView());
}
public void displayFullEffectView(GiftBean gift) {
getDefaultFullEffectView().displayEffectView(gift);
}
public void displayChatEffectView(GiftBean gift) {
getDefaultChatEffectView().displayEffectView(gift);
}
public void openOrCloseEffectViewWith(boolean isShow) {
getDefaultFullEffectView().openOrCloseEffectViewWith(isShow);
getDefaultChatEffectView().openOrCloseEffectViewWith(isShow);
}
public void destroyEffectSvga() {
if (fullEffectView != null) {
fullEffectView.destroyEffectView();
if (bgEffectView != null) {
((ViewGroup) bgEffectView).removeView(fullEffectView);
}
fullEffectView = null;
}
if (chatEffectView != null) {
chatEffectView.destroyEffectView();
if (bgEffectView != null) {
((ViewGroup) bgEffectView).removeView(chatEffectView);
}
chatEffectView = null;
}
if (bgEffectView != null) {
bgEffectView = null;
}
}
public void stopPlay() {
if (fullEffectView != null) {
fullEffectView.stopPlay();
}
if (chatEffectView != null) {
chatEffectView.stopPlay();
}
}
private void initFullEffectView() {
fullEffectView = new GiftAnimView(context);
fullEffectView.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
));
// 创建专用线程池替代GCD队列
ExecutorService queue = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>(),
Executors.defaultThreadFactory());
fullEffectView.setQueue(queue);
}
private void initChatEffectView() {
chatEffectView = new GiftAnimView(context);
chatEffectView.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
));
// 创建专用线程池替代GCD队列
ExecutorService queue = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>(),
Executors.defaultThreadFactory());
chatEffectView.setQueue(queue);
}
}

View File

@@ -238,6 +238,16 @@ public class WheatLayoutManager {
}
}
public void updateSingleCharm(RoomPitBean pitBean, int pitNumber) {
if (pitList == null || pitList.isEmpty() || pitNumber < 1 || pitNumber > 10) return;
if (isSingleMode && this.currentSinglePit != pitNumber) return;
RoomDefaultWheatView wheatView = findWheatViewByPitNumber(pitNumber);
if (wheatView != null) {
wheatView.setCharm(pitBean.getCharm());
}
}
@Nullable
private RoomDefaultWheatView findWheatViewByPitNumber(int pitNumber) {
for (int i = 0; i < container.getChildCount(); i++) {

View File

@@ -402,6 +402,24 @@ public class WheatLayoutSingManager {
}
}
public void upDataCharm(RoomPitBean pitBean, int pitNumber){
// 检查容器状态
if (container == null || !isContainerValid()) {
return;
}
if (pitList == null || pitList.isEmpty() || pitNumber < 1 || pitNumber > 10) return;
// 如果是单个展示模式且不是当前麦位,不处理
if (isSingleMode && this.currentSinglePit != pitNumber) return;
RoomSingSongWheatView wheatView = findWheatViewByPitNumber(pitNumber);
if (wheatView != null) {
RoomPitBean bean = pitBean;
wheatView.setCharm(bean.getCharm()); // 刷新数据
}
}
@Nullable
private RoomSingSongWheatView findWheatViewByPitNumber(int pitNumber) {
// 检查容器状态

View File

@@ -35,8 +35,7 @@
android:scaleType="fitCenter"
android:visibility="gone"
tools:visibility="visible"
app:layout_constraintHeight_percent="1"
app:layout_constraintWidth_percent="1.05"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintBottom_toBottomOf="@id/riv"
app:layout_constraintEnd_toEndOf="@id/riv"
app:layout_constraintStart_toStartOf="@id/riv"

View File

@@ -370,6 +370,9 @@ public class HomePresenter extends BasePresenter<HomeContacts.View> implements H
@Override
public void onNext(ThemeBean themeBean) {
if (MvpRef==null){
MvpRef = new WeakReference<>(mView);
}
MvpRef.get().getThemeData(themeBean);
}
});

View File

@@ -139,6 +139,8 @@ import com.xscm.moduleutil.utils.SystemUtils;
import com.xscm.moduleutil.widget.AvatarFrameView;
import com.xscm.moduleutil.widget.CircularProgressView;
import com.xscm.moduleutil.widget.CustomMusicFloatingView;
import com.xscm.moduleutil.widget.GiftAnimView;
import com.xscm.moduleutil.widget.QXGiftPlayerManager;
import com.xscm.moduleutil.widget.SilentCountDownTimer;
import com.xscm.moduleutil.widget.ViewUtils;
import com.xscm.moduleutil.widget.floatingView.Floa;
@@ -158,6 +160,8 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@@ -301,6 +305,61 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
}
}
private View bgEffectView;
private void setupEffectView() {
if (bgEffectView == null) {
// 获取单例管理器
QXGiftPlayerManager manager = QXGiftPlayerManager.getInstance(getApplicationContext());
// 获取背景特效视图并添加到布局中
bgEffectView = manager.getDefaultBgEffectView();
// 找到 mBinding.svgaGift 的父容器
ViewParent parent = mBinding.svgaGift.getParent();
if (parent instanceof ViewGroup) {
ViewGroup parentViewGroup = (ViewGroup) parent;
// 将 bgEffectView 添加到父容器中,位置在 mBinding.svgaGift 之后
int index = parentViewGroup.indexOfChild(mBinding.svgaGift);
parentViewGroup.addView(bgEffectView);
// 设置布局参数 - 填满父视图
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.MATCH_PARENT
);
bgEffectView.setLayoutParams(params);
} else {
LogUtils.e("mBinding.svgaGift 没有有效的父容器");
return;
}
// 获取全屏特效视图
GiftAnimView fullEffectView = manager.getDefaultFullEffectView();
// 设置全屏特效视图的布局参数 - 居中并设置尺寸
FrameLayout.LayoutParams fullParams = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
);
fullParams.gravity = Gravity.CENTER;
fullEffectView.setLayoutParams(fullParams);
// 获取聊天特效视图
GiftAnimView chatEffectView = manager.getDefaultChatEffectView();
// 设置聊天特效视图的布局参数 - 底部居中并设置尺寸
FrameLayout.LayoutParams chatParams = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
);
chatParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
chatEffectView.setLayoutParams(chatParams);
}
// 从SharedPreferences获取是否关闭特效的设置
boolean isClose = SpUtil.getOpenEffect() != 1;
QXGiftPlayerManager.getInstance(getApplicationContext()).openOrCloseEffectViewWith(!isClose);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
@@ -317,6 +376,7 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
// }
return false;
}
/// 最小化
private void showExitRoomDialog() {
ExitRoomBottomSheet bottomSheet = ExitRoomBottomSheet.newInstance();
@@ -446,18 +506,23 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
//
// @Override
// public String doInBackground() throws Throwable {
// LogUtils.e("@@@@" + "doInBackground"+"playQueue.size()===="+playQueue.size());
// if(!playQueue.isEmpty()){
// return playQueue.poll();
// if (mBinding.svgaGift.isPlaying()){
// Thread.sleep(100); // 短暂等待
// return "";
// }
// if(!roomMessageEventQueue.isEmpty()){
// Thread.sleep(100); // 短暂等待
// return roomMessageEventQueue.poll();
// }
// return "";
// }
//
// @Override
// public void onSuccess(String result) {
// LogUtils.e("@@@@" + "onSuccess"+"playQueue.size()===="+playQueue.size());
// LogUtils.e("@@@@" + "onSuccess"+"playQueue.size()===="+roomMessageEventQueue.size());
// if(!TextUtils.isEmpty(result)){
// mBinding.svgaGift.setSource(result, 2);
//// mBinding.svgaGift.setSource(result, 2);
// mBinding.svgaGift.downloadAndPlayMp4(result);
// }
// }
//
@@ -487,16 +552,9 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
// 在子线程中执行网络请求
performNetworkRequestsAsync();
// if (BuildConfig.DEBUG) {
// StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
// .detectDiskReads()
// .detectDiskWrites()
// .detectNetwork()
// .penaltyLog()
// .build());
// }
}
private void checkAndRestoreMinimizeState() {
SharedPreferences prefs = getSharedPreferences("room_minimize_state", Context.MODE_PRIVATE);
boolean isMinimized = prefs.getBoolean("is_minimized", false);
@@ -513,6 +571,7 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
}
}
}
/**
* 在子线程中执行网络请求,避免阻塞主线程
*/
@@ -548,18 +607,6 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
});
}
// /**
// * 网络请求前的准备工作
// */
// private void prepareNetworkRequest() {
// try {
// // 可以在这里做一些轻量级的预处理工作
// // 例如:检查网络状态、准备请求参数等
// LogUtils.d("Preparing network request for room: " + roomId);
// } catch (Exception e) {
// LogUtils.e("Error in prepareNetworkRequest: " + e.getMessage());
// }
// }
// 提供安全的访问方法
public static RoomActivity getCurrentActivity() {
@@ -632,11 +679,9 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT; // 使用你定义的getWidth方法
layoutParams.height = SystemUtils.getWidth(74); // 示例高度
mBinding.roomTop.getRoot().setLayoutParams(layoutParams);
// ViewGroup.LayoutParams layoutParams2 = mBinding.vpRoomPager.getLayoutParams();
// layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT; // 使用你定义的getWidth方法
// layoutParams.height = SystemUtils.getWidth(74); // 示例高度
// mBinding.roomTop.getRoot().setLayoutParams(layoutParams);
// MP4PlaybackCallback mp4PlaybackCallback=MP4PlaybackCallback.getInstance();
// mp4PlaybackCallback.setAvatarFrameView(mBinding.svgaGift);
// mBinding.svgaGift.setAnimListener(mp4PlaybackCallback);
}
private void onGiftGiveProgressClcik() {
@@ -919,16 +964,26 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
private Runnable roomSwitchRunnable;
private String pendingRoomId;
private String lastSwitchedRoomId = "";
private final Object roomMessageLock = new Object();
private BlockingQueue<String> roomMessageEventQueue = new LinkedBlockingQueue<>();
int i = 0;
@Subscribe(threadMode = ThreadMode.MAIN)
public void roomInfoEvent(RoomMessageEvent messageEvent) {
if (messageEvent == null) return;
int msgType = messageEvent.getMsgType();
RoomMessageEvent.T text = messageEvent.getText();
if (msgType == 1005) {
handleMsgType1005(messageEvent, text);
LogUtils.e("@@@@" + "EventBusnujm2"+"playQueue.size()===="+ messageEvent.getText().getGiftInfo());
// synchronized (roomMessageLock) {
// roomMessageEventQueue.add(messageEvent.getText().getGiftInfo().getPlay_image());
// }
QXGiftPlayerManager.getInstance(this).displayFullEffectView(messageEvent.getText().getGiftInfo());
// handleMsgType1005(messageEvent, text);
hand1005(messageEvent, text);
} else if (msgType == 123) {
EventBus.getDefault().post(new RoomSettingEvent());
} else if (msgType == 1014) {
@@ -1106,7 +1161,7 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
}
roomFragment.updateSeatViewExchangedWithPitArray(mRoomInfoResp);
}
private Queue<String> playQueue = new LinkedList<>();
private static volatile MP4PlaybackCallback sInstance;
public static class MP4PlaybackCallback implements IAnimListener {
@@ -1127,6 +1182,7 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
}
return sInstance;
}
// 设置外部引用的方法
public void setAvatarFrameView(AvatarFrameView view) {
this.avatarFrameView = view;
@@ -1135,9 +1191,9 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
@Override
public void onFailed(int i, @Nullable String s) {
LogUtils.e("@@@", "MP4 playback failed: " + s);
if (avatarFrameView != null) {
avatarFrameView.onPlaybackComplete();
}
// if (avatarFrameView != null) {
// avatarFrameView.onPlaybackComplete();
// }
}
@Override
@@ -1159,10 +1215,11 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
public void onVideoComplete() {
LogUtils.e("@@@@" + "EventBus onVideoComplete");
if (avatarFrameView != null) {
avatarFrameView.onPlaybackComplete();
}
EventBus.getDefault().post(new GiftAvatarBean());
// if (avatarFrameView != null) {
// avatarFrameView.onPlaybackComplete();
// }
// avatarFrameView.playNextFromQueue();
// EventBus.getDefault().post(new GiftAvatarBean());
}
@Override
@@ -1172,26 +1229,24 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
}
private void handleMsgType1005(RoomMessageEvent messageEvent, RoomMessageEvent.T text) {
private void handleMsgType1005(String url) {
if (SpUtil.getOpenEffect() == 1) {
// LogUtils.e("@@@@" + "handleMsgType1005"+"mBinding.svgaGift.isPlaying()===="+mBinding.svgaGift.isPlaying());
// mBinding.svgaGift.setSource(url, 2);
// }
}
}
private void hand1005(RoomMessageEvent messageEvent, RoomMessageEvent.T text) {
if (text == null || mRoomInfoResp == null || mRoomInfoResp.getRoom_info() == null) return;
GiftBean giftInfo = text.getGiftInfo();
UserInfo toUserInfo = text.getToUserInfo();
if (giftInfo == null || toUserInfo == null) return;
MP4PlaybackCallback mp4PlaybackCallback=MP4PlaybackCallback.getInstance();
mp4PlaybackCallback.setAvatarFrameView(mBinding.svgaGift);
mBinding.svgaGift.setAnimListener(mp4PlaybackCallback);
if (SpUtil.getOpenEffect() == 1) {
// 特效关闭时清空队列并停止播放
playQueue.add(giftInfo.getPlay_image());
LogUtils.e("@@@@" + "handleMsgType1005"+"playQueue.size()===="+playQueue.size());
if(!mBinding.svgaGift.isPlaying()){
LogUtils.e("@@@@" + "handleMsgType1005"+"mBinding.svgaGift.isPlaying()===="+mBinding.svgaGift.isPlaying());
mBinding.svgaGift.setSource(playQueue.poll(), 2);
}
}
List<RoomPitBean> pitList = mRoomInfoResp.getRoom_info().getPit_list();
if (pitList == null) return;
@@ -1211,35 +1266,22 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
roomFragment.SingSongEvent(messageEvent);
return;
}
}
else if ("7".equals(typeId)) {//交友房
} else if ("7".equals(typeId)) {//交友房
roomFragment.friendshipRoomFragmentEvent(messageEvent);
return;
// for (RoomPitBean roomPitBean : pitList) {
// if (roomPitBean.getUser_id().equals(toUserInfo.getUser_id() + "")) {
// roomPitBean.setCharm(toUserInfo.getCharm());
// try {
// pitList.set(Integer.parseInt(roomPitBean.getPit_number()) - 1, roomPitBean);
// } catch (NumberFormatException e) {
// // Handle exception
// }
// }
// }
// roomFragment.updateSeatViewExchangedWithPitArray(mRoomInfoResp);
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void handleGiftAvatarBean(GiftAvatarBean giftAvatarBean) {
LogUtils.e("@@@@" + "EventBus2222222"+"playQueue.size()===="+playQueue.size());
if(!playQueue.isEmpty()){
String payUrl=playQueue.poll();
if(!mBinding.svgaGift.isPlaying()){
mBinding.svgaGift.setSource(payUrl, 2);
}
}
}
// @Subscribe(threadMode = ThreadMode.MAIN)
// public void handleGiftAvatarBean(GiftAvatarBean giftAvatarBean) {
// LogUtils.e("@@@@" + "EventBus2222222"+"playQueue.size()===="+roomMessageEventQueue.size());
// if(!roomMessageEventQueue.isEmpty()){
// String payUrl=roomMessageEventQueue.poll();
//// if(!mBinding.svgaGift.isPlaying()){
//// mBinding.svgaGift.setSource(payUrl, 2);
//// }
// }
// }
private void handleMsgType1014(RoomMessageEvent messageEvent, RoomMessageEvent.T text) {
if (text == null) return;
@@ -1931,10 +1973,12 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
@Subscribe(threadMode = ThreadMode.MAIN)
public void setEffectSwitch(EffectEvent event) {
if (event.isEffectOn()) {//特效开启
QXGiftPlayerManager.getInstance(this).openOrCloseEffectViewWith(true);
mBinding.svgaGift.setVisibility(View.VISIBLE);
} else {
// mBinding.svgaGift.closeEffect();
mBinding.svgaGift.closeEffect();
// mBinding.svgaGift.closeEffect();
QXGiftPlayerManager.getInstance(this).openOrCloseEffectViewWith(false);
mBinding.svgaGift.setVisibility(View.GONE);
}
}
@@ -1950,7 +1994,11 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
return;
}
if (roomJoinMountModel.getShow_type() != 1) {
mBinding.svgaZuoji.setSource(roomJoinMountModel.getRide_url(), 2);
GiftBean gift = new GiftBean();
gift.setGift_id("");
gift.setPlay_image(roomJoinMountModel.getRide_url());
QXGiftPlayerManager.getInstance(this).displayChatEffectView(gift);
// mBinding.svgaZuoji.setSource(roomJoinMountModel.getRide_url(), 2);
}
}
@@ -2148,6 +2196,7 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
finish();
}
// 添加前后台状态检测
private boolean isAppInForeground() {
ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
@@ -2620,13 +2669,6 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
AgoraManager.getInstance(this).setBjMusic(true);
}
// if ((roomBean.getType_id().equals("1") && roomBean.getLabel_id().equals("2")) || (roomBean.getType_id().equals("3") && roomBean.getLabel_id().equals("2")
// || (roomBean.getType_id().equals("4") && roomBean.getLabel_id().equals("2")))) {
// AgoraManager.getInstance(this).setBjMusic(false);
//
// } else {
// AgoraManager.getInstance(this).setBjMusic(true);
// }
AgoraManager.getInstance(this).stopMuisc();
initializeAudio();
@@ -2634,11 +2676,6 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
toutiao();
upRoomInfo(resp);
// if (mRoomInfoResp.getUser_info().getPit_number() == 9 && mRoomInfoResp.getUser_info().getUser_id().equals(SpUtil.getUserId() + "")) {
// mBinding.roomTop.rl.setVisibility(View.VISIBLE);
// } else {
// mBinding.roomTop.rl.setVisibility(View.GONE);
// }
if (userIds.length() > 0 && roomId != null) {
// MvpPre.userOnlineStatus(userIds.toString(), roomId);
@@ -2653,6 +2690,8 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
} else {
mBinding.roomTop.rl.setVisibility(View.GONE);
}
setupEffectView();
}
private void instView() {//隐藏视图
@@ -2954,6 +2993,7 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
// }
// }
}
private void resumeRoomState() {
// 恢复房间相关状态
if (MvpPre != null && roomId != null) {
@@ -3380,6 +3420,9 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
// 移除所有 OnClickListener 防止内存泄漏
clearClickListeners();
}
roomMessageEventQueue.clear();
ThreadUtils.cancel();
QXGiftPlayerManager.getInstance(getApplicationContext()).destroyEffectSvga();
} catch (Exception e) {
LogUtils.e("cleanupResources error: " + e.getMessage());
@@ -3419,11 +3462,11 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
try {
if (mBinding != null) {
if (mBinding.svgaGift != null) {
mBinding.svgaGift.release();
}
if (mBinding.svgaZuoji != null) {
mBinding.svgaZuoji.release();
// mBinding.svgaGift.release();
}
// if (mBinding.svgaZuoji != null) {
// mBinding.svgaZuoji.release();
// }
}
} catch (Exception e) {
LogUtils.e("clearSVGAResources error: " + e.getMessage());

View File

@@ -234,7 +234,7 @@ public class RoomAuctionFragment extends BaseMvpFragment<RoomAuctionPresenterTow
}
}
}
getvjs();
}
@Override
@@ -247,7 +247,7 @@ public class RoomAuctionFragment extends BaseMvpFragment<RoomAuctionPresenterTow
public void initOverlayButtons() {
// if (isButtonsInflated) return;
stub = requireActivity().findViewById(R.id.stub_buttons);
stub = requireActivity().findViewById(R.id.stub_buttons2);
if (stub != null) {
View inflated = stub.inflate();

View File

@@ -438,7 +438,11 @@ public class RoomFragment extends BaseMvpFragment<RoomPresenter, FragmentRoomBin
((RoomActivity) getActivity()).changeBackground(com.xscm.moduleutil.R.mipmap.cabin_bj);
((RoomActivity) getActivity()).setvisibTop(false);
} else if (mRoomInfoResp.getRoom_info().getType_id().equals("7")) {
if (mRoomInfoResp.getRoom_info().getRoom_background()==null || mRoomInfoResp.getRoom_info().getRoom_background().equals("")) {
((RoomActivity) getActivity()).changeBackground(com.xscm.moduleutil.R.mipmap.jiaoy_bj);
}else {
((RoomActivity) getActivity()).changeBackgroundColor(mRoomInfoResp.getRoom_info().getRoom_background());
}
((RoomActivity) getActivity()).setvisibTop(true);
} else {
((RoomActivity) getActivity()).changeBackgroundColor(mRoomInfoResp.getRoom_info().getRoom_background());

View File

@@ -15,6 +15,7 @@ import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.LinearInterpolator;
import android.widget.PopupWindow;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.ToastUtils;
@@ -835,17 +836,17 @@ public class RoomKtvFragment extends BaseMvpFragment<RoomPresenter, FragmentRoom
RoomPitBean pitBean = mBinding.muYc.pitBean;
if ((messageEvent.getText().getToUserInfo().getUser_id() + "").equals(pitBean.getUser_id())) {
pitBean.setCharm(messageEvent.getText().getToUserInfo().getCharm());
mBinding.muYc.setData(pitBean);
mBinding.muYc.setCharm(pitBean.getCharm());
}
if ((messageEvent.getText().getToUserInfo().getUser_id() + "").equals(mBinding.muZc.pitBean.getUser_id())) {
mBinding.muZc.pitBean.setCharm(messageEvent.getText().getToUserInfo().getCharm());
mBinding.muZc.setData(mBinding.muZc.pitBean);
mBinding.muZc.setCharm(mBinding.muZc.pitBean.getCharm());
return;
}
if ((messageEvent.getText().getToUserInfo().getUser_id() + "").equals(mBinding.muJb.pitBean.getUser_id())) {
mBinding.muJb.pitBean.setCharm(messageEvent.getText().getToUserInfo().getCharm());
mBinding.muJb.setData(mBinding.muJb.pitBean);
mBinding.muJb.setCharm(mBinding.muJb.pitBean.getCharm());
return;
}
for (int i = 0; i < roomInfoResp.getSong_pit_list().size(); i++) {

View File

@@ -1375,21 +1375,21 @@ public class SingSongFragment extends BaseRoomFragment<SingSongPresenter, Fragme
for (RoomPitBean pitBean : roomInfoResp.getRoom_info().getPit_list()) {
if (pitBean.getUser_id().equals(message.getText().getToUserInfo().getUser_id() + "")) {
pitBean.setCharm(message.getText().getToUserInfo().getCharm());
wheatLayoutSingManager.updateSingleWheat(pitBean, Integer.parseInt(pitBean.getPit_number()));
wheatLayoutSingManager.upDataCharm(pitBean, Integer.parseInt(pitBean.getPit_number()));
}
}
} else {
for (RoomPitBean pitBean : roomInfoRespPk.getRoom_info().getPit_list()) {
if (pitBean.getUser_id().equals(message.getText().getToUserInfo().getUser_id() + "")) {
pitBean.setCharm(message.getText().getToUserInfo().getCharm());
wheatLayoutManager2.updateSingleWheat(pitBean, Integer.parseInt(pitBean.getPit_number()));
wheatLayoutManager2.updateSingleCharm(pitBean, Integer.parseInt(pitBean.getPit_number()));
}
}
for (RoomPitBean pitBean : roomInfoResp.getRoom_info().getPit_list()) {
if (pitBean.getUser_id().equals(message.getText().getToUserInfo().getUser_id() + "")) {
pitBean.setCharm(message.getText().getToUserInfo().getCharm());
wheatLayoutManager1.updateSingleWheat(pitBean, Integer.parseInt(pitBean.getPit_number()));
wheatLayoutManager1.updateSingleCharm(pitBean, Integer.parseInt(pitBean.getPit_number()));
}
}
}

View File

@@ -342,23 +342,32 @@
<!-- </ScrollView>-->
<com.xscm.moduleutil.widget.AvatarFrameView
<View
android:id="@+id/svga_gift"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@color/transparent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<!-- <com.xscm.moduleutil.widget.AvatarFrameView-->
<!-- android:id="@+id/svga_gift"-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="0dp"-->
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
<!-- app:layout_constraintEnd_toEndOf="parent"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintTop_toTopOf="parent" />-->
<com.xscm.moduleutil.widget.AvatarFrameView
android:id="@+id/svga_zuoji"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<!-- <com.xscm.moduleutil.widget.AvatarFrameView-->
<!-- android:id="@+id/svga_zuoji"-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="0dp"-->
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
<!-- app:layout_constraintEnd_toEndOf="parent"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintTop_toTopOf="parent" />-->
<!--礼物连送图标-->
<androidx.constraintlayout.widget.ConstraintLayout

View File

@@ -522,14 +522,14 @@
</androidx.constraintlayout.widget.ConstraintLayout>
<ViewStub
android:id="@+id/stub_buttons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout="@layout/top_overlay_buttons"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:visibility="gone"/>
<!-- <ViewStub-->
<!-- android:id="@+id/stub_buttons"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout="@layout/top_overlay_buttons"-->
<!-- app:layout_constraintEnd_toEndOf="parent"-->
<!-- app:layout_constraintTop_toTopOf="parent"-->
<!-- android:visibility="gone"/>-->
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -317,7 +317,7 @@
android:layout_marginTop="-55dp"
android:layout_marginEnd="@dimen/dp_5"
android:clickable="true"
android:elevation="10dp"
android:elevation="9999dp"
android:focusable="true"
android:foreground="?android:attr/selectableItemBackground"
android:translationZ="30dp"

View File

@@ -198,7 +198,8 @@
android:layout_marginStart="@dimen/dp_12"
android:background="@drawable/bg_r73_33fffff"
android:layout_toEndOf="@id/btn_notice"
android:visibility="gone">
android:visibility="gone"
tools:visibility="visible">
<ImageView
android:id="@+id/im_qc"
@@ -229,11 +230,14 @@
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_toEndOf="@+id/rl"
android:layout_marginTop="@dimen/dp_40"
android:layout_alignTop="@id/btn_notice"
android:background="@android:color/transparent"
android:layout="@layout/top_overlay_buttons"
android:visibility="gone"
tools:visibility="visible"
/>
</RelativeLayout>
</layout>

View File

@@ -33,7 +33,7 @@ public class ZhuangBanShangChengAdapter extends BaseQuickAdapter<ZhuangBanShangC
ThemeableDrawableUtils.setThemeableRoundedBackground( tv_integral, ColorManager.getInstance().getPrimaryColorInt(), corners);
tv_integral.setTextColor(ColorManager.getInstance().getButtonColorInt());
helper.setText(R.id.integral, item.getRemaining_day())
helper.setText(R.id.integral, item.getRemaining_day()+"")
.setText(R.id.tv_name_period, item.getTitle());
// .setText(R.id.tv_time, "(有效期${item.period}天)")
if (item.isIs_select()) {