66 2
This commit is contained in:
@@ -147,6 +147,8 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
||||
|
||||
@Override
|
||||
public void setGiftList(List<RoonGiftModel> data, int type) {
|
||||
if (data == null)
|
||||
return;
|
||||
giftList = new ArrayList<>();
|
||||
giftList.addAll(data);
|
||||
pageCount = (int) Math.ceil(data.size() * 1.0 / pageSize);
|
||||
@@ -182,7 +184,7 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
||||
@Override
|
||||
public void giftPack(List<GiftPackBean> giftPackBean) {
|
||||
giftPackList = new ArrayList<>();
|
||||
if (getActivity()==null){
|
||||
if (getActivity() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -209,7 +211,6 @@ public class GiftTwoDetailsFragment extends BaseMvpFragment<RewardGiftPresenter,
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -81,6 +81,11 @@ import io.agora.rtc2.RtcEngineEx;
|
||||
import io.agora.rtc2.ScreenCaptureParameters;
|
||||
import io.agora.rtc2.video.VideoCanvas;
|
||||
import io.agora.rtc2.video.VideoEncoderConfiguration;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.ObservableSource;
|
||||
import io.reactivex.ObservableTransformer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class AgoraManager {
|
||||
|
||||
@@ -111,6 +116,9 @@ public class AgoraManager {
|
||||
private static ExecutorService executorService = Executors.newFixedThreadPool(3);
|
||||
|
||||
public int pkUserId;
|
||||
private Disposable disposableA;
|
||||
private Disposable disposableB;
|
||||
private Disposable disposableC;
|
||||
|
||||
public void setLastRoomId(String value) {
|
||||
lastRoomId = value;
|
||||
@@ -324,7 +332,15 @@ public class AgoraManager {
|
||||
}
|
||||
handlers.clear();
|
||||
}
|
||||
|
||||
if (disposableA != null && !disposableA.isDisposed()){
|
||||
disposableA.dispose();
|
||||
}
|
||||
if (disposableB != null && !disposableB.isDisposed()){
|
||||
disposableB.dispose();
|
||||
}
|
||||
if (disposableC != null && !disposableC.isDisposed()){
|
||||
disposableC.dispose();
|
||||
}
|
||||
// 关闭线程池
|
||||
if (executorService != null && !executorService.isShutdown()) {
|
||||
executorService.shutdown();
|
||||
@@ -998,6 +1014,7 @@ public class AgoraManager {
|
||||
* type:1:个人点击了点歌按钮
|
||||
* type:2:别人进入后
|
||||
*/
|
||||
@SuppressLint("CheckResult")
|
||||
public void isPreload(long songCode, int type) {
|
||||
mSongCode = songCode;
|
||||
LogUtils.e("AgoraManager", "isPreload: " + songCode);
|
||||
@@ -1047,18 +1064,8 @@ public class AgoraManager {
|
||||
if (type == 1) {
|
||||
if (code < 0) {
|
||||
String result = musicContentCenter.preload(mSongCode);
|
||||
// 使用后台线程池处理预加载检查,避免阻塞UI线程
|
||||
executeInBackground(() -> {
|
||||
try {
|
||||
Thread.sleep(3000); // 3秒延迟
|
||||
LogUtils.d("AgoraManager", "Preload result: " + result);
|
||||
// 切换回主线程执行后续操作
|
||||
createTrackedHandler(Looper.getMainLooper()).post(() -> {
|
||||
isPreload(mSongCode, type);
|
||||
});
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("AgoraManager", "Preload song failed: songCode=" + mSongCode, e);
|
||||
}
|
||||
disposableB = Observable.timer(3000, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe(aLong -> {
|
||||
isPreload(mSongCode, type);
|
||||
});
|
||||
} else {
|
||||
handleMusicPlayerState(songCode);
|
||||
@@ -1067,18 +1074,9 @@ public class AgoraManager {
|
||||
if (code < 0) {
|
||||
String result = musicContentCenter.preload(mSongCode);
|
||||
// 使用后台线程池处理预加载检查,避免阻塞UI线程
|
||||
executeInBackground(() -> {
|
||||
try {
|
||||
Thread.sleep(3000); // 3秒延迟
|
||||
LogUtils.d("AgoraManager", "Preload result: " + result);
|
||||
// 切换回主线程执行后续操作
|
||||
createTrackedHandler(Looper.getMainLooper()).post(() -> {
|
||||
disposableC = Observable.timer(3000, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe(aLong -> {
|
||||
isPreload(mSongCode, type);
|
||||
});
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("AgoraManager", "Preload song failed: songCode=" + mSongCode, e);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
try {
|
||||
musicPlayer.open(mSongCode, 0);
|
||||
@@ -1107,16 +1105,8 @@ public class AgoraManager {
|
||||
LogUtils.e("lxj", "空闲");
|
||||
musicPlayer.open(songCode, 0);
|
||||
// 使用后台线程处理延迟任务,避免阻塞UI线程
|
||||
executeInBackground(() -> {
|
||||
try {
|
||||
Thread.sleep(2000); // 2秒延迟
|
||||
// 切换回主线程执行后续操作
|
||||
createTrackedHandler(Looper.getMainLooper()).post(() -> {
|
||||
isPreload(songCode, 1);
|
||||
});
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("AgoraManager", "Error in idle state handling", e);
|
||||
}
|
||||
disposableA = Observable.timer(2000, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe(aLong -> {
|
||||
isPreload(mSongCode, 1);
|
||||
});
|
||||
break;
|
||||
case PLAYER_STATE_OPEN_COMPLETED:
|
||||
|
||||
Reference in New Issue
Block a user