mirror of
https://github.com/ChronosX88/Influence.git
synced 2024-11-09 20:11:01 +00:00
If the user has no avatar, then put the first (upper case) letter of his JID
This commit is contained in:
parent
548de95a5a
commit
77c97cf012
@ -55,12 +55,13 @@ public class DialogListPresenter implements CoreContracts.IDialogListPresenterCo
|
|||||||
private CoreContracts.IChatListViewContract view;
|
private CoreContracts.IChatListViewContract view;
|
||||||
private CoreContracts.IDialogListLogicContract logic;
|
private CoreContracts.IDialogListLogicContract logic;
|
||||||
private DialogsListAdapter<GenericDialog> dialogListAdapter = new DialogsListAdapter<>((imageView, url, payload) -> {
|
private DialogsListAdapter<GenericDialog> dialogListAdapter = new DialogsListAdapter<>((imageView, url, payload) -> {
|
||||||
|
String firstLetter = Character.toString(Character.toUpperCase(url.charAt(0)));
|
||||||
imageView.setImageDrawable(TextDrawable.builder()
|
imageView.setImageDrawable(TextDrawable.builder()
|
||||||
.beginConfig()
|
.beginConfig()
|
||||||
.width(32)
|
.width(32)
|
||||||
.height(32)
|
.height(32)
|
||||||
.endConfig()
|
.endConfig()
|
||||||
.buildRound(Character.toString(url.charAt(0)), ColorGenerator.MATERIAL.getColor(Character.toString(url.charAt(0)))));
|
.buildRound(firstLetter, ColorGenerator.MATERIAL.getColor(firstLetter)));
|
||||||
CompletableFuture.supplyAsync(() -> {
|
CompletableFuture.supplyAsync(() -> {
|
||||||
while (AppHelper.getXmppConnection() == null);
|
while (AppHelper.getXmppConnection() == null);
|
||||||
while (AppHelper.getXmppConnection().isConnectionAlive() != true);
|
while (AppHelper.getXmppConnection().isConnectionAlive() != true);
|
||||||
@ -150,12 +151,14 @@ public class DialogListPresenter implements CoreContracts.IDialogListPresenterCo
|
|||||||
@Override
|
@Override
|
||||||
public void loadRemoteContactList() {
|
public void loadRemoteContactList() {
|
||||||
CompletableFuture.supplyAsync(() -> logic.getRemoteContacts()).thenAccept((contacts) -> {
|
CompletableFuture.supplyAsync(() -> logic.getRemoteContacts()).thenAccept((contacts) -> {
|
||||||
|
AppHelper.getMainUIThread().post(() -> {
|
||||||
if(contacts != null) {
|
if(contacts != null) {
|
||||||
StreamSupport.stream(contacts).forEach(contact -> {
|
StreamSupport.stream(contacts).forEach(contact -> {
|
||||||
LocalDBWrapper.createChatEntry(contact.getJid().asUnescapedString(), contact.getName() == null ? contact.getJid().asUnescapedString() : contact.getName());
|
LocalDBWrapper.createChatEntry(contact.getJid().asUnescapedString(), contact.getName() == null ? contact.getJid().asUnescapedString().split("@")[0] : contact.getName());
|
||||||
dialogListAdapter.upsertItem(new GenericDialog(LocalDBWrapper.getChatByChatID(contact.getJid().asUnescapedString())));
|
dialogListAdapter.upsertItem(new GenericDialog(LocalDBWrapper.getChatByChatID(contact.getJid().asUnescapedString())));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,12 +97,13 @@ class ChatActivity : AppCompatActivity(), CoreContracts.IChatViewContract {
|
|||||||
chatAvatar!!.setImageBitmap(avatar)
|
chatAvatar!!.setImageBitmap(avatar)
|
||||||
} else {
|
} else {
|
||||||
val chatName = intent.getStringExtra("chatName")
|
val chatName = intent.getStringExtra("chatName")
|
||||||
|
val firstLetter = Character.toString(chatName[0].toUpperCase())
|
||||||
chatAvatar!!.setImageDrawable(TextDrawable.builder()
|
chatAvatar!!.setImageDrawable(TextDrawable.builder()
|
||||||
.beginConfig()
|
.beginConfig()
|
||||||
.width(32)
|
.width(32)
|
||||||
.height(32)
|
.height(32)
|
||||||
.endConfig()
|
.endConfig()
|
||||||
.buildRound(Character.toString(chatName[0]), ColorGenerator.MATERIAL.getColor(Character.toString(chatName[0]))))
|
.buildRound(firstLetter, ColorGenerator.MATERIAL.getColor(firstLetter)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user