本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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();
}
}
示例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;
}
示例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);
}
}
}
}
});
}
示例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();
}
}
}
示例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);
}
}
}
}
示例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());
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
});
}
示例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);
}