From eadcaf826ba236e687256900df7ea0ee322e52fe Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Sat, 7 Jan 2023 16:46:11 +0800 Subject: [PATCH] =?UTF-8?q?xiu=E6=94=B9=E7=9B=B4=E6=92=AD=E9=97=B4?= =?UTF-8?q?=E8=81=8A=E5=A4=A9=E5=88=97=E8=A1=A8=E6=BB=9A=E5=8A=A8=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=8C=E4=BF=AE=E6=94=B9=E7=83=AD=E5=BA=A6=E5=8A=A0?= =?UTF-8?q?=E6=88=90=E5=88=97=E8=A1=A8=E7=AD=89=E7=BA=A7=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yunbao/live/adapter/LiveChatAdapter.java | 10 ++++++---- .../live/dialog/LiveGiveHotDialogFragment.java | 14 +++++++++++++- .../com/yunbao/live/views/LiveRoomViewHolder.java | 6 +++--- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java b/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java index 7cff740ac..cce3d4c7d 100644 --- a/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java @@ -129,7 +129,7 @@ public class LiveChatAdapter extends RecyclerView.Adapter { public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); if (isBottom && dy >= 0) return; - // Log.i(TAG, "onScrolled: " + dy); + Log.i(TAG, "onScrolled: " + dy); mRecyclerViewScrolledDy = dy; isBottom = false; } @@ -140,6 +140,7 @@ public class LiveChatAdapter extends RecyclerView.Adapter { if (newState == 0 && isSlideToBottom(recyclerView)) { // Log.i(TAG, "onScrollStateChanged: 到底部了"); mRecyclerViewScrolledDy = 0; + scrollToBottom(); isBottom = true; } else if (newState == 0) { // Log.i(TAG, "onScrollStateChanged: 不是底部"); @@ -394,7 +395,7 @@ public class LiveChatAdapter extends RecyclerView.Adapter { } @SuppressLint("NotifyDataSetChanged") - public void insertItem(LiveChatBean bean) { + public synchronized void insertItem(LiveChatBean bean) { if (bean == null) { return; } @@ -411,9 +412,9 @@ public class LiveChatAdapter extends RecyclerView.Adapter { } else { notifyItemInserted(getItemCount()); } - size = mList.size(); +// size = mList.size(); if (isBottom || mRecyclerViewScrolledDy == 0) { - scrollToBottom(); + scrollToBottom(); } else { Bus.get().post(new LiveAudienceEvent() .setType(LiveAudienceEvent.LiveAudienceType.NEW_MESSAGE_REMINDER)); @@ -428,6 +429,7 @@ public class LiveChatAdapter extends RecyclerView.Adapter { } + private void scrollToBottom(final RecyclerView recyclerView) { // scroll to last item to get the view of last item final LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager(); diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveGiveHotDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveGiveHotDialogFragment.java index b82f1e3c8..691a1c4d4 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveGiveHotDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveGiveHotDialogFragment.java @@ -3,6 +3,7 @@ package com.yunbao.live.dialog; import android.annotation.SuppressLint; import android.app.ActionBar; import android.content.Context; +import android.graphics.drawable.Drawable; import android.os.Bundle; import androidx.annotation.Nullable; import androidx.recyclerview.widget.LinearLayoutManager; @@ -37,6 +38,7 @@ import com.yunbao.live.activity.LiveActivity; import com.yunbao.live.bean.HotBean; import com.yunbao.live.custom.TopGradual; import com.yunbao.live.http.LiveHttpUtil; +import com.yunbao.live.utils.LiveTextRender; import java.net.MalformedURLException; import java.net.URL; @@ -205,7 +207,17 @@ public class LiveGiveHotDialogFragment extends AbsDialogFragment { viewHolder.sex.setImageResource(CommonIconUtil.getSexIcon(mDatas.get(position).getSex())); LevelBean levelBean = CommonAppConfig.getInstance().getLevel(mDatas.get(position).getLevel()); if (levelBean != null) { - ImgLoader.display(mContext, levelBean.getThumb(), viewHolder.level); + new LiveTextRender().getLevelImage(mContext, levelBean.getLevel(), new ImgLoader.DrawableCallback() { + @Override + public void onLoadSuccess(Drawable drawable) { + ImgLoader.display2(mContext, drawable, viewHolder.level); + } + + @Override + public void onLoadFailed() { + + } + }); } String hotStr = mDatas.get(position).getHot_score().substring(0, mDatas.get(position).getHot_score().length() - 3); viewHolder.tv_hot_number.setText(hotStr + "k"); diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java index 875f055ae..86c03492a 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -877,10 +877,10 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis mChatRecyclerView.setLayoutParams(params1); mChatRecyclerView.setHasFixedSize(true); - LinearLayoutManager layoutManager = new LiveChatRecyclerViewLayoutManager(mContext); + LinearLayoutManager layoutManager = new LinearLayoutManager(mContext); layoutManager.setOrientation(RecyclerView.VERTICAL); -// layoutManager.setReverseLayout(false); -// layoutManager.setStackFromEnd(true); +// layoutManager.setReverseLayout(true); + layoutManager.setStackFromEnd(true); mChatRecyclerView.setLayoutManager(layoutManager); mChatRecyclerView.addItemDecoration(new TopGradual()); mChatRecyclerView.setItemViewCacheSize(10);