当前位置: 首页>>代码示例>>Java>>正文


Java MXSession.isMessageId方法代码示例

本文整理汇总了Java中org.matrix.androidsdk.MXSession.isMessageId方法的典型用法代码示例。如果您正苦于以下问题:Java MXSession.isMessageId方法的具体用法?Java MXSession.isMessageId怎么用?Java MXSession.isMessageId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.matrix.androidsdk.MXSession的用法示例。


在下文中一共展示了MXSession.isMessageId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateJumpToBanner

import org.matrix.androidsdk.MXSession; //导入方法依赖的package包/类
/**
 * Check if we display "Jump to" banner
 */
private synchronized void updateJumpToBanner() {
    //Log.d(LOG_TAG, "updateJumpToBanner");
    boolean showJumpToView = false;

    mReadMarkerEventId = mRoomSummary.getReadMarkerEventId();
    if (mRoomSummary != null && mReadMarkerEventId != null && !mHasJumpedToFirstUnread) {
        final String readReceiptEventId = mRoomSummary.getReadReceiptEventId();

        if (!mReadMarkerEventId.equals(readReceiptEventId)) {
            if (!MXSession.isMessageId(mReadMarkerEventId)) {
                // Read marker is invalid, ignore it as it should not occur
                Log.e(LOG_TAG, "updateJumpToBanner: Read marker event id is invalid, ignore it as it should not occur");
            } else {
                final Event readMarkerEvent = getEvent(mReadMarkerEventId);
                if (readMarkerEvent == null) {
                    // Event is not in store so we assume it is further in the past
                    // Note: preview will be opened to the last read since we have no way to
                    // determine the event id of the first unread
                    showJumpToView = true;
                } else {
                    // Last read event is in the store
                    Collection<Event> roomMessagesCol = mRoom.getDataHandler().getStore().getRoomMessages(mRoom.getRoomId());
                    if (roomMessagesCol == null) {
                        Log.e(LOG_TAG, "updateJumpToBanner getRoomMessages returned null instead of collection with event " + readMarkerEvent.eventId);
                    } else {
                        List<Event> roomMessages = new ArrayList<>(roomMessagesCol);
                        final int lastReadEventIndex = roomMessages.indexOf(readMarkerEvent);
                        final int firstUnreadEventIndex = lastReadEventIndex != -1 ? lastReadEventIndex + 1 : -1;
                        if (firstUnreadEventIndex != -1 && firstUnreadEventIndex < roomMessages.size()) {
                            final Event firstUnreadEvent = roomMessages.get(firstUnreadEventIndex);
                            if (mFirstVisibleEvent != null && firstUnreadEvent != null) {
                                if (firstUnreadEvent.getOriginServerTs() > mFirstVisibleEvent.getOriginServerTs()) {
                                    // Beginning of first unread message is visible
                                    showJumpToView = false;
                                } else if (firstUnreadEvent.getOriginServerTs() == mFirstVisibleEvent.getOriginServerTs()) {
                                    // Check if beginning of first unread message is visible
                                    final ListView listView = mVectorMessageListFragment.getMessageListView();
                                    final View firstUnreadView = listView != null ? listView.getChildAt(0) : null;
                                    showJumpToView = firstUnreadView != null && firstUnreadView.getTop() < 0;
                                    if (mHasJumpedToFirstUnread && !showJumpToView) {
                                        forgetReadMarker();
                                    }
                                } else {
                                    // Beginning of first unread message is hidden
                                    showJumpToView = true;
                                }
                            }
                        }
                    }
                }
            }
        }

        if (mVectorMessageListFragment.getMessageAdapter() != null) {
            mVectorMessageListFragment.getMessageAdapter().updateReadMarker(mReadMarkerEventId, readReceiptEventId);
        }
    }

    // Update "jump to" view's visibility
    if (isLiveMode() && showJumpToView) {
        mJumpToUnreadViewSpinner.setVisibility(View.GONE);
        mCloseJumpToUnreadView.setVisibility(View.VISIBLE);
        mJumpToUnreadView.setVisibility(View.VISIBLE);
    } else {
        mJumpToUnreadView.setVisibility(View.GONE);
    }

    if (mHasJumpedToBottom) {
        mHasJumpedToBottom = false;
        checkUnreadMessage();
    }
}
 
开发者ID:vector-im,项目名称:riot-android,代码行数:76,代码来源:ReadMarkerManager.java


注:本文中的org.matrix.androidsdk.MXSession.isMessageId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。