Bug fixes

This commit is contained in:
DrKLO 2014-07-13 03:02:21 +04:00
parent f00aef78bd
commit 1122ab85d1
3 changed files with 50 additions and 45 deletions

View file

@ -1548,14 +1548,14 @@ public class MessagesController implements NotificationCenter.NotificationCenter
dialog.unread_count = 0;
NotificationCenter.getInstance().postNotificationName(dialogsNeedReload);
}
}
});
}
});
HashMap<Long, Integer> dialogsToUpdate = new HashMap<Long, Integer>();
dialogsToUpdate.put(dialog_id, 0);
NotificationsController.getInstance().processDialogsUpdateRead(dialogsToUpdate, true);
}
});
}
});
}
if (req.max_id != Integer.MAX_VALUE) {
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override
@ -1634,14 +1634,13 @@ public class MessagesController implements NotificationCenter.NotificationCenter
dialog.unread_count = 0;
NotificationCenter.getInstance().postNotificationName(dialogsNeedReload);
}
}
});
}
});
HashMap<Long, Integer> dialogsToUpdate = new HashMap<Long, Integer>();
dialogsToUpdate.put(dialog_id, 0);
NotificationsController.getInstance().processDialogsUpdateRead(dialogsToUpdate, true);
}
});
}
});
if (chat.ttl > 0 && was) {
int serverTime = Math.max(ConnectionsManager.getInstance().getCurrentTime(), max_date);
@ -2488,15 +2487,15 @@ public class MessagesController implements NotificationCenter.NotificationCenter
public void run(TLObject response, TLRPC.TL_error error) {
if (newMsgObj != null) {
if (error == null) {
TLRPC.messages_SentEncryptedMessage res = (TLRPC.messages_SentEncryptedMessage) response;
final TLRPC.messages_SentEncryptedMessage res = (TLRPC.messages_SentEncryptedMessage) response;
newMsgObj.messageOwner.date = res.date;
if (res.file instanceof TLRPC.TL_encryptedFile) {
processSentMessage(newMsgObj.messageOwner, null, res.file, req, originalPath);
}
MessagesStorage.getInstance().updateMessageStateAndId(newMsgObj.messageOwner.random_id, newMsgObj.messageOwner.id, newMsgObj.messageOwner.id, res.date, true);
MessagesStorage.getInstance().storageQueue.postRunnable(new Runnable() {
@Override
public void run() {
MessagesStorage.getInstance().updateMessageStateAndId(newMsgObj.messageOwner.random_id, newMsgObj.messageOwner.id, newMsgObj.messageOwner.id, res.date, false);
Utilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
@ -2528,7 +2527,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
public void run(TLObject response, TLRPC.TL_error error) {
if (error == null) {
final int oldId = newMsgObj.messageOwner.id;
ArrayList<TLRPC.Message> sentMessages = new ArrayList<TLRPC.Message>();
final ArrayList<TLRPC.Message> sentMessages = new ArrayList<TLRPC.Message>();
if (response instanceof TLRPC.TL_messages_sentMessage) {
TLRPC.TL_messages_sentMessage res = (TLRPC.TL_messages_sentMessage) response;
@ -2603,19 +2602,17 @@ public class MessagesController implements NotificationCenter.NotificationCenter
}
}
}
MessagesStorage.getInstance().updateMessageStateAndId(newMsgObj.messageOwner.random_id, oldId, newMsgObj.messageOwner.id, 0, true);
if (!sentMessages.isEmpty()) {
MessagesStorage.getInstance().putMessages(sentMessages, true, true);
}
MessagesStorage.getInstance().storageQueue.postRunnable(new Runnable() {
@Override
public void run() {
MessagesStorage.getInstance().updateMessageStateAndId(newMsgObj.messageOwner.random_id, oldId, newMsgObj.messageOwner.id, 0, false);
MessagesStorage.getInstance().putMessages(sentMessages, true, false);
Utilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
newMsgObj.messageOwner.send_state = MESSAGE_SEND_STATE_SENT;
NotificationCenter.getInstance().postNotificationName(messageReceivedByServer, oldId, newMsgObj.messageOwner.id, newMsgObj);
sendingMessages.remove(oldId); //TODO CHECK THIS!!!
sendingMessages.remove(oldId);
}
});
}

View file

@ -475,7 +475,7 @@ public class NotificationsController {
if (messageObjects.isEmpty()) {
return;
}
notifyCheck = isLast;
boolean added = false;
int oldCount = popupMessages.size();
HashMap<Long, Boolean> settingsCache = new HashMap<Long, Boolean>();
@ -487,9 +487,10 @@ public class NotificationsController {
continue;
}
long dialog_id = messageObject.getDialogId();
if (dialog_id == openned_dialog_id) {
if (dialog_id == openned_dialog_id && ApplicationLoader.isScreenOn) {
continue;
}
added = true;
Boolean value = settingsCache.get(dialog_id);
boolean isChat = (int)dialog_id < 0;
@ -508,6 +509,10 @@ public class NotificationsController {
}
}
if (added) {
notifyCheck = isLast;
}
if (!popupMessages.isEmpty() && oldCount != popupMessages.size()) {
if (ApplicationLoader.mainInterfacePaused || !ApplicationLoader.isScreenOn) {
MessageObject messageObject = messageObjects.get(0);

View file

@ -2860,12 +2860,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
@Override
public void didSelectDialog(MessagesActivity activity, long did, boolean param) {
if (dialog_id != 0 && (forwaringMessage != null || !selectedMessagesIds.isEmpty())) {
private void forwardSelectedMessages(long did, boolean fromMyName) {
if (forwaringMessage != null) {
if (forwaringMessage.messageOwner.id > 0) {
if (!param) {
if (!fromMyName) {
MessagesController.getInstance().sendMessage(forwaringMessage, did);
} else {
processForwardFromMe(forwaringMessage, did);
@ -2877,7 +2875,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
Collections.sort(ids);
for (Integer id : ids) {
if (id > 0) {
if (!param) {
if (!fromMyName) {
MessagesController.getInstance().sendMessage(selectedMessagesIds.get(id), did);
} else {
processForwardFromMe(selectedMessagesIds.get(id), did);
@ -2887,11 +2885,15 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
selectedMessagesCanCopyIds.clear();
selectedMessagesIds.clear();
}
}
@Override
public void didSelectDialog(MessagesActivity activity, long did, boolean param) {
if (dialog_id != 0 && (forwaringMessage != null || !selectedMessagesIds.isEmpty())) {
if (did != dialog_id) {
int lower_part = (int)did;
if (lower_part != 0) {
activity.removeSelfFromStack();
Bundle args = new Bundle();
args.putBoolean("scrollToTopOnResume", scrollToTopOnResume);
if (lower_part > 0) {
@ -2899,14 +2901,15 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} else if (lower_part < 0) {
args.putInt("chat_id", -lower_part);
}
presentFragment(new ChatActivity(args));
presentFragment(new ChatActivity(args), true);
removeSelfFromStack();
forwardSelectedMessages(did, param);
} else {
activity.finishFragment();
}
} else {
activity.finishFragment();
forwardSelectedMessages(did, param);
chatListView.setSelectionFromTop(messages.size() - 1, -100000 - chatListView.getPaddingTop());
scrollToTopOnResume = true;
}