1:修改点唱房的bug
2:添加公会消息类型
This commit is contained in:
@@ -12,10 +12,14 @@ public class NewsContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
void showNews(List<NewsMessageList> newsList);
|
||||
void finishRefresh();
|
||||
|
||||
void postInvite();
|
||||
}
|
||||
public interface IHomePre extends IPresenter {
|
||||
|
||||
void getMessagetitle(String type,String page,String pageLimit);
|
||||
|
||||
void postInvite(String apply_id, String type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,13 +6,16 @@ import com.xscm.moduleutil.bean.NewsMessageList;
|
||||
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 NewsPresenter extends BasePresenter<NewsContacts.View> implements NewsContacts.IHomePre {
|
||||
NewsContacts.View mView;
|
||||
public NewsPresenter(NewsContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
mView = view;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,9 +30,31 @@ public class NewsPresenter extends BasePresenter<NewsContacts.View> implements N
|
||||
|
||||
@Override
|
||||
public void onNext(List<NewsMessageList> newsMessageLists) {
|
||||
if (MvpRef==null){
|
||||
MvpRef=new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().showNews(newsMessageLists);
|
||||
MvpRef.get().finishRefresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInvite(String apply_id, String type) {
|
||||
api.postInvite(apply_id, 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().postInvite();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,48 +61,78 @@ public class OfficialNoticeActivity extends BaseMvpActivity<NewsPresenter, Activ
|
||||
protected void convert(BaseViewHolder helper, NewsMessageList item) {
|
||||
String time = TimeUtils.getDateToStringNoZ(Long.parseLong(item.getCreatetime()) * 1000L);
|
||||
helper.setText(R.id.tv_sys_time, time);
|
||||
if (item.getImage()==null || item.getImage().isEmpty()){
|
||||
helper.getView(R.id.tv_sys_con).setVisibility(VISIBLE);
|
||||
helper.setText(R.id.tv_sys_con, item.getContent());
|
||||
helper.getView(R.id.ll_system_official).setVisibility(GONE);
|
||||
}else {
|
||||
helper.getView(R.id.tv_sys_con).setVisibility(GONE);
|
||||
helper.getView(R.id.ll_system_official).setVisibility(VISIBLE);
|
||||
ImageUtils.loadHeadCC(item.getImage(), helper.getView(R.id.image));
|
||||
helper.setText(R.id.tv_cont, Html.fromHtml(item.getContent()));
|
||||
}
|
||||
helper.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (item.getRoom_id()>0){
|
||||
RoomManager.getInstance().fetchRoomDataAndEnter(getApplicationContext(), item.getRoom_id()+"","",null);
|
||||
// ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("roomId", item.getRoom_id() + "").navigation();
|
||||
}else if (item.getRoom_id() == 0 && item.getUrl() != null && !item.getUrl().isEmpty()){
|
||||
Intent intent = new Intent(OfficialNoticeActivity.this, WebViewActivity.class);
|
||||
intent.putExtra("url", item.getUrl());
|
||||
startActivity(intent);
|
||||
// ARouter.getInstance().build(ARouteConstants.H5).withString("url", item.getUrl()).navigation();
|
||||
}
|
||||
if (item.getType() == 6) {
|
||||
helper.getView(R.id.ll_system).setVisibility(GONE);
|
||||
helper.getView(R.id.ll_gh).setVisibility(VISIBLE);
|
||||
|
||||
helper.setText(R.id.tv_sys_cons, item.getContent());
|
||||
if (item.getGuild_invited_status()==0){
|
||||
helper.getView(R.id.ll_but).setVisibility(VISIBLE);
|
||||
helper.getView(R.id.tv_cancel2).setVisibility(GONE);
|
||||
}else if (item.getGuild_invited_status()==1){
|
||||
helper.getView(R.id.ll_but).setVisibility(GONE);
|
||||
helper.getView(R.id.tv_cancel2).setVisibility(VISIBLE);
|
||||
helper.setText(R.id.tv_cancel2,"已同意");
|
||||
}else if (item.getGuild_invited_status()==2){
|
||||
helper.getView(R.id.ll_but).setVisibility(GONE);
|
||||
helper.getView(R.id.tv_cancel2).setVisibility(VISIBLE);
|
||||
helper.setText(R.id.tv_cancel2,"已拒绝");
|
||||
}
|
||||
});
|
||||
helper.getView(R.id.tv_cancel).setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
MvpPre.postInvite(item.getId()+"","2");
|
||||
helper.getView(R.id.ll_but).setVisibility(GONE);
|
||||
helper.getView(R.id.tv_cancel2).setVisibility(VISIBLE);
|
||||
helper.setText(R.id.tv_cancel2,"已拒绝");
|
||||
}
|
||||
});
|
||||
|
||||
helper.getView(R.id.tv_confirm).setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
MvpPre.postInvite(item.getId()+"","1");
|
||||
helper.getView(R.id.ll_but).setVisibility(GONE);
|
||||
helper.getView(R.id.tv_cancel2).setVisibility(VISIBLE);
|
||||
helper.setText(R.id.tv_cancel2,"已同意");
|
||||
MvpPre.getMessagetitle(type, "1", "10");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// if (item.getType().equals("1")) {
|
||||
// helper.getView(R.id.ll_system_official).setVisibility(GONE);
|
||||
// } else if (item.getType().equals("2")) {
|
||||
// helper.getView(R.id.tv_sys_con).setVisibility(GONE);
|
||||
// helper.getView(R.id.ll_system_official).setVisibility(VISIBLE);
|
||||
// } else {
|
||||
// helper.getView(R.id.ll_system_official).setVisibility(GONE);
|
||||
// }
|
||||
} else {
|
||||
helper.getView(R.id.ll_system).setVisibility(VISIBLE);
|
||||
helper.getView(R.id.ll_gh).setVisibility(GONE);
|
||||
if (item.getImage() == null || item.getImage().isEmpty()) {
|
||||
helper.getView(R.id.tv_sys_con).setVisibility(VISIBLE);
|
||||
helper.setText(R.id.tv_sys_con, item.getContent());
|
||||
helper.getView(R.id.ll_system_official).setVisibility(GONE);
|
||||
} else {
|
||||
helper.getView(R.id.tv_sys_con).setVisibility(GONE);
|
||||
helper.getView(R.id.ll_system_official).setVisibility(VISIBLE);
|
||||
ImageUtils.loadHeadCC(item.getImage(), helper.getView(R.id.image));
|
||||
helper.setText(R.id.tv_cont, Html.fromHtml(item.getContent()));
|
||||
}
|
||||
helper.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (item.getRoom_id() > 0) {
|
||||
RoomManager.getInstance().fetchRoomDataAndEnter(getApplicationContext(), item.getRoom_id() + "", "", null);
|
||||
// ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("roomId", item.getRoom_id() + "").navigation();
|
||||
} else if (item.getRoom_id() == 0 && item.getUrl() != null && !item.getUrl().isEmpty()) {
|
||||
Intent intent = new Intent(OfficialNoticeActivity.this, WebViewActivity.class);
|
||||
intent.putExtra("url", item.getUrl());
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// helper.getView(R.id.image).setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
//
|
||||
// }
|
||||
// });
|
||||
}
|
||||
};
|
||||
mBinding.recycleView.setAdapter(mAdapter);
|
||||
@@ -122,7 +152,18 @@ public class OfficialNoticeActivity extends BaseMvpActivity<NewsPresenter, Activ
|
||||
|
||||
@Override
|
||||
public void showNews(List<NewsMessageList> newsList) {
|
||||
mAdapter.setNewData(newsList);
|
||||
// 判断是否为第一页
|
||||
if (page == 1) {
|
||||
// 第一页,使用setNewData替换所有数据
|
||||
mAdapter.setNewData(newsList);
|
||||
} else {
|
||||
// 非第一页(上拉加载),判断是否有数据
|
||||
if (newsList != null && !newsList.isEmpty()) {
|
||||
// 有数据,添加到现有数据中
|
||||
mAdapter.addData(newsList);
|
||||
}
|
||||
// 如果没有数据,不做任何操作,保持原有数据不变
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -130,4 +171,9 @@ public class OfficialNoticeActivity extends BaseMvpActivity<NewsPresenter, Activ
|
||||
mBinding.smartRefreshLayout.finishRefresh();
|
||||
mBinding.smartRefreshLayout.finishLoadMore();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInvite() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1032,7 +1032,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
|
||||
fun getRoomInfoResp(): List<RoomPitBean>? {
|
||||
val roomPitBeans = mRoomInfoResp?.room_info?.pit_list.orEmpty().filter {
|
||||
it.user_id != null && it.user_id != "0" && it.user_id.isNotEmpty()&& it.user_id.toInt() != SpUtil.getUserId()
|
||||
it.user_id != null && it.user_id != "0" && it.user_id.isNotEmpty()&& it.user_id.toInt() != SpUtil.getUserId() && it.pit_number.toInt()<9
|
||||
}
|
||||
return roomPitBeans.ifEmpty { null }
|
||||
}
|
||||
@@ -3692,7 +3692,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
// TODO: 根据返回的在线列表获取对应的值,查看是否有在线用户
|
||||
override fun getRoomOnline(onlineBean: RoomOnline?) {
|
||||
if (onlineBean != null) {
|
||||
val onlineBeans: MutableList<RoomOnlineBean> = ArrayList()
|
||||
@@ -3818,7 +3818,12 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
}
|
||||
|
||||
RoomType.JUKEBOX -> {
|
||||
changeBackgroundColor(mRoomInfoResp!!.room_info.room_background)
|
||||
if (mRoomInfoResp!!.room_info.room_background == null || mRoomInfoResp!!.room_info.room_background == "") {
|
||||
changeBackground(com.xscm.moduleutil.R.mipmap.jukebox_bj)
|
||||
} else {
|
||||
changeBackgroundColor(mRoomInfoResp!!.room_info.room_background)
|
||||
}
|
||||
// changeBackgroundColor(mRoomInfoResp!!.room_info.room_background)
|
||||
setvisibTop(true)
|
||||
QXRoomSeatViewType.JUKEBOX
|
||||
}
|
||||
|
||||
@@ -4,9 +4,12 @@ import static android.view.View.GONE;
|
||||
import static android.view.View.VISIBLE;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.PopupWindow;
|
||||
import android.widget.Switch;
|
||||
@@ -93,6 +96,7 @@ public class RoomJukeboxFragment extends BaseMvpFragment<JukeboxPresenter, Fragm
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
initPopupWindow();
|
||||
mBinding.guestContainer.setVisibility(GONE);
|
||||
adapter = new RoomJukeboxAdapter(R.layout.item_jukebox);
|
||||
GridLayoutManager layoutManager = new GridLayoutManager(getContext(), 4);
|
||||
@@ -227,6 +231,34 @@ public class RoomJukeboxFragment extends BaseMvpFragment<JukeboxPresenter, Fragm
|
||||
return false; // 不是快速重复点击
|
||||
}
|
||||
|
||||
private void initPopupWindow() {
|
||||
// 加载弹出视图布局
|
||||
View popupView = LayoutInflater.from(getContext()).inflate(R.layout.popup_menu, null, false);
|
||||
|
||||
// 创建 PopupWindow
|
||||
DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
|
||||
// 设置固定宽高(单位是像素)
|
||||
int screenWidth = displayMetrics.widthPixels;
|
||||
int screenHeight = displayMetrics.heightPixels;
|
||||
|
||||
int popupWidth = (int) (screenWidth * 0.25); // 屏幕宽度的 60%
|
||||
int popupHeight = (int) (screenHeight * 0.13); // 屏幕高度的 40%
|
||||
|
||||
popupWindow = new PopupWindow(popupView, popupWidth, popupHeight, true);
|
||||
|
||||
// 必须设置背景,否则布局会压缩
|
||||
popupWindow.setBackgroundDrawable(getResources().getDrawable(com.xscm.moduleutil.R.drawable.bg_r16_fff));
|
||||
|
||||
// 设置动画效果(可选)
|
||||
popupWindow.setAnimationStyle(com.xscm.moduleutil.R.style.PopupAnimation);
|
||||
|
||||
// 设置点击外部区域时自动关闭
|
||||
popupWindow.setOutsideTouchable(true);
|
||||
popupWindow.setFocusable(true);
|
||||
|
||||
// 设置弹出视图中的点击事件
|
||||
setPopupMenuClickListener(popupView, null);
|
||||
}
|
||||
private void showPopupMenu(View anchorView) {
|
||||
if (popupWindow != null && !popupWindow.isShowing()) {
|
||||
// 获取锚点视图的坐标
|
||||
@@ -359,11 +391,13 @@ public class RoomJukeboxFragment extends BaseMvpFragment<JukeboxPresenter, Fragm
|
||||
mBinding.tvPerformerName.setVisibility(GONE);
|
||||
mBinding.tvNetName.setVisibility(VISIBLE);
|
||||
mBinding.ciNetAva.setVisibility(VISIBLE);
|
||||
setUserAvaSize(63);
|
||||
ImageUtils.loadHead(roomInfoResp.getSinger_info().getSong_info().getSinger_avatar(), mBinding.ciUserAva);
|
||||
// ImageUtils.loadHead(roomInfoResp.getSinger_info().getSong_info().getSinger_avatar(), mBinding.ciUserAva);
|
||||
mBinding.tvSong.setText("演唱歌曲:" + roomInfoResp.getSinger_info().getSong_info().getSong_name());
|
||||
ImageUtils.loadHead(roomInfoResp.getSinger_info().getSong_info().getBoss_avatar(), mBinding.ciNetAva);
|
||||
mBinding.tvNetName.setText("老板");
|
||||
songId = roomInfoResp.getSinger_info().getSong_info().getSinger_song_id();
|
||||
songId = roomInfoResp.getSinger_info().getSong_info().getId();
|
||||
|
||||
if (roomInfoResp.getSinger_info().getNext_song_info() != null) {
|
||||
mBinding.guestContainer.setVisibility(View.VISIBLE);
|
||||
@@ -374,6 +408,9 @@ public class RoomJukeboxFragment extends BaseMvpFragment<JukeboxPresenter, Fragm
|
||||
}
|
||||
|
||||
String userId = String.valueOf(roomInfoResp.getSinger_info().getSong_info().getSinger_user_id());
|
||||
if (userId.equals(SpUtil.getUserId()+"")){
|
||||
upMike(true);
|
||||
}
|
||||
if (mBinding.wvZc.getUserId().equals(userId)) {
|
||||
mBinding.wvZc.pitBean.setImageType(true);
|
||||
mBinding.wvZc.setData(mBinding.wvZc.pitBean);
|
||||
@@ -388,11 +425,19 @@ public class RoomJukeboxFragment extends BaseMvpFragment<JukeboxPresenter, Fragm
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
} else {
|
||||
setUserAvaSize(32);
|
||||
mBinding.ciUserAva.setImageResource(R.mipmap.microphone);
|
||||
mBinding.tvPerformerName.setVisibility(VISIBLE);
|
||||
mBinding.tvNetName.setVisibility(GONE);
|
||||
mBinding.ciNetAva.setVisibility(GONE);
|
||||
mBinding.tvSong.setText("演唱歌曲:无");
|
||||
mBinding.imQg.setVisibility(GONE);
|
||||
}
|
||||
|
||||
}
|
||||
if (mBinding.wvZc.getUserId()!=null && !mBinding.wvZc.getUserId().equals("0") && !mBinding.wvZc.getUserId().equals("") && mBinding.wvZc.getUserId().equals(SpUtil.getUserId()+"")) {
|
||||
mBinding.imQg.setVisibility(VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -614,6 +659,8 @@ public class RoomJukeboxFragment extends BaseMvpFragment<JukeboxPresenter, Fragm
|
||||
ImageUtils.loadHead(messageEvent.getText().getNext_song_info().getSinger_avatar(), mBinding.ciGsAva);
|
||||
mBinding.tvGsName.setText(messageEvent.getText().getNext_song_info().getSinger_nickname());
|
||||
roomInfoResp.getSinger_info().setNext_song_info(messageEvent.getText().getNext_song_info());
|
||||
}else {
|
||||
mBinding.guestContainer.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -624,14 +671,21 @@ public class RoomJukeboxFragment extends BaseMvpFragment<JukeboxPresenter, Fragm
|
||||
mBinding.tvPerformerName.setVisibility(GONE);
|
||||
mBinding.tvNetName.setVisibility(VISIBLE);
|
||||
mBinding.ciNetAva.setVisibility(VISIBLE);
|
||||
setUserAvaSize(63);
|
||||
|
||||
|
||||
ImageUtils.loadHead(messageEvent.getText().getSong_info().getSinger_avatar(), mBinding.ciUserAva);
|
||||
mBinding.tvSong.setText("演唱歌曲:" + messageEvent.getText().getSong_info().getSong_name());
|
||||
|
||||
roomInfoResp.getSinger_info().setSong_info(messageEvent.getText().getSong_info());
|
||||
ImageUtils.loadHead(messageEvent.getText().getSong_info().getBoss_avatar(), mBinding.ciNetAva);
|
||||
mBinding.tvNetName.setText("老板");
|
||||
songId = messageEvent.getText().getSong_info().getSinger_song_id();
|
||||
songId = messageEvent.getText().getSong_info().getId();
|
||||
String userId = String.valueOf(messageEvent.getText().getSong_info().getSinger_user_id());
|
||||
if (userId.equals(SpUtil.getUserId()+"")){
|
||||
upMike(true);
|
||||
}
|
||||
|
||||
if (mBinding.wvZc.getUserId().equals(userId)) {
|
||||
mBinding.wvZc.pitBean.setImageType(true);
|
||||
mBinding.wvZc.setData(mBinding.wvZc.pitBean);
|
||||
@@ -645,6 +699,31 @@ public class RoomJukeboxFragment extends BaseMvpFragment<JukeboxPresenter, Fragm
|
||||
}
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}else {
|
||||
setUserAvaSize(32);
|
||||
mBinding.ciUserAva.setImageResource(R.mipmap.microphone);
|
||||
mBinding.tvPerformerName.setVisibility(VISIBLE);
|
||||
mBinding.tvNetName.setVisibility(GONE);
|
||||
mBinding.ciNetAva.setVisibility(GONE);
|
||||
mBinding.tvSong.setText("演唱歌曲:无");
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: 2025/11/22 当有演唱者的时候,修改演唱者头像的大小
|
||||
private void setUserAvaSize(int size) {
|
||||
// 设置控件大小为50dp x 50dp
|
||||
int sizeInPx = (int) (size * getResources().getDisplayMetrics().density + 0.5f);
|
||||
ViewGroup.LayoutParams layoutParams = mBinding.ciUserAva.getLayoutParams();
|
||||
layoutParams.width = sizeInPx;
|
||||
layoutParams.height = sizeInPx;
|
||||
mBinding.ciUserAva.setLayoutParams(layoutParams);
|
||||
}
|
||||
|
||||
// TODO: 2025/11/22 当在演唱位的时候,显示麦克风,当上麦的时候,也展示麦克风,
|
||||
private void upMike(boolean isBool){
|
||||
if (getActivity() != null) {
|
||||
// 假设Activity有获取麦位数据的方法
|
||||
((RoomActivity) getActivity()).setrlMic(isBool);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -91,8 +91,10 @@ public class SongRequestFragment extends BaseMvpFragment<RequestSongPresenter, F
|
||||
// 初始化麦位RecyclerView
|
||||
wheatPositionAdapter = new WheatPositionAdapter(new ArrayList<>());
|
||||
wheatPositionAdapter.setOnItemSelectedListener(position -> {
|
||||
selectedWheatPosition = Integer.parseInt(position.getUser_id());
|
||||
updateSongList(selectedWheatPosition);
|
||||
if (position != null && position.getUser_id() != null && !position.getUser_id().isEmpty()) {
|
||||
selectedWheatPosition = Integer.parseInt(position.getUser_id());
|
||||
updateSongList(selectedWheatPosition);
|
||||
}
|
||||
});
|
||||
|
||||
mBinding.rvWheatPositions.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false));
|
||||
|
||||
@@ -374,7 +374,7 @@ public class SingerVerificationActivity extends BaseMvpActivity<SingerVerificati
|
||||
}
|
||||
|
||||
// 检查录音时长是否达到最小要求(60秒)
|
||||
if (recordingDuration < 5 * 1000) {
|
||||
if (recordingDuration < 60 * 1000) {
|
||||
Toast.makeText(this, "录音时间太短,请至少录制60秒", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
@@ -432,7 +432,6 @@ public class SingerVerificationActivity extends BaseMvpActivity<SingerVerificati
|
||||
}
|
||||
}
|
||||
|
||||
// 停止播放
|
||||
private void stopPlaying() {
|
||||
try {
|
||||
if (mediaPlayer != null) {
|
||||
@@ -458,6 +457,7 @@ public class SingerVerificationActivity extends BaseMvpActivity<SingerVerificati
|
||||
updateUI();
|
||||
}
|
||||
}
|
||||
// 停止播放
|
||||
|
||||
// 重新录音
|
||||
private void reRecord() {
|
||||
@@ -500,11 +500,20 @@ public class SingerVerificationActivity extends BaseMvpActivity<SingerVerificati
|
||||
|
||||
// 提交认证
|
||||
private void submitVerification() {
|
||||
// 如果有多个录音片段,先处理它们
|
||||
// 如果有多个录音片段,先合并它们
|
||||
if (recordingSegments.size() > 1) {
|
||||
mergeAudioFiles();
|
||||
// 如果还没有合并文件,先进行合并
|
||||
if (mergedRecordingFile == null || !mergedRecordingFile.exists()) {
|
||||
Log.d("SingerVerification", "提交前合并音频片段,共 " + recordingSegments.size() + " 个片段");
|
||||
mergeAudioFiles();
|
||||
} else {
|
||||
Log.d("SingerVerification", "使用已合并的音频文件: " + mergedRecordingFile.getAbsolutePath());
|
||||
recordingFile = mergedRecordingFile;
|
||||
}
|
||||
} else if (recordingSegments.size() == 1) {
|
||||
// 只有一个片段,直接使用
|
||||
recordingFile = recordingSegments.get(0);
|
||||
Log.d("SingerVerification", "使用单个录音片段: " + recordingFile.getAbsolutePath());
|
||||
}
|
||||
|
||||
if (recordingFile == null || !recordingFile.exists()) {
|
||||
@@ -513,11 +522,13 @@ public class SingerVerificationActivity extends BaseMvpActivity<SingerVerificati
|
||||
}
|
||||
|
||||
// 检查录音时长是否达到最小要求(60秒)
|
||||
if (recordingDuration < 5 * 1000) {
|
||||
if (recordingDuration < 60 * 1000) {
|
||||
Toast.makeText(this, "录音时间太短,请至少录制60秒", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
Log.d("SingerVerification", "提交认证,使用文件: " + recordingFile.getAbsolutePath() +
|
||||
", 大小: " + recordingFile.length() + " bytes");
|
||||
MvpPre.uploadFile(recordingFile, 3);
|
||||
}
|
||||
|
||||
@@ -621,7 +632,11 @@ public class SingerVerificationActivity extends BaseMvpActivity<SingerVerificati
|
||||
handleMergeError(e);
|
||||
} finally {
|
||||
cleanupResources(muxer, buffer);
|
||||
cleanupSegments(processedSegments);
|
||||
// 修复:延迟删除原始音频片段,确保合并文件已经完全写入且被使用
|
||||
// 延迟删除,给用户足够时间试听
|
||||
new Handler().postDelayed(() -> {
|
||||
cleanupSegments(processedSegments);
|
||||
}, 30000); // 延迟30秒删除,确保用户有足够时间试听
|
||||
}
|
||||
}
|
||||
|
||||
@@ -646,6 +661,8 @@ public class SingerVerificationActivity extends BaseMvpActivity<SingerVerificati
|
||||
ByteBuffer buffer, MediaCodec.BufferInfo bufferInfo, long baseTimeUs) throws IOException {
|
||||
MediaExtractor extractor = new MediaExtractor();
|
||||
long actualDuration = 0;
|
||||
long firstSampleTime = Long.MAX_VALUE;
|
||||
long lastSampleTime = 0;
|
||||
|
||||
try {
|
||||
extractor.setDataSource(segment.getAbsolutePath());
|
||||
@@ -661,9 +678,18 @@ public class SingerVerificationActivity extends BaseMvpActivity<SingerVerificati
|
||||
Log.d("SingerVerification", "处理片段: " + segment.getAbsolutePath() +
|
||||
", 估计时长: " + estimatedDuration + "us, 基准时间: " + baseTimeUs + "us");
|
||||
|
||||
long maxSampleTime = 0;
|
||||
int sampleCount = 0;
|
||||
|
||||
// 先读取第一个样本的时间戳,作为片段的起始时间
|
||||
extractor.seekTo(0, MediaExtractor.SEEK_TO_CLOSEST_SYNC);
|
||||
long firstFrameTime = extractor.getSampleTime();
|
||||
if (firstFrameTime == -1) {
|
||||
firstFrameTime = 0;
|
||||
}
|
||||
|
||||
// 重置到文件开头
|
||||
extractor.seekTo(0, MediaExtractor.SEEK_TO_PREVIOUS_SYNC);
|
||||
|
||||
while (true) {
|
||||
int sampleSize = extractor.readSampleData(buffer, 0);
|
||||
if (sampleSize < 0) {
|
||||
@@ -672,18 +698,23 @@ public class SingerVerificationActivity extends BaseMvpActivity<SingerVerificati
|
||||
|
||||
long sampleTime = extractor.getSampleTime();
|
||||
if (sampleTime == -1) {
|
||||
// 如果没有时间戳,使用估计值(不推荐)
|
||||
// 如果没有时间戳,使用估计值
|
||||
sampleTime = sampleCount * 1000000 / 44100; // 假设44.1kHz
|
||||
}
|
||||
|
||||
// 记录最大样本时间作为实际持续时间
|
||||
if (sampleTime > maxSampleTime) {
|
||||
maxSampleTime = sampleTime;
|
||||
// 记录第一个和最后一个样本时间
|
||||
if (firstSampleTime == Long.MAX_VALUE) {
|
||||
firstSampleTime = sampleTime;
|
||||
}
|
||||
lastSampleTime = sampleTime;
|
||||
|
||||
// 重新计算时间戳,确保每个片段从baseTimeUs开始
|
||||
// 使用相对时间戳(相对于片段的第一个样本)
|
||||
long relativeTime = sampleTime - firstFrameTime;
|
||||
|
||||
bufferInfo.offset = 0;
|
||||
bufferInfo.size = sampleSize;
|
||||
bufferInfo.presentationTimeUs = baseTimeUs + sampleTime;
|
||||
bufferInfo.presentationTimeUs = baseTimeUs + relativeTime;
|
||||
bufferInfo.flags = extractor.getSampleFlags();
|
||||
|
||||
// 确保时间戳是递增的
|
||||
@@ -696,10 +727,13 @@ public class SingerVerificationActivity extends BaseMvpActivity<SingerVerificati
|
||||
sampleCount++;
|
||||
}
|
||||
|
||||
// 修复:使用实际的最大样本时间 + 最后一个样本的持续时间估计
|
||||
if (maxSampleTime > 0) {
|
||||
// 添加最后一个样本的估计持续时间(假设20ms)
|
||||
actualDuration = maxSampleTime + 20000;
|
||||
// 计算实际持续时间
|
||||
if (lastSampleTime > firstSampleTime && firstSampleTime != Long.MAX_VALUE) {
|
||||
// 使用实际的样本时间差
|
||||
actualDuration = lastSampleTime - firstSampleTime + 20000; // 添加最后一个样本的估计持续时间
|
||||
} else if (sampleCount > 0) {
|
||||
// 如果没有有效的时间戳,使用样本数量估算
|
||||
actualDuration = sampleCount * 1000000 / 44100; // 假设44.1kHz
|
||||
} else {
|
||||
// 如果没有样本,使用格式的估计值
|
||||
actualDuration = estimatedDuration;
|
||||
@@ -729,6 +763,7 @@ public class SingerVerificationActivity extends BaseMvpActivity<SingerVerificati
|
||||
if (mergedRecordingFile != null && mergedRecordingFile.exists() && mergedRecordingFile.length() > 0) {
|
||||
recordingFile = mergedRecordingFile;
|
||||
Log.d("SingerVerification", "音频文件合并完成,文件大小: " + mergedRecordingFile.length() + " bytes");
|
||||
Log.d("SingerVerification", "设置当前播放文件为合并文件: " + mergedRecordingFile.getAbsolutePath());
|
||||
} else {
|
||||
Log.e("SingerVerification", "合并文件不存在或为空,使用第一个录音片段");
|
||||
if (!recordingSegments.isEmpty()) {
|
||||
@@ -736,8 +771,9 @@ public class SingerVerificationActivity extends BaseMvpActivity<SingerVerificati
|
||||
}
|
||||
}
|
||||
|
||||
// 清理录音片段列表
|
||||
recordingSegments.clear();
|
||||
// 修复:不立即清空录音片段列表,延迟清空以确保合并文件可以被正确使用
|
||||
// 将在延迟删除片段时清空列表
|
||||
Log.d("SingerVerification", "保留录音片段列表,将在延迟删除时清空");
|
||||
}
|
||||
|
||||
private void handleMergeError(Exception e) {
|
||||
@@ -760,7 +796,7 @@ public class SingerVerificationActivity extends BaseMvpActivity<SingerVerificati
|
||||
}
|
||||
|
||||
private void cleanupSegments(List<File> segments) {
|
||||
// 延迟删除片段,确保合并文件已经完全写入
|
||||
// 延迟删除片段,确保合并文件已经完全写入且被使用
|
||||
new Handler().postDelayed(() -> {
|
||||
for (File segment : segments) {
|
||||
try {
|
||||
@@ -776,6 +812,10 @@ public class SingerVerificationActivity extends BaseMvpActivity<SingerVerificati
|
||||
Log.e("SingerVerification", "删除音频片段失败: " + segment.getAbsolutePath(), e);
|
||||
}
|
||||
}
|
||||
|
||||
// 修复:删除所有片段后,清空录音片段列表
|
||||
recordingSegments.clear();
|
||||
Log.d("SingerVerification", "已清空录音片段列表");
|
||||
}, 2000); // 延迟2秒删除,确保合并文件已经完全写入
|
||||
}
|
||||
|
||||
@@ -813,7 +853,8 @@ public class SingerVerificationActivity extends BaseMvpActivity<SingerVerificati
|
||||
@Override
|
||||
public void singerAuth(String s) {
|
||||
reRecord();
|
||||
finish();
|
||||
mBinding.clCorner.setVisibility(GONE);
|
||||
mBinding.cornerStatus.setText("认证中");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -43,6 +43,15 @@ public class UserPlaylistActivity extends BaseMvpActivity<SingerVerificationPres
|
||||
//新增歌单
|
||||
// 在Activity或Fragment中调用
|
||||
CustomInputDialog customInputDialog = new CustomInputDialog(UserPlaylistActivity.this);
|
||||
customInputDialog.setOnDialogDismissListener(new CustomInputDialog.OnDialogDismissListener() {
|
||||
@Override
|
||||
public void onDialogDismiss(boolean dataChanged) {
|
||||
if (dataChanged)
|
||||
// 数据已更改,重新加载数据
|
||||
page = 1;
|
||||
MvpPre.getSong(SpUtil.getUserId() + "", "", page + "", "10");
|
||||
}
|
||||
});
|
||||
customInputDialog.show();
|
||||
}
|
||||
});
|
||||
@@ -67,7 +76,7 @@ public class UserPlaylistActivity extends BaseMvpActivity<SingerVerificationPres
|
||||
if (dataChanged)
|
||||
// 数据已更改,重新加载数据
|
||||
page = 1;
|
||||
MvpPre.getSong(SpUtil.getUserId() + "", "", page + "", "10");
|
||||
MvpPre.getSong(SpUtil.getUserId() + "", "", page + "", "10");
|
||||
}
|
||||
});
|
||||
customInputDialog.show();
|
||||
|
||||
@@ -66,17 +66,16 @@
|
||||
|
||||
|
||||
|
||||
<com.xscm.moduleutil.widget.CircularImage
|
||||
<com.makeramen.roundedimageview.RoundedImageView
|
||||
android:id="@+id/ci_user_ava"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginHorizontal="@dimen/dp_95"
|
||||
android:layout_marginVertical="@dimen/dp_50"
|
||||
android:layout_width="@dimen/dp_32"
|
||||
android:layout_height="@dimen/dp_32"
|
||||
android:src="@mipmap/microphone"
|
||||
app:layout_constraintEnd_toEndOf="@+id/im_performer"
|
||||
app:layout_constraintStart_toStartOf="@+id/im_performer"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/im_performer"
|
||||
app:layout_constraintTop_toTopOf="@+id/im_performer" />
|
||||
app:layout_constraintTop_toTopOf="@+id/im_performer"
|
||||
app:riv_oval="true"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_performer_name"
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_marginTop="@dimen/dp_12"
|
||||
android:paddingLeft="@dimen/dp_16"
|
||||
android:paddingRight="@dimen/dp_16">
|
||||
@@ -40,74 +40,151 @@
|
||||
android:id="@+id/ll_system_official"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_marginTop="@dimen/dp_16"
|
||||
android:background="@drawable/bg_r16_fff">
|
||||
android:background="@drawable/bg_r16_fff"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.tencent.qcloud.tuikit.timcommon.component.RoundCornerImageView
|
||||
android:id="@+id/image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_135"
|
||||
android:layout_marginLeft="@dimen/dp_12"
|
||||
android:layout_marginRight="@dimen/dp_12"
|
||||
android:layout_marginTop="@dimen/dp_12"
|
||||
android:layout_marginRight="@dimen/dp_12"
|
||||
android:scaleType="fitXY"
|
||||
app:corner_radius="@dimen/dp_8"
|
||||
android:src="@mipmap/default_avatar"
|
||||
/>
|
||||
app:corner_radius="@dimen/dp_8" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_cont"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_6"
|
||||
android:layout_marginLeft="@dimen/dp_12"
|
||||
android:layout_marginTop="@dimen/dp_6"
|
||||
android:layout_marginRight="@dimen/dp_12"
|
||||
android:gravity="left|center"
|
||||
android:text="【某某传媒·粉丝狂欢】今晚22点已开启嗨玩三重奏,不仅有才艺舞台,还有分组pk,粉丝互动环节等你来~"
|
||||
android:textColor="@color/color_FF333333"
|
||||
android:textSize="@dimen/sp_14" />
|
||||
android:textSize="@dimen/sp_14"
|
||||
tools:text="【某某传媒·粉丝狂欢】今晚22点已开启嗨玩三重奏,不仅有才艺舞台,还有分组pk,粉丝互动环节等你来~" />
|
||||
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_0_5"
|
||||
android:background="#E2E2E2"
|
||||
android:layout_marginTop="@dimen/dp_16"
|
||||
android:layout_marginStart="@dimen/dp_12"
|
||||
android:layout_marginTop="@dimen/dp_16"
|
||||
android:layout_marginEnd="@dimen/dp_12"
|
||||
/>
|
||||
android:background="#E2E2E2" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_8"
|
||||
android:layout_marginBottom="@dimen/dp_12"
|
||||
>
|
||||
android:layout_marginBottom="@dimen/dp_12">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_lock"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/dp_12"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_marginStart="@dimen/dp_12"
|
||||
android:gravity="left|center"
|
||||
android:text="立即查看"
|
||||
android:textColor="@color/color_FF333333"
|
||||
android:textSize="@dimen/sp_16"
|
||||
android:textStyle="bold"
|
||||
/>
|
||||
android:textStyle="bold" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/detail_icon_go"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_marginEnd="@dimen/dp_12"
|
||||
/>
|
||||
android:src="@drawable/detail_icon_go" />
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_gh"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/bg_r16_fff"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/dp_10"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="@dimen/dp_10"
|
||||
android:gravity="center"
|
||||
android:text="公会通知"
|
||||
android:textColor="@color/color_FF333333"
|
||||
android:textSize="@dimen/sp_14" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_sys_cons"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_10"
|
||||
android:gravity="left|center"
|
||||
android:padding="@dimen/dp_5"
|
||||
android:text="系统消息"
|
||||
android:textColor="@color/color_FF333333"
|
||||
android:textSize="@dimen/sp_12" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_but"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_cancel"
|
||||
android:layout_width="@dimen/dp_110"
|
||||
android:layout_height="@dimen/dp_40"
|
||||
android:layout_marginEnd="@dimen/dp_10"
|
||||
android:background="@drawable/bg_r53_f3f3f3"
|
||||
android:gravity="center"
|
||||
android:text="拒绝"
|
||||
android:textColor="@color/color_FF999999"
|
||||
android:textSize="@dimen/sp_14" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_confirm"
|
||||
android:layout_width="@dimen/dp_110"
|
||||
android:layout_height="@dimen/dp_40"
|
||||
android:layout_marginStart="@dimen/dp_10"
|
||||
android:background="@drawable/bg_r53_0dffb9"
|
||||
android:backgroundTint="#3ABC6D"
|
||||
android:gravity="center"
|
||||
android:text="同意"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/sp_14" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_cancel2"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="@dimen/dp_40"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginEnd="@dimen/dp_10"
|
||||
android:background="@drawable/bg_r53_f3f3f3"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/color_FF999999"
|
||||
android:textSize="@dimen/sp_14"
|
||||
android:visibility="gone"
|
||||
tools:text="取消" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
@@ -59,11 +59,12 @@
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitCenter"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintWidth_percent="1.1"
|
||||
app:layout_constraintHeight_percent="0.9"
|
||||
app:layout_constraintBottom_toBottomOf="@id/riv"
|
||||
app:layout_constraintEnd_toEndOf="@id/riv"
|
||||
app:layout_constraintStart_toStartOf="@id/riv"
|
||||
app:layout_constraintTop_toTopOf="@id/riv"
|
||||
app:layout_constraintWidth_percent="1.15"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<!-- 麦圈 - 在头像框上面展示 -->
|
||||
|
||||
Reference in New Issue
Block a user