修改名称。
This commit is contained in:
@@ -0,0 +1,176 @@
|
||||
package com.xscm.modulemain.activity.room.activity;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.activity.room.contacts.VoiceCategoryContacts;
|
||||
import com.xscm.modulemain.activity.room.presenter.VoiceCategoryPresenter;
|
||||
import com.xscm.modulemain.adapter.PopularRoomAdapter;
|
||||
import com.xscm.modulemain.databinding.ActivityPopularRoomBinding;
|
||||
import com.xscm.modulemain.BaseMvpActivity;
|
||||
import com.xscm.modulemain.manager.RoomManager;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.bean.BannerModel;
|
||||
import com.xscm.moduleutil.bean.RoomTypeModel;
|
||||
import com.xscm.moduleutil.bean.TopRoom;
|
||||
import com.xscm.moduleutil.listener.MessageListenerSingleton;
|
||||
import com.xscm.moduleutil.utils.ClickUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
|
||||
/**
|
||||
* @Description: 热门房间
|
||||
* @Author: Xue
|
||||
* @CreateDate: 2021/4/7 11:05
|
||||
*/
|
||||
public class PopularRoomActivity extends BaseMvpActivity<VoiceCategoryPresenter, ActivityPopularRoomBinding> implements VoiceCategoryContacts.View {
|
||||
|
||||
PopularRoomAdapter mAdapter;
|
||||
private int page = 1;
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
super.initView();
|
||||
mBinding.topBar.setColor(getResources().getColor(R.color.white));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
mAdapter = new PopularRoomAdapter();
|
||||
mBinding.rvPopularRoom.setAdapter(mAdapter);
|
||||
GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 2);
|
||||
gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
|
||||
@Override
|
||||
public int getSpanSize(int position) {
|
||||
switch (position) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
return 1;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
});
|
||||
mBinding.rvPopularRoom.setLayoutManager(gridLayoutManager);
|
||||
mBinding.smartRefreshLayout.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
|
||||
@Override
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
page++;
|
||||
MvpPre.getCarousels(1, page, "20", "2", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
page = 1;
|
||||
mAdapter.setNewData(new ArrayList<>());
|
||||
MvpPre.getCarousels(1, page, "20", "2", "");
|
||||
}
|
||||
});
|
||||
|
||||
mAdapter.setOnRoomClickListener((room, position) -> {
|
||||
if ( ClickUtils.isFastDoubleClick()){
|
||||
return;
|
||||
}
|
||||
|
||||
// 添加索引有效性检查
|
||||
if (position < 0 || position >= mAdapter.getData().size()) {
|
||||
return;
|
||||
}
|
||||
TopRoom item = mAdapter.getItem(position);
|
||||
if (item != null ) {
|
||||
mBinding.coolWaitView.setVisibility(View.VISIBLE);
|
||||
MessageListenerSingleton.getInstance().joinGroup(item.getRoom_id());
|
||||
RoomManager.getInstance().fetchRoomDataAndEnter(getApplicationContext(), item.getRoom_id(), "",null);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
Observable.timer(5, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe(aLong -> {
|
||||
mBinding.coolWaitView.setVisibility(View.GONE);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
page=1;
|
||||
MvpPre.getCarousels(1, page, "10", "2", "");//顶部推荐
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_popular_room;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected VoiceCategoryPresenter bindPresenter() {
|
||||
return new VoiceCategoryPresenter(this, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishRefreshLoadMore() {
|
||||
mBinding.smartRefreshLayout.finishRefresh();
|
||||
mBinding.smartRefreshLayout.finishLoadMore();
|
||||
CommonAppContext.getInstance().isRoomJoininj=false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCategories(List<RoomTypeModel> list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBanners(List<BannerModel> bannerModels) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRoomId(String roomId) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTopRoom(List<TopRoom> topRooms, int type) {
|
||||
if (topRooms != null && topRooms.size() > 0) {
|
||||
if (page == 1) {
|
||||
mAdapter.setNewData(topRooms); // 刷新时替换数据
|
||||
} else {
|
||||
// 检查是否有重复数据
|
||||
boolean hasDuplicate = false;
|
||||
List<TopRoom> currentData = mAdapter.getData();
|
||||
if (!currentData.isEmpty() && topRooms.size() > 0) {
|
||||
// 检查第一条数据是否已经存在
|
||||
TopRoom firstNewData = topRooms.get(0);
|
||||
for (TopRoom item : currentData) {
|
||||
if (item.getRoom_id().equals(firstNewData.getRoom_id())) {
|
||||
hasDuplicate = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasDuplicate) {
|
||||
mAdapter.addData(topRooms); // 加载更多时添加数据
|
||||
}
|
||||
}
|
||||
} else if (page == 1) {
|
||||
// 如果是刷新且没有数据,清空列表
|
||||
mAdapter.setNewData(new ArrayList<>());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.xscm.modulemain.activity.room.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.Color;
|
||||
import android.text.TextUtils;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import com.xscm.modulemain.BaseMvpActivity;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.adapter.SectionsPagerAdapter;
|
||||
import com.xscm.modulemain.databinding.ActivityRankingListBinding;
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
|
||||
/**
|
||||
*@author lxj
|
||||
*@data 2025/5/15
|
||||
*@description: 排行榜
|
||||
*/
|
||||
public class RankingListActivity extends BaseMvpActivity<IPresenter,ActivityRankingListBinding> implements IView<Activity> {
|
||||
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IPresenter bindPresenter() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
mBinding.topBar.setTitle("排行榜");
|
||||
mBinding.topBar.setColor(getResources().getColor(R.color.white));
|
||||
SectionsPagerAdapter sectionsPagerAdapter = new SectionsPagerAdapter(this, getSupportFragmentManager());
|
||||
mBinding.viewPager.setAdapter(sectionsPagerAdapter);
|
||||
mBinding.tabs.setupWithViewPager( mBinding.viewPager);
|
||||
setupCustomTabs();
|
||||
}
|
||||
private void setupCustomTabs() {
|
||||
TabLayout tabs = findViewById(R.id.tabs);
|
||||
|
||||
// 为每个tab创建自定义视图
|
||||
for (int i = 0; i < tabs.getTabCount(); i++) {
|
||||
TabLayout.Tab tab = tabs.getTabAt(i);
|
||||
if (tab != null) {
|
||||
TextView customView = new TextView(this);
|
||||
customView.setText(tab.getText());
|
||||
customView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12); // 未选中时的字体大小
|
||||
customView.setTextColor(Color.parseColor("#ffffff")); // 未选中时的灰色
|
||||
customView.setGravity(Gravity.CENTER);
|
||||
customView.setSingleLine(true); // 确保不换行显示
|
||||
customView.setEllipsize(TextUtils.TruncateAt.END); // 超出部分显示省略号
|
||||
|
||||
tab.setCustomView(customView);
|
||||
}
|
||||
}
|
||||
|
||||
// 设置选中监听器
|
||||
tabs.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
||||
@Override
|
||||
public void onTabSelected(TabLayout.Tab tab) {
|
||||
if (tab.getCustomView() != null) {
|
||||
TextView textView = (TextView) tab.getCustomView();
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14); // 选中时的字体大小
|
||||
textView.setTextColor(Color.WHITE); // 选中时的黑色
|
||||
textView.setSingleLine(true); // 确保不换行显示
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabUnselected(TabLayout.Tab tab) {
|
||||
if (tab.getCustomView() != null) {
|
||||
TextView textView = (TextView) tab.getCustomView();
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12); // 未选中时的字体大小
|
||||
textView.setTextColor(Color.parseColor("#ffffff")); // 未选中时的灰色
|
||||
textView.setSingleLine(true); // 确保不换行显示
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabReselected(TabLayout.Tab tab) {
|
||||
}
|
||||
});
|
||||
|
||||
// 设置初始选中tab的样式(如果有的话)
|
||||
if (tabs.getTabCount() > 0 && tabs.getSelectedTabPosition() >= 0) {
|
||||
TabLayout.Tab selectedTab = tabs.getTabAt(tabs.getSelectedTabPosition());
|
||||
if (selectedTab != null && selectedTab.getCustomView() != null) {
|
||||
TextView textView = (TextView) selectedTab.getCustomView();
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
|
||||
textView.setTextColor(Color.WHITE);
|
||||
textView.setSingleLine(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_ranking_list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.xscm.modulemain.activity.room.activity;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
|
||||
import com.xscm.modulemain.BaseMvpActivity;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.activity.room.contacts.RedEnvelopesContacts;
|
||||
import com.xscm.modulemain.activity.room.presenter.RedEnvelopesPresenter;
|
||||
import com.xscm.modulemain.adapter.RedAdapter;
|
||||
import com.xscm.modulemain.databinding.FragmentRedBinding;
|
||||
import com.xscm.moduleutil.bean.RedpacketDetail;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author qx
|
||||
* @data 2025/9/29
|
||||
* @description:红包最终的展示页面
|
||||
*/
|
||||
@Route(path = ARouteConstants.ROOM_RED_RESULT)
|
||||
public class RedResultActivity extends BaseMvpActivity<RedEnvelopesPresenter, FragmentRedBinding> implements RedEnvelopesContacts.View {
|
||||
|
||||
private RedAdapter redAdapter;
|
||||
private String redpacketId;
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
redpacketId = getIntent().getStringExtra("redpacketId");
|
||||
if (redpacketId == null || redpacketId.isEmpty()) {
|
||||
// 处理红包ID为空的情况
|
||||
return;
|
||||
}
|
||||
if (MvpPre==null){
|
||||
MvpPre = new RedEnvelopesPresenter(this, this);
|
||||
}
|
||||
MvpPre.getRedpacketDetail(redpacketId);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RedEnvelopesPresenter bindPresenter() {
|
||||
return new RedEnvelopesPresenter(this, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
mBinding.recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
redAdapter = new RedAdapter();
|
||||
mBinding.recyclerView.setAdapter(redAdapter);
|
||||
// 确保最后一项完全可见
|
||||
mBinding.recyclerView.setClipToPadding(false);
|
||||
mBinding.recyclerView.setPadding(
|
||||
0,
|
||||
getResources().getDimensionPixelSize(com.xscm.moduleutil.R.dimen.dp_12),
|
||||
0,
|
||||
getResources().getDimensionPixelSize(com.xscm.moduleutil.R.dimen.dp_12)
|
||||
);
|
||||
mBinding.smartRefreshLayout.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
|
||||
|
||||
@Override
|
||||
public void onRefresh(@NonNull @NotNull RefreshLayout refreshLayout) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadMore(@NonNull @NotNull RefreshLayout refreshLayout) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fragment_red;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void redPacketDetail(RedpacketDetail redpacketDetail) {
|
||||
// 检查 Activity 是否已经销毁
|
||||
if (isFinishing() || isDestroyed()) {
|
||||
return;
|
||||
}
|
||||
if (redpacketDetail != null) {
|
||||
ImageUtils.loadHeadCC(redpacketDetail.getRedpacket_info().getAvatar(), mBinding.userAvatar);
|
||||
mBinding.userName.setText(redpacketDetail.getRedpacket_info().getNickname());
|
||||
mBinding.tvRedTitle.setText(redpacketDetail.getRedpacket_info().getRemark());
|
||||
mBinding.tvJb.setText(redpacketDetail.getRedpacket_info().getCoin_type() == 1 ? "金币" : "钻石");
|
||||
if (redpacketDetail.getMy_record() != null) {
|
||||
mBinding.tvRedJb.setText(redpacketDetail.getMy_record().getAmount());
|
||||
}else {
|
||||
mBinding.tvRedJb.setText("0.00");
|
||||
}
|
||||
mBinding.tvLq.setText("已领取"+redpacketDetail.getRecords().size() + "/" + redpacketDetail.getRedpacket_info().getTotal_count());
|
||||
redAdapter.setNewData(redpacketDetail.getRecords());
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,283 @@
|
||||
package com.xscm.modulemain.activity.room.activity;
|
||||
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.blankj.utilcode.util.StringUtils;
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.adapter.SearchHistoryAdapter;
|
||||
import com.xscm.modulemain.adapter.SearchRecordAdapter;
|
||||
import com.xscm.modulemain.adapter.SearchRoomResultAdapter;
|
||||
import com.xscm.modulemain.adapter.SearchUserResultAdapter;
|
||||
import com.xscm.modulemain.activity.room.contacts.SearchContacts;
|
||||
import com.xscm.modulemain.databinding.ActivitySearchBinding;
|
||||
import com.xscm.modulemain.activity.room.presenter.SearchPresenter;
|
||||
import com.google.android.flexbox.FlexDirection;
|
||||
import com.google.android.flexbox.FlexWrap;
|
||||
import com.google.android.flexbox.FlexboxLayoutManager;
|
||||
import com.xscm.modulemain.BaseMvpActivity;
|
||||
import com.xscm.modulemain.manager.RoomManager;
|
||||
import com.xscm.moduleutil.bean.RecordSection;
|
||||
import com.xscm.moduleutil.bean.RoomSearchResp;
|
||||
import com.xscm.moduleutil.bean.SearchAll;
|
||||
import com.xscm.moduleutil.bean.UserResultResp;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.utils.ChatLauncher;
|
||||
import com.xscm.moduleutil.widget.dialog.CommonDialog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/*
|
||||
* 搜索页面
|
||||
*/
|
||||
public class SearchActivity extends BaseMvpActivity<SearchPresenter, ActivitySearchBinding> implements SearchContacts.View, CommonDialog.OnClickListener {
|
||||
private String keyWord;
|
||||
private List<RoomSearchResp> roomResultInfoList = new ArrayList<>();
|
||||
|
||||
|
||||
private SearchHistoryAdapter mSearchHistoryAdapter;
|
||||
private SearchRecordAdapter mSearchRecordAdapter;
|
||||
private SearchRoomResultAdapter mSearchRoomResultAdapter;
|
||||
private SearchUserResultAdapter mSearchUserResultAdapter;
|
||||
private CommonDialog commonDialog;
|
||||
|
||||
@Override
|
||||
protected SearchPresenter bindPresenter() {
|
||||
return new SearchPresenter(this, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
|
||||
//搜索记录
|
||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
|
||||
mBinding.recycleViewRecord.setLayoutManager(linearLayoutManager);
|
||||
mBinding.recycleViewRecord.setAdapter(mSearchRecordAdapter = new SearchRecordAdapter());
|
||||
mSearchRecordAdapter.bindToRecyclerView(mBinding.recycleViewRecord);
|
||||
mSearchRecordAdapter.setEmptyView(R.layout.index_view_empty);
|
||||
//搜索历史
|
||||
FlexboxLayoutManager flexboxLayoutManager = new FlexboxLayoutManager(this);
|
||||
flexboxLayoutManager.setFlexDirection(FlexDirection.ROW);
|
||||
flexboxLayoutManager.setFlexWrap(FlexWrap.WRAP);
|
||||
mBinding.recycleViewHistory.setLayoutManager(flexboxLayoutManager);
|
||||
mBinding.recycleViewHistory.setAdapter(mSearchHistoryAdapter = new SearchHistoryAdapter());
|
||||
|
||||
//搜索到用户数据
|
||||
mBinding.recycleViewUser.setLayoutManager(new LinearLayoutManager(this));
|
||||
mBinding.recycleViewUser.setAdapter(mSearchUserResultAdapter = new SearchUserResultAdapter());
|
||||
//搜索到房间信息
|
||||
GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 2);
|
||||
mBinding.recycleViewRoom.setLayoutManager(gridLayoutManager);
|
||||
mBinding.recycleViewRoom.setAdapter(mSearchRoomResultAdapter = new SearchRoomResultAdapter());
|
||||
|
||||
mBinding.editQuery.addTextChangedListener(new TextWatcher() {
|
||||
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
keyWord = mBinding.editQuery.getText().toString();
|
||||
MvpPre.saveSearchHistory(keyWord);
|
||||
if (StringUtils.isEmpty(keyWord)) {
|
||||
mBinding.ivClose.setImageLevel(1);
|
||||
mBinding.ivClose.performClick();
|
||||
} else {
|
||||
mSearchUserResultAdapter.setKeyWord(keyWord);
|
||||
mSearchRecordAdapter.setKeyWord(keyWord);
|
||||
mBinding.ivClose.setImageLevel(2);
|
||||
mBinding.llHistory.setVisibility(View.GONE);
|
||||
MvpPre.getSearchHistory();
|
||||
MvpPre.fuzzyQuery(keyWord);
|
||||
MvpPre.search(keyWord);
|
||||
}
|
||||
}
|
||||
});
|
||||
MvpPre.getSearchHistory();
|
||||
|
||||
//快捷搜索列表点击
|
||||
mSearchRecordAdapter.setOnItemChildClickListener((adapter, view, position) -> {
|
||||
MvpPre.saveSearchHistory(Objects.requireNonNull(mSearchRecordAdapter.getItem(position)).t);
|
||||
MvpPre.search(Objects.requireNonNull(mSearchRecordAdapter.getItem(position)).t);
|
||||
});
|
||||
//搜索历史点击
|
||||
mSearchHistoryAdapter.setOnItemClickListener((adapter, view, position) -> {
|
||||
mBinding.editQuery.setText(mSearchHistoryAdapter.getItem(position));
|
||||
try {
|
||||
mBinding.editQuery.setSelection(mSearchHistoryAdapter.getItem(position).length());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
//关注或取消关注
|
||||
mSearchUserResultAdapter.setOnItemChildClickListener((adapter, view, position) -> {
|
||||
UserResultResp item = mSearchUserResultAdapter.getItem(position);
|
||||
MvpPre.followUser(item.getUser_id(), item.getFollow().equals("0") ? 1 : 2, position);
|
||||
});
|
||||
//用户列表点击事件
|
||||
mSearchUserResultAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
|
||||
UserResultResp item = mSearchUserResultAdapter.getItem(position);
|
||||
}
|
||||
});
|
||||
|
||||
mSearchUserResultAdapter.setOnItemClickListener(new SearchUserResultAdapter.OnItemClickListener() {
|
||||
@Override
|
||||
public void onGnsClick(UserResultResp item) {
|
||||
if (item.getRoom_id() != null && !item.getRoom_id().isEmpty() && !"0".equals(item.getRoom_id())) {
|
||||
|
||||
RoomManager.getInstance().fetchRoomDataAndEnter(SearchActivity.this, item.getRoom_id(), "",null);
|
||||
|
||||
} else {
|
||||
ChatLauncher.getInstance().launchC2CChat(SearchActivity.this, item.getUser_id());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHeadImageClick(UserResultResp item) {
|
||||
ARouter.getInstance().build(ARouteConstants.USER_HOME_PAGE).withString("userId", item.getUser_id()).navigation();
|
||||
//
|
||||
}
|
||||
});
|
||||
//房间列表点击时事件
|
||||
mSearchRoomResultAdapter.setOnItemClickListener((adapter, view, position) -> {
|
||||
RoomSearchResp item = mSearchRoomResultAdapter.getItem(position);
|
||||
if (item != null) {
|
||||
RoomManager.getInstance().fetchRoomDataAndEnter(getApplicationContext(), item.getRoom_id(), "",null);
|
||||
}
|
||||
});
|
||||
mBinding.ivDelete.setOnClickListener(v -> {
|
||||
if (commonDialog == null) {
|
||||
commonDialog = new CommonDialog(SearchActivity.this);
|
||||
commonDialog.setmOnClickListener(SearchActivity.this);
|
||||
}
|
||||
commonDialog.show();
|
||||
});
|
||||
mBinding.ivClose.setOnClickListener(v -> {
|
||||
if (!StringUtils.isEmpty(keyWord)) {
|
||||
mBinding.editQuery.setText("");
|
||||
}
|
||||
mBinding.recycleViewRecord.setVisibility(View.GONE);
|
||||
mBinding.llHistory.setVisibility(View.VISIBLE);
|
||||
mBinding.rlResult.setVisibility(View.GONE);
|
||||
});
|
||||
mBinding.tvRoomCount.setOnClickListener(v -> {
|
||||
mSearchRoomResultAdapter.setNewData(roomResultInfoList);
|
||||
mBinding.rlRoom.setVisibility(View.GONE);
|
||||
mBinding.rlUser.setVisibility(View.GONE);
|
||||
mBinding.recycleViewUser.setVisibility(View.GONE);
|
||||
});
|
||||
mBinding.tvCancel.setOnClickListener(v -> finish());
|
||||
mBinding.editQuery.requestFocus();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_search;
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索历史
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
@Override
|
||||
public void setSearchHistory(List<String> data) {
|
||||
mSearchHistoryAdapter.setNewData(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索的结果
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
@Override
|
||||
public void setSearch(SearchAll data) {
|
||||
mBinding.recycleViewRecord.setVisibility(View.GONE);
|
||||
mBinding.llHistory.setVisibility(View.GONE);
|
||||
mBinding.rlResult.setVisibility(View.VISIBLE);
|
||||
if (data == null || (data.getRooms() == null && data.getUsers() == null)) {
|
||||
mBinding.rlNull.setVisibility(View.VISIBLE);
|
||||
mBinding.nestedscrollview.setVisibility(View.GONE);
|
||||
} else {
|
||||
mBinding.rlNull.setVisibility(View.GONE);
|
||||
mBinding.nestedscrollview.setVisibility(View.VISIBLE);
|
||||
if (data.getRooms()==null) {
|
||||
mBinding.recycleViewRoom.setVisibility(View.GONE);
|
||||
mBinding.rlRoom.setVisibility(View.GONE);
|
||||
} else {
|
||||
mBinding.recycleViewRoom.setVisibility(View.VISIBLE);
|
||||
mBinding.rlRoom.setVisibility(View.VISIBLE);
|
||||
if (data.getRooms().size() > 2) {
|
||||
mSearchRoomResultAdapter.setNewData(data.getRooms().subList(0, 2));
|
||||
} else {
|
||||
mSearchRoomResultAdapter.setNewData(data.getRooms());
|
||||
}
|
||||
mBinding.tvRoomCount.setText("全部 " + data.getRooms().size());
|
||||
}
|
||||
if (data.getUsers() != null && data.getUsers().size() != 0) {
|
||||
mBinding.rlUser.setVisibility(View.VISIBLE);
|
||||
mBinding.recycleViewUser.setVisibility(View.VISIBLE);
|
||||
mSearchUserResultAdapter.setNewData(data.getUsers());
|
||||
} else {
|
||||
mBinding.rlUser.setVisibility(View.GONE);
|
||||
mBinding.recycleViewUser.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 模糊快捷查询
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
@Override
|
||||
public void setFuzzyQuery(List<RecordSection> data) {
|
||||
mBinding.recycleViewRecord.setVisibility(View.VISIBLE);
|
||||
mBinding.llHistory.setVisibility(View.GONE);
|
||||
mBinding.rlResult.setVisibility(View.GONE);
|
||||
mSearchRecordAdapter.setNewData(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关注成功
|
||||
*
|
||||
* @param type
|
||||
* @param postion
|
||||
*/
|
||||
@Override
|
||||
public void followUserSuccess(int type, int postion) {
|
||||
UserResultResp item = mSearchUserResultAdapter.getItem(postion);
|
||||
item.setFollow(type == 1 ? "1" : "0");
|
||||
mSearchUserResultAdapter.notifyItemChanged(postion, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLeftClick() {
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onRightClick() {
|
||||
MvpPre.deleteSearchHistory();
|
||||
MvpPre.getSearchHistory();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.room.RoomAuction;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BidListContacts {
|
||||
|
||||
public interface View extends IView<Activity> {
|
||||
void roomAuctionList(List<RoomAuction.AuctionListBean> auctionListBean);
|
||||
void setNo1(RoomAuction.AuctionListBean listsBean);
|
||||
void setNo2(RoomAuction.AuctionListBean listsBean);
|
||||
void setNo3(RoomAuction.AuctionListBean listsBean);
|
||||
void setCharmEmpty();
|
||||
|
||||
}
|
||||
|
||||
public interface IRoomPre extends IPresenter {
|
||||
void roomAuctionList(String auction_id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.RoomRelationBean;
|
||||
import com.xscm.moduleutil.bean.RoomTime;
|
||||
import com.xscm.moduleutil.bean.RoonGiftModel;
|
||||
import com.xscm.moduleutil.bean.room.AuctionBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CardRelationshipContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
void roomRelationList(List<RoomRelationBean> roomRelationBeans);
|
||||
void setGiftList(List<RoonGiftModel> roonGiftModels);
|
||||
void roomAuction(AuctionBean auctionBean);
|
||||
void roomAuctionTime(RoomTime roomTime);
|
||||
}
|
||||
public interface IRoomPre extends IPresenter {
|
||||
void roomRelationList(String type);
|
||||
|
||||
void getGiftList(String id);
|
||||
|
||||
void roomAuction(String roomId, String userId,String giftId, String relation_id, String auction_type, String time_day);
|
||||
void roomAuctionTime(String gift_id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
|
||||
|
||||
public final class ChatRoomContacts {
|
||||
|
||||
|
||||
public interface View extends IView<Activity> {
|
||||
|
||||
}
|
||||
|
||||
public interface IPublicScreenEaseChatPre extends IPresenter {
|
||||
void logEmchat(int code,String msg,String toChatUsername);
|
||||
|
||||
void switchPublicScreen(String room_id,String status);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.CharmRankingResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/6/10
|
||||
*@description: 排行榜对应的接口
|
||||
*/
|
||||
public class DataListContacts {
|
||||
|
||||
public interface View extends IView<Activity> {
|
||||
|
||||
//榜一更新
|
||||
void setNo1(CharmRankingResp listsBean);
|
||||
//榜二更新
|
||||
void setNo2(CharmRankingResp listsBean);
|
||||
//榜三更新
|
||||
void setNo3(CharmRankingResp listsBean);
|
||||
//魅力榜和魅力榜界面更新
|
||||
|
||||
void setCharmEmpty( List<CharmRankingResp> list);
|
||||
|
||||
void setWealthEmpty(List<CharmRankingResp> list);
|
||||
}
|
||||
public interface IRoomDataListPre extends IPresenter {
|
||||
|
||||
//定义魅力榜数据访问接口
|
||||
void getCharmListInfo(String roomId,String type, String time_type, String page, String page_limit);
|
||||
|
||||
//定义财富榜数据访问接口
|
||||
void getWealthListInfo(String roomId, String type, String time_type, String page, String page_limit);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.UserOnlineStatusBean;
|
||||
import com.xscm.moduleutil.bean.room.FriendUserBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FriendshipRoomContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
void applyPit();
|
||||
|
||||
void endFriend(FriendUserBean friendUserBean);
|
||||
|
||||
void createRelation();
|
||||
|
||||
void userOnlineStatus(List<UserOnlineStatusBean> list);
|
||||
}
|
||||
|
||||
public interface IRoomPre extends IPresenter {
|
||||
void applyPit(String roomId, String pitNumber);
|
||||
|
||||
void startFriend(String roomId);
|
||||
|
||||
void delay(String friend_id,String room_id,String delay_times);
|
||||
|
||||
void endFriend(String friend_id,String room_id);
|
||||
|
||||
void createRelation(String room_id,String friend_id,String user1_id,String user2_id,String relation_id);
|
||||
|
||||
void userOnlineStatus(String userId, String roomid);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.HomeBean;
|
||||
import com.xscm.moduleutil.bean.TopRoom;
|
||||
import com.xscm.moduleutil.bean.room.RoomInfoResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class HotListContacts {
|
||||
|
||||
|
||||
public interface View extends IView<Activity> {
|
||||
void roomList(List<TopRoom> data, int type);
|
||||
|
||||
void finishRefreshLoadMore();
|
||||
|
||||
void getMoreRoomList(List<HomeBean> data);
|
||||
|
||||
void roomInfo(RoomInfoResp resp);
|
||||
|
||||
void showPasswordDialog();
|
||||
|
||||
void enterFail();
|
||||
}
|
||||
|
||||
public interface IHotListPre extends IPresenter {
|
||||
void getRoomList(int type,String page,String page_limit,String is_top,String label_id);
|
||||
|
||||
void getMoreRoomList(String userId);
|
||||
|
||||
void getRoomListTow();
|
||||
|
||||
void getRoomIn(String roomId, String password);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.room.RoomHourBean;
|
||||
|
||||
public class HourlyChartContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
void getRoomHourRanking(RoomHourBean roomHourBean);
|
||||
|
||||
void findView();
|
||||
}
|
||||
|
||||
public interface IRoomPre extends IPresenter {
|
||||
void getRoomHourRanking(String page,String page_limit);// 房间小时榜
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
|
||||
public class PkTimeContract {
|
||||
public interface View extends IView<Activity> {
|
||||
void startPk();
|
||||
}
|
||||
|
||||
public interface IRoomPre extends IPresenter {
|
||||
void startPk(String pk_id,String pk_times);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.PlaceholderBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PlaceholderContacts {
|
||||
|
||||
public interface View extends IView<Activity> {
|
||||
void wealthRanking(PlaceholderBean.MyRanking data);
|
||||
void setNo1(PlaceholderBean.ListsBean data,String type);
|
||||
void setNo2(PlaceholderBean.ListsBean data,String type);
|
||||
void setNo3(PlaceholderBean.ListsBean data,String type);
|
||||
void setList(List<PlaceholderBean.ListsBean > list);
|
||||
}
|
||||
|
||||
public interface IPres extends IPresenter {
|
||||
void wealthRanking(String ranking_type,String type);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.HeadlineBean;
|
||||
|
||||
public class PublishCommentContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
void sendHeadine();
|
||||
void currentHeadline(HeadlineBean headlineBean);
|
||||
}
|
||||
public interface IRoomPre extends IPresenter {
|
||||
void sendHeadine(String content,String money,String roomId);
|
||||
|
||||
void currentHeadline();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.RedpacketDetail;
|
||||
|
||||
public class RedEnvelopesContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
void redPacketDetail(RedpacketDetail redpacketDetail);
|
||||
}
|
||||
|
||||
public interface IRoomPre extends IPresenter {
|
||||
void getRedpacketDetail(String redpacketId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.MusicSongBean;
|
||||
import com.xscm.moduleutil.bean.SongMusicBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RequestContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
void songList(List<MusicSongBean> musicSongBeans);
|
||||
|
||||
void upSong(String s);
|
||||
|
||||
void song(List<SongMusicBean> music);
|
||||
|
||||
}
|
||||
public interface IRoomPre extends IPresenter {
|
||||
void songList(String roomId);
|
||||
|
||||
void upSong(String did,String type);
|
||||
|
||||
void song(String roomId,String user_id,String song_code,String song_name,String singer,String poster,String duration);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.UserOnlineStatusBean;
|
||||
import com.xscm.moduleutil.bean.room.AuctionBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RoomAuctionContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
void applyPit();
|
||||
|
||||
void roomAuction(AuctionBean auctionBean);
|
||||
|
||||
void auctionDelay();
|
||||
void auctionEnd();
|
||||
void auctionMode();
|
||||
void userOnlineStatus(List<UserOnlineStatusBean> list);
|
||||
|
||||
}
|
||||
|
||||
public interface IRoomDataListPre extends IPresenter {
|
||||
void applyPit(String roomId, String pitNumber);
|
||||
|
||||
void roomAuction(String roomId, String userId,String giftId, String relation_id, String auction_type, String time_day);
|
||||
|
||||
void auctionDelay(String auctionId);
|
||||
void auctionEnd(String auctionId,String roomId);
|
||||
|
||||
void auctionMode(String roomId,String labelId);
|
||||
void userOnlineStatus(String userId, String roomid);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.RoomBgBean;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class RoomBackgroundContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
void getBackgroundList(RoomBgBean list);
|
||||
void upLoadSuccess(String url, int type, int index, int total);
|
||||
void uploadBgImage();
|
||||
void editRoom();
|
||||
}
|
||||
|
||||
public interface RoomBackgroudPre extends IPresenter {
|
||||
void getBackgroundList();
|
||||
|
||||
void uploadFile(File file, int type, int index, int sice);
|
||||
|
||||
void uploadBgImage(String id, String image_url);
|
||||
|
||||
void editRoom(String room_id, String room_name, String room_cover, String room_intro,String room_background_id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
|
||||
public class RoomCabinContacts {
|
||||
|
||||
public interface View extends IView<Activity> {
|
||||
void quitRoom();
|
||||
}
|
||||
|
||||
public interface IRoomPre extends IPresenter {
|
||||
void quitRoom(String roomId, String userId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.RoomUserCharmListBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RoomCharmDialogContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
void roomUserCharmList(List<RoomUserCharmListBean> roomUserCharmListBeans);
|
||||
}
|
||||
|
||||
public interface IRoomPre extends IPresenter {
|
||||
|
||||
void roomUserCharmList(String room_id, String user_id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
|
||||
public class RoomChartsContacts {
|
||||
|
||||
public interface View extends IView<Activity> {
|
||||
|
||||
}
|
||||
|
||||
public interface IRoomPre extends IPresenter {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.RoomRelationBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RoomCloseContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
// TODO: 2025/3/10 获取亲密关系
|
||||
void roomRelationList(List<RoomRelationBean> list);
|
||||
|
||||
}
|
||||
|
||||
public interface IRoomToolPre extends IPresenter {
|
||||
// TODO: 2025/3/10 获取亲密关系
|
||||
void roomRelationList(String type);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.RedPacketInfo;
|
||||
import com.xscm.moduleutil.bean.RoomCharmRankBean;
|
||||
import com.xscm.moduleutil.bean.UserOnlineStatusBean;
|
||||
import com.xscm.moduleutil.bean.room.RoomInfoResp;
|
||||
import com.xscm.moduleutil.bean.room.RoomOnline;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RoomContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
void roomInfo(RoomInfoResp resp);
|
||||
|
||||
void showPasswordDialog();
|
||||
|
||||
void enterFail();
|
||||
|
||||
void getRoomOnline(RoomOnline onlineBean);
|
||||
|
||||
void applyPit();
|
||||
|
||||
void downPit();
|
||||
|
||||
void applySong();
|
||||
|
||||
void agreeSong();
|
||||
|
||||
void postRoomInfo(RoomInfoResp resp);
|
||||
|
||||
void getCharmRank(List<RoomCharmRankBean> list);
|
||||
|
||||
void changeSong();
|
||||
|
||||
void hostUserPit();
|
||||
|
||||
void quitRoom();
|
||||
void quitRoom2(String roomId);
|
||||
|
||||
void userGuanzSuccess(String s);
|
||||
|
||||
void acceptPk();
|
||||
|
||||
void clearUserCharm();
|
||||
|
||||
void userOnlineStatus(List<UserOnlineStatusBean> list);
|
||||
|
||||
void findRoom();
|
||||
|
||||
void roomRedPackets(List<RedPacketInfo> list);
|
||||
}
|
||||
|
||||
public interface IRoomPre extends IPresenter {
|
||||
void getRoomIn(String roomId, String password);//加入房间
|
||||
|
||||
void getRoomOnline(String roomId, String page, String page_limit);
|
||||
|
||||
void applyPit(String roomId, String pitNumber);
|
||||
|
||||
void downPit(String roomId, String pitNumber);
|
||||
|
||||
void applySong(String roomId);
|
||||
|
||||
void agreeSong(String roomId, String type);//申请点唱模式 type:1同意 2拒绝
|
||||
|
||||
void endSong(String roomId);
|
||||
|
||||
void postRoomInfo(String roomId);
|
||||
|
||||
void getCharmRank(String roomId);
|
||||
|
||||
void changeSong(String roomId, String now_did);
|
||||
|
||||
void hostUserPit(String roomId, String pitNumber, String userId, String type);
|
||||
|
||||
void quitRoom(String roomId, String userId);
|
||||
void quitRoom2(String roomId, String userId);
|
||||
|
||||
void userGuanz(String userId, String type);
|
||||
|
||||
void acceptPk(String pkId, String type);
|
||||
|
||||
void clearUserCharm(String roomId, String userId);//清除魅力值
|
||||
|
||||
void userOnlineStatus(String userId, String roomid);
|
||||
|
||||
void auctionEnd(String auctionId,String roomId);
|
||||
|
||||
void auctionDelay(String auctionId);
|
||||
|
||||
void roomRedPackets(String roomId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.HostBean;
|
||||
import com.xscm.moduleutil.bean.RoomSearchResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RoomHostContacts {
|
||||
|
||||
public interface View extends IView<Activity> {
|
||||
void setHostrList(List<HostBean> list);
|
||||
|
||||
void getUserHostList(List<RoomSearchResp> list);
|
||||
|
||||
void postHostAdd(String s,String type,String is_add);
|
||||
|
||||
void postPresidedRatio(String s);
|
||||
|
||||
void postPresidedDel(String s);
|
||||
void doDismiss();
|
||||
}
|
||||
|
||||
public interface IRoomToolPre extends IPresenter {
|
||||
void clearHostList(String roomId,String type);
|
||||
|
||||
void setUserHostList(String roomId,String type);
|
||||
void setPresidedRatio(String room_id,String id, String ratio);
|
||||
|
||||
void postHostAdd(String roomId, String userId,String type,String is_add);
|
||||
|
||||
// void presidedDel(String id);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
|
||||
|
||||
public final class RoomPasswordSetContacts {
|
||||
|
||||
|
||||
public interface View extends IView<Activity> {
|
||||
void roomPasswordSettingSuccess();
|
||||
}
|
||||
|
||||
public interface IRoomPasswordSetPre extends IPresenter {
|
||||
void setRoomPassword(String roomId, String password);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.room.RoomBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RoomPkContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
void searchPkRoom(List<RoomBean> roomBeans);
|
||||
|
||||
void sendPk();
|
||||
void refusePk();
|
||||
|
||||
void finishLoading();
|
||||
}
|
||||
public interface IRoomPre extends IPresenter {
|
||||
void searchPkRoom(String roomId,String page,String limit);
|
||||
|
||||
void sendPk(String roomIda,String createUserId, String roomIdb);
|
||||
|
||||
void refusePk(String roomId,String is_pk);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.room.RoomSettingBean;
|
||||
|
||||
public class RoomSettingContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
void changeRoomSuccess(String s,int position,RoomSettingBean bean);
|
||||
|
||||
void changeRoomType(String s);
|
||||
|
||||
void agreeSong(String s);
|
||||
}
|
||||
|
||||
public interface IRoomPre extends IPresenter {
|
||||
|
||||
void changeRoom(String roomId, String userId, int position, RoomSettingBean bean);
|
||||
|
||||
void changeRoomType(String roomId,String type);//修改房间类型 type:1点唱、2拍卖、3男神、4女神
|
||||
|
||||
void agreeSong(String roomId, String type);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.RelationCardBean;
|
||||
import com.xscm.moduleutil.bean.UserInfo;
|
||||
|
||||
public class RoomUserContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
void getRoomUserInfo(UserInfo userInfo);
|
||||
|
||||
void downPit();
|
||||
|
||||
void kickOutRoom();
|
||||
void postHostAdd(String s,String type,String is_add);
|
||||
void setMutePit(String pitNumber, String is_mute);
|
||||
void addBlackList();
|
||||
void userGuanzSuccess(String s);
|
||||
void hostUserPit();
|
||||
void giveCoin();
|
||||
void relationCard(RelationCardBean list);
|
||||
|
||||
void topRelationCard(String s);
|
||||
void deleteRelationCard(String s);
|
||||
void clearUserCharm();
|
||||
|
||||
void applyPit();
|
||||
}
|
||||
|
||||
public interface ViewGx extends IView<Activity> {
|
||||
}
|
||||
|
||||
public interface IEmotionRoomPre extends IPresenter {
|
||||
void getRoomUserInfo(String roomId,String userId);
|
||||
|
||||
void downPit(String roomId, String pitNumber);//下麦
|
||||
|
||||
void kickOutRoom(String roomId, String userId);
|
||||
|
||||
void postHostAdd(String roomId, String userId,String type,String is_add);
|
||||
|
||||
void setMutePit(String roomId, String pitNumber,String is_mute);// 禁言 禁麦 \解禁
|
||||
|
||||
void addBlackList(String userId);
|
||||
void userGuanz(String userId,String type);
|
||||
|
||||
void hostUserPit(String roomId,String pitNumber,String userId,String type);
|
||||
|
||||
void giveCoin(String user_id,String coin);
|
||||
|
||||
void relationCard(String user_id);
|
||||
|
||||
void topRelationCard(String id);
|
||||
void deleteRelationCard(String id);
|
||||
|
||||
void clearUserCharm(String roomId,String userId);
|
||||
|
||||
void applyPit(String roomId,String pitNumber);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.RecordSection;
|
||||
import com.xscm.moduleutil.bean.SearchAll;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public final class SearchContacts {
|
||||
|
||||
public interface View extends IView<Activity> {
|
||||
void setSearchHistory(List<String> data);
|
||||
|
||||
void setSearch(SearchAll data);
|
||||
|
||||
void setFuzzyQuery(List<RecordSection> data);
|
||||
|
||||
void followUserSuccess(int type, int postion);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public interface ISearchPre extends IPresenter {
|
||||
void getSearchHistory();
|
||||
|
||||
void saveSearchHistory(String keyWord);
|
||||
|
||||
void deleteSearchHistory();
|
||||
|
||||
void search(String keyWord);
|
||||
|
||||
void fuzzyQuery(String keyWord);
|
||||
|
||||
void followUser(String userId, int type, int postion);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.PkSwTokenBean;
|
||||
import com.xscm.moduleutil.bean.UserOnlineStatusBean;
|
||||
import com.xscm.moduleutil.bean.room.RoomInfoResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SingSongContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
void applyPit();
|
||||
void setMutePit(String pitNumber, String is_mute);
|
||||
void setLockPit(String pitNumber, String is_lock);
|
||||
|
||||
void postRoomInfo(RoomInfoResp resp);
|
||||
void postRoomInfoPk(RoomInfoResp resp);
|
||||
void postRoomInfoUp(RoomInfoResp resp);
|
||||
|
||||
void endPk();
|
||||
|
||||
void userOnlineStatus(List<UserOnlineStatusBean> list);
|
||||
|
||||
void postAgora(PkSwTokenBean pkSwTokenBean);
|
||||
}
|
||||
|
||||
public interface IEmotionRoomPre extends IPresenter {
|
||||
void applyPit(String roomId, String pitNumber);
|
||||
|
||||
void setMutePit(String roomId, String pitNumber,String is_mute);//禁麦
|
||||
|
||||
void setLockPit(String roomId, String pitNumber, String is_lock);
|
||||
|
||||
void postRoomInfo(String roomId,String number,int type);
|
||||
|
||||
void endPk(String pk_id,String type,String user_id);
|
||||
void userOnlineStatus(String userId, String roomid);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.GiftUserWallBean;
|
||||
|
||||
public final class UserGiftWallConacts {
|
||||
|
||||
|
||||
public interface View extends IView<Activity> {
|
||||
void setGiftWall(GiftUserWallBean data);
|
||||
}
|
||||
|
||||
|
||||
public interface IUserGiftWallPre extends IPresenter {
|
||||
void giftWall(String userId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.BannerModel;
|
||||
import com.xscm.moduleutil.bean.RoomTypeModel;
|
||||
import com.xscm.moduleutil.bean.TopRoom;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public final class VoiceCategoryContacts {
|
||||
|
||||
|
||||
public interface View extends IView<Activity> {
|
||||
void setCategories(List<RoomTypeModel> list);
|
||||
|
||||
|
||||
void setBanners(List<BannerModel> bannerModels);
|
||||
|
||||
void setRoomId(String roomId);
|
||||
|
||||
void setTopRoom(List<TopRoom> topRooms,int type);
|
||||
|
||||
void finishRefreshLoadMore();
|
||||
}
|
||||
|
||||
public interface IIndexCategoryPre extends IPresenter {
|
||||
void getCategories();
|
||||
|
||||
void getMediaRoom(String type);
|
||||
|
||||
void getCarousels(int type, int page,String page_limit,String is_top,String label_id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.ActivitiesPermission;
|
||||
|
||||
|
||||
public final class VoiceContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
|
||||
// void setBanners(List<BannerResp> list);
|
||||
|
||||
void hideRecommend(boolean hideRecommend,boolean hideGame);
|
||||
void activitiesPermissionSuccess(ActivitiesPermission activitiesPermission);
|
||||
|
||||
}
|
||||
|
||||
public interface IIndexPre extends IPresenter {
|
||||
|
||||
void getBanners();
|
||||
|
||||
void getNameAuthResult(int type);
|
||||
|
||||
void activitiesPermission();//活动弹框权限
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.xscm.modulemain.activity.room.contacts;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.room.RoomApplyListBean;
|
||||
|
||||
public class WheatContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
void roomApplyListBean(RoomApplyListBean roomApplyListBeans);
|
||||
void clearApply();
|
||||
void agreePit();
|
||||
void applyPit();
|
||||
|
||||
void giveGift();
|
||||
}
|
||||
|
||||
public interface IRoomPre extends IPresenter {
|
||||
void roomApplyListBean(String roomId);
|
||||
|
||||
void clearApply(String roomId);//清空申请上面列表
|
||||
|
||||
void agreePit(String roomId,String userId);//同意上麦
|
||||
|
||||
void refusePit(String roomId,String userId);//拒绝上麦
|
||||
|
||||
void helpApply(String roomId,String userId);
|
||||
|
||||
void applyPit(String roomId, String pitNumber);
|
||||
|
||||
void roomGift(String room_id, String gift_id, String gift_num, String to_uid, String type, String pit_number);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,709 @@
|
||||
package com.xscm.modulemain.activity.room.fragment;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.os.CountDownTimer;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.blankj.utilcode.util.GsonUtils;
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.tencent.imsdk.v2.V2TIMManager;
|
||||
import com.tencent.imsdk.v2.V2TIMMessage;
|
||||
import com.tencent.imsdk.v2.V2TIMSendCallback;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.activity.room.activity.RoomActivity;
|
||||
import com.xscm.modulemain.activity.room.contacts.ChatRoomContacts;
|
||||
import com.xscm.modulemain.activity.room.presenter.ChatRoomPresenter;
|
||||
import com.xscm.modulemain.adapter.EaseChatAdapter;
|
||||
import com.xscm.modulemain.databinding.RoomFragementTransEaseChatBinding;
|
||||
import com.xscm.modulemain.dialog.RoomUserInfoFragment;
|
||||
import com.xscm.moduleutil.base.BaseMvpFragment;
|
||||
import com.xscm.moduleutil.bean.RoomInputEvent;
|
||||
import com.xscm.moduleutil.bean.RoomMessageEvent;
|
||||
import com.xscm.moduleutil.bean.RoomSettingEvent;
|
||||
import com.xscm.moduleutil.bean.UserInfo;
|
||||
import com.xscm.moduleutil.bean.room.Children;
|
||||
import com.xscm.moduleutil.bean.room.EMMessageInfo;
|
||||
import com.xscm.moduleutil.bean.room.EmotionDeatils;
|
||||
import com.xscm.moduleutil.bean.room.RoomInfoResp;
|
||||
import com.xscm.moduleutil.bean.room.RoomUserBean;
|
||||
import com.xscm.moduleutil.event.RoomJoinMountModel;
|
||||
import com.xscm.moduleutil.event.RoomTaskEvent;
|
||||
import com.xscm.moduleutil.listener.MessageListenerSingleton;
|
||||
import com.xscm.moduleutil.rtc.MusicPlayBean;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
import com.xscm.moduleutil.utils.logger.Logger;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* @author qx
|
||||
* @data 2025/6/17
|
||||
* @description: 聊天室
|
||||
*/
|
||||
public class ChatRoomFragment extends BaseMvpFragment<ChatRoomPresenter, RoomFragementTransEaseChatBinding>
|
||||
implements ChatRoomContacts.View {
|
||||
private final static String TAG = "聊天室";
|
||||
private boolean isBottom = true;
|
||||
private int count = 0;
|
||||
private RoomInfoResp roomInfoResp;
|
||||
private EaseChatAdapter easeChatAdapter;
|
||||
private String roomId;
|
||||
private MessageListenerSingleton.PublicScreenMessageListener messageListener;
|
||||
|
||||
// 在需要的地方调用 Activity 的方法
|
||||
public void someMethod() {
|
||||
easeChatAdapter.clearData();
|
||||
}
|
||||
|
||||
public ChatRoomFragment(){}
|
||||
public ChatRoomFragment(RoomInfoResp resp){
|
||||
roomInfoResp = resp;
|
||||
|
||||
roomId = resp.getRoom_info().getRoom_id();
|
||||
}
|
||||
|
||||
public static ChatRoomFragment newInstance(RoomInfoResp resp) {
|
||||
return new ChatRoomFragment(resp);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ChatRoomPresenter bindPresenter() {
|
||||
return new ChatRoomPresenter(this, getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
onFragmentShowDestroy();
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
public void onFragmentShowDestroy() {
|
||||
if (messageListener != null) {
|
||||
LogUtils.e("移除监听器");
|
||||
MessageListenerSingleton.getInstance().removePublicScreenMessageListener(messageListener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
// 确保适配器已初始化
|
||||
if (easeChatAdapter == null) {
|
||||
initChatAdapter();
|
||||
}
|
||||
if (easeChatAdapter != null) {
|
||||
easeChatAdapter.clearData();
|
||||
}
|
||||
this.roomId = roomInfoResp.getRoom_info().getRoom_id();
|
||||
|
||||
RoomMessageEvent.T t = new RoomMessageEvent.T();
|
||||
t.setText("羽声严禁未成年人进行直播或打赏,官方将24小时在线巡查。我们提倡绿色直播,直播间严禁出现涉政、涉恐、涉黄、涉赌等违法违规内容,严禁宣传封建迷信、宗教极端思想、出现低俗色情、吸烟酗酒等内容,严禁违反社会主义核心价值观、践踏社会道德底线、诱导打赏、低俗 PK 、买卖金币等行为,请大家共同遵守、监督并及时举报。请勿相信各类刷钻、购买礼包、游戏币及电商贩卖等非官方广告信息,谨防网络诈骗。");
|
||||
// 加入群组成功
|
||||
handleRoomMessage(new RoomMessageEvent(1000, roomId, t));
|
||||
onChatRoomViewCreation();
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录聊天室
|
||||
*/
|
||||
public void onChatRoomViewCreation() {
|
||||
// 先移除旧的监听器
|
||||
if (messageListener != null) {
|
||||
MessageListenerSingleton.getInstance().removePublicScreenMessageListener(messageListener);
|
||||
messageListener = null;
|
||||
}
|
||||
// 设置消息监听器
|
||||
setupMessageListener();
|
||||
|
||||
// 检查是否有缓存的消息需要处理
|
||||
checkAndProcessCachedMessages();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置消息监听器
|
||||
*/
|
||||
private void setupMessageListener() {
|
||||
// 创建并添加监听器
|
||||
messageListener = message -> {
|
||||
// 确保在主线程更新 UI
|
||||
if (getActivity() != null) {
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
handleRoomMessage(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
MessageListenerSingleton.getInstance().addPublicScreenMessageListener(messageListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查并处理缓存的消息
|
||||
*/
|
||||
private void checkAndProcessCachedMessages() {
|
||||
if (roomId == null || roomId.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 延迟一小段时间,确保监听器已注册
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// 获取并处理缓存的消息
|
||||
List<RoomMessageEvent> cachedMessages = MessageListenerSingleton.getInstance().getAndClearCachedMessages(roomId);
|
||||
if (!cachedMessages.isEmpty()) {
|
||||
LogUtils.d("PublicScreenEaseChatFragment", "处理缓存消息数量: " + cachedMessages.size());
|
||||
for (RoomMessageEvent message : cachedMessages) {
|
||||
handleRoomMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 300); // 延迟300ms确保监听器已注册
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void initListener() {
|
||||
mBinding.recycleViewPublic.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
|
||||
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
|
||||
LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
|
||||
//屏幕中最后一个可见子项的position
|
||||
int lastVisibleItemPosition = layoutManager.findLastVisibleItemPosition();
|
||||
//当前屏幕所看到的子项个数
|
||||
int visibleItemCount = layoutManager.getChildCount();
|
||||
//当前RecyclerView的所有子项个数
|
||||
int totalItemCount = layoutManager.getItemCount();
|
||||
//RecyclerView的滑动状态
|
||||
if (visibleItemCount > 0 && lastVisibleItemPosition == totalItemCount - 1) {
|
||||
if (mBinding.tvCount != null) {
|
||||
mBinding.tvCount.setVisibility(View.GONE);
|
||||
}
|
||||
isBottom = true;
|
||||
count = 0;
|
||||
} else {
|
||||
isBottom = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void upRoomInfo(RoomInfoResp resp){
|
||||
if (resp == null)
|
||||
return;
|
||||
roomInfoResp = resp;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
|
||||
mBinding.recycleViewPublic.setLayoutManager(linearLayoutManager);
|
||||
initChatAdapter();
|
||||
easeChatAdapter.setOnItemClickListener((adapter, view, position) -> {
|
||||
EMMessageInfo item = easeChatAdapter.getItem(position);
|
||||
RoomMessageEvent emMessage = item.getEmMessage();
|
||||
if (emMessage.getText().getFromUserInfo() != null) {
|
||||
RoomUserInfoFragment.show(roomInfoResp.getRoom_info().getRoom_id(), emMessage.getText().getFromUserInfo().getUser_id() != 0 ? emMessage.getText().getFromUserInfo().getUser_id() + "" : emMessage.getText().getFromUserInfo().getId() + "", emMessage.getText().getFromUserInfo().getPit_number(), getHostUser(roomInfoResp.getUser_info()), false, 5, isNumberWhether(), getChildFragmentManager());
|
||||
}
|
||||
|
||||
});
|
||||
// //判断是否开启公屏
|
||||
setUpPublicScreen();
|
||||
mBinding.tvCount.setOnClickListener(this::onClick);
|
||||
mBinding.tvTabAll.setOnClickListener(this::onClick);
|
||||
mBinding.tvTabUser.setOnClickListener(this::onClick);
|
||||
mBinding.tvTabSystem.setOnClickListener(this::onClick);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化聊天适配器
|
||||
*/
|
||||
private void initChatAdapter() {
|
||||
if (easeChatAdapter == null) {
|
||||
easeChatAdapter = new EaseChatAdapter();
|
||||
// 添加空值检查,确保mBinding和recycleViewPublic都不为null
|
||||
if (mBinding != null) {
|
||||
mBinding.recycleViewPublic.setAdapter(easeChatAdapter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int isNumberWhether() {
|
||||
if (roomInfoResp.getUser_info().getPit_number() == 9) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int getHostUser(RoomUserBean item) {
|
||||
if (item.getPit_number() != 0) {
|
||||
if (item.getIs_room_owner() == 1) {
|
||||
return 1;
|
||||
} else if (item.getIs_management() == 1) {
|
||||
return 2;
|
||||
} else if (item.getIs_host() == 1) {
|
||||
return 3;
|
||||
} else {
|
||||
return 4;
|
||||
}
|
||||
} else {
|
||||
if (item.getIs_room_owner() == 1) {
|
||||
return 1;
|
||||
} else if (item.getIs_management() == 1) {
|
||||
return 2;
|
||||
} else if (item.getIs_host() == 1) {
|
||||
return 3;
|
||||
}
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void setUpPublicScreen() {
|
||||
//如果有数据或者recycle view有item view就删除;否则程序崩溃,找不到item
|
||||
if (mBinding.recycleViewPublic.getChildCount() > 0) {
|
||||
mBinding.recycleViewPublic.removeAllViews();
|
||||
}
|
||||
mBinding.recycleViewPublic.setVisibility(View.VISIBLE);//开启消息列表
|
||||
mBinding.llHeadTab.setVisibility(View.GONE);
|
||||
mBinding.tvClose.setVisibility(View.GONE);
|
||||
count = 0;//未读数0
|
||||
isBottom = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.room_fragement_trans_ease_chat;
|
||||
}
|
||||
|
||||
|
||||
public void onClick(View view) {
|
||||
int view_id = view.getId();
|
||||
|
||||
if (view_id == R.id.tv_tab_all) {
|
||||
easeChatAdapter.setShowType(EaseChatAdapter.SHOW_TYPE_ALL);
|
||||
mBinding.tvTabAll.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
mBinding.tvTabAll.setTextSize(14);
|
||||
|
||||
mBinding.tvTabUser.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
mBinding.tvTabSystem.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
mBinding.tvTabSystem.setBackgroundResource(0);
|
||||
mBinding.tvTabUser.setBackgroundResource(0);
|
||||
mBinding.tvTabUser.setTextSize(12);
|
||||
mBinding.tvTabSystem.setTextSize(12);
|
||||
|
||||
} else if (view_id == R.id.tv_tab_user) {
|
||||
easeChatAdapter.setShowType(EaseChatAdapter.SHOW_TYPE_USER);
|
||||
mBinding.tvTabUser.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
mBinding.tvTabUser.setTextSize(14);
|
||||
|
||||
mBinding.tvTabAll.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
mBinding.tvTabSystem.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
mBinding.tvTabSystem.setBackgroundResource(0);
|
||||
mBinding.tvTabAll.setBackgroundResource(0);
|
||||
mBinding.tvTabAll.setTextSize(12);
|
||||
mBinding.tvTabSystem.setTextSize(12);
|
||||
} else if (view_id == R.id.tv_tab_system) {
|
||||
easeChatAdapter.setShowType(EaseChatAdapter.SHOW_TYPE_SYSTEM);
|
||||
|
||||
mBinding.tvTabSystem.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
mBinding.tvTabSystem.setTextSize(14);
|
||||
|
||||
mBinding.tvTabAll.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
mBinding.tvTabUser.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
mBinding.tvTabUser.setBackgroundResource(0);
|
||||
mBinding.tvTabAll.setBackgroundResource(0);
|
||||
mBinding.tvTabAll.setTextSize(12);
|
||||
mBinding.tvTabUser.setTextSize(12);
|
||||
} else if (view_id == R.id.tv_count) {
|
||||
mBinding.recycleViewPublic.scrollToPosition(easeChatAdapter.getItemCount() - 1);
|
||||
mBinding.tvCount.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
}
|
||||
public void fasong(RoomInputEvent roomInputEvent) {
|
||||
String message = roomInputEvent.text;
|
||||
RoomMessageEvent.T t = new RoomMessageEvent.T();
|
||||
t.setText(message);
|
||||
t.setFromUserInfo(SpUtil.getUserInfo());
|
||||
RoomMessageEvent roomMessageEvent = new RoomMessageEvent(1, roomInfoResp.getRoom_info().getRoom_id(), t);
|
||||
handleRoomMessage(roomMessageEvent);
|
||||
String json = GsonUtils.toJson(roomMessageEvent);
|
||||
// 转换为 byte[]
|
||||
byte[] binaryData = json.getBytes(StandardCharsets.UTF_8);
|
||||
// 创建自定义消息
|
||||
V2TIMMessage v2TIMMessage = V2TIMManager.getMessageManager().createCustomMessage(binaryData);
|
||||
// 发送消息
|
||||
V2TIMManager.getMessageManager().sendMessage(v2TIMMessage, null, "room" + roomInfoResp.getRoom_info().getRoom_id(), V2TIMMessage.V2TIM_PRIORITY_NORMAL, false, null, new V2TIMSendCallback<V2TIMMessage>() {
|
||||
@Override
|
||||
public void onProgress(int progress) {
|
||||
// 自定义消息不会回调进度
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(V2TIMMessage message) {
|
||||
// 发送群聊自定义消息成功
|
||||
EventBus.getDefault().post(new RoomTaskEvent());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
// 发送群聊自定义消息失败
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void sendChatEmoji(EmotionDeatils emotionDeatils) {
|
||||
EmotionDeatils event = new EmotionDeatils();
|
||||
if (emotionDeatils != null && emotionDeatils.getChildren() != null && !emotionDeatils.getChildren().isEmpty() && emotionDeatils.getChildren().size() > 0) {
|
||||
int position = new Random().nextInt(emotionDeatils.getChildren().size());
|
||||
Children children = emotionDeatils.getChildren().get(position);
|
||||
event.setImage(children.getImage());
|
||||
event.setAnimate_image(emotionDeatils.getAnimate_image());
|
||||
} else {
|
||||
event = emotionDeatils;
|
||||
}
|
||||
RoomMessageEvent roomMessageEvent = new RoomMessageEvent();
|
||||
roomMessageEvent.setRoomId(roomId);
|
||||
roomMessageEvent.setMsgType(2);//这是表情类型,1:单发文本消息 2:单发表情消息
|
||||
UserInfo userInfo = SpUtil.getUserInfo();
|
||||
RoomMessageEvent.T t = new RoomMessageEvent.T();
|
||||
t.setFromUserInfo(userInfo);
|
||||
t.setEmoji(event);
|
||||
roomMessageEvent.setText(t);
|
||||
handleRoomMessage(roomMessageEvent);
|
||||
String json = GsonUtils.toJson(roomMessageEvent);
|
||||
// 转换为 byte[]
|
||||
byte[] binaryData = json.getBytes(StandardCharsets.UTF_8);
|
||||
// 创建自定义消息
|
||||
V2TIMMessage v2TIMMessage = V2TIMManager.getMessageManager().createCustomMessage(binaryData);
|
||||
// 发送消息
|
||||
V2TIMManager.getMessageManager().sendMessage(v2TIMMessage, null, "room" + roomId, V2TIMMessage.V2TIM_PRIORITY_NORMAL, false, null, new V2TIMSendCallback<V2TIMMessage>() {
|
||||
@Override
|
||||
public void onProgress(int progress) {
|
||||
// 自定义消息不会回调进度
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(V2TIMMessage message) {
|
||||
// 发送群聊自定义消息成功
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String desc) {
|
||||
// 发送群聊自定义消息失败
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void handleRoomMessage(RoomMessageEvent message) {
|
||||
if (message == null) return;
|
||||
|
||||
if (easeChatAdapter == null) {
|
||||
easeChatAdapter = new EaseChatAdapter();
|
||||
}
|
||||
|
||||
if (message.getRoomId() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (roomId == null ||(!message.getRoomId().contains(roomId)&&message.getMsgType()!=125)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 使用Handler将消息处理放到消息队列中,避免阻塞
|
||||
if (messageHandler.hasMessages(MSG_HANDLE_ROOM_MESSAGE)) {
|
||||
// 如果队列中已有待处理消息,将当前消息加入队列
|
||||
Message msg = Message.obtain();
|
||||
msg.what = MSG_HANDLE_ROOM_MESSAGE;
|
||||
msg.obj = message;
|
||||
messageHandler.sendMessage(msg);
|
||||
} else {
|
||||
// 立即处理第一条消息
|
||||
processRoomMessage(message);
|
||||
// 标记有待处理消息
|
||||
messageHandler.sendEmptyMessageDelayed(MSG_HANDLE_ROOM_MESSAGE, 100);
|
||||
}
|
||||
}
|
||||
|
||||
private static final int MSG_HANDLE_ROOM_MESSAGE = 1001;
|
||||
private final Handler messageHandler = new Handler(Looper.getMainLooper()) {
|
||||
private List<RoomMessageEvent> messageQueue = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void handleMessage(@NonNull Message msg) {
|
||||
if (msg.what == MSG_HANDLE_ROOM_MESSAGE) {
|
||||
if (!messageQueue.isEmpty()) {
|
||||
// 批量处理消息
|
||||
processBatchMessages(messageQueue);
|
||||
messageQueue.clear();
|
||||
} else if (msg.obj instanceof RoomMessageEvent) {
|
||||
// 处理单条消息
|
||||
processRoomMessage((RoomMessageEvent) msg.obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private void processBatchMessages(List<RoomMessageEvent> messages) {
|
||||
if (messages.isEmpty() || easeChatAdapter == null) return;
|
||||
|
||||
List<EMMessageInfo> messageInfos = new ArrayList<>();
|
||||
for (RoomMessageEvent message : messages) {
|
||||
EMMessageInfo info = createMessageInfoIfNeeded(message);
|
||||
if (info != null) {
|
||||
messageInfos.add(info);
|
||||
}
|
||||
if (getActivity() instanceof RoomActivity) {
|
||||
((RoomActivity) getActivity()).roomInfoEvent(message);
|
||||
}
|
||||
}
|
||||
|
||||
if (!messageInfos.isEmpty()) {
|
||||
easeChatAdapter.addData(messageInfos);
|
||||
scrollToBottomIfNeed();
|
||||
}
|
||||
}
|
||||
|
||||
private void processRoomMessage(RoomMessageEvent message) {
|
||||
if (message == null) return;
|
||||
|
||||
int msgType = message.getMsgType();
|
||||
RoomMessageEvent.T text = message.getText();
|
||||
|
||||
switch (msgType) {
|
||||
case 1001:
|
||||
if (text != null) {
|
||||
RoomJoinMountModel roomJoinMountModel = new RoomJoinMountModel(
|
||||
message.getRoomId(), text.getJia_jia(), 2);
|
||||
EventBus.getDefault().post(roomJoinMountModel);
|
||||
}
|
||||
postAndAddMessage(message);
|
||||
break;
|
||||
case 123:
|
||||
easeChatAdapter.clearData();
|
||||
postAndAddMessage(message);
|
||||
break;
|
||||
case 1002:
|
||||
case 1012:
|
||||
case 1011:
|
||||
case 1014:
|
||||
case 1013:
|
||||
case 1026:
|
||||
case 1015:
|
||||
case 1021:
|
||||
case 1034:
|
||||
case 1035:
|
||||
case 1050:
|
||||
case 1054:
|
||||
case 1051:
|
||||
case 1052:
|
||||
case 1053:
|
||||
case 1055:
|
||||
case 1056:
|
||||
case 1057:
|
||||
case 1059:
|
||||
case 1060:
|
||||
case 1061:
|
||||
case 1025:
|
||||
case 1058:
|
||||
case 125:
|
||||
if (getActivity() instanceof RoomActivity) {
|
||||
((RoomActivity) getActivity()).roomInfoEvent(message);
|
||||
}
|
||||
break;
|
||||
|
||||
case 124:
|
||||
if (text != null && text.getText() != null) {
|
||||
try {
|
||||
RoomMessageEvent.text parsedText = GsonUtils.fromJson(
|
||||
text.getText(), RoomMessageEvent.text.class);
|
||||
if (parsedText != null) {
|
||||
MusicPlayBean musicPlayBean = new MusicPlayBean();
|
||||
musicPlayBean.setPosition(parsedText.getPosition());
|
||||
EventBus.getDefault().post(musicPlayBean);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("解析音乐播放消息失败", e);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 1007:
|
||||
case 1018:
|
||||
case 1006:
|
||||
case 1017:
|
||||
case 1016:
|
||||
if (text != null && text.getFromUserInfo() != null &&
|
||||
text.getFromUserInfo().getUser_id() == SpUtil.getUserId()) {
|
||||
EMMessageInfo info = new EMMessageInfo(message);
|
||||
easeChatAdapter.addData(info);
|
||||
scrollToBottomIfNeed();
|
||||
}
|
||||
if (getActivity() instanceof RoomActivity) {
|
||||
((RoomActivity) getActivity()).roomInfoEvent(message);
|
||||
}
|
||||
break;
|
||||
|
||||
case 1003:
|
||||
case 1004:
|
||||
case 1000:
|
||||
case 1:
|
||||
case 2:
|
||||
case 1030:
|
||||
case 1033:
|
||||
case 1032:
|
||||
case 1039:
|
||||
postAndAddMessage(message);
|
||||
break;
|
||||
|
||||
case 1038:
|
||||
addSingleMessage(message);
|
||||
break;
|
||||
|
||||
case 1049:
|
||||
postAndAddMessage(message);
|
||||
break;
|
||||
|
||||
case 1005:
|
||||
if (getActivity() instanceof RoomActivity) {
|
||||
((RoomActivity) getActivity()).roomInfoEvent(message);
|
||||
}
|
||||
if (text != null && text.getText() != null) {
|
||||
addSingleMessage(message);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (getActivity() instanceof RoomActivity) {
|
||||
((RoomActivity) getActivity()).roomInfoEvent(message);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private EMMessageInfo createMessageInfoIfNeeded(RoomMessageEvent message) {
|
||||
int msgType = message.getMsgType();
|
||||
RoomMessageEvent.T text = message.getText();
|
||||
if (text.getIs_pk()!=null&&text.getIs_pk().equals("1")){
|
||||
return null;
|
||||
}
|
||||
|
||||
switch (msgType) {
|
||||
case 1001:
|
||||
case 1002:
|
||||
case 123:
|
||||
case 1003:
|
||||
case 1004:
|
||||
case 1000:
|
||||
case 1:
|
||||
case 2:
|
||||
case 1030:
|
||||
case 1033:
|
||||
case 1032:
|
||||
case 1039:
|
||||
case 1049:
|
||||
return new EMMessageInfo(message);
|
||||
|
||||
case 1005:
|
||||
if (text.getText() != null) {
|
||||
return new EMMessageInfo(message);
|
||||
}
|
||||
break;
|
||||
|
||||
case 1038:
|
||||
return new EMMessageInfo(message);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void addSingleMessage(RoomMessageEvent message) {
|
||||
if (message.getText().getIs_pk()!=null&&message.getText().getIs_pk().equals("1")){
|
||||
return;
|
||||
}
|
||||
if (easeChatAdapter != null) {
|
||||
if (message.getMsgType() == 1049) {
|
||||
if (message.getText().getStep() != 3) {
|
||||
easeChatAdapter.addData(new EMMessageInfo(message));
|
||||
scrollToBottomIfNeed();
|
||||
}
|
||||
} else {
|
||||
easeChatAdapter.addData(new EMMessageInfo(message));
|
||||
scrollToBottomIfNeed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void postAndAddMessage(RoomMessageEvent message) {
|
||||
if (getActivity() instanceof RoomActivity) {
|
||||
((RoomActivity) getActivity()).roomInfoEvent(message);
|
||||
}
|
||||
addSingleMessage(message);
|
||||
}
|
||||
|
||||
|
||||
// 优化 scrollToBottomIfNeed 方法
|
||||
private void scrollToBottomIfNeed() {
|
||||
if (isBottom && easeChatAdapter != null) {
|
||||
int itemCount = easeChatAdapter.getItemCount();
|
||||
if (itemCount > 0) {
|
||||
mBinding.recycleViewPublic.scrollToPosition(itemCount - 1);
|
||||
}
|
||||
} else {
|
||||
count++;
|
||||
mBinding.tvCount.setText(count + "条新消息");
|
||||
mBinding.tvCount.setVisibility(View.VISIBLE);
|
||||
|
||||
// 当未读消息过多时,限制数量显示
|
||||
if (count > 99) {
|
||||
mBinding.tvCount.setText("99+条新消息");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void roomJoinMount(RoomSettingEvent roomSetting) {
|
||||
if (roomSetting == null) {
|
||||
easeChatAdapter.clearData();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 房间信息
|
||||
*
|
||||
* @param resp
|
||||
*/
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void roomInfo(RoomInfoResp resp) {
|
||||
this.roomInfoResp = resp;
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,194 @@
|
||||
package com.xscm.modulemain.activity.room.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.adapter.HotAdapter;
|
||||
import com.xscm.modulemain.activity.room.contacts.HotListContacts;
|
||||
import com.xscm.modulemain.databinding.FragmentHotListBinding;
|
||||
import com.xscm.modulemain.activity.room.presenter.HotListPresenter;
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
|
||||
import com.xscm.modulemain.manager.RoomManager;
|
||||
import com.xscm.moduleutil.base.BaseMvpFragment;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.bean.HomeBean;
|
||||
import com.xscm.moduleutil.bean.TopRoom;
|
||||
import com.xscm.moduleutil.bean.room.RoomInfoResp;
|
||||
import com.xscm.moduleutil.listener.MessageListenerSingleton;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.utils.ClickUtils;
|
||||
import com.xscm.moduleutil.utils.TimeUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class HotListFragment extends BaseMvpFragment<HotListPresenter, FragmentHotListBinding> implements HotListContacts.View {
|
||||
private String label_id;
|
||||
private HotAdapter mAdapter;
|
||||
private String tag;
|
||||
private int page;
|
||||
|
||||
private VoiceCategoryFragment voiceCategoryFragment;
|
||||
public HotListFragment(){}
|
||||
public HotListFragment(VoiceCategoryFragment voiceCategoryFragment){
|
||||
this.voiceCategoryFragment = voiceCategoryFragment;
|
||||
}
|
||||
public static HotListFragment newInstance(VoiceCategoryFragment voiceCategoryFragment, String type, String tag) {
|
||||
Bundle args = new Bundle();
|
||||
args.putString("label_id", type);
|
||||
args.putString("tag", tag);
|
||||
HotListFragment fragment = new HotListFragment(voiceCategoryFragment);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initArgs(Bundle arguments) {
|
||||
super.initArgs(arguments);
|
||||
label_id = arguments.getString("label_id");
|
||||
tag = arguments.getString("tag");
|
||||
page = 1; // 重置page
|
||||
}
|
||||
|
||||
@Override
|
||||
protected HotListPresenter bindPresenter() {
|
||||
return new HotListPresenter(this, getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
MvpPre.getRoomList(2, "1", "20", "1", label_id);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
if (tag.equals(VoiceCategoryFragment.TYPE_HOT)) {
|
||||
mBinding.tvHot.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mBinding.tvHot.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
mAdapter = new HotAdapter(null);
|
||||
// mAdapter.openLoadAnimation(BaseQuickAdapter.SCALEIN);
|
||||
mBinding.recycleView.setAdapter(mAdapter);
|
||||
GridLayoutManager gridLayoutManager = new GridLayoutManager(getActivity(), 2);
|
||||
gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
|
||||
@Override
|
||||
public int getSpanSize(int position) {
|
||||
switch (position) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
return 1;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
});
|
||||
mBinding.recycleView.setLayoutManager(gridLayoutManager);
|
||||
mBinding.smartRefreshLayout.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
|
||||
@Override
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
page++;
|
||||
MvpPre.getRoomList(2, page+"", "20", "1", label_id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
page = 1;
|
||||
mAdapter.setNewData(new ArrayList<>());
|
||||
MvpPre.getRoomList(2, page+"", "20", "1", label_id);
|
||||
}
|
||||
});
|
||||
|
||||
mAdapter.setOnRoomClickListener((room, position) -> {
|
||||
if ( ClickUtils.isFastDoubleClick()){
|
||||
return;
|
||||
}
|
||||
voiceCategoryFragment.showLoading();
|
||||
// 添加索引有效性检查
|
||||
if (position < 0 || position >= mAdapter.getData().size()) {
|
||||
return;
|
||||
}
|
||||
TopRoom item = mAdapter.getItem(position);
|
||||
if (item != null ) {
|
||||
RoomManager.getInstance().fetchRoomDataAndEnter(getActivity(), item.getRoom_id(), "",null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fragment_hot_list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void roomList(List<TopRoom> data, int type) {
|
||||
if (data != null && !data.isEmpty()) {
|
||||
if (page == 1) {
|
||||
mAdapter.setNewData(data); // 刷新时替换数据
|
||||
} else {
|
||||
// 检查是否有重复数据
|
||||
boolean hasDuplicate = false;
|
||||
List<TopRoom> currentData = mAdapter.getData();
|
||||
if (!currentData.isEmpty() && !data.isEmpty()) {
|
||||
// 检查第一条数据是否已经存在
|
||||
TopRoom firstNewData = data.get(0);
|
||||
for (TopRoom item : currentData) {
|
||||
if (item.getRoom_id().equals(firstNewData.getRoom_id())) {
|
||||
hasDuplicate = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasDuplicate) {
|
||||
mAdapter.addData(data); // 加载更多时添加数据
|
||||
}
|
||||
}
|
||||
} else if (page == 1) {
|
||||
// 如果是刷新且没有数据,清空列表
|
||||
mAdapter.setNewData(new ArrayList<>());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishRefreshLoadMore() {
|
||||
mBinding.smartRefreshLayout.finishRefresh();
|
||||
mBinding.smartRefreshLayout.finishLoadMore();
|
||||
CommonAppContext.getInstance().isRoomJoininj=false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMoreRoomList(List<HomeBean> data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void roomInfo(RoomInfoResp resp) {
|
||||
ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("form", "首页热门列表").withSerializable("roomInfo", resp).withString("roomId", resp.getRoom_info().getRoom_id()).navigation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showPasswordDialog() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterFail() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,253 @@
|
||||
package com.xscm.modulemain.activity.room.fragment;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.databinding.FragmentMuiscSongBinding;
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
|
||||
import com.xscm.modulemain.activity.room.contacts.RequestContacts;
|
||||
import com.xscm.modulemain.activity.room.presenter.RequestPresenter;
|
||||
import com.xscm.moduleutil.base.BaseMvpFragment;
|
||||
import com.xscm.moduleutil.bean.MusicSongBean;
|
||||
import com.xscm.moduleutil.bean.SongMusicBean;
|
||||
import com.xscm.moduleutil.bean.room.RoomInfoResp;
|
||||
import com.xscm.moduleutil.color.ThemeableDrawableUtils;
|
||||
import com.xscm.moduleutil.rtc.AgoraManager;
|
||||
import com.xscm.moduleutil.utils.ColorManager;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
import com.xscm.moduleutil.utils.TimeUtils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.agora.musiccontentcenter.Music;
|
||||
|
||||
/**
|
||||
* @author qx
|
||||
* @data 2025/6/19
|
||||
* @description: 点唱已点歌曲
|
||||
*/
|
||||
public class MusicSongListFragment extends BaseMvpFragment<RequestPresenter, FragmentMuiscSongBinding> implements RequestContacts.View {
|
||||
private String roomId;
|
||||
private RoomInfoResp roomInfoResp;
|
||||
BaseQuickAdapter<MusicSongBean, BaseViewHolder> adapter;
|
||||
private int page = 1;
|
||||
int status;
|
||||
|
||||
@Override
|
||||
public void songList(List<MusicSongBean> musicSongBeans) {
|
||||
|
||||
|
||||
if (roomInfoResp.getUser_info().getUser_id().equals(SpUtil.getUserId() + "") && roomInfoResp.getUser_info().getPit_number() == 9) {
|
||||
status = 1;
|
||||
}
|
||||
if (musicSongBeans != null) {
|
||||
for (MusicSongBean musicSongBean : musicSongBeans) {
|
||||
musicSongBean.setIs_hot(status);
|
||||
}
|
||||
}
|
||||
|
||||
// if (page==1){
|
||||
adapter.setNewData(musicSongBeans);
|
||||
|
||||
// }else {
|
||||
// adapter.addData(musicSongBeans);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void upSong(String S) {
|
||||
ToastUtils.showShort(S);
|
||||
MvpPre.songList(roomId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void song(List<SongMusicBean> music) {
|
||||
com.hjq.toast.ToastUtils.show("操作成功");
|
||||
}
|
||||
|
||||
public interface OnRequestFragmentListener {
|
||||
void onCloseDialog();
|
||||
}
|
||||
|
||||
private OnRequestFragmentListener listener;
|
||||
|
||||
// 绑定监听器
|
||||
public void setOnRequestFragmentListener(OnRequestFragmentListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public static MusicSongListFragment newInstance(String roomId, RoomInfoResp roomInfoResp, int type) {
|
||||
Bundle args = new Bundle();
|
||||
MusicSongListFragment fragment = new MusicSongListFragment();
|
||||
args.putString("roomId", roomId);
|
||||
args.putInt("type", type);
|
||||
args.putSerializable("roomInfoResp", roomInfoResp);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RequestPresenter bindPresenter() {
|
||||
return new RequestPresenter(this, getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
roomId = getArguments().getString("roomId");
|
||||
roomInfoResp = (RoomInfoResp) getArguments().getSerializable("roomInfoResp");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
boolean b = AgoraManager.getInstance(getContext()).isBjMusic();
|
||||
if (b) {
|
||||
List<MusicSongBean> musicSongBeans = new ArrayList<>();
|
||||
List<Music> music = AgoraManager.getInstance(getContext()).getMusicList();
|
||||
if (music != null && music.size() > 0) {
|
||||
for (int i = 0; i < music.size(); i++) {
|
||||
MusicSongBean musicSongBean = new MusicSongBean();
|
||||
musicSongBean.setSong_code(String.valueOf(music.get(i).getSongCode()));
|
||||
musicSongBean.setSong_name(music.get(i).getName());
|
||||
musicSongBean.setSinger(music.get(i).getSinger());
|
||||
musicSongBean.setPoster(music.get(i).getPoster());
|
||||
musicSongBean.setDuration(music.get(i).getDurationS() + "");
|
||||
musicSongBeans.add(musicSongBean);
|
||||
}
|
||||
adapter.setNewData(musicSongBeans);
|
||||
}
|
||||
} else {
|
||||
MvpPre.songList(roomId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
mBinding.smartRefreshLayout.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
|
||||
@Override
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
page++;
|
||||
MvpPre.songList(roomId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
page = 1;
|
||||
MvpPre.songList(roomId);
|
||||
}
|
||||
});
|
||||
|
||||
mBinding.recycleView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
|
||||
adapter = new BaseQuickAdapter<MusicSongBean, BaseViewHolder>(R.layout.item_song_list, null) {
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, MusicSongBean item) {
|
||||
|
||||
LogUtils.e("@@@", item);
|
||||
// 获取当前 item 的 position
|
||||
int position = helper.getLayoutPosition();
|
||||
ImageView muisSy = helper.getView(R.id.muis_sy);
|
||||
TextView muisPrice = helper.getView(R.id.muis_price);
|
||||
if (position == 0) {
|
||||
helper.setText(R.id.muis_price, "结束");
|
||||
|
||||
muisSy.setVisibility(View.GONE);
|
||||
} else if (position == 1) {
|
||||
|
||||
muisSy.setVisibility(View.GONE);
|
||||
muisPrice.setVisibility(View.GONE);
|
||||
} else {
|
||||
muisPrice.setVisibility(View.VISIBLE);
|
||||
helper.setText(R.id.muis_price, "置顶");
|
||||
muisSy.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
helper.setText(R.id.muis_name, item.getSong_name());
|
||||
if (item.getDuration().isEmpty()) {
|
||||
helper.setText(R.id.muis_desc, "00:00");
|
||||
} else {
|
||||
helper.setText(R.id.muis_desc, TimeUtils.formatDuration(Long.parseLong(item.getDuration()) * 1000));
|
||||
}
|
||||
helper.setText(R.id.muis_set, "\t" + item.getSinger());
|
||||
helper.setText(R.id.muis_nickname, item.getNickname());
|
||||
|
||||
ImageUtils.loadHeadCC(item.getPoster(), helper.getView(R.id.muis_avatar));
|
||||
|
||||
helper.getView(R.id.muis_price).setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
TextView textView = helper.getView(R.id.muis_price);
|
||||
if (textView.getText().toString().equals("置顶")) {
|
||||
MvpPre.upSong(item.getDid(), "2");
|
||||
} else {
|
||||
|
||||
}
|
||||
if (listener != null) {
|
||||
listener.onCloseDialog(); // 触发关闭 DialogFragment
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
helper.getView(R.id.muis_sy).setOnClickListener(v -> MvpPre.upSong(item.getDid(), "1"));
|
||||
|
||||
if (item.getIs_hot() == 1) {
|
||||
helper.setVisible(R.id.muis_sy, true);
|
||||
helper.setVisible(R.id.muis_price, true);
|
||||
} else {
|
||||
helper.setVisible(R.id.muis_sy, false);
|
||||
helper.setVisible(R.id.muis_price, false);
|
||||
}
|
||||
|
||||
TextView muis_price=helper.getView(R.id.muis_price);
|
||||
ThemeableDrawableUtils.setThemeableRoundedBackground(muis_price, ColorManager.getInstance().getPrimaryColorInt(), 34);
|
||||
muis_price.setTextColor(ColorManager.getInstance().getButtonColorInt());
|
||||
}
|
||||
};
|
||||
mBinding.recycleView.setAdapter(adapter);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fragment_muisc_song;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,261 @@
|
||||
package com.xscm.modulemain.activity.room.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.adapter.RankingCharmListAdapter;
|
||||
import com.xscm.modulemain.databinding.RoomRankingChildBinding;
|
||||
import com.xscm.modulemain.dialog.RoomUserInfoFragment;
|
||||
import com.xscm.modulemain.activity.room.contacts.DataListContacts;
|
||||
import com.xscm.modulemain.activity.room.presenter.DataListPresenter;
|
||||
import com.xscm.moduleutil.base.BaseMvpFragment;
|
||||
import com.xscm.moduleutil.bean.CharmRankingResp;
|
||||
import com.xscm.moduleutil.bean.room.RoomInfoResp;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
import com.xscm.moduleutil.utils.StringUtil;
|
||||
import com.xscm.moduleutil.widget.CommonEmptyView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author qx
|
||||
* @data 2025/6/10
|
||||
* @description:
|
||||
*/
|
||||
public class RankingChildFragment extends BaseMvpFragment<DataListPresenter, RoomRankingChildBinding> implements DataListContacts.View {
|
||||
|
||||
private static final String TAG = "RankingChildFragment";
|
||||
|
||||
public static final int TYPE_DATA = 1;//日榜
|
||||
private String roomId;
|
||||
private int dataType;
|
||||
private int rankType = 1;
|
||||
private RankingCharmListAdapter cAdapter;//魅力适配器
|
||||
private RankingCharmListAdapter wAdapter;//财富适配器
|
||||
private CommonEmptyView commonEmptyView;
|
||||
private RoomInfoResp roomInfoResp;
|
||||
|
||||
/**
|
||||
* newInstance 初始化fragment
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static RankingChildFragment newInstance(String roomId, int dataType, int rankType, RoomInfoResp roomInfoResp) {
|
||||
RankingChildFragment rankingChildFragment = new RankingChildFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("roomId", roomId);
|
||||
bundle.putInt("dataType", dataType);
|
||||
bundle.putInt("rankType", rankType);
|
||||
bundle.putSerializable("roomInfoResp", roomInfoResp);
|
||||
rankingChildFragment.setArguments(bundle);
|
||||
return rankingChildFragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DataListPresenter bindPresenter() {
|
||||
return new DataListPresenter(this, getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initArgs(Bundle arguments) {
|
||||
super.initArgs(arguments);
|
||||
roomId = getArguments().getString("roomId");
|
||||
dataType = getArguments().getInt("dataType");
|
||||
rankType = getArguments().getInt("rankType");
|
||||
roomInfoResp = (RoomInfoResp) getArguments().getSerializable("roomInfoResp");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
if (rankType == 1) {
|
||||
cAdapter = new RankingCharmListAdapter();
|
||||
mBinding.rankRecycleView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
mBinding.rankRecycleView.setAdapter(cAdapter);
|
||||
cAdapter.bindToRecyclerView(mBinding.rankRecycleView);
|
||||
MvpPre.getCharmListInfo(roomId, rankType + "", dataType + "", "1", "20");
|
||||
} else {
|
||||
wAdapter = new RankingCharmListAdapter();
|
||||
mBinding.rankRecycleView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
mBinding.rankRecycleView.setAdapter(wAdapter);
|
||||
wAdapter.bindToRecyclerView(mBinding.rankRecycleView);
|
||||
MvpPre.getWealthListInfo(roomId, rankType + "", dataType + "", "1", "20");
|
||||
}
|
||||
// onRefreshEvent(null);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
commonEmptyView = new CommonEmptyView(getContext());
|
||||
commonEmptyView.setEmptyText("暂无上榜");
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化监听
|
||||
*/
|
||||
@Override
|
||||
protected void initListener() {
|
||||
super.initListener();
|
||||
if (rankType == 1) {
|
||||
cAdapter.setOnItemChildClickListener((adapter, view, position) -> {
|
||||
if (view.getId() == R.id.room_item_head) {
|
||||
CharmRankingResp item = cAdapter.getItem(position);
|
||||
RoomUserInfoFragment.show(roomId,item.getUser_id(), "", getHostUser(), true, 3, 0, getChildFragmentManager());
|
||||
}
|
||||
});
|
||||
} else {
|
||||
wAdapter.setOnItemChildClickListener((adapter, view, position) -> {
|
||||
if (view.getId() == R.id.room_item_head) {
|
||||
CharmRankingResp item = wAdapter.getItem(position);
|
||||
RoomUserInfoFragment.show(roomId,item.getUser_id(), "", getHostUser(), true, 3, 0, getChildFragmentManager());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 这是判断当前用户是否是麦上房主、管理员、主持,不在主持麦的都是不同用户
|
||||
* 2025-7-31 10:42:37,新添加的要求:根据角色不同,显示不同的按钮
|
||||
* 房主不论麦上麦下,有全部权限 管理员、主持:不论麦上麦下,有部分权限 用户:只有举报拉黑权限
|
||||
* 所有的是从下往上看数据的时候,只有举报和拉黑
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private int getHostUser() {
|
||||
if (roomInfoResp.getUser_info().getPit_number() == 9) {
|
||||
if (roomInfoResp.getUser_info().getIs_room_owner() == 1) {
|
||||
return 1;
|
||||
} else if (roomInfoResp.getUser_info().getIs_management() == 1) {
|
||||
return 2;
|
||||
} else if (roomInfoResp.getUser_info().getIs_host() == 1) {
|
||||
return 3;
|
||||
} else {
|
||||
return 4;
|
||||
}
|
||||
} else {
|
||||
if (roomInfoResp.getUser_info().getIs_room_owner() == 1) {
|
||||
return 1;
|
||||
}
|
||||
if (roomInfoResp.getUser_info().getIs_management() == 1) {
|
||||
return 2;
|
||||
}
|
||||
if (roomInfoResp.getUser_info().getIs_host() == 1) {
|
||||
return 3;
|
||||
}
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
Log.d(TAG, "(Start)启动了===========================RankingChildFragment");
|
||||
return R.layout.room_ranking_child;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setNo1(CharmRankingResp listsBean) {
|
||||
ImageUtils.loadHeadCC(listsBean.getAvatar(), mBinding.roomRankTop1HeadIcon);
|
||||
mBinding.roomTop1Name.setText(listsBean.getNickname());
|
||||
mBinding.roomHeadTop1Label.setText(StringUtil.toWan2(listsBean.getTotal(), 2));
|
||||
setview(listsBean.getIcon(), mBinding.llVip1);
|
||||
mBinding.roomRankTop1HeadIcon.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
RoomUserInfoFragment.show(roomId,listsBean.getUser_id(), "", getHostUser(), false, 3, 0, getChildFragmentManager());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNo2(CharmRankingResp listsBean) {
|
||||
ImageUtils.loadHeadCC(listsBean.getAvatar(), mBinding.roomRankTop2HeadIcon);
|
||||
mBinding.roomTop2Name.setText(listsBean.getNickname());
|
||||
mBinding.roomHeadTop2Label.setText(StringUtil.toWan2(listsBean.getTotal(), 2));
|
||||
setview(listsBean.getIcon(), mBinding.llVip2);
|
||||
mBinding.roomRankTop2HeadIcon.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
RoomUserInfoFragment.show(roomId,listsBean.getUser_id(), "", getHostUser(), false, 3, 0, getChildFragmentManager());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setview(List<String> item, LinearLayout llContainer) {
|
||||
List<String> images = item; // 获取图片列表
|
||||
|
||||
for (String url : images) {
|
||||
if (url.contains("http")) {
|
||||
ImageView imageView1 = new ImageView(getContext());
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
||||
getContext().getResources().getDimensionPixelSize(com.xscm.moduleutil.R.dimen.dp_57),
|
||||
getContext().getResources().getDimensionPixelSize(com.xscm.moduleutil.R.dimen.dp_15)
|
||||
);
|
||||
params.setMargins(0, 0, getContext().getResources().getDimensionPixelSize(com.xscm.moduleutil.R.dimen.dp_5), 0); // 右边距
|
||||
imageView1.setLayoutParams(params);
|
||||
imageView1.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||||
|
||||
// 使用 Glide 加载图片
|
||||
ImageUtils.loadHeadCC(url, imageView1);
|
||||
|
||||
llContainer.addView(imageView1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNo3(CharmRankingResp listsBean) {
|
||||
ImageUtils.loadHeadCC(listsBean.getAvatar(), mBinding.roomRankTop3HeadIcon);
|
||||
mBinding.roomTop3Name.setText(listsBean.getNickname());
|
||||
mBinding.roomHeadTop3Label.setText(StringUtil.toWan2(listsBean.getTotal(), 2));
|
||||
setview(listsBean.getIcon(), mBinding.llVip3);
|
||||
mBinding.roomRankTop3HeadIcon.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
RoomUserInfoFragment.show(roomId,listsBean.getUser_id(), "", getHostUser(), false, 3, 0, getChildFragmentManager());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCharmEmpty(List<CharmRankingResp> list) {
|
||||
if (list != null) {
|
||||
if (cAdapter==null){
|
||||
wAdapter.setNewData(list);
|
||||
}else {
|
||||
cAdapter.setNewData(list);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWealthEmpty(List<CharmRankingResp> list) {
|
||||
if (list != null){
|
||||
wAdapter.setNewData(list);
|
||||
}else {
|
||||
wAdapter.setEmptyView(commonEmptyView);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.xscm.modulemain.activity.room.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.databinding.RoomRankingParentBinding;
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.adapter.MyFragmentPagerAdapter;
|
||||
import com.xscm.moduleutil.base.BaseMvpFragment;
|
||||
import com.xscm.moduleutil.bean.room.RoomInfoResp;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/6/10
|
||||
*@description:
|
||||
*/
|
||||
public class RankingParentFragment extends BaseMvpFragment<IPresenter, RoomRankingParentBinding> {
|
||||
|
||||
//成员变量 + 全局变量
|
||||
public static final int TYPE_DATA = 1;//日榜
|
||||
public static final int TYPE_WEEK = 2;//周榜
|
||||
public static final int TYPE_MON = 3;//月榜
|
||||
private static String mRoomId;//房间ID
|
||||
private static int rankType = 1;//统计类型(魅力 / 财富)
|
||||
private RoomInfoResp roomInfoResp;
|
||||
|
||||
public static RankingParentFragment newInstance(String roomId,int rankType,RoomInfoResp roomInfoResp) {
|
||||
Bundle args = new Bundle();
|
||||
args.putString("roomId", roomId);
|
||||
args.putInt("rankType", rankType);
|
||||
args.putSerializable("roomInfoResp", roomInfoResp);
|
||||
RankingParentFragment fragment = new RankingParentFragment();
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initArgs(Bundle arguments) {
|
||||
super.initArgs(arguments);
|
||||
mRoomId = arguments.getString("roomId");
|
||||
rankType = arguments.getInt("rankType");
|
||||
roomInfoResp = (RoomInfoResp) arguments.getSerializable("roomInfoResp");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IPresenter bindPresenter() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
List<Fragment> fragments = new ArrayList<>();
|
||||
fragments.add(RankingChildFragment.newInstance(mRoomId, TYPE_DATA, rankType, roomInfoResp));
|
||||
fragments.add(RankingChildFragment.newInstance(mRoomId, TYPE_WEEK, rankType, roomInfoResp));
|
||||
fragments.add(RankingChildFragment.newInstance(mRoomId, TYPE_MON, rankType, roomInfoResp));
|
||||
MyFragmentPagerAdapter myFragmentPagerAdapter = new MyFragmentPagerAdapter(fragments, getChildFragmentManager());
|
||||
mBinding.vpRankChild.setAdapter(myFragmentPagerAdapter);
|
||||
String[] title = new String[]{"日榜", "周榜", "月榜"};
|
||||
mBinding.slidingTabLayout.setViewPager(mBinding.vpRankChild, title);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.room_ranking_parent;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,342 @@
|
||||
package com.xscm.modulemain.activity.room.fragment;
|
||||
|
||||
import static com.xscm.moduleutil.enumType.RedEnvelopeStatus.QXRedBagDrawTypeCollect;
|
||||
import static com.xscm.moduleutil.enumType.RedEnvelopeStatus.QXRedBagDrawTypeOpen;
|
||||
import static com.xscm.moduleutil.enumType.RedEnvelopeStatus.QXRedBagDrawTypePwdSend;
|
||||
import static com.xscm.moduleutil.enumType.RedEnvelopeStatus.QXRedBagDrawTypeTimeDown;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.os.CountDownTimer;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.blankj.utilcode.util.ScreenUtils;
|
||||
import com.blankj.utilcode.util.TimeUtils;
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.activity.room.activity.RoomActivity;
|
||||
import com.xscm.modulemain.databinding.FragmentRedEnvelopesBinding;
|
||||
import com.xscm.moduleutil.bean.RedPackGrab;
|
||||
import com.xscm.moduleutil.bean.RedPacketInfo;
|
||||
import com.xscm.moduleutil.bean.UserInfo;
|
||||
import com.xscm.moduleutil.enumType.RedEnvelopeStatus;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.http.RetrofitClient;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
import com.xscm.moduleutil.view.QXRedBagSendView;
|
||||
import com.xscm.moduleutil.widget.dialog.BaseDialog;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
/**
|
||||
* @author xscm
|
||||
* @ClassName RedEnvelopesFragment
|
||||
* @Description 抢红包的dialog
|
||||
* @Date 2021/12/28 10:09
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class RedEnvelopesFragment extends BaseDialog<FragmentRedEnvelopesBinding> {
|
||||
private RedEnvelopeStatus drawType;
|
||||
public RedPacketInfo mRedPacketInfo;
|
||||
public boolean isCollectedRoom;//是否收藏房间
|
||||
|
||||
public long needTime;// 倒计时
|
||||
public boolean isFromToComment;//是否是发送评论地方过来
|
||||
|
||||
private CountDownTimer countDownTimer;
|
||||
private Context mContext;
|
||||
|
||||
public RedEnvelopesFragment(@NonNull @NotNull Context context) {
|
||||
super(context, com.xscm.moduleutil.R.style.BaseDialogStyleH);
|
||||
mContext=context;
|
||||
}
|
||||
|
||||
//是否收藏方法
|
||||
public void setIsCollectedRoom(boolean isCollectedRoom) {
|
||||
this.isCollectedRoom = isCollectedRoom;
|
||||
}
|
||||
|
||||
public void setFromToComment(boolean isFromToComment) {
|
||||
this.isFromToComment = isFromToComment;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
setCancelable(false);
|
||||
setCanceledOnTouchOutside(false);
|
||||
Window window = getWindow();
|
||||
window.setLayout((int) (ScreenUtils.getScreenWidth() * 0.8), WindowManager.LayoutParams.WRAP_CONTENT);
|
||||
mBinding.imRedClose.setOnClickListener(v -> {
|
||||
QXRedBagSendView redBagView = new QXRedBagSendView(getContext());
|
||||
redBagView.showInView((ViewGroup) getWindow().getDecorView());
|
||||
dismiss();
|
||||
});
|
||||
|
||||
|
||||
mBinding.imRedK.setOnClickListener(v -> {
|
||||
RetrofitClient.getInstance().grab(mRedPacketInfo.getRedpacket_id(), new BaseObserver<RedPackGrab>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(@NotNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NotNull RedPackGrab redPackGrab) {
|
||||
if (redPackGrab.getCode() == 1) {
|
||||
mRedPacketInfo.setIs_qiang(1);
|
||||
ARouter.getInstance().build(ARouteConstants.ROOM_RED_RESULT).withString("redpacketId", mRedPacketInfo.getRedpacket_id()).navigation();
|
||||
dismiss();
|
||||
} else if (redPackGrab.getCode() == 2) {
|
||||
ToastUtils.showShort("您已经抢过红包了");
|
||||
ARouter.getInstance().build(ARouteConstants.ROOM_RED_RESULT).withString("redpacketId", mRedPacketInfo.getRedpacket_id()).navigation();
|
||||
dismiss();
|
||||
} else {
|
||||
snatched();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
mBinding.tvCk.setOnClickListener(v -> ARouter.getInstance().build(ARouteConstants.ROOM_RED_RESULT).withString("redpacketId", mRedPacketInfo.getRedpacket_id()).navigation());
|
||||
mBinding.textPl.setOnClickListener(v -> {
|
||||
if (drawType == RedEnvelopeStatus.QXRedBagDrawTypeCollect){
|
||||
RetrofitClient.getInstance().followRoom(mRedPacketInfo.getRoom_id()+"","1", new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(@NotNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NotNull String s) {
|
||||
if (mContext instanceof RoomActivity) {
|
||||
((RoomActivity) mContext).setUserInfo();
|
||||
}
|
||||
|
||||
if (mRedPacketInfo.canOpenNow()){
|
||||
setType(QXRedBagDrawTypeOpen);
|
||||
}else {
|
||||
setType(QXRedBagDrawTypeTimeDown);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}else if (drawType == RedEnvelopeStatus.QXRedBagDrawTypePwdSend){
|
||||
UserInfo userInfo = new UserInfo();
|
||||
userInfo.setRed_num(mRedPacketInfo.getPassword());
|
||||
EventBus.getDefault().post(userInfo);
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void snatched() {
|
||||
mBinding.tvRedCount.setText("手慢,没有抢到");
|
||||
mBinding.imRedK.setVisibility(View.GONE);
|
||||
mBinding.textPl.setVisibility(View.GONE);
|
||||
mBinding.tvTitle.setVisibility(View.GONE);
|
||||
mBinding.tvPinl.setVisibility(View.GONE);
|
||||
mBinding.tvKl.setVisibility(View.GONE);
|
||||
mBinding.tvCk.setVisibility(View.VISIBLE);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.fragment_red_envelopes;
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
public void setRedPacket(RedPacketInfo redPacketInfo) {
|
||||
this.mRedPacketInfo = redPacketInfo;
|
||||
setType(getDrawTypeWithRedpacktModel(redPacketInfo));
|
||||
if (redPacketInfo.getType() == 2) {
|
||||
mBinding.imKlB.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mBinding.imKlB.setVisibility(View.GONE);
|
||||
}
|
||||
ImageUtils.loadHeadCC(redPacketInfo.getAvatar(), mBinding.userAvatar);
|
||||
mBinding.tvUserName.setText(redPacketInfo.getNickname() + "的红包");
|
||||
mBinding.tvRedCount.setText(redPacketInfo.getRemark());
|
||||
if (drawType == RedEnvelopeStatus.QXRedBagDrawTypeOpen) {
|
||||
mBinding.clPwd.setVisibility(View.GONE);
|
||||
mBinding.textShare.setVisibility(View.GONE);
|
||||
} else {
|
||||
mBinding.clPwd.setVisibility(View.VISIBLE);
|
||||
mBinding.textShare.setVisibility(View.VISIBLE);
|
||||
if (redPacketInfo.getType() == 2) {
|
||||
mBinding.tvKl.setVisibility(View.VISIBLE);
|
||||
mBinding.imKlB.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mBinding.tvKl.setVisibility(View.GONE);
|
||||
mBinding.imKlB.setVisibility(View.GONE);
|
||||
}
|
||||
if (redPacketInfo.getConditions() == null || redPacketInfo.getConditions().equals("0")) {
|
||||
mBinding.clPwd.setVisibility(View.GONE);
|
||||
} else {
|
||||
mBinding.clPwd.setVisibility(View.VISIBLE);
|
||||
mBinding.tvKl.setVisibility(View.VISIBLE);
|
||||
if (redPacketInfo.getConditions().equals("1")) {
|
||||
mBinding.tvKl.setText("收藏房间");
|
||||
} else if (redPacketInfo.getConditions().equals("2")) {
|
||||
mBinding.tvKl.setText("仅麦上用户");
|
||||
} else {
|
||||
mBinding.tvKl.setText("收藏房间,进麦上用户");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
public void setNeedTime(long needTimes){
|
||||
this.needTime = needTimes;
|
||||
if (needTime > 0) {
|
||||
mBinding.textPl.setText(TimeUtils.millis2String(needTime*1000, "mm:ss")+"后开启红包");
|
||||
}
|
||||
}
|
||||
|
||||
private RedEnvelopeStatus getDrawTypeWithRedpacktModel(RedPacketInfo redPacketInfo) {
|
||||
if (redPacketInfo.getType() == 1) {//普通红包
|
||||
drawType = QXRedBagDrawTypeOpen;
|
||||
if (redPacketInfo.getCountdown() > 0) {
|
||||
if (redPacketInfo.remainingTime() > 0) {
|
||||
drawType = QXRedBagDrawTypeTimeDown;
|
||||
}
|
||||
}
|
||||
//收藏房间在先
|
||||
if (redPacketInfo.getConditions().contains("1") && !isCollectedRoom) {
|
||||
drawType = QXRedBagDrawTypeCollect;
|
||||
}
|
||||
} else {//口令红包
|
||||
drawType = QXRedBagDrawTypePwdSend;
|
||||
if (isFromToComment) {
|
||||
if (redPacketInfo.getConditions().contains("1") && !isCollectedRoom) {
|
||||
drawType = QXRedBagDrawTypeCollect;
|
||||
} else {
|
||||
if (redPacketInfo.canOpenNow()) {
|
||||
drawType = QXRedBagDrawTypeOpen;
|
||||
} else {
|
||||
drawType = QXRedBagDrawTypeTimeDown;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return drawType;
|
||||
}
|
||||
|
||||
private void setType(RedEnvelopeStatus type) {
|
||||
this.drawType = type;
|
||||
switch (type) {
|
||||
case QXRedBagDrawTypeOpen:
|
||||
handleReadyToOpen();
|
||||
break;
|
||||
case QXRedBagDrawTypeFinished:
|
||||
qXRedBagDrawTypeFinished();
|
||||
break;
|
||||
case QXRedBagDrawTypeCollect:
|
||||
qXRedBagDrawTypeCollect();
|
||||
break;
|
||||
case QXRedBagDrawTypeTimeDown:
|
||||
qXRedBagDrawTypeTimeDown();
|
||||
break;
|
||||
|
||||
case QXRedBagDrawTypePwdSend:
|
||||
qXRedBagDrawTypePwdSend();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void qXRedBagDrawTypePwdSend() {
|
||||
mBinding.imRedK.setVisibility(View.GONE);
|
||||
mBinding.tvRedCount.setText(mRedPacketInfo.getRemark());
|
||||
mBinding.tvCk.setVisibility(View.GONE);
|
||||
mBinding.textPl.setVisibility(View.VISIBLE);
|
||||
mBinding.textPl.setText(setValue(QXRedBagDrawTypePwdSend));
|
||||
|
||||
}
|
||||
|
||||
private void qXRedBagDrawTypeTimeDown() {
|
||||
mBinding.imRedK.setVisibility(View.GONE);
|
||||
mBinding.tvRedCount.setText(mRedPacketInfo.getRemark());
|
||||
mBinding.tvCk.setVisibility(View.GONE);
|
||||
mBinding.textPl.setVisibility(View.VISIBLE);
|
||||
mBinding.textPl.setText(setValue(QXRedBagDrawTypeTimeDown));
|
||||
}
|
||||
|
||||
private void qXRedBagDrawTypeCollect() {
|
||||
mBinding.imRedK.setVisibility(View.GONE);
|
||||
mBinding.tvRedCount.setText(mRedPacketInfo.getRemark());
|
||||
mBinding.tvCk.setVisibility(View.GONE);
|
||||
mBinding.textPl.setVisibility(View.VISIBLE);
|
||||
mBinding.textPl.setText(setValue(QXRedBagDrawTypeCollect));
|
||||
mBinding.textShare.setVisibility(View.VISIBLE);
|
||||
mBinding.clPwd.setVisibility(View.VISIBLE);
|
||||
mBinding.tvPinl.setVisibility(View.GONE);
|
||||
mBinding.tvKl.setVisibility(View.VISIBLE);
|
||||
mBinding.tvKl.setText("收藏房间");
|
||||
|
||||
}
|
||||
|
||||
private String setValue(RedEnvelopeStatus type) {
|
||||
switch (type) {
|
||||
|
||||
case QXRedBagDrawTypeCollect:
|
||||
return "收藏房间抢红包";
|
||||
case QXRedBagDrawTypeTimeDown:
|
||||
return "00:00后开启红包";
|
||||
case QXRedBagDrawTypePwdSend:
|
||||
return "发送评论抢红包";
|
||||
default:
|
||||
return "点击打开红包";
|
||||
}
|
||||
}
|
||||
|
||||
private void qXRedBagDrawTypeFinished() {
|
||||
mBinding.textPl.setVisibility(View.GONE);
|
||||
mBinding.tvTitle.setVisibility(View.GONE);
|
||||
mBinding.tvPinl.setVisibility(View.GONE);
|
||||
mBinding.tvKl.setVisibility(View.GONE);
|
||||
mBinding.tvCk.setVisibility(View.VISIBLE);
|
||||
mBinding.tvRedCount.setText("手慢了,红包被领完了");
|
||||
mBinding.imRedK.setVisibility(View.GONE);
|
||||
mBinding.clPwd.setVisibility(View.GONE);
|
||||
mBinding.textShare.setVisibility(View.GONE);
|
||||
}
|
||||
private void handleReadyToOpen() {
|
||||
mBinding.textPl.setVisibility(View.GONE);
|
||||
mBinding.tvTitle.setVisibility(View.GONE);
|
||||
mBinding.tvPinl.setVisibility(View.GONE);
|
||||
mBinding.tvKl.setVisibility(View.GONE);
|
||||
mBinding.imRedK.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
// 取消倒计时,避免内存泄漏
|
||||
if (countDownTimer != null) {
|
||||
countDownTimer.cancel();
|
||||
countDownTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void changeViewType(RedEnvelopeStatus type) {
|
||||
setType(type);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
package com.xscm.modulemain.activity.room.fragment;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.adapter.RelationshipAdapter;
|
||||
import com.xscm.modulemain.databinding.FragmentRelationshipBinding;
|
||||
import com.xscm.modulemain.activity.room.contacts.RoomUserContacts;
|
||||
import com.xscm.modulemain.activity.room.presenter.RoomUserPresenter;
|
||||
import com.xscm.moduleutil.base.BaseMvpDialogFragment;
|
||||
import com.xscm.moduleutil.bean.RelationCardBean;
|
||||
import com.xscm.moduleutil.bean.RelationshipBean;
|
||||
import com.xscm.moduleutil.bean.UserInfo;
|
||||
import com.xscm.moduleutil.dialog.ConfirmDialog;
|
||||
|
||||
/**
|
||||
* @author qx
|
||||
* @data 2025/6/13
|
||||
* @description: 关系卡和关系位的fragemnt
|
||||
*/
|
||||
public class RelationshipFragment extends BaseMvpDialogFragment<RoomUserPresenter, FragmentRelationshipBinding> implements RoomUserContacts.View {
|
||||
|
||||
RelationshipAdapter adapter;
|
||||
private String userId;
|
||||
private int type;
|
||||
|
||||
public static void show(String user_id, int type, FragmentManager fragmentManager) {
|
||||
RelationshipFragment dialogFragment = new RelationshipFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString("userId", user_id);
|
||||
args.putInt("type", type);
|
||||
dialogFragment.setArguments(args);
|
||||
dialogFragment.show(fragmentManager, "RelationshipFragment");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
userId = getArguments().getString("userId");
|
||||
type = getArguments().getInt("type");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDialogStyle(Window window) {
|
||||
super.initDialogStyle(window);
|
||||
window.setGravity(Gravity.BOTTOM);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RoomUserPresenter bindPresenter() {
|
||||
return new RoomUserPresenter(this, getContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
MvpPre.relationCard(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
mBinding.rvHostList.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
|
||||
adapter = new RelationshipAdapter();
|
||||
mBinding.rvHostList.setAdapter(adapter);
|
||||
adapter.setOnItemClickListener((RelationshipAdapter.OnItemClickListener) (view, data, position) -> {
|
||||
if (view.getId() == R.id.im_zhid) {
|
||||
queren(1, data.getId(), "");
|
||||
} else if (view.getId() == R.id.im_shanchu) {
|
||||
queren(2, data.getId(), data.getDelete_me_coin());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void queren(int type, int id, String num) {
|
||||
if (type == 1) {
|
||||
// 创建并显示确认对话框
|
||||
new ConfirmDialog(getActivity(),
|
||||
"提示",
|
||||
"您确定要置顶本关系吗?",
|
||||
"确认",
|
||||
"取消",
|
||||
v -> {
|
||||
// 点击“确认”按钮时执行删除操作
|
||||
MvpPre.topRelationCard(id + "");
|
||||
dismiss();
|
||||
},
|
||||
v -> {
|
||||
// 点击“取消”按钮时什么都不做
|
||||
}, false, 0).show();
|
||||
} else if (type == 2) {
|
||||
// 创建并显示确认对话框
|
||||
new ConfirmDialog(getActivity(),
|
||||
"提示",
|
||||
"您确定要删除本关系吗?解除关系需要" + num + "金币",
|
||||
"确认",
|
||||
"取消",
|
||||
v -> {
|
||||
// 点击“确认”按钮时执行删除操作
|
||||
MvpPre.deleteRelationCard(id + "");
|
||||
dismiss();
|
||||
},
|
||||
v -> {
|
||||
// 点击“取消”按钮时什么都不做
|
||||
}, false, 0).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fragment_relationship;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getRoomUserInfo(UserInfo userInfo) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downPit() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kickOutRoom() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postHostAdd(String s, String type, String is_add) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMutePit(String pitNumber, String is_mute) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBlackList() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void userGuanzSuccess(String s) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hostUserPit() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveCoin() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void relationCard(RelationCardBean list) {
|
||||
if (list !=null) {
|
||||
if (type == 1) {
|
||||
if (list != null && list.getQinmi() != null) {
|
||||
for (int i = 0; i < list.getQinmi().size(); i++) {
|
||||
list.getQinmi().get(i).setType(1);
|
||||
}
|
||||
adapter.setNewData(list.getQinmi());
|
||||
}
|
||||
} else if (type == 2) {
|
||||
if (list != null && list.getZhenai() != null) {
|
||||
for (int i = 0; i < list.getZhenai().size(); i++) {
|
||||
list.getZhenai().get(i).setType(2);
|
||||
}
|
||||
adapter.setNewData(list.getZhenai());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void topRelationCard(String s) {
|
||||
MvpPre.relationCard(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRelationCard(String s) {
|
||||
MvpPre.relationCard(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearUserCharm() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyPit() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
package com.xscm.modulemain.activity.room.fragment;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.databinding.FragmentRequestBinding;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
|
||||
import com.xscm.modulemain.activity.room.contacts.RequestContacts;
|
||||
import com.xscm.modulemain.activity.room.presenter.RequestPresenter;
|
||||
import com.xscm.moduleutil.base.BaseMvpFragment;
|
||||
import com.xscm.moduleutil.bean.MusicSongBean;
|
||||
import com.xscm.moduleutil.bean.SongMusicBean;
|
||||
import com.xscm.moduleutil.color.ThemeableDrawableUtils;
|
||||
import com.xscm.moduleutil.rtc.AgoraManager;
|
||||
import com.xscm.moduleutil.rtc.MusicBean;
|
||||
import com.xscm.moduleutil.utils.ColorManager;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
import com.xscm.moduleutil.utils.TimeUtils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.agora.musiccontentcenter.Music;
|
||||
|
||||
/**
|
||||
* @author qx
|
||||
* @data 2025/6/10
|
||||
* @description: 点唱viwPage的fragment
|
||||
*/
|
||||
public class RequestFragment extends BaseMvpFragment<RequestPresenter, FragmentRequestBinding> implements RequestContacts.View {
|
||||
|
||||
public static final int TYPE_DATA = 1;//点歌
|
||||
public static final int TYPE_WEEK = 2;//已点
|
||||
private String roomId;
|
||||
BaseQuickAdapter<Music, BaseViewHolder> adapter;
|
||||
private int page = 1;
|
||||
String input="";
|
||||
private int status;
|
||||
@Override
|
||||
public void songList(List<MusicSongBean> musicSongBeans) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upSong(String S) {
|
||||
ToastUtils.show(S);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void song(List<SongMusicBean> music) {
|
||||
ToastUtils.show("操作成功");
|
||||
}
|
||||
|
||||
public interface OnRequestFragmentListener {
|
||||
void onCloseDialog(Music musicSongBean);
|
||||
}
|
||||
|
||||
private OnRequestFragmentListener listener;
|
||||
|
||||
// 绑定监听器
|
||||
public void setOnRequestFragmentListener(OnRequestFragmentListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public static RequestFragment newInstance(String roomId, int type,int status) {
|
||||
Bundle args = new Bundle();
|
||||
RequestFragment fragment = new RequestFragment();
|
||||
args.putString("roomId", roomId);
|
||||
args.putInt("type", type);
|
||||
args.putInt("status", status);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RequestPresenter bindPresenter() {
|
||||
return new RequestPresenter(this, getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
roomId = getArguments().getString("roomId");
|
||||
status = getArguments().getInt("status");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
mBinding.editQuery.setText(SpUtil.getMusicName());
|
||||
|
||||
mBinding.editQuery.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
input = s.toString();
|
||||
SpUtil.setMusicName( input);
|
||||
AgoraManager.getInstance(getContext()).searchMusic(input, 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
mBinding.smartRefreshLayout.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
|
||||
@Override
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
page++;
|
||||
AgoraManager.getInstance(getContext()).searchMusic(mBinding.editQuery.getText().toString(), page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
page = 1;
|
||||
AgoraManager.getInstance(getContext()).searchMusic(mBinding.editQuery.getText().toString(), page);
|
||||
}
|
||||
});
|
||||
|
||||
mBinding.recycleView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
|
||||
adapter = new BaseQuickAdapter<Music, BaseViewHolder>(R.layout.item_reward, null) {
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, Music item) {
|
||||
LogUtils.e("@@@", item);
|
||||
helper.setText(R.id.muis_name, item.getName());
|
||||
helper.setText(R.id.muis_desc, TimeUtils.formatDuration(item.getReleaseTime().isEmpty() ? 0 : Long.parseLong(item.getReleaseTime())));
|
||||
helper.setText(R.id.muis_desc, "\t" + item.getSinger());
|
||||
ImageUtils.loadHeadCC(item.getPoster(), helper.getView(R.id.muis_avatar));
|
||||
|
||||
helper.getView(R.id.muis_price).setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (status==1) {
|
||||
MvpPre.song(roomId, SpUtil.getUserId() + "", item.getSongCode() + "", item.getName(), item.getSinger(), item.getPoster(), String.valueOf(item.getDurationS()));
|
||||
} else {
|
||||
if (AgoraManager.getInstance(getContext()).getMusicList()==null) {
|
||||
// AgoraManager.getInstance(getContext()).isPreload2(item.getSongCode(), 1);
|
||||
List<Music> music = new ArrayList<>();
|
||||
music.add(item);
|
||||
AgoraManager.getInstance(getContext()).setMusicList(music);
|
||||
EventBus.getDefault().post(item);
|
||||
AgoraManager.getInstance(getContext()).nextSong();
|
||||
} else {
|
||||
|
||||
List<Music> music = AgoraManager.getInstance(getContext()).getMusicList();
|
||||
music.add(item);
|
||||
AgoraManager.getInstance(getContext()).setMusicList(music);
|
||||
}
|
||||
|
||||
}
|
||||
ToastUtils.show("添加成功");
|
||||
}
|
||||
});
|
||||
TextView muis_price=helper.getView(R.id.muis_price);
|
||||
ThemeableDrawableUtils.setThemeableRoundedBackground(muis_price, ColorManager.getInstance().getPrimaryColorInt(), 34);
|
||||
muis_price.setTextColor(ColorManager.getInstance().getButtonColorInt());
|
||||
}
|
||||
};
|
||||
mBinding.recycleView.setAdapter(adapter);
|
||||
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onMusicSearchResultEvent(MusicBean music) {
|
||||
if (music.getMusicList() != null) {
|
||||
if (music.getPage() == 1) {
|
||||
adapter.setNewData(music.getMusicList());
|
||||
} else {
|
||||
adapter.addData(music.getMusicList());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fragment_request;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,321 @@
|
||||
package com.xscm.modulemain.activity.room.fragment;
|
||||
|
||||
import static android.app.Activity.RESULT_OK;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.databinding.RoomFragementDialogRoomBackgroundBinding;
|
||||
import com.luck.picture.lib.basic.PictureSelector;
|
||||
import com.luck.picture.lib.config.PictureConfig;
|
||||
import com.luck.picture.lib.entity.LocalMedia;
|
||||
import com.xscm.modulemain.activity.room.contacts.RoomBackgroundContacts;
|
||||
import com.xscm.modulemain.activity.room.presenter.RoomBackgroundPresenter;
|
||||
import com.xscm.moduleutil.base.BaseMvpDialogFragment;
|
||||
import com.xscm.moduleutil.bean.RoomBgBean;
|
||||
import com.xscm.moduleutil.dialog.ConfirmDialog;
|
||||
import com.xscm.moduleutil.utils.GlideEngine;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
import com.xscm.moduleutil.utils.PermissionDescriptionHelper;
|
||||
import com.xscm.moduleutil.widget.Constants;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/6/24
|
||||
*@description: 更换房间背景
|
||||
*/
|
||||
public class RoomBackgroundDialogFragment extends BaseMvpDialogFragment<RoomBackgroundPresenter, RoomFragementDialogRoomBackgroundBinding> implements RoomBackgroundContacts.View {
|
||||
|
||||
|
||||
private MyAdapter mAdapter;
|
||||
|
||||
private String roomId;
|
||||
private String picture;
|
||||
private boolean pictureChanged;
|
||||
private List<RoomBgBean.RoomBg> publicBgList = new ArrayList<>();
|
||||
private List<RoomBgBean.RoomBg> myBgList = new ArrayList<>();
|
||||
|
||||
|
||||
public static RoomBackgroundDialogFragment newInstance(String roomId) {
|
||||
RoomBackgroundDialogFragment fragment = new RoomBackgroundDialogFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("roomId", roomId);
|
||||
fragment.setArguments(bundle);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
mBinding.recyclerView.setLayoutManager(new GridLayoutManager(getContext(), 3));
|
||||
mAdapter = new MyAdapter();
|
||||
mBinding.recyclerView.setAdapter(mAdapter);
|
||||
|
||||
mAdapter.setOnItemClickListener(new MyAdapter.OnItemClickListener() {
|
||||
@Override
|
||||
public void onAddImageClick() {
|
||||
// 处理“添加图片”点击逻辑(例如打开相册)
|
||||
startChoosePhoto(1, PictureConfig.REQUEST_CAMERA, false, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackgroundClick(RoomBgBean.RoomBg item) {
|
||||
|
||||
queren1(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void queren1(RoomBgBean.RoomBg item) {
|
||||
// 创建并显示确认对话框
|
||||
new ConfirmDialog(getContext(),
|
||||
"温馨提示",
|
||||
"是否选择当前图片为背景图片",
|
||||
"确认",
|
||||
"取消",
|
||||
v -> {
|
||||
// 点击“确认”按钮时执行删除操作
|
||||
MvpPre.editRoom(roomId, "", "", "", item.getImage_url());
|
||||
|
||||
},
|
||||
v -> {
|
||||
// 点击“取消”按钮时什么都不做
|
||||
|
||||
},false,0).show();
|
||||
}
|
||||
|
||||
private void startChoosePhoto(int mimeType, int requestCode, boolean isVideo, int type) {
|
||||
PictureSelector.create(this)
|
||||
.openGallery(mimeType)
|
||||
.isGif(isVideo)
|
||||
.setImageEngine(GlideEngine.createGlideEngine())
|
||||
.setPermissionDescriptionListener(PermissionDescriptionHelper.createListener())
|
||||
.setMaxSelectNum(type)
|
||||
.isPreviewImage(true)
|
||||
.isDisplayCamera(false)
|
||||
.setOutputCameraDir(Constants.FILE_PATH)
|
||||
.isOriginalSkipCompress(true)
|
||||
.forResult(requestCode); //结果回调onActivityResult code
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (resultCode == RESULT_OK && data != null) {
|
||||
switch (requestCode) {
|
||||
|
||||
case PictureConfig.REQUEST_CAMERA:
|
||||
List<LocalMedia> localMediaList = PictureSelector.obtainSelectorList(data);
|
||||
|
||||
List<LocalMedia> localMedia1 = PictureSelector.obtainSelectorList(data);
|
||||
if (localMedia1 != null && localMedia1.size() != 0) {
|
||||
LocalMedia imgMedia = localMedia1.get(0);
|
||||
String url;
|
||||
if (imgMedia.isCompressed()) {
|
||||
url = imgMedia.getCompressPath();
|
||||
} else {
|
||||
url = imgMedia.getRealPath();
|
||||
}
|
||||
MvpPre.uploadFile(new File(url), 1, 1, 1);
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upLoadSuccess(String url, int type, int index, int total) {
|
||||
MvpPre.uploadBgImage("", url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadBgImage() {
|
||||
MvpPre.getBackgroundList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void editRoom() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
mBinding.tvTitle.setOnClickListener(this::onViewClicked);
|
||||
mBinding.tvTitle2.setOnClickListener(this::onViewClicked);
|
||||
// 设置默认样式(可选)
|
||||
resetBackgroundTextStyles();
|
||||
}
|
||||
|
||||
private void setTextViewStyle(TextView tv, String colorHex, int textSizeSp) {
|
||||
tv.setTextColor(Color.parseColor(colorHex));
|
||||
tv.setTextSize(textSizeSp);
|
||||
}
|
||||
|
||||
private void resetBackgroundTextStyles() {
|
||||
setTextViewStyle(mBinding.tvTitle, "#333333", 16);
|
||||
setTextViewStyle(mBinding.tvTitle2, "#999999", 12);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void initArgs(Bundle arguments) {
|
||||
super.initArgs(arguments);
|
||||
roomId = arguments.getString("roomId");
|
||||
picture = arguments.getString("picture");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
Window window = getDialog().getWindow();
|
||||
if (window != null) {
|
||||
// 设置固定高度为 500dp
|
||||
int screenHeight = getResources().getDisplayMetrics().heightPixels;
|
||||
int heightInDp = (int) (screenHeight * 0.6f);
|
||||
window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, heightInDp);
|
||||
|
||||
// 可选:设置动画样式(从底部弹出)
|
||||
window.setWindowAnimations(com.xscm.moduleutil.R.style.CommonShowDialogBottom);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDialogStyle(Window window) {
|
||||
super.initDialogStyle(window);
|
||||
window.setGravity(Gravity.BOTTOM);
|
||||
setCancelable(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.room_fragement_dialog_room_background;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RoomBackgroundPresenter bindPresenter() {
|
||||
return new RoomBackgroundPresenter(this, getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
pictureChanged = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetach() {
|
||||
if (!pictureChanged) {
|
||||
EventBus.getDefault().post(new RoomBgBean());
|
||||
}
|
||||
super.onDetach();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
MvpPre.getBackgroundList();
|
||||
}
|
||||
|
||||
|
||||
public void onViewClicked(View view) {
|
||||
if (view.getId() == R.id.tv_title2) {
|
||||
// 点击“我的背景”
|
||||
setTextViewStyle(mBinding.tvTitle2, "#333333", 16);
|
||||
setTextViewStyle(mBinding.tvTitle, "#999999", 12);
|
||||
List<RoomBgBean.RoomBg> listWithAddBtn = new ArrayList<>();
|
||||
RoomBgBean.RoomBg addBg = new RoomBgBean.RoomBg();
|
||||
addBg.setAddButton(true);
|
||||
addBg.setImage_url(null); // 可选:设为空图 URL
|
||||
|
||||
// 插入到顶部
|
||||
listWithAddBtn.add(addBg);
|
||||
listWithAddBtn.addAll(myBgList);
|
||||
mAdapter.setNewData(listWithAddBtn);
|
||||
} else if (view.getId() == R.id.tv_title) {
|
||||
// 点击“公共背景”
|
||||
setTextViewStyle(mBinding.tvTitle, "#333333", 16); // 当前项大字体、深色
|
||||
setTextViewStyle(mBinding.tvTitle2, "#999999", 12);
|
||||
mAdapter.setNewData(publicBgList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showLoadings(String content) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBackgroundList(RoomBgBean list) {
|
||||
publicBgList = list.getPublic_bg();
|
||||
myBgList = list.getPrivate_bg();
|
||||
|
||||
// 如果当前正在显示“我的背景”,则刷新 RecyclerView
|
||||
if (mBinding.tvTitle2.getCurrentTextColor() == Color.parseColor("#333333")) {
|
||||
List<RoomBgBean.RoomBg> listWithAddBtn = new ArrayList<>();
|
||||
RoomBgBean.RoomBg addBg = new RoomBgBean.RoomBg();
|
||||
addBg.setAddButton(true);
|
||||
listWithAddBtn.add(addBg);
|
||||
listWithAddBtn.addAll(myBgList);
|
||||
mAdapter.setNewData(listWithAddBtn); // 更新 adapter 数据并刷新
|
||||
}
|
||||
mAdapter.setNewData(publicBgList);
|
||||
}
|
||||
|
||||
private static class MyAdapter extends BaseQuickAdapter<RoomBgBean.RoomBg, BaseViewHolder> {
|
||||
public interface OnItemClickListener {
|
||||
void onAddImageClick(); // 点击“添加图片”按钮时触发
|
||||
void onBackgroundClick(RoomBgBean.RoomBg item); // 点击普通背景项时触发
|
||||
}
|
||||
private OnItemClickListener onItemClickListener;
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener listener) {
|
||||
this.onItemClickListener = listener;
|
||||
}
|
||||
MyAdapter() {
|
||||
super(R.layout.room_rv_item_room_bg);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, RoomBgBean.RoomBg item) {
|
||||
if (item.isAddButton()) {
|
||||
// “添加图片”按钮样式
|
||||
helper.setImageResource(R.id.iv_bg, com.xscm.moduleutil.R.mipmap.add_img); // 添加图片图标
|
||||
helper.itemView.setOnClickListener(v -> {
|
||||
if (onItemClickListener != null) {
|
||||
onItemClickListener.onAddImageClick();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 普通图片项
|
||||
ImageUtils.loadHeadCC(item.getImage_url(), helper.getView(R.id.iv_bg));
|
||||
helper.itemView.setOnClickListener(v -> {
|
||||
if (onItemClickListener != null) {
|
||||
onItemClickListener.onBackgroundClick(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,759 @@
|
||||
package com.xscm.modulemain.activity.room.fragment;
|
||||
|
||||
import static android.view.View.GONE;
|
||||
import static android.view.View.VISIBLE;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.CountDownTimer;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.core.app.NotificationManagerCompat;
|
||||
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.blankj.utilcode.util.TimeUtils;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.orhanobut.logger.Logger;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.activity.room.activity.RoomActivity;
|
||||
import com.xscm.modulemain.activity.room.contacts.RoomCabinContacts;
|
||||
import com.xscm.modulemain.activity.room.presenter.RoomCabinPresenter;
|
||||
import com.xscm.modulemain.databinding.RoomCabinFragmentBinding;
|
||||
import com.xscm.modulemain.dialog.ExitRoomBottomSheet;
|
||||
import com.xscm.modulemain.dialog.RoomGiftDialogFragment;
|
||||
import com.xscm.moduleutil.base.BaseRoomFragment;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.bean.RoomMessageEvent;
|
||||
import com.xscm.moduleutil.bean.UserInfo;
|
||||
import com.xscm.moduleutil.bean.room.RoomCpUserBean;
|
||||
import com.xscm.moduleutil.bean.room.RoomInfoResp;
|
||||
import com.xscm.moduleutil.bean.room.RoomPitBean;
|
||||
import com.xscm.moduleutil.event.CabinEvent;
|
||||
import com.xscm.moduleutil.listener.MessageListenerSingleton;
|
||||
import com.xscm.moduleutil.rtc.AgoraManager;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
import com.xscm.moduleutil.widget.dialog.CommonDialog;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Date;
|
||||
|
||||
import io.agora.rtc2.Constants;
|
||||
import io.agora.rtc2.IRtcEngineEventHandler;
|
||||
import io.agora.rtc2.RtcEngine;
|
||||
import io.agora.rtc2.RtcEngineEx;
|
||||
import io.agora.rtc2.video.VideoCanvas;
|
||||
|
||||
/**
|
||||
* @author qx
|
||||
* @data 2025/7/1
|
||||
* @description: 电影房
|
||||
*/
|
||||
public class RoomCabinFragment extends BaseRoomFragment<RoomCabinPresenter, RoomCabinFragmentBinding> implements RoomCabinContacts.View {
|
||||
private static final String LABEL_ID_MOVIE = "5";
|
||||
protected String roomId;
|
||||
protected String pitNumber;//当前点击的麦序
|
||||
protected CommonDialog commonDialog;
|
||||
CountDownTimer mCountDownTimer;
|
||||
private RoomInfoResp roomInfoResp;
|
||||
private int remainingTime;
|
||||
private boolean isShow = false;
|
||||
private RoomCpUserBean cpUserBean;
|
||||
private boolean isMicPlace = false;
|
||||
private RtcEngineEx engine;
|
||||
private String label_id="";
|
||||
|
||||
private int remoteUid = -1;
|
||||
|
||||
|
||||
public RoomCabinFragment(){}
|
||||
public RoomCabinFragment(RoomInfoResp roomInfoResp){
|
||||
this.roomInfoResp = roomInfoResp;
|
||||
}
|
||||
public static RoomCabinFragment newInstance(RoomInfoResp roomInfoResp) {
|
||||
Bundle args = new Bundle();
|
||||
RoomCabinFragment fragment = new RoomCabinFragment(roomInfoResp);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
if (CommonAppContext.getInstance().lable_id.equals("6") && CommonAppContext.getInstance().isMicPlace){
|
||||
joinChannel();
|
||||
isMicPlace = true;
|
||||
mBinding.im3.setImageResource(com.xscm.moduleutil.R.mipmap.clogs_car);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void enableNotifications() {
|
||||
if (NotificationManagerCompat.from(requireContext()).areNotificationsEnabled()) {
|
||||
Log.d("RoomCabinFragment", "Notifications enable!");
|
||||
return;
|
||||
}
|
||||
Log.d("RoomCabinFragment", "Notifications not enable!");
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setTitle("提示")
|
||||
.setMessage("请打开通知权限,防止后台共享屏幕中断")
|
||||
.setPositiveButton("设置", (dialog, which) -> {
|
||||
Intent intent = new Intent();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
intent.setAction(Settings.ACTION_APP_NOTIFICATION_SETTINGS);
|
||||
intent.putExtra(Settings.EXTRA_APP_PACKAGE, getActivity().getPackageName());
|
||||
intent.putExtra(Settings.EXTRA_CHANNEL_ID, getActivity().getApplicationInfo().uid);
|
||||
} else {
|
||||
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
}
|
||||
startActivity(intent);
|
||||
dialog.dismiss();
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RoomCabinPresenter bindPresenter() {
|
||||
return new RoomCabinPresenter(this, getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
if (roomInfoResp == null) return;
|
||||
|
||||
if (roomInfoResp != null) {
|
||||
roomId = roomInfoResp.getRoom_info().getRoom_id();
|
||||
cpUserBean = roomInfoResp.getCp_user();
|
||||
label_id = roomInfoResp.getRoom_info().getLabel_id();
|
||||
}
|
||||
if (roomInfoResp != null && roomInfoResp.getRoom_owner().getUser_id().equals(SpUtil.getUserId()+"")){
|
||||
mBinding.im3.setVisibility(VISIBLE);
|
||||
}else {
|
||||
mBinding.im3.setVisibility(GONE);
|
||||
}
|
||||
|
||||
mBinding.ivExit.setOnClickListener(this::onHeartLineClicked);
|
||||
|
||||
// 获取当前用户 ID
|
||||
String currentUserId = SpUtil.getUserId() + "";
|
||||
|
||||
// 定义两个 RoomPitBean 对象,分别用于显示在 roomMakeWheat1 和 roomMakeWheat2
|
||||
RoomPitBean selfBean = new RoomPitBean(); // 自己的 bean
|
||||
RoomPitBean otherBean = new RoomPitBean(); // 另一个用户的 bean
|
||||
|
||||
boolean isSelfFirst = false;
|
||||
|
||||
// 判断当前用户是 user_id 还是 user_id1
|
||||
if (cpUserBean != null) {
|
||||
if (currentUserId.equals(cpUserBean.getUser_id())) {
|
||||
// 当前用户是 user_id
|
||||
selfBean.setUser_id(cpUserBean.getUser_id());
|
||||
selfBean.setUser_code(cpUserBean.getUser_code());
|
||||
selfBean.setNickname(cpUserBean.getNickname());
|
||||
selfBean.setAvatar(cpUserBean.getAvatar());
|
||||
selfBean.setDress(cpUserBean.getDress());
|
||||
selfBean.setPit_number("000");
|
||||
|
||||
otherBean.setUser_id(cpUserBean.getUser_id1());
|
||||
otherBean.setUser_code(cpUserBean.getUser_code1());
|
||||
otherBean.setNickname(cpUserBean.getNickname1());
|
||||
otherBean.setAvatar(cpUserBean.getAvatar1());
|
||||
otherBean.setDress(cpUserBean.getDress1());
|
||||
otherBean.setPit_number("000");
|
||||
|
||||
|
||||
} else if (currentUserId.equals(cpUserBean.getUser_id1())) {
|
||||
// 当前用户是 user_id1,则交换位置
|
||||
selfBean.setUser_id(cpUserBean.getUser_id1());
|
||||
selfBean.setUser_code(cpUserBean.getUser_code1());
|
||||
selfBean.setNickname(cpUserBean.getNickname1());
|
||||
selfBean.setAvatar(cpUserBean.getAvatar1());
|
||||
selfBean.setDress(cpUserBean.getDress1());
|
||||
selfBean.setPit_number("000");
|
||||
|
||||
otherBean.setUser_id(cpUserBean.getUser_id());
|
||||
otherBean.setUser_code(cpUserBean.getUser_code());
|
||||
otherBean.setNickname(cpUserBean.getNickname());
|
||||
otherBean.setAvatar(cpUserBean.getAvatar());
|
||||
otherBean.setDress(cpUserBean.getDress());
|
||||
otherBean.setPit_number("000");
|
||||
}
|
||||
}
|
||||
// 不论谁是自己,始终将自己放在 roomMakeWheat1
|
||||
mBinding.roomMakeWheat1.setData(selfBean);
|
||||
// 将另一个用户的数据放在 roomMakeWheat2
|
||||
mBinding.roomMakeWheat2.setData(otherBean);
|
||||
mBinding.tvMainTitle.setText(roomInfoResp.getRoom_info().getRoom_name());
|
||||
mBinding.tvHeartValue2.setText(roomInfoResp.getRoom_info().getHot_value());
|
||||
if (cpUserBean != null) {
|
||||
countDownTime(Long.parseLong(cpUserBean.getTime_day()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
super.initView();
|
||||
|
||||
mBinding.im1.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (!isShow) {
|
||||
switchMic(2);
|
||||
isMute(1);
|
||||
} else {
|
||||
switchMic(1);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
mBinding.im2.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
RoomPitBean roomPitBean = mBinding.roomMakeWheat2.pitBean;
|
||||
UserInfo userInfo = new UserInfo();
|
||||
userInfo.setUser_id(Integer.parseInt(roomPitBean.getUser_id()!=null ? roomPitBean.getUser_id() : "0"));
|
||||
userInfo.setNickname(roomPitBean.getNickname());
|
||||
userInfo.setAvatar(roomPitBean.getAvatar());
|
||||
userInfo.setPit_number("");
|
||||
RoomGiftDialogFragment.show(null, userInfo, roomInfoResp.getRoom_info().getRoom_id(),0,"", getParentFragmentManager());
|
||||
|
||||
}
|
||||
});
|
||||
if (!CommonAppContext.getInstance().isShowAg){
|
||||
switchMic(2);
|
||||
}else {
|
||||
isShow = true;
|
||||
switchMic(2);
|
||||
}
|
||||
|
||||
mBinding.im3.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// requestScreenCapture();
|
||||
if (!isMicPlace) {
|
||||
joinChannel();
|
||||
isMicPlace = true;
|
||||
mBinding.im3.setImageResource(com.xscm.moduleutil.R.mipmap.clogs_car);
|
||||
CommonAppContext.getInstance().isMicPlace = true;
|
||||
} else {
|
||||
isMicPlace = false;
|
||||
ToastUtils.show("将停止屏幕共享");
|
||||
AgoraManager.getInstance(getActivity()).stopScreenCapture();
|
||||
mBinding.im3.setImageResource(com.xscm.moduleutil.R.mipmap.gongxiang);
|
||||
CommonAppContext.getInstance().isMicPlace = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (roomInfoResp != null && roomInfoResp.getRoom_owner().getUser_id().equals(SpUtil.getUserId()+"")){
|
||||
mBinding.im3.setVisibility(VISIBLE);
|
||||
}else {
|
||||
mBinding.im3.setVisibility(GONE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void handleMsgType1028(RoomMessageEvent messageEvent){
|
||||
if (messageEvent.getMsgType()==1028){
|
||||
mBinding.tvHeartValue2.setText(messageEvent.getText().getHot_value());
|
||||
}
|
||||
}
|
||||
|
||||
public void upCabinFragment(long time){
|
||||
countDownTime( time);
|
||||
}
|
||||
|
||||
public void switchMic(int type) {
|
||||
|
||||
if (type == 1) {
|
||||
mBinding.im1.setImageResource(com.xscm.moduleutil.R.mipmap.close_m);
|
||||
AgoraManager.getInstance(getActivity()).ClientRole(true);
|
||||
AgoraManager.getInstance(getActivity()).muteLocalAudioStream(false);
|
||||
AgoraManager.getInstance(getActivity()).setLocalAudioEnabled(true,SpUtil.getUserId()+"");
|
||||
isShow = false;
|
||||
CommonAppContext.getInstance().isShowAg=false;
|
||||
|
||||
} else {
|
||||
mBinding.im1.setImageResource(com.xscm.moduleutil.R.mipmap.op_m);
|
||||
AgoraManager.getInstance(getActivity()).ClientRole(true);
|
||||
AgoraManager.getInstance(getActivity()).muteLocalAudioStream(true);
|
||||
AgoraManager.getInstance(getActivity()).setLocalAudioEnabled(false,SpUtil.getUserId()+"");
|
||||
isShow = true;
|
||||
CommonAppContext.getInstance().isShowAg=true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void isMute(int is_mute) {
|
||||
RoomMessageEvent.text text = new RoomMessageEvent.text();
|
||||
text.setIs_mute(is_mute);
|
||||
String s = com.blankj.utilcode.util.GsonUtils.toJson(text);
|
||||
RoomMessageEvent.T t = new RoomMessageEvent.T();
|
||||
t.setFromUserInfo(SpUtil.getUserInfo());
|
||||
t.setText(s);
|
||||
RoomMessageEvent roomMessageEvent = new RoomMessageEvent(126, roomInfoResp.getRoom_info().getRoom_id(), t);
|
||||
String json = com.blankj.utilcode.util.GsonUtils.toJson(roomMessageEvent);
|
||||
// 转换为 byte[]
|
||||
byte[] binaryData = json.getBytes(StandardCharsets.UTF_8);
|
||||
// 创建自定义消息
|
||||
MessageListenerSingleton.getInstance().sendCustomRoomMessage(
|
||||
roomId + "",
|
||||
binaryData
|
||||
);
|
||||
}
|
||||
|
||||
public void roomInfoEvent(RoomMessageEvent messageEvent) {
|
||||
if (messageEvent.getMsgType() == 1028) {
|
||||
mBinding.tvHeartValue2.setText(messageEvent.getText().getHot_value());
|
||||
}
|
||||
}
|
||||
|
||||
private void onHeartLineClicked(View view) {
|
||||
if (view.getId() == R.id.iv_exit) {
|
||||
// EventBus.getDefault().post(new RoomOutEvent());
|
||||
// ARouter.getInstance().build(ARouteConstants.LIVE_ROOM).withString("form","首页热门列表").withString("roomId", item.getRoom_id()).navigation();
|
||||
ExitRoomBottomSheet bottomSheet = ExitRoomBottomSheet.newInstance(false,true,true);
|
||||
|
||||
bottomSheet.setOnOptionSelectedListener(new ExitRoomBottomSheet.OnOptionSelectedListener() {
|
||||
@Override
|
||||
public void onMinimize() {
|
||||
// 处理最小化逻辑,比如不销毁 Activity,仅移至后台
|
||||
// CommonAppContext.getInstance().isShow = false;
|
||||
// ARouter.getInstance().build(ARouteConstants.ME).navigation();//栈顶复用
|
||||
// if (getActivity() instanceof RoomActivity) {
|
||||
// ((RoomActivity) getActivity()).moveTaskToBack(true);
|
||||
// }
|
||||
|
||||
// 在Activity中
|
||||
// Intent serviceIntent = new Intent(getContext(), FloatingWindowService.class);
|
||||
|
||||
// 判断是否已有浮窗正在显示
|
||||
// if (!EasyFloat.isShow("testFloat")) {
|
||||
// // 启动前台服务以维持浮窗
|
||||
// Context context = requireContext();
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
// // Android 12+ 需要指定 foregroundServiceType
|
||||
// Intent serviceIntent = new Intent(context, FloatingWindowService.class);
|
||||
// serviceIntent.setAction("ACTION_START_FLOAT");
|
||||
// context.startForegroundService(serviceIntent);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExitRoom() {
|
||||
CommonAppContext.getInstance().isMicPlace = false;
|
||||
// 调用退出房间方法
|
||||
if (label_id!=null && label_id.equals(LABEL_ID_MOVIE)){
|
||||
MvpPre.quitRoom(roomId, SpUtil.getUserId() + "");
|
||||
// ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("from", "我的界面").withString("roomId", AgoraManager.getInstance(getActivity()).getLastRoomId()).navigation();
|
||||
return;
|
||||
}
|
||||
if (roomInfoResp != null) {
|
||||
MvpPre.quitRoom(roomInfoResp.getRoom_info().getRoom_id(), SpUtil.getUserId() + "");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
// 用户点击取消,不做任何事
|
||||
}
|
||||
});
|
||||
bottomSheet.show(getChildFragmentManager(), "ExitRoomBottomSheet");
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: 2025/3/12 倒计时
|
||||
public void countDownTime(long time) {
|
||||
try {
|
||||
if (time <= 0) {
|
||||
setTime(0);
|
||||
releaseCountDownTimer();
|
||||
return;
|
||||
}
|
||||
releaseCountDownTimer();
|
||||
// 获取当前时间的毫秒值
|
||||
long currentTime = System.currentTimeMillis() / 1000L;
|
||||
// 计算倒计时的总秒数
|
||||
long countDownTime = (time - currentTime);
|
||||
Logger.d("小黑屋", "countDownTime = " + countDownTime);
|
||||
if (countDownTime <= 0) {
|
||||
setTime(0);
|
||||
releaseCountDownTimer();
|
||||
return;
|
||||
}
|
||||
mCountDownTimer = new CountDownTimer(countDownTime * 1000L, 1000L) {
|
||||
@Override
|
||||
public void onTick(long millisUntilFinished) {
|
||||
int time1 = (int) (millisUntilFinished / 1000);
|
||||
// pitBean.setCount_down(time1);
|
||||
setTime(time1);
|
||||
remainingTime = time1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
setTime(0);
|
||||
remainingTime = 0;
|
||||
}
|
||||
};
|
||||
mCountDownTimer.start();
|
||||
} catch (Exception e) {
|
||||
Logger.e("countDownTime", e);
|
||||
}
|
||||
}
|
||||
|
||||
private String formatTime(int totalSeconds) {
|
||||
int days = totalSeconds / (24 * 3600);
|
||||
int remaining = totalSeconds % (24 * 3600);
|
||||
|
||||
int hours = remaining / 3600;
|
||||
remaining %= 3600;
|
||||
|
||||
int minutes = remaining / 60;
|
||||
int seconds = remaining % 60;
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
if (days > 0) {
|
||||
sb.append(days).append("天");
|
||||
}
|
||||
|
||||
if (hours > 0 || days > 0) {
|
||||
sb.append(hours).append("小时");
|
||||
}
|
||||
|
||||
if (minutes > 0 || hours > 0 || days > 0) {
|
||||
sb.append(minutes).append("分");
|
||||
}
|
||||
|
||||
sb.append(seconds).append("秒");
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("DefaultLocale")
|
||||
public void setTime(int time) {
|
||||
if (time == 0) {
|
||||
mBinding.datingTime.setText("00:00:00");
|
||||
}
|
||||
String formattedTime = formatTime(time);
|
||||
if (label_id!=null && label_id.equals(LABEL_ID_MOVIE)){
|
||||
mBinding.datingTime.setText("倒计时:" + formattedTime);
|
||||
}else {
|
||||
mBinding.datingTime.setText("到期时间:" + formattedTime);
|
||||
}
|
||||
mBinding.datingTime.setVisibility(VISIBLE);
|
||||
}
|
||||
|
||||
private void releaseCountDownTimer() {
|
||||
if (mCountDownTimer != null) {
|
||||
mCountDownTimer.cancel();
|
||||
mCountDownTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.room_cabin_fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void roomInfoUpdate(RoomInfoResp resp) {
|
||||
roomInfoResp = resp;
|
||||
// updateWheatData();
|
||||
|
||||
if (roomInfoResp != null) {
|
||||
roomId = roomInfoResp.getRoom_info().getRoom_id();
|
||||
cpUserBean = roomInfoResp.getCp_user();
|
||||
label_id = roomInfoResp.getRoom_info().getLabel_id();
|
||||
}
|
||||
if (roomInfoResp != null && roomInfoResp.getRoom_owner().getUser_id().equals(SpUtil.getUserId()+"")){
|
||||
mBinding.im3.setVisibility(VISIBLE);
|
||||
// setvkk(false);
|
||||
}else {
|
||||
mBinding.im3.setVisibility(GONE);
|
||||
}
|
||||
|
||||
mBinding.ivExit.setOnClickListener(this::onHeartLineClicked);
|
||||
|
||||
// 获取当前用户 ID
|
||||
String currentUserId = SpUtil.getUserId() + "";
|
||||
|
||||
// 定义两个 RoomPitBean 对象,分别用于显示在 roomMakeWheat1 和 roomMakeWheat2
|
||||
RoomPitBean selfBean = new RoomPitBean(); // 自己的 bean
|
||||
RoomPitBean otherBean = new RoomPitBean(); // 另一个用户的 bean
|
||||
|
||||
boolean isSelfFirst = false;
|
||||
|
||||
// 判断当前用户是 user_id 还是 user_id1
|
||||
if (cpUserBean != null) {
|
||||
if (currentUserId.equals(cpUserBean.getUser_id())) {
|
||||
// 当前用户是 user_id
|
||||
selfBean.setUser_id(cpUserBean.getUser_id());
|
||||
selfBean.setUser_code(cpUserBean.getUser_code());
|
||||
selfBean.setNickname(cpUserBean.getNickname());
|
||||
selfBean.setAvatar(cpUserBean.getAvatar());
|
||||
selfBean.setDress(cpUserBean.getDress());
|
||||
selfBean.setPit_number("000");
|
||||
|
||||
otherBean.setUser_id(cpUserBean.getUser_id1());
|
||||
otherBean.setUser_code(cpUserBean.getUser_code1());
|
||||
otherBean.setNickname(cpUserBean.getNickname1());
|
||||
otherBean.setAvatar(cpUserBean.getAvatar1());
|
||||
otherBean.setDress(cpUserBean.getDress1());
|
||||
otherBean.setPit_number("000");
|
||||
|
||||
|
||||
} else if (currentUserId.equals(cpUserBean.getUser_id1())) {
|
||||
// 当前用户是 user_id1,则交换位置
|
||||
selfBean.setUser_id(cpUserBean.getUser_id1());
|
||||
selfBean.setUser_code(cpUserBean.getUser_code1());
|
||||
selfBean.setNickname(cpUserBean.getNickname1());
|
||||
selfBean.setAvatar(cpUserBean.getAvatar1());
|
||||
selfBean.setDress(cpUserBean.getDress1());
|
||||
selfBean.setPit_number("000");
|
||||
|
||||
otherBean.setUser_id(cpUserBean.getUser_id());
|
||||
otherBean.setUser_code(cpUserBean.getUser_code());
|
||||
otherBean.setNickname(cpUserBean.getNickname());
|
||||
otherBean.setAvatar(cpUserBean.getAvatar());
|
||||
otherBean.setDress(cpUserBean.getDress());
|
||||
otherBean.setPit_number("000");
|
||||
}
|
||||
}
|
||||
// 不论谁是自己,始终将自己放在 roomMakeWheat1
|
||||
mBinding.roomMakeWheat1.setData(selfBean);
|
||||
// 将另一个用户的数据放在 roomMakeWheat2
|
||||
mBinding.roomMakeWheat2.setData(otherBean);
|
||||
mBinding.tvMainTitle.setText(roomInfoResp.getRoom_info().getRoom_name());
|
||||
mBinding.tvHeartValue2.setText(roomInfoResp.getRoom_info().getHot_value());
|
||||
if (cpUserBean != null) {
|
||||
countDownTime(Long.parseLong(cpUserBean.getTime_day()));
|
||||
}
|
||||
// mediaProjectionManager = (MediaProjectionManager) getContext().getSystemService(Context.MEDIA_PROJECTION_SERVICE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerWheatViews() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unRegisterWheatViews() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initListener() {
|
||||
super.initListener();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] collectCurrentCardiacValues() {
|
||||
int[] cvs = new int[8];
|
||||
return cvs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void quitRoom() {
|
||||
if (getActivity() instanceof RoomActivity) {
|
||||
LogUtils.e("lxj", "退出房间时间:" + TimeUtils.date2String(new Date())+":退出的roomId"+roomId);
|
||||
MessageListenerSingleton.getInstance().quitGroup(roomId);
|
||||
((RoomActivity) getActivity()).quit();
|
||||
((RoomActivity) getActivity()).quitRoom2(roomId);
|
||||
if (label_id!=null && label_id.equals(LABEL_ID_MOVIE)){
|
||||
((RoomActivity) getActivity()).jiaR();
|
||||
//// ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("from", "我的界面").withString("roomId", AgoraManager.getInstance(getActivity()).getLastRoomId()).navigation();
|
||||
return;
|
||||
}else {
|
||||
((RoomActivity) getActivity()).performExitRoom(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// private MediaProjection[] mediaProjection = new MediaProjection[1];
|
||||
// private MediaProjectionManager mediaProjectionManager;
|
||||
// private final ActivityResultLauncher<Intent> mediaProjectionLauncher = registerForActivityResult(
|
||||
// new ActivityResultContracts.StartActivityForResult(),
|
||||
// result -> {
|
||||
// if (result.getResultCode() == Activity.RESULT_OK) {
|
||||
// try {
|
||||
// mediaProjection[0] = mediaProjectionManager
|
||||
// .getMediaProjection(result.getResultCode(), result.getData());
|
||||
// joinChannel();
|
||||
// } catch (Exception e) {
|
||||
// Log.e("RoomCabinFragment", "error msg: " + e.getMessage());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// );
|
||||
|
||||
private void isConfig() {
|
||||
|
||||
enableNotifications();
|
||||
}
|
||||
|
||||
|
||||
private void joinChannel() {
|
||||
|
||||
AgoraManager.getInstance(getActivity()).updateChannelMediaOptions();
|
||||
AgoraManager.getInstance(getActivity()).post();
|
||||
}
|
||||
|
||||
/**
|
||||
* IRtcEngineEventHandler is an abstract class providing default implementation.
|
||||
* The SDK uses this class to report to the app on SDK runtime events.
|
||||
*/
|
||||
private final IRtcEngineEventHandler iRtcEngineEventHandler = new IRtcEngineEventHandler() {
|
||||
/**
|
||||
* Error code description can be found at:
|
||||
* en: https://api-ref.agora.io/en/video-sdk/android/4.x/API/class_irtcengineeventhandler.html#callback_irtcengineeventhandler_onerror
|
||||
* cn: https://docs.agora.io/cn/video-call-4.x/API%20Reference/java_ng/API/class_irtcengineeventhandler.html#callback_irtcengineeventhandler_onerror
|
||||
*/
|
||||
@Override
|
||||
public void onError(int err) {
|
||||
Log.e("RoomCabinFragment", String.format("onError code %d message %s", err, RtcEngine.getErrorDescription(err)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJoinChannelSuccess(String channel, int uid, int elapsed) {
|
||||
Log.i("RoomCabinFragment", String.format("onJoinChannelSuccess channel %s uid %d", channel, uid));
|
||||
}
|
||||
|
||||
/// 本地视频状态回调
|
||||
@Override
|
||||
public void onLocalVideoStateChanged(Constants.VideoSourceType source, int state, int error) {
|
||||
super.onLocalVideoStateChanged(source, state, error);
|
||||
Log.i("RoomCabinFragment", "onLocalVideoStateChanged source=" + source + ", state=" + state + ", error=" + error);
|
||||
if (source == Constants.VideoSourceType.VIDEO_SOURCE_SCREEN_PRIMARY) {
|
||||
if (state == Constants.LOCAL_VIDEO_STREAM_STATE_ENCODING) {
|
||||
if (error == Constants.ERR_OK) {
|
||||
Logger.d("onLocalVideoStateChanged", "Screen sharing start successfully.");
|
||||
}
|
||||
} else if (state == Constants.LOCAL_VIDEO_STREAM_STATE_FAILED) {
|
||||
if (error == Constants.ERR_SCREEN_CAPTURE_SYSTEM_NOT_SUPPORTED) {
|
||||
Logger.e("onLocalVideoStateChanged", "Screen sharing has been cancelled");
|
||||
} else {
|
||||
Logger.e("onLocalVideoStateChanged", "Screen sharing failed. Error code: " + error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///报告远端视频状态
|
||||
@Override
|
||||
public void onRemoteVideoStateChanged(int uid, int state, int reason, int elapsed) {
|
||||
super.onRemoteVideoStateChanged(uid, state, reason, elapsed);
|
||||
Log.i("RoomCabinFragment", "onRemoteVideoStateChanged:uid->" + uid + ", state->" + state);
|
||||
}
|
||||
|
||||
///远端视频统计
|
||||
@Override
|
||||
public void onRemoteVideoStats(RemoteVideoStats stats) {
|
||||
super.onRemoteVideoStats(stats);
|
||||
Log.d("RoomCabinFragment", "onRemoteVideoStats: width:" + stats.width + " x height:" + stats.height);
|
||||
}
|
||||
///加入频道
|
||||
@Override
|
||||
public void onUserJoined(int uid, int elapsed) {
|
||||
super.onUserJoined(uid, elapsed);
|
||||
Log.i("RoomCabinFragment", "onUserJoined->" + uid);
|
||||
if (remoteUid > 0) {
|
||||
return;
|
||||
}
|
||||
remoteUid = uid;
|
||||
requireActivity().runOnUiThread(() -> {
|
||||
SurfaceView renderView = new SurfaceView(getContext());
|
||||
engine.setupRemoteVideo(new VideoCanvas(renderView, Constants.RENDER_MODE_FIT, uid));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 当远程用户(通信)/主机(直播)离开频道时触发。
|
||||
* *@参数 uid 要更改音频状态的用户的ID。
|
||||
* @参数 reason 用户离线的原因:
|
||||
* 用户离线退出(0):用户离开了当前频道。USER OFFLINE DROPPED(1):SDK超时,用户在一定时间内未接收到数据包,因此被标记为离线状态。如果用户在通话中退出,且消息未传递到SDK(因为信道不可靠),SDK 将假定用户已离线。
|
||||
* 用户离线成为观众(仅限直播)。客户端角色从主持人变为观众。
|
||||
* @param uid
|
||||
* @param reason
|
||||
*/
|
||||
@Override
|
||||
public void onUserOffline(int uid, int reason) {
|
||||
Log.i("RoomCabinFragment", String.format("user %d offline! reason:%d", uid, reason));
|
||||
// showLongToast(String.format("user %d offline! reason:%d", uid, reason));
|
||||
if (remoteUid == uid) {
|
||||
remoteUid = -1;
|
||||
requireActivity().runOnUiThread(() -> {
|
||||
engine.setupRemoteVideo(new VideoCanvas(null, Constants.RENDER_MODE_FIT, uid));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocalAudioStats(LocalAudioStats stats) {
|
||||
super.onLocalAudioStats(stats);
|
||||
Log.d("RoomCabinFragment", "onLocalAudioStats: " + stats.numChannels + " x " + stats.sentSampleRate + " Hz");
|
||||
}
|
||||
|
||||
///报告远端视频流状态监护
|
||||
@Override
|
||||
public void onRemoteAudioStateChanged(int uid, int state, int reason, int elapsed) {
|
||||
super.onRemoteAudioStateChanged(uid, state, reason, elapsed);
|
||||
Log.i("RoomCabinFragment", "onRemoteAudioStateChanged: uid->" + uid + ", state->" + state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFirstRemoteAudioFrame(int uid, int elapsed) {
|
||||
super.onFirstRemoteAudioFrame(uid, elapsed);
|
||||
Log.i("RoomCabinFragment", "onFirstRemoteAudioFrame: uid->" + uid);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
@Subscribe (threadMode = ThreadMode.MAIN)
|
||||
public void roomInfoEvent(CabinEvent messageEvent) {
|
||||
if (messageEvent.isJoined()){
|
||||
if (CommonAppContext.getInstance().isMicPlace) {
|
||||
isMicPlace = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
releaseResources();
|
||||
}
|
||||
|
||||
public void releaseResources(){
|
||||
releaseCountDownTimer();
|
||||
// ImageUtils.clearDiskCache(getActivity());
|
||||
// if (mediaProjection[0] != null) {
|
||||
// mediaProjection[0].stop();
|
||||
// mediaProjection[0] = null;
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
package com.xscm.modulemain.activity.room.fragment;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.blankj.utilcode.util.FragmentUtils;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.databinding.FragmentRoomChartsBinding;
|
||||
import com.example.moduletablayout.listener.CustomTabEntity;
|
||||
import com.example.moduletablayout.listener.OnTabSelectListener;
|
||||
import com.xscm.modulemain.activity.room.contacts.RoomChartsContacts;
|
||||
import com.xscm.modulemain.activity.room.presenter.RoomChartsPresenter;
|
||||
import com.xscm.moduleutil.base.BaseMvpDialogFragment;
|
||||
import com.xscm.moduleutil.bean.room.RoomInfoResp;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/6/10
|
||||
*@description: 房间排行榜
|
||||
*/
|
||||
public class RoomChartsFragment extends BaseMvpDialogFragment<RoomChartsPresenter, FragmentRoomChartsBinding> implements RoomChartsContacts.View {
|
||||
private String mRoomId;
|
||||
public static final int TYPE_CHARM = 1;//财富榜
|
||||
public static final int TYPE_WEALTH = 2;//魅力榜
|
||||
private int type = TYPE_CHARM;
|
||||
private int childType = RankingChildFragment.TYPE_DATA;
|
||||
private RoomInfoResp mRoomInfoResp;
|
||||
|
||||
public static RoomChartsFragment newInstance(String roomId,RoomInfoResp roomInfoResp) {
|
||||
RoomChartsFragment roomRankingFragment = new RoomChartsFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("roomId", roomId);
|
||||
bundle.putSerializable("roomInfoResp", roomInfoResp);
|
||||
roomRankingFragment.setArguments(bundle);
|
||||
return roomRankingFragment;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected RoomChartsPresenter bindPresenter() {
|
||||
return new RoomChartsPresenter( this,getActivity());
|
||||
}
|
||||
@Override
|
||||
protected void initDialogStyle(Window window) {
|
||||
super.initDialogStyle(window);
|
||||
window.setGravity(Gravity.BOTTOM);
|
||||
WindowManager.LayoutParams lp = window.getAttributes();
|
||||
lp.dimAmount = 0.4f;
|
||||
int screenHeight = getResources().getDisplayMetrics().heightPixels;
|
||||
lp.height = (int) (screenHeight * 0.8f); // 80% 高度
|
||||
lp.width = WindowManager.LayoutParams.MATCH_PARENT; // 宽度撑满
|
||||
window.setAttributes(lp);
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
mRoomId = getArguments().getString("roomId");
|
||||
mRoomInfoResp = (RoomInfoResp) getArguments().getSerializable("roomInfoResp");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
|
||||
FragmentUtils.add(getChildFragmentManager(), RankingChildFragment.newInstance(mRoomId, childType, type, mRoomInfoResp), R.id.fl_content);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
mBinding.slidingTabLayout.setOnTabSelectListener(new OnTabSelectListener() {
|
||||
@Override
|
||||
public void onTabSelect(int position) {
|
||||
childType = ++position;
|
||||
refresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabReselect(int position) {
|
||||
|
||||
}
|
||||
});
|
||||
ArrayList<CustomTabEntity> tabItems = new ArrayList<>();
|
||||
tabItems.add(new TabItem("小时榜"));
|
||||
tabItems.add(new TabItem("日榜"));
|
||||
tabItems.add(new TabItem("周榜"));
|
||||
mBinding.slidingTabLayout.setTabData(tabItems);
|
||||
|
||||
mBinding.tvCharm.setOnClickListener(this::onViewClicked);
|
||||
mBinding.tvWealth.setOnClickListener(this::onViewClicked);
|
||||
}
|
||||
private void refresh() {
|
||||
FragmentUtils.replace(getChildFragmentManager(), RankingChildFragment.newInstance(mRoomId, childType, type, mRoomInfoResp), R.id.fl_content);
|
||||
}
|
||||
|
||||
public static class TabItem implements CustomTabEntity {
|
||||
private String title;
|
||||
|
||||
public TabItem(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTabTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTabSelectedIcon() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTabUnselectedIcon() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
public void onViewClicked(View view) {
|
||||
int id = view.getId();
|
||||
if (id == R.id.tv_charm) {
|
||||
type = TYPE_WEALTH;//魅力
|
||||
mBinding.tvCharm.setTextColor(getResources().getColor(com.xscm.moduleutil.R.color.white));
|
||||
mBinding.tvWealth.setTextColor(getResources().getColor(com.xscm.moduleutil.R.color.color_DADADA));
|
||||
mBinding.tvCharm.setTextSize(18);
|
||||
mBinding.tvWealth.setTextSize(16);
|
||||
} else {
|
||||
type = TYPE_CHARM;//财富
|
||||
mBinding.tvWealth.setTextColor(getResources().getColor(com.xscm.moduleutil.R.color.white));
|
||||
mBinding.tvCharm.setTextColor(getResources().getColor(com.xscm.moduleutil.R.color.color_DADADA));
|
||||
mBinding.tvWealth.setTextSize(18);
|
||||
mBinding.tvCharm.setTextSize(16);
|
||||
}
|
||||
refresh();
|
||||
}
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fragment_room_charts;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,67 @@
|
||||
package com.xscm.modulemain.activity.room.fragment;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.blankj.utilcode.util.ScreenUtils;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.moduleutil.widget.dialog.BaseDialog;
|
||||
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/6/10
|
||||
*@description: 房间公告展示
|
||||
*/
|
||||
public class RoomNoticeDialogFragment extends BaseDialog {
|
||||
private Context mContext;
|
||||
private TextView tvTile;
|
||||
private TextView tvContent;
|
||||
private ImageView ivClose;
|
||||
String title, content;
|
||||
|
||||
public RoomNoticeDialogFragment(@NonNull Context context) {
|
||||
super(context);
|
||||
this.mContext = context;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.fragment_room_notice_dialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
getWindow().setLayout((int) (ScreenUtils.getScreenWidth() * 0.86), ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
tvTile=findViewById(R.id.tv_title);
|
||||
tvContent=findViewById(R.id.tv_content);
|
||||
ivClose=findViewById(R.id.iv_close);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
|
||||
|
||||
ivClose.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
tvContent.setText(content);
|
||||
}
|
||||
public void setTitle(String title) {
|
||||
tvTile.setText(title);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package com.xscm.modulemain.activity.room.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import com.blankj.utilcode.util.ScreenUtils;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.databinding.RoomDialogRoomPwSettingBinding;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.xscm.modulemain.activity.room.contacts.RoomPasswordSetContacts;
|
||||
import com.xscm.modulemain.activity.room.presenter.RoomPasswordSetPresenter;
|
||||
import com.xscm.moduleutil.base.BaseMvpDialogFragment;
|
||||
import com.xscm.moduleutil.event.PasswordInputEvent;
|
||||
import com.xscm.moduleutil.event.RoomOutEvent;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/6/9
|
||||
*@description: 输入密码弹窗
|
||||
*/
|
||||
public class RoomPasswordSetDialogFragment extends BaseMvpDialogFragment<RoomPasswordSetPresenter, RoomDialogRoomPwSettingBinding> implements RoomPasswordSetContacts.View {
|
||||
|
||||
private static final String TAG = "RoomPasswordSetDialogFragment";
|
||||
|
||||
|
||||
private boolean hidePwd;
|
||||
private String roomId;
|
||||
|
||||
public static RoomPasswordSetDialogFragment newInstance(boolean hidePwd, String roomId) {
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean("hidePwd", hidePwd);
|
||||
args.putString("roomId", roomId);
|
||||
RoomPasswordSetDialogFragment fragment = new RoomPasswordSetDialogFragment();
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initArgs(Bundle arguments) {
|
||||
super.initArgs(arguments);
|
||||
this.hidePwd = arguments.getBoolean("hidePwd");
|
||||
this.roomId = arguments.getString("roomId");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.room_dialog_room_pw_setting;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
//是否隐藏密码
|
||||
if (hidePwd) {
|
||||
mBinding.txTitle.setText("请输入房间密码");
|
||||
mBinding.useHintTxt.setVisibility(View.INVISIBLE);
|
||||
mBinding.gpvPswView.setPasswordVisibility(false);
|
||||
} else {
|
||||
mBinding.txTitle.setText("请设置房间密码");
|
||||
mBinding.useHintTxt.setVisibility(View.VISIBLE);
|
||||
mBinding.gpvPswView.setPasswordVisibility(true);
|
||||
}
|
||||
mBinding.btPw.setOnClickListener(this::onViewClicked);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDialogStyle(Window window) {
|
||||
super.initDialogStyle(window);
|
||||
int width = (int) (ScreenUtils.getScreenWidth() * 341.0 / 375);
|
||||
window.setLayout(width, WindowManager.LayoutParams.WRAP_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RoomPasswordSetPresenter bindPresenter() {
|
||||
return new RoomPasswordSetPresenter(this, getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
if (hidePwd) {
|
||||
EventBus.getDefault().post(new RoomOutEvent());
|
||||
}
|
||||
}
|
||||
|
||||
public void onViewClicked(View view) {
|
||||
String passWord = mBinding.gpvPswView.getPassWord();
|
||||
if (passWord.length() != 4 && passWord.length() > 0) {
|
||||
ToastUtils.show("请输入完整的密码");
|
||||
return;
|
||||
}
|
||||
if (hidePwd) {
|
||||
EventBus.getDefault().post(new PasswordInputEvent(passWord));
|
||||
hidePwd = false;
|
||||
dismiss();
|
||||
} else {
|
||||
MvpPre.setRoomPassword(roomId, passWord);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void roomPasswordSettingSuccess() {
|
||||
ToastUtils.show("密码设置成功");
|
||||
dismiss();
|
||||
}
|
||||
|
||||
public void show(FragmentManager manager) {
|
||||
show(manager, TAG);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,401 @@
|
||||
package com.xscm.modulemain.activity.room.fragment;
|
||||
|
||||
import static android.view.View.GONE;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import com.google.android.material.tabs.TabLayoutMediator;
|
||||
import com.stx.xhb.xbanner.XBanner;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.activity.msg.OfficialNoticeActivity;
|
||||
import com.xscm.modulemain.activity.room.activity.PopularRoomActivity;
|
||||
import com.xscm.modulemain.activity.room.activity.RankingListActivity;
|
||||
import com.xscm.modulemain.activity.room.contacts.VoiceCategoryContacts;
|
||||
import com.xscm.modulemain.activity.room.presenter.VoiceCategoryPresenter;
|
||||
import com.xscm.modulemain.adapter.CarouselBannerAdapter;
|
||||
import com.xscm.modulemain.databinding.FragmentVoiceCategoryBinding;
|
||||
import com.xscm.modulemain.activity.WebViewActivity;
|
||||
import com.xscm.modulemain.manager.RoomManager;
|
||||
import com.xscm.moduleutil.base.BaseMvpFragment;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.bean.BannerModel;
|
||||
import com.xscm.moduleutil.bean.RoomTypeModel;
|
||||
import com.xscm.moduleutil.bean.TopRoom;
|
||||
import com.xscm.moduleutil.event.MqttBean;
|
||||
import com.xscm.moduleutil.event.RoomGiftRunable;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
import com.xscm.moduleutil.utils.logger.DataLogger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 声播
|
||||
*/
|
||||
public class VoiceCategoryFragment extends BaseMvpFragment<VoiceCategoryPresenter, FragmentVoiceCategoryBinding> implements VoiceCategoryContacts.View {
|
||||
|
||||
public static final String TYPE_ME = "-1";
|
||||
public static final String TYPE_RECOMMEND = "-2";
|
||||
public static final String TYPE_HOT = "-3";
|
||||
public static final String TYPE_ORDER = "-4";
|
||||
public static final String TYPE_INDEX = "index";
|
||||
|
||||
private List<TopRoom> roomList;
|
||||
|
||||
private List<MqttBean.ListBean> mqttList;
|
||||
private List<String> info;
|
||||
CarouselBannerAdapter carouselBannerAdapter;
|
||||
|
||||
private VoiceFragment voiceFragment;
|
||||
|
||||
public VoiceCategoryFragment () {
|
||||
}
|
||||
|
||||
|
||||
public VoiceCategoryFragment (VoiceFragment voiceFragment){
|
||||
this.voiceFragment = voiceFragment;
|
||||
}
|
||||
|
||||
public static VoiceCategoryFragment newInstance(VoiceFragment voiceFragment) {
|
||||
return new VoiceCategoryFragment(voiceFragment);
|
||||
}
|
||||
|
||||
public void showLoading(){
|
||||
voiceFragment.isShowLoading(true);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
return super.onCreateView(inflater, container, savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected VoiceCategoryPresenter bindPresenter() {
|
||||
return new VoiceCategoryPresenter(this, getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
MvpPre.getBanners();
|
||||
MvpPre.getCarousels(1, 1, "10", "2", "");//顶部推荐
|
||||
MvpPre.getCategories();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
|
||||
|
||||
mBinding.banner.loadImage(new XBanner.XBannerAdapter() {
|
||||
@Override
|
||||
public void loadBanner(XBanner banner, Object model, View view, int position) {
|
||||
BannerModel bannerModel = (BannerModel) model;
|
||||
ImageUtils.loadCenterCrop((String) bannerModel.getXBannerUrl(), (ImageView) view);
|
||||
}
|
||||
});
|
||||
mBinding.banner.setOnItemClickListener(new XBanner.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(XBanner banner, Object model, View view, int position) {
|
||||
/**
|
||||
* 1房间2文章3链接 其他详情图
|
||||
*
|
||||
* type=1时,该值表示房间id;type=2时,表示文章id
|
||||
*/
|
||||
BannerModel bannerModel = (BannerModel) model;
|
||||
Intent intent=new Intent(getActivity(), WebViewActivity.class);
|
||||
intent.putExtra("url", bannerModel.getUrl());
|
||||
intent.putExtra("title", "首页横幅");
|
||||
startActivity(intent);
|
||||
// ARouter.getInstance().build(ARouteConstants.H5).withString("url", bannerModel.getUrl()).withString("title", "首页横幅").navigation();
|
||||
}
|
||||
});
|
||||
DisplayMetrics displayMetrics = new DisplayMetrics();
|
||||
requireActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
|
||||
|
||||
carouselBannerAdapter = new CarouselBannerAdapter();
|
||||
mBinding.bannerViewPager
|
||||
.setAdapter(carouselBannerAdapter)
|
||||
.create();
|
||||
|
||||
mBinding.bannerViewPager.setIndicatorVisibility(GONE);
|
||||
mBinding.constraintLayout.setVisibility(GONE);
|
||||
|
||||
carouselBannerAdapter.setOnItemClickListener((view, data, position) -> {
|
||||
// 示例:跳转到房间 详情页
|
||||
if (data != null) {
|
||||
showLoading();
|
||||
RoomManager.getInstance().fetchRoomDataAndEnter(getActivity(), data.getRoom_id() ,"",null);
|
||||
}
|
||||
});
|
||||
|
||||
mBinding.tvWg.setOnClickListener(v -> {
|
||||
if (mBinding.marqueeView == null || mqttList == null || mqttList.isEmpty()) {
|
||||
// 可以选择在这里添加日志或提示
|
||||
// Log.w(TAG, "MarqueeView or mqttList is null/empty, cannot handle click.");
|
||||
return; // 直接返回,不执行后续操作
|
||||
}
|
||||
try {
|
||||
int position = mBinding.marqueeView.getPosition();
|
||||
// 检查 position 是否有效
|
||||
if (position < 0 || position >= mqttList.size()) {
|
||||
// Log.w(TAG, "Invalid position from MarqueeView: " + position);
|
||||
return; // 位置无效,直接返回
|
||||
}
|
||||
// 获取对应的 MqttBean.ListBean 对象
|
||||
MqttBean.ListBean item = mqttList.get(position);
|
||||
if (item != null) { // 再次检查 item 是否为 null
|
||||
String roomId = item.getRoom_id(); // 或者 item.getRoomId(); 确保方法名正确
|
||||
if (roomId != null && !roomId.isEmpty()) { // 检查 roomId 是否有效
|
||||
showLoading();
|
||||
RoomManager.getInstance().fetchRoomDataAndEnter(getActivity(), roomId,"",null);
|
||||
} else {
|
||||
// Log.d(TAG, "Room ID is null or empty for item at position: " + position);
|
||||
}
|
||||
} else {
|
||||
// Log.w(TAG, "Item at position " + position + " is null in mqttList.");
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
});
|
||||
|
||||
mBinding.homePhb.setOnClickListener(v -> {
|
||||
startActivity(new Intent(getContext(), RankingListActivity.class));
|
||||
});
|
||||
|
||||
mBinding.myHome.setOnClickListener(v -> {
|
||||
ARouter.getInstance().build(ARouteConstants.MY_ROOM).navigation();
|
||||
});
|
||||
|
||||
mBinding.homeGg.setOnClickListener(v -> {
|
||||
Intent intent=new Intent(getActivity(), OfficialNoticeActivity.class);
|
||||
intent.putExtra("type", "2");
|
||||
startActivity(intent);
|
||||
});
|
||||
|
||||
mBinding.imX.setOnClickListener(v -> {
|
||||
Intent intent=new Intent(getActivity(), PopularRoomActivity.class);
|
||||
startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
||||
public void onEvent1() {
|
||||
try {
|
||||
List<MqttBean> cachedMqttBeans = RoomGiftRunable.getMqttCache();
|
||||
if (cachedMqttBeans == null || cachedMqttBeans.isEmpty()) {
|
||||
mBinding.rl.setVisibility(GONE);
|
||||
} else {
|
||||
mBinding.rl.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if (mqttList == null) {
|
||||
mqttList = new ArrayList<>();
|
||||
info = new ArrayList<>();
|
||||
}
|
||||
mqttList.clear();
|
||||
info.clear();
|
||||
// 处理缓存数据
|
||||
|
||||
// 处理每一条 mqttBean 数据
|
||||
// for (MqttBean mqttBean : cachedMqttBeans) {
|
||||
// mqttList.addAll(mqttBean.getList());
|
||||
// info.add(mqttBean.getList().getFromUserName() + "送给" + mqttBean.getList().getToUserName() + "\n" + mqttBean.getList().getGiftName());
|
||||
//// info.add(mqttBean.getList().getFromUserName() + "送给" + mqttBean.getList().getToUserName() + "\n" + mqttBean.getList().getGiftName());
|
||||
// }
|
||||
|
||||
for (int i=0;i<cachedMqttBeans.size();i++){
|
||||
mqttList.addAll(cachedMqttBeans.get(i).getList());
|
||||
}
|
||||
for (int i=0;i<mqttList.size();i++){
|
||||
info.add(mqttList.get(i).getFromUserName() + "送给" + mqttList.get(i).getToUserName() + "\n" + mqttList.get(i).getGiftName());
|
||||
}
|
||||
|
||||
|
||||
mBinding.marqueeView.startWithList(info);
|
||||
} catch (Exception e) {
|
||||
DataLogger.LogUtil.d("onEvent1");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fragment_voice_category;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
onEvent1();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCategories(List<RoomTypeModel> list) {
|
||||
// // 数据有效性检查
|
||||
if (list == null || list.isEmpty() || getActivity() == null) {
|
||||
try {
|
||||
ToastUtils.showLong("登录已过期,请重新登录");
|
||||
CommonAppContext.getInstance().clearLoginInfo();
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 创建适配器
|
||||
MyFragmentPagerAdapter adapter = new MyFragmentPagerAdapter(getActivity(), list);
|
||||
mBinding.viewPager.setAdapter(adapter);
|
||||
|
||||
// 设置 TabLayout 与 ViewPager2 的关联
|
||||
new TabLayoutMediator(mBinding.slidingTabLayout, mBinding.viewPager,
|
||||
(tab, position) -> {
|
||||
// 边界检查
|
||||
if (position >= 0 && position < list.size() && list.get(position) != null) {
|
||||
// 创建自定义布局
|
||||
View customView = LayoutInflater.from(requireContext())
|
||||
.inflate(R.layout.custom_tab_layout, null);
|
||||
TextView textView = customView.findViewById(R.id.tab_text);
|
||||
textView.setText(list.get(position).getLabel_name());
|
||||
|
||||
// 设置初始状态
|
||||
if (position == 0) {
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
|
||||
textView.setTextColor(getResources().getColor(android.R.color.white));
|
||||
// customView.setBackgroundResource(com.xscm.moduleutil.R.drawable.tab_indicator);
|
||||
} else {
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
|
||||
textView.setTextColor(Color.parseColor("#F1ECFF"));
|
||||
// customView.setBackgroundResource(com.xscm.moduleutil.R.drawable.tab_unselected_background);
|
||||
}
|
||||
|
||||
tab.setCustomView(customView);
|
||||
}
|
||||
}
|
||||
).attach();
|
||||
|
||||
mBinding.slidingTabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
||||
@Override
|
||||
public void onTabSelected(TabLayout.Tab tab) {
|
||||
int position = tab.getPosition();
|
||||
// 边界检查
|
||||
if (position >= 0 && position < list.size()) {
|
||||
View customView = tab.getCustomView();
|
||||
if (customView != null) {
|
||||
TextView textView = customView.findViewById(R.id.tab_text);
|
||||
if (textView != null) {
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
|
||||
textView.setTextColor(getResources().getColor(android.R.color.white));
|
||||
}
|
||||
// customView.setBackgroundResource(com.xscm.moduleutil.R.drawable.tab_indicator);
|
||||
}
|
||||
|
||||
RoomTypeModel roomTypeModel = list.get(position);
|
||||
String categoryId = roomTypeModel.getId();
|
||||
HotListFragment.newInstance(VoiceCategoryFragment.this,categoryId, TYPE_INDEX);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabUnselected(TabLayout.Tab tab) {
|
||||
// 直接通过 TabLayout 设置未选中状态的文字大小
|
||||
View customView = tab.getCustomView();
|
||||
if (customView != null) {
|
||||
TextView textView = customView.findViewById(R.id.tab_text);
|
||||
if (textView != null) {
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
|
||||
textView.setTextColor(Color.parseColor("#F1ECFF"));
|
||||
}
|
||||
customView.setBackgroundResource(com.xscm.moduleutil.R.drawable.tab_unselected_background);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabReselected(TabLayout.Tab tab) {
|
||||
}
|
||||
});
|
||||
|
||||
// 设置默认选中的标签
|
||||
if (mBinding.slidingTabLayout.getTabCount() > 0) {
|
||||
mBinding.slidingTabLayout.selectTab(mBinding.slidingTabLayout.getTabAt(0));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBanners(List<BannerModel> bannerModels) {
|
||||
mBinding.banner.setBannerData(R.layout.index_image_banner, bannerModels);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setRoomId(String roomId) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTopRoom(List<TopRoom> topRooms, int type) {
|
||||
// if (topRooms == null || topRooms.isEmpty() || topRooms.size() < 1) {
|
||||
// mBinding.constraintLayout.setVisibility(View.GONE);
|
||||
// return;
|
||||
// }else {
|
||||
mBinding.constraintLayout.setVisibility(View.VISIBLE);
|
||||
// }
|
||||
roomList = topRooms;
|
||||
mBinding.bannerViewPager.create(topRooms); // 刷新数据并启动自动播放
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishRefreshLoadMore() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
private class MyFragmentPagerAdapter extends FragmentStateAdapter {
|
||||
|
||||
private List<RoomTypeModel> list;
|
||||
|
||||
public MyFragmentPagerAdapter(@NonNull FragmentActivity fragmentActivity, List<RoomTypeModel> list) {
|
||||
super(fragmentActivity);
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment createFragment(int position) {
|
||||
RoomTypeModel roomTypeModel = list.get(position);
|
||||
String categoryId = roomTypeModel.getId();
|
||||
return HotListFragment.newInstance(VoiceCategoryFragment.this,categoryId, TYPE_INDEX);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
package com.xscm.modulemain.activity.room.fragment;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.xscm.modulemain.R;
|
||||
import com.xscm.modulemain.activity.room.activity.RankingListActivity;
|
||||
import com.xscm.modulemain.activity.room.activity.SearchActivity;
|
||||
import com.xscm.modulemain.activity.room.contacts.VoiceContacts;
|
||||
import com.xscm.modulemain.databinding.FragmentVoiceBinding;
|
||||
import com.xscm.modulemain.activity.room.presenter.VoicePresenter;
|
||||
import com.xscm.moduleutil.adapter.MyFragmentPagerAdapter;
|
||||
import com.xscm.moduleutil.base.BaseMvpFragment;
|
||||
import com.xscm.moduleutil.bean.ActivitiesPermission;
|
||||
import com.xscm.moduleutil.bean.FirstChargeGiftBean;
|
||||
import com.xscm.moduleutil.dialog.FirstChargeDialog;
|
||||
import com.xscm.moduleutil.dialog.RechargeDialogFragment;
|
||||
import com.xscm.modulemain.dialog.YouthModelDialog;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
|
||||
|
||||
public class VoiceFragment extends BaseMvpFragment<VoicePresenter, FragmentVoiceBinding> implements VoiceContacts.View {
|
||||
// private MyInfoResp mMyInfoResp;
|
||||
|
||||
public static VoiceFragment newInstance () {
|
||||
return new VoiceFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData () {
|
||||
MvpPre.getConfig();//
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
isShowLoading(false);
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
public void isShowLoading(boolean isShowLoading){
|
||||
if (isShowLoading) {
|
||||
mBinding.coolWaitView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
Observable.timer(5, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe(aLong -> {
|
||||
mBinding.coolWaitView.setVisibility(View.GONE);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView () {
|
||||
|
||||
|
||||
mBinding.llSearch.setOnClickListener(v -> {
|
||||
// ARouter.getInstance().build(ARouteConstants.INDEX_SEARCH).navigation();
|
||||
|
||||
});
|
||||
|
||||
mBinding.ivRoom.setOnClickListener(v -> {
|
||||
//我的房间
|
||||
ARouter.getInstance().build(ARouteConstants.MY_ROOM).withFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT).navigation();
|
||||
});
|
||||
|
||||
|
||||
mBinding.ivRoom3.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(getContext(), SearchActivity.class);
|
||||
startActivity(intent);
|
||||
});
|
||||
|
||||
mBinding.ivRankingList.setOnClickListener(v -> {
|
||||
startActivity(new Intent(getContext(), RankingListActivity.class));
|
||||
});
|
||||
// 检查是否需要显示青少年模式弹窗
|
||||
if (!shouldShowYouthModelDialog()) {
|
||||
showYouthModelDialog();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean shouldShowYouthModelDialog() {
|
||||
// 从 SharedPreferences 中获取是否已经显示过青少年模式弹窗
|
||||
boolean isYouthModelShown = SpUtil.getBooleanValue("youth_model_shown",false);
|
||||
return isYouthModelShown;
|
||||
}
|
||||
private void showYouthModelDialog() {
|
||||
YouthModelDialog youthModelDialog = new YouthModelDialog(getContext(), null);
|
||||
youthModelDialog.show();
|
||||
youthModelDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
// 记录已经显示过青少年模式弹窗
|
||||
SpUtil.setBooleanValue("youth_model_shown", true);
|
||||
dialog.dismiss();
|
||||
MvpPre.activitiesPermission();
|
||||
|
||||
// 在这里可以继续显示其他弹窗,如首充弹窗
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: 2025/10/12 首充好礼
|
||||
private void firstCharge(){
|
||||
FirstChargeDialog firstChargeDialog = new FirstChargeDialog(getActivity());
|
||||
firstChargeDialog.show();
|
||||
firstChargeDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
//首充弹窗关闭后,弹首充
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
firstChargeDialog.setOnFirstChargeListener(new FirstChargeDialog.OnFirstChargeListener() {
|
||||
@Override
|
||||
public void onFirstChargeConfirmed(FirstChargeGiftBean giftBean, int type) {
|
||||
String s = "";
|
||||
String gift_bag_id= "";
|
||||
if (giftBean.getGift_bag().size()!=0) {
|
||||
gift_bag_id = giftBean.getGift_bag().get(0).getGift_bag_id();
|
||||
s = giftBean.getGift_bag().get(0).getMoney();
|
||||
}
|
||||
if (s == null) {
|
||||
ToastUtils.showShort("暂无礼物");
|
||||
return;
|
||||
}
|
||||
|
||||
RechargeDialogFragment.show(null, s, getChildFragmentManager(),gift_bag_id,"1");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFirstChargeCancelled() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initListener () {
|
||||
super.initListener();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId () {
|
||||
return R.layout.fragment_voice;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected VoicePresenter bindPresenter () {
|
||||
return new VoicePresenter(this, getContext());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void hideRecommend ( boolean hideRecommend, boolean hideGame){
|
||||
List<Fragment> fragments = new ArrayList<>();
|
||||
fragments.add(VoiceCategoryFragment.newInstance(VoiceFragment.this));
|
||||
mBinding.viewPager.setAdapter(new MyFragmentPagerAdapter(fragments, getChildFragmentManager()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activitiesPermissionSuccess(ActivitiesPermission activitiesPermission) {
|
||||
if (activitiesPermission != null) {
|
||||
if (activitiesPermission.getFirst_charge_permission() == 1) {
|
||||
firstCharge();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.blankj.utilcode.util.ObjectUtils;
|
||||
import com.xscm.modulemain.activity.room.contacts.BidListContacts;
|
||||
import com.xscm.moduleutil.bean.room.RoomAuction;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class BidListPresenter extends BasePresenter<BidListContacts.View> implements BidListContacts.IRoomPre {
|
||||
public BidListPresenter(BidListContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void roomAuctionList(String auction_id) {
|
||||
api.roomAuctionList(auction_id, new BaseObserver<List<RoomAuction.AuctionListBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<RoomAuction.AuctionListBean> auctionListBeans) {
|
||||
List<RoomAuction.AuctionListBean> lists = auctionListBeans;
|
||||
if (!ObjectUtils.isEmpty(lists)) {//lists判空
|
||||
//榜一
|
||||
if (lists.size() > 0) {
|
||||
MvpRef.get().setNo1(lists.get(0));
|
||||
}
|
||||
//榜二
|
||||
if (lists.size() > 1) {
|
||||
MvpRef.get().setNo2(lists.get(1));
|
||||
}
|
||||
//榜三
|
||||
if (lists.size() > 2) {
|
||||
MvpRef.get().setNo3(lists.get(2));
|
||||
}
|
||||
//第四名及后
|
||||
if (lists.size() > 3) {
|
||||
MvpRef.get().roomAuctionList(lists.subList(3, lists.size()));
|
||||
}
|
||||
}else {
|
||||
MvpRef.get().setCharmEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.xscm.modulemain.activity.room.contacts.CardRelationshipContacts;
|
||||
import com.xscm.moduleutil.bean.RoomRelationBean;
|
||||
import com.xscm.moduleutil.bean.RoomTime;
|
||||
import com.xscm.moduleutil.bean.RoonGiftModel;
|
||||
import com.xscm.moduleutil.bean.room.AuctionBean;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class CardRelationshipPresenter extends BasePresenter<CardRelationshipContacts.View> implements CardRelationshipContacts.IRoomPre{
|
||||
public CardRelationshipPresenter(CardRelationshipContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void roomRelationList(String type) {
|
||||
api.roomRelationList(type, new BaseObserver<List<RoomRelationBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<RoomRelationBean> roomRelationBeans) {
|
||||
MvpRef.get().roomRelationList(roomRelationBeans);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGiftList(String id) {
|
||||
api.getGiftList(Integer.parseInt(id),"", new BaseObserver<List<RoonGiftModel>>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<RoonGiftModel> roonGiftModels) {
|
||||
MvpRef.get().setGiftList(roonGiftModels);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void roomAuction(String roomId, String userId, String giftId, String relation_id, String auction_type, String time_day) {
|
||||
api.roomAuction(roomId,userId,giftId,relation_id,auction_type,time_day, new BaseObserver<AuctionBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable( d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(AuctionBean auctionBean) {
|
||||
MvpRef.get().roomAuction(auctionBean);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void roomAuctionTime(String gift_id) {
|
||||
api.roomAuctionTime(gift_id, new BaseObserver<RoomTime>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(RoomTime roomTime) {
|
||||
MvpRef.get().roomAuctionTime(roomTime);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.xscm.modulemain.activity.room.contacts.ChatRoomContacts;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
|
||||
public class ChatRoomPresenter extends BasePresenter<ChatRoomContacts.View> implements ChatRoomContacts.IPublicScreenEaseChatPre {
|
||||
public ChatRoomPresenter(ChatRoomContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logEmchat(int code, String msg, String toChatUsername) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void switchPublicScreen(String room_id, String status) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.blankj.utilcode.util.ObjectUtils;
|
||||
import com.xscm.modulemain.activity.room.contacts.DataListContacts;
|
||||
import com.xscm.moduleutil.base.BaseRoomPresenter;
|
||||
import com.xscm.moduleutil.bean.CharmRankingResp;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/6/10
|
||||
*@description: 排行榜
|
||||
*/
|
||||
public class DataListPresenter extends BaseRoomPresenter<DataListContacts.View> implements DataListContacts.IRoomDataListPre {
|
||||
private static final String TAG = "DataListPresenter";
|
||||
|
||||
public DataListPresenter(DataListContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void getCharmListInfo(String roomId, String type, String time_type, String page, String page_limit) {
|
||||
|
||||
api.getRoomRank(roomId, type,time_type,page,page_limit, new BaseObserver<List<CharmRankingResp>>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<CharmRankingResp> charmRankingResp) {
|
||||
if (!ObjectUtils.isEmpty(charmRankingResp)){
|
||||
if (charmRankingResp.size()>0){
|
||||
MvpRef.get().setNo1(charmRankingResp.get(0));
|
||||
}
|
||||
if (charmRankingResp.size()>1){
|
||||
MvpRef.get().setNo2(charmRankingResp.get(1));
|
||||
}
|
||||
if (charmRankingResp.size()>2){
|
||||
MvpRef.get().setNo3(charmRankingResp.get(2));
|
||||
}
|
||||
if (charmRankingResp.size()>3) {
|
||||
MvpRef.get().setCharmEmpty(charmRankingResp.subList(3, charmRankingResp.size()));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getWealthListInfo(String roomId, String type, String time_type, String page, String page_limit) {
|
||||
api.getRoomRank(roomId, type,time_type,page,page_limit, new BaseObserver<List<CharmRankingResp>>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<CharmRankingResp> charmRankingResp) {
|
||||
if (!ObjectUtils.isEmpty(charmRankingResp)){
|
||||
if (charmRankingResp.size()>0){
|
||||
MvpRef.get().setNo1(charmRankingResp.get(0));
|
||||
}
|
||||
if (charmRankingResp.size()>1){
|
||||
MvpRef.get().setNo2(charmRankingResp.get(1));
|
||||
}
|
||||
if (charmRankingResp.size()>2){
|
||||
MvpRef.get().setNo3(charmRankingResp.get(2));
|
||||
}
|
||||
if (charmRankingResp.size()>3) {
|
||||
MvpRef.get().setWealthEmpty(charmRankingResp.subList(3, charmRankingResp.size()));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.xscm.modulemain.activity.room.contacts.FriendshipRoomContacts;
|
||||
import com.xscm.moduleutil.base.BaseRoomPresenter;
|
||||
import com.xscm.moduleutil.bean.UserOnlineStatusBean;
|
||||
import com.xscm.moduleutil.bean.room.FriendUserBean;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.http.RetrofitClient;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class FriendshipRoomPresenter extends BaseRoomPresenter<FriendshipRoomContacts.View> implements FriendshipRoomContacts.IRoomPre{
|
||||
FriendshipRoomContacts.View mView;
|
||||
|
||||
public FriendshipRoomPresenter(FriendshipRoomContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
mView = view;
|
||||
}
|
||||
@Override
|
||||
public void applyPit(String roomId, String pitNumber) {
|
||||
api.applyPit(roomId, pitNumber, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
MvpRef.get().applyPit();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startFriend(String roomId) {
|
||||
api.startFriend(roomId, new BaseObserver<String>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable( d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delay(String friend_id, String room_id, String delay_times) {
|
||||
api.delay(friend_id, room_id, delay_times, new BaseObserver<String>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endFriend(String friend_id, String room_id) {
|
||||
api.endFriend(friend_id, room_id, new BaseObserver<FriendUserBean>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(FriendUserBean friendUserBean) {
|
||||
MvpRef.get().endFriend(friendUserBean);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: 2025/8/24 交友房选择关系
|
||||
@Override
|
||||
public void createRelation(String room_id, String friend_id, String user1_id, String user2_id, String relation_id) {
|
||||
api.createRelation(room_id,friend_id,user1_id,user2_id,relation_id, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
MvpRef.get().createRelation();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void userOnlineStatus(String userId, String roomid) {
|
||||
RetrofitClient.getInstance().userOnlineStatus(userId, roomid, new BaseObserver<List<UserOnlineStatusBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<UserOnlineStatusBean> userOnlineStatusBean) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().userOnlineStatus(userOnlineStatusBean);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,235 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.xscm.modulemain.activity.room.contacts.HotListContacts;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.bean.TopRoom;
|
||||
import com.xscm.moduleutil.bean.room.RoomInfoResp;
|
||||
import com.xscm.moduleutil.http.APIException;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
import com.xscm.moduleutil.rtc.AgoraManager;
|
||||
import com.xscm.moduleutil.utils.GsonUtils;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class HotListPresenter extends BasePresenter<HotListContacts.View> implements HotListContacts.IHotListPre {
|
||||
HotListContacts.View mView;
|
||||
|
||||
public HotListPresenter(HotListContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
mView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getRoomList(int type, String page, String page_limit, String is_top, String label_id) {
|
||||
Type listType = new TypeToken<List<TopRoom>>() {}.getType();
|
||||
List<TopRoom> restoredRoomModels = GsonUtils.getGSON().fromJson(SpUtil.getTopRoom(), listType);
|
||||
if (restoredRoomModels!= null && restoredRoomModels.size() > 0 ) {
|
||||
// MvpRef.get().roomList(restoredRoomModels, type);
|
||||
}
|
||||
api.getTopRooms(page+"",page_limit,is_top,label_id,new BaseObserver<List<TopRoom>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<TopRoom> topRooms) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
HotListContacts.View view = MvpRef.get();
|
||||
if (view != null) {
|
||||
if (topRooms != null) {
|
||||
SpUtil.setTopRoom("");
|
||||
SpUtil.setTopRoom(GsonUtils.getGSON().toJson(topRooms));
|
||||
view.roomList(topRooms, type);
|
||||
} else {
|
||||
view.roomList(new ArrayList<>(), type);
|
||||
}
|
||||
view.finishRefreshLoadMore();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: 2025/6/10 加入房间
|
||||
@Override
|
||||
public void getRoomIn(String roomId, String password) {
|
||||
|
||||
// Type listType = new TypeToken<RoomInfoResp>() {}.getType();
|
||||
// RoomInfoResp restoredRoomModels = GsonUtils.getGSON().fromJson(SpUtil.getRoomInfoResp(), listType);
|
||||
// if (restoredRoomModels!= null ) {
|
||||
// MvpRef.get().roomInfo(restoredRoomModels);
|
||||
// }
|
||||
|
||||
api.roomGetIn(roomId, password, new BaseObserver<RoomInfoResp>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(RoomInfoResp resp) {
|
||||
String appId = CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId();
|
||||
String token = resp.getUser_info().getAgora_token(); // 如果启用了鉴权才需要
|
||||
String roomId = resp.getRoom_info().getRoom_id(); // 房间 ID
|
||||
String rtm_token=resp.getUser_info().getAgora_rtm_token();
|
||||
SpUtil.setRtmToken(rtm_token);
|
||||
int uid = SpUtil.getUserId(); // 0 表示由 Agora 自动生成 UID
|
||||
boolean enableMic = false; // 是否开启麦克风
|
||||
boolean enableJs=false; // 是否开启角色
|
||||
if (resp.getUser_info().getPit_number()!=0){
|
||||
enableJs=true;
|
||||
}
|
||||
LogUtils.e("token",token);
|
||||
LogUtils.e("roomId:",roomId);
|
||||
// 初始化 Agora 并加入房间
|
||||
AgoraManager.getInstance(getView().getSelfActivity())
|
||||
.joinRoom(token, roomId, uid, enableMic,enableJs);
|
||||
// 2. 加入房间
|
||||
// rtcCore.joinRoom(token, roomId, uid, enableMic);
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().roomInfo(resp);
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
super.onError(e);
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
if (e instanceof APIException) {
|
||||
APIException apiException = (APIException) e;
|
||||
if (apiException.getCode() == 10000) {
|
||||
MvpRef.get().showPasswordDialog();
|
||||
} else {
|
||||
MvpRef.get().enterFail();
|
||||
}
|
||||
} else {
|
||||
MvpRef.get().enterFail();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMoreRoomList(String userId) {
|
||||
// Type listType = new TypeToken<List<HomeBean>>() {}.getType();
|
||||
// List<HomeBean> restoredRoomModels = GsonUtils.getGSON().fromJson(SpUtils.getHomeBean(), listType);
|
||||
// if (restoredRoomModels != null && restoredRoomModels.size() > 0) {
|
||||
// MvpRef.get().getMoreRoomList(restoredRoomModels);
|
||||
// }
|
||||
// ApiClient.getInstance().homepageBend(userId, new BaseObserver<List<HomeBean>>() {
|
||||
// @Override
|
||||
// public void onSubscribe(Disposable d) {
|
||||
// addDisposable(d);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(List<HomeBean> roomModels) {
|
||||
//// MvpRef.get().roomList(roomModels);
|
||||
//
|
||||
//// SpUtils.setHomeBean(GsonUtils.getGSON().toJson(roomModels));
|
||||
//// MvpRef.get().getMoreRoomList(roomModels);
|
||||
//
|
||||
// String newHomeBeanJson = GsonUtils.getGSON().toJson(roomModels);
|
||||
// // 从本地缓存中读取现有的数据
|
||||
// String existingHomeBeanJson = SpUtils.getHomeBean();
|
||||
// // 比较新获取的数据和缓存中的数据是否一致
|
||||
// if (!newHomeBeanJson.equals(existingHomeBeanJson)) {
|
||||
// // 如果不一致,保存新数据到本地缓存
|
||||
// SpUtils.setHomeBean(newHomeBeanJson);
|
||||
// // 并调用方法处理新数据
|
||||
// MvpRef.get().getMoreRoomList(roomModels);
|
||||
// }else {
|
||||
// MvpRef.get().finishRefreshLoadMore();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
// MvpRef.get().finishRefreshLoadMore();
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
// TODO: 2025/4/23 推荐
|
||||
@Override
|
||||
public void getRoomListTow() {
|
||||
// Type listType = new TypeToken<List<RoomModel>>() {}.getType();
|
||||
// List<RoomModel> restoredRoomModels = GsonUtils.getGSON().fromJson(SpUtils.getRoomModel(), listType);
|
||||
// if (restoredRoomModels != null && restoredRoomModels.size() > 0) {
|
||||
// MvpRef.get().roomList(restoredRoomModels);
|
||||
// }
|
||||
// ApiClient.getInstance().getNewRoomList(new BaseObserver<List<RoomModel>>() {
|
||||
// @Override
|
||||
// public void onSubscribe(Disposable d) {
|
||||
// addDisposable(d);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(List<RoomModel> roomModels) {
|
||||
//
|
||||
//// MvpRef.get().roomList(roomModels);
|
||||
// String newHomeBeanJson = GsonUtils.getGSON().toJson(roomModels);
|
||||
// // 从本地缓存中读取现有的数据
|
||||
// String existingHomeBeanJson = SpUtils.getRoomModel();
|
||||
// // 比较新获取的数据和缓存中的数据是否一致
|
||||
// if (!newHomeBeanJson.equals(existingHomeBeanJson)) {
|
||||
// // 如果不一致,保存新数据到本地缓存
|
||||
// SpUtils.setRoomModel(newHomeBeanJson);
|
||||
// // 并调用方法处理新数据
|
||||
// MvpRef.get().roomList(roomModels);
|
||||
// }else {
|
||||
// MvpRef.get().finishRefreshLoadMore();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
// MvpRef.get().finishRefreshLoadMore();
|
||||
// }
|
||||
// });
|
||||
|
||||
// List<RoomModel> roomModels = new ArrayList<RoomModel>();
|
||||
// for (int i = 0; i < 5; i++) {
|
||||
// RoomModel roomModel = new RoomModel();
|
||||
// roomModel.setRoom_id("1");
|
||||
// roomModel.setRoom_code("1");
|
||||
// roomModel.setUser_id("1");
|
||||
// roomModel.setRoom_name("房间名称"+i);
|
||||
// roomModel.setLabel_id("23");
|
||||
// roomModel.setType_id("1");
|
||||
// roomModel.setPopularity("1");
|
||||
// roomModel.setLabel_name("1");
|
||||
// roomModel.setOwner_picture("1");
|
||||
// roomModel.setOwner_sex("1");
|
||||
// roomModel.setHolder("1");
|
||||
// roomModel.setHolder_picture("1");
|
||||
// roomModel.setHolder_sex("1");
|
||||
// roomModel.setOwner_nickname("名称"+i);
|
||||
// roomModel.setHolder_nickname("h名称"+i);
|
||||
// roomModel.setIs_owner(1);
|
||||
// roomModel.setLocked(1);
|
||||
//
|
||||
// roomModels.add(roomModel);
|
||||
// }
|
||||
//
|
||||
// MvpRef.get().roomList(roomModels);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.xscm.modulemain.activity.room.contacts.HourlyChartContacts;
|
||||
import com.xscm.moduleutil.bean.room.RoomHourBean;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class HourlyChartPresenter extends BasePresenter<HourlyChartContacts.View> implements HourlyChartContacts.IRoomPre{
|
||||
|
||||
HourlyChartContacts.View mView;
|
||||
public HourlyChartPresenter(HourlyChartContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
this.mView=view;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void getRoomHourRanking(String page, String page_limit) {
|
||||
api.getRoomHourRanking(page, page_limit, new BaseObserver<RoomHourBean>() {
|
||||
@Override
|
||||
public void onSubscribe(@NotNull Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NotNull RoomHourBean roomHourBean) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().getRoomHourRanking(roomHourBean);
|
||||
MvpRef.get().findView();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.xscm.modulemain.activity.room.contacts.PkTimeContract;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class PkTimePresenter extends BasePresenter<PkTimeContract.View> implements PkTimeContract.IRoomPre{
|
||||
public PkTimePresenter(PkTimeContract.View view, Context context) {
|
||||
super(view, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startPk(String pk_id, String pk_times) {
|
||||
api.startPk(pk_id, pk_times, new BaseObserver<String>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
// MvpRef.get().startPk();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.blankj.utilcode.util.ObjectUtils;
|
||||
import com.xscm.modulemain.activity.room.contacts.PlaceholderContacts;
|
||||
import com.xscm.moduleutil.bean.PlaceholderBean;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class PlaceholderPresenter extends BasePresenter<PlaceholderContacts.View> implements PlaceholderContacts.IPres {
|
||||
public PlaceholderPresenter(PlaceholderContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wealthRanking(String ranking_type, String type) {
|
||||
api.wealthRanking(ranking_type, type, new BaseObserver<PlaceholderBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(PlaceholderBean placeholderBean) {
|
||||
MvpRef.get().wealthRanking(placeholderBean.getMy_ranking());
|
||||
|
||||
if (!ObjectUtils.isEmpty(placeholderBean.getLists())) {
|
||||
List<PlaceholderBean.ListsBean> lists = placeholderBean.getLists();
|
||||
MvpRef.get().setNo1(lists.get(0),ranking_type);
|
||||
if (lists.size() > 1) {
|
||||
MvpRef.get().setNo2(lists.get(1),ranking_type);
|
||||
}else {
|
||||
MvpRef.get().setNo2(null,ranking_type);
|
||||
}
|
||||
if (lists.size() > 2) {
|
||||
MvpRef.get().setNo3(lists.get(2),ranking_type);
|
||||
}else {
|
||||
MvpRef.get().setNo3(null,ranking_type);
|
||||
}
|
||||
if (lists.size() > 3) {
|
||||
MvpRef.get().setList(lists.subList(3, lists.size()));
|
||||
}else {
|
||||
MvpRef.get().setList(null);
|
||||
}
|
||||
}else {
|
||||
MvpRef.get().setNo1(null,ranking_type);
|
||||
MvpRef.get().setNo2(null,ranking_type);
|
||||
MvpRef.get().setNo3(null,ranking_type);
|
||||
MvpRef.get().setList(null);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.xscm.modulemain.activity.room.contacts.PublishCommentContacts;
|
||||
import com.xscm.moduleutil.bean.HeadlineBean;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class PublishCommentPresenter extends BasePresenter<PublishCommentContacts.View> implements PublishCommentContacts.IRoomPre {
|
||||
public PublishCommentPresenter(PublishCommentContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendHeadine(String content, String money,String roomId) {
|
||||
api.sendHeadine(content, money,roomId, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
MvpRef.get().sendHeadine();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void currentHeadline() {
|
||||
api.currentHeadline(new BaseObserver<HeadlineBean>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(HeadlineBean headlineBean) {
|
||||
MvpRef.get().currentHeadline(headlineBean);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.xscm.modulemain.activity.room.contacts.RedEnvelopesContacts;
|
||||
import com.xscm.moduleutil.bean.RedpacketDetail;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class RedEnvelopesPresenter extends BasePresenter<RedEnvelopesContacts.View> implements RedEnvelopesContacts.IRoomPre{
|
||||
RedEnvelopesContacts.View mView;
|
||||
public RedEnvelopesPresenter(RedEnvelopesContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
mView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getRedpacketDetail(String redpacketId) {
|
||||
api.redPacketDetail(redpacketId, new BaseObserver<RedpacketDetail>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(@NotNull Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NotNull RedpacketDetail redpacketDetail) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().redPacketDetail(redpacketDetail);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.xscm.modulemain.activity.room.contacts.RequestContacts;
|
||||
import com.xscm.moduleutil.bean.MusicSongBean;
|
||||
import com.xscm.moduleutil.bean.SongMusicBean;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class RequestPresenter extends BasePresenter<RequestContacts.View> implements RequestContacts.IRoomPre{
|
||||
public RequestPresenter(RequestContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void songList(String roomId) {
|
||||
api.songList(roomId, new BaseObserver<List<MusicSongBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<MusicSongBean> musicSongBeans) {
|
||||
MvpRef.get().songList(musicSongBeans);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upSong(String did, String type) {
|
||||
api.upSong(did, type, new BaseObserver<String>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
MvpRef.get().upSong(s);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void song(String roomId, String user_id, String song_code, String song_name, String singer, String poster, String duration) {
|
||||
api.song(roomId, user_id, song_code, song_name, singer, poster, duration, new BaseObserver<List<SongMusicBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<SongMusicBean> songMusicBeans) {
|
||||
MvpRef.get().song(songMusicBeans);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.xscm.modulemain.activity.room.contacts.RoomAuctionContacts;
|
||||
import com.xscm.moduleutil.bean.room.AuctionBean;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.http.RetrofitClient;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class RoomAuctionPresenter extends BasePresenter<RoomAuctionContacts.View> implements RoomAuctionContacts.IRoomDataListPre {
|
||||
public RoomAuctionPresenter(RoomAuctionContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyPit(String roomId, String pitNumber) {
|
||||
api.applyPit(roomId, pitNumber, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
MvpRef.get().applyPit();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void roomAuction(String roomId, String userId, String giftId, String relation_id, String auction_type, String time_day) {
|
||||
api.roomAuction(roomId,userId,giftId,relation_id,auction_type,time_day, new BaseObserver<AuctionBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable( d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(AuctionBean auctionBean) {
|
||||
MvpRef.get().roomAuction(auctionBean);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void auctionDelay(String auctionId) {
|
||||
RetrofitClient.getInstance().auctionDelay(auctionId, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
|
||||
MvpRef.get().auctionDelay();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void auctionEnd(String auctionId,String roomId) {
|
||||
RetrofitClient.getInstance().auctionEnd(auctionId,roomId, new BaseObserver<String>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
MvpRef.get().auctionEnd();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void auctionMode(String roomId, String labelId) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void userOnlineStatus(String userId, String roomid) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.xscm.modulemain.activity.room.contacts.RoomAuctionContacts;
|
||||
import com.xscm.moduleutil.bean.UserOnlineStatusBean;
|
||||
import com.xscm.moduleutil.bean.room.AuctionBean;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.http.RetrofitClient;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class RoomAuctionPresenterTow extends BasePresenter<RoomAuctionContacts.View> implements RoomAuctionContacts.IRoomDataListPre {
|
||||
RoomAuctionContacts.View mView;
|
||||
public RoomAuctionPresenterTow(RoomAuctionContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
mView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyPit(String roomId, String pitNumber) {
|
||||
api.applyPit(roomId, pitNumber, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().applyPit();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void roomAuction(String roomId, String userId, String giftId, String relation_id, String auction_type, String time_day) {
|
||||
api.roomAuction(roomId,userId,giftId,relation_id,auction_type,time_day, new BaseObserver<AuctionBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable( d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(AuctionBean auctionBean) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().roomAuction(auctionBean);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void auctionDelay(String auctionId) {
|
||||
RetrofitClient.getInstance().auctionDelay(auctionId, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
|
||||
// MvpRef.get().auctionDelay();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void auctionEnd(String auctionId,String roomId) {
|
||||
RetrofitClient.getInstance().auctionEnd(auctionId,roomId, new BaseObserver<String>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
// MvpRef.get().auctionEnd();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void auctionMode(String roomId, String labelId) {
|
||||
RetrofitClient.getInstance().auctionMode(roomId, labelId, new BaseObserver<String>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
public void userOnlineStatus(String userId, String roomid) {
|
||||
api.userOnlineStatus(userId, roomid, new BaseObserver<List<UserOnlineStatusBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<UserOnlineStatusBean> userOnlineStatusBean) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().userOnlineStatus(userOnlineStatusBean);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.xscm.modulemain.activity.room.contacts.RoomBackgroundContacts;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.bean.RoomBgBean;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
import com.xscm.moduleutil.utils.cos.CosUploadManager;
|
||||
import com.xscm.moduleutil.utils.oss.OSSOperUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class RoomBackgroundPresenter extends BasePresenter<RoomBackgroundContacts.View> implements RoomBackgroundContacts.RoomBackgroudPre {
|
||||
public RoomBackgroundPresenter(RoomBackgroundContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBackgroundList() {
|
||||
api.getBackgroundList(new BaseObserver<RoomBgBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(RoomBgBean roomBgBeans) {
|
||||
MvpRef.get().getBackgroundList(roomBgBeans);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadFile(File file, int type, int index, int size) {
|
||||
String url = OSSOperUtils.getPath(file, type);
|
||||
CosUploadManager.getInstance(CommonAppContext.getInstance()).upParameters(url,file.getPath(), new CosUploadManager.UploadCallback() {
|
||||
@Override
|
||||
public void onSuccess(String url) {
|
||||
if (isViewAttach()) {
|
||||
MvpRef.get().upLoadSuccess(url, type, index, size);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Exception e) {
|
||||
ToastUtils.show("上传失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure1(IllegalStateException e) {
|
||||
ToastUtils.show("上传失败");
|
||||
MvpRef.get().disLoadings();
|
||||
}
|
||||
});
|
||||
// OSSOperUtils.newInstance().putObjectMethod(url, file.getPath(), new OSSOperUtils.OssCallback() {
|
||||
// @Override
|
||||
// public void onSuccess() {
|
||||
// if (isViewAttach()) {
|
||||
// MvpRef.get().upLoadSuccess(OSSOperUtils.AliYunOSSURLFile + url, type, index, size);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onFail() {
|
||||
// if (isViewAttach()) {
|
||||
// MvpRef.get().disLoadings();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadBgImage(String id, String image_url) {
|
||||
api.uploadBgImage(id, image_url, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String string) {
|
||||
MvpRef.get().uploadBgImage();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void editRoom(String room_id, String room_name, String room_cover, String room_intro, String room_background) {
|
||||
api.editRoom(room_id, room_name, room_cover, room_intro, room_background, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String string) {
|
||||
MvpRef.get().editRoom();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.xscm.modulemain.activity.room.contacts.RoomCabinContacts;
|
||||
import com.xscm.moduleutil.base.BaseRoomPresenter;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class RoomCabinPresenter extends BaseRoomPresenter<RoomCabinContacts.View> implements RoomCabinContacts.IRoomPre{
|
||||
public RoomCabinPresenter(RoomCabinContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void quitRoom(String roomId, String userId) {
|
||||
api.quitRoom(roomId, userId, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String string) {
|
||||
MvpRef.get().quitRoom();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.xscm.modulemain.activity.room.contacts.RoomCharmDialogContacts;
|
||||
import com.xscm.moduleutil.bean.RoomUserCharmListBean;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class RoomCharmDialogPresenter extends BasePresenter<RoomCharmDialogContacts.View> implements RoomCharmDialogContacts.IRoomPre {
|
||||
|
||||
RoomCharmDialogContacts.View mView;
|
||||
|
||||
public RoomCharmDialogPresenter(RoomCharmDialogContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
mView = view;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void roomUserCharmList(String room_id, String user_id) {
|
||||
api.roomUserCharmList(room_id, user_id,new BaseObserver<List<RoomUserCharmListBean>>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<RoomUserCharmListBean> roomUserCharmListBeans) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().roomUserCharmList(roomUserCharmListBeans);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.xscm.modulemain.activity.room.contacts.RoomChartsContacts;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
|
||||
public class RoomChartsPresenter extends BasePresenter<RoomChartsContacts.View> implements RoomChartsContacts.IRoomPre {
|
||||
public RoomChartsPresenter(RoomChartsContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.xscm.modulemain.activity.room.contacts.RoomCloseContacts;
|
||||
import com.xscm.moduleutil.bean.RoomRelationBean;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class RoomClosePresenter extends BasePresenter<RoomCloseContacts.View> implements RoomCloseContacts.IRoomToolPre {
|
||||
RoomCloseContacts.View mView;
|
||||
|
||||
public RoomClosePresenter(RoomCloseContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
mView = view;
|
||||
}
|
||||
@Override
|
||||
public void roomRelationList(String type) {
|
||||
api.roomRelationList(type, new BaseObserver<List<RoomRelationBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<RoomRelationBean> roomRelationBeans) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().roomRelationList(roomRelationBeans);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.xscm.modulemain.activity.room.contacts.RoomHostContacts;
|
||||
import com.xscm.moduleutil.bean.HostBean;
|
||||
import com.xscm.moduleutil.bean.RoomSearchResp;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class RoomHostPresenter extends BasePresenter<RoomHostContacts.View> implements RoomHostContacts.IRoomToolPre {
|
||||
|
||||
|
||||
public RoomHostPresenter(RoomHostContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
}
|
||||
|
||||
// TODO: 2025/3/15 获取当前房间的主持人列表
|
||||
@Override
|
||||
public void clearHostList(String roomId,String type) {
|
||||
api.getHostList(roomId,type, new BaseObserver<List<HostBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<HostBean> giftModels) {
|
||||
MvpRef.get().setHostrList(giftModels);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: 2025/3/15 获取用户信息
|
||||
@Override
|
||||
public void setUserHostList(String keyWord,String type) {
|
||||
api.getSearch(keyWord,type, new BaseObserver<List<RoomSearchResp>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<RoomSearchResp> roomSearchResps) {
|
||||
MvpRef.get().getUserHostList(roomSearchResps);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: 2025/3/17 设置收益比例
|
||||
@Override
|
||||
public void setPresidedRatio(String room_id,String user_id, String ratio) {
|
||||
api.setPresidedRatio(room_id,user_id, ratio, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
MvpRef.get().postPresidedRatio(s);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
// TODO: 2025/3/17 添加主持人
|
||||
@Override
|
||||
public void postHostAdd(String roomId, String userId,String type,String is_add) {
|
||||
api.postHostAdd(roomId, userId, type, is_add, new BaseObserver<String>() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
MvpRef.get().postHostAdd(s,type,is_add);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.xscm.modulemain.activity.room.contacts.RoomPasswordSetContacts;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class RoomPasswordSetPresenter extends BasePresenter<RoomPasswordSetContacts.View> implements RoomPasswordSetContacts.IRoomPasswordSetPre {
|
||||
public RoomPasswordSetPresenter(RoomPasswordSetContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRoomPassword(String roomId, String password) {
|
||||
api.updatePassword(roomId, password, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
MvpRef.get().roomPasswordSettingSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.xscm.modulemain.activity.room.contacts.RoomPkContacts;
|
||||
import com.xscm.moduleutil.bean.room.RoomBean;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class RoomPkPresenter extends BasePresenter<RoomPkContacts.View> implements RoomPkContacts.IRoomPre {
|
||||
public RoomPkPresenter(RoomPkContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void searchPkRoom(String roomId, String page, String limit) {
|
||||
api.searchPkRoom(roomId, page, limit, new BaseObserver<List<RoomBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<RoomBean> roomBeans) {
|
||||
MvpRef.get().searchPkRoom(roomBeans);
|
||||
MvpRef.get().finishLoading();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPk(String roomIda, String createUserId, String roomIdb) {
|
||||
api.sendPk(roomIda, createUserId, roomIdb, new BaseObserver<Object>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(Object o) {
|
||||
MvpRef.get().sendPk();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refusePk(String roomId, String is_pk) {
|
||||
api.refusePk(roomId, is_pk, new BaseObserver<String>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
MvpRef.get().refusePk();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,462 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.xscm.modulemain.activity.room.contacts.RoomContacts;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.bean.RedPacketInfo;
|
||||
import com.xscm.moduleutil.bean.RoomCharmRankBean;
|
||||
import com.xscm.moduleutil.bean.UserOnlineStatusBean;
|
||||
import com.xscm.moduleutil.bean.room.RoomInfoResp;
|
||||
import com.xscm.moduleutil.bean.room.RoomOnline;
|
||||
import com.xscm.moduleutil.http.APIException;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.http.RetrofitClient;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
import com.xscm.moduleutil.rtc.AgoraManager;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class RoomPresenter extends BasePresenter<RoomContacts.View> implements RoomContacts.IRoomPre {
|
||||
RoomContacts.View mView;
|
||||
public RoomPresenter(RoomContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
mView = view;
|
||||
}
|
||||
|
||||
// TODO: 2025/6/10 加入房间
|
||||
@Override
|
||||
public void getRoomIn(String roomId, String password) {
|
||||
|
||||
// Type listType = new TypeToken<RoomInfoResp>() {}.getType();
|
||||
// RoomInfoResp restoredRoomModels = GsonUtils.getGSON().fromJson(SpUtil.getRoomInfoResp(), listType);
|
||||
// if (restoredRoomModels!= null ) {
|
||||
// MvpRef.get().roomInfo(restoredRoomModels);
|
||||
// }
|
||||
|
||||
api.roomGetIn(roomId, password, new BaseObserver<RoomInfoResp>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(RoomInfoResp resp) {
|
||||
String appId = CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId();
|
||||
String token = resp.getUser_info().getAgora_token(); // 如果启用了鉴权才需要
|
||||
String roomId = resp.getRoom_info().getRoom_id(); // 房间 ID
|
||||
String rtm_token=resp.getUser_info().getAgora_rtm_token();
|
||||
SpUtil.setRtmToken(rtm_token);
|
||||
int uid = SpUtil.getUserId(); // 0 表示由 Agora 自动生成 UID
|
||||
boolean enableMic = false; // 是否开启麦克风
|
||||
boolean enableJs=false; // 是否开启角色
|
||||
if (resp.getUser_info().getPit_number()!=0){
|
||||
enableJs=true;
|
||||
}
|
||||
LogUtils.e("token",token);
|
||||
LogUtils.e("roomId:",roomId);
|
||||
|
||||
if (getView()!= null && getView().getSelfActivity()!=null){
|
||||
AgoraManager.getInstance(getView().getSelfActivity())
|
||||
.joinRoom(token, roomId, uid, enableMic,enableJs);
|
||||
}else {
|
||||
AgoraManager.getInstance(mContext.getApplicationContext())
|
||||
.joinRoom(token, roomId, uid, enableMic,enableJs);
|
||||
}
|
||||
|
||||
// 初始化 Agora 并加入房间
|
||||
|
||||
|
||||
// RtcCore rtcCore = RtcCore.getInstance(getView().getSelfActivity());
|
||||
// rtcCore.initAgora(appId);
|
||||
|
||||
// 2. 加入房间
|
||||
// rtcCore.joinRoom(token, roomId, uid, enableMic);
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().roomInfo(resp);
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
super.onError(e);
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
if (e instanceof APIException) {
|
||||
APIException apiException = (APIException) e;
|
||||
if (apiException.getCode() == 10000) {
|
||||
MvpRef.get().showPasswordDialog();
|
||||
} else {
|
||||
MvpRef.get().enterFail();
|
||||
}
|
||||
} else {
|
||||
MvpRef.get().enterFail();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: 2025/6/10 在线列表
|
||||
@Override
|
||||
public void getRoomOnline(String roomId, String page, String page_limit) {
|
||||
api.getRoomOnline(roomId, page, page_limit, new BaseObserver<RoomOnline>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(RoomOnline roomOnlineBeans) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().getRoomOnline(roomOnlineBeans);
|
||||
MvpRef.get().findRoom();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyPit(String roomId, String pitNumber) {
|
||||
api.applyPit(roomId, pitNumber, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().applyPit();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downPit(String roomId, String pitNumber) {
|
||||
api.downPit(roomId, pitNumber, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().downPit();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applySong(String roomId) {
|
||||
if (api== null){
|
||||
api = RetrofitClient.getInstance();
|
||||
}
|
||||
api.applySong(roomId, new BaseObserver<String>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().applySong();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void agreeSong(String roomId, String type) {
|
||||
if (api== null){
|
||||
api = RetrofitClient.getInstance();
|
||||
}
|
||||
api.agreeSong(roomId, type, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().agreeSong();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endSong(String roomId) {
|
||||
api.endSong(roomId, new BaseObserver<String>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().agreeSong();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postRoomInfo(String roomId) {
|
||||
api.postRoomInfo(roomId, new BaseObserver<RoomInfoResp>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(RoomInfoResp roomInfoResp) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
if (roomInfoResp==null){
|
||||
MvpRef.get().postRoomInfo(null);
|
||||
}else {
|
||||
MvpRef.get().postRoomInfo(roomInfoResp);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCharmRank(String roomId) {
|
||||
api.getCharmRank(roomId, new BaseObserver<List<RoomCharmRankBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<RoomCharmRankBean> roomCharmRankBeans) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().getCharmRank(roomCharmRankBeans);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeSong(String roomId, String now_did) {
|
||||
api.changeSong(roomId, now_did, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().changeSong();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hostUserPit(String roomId, String pitNumber, String userId, String type) {
|
||||
api.hostUserPit(roomId, pitNumber, userId, type, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String string) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().hostUserPit();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void quitRoom(String roomId, String userId) {
|
||||
api.quitRoom(roomId, userId, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String string) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().quitRoom();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void quitRoom2(String roomId, String userId) {
|
||||
api.quitRoom(roomId, userId, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String string) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().quitRoom2(roomId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void userGuanz(String userId, String type) {
|
||||
api.userGuanz(userId,type, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().userGuanzSuccess(s);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void acceptPk(String pkId, String type) {
|
||||
api.acceptPk(pkId, type, new BaseObserver<String>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().acceptPk();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearUserCharm(String roomId, String userId) {
|
||||
api.clearUserCharm(roomId, userId, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().clearUserCharm();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void userOnlineStatus(String userId, String roomid) {
|
||||
api.userOnlineStatus(userId, roomid, new BaseObserver<List<UserOnlineStatusBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<UserOnlineStatusBean> userOnlineStatusBean) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().userOnlineStatus(userOnlineStatusBean);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void auctionEnd(String auctionId,String roomId) {
|
||||
api.auctionEnd(auctionId,roomId, new BaseObserver<String>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
// MvpRef.get().auctionEnd();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void auctionDelay(String auctionId) {
|
||||
RetrofitClient.getInstance().auctionDelay(auctionId, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
|
||||
// MvpRef.get().auctionDelay();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void roomRedPackets(String roomId) {
|
||||
api.roomRedPackets(roomId,new BaseObserver<List<RedPacketInfo>>(){
|
||||
|
||||
@Override
|
||||
public void onSubscribe(@NotNull Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NotNull List<RedPacketInfo> redPacketInfos) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().roomRedPackets(redPacketInfos);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.xscm.modulemain.activity.room.contacts.RoomSettingContacts;
|
||||
import com.xscm.moduleutil.bean.room.RoomSettingBean;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.http.RetrofitClient;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class RoomSettingPresenter extends BasePresenter<RoomSettingContacts.View> implements RoomSettingContacts.IRoomPre{
|
||||
RoomSettingContacts.View mView;
|
||||
public RoomSettingPresenter(RoomSettingContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
mView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeRoom(String roomId, String userId, int position, RoomSettingBean bean) {
|
||||
if (api==null){
|
||||
api= RetrofitClient.getInstance();
|
||||
}
|
||||
api.changeRoom(roomId, userId, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().changeRoomSuccess(s, position,bean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
super.onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
super.onError(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeRoomType(String roomId, String type) {
|
||||
if (api==null){
|
||||
api= RetrofitClient.getInstance();
|
||||
}
|
||||
api.changeRoomType(roomId, type, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String string) {
|
||||
if (MvpRef==null){
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().changeRoomType(string);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void agreeSong(String roomId, String type) {
|
||||
if (api== null){
|
||||
api = RetrofitClient.getInstance();
|
||||
}
|
||||
api.agreeSong(roomId, type, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().agreeSong(s);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,319 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.xscm.modulemain.activity.room.contacts.RoomUserContacts;
|
||||
import com.xscm.moduleutil.bean.RelationCardBean;
|
||||
import com.xscm.moduleutil.bean.UserInfo;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.http.RetrofitClient;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class RoomUserPresenter extends BasePresenter<RoomUserContacts.View> implements RoomUserContacts.IEmotionRoomPre {
|
||||
RoomUserContacts.View mView;
|
||||
|
||||
public RoomUserPresenter(RoomUserContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
mView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getRoomUserInfo(String roomId, String userId) {
|
||||
if (api==null){
|
||||
api= RetrofitClient.getInstance();
|
||||
}
|
||||
api.getRoomUserInfo(roomId, userId, new BaseObserver<UserInfo>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(UserInfo userInfo) {
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().getRoomUserInfo(userInfo);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downPit(String roomId, String pitNumber) {
|
||||
if (api==null){
|
||||
api= RetrofitClient.getInstance();
|
||||
}
|
||||
api.downPit(roomId, pitNumber, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String string) {
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().downPit();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hostUserPit(String roomId, String pitNumber, String userId, String type) {
|
||||
if (api==null){
|
||||
api= RetrofitClient.getInstance();
|
||||
}
|
||||
api.hostUserPit(roomId, pitNumber, userId, type, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String string) {
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().hostUserPit();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveCoin(String user_id, String coin) {
|
||||
if (api==null){
|
||||
api= RetrofitClient.getInstance();
|
||||
}
|
||||
api.giveCoin(user_id, coin, new BaseObserver<String>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().giveCoin();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void relationCard(String user_id) {
|
||||
if (api==null){
|
||||
api= RetrofitClient.getInstance();
|
||||
}
|
||||
api.relationCard(user_id, new BaseObserver<RelationCardBean>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(RelationCardBean relationCardBeans) {
|
||||
if (MvpRef == null){
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().relationCard(relationCardBeans);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void topRelationCard(String id) {
|
||||
if (api==null){
|
||||
api= RetrofitClient.getInstance();
|
||||
}
|
||||
api.topRelationCard(id, new BaseObserver<String>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().topRelationCard(s);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRelationCard(String id) {
|
||||
if (api==null){
|
||||
api= RetrofitClient.getInstance();
|
||||
}
|
||||
api.deleteRelationCard(id, new BaseObserver<String>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().deleteRelationCard(s);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearUserCharm(String roomId, String userId) {
|
||||
api.clearUserCharm(roomId, userId, new BaseObserver<String>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().clearUserCharm();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kickOutRoom(String roomId, String userId) {
|
||||
if (api==null){
|
||||
api= RetrofitClient.getInstance();
|
||||
}
|
||||
api.kickOutRoom(roomId, userId, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String string) {
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().kickOutRoom();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postHostAdd(String roomId, String userId, String type, String is_add) {
|
||||
if (api==null){
|
||||
api= RetrofitClient.getInstance();
|
||||
}
|
||||
api.postHostAdd(roomId, userId, type, is_add, new BaseObserver<String>() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().postHostAdd(s, type, is_add);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMutePit(String roomId, String user_id, String is_mute) {
|
||||
if (api==null){
|
||||
api= RetrofitClient.getInstance();
|
||||
}
|
||||
api.setMutePit(roomId, user_id, is_mute, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String string) {
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().setMutePit(user_id, is_mute);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBlackList(String userId) {
|
||||
if (api==null){
|
||||
api= RetrofitClient.getInstance();
|
||||
}
|
||||
api.addBlackList(userId, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String string) {
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().addBlackList();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void userGuanz(String userId, String type) {
|
||||
if (api==null){
|
||||
api= RetrofitClient.getInstance();
|
||||
}
|
||||
api.userGuanz(userId, type, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef == null) {
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().userGuanzSuccess(s);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyPit(String roomId, String pitNumber) {
|
||||
RetrofitClient.getInstance().applyPit(roomId, pitNumber, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().applyPit();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.blankj.utilcode.util.StringUtils;
|
||||
import com.xscm.modulemain.activity.room.contacts.SearchContacts;
|
||||
import com.xscm.moduleutil.bean.SearchAll;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class SearchPresenter extends BasePresenter<SearchContacts.View> implements SearchContacts.ISearchPre {
|
||||
|
||||
private List<String> mHistory = new ArrayList<>();
|
||||
|
||||
public SearchPresenter(SearchContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void getSearchHistory() {
|
||||
String data = SpUtil.getSearchHistory();
|
||||
if (!StringUtils.isEmpty(data)) {
|
||||
mHistory = JSON.parseArray(data, String.class);
|
||||
} else {
|
||||
mHistory.clear();
|
||||
}
|
||||
MvpRef.get().setSearchHistory(mHistory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveSearchHistory(String keyWord) {
|
||||
mHistory.remove(keyWord);
|
||||
mHistory.add(0, keyWord);
|
||||
SpUtil.saveSearchHistory(JSON.toJSONString(mHistory));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteSearchHistory() {
|
||||
SpUtil.saveSearchHistory("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void search(String keyWord) {
|
||||
// AppLogUtil.reportAppLog(AppLogEvent.A020301, "send_value", keyWord);
|
||||
// MvpRef.get().showLoadings();
|
||||
api.getSearchAll(keyWord, new BaseObserver<SearchAll>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(SearchAll searchResps) {
|
||||
MvpRef.get().setSearch(searchResps);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fuzzyQuery(String keyWord) {
|
||||
// ApiClient.getInstance().getSearch(keyWord, new BaseObserver<SearchResp>() {
|
||||
// @Override
|
||||
// public void onSubscribe(Disposable d) {
|
||||
// addDisposable(d);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(SearchResp searchResp) {
|
||||
// List<RecordSection> data = new ArrayList<>();
|
||||
// RoomResultResp room_result = searchResp.getRoom_result();
|
||||
// List<RoomResultResp.RoomResultInfo> list = room_result.getList();
|
||||
// if (list != null && list.size() != 0) {
|
||||
// data.add(new RecordSection(true, "相关房间"));
|
||||
// for (RoomResultResp.RoomResultInfo item : list) {
|
||||
// data.add(new RecordSection(item.getRoom_name()));
|
||||
// }
|
||||
// }
|
||||
// List<UserResultResp> user_result = searchResp.getUser_result();
|
||||
// if (user_result != null && user_result.size() != 0) {
|
||||
// data.add(new RecordSection(true, "相关用户"));
|
||||
// for (UserResultResp item : user_result) {
|
||||
// data.add(new RecordSection(item.getNickname()));
|
||||
// }
|
||||
// }
|
||||
// MvpRef.get().setFuzzyQuery(data);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
//
|
||||
// }
|
||||
// });
|
||||
|
||||
MvpRef.get().setFuzzyQuery(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void followUser(String userId, int type, int postion) {
|
||||
// MvpRef.get().showLoadings();
|
||||
// ApiClient.getInstance().followUser(userId, type, new BaseObserver<String>() {
|
||||
// @Override
|
||||
// public void onSubscribe(Disposable d) {
|
||||
// addDisposable(d);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(String s) {
|
||||
// MvpRef.get().followUserSuccess(type, postion);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
// MvpRef.get().disLoadings();
|
||||
// }
|
||||
// });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.xscm.modulemain.activity.room.contacts.SingSongContacts;
|
||||
import com.xscm.moduleutil.base.BaseRoomPresenter;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.bean.PkSwTokenBean;
|
||||
import com.xscm.moduleutil.bean.UserOnlineStatusBean;
|
||||
import com.xscm.moduleutil.bean.room.RoomInfoResp;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.http.RetrofitClient;
|
||||
import com.xscm.moduleutil.rtc.AgoraManager;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class SingSongPresenter extends BaseRoomPresenter<SingSongContacts.View> implements SingSongContacts.IEmotionRoomPre {
|
||||
private SingSongContacts.View mView;
|
||||
public SingSongPresenter(SingSongContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
mView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyPit(String roomId, String pitNumber) {
|
||||
RetrofitClient.getInstance().applyPit(roomId, pitNumber, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().applyPit();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMutePit(String roomId, String pitNumber, String is_mute) {
|
||||
RetrofitClient.getInstance().setMutePit(roomId, pitNumber, is_mute, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String string) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().setMutePit(pitNumber, is_mute);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLockPit(String roomId, String pitNumber, String is_lock) {
|
||||
RetrofitClient.getInstance().setLockPit(roomId, pitNumber, is_lock, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String string) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().setLockPit(pitNumber, is_lock);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// 请求房间信息,当pk同意的时候,获取对方房间信息,同时请求自己房间信息,做页面的更新 添加一type:1:请求对方信息 2:请求自己房间信息 3:是否接受PK
|
||||
@Override
|
||||
public void postRoomInfo(String roomId, String number,int type) {
|
||||
RetrofitClient.getInstance().postRoomInfo(roomId, new BaseObserver<RoomInfoResp>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(RoomInfoResp roomInfoResp) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
if (roomInfoResp==null){
|
||||
return;
|
||||
}
|
||||
String roomId = roomInfoResp.getRoom_info().getRoom_id(); // 房间 ID
|
||||
String rtm_token = roomInfoResp.getUser_info().getAgora_rtm_token();
|
||||
SpUtil.setRtmToken(rtm_token);
|
||||
int uid = SpUtil.getUserId(); // 0 表示由 Agora 自动生成 UID
|
||||
boolean enableMic = false; // 是否开启麦克风
|
||||
if (type==1) {
|
||||
if (roomInfoResp.getPk_info() != null) {
|
||||
if (number.equals("9")) {
|
||||
LogUtils.e("pk_info", ""+number);
|
||||
postRoomSwToken(roomId,uid,roomInfoResp.getPk_info().getInvite_pk_user_id());
|
||||
///添加多频道
|
||||
}
|
||||
}
|
||||
MvpRef.get().postRoomInfoPk(roomInfoResp);
|
||||
// postRoomInfo(SpUtil.getMyRoomId(),"9",3);
|
||||
}else if (type==3){
|
||||
// AgoraManagerEx.getInstance(getView().getSelfActivity()).leaveChannelEx(roomInfoResp.getRoom_info().getLast_pk_room_id()+"", uid);
|
||||
MvpRef.get().postRoomInfoUp(roomInfoResp);
|
||||
}else {
|
||||
// AgoraManagerEx.getInstance(getView().getSelfActivity()).leaveChannelEx(roomInfoResp.getRoom_info().getLast_pk_room_id()+"", uid);
|
||||
MvpRef.get().postRoomInfo(roomInfoResp);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endPk(String pk_id, String type, String user_id) {
|
||||
RetrofitClient.getInstance().endPk(pk_id, type, user_id, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().endPk();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void userOnlineStatus(String userId, String roomid) {
|
||||
RetrofitClient.getInstance().userOnlineStatus(userId, roomid, new BaseObserver<List<UserOnlineStatusBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<UserOnlineStatusBean> userOnlineStatusBean) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().userOnlineStatus(userOnlineStatusBean);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void postRoomSwToken(String roomId,int uid,String invite_pk_user_id) {
|
||||
RetrofitClient.getInstance().postRoomSwToken(roomId, new BaseObserver<PkSwTokenBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(PkSwTokenBean pkSwTokenBean) {
|
||||
if (pkSwTokenBean!=null){
|
||||
if (pkSwTokenBean.getAgora_token() != null){
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().postAgora(pkSwTokenBean);
|
||||
|
||||
// AgoraManager.getInstance(getView().getSelfActivity())
|
||||
// .joinChannelEx(pkSwTokenBean.getAgora_token(), roomId, uid);
|
||||
// AgoraManager.getInstance(getView().getSelfActivity()).muteAllRemoteAudioStreamsExUserId(false, invite_pk_user_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.xscm.modulemain.activity.room.contacts.UserGiftWallConacts;
|
||||
import com.xscm.moduleutil.bean.GiftUserWallBean;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class UserGiftWallPresenter extends BasePresenter<UserGiftWallConacts.View> implements UserGiftWallConacts.IUserGiftWallPre {
|
||||
|
||||
public UserGiftWallPresenter(UserGiftWallConacts.View view, Context context) {
|
||||
super(view, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giftWall(String userId) {
|
||||
api.giftWall(userId ,new BaseObserver<GiftUserWallBean>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(GiftUserWallBean giftUserWallBeans) {
|
||||
MvpRef.get().setGiftWall(giftUserWallBeans);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.xscm.modulemain.activity.room.contacts.VoiceCategoryContacts;
|
||||
import com.xscm.moduleutil.bean.BannerModel;
|
||||
import com.xscm.moduleutil.bean.RoomTypeModel;
|
||||
import com.xscm.moduleutil.bean.TopRoom;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
import com.xscm.moduleutil.utils.GsonUtils;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class VoiceCategoryPresenter extends BasePresenter<VoiceCategoryContacts.View> implements VoiceCategoryContacts.IIndexCategoryPre {
|
||||
VoiceCategoryContacts.View mView;
|
||||
public VoiceCategoryPresenter(VoiceCategoryContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
mView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCategories() {
|
||||
Type listType = new TypeToken<List<RoomTypeModel>>() {}.getType();
|
||||
List<RoomTypeModel> restoredRoomModels = GsonUtils.getGSON().fromJson(SpUtil.getRoomTypeModel(), listType);
|
||||
if (restoredRoomModels!= null && restoredRoomModels.size() > 0) {
|
||||
MvpRef.get().setCategories(restoredRoomModels);
|
||||
}
|
||||
api.getRoomCategories(new BaseObserver<List<RoomTypeModel>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<RoomTypeModel> list) {
|
||||
SpUtil.setRoomTypeModel(GsonUtils.getGSON().toJson(list));
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().setCategories(list);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMediaRoom(String label_id) {
|
||||
}
|
||||
|
||||
public void getBanners() {
|
||||
// Type listType = new TypeToken<List<BannerModel>>() {}.getType();
|
||||
// List<BannerModel> restoredRoomModels = GsonUtils.getGSON().fromJson(SpUtils.getHomeBanner(), listType);
|
||||
// MvpRef.get().setBanners(restoredRoomModels);
|
||||
api.getBanners(new BaseObserver<List<BannerModel>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<BannerModel> bannerModels) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().setBanners(bannerModels);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
@Override
|
||||
public void getCarousels(int type, int page, String page_limit, String is_top, String label_id) {
|
||||
if (type == 1) {//这是获取顶部的推荐房间
|
||||
// Type listType = new TypeToken<List<TopRoom>>() {}.getType();
|
||||
// List<TopRoom> restoredRoomModels = GsonUtils.getGSON().fromJson(SpUtil.getTopRoomTop(), listType);
|
||||
// if (restoredRoomModels!= null && restoredRoomModels.size() > 0) {
|
||||
// MvpRef.get().setTopRoom(restoredRoomModels,type);
|
||||
// }
|
||||
api.getTopRooms(page+"",page_limit,is_top,label_id,new BaseObserver<List<TopRoom>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<TopRoom> topRooms) {
|
||||
SpUtil.setTopRoomTop(GsonUtils.getGSON().toJson(topRooms));
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().setTopRoom(topRooms,type);
|
||||
MvpRef.get().finishRefreshLoadMore();
|
||||
|
||||
}
|
||||
});
|
||||
}else if (type == 2){//这是获取所有房间
|
||||
// Type listType = new TypeToken<List<TopRoom>>() {}.getType();
|
||||
// List<TopRoom> restoredRoomModels = GsonUtils.getGSON().fromJson(SpUtil.getTopRoom(), listType);
|
||||
// if (restoredRoomModels!= null && restoredRoomModels.size() > 0) {
|
||||
// MvpRef.get().setTopRoom(restoredRoomModels, type);
|
||||
// }
|
||||
api.getTopRooms(page+"",page_limit,is_top,label_id,new BaseObserver<List<TopRoom>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<TopRoom> topRooms) {
|
||||
// SpUtil.setTopRoom(GsonUtils.getGSON().toJson(topRooms));
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().setTopRoom(topRooms,type);
|
||||
MvpRef.get().finishRefreshLoadMore();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.xscm.modulemain.activity.room.contacts.VoiceContacts;
|
||||
import com.xscm.moduleutil.bean.ActivitiesPermission;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class VoicePresenter extends BasePresenter<VoiceContacts.View> implements VoiceContacts.IIndexPre {
|
||||
private VoiceContacts.View mView;
|
||||
public VoicePresenter(VoiceContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
this.mView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBanners() {
|
||||
// NewApi.getInstance().getBannerList(new BaseObserver<List<BannerResp>>() {
|
||||
// @Override
|
||||
// public void onSubscribe(Disposable d) {
|
||||
// addDisposable(d);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(List<BannerResp> bannerResp) {
|
||||
// MvpRef.get().setBanners(bannerResp);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
//
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void getConfig() {
|
||||
// api.appUpdate(new com.qpyy.libcommon.http.BaseObserver<AppUpdateModel>() {
|
||||
// @Override
|
||||
// public void onSubscribe(Disposable d) {
|
||||
// addDisposable(d);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(AppUpdateModel appUpdateModel) {
|
||||
// String channelId = "default";
|
||||
// try {
|
||||
// channelId = MetaDataUtils.getMetaDataInApp("TD_CHANNEL_ID");
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// MvpRef.get().hideRecommend((appUpdateModel != null && appUpdateModel.getChannels() != null
|
||||
// && appUpdateModel.getChannels().contains(channelId))
|
||||
// || (appUpdateModel != null && !appUpdateModel.isShowRecommend())
|
||||
// , (appUpdateModel != null && appUpdateModel.getChannels() != null
|
||||
// && appUpdateModel.getChannels().contains(channelId))
|
||||
// || (appUpdateModel != null && !appUpdateModel.isShowGame()));
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
//
|
||||
// }
|
||||
// });
|
||||
MvpRef.get().hideRecommend(false, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getNameAuthResult(int type) {
|
||||
// NewApi.getInstance().getNameAuthResult(new com.qpyy.libcommon.api.BaseObserver<NameAuthResult>(false) {
|
||||
// @Override
|
||||
// public void onSubscribe(Disposable d) {
|
||||
// addDisposable(d);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(NameAuthResult result) {
|
||||
// if (result.getApp_status() == 2) {
|
||||
// ARouter.getInstance().build(ARouteConstants.AUTH_RESULT_PAGE).withString("failStr", result.getReason()).withInt("examineType", 1).withInt("returnResult", 3).navigation();
|
||||
// } else if (result.getApp_status() == 0) {
|
||||
//// ToastUtils.show("审核中");
|
||||
// ARouter.getInstance().build(ARouteConstants.AUTH_RESULT_PAGE).withString("failStr", result.getReason()).withInt("examineType", 1).withInt("returnResult", 1).navigation();
|
||||
// } else if (result.getApp_status() == 1) {
|
||||
//// ToastUtils.show("已认证");
|
||||
// ARouter.getInstance().build(ARouteConstants.AUTH_RESULT_PAGE).withString("failStr", result.getReason()).withInt("examineType", 1).withInt("returnResult", 2).navigation();
|
||||
// } else if (result.getApp_status() == 3) {
|
||||
// go2NameAuth(type);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onErrorCode(int code) {
|
||||
// super.onErrorCode(code);
|
||||
// if (code == ErrorCode.AUTH_NOT_EXIT) {
|
||||
// go2NameAuth(type);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
//
|
||||
// }
|
||||
// });
|
||||
}
|
||||
private void go2NameAuth(int type) {
|
||||
// if (type == 0) {
|
||||
// ARouter.getInstance().build(ARouteConstants.ME_NAME_AUTH).withString("from","我的界面").navigation();
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activitiesPermission() {
|
||||
api.activitiesPermission(new BaseObserver<ActivitiesPermission>() {
|
||||
@Override
|
||||
public void onSubscribe(@NotNull Disposable d) {
|
||||
addDisposable( d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NotNull ActivitiesPermission activitiesPermission) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().activitiesPermissionSuccess(activitiesPermission);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package com.xscm.modulemain.activity.room.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.xscm.modulemain.activity.room.contacts.WheatContacts;
|
||||
import com.xscm.moduleutil.bean.room.RoomApplyListBean;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class WheatPresenter extends BasePresenter<WheatContacts.View> implements WheatContacts.IRoomPre {
|
||||
|
||||
private WheatContacts.View mView;
|
||||
|
||||
public WheatPresenter(WheatContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
this.mView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void roomApplyListBean(String roomId) {
|
||||
api.roomApplyListBean(roomId, new BaseObserver<RoomApplyListBean>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(RoomApplyListBean roomApplyListBeans) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().roomApplyListBean(roomApplyListBeans);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearApply(String roomId) {
|
||||
api.clearApply(roomId, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().clearApply();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void agreePit(String roomId, String userId) {
|
||||
api.agreePit(roomId, userId, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().agreePit();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refusePit(String roomId, String userId) {
|
||||
api.refusePit(roomId, userId, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().agreePit();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void helpApply(String roomId, String userId) {
|
||||
api.helpApply(roomId, userId, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().agreePit();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyPit(String roomId, String pitNumber) {
|
||||
api.applyPit(roomId, pitNumber, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().applyPit();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void roomGift(String room_id, String gift_id, String gift_num, String to_uid, String type, String pit_number) {
|
||||
api.roomGift(room_id, gift_id, gift_num, to_uid, type, pit_number,"", new BaseObserver<String>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().giveGift();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user