2025-12-22 16:31:46 +08:00
|
|
|
|
package com.example.livestreaming;
|
|
|
|
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
|
|
|
|
|
|
|
import com.example.livestreaming.databinding.ActivityFindGameBinding;
|
|
|
|
|
|
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
|
|
|
|
|
|
2026-01-02 20:39:14 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 找人玩游戏 - 从后端API加载消息
|
|
|
|
|
|
*/
|
|
|
|
|
|
public class FindGameActivity extends BaseCategoryActivity {
|
2025-12-22 16:31:46 +08:00
|
|
|
|
|
2026-01-02 20:39:14 +08:00
|
|
|
|
private static final int CATEGORY_ID = -1; // 通过名称自动查找
|
|
|
|
|
|
private static final String CATEGORY_NAME = "找人玩游戏";
|
|
|
|
|
|
|
2025-12-22 16:31:46 +08:00
|
|
|
|
private ActivityFindGameBinding binding;
|
|
|
|
|
|
|
|
|
|
|
|
public static void start(Context context) {
|
2026-01-02 20:39:14 +08:00
|
|
|
|
context.startActivity(new Intent(context, FindGameActivity.class));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected int getCategoryId() {
|
|
|
|
|
|
return CATEGORY_ID;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected String getCategoryName() {
|
|
|
|
|
|
return CATEGORY_NAME;
|
2025-12-22 16:31:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
binding = ActivityFindGameBinding.inflate(getLayoutInflater());
|
|
|
|
|
|
setContentView(binding.getRoot());
|
|
|
|
|
|
|
|
|
|
|
|
setupUI();
|
2026-01-02 20:39:14 +08:00
|
|
|
|
// 初始化消息列表(从API加载)
|
|
|
|
|
|
initMessageList(binding.recyclerPosts, binding.emptyView, null, binding.fabPublish);
|
2025-12-22 16:31:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void setupUI() {
|
|
|
|
|
|
binding.backButton.setOnClickListener(v -> finish());
|
|
|
|
|
|
|
|
|
|
|
|
BottomNavigationView bottomNavigation = binding.bottomNavInclude.bottomNavigation;
|
|
|
|
|
|
bottomNavigation.setSelectedItemId(R.id.nav_friends);
|
2025-12-23 15:37:37 +08:00
|
|
|
|
UnreadMessageManager.updateBadge(bottomNavigation);
|
|
|
|
|
|
|
2025-12-22 16:31:46 +08:00
|
|
|
|
bottomNavigation.setOnItemSelectedListener(item -> {
|
|
|
|
|
|
int id = item.getItemId();
|
|
|
|
|
|
if (id == R.id.nav_home) {
|
|
|
|
|
|
startActivity(new Intent(this, MainActivity.class));
|
|
|
|
|
|
finish();
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (id == R.id.nav_wish_tree) {
|
2026-01-06 14:24:42 +08:00
|
|
|
|
WishTreeWebViewActivity.start(this);
|
2025-12-22 16:31:46 +08:00
|
|
|
|
finish();
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (id == R.id.nav_messages) {
|
|
|
|
|
|
MessagesActivity.start(this);
|
|
|
|
|
|
finish();
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (id == R.id.nav_profile) {
|
|
|
|
|
|
ProfileActivity.start(this);
|
|
|
|
|
|
finish();
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2025-12-23 15:37:37 +08:00
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void onResume() {
|
|
|
|
|
|
super.onResume();
|
|
|
|
|
|
if (binding != null) {
|
|
|
|
|
|
BottomNavigationView bottomNav = binding.bottomNavInclude.bottomNavigation;
|
|
|
|
|
|
bottomNav.setSelectedItemId(R.id.nav_friends);
|
|
|
|
|
|
UnreadMessageManager.updateBadge(bottomNav);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-12-22 16:31:46 +08:00
|
|
|
|
}
|