use of de.pixart.messenger.xmpp.mam.MamReference in project Pix-Art-Messenger by kriztan.
the class MessageAdapter method loadMoreMessages.
private void loadMoreMessages(Conversation conversation) {
conversation.setLastClearHistory(0, null);
activity.xmppConnectionService.updateConversation(conversation);
conversation.setHasMessagesLeftOnServer(true);
conversation.setFirstMamReference(null);
long timestamp = conversation.getLastMessageTransmitted().getTimestamp();
if (timestamp == 0) {
timestamp = System.currentTimeMillis();
}
conversation.messagesLoaded.set(true);
MessageArchiveService.Query query = activity.xmppConnectionService.getMessageArchiveService().query(conversation, new MamReference(0), timestamp, false);
if (query != null) {
Toast.makeText(activity, R.string.fetching_history_from_server, Toast.LENGTH_LONG).show();
} else {
Toast.makeText(activity, R.string.not_fetching_history_retention_period, Toast.LENGTH_SHORT).show();
}
}
use of de.pixart.messenger.xmpp.mam.MamReference in project Pix-Art-Messenger by kriztan.
the class DatabaseBackend method getLastClearDate.
public MamReference getLastClearDate(Account account) {
SQLiteDatabase db = this.getReadableDatabase();
String[] columns = { Conversation.ATTRIBUTES };
String selection = Conversation.ACCOUNT + "=?";
String[] args = { account.getUuid() };
Cursor cursor = db.query(Conversation.TABLENAME, columns, selection, args, null, null, null);
MamReference maxClearDate = new MamReference(0);
while (cursor.moveToNext()) {
try {
final JSONObject o = new JSONObject(cursor.getString(0));
maxClearDate = MamReference.max(maxClearDate, MamReference.fromAttribute(o.getString(Conversation.ATTRIBUTE_LAST_CLEAR_HISTORY)));
} catch (Exception e) {
// ignored
}
}
cursor.close();
return maxClearDate;
}
Aggregations