声音秀展示位置修改
This commit is contained in:
@@ -25,6 +25,8 @@ import com.netease.nimlib.sdk.RequestCallbackWrapper;
|
|||||||
import com.netease.nimlib.sdk.uinfo.model.NimUserInfo;
|
import com.netease.nimlib.sdk.uinfo.model.NimUserInfo;
|
||||||
import com.yizhuan.erban.R;
|
import com.yizhuan.erban.R;
|
||||||
import com.yizhuan.erban.UIHelper;
|
import com.yizhuan.erban.UIHelper;
|
||||||
|
import com.yizhuan.erban.audio.helper.AudioPlayerHelper;
|
||||||
|
import com.yizhuan.erban.audio.helper.OnPlayListener;
|
||||||
import com.yizhuan.erban.avroom.ButtonItemFactory;
|
import com.yizhuan.erban.avroom.ButtonItemFactory;
|
||||||
import com.yizhuan.erban.avroom.activity.AVRoomActivity;
|
import com.yizhuan.erban.avroom.activity.AVRoomActivity;
|
||||||
import com.yizhuan.erban.base.BaseBindingActivity;
|
import com.yizhuan.erban.base.BaseBindingActivity;
|
||||||
@@ -68,6 +70,7 @@ import com.yizhuan.xchat_android_core.user.UserInfoUiMgr;
|
|||||||
import com.yizhuan.xchat_android_core.user.UserModel;
|
import com.yizhuan.xchat_android_core.user.UserModel;
|
||||||
import com.yizhuan.xchat_android_core.user.bean.UserDetailInfo;
|
import com.yizhuan.xchat_android_core.user.bean.UserDetailInfo;
|
||||||
import com.yizhuan.xchat_android_core.user.bean.UserInfo;
|
import com.yizhuan.xchat_android_core.user.bean.UserInfo;
|
||||||
|
import com.yizhuan.xchat_android_core.user.bean.UserInfoSkillEntity;
|
||||||
import com.yizhuan.xchat_android_core.user.bean.UserPhoto;
|
import com.yizhuan.xchat_android_core.user.bean.UserPhoto;
|
||||||
import com.yizhuan.xchat_android_core.user.event.LoginUserInfoUpdateEvent;
|
import com.yizhuan.xchat_android_core.user.event.LoginUserInfoUpdateEvent;
|
||||||
import com.yizhuan.xchat_android_core.utils.LogUtils;
|
import com.yizhuan.xchat_android_core.utils.LogUtils;
|
||||||
@@ -75,6 +78,7 @@ import com.yizhuan.xchat_android_core.utils.StarUtils;
|
|||||||
import com.yizhuan.xchat_android_core.utils.net.BeanObserver;
|
import com.yizhuan.xchat_android_core.utils.net.BeanObserver;
|
||||||
import com.yizhuan.xchat_android_library.annatation.ActLayoutRes;
|
import com.yizhuan.xchat_android_library.annatation.ActLayoutRes;
|
||||||
import com.yizhuan.xchat_android_library.utils.ListUtils;
|
import com.yizhuan.xchat_android_library.utils.ListUtils;
|
||||||
|
import com.yizhuan.xchat_android_library.utils.SingleToastUtil;
|
||||||
import com.yizhuan.xchat_android_library.utils.SizeUtils;
|
import com.yizhuan.xchat_android_library.utils.SizeUtils;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
@@ -112,6 +116,8 @@ public class UserInfoActivity extends BaseBindingActivity<ActivityUserInfoBindin
|
|||||||
private UserInfoViewModel viewModel;
|
private UserInfoViewModel viewModel;
|
||||||
private UserInfoPagerAdapter pagerAdapter;
|
private UserInfoPagerAdapter pagerAdapter;
|
||||||
|
|
||||||
|
private boolean audioPlaying = false;
|
||||||
|
|
||||||
@SuppressLint("CheckResult")
|
@SuppressLint("CheckResult")
|
||||||
@Override
|
@Override
|
||||||
protected void init() {
|
protected void init() {
|
||||||
@@ -569,6 +575,7 @@ public class UserInfoActivity extends BaseBindingActivity<ActivityUserInfoBindin
|
|||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
EventBus.getDefault().unregister(this);
|
EventBus.getDefault().unregister(this);
|
||||||
|
stopAudio();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -592,6 +599,71 @@ public class UserInfoActivity extends BaseBindingActivity<ActivityUserInfoBindin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void initVoiceShow(UserInfoSkillEntity skillEntity) {
|
||||||
|
if (skillEntity != null) {
|
||||||
|
mBinding.llAudio.setVisibility(View.VISIBLE);
|
||||||
|
mBinding.livUser.stop();
|
||||||
|
mBinding.llAudio.setOnClickListener(v -> toggleAudio(skillEntity.getPropVals()));
|
||||||
|
} else {
|
||||||
|
mBinding.llAudio.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void toggleAudio(List<String> list) {
|
||||||
|
if (ListUtils.isListEmpty(list)) return;
|
||||||
|
String url = "";
|
||||||
|
for (String s : list) {
|
||||||
|
if (s.contains("http")) {
|
||||||
|
url = s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (TextUtils.isEmpty(url)) return;
|
||||||
|
if (!audioPlaying) {
|
||||||
|
playAudio(url);
|
||||||
|
} else {
|
||||||
|
stopAudio();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void playAudio(String url) {
|
||||||
|
if (audioPlaying) return;
|
||||||
|
audioPlaying = true;
|
||||||
|
mBinding.livUser.start();
|
||||||
|
mBinding.ivAudioControl.setImageResource(R.drawable.ic_skill_play);
|
||||||
|
AudioPlayerHelper.get().playInThread(url, new OnPlayListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(String error) {
|
||||||
|
SingleToastUtil.showToast("播放出错,请重试");
|
||||||
|
stopAudio();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPrepared() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlaying(long currDuration) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCompletion() {
|
||||||
|
stopAudio();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void stopAudio() {
|
||||||
|
if (!audioPlaying) return;
|
||||||
|
audioPlaying = false;
|
||||||
|
mBinding.livUser.stop();
|
||||||
|
mBinding.ivAudioControl.setImageResource(R.drawable.ic_skill_pause);
|
||||||
|
AudioPlayerHelper.get().endPlay();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean needSteepStateBar() {
|
protected boolean needSteepStateBar() {
|
||||||
return true;
|
return true;
|
||||||
|
@@ -26,6 +26,7 @@ import com.yizhuan.erban.skill.activity.SkillHomeActivity
|
|||||||
import com.yizhuan.erban.skill.activity.SkillHomeActivity.Companion.PAGE_TYPE_CUSTOM
|
import com.yizhuan.erban.skill.activity.SkillHomeActivity.Companion.PAGE_TYPE_CUSTOM
|
||||||
import com.yizhuan.erban.skill.activity.SkillHomeActivity.Companion.PAGE_TYPE_SELF
|
import com.yizhuan.erban.skill.activity.SkillHomeActivity.Companion.PAGE_TYPE_SELF
|
||||||
import com.yizhuan.erban.ui.user.UserGiftActivity
|
import com.yizhuan.erban.ui.user.UserGiftActivity
|
||||||
|
import com.yizhuan.erban.ui.user.UserInfoActivity
|
||||||
import com.yizhuan.erban.ui.user.adapter.GiftAdapter
|
import com.yizhuan.erban.ui.user.adapter.GiftAdapter
|
||||||
import com.yizhuan.erban.ui.user.adapter.SkillCardAdapter
|
import com.yizhuan.erban.ui.user.adapter.SkillCardAdapter
|
||||||
import com.yizhuan.erban.ui.user.decorationsend.UserInfoSkillDecoration
|
import com.yizhuan.erban.ui.user.decorationsend.UserInfoSkillDecoration
|
||||||
@@ -159,16 +160,8 @@ class UserInfoInfoFragment : BaseViewBindingFragment<FragmentUserinfoUserinfoBin
|
|||||||
val audio = list.find { it.cardId == 8 }
|
val audio = list.find { it.cardId == 8 }
|
||||||
var newList: MutableList<UserInfoSkillEntity> = list.toMutableList()
|
var newList: MutableList<UserInfoSkillEntity> = list.toMutableList()
|
||||||
if (audio != null) {
|
if (audio != null) {
|
||||||
binding.llAudio.visibility = View.VISIBLE
|
(activity as? UserInfoActivity)?.initVoiceShow(audio)
|
||||||
binding.livUser.stop()
|
|
||||||
binding.llAudio.setOnClickListener { toggleAudio(audio.propVals) }
|
|
||||||
newList.remove(audio)
|
newList.remove(audio)
|
||||||
if (newList.isEmpty()) {//只有声音秀
|
|
||||||
binding.recyclerSkill.visibility = View.GONE
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
binding.llAudio.visibility = View.GONE
|
|
||||||
}
|
}
|
||||||
if (skillAdapter == null) {
|
if (skillAdapter == null) {
|
||||||
skillAdapter = SkillCardAdapter(mContext)
|
skillAdapter = SkillCardAdapter(mContext)
|
||||||
@@ -245,48 +238,5 @@ class UserInfoInfoFragment : BaseViewBindingFragment<FragmentUserinfoUserinfoBin
|
|||||||
binding.tvGiftDetail.setOnClickListener(this)
|
binding.tvGiftDetail.setOnClickListener(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun toggleAudio(list: List<String>) {
|
|
||||||
val url = list.find { it.contains("http") } ?: return
|
|
||||||
if (!audioPlaying) {
|
|
||||||
playAudio(url)
|
|
||||||
} else {
|
|
||||||
stopAudio()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDestroyView() {
|
|
||||||
stopAudio()
|
|
||||||
super.onDestroyView()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun playAudio(url: String) {
|
|
||||||
if (audioPlaying) return
|
|
||||||
audioPlaying = true
|
|
||||||
binding.livUser.start()
|
|
||||||
binding.ivAudioControl.setImageResource(R.drawable.ic_skill_play)
|
|
||||||
AudioPlayerHelper.get().playInThread(url, object : OnPlayListener {
|
|
||||||
override fun onError(error: String?) {
|
|
||||||
"播放出错,请重试".toast()
|
|
||||||
stopAudio()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onPrepared() {}
|
|
||||||
|
|
||||||
override fun onPlaying(currDuration: Long) {}
|
|
||||||
|
|
||||||
override fun onCompletion() {
|
|
||||||
stopAudio()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun stopAudio() {
|
|
||||||
if (!audioPlaying) return
|
|
||||||
audioPlaying = false
|
|
||||||
if (!isDestroyView) {
|
|
||||||
binding.livUser.stop()
|
|
||||||
binding.ivAudioControl.setImageResource(R.drawable.ic_skill_pause)
|
|
||||||
}
|
|
||||||
AudioPlayerHelper.get().endPlay()
|
|
||||||
}
|
|
||||||
}
|
}
|
@@ -2,15 +2,15 @@
|
|||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:shape="rectangle">
|
android:shape="rectangle">
|
||||||
|
|
||||||
<corners
|
|
||||||
android:bottomLeftRadius="@dimen/dp_4"
|
|
||||||
android:bottomRightRadius="@dimen/dp_19"
|
|
||||||
android:topLeftRadius="@dimen/dp_19"
|
|
||||||
android:topRightRadius="@dimen/dp_4" />
|
|
||||||
<gradient
|
<gradient
|
||||||
android:endColor="#B3daf8fc"
|
|
||||||
android:startColor="#B3f4f5ef"
|
|
||||||
android:angle="180"
|
android:angle="180"
|
||||||
android:type="linear"/>
|
android:endColor="#ffe7fbfd"
|
||||||
|
android:startColor="#fff8f8f4"
|
||||||
|
android:type="linear"
|
||||||
|
android:useLevel="true" />
|
||||||
|
|
||||||
|
<corners
|
||||||
|
android:bottomLeftRadius="99dp"
|
||||||
|
android:topLeftRadius="99dp" />
|
||||||
|
|
||||||
</shape>
|
</shape>
|
@@ -66,6 +66,36 @@
|
|||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
android:textSize="10dp" />
|
android:textSize="10dp" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/ll_audio"
|
||||||
|
android:layout_width="63dp"
|
||||||
|
android:layout_height="@dimen/dp_25"
|
||||||
|
android:background="@drawable/bg_userinfo_skill_audio"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_gravity="end|center_vertical"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/iv_audio_control"
|
||||||
|
android:layout_width="@dimen/dp_15"
|
||||||
|
android:layout_height="@dimen/dp_15"
|
||||||
|
android:layout_marginLeft="@dimen/dp_8"
|
||||||
|
android:src="@drawable/ic_skill_pause" />
|
||||||
|
|
||||||
|
<com.yizhuan.erban.ui.widget.LivingIconView
|
||||||
|
android:id="@+id/liv_user"
|
||||||
|
android:layout_width="60dp"
|
||||||
|
android:layout_height="20dp"
|
||||||
|
android:layout_marginLeft="@dimen/dp_6"
|
||||||
|
android:background="@color/transparent"
|
||||||
|
android:scaleType="fitXY"
|
||||||
|
app:cus_dp_height="20dp"
|
||||||
|
app:cus_dp_width="60dp"
|
||||||
|
app:cus_drawable="@drawable/skill_audio_animation" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@@ -31,41 +31,13 @@
|
|||||||
android:textSize="@dimen/sp_14"
|
android:textSize="@dimen/sp_14"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/ll_audio"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="@dimen/dp_40"
|
|
||||||
android:layout_marginTop="@dimen/dp_8"
|
|
||||||
android:background="@drawable/bg_userinfo_skill_audio"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:visibility="gone">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/iv_audio_control"
|
|
||||||
android:layout_width="@dimen/dp_18"
|
|
||||||
android:layout_height="@dimen/dp_18"
|
|
||||||
android:layout_marginLeft="@dimen/dp_8"
|
|
||||||
android:src="@drawable/ic_skill_pause" />
|
|
||||||
|
|
||||||
<com.yizhuan.erban.ui.widget.LivingIconView
|
|
||||||
android:id="@+id/liv_user"
|
|
||||||
android:layout_width="90dp"
|
|
||||||
android:layout_height="30dp"
|
|
||||||
android:layout_marginLeft="@dimen/dp_8"
|
|
||||||
android:background="@color/transparent"
|
|
||||||
android:scaleType="fitXY"
|
|
||||||
app:cus_dp_height="30dp"
|
|
||||||
app:cus_dp_width="90dp"
|
|
||||||
app:cus_drawable="@drawable/skill_audio_animation" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/recycler_skill"
|
android:id="@+id/recycler_skill"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="@dimen/dp_8" />
|
android:layout_marginTop="@dimen/dp_8"
|
||||||
|
android:layout_marginBottom="8dp"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
Reference in New Issue
Block a user