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