當前位置: 首頁>>代碼示例>>Java>>正文


Java MXSession類代碼示例

本文整理匯總了Java中org.matrix.androidsdk.MXSession的典型用法代碼示例。如果您正苦於以下問題:Java MXSession類的具體用法?Java MXSession怎麽用?Java MXSession使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MXSession類屬於org.matrix.androidsdk包,在下文中一共展示了MXSession類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getMemberDisplayNameFromUserId

import org.matrix.androidsdk.MXSession; //導入依賴的package包/類
/**
 * Get the displayable name of the user whose ID is passed in aUserId.
 *
 * @param context
 * @param matrixId matrix ID
 * @param userId   user ID
 * @return the user display name
 */
private static String getMemberDisplayNameFromUserId(final Context context, final String matrixId,
                                                     final String userId) {
    String displayNameRetValue;
    MXSession session;

    if (null == matrixId || null == userId) {
        displayNameRetValue = null;
    } else if ((null == (session = Matrix.getMXSession(context, matrixId))) || (!session.isAlive())) {
        displayNameRetValue = null;
    } else {
        User user = session.getDataHandler().getStore().getUser(userId);

        if ((null != user) && !TextUtils.isEmpty(user.displayname)) {
            displayNameRetValue = user.displayname;
        } else {
            displayNameRetValue = userId;
        }
    }

    return displayNameRetValue;
}
 
開發者ID:vector-im,項目名稱:riot-android,代碼行數:30,代碼來源:RoomUtils.java

示例2: getRoomName

import org.matrix.androidsdk.MXSession; //導入依賴的package包/類
/**
 * Retrieve the room name.
 *
 * @param session the session
 * @param room    the room
 * @param event   the event
 * @return the room name
 */
public static String getRoomName(Context context, MXSession session, Room room, Event event) {
    String roomName = VectorUtils.getRoomDisplayName(context, session, room);

    // avoid displaying the room Id
    // try to find the sender display name
    if (TextUtils.equals(roomName, room.getRoomId())) {
        roomName = room.getName(session.getMyUserId());

        // avoid room Id as name
        if (TextUtils.equals(roomName, room.getRoomId()) && (null != event)) {
            User user = session.getDataHandler().getStore().getUser(event.sender);

            if (null != user) {
                roomName = user.displayname;
            } else {
                roomName = event.sender;
            }
        }
    }

    return roomName;
}
 
開發者ID:vector-im,項目名稱:riot-android,代碼行數:31,代碼來源:NotificationUtils.java

示例3: isPowerLevelEnoughForAvatarUpdate

import org.matrix.androidsdk.MXSession; //導入依賴的package包/類
/**
 * Check if the user power level allows to update the room avatar. This is mainly used to
 * determine if camera permission must be checked or not.
 *
 * @param aRoom    the room
 * @param aSession the session
 * @return true if the user power level allows to update the avatar, false otherwise.
 */
public static boolean isPowerLevelEnoughForAvatarUpdate(Room aRoom, MXSession aSession) {
    boolean canUpdateAvatarWithCamera = false;
    PowerLevels powerLevels;

    if ((null != aRoom) && (null != aSession)) {
        if (null != (powerLevels = aRoom.getLiveState().getPowerLevels())) {
            int powerLevel = powerLevels.getUserPowerLevel(aSession.getMyUserId());

            // check the power level against avatar level
            canUpdateAvatarWithCamera = (powerLevel >= powerLevels.minimumPowerLevelForSendingEventAsStateEvent(Event.EVENT_TYPE_STATE_ROOM_AVATAR));
        }
    }

    return canUpdateAvatarWithCamera;
}
 
開發者ID:vector-im,項目名稱:riot-android,代碼行數:24,代碼來源:CommonActivityUtils.java

示例4: onCreate

import org.matrix.androidsdk.MXSession; //導入依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mMatrixId = getArguments().getString(EXTRA_MATRIX_ID);
    mRoomId = getArguments().getString(EXTRA_ROOM_ID);

    MXSession session = Matrix.getInstance(getActivity()).getSession(mMatrixId);

    if (null != session) {
        mRoom = session.getDataHandler().getRoom(mRoomId);
    }

    if (null == mRoom) {
        dismiss();
    }
}
 
開發者ID:matrix-org,項目名稱:matrix-android-console,代碼行數:17,代碼來源:RoomInfoUpdateDialogFragment.java

示例5: findOneToOneRoomList

import org.matrix.androidsdk.MXSession; //導入依賴的package包/類
/**
 * Return all the 1:1 rooms joined by the searched user and by the current logged in user.
 * This method go through all the rooms, and for each room, tests if the searched user
 * and the logged in user are present.
 *
 * @param aSession        session
 * @param aSearchedUserId the searched user ID
 * @return an array containing the found rooms
 */
