diff --git a/agora-ktv-kit-release/.gitignore b/agora-ktv-kit-release/.gitignore deleted file mode 100644 index 36af4938d..000000000 --- a/agora-ktv-kit-release/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/build -*.iml -*.DS_Store \ No newline at end of file diff --git a/agora-ktv-kit-release/agora-ktv-kit-release.aar b/agora-ktv-kit-release/agora-ktv-kit-release.aar deleted file mode 100644 index a3a1b801c..000000000 Binary files a/agora-ktv-kit-release/agora-ktv-kit-release.aar and /dev/null differ diff --git a/agora-ktv-kit-release/build.gradle b/agora-ktv-kit-release/build.gradle deleted file mode 100644 index 5e82351ab..000000000 --- a/agora-ktv-kit-release/build.gradle +++ /dev/null @@ -1,2 +0,0 @@ -configurations.maybeCreate("default") -artifacts.add("default", file('agora-ktv-kit-release.aar')) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a282fc906..c27c158c8 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -875,23 +875,6 @@ - - - - @Override public void exitRoom(RoomInfo roomInfo) { closeOpenRoomAnimation(); - //ktv退出的时候需要用到 - if (AudioEngineManager.get().isOpenKtv() && roomInfo != null) { - KtvMusicManager.INSTANCE.deleteUserAllChooseMusic(roomInfo.getUid()).subscribe(); - AudioEngineManager.get().closeKtvModel(); - } DaemonService.stop(MainActivity.this); } diff --git a/app/src/main/java/com/yizhuan/erban/avroom/adapter/KtvMicroViewAdapter.java b/app/src/main/java/com/yizhuan/erban/avroom/adapter/KtvMicroViewAdapter.java deleted file mode 100644 index 0623d3d7a..000000000 --- a/app/src/main/java/com/yizhuan/erban/avroom/adapter/KtvMicroViewAdapter.java +++ /dev/null @@ -1,189 +0,0 @@ -package com.yizhuan.erban.avroom.adapter; - -import android.content.Context; - -import androidx.recyclerview.widget.GridLayoutManager; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.TextView; - -import com.netease.nim.uikit.common.util.sys.ScreenUtil; -import com.netease.nimlib.sdk.chatroom.model.ChatRoomMember; -import com.yizhuan.erban.R; -import com.yizhuan.erban.avroom.ktv.KtvMusicManager; -import com.yizhuan.erban.ui.widget.magicindicator.buildins.UIUtil; -import com.yizhuan.xchat_android_core.bean.RoomQueueInfo; -import com.yizhuan.xchat_android_core.manager.AvRoomDataManager; -import com.yizhuan.xchat_android_core.room.ktv.event.MusicCountEvent; -import com.yizhuan.xchat_android_core.room.pk.bean.PKTeamInfo; -import com.yizhuan.xchat_android_core.room.queue.bean.MicMemberInfo; -import com.yizhuan.xchat_android_core.utils.StringUtils; -import com.yizhuan.xchat_android_library.rxbus.RxBus; - -import io.reactivex.android.schedulers.AndroidSchedulers; -import io.reactivex.disposables.CompositeDisposable; - -/** - * @author xiaoyu - * @date 2017/12/18 - */ - -public class KtvMicroViewAdapter extends BaseMicroViewAdapter { - - private int[] realPositions = {1, 5, 2, 6, 0, 3, 7, 4, 8}; - - private ViewGroup.LayoutParams microParams; - private ViewGroup.LayoutParams bossParams; - - public KtvMicroViewAdapter(Context context) { - super(context); - int itemWidth = (int) (ScreenUtil.screenWidth * 0.1875); - microParams = new ViewGroup.LayoutParams(itemWidth, UIUtil.dip2px(context, 80)); - bossParams = new ViewGroup.LayoutParams(ScreenUtil.screenWidth / 4, UIUtil.dip2px(context, 160)); - disposables.add(RxBus.get().toFlowable(MusicCountEvent.class) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(musicCountEvent -> notifyDataSetChanged())); - } - - /** - * Set LayoutManager and bind this to {@link RecyclerView} - */ - @Override - public void bindToRecyclerView(RecyclerView recyclerView) { - GridLayoutManager layoutManager = new GridLayoutManager(context, 2); - layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); - layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { - @Override - public int getSpanSize(int position) { - return position == 4 ? 2 : 1; - } - }); - recyclerView.setLayoutManager(layoutManager); - recyclerView.setAdapter(this); - } - - @Override - public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { - View item = LayoutInflater.from(parent.getContext()) - .inflate(viewType == TYPE_BOSS ? R.layout.item_ktv_boss_micro : R.layout.list_item_ktv_micro, parent, false); - return new KtvMicroViewHolder(item, viewType == TYPE_BOSS); - - } - - @Override - public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, final int position) { - int realPosition = realPositions[position]; - RoomQueueInfo roomQueueInfo = AvRoomDataManager.get().getRoomQueueMemberInfoByMicPosition(realPosition - 1); - viewHolder.itemView.setLayoutParams(position == 4 ? bossParams : microParams); - if (roomQueueInfo == null) return; - NormalMicroViewHolder holder = (NormalMicroViewHolder) viewHolder; - holder.bind(roomQueueInfo, realPosition - 1); - } - - @Override - public String microType() { - return BaseMicroViewAdapter.MICRO_TYPE_KTV; - } - - @Override - public int getItemViewType(int position) { - return (position == 4) ? TYPE_BOSS : TYPE_NORMAL; - } - - class KtvMicroViewHolder extends NormalMicroViewHolder { - - ImageView ivSinger; - TextView tvPkMark; - boolean mIsBoss; - - KtvMicroViewHolder(View itemView, boolean isBoss) { - super(itemView); - ivSinger = itemView.findViewById(R.id.iv_singer); - tvPkMark = (TextView) itemView.findViewById(R.id.tv_pk_mark); - mIsBoss = isBoss; - - } - - @Override - public void clear() { - super.clear(); - ivSinger.setVisibility(View.GONE); - tvPkMark.setVisibility(View.GONE); - disposables.dispose(); - } - - @Override - protected void setDefalutText(int index) { - tvNick.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); - if (mIsBoss) { - tvNick.setTextColor(context.getResources().getColor(R.color.white_transparent_30)); - tvNick.setText("未上座"); - } else - super.setDefalutText(index); - } - - @Override - protected void setSelectText(int index, String nick, int gender) { - super.setSelectText(index, nick, gender); - - if (mIsBoss) { - setBossViewGender(tvNick, gender == 1); - } else - tvNick.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); - } - - @Override - void bind(RoomQueueInfo info, int position) { - super.bind(info, position); - MicMemberInfo micMemberInfo = info.mChatRoomMember; - if (micMemberInfo != null && micMemberInfo.getGroupType() == PKTeamInfo.TEAM_RED) { - tvPkMark.setVisibility(View.VISIBLE); - tvPkMark.setBackgroundResource(R.drawable.shape_pk_mic_queue_mark_red); - tvPkMark.setText("红队"); - ivSinger.setVisibility(View.GONE); - if (isSinging(info.mChatRoomMember)) { - tvPkMark.setCompoundDrawablesWithIntrinsicBounds(tvPkMark.getResources().getDrawable(R.drawable.ktv_pk_singing_mark), null, null, null); - } else { - tvPkMark.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null); - } - } else if (micMemberInfo != null && micMemberInfo.getGroupType() == PKTeamInfo.TEAM_BLUE) { - tvPkMark.setVisibility(View.VISIBLE); - tvPkMark.setBackgroundResource(R.drawable.shape_pk_mic_queue_mark_blue); - tvPkMark.setText("蓝队"); - ivSinger.setVisibility(View.GONE); - if (isSinging(info.mChatRoomMember)) { - tvPkMark.setCompoundDrawablesWithIntrinsicBounds(tvPkMark.getResources().getDrawable(R.drawable.ktv_pk_singing_mark), null, null, null); - } else { - tvPkMark.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null); - } - } else { - tvPkMark.setVisibility(View.GONE); - if (isSinging(info.mChatRoomMember)) { - ivSinger.setVisibility(View.VISIBLE); - } else { - ivSinger.setVisibility(View.GONE); - } - } - - } - - private boolean isSinging(MicMemberInfo chatRoomMember) { - return chatRoomMember != null && KtvMusicManager.INSTANCE.getCurrMusic().getUid() == StringUtils.toLong(chatRoomMember.getAccount()); - } - } - - - private CompositeDisposable disposables = new CompositeDisposable(); - - @Override - public void onDetachedFromRecyclerView(RecyclerView recyclerView) { - super.onDetachedFromRecyclerView(recyclerView); - disposables.dispose(); - } - -} diff --git a/app/src/main/java/com/yizhuan/erban/avroom/fragment/HomePartyRoomFragment.java b/app/src/main/java/com/yizhuan/erban/avroom/fragment/HomePartyRoomFragment.java index 0df856ae9..97f048065 100644 --- a/app/src/main/java/com/yizhuan/erban/avroom/fragment/HomePartyRoomFragment.java +++ b/app/src/main/java/com/yizhuan/erban/avroom/fragment/HomePartyRoomFragment.java @@ -15,7 +15,6 @@ import com.yizhuan.erban.avroom.activity.AVRoomActivity; import com.yizhuan.erban.avroom.adapter.BaseMicroViewAdapter; import com.yizhuan.erban.avroom.adapter.CpMicroViewAdapter; import com.yizhuan.erban.avroom.adapter.DatingMicroViewAdapter; -import com.yizhuan.erban.avroom.adapter.KtvMicroViewAdapter; import com.yizhuan.erban.avroom.adapter.MicroViewAdapter; import com.yizhuan.erban.avroom.anotherroompk.RoomPkFinishDialog; import com.yizhuan.erban.avroom.anotherroompk.RoomPkForceFinishDialog; @@ -26,7 +25,6 @@ import com.yizhuan.erban.avroom.dialog.PKResultDialog; import com.yizhuan.erban.avroom.dialog.PKScoreBoardDialog; import com.yizhuan.erban.avroom.firstcharge.FirstChargePrizeDialog; import com.yizhuan.erban.avroom.giftvalue.GiftValueDialogUiHelper; -import com.yizhuan.erban.avroom.ktv.KtvSongListActivity; import com.yizhuan.erban.avroom.presenter.HomePartyPresenter; import com.yizhuan.erban.avroom.view.IHomePartyView; import com.yizhuan.erban.avroom.widget.PKBoardView; @@ -454,11 +452,7 @@ public class HomePartyRoomFragment extends BaseRoomFragment implements View.OnClickListener { - - private String[] errs = new String[]{ - "歌词有误", - "歌词与伴奏有错位", - "原唱与伴奏不匹配", - "伴奏有误", - "伴奏音质差", - "MV质量差", - "无法播放", - "其他"}; - private int musicId; - - public KtvCommitErrorDialog(Context context, int musicId) { - super(context, R.style.TranslucentNoTitle); - this.musicId = musicId; - } - - public static KtvCommitErrorDialog newInstance(Context context, int musicId) { - return new KtvCommitErrorDialog(context, musicId); - } - - @Override - protected void init() { - binding.setClick(this); - TextView checkBox; - for (String err : errs) { - checkBox = (TextView) getLayoutInflater().inflate(R.layout.item_ktv_err, null); - checkBox.setText(err); - binding.llErrs.addView(checkBox, createLayoutParams()); - checkBox.setOnClickListener(v -> { - v.setSelected(!v.isSelected()); - updateCommitStatus(); - }); - } - } - - private void updateCommitStatus() { - boolean clickable = false; - for (int i = 0; i < binding.llErrs.getChildCount(); i++) { - if (binding.llErrs.getChildAt(i).isSelected()) { - clickable = true; - break; - } - } - binding.tvSure.setClickable(clickable); - binding.tvSure.setSolid(clickable ? context.getResources().getColor(R.color.appColor) : - context.getResources().getColor(R.color.color_FFC4A7)); - } - - private LinearLayout.LayoutParams createLayoutParams() { - LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, UIUtil.dip2px(context, 38)); - layoutParams.setMarginStart(UIUtil.dip2px(context, 15)); - layoutParams.setMarginEnd(UIUtil.dip2px(context, 15)); - return layoutParams; - } - - public void onClick(View view) { - TextView checkBox; - switch (view.getId()) { - case R.id.tv_sure: - StringBuilder errMsg = new StringBuilder(); - for (int i = 0; i < binding.llErrs.getChildCount(); i++) { - checkBox = (TextView) binding.llErrs.getChildAt(i); - if (checkBox.isSelected()) { - if (i != 0) errMsg.append(","); - errMsg.append(checkBox.getText().toString()); - } - } - if (TextUtils.isEmpty(errMsg.toString())) { - SingleToastUtil.showToast("请至少选择一种错误!"); - return; - } - KtvMusicManager.INSTANCE.musicError(musicId, errMsg.toString()) - .subscribe(s -> { - closeDialog(); - SingleToastUtil.showToast("提交成功!"); - }); - break; - default: - break; - } - } - - - - -} \ No newline at end of file diff --git a/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvHelper.java b/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvHelper.java deleted file mode 100644 index 0cf65e758..000000000 --- a/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvHelper.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.yizhuan.erban.avroom.ktv; - -import android.content.Context; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.TextView; - -import com.netease.nimlib.sdk.chatroom.ChatRoomMessageBuilder; -import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage; - -import com.yizhuan.erban.R; -import com.yizhuan.erban.utils.UserUtils; -import com.yizhuan.xchat_android_core.im.custom.bean.MusicInfoAttachment; -import com.yizhuan.xchat_android_core.manager.IMNetEaseManager; -import com.yizhuan.xchat_android_core.room.ktv.bean.MusicInfo; -import com.yizhuan.xchat_android_library.utils.NetworkUtils; - -import io.reactivex.Single; - -import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_KTV; - - -public class KtvHelper { - - public static final int NO_NET = 1; - public static final int NO_SONG = 2; - public static final int NO_ROOM = 3; - public static final int NO_DATA = 4; - public static View createKtvEmptyView(Context context,int type ) { - if (!NetworkUtils.isNetworkAvailable(context)) type = NO_NET; - String hint =""; - int resId = 0; - switch (type) { - case NO_NET: - hint = "网络异常,加载失败"; - resId = R.drawable.icon_common_failure; - break; - case NO_DATA: - hint = "搜索无歌曲"; - resId = R.drawable.icon_common_failure; - break; - case NO_ROOM: - hint = "无房间开唱"; - resId = R.drawable.icon_common_failure; - break; - case NO_SONG: - hint = "无点唱歌曲"; - resId = R.drawable.icon_common_failure; - break; - } - View view = LayoutInflater.from(context).inflate(R.layout.fragment_no_data_large_iv, null); - view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); - ((TextView)view.findViewById(R.id.no_data_text)).setText(hint); - ((ImageView)view.findViewById(R.id.no_data_icon)).setImageResource(resId); - return view; - } - - public static Single sendChatRoomMusicMessage(int sub, MusicInfo musicInfo) { - MusicInfoAttachment musicInfoAttachment = new MusicInfoAttachment(CUSTOM_MSG_KTV, sub); - if (musicInfo != null) { - musicInfo.setOperationNick(UserUtils.getUserInfo().getNick()); - musicInfo.setOperationUid(UserUtils.getUserUid()); - musicInfoAttachment.setMusicInfo(musicInfo); - } - final ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage( - UserUtils.getCurrentRoomId() + "", musicInfoAttachment); - return IMNetEaseManager.get().sendChatRoomMessage(message, false); - } -} diff --git a/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvMusicManager.java b/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvMusicManager.java deleted file mode 100644 index a4c740b6b..000000000 --- a/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvMusicManager.java +++ /dev/null @@ -1,207 +0,0 @@ -package com.yizhuan.erban.avroom.ktv; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; - -import com.coorchice.library.utils.LogUtils; -import com.yizhuan.erban.utils.UserUtils; -import com.yizhuan.xchat_android_core.manager.AvRoomDataManager; - -import com.yizhuan.xchat_android_core.manager.IMNetEaseManager; -import com.yizhuan.xchat_android_core.manager.AudioEngineManager; -import com.yizhuan.xchat_android_core.room.ktv.KtvModel; -import com.yizhuan.xchat_android_core.room.ktv.bean.MusicInfo; -import com.yizhuan.xchat_android_core.room.ktv.bean.RoomMusicInfo; -import com.yizhuan.xchat_android_core.room.ktv.event.KtvEvent; -import com.yizhuan.xchat_android_core.room.ktv.event.MusicCountEvent; -import com.yizhuan.xchat_android_core.utils.net.RxHelper; -import com.yizhuan.xchat_android_library.rxbus.RxBus; -import com.yizhuan.xchat_android_library.utils.ListUtils; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.concurrent.TimeUnit; - -import io.reactivex.Observable; -import io.reactivex.Single; -import io.reactivex.android.schedulers.AndroidSchedulers; -import io.reactivex.disposables.Disposable; -import io.reactivex.schedulers.Schedulers; - -import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_KTV_DELETE_USER_ALL; -import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_KTV_FINISH; -import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_KTV_SWITCH; - -public enum KtvMusicManager { - INSTANCE; - private final ArrayList mData = new ArrayList<>(); - private MusicInfo currMusic; - private double currPlayPos; - private Disposable ktvDisposable; - private Disposable startDisposable; - private Disposable dataDisposable; - private Disposable switchDisposable; - - public void reset() { - dispose(ktvDisposable); - ktvDisposable = RxBus.get().toFlowable(KtvEvent.class) - .subscribe(this::handleKtvEvent); - initData(); - } - - private void initData() { - dispose(dataDisposable); - dataDisposable = KtvModel.get().getRoomMusic(UserUtils.getCurrentRoomUid()) - .compose(RxHelper.handleBeanData()) - .doOnSuccess(this::setData) - .filter(roomMusicInfo -> !AvRoomDataManager.get().isOwnerOnMic() && !ListUtils.isListEmpty(roomMusicInfo.getUserChooseMusicVos())) - .toObservable() - .flatMap(roomMusicInfo -> Observable.fromIterable(roomMusicInfo.getUserChooseMusicVos())) - .filter(musicInfo -> musicInfo.getUid() == UserUtils.getUserUid()) - .firstElement() - .toSingle() - .flatMap(musicInfo -> deleteUserAllChooseMusic()) - .subscribe(s -> { }, e -> { }); - } - - public void setData(RoomMusicInfo roomMusicInfo) { - mData.clear(); - currMusic = roomMusicInfo.getSingingMusicVo(); - if (!ListUtils.isListEmpty(roomMusicInfo.getUserChooseMusicVos())) { - mData.addAll(roomMusicInfo.getUserChooseMusicVos()); - } - RxBus.get().post(KtvEvent.newInstance(KtvEvent.MUSIC_UPDATE, null)); - RxBus.get().post(new MusicCountEvent(mData.size())); - } - - //处理KTV相关的各种事件 - private void handleKtvEvent(KtvEvent ktvEvent) { - LogUtils.d(ktvEvent.toString()); - MusicInfo musicInfo = ktvEvent.getMusicInfo(); - switch (ktvEvent.getType()) { - case KtvEvent.SWITCH_MUSIC: - if (currMusic != null) mData.remove(currMusic); - currMusic = musicInfo; - AudioEngineManager.get().stopPush(); - startMv(musicInfo); - break; - case KtvEvent.ADD_MUSIC: - if (musicInfo != null) { - mData.add(musicInfo); - } - break; - case KtvEvent.POP_MUSIC: - if (musicInfo != null) { - mData.remove(musicInfo); - } - break; - case KtvEvent.NO_MUSIC: - case KtvEvent.CLOSE_KTV_MODEL: - AudioEngineManager.get().stopPush(); - AudioEngineManager.get().setLive(false); - mData.clear(); - currMusic = null; - break; - case KtvEvent.DELETE_USER_CHOOSE_MUSIC: - if (musicInfo != null) { - mData.remove(musicInfo); - } - case KtvEvent.DELETE_USER_ALL_MUSIC: - if (musicInfo != null) { - Iterator iterator = mData.iterator(); - while (iterator.hasNext()) { - if (iterator.next().getUid() == musicInfo.getUid()) { - iterator.remove(); - } - } - } - break; - case KtvEvent.MUSIC_COMPLETE: - LogUtils.d("MUSIC_COMPLETE"); - // if (AudioEngineManager.get().isPush()) switchSong(false); - break; - default: - break; - } - RxBus.get().post(new MusicCountEvent(mData.size())); - } - - private void startMv(MusicInfo musicInfo) { - if (musicInfo == null ||UserUtils.getUserUid() != musicInfo.getUid()) return; - dispose(startDisposable); - currPlayPos = -1; - startDisposable = Observable.just(0) - .subscribeOn(Schedulers.io()) - .delay(2, TimeUnit.SECONDS) - .takeUntil(integer -> !KtvView.isShowPrepare || UserUtils.getUserUid() != getCurrMusic().getUid())//准备中下麦处理 - .doOnNext(integer -> AudioEngineManager.get().startMv(musicInfo.getMusicUrl())) - .flatMap(integer -> Observable.interval(0, 1, TimeUnit.SECONDS)) - .observeOn(AndroidSchedulers.mainThread()) - .takeUntil(aLong -> !AudioEngineManager.get().isPush()) - .filter(aLong -> (AudioEngineManager.get().getPlayPos() > 0.99d || - (AudioEngineManager.get().getPlayPos() > 0.94d && AudioEngineManager.get().isPlaying() && - currPlayPos == (currPlayPos = AudioEngineManager.get().getPlayPos())))) - .take(1) - .subscribe(aLong -> switchSong(false)); - - } - - public Single addMusic(MusicInfo musicInfo) { - return KtvModel.get().chooseMusic(musicInfo.getMusicId(), UserUtils.getUserUid(), UserUtils.getCurrentRoomUid()); - } - - public Single popMusic(MusicInfo musicInfo) { - return KtvModel.get().popMusic(musicInfo.getMusicId(), musicInfo.getUid(), UserUtils.getCurrentRoomUid()); - } - - public Single switchMusic() { - return KtvModel.get().switchMusic(UserUtils.getCurrentRoomUid()); - } - - public Single deleteUserChooseMusic(MusicInfo musicInfo) { - return KtvModel.get().deleteUserChooseMusic(musicInfo.getMusicId(), musicInfo.getUid(), UserUtils.getCurrentRoomUid()); - } - - public Single deleteRoomAllChooseMusic() { - return KtvModel.get().deleteRoomAllChooseMusic(UserUtils.getCurrentRoomUid()); - } - - public Single deleteUserAllChooseMusic() { - return deleteUserAllChooseMusic(UserUtils.getCurrentRoomUid()); - } - - public Single deleteUserAllChooseMusic(long roomUid) { - return KtvModel.get() - .deleteUserAllChooseMusic(UserUtils.getUserUid(), roomUid) - .doOnSuccess(s -> KtvHelper.sendChatRoomMusicMessage(CUSTOM_MSG_SUB_KTV_DELETE_USER_ALL, null) - .subscribe(chatRoomMessage -> RxBus.get().post(KtvEvent.newInstance(KtvEvent.DELETE_USER_ALL_MUSIC, null)))); - } - - public void switchSong(boolean isSwitch) { - MusicInfo musicInfo = getCurrMusic(); - dispose(switchDisposable); - switchDisposable = KtvMusicManager.INSTANCE.switchMusic() - .flatMap(s -> KtvHelper.sendChatRoomMusicMessage(isSwitch ? CUSTOM_MSG_SUB_KTV_SWITCH : CUSTOM_MSG_SUB_KTV_FINISH, musicInfo)) - .subscribe(chatRoomMessage -> IMNetEaseManager.get().addMessages(chatRoomMessage)); - } - - public Single musicError(int musicId,String errorMsg) { - return KtvModel.get().musicError(musicId, UserUtils.getUserUid(),errorMsg); - } - - - private void dispose(@Nullable Disposable disposable) { - if (disposable != null) disposable.dispose(); - } - - @NonNull - public List getMusicList() { - return mData; - } - - @NonNull - public MusicInfo getCurrMusic() { - return currMusic == null ? new MusicInfo() : currMusic; - } -} diff --git a/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvRoomListActivity.java b/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvRoomListActivity.java deleted file mode 100644 index e22672263..000000000 --- a/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvRoomListActivity.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.yizhuan.erban.avroom.ktv; - -import android.content.Context; -import android.content.Intent; -import androidx.fragment.app.Fragment; - -import com.yizhuan.erban.R; -import com.yizhuan.erban.base.BaseBindingActivity; -import com.yizhuan.erban.common.ViewPagerAdapter; -import com.yizhuan.erban.databinding.ActivityKtvRoomListBinding; -import com.yizhuan.erban.decoration.view.widgets.CarMagicIndicator; -import com.yizhuan.erban.ui.widget.magicindicator.ViewPagerHelper; -import com.yizhuan.erban.ui.widget.magicindicator.buildins.commonnavigator.CommonNavigator; -import com.yizhuan.xchat_android_core.home.bean.TabInfo; -import com.yizhuan.xchat_android_library.annatation.ActLayoutRes; -import com.yizhuan.xchat_android_library.utils.CommonUtils; - -import java.util.ArrayList; -import java.util.List; - -/** - *

KTV房间列表

- * - */ -@ActLayoutRes(R.layout.activity_ktv_room_list) -public class KtvRoomListActivity extends BaseBindingActivity implements CarMagicIndicator.OnItemSelectListener { - - public static void start(Context context) { - if (CommonUtils.isFastDoubleClick(500)) return; - Intent starter = new Intent(context, KtvRoomListActivity.class); - //starter.putExtra(); - context.startActivity(starter); - } - @Override - protected void init() { - List list = new ArrayList<>(); - list.add(KtvRoomListFragment.newInstance(KtvRoomListFragment.NEW)); - list.add(KtvRoomListFragment.newInstance(KtvRoomListFragment.HOT)); - List tabInfoList = new ArrayList<>(2); - tabInfoList.add(new TabInfo(1, "最新")); - tabInfoList.add(new TabInfo(2, "最热")); - CommonNavigator commonNavigator = new CommonNavigator(this); - commonNavigator.setAdjustMode(true); - CarMagicIndicator indicator = new CarMagicIndicator(this, tabInfoList, 0); - indicator.setOnItemSelectListener(this); - commonNavigator.setAdapter(indicator); - mBinding.viewIndicator.setNavigator(commonNavigator); - ViewPagerHelper.bind(mBinding.viewIndicator, mBinding.viewPager); - String[] titles = {"最新", "最热"}; - mBinding.setClick(this); - initTitleBar("KTV房"); - // mBinding.tabLayout.setupWithViewPager(mBinding.viewPager); - // mBinding.tabLayout.setTabGravity(TabLayout.GRAVITY_CENTER); - mBinding.viewPager.setAdapter(new ViewPagerAdapter(getSupportFragmentManager(), list, titles)); - } - - @Override - public void onItemSelect(int position) { - mBinding.viewPager.setCurrentItem(position); - } -} diff --git a/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvRoomListFragment.java b/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvRoomListFragment.java deleted file mode 100644 index e4bf62bfe..000000000 --- a/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvRoomListFragment.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.yizhuan.erban.avroom.ktv; - -import android.os.Bundle; - -import androidx.recyclerview.widget.GridLayoutManager; -import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; - -import com.chad.library.adapter.base.BaseQuickAdapter; -import com.yizhuan.erban.BR; -import com.yizhuan.erban.R; -import com.yizhuan.erban.avroom.activity.AVRoomActivity; -import com.yizhuan.erban.base.BaseBindingFragment; -import com.yizhuan.erban.bindadapter.BaseAdapter; -import com.yizhuan.erban.databinding.FragmentRecyclerViewBindNoBgBinding; -import com.yizhuan.xchat_android_core.room.ktv.bean.KtvRoomInfo; -import com.yizhuan.xchat_android_library.annatation.ActLayoutRes; - -@ActLayoutRes(R.layout.fragment_recycler_view_bind_no_bg) -public class KtvRoomListFragment extends BaseBindingFragment implements SwipeRefreshLayout.OnRefreshListener, BaseQuickAdapter.RequestLoadMoreListener { - private BaseAdapter adapter; - private KtvRoomListVm ktvRoomListVm; - public static final int NEW = 1; - public static final int HOT = 2; - - @Override - public void initiate() { - int type = getArguments().getInt("type", HOT); - ktvRoomListVm = new KtvRoomListVm(mBinding, type); - adapter = new BaseAdapter<>(R.layout.list_item_ktv_room, BR.ktvRoomInfo); - adapter.setEmptyView(KtvHelper.createKtvEmptyView(getContext(),KtvHelper.NO_ROOM )); - mBinding.setViewmodel(ktvRoomListVm); - mBinding.recyclerView.setLayoutManager(new GridLayoutManager(mContext,2)); - mBinding.recyclerView.setAdapter(adapter); - mBinding.swipeRefresh.setOnRefreshListener(this); - loadData(false); - adapter.setOnLoadMoreListener(this, mBinding.recyclerView); - adapter.setOnItemClickListener((adapter, view, position) ->{ - AVRoomActivity.start(getActivity(), ((KtvRoomInfo)adapter.getData().get(position)).getRoomUid()); -// getActivity().finish(); - } - ); - - } - - private void loadData(boolean isLoad) { - ktvRoomListVm.loadData(isLoad) - .compose(bindToLifecycle()) - .doAfterTerminate(() -> { - if (adapter.getItemCount() == 0) showNoData(); - else hideStatus(); - }).subscribe(); - } - - public static KtvRoomListFragment newInstance(int type) { - Bundle args = new Bundle(); - args.putInt("type", type); - KtvRoomListFragment fragment = new KtvRoomListFragment(); - fragment.setArguments(args); - return fragment; - } - - @Override - public void onReloadData() { - loadData(false); - showLoading(); - } - - @Override - public void onRefresh() { - loadData(false); - } - - @Override - public void onLoadMoreRequested() { - loadData(true); - } - -} diff --git a/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvRoomListVm.java b/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvRoomListVm.java deleted file mode 100644 index 970b6bcc4..000000000 --- a/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvRoomListVm.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.yizhuan.erban.avroom.ktv; - - -import com.yizhuan.erban.base.BaseListViewModel; -import com.yizhuan.erban.base.BaseMsListViewModel; -import com.yizhuan.erban.databinding.FragmentRecyclerViewBindNoBgBinding; -import com.yizhuan.xchat_android_core.bean.response.ServiceResult; -import com.yizhuan.xchat_android_core.room.ktv.KtvModel; -import com.yizhuan.xchat_android_core.room.ktv.bean.KtvRoomInfo; - -import java.util.List; - -import io.reactivex.Single; - -/** - * Created by huangmeng1 on 2018/5/9. - */ - -public class KtvRoomListVm extends BaseMsListViewModel { - - private int sortType; - - public KtvRoomListVm(FragmentRecyclerViewBindNoBgBinding mBinding, int sortType) { - super(mBinding); - this.sortType = sortType; - pageSize = 20; - } - - @Override - public Single>> getSingle() { - return KtvModel.get().getKtvRooms(sortType, page, pageSize); - } - -} diff --git a/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvSearchSongActivity.java b/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvSearchSongActivity.java deleted file mode 100644 index bf69bb953..000000000 --- a/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvSearchSongActivity.java +++ /dev/null @@ -1,191 +0,0 @@ -package com.yizhuan.erban.avroom.ktv; - -import android.annotation.SuppressLint; -import android.content.Context; -import android.content.Intent; -import android.text.Editable; -import android.text.TextUtils; -import android.text.TextWatcher; -import android.view.KeyEvent; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.view.inputmethod.EditorInfo; -import android.widget.TextView; - -import androidx.recyclerview.widget.LinearLayoutManager; - -import com.chad.library.adapter.base.BaseQuickAdapter; -import com.coorchice.library.SuperTextView; -import com.google.android.flexbox.FlexboxLayout; -import com.yizhuan.erban.BR; -import com.yizhuan.erban.R; -import com.yizhuan.erban.base.BaseBindingActivity; -import com.yizhuan.erban.bindadapter.BaseAdapter; -import com.yizhuan.erban.databinding.ActivityKtvSearchSongBinding; -import com.yizhuan.erban.ui.widget.magicindicator.buildins.UIUtil; -import com.yizhuan.erban.utils.UserUtils; -import com.yizhuan.xchat_android_core.manager.AvRoomDataManager; -import com.yizhuan.xchat_android_core.room.ktv.bean.MusicInfo; -import com.yizhuan.xchat_android_core.room.ktv.event.KtvEvent; -import com.yizhuan.xchat_android_core.room.ktv.event.MusicCountEvent; -import com.yizhuan.xchat_android_core.utils.SharedPreferenceUtils; -import com.yizhuan.xchat_android_library.annatation.ActLayoutRes; -import com.yizhuan.xchat_android_library.rxbus.RxBus; -import com.yizhuan.xchat_android_library.utils.CommonUtils; - -import io.reactivex.android.schedulers.AndroidSchedulers; - -/** - *

KTV搜索歌曲

- * - */ - -@ActLayoutRes(R.layout.activity_ktv_search_song) -public class KtvSearchSongActivity extends BaseBindingActivity implements TextWatcher, BaseQuickAdapter.RequestLoadMoreListener, BaseQuickAdapter.OnItemClickListener, TextView.OnEditorActionListener { - private KtvSearchSongVm vm; - private BaseAdapter adapter; - - - public static void start(Context context) { - if (CommonUtils.isFastDoubleClick(500)) return; - Intent starter = new Intent(context, KtvSearchSongActivity.class); - //starter.putExtra(); - context.startActivity(starter); - } - - @SuppressLint("CheckResult") - @Override - protected void init() { - initTitleBar("点歌台"); - vm = new KtvSearchSongVm(mBinding); - mBinding.setViewModel(vm); - mBinding.setClick(this); - mBinding.swipeRefresh.setEnabled(false); - mBinding.edtSearch.addTextChangedListener(this); - adapter = new BaseAdapter<>(R.layout.list_item_ktv_search, BR.musicInfo); - adapter.setOnLoadMoreListener(this, mBinding.recyclerView); - mBinding.recyclerView.setLayoutManager(new LinearLayoutManager(context)); - mBinding.recyclerView.setAdapter(adapter); - adapter.setOnItemClickListener(this); - adapter.setEmptyView(KtvHelper.createKtvEmptyView(context, KtvHelper.NO_DATA)); - mBinding.edtSearch.setOnEditorActionListener(this); - if (vm.getHistoryList().size() == 0) { - mBinding.ivClearHistory.setVisibility(View.INVISIBLE); - } else { - for (String item : vm.getHistoryList()) { - mBinding.fblHistory.addView(createSearchItem(item), createLayoutParams()); - } - } - mBinding.tvSongCount.setText("已点" + KtvMusicManager.INSTANCE.getMusicList().size()); - RxBus.get().toFlowable(KtvEvent.class) - .compose(bindToLifecycle()) - .filter(ktvEvent -> ktvEvent.getType() == KtvEvent.ADD_MUSIC_BY_USER) - .subscribe(ktvEvent -> finish()); - RxBus.get().toFlowable(MusicCountEvent.class) - .compose(bindToLifecycle()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(musicCountEvent -> mBinding.tvSongCount.setText("已点" + musicCountEvent.getCount())); - } - - private SuperTextView createSearchItem(String text) { - SuperTextView textView = (SuperTextView) LayoutInflater.from(context).inflate(R.layout.item_ktv_search_history, null); - textView.setText(text); - textView.setMaxLines(1); - textView.setOnClickListener(v -> { - mBinding.edtSearch.setText(text); - mBinding.edtSearch.setSelection(mBinding.edtSearch.getText().toString().length()); - loadData(text); - }); - return textView; - } - - private FlexboxLayout.LayoutParams createLayoutParams() { - FlexboxLayout.LayoutParams layoutParams = new FlexboxLayout.LayoutParams( - ViewGroup.LayoutParams.WRAP_CONTENT, UIUtil.dip2px(this, 28)); - layoutParams.setMargins(0, 0, UIUtil.dip2px(this, 8), UIUtil.dip2px(this, 10)); - return layoutParams; - } - - @Override - public void onClick(View v) { - switch (v.getId()) { - case R.id.tv_search: - loadData(mBinding.edtSearch.getText().toString()); - break; - case R.id.iv_clear_history: - mBinding.fblHistory.removeAllViews(); - mBinding.ivClearHistory.setVisibility(View.INVISIBLE); - SharedPreferenceUtils.remove("ktv_history"); - break; - - case R.id.ib_clear_edt: - mBinding.edtSearch.setText(""); - break; - } - } - - @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) { - if (TextUtils.isEmpty(s.toString())) { - mBinding.recyclerView.setVisibility(View.GONE); - mBinding.llHistory.setVisibility(View.VISIBLE); - } - - } - - private void loadData(String searchKey) { - if (TextUtils.isEmpty(searchKey)) { - toast("请输入搜索关键字~"); - return; - } - hideIME(); - mBinding.recyclerView.setVisibility(View.VISIBLE); - mBinding.llHistory.setVisibility(View.GONE); - if (vm.addHistory(searchKey)) { - if (mBinding.ivClearHistory.getVisibility() == View.INVISIBLE) { - mBinding.ivClearHistory.setVisibility(View.VISIBLE); - } - if (mBinding.fblHistory.getChildCount() == 12) mBinding.fblHistory.removeViewAt(11); - mBinding.fblHistory.addView(createSearchItem(searchKey), 0, createLayoutParams()); - } - vm.setSearchKey(searchKey); - vm.loadData(this, false); - } - - @Override - public void onLoadMoreRequested() { - vm.loadData(this, true); - } - - @Override - public void onItemClick(BaseQuickAdapter adapter, View view, int position) { - if (CommonUtils.isFastDoubleClick(500)) return; - if (AvRoomDataManager.get().isOnMic(UserUtils.getUserUid())) { - KtvSelectSongDialog.newInstance(context, this.adapter.getData().get(position)) - .openDialog(); - } else { - getDialogManager().showOkDialog("只有麦上用户才可以点歌哦~"); - } - } - - @Override - public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { - if (actionId == EditorInfo.IME_ACTION_SEND || actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_ACTION_SEARCH - || (event != null && KeyEvent.KEYCODE_ENTER == event.getKeyCode() && KeyEvent.ACTION_DOWN == event.getAction())) { - loadData(mBinding.edtSearch.getText().toString()); - return true; - } - return false; - } -} diff --git a/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvSearchSongVm.java b/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvSearchSongVm.java deleted file mode 100644 index 95043c670..000000000 --- a/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvSearchSongVm.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.yizhuan.erban.avroom.ktv; - -import android.text.TextUtils; - -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; - -import com.yizhuan.erban.base.BaseMsListViewModel; -import com.yizhuan.erban.databinding.ActivityKtvSearchSongBinding; -import com.yizhuan.xchat_android_core.bean.response.ServiceResult; -import com.yizhuan.xchat_android_core.room.ktv.KtvModel; -import com.yizhuan.xchat_android_core.room.ktv.bean.MusicInfo; -import com.yizhuan.xchat_android_core.utils.SharedPreferenceUtils; - -import java.util.ArrayList; -import java.util.List; - -import io.reactivex.Single; - -public class KtvSearchSongVm extends BaseMsListViewModel { - - private String searchKey; - - public KtvSearchSongVm(ActivityKtvSearchSongBinding mBinding) { - super(mBinding); - } - - public void setSearchKey(String searchKey) { - this.searchKey = searchKey; - } - - @Override - public Single>> getSingle() { - return KtvModel.get().searchMusic(searchKey, page, pageSize); - } - - - public boolean addHistory(String searchKey) { - if (TextUtils.isEmpty(searchKey)) return false; - List historyList = getHistoryList(); - if (!historyList.contains(searchKey)) { - if (historyList.size() > 11) historyList.remove(11); - historyList.add(0, searchKey); - SharedPreferenceUtils.put("ktv_history", new Gson().toJson(historyList)); - return true; - } - return false; - } - - public List getHistoryList() { - String historys = (String) SharedPreferenceUtils.get("ktv_history", ""); - List historyList = new ArrayList<>(); - if (!TextUtils.isEmpty(historys)) { - historyList.addAll(new Gson().fromJson(historys, new TypeToken>() { - }.getType())); - } - return historyList; - } -} diff --git a/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvSelectSongActivity.java b/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvSelectSongActivity.java deleted file mode 100644 index e8576229a..000000000 --- a/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvSelectSongActivity.java +++ /dev/null @@ -1,106 +0,0 @@ -package com.yizhuan.erban.avroom.ktv; - -import android.annotation.SuppressLint; -import android.content.Context; -import android.content.Intent; -import androidx.recyclerview.widget.LinearLayoutManager; -import android.view.View; - -import com.chad.library.adapter.base.BaseQuickAdapter; - -import com.yizhuan.erban.BR; -import com.yizhuan.erban.R; -import com.yizhuan.erban.base.BaseBindingActivity; -import com.yizhuan.erban.bindadapter.BaseAdapter; -import com.yizhuan.erban.common.widget.dialog.DialogManager; -import com.yizhuan.erban.databinding.ActivityKtvSelectSongBinding; -import com.yizhuan.erban.utils.UserUtils; -import com.yizhuan.xchat_android_core.manager.AvRoomDataManager; -import com.yizhuan.xchat_android_core.room.ktv.bean.MusicInfo; -import com.yizhuan.xchat_android_core.room.ktv.event.MusicCountEvent; -import com.yizhuan.xchat_android_core.super_admin.SaConstant; -import com.yizhuan.xchat_android_core.super_admin.util.SuperAdminUtil; -import com.yizhuan.xchat_android_library.annatation.ActLayoutRes; -import com.yizhuan.xchat_android_library.rxbus.RxBus; -import com.yizhuan.xchat_android_library.utils.CommonUtils; -import com.yizhuan.xchat_android_library.utils.SingleToastUtil; - -import io.reactivex.android.schedulers.AndroidSchedulers; - -/** - *

KTV点歌台

- * - */ - -@ActLayoutRes(R.layout.activity_ktv_select_song) -public class KtvSelectSongActivity extends BaseBindingActivity implements BaseQuickAdapter.RequestLoadMoreListener, BaseQuickAdapter.OnItemClickListener { - private KtvSelectSongVm vm; - private BaseAdapter adapter; - - public static void start(Context context, boolean isHint) { - if (SuperAdminUtil.isSuperAdmin()) { - SingleToastUtil.showToast(SaConstant.TOAST_ERROR_TIPS); - return; - } - if (CommonUtils.isFastDoubleClick(500)) return; - if (!AvRoomDataManager.get().isOnMic(UserUtils.getUserUid()) && isHint) { - new DialogManager(context).showOkDialog("只有麦上用户才可以点歌哦~"); - return; - } - Intent starter = new Intent(context, KtvSelectSongActivity.class); - // starter.putExtra(); - context.startActivity(starter); - } - - - @SuppressLint("CheckResult") - @Override - protected void init() { - initTitleBar("点歌台"); - vm = new KtvSelectSongVm(mBinding); - mBinding.setViewModel(vm); - mBinding.setClick(this); - adapter = new BaseAdapter<>(R.layout.list_item_ktv_select, BR.musicInfo); - adapter.setOnLoadMoreListener(this, mBinding.recyclerView); - mBinding.swipeRefresh.setEnabled(false); - mBinding.recyclerView.setLayoutManager(new LinearLayoutManager(this)); - mBinding.recyclerView.setAdapter(adapter); - vm.loadData(this, false); - adapter.setOnItemClickListener(this); - mBinding.stvKtvSong.setText("已点" + KtvMusicManager.INSTANCE.getMusicList().size()); - RxBus.get().toFlowable(MusicCountEvent.class) - .compose(bindToLifecycle()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(musicCountEvent -> mBinding.stvKtvSong.setText("已点" + musicCountEvent.getCount())); - } - - @Override - public void onClick(View v) { - switch (v.getId()) { - case R.id.container_search: - KtvSearchSongActivity.start(context); - break; - case R.id.stv_ktv_song: - KtvSongListActivity.start(context, true); - break; - } - } - - @Override - public void onLoadMoreRequested() { - vm.loadData(this, true); - } - - @Override - public void onItemClick(BaseQuickAdapter adapter, View view, int position) { - if (CommonUtils.isFastDoubleClick(500)) return; - if (!AvRoomDataManager.get().isOnMic(UserUtils.getUserUid())) { - getDialogManager() - .showOkDialog("只有麦上用户才可以点歌喔~"); - return; - } - KtvSelectSongDialog.newInstance(context, (MusicInfo) adapter.getData().get(position)) - - .openDialog(); - } -} diff --git a/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvSelectSongDialog.java b/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvSelectSongDialog.java deleted file mode 100644 index af296398a..000000000 --- a/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvSelectSongDialog.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.yizhuan.erban.avroom.ktv; - -import android.content.Context; -import android.text.style.ForegroundColorSpan; -import android.view.View; - - -import com.yizhuan.erban.R; -import com.yizhuan.erban.treasure_box.widget.dialog.BaseBindingDialog; -import com.yizhuan.erban.avroom.widget.MessageView; -import com.yizhuan.erban.common.widget.dialog.DialogManager; -import com.yizhuan.erban.databinding.DialogKtvSelectSongBinding; -import com.yizhuan.erban.utils.UserUtils; -import com.yizhuan.xchat_android_core.manager.AvRoomDataManager; -import com.yizhuan.xchat_android_core.manager.IMNetEaseManager; -import com.yizhuan.xchat_android_core.manager.AudioEngineManager; -import com.yizhuan.xchat_android_core.room.ktv.bean.MusicInfo; -import com.yizhuan.xchat_android_core.room.ktv.event.KtvEvent; -import com.yizhuan.xchat_android_core.utils.net.BeanObserver; -import com.yizhuan.xchat_android_library.annatation.ActLayoutRes; -import com.yizhuan.xchat_android_library.rxbus.RxBus; -import com.yizhuan.xchat_android_library.utils.SingleToastUtil; - -import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_KTV_ADD; - - -@ActLayoutRes(R.layout.dialog_ktv_select_song) -public class KtvSelectSongDialog extends BaseBindingDialog implements View.OnClickListener { - private MusicInfo musicInfo; - - public KtvSelectSongDialog(Context context, MusicInfo musicInfo) { - super(context, R.style.MyAlertDialogStyle); - this.musicInfo = musicInfo; - } - - public static KtvSelectSongDialog newInstance(Context context, MusicInfo musicInfo) { - return new KtvSelectSongDialog(context, musicInfo); - } - - @Override - protected void init() { - binding.setMusicInfo(musicInfo); - binding.setClick(this); - - MessageView.SpannableBuilder builder = new MessageView.SpannableBuilder(binding.tvUploader) - .append("感谢 ") - .append(musicInfo.getUploader(), new ForegroundColorSpan(context.getResources().getColor(R.color.appColor))) - .append(" 上传"); - binding.tvUploader.setText(builder.build()); - } - - public void onClick(View view) { - switch (view.getId()) { - case R.id.tv_cancel: - closeDialog(); - break; - case R.id.tv_sure: - if (!AudioEngineManager.get().isOpenKtv()){ - SingleToastUtil.showToast("管理已经已经关闭KTV模式哦~~"); - return; - } - if (!AvRoomDataManager.get().isOnMic(UserUtils.getUserUid())) { - new DialogManager(context).showOkDialog("只有麦上用户才可以点歌哦~"); - return; - } - KtvMusicManager.INSTANCE.addMusic(musicInfo) - .subscribe(new BeanObserver() { - @Override - public void onErrorMsg(String error) { - SingleToastUtil.showToast(error); - } - - @Override - public void onSuccess(String s) { - closeDialog(); - SingleToastUtil.showToast("点歌成功~~"); - RxBus.get().post(KtvEvent.newInstance(KtvEvent.ADD_MUSIC_BY_USER, musicInfo)); - RxBus.get().post(KtvEvent.newInstance(KtvEvent.ADD_MUSIC, musicInfo)); - KtvHelper.sendChatRoomMusicMessage(CUSTOM_MSG_SUB_KTV_ADD, musicInfo) - .subscribe(chatRoomMessage -> { - IMNetEaseManager.get().addMessages(chatRoomMessage); - }); - } - }); - break; - default: - break; - } - } - -} diff --git a/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvSelectSongVm.java b/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvSelectSongVm.java deleted file mode 100644 index 9c1554eb8..000000000 --- a/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvSelectSongVm.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.yizhuan.erban.avroom.ktv; - - -import com.yizhuan.erban.base.BaseMsListViewModel; -import com.yizhuan.erban.databinding.ActivityKtvSelectSongBinding; -import com.yizhuan.xchat_android_core.bean.response.ServiceResult; -import com.yizhuan.xchat_android_core.room.ktv.KtvModel; -import com.yizhuan.xchat_android_core.room.ktv.bean.MusicInfo; - -import java.util.List; - -import io.reactivex.Single; - -public class KtvSelectSongVm extends BaseMsListViewModel { - - public KtvSelectSongVm(ActivityKtvSelectSongBinding mBinding) { - super(mBinding); - } - - @Override - public Single>> getSingle() { - return KtvModel.get().hotMusic(page, pageSize); - } -} diff --git a/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvSongListActivity.java b/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvSongListActivity.java deleted file mode 100644 index 6ebcfb2bd..000000000 --- a/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvSongListActivity.java +++ /dev/null @@ -1,152 +0,0 @@ -package com.yizhuan.erban.avroom.ktv; - -import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_KTV_DELETE; -import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_KTV_TOP; - -import android.content.Context; -import android.content.Intent; -import android.os.Bundle; -import android.view.View; - -import androidx.annotation.Nullable; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; - -import com.trello.rxlifecycle3.android.ActivityEvent; -import com.yizhuan.erban.BR; -import com.yizhuan.erban.R; -import com.yizhuan.erban.base.BaseBindingActivity; -import com.yizhuan.erban.base.TitleBar; -import com.yizhuan.erban.bindadapter.BaseAdapter; -import com.yizhuan.erban.databinding.ActivityKtvSongListBinding; -import com.yizhuan.xchat_android_core.manager.IMNetEaseManager; -import com.yizhuan.xchat_android_core.room.ktv.bean.MusicInfo; -import com.yizhuan.xchat_android_core.room.ktv.event.KtvEvent; -import com.yizhuan.xchat_android_core.super_admin.SaConstant; -import com.yizhuan.xchat_android_core.super_admin.util.SuperAdminUtil; -import com.yizhuan.xchat_android_library.annatation.ActLayoutRes; -import com.yizhuan.xchat_android_library.rxbus.RxBus; -import com.yizhuan.xchat_android_library.utils.CommonUtils; -import com.yizhuan.xchat_android_library.utils.SingleToastUtil; - -import java.util.Collections; - -/** - *

KTV房间已点列表

- * - */ - -@ActLayoutRes(R.layout.activity_ktv_song_list) -public class KtvSongListActivity extends BaseBindingActivity implements SwipeRefreshLayout.OnRefreshListener { - - private KtvSongListVm vm; - private BaseAdapter adapter; - private boolean hasSelectSong; - - public static void start(Context context, boolean hasSelectSong) { - if (SuperAdminUtil.isSuperAdmin()) { - SingleToastUtil.showToast(SaConstant.TOAST_ERROR_TIPS); - return; - } - if (CommonUtils.isFastDoubleClick(500)) return; - Intent starter = new Intent(context, KtvSongListActivity.class); - //starter.putExtra(); - context.startActivity(starter); - } - - @Override - protected void init() { - initTitleBar("已点(0)"); - vm = new KtvSongListVm(mBinding); - mBinding.setViewModel(vm); - mBinding.setClick(this); - vm.count.observe(this, count -> { - if (count == null) { - return; - } - setTitleBarText("已点(" + count + ")"); - }); - adapter = new KtvSongListAdapter(R.layout.list_item_ktv_song, BR.musicInfo, new int[]{R.id.stv_delete, R.id.stv_top}); - adapter.setEmptyView(KtvHelper.createKtvEmptyView(context,KtvHelper.NO_SONG )); - mBinding.swipeRefresh.setOnRefreshListener(this); - mBinding.recyclerView.setLayoutManager(new LinearLayoutManager(context)); - mBinding.recyclerView.setAdapter(adapter); - vm.loadData(this, false); - adapter.setOnItemChildClickListener((adapter, view, position) -> { - MusicInfo musicInfo = (MusicInfo) adapter.getItem(position); - if (musicInfo == null) return; - switch (view.getId()) { - case R.id.stv_top: - KtvMusicManager.INSTANCE.popMusic(musicInfo) - .compose(bindUntilEvent(ActivityEvent.DESTROY)) - .subscribe(s -> { - for (int i = position; i > 1; i--) { - Collections.swap(adapter.getData(), i, i - 1); - } - KtvHelper.sendChatRoomMusicMessage(CUSTOM_MSG_SUB_KTV_TOP,musicInfo) - .subscribe(chatRoomMessage -> IMNetEaseManager.get().addMessages(chatRoomMessage)); - }); - break; - case R.id.stv_delete: - KtvMusicManager.INSTANCE.deleteUserChooseMusic(musicInfo) - .compose(bindUntilEvent(ActivityEvent.DESTROY)) - .subscribe(s -> { - adapter.remove(position); - vm.count.setValue(adapter.getItemCount()); - KtvHelper.sendChatRoomMusicMessage(CUSTOM_MSG_SUB_KTV_DELETE,musicInfo) - .subscribe(chatRoomMessage -> IMNetEaseManager.get().addMessages(chatRoomMessage)); - }); - break; - } - }); - RxBus.get().toFlowable(KtvEvent.class) - .compose(bindToLifecycle()) - .filter(ktvEvent -> ktvEvent.getType() == KtvEvent.ADD_MUSIC_BY_USER) - .subscribe(ktvEvent -> vm.loadData(KtvSongListActivity.this, false)); - } - - public void initTitleBar(String title) { - mTitleBar = (TitleBar) findViewById(R.id.title_bar); - if (mTitleBar != null) { - mTitleBar.setTitle(title); - mTitleBar.setImmersive(false); - mTitleBar.setTitleColor(getResources().getColor(R.color.back_font)); - mTitleBar.setLeftImageResource(R.mipmap.common_ic_back); - mTitleBar.setLeftClickListener(v -> onLeftClickListener()); - mTitleBar.addAction(new TitleBar.ImageAction(R.drawable.icon_ktv_select_song_right) { - @Override - public void performAction(View view) { - KtvSelectSongActivity.start(context, true); - } - }); - } - } - - public void setTitleBarText(String title) { - mTitleBar = (TitleBar) findViewById(R.id.title_bar); - if (mTitleBar != null) { - mTitleBar.setTitle(title); - } - } - - @Override - public void onClick(View v) { - - } - - @Override - public void onRefresh() { - vm.loadData(this, false); - } - - @Override - public void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - } - -} diff --git a/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvSongListAdapter.java b/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvSongListAdapter.java deleted file mode 100644 index 0d1debb6f..000000000 --- a/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvSongListAdapter.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.yizhuan.erban.avroom.ktv; - -import androidx.annotation.Nullable; - -import com.yizhuan.erban.R; -import com.yizhuan.erban.bindadapter.BaseAdapter; -import com.yizhuan.erban.bindadapter.BindingViewHolder; -import com.yizhuan.erban.ui.widget.LivingIconView; -import com.yizhuan.erban.utils.UserUtils; -import com.yizhuan.xchat_android_core.manager.AvRoomDataManager; -import com.yizhuan.xchat_android_core.room.ktv.bean.MusicInfo; - -public class KtvSongListAdapter extends BaseAdapter { - - public KtvSongListAdapter(int layoutResId, int brid, @Nullable int[] clickIds) { - super(layoutResId, brid, clickIds); - } - - @Override - protected void convert(BindingViewHolder helper, MusicInfo item) { - super.convert(helper, item); - int position = helper.getLayoutPosition(); - boolean isManager = AvRoomDataManager.get().isRoomOwner() || AvRoomDataManager.get().isRoomAdmin(); - helper.setVisible(R.id.stv_top, position != 0 && position != 1 && isManager); - helper.setVisible(R.id.stv_delete, position != 0 && (isManager || UserUtils.getUserUid() == item.getUid())); - helper.setTextColor(R.id.tv_song_name, position == 0 ? 0xffff4362 : 0xff333333); - helper.setVisible(R.id.tv_singing, position == 0); - ((LivingIconView) helper.getView(R.id.tv_singing)).stop(); - if (position == 0) { - ((LivingIconView) helper.getView(R.id.tv_singing)).start(); - } - helper.addOnClickListener(R.id.stv_top) - .addOnClickListener(R.id.stv_delete); - } -} diff --git a/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvSongListVm.java b/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvSongListVm.java deleted file mode 100644 index 37f9100ed..000000000 --- a/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvSongListVm.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.yizhuan.erban.avroom.ktv; - -import androidx.lifecycle.MutableLiveData; -import androidx.databinding.ObservableInt; - - -import com.yizhuan.erban.base.BaseMsListViewModel; -import com.yizhuan.erban.databinding.ActivityKtvSongListBinding; -import com.yizhuan.erban.utils.UserUtils; -import com.yizhuan.xchat_android_core.bean.response.ServiceResult; -import com.yizhuan.xchat_android_core.room.ktv.KtvModel; -import com.yizhuan.xchat_android_core.room.ktv.bean.MusicInfo; - -import java.util.List; - -import io.reactivex.Single; - -public class KtvSongListVm extends BaseMsListViewModel { - - public MutableLiveData count = new MutableLiveData<>(); - - public KtvSongListVm(ActivityKtvSongListBinding mBinding) { - super(mBinding); - pageSize = 50; - count.setValue(0); - } - - @Override - public Single>> getSingle() { - return KtvModel.get().getRoomMusic(UserUtils.getCurrentRoomUid()) - .flatMap(result -> { - KtvMusicManager.INSTANCE.setData(result.getData()); - List musicInfoList = result.getData().getUserChooseMusicVos(); - count.setValue(musicInfoList.size()); - return Single.just(new ServiceResult>() - .setCode(result.getCode()) - .setMessage(result.getMessage()) - .setData(musicInfoList)); - } - ); - } -} diff --git a/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvView.java b/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvView.java deleted file mode 100644 index 743df8235..000000000 --- a/app/src/main/java/com/yizhuan/erban/avroom/ktv/KtvView.java +++ /dev/null @@ -1,541 +0,0 @@ -package com.yizhuan.erban.avroom.ktv; - -import android.annotation.SuppressLint; -import android.content.Context; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.constraintlayout.widget.Group; -import androidx.cardview.widget.CardView; -import android.util.AttributeSet; -import android.view.MotionEvent; -import android.view.SurfaceView; -import android.view.View; -import android.widget.FrameLayout; -import android.widget.ImageButton; -import android.widget.ImageView; -import android.widget.SeekBar; -import android.widget.TextView; - -import com.coorchice.library.SuperTextView; -import com.netease.nim.uikit.common.util.sys.ScreenUtil; - -import com.orhanobut.logger.Logger; -import com.yizhuan.erban.R; -import com.yizhuan.erban.common.widget.dialog.DialogManager; -import com.yizhuan.erban.ui.utils.ImageLoadUtils; -import com.yizhuan.erban.utils.UserUtils; -import com.yizhuan.xchat_android_core.bean.RoomQueueInfo; -import com.yizhuan.xchat_android_core.manager.AvRoomDataManager; -import com.yizhuan.xchat_android_core.manager.IMNetEaseManager; -import com.yizhuan.xchat_android_core.manager.AudioEngineManager; -import com.yizhuan.xchat_android_core.room.ktv.bean.MusicInfo; -import com.yizhuan.xchat_android_core.room.ktv.event.KtvEvent; -import com.yizhuan.xchat_android_core.room.ktv.event.RemoteVideoEvent; -import com.yizhuan.xchat_android_core.statistic.StatisticManager; -import com.yizhuan.xchat_android_core.statistic.protocol.StatisticsProtocol; -import com.yizhuan.xchat_android_core.super_admin.SaConstant; -import com.yizhuan.xchat_android_core.super_admin.util.SuperAdminUtil; -import com.yizhuan.xchat_android_library.rxbus.RxBus; -import com.yizhuan.xchat_android_library.utils.SingleToastUtil; - -import java.util.concurrent.TimeUnit; - - -import butterknife.BindView; -import butterknife.ButterKnife; -import io.agora.ktvkit.VideoPlayerView; -import io.agora.rtc.RtcEngine; -import io.agora.rtc.video.VideoCanvas; -import io.reactivex.Observable; -import io.reactivex.Observer; -import io.reactivex.android.schedulers.AndroidSchedulers; -import io.reactivex.disposables.CompositeDisposable; -import io.reactivex.disposables.Disposable; - -import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_KTV_CLOSE; - -public class KtvView extends CardView { - - private Context context; - public static final int KTV_ROOM_OWNER = 1;//房主 - public static final int KTV_ROOM_MANAGER = 2;//管理员 - public static final int KTV_ROOM_MV_BROADCASTER = 3;//mv主播 - public static final int KTV_ROOM_AUDIENCE = 4;//观众 - - @Nullable - private View statusView; - private CompositeDisposable disposables; - private FrameLayout playContainer; - private FrameLayout statusContainer; - private VideoPlayerView xPlay; - private boolean isShowNoSong; - public static boolean isShowPrepare; - private Disposable tipDisposable; - private Disposable prepareDisposable; - - public KtvView(@NonNull Context context) { - this(context, null); - } - - public KtvView(@NonNull Context context, @Nullable AttributeSet attrs) { - super(context, attrs); - this.context = context; - init(); - } - - private void init() { - inflate(context, R.layout.layout_ktv_view, this); - setRadius(ScreenUtil.dip2px(10)); - disposables = new CompositeDisposable(); - playContainer = findViewById(R.id.play_container); - statusContainer = findViewById(R.id.status_container); - this.setOnClickListener(listener); - playContainer.setOnClickListener(listener); - statusContainer.setOnClickListener(listener); - showXPlay(AudioEngineManager.get().isPush()); - if (!AudioEngineManager.get().isLive() || KtvMusicManager.INSTANCE.getMusicList().size() == 0) { - statusView = showNoSong(); - } else if (!AudioEngineManager.get().isPush()) { - setupRemoteVideo(AudioEngineManager.get().getRemoteUid()); - } - subscribeEvent(); - } - - private Runnable runnable = this::resetStatusView; - private OnClickListener listener = new OnClickListener() { - @Override - public void onClick(View v) { - if (statusView != null) { - resetStatusView(); - return; - } - statusView = getUserType() == KTV_ROOM_AUDIENCE ? showChooseSong() : showCommand(); - } - }; - - private void subscribeEvent() { - Disposable disposable1 = RxBus.get().toFlowable(RemoteVideoEvent.class) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(remoteVideoEvent -> setupRemoteVideo(remoteVideoEvent.getUid())); - Disposable disposable2 = RxBus.get().toFlowable(KtvEvent.class) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(this::handleKtvEvent); - disposables.addAll(disposable1, disposable2); - } - - - //处理KTV相关的各种事件 - private void handleKtvEvent(KtvEvent ktvEvent) { - MusicInfo musicInfo = ktvEvent.getMusicInfo(); - switch (ktvEvent.getType()) { - case KtvEvent.SWITCH_MUSIC: - if (musicInfo != null) { - statusView = showPrepare(musicInfo); - } - break; - case KtvEvent.STOP: - if (AudioEngineManager.get().isPush() && AudioEngineManager.get().isPlaying()) { - AudioEngineManager.get().playOrPause(); - } - break; - case KtvEvent.CONTINUE: - if (AudioEngineManager.get().isPush() && !AudioEngineManager.get().isPlaying()) { - AudioEngineManager.get().playOrPause(); - } - break; - case KtvEvent.NO_MUSIC: - statusView = showNoSong(); - break; - case KtvEvent.MUSIC_UPDATE: - if (KtvMusicManager.INSTANCE.getMusicList().size() > 0 && isShowNoSong) { - resetStatusView(); - } - if (KtvMusicManager.INSTANCE.getMusicList().size() == 0 && !isShowNoSong) { - statusView = showNoSong(); - } - break; - case KtvEvent.ROOM_USER_MANAGER_STATUS: - if (btnCloseNoSong != null) { - initCloseBtn(btnCloseNoSong); - } - break; - default: - break; - } - } - - - public synchronized void setupRemoteVideo(int uid) { - if (UserUtils.getUserUid() == uid || AudioEngineManager.get().isPush()) return; - if (!isShowPrepare) resetStatusView(); - playContainer.removeAllViews(); - SurfaceView surfaceView = RtcEngine.CreateRendererView(context.getApplicationContext()); - playContainer.addView(surfaceView); - AudioEngineManager.get().setupRemoteVideo(new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_ADAPTIVE, uid), uid); - } - - - static class NoSongViewHolder { - @BindView(R.id.tv_no_user) - TextView tvNoUser; - @BindView(R.id.tv_tips) - TextView tvTips; - @BindView(R.id.tv_choose_song) - SuperTextView tvChooseSong; - @BindView(R.id.ib_close) - ImageButton ibClose; - - NoSongViewHolder(View view) { - ButterKnife.bind(this, view); - } - } - - private String[] tips = new String[]{ - "点击“我要点歌”按钮可进行点歌哦~", - "建议唱歌的用户上麦点歌,以免有声音延迟", - "演唱时,佩戴耳机效果更佳哦~", - "耳机离嘴唇一定距离可防止喷麦", - "演唱时试试由腹部发声,会有意外收获"}; - - /** - * 无人唱歌界面的关闭按钮 - */ - private ImageButton btnCloseNoSong; - - private View showNoSong() { - isShowNoSong = true; - isShowPrepare = false; - playContainer.removeCallbacks(runnable); - View view = inflate(context, R.layout.layout_ktv_no_song, null); - NoSongViewHolder holder = new NoSongViewHolder(view); - view.setOnClickListener(v -> { - //吃掉父view点击事件 - }); - Logger.i("显示无人唱歌的ui"); - btnCloseNoSong = holder.ibClose; - initCloseBtn(holder.ibClose); - if (tipDisposable != null) tipDisposable.dispose(); - tipDisposable = Observable.interval(0, 5, TimeUnit.SECONDS) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(aLong -> holder.tvTips.setText(tips[(int) (aLong % tips.length)])); - holder.tvChooseSong.setOnClickListener(v -> KtvSelectSongActivity.start(context, true)); - showStatusView(view); - return view; - } - - - static class CommandViewHolder { - @BindView(R.id.ib_close) - ImageButton ibClose; - @BindView(R.id.tv_change_audio) - SuperTextView tvChangeAudio; - @BindView(R.id.tv_song_name) - TextView tvSongName; - @BindView(R.id.tv_commit_err) - TextView tvCommitErr; - @BindView(R.id.iv_play_or_pause) - ImageView ivPlayOrPause; - - @BindView(R.id.iv_switch_song) - ImageView ivSwitchSong; - @BindView(R.id.sb_person_voice) - SeekBar sbPersonVoice; - @BindView(R.id.sb_accompany_voice) - SeekBar sbAccompanyVoice; - @BindView(R.id.sb_song_current_position) - SeekBar sbSongCurrentPosition; - @BindView(R.id.group_seek_bar) - Group group; - @BindView(R.id.tv_surplus_time) - TextView tvSurplusTime; - CommandViewHolder(View view) { - ButterKnife.bind(this, view); - } - } - - private View commandView; - - private Disposable commandDisposable; - - private View showCommand() { - playContainer.postDelayed(runnable, 3000); - if (commandView == null) { - commandView = inflate(context, R.layout.layout_ktv_command, null); - } - CommandViewHolder holder = new CommandViewHolder(commandView); - if (getUserType() != KTV_ROOM_MV_BROADCASTER) { - holder.group.setVisibility(GONE); - } else { - holder.group.setVisibility(VISIBLE); - } - holder.tvSongName.setText(KtvMusicManager.INSTANCE.getCurrMusic().getMusicName()); - initPlayBtn(holder); - initCloseBtn(holder.ibClose); - initChangeAudioBtn(holder.tvChangeAudio); - holder.tvChangeAudio.setOnClickListener(v -> { - AudioEngineManager.get().changeAudioStream(); - initChangeAudioBtn(holder.tvChangeAudio); - resetStatusView(); - }); - holder.tvCommitErr.setOnClickListener(v -> - KtvCommitErrorDialog.newInstance(context, KtvMusicManager.INSTANCE.getCurrMusic().getMusicId()).show()); - holder.ivPlayOrPause.setOnClickListener(v -> { - if (AudioEngineManager.get().isPush()) { - AudioEngineManager.get().playOrPause(); - } - /* else { //暂时不需要 - KtvHelper.sendChatRoomMusicMessage( - AudioEngineManager.get().isPlaying() ? CUSTOM_MSG_SUB_KTV_STOP : CUSTOM_MSG_SUB_KTV_CONTINUE, - null) - .subscribe(); - }*/ - initPlayBtn(holder); - resetStatusView(); - }); - holder.ivSwitchSong.setOnClickListener(v -> { - KtvMusicManager.INSTANCE.switchSong(true); - resetStatusView(); - }); - holder.sbAccompanyVoice.setProgress((int) (AudioEngineManager.get().getAccompanyVoice()*100)); - holder.sbAccompanyVoice.setOnSeekBarChangeListener( - (LambdaOnSeekBarChangeListener) (seekBar, progress, fromUser) -> - AudioEngineManager.get().setAccompanyVoice(progress/100d)); - holder.sbPersonVoice.setProgress((int) (AudioEngineManager.get().getPersonVoice()*100)); - holder.sbPersonVoice.setOnSeekBarChangeListener( - (LambdaOnSeekBarChangeListener) (seekBar, progress, fromUser) -> - AudioEngineManager.get().setPersonVoice(progress/100d)); - releaseCommandDisposable(); - commandDisposable = Observable.interval(0, 1, TimeUnit.SECONDS, AndroidSchedulers.mainThread()) - .subscribe(aLong -> setSeekDuration(holder)); - showStatusView(commandView); - return commandView; - } - - private void releaseCommandDisposable() { - if (commandDisposable != null && !commandDisposable.isDisposed()) { - commandDisposable.dispose(); - commandDisposable = null; - } - } - - @SuppressLint("ClickableViewAccessibility") - private void setSeekDuration(CommandViewHolder holder) { - double pos = AudioEngineManager.get().getPlayPos(); - holder.sbSongCurrentPosition.setProgress((int) (100 * pos)); - //禁止点击 - holder.sbSongCurrentPosition.setClickable(false); - holder.sbSongCurrentPosition.setOnTouchListener(new OnTouchListener() { - @Override - public boolean onTouch(View v, MotionEvent event) { - return true; - } - }); - int duration = AudioEngineManager.get().getPlayDuration() / 1000;//单位秒 - duration = (int) (duration - duration * pos);//剩余的时间 - if (duration < 0) { - duration = 0; - } - int min = duration / 60; - int sec = duration % 60; - String secStr = String.valueOf(sec); - if (sec < 10) { - secStr = "0" + secStr; - } - holder.tvSurplusTime.setText("-" + min + ":" + secStr); - } - - private void initPlayBtn(CommandViewHolder holder) { - if (AudioEngineManager.get().isPlaying()) { - holder.ivPlayOrPause.setImageResource(R.drawable.icon_ktv_pause); - } else { - holder.ivPlayOrPause.setImageResource(R.drawable.icon_ktv_play); - } - } - - private void initChangeAudioBtn(SuperTextView textView) { - if (!AudioEngineManager.get().isAccompany()) { - textView.setTextColor(getResources().getColor(R.color.color_CCFF5B69)); - textView.setText("原唱"); - } else { - textView.setTextColor(getResources().getColor(R.color.white_transparent_60)); - textView.setText("伴奏"); - } - } - - static class PrepareViewHolder { - @BindView(R.id.ib_close) - ImageButton ibClose; - @BindView(R.id.iv_avatar) - ImageView ivAvatar; - @BindView(R.id.tv_no_user) - TextView tvNoUser; - @BindView(R.id.tv_song_name) - TextView tvSongName; - @BindView(R.id.tv_tips) - SuperTextView tvTips; - @BindView(R.id.iv_singer_avatar_bg) - ImageView ivSingerAvatarBg; - - PrepareViewHolder(View view) { - ButterKnife.bind(this, view); - } - } - - private View showPrepare(MusicInfo musicInfo) { - isShowPrepare = true; - isShowNoSong = false; - View view = inflate(context, R.layout.layout_ktv_prepare, null); - view.setOnClickListener(v -> { - //吃掉父view点击事件 - }); - PrepareViewHolder holder = new PrepareViewHolder(view); - RoomQueueInfo roomQueueInfo = AvRoomDataManager.get().getRoomQueueMemberInfoByAccount(String.valueOf(musicInfo.getUid())); - if (roomQueueInfo != null && roomQueueInfo.mChatRoomMember != null) { - ImageLoadUtils.loadAvatar(context, roomQueueInfo.mChatRoomMember.getAvatar(), holder.ivAvatar); - ImageLoadUtils.loadImageWithBlur(context, - roomQueueInfo.mChatRoomMember.getAvatar(), holder.ivSingerAvatarBg, 24, 10); - } - holder.tvNoUser.setText(musicInfo.getUserNick() + " 请准备"); - initCloseBtn(holder.ibClose); - if (prepareDisposable != null) prepareDisposable.dispose(); - - boolean isPushUser = UserUtils.getUserUid() == musicInfo.getUid(); - showXPlay(isPushUser); - Observable.intervalRange(0, 4, 0, 1, TimeUnit.SECONDS) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(new Observer() { - @Override - public void onNext(Long aLong) { - holder.tvSongName.setText((3 - aLong) + "秒后开始演唱: " + musicInfo.getMusicName()); - } - - @Override - public void onComplete() { - //准备中下麦处理 - if (isShowPrepare) { - resetStatusView(); - } - - } - - @Override - public void onSubscribe(Disposable d) { - prepareDisposable = d; - } - - @Override - public void onError(Throwable e) { - e.printStackTrace(); - } - }); - showStatusView(view); - return view; - } - - static class ChooseSongViewHolder { - @BindView(R.id.tv_tips) - TextView tvTips; - @BindView(R.id.tv_choose_song) - SuperTextView tvChooseSong; - - ChooseSongViewHolder(View view) { - ButterKnife.bind(this, view); - } - } - - private View showChooseSong() { - playContainer.postDelayed(runnable, 3000); - View view = inflate(context, R.layout.layout_ktv_choose_song, null); - ChooseSongViewHolder holder = new ChooseSongViewHolder(view); - holder.tvTips.setText(KtvMusicManager.INSTANCE.getCurrMusic().getMusicName()); - holder.tvChooseSong.setOnClickListener(v -> KtvSelectSongActivity.start(context, true)); - showStatusView(view); - return view; - } - - private void showStatusView(View view) { - statusContainer.setVisibility(VISIBLE); - statusContainer.removeAllViews(); - statusContainer.addView(view); - } - - private void resetStatusView() { - if (statusView != null) { - isShowNoSong = false; - isShowPrepare = false; - playContainer.removeCallbacks(runnable); - statusContainer.setVisibility(GONE); - statusView = null; - } - btnCloseNoSong = null; - releaseCommandDisposable(); - } - - private int getUserType() { - MusicInfo currMusic = KtvMusicManager.INSTANCE.getCurrMusic(); - if (currMusic.getUid() == UserUtils.getUserUid()) { - return KTV_ROOM_MV_BROADCASTER; - } - if (AvRoomDataManager.get().isRoomOwner()) { - return KTV_ROOM_OWNER; - } - if (AvRoomDataManager.get().isRoomAdmin()) { - return KTV_ROOM_MANAGER; - } - return KTV_ROOM_AUDIENCE; - } - - /** - * 如果是房主或管理员,显示关闭ktv的按钮 - * - * @param button 关闭ktv的按钮 - */ - - private void initCloseBtn(ImageButton button) { - if (AvRoomDataManager.get().isManager()) { - button.setVisibility(VISIBLE); - button.setOnClickListener(v -> { - if (SuperAdminUtil.isSuperAdmin()) { - SingleToastUtil.showToast(SaConstant.TOAST_ERROR_TIPS); - return; - } - if (AvRoomDataManager.get().isCpRoom()) { - StatisticManager.Instance().onEvent(StatisticsProtocol.roomcp_ktv_close_click, "关闭KTV"); - } - new DialogManager(context).showOkCancelWithTitleDialog("关闭KTV后,所有歌曲将被删除!", - () -> { - RxBus.get().post(new KtvEvent(KtvEvent.CLOSE_KTV_MODEL)); - KtvHelper.sendChatRoomMusicMessage(CUSTOM_MSG_SUB_KTV_CLOSE, new MusicInfo()) - .subscribe(chatRoomMessage -> IMNetEaseManager.get().addMessages(chatRoomMessage)); - }); - }); - - } else { - button.setVisibility(INVISIBLE); - } - } - - @Override - protected void onDetachedFromWindow() { - super.onDetachedFromWindow(); - if (disposables != null) disposables.dispose(); - if (tipDisposable != null) tipDisposable.dispose(); - if (prepareDisposable != null) prepareDisposable.dispose(); - } - - private void showXPlay(boolean isShow) { - /*if (isShow && AudioEngineManager.get().getKtvKit()!=null) { - playContainer.removeAllViews(); - xPlay = new VideoPlayerView(context, AudioEngineManager.get().getKtvKit()); - xPlay.setZOrderMediaOverlay(true); - playContainer.addView(xPlay); - }*/ - - } - - public void updateCloseBtnNoSong() { - if (btnCloseNoSong != null) { - initCloseBtn(btnCloseNoSong); - } - } -} diff --git a/app/src/main/java/com/yizhuan/erban/avroom/ktv/LambdaOnSeekBarChangeListener.java b/app/src/main/java/com/yizhuan/erban/avroom/ktv/LambdaOnSeekBarChangeListener.java deleted file mode 100644 index fafca7b98..000000000 --- a/app/src/main/java/com/yizhuan/erban/avroom/ktv/LambdaOnSeekBarChangeListener.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.yizhuan.erban.avroom.ktv; - -import android.widget.SeekBar; - -public interface LambdaOnSeekBarChangeListener extends SeekBar.OnSeekBarChangeListener { - @Override - default void onStartTrackingTouch(SeekBar seekBar) { - } - - @Override - default void onStopTrackingTouch(SeekBar seekBar) { - } -} diff --git a/app/src/main/java/com/yizhuan/erban/avroom/widget/MessageView.java b/app/src/main/java/com/yizhuan/erban/avroom/widget/MessageView.java index 6f457d5cc..ae5a42891 100644 --- a/app/src/main/java/com/yizhuan/erban/avroom/widget/MessageView.java +++ b/app/src/main/java/com/yizhuan/erban/avroom/widget/MessageView.java @@ -102,7 +102,6 @@ import com.yizhuan.xchat_android_core.im.custom.bean.MonsterHuntingResultAttachm import com.yizhuan.xchat_android_core.im.custom.bean.MonsterStatusAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.MultiGiftAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.MultiLuckyGiftAttachment; -import com.yizhuan.xchat_android_core.im.custom.bean.MusicInfoAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.NobleAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.RedPackageRoomMsgAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.RoomBoxPrizeAttachment; @@ -138,7 +137,6 @@ import com.yizhuan.xchat_android_core.room.bean.WelcomeInfo; import com.yizhuan.xchat_android_core.room.face.DynamicFaceModel; import com.yizhuan.xchat_android_core.room.face.FaceInfo; import com.yizhuan.xchat_android_core.room.face.FaceReceiveInfo; -import com.yizhuan.xchat_android_core.room.ktv.bean.MusicInfo; import com.yizhuan.xchat_android_core.room.model.AvRoomModel; import com.yizhuan.xchat_android_core.room.pk.attachment.RoomPkAttachment; import com.yizhuan.xchat_android_core.room.pk.bean.PKTeamInfo; @@ -873,11 +871,8 @@ public class MessageView extends FrameLayout { } } else if (first == CustomAttachment.CUSTOM_MSG_BOX) { setBoxMeMsg(chatRoomMessage, tvContent); - } - else if (first == CustomAttachment.CUSTOM_MSG_RADISH) { + } else if (first == CustomAttachment.CUSTOM_MSG_RADISH) { setRadishMeMsg(chatRoomMessage, tvContent); - }else if (first == CustomAttachment.CUSTOM_MSG_KTV) { - setKtvMsg(chatRoomMessage, tvContent); } else if (first == CustomAttachment.CUSTOM_MSG_QUEUING_MIC) { switch (second) { case CustomAttachment.CUSTOM_MSG_SUB_QUEUING_MIC_NON_EMPTY: @@ -2596,59 +2591,6 @@ public class MessageView extends FrameLayout { tvContent.setText(text.build()); } - private void setKtvMsg(ChatRoomMessage chatRoomMessage, TextView tvContent) { - - MusicInfoAttachment attachment = (MusicInfoAttachment) chatRoomMessage.getAttachment(); - MusicInfo musicInfo = attachment.getMusicInfo(); - if (musicInfo == null) return; - String tip = ""; - int second = attachment.getSecond(); - switch (second) { - case CustomAttachment.CUSTOM_MSG_SUB_KTV_ADD: - tip = " 点了一首 "; - break; - case CustomAttachment.CUSTOM_MSG_SUB_KTV_DELETE: - tip = " 删除了 "; - break; - case CustomAttachment.CUSTOM_MSG_SUB_KTV_SWITCH: - tip = " 切掉了 "; - break; - case CustomAttachment.CUSTOM_MSG_SUB_KTV_TOP: - tip = " 置顶了 "; - break; - case CustomAttachment.CUSTOM_MSG_SUB_KTV_FINISH: - tip = " 演唱结束,呱唧呱唧"; - break; - case CustomAttachment.CUSTOM_MSG_SUB_KTV_OPEN: - tip = " 房主或管理员开启了KTV模式"; - break; - case CustomAttachment.CUSTOM_MSG_SUB_KTV_CLOSE: - tip = " 房主或管理员关闭了KTV模式"; - break; - } - - //开启和关闭ktv模式的消息 - if (second == CustomAttachment.CUSTOM_MSG_SUB_KTV_OPEN || second == CustomAttachment.CUSTOM_MSG_SUB_KTV_CLOSE) { - SpannableBuilder text = new SpannableBuilder(tvContent) - .append("消息: ", new ForegroundColorSpan(roomTipColor)) - .append(tip, new ForegroundColorSpan(greyColor)); - tvContent.setText(text.build()); - return; - } - // 内容 - String nick = TextUtils.isEmpty(musicInfo.getOperationNick()) ? - musicInfo.getUserNick() : musicInfo.getOperationNick(); - nick = RegexUtil.getPrintableString(nick); - SpannableBuilder text = new SpannableBuilder(tvContent) - .append(nick, - new ForegroundColorSpan(roomTipNickColor)) - .append(tip, new ForegroundColorSpan(greyColor)); - if (attachment.getSecond() != CustomAttachment.CUSTOM_MSG_SUB_KTV_FINISH) {//结束的消息不需要拼接歌曲名 - text.append(musicInfo.getMusicName()); - } - tvContent.setText(text.build()); - } - /** * 瓜分钻石的消息,二级和三级都有 * diff --git a/app/src/main/java/com/yizhuan/erban/ui/widget/UserInfoDialog.java b/app/src/main/java/com/yizhuan/erban/ui/widget/UserInfoDialog.java index e51f197e5..faf339150 100644 --- a/app/src/main/java/com/yizhuan/erban/ui/widget/UserInfoDialog.java +++ b/app/src/main/java/com/yizhuan/erban/ui/widget/UserInfoDialog.java @@ -35,7 +35,6 @@ import com.yizhuan.erban.avroom.ButtonItemFactory; import com.yizhuan.erban.avroom.activity.AVRoomActivity; import com.yizhuan.erban.avroom.adapter.UpMicAdapter; import com.yizhuan.erban.avroom.giftvalue.GiftValueDialogUiHelper; -import com.yizhuan.erban.avroom.ktv.KtvMusicManager; import com.yizhuan.erban.avroom.widget.ViewItem; import com.yizhuan.erban.common.widget.dialog.DialogManager; import com.yizhuan.erban.ui.user.UserInfoActivity; @@ -1106,15 +1105,7 @@ public class UserInfoDialog extends AppCompatDialog implements View.OnClickListe SingleToastUtil.showToast("游戏中不可以主动下麦!"); return; } - - if (AvRoomDataManager.get().mCurrentRoomInfo.isOpenKTV()) { - new DialogManager(context).showOkCancelDialog("KTV模式下下麦会移除您已点的所有歌曲,确定进行此操作?", false, - () -> { - handleDownMicro(); - KtvMusicManager.INSTANCE.deleteUserAllChooseMusic().subscribe(); - } - ); - } else if (AvRoomDataManager.get().haveStartDragon) { + if (AvRoomDataManager.get().haveStartDragon) { new DialogManager(context).showOkCancelDialog("你正在交友匹配中,此操作代表你放弃本局匹配展示,确定进行此操作?", false, new DialogManager.OkCancelDialogListener() { @Override public void onCancel() { diff --git a/app/src/main/res/layout/activity_ktv_room_list.xml b/app/src/main/res/layout/activity_ktv_room_list.xml deleted file mode 100644 index 04ff73878..000000000 --- a/app/src/main/res/layout/activity_ktv_room_list.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/activity_ktv_search_song.xml b/app/src/main/res/layout/activity_ktv_search_song.xml deleted file mode 100644 index a7d1a07f7..000000000 --- a/app/src/main/res/layout/activity_ktv_search_song.xml +++ /dev/null @@ -1,179 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/activity_ktv_select_song.xml b/app/src/main/res/layout/activity_ktv_select_song.xml deleted file mode 100644 index 65ab228f3..000000000 --- a/app/src/main/res/layout/activity_ktv_select_song.xml +++ /dev/null @@ -1,113 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_ktv_song_list.xml b/app/src/main/res/layout/activity_ktv_song_list.xml deleted file mode 100644 index fc1b82642..000000000 --- a/app/src/main/res/layout/activity_ktv_song_list.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_ktv_commit_error.xml b/app/src/main/res/layout/dialog_ktv_commit_error.xml deleted file mode 100644 index bcd0e68c2..000000000 --- a/app/src/main/res/layout/dialog_ktv_commit_error.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_ktv_select_song.xml b/app/src/main/res/layout/dialog_ktv_select_song.xml deleted file mode 100644 index 09b7fa76b..000000000 --- a/app/src/main/res/layout/dialog_ktv_select_song.xml +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/layout_ktv_choose_song.xml b/app/src/main/res/layout/layout_ktv_choose_song.xml deleted file mode 100644 index bd8ed3d14..000000000 --- a/app/src/main/res/layout/layout_ktv_choose_song.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - diff --git a/app/src/main/res/layout/layout_ktv_command.xml b/app/src/main/res/layout/layout_ktv_command.xml deleted file mode 100644 index 06ff3cf32..000000000 --- a/app/src/main/res/layout/layout_ktv_command.xml +++ /dev/null @@ -1,209 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/layout_ktv_no_song.xml b/app/src/main/res/layout/layout_ktv_no_song.xml deleted file mode 100644 index de0a2cbc3..000000000 --- a/app/src/main/res/layout/layout_ktv_no_song.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - diff --git a/app/src/main/res/layout/layout_ktv_prepare.xml b/app/src/main/res/layout/layout_ktv_prepare.xml deleted file mode 100644 index 0657e4cfc..000000000 --- a/app/src/main/res/layout/layout_ktv_prepare.xml +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/layout_ktv_view.xml b/app/src/main/res/layout/layout_ktv_view.xml deleted file mode 100644 index 6085137fe..000000000 --- a/app/src/main/res/layout/layout_ktv_view.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/list_item_ktv_micro.xml b/app/src/main/res/layout/list_item_ktv_micro.xml deleted file mode 100644 index d8f244282..000000000 --- a/app/src/main/res/layout/list_item_ktv_micro.xml +++ /dev/null @@ -1,151 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/list_item_ktv_room.xml b/app/src/main/res/layout/list_item_ktv_room.xml deleted file mode 100644 index 225611d46..000000000 --- a/app/src/main/res/layout/list_item_ktv_room.xml +++ /dev/null @@ -1,84 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/list_item_ktv_search.xml b/app/src/main/res/layout/list_item_ktv_search.xml deleted file mode 100644 index 20fd07bb7..000000000 --- a/app/src/main/res/layout/list_item_ktv_search.xml +++ /dev/null @@ -1,109 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/list_item_ktv_select.xml b/app/src/main/res/layout/list_item_ktv_select.xml deleted file mode 100644 index a567425be..000000000 --- a/app/src/main/res/layout/list_item_ktv_select.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/list_item_ktv_song.xml b/app/src/main/res/layout/list_item_ktv_song.xml deleted file mode 100644 index 58a2d4d63..000000000 --- a/app/src/main/res/layout/list_item_ktv_song.xml +++ /dev/null @@ -1,99 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/build.gradle b/build.gradle index 67585e268..9d8d0c698 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.4.0' + ext.kotlin_version = '1.5.31' println "\n\n\n" println '当前选择版本 Version Name:'+ version_name diff --git a/core/build.gradle b/core/build.gradle index 28a6f4f07..73e75ee88 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -56,13 +56,13 @@ android { } def loggerVersion = "2.2.0" -def Lombok = "1.18.10" +def Lombok = "1.18.18" dependencies { api fileTree(dir: 'libs', include: ['*.jar']) - testImplementation 'junit:junit:4.13.1' - androidTestImplementation 'androidx.test.ext:junit:1.1.2' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' api "com.orhanobut:logger:${loggerVersion}" @@ -76,10 +76,10 @@ dependencies { // 支付 api fileTree(dir: 'alipay-libs', include: ['*.jar']) - api 'com.tencent.mm.opensdk:wechat-sdk-android-with-mta:5.1.6' + api 'com.tencent.mm.opensdk:wechat-sdk-android-with-mta:5.4.0' // 声网 - api 'io.agora.rtc:full-sdk:3.0.1' + api 'io.agora.rtc:full-sdk:3.6.2' // core implementation 'com.liulishuo.okdownload:okdownload:1.0.4' @@ -88,17 +88,16 @@ dependencies { // provide okhttp to connect to backend implementation 'com.liulishuo.okdownload:okhttp:1.0.4' // Room - api 'androidx.room:room-runtime:2.2.5' - annotationProcessor 'androidx.room:room-compiler:2.2.5' + api 'androidx.room:room-runtime:2.3.0' + annotationProcessor 'androidx.room:room-compiler:2.3.0' // RxJava support for Room - api 'androidx.room:room-rxjava2:2.2.5' + api 'androidx.room:room-rxjava2:2.3.0' - api 'com.tencent.bugly:crashreport_upgrade:1.5.23' + api 'com.tencent.bugly:crashreport_upgrade:1.6.1' api 'com.tencent.bugly:nativecrashreport:3.9.2' api project(':nim_uikit') api project(':library') - api project(':agora-ktv-kit-release') api project(':trtc_release') } diff --git a/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/manager/IMNetEaseManager.java b/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/manager/IMNetEaseManager.java index 641275b89..72cb5901b 100644 --- a/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/manager/IMNetEaseManager.java +++ b/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/manager/IMNetEaseManager.java @@ -97,7 +97,6 @@ import com.yizhuan.xchat_android_core.im.custom.bean.MonsterHuntingResultAttachm import com.yizhuan.xchat_android_core.im.custom.bean.MonsterStatusAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.MultiGiftAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.MultiLuckyGiftAttachment; -import com.yizhuan.xchat_android_core.im.custom.bean.MusicInfoAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.NobleAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.RoomBoxPrizeAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.RoomGiftValueAttachment; @@ -136,8 +135,6 @@ import com.yizhuan.xchat_android_core.room.bean.RoomInfo; import com.yizhuan.xchat_android_core.room.exception.AntiSpamHitException; import com.yizhuan.xchat_android_core.room.face.DynamicFaceModel; import com.yizhuan.xchat_android_core.room.giftvalue.helper.GiftValueMrg; -import com.yizhuan.xchat_android_core.room.ktv.bean.MusicInfo; -import com.yizhuan.xchat_android_core.room.ktv.event.KtvEvent; import com.yizhuan.xchat_android_core.room.model.AvRoomModel; import com.yizhuan.xchat_android_core.room.model.MicQueueModel; import com.yizhuan.xchat_android_core.room.pk.attachment.RoomPkAttachment; @@ -994,41 +991,6 @@ public final class IMNetEaseManager { noticeDragonBarStart(msg, RoomEvent.DRAGON_BAR_START); } break; - case CUSTOM_MSG_KTV: - MusicInfo musicInfo = ((MusicInfoAttachment) msg.getAttachment()).getMusicInfo(); - switch (second) { - case CUSTOM_MSG_SUB_KTV_SWITCH: - case CUSTOM_MSG_SUB_KTV_TOP: - case CUSTOM_MSG_SUB_KTV_OPEN: - case CUSTOM_MSG_SUB_KTV_CLOSE: - case CUSTOM_MSG_SUB_KTV_FINISH: - addMessages(msg); - break; - case CUSTOM_MSG_SUB_KTV_SWITCH_NO_SEND: - RxBus.get().post(KtvEvent.newInstance(KtvEvent.SWITCH_MUSIC, musicInfo)); - break; - case CUSTOM_MSG_SUB_KTV_ADD: - addMessages(msg); - RxBus.get().post(KtvEvent.newInstance(KtvEvent.ADD_MUSIC, musicInfo)); - break; - case CUSTOM_MSG_SUB_KTV_DELETE: - addMessages(msg); - RxBus.get().post(KtvEvent.newInstance(KtvEvent.DELETE_USER_CHOOSE_MUSIC, musicInfo)); - break; - case CUSTOM_MSG_SUB_KTV_DELETE_USER_ALL: - RxBus.get().post(KtvEvent.newInstance(KtvEvent.DELETE_USER_ALL_MUSIC, musicInfo)); - break; - case CUSTOM_MSG_SUB_KTV_END: - RxBus.get().post(KtvEvent.newInstance(KtvEvent.NO_MUSIC, musicInfo)); - break; - case CUSTOM_MSG_SUB_KTV_STOP: - RxBus.get().post(KtvEvent.newInstance(KtvEvent.STOP, musicInfo)); - break; - case CUSTOM_MSG_SUB_KTV_CONTINUE: - RxBus.get().post(KtvEvent.newInstance(KtvEvent.CONTINUE, musicInfo)); - break; - } - break; case CUSTOM_MSG_GAME: break; case CUSTOM_MSG_QUEUING_MIC: diff --git a/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/manager/agora/RtcEngineManager.java b/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/manager/agora/RtcEngineManager.java index 137325b80..ee5a1538d 100644 --- a/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/manager/agora/RtcEngineManager.java +++ b/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/manager/agora/RtcEngineManager.java @@ -154,7 +154,7 @@ public class RtcEngineManager extends BaseEngine { public void setRemoteMute(long uid, boolean mute) { Logger.t(TAG).d("setRemoteMute uid:%s mute:%s", uid, mute); - if (mRtcEngine != null) { + if (mRtcEngine != null && !isRemoteMute) { mRtcEngine.muteRemoteAudioStream((int) uid, mute); } } diff --git a/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/manager/trtc/TRTCEffectManager.java b/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/manager/trtc/TRTCEffectManager.java index 81e85f8c5..b0a7d0e51 100644 --- a/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/manager/trtc/TRTCEffectManager.java +++ b/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/manager/trtc/TRTCEffectManager.java @@ -7,6 +7,7 @@ import java.util.HashSet; import java.util.Set; import io.agora.rtc.IAudioEffectManager; +import io.agora.rtc.audio.AgoraRhythmPlayerConfig; /** * 音效的控制类 @@ -103,6 +104,11 @@ public class TRTCEffectManager implements IAudioEffectManager { return 0; } + @Override + public int playEffect(int soundId, String filePath, int loopCount, double pitch, double pan, double gain, boolean publish, int startPos) { + return 0; + } + @Override public int stopEffect(int soundId) { stopAudioEffect(soundId); @@ -161,6 +167,36 @@ public class TRTCEffectManager implements IAudioEffectManager { return 0; } + @Override + public int getEffectCurrentPosition(int soundId) { + return 0; + } + + @Override + public int setEffectPosition(int soundId, int pos) { + return 0; + } + + @Override + public int getEffectDuration(String filePath) { + return 0; + } + + @Override + public int startRhythmPlayer(String sound1, String sound2, AgoraRhythmPlayerConfig config) { + return 0; + } + + @Override + public int stopRhythmPlayer() { + return 0; + } + + @Override + public int configRhythmPlayer(AgoraRhythmPlayerConfig config) { + return 0; + } + public void setMusicObserver(TXAudioEffectManager.TXMusicPlayObserver observer) { mMusicPlayObserver = observer; } diff --git a/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/manager/trtc/TRTCEngineAdapter.java b/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/manager/trtc/TRTCEngineAdapter.java index 3faf792ce..a536d1048 100644 --- a/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/manager/trtc/TRTCEngineAdapter.java +++ b/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/manager/trtc/TRTCEngineAdapter.java @@ -1642,7 +1642,7 @@ public class TRTCEngineAdapter extends BaseAdapterImpl { TRTCEngineAdapterListener.onError(WARN_INVALID_VIEW); return -1; } - localVideoView = new TXCloudVideoView(local.view); + localVideoView = new TXCloudVideoView(local.view.getContext()); isStartPreview = true; this.startPreview(); @@ -1663,8 +1663,8 @@ public class TRTCEngineAdapter extends BaseAdapterImpl { remoteVideoMap.remove(remote.uid); return -1; } - remoteVideoMap.put(remote.uid, new TXCloudVideoView(remote.view)); - trtcCloud.startRemoteView(String.valueOf(remote.uid), new TXCloudVideoView(remote.view)); + remoteVideoMap.put(remote.uid, new TXCloudVideoView(remote.view.getContext())); + trtcCloud.startRemoteView(String.valueOf(remote.uid), new TXCloudVideoView(remote.view.getContext())); return 0; } diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachParser.java b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachParser.java index 57213f6bf..5b84a9da1 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachParser.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachParser.java @@ -323,10 +323,6 @@ public class CustomAttachParser implements MsgAttachmentParser { case CUSTOM_MSG_BOX: attachment = new RoomBoxPrizeAttachment(CUSTOM_MSG_BOX, second); break; - case CUSTOM_MSG_KTV: - attachment = new MusicInfoAttachment(first, second); - break; - case CUSTOM_MSG_PUBLIC_CHAT_HALL: switch (second) { case CUSTOM_MSG_SUB_PUBLIC_CHAT_HALL_AIT: diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/MusicInfoAttachment.java b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/MusicInfoAttachment.java deleted file mode 100644 index b7608e5d8..000000000 --- a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/MusicInfoAttachment.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.yizhuan.xchat_android_core.im.custom.bean; - -import com.alibaba.fastjson.JSONObject; -import com.google.gson.Gson; -import com.yizhuan.xchat_android_core.room.ktv.bean.MusicInfo; - -/** - * Created by chenran on 2017/10/4. - */ - -public class MusicInfoAttachment extends CustomAttachment { - private MusicInfo musicInfo; - - public MusicInfoAttachment(int first, int second) { - super(first, second); - } - - @Override - protected void parseData(JSONObject jsonObject) { - musicInfo = new Gson().fromJson(jsonObject.toJSONString(),MusicInfo.class); - } - - public MusicInfo getMusicInfo() { - return musicInfo; - } - - public void setMusicInfo(MusicInfo musicInfo) { - this.musicInfo = musicInfo; - } - - @Override - protected JSONObject packData() { - JSONObject object = new JSONObject(); - if (musicInfo!=null){ - object.put("userNick", musicInfo.getUserNick()); - object.put("avatar", musicInfo.getAvatar()); - object.put("cover", musicInfo.getCover()); - object.put("duration", musicInfo.getDuration()); - object.put("durationFormat", musicInfo.getDurationFormat()); - object.put("musicId", musicInfo.getMusicId()); - object.put("musicName", musicInfo.getMusicName()); - object.put("musicUrl", musicInfo.getMusicUrl()); - object.put("operationNick", musicInfo.getOperationNick()); - object.put("operationUid", musicInfo.getOperationUid()); - object.put("singer", musicInfo.getSinger()); - object.put("uid", musicInfo.getUid()); - object.put("uploader", musicInfo.getUploader()); - } - return object; - } - - @Override - public String toString() { - return "MusicInfoAttachment{" + - "musicInfo=" + musicInfo + - ", first=" + first + - ", second=" + second + - '}'; - } -} diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/manager/AvRoomDataManager.java b/core/src/main/java/com/yizhuan/xchat_android_core/manager/AvRoomDataManager.java index 594496464..bfa53a567 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/manager/AvRoomDataManager.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/manager/AvRoomDataManager.java @@ -33,7 +33,6 @@ import com.yizhuan.xchat_android_core.room.bean.SimplePartyRoomInfo; import com.yizhuan.xchat_android_core.room.event.RoomClearScreenEvent; import com.yizhuan.xchat_android_core.room.game.GameStatus; import com.yizhuan.xchat_android_core.room.giftvalue.helper.GiftValueMrg; -import com.yizhuan.xchat_android_core.room.ktv.event.KtvEvent; import com.yizhuan.xchat_android_core.room.bean.RoomModeType; import com.yizhuan.xchat_android_core.super_admin.SuperAdminDataMrg; import com.yizhuan.xchat_android_core.super_admin.util.SuperAdminUtil; @@ -58,7 +57,6 @@ import java.util.Map; import java.util.Objects; import io.reactivex.Single; -import io.reactivex.disposables.Disposable; import io.reactivex.processors.PublishProcessor; /** @@ -519,9 +517,6 @@ public final class AvRoomDataManager { if (AvRoomDataManager.get().isOwner(account) && mOwnerMember != null) { //自己是管理员被移除,恢复身份 mOwnerMember.setMemberType(MemberType.NORMAL); - if (isOpenKTV()) { - notifyManagerChange(); - } } } @@ -1024,11 +1019,7 @@ public final class AvRoomDataManager { * @return - */ public boolean isOpenKTV() { - RoomInfo roomInfo = AvRoomDataManager.get().mCurrentRoomInfo; - if (roomInfo == null) { - return false; - } - return roomInfo.isOpenKTV(); + return false; } /** @@ -1100,14 +1091,6 @@ public final class AvRoomDataManager { if (!isContain) { mRoomManagerList.add(member); } - if (isOwner(member.getAccount()) && isOpenKTV()) { - //如果是自己被添加管理员,才发出事件 - notifyManagerChange(); - } - } - - private void notifyManagerChange() { - RxBus.get().post(KtvEvent.newInstance(KtvEvent.ROOM_USER_MANAGER_STATUS, null)); } public long getRoomId() { diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/room/ktv/IKtvModel.java b/core/src/main/java/com/yizhuan/xchat_android_core/room/ktv/IKtvModel.java deleted file mode 100644 index 2849a401d..000000000 --- a/core/src/main/java/com/yizhuan/xchat_android_core/room/ktv/IKtvModel.java +++ /dev/null @@ -1,126 +0,0 @@ -package com.yizhuan.xchat_android_core.room.ktv; - -import com.yizhuan.xchat_android_core.base.IModel; -import com.yizhuan.xchat_android_core.bean.response.ServiceResult; -import com.yizhuan.xchat_android_core.room.ktv.bean.KtvRoomInfo; -import com.yizhuan.xchat_android_core.room.ktv.bean.MusicInfo; -import com.yizhuan.xchat_android_core.room.ktv.bean.RoomMusicInfo; -import java.util.List; -import io.reactivex.Single; - - -public interface IKtvModel extends IModel { - - /** - * 房间已点歌曲列表 - * - * @param roomUid 房主uid - * @return - */ - Single> getRoomMusic(long roomUid); - - /** - * 获取ktv房间列表 - * - * @param orderType 排序方式。1:最新, 2:最热 - * @return - */ - Single>> getKtvRooms(int orderType, int page, int pageSize); - - /** - * 搜索歌曲 - * - * @param searchKey 搜索关键字 - * @return 歌曲列表 - */ - Single>> searchMusic(String searchKey, int page, int pageSize); - - /** - * 热门歌曲列表 - * - * @return - */ - Single>> hotMusic(int page, int pageSize); - - /** - * 删除用户已点的歌曲(单曲) - * - * @param musicId 歌曲id - * @param uid 被删除歌曲的用户uid - * @param roomUid 房主uid - * @return - */ - Single deleteUserChooseMusic(int musicId, long uid, long roomUid); - - /** - * 删除用户已点的所有歌曲,如果正在演唱的是他的歌,后台会发送切歌消息 - * - * @param uid - * @param roomUid - * @return - */ - Single deleteUserAllChooseMusic(long uid, long roomUid); - - /** - * 删除房间已点的所有歌曲 - * - * @param roomUid - * @return - */ - Single deleteRoomAllChooseMusic(long roomUid); - - /** - * 开启房间ktv模式 - * - * @param roomUid - * @return - */ - Single openKtvMode(long roomUid); - - /** - * 关闭房间ktv模式 - * - * @param roomUid - * @return - */ - Single closeKtvMode(long roomUid); - - /** - * 置顶歌曲 - * - * @param musicId 歌曲id - * @param uid 置顶歌曲对应的用户uid - * @param roomUid 房主uid - * @return - */ - Single popMusic(int musicId, long uid, long roomUid); - - /** - * 切歌 - * - * @param roomUid - * @return - */ - Single switchMusic(long roomUid); - - /** - * 点歌 - * - * @param musicId 歌曲id - * @param uid 歌曲对应的用户uid - * @param roomUid 房主uid - * @return - */ - Single chooseMusic(int musicId, long uid, long roomUid); - - /** - * 歌曲报错 - * - * @param musicId 歌曲id - * @param errorUid 报错人uid - * @param errorMsg 错误信息 - * @return - */ - Single musicError(int musicId, long errorUid, String errorMsg); - -} diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/room/ktv/KtvModel.java b/core/src/main/java/com/yizhuan/xchat_android_core/room/ktv/KtvModel.java deleted file mode 100644 index 5f89bbbee..000000000 --- a/core/src/main/java/com/yizhuan/xchat_android_core/room/ktv/KtvModel.java +++ /dev/null @@ -1,326 +0,0 @@ -package com.yizhuan.xchat_android_core.room.ktv; - -import com.yizhuan.xchat_android_core.base.BaseModel; -import com.yizhuan.xchat_android_core.bean.response.ServiceResult; -import com.yizhuan.xchat_android_core.room.ktv.bean.KtvRoomInfo; -import com.yizhuan.xchat_android_core.room.ktv.bean.MusicInfo; -import com.yizhuan.xchat_android_core.room.ktv.bean.RoomMusicInfo; -import com.yizhuan.xchat_android_core.utils.net.RxHelper; -import com.yizhuan.xchat_android_library.net.rxnet.RxNet; - -import java.util.List; - -import io.reactivex.Single; -import io.reactivex.SingleSource; -import io.reactivex.functions.Function; -import retrofit2.http.Field; -import retrofit2.http.FormUrlEncoded; -import retrofit2.http.GET; -import retrofit2.http.POST; -import retrofit2.http.Query; - - -public class KtvModel extends BaseModel implements IKtvModel { - - private Api api; - - private KtvModel(){ - api = RxNet.create(Api.class); - } - - private static class KtvModelHelper{ - private static IKtvModel instance = new KtvModel(); - } - - public static IKtvModel get(){ - return KtvModelHelper.instance; - } - - @Override - public Single> getRoomMusic(long roomUid) { - return api.getRoomMusic(roomUid) - .compose(RxHelper.handleSchedulers()); - } - - @Override - public Single>> getKtvRooms(int orderType, int page, int pageSize) { - return api.getKtvRooms(orderType, page, pageSize); - } - - @Override - public Single>> searchMusic(String searchKey, int page, int pageSize) { - return api.searchMusic(searchKey, page, pageSize) - .compose(RxHelper.handleSchedulers()); - } - - @Override - public Single>> hotMusic(int page, int pageSize) { - return api.hotMusic(page, pageSize) - .compose(RxHelper.handleSchedulers()); - } - - @Override - public Single deleteUserChooseMusic(int musicId, long uid, long roomUid) { - return api.deleteUserChooseMusic(musicId, uid, roomUid) - .compose(RxHelper.handleSchedulers()) - .flatMap(result -> { - if (result.isSuccess()) { - return Single.just("删除歌曲成功"); - } - return Single.error(new Throwable(result.getMessage())); - }); - } - - @Override - public Single deleteUserAllChooseMusic(long uid, long roomUid) { - return api.deleteUserAllChooseMusic(uid, roomUid) - .compose(RxHelper.handleSchedulers()) - .flatMap(result -> { - if (result.isSuccess()) { - return Single.just("删除全部歌曲成功"); - } - return Single.error(new Throwable(result.getMessage())); - }); - } - - @Override - public Single deleteRoomAllChooseMusic(long roomUid) { - return api.deleteRoomAllChooseMusic(roomUid) - .compose(RxHelper.handleSchedulers()) - .flatMap(result -> { - if (result.isSuccess()) { - return Single.just("删除成功"); - } - return Single.error(new Throwable(result.getMessage())); - }); - } - - @Override - public Single openKtvMode(long roomUid) { - return api.openKtvMode(roomUid) - .compose(RxHelper.handleSchedulers()) - .flatMap(result -> { - if (result.isSuccess()) { - return Single.just(true); - } - return Single.error(new Throwable(RxHelper.getValidMessage(result))); - }); - } - - @Override - public Single closeKtvMode(long roomUid) { - return api.closeKtvMode(roomUid) - .compose(RxHelper.handleSchedulers()) - .flatMap(result -> { - if (result.isSuccess()) { - return Single.just(true); - } - return Single.error(new Throwable(RxHelper.getValidMessage(result))); - }); - } - - @Override - public Single popMusic(int musicId, long uid, long roomUid) { - return api.popMusic(musicId, uid, roomUid) - .compose(RxHelper.handleSchedulers()) - .flatMap(result -> { - if (result.isSuccess()) { - return Single.just("歌曲置顶成功"); - } - return Single.error(new Throwable(result.getMessage())); - }); - } - - @Override - public Single switchMusic(long roomUid) { - return api.switchMusic(roomUid) - .compose(RxHelper.handleSchedulers()) - .flatMap(result -> { - if (result.isSuccess()) { - return Single.just(true); - } - return Single.error(new Throwable(RxHelper.getValidMessage(result))); - }); - } - - @Override - public Single chooseMusic(int musicId, long uid, long roomUid) { - return api.chooseMusic(musicId, uid, roomUid) - .compose(RxHelper.handleSchedulers()) - .flatMap(result -> { - if (result.isSuccess()) { - return Single.just("点歌成功"); - } else { - return Single.error(new Throwable(result.getMessage())); - } - }); - } - - @Override - public Single musicError(int musicId, long errorUid, String errorMsg) { - return api.musicError(musicId, errorUid, errorMsg) - .compose(RxHelper.handleSchedulers()) - .flatMap(result -> { - if (result.isSuccess()) { - return Single.just("提交成功"); - } else { - return Single.error(new Throwable(result.getMessage())); - } - }); - } - - - private interface Api{ - - /** - * 房间已点歌曲列表 - * - * @param roomUid 房主uid - * @return - */ - @GET("ktv/getRoomChooseMusics") - Single> getRoomMusic(@Query("roomUid") long roomUid); - - /** - * 获取ktv房间列表 - * - * @param orderType 排序方式。1:最新, 2:最热 - * @return - */ - @GET("room/listKTVRooms") - Single>> getKtvRooms(@Query("orderType") int orderType, - @Query("page") int page, - @Query("pageSize") int pageSize); - - /** - * 搜索歌曲 - * - * @param searchKey 搜索关键字 - * @return 歌曲列表 - */ - @GET("ktv/searchMusic") - Single>> searchMusic(@Query("searchKey") String searchKey, - @Query("page") int page, - @Query("pageSize") int pageSize); - - /** - * 热门歌曲列表 - * - * @return - */ - @GET("ktv/listHotMusic") - Single>> hotMusic(@Query("page") int page, - @Query("pageSize") int pageSize); - - /** - * 删除用户已点的歌曲(单曲) - * - * @param musicId 歌曲id - * @param uid 被删除歌曲的用户uid - * @param roomUid 房主uid - * @return - */ - @FormUrlEncoded - @POST("ktv/deleteUserChooseMusic") - Single> deleteUserChooseMusic(@Field("musicId") int musicId, - @Field("targetUid") long uid, - @Field("roomUid") long roomUid); - - /** - * 删除用户已点的所有歌曲,如果正在演唱的是他的歌,后台会发送切歌消息 - * - * @param uid - * @param roomUid - * @return - */ - @FormUrlEncoded - @POST("ktv/deleteUserAllChooseMusic") - Single> deleteUserAllChooseMusic(@Field("targetUid") long uid, - @Field("roomUid") long roomUid); - - /** - * 删除房间已点的所有歌曲 - * - * @param roomUid - * @return - */ - @FormUrlEncoded - @POST("ktv/deleteRoomAllChooseMusic") - Single> deleteRoomAllChooseMusic(@Field("roomUid") long roomUid); - - /** - * 开启房间ktv模式 - * - * @param roomUid - * @return - */ - @FormUrlEncoded - @POST("room/openKTVMode") - Single> openKtvMode(@Field("roomUid") long roomUid); - - /** - * 关闭房间ktv模式 - * - * @param roomUid - * @return - */ - @FormUrlEncoded - @POST("room/closeKTVMode") - Single> closeKtvMode(@Field("roomUid") long roomUid); - - - /** - * 置顶歌曲 - * - * @param musicId 歌曲id - * @param uid 置顶歌曲对应的用户uid - * @param roomUid 房主uid - * @return - */ - @FormUrlEncoded - @POST("ktv/popMusic") - Single> popMusic(@Field("musicId") int musicId, - @Field("targetUid") long uid, - @Field("roomUid") long roomUid); - - /** - * 切歌 - * - * @param roomUid - * @return - */ - @FormUrlEncoded - @POST("ktv/switchMusic") - Single> switchMusic(@Field("roomUid") long roomUid); - - /** - * 点歌 - * - * @param musicId 歌曲id - * @param uid 歌曲对应的用户uid - * @param roomUid 房主uid - * @return - */ - @FormUrlEncoded - @POST("ktv/chooseMusic") - Single> chooseMusic(@Field("musicId") int musicId, - @Field("uid") long uid, - @Field("roomUid") long roomUid); - - /** - * 歌曲报错 - * - * @param musicId 歌曲id - * @param errorUid 报错人uid - * @param errorMsg 错误信息 - * @return - */ - @FormUrlEncoded - @POST("ktv/musicError") - Single> musicError(@Field("musicId") int musicId, - @Field("errorUid") long errorUid, - @Field("errorMsg") String errorMsg); - - } - -} diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/room/ktv/bean/KtvRoomInfo.java b/core/src/main/java/com/yizhuan/xchat_android_core/room/ktv/bean/KtvRoomInfo.java deleted file mode 100644 index cd2ca6d2e..000000000 --- a/core/src/main/java/com/yizhuan/xchat_android_core/room/ktv/bean/KtvRoomInfo.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.yizhuan.xchat_android_core.room.ktv.bean; - -public class KtvRoomInfo { - - /** - * roomUid : 90006982 - * roomId : 26811582 - * title : 第一个ktv房.... - * onlineNum : 5 - * singingMusicName : 就现在 - */ - - private int roomUid; - private int roomId; - private String title; - private int onlineNum; - private String singingMusicName; - private String avatar; - - public int getRoomUid() { - return roomUid; - } - - public void setRoomUid(int roomUid) { - this.roomUid = roomUid; - } - - public int getRoomId() { - return roomId; - } - - public void setRoomId(int roomId) { - this.roomId = roomId; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public int getOnlineNum() { - return onlineNum; - } - - public void setOnlineNum(int onlineNum) { - this.onlineNum = onlineNum; - } - - public String getSingingMusicName() { - return singingMusicName; - } - - public void setSingingMusicName(String singingMusicName) { - this.singingMusicName = singingMusicName; - } - - public String getAvatar() { - return avatar; - } - - public void setAvatar(String avatar) { - this.avatar = avatar; - } -} diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/room/ktv/bean/MusicInfo.java b/core/src/main/java/com/yizhuan/xchat_android_core/room/ktv/bean/MusicInfo.java deleted file mode 100644 index dc7a2ac4a..000000000 --- a/core/src/main/java/com/yizhuan/xchat_android_core/room/ktv/bean/MusicInfo.java +++ /dev/null @@ -1,165 +0,0 @@ -package com.yizhuan.xchat_android_core.room.ktv.bean; - -public class MusicInfo { - - /** - * musicId : 3 - * musicName : 幻想家 - * singer : 叶炫清 - * musicUrl : https://img.letusmix.com/%E5%8F%B6%E7%82%AB%E6%B8%85-%E5%B9%BB%E6%83%B3%E5%AE%B6-%E5%9B%BD%E8%AF%AD-1066843.mpg - * cover : https://img.letusmix.com/6ab60eec2eb24e87b19bd64d8be56ede_cover.jpg - * duration : 266 - * durationFormat : 00:04:26 - * uploader : 十二月的猴子 - */ - - private int musicId; - private String musicName; - private String singer; - private String musicUrl; - private String cover; - private long uid; - private String userNick; - private int duration; - private String durationFormat; - private String uploader; - private String avatar; - private long operationUid; - private String operationNick; - - public int getMusicId() { - return musicId; - } - - public void setMusicId(int musicId) { - this.musicId = musicId; - } - - public String getMusicName() { - return musicName; - } - - public void setMusicName(String musicName) { - this.musicName = musicName; - } - - public String getSinger() { - return singer; - } - - public void setSinger(String singer) { - this.singer = singer; - } - - public String getMusicUrl() { - return musicUrl; - } - - public void setMusicUrl(String musicUrl) { - this.musicUrl = musicUrl; - } - - public String getCover() { - return cover; - } - - public void setCover(String cover) { - this.cover = cover; - } - - public int getDuration() { - return duration; - } - - public void setDuration(int duration) { - this.duration = duration; - } - - public String getDurationFormat() { - return durationFormat; - } - - public void setDurationFormat(String durationFormat) { - this.durationFormat = durationFormat; - } - - public String getUploader() { - return uploader; - } - - public void setUploader(String uploader) { - this.uploader = uploader; - } - - public long getUid() { - return uid; - } - - public void setUid(long uid) { - this.uid = uid; - } - - public String getUserNick() { - return userNick; - } - - public void setUserNick(String userNick) { - this.userNick = userNick; - } - - public String getAvatar() { - return avatar; - } - - public void setAvatar(String avatar) { - this.avatar = avatar; - } - - public long getOperationUid() { - return operationUid; - } - - public void setOperationUid(long operationUid) { - this.operationUid = operationUid; - } - - public String getOperationNick() { - return operationNick; - } - - public void setOperationNick(String operationNick) { - this.operationNick = operationNick; - } - - @Override - public String toString() { - return "MusicInfo{" + - "musicId=" + musicId + - ", musicName='" + musicName + '\'' + - ", singer='" + singer + '\'' + - ", musicUrl='" + musicUrl + '\'' + - ", cover='" + cover + '\'' + - ", uid=" + uid + - ", userNick='" + userNick + '\'' + - ", duration=" + duration + - ", durationFormat='" + durationFormat + '\'' + - ", uploader='" + uploader + '\'' + - ", avatar='" + avatar + '\'' + - ", operationUid=" + operationUid + - ", operationNick='" + operationNick + '\'' + - '}'; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - MusicInfo musicInfo = (MusicInfo) o; - return musicId == musicInfo.musicId; - } - - @Override - public int hashCode() { - return musicId; - } -} diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/room/ktv/bean/RoomMusicInfo.java b/core/src/main/java/com/yizhuan/xchat_android_core/room/ktv/bean/RoomMusicInfo.java deleted file mode 100644 index c8e52081f..000000000 --- a/core/src/main/java/com/yizhuan/xchat_android_core/room/ktv/bean/RoomMusicInfo.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.yizhuan.xchat_android_core.room.ktv.bean; - -import java.util.List; - -public class RoomMusicInfo { - private MusicInfo singingMusicVo; - private List userChooseMusicVos; - - public MusicInfo getSingingMusicVo() { - return singingMusicVo; - } - - public void setSingingMusicVo(MusicInfo singingMusicVo) { - this.singingMusicVo = singingMusicVo; - } - - public List getUserChooseMusicVos() { - return userChooseMusicVos; - } - - public void setUserChooseMusicVos(List userChooseMusicVos) { - this.userChooseMusicVos = userChooseMusicVos; - } - - @Override - public String toString() { - return "RoomMusicInfo{" + - "singingMusicVo=" + singingMusicVo + - ", userChooseMusicVos=" + userChooseMusicVos + - '}'; - } -} diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/room/ktv/event/KtvEvent.java b/core/src/main/java/com/yizhuan/xchat_android_core/room/ktv/event/KtvEvent.java deleted file mode 100644 index 4d596c86a..000000000 --- a/core/src/main/java/com/yizhuan/xchat_android_core/room/ktv/event/KtvEvent.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.yizhuan.xchat_android_core.room.ktv.event; - -import androidx.annotation.Nullable; -import com.yizhuan.xchat_android_core.room.ktv.bean.MusicInfo; - -public class KtvEvent { - - public static final int CLOSE_KTV_MODEL = 1; - public static final int SWITCH_MUSIC = 2; - public static final int POP_MUSIC = 3; - public static final int ADD_MUSIC = 4; - public static final int DELETE_USER_CHOOSE_MUSIC = 5; - public static final int DELETE_USER_ALL_MUSIC = 6; - public static final int NO_MUSIC = 7; - public static final int STOP = 8; - public static final int CONTINUE = 9; - public static final int ADD_MUSIC_BY_USER = 10;//点歌后结束对应界面的通知 - public static final int MUSIC_UPDATE = 11; - public static final int MUSIC_COMPLETE = 12; - //add by lvzebiao 自己的管理员状态发生变化时,需要更新相关的ui, - public static final int ROOM_USER_MANAGER_STATUS = 13; - private int type; - - @Nullable - private MusicInfo musicInfo; - - public static KtvEvent newInstance(int type,MusicInfo musicInfo) { - return new KtvEvent(type).setMusicInfo(musicInfo); - } - - public KtvEvent(int type) { - this.type = type; - } - - public int getType() { - return type; - } - - public void setType(int type) { - this.type = type; - } - - @Nullable - public MusicInfo getMusicInfo() { - return musicInfo; - } - - public KtvEvent setMusicInfo(MusicInfo musicInfo) { - this.musicInfo = musicInfo; - return this; - } - - @Override - public String toString() { - return "KtvEvent{" + - "type=" + type + - ", musicInfo=" + musicInfo + - '}'; - } -} diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/room/ktv/event/MusicCountEvent.java b/core/src/main/java/com/yizhuan/xchat_android_core/room/ktv/event/MusicCountEvent.java deleted file mode 100644 index 28257c1dd..000000000 --- a/core/src/main/java/com/yizhuan/xchat_android_core/room/ktv/event/MusicCountEvent.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.yizhuan.xchat_android_core.room.ktv.event; - -public class MusicCountEvent { - private int count; - - public MusicCountEvent(int count) { - this.count = count; - } - - public int getCount() { - return count; - } - - public void setCount(int count) { - this.count = count; - } -} diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/room/ktv/event/RemoteVideoEvent.java b/core/src/main/java/com/yizhuan/xchat_android_core/room/ktv/event/RemoteVideoEvent.java deleted file mode 100644 index 009b7896d..000000000 --- a/core/src/main/java/com/yizhuan/xchat_android_core/room/ktv/event/RemoteVideoEvent.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.yizhuan.xchat_android_core.room.ktv.event; - -public class RemoteVideoEvent { - - private int uid; - - public RemoteVideoEvent(int uid) { - this.uid = uid; - } - - public int getUid() { - return uid; - } - - public void setUid(int uid) { - this.uid = uid; - } -} diff --git a/settings.gradle b/settings.gradle index b846ff878..e3e1ab2ef 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,5 +1,4 @@ include ':app' -include ':agora-ktv-kit-release' include ':android_crop_lib' include ':trtc_release' include ':core'