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


Java MXDataHandler.getStore方法代码示例

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


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

示例1: updateBadgeCount

import org.matrix.androidsdk.MXDataHandler; //导入方法依赖的package包/类
/**
 * Update the badge count value according to the rooms content.
 *
 * @param aContext     App context
 * @param aDataHandler data handler instance
 */
private static void updateBadgeCount(Context aContext, MXDataHandler aDataHandler) {
    //sanity check
    if ((null == aContext) || (null == aDataHandler)) {
        Log.w(LOG_TAG, "## updateBadgeCount(): invalid input null values");
    } else if (null == aDataHandler.getStore()) {
        Log.w(LOG_TAG, "## updateBadgeCount(): invalid store instance");
    } else {
        ArrayList<Room> roomCompleteList = new ArrayList<>(aDataHandler.getStore().getRooms());
        int unreadRoomsCount = 0;

        for (Room room : roomCompleteList) {
            if (room.getNotificationCount() > 0) {
                unreadRoomsCount++;
            }
        }

        // update the badge counter
        Log.d(LOG_TAG, "## updateBadgeCount(): badge update count=" + unreadRoomsCount);
        CommonActivityUtils.updateBadgeCount(aContext, unreadRoomsCount);
    }
}
 
开发者ID:vector-im,项目名称:riot-android,代码行数:28,代码来源:CommonActivityUtils.java

示例2: initDirectChatsData

import org.matrix.androidsdk.MXDataHandler; //导入方法依赖的package包/类
/**
 * Fill the direct chats adapter with data
 */
private void initDirectChatsData() {
    if ((null == mSession) || (null == mSession.getDataHandler())) {
        Log.e(LOG_TAG, "## initDirectChatsData() : null session");
    }

    final List<String> directChatIds = mSession.getDirectChatRoomIdsList();
    final MXDataHandler dataHandler = mSession.getDataHandler();
    final IMXStore store = dataHandler.getStore();

    mDirectChats.clear();
    if (directChatIds != null && !directChatIds.isEmpty()) {
        for (String roomId : directChatIds) {
            Room room = store.getRoom(roomId);

            if ((null != room) && !room.isConferenceUserRoom()) {
                // it seems that the server syncs some left rooms
                if (null == room.getMember(mSession.getMyUserId())) {
                    Log.e(LOG_TAG, "## initDirectChatsData(): invalid room " + room.getRoomId() + ", the user is not anymore member of it");
                } else {
                    final Set<String> tags = room.getAccountData().getKeys();
                    if ((null == tags) || !tags.contains(RoomTag.ROOM_TAG_LOW_PRIORITY)) {
                        mDirectChats.add(dataHandler.getRoom(roomId));
                    }
                }
            }
        }
    }
}
 
开发者ID:vector-im,项目名称:riot-android,代码行数:32,代码来源:PeopleFragment.java

示例3: refreshSummariesList

import org.matrix.androidsdk.MXDataHandler; //导入方法依赖的package包/类
private void refreshSummariesList() {
    if (null != mMxSession) {
        // sanity check
        MXDataHandler dataHandler = mMxSession.getDataHandler();
        if ((null == dataHandler) || (null == dataHandler.getStore())) {
            Log.w(DBG_CLASS_NAME, "## refreshSummariesList(): unexpected null values - return");
            return;
        }

        // update/retrieve the complete summary list
        ArrayList<RoomSummary> roomSummariesCompleteList = new ArrayList<>(dataHandler.getStore().getSummaries());

        // define comparator logic
        Comparator<RoomSummary> summaryComparator = new Comparator<RoomSummary>() {
            public int compare(RoomSummary aLeftObj, RoomSummary aRightObj) {
                int retValue;
                long deltaTimestamp;

                if ((null == aLeftObj) || (null == aLeftObj.getLatestReceivedEvent())) {
                    retValue = 1;
                } else if ((null == aRightObj) || (null == aRightObj.getLatestReceivedEvent())) {
                    retValue = -1;
                } else if ((deltaTimestamp = aRightObj.getLatestReceivedEvent().getOriginServerTs() - aLeftObj.getLatestReceivedEvent().getOriginServerTs()) > 0) {
                    retValue = 1;
                } else if (deltaTimestamp < 0) {
                    retValue = -1;
                } else {
                    retValue = 0;
                }

                return retValue;
            }
        };

        Collections.sort(roomSummariesCompleteList, summaryComparator);

        // init data model used to be be displayed in the list view
        mSummaryListByGroupPosition = buildSummariesByGroups(roomSummariesCompleteList);
    }
}
 
开发者ID:vector-im,项目名称:riot-android,代码行数:41,代码来源:VectorRoomSummaryAdapter.java


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