本文整理汇总了Java中com.netease.nim.uikit.common.ui.listview.ListViewUtil类的典型用法代码示例。如果您正苦于以下问题:Java ListViewUtil类的具体用法?Java ListViewUtil怎么用?Java ListViewUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ListViewUtil类属于com.netease.nim.uikit.common.ui.listview包,在下文中一共展示了ListViewUtil类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: jumpToIndex
import com.netease.nim.uikit.common.ui.listview.ListViewUtil; //导入依赖的package包/类
/**
* 跳转到选中的公告
*
* @param list 群公告列表
*/
private void jumpToIndex(List<Announcement> list) {
if (TextUtils.isEmpty(announceId)) {
return;
}
int jumpIndex = -1;
for (int i = 0; i < list.size(); i++) {
if (list.get(i).getId().equals(announceId)) {
jumpIndex = i;
break;
}
}
if (jumpIndex >= 0) {
final int position = jumpIndex;
uiHandler.postDelayed(new Runnable() {
@Override
public void run() {
ListViewUtil.scrollToPosition(announceListView, position, 0);
}
}, 200);
}
}
示例2: refreshViewHolderByIndex
import com.netease.nim.uikit.common.ui.listview.ListViewUtil; //导入依赖的package包/类
/**
* 刷新单条消息
*
* @param index
*/
private void refreshViewHolderByIndex(final int index) {
container.activity.runOnUiThread(new Runnable() {
@Override
public void run() {
if (index < 0) {
return;
}
Object tag = ListViewUtil.getViewHolderByIndex(messageListView, index);
if (tag instanceof MsgViewHolderBase) {
MsgViewHolderBase viewHolder = (MsgViewHolderBase) tag;
viewHolder.refreshCurrentItem();
}
}
});
}
示例3: refreshViewHolder
import com.netease.nim.uikit.common.ui.listview.ListViewUtil; //导入依赖的package包/类
private void refreshViewHolder(final SystemMessage message) {
final long messageId = message.getMessageId();
int index = -1;
for (int i = 0; i < items.size(); i++) {
SystemMessage item = items.get(i);
if (messageId == item.getMessageId()) {
index = i;
break;
}
}
if (index < 0) {
return;
}
final int m = index;
runOnUiThread(new Runnable() {
@Override
public void run() {
if (m < 0) {
return;
}
Object tag = ListViewUtil.getViewHolderByIndex(listView, m);
if (tag instanceof SystemMessageViewHolder) {
((SystemMessageViewHolder) tag).refreshDirectly(message);
}
}
});
}
示例4: scrollToBottom
import com.netease.nim.uikit.common.ui.listview.ListViewUtil; //导入依赖的package包/类
public void scrollToBottom() {
uiHandler.postDelayed(new Runnable() {
@Override
public void run() {
ListViewUtil.scrollToBottom(messageListView);
}
}, 200);
}
示例5: scrollToItem
import com.netease.nim.uikit.common.ui.listview.ListViewUtil; //导入依赖的package包/类
public void scrollToItem(final int position) {
uiHandler.postDelayed(new Runnable() {
@Override
public void run() {
ListViewUtil.scrollToPosition(messageListView, position, 0);
}
}, 200);
}
示例6: onIncomingMessage
import com.netease.nim.uikit.common.ui.listview.ListViewUtil; //导入依赖的package包/类
public void onIncomingMessage(List<IMMessage> messages) {
boolean needScrollToBottom = ListViewUtil.isLastMessageVisible(messageListView);
boolean needRefresh = false;
List<IMMessage> addedListItems = new ArrayList<>(messages.size());
for (IMMessage message : messages) {
if (isMyMessage(message)) {
items.add(message);
addedListItems.add(message);
needRefresh = true;
}
}
if (needRefresh) {
adapter.notifyDataSetChanged();
}
adapter.updateShowTimeItem(addedListItems, false, true);
// incoming messages tip
IMMessage lastMsg = messages.get(messages.size() - 1);
if (isMyMessage(lastMsg)) {
if (needScrollToBottom) {
ListViewUtil.scrollToBottom(messageListView);
} else if (incomingMsgPrompt != null && lastMsg.getSessionType() != SessionTypeEnum.ChatRoom) {
incomingMsgPrompt.show(lastMsg);
}
}
}
示例7: onMsgSend
import com.netease.nim.uikit.common.ui.listview.ListViewUtil; //导入依赖的package包/类
public void onMsgSend(IMMessage message) {
// add to listView and refresh
items.add(message);
List<IMMessage> addedListItems = new ArrayList<>(1);
addedListItems.add(message);
adapter.updateShowTimeItem(addedListItems, false, true);
adapter.notifyDataSetChanged();
ListViewUtil.scrollToBottom(messageListView);
}
示例8: init
import com.netease.nim.uikit.common.ui.listview.ListViewUtil; //导入依赖的package包/类
private void init() {
ViewGroup containerView = (ViewGroup) view.findViewById(R.id.message_activity_list_view_container);
View.inflate(context, R.layout.nim_new_message_tip_layout, containerView);
newMessageTipLayout = containerView.findViewById(R.id.new_message_tip_layout);
newMessageTipLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ListViewUtil.scrollToBottom(messageListView);
newMessageTipLayout.setVisibility(View.GONE);
}
});
newMessageTipTextView = (TextView) newMessageTipLayout.findViewById(R.id.new_message_tip_text_view);
newMessageTipHeadImageView = (HeadImageView) newMessageTipLayout.findViewById(R.id.new_message_tip_head_image_view);
}
示例9: refreshViewHolderByIndex
import com.netease.nim.uikit.common.ui.listview.ListViewUtil; //导入依赖的package包/类
protected void refreshViewHolderByIndex(final int index) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
Object tag = ListViewUtil.getViewHolderByIndex(listView, index);
if (tag instanceof RecentViewHolder) {
RecentViewHolder viewHolder = (RecentViewHolder) tag;
viewHolder.refreshCurrentItem();
}
}
});
}
示例10: loadMessages
import com.netease.nim.uikit.common.ui.listview.ListViewUtil; //导入依赖的package包/类
/**
* 加载历史消息
*/
public void loadMessages() {
listView.onRefreshStart(AutoRefreshListView.Mode.END);
boolean loadCompleted; // 是否已经加载完成,后续没有数据了or已经满足本次请求数量
int validMessageCount = 0; // 实际加载的数量(排除被过滤被合并的条目)
List<String> messageFromAccounts = new ArrayList<>(LOAD_MESSAGE_COUNT);
while (true) {
List<SystemMessage> temps = NIMClient.getService(SystemMessageService.class)
.querySystemMessagesBlock(loadOffset, LOAD_MESSAGE_COUNT);
loadOffset += temps.size();
loadCompleted = temps.size() < LOAD_MESSAGE_COUNT;
int tempValidCount = 0;
for (SystemMessage m : temps) {
// 去重
if (duplicateFilter(m)) {
continue;
}
// 同一个账号的好友申请仅保留最近一条
if (addFriendVerifyFilter(m)) {
continue;
}
// 保存有效消息
items.add(m);
tempValidCount++;
if (!messageFromAccounts.contains(m.getFromAccount())) {
messageFromAccounts.add(m.getFromAccount());
}
// 判断是否达到请求数
if (++validMessageCount >= LOAD_MESSAGE_COUNT) {
loadCompleted = true;
// 已经满足要求,此时需要修正loadOffset
loadOffset -= temps.size();
loadOffset += tempValidCount;
break;
}
}
if (loadCompleted) {
break;
}
}
// 更新数据源,刷新界面
refresh();
boolean first = firstLoad;
firstLoad = false;
if (first) {
ListViewUtil.scrollToPosition(listView, 0, 0); // 第一次加载后显示顶部
}
listView.onRefreshComplete(validMessageCount, LOAD_MESSAGE_COUNT, true);
// 收集未知用户资料的账号集合并从远程获取
collectAndRequestUnknownUserInfo(messageFromAccounts);
}