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


Java MXDataHandler类代码示例

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


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

示例1: createSession

import org.matrix.androidsdk.MXDataHandler; //导入依赖的package包/类
/**
 * Creates an MXSession from some credentials.
 * @param context the context.
 * @param hsConfig The HomeserverConnectionConfig to create a session from.
 * @return The session.
 */
public MXSession createSession(Context context, HomeserverConnectionConfig hsConfig) {
    IMXStore store;

    Credentials credentials = hsConfig.getCredentials();

    if (true) {
        store = new MXFileStore(hsConfig, context);
    } else {
        store = new MXMemoryStore(hsConfig.getCredentials());
    }

    return new MXSession(hsConfig, new MXDataHandler(store, credentials, new MXDataHandler.InvalidTokenListener() {
        @Override
        public void onTokenCorrupted() {
            if (null != ConsoleApplication.getCurrentActivity()) {
                CommonActivityUtils.logout(ConsoleApplication.getCurrentActivity());
            }
        }
    }), mAppContext);
}
 
开发者ID:matrix-org,项目名称:matrix-android-console,代码行数:27,代码来源:Matrix.java

示例2: specificUpdateBadgeUnreadCount

import org.matrix.androidsdk.MXDataHandler; //导入依赖的package包/类
/**
 * Refresh the badge count for specific configurations.<br>
 * The refresh is only effective if the device is:
 * <ul><li>offline</li><li>does not support GCM</li>
 * <li>GCM registration failed</li>
 * <br>Notifications rooms are parsed to track the notification count value.
 *
 * @param aSession session value
 * @param aContext App context
 */
public static void specificUpdateBadgeUnreadCount(MXSession aSession, Context aContext) {
    MXDataHandler dataHandler;

    // sanity check
    if ((null == aContext) || (null == aSession)) {
        Log.w(LOG_TAG, "## specificUpdateBadgeUnreadCount(): invalid input null values");
    } else if ((null == (dataHandler = aSession.getDataHandler()))) {
        Log.w(LOG_TAG, "## specificUpdateBadgeUnreadCount(): invalid DataHandler instance");
    } else {
        if (aSession.isAlive()) {
            boolean isRefreshRequired;
            GcmRegistrationManager gcmMgr = Matrix.getInstance(aContext).getSharedGCMRegistrationManager();

            // update the badge count if the device is offline, GCM is not supported or GCM registration failed
            isRefreshRequired = !Matrix.getInstance(aContext).isConnected();
            isRefreshRequired |= (null != gcmMgr) && (!gcmMgr.useGCM() || !gcmMgr.hasRegistrationToken());

            if (isRefreshRequired) {
                updateBadgeCount(aContext, dataHandler);
            }
        }
    }
}
 
开发者ID:vector-im,项目名称:riot-android,代码行数:34,代码来源:CommonActivityUtils.java

示例3: 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

示例4: RoomMediaMessagesSender

import org.matrix.androidsdk.MXDataHandler; //导入依赖的package包/类
/**
 * Constructor
 *
 * @param context     the context
 * @param dataHandler the dataHanlder
 * @param room        the room
 */
RoomMediaMessagesSender(Context context, MXDataHandler dataHandler, Room room) {
    mRoom = room;
    mContext = context.getApplicationContext();
    mDataHandler = dataHandler;

    if (null == mUiHandler) {
        mUiHandler = new android.os.Handler(Looper.getMainLooper());

        HandlerThread eventHandlerThread = new HandlerThread("RoomDataItemsSender_event", Thread.MIN_PRIORITY);
        eventHandlerThread.start();
        mEventHandler = new android.os.Handler(eventHandlerThread.getLooper());

        HandlerThread encodingHandlerThread = new HandlerThread("RoomDataItemsSender_encoding", Thread.MIN_PRIORITY);
        encodingHandlerThread.start();
        mEncodingHandler = new android.os.Handler(encodingHandlerThread.getLooper());
    }
}
 
开发者ID:matrix-org,项目名称:matrix-android-sdk,代码行数:25,代码来源:RoomMediaMessagesSender.java

示例5: UnsentEventsManager

import org.matrix.androidsdk.MXDataHandler; //导入依赖的package包/类
/**
 * Constructor
 *
 * @param networkConnectivityReceiver the network received
 * @param dataHandler                 the data handler
 */
public UnsentEventsManager(NetworkConnectivityReceiver networkConnectivityReceiver, MXDataHandler dataHandler) {
    mNetworkConnectivityReceiver = networkConnectivityReceiver;

    // add a default listener
    // to resend the unsent messages
    mNetworkConnectivityReceiver.addEventListener(new IMXNetworkEventListener() {
        @Override
        public void onNetworkConnectionUpdate(boolean isConnected) {
            mbIsConnected = isConnected;

            if (isConnected) {
                resentUnsents();
            }
        }
    });

    mbIsConnected = mNetworkConnectivityReceiver.isConnected();

    mDataHandler = dataHandler;
}
 
开发者ID:matrix-org,项目名称:matrix-android-sdk,代码行数:27,代码来源:UnsentEventsManager.java

示例6: 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

示例7: 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

示例8: EventTimeline

import org.matrix.androidsdk.MXDataHandler; //导入依赖的package包/类
/**
 * Constructor from room and event Id
 *
 * @param dataHandler the data handler
 * @param roomId      the room Id
 * @param eventId     the event id.
 */
public EventTimeline(MXDataHandler dataHandler, String roomId, String eventId) {
    mInitialEventId = eventId;
    mDataHandler = dataHandler;

    mStore = new MXMemoryStore(dataHandler.getCredentials(), null);
    mRoom = mDataHandler.getRoom(mStore, roomId, true);
    mRoom.setLiveTimeline(this);
    mRoom.setReadyState(true);
    setRoomId(roomId);

    mState.setDataHandler(dataHandler);
    mBackState.setDataHandler(dataHandler);
}
 
开发者ID:matrix-org,项目名称:matrix-android-sdk,代码行数:21,代码来源:EventTimeline.java

示例9: setDataHandler

import org.matrix.androidsdk.MXDataHandler; //导入依赖的package包/类
/**
 * Set the data handler.
 *
 * @param store       the store
 * @param dataHandler the data handler.
 */
public void setDataHandler(IMXStore store, MXDataHandler dataHandler) {
    mStore = store;
    mDataHandler = dataHandler;
    mState.setDataHandler(dataHandler);
    mBackState.setDataHandler(dataHandler);
}
 
开发者ID:matrix-org,项目名称:matrix-android-sdk,代码行数:13,代码来源:EventTimeline.java

示例10: init

import org.matrix.androidsdk.MXDataHandler; //导入依赖的package包/类
/**
 * Init the room fields.
 *
 * @param store       the store.
 * @param roomId      the room id
 * @param dataHandler the data handler
 */
public void init(IMXStore store, String roomId, MXDataHandler dataHandler) {
    mLiveTimeline.setRoomId(roomId);
    mDataHandler = dataHandler;
    mStore = store;

    if (null != mDataHandler) {
        mMyUserId = mDataHandler.getUserId();
        mLiveTimeline.setDataHandler(mStore, dataHandler);
    }
}
 
开发者ID:matrix-org,项目名称:matrix-android-sdk,代码行数:18,代码来源:Room.java

示例11: setDataHandler

import org.matrix.androidsdk.MXDataHandler; //导入依赖的package包/类
/**
 * Set the event listener to send back events to. This is typically the DataHandler for dispatching the events to listeners.
 *
 * @param dataHandler should be the main data handler for dispatching back events to registered listeners.
 */
public void setDataHandler(MXDataHandler dataHandler) {
    mDataHandler = dataHandler;

    for (IMXEventListener listener : getPendingListeners()) {
        mDataHandler.addListener(listener);
    }
}
 
开发者ID:matrix-org,项目名称:matrix-android-sdk,代码行数:13,代码来源:User.java

示例12: getDataHandler

import org.matrix.androidsdk.MXDataHandler; //导入依赖的package包/类
/**
 * @return the user dataHandler
 */
public MXDataHandler getDataHandler() {
    return (MXDataHandler) mDataHandler;
}
 
开发者ID:matrix-org,项目名称:matrix-android-sdk,代码行数:7,代码来源:RoomState.java

示例13: getMemberName

import org.matrix.androidsdk.MXDataHandler; //导入依赖的package包/类
/**
 * Return an unique display name of the member userId.
 *
 * @param userId the user id
 * @return unique display name
 */
public String getMemberName(String userId) {
    // sanity check
    if (null == userId) {
        return null;
    }

    String displayName;

    synchronized (this) {
        if (null == mMemberDisplayNameByUserId) {
            mMemberDisplayNameByUserId = new HashMap<>();
        }
        displayName = mMemberDisplayNameByUserId.get(userId);
    }

    if (null != displayName) {
        return displayName;
    }

    // Get the user display name from the member list of the room
    RoomMember member = getMember(userId);

    // Do not consider null display name
    if ((null != member) && !TextUtils.isEmpty(member.displayname)) {
        displayName = member.displayname;

        synchronized (this) {
            ArrayList<String> matrixIds = new ArrayList<>();

            // Disambiguate users who have the same display name in the room
            for (RoomMember aMember : mMembers.values()) {
                if (displayName.equals(aMember.displayname)) {
                    matrixIds.add(aMember.getUserId());
                }
            }

            // if several users have the same display name
            // index it i.e bob (<Matrix id>)
            if (matrixIds.size() > 1) {
                displayName += " (" + userId + ")";
            }
        }
    } else if ((null != member) && TextUtils.equals(member.membership, RoomMember.MEMBERSHIP_INVITE)) {
        User user = ((MXDataHandler) mDataHandler).getUser(userId);

        if (null != user) {
            displayName = user.displayname;
        }
    }

    if (null == displayName) {
        // By default, use the user ID
        displayName = userId;
    }

    mMemberDisplayNameByUserId.put(userId, displayName);

    return displayName;
}
 
开发者ID:matrix-org,项目名称:matrix-android-sdk,代码行数:66,代码来源:RoomState.java

示例14: getDataHandler

import org.matrix.androidsdk.MXDataHandler; //导入依赖的package包/类
/**
 * @return the used datahandler
 */
public MXDataHandler getDataHandler() {
    return mDataHandler;
}
 
开发者ID:matrix-org,项目名称:matrix-android-sdk,代码行数:7,代码来源:Room.java

示例15: DefaultEventsThreadListener

import org.matrix.androidsdk.MXDataHandler; //导入依赖的package包/类
public DefaultEventsThreadListener(MXDataHandler data) {
    mData = data;
}
 
开发者ID:matrix-org,项目名称:matrix-android-sdk,代码行数:4,代码来源:DefaultEventsThreadListener.java


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