本文整理汇总了Java中org.matrix.androidsdk.rest.model.User类的典型用法代码示例。如果您正苦于以下问题:Java User类的具体用法?Java User怎么用?Java User使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
User类属于org.matrix.androidsdk.rest.model包,在下文中一共展示了User类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MyPresenceManager
import org.matrix.androidsdk.rest.model.User; //导入依赖的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);
}
}
}
}
});
}
示例2: memberDisplayName
import org.matrix.androidsdk.rest.model.User; //导入依赖的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;
}
示例3: MyPresenceManager
import org.matrix.androidsdk.rest.model.User; //导入依赖的package包/类
private MyPresenceManager(Context context, MXSession session) {
myUser = session.getMyUser();
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);
}
}
}
}
});
}
示例4: initAutoCompletion
import org.matrix.androidsdk.rest.model.User; //导入依赖的package包/类
/**
* Build the auto completions list for a room
*
* @param session the session
* @param roomId the room Id
*/
public void initAutoCompletion(MXSession session, String roomId) {
List<User> users = new ArrayList<>();
if (!TextUtils.isEmpty(roomId)) {
Room room = session.getDataHandler().getStore().getRoom(roomId);
if (null != room) {
Collection<RoomMember> members = room.getMembers();
for (RoomMember member : members) {
User user = session.getDataHandler().getUser(member.getUserId());
if (null != user) {
users.add(user);
}
}
}
}
initAutoCompletion(session, users);
}
示例5: getMemberDisplayNameFromUserId
import org.matrix.androidsdk.rest.model.User; //导入依赖的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;
}
示例6: onPresenceUpdate
import org.matrix.androidsdk.rest.model.User; //导入依赖的package包/类
@Override
public void onPresenceUpdate(final Event event, final User user) {
runOnUiThread(new Runnable() {
@Override
public void run() {
Map<Integer, List<Integer>> visibleChildViews = VectorUtils.getVisibleChildViews(mListView, mAdapter);
for (Integer groupPosition : visibleChildViews.keySet()) {
List<Integer> childPositions = visibleChildViews.get(groupPosition);
for (Integer childPosition : childPositions) {
Object item = mAdapter.getChild(groupPosition, childPosition);
if (item instanceof ParticipantAdapterItem) {
ParticipantAdapterItem participantAdapterItem = (ParticipantAdapterItem) item;
if (TextUtils.equals(user.user_id, participantAdapterItem.mUserId)) {
mAdapter.notifyDataSetChanged();
break;
}
}
}
}
}
});
}
示例7: getMemberDisplayNameFromUserId
import org.matrix.androidsdk.rest.model.User; //导入依赖的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;
}
示例8: getRoomName
import org.matrix.androidsdk.rest.model.User; //导入依赖的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;
}
示例9: listKnownParticipants
import org.matrix.androidsdk.rest.model.User; //导入依赖的package包/类
/**
* List the active users i.e the active rooms users (invited or joined) and the contacts with matrix id emails.
* This function could require a long time to process so it should be called in background.
*
* @param session the session.
* @return a map indexed by the matrix id.
*/
public static Map<String, ParticipantAdapterItem> listKnownParticipants(MXSession session) {
// check known users
Collection<User> users = session.getDataHandler().getStore().getUsers();
// a hash map is a lot faster than a list search
Map<String, ParticipantAdapterItem> map = new HashMap<>(users.size());
// we don't need to populate the room members or each room
// because an user is created for each joined / invited room member event
for (User user : users) {
if (!MXCallsManager.isConferenceUserId(user.user_id)) {
map.put(user.user_id, new ParticipantAdapterItem(user));
}
}
return map;
}
示例10: onPresenceUpdate
import org.matrix.androidsdk.rest.model.User; //导入依赖的package包/类
@Override
public void onPresenceUpdate(final Event event, final User user) {
if (null != mCryptoEventsListener) {
mCryptoEventsListener.onPresenceUpdate(event, user);
}
final List<IMXEventListener> eventListeners = getListenersSnapshot();
mUiHandler.post(new Runnable() {
@Override
public void run() {
for (IMXEventListener listener : eventListeners) {
try {
listener.onPresenceUpdate(event, user);
} catch (Exception e) {
Log.e(LOG_TAG, "onPresenceUpdate " + e.getMessage());
}
}
}
});
}
示例11: displayname
import org.matrix.androidsdk.rest.model.User; //导入依赖的package包/类
/**
* Get the user's display name.
* @param userId the user id
* @param callback the callback to return the name on success
*/
public void displayname(final String userId, final ApiCallback<String> callback) {
final String description = "display name userId : " + userId;
try {
mApi.displayname(userId, new RestAdapterCallback<User>(description, mUnsentEventsManager, callback, new RestAdapterCallback.RequestRetryCallBack() {
@Override
public void onRetry() {
displayname(userId, callback);
}
}) {
@Override
public void success(User user, Response response) {
onEventSent();
callback.onSuccess(user.displayname);
}
});
} catch (Throwable t) {
callback.onUnexpectedError(new Exception(t));
}
}
示例12: updateDisplayname
import org.matrix.androidsdk.rest.model.User; //导入依赖的package包/类
/**
* Update this user's own display name.
* @param newName the new name
* @param callback the callback if the call succeeds
*/
public void updateDisplayname(final String newName, final ApiCallback<Void> callback) {
// privacy
//final String description = "updateDisplayname newName : " + newName;
final String description = "update display name";
User user = new User();
user.displayname = newName;
try {
// don't retry if the network comes back
// let the user chooses what he want to do
mApi.displayname(mCredentials.userId, user, new RestAdapterCallback<Void>(description, mUnsentEventsManager, callback, new RestAdapterCallback.RequestRetryCallBack() {
@Override
public void onRetry() {
updateDisplayname(newName, callback);
}
}));
} catch (Throwable t) {
callback.onUnexpectedError(new Exception(t));
}
}
示例13: avatarUrl
import org.matrix.androidsdk.rest.model.User; //导入依赖的package包/类
/**
* Get the user's avatar URL.
* @param userId the user id
* @param callback the callback to return the URL on success
*/
public void avatarUrl(final String userId, final ApiCallback<String> callback) {
final String description = "avatarUrl userId : " + userId;
try {
mApi.avatarUrl(userId, new RestAdapterCallback<User>(description, mUnsentEventsManager, callback, new RestAdapterCallback.RequestRetryCallBack() {
@Override
public void onRetry() {
avatarUrl(userId, callback);
}
}) {
@Override
public void success(User user, Response response) {
onEventSent();
callback.onSuccess(user.getAvatarUrl());
}
});
} catch (Throwable t) {
callback.onUnexpectedError(new Exception(t));
}
}
示例14: updateAvatarUrl
import org.matrix.androidsdk.rest.model.User; //导入依赖的package包/类
/**
* Update this user's own avatar URL.
* @param newUrl the new name
* @param callback the callback if the call succeeds
*/
public void updateAvatarUrl(final String newUrl, final ApiCallback<Void> callback) {
// privacy
//final String description = "updateAvatarUrl newUrl : " + newUrl;
final String description = "updateAvatarUrl";
User user = new User();
user.setAvatarUrl(newUrl);
try {
mApi.avatarUrl(mCredentials.userId, user, new RestAdapterCallback<Void>(description, mUnsentEventsManager, callback, new RestAdapterCallback.RequestRetryCallBack() {
@Override
public void onRetry() {
updateAvatarUrl(newUrl, callback);
}
}));
} catch (Throwable t) {
callback.onUnexpectedError(new Exception(t));
}
}
示例15: inviteUserToRoom
import org.matrix.androidsdk.rest.model.User; //导入依赖的package包/类
/**
* Invite a user to a room.
*
* @param roomId the room id
* @param userId the user id
* @param callback the async callback
*/
public void inviteUserToRoom(final String roomId, final String userId, final ApiCallback<Void> callback) {
final String description = "inviteToRoom : roomId " + roomId + " userId " + userId;
User user = new User();
user.user_id = userId;
try {
mApi.invite(roomId, user, new RestAdapterCallback<Void>(description, mUnsentEventsManager, callback, new RestAdapterCallback.RequestRetryCallBack() {
@Override
public void onRetry() {
inviteUserToRoom(roomId, userId, callback);
}
}));
} catch (Throwable t) {
callback.onUnexpectedError(new Exception(t));
}
}