zhibo/android-app/app/src/main/java/com/example/livestreaming/FindGameActivity.java

88 lines
2.7 KiB
Java
Raw Normal View History

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;
/**
* 找人玩游戏 - 从后端API加载消息
*/
public class FindGameActivity extends BaseCategoryActivity {
private static final int CATEGORY_ID = -1; // 通过名称自动查找
private static final String CATEGORY_NAME = "找人玩游戏";
private ActivityFindGameBinding binding;
public static void start(Context context) {
context.startActivity(new Intent(context, FindGameActivity.class));
}
@Override
protected int getCategoryId() {
return CATEGORY_ID;
}
@Override
protected String getCategoryName() {
return CATEGORY_NAME;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityFindGameBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
setupUI();
// 初始化消息列表从API加载
initMessageList(binding.recyclerPosts, binding.emptyView, null, binding.fabPublish);
}
private void setupUI() {
binding.backButton.setOnClickListener(v -> finish());
BottomNavigationView bottomNavigation = binding.bottomNavInclude.bottomNavigation;
bottomNavigation.setSelectedItemId(R.id.nav_friends);
UnreadMessageManager.updateBadge(bottomNavigation);
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);
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;
});
}
@Override
protected void onResume() {
super.onResume();
if (binding != null) {
BottomNavigationView bottomNav = binding.bottomNavInclude.bottomNavigation;
bottomNav.setSelectedItemId(R.id.nav_friends);
UnreadMessageManager.updateBadge(bottomNav);
}
}
}