use of chat.rocket.android.layouthelper.chatroom.AbstractNewMessageIndicatorManager in project Rocket.Chat.Android by RocketChat.
the class RoomFragment method onSetupView.
@Override
protected void onSetupView() {
RecyclerView listView = (RecyclerView) rootView.findViewById(R.id.recyclerview);
adapter = new MessageListAdapter(getContext());
listView.setAdapter(adapter);
adapter.setOnItemClickListener(this);
adapter.setOnItemLongClickListener(this);
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, true);
listView.setLayoutManager(layoutManager);
autoScrollManager = new RecyclerViewAutoScrollManager(layoutManager) {
@Override
protected void onAutoScrollMissed() {
if (newMessageIndicatorManager != null) {
presenter.onUnreadCount();
}
}
};
adapter.registerAdapterDataObserver(autoScrollManager);
scrollListener = new LoadMoreScrollListener(layoutManager, 40) {
@Override
public void requestMoreItem() {
presenter.loadMoreMessages();
}
};
listView.addOnScrollListener(scrollListener);
listView.addOnScrollListener(new RecyclerViewScrolledToBottomListener(layoutManager, 1, this::markAsReadIfNeeded));
newMessageIndicatorManager = new AbstractNewMessageIndicatorManager() {
@Override
protected void onShowIndicator(int count, boolean onlyAlreadyShown) {
if ((onlyAlreadyShown && unreadIndicator != null && unreadIndicator.isShown()) || !onlyAlreadyShown) {
unreadIndicator = getUnreadCountIndicatorView(count);
unreadIndicator.show();
}
}
@Override
protected void onHideIndicator() {
if (unreadIndicator != null && unreadIndicator.isShown()) {
unreadIndicator.dismiss();
}
}
};
setupSideMenu();
setupMessageComposer();
setupMessageActions();
}
Aggregations