mirror of
https://github.com/ChronosX88/Influence.git
synced 2024-11-09 12:01:01 +00:00
[FIXME] Removed adding users to user list in ChatEntity. Added toast when send message if network error
This commit is contained in:
parent
30eed3d65d
commit
ba86adbc78
@ -71,10 +71,7 @@ public class NetworkHandler implements IncomingChatMessageListener, PresenceEven
|
||||
public void newIncomingMessage(EntityBareJid from, Message message, Chat chat) {
|
||||
String chatID = chat.getXmppAddressOfChatPartner().asUnescapedString();
|
||||
if(LocalDBWrapper.getChatByChatID(from.asEntityBareJidString()) == null) {
|
||||
ArrayList<GenericUser> users = new ArrayList<>();
|
||||
users.add(new GenericUser(AppHelper.getJid(), AppHelper.getJid().split("@")[0], AppHelper.getJid()));
|
||||
users.add(new GenericUser(chat.getXmppAddressOfChatPartner().asBareJid().asUnescapedString(), chat.getXmppAddressOfChatPartner().asBareJid().asUnescapedString().split("@")[0], chat.getXmppAddressOfChatPartner().asBareJid().asUnescapedString()));
|
||||
LocalDBWrapper.createChatEntry(chatID, chat.getXmppAddressOfChatPartner().asBareJid().asUnescapedString().split("@")[0], users);
|
||||
LocalDBWrapper.createChatEntry(chatID, chat.getXmppAddressOfChatPartner().asBareJid().asUnescapedString().split("@")[0], new ArrayList<>());
|
||||
}
|
||||
long messageID = LocalDBWrapper.createMessageEntry(chatID, message.getStanzaId(), from.asUnescapedString(), TrueTime.now().getTime(), message.getBody(), true, false);
|
||||
int newUnreadMessagesCount = LocalDBWrapper.getChatByChatID(chatID).unreadMessagesCount + 1;
|
||||
|
@ -17,6 +17,7 @@
|
||||
package io.github.chronosx88.influence.presenters
|
||||
|
||||
import android.view.MenuItem
|
||||
import android.widget.Toast
|
||||
import com.google.gson.Gson
|
||||
import com.stfalcon.chatkit.messages.MessageHolders
|
||||
import com.stfalcon.chatkit.messages.MessagesListAdapter
|
||||
@ -56,7 +57,7 @@ class ChatPresenter(private val view: CoreContracts.IChatViewContract, private v
|
||||
val holdersConfig = MessageHolders()
|
||||
holdersConfig.setIncomingTextLayout(R.layout.item_incoming_text_message_custom)
|
||||
chatAdapter = MessagesListAdapter(AppHelper.getJid(), holdersConfig, AvatarImageLoader(view.getActivityObject()))
|
||||
chatAdapter.setLoadMoreListener { page, _ -> loadMoreMessages() }
|
||||
chatAdapter.setLoadMoreListener { _, _ -> loadMoreMessages() }
|
||||
view.setAdapter(chatAdapter)
|
||||
getUserStatus()
|
||||
EventBus.getDefault().register(this)
|
||||
@ -71,6 +72,7 @@ class ChatPresenter(private val view: CoreContracts.IChatViewContract, private v
|
||||
EventBus.getDefault().post(LastMessageEvent(chatEntity!!.jid, message))
|
||||
return true
|
||||
}
|
||||
Toast.makeText(view.getActivityObject(), "Network error!", Toast.LENGTH_SHORT).show()
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -148,10 +148,7 @@ public class DialogListPresenter implements CoreContracts.IDialogListPresenterCo
|
||||
if(contacts != null) {
|
||||
StreamSupport.stream(contacts).forEach(contact -> {
|
||||
String chatID = contact.getJid().asUnescapedString();
|
||||
ArrayList<GenericUser> users = new ArrayList<>();
|
||||
users.add(new GenericUser(AppHelper.getJid(), AppHelper.getJid().split("@")[0], AppHelper.getJid()));
|
||||
users.add(new GenericUser(chatID, contact.getName() == null ? contact.getJid().asUnescapedString().split("@")[0] : contact.getName(), chatID));
|
||||
LocalDBWrapper.createChatEntry(chatID, contact.getName() == null ? contact.getJid().asUnescapedString().split("@")[0] : contact.getName(), users);
|
||||
LocalDBWrapper.createChatEntry(chatID, contact.getName() == null ? contact.getJid().asUnescapedString().split("@")[0] : contact.getName(), new ArrayList<>());
|
||||
GenericDialog dialog = new GenericDialog(LocalDBWrapper.getChatByChatID(chatID));
|
||||
MessageEntity messageEntity = LocalDBWrapper.getLastMessage(chatID);
|
||||
if(messageEntity != null) {
|
||||
|
@ -48,10 +48,7 @@ class MainPresenter(private val view: CoreContracts.IMainViewContract) : CoreCon
|
||||
view.showSnackbar(AppHelper.getContext().getString(R.string.invalid_jid_error))
|
||||
return
|
||||
}
|
||||
val users = ArrayList<GenericUser>()
|
||||
users.add(GenericUser(AppHelper.getJid(), AppHelper.getJid().split("@")[0], AppHelper.getJid()))
|
||||
users.add(GenericUser(username, username.split("@")[0], AppHelper.getJid()))
|
||||
LocalDBWrapper.createChatEntry(username, username.split("@")[0], users)
|
||||
LocalDBWrapper.createChatEntry(username, username.split("@")[0], ArrayList<GenericUser>())
|
||||
EventBus.getDefault().post(NewChatEvent(username))
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user