From ae52e63e147cae0a724012a123ea82f40d1329fb Mon Sep 17 00:00:00 2001 From: ChronosX88 Date: Thu, 23 May 2019 17:05:05 +0400 Subject: [PATCH] Added letter icon in avatar if user has no avatar --- app/build.gradle | 1 + .../influence/presenters/DialogListPresenter.java | 9 ++++++++- build.gradle | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 160be19..9ba81d1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -65,6 +65,7 @@ dependencies { implementation 'net.sourceforge.streamsupport:streamsupport:1.7.0' implementation 'org.greenrobot:eventbus:3.1.1' implementation 'net.sourceforge.streamsupport:android-retrofuture:1.7.0' + implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1' } repositories { mavenCentral() diff --git a/app/src/main/java/io/github/chronosx88/influence/presenters/DialogListPresenter.java b/app/src/main/java/io/github/chronosx88/influence/presenters/DialogListPresenter.java index 83f4959..cdc1f48 100644 --- a/app/src/main/java/io/github/chronosx88/influence/presenters/DialogListPresenter.java +++ b/app/src/main/java/io/github/chronosx88/influence/presenters/DialogListPresenter.java @@ -23,6 +23,8 @@ import android.graphics.BitmapFactory; import androidx.appcompat.app.AlertDialog; +import com.amulyakhare.textdrawable.TextDrawable; +import com.amulyakhare.textdrawable.util.ColorGenerator; import com.stfalcon.chatkit.dialogs.DialogsListAdapter; import org.greenrobot.eventbus.EventBus; @@ -52,7 +54,12 @@ public class DialogListPresenter implements CoreContracts.IDialogListPresenterCo private CoreContracts.IChatListViewContract view; private CoreContracts.IDialogListLogicContract logic; private DialogsListAdapter dialogListAdapter = new DialogsListAdapter<>((imageView, url, payload) -> { - imageView.setImageResource(R.mipmap.ic_launcher); + imageView.setImageDrawable(TextDrawable.builder() + .beginConfig() + .width(32) + .height(32) + .endConfig() + .buildRound(Character.toString(url.charAt(0)), ColorGenerator.MATERIAL.getColor(Character.toString(url.charAt(0))))); CompletableFuture.supplyAsync(() -> { while (AppHelper.getXmppConnection() == null); while (AppHelper.getXmppConnection().isConnectionAlive() != true); diff --git a/build.gradle b/build.gradle index 543c3a2..0cb80ab 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { google() jcenter() maven { - url "http://tomp2p.net/dev/mvn/" + url 'http://dl.bintray.com/amulyakhare/maven' } } dependencies {