优化细节

This commit is contained in:
xuhuixiang
2026-02-07 10:14:35 +08:00
parent c128312387
commit 50f7f161ff
4 changed files with 35 additions and 7 deletions

View File

@@ -47,6 +47,7 @@ import retrofit2.http.Query;
public interface ApiService {
String URL = "https://www.bab3live.com";
// String URL="https://babelive.my";
String LivePLayerStartUrl = "https://play.bab3live.com/live/";

View File

@@ -103,7 +103,12 @@ public class TodayMatchesBean implements Serializable {
if(TextUtils.isEmpty(callbackData)){
return 0;
}
return getCallbackDataWH(true);
if(callbackData.contains("{")&&callbackData.contains("}")) {
return getCallbackDataWH(true);
}else{
return 0;
}
}
private Integer getCallbackDataWH(boolean isWidth) {
@@ -131,7 +136,11 @@ public class TodayMatchesBean implements Serializable {
if(TextUtils.isEmpty(callbackData)){
return 0;
}
return getCallbackDataWH(false);
if(callbackData.contains("{")&&callbackData.contains("}")) {
return getCallbackDataWH(false);
}else{
return 0;
}
}
public void setHeight(Integer height) {

View File

@@ -210,6 +210,8 @@ public class GameAliPortraitActivity extends BaseActivity<MainViewModel, Activit
dataBinding.messageEt.setText("");
isInit = true;
String address = ApiService.URL + "/ws/stomp/endpoint/websocket?token=" + InitApp.getAccessTokenBase();
// address = "http://192.168.0.165:8080/stomp/endpoint/websocket?token=" + InitApp.getAccessTokenBase();
mStompClient = Stomp.over(Stomp.ConnectionProvider.OKHTTP, address);
mStompClient.connect();
lifecycle(mStompClient);
@@ -574,17 +576,20 @@ public class GameAliPortraitActivity extends BaseActivity<MainViewModel, Activit
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("type", "TEXT");
jsonObject.put("roomId", "leagues_" + todayMatchesBean.getId());
jsonObject.put("messageId", UUID.randomUUID().toString());
jsonObject.put("timestamp", System.currentTimeMillis());
jsonObject.put("senderId", userBean.getUserId());
jsonObject.put("senderId", userBean.getUserId()+"");
jsonObject.put("senderName", userBean.getNickName());
jsonObject.put("avatar", userBean.getAvatar());
jsonObject.put("content", dataBinding.messageEt.getText().toString().trim());
String rooms = "/topic/rooms/leagues_" + todayMatchesBean.getId();
jsonObject.put("roomId","leagues_" + todayMatchesBean.getId());
if (!TextUtils.isEmpty(todayMatchesBean.getChannelName())) {
rooms = "/topic/rooms/" + todayMatchesBean.getChannelName();
jsonObject.put("roomId",todayMatchesBean.getChannelName());
}
mStompClient.send(rooms, jsonObject.toString()).subscribe();

View File

@@ -50,6 +50,7 @@ import java.util.UUID;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;
import io.reactivex.exceptions.OnErrorNotImplementedException;
import io.reactivex.schedulers.Schedulers;
import ua.naiksoftware.stomp.Stomp;
import ua.naiksoftware.stomp.StompClient;
@@ -193,6 +194,8 @@ public class ChatFragment extends BaseLazyFragment<MainViewModel, FragmentChatBi
dataBinding.messageEt.setText("");
isInit = true;
String address = ApiService.URL + "/ws/stomp/endpoint/websocket?token=" + InitApp.getAccessTokenBase();
// address = "http://192.168.0.165:8080/stomp/endpoint/websocket?token=" + InitApp.getAccessTokenBase();
LogUtils.i("SOCKET地址"+address);
mStompClient = Stomp.over(Stomp.ConnectionProvider.OKHTTP, address);
mStompClient.connect();
lifecycle(mStompClient);
@@ -223,19 +226,24 @@ public class ChatFragment extends BaseLazyFragment<MainViewModel, FragmentChatBi
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("type", "TEXT");
jsonObject.put("roomId", "leagues_" + todayMatchesBean.getId());
jsonObject.put("messageId", UUID.randomUUID().toString());
jsonObject.put("timestamp", System.currentTimeMillis());
jsonObject.put("senderId", userBean.getUserId());
jsonObject.put("senderId", userBean.getUserId()+"");
jsonObject.put("senderName", userBean.getNickName());
jsonObject.put("avatar", userBean.getAvatar());
jsonObject.put("content", dataBinding.messageEt.getText().toString().trim());
String rooms = "/topic/rooms/leagues_" + todayMatchesBean.getId();
jsonObject.put("roomId","leagues_" + todayMatchesBean.getId());
if (!TextUtils.isEmpty(todayMatchesBean.getChannelName())) {
rooms = "/topic/rooms/" + todayMatchesBean.getChannelName();
jsonObject.put("roomId",todayMatchesBean.getChannelName());
}
// LogUtils.i("房间号:"+rooms);
// LogUtils.i("房间号1"+jsonObject.toString());
mStompClient.send(rooms, jsonObject.toString()).subscribe();
dataBinding.messageEt.setText("");
} else {
@@ -420,7 +428,12 @@ public class ChatFragment extends BaseLazyFragment<MainViewModel, FragmentChatBi
@Override
public void onDestroyView() {
if(mStompClient!=null) {
mStompClient.disconnect();
try {
mStompClient.disconnect();
}catch (OnErrorNotImplementedException e){
}
}
if (compositeDisposable != null) compositeDisposable.dispose();