Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change dialog model #139

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package com.stfalcon.chatkit.commons.models;

import java.util.List;

/**
* For implementing by real dialog model
*/
Expand All @@ -30,7 +28,7 @@ public interface IDialog<MESSAGE extends IMessage> {

String getDialogName();

List<? extends IUser> getUsers();
int getUsersCount();

MESSAGE getLastMessage();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ public void onBind(final DIALOG dialog) {
imageLoader.loadImage(ivLastMessageUser, dialog.getLastMessage().getUser().getAvatar());
}
ivLastMessageUser.setVisibility(dialogStyle.isDialogMessageAvatarEnabled()
&& dialog.getUsers().size() > 1 ? VISIBLE : GONE);
&& dialog.getUsersCount() > 1 ? VISIBLE : GONE);

//Set Last message text
tvLastMessage.setText(dialog.getLastMessage().getText());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ private static Dialog getDialog(int i, Date lastMessageCreatedAt) {
getRandomId(),
users.size() > 1 ? groupChatTitles.get(users.size() - 2) : users.get(0).getName(),
users.size() > 1 ? groupChatImages.get(users.size() - 2) : getRandomAvatar(),
users,
getMessage(lastMessageCreatedAt),
i < 3 ? 3 - i : 0);
i < 3 ? 3 - i : 0,
users.size());
}

private static ArrayList<User> getUsers() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import com.stfalcon.chatkit.commons.models.IDialog;

import java.util.ArrayList;

/*
* Created by troy379 on 04.04.17.
*/
Expand All @@ -12,20 +10,18 @@ public class Dialog implements IDialog<Message> {
private String id;
private String dialogPhoto;
private String dialogName;
private ArrayList<User> users;
private Message lastMessage;
private int usersCount;

private int unreadCount;

public Dialog(String id, String name, String photo,
ArrayList<User> users, Message lastMessage, int unreadCount) {

public Dialog(String id, String name, String photo, Message lastMessage, int unreadCount, int usersCount) {
this.id = id;
this.dialogName = name;
this.dialogPhoto = photo;
this.users = users;
this.lastMessage = lastMessage;
this.unreadCount = unreadCount;
this.usersCount = usersCount;
}

@Override
Expand All @@ -44,8 +40,8 @@ public String getDialogName() {
}

@Override
public ArrayList<User> getUsers() {
return users;
public int getUsersCount() {
return usersCount;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ public CustomDialogViewHolder(View itemView) {
public void onBind(Dialog dialog) {
super.onBind(dialog);

if (dialog.getUsers().size() > 1) {
if (dialog.getUsersCount() > 1) {
onlineIndicator.setVisibility(View.GONE);
} else {
boolean isOnline = dialog.getUsers().get(0).isOnline();
boolean isOnline = dialog.getLastMessage().getUser().isOnline();
onlineIndicator.setVisibility(View.VISIBLE);
if (isOnline) {
onlineIndicator.setBackgroundResource(R.drawable.shape_bubble_online);
Expand Down