安卓端的代码编写
This commit is contained in:
parent
86709109a5
commit
8f8a3ef03d
|
|
@ -183,41 +183,11 @@ public class CategoryFilterManager {
|
|||
String roomType = r.getType();
|
||||
if (c.equals(roomType)) {
|
||||
filtered.add(r);
|
||||
continue;
|
||||
}
|
||||
// 降级到演示数据分类算法
|
||||
String demoCategory = getDemoCategoryForRoom(r);
|
||||
if (c.equals(demoCategory)) {
|
||||
filtered.add(r);
|
||||
}
|
||||
}
|
||||
return filtered;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取房间的演示分类(用于降级处理)
|
||||
*/
|
||||
private String getDemoCategoryForRoom(Room room) {
|
||||
if (room == null) return "推荐";
|
||||
String title = room.getTitle() != null ? room.getTitle() : "";
|
||||
String streamer = room.getStreamerName() != null ? room.getStreamerName() : "";
|
||||
|
||||
// 简单的分类逻辑(可以根据实际需求调整)
|
||||
if (title.contains("游戏") || streamer.contains("游戏")) {
|
||||
return "游戏";
|
||||
}
|
||||
if (title.contains("音乐") || streamer.contains("音乐")) {
|
||||
return "音乐";
|
||||
}
|
||||
if (title.contains("聊天") || streamer.contains("聊天")) {
|
||||
return "聊天";
|
||||
}
|
||||
if (title.contains("才艺") || streamer.contains("才艺")) {
|
||||
return "才艺";
|
||||
}
|
||||
return "推荐";
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存最后选中的分类
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -51,11 +51,7 @@ public class LikesListActivity extends AppCompatActivity {
|
|||
|
||||
private List<ConversationItem> buildDemoLikes() {
|
||||
List<ConversationItem> list = new ArrayList<>();
|
||||
list.add(new ConversationItem("l1", "小雨", "赞了你的直播间", "09:12", 0, false));
|
||||
list.add(new ConversationItem("l2", "阿宁", "赞了你的作品", "昨天", 0, false));
|
||||
list.add(new ConversationItem("l3", "小星", "赞了你", "周二", 0, false));
|
||||
list.add(new ConversationItem("l4", "小林", "赞了你的直播回放", "上周", 0, false));
|
||||
list.add(new ConversationItem("l5", "阿杰", "赞了你的作品", "上周", 0, false));
|
||||
// 不再使用模拟数据,只从后端接口获取真实点赞数据
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,17 +96,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
|
||||
// 用户打开APP时不需要强制登录,可以直接使用APP
|
||||
// 只有在使用需要登录的功能时(如加好友、发送弹幕等),才检查登录状态
|
||||
// TODO: 接入后端接口 - 用户登录
|
||||
// 接口路径: POST /api/front/login(ApiService中已定义)
|
||||
// 请求参数: LoginRequest {account: string, password: string}
|
||||
// 返回数据格式: ApiResponse<LoginResponse>
|
||||
// LoginResponse对象应包含: token, userId, nickname, avatarUrl等字段
|
||||
// 登录成功后,保存token到AuthStore,并更新用户信息
|
||||
// TODO: 接入后端接口 - 用户注册
|
||||
// 接口路径: POST /api/front/register(ApiService中已定义)
|
||||
// 请求参数: RegisterRequest {phone: string, password: string, verificationCode: string, nickname: string}
|
||||
// 返回数据格式: ApiResponse<LoginResponse>
|
||||
// 注册成功后,自动登录并保存token
|
||||
// 登录和注册功能已在LoginActivity中实现
|
||||
binding = ActivityMainBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
|
|
@ -120,15 +110,10 @@ public class MainActivity extends AppCompatActivity {
|
|||
loadAvatarFromPrefs();
|
||||
setupSpeechRecognizer();
|
||||
|
||||
// TODO: 接入后端接口 - 获取未读消息总数
|
||||
// 接口路径: GET /api/messages/unread/count
|
||||
// 请求参数: 无(从token中获取userId)
|
||||
// 返回数据格式: ApiResponse<Integer> 或 ApiResponse<{unreadCount: number}>
|
||||
// 返回当前用户所有会话的未读消息总数
|
||||
// 初始化未读消息数量(演示数据)
|
||||
// 初始化未读消息数量
|
||||
if (UnreadMessageManager.getUnreadCount(this) == 0) {
|
||||
// 从消息列表计算总未读数量
|
||||
UnreadMessageManager.setUnreadCount(this, calculateTotalUnreadCount());
|
||||
// 从会话列表获取总未读数量
|
||||
fetchUnreadMessageCount();
|
||||
}
|
||||
|
||||
// 初始化顶部标签页数据
|
||||
|
|
@ -538,15 +523,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
// 如果文本为空,启动语音识别
|
||||
startVoiceRecognition();
|
||||
} else {
|
||||
// 如果文本不为空,执行搜索
|
||||
// TODO: 接入后端接口 - 搜索功能
|
||||
// 接口路径: GET /api/search
|
||||
// 请求参数:
|
||||
// - keyword: 搜索关键词
|
||||
// - type (可选): 搜索类型(room/user/all)
|
||||
// - page (可选): 页码
|
||||
// 返回数据格式: ApiResponse<{rooms: Room[], users: User[]}>
|
||||
// 跳转到搜索页面并传递搜索关键词
|
||||
// 如果文本不为空,跳转到搜索页面
|
||||
SearchActivity.start(MainActivity.this, searchText);
|
||||
}
|
||||
});
|
||||
|
|
@ -835,17 +812,41 @@ public class MainActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
/**
|
||||
* 计算总未读消息数量(从演示数据中计算)
|
||||
* 从后端获取未读消息总数
|
||||
*/
|
||||
private int calculateTotalUnreadCount() {
|
||||
// 模拟从消息列表计算总未读数量
|
||||
// 这里使用 MessagesActivity 中的演示数据
|
||||
int total = 0;
|
||||
total += 2; // 系统通知
|
||||
total += 5; // 附近的人
|
||||
total += 19; // 直播间群聊
|
||||
total += 1; // 客服
|
||||
return total;
|
||||
private void fetchUnreadMessageCount() {
|
||||
// 检查登录状态
|
||||
if (!AuthHelper.isLoggedIn(this)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 从会话列表接口获取未读消息总数
|
||||
ApiClient.getService(getApplicationContext()).getConversations()
|
||||
.enqueue(new Callback<ApiResponse<List<ConversationResponse>>>() {
|
||||
@Override
|
||||
public void onResponse(Call<ApiResponse<List<ConversationResponse>>> call,
|
||||
Response<ApiResponse<List<ConversationResponse>>> response) {
|
||||
ApiResponse<List<ConversationResponse>> body = response.body();
|
||||
if (response.isSuccessful() && body != null && body.isOk() && body.getData() != null) {
|
||||
int totalUnread = 0;
|
||||
for (ConversationResponse conv : body.getData()) {
|
||||
if (conv != null && conv.getUnreadCount() != null) {
|
||||
totalUnread += conv.getUnreadCount();
|
||||
}
|
||||
}
|
||||
UnreadMessageManager.setUnreadCount(MainActivity.this, totalUnread);
|
||||
// 更新底部导航栏徽章
|
||||
if (binding != null && binding.bottomNavInclude != null) {
|
||||
UnreadMessageManager.updateBadge(binding.bottomNavInclude.bottomNavigation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ApiResponse<List<ConversationResponse>>> call, Throwable t) {
|
||||
// 网络错误,忽略
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -961,14 +962,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
|
||||
|
||||
// TODO: 接入后端接口 - 创建直播间
|
||||
// 接口路径: POST /api/rooms
|
||||
// 请求参数: CreateRoomRequest
|
||||
// - title: 直播间标题
|
||||
// - streamerName: 主播名称
|
||||
// - type: 直播类型(如"live")
|
||||
// 返回数据格式: ApiResponse<Room>
|
||||
// Room对象应包含: id, title, streamerName, streamKey, streamUrls (包含rtmp, flv, hls地址)等字段
|
||||
// 调用后端接口创建直播间
|
||||
ApiClient.getService(getApplicationContext()).createRoom(new CreateRoomRequest(title, streamerName, "live"))
|
||||
.enqueue(new Callback<ApiResponse<Room>>() {
|
||||
@Override
|
||||
|
|
@ -1307,10 +1301,6 @@ public class MainActivity extends AppCompatActivity {
|
|||
String roomType = r.getType();
|
||||
if (c.equals(roomType)) {
|
||||
filtered.add(r);
|
||||
continue;
|
||||
}
|
||||
if (c.equals(getDemoCategoryForRoom(r))) {
|
||||
filtered.add(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1410,70 +1400,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
}
|
||||
}
|
||||
|
||||
private String getDemoCategoryForRoom(Room room) {
|
||||
String[] categories = new String[]{"游戏", "才艺", "户外", "音乐", "美食", "聊天"};
|
||||
try {
|
||||
String seed = room != null && room.getId() != null ? room.getId() : room != null ? room.getTitle() : "";
|
||||
int h = Math.abs(seed != null ? seed.hashCode() : 0);
|
||||
return categories[h % categories.length];
|
||||
} catch (Exception ignored) {
|
||||
return "游戏";
|
||||
}
|
||||
}
|
||||
|
||||
private List<Room> buildDemoRooms(int count) {
|
||||
List<Room> list = new ArrayList<>();
|
||||
|
||||
// 预定义的演示数据,包含不同类型的直播内容
|
||||
String[][] demoData = {
|
||||
{"王者荣耀排位赛", "小明选手", "游戏", "true"},
|
||||
{"吃鸡大逃杀", "游戏高手", "游戏", "true"},
|
||||
{"唱歌连麦", "音乐达人", "音乐", "true"},
|
||||
{"户外直播", "旅行者", "户外", "false"},
|
||||
{"美食制作", "厨神小李", "美食", "true"},
|
||||
{"才艺表演", "舞蹈小妹", "才艺", "true"},
|
||||
{"聊天交友", "暖心姐姐", "聊天", "false"},
|
||||
{"LOL竞技场", "电竞选手", "游戏", "true"},
|
||||
{"古风演奏", "琴师小王", "音乐", "true"},
|
||||
{"健身教学", "教练张", "户外", "false"},
|
||||
{"摄影分享", "摄影师", "户外", "true"},
|
||||
{"宠物秀", "萌宠主播", "才艺", "true"},
|
||||
{"编程教学", "码农老王", "聊天", "false"},
|
||||
{"读书分享", "书虫小妹", "聊天", "true"},
|
||||
{"手工制作", "手艺人", "才艺", "true"},
|
||||
{"英语口语", "外教老师", "聊天", "false"},
|
||||
{"魔术表演", "魔术师", "才艺", "true"},
|
||||
{"街头访谈", "记者小张", "户外", "true"},
|
||||
{"乐器教学", "音乐老师", "音乐", "false"},
|
||||
{"电影解说", "影评人", "聊天", "true"}
|
||||
};
|
||||
|
||||
for (int i = 0; i < count && i < demoData.length; i++) {
|
||||
String id = "demo-" + i;
|
||||
String title = demoData[i][0];
|
||||
String streamer = demoData[i][1];
|
||||
String type = demoData[i][2];
|
||||
boolean live = Boolean.parseBoolean(demoData[i][3]);
|
||||
Room room = new Room(id, title, streamer, live);
|
||||
room.setType(type);
|
||||
list.add(room);
|
||||
}
|
||||
|
||||
// 如果需要更多数据,继续生成
|
||||
String[] categories = new String[]{"游戏", "才艺", "户外", "音乐", "美食", "聊天"};
|
||||
for (int i = demoData.length; i < count; i++) {
|
||||
String id = "demo-" + i;
|
||||
String title = "直播房间" + (i + 1);
|
||||
String streamer = "主播" + (i + 1);
|
||||
String type = categories[i % categories.length];
|
||||
boolean live = i % 3 != 0;
|
||||
Room room = new Room(id, title, streamer, live);
|
||||
room.setType(type);
|
||||
list.add(room);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从后端加载分类数据
|
||||
|
|
@ -1596,24 +1523,17 @@ public class MainActivity extends AppCompatActivity {
|
|||
|
||||
/**
|
||||
* 初始化顶部标签页数据
|
||||
* TODO: 接入后端接口 - 获取顶部标签页配置(关注/发现/附近)
|
||||
* 接口路径: GET /api/home/tabs
|
||||
* 请求参数: 无(从token中获取userId,可选)
|
||||
* 返回数据格式: ApiResponse<List<TabConfig>>
|
||||
* TabConfig对象应包含: id, name, iconUrl, badgeCount(未读数等)等字段
|
||||
* 用于动态配置顶部标签页,支持个性化显示
|
||||
* 顶部标签页(关注/发现/附近)为固定配置,不需要从后端动态获取
|
||||
*/
|
||||
private void initializeTopTabData() {
|
||||
// 初始化关注页面数据(已关注主播的直播)- 使用演示数据
|
||||
// 初始化关注页面数据
|
||||
followRooms.clear();
|
||||
followRooms.addAll(buildFollowRooms());
|
||||
|
||||
// 初始化发现页面数据 - 从后端获取真实直播间
|
||||
fetchDiscoverRooms();
|
||||
|
||||
// 初始化附近页面数据(模拟位置数据)
|
||||
// 初始化附近页面数据
|
||||
nearbyUsers.clear();
|
||||
nearbyUsers.addAll(buildNearbyUsers());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1834,46 +1754,66 @@ public class MainActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
/**
|
||||
* 构建关注页面的房间列表(已关注主播的直播)
|
||||
* 显示关注页面时从后端获取关注主播的直播间列表
|
||||
* 注意:关注功能需要用户登录,在showFollowTab()中会检查登录状态
|
||||
*/
|
||||
private List<Room> buildFollowRooms() {
|
||||
// TODO: 接入后端接口 - 获取关注主播的直播间列表
|
||||
// 接口路径: GET /api/following/rooms 或 GET /api/rooms?type=following
|
||||
// 请求参数:
|
||||
// - userId: 当前用户ID(从token中获取)
|
||||
// - page (可选): 页码
|
||||
// - pageSize (可选): 每页数量
|
||||
// 返回数据格式: ApiResponse<List<Room>>
|
||||
// Room对象应包含: id, title, streamerName, streamerId, type, isLive, coverUrl, viewerCount等字段
|
||||
// 只返回当前用户已关注的主播正在直播的房间
|
||||
List<Room> list = new ArrayList<>();
|
||||
|
||||
// 从FollowingListActivity获取已关注的主播列表
|
||||
// 这里使用模拟数据,实际应该从数据库或API获取
|
||||
String[][] followData = {
|
||||
{"王者荣耀排位赛", "王者荣耀陪练", "游戏", "true"},
|
||||
{"音乐电台", "音乐电台", "音乐", "false"},
|
||||
{"户外直播", "户外阿杰", "户外", "true"},
|
||||
{"美食探店", "美食探店", "美食", "false"},
|
||||
{"聊天连麦", "聊天小七", "聊天", "true"},
|
||||
{"才艺表演", "才艺小妹", "才艺", "true"},
|
||||
{"游戏竞技", "游戏高手", "游戏", "true"},
|
||||
{"音乐演奏", "音乐达人", "音乐", "false"}
|
||||
};
|
||||
|
||||
for (int i = 0; i < followData.length; i++) {
|
||||
String id = "follow-" + i;
|
||||
String title = followData[i][0];
|
||||
String streamer = followData[i][1];
|
||||
String type = followData[i][2];
|
||||
boolean live = Boolean.parseBoolean(followData[i][3]);
|
||||
Room room = new Room(id, title, streamer, live);
|
||||
room.setType(type);
|
||||
list.add(room);
|
||||
private void fetchFollowRooms() {
|
||||
// 检查登录状态
|
||||
if (!AuthHelper.isLoggedIn(this)) {
|
||||
followRooms.clear();
|
||||
if (adapter != null) {
|
||||
adapter.submitList(new ArrayList<>());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
return list;
|
||||
// 显示加载状态
|
||||
if (binding.loading != null) {
|
||||
binding.loading.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
// 从关注列表获取关注的用户ID,然后筛选出正在直播的房间
|
||||
ApiClient.getService(getApplicationContext()).getFollowingList(1, 100)
|
||||
.enqueue(new Callback<ApiResponse<PageResponse<Map<String, Object>>>>() {
|
||||
@Override
|
||||
public void onResponse(Call<ApiResponse<PageResponse<Map<String, Object>>>> call,
|
||||
Response<ApiResponse<PageResponse<Map<String, Object>>>> response) {
|
||||
if (binding.loading != null) {
|
||||
binding.loading.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
ApiResponse<PageResponse<Map<String, Object>>> body = response.body();
|
||||
if (response.isSuccessful() && body != null && body.isOk() && body.getData() != null) {
|
||||
List<Map<String, Object>> followingList = body.getData().getList();
|
||||
if (followingList != null && !followingList.isEmpty()) {
|
||||
// 获取所有直播间,然后筛选出关注用户的直播间
|
||||
fetchAndFilterFollowRooms(followingList);
|
||||
} else {
|
||||
followRooms.clear();
|
||||
if ("关注".equals(currentTopTab) && adapter != null) {
|
||||
adapter.submitList(new ArrayList<>());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ApiResponse<PageResponse<Map<String, Object>>>> call, Throwable t) {
|
||||
if (binding.loading != null) {
|
||||
binding.loading.setVisibility(View.GONE);
|
||||
}
|
||||
followRooms.clear();
|
||||
if ("关注".equals(currentTopTab) && adapter != null) {
|
||||
adapter.submitList(new ArrayList<>());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有直播间并筛选出关注用户的直播间
|
||||
*/
|
||||
private void fetchAndFilterFollowRooms(List<Map<String, Object>>
|
||||
|
||||
/**
|
||||
* 构建发现页面的房间列表(推荐算法前端实现)
|
||||
|
|
@ -1890,62 +1830,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
// 后端应根据用户观看历史、点赞记录、关注关系等进行个性化推荐
|
||||
List<Room> list = new ArrayList<>();
|
||||
|
||||
// 推荐算法:基于观看历史、点赞等模拟数据
|
||||
// 这里实现一个简单的推荐算法:
|
||||
// 1. 优先推荐正在直播的房间
|
||||
// 2. 优先推荐热门类型(游戏、才艺、音乐)
|
||||
// 3. 添加一些随机性
|
||||
|
||||
String[][] discoverData = {
|
||||
{"王者荣耀排位赛", "小明选手", "游戏", "true"},
|
||||
{"吃鸡大逃杀", "游戏高手", "游戏", "true"},
|
||||
{"唱歌连麦", "音乐达人", "音乐", "true"},
|
||||
{"户外直播", "旅行者", "户外", "false"},
|
||||
{"美食制作", "厨神小李", "美食", "true"},
|
||||
{"才艺表演", "舞蹈小妹", "才艺", "true"},
|
||||
{"聊天交友", "暖心姐姐", "聊天", "false"},
|
||||
{"LOL竞技场", "电竞选手", "游戏", "true"},
|
||||
{"古风演奏", "琴师小王", "音乐", "true"},
|
||||
{"健身教学", "教练张", "户外", "false"},
|
||||
{"摄影分享", "摄影师", "户外", "true"},
|
||||
{"宠物秀", "萌宠主播", "才艺", "true"},
|
||||
{"编程教学", "码农老王", "聊天", "false"},
|
||||
{"读书分享", "书虫小妹", "聊天", "true"},
|
||||
{"手工制作", "手艺人", "才艺", "true"},
|
||||
{"英语口语", "外教老师", "聊天", "false"},
|
||||
{"魔术表演", "魔术师", "才艺", "true"},
|
||||
{"街头访谈", "记者小张", "户外", "true"},
|
||||
{"乐器教学", "音乐老师", "音乐", "false"},
|
||||
{"电影解说", "影评人", "聊天", "true"},
|
||||
{"游戏攻略", "游戏解说", "游戏", "true"},
|
||||
{"K歌大赛", "K歌达人", "音乐", "true"},
|
||||
{"美食探店", "美食博主", "美食", "true"},
|
||||
{"舞蹈教学", "舞蹈老师", "才艺", "true"}
|
||||
};
|
||||
|
||||
// 推荐算法:优先显示正在直播的,然后按类型排序
|
||||
List<Room> liveRooms = new ArrayList<>();
|
||||
List<Room> offlineRooms = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < discoverData.length; i++) {
|
||||
String id = "discover-" + i;
|
||||
String title = discoverData[i][0];
|
||||
String streamer = discoverData[i][1];
|
||||
String type = discoverData[i][2];
|
||||
boolean live = Boolean.parseBoolean(discoverData[i][3]);
|
||||
Room room = new Room(id, title, streamer, live);
|
||||
room.setType(type);
|
||||
|
||||
if (live) {
|
||||
liveRooms.add(room);
|
||||
} else {
|
||||
offlineRooms.add(room);
|
||||
}
|
||||
}
|
||||
|
||||
// 先添加正在直播的,再添加未直播的
|
||||
list.addAll(liveRooms);
|
||||
list.addAll(offlineRooms);
|
||||
// 不再使用模拟数据,只从后端接口获取真实推荐直播间数据
|
||||
|
||||
return list;
|
||||
}
|
||||
|
|
@ -1967,28 +1852,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
// 需要先获取用户位置权限,然后调用此接口
|
||||
List<NearbyUser> list = new ArrayList<>();
|
||||
|
||||
// 模拟位置数据:生成不同距离的用户
|
||||
String[] names = {"小王", "小李", "安安", "小陈", "小美", "老张", "小七", "阿杰",
|
||||
"小雨", "阿宁", "小星", "小林", "小杨", "小刘", "小赵", "小孙", "小周", "小吴"};
|
||||
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
String id = "nearby-user-" + i;
|
||||
String name = names[i];
|
||||
boolean live = i % 3 == 0; // 每3个用户中有一个在直播
|
||||
|
||||
String distanceText;
|
||||
if (i < 3) {
|
||||
distanceText = (300 + i * 120) + "m";
|
||||
} else if (i < 10) {
|
||||
float km = 0.8f + (i - 3) * 0.35f;
|
||||
distanceText = String.format("%.1fkm", km);
|
||||
} else {
|
||||
float km = 3.5f + (i - 10) * 0.5f;
|
||||
distanceText = String.format("%.1fkm", km);
|
||||
}
|
||||
|
||||
list.add(new NearbyUser(id, name, distanceText, live));
|
||||
}
|
||||
// 不再使用模拟数据,只从后端接口获取真实附近用户数据
|
||||
|
||||
return list;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,9 +75,8 @@ public class MessageSendHelper {
|
|||
// 3. 调用接口
|
||||
// 4. 处理响应
|
||||
|
||||
// 临时模拟成功
|
||||
if (callback != null) {
|
||||
callback.onSuccess("temp_message_id_" + System.currentTimeMillis());
|
||||
callback.onError("消息发送功能待接入后端接口");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -150,9 +149,8 @@ public class MessageSendHelper {
|
|||
// 5. 上传图片
|
||||
// 6. 处理响应
|
||||
|
||||
// 临时模拟成功
|
||||
if (callback != null) {
|
||||
callback.onSuccess("temp_image_message_id_" + System.currentTimeMillis());
|
||||
callback.onError("图片消息发送功能待接入后端接口");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -224,9 +222,8 @@ public class MessageSendHelper {
|
|||
// 4. 上传语音
|
||||
// 5. 处理响应
|
||||
|
||||
// 临时模拟成功
|
||||
if (callback != null) {
|
||||
callback.onSuccess("temp_voice_message_id_" + System.currentTimeMillis());
|
||||
callback.onError("语音消息发送功能待接入后端接口");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -704,13 +704,7 @@ public class MessagesActivity extends AppCompatActivity {
|
|||
|
||||
private List<ConversationItem> buildDemoConversations() {
|
||||
List<ConversationItem> list = new ArrayList<>();
|
||||
list.add(new ConversationItem("sys", "系统通知", "欢迎来到直播间~新手指南已送达", "09:12", 2, false));
|
||||
list.add(new ConversationItem("a", "小王(主播)", "今晚8点开播,记得来捧场!", "昨天", 0, false));
|
||||
list.add(new ConversationItem("b", "附近的人", "嗨~一起连麦吗?", "昨天", 5, false));
|
||||
list.add(new ConversationItem("c", "运营小助手", "活动报名已通过,点击查看详情", "周二", 0, true));
|
||||
list.add(new ConversationItem("d", "直播间群聊", "[图片]", "周一", 19, false));
|
||||
list.add(new ConversationItem("e", "小李", "收到啦", "周一", 0, false));
|
||||
list.add(new ConversationItem("f", "客服", "您好,请描述一下遇到的问题", "上周", 1, false));
|
||||
// 不再使用模拟数据,只从后端接口获取真实会话数据
|
||||
return list;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1231,14 +1231,7 @@ public class RoomDetailActivity extends AppCompatActivity {
|
|||
*/
|
||||
private void setDefaultGifts() {
|
||||
availableGifts = new ArrayList<>();
|
||||
availableGifts.add(new Gift("1", "玫瑰", 10, R.drawable.ic_gift_rose, 1));
|
||||
availableGifts.add(new Gift("2", "爱心", 20, R.drawable.ic_gift_heart, 1));
|
||||
availableGifts.add(new Gift("3", "蛋糕", 50, R.drawable.ic_gift_cake, 2));
|
||||
availableGifts.add(new Gift("4", "星星", 100, R.drawable.ic_gift_star, 2));
|
||||
availableGifts.add(new Gift("5", "钻石", 200, R.drawable.ic_gift_diamond, 3));
|
||||
availableGifts.add(new Gift("6", "皇冠", 500, R.drawable.ic_gift_crown, 4));
|
||||
availableGifts.add(new Gift("7", "跑车", 1000, R.drawable.ic_gift_car, 5));
|
||||
availableGifts.add(new Gift("8", "火箭", 2000, R.drawable.ic_gift_rocket, 5));
|
||||
// 不再使用模拟数据,只从后端接口获取真实礼物数据
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1505,7 +1498,7 @@ public class RoomDetailActivity extends AppCompatActivity {
|
|||
*/
|
||||
private void showPaymentMethodDialog(String orderId, RechargeOption selectedOption,
|
||||
androidx.appcompat.app.AlertDialog rechargeDialog) {
|
||||
String[] paymentMethods = {"支付宝支付", "微信支付", "余额支付(模拟)"};
|
||||
String[] paymentMethods = {"支付宝支付", "微信支付"};
|
||||
|
||||
new MaterialAlertDialogBuilder(this)
|
||||
.setTitle("选择支付方式")
|
||||
|
|
@ -1522,10 +1515,6 @@ public class RoomDetailActivity extends AppCompatActivity {
|
|||
payType = "weixin";
|
||||
payChannel = "weixinAppAndroid";
|
||||
break;
|
||||
case 2: // 余额支付(模拟)
|
||||
// 模拟充值成功
|
||||
simulateRechargeSuccess(selectedOption, rechargeDialog);
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
|
@ -1567,8 +1556,9 @@ public class RoomDetailActivity extends AppCompatActivity {
|
|||
"\n请集成支付SDK完成实际支付",
|
||||
Toast.LENGTH_LONG).show();
|
||||
|
||||
// 暂时模拟支付成功
|
||||
simulateRechargeSuccess(selectedOption, rechargeDialog);
|
||||
// TODO: 集成支付SDK后,在支付成功回调中更新余额
|
||||
// 支付成功后应该调用后端接口查询订单状态并更新余额
|
||||
rechargeDialog.dismiss();
|
||||
} else {
|
||||
Toast.makeText(RoomDetailActivity.this,
|
||||
"支付失败: " + apiResponse.getMessage(),
|
||||
|
|
@ -1590,28 +1580,6 @@ public class RoomDetailActivity extends AppCompatActivity {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 模拟充值成功
|
||||
*/
|
||||
private void simulateRechargeSuccess(RechargeOption selectedOption,
|
||||
androidx.appcompat.app.AlertDialog rechargeDialog) {
|
||||
userCoinBalance += selectedOption.getCoinAmount();
|
||||
|
||||
// 更新礼物弹窗中的余额显示
|
||||
if (giftDialog != null && giftDialog.isShowing()) {
|
||||
View giftView = giftDialog.findViewById(R.id.coinBalance);
|
||||
if (giftView instanceof android.widget.TextView) {
|
||||
((android.widget.TextView) giftView).setText(String.valueOf(userCoinBalance));
|
||||
}
|
||||
}
|
||||
|
||||
Toast.makeText(this,
|
||||
String.format("充值成功!获得 %d 金币", selectedOption.getCoinAmount()),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
|
||||
rechargeDialog.dismiss();
|
||||
}
|
||||
|
||||
/**
|
||||
* 从后端加载用户金币余额
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -367,47 +367,18 @@ public class TabPlaceholderActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
private List<Room> buildFollowDemoRooms(int count) {
|
||||
List<Room> list = new ArrayList<>();
|
||||
for (int i = 0; i < count; i++) {
|
||||
String id = "follow-" + i;
|
||||
String title = "关注主播直播间 " + (i + 1);
|
||||
String streamer = "已关注主播" + (i + 1);
|
||||
boolean live = i % 4 != 0;
|
||||
list.add(new Room(id, title, streamer, live));
|
||||
}
|
||||
return list;
|
||||
// 不再使用模拟数据,只从后端接口获取真实关注主播的直播间数据
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
private List<NearbyUser> buildNearbyDemoUsers(int count) {
|
||||
List<NearbyUser> list = new ArrayList<>();
|
||||
String[] names = {"小王", "小李", "安安", "小陈", "小美", "老张", "小七", "阿杰",
|
||||
"小雨", "阿宁", "小星", "小林", "小杨", "小刘", "小赵", "小孙", "小周", "小吴"};
|
||||
for (int i = 0; i < count; i++) {
|
||||
String id = "user-" + i;
|
||||
String name = i < names.length ? names[i] : "用户" + (i + 1);
|
||||
boolean live = false; // 不再显示直播状态
|
||||
String distanceText;
|
||||
if (i < 3) {
|
||||
distanceText = (300 + i * 120) + "m";
|
||||
} else {
|
||||
float km = 0.8f + (i - 3) * 0.35f;
|
||||
distanceText = String.format("%.1fkm", km);
|
||||
}
|
||||
list.add(new NearbyUser(id, name, distanceText, live));
|
||||
}
|
||||
return list;
|
||||
// 不再使用模拟数据,只从后端接口获取真实附近用户数据
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
private List<Room> buildDiscoverDemoRooms(int count) {
|
||||
List<Room> list = new ArrayList<>();
|
||||
for (int i = 0; i < count; i++) {
|
||||
String id = "discover-" + i;
|
||||
String title = "推荐直播间 " + (i + 1);
|
||||
String streamer = "推荐主播" + (i + 1);
|
||||
boolean live = i % 4 != 0;
|
||||
list.add(new Room(id, title, streamer, live));
|
||||
}
|
||||
return list;
|
||||
// 不再使用模拟数据,只从后端接口获取真实推荐直播间数据
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
private void showParkBadges() {
|
||||
|
|
@ -453,17 +424,8 @@ public class TabPlaceholderActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
private List<BadgeItem> buildDemoBadges() {
|
||||
List<BadgeItem> list = new ArrayList<>();
|
||||
list.add(new BadgeItem("b-1", "新人报道", "首次完善个人资料", R.drawable.ic_person_24, true, false));
|
||||
list.add(new BadgeItem("b-2", "热度新星", "累计获得100次点赞", R.drawable.ic_heart_24, false, false));
|
||||
list.add(new BadgeItem("b-3", "连续签到", "连续签到7天", R.drawable.ic_grid_24, false, true));
|
||||
list.add(new BadgeItem("b-4", "分享达人", "分享主页3次", R.drawable.ic_copy_24, false, false));
|
||||
list.add(new BadgeItem("b-5", "探索者", "进入发现页10次", R.drawable.ic_globe_24, true, false));
|
||||
list.add(new BadgeItem("b-6", "公园守护", "完成公园任务5次", R.drawable.ic_tree_24, false, true));
|
||||
list.add(new BadgeItem("b-7", "话题参与", "发布话题内容1次", R.drawable.ic_palette_24, false, false));
|
||||
list.add(new BadgeItem("b-8", "社交达人", "添加好友5人", R.drawable.ic_people_24, false, true));
|
||||
list.add(new BadgeItem("b-9", "开播尝鲜", "创建直播间1次", R.drawable.ic_mic_24, false, false));
|
||||
return list;
|
||||
// 不再使用模拟数据,只从后端接口获取真实勋章数据
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
private void showMore() {
|
||||
|
|
|
|||
|
|
@ -55,14 +55,7 @@ public class WatchHistoryActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
private List<Room> buildDemoHistory(int count) {
|
||||
List<Room> list = new ArrayList<>();
|
||||
for (int i = 0; i < count; i++) {
|
||||
String id = "history-" + i;
|
||||
String title = "看过的直播间 " + (i + 1);
|
||||
String streamer = "主播" + (i + 1);
|
||||
boolean live = i % 5 != 0;
|
||||
list.add(new Room(id, title, streamer, live));
|
||||
}
|
||||
return list;
|
||||
// 不再使用模拟数据,只从后端接口获取真实观看历史数据
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user