本文整理汇总了Java中org.matrix.androidsdk.MXSession.isAlive方法的典型用法代码示例。如果您正苦于以下问题:Java MXSession.isAlive方法的具体用法?Java MXSession.isAlive怎么用?Java MXSession.isAlive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.matrix.androidsdk.MXSession
的用法示例。
在下文中一共展示了MXSession.isAlive方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: stop
import org.matrix.androidsdk.MXSession; //导入方法依赖的package包/类
private void stop() {
if (mIsForegound) {
stopForeground(true);
}
if (mSessions != null) {
for(MXSession session : mSessions) {
if (session.isAlive()) {
session.stopEventStream();
session.getDataHandler().removeListener(mListener);
}
}
}
mMatrixIds = null;
mSessions = null;
mState = StreamAction.STOP;
mActiveEventStreamService = null;
}
示例2: 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());
}
示例3: 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;
}
示例4: 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);
}
}
示例5: isGoingToSplash
import org.matrix.androidsdk.MXSession; //导入方法依赖的package包/类
/**
* With android M, the permissions kills the backgrounded application
* and try to restart the last opened activity.
* But, the sessions are not initialised (i.e the stores are not ready and so on).
* Thus, the activity could have an invalid behaviour.
* It seems safer to go to splash screen and to wait for the end of the initialisation.
*
* @param activity the caller activity
* @param sessionId the session id
* @param roomId the room id
* @return true if go to splash screen
*/
public static boolean isGoingToSplash(Activity activity, String sessionId, String roomId) {
if (Matrix.hasValidSessions()) {
List<MXSession> sessions = Matrix.getInstance(activity).getSessions();
for (MXSession session : sessions) {
if (session.isAlive() && !session.getDataHandler().getStore().isReady()) {
Intent intent = new Intent(activity, SplashActivity.class);
if ((null != sessionId) && (null != roomId)) {
intent.putExtra(SplashActivity.EXTRA_MATRIX_ID, sessionId);
intent.putExtra(SplashActivity.EXTRA_ROOM_ID, roomId);
}
activity.startActivity(intent);
activity.finish();
return true;
}
}
}
return false;
}
示例6: 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;
}
示例7: getMemberDisplayNameFromUserId
import org.matrix.androidsdk.MXSession; //导入方法依赖的package包/类
/**
* Get the displayable name of the user whose ID is passed in aUserId.
*
* @param aMatrixId matrix ID
* @param aUserId user ID
* @return the user display name
*/
private String getMemberDisplayNameFromUserId(String aMatrixId, String aUserId) {
String displayNameRetValue;
MXSession session;
if ((null == aMatrixId) || (null == aUserId)) {
displayNameRetValue = null;
} else if ((null == (session = Matrix.getMXSession(mContext, aMatrixId))) || (!session.isAlive())) {
displayNameRetValue = null;
} else {
User user = session.getDataHandler().getStore().getUser(aUserId);
if ((null != user) && !TextUtils.isEmpty(user.displayname)) {
displayNameRetValue = user.displayname;
} else {
displayNameRetValue = aUserId;
}
}
return displayNameRetValue;
}
示例8: setSessionErrorListener
import org.matrix.androidsdk.MXSession; //导入方法依赖的package包/类
/**
* Add an error listener to each sessions
* @param activity the activity.
*/
public static void setSessionErrorListener(Activity activity) {
if ((null != instance) && (null != activity)) {
Collection<MXSession> sessions = getMXSessions(activity);
for(MXSession session : sessions) {
if (session.isAlive()) {
session.setFailureCallback(new ErrorListener(session, activity));
}
}
}
}
示例9: removeSessionErrorListener
import org.matrix.androidsdk.MXSession; //导入方法依赖的package包/类
/**
* Remove the sessions error listener to each
*/
public static void removeSessionErrorListener(Activity activity) {
if ((null != instance) && (null != activity)) {
Collection<MXSession> sessions = getMXSessions(activity);
for(MXSession session : sessions) {
if (session.isAlive()) {
session.setFailureCallback(null);
}
}
}
}
示例10: onDestroy
import org.matrix.androidsdk.MXSession; //导入方法依赖的package包/类
@Override
protected void onDestroy() {
super.onDestroy();
Collection<MXSession> sessions = mDoneListeners.keySet();
for(MXSession session : sessions) {
if (session.isAlive()) {
session.getDataHandler().removeListener(mDoneListeners.get(session));
}
}
}
示例11: computeApplicationCacheSize
import org.matrix.androidsdk.MXSession; //导入方法依赖的package包/类
/**
* Return the application cache size as formatted string.
* @return the application cache size as formatted string.
*/
private String computeApplicationCacheSize() {
long size = 0;
size += mMediasCache.cacheSize();
for(MXSession session : Matrix.getMXSessions(SettingsActivity.this)) {
if (session.isAlive()) {
size += session.getDataHandler().getStore().diskUsage();
}
}
return android.text.format.Formatter.formatFileSize(SettingsActivity.this, size);
}
示例12: setSessionErrorListener
import org.matrix.androidsdk.MXSession; //导入方法依赖的package包/类
/**
* Add an error listener to each sessions
*
* @param activity the activity.
*/
public static void setSessionErrorListener(Activity activity) {
if ((null != instance) && (null != activity)) {
Collection<MXSession> sessions = getMXSessions(activity);
for (MXSession session : sessions) {
if (session.isAlive()) {
session.setFailureCallback(new ErrorListener(session, activity));
}
}
}
}
示例13: hasValidSessions
import org.matrix.androidsdk.MXSession; //导入方法依赖的package包/类
/**
* @return true if the matrix client instance defines a valid session
*/
public static boolean hasValidSessions() {
if (null == instance) {
Log.e(LOG_TAG, "hasValidSessions : has no instance");
return false;
}
boolean res;
synchronized (LOG_TAG) {
res = (null != instance.mMXSessions) && (instance.mMXSessions.size() > 0);
if (!res) {
Log.e(LOG_TAG, "hasValidSessions : has no session");
} else {
for (MXSession session : instance.mMXSessions) {
// some GA issues reported that the data handler can be null
// so assume the application should be restarted
res &= session.isAlive() && (null != session.getDataHandler());
}
if (!res) {
Log.e(LOG_TAG, "hasValidSessions : one sesssion has no valid data handler");
}
}
}
return res;
}
示例14: clearSession
import org.matrix.androidsdk.MXSession; //导入方法依赖的package包/类
/**
* Clear a session.
*
* @param context the context.
* @param session the session to clear.
* @param clearCredentials true to clear the credentials.
*/
public synchronized void clearSession(final Context context, final MXSession session, final boolean clearCredentials, final SimpleApiCallback<Void> aCallback) {
if (!session.isAlive()) {
Log.e(LOG_TAG, "## clearSession() " + session.getMyUserId() + " is already released");
return;
}
Log.d(LOG_TAG, "## clearSession() " + session.getMyUserId() + " clearCredentials " + clearCredentials);
if (clearCredentials) {
mLoginStorage.removeCredentials(session.getHomeServerConfig());
}
session.getDataHandler().removeListener(mLiveEventListener);
SimpleApiCallback<Void> callback = new SimpleApiCallback<Void>() {
@Override
public void onSuccess(Void info) {
VectorApp.removeSyncingSession(session);
synchronized (LOG_TAG) {
mMXSessions.remove(session);
}
if (null != aCallback) {
aCallback.onSuccess(null);
}
}
};
if (clearCredentials) {
session.logout(context, callback);
} else {
session.clear(context, callback);
}
}
示例15: prepareCallNotification
import org.matrix.androidsdk.MXSession; //导入方法依赖的package包/类
/**
* Prepare a call notification.
* Only the incoming calls are managed by now and have a dedicated notification.
*
* @param event the event
* @param bingRule the bing rule
*/
private void prepareCallNotification(Event event, BingRule bingRule) {
// display only the invitation messages by now
// because the other ones are not displayed.
if (!event.getType().equals(Event.EVENT_TYPE_CALL_INVITE)) {
Log.d(LOG_TAG, "prepareCallNotification : don't bing - Call invite");
return;
}
MXSession session = Matrix.getMXSession(getApplicationContext(), event.getMatrixId());
// invalid session ?
// should never happen.
// But it could be triggered because of multi accounts management.
// The dedicated account is removing but some pushes are still received.
if ((null == session) || !session.isAlive()) {
Log.d(LOG_TAG, "prepareCallNotification : don't bing - no session");
return;
}
Room room = session.getDataHandler().getRoom(event.roomId);
// invalid room ?
if (null == room) {
Log.d(LOG_TAG, "prepareCallNotification : don't bing - the room does not exist");
return;
}
String callId = null;
try {
callId = event.getContentAsJsonObject().get("call_id").getAsString();
} catch (Exception e) {
Log.e(LOG_TAG, "prepareNotification : getContentAsJsonObject " + e.getMessage());
}
if (!TextUtils.isEmpty(callId)) {
displayIncomingCallNotification(session, room, event, callId, bingRule);
}
}