private static ArrayList<Room> findOneToOneRoomList(final MXSession aSession, final String aSearchedUserId) {
    ArrayList<Room> listRetValue = new ArrayList<>();
    List<RoomMember> roomMembersList;
    String userId0, userId1;

    if ((null != aSession) && (null != aSearchedUserId)) {
        Collection<Room> roomsList = aSession.getDataHandler().getStore().getRooms();

        for (Room room : roomsList) {
            roomMembersList = (List<RoomMember>) room.getJoinedMembers();

            if ((null != roomMembersList) && (ROOM_SIZE_ONE_TO_ONE == roomMembersList.size())) {
                userId0 = roomMembersList.get(0).getUserId();
                userId1 = roomMembersList.get(1).getUserId();

                // add the room where the second member is the searched one
                if (userId0.equals(aSearchedUserId) || userId1.equals(aSearchedUserId)) {
                    listRetValue.add(room);
                }
            }
        }
    }

    return listRetValue;
}
 
開發者ID:vector-im,項目名稱:riot-android,代碼行數:35,代碼來源:CommonActivityUtils.java

示例6: MyPresenceManager

import org.matrix.androidsdk.MXSession; //導入依賴的package包/類
private MyPresenceManager(Context context, MXSession session) {
    myUser = session.getMyUser();
    mHandler = new Handler(Looper.getMainLooper());

    myUser.addEventListener(new MXEventListener() {
        @Override
        public void onPresenceUpdate(Event event, User user) {
            myUser.presence = user.presence;

            // If the received presence is the same as the last one we've advertised, this must be
            // the event stream sending back our own event => nothing more to do
            if (!user.presence.equals(latestAdvertisedPresence)) {
                // If we're here, the presence event comes from another of this user's devices. If it's saying for example that it's
                // offline but we're currently online, our presence takes precedence; in which case, we broadcast the correction
                Integer newPresenceOrder = presenceOrderMap.get(user.presence);
                if (newPresenceOrder != null) {
                    int ourPresenceOrder = presenceOrderMap.get(latestAdvertisedPresence);
                    // If the new presence is further down the order list, we correct it
                    if (newPresenceOrder > ourPresenceOrder) {
                        advertisePresence(latestAdvertisedPresence);
                    }
                }
            }
        }
    });
}
 
開發者ID:matrix-org,項目名稱:matrix-android-console,代碼行數:27,代碼來源:MyPresenceManager.java

示例7: checkNotification

import org.matrix.androidsdk.MXSession; //導入依賴的package包/類
private void checkNotification() {
    if (null != mNotificationRoomId) {
        boolean clearNotification = true;
        MXSession session = Matrix.getInstance(this).getSession(mNotificationSessionId);

        if (null != session) {
            Room room = session.getDataHandler().getRoom(mNotificationRoomId);

            if (null != room) {
                // invitation notification
                if (null == mNotificationEventId) {
                    clearNotification = !room.isInvited();
                } else {
                    clearNotification = room.isEventRead(mNotificationEventId);
                }
            }
        }

        if (clearNotification) {
            clearNotification();
        }
    }
}
 
開發者ID:matrix-org,項目名稱:matrix-android-console,代碼行數:24,代碼來源:EventStreamService.java

示例8: stopAccounts

import org.matrix.androidsdk.MXSession; //導入依賴的package包/類
/**
 * Stop some accounts of the current service.
 * @param matrixIds the account identifiers to add.
 */
public void stopAccounts(List<String> matrixIds) {
    for(String matrixId : matrixIds) {
        // not yet started
        if (mMatrixIds.indexOf(matrixId) >= 0) {
            MXSession session = Matrix.getInstance(getApplicationContext()).getSession(matrixId);

            if (null != session) {

                session.stopEventStream();
                session.getDataHandler().removeListener(mListener);

                mSessions.remove(session);
                mMatrixIds.remove(matrixId);
            }
        }
    }
}
 
開發者ID:matrix-org,項目名稱:matrix-android-console,代碼行數:22,代碼來源:EventStreamService.java

示例9: roomFromRoomSummary

import org.matrix.androidsdk.MXSession; //導入依賴的package包/類
/**
 * Retrieve a Room from a room summary
 * @param roomSummary the room roomId to retrieve.
 * @return the Room.
 */
public Room roomFromRoomSummary(RoomSummary roomSummary) {
    // sanity check
    if ((null == roomSummary) || (null == roomSummary.getMatrixId())) {
        return null;
    }

    MXSession session = Matrix.getMXSession(mContext, roomSummary.getMatrixId());

    // check if the session is active
    if ((null == session) || (!session.isAlive())) {
        return null;
    }

    return Matrix.getMXSession(mContext, roomSummary.getMatrixId()).getDataHandler().getStore().getRoom(roomSummary.getRoomId());
}
 
開發者ID:matrix-org,項目名稱:matrix-android-console,代碼行數:21,代碼來源:ConsoleRoomSummaryAdapter.java

示例10: memberDisplayName

