• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java MXSession类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: getSessions

import org.matrix.androidsdk.MXSession; //导入依赖的package包/类
/**
 * @return The list of sessions
 */
public ArrayList<MXSession> getSessions() {
    ArrayList<MXSession> sessions = new ArrayList<MXSession>();

    synchronized (instance) {
        if (null != mMXSessions) {
            sessions = new ArrayList<MXSession>(mMXSessions);
        }
    }

    return sessions;
}
 
开发者ID:matrix-org,项目名称:matrix-android-console,代码行数:15,代码来源:Matrix.java


示例17: getDefaultSession

import org.matrix.androidsdk.MXSession; //导入依赖的package包/类
/**
 * Retrieve the default session if one exists.
 *
 * The default session may be user-configured, or it may be the last session the user was using.
 * @return The default session or null.
 */
public synchronized MXSession getDefaultSession() {
    ArrayList<MXSession> sessions = getSessions();

    if (sessions.size() > 0) {
        return sessions.get(0);
    }

    ArrayList<HomeserverConnectionConfig> hsConfigList = mLoginStorage.getCredentialsList();

    // any account ?
    if ((hsConfigList == null) || (hsConfigList.size() == 0)) {
        return null;
    }

    ArrayList<String> matrixIds = new ArrayList<String>();
    sessions = new ArrayList<MXSession>();

    for(HomeserverConnectionConfig config: hsConfigList) {
        // avoid duplicated accounts.
        if (config.getCredentials() != null && matrixIds.indexOf(config.getCredentials().userId) < 0) {
            MXSession session = createSession(config);
            sessions.add(session);
            matrixIds.add(config.getCredentials().userId);
        }
    }

    synchronized (instance) {
        mMXSessions = sessions;
    }

    return sessions.get(0);
}
 
开发者ID:matrix-org,项目名称:matrix-android-console,代码行数:39,代码来源:Matrix.java


示例18: VectorParticipantsAdapter

import org.matrix.androidsdk.MXSession; //导入依赖的package包/类
/**
 * Create a room member adapter.
 * If a room id is defined, the adapter is in edition mode : the user can add / remove dynamically members or leave the room.
 * If there is none, the room is in creation mode : the user can add/remove members to create a new room.
 *
 * @param context                the context.
 * @param cellLayoutResourceId   the cell layout.
 * @param headerLayoutResourceId the header layout
 * @param session                the session.
 * @param roomId                 the room id.
 * @param withAddIcon            whether we need to display the "+" icon
 */
public VectorParticipantsAdapter(Context context, int cellLayoutResourceId, int headerLayoutResourceId, MXSession session, String roomId, boolean withAddIcon) {
    mContext = context;

    mLayoutInflater = LayoutInflater.from(context);
    mCellLayoutResourceId = cellLayoutResourceId;
    mHeaderLayoutResourceId = headerLayoutResourceId;

    mSession = session;
    mRoomId = roomId;
    mWithAddIcon = withAddIcon;

    mSortMethod = ParticipantAdapterItem.getComparator(session);
}
 
开发者ID:vector-im,项目名称:riot-android,代码行数:26,代码来源:VectorParticipantsAdapter.java


示例19: 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));
            }
        }
    }
}
 
开发者ID:matrix-org,项目名称:matrix-android-console,代码行数:16,代码来源:Matrix.java


示例20: refreshPushRules

import org.matrix.androidsdk.MXSession; //导入依赖的package包/类
/**
 * Refresh the sessions push rules.
 */
public void refreshPushRules() {
    ArrayList<MXSession> sessions = null;

    synchronized (this) {
        sessions = getSessions();
    }

    for(MXSession session : sessions) {
        if (null != session.getDataHandler()) {
            session.getDataHandler().refreshPushRules();
        }
    }
}
 
开发者ID:matrix-org,项目名称:matrix-android-console,代码行数:17,代码来源:Matrix.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Trigger类代码示例发布时间:2022-05-16
下一篇:
Java RebalanceService类代码示例发布时间:2022-05-16
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap