當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。