import org.matrix.androidsdk.MXSession; //導入依賴的package包/類
public String memberDisplayName(String matrixId, String userId) {
    MXSession session = Matrix.getMXSession(mContext, matrixId);

    // check if the session is active
    if ((null == session) || (!session.isAlive())) {
        return null;
    }

    User user = session.getDataHandler().getStore().getUser(userId);

    if ((null != user) && !TextUtils.isEmpty(user.displayname)) {
        return user.displayname;
    }

    return userId;
}
 
開發者ID:matrix-org,項目名稱:matrix-android-console,代碼行數:17,代碼來源:ConsoleRoomSummaryAdapter.java

示例11: logout

import org.matrix.androidsdk.MXSession; //導入依賴的package包/類
public static void logout(Activity activity, MXSession session, Boolean clearCredentials) {
    if (session.isAlive()) {
        // stop the service
        EventStreamService eventStreamService = EventStreamService.getInstance();
        ArrayList<String> matrixIds = new ArrayList<String>();
        matrixIds.add(session.getMyUserId());
        eventStreamService.stopAccounts(matrixIds);

        // Publish to the server that we're now offline
        MyPresenceManager.getInstance(activity, session).advertiseOffline();
        MyPresenceManager.remove(session);

        // unregister from the GCM.
        Matrix.getInstance(activity).getSharedGcmRegistrationManager().unregisterSession(session, null);

        // clear credentials
        Matrix.getInstance(activity).clearSession(activity, session, clearCredentials);
    }
}
 
開發者ID:matrix-org,項目名稱:matrix-android-console,代碼行數:20,代碼來源:CommonActivityUtils.java

示例12: pause

import org.matrix.androidsdk.MXSession; //導入依賴的package包/類
/**
 * internal pause method.
 */
private void pause() {
    StreamAction state = getServiceState();

    if ((StreamAction.START == state) || (StreamAction.RESUME == state)) {
        Log.d(LOG_TAG, "onStartCommand pause from state " + state);

        if (mSessions != null) {
            for (MXSession session : mSessions) {
                session.pauseEventStream();
            }

            setServiceState(StreamAction.PAUSE);
        }
    } else {
        Log.e(LOG_TAG, "onStartCommand invalid state pause " + state);
    }
}
 
開發者ID:vector-im,項目名稱:riot-android,代碼行數:21,代碼來源:EventStreamService.java

示例13: VectorSearchMessagesListAdapter

import org.matrix.androidsdk.MXSession; //導入依賴的package包/類
public VectorSearchMessagesListAdapter(MXSession session, Context context, boolean displayRoomName, MXMediasCache mediasCache) {
    super(session, context,
            R.layout.adapter_item_vector_search_message_text_emote_notice,
            R.layout.adapter_item_vector_search_message_image_video,
            R.layout.adapter_item_vector_search_message_text_emote_notice,
            R.layout.adapter_item_vector_search_message_room_member,
            R.layout.adapter_item_vector_search_message_text_emote_notice,
            R.layout.adapter_item_vector_search_message_file,
            R.layout.adapter_item_vector_search_message_image_video,
            -1,
            R.layout.adapter_item_vector_search_message_emoji,
            mediasCache);

    setNotifyOnChange(true);
    mDisplayRoomName = displayRoomName;
    mSearchHighlightMessageTextColor = ContextCompat.getColor(context, R.color.vector_green_color);
}
 
開發者ID:vector-im,項目名稱:riot-android,代碼行數:18,代碼來源:VectorSearchMessagesListAdapter.java

示例14: clearSessions

import org.matrix.androidsdk.MXSession; //導入依賴的package包/類
/**
 * Internal routine to clear the sessions data
 *
 * @param context          the context
 * @param iterator         the sessions iterator
 * @param clearCredentials true to clear the credentials.
 * @param callback         the asynchronous callback
 */
private synchronized void clearSessions(final Context context, final Iterator<MXSession> iterator, final boolean clearCredentials, final ApiCallback<Void> callback) {
    if (!iterator.hasNext()) {
        if (null != callback) {
            callback.onSuccess(null);
        }
        return;
    }

    clearSession(context, iterator.next(), clearCredentials, new SimpleApiCallback<Void>() {
        @Override
        public void onSuccess(Void info) {
            clearSessions(context, iterator, clearCredentials, callback);
        }
    });

}
 
開發者ID:vector-im,項目名稱:riot-android,代碼行數:25,代碼來源:Matrix.java

示例15: Matrix

import org.matrix.androidsdk.MXSession; //導入依賴的package包/類
protected Matrix(Context appContext) {
    mAppContext = appContext.getApplicationContext();
    mLoginStorage = new LoginStorage(mAppContext);
    mMXSessions = new ArrayList<MXSession>();
    mGcmRegistrationManager = new GcmRegistrationManager(mAppContext);
    RageShake.getInstance().start(mAppContext);
}
 
開發者ID:matrix-org,項目名稱:matrix-android-console,代碼行數:8,代碼來源:Matrix.java


注:本文中的org.matrix.androidsdk.MXSession類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。