测试修改
This commit is contained in:
parent
8aefa10ef8
commit
0a6471163c
@ -68,16 +68,13 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
|
||||
mList = new ArrayList<>();
|
||||
mInflater = LayoutInflater.from(context);
|
||||
model = IMLoginManager.get(context).getUserInfo();
|
||||
mOnClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Object tag = v.getTag();
|
||||
if (tag != null) {
|
||||
LiveChatBean bean = (LiveChatBean) tag;
|
||||
if (mOnItemClickListener != null) {
|
||||
if (bean.getType() != LiveChatBean.SYSTEM) {
|
||||
mOnItemClickListener.onItemClick(bean, 0);
|
||||
}
|
||||
mOnClickListener = v -> {
|
||||
Object tag = v.getTag();
|
||||
if (tag != null) {
|
||||
LiveChatBean bean = (LiveChatBean) tag;
|
||||
if (mOnItemClickListener != null) {
|
||||
if (bean.getType() != LiveChatBean.SYSTEM) {
|
||||
mOnItemClickListener.onItemClick(bean, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -195,23 +192,16 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
|
||||
rv_chat_active.setLayoutManager(gridLayoutManager);
|
||||
rv_chat_active.setAdapter(listAdapter);
|
||||
|
||||
tv_chat_active_into.setOnClickListener(new View.OnClickListener() {//点击打开活动
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String url = CommonAppConfig.HOST + "/" + bean.getContent() + "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + LiveRoomViewHolder.mLiveUid;
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", url);
|
||||
LiveHDDialogFragment fragment = new LiveHDDialogFragment();
|
||||
fragment.setArguments(bundle);
|
||||
fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
|
||||
}
|
||||
});
|
||||
v_chat_active_close.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
removetItem(bean);
|
||||
}
|
||||
//点击打开活动
|
||||
tv_chat_active_into.setOnClickListener(v -> {
|
||||
String url = CommonAppConfig.HOST + "/" + bean.getContent() + "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + LiveRoomViewHolder.mLiveUid;
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", url);
|
||||
LiveHDDialogFragment fragment = new LiveHDDialogFragment();
|
||||
fragment.setArguments(bundle);
|
||||
fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
|
||||
});
|
||||
v_chat_active_close.setOnClickListener(v -> removetItem(bean));
|
||||
} else if (bean.getType() == -3 || bean.getType() == -4 || bean.getType() == -5) {//整蛊
|
||||
if (bean.getBubble() != null && !bean.getBubble().equals("")) {
|
||||
//加载.9图聊天气泡
|
||||
@ -359,41 +349,31 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
|
||||
}
|
||||
}
|
||||
|
||||
public void insertItem(LiveChatBean bean) {
|
||||
public synchronized void insertItem(LiveChatBean bean) {
|
||||
|
||||
if (bean == null) {
|
||||
return;
|
||||
}
|
||||
int size = mList.size();
|
||||
if (size > 0) {
|
||||
if (mList.get(size - 1).getType() == -10) {
|
||||
mList.remove(size - 1);
|
||||
size = size - 1;
|
||||
}
|
||||
}
|
||||
//设置最大展示99条消息
|
||||
if (size == 100) {
|
||||
mList.remove(1);
|
||||
mList.remove(0);
|
||||
}
|
||||
mList.add(bean);
|
||||
notifyItemChanged(size);
|
||||
|
||||
LiveChatBean beanNull = new LiveChatBean();
|
||||
beanNull.setType(-10);
|
||||
mList.add(beanNull);
|
||||
notifyItemChanged(size + 1);
|
||||
|
||||
if (isSlideToBottom(mRecyclerView)) {
|
||||
mRecyclerView.scrollToPosition(size + 1);
|
||||
mRecyclerView.scrollToPosition(getItemCount() - 1);
|
||||
} else {
|
||||
Bus.get().post(new LiveAudienceEvent()
|
||||
.setType(LiveAudienceEvent.LiveAudienceType.NEW_MESSAGE_REMINDER));
|
||||
|
||||
if (bean.getAtUserID()!=null&&bean.getAtUserID().contains(String.valueOf(model.getId()))) {
|
||||
if (bean.getAtUserID() != null && bean.getAtUserID().contains(String.valueOf(model.getId()))) {
|
||||
Bus.get().post(new LiveAudienceEvent()
|
||||
.setType(LiveAudienceEvent.LiveAudienceType.AT_MESSAGE));
|
||||
mPosition = size + 1;
|
||||
mPosition = size;
|
||||
}
|
||||
}
|
||||
notifyItemChanged(getItemCount() - 1);
|
||||
|
||||
}
|
||||
|
||||
@ -422,10 +402,11 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
|
||||
|
||||
public void scrollToBottom() {
|
||||
if (mList.size() > 0) {
|
||||
mRecyclerView.smoothScrollToPosition(getItemCount());
|
||||
mRecyclerView.smoothScrollToPosition(getItemCount() - 1);
|
||||
}
|
||||
}
|
||||
public void scrollToAt(){
|
||||
|
||||
public void scrollToAt() {
|
||||
if (mList.size() > 0) {
|
||||
mRecyclerView.smoothScrollToPosition(mPosition);
|
||||
}
|
||||
|
@ -813,7 +813,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
|
||||
mChatRecyclerView.setLayoutParams(params1);
|
||||
|
||||
mChatRecyclerView.setHasFixedSize(true);
|
||||
mChatRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
|
||||
mChatRecyclerView.setLayoutManager(new LinearLayoutManager(mContext));
|
||||
mChatRecyclerView.addItemDecoration(new TopGradual());
|
||||
mLiveChatAdapter = new LiveChatAdapter(mContext);
|
||||
mLiveChatAdapter.setOnItemClickListener(new OnItemClickListener<LiveChatBean>() {
|
||||
|
@ -6,22 +6,32 @@ import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.opensource.svgaplayer.SVGADrawable;
|
||||
import com.opensource.svgaplayer.SVGAImageView;
|
||||
import com.opensource.svgaplayer.SVGAParser;
|
||||
import com.opensource.svgaplayer.SVGAVideoEntity;
|
||||
import com.yunbao.common.bean.OlineUserlistModel;
|
||||
import com.yunbao.common.event.OlineEvent;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.SVGAViewUtils;
|
||||
import com.yunbao.common.views.weight.ClipPathCircleImage;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
import com.yunbao.live.R;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
public class OlineListItemViewHolder extends RecyclerView.ViewHolder {
|
||||
private TextView userName;
|
||||
private ClipPathCircleImage avatar;
|
||||
private SVGAImageView avatarSvaga;
|
||||
|
||||
public OlineListItemViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
userName = itemView.findViewById(R.id.user_name);
|
||||
avatar = itemView.findViewById(R.id.avatar);
|
||||
avatarSvaga = itemView.findViewById(R.id.avatar_svaga);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -30,6 +40,22 @@ public class OlineListItemViewHolder extends RecyclerView.ViewHolder {
|
||||
* @param model 数据
|
||||
*/
|
||||
public void setData(OlineUserlistModel model) {
|
||||
try {
|
||||
new SVGAParser(itemView.getContext()).parse(new URL(model.getDress().getAvatarFrame()), new SVGAParser.ParseCompletion() {
|
||||
@Override
|
||||
public void onComplete(SVGAVideoEntity videoItem) {
|
||||
SVGADrawable drawable = new SVGADrawable(videoItem);
|
||||
avatarSvaga.setImageDrawable(drawable);
|
||||
SVGAViewUtils.playEndClear(avatarSvaga,false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
}
|
||||
});
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ImgLoader.displayAvatar(itemView.getContext(), model.getAvatar(), avatar);
|
||||
userName.setText(model.getUserNicename());
|
||||
ViewClicksAntiShake.clicksAntiShake(itemView, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
|
@ -9,12 +9,24 @@
|
||||
android:layout_marginBottom="18dp"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<com.yunbao.common.views.weight.ClipPathCircleImage
|
||||
android:id="@+id/avatar"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:scaleType="centerCrop" />
|
||||
<FrameLayout
|
||||
android:layout_width="52dp"
|
||||
android:layout_height="52dp"
|
||||
android:layout_marginStart="20dp">
|
||||
|
||||
<com.yunbao.common.views.weight.ClipPathCircleImage
|
||||
android:id="@+id/avatar"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_gravity="center"
|
||||
android:scaleType="centerCrop" />
|
||||
|
||||
<com.opensource.svgaplayer.SVGAImageView
|
||||
android:id="@+id/avatar_svaga"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</FrameLayout>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/user_name"
|
||||
|
Loading…
Reference in New Issue
Block a user