- Add the Codota plugin to your IDE and get smart completions
private void myMethod () {DateTime d =
new DateTime()
DateTimeFormatter formatter;String text;formatter.parseDateTime(text)
Object instant;new DateTime(instant)
- Smart code suggestions by Codota
}
private void refreshConversationThenNotify(final AVIMMessage message, final SimpleCallback callback) { if (null == message || null == callback) { return; } final AVIMClient client = AVIMClient.getInstance(session.getSelfPeerId()); final AVIMConversation conversation = client.getConversation(message.getConversationId(), convType); refreshConversationThenNotify(conversation, callback); }
/** * get AVIMClient instance by clientId. * @param clientId * @return */ public static AVIMClient getInstance(String clientId) { if (StringUtil.isEmpty(clientId)) { return null; } AVIMClient client = clients.get(clientId); if (null == client) { client = new AVIMClient(clientId); AVIMClient elderClient = clients.putIfAbsent(clientId, client); if (null != elderClient) { client = elderClient; } } return client; }
/** * Create a new temporary Conversation * * @param conversationMembers * @param ttl * @param callback */ public void createTemporaryConversation(final List<String> conversationMembers, int ttl, final AVIMConversationCreatedCallback callback) { this.createConversation(conversationMembers, null, null, false, true, true, ttl, callback); }
/** * get conversation by id and type * * @param conversationId * @param convType * @return */ public AVIMConversation getConversation(String conversationId, int convType) { AVIMConversation result = null; switch (convType) { case Conversation.CONV_TYPE_SYSTEM: result = getServiceConversation(conversationId); break; case Conversation.CONV_TYPE_TEMPORARY: result = getTemporaryConversation(conversationId); break; case Conversation.CONV_TYPE_TRANSIENT: result = getChatRoom(conversationId); break; default: result = getConversation(conversationId); break; } return result; }
public static AVIMClient getInstance(AVUser user, String tag) { AVIMClient client = getInstance(user); client.tag = tag; return client; }
/** * 增加查询条件,指定聊天室的组员条件满足条件的才返回 * * @param peerIds * @param includeSelf 是否包含自己 * @return */ public AVIMConversationsQuery withMembers(List<String> peerIds, boolean includeSelf) { Set<String> targetPeerIds = new HashSet<String>(peerIds); if (includeSelf) { targetPeerIds.add(client.getClientId()); } containsMembers(new LinkedList<String>(targetPeerIds)); this.whereSizeEqual(Conversation.MEMBERS, targetPeerIds.size()); return this; }
void queryConversationMemberInfo(final QueryConditions queryConditions, final AVIMConversationMemberQueryCallback cb) { if (null == queryConditions || null == cb) { return; } if (!realtimeSessionTokenExpired()) { queryConvMemberThroughNetwork(queryConditions, cb); } else { // refresh realtime session token. LOGGER.d("realtime session token expired, start to refresh..."); boolean ret = InternalConfiguration.getOperationTube().renewSessionToken(this.getClientId(), new AVIMClientCallback() { @Override public void done(AVIMClient client, AVIMException e) { if (null != e) { cb.internalDone(null, AVIMException.wrapperAVException(e)); } else { queryConvMemberThroughNetwork(queryConditions, cb); } } }); if (!ret) { cb.internalDone(null, new AVException(AVException.OPERATION_FORBIDDEN, "couldn't start service in background.")); } } }
void updateRealtimeSessionToken(String sessionToken, int expireInSec) { this.realtimeSessionToken = sessionToken; this.realtimeSessionTokenExpired = System.currentTimeMillis() + expireInSec * 1000; AVIMClient.getInstance(this.getSelfPeerId()).updateRealtimeSessionToken(sessionToken, this.realtimeSessionTokenExpired/1000); if (StringUtil.isEmpty(sessionToken)) { AVSessionCacheHelper.IMSessionTokenCache.removeIMSessionToken(getSelfPeerId()); } else { AVSessionCacheHelper.IMSessionTokenCache.addIMSessionToken(getSelfPeerId(), sessionToken, realtimeSessionTokenExpired); } }
/** * get default clientId. * @return */ public static String getDefaultClient() { if (getClientsCount() == 1) { return clients.keySet().iterator().next(); } return ""; }
protected static void processMessageReceipt(AVIMMessage message, AVIMClient client) { client.getStorage().updateMessage(message, message.getMessageId()); message = parseTypedMessage(message); final AVIMConversation conversation = client.getConversation(message.getConversationId()); retrieveAllMessageHandlers(message, conversation, true); }
/** * get an existed conversation * * @param conversationId * @param isTransient * @param isTemporary * @return */ public AVIMConversation getConversation(String conversationId, boolean isTransient, boolean isTemporary) { return this.getConversation(conversationId, isTransient, isTemporary,false); }
/** * Create a new temporary Conversation * * @param conversationMembers * @param callback */ public void createTemporaryConversation(final List<String> conversationMembers, final AVIMConversationCreatedCallback callback) { this.createTemporaryConversation(conversationMembers, 86400*3, callback); }
public static AVIMClientEventHandler getClientEventHandler() { return AVIMClient.getClientEventHandler(); }
@Override protected final void processEvent0(int operation, Object operator, Object operand, Object eventScene) { switch (operation) { case Conversation.STATUS_ON_CONNECTION_RESUMED: onConnectionResume((AVIMClient) eventScene); break; case Conversation.STATUS_ON_CONNECTION_PAUSED: onConnectionPaused((AVIMClient) eventScene); break; case Conversation.STATUS_ON_CLIENT_OFFLINE: onClientOffline((AVIMClient) eventScene, (Integer) operand); ((AVIMClient) eventScene).close(null); // TODO: FIXME break; default: LOGGER.d("Not supported operation:" + operand); } }
/** * get AVIMClient instance by clientId and tag. * @param clientId * @param tag * @return */ public static AVIMClient getInstance(String clientId, String tag) { AVIMClient client = getInstance(clientId); client.tag = tag; return client; }
public static void processMessage(AVIMMessage message, int convType, AVIMClient client, boolean hasMore, boolean isTransient) { message.setCurrentClient(client.getClientId()); AVIMMessageManager.processMessage(message, convType, client, hasMore, isTransient); }
public static MessagePatchModifiedPacket getPatchMessagePacket(String peerId, long lastPatchTime) { MessagePatchModifiedPacket messagePatchModifiedPacket = new MessagePatchModifiedPacket(); if (AVIMClient.getClientsCount() > 1) { // peerId is necessary only when more than 1 client logined. messagePatchModifiedPacket.setPeerId(peerId); } messagePatchModifiedPacket.lastPatchTime = lastPatchTime; return messagePatchModifiedPacket; }
protected static void processMessage(AVIMMessage message, int convType, AVIMClient client, boolean hasMore, boolean isTransient) { // 如果已经通过拉获得了消息,则推的消息不回调 if (client.getStorage().containMessage(message)) { return; } // hasMore 才设为 breakpoint // LogUtil.log.i("hasMore = " + hasMore);\ if (!isTransient && AVIMOptions.getGlobalOptions().isMessageQueryCacheEnabled()) { client.getStorage().insertMessage(message, hasMore); } message = parseTypedMessage(message); final AVIMConversation conversation = client.getConversation(message.getConversationId(), convType); conversation.setLastMessage(message); if (!isTransient) { conversation.increaseUnreadCount(1, message.mentioned()); } conversation.setLastMessageAt(new Date(message.getTimestamp())); retrieveAllMessageHandlers(message, conversation, false); }
/** * get an existed Chatroom by id * @param conversationId * @return */ public AVIMConversation getChatRoom(String conversationId) { return this.getConversation(conversationId, true, false); }
void onConversationDeliveredAtEvent(final long deliveredAt) { final AVIMConversationEventHandler handler = AVIMMessageManagerHelper.getConversationEventHandler(); if (handler != null) { AVIMClient client = AVIMClient.getInstance(session.getSelfPeerId()); final AVIMConversation conversation = client.getConversation(this.conversationId); refreshConversationThenNotify(conversation, new SimpleCallback() { @Override public void done() { handler.processEvent(Conversation.STATUS_ON_MESSAGE_DELIVERED, deliveredAt, null, conversation); } }); } } private String conversationGene = null;