[Modify]修復公會消息bug

This commit is contained in:
wushaocheng
2023-02-27 23:55:21 +08:00
parent ca914d7163
commit 39916f2c20

View File

@@ -1,5 +1,7 @@
package com.yizhuan.erban.ui.im;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
@@ -10,7 +12,9 @@ import android.os.Handler;
import android.text.TextUtils;
import android.util.Pair;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
@@ -120,6 +124,8 @@ public class MessageListPanelEx {
// 待转发消息
private IMMessage forwardMessage;
private CountDownTimer countDownTimer;
private boolean isShowAnim = false;
private OnItemClickListener listener = new OnItemClickListener() {
@Override
public void onItemClick(IRecyclerView adapter, View view, int position) {
@@ -855,10 +861,10 @@ public class MessageListPanelEx {
}
}
private int getLoadMsgCount(){
if(TextUtils.isEmpty(recordId)){
private int getLoadMsgCount() {
if (TextUtils.isEmpty(recordId)) {
return NimUIKitImpl.getOptions().messageCountLoadOnce;
}else {
} else {
return 50;
}
}
@@ -940,7 +946,7 @@ public class MessageListPanelEx {
if (firstLoad) {
doScrollToBottom();
sendReceipt(); // 发送已读回执
if (!TextUtils.isEmpty(recordId)) {
if (!TextUtils.isEmpty(recordId) && !isShowAnim) {
doScrollToPosition();
}
}
@@ -956,6 +962,28 @@ public class MessageListPanelEx {
int index = getApplyItemIndex(recordId);
if (index >= 0 && index < items.size()) {
messageListView.scrollToPosition(index);
messageListView.getViewTreeObserver().addOnGlobalLayoutListener(() -> {
// 默认选中第一个
RecyclerView.LayoutManager layoutManager = messageListView.getLayoutManager();
if (layoutManager != null) {
View view = layoutManager.findViewByPosition(index);
RelativeLayout relativeLayout = (RelativeLayout) view; //获取布局中任意控件对象
FrameLayout frameLayout = null;
if (relativeLayout != null) {
frameLayout = relativeLayout.findViewById(R.id.message_item_content);
}
if (frameLayout != null) {
//透明度起始为1结束时为0
ObjectAnimator animator = ObjectAnimator.ofFloat(frameLayout, "alpha", 0f, 1f);
animator.setDuration(1500);//时间1s
animator.setRepeatCount(1);
animator.setRepeatMode(ValueAnimator.RESTART);
animator.start();
isShowAnim = true;
}
}
});
}
}
}, 500);