# DialogsList
DialogsList is a component for displaying and management of a dialog list. The main features: fast and simple implementation, one-on-one and group dialog support, unread messages’ markers. Also there are several customization methods for changing appearance of dialog list and realization of additional features, which are not included by default.
## How to make it work
To start using the component, you just need to follow a few steps:
#### Add the widget into your xml layout:
```xml
```
#### Set an adapter
For `DialogsList` default realization you just need to transfer dialog list and dialog avatar image upload realization to adapter’s constructor ([Click here to know more about image loading](IMAGE_LOADER.md)).
```java
DialogsListAdapter dialogsListAdapter = new DialogsListAdapter<>(dialogs, new ImageLoader() {
@Override
public void loadImage(ImageView imageView, String url) {
//If you using another library - write here your way to load image
Picasso.with(DialogsListActivity.this).load(url).into(imageView);
}
});
dialogsListView.setAdapter(dialogsListAdapter);
```
#### Prepare your model
To be able to add dialog, you must implement the `IDialog` interface to your existing model and override its methods:
```java
public class DefaultDialog implements IDialog {
/*...*/
@Override
public String getId() {
return id;
}
@Override
public String getDialogPhoto() {
return dialogPhoto;
}
@Override
public String getDialogName() {
return dialogName;
}
@Override
public ArrayList getUsers() {
return users;
}
@Override
public IMessage getLastMessage() {
return lastMessage;
}
@Override
public void setLastMessage(IMessage lastMessage) {
this.lastMessage = lastMessage;
}
@Override
public int getUnreadCount() {
return unreadCount;
}
```
As you can see, you need also to implement the `IUser` interface for message author:
```java
public class Author implements IUser {
/*...*/
@Override
public String getId() {
return id;
}
@Override
public String getName() {
return name;
}
@Override
public String getAvatar() {
return avatar;
}
}
```
That's all! This approach allows the adapter to work with your dialog model without any converting of types!
## Data management
#### Setting and adding new dialogs
When your models are ready to be used by adapter, you can simply add them to the list. There is four ways to do this:
* adapter.setItems